use of com.bluepowermod.block.machine.BlockAlloyWire in project BluePower by Qmunity.
the class TileWire method getCapability.
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
List<Direction> directions = new ArrayList<>(BlockBPCableBase.FACING.getPossibleValues());
if (level != null) {
BlockState state = getBlockState();
if (state.getBlock() instanceof BlockAlloyWire) {
// Remove upward connections
directions.remove(state.getValue(BlockAlloyWire.FACING));
// Make sure the cable is on the same side of the block
directions.removeIf(d -> level.getBlockState(worldPosition.relative(d)).getBlock() instanceof BlockAlloyWire && level.getBlockState(worldPosition.relative(d)).getValue(BlockAlloyWire.FACING) != state.getValue(BlockAlloyWire.FACING));
// Make sure the cable is the same color or none
// if(device.getInsulationColor(null) != MinecraftColor.NONE)
// directions.removeIf(d -> {
// TileEntity tile = world.getBlockEntity(worldPosition.relative(d));
// return tile instanceof TileWire
// && !(((TileWire) tile).device.getInsulationColor(d) == device.getInsulationColor(d.getOpposite())
// || ((TileWire) tile).device.getInsulationColor(d) == MinecraftColor.NONE);
// });
}
}
if (cap == CapabilityRedstoneDevice.UNINSULATED_CAPABILITY && (side == null || directions.contains(side))) {
if (redstoneCap == null)
redstoneCap = LazyOptional.of(() -> device);
return redstoneCap.cast();
}
return LazyOptional.empty();
}
Aggregations