mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-30 09:07:55 +00:00
Implement IPeripheral.getTarget on a few additional TEs
Also make it nullable. Hopefully this will allow us to distinguish between non-default implementations more easily.
This commit is contained in:
@@ -81,10 +81,10 @@ public interface IPeripheral
|
|||||||
*
|
*
|
||||||
* @return The object this peripheral targets
|
* @return The object this peripheral targets
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nullable
|
||||||
default Object getTarget()
|
default Object getTarget()
|
||||||
{
|
{
|
||||||
return this;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -72,6 +72,13 @@ public class CommandBlockPeripheral implements IPeripheral, ICapabilityProvider
|
|||||||
return other != null && other.getClass() == getClass();
|
return other != null && other.getClass() == getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Object getTarget()
|
||||||
|
{
|
||||||
|
return commandBlock;
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public <T> LazyOptional<T> getCapability( @Nonnull Capability<T> cap, @Nullable Direction side )
|
public <T> LazyOptional<T> getCapability( @Nonnull Capability<T> cap, @Nullable Direction side )
|
||||||
|
@@ -114,6 +114,13 @@ public class TileCable extends TileGeneric
|
|||||||
BlockPos pos = getPos().offset( modemDirection );
|
BlockPos pos = getPos().offset( modemDirection );
|
||||||
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Object getTarget()
|
||||||
|
{
|
||||||
|
return TileCable.this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
private LazyOptional<IPeripheral> modemCap;
|
private LazyOptional<IPeripheral> modemCap;
|
||||||
|
|
||||||
|
@@ -407,6 +407,13 @@ public class TileWiredModemFull extends TileGeneric
|
|||||||
BlockPos pos = getPos().offset( side );
|
BlockPos pos = getPos().offset( side );
|
||||||
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Object getTarget()
|
||||||
|
{
|
||||||
|
return TileWiredModemFull.this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -70,6 +70,13 @@ public class TileWirelessModem extends TileGeneric
|
|||||||
{
|
{
|
||||||
return this == other || (other instanceof Peripheral && entity == ((Peripheral) other).entity);
|
return this == other || (other instanceof Peripheral && entity == ((Peripheral) other).entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Object getTarget()
|
||||||
|
{
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean advanced;
|
private final boolean advanced;
|
||||||
|
@@ -14,6 +14,7 @@ import dan200.computercraft.core.apis.TermMethods;
|
|||||||
import dan200.computercraft.core.terminal.Terminal;
|
import dan200.computercraft.core.terminal.Terminal;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class MonitorPeripheral extends TermMethods implements IPeripheral
|
public class MonitorPeripheral extends TermMethods implements IPeripheral
|
||||||
{
|
{
|
||||||
@@ -85,4 +86,11 @@ public class MonitorPeripheral extends TermMethods implements IPeripheral
|
|||||||
{
|
{
|
||||||
return getMonitor().isColour();
|
return getMonitor().isColour();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Object getTarget()
|
||||||
|
{
|
||||||
|
return monitor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,4 +44,11 @@ public class CraftingTablePeripheral implements IPeripheral
|
|||||||
{
|
{
|
||||||
return other instanceof CraftingTablePeripheral;
|
return other instanceof CraftingTablePeripheral;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Object getTarget()
|
||||||
|
{
|
||||||
|
return turtle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user