use of mcjty.xnet.blocks.router.TileEntityRouter in project XNet by McJty.
the class ConnectorBlock method isConnectable.
public static boolean isConnectable(IBlockAccess world, BlockPos connectorPos, EnumFacing facing) {
BlockPos pos = connectorPos.offset(facing);
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block.isAir(state, world, pos)) {
return false;
}
ConnectorTileEntity connectorTE = (ConnectorTileEntity) world.getTileEntity(connectorPos);
if (connectorTE == null) {
return false;
}
if (!connectorTE.isEnabled(facing)) {
return false;
}
TileEntity te = world.getTileEntity(pos);
if (block instanceof IConnectable) {
IConnectable.ConnectResult result = ((IConnectable) block).canConnect(world, connectorPos, pos, te, facing);
if (result == IConnectable.ConnectResult.NO) {
return false;
} else if (result == IConnectable.ConnectResult.YES) {
return true;
}
}
for (IConnectable connectable : XNet.xNetApi.getConnectables()) {
IConnectable.ConnectResult result = connectable.canConnect(world, connectorPos, pos, te, facing);
if (result == IConnectable.ConnectResult.NO) {
return false;
} else if (result == IConnectable.ConnectResult.YES) {
return true;
}
}
if (block instanceof ConnectorBlock) {
return false;
}
if (block instanceof RedstoneProxyBlock || block == Blocks.REDSTONE_LAMP || block == Blocks.LIT_REDSTONE_LAMP || block == Blocks.PISTON || block == Blocks.STICKY_PISTON) {
return true;
}
if (block.canConnectRedstone(state, world, pos, null) || state.canProvidePower()) {
return true;
}
if (te == null) {
return false;
}
if (te instanceof IInventory) {
return true;
}
if (EnergyTools.isEnergyTE(te)) {
return true;
}
if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
return true;
}
if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) {
return true;
}
if (te instanceof TileEntityController) {
return true;
}
if (te instanceof TileEntityRouter) {
return true;
}
return false;
}
use of mcjty.xnet.blocks.router.TileEntityRouter in project XNet by McJty.
the class RouterIterator method findNext.
private void findNext() {
foundRouter = null;
while (facingIdx != -1) {
BlockPos routerPos = pos.offset(EnumFacing.VALUES[facingIdx]);
facingIdx++;
if (facingIdx >= EnumFacing.VALUES.length) {
facingIdx = -1;
}
TileEntity te = world.getTileEntity(routerPos);
if (te instanceof TileEntityRouter) {
foundRouter = (TileEntityRouter) te;
return;
}
}
}
use of mcjty.xnet.blocks.router.TileEntityRouter in project XNet by McJty.
the class RouterIterator method next.
@Override
public TileEntityRouter next() {
TileEntityRouter f = foundRouter;
findNext();
return f;
}
Aggregations