mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-12 23:37:29 +01:00
Refactored peripheralHandler to peripheral
- peripheralHandler was the wrong name. It's just a peripheral. - Changed peripheral type from "cdl" to "Create_DisplayLink" - Added equals function to DisplayLinkPeripheral
This commit is contained in:
parent
6591c2d46e
commit
47b8619d07
3 changed files with 14 additions and 14 deletions
|
@ -14,24 +14,24 @@ public interface ComputerControllable {
|
|||
|
||||
IPeripheral createPeripheral();
|
||||
|
||||
void setPeripheralHandler(LazyOptional<IPeripheral> peripheralHandler);
|
||||
void setPeripheral(LazyOptional<IPeripheral> peripheral);
|
||||
|
||||
LazyOptional<IPeripheral> getPeripheralHandler();
|
||||
LazyOptional<IPeripheral> getPeripheral();
|
||||
|
||||
default <T> LazyOptional<T> getPeripheralCapability(@NotNull Capability<T> cap) {
|
||||
if (cap == PERIPHERAL_CAPABILITY) {
|
||||
if (getPeripheralHandler() == null || !getPeripheralHandler().isPresent())
|
||||
setPeripheralHandler(LazyOptional.of(this::createPeripheral));
|
||||
if (getPeripheral() == null || !getPeripheral().isPresent())
|
||||
setPeripheral(LazyOptional.of(this::createPeripheral));
|
||||
|
||||
return getPeripheralHandler().cast();
|
||||
return getPeripheral().cast();
|
||||
}
|
||||
|
||||
return LazyOptional.empty();
|
||||
}
|
||||
|
||||
default void removePeripheral() {
|
||||
if (getPeripheralHandler() != null)
|
||||
getPeripheralHandler().invalidate();
|
||||
if (getPeripheral() != null)
|
||||
getPeripheral().invalidate();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -124,12 +124,12 @@ public class DisplayLinkPeripheral implements IPeripheral {
|
|||
@NotNull
|
||||
@Override
|
||||
public String getType() {
|
||||
return "cdl";
|
||||
return "Create_DisplayLink";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable IPeripheral other) {
|
||||
return false;
|
||||
return this == other;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class DisplayLinkTileEntity extends SmartTileEntity implements ComputerCo
|
|||
|
||||
public int refreshTicks;
|
||||
|
||||
private LazyOptional<IPeripheral> peripheralHandler;
|
||||
private LazyOptional<IPeripheral> peripheral;
|
||||
|
||||
public DisplayLinkTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
|
@ -203,13 +203,13 @@ public class DisplayLinkTileEntity extends SmartTileEntity implements ComputerCo
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setPeripheralHandler(LazyOptional<IPeripheral> peripheralHandler) {
|
||||
this.peripheralHandler = peripheralHandler;
|
||||
public void setPeripheral(LazyOptional<IPeripheral> peripheral) {
|
||||
this.peripheral = peripheral;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LazyOptional<IPeripheral> getPeripheralHandler() {
|
||||
return this.peripheralHandler;
|
||||
public LazyOptional<IPeripheral> getPeripheral() {
|
||||
return this.peripheral;
|
||||
}
|
||||
|
||||
public void target(BlockPos targetPosition) {
|
||||
|
|
Loading…
Reference in a new issue