protected RedNetConnectionType getConnectionState(ForgeDirection side, boolean decorative) { byte _mode = cableMode[side.ordinal()]; if (!decorative) _mode = 1; if (cableMode[6] == 1) _mode = 3; BlockPosition bp = new BlockPosition(this); bp.orientation = side; bp.moveForwards(1); int blockId = worldObj.getBlockId(bp.x, bp.y, bp.z); Block b = Block.blocksList[blockId]; if (b == null) // block doesn't exist (air) - never connect { return RedNetConnectionType.None; } else if (blockId == MineFactoryReloadedCore.rednetCableBlock.blockID) // cables - always connect { return RedNetConnectionType.CableAll; } else if (_mode == 3) // cable-only, and not a cable - don't connect { return RedNetConnectionType.None; } else if (b instanceof IConnectableRedNet) // API node - let them figure it out { RedNetConnectionType type = ((IConnectableRedNet) b) .getConnectionType(worldObj, bp.x, bp.y, bp.z, side.getOpposite()); return type.isConnectionForced & !(_mode == 1 | _mode == 2) ? RedNetConnectionType.None : type; } else if (b instanceof IRedNetNoConnection || b.isAirBlock(worldObj, bp.x, bp.y, bp.z)) { return RedNetConnectionType.None; } else if (_mode == 2 && b.isBlockSolidOnSide(worldObj, bp.x, bp.y, bp.z, side.getOpposite())) { return RedNetConnectionType.ForcedCableSingle; } else if (_mode == 1) // mode 1 forces plate mode for weak power { return RedNetConnectionType.ForcedPlateSingle; } else if ((blockId <= _maxVanillaBlockId && !_connectionWhitelist.contains(blockId)) || _connectionBlackList.contains(blockId) || b instanceof IRedNetDecorative) // standard connection logic, then figure out if we shouldn't connect // mode 1 will skip this { return RedNetConnectionType.None; } else if (b.isBlockSolidOnSide(worldObj, bp.x, bp.y, bp.z, side.getOpposite())) { return RedNetConnectionType.CableSingle; } else { return RedNetConnectionType.PlateSingle; } }
@Override protected boolean activateMachine() { List<?> entities = worldObj.getEntitiesWithinAABB( EntityAgeable.class, _areaManager.getHarvestArea().toAxisAlignedBB()); for (Object o : entities) { if (!(o instanceof EntityAgeable)) { continue; } EntityAgeable a = (EntityAgeable) o; if ((a.getGrowingAge() < 0 && !_moveOld) || (a.getGrowingAge() >= 0 && _moveOld)) { BlockPosition bp = BlockPosition.fromFactoryTile(this); bp.moveBackwards(1); a.setPosition(bp.x + 0.5, bp.y + 0.5, bp.z + 0.5); return true; } } setIdleTicks(getIdleTicksMax()); return false; }
private void updateNetwork() { if (worldObj.isRemote) { return; } BlockPosition ourbp = new BlockPosition(this); RedstoneNetwork.log("Cable at %s updating network", ourbp.toString()); if (_network == null) { for (BlockPosition bp : ourbp.getAdjacent(true)) { TileEntity te = bp.getTileEntity(worldObj); if (te instanceof TileEntityRedNetCable) { TileEntityRedNetCable cable = ((TileEntityRedNetCable) te); if (cable.getNetwork() != null && !cable.getNetwork().isInvalid()) { _network = cable.getNetwork(); break; } } } } if (_network == null) { RedstoneNetwork.log("Initializing new network at %s", ourbp.toString()); setNetwork(new RedstoneNetwork(worldObj)); } for (BlockPosition bp : ourbp.getAdjacent(true)) { TileEntity te = bp.getTileEntity(worldObj); if (te instanceof TileEntityRedNetCable) { TileEntityRedNetCable cable = ((TileEntityRedNetCable) te); if (cable.getNetwork() == null) { cable.setNetwork(_network); } else if (cable.getNetwork() != _network && cable.getNetwork() != null && !cable.getNetwork().isInvalid()) { _network.mergeNetwork(cable.getNetwork()); } } else { updateNearbyNode(bp); } } }