mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-02-14 10:00:06 +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:
parent
5409d441b5
commit
4f8217d1ab
@ -81,10 +81,10 @@ public interface IPeripheral
|
||||
*
|
||||
* @return The object this peripheral targets
|
||||
*/
|
||||
@Nonnull
|
||||
@Nullable
|
||||
default Object getTarget()
|
||||
{
|
||||
return this;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,6 +72,13 @@ public class CommandBlockPeripheral implements IPeripheral, ICapabilityProvider
|
||||
return other != null && other.getClass() == getClass();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Object getTarget()
|
||||
{
|
||||
return commandBlock;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
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 );
|
||||
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;
|
||||
|
||||
|
@ -407,6 +407,13 @@ public class TileWiredModemFull extends TileGeneric
|
||||
BlockPos pos = getPos().offset( side );
|
||||
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);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Object getTarget()
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean advanced;
|
||||
|
@ -14,6 +14,7 @@ import dan200.computercraft.core.apis.TermMethods;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class MonitorPeripheral extends TermMethods implements IPeripheral
|
||||
{
|
||||
@ -85,4 +86,11 @@ public class MonitorPeripheral extends TermMethods implements IPeripheral
|
||||
{
|
||||
return getMonitor().isColour();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getTarget()
|
||||
{
|
||||
return monitor;
|
||||
}
|
||||
}
|
||||
|
@ -44,4 +44,11 @@ public class CraftingTablePeripheral implements IPeripheral
|
||||
{
|
||||
return other instanceof CraftingTablePeripheral;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Object getTarget()
|
||||
{
|
||||
return turtle;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user