use of powercrystals.minefactoryreloaded.api.rednet.RedNetConnectionType in project MineFactoryReloaded by powercrystals.
the class BlockRedNetCable method getParts.
private AxisAlignedBB[] getParts(TileEntityRedNetCable cable) {
RedNetConnectionType csu = cable.getConnectionState(ForgeDirection.UP);
RedNetConnectionType csd = cable.getConnectionState(ForgeDirection.DOWN);
RedNetConnectionType csn = cable.getConnectionState(ForgeDirection.NORTH);
RedNetConnectionType css = cable.getConnectionState(ForgeDirection.SOUTH);
RedNetConnectionType csw = cable.getConnectionState(ForgeDirection.WEST);
RedNetConnectionType cse = cable.getConnectionState(ForgeDirection.EAST);
AxisAlignedBB[] parts = new AxisAlignedBB[15];
parts[0] = AxisAlignedBB.getBoundingBox(csw != RedNetConnectionType.None ? 0 : _wireStart, _wireStart, _wireStart, cse != RedNetConnectionType.None ? 1 : _wireEnd, _wireEnd, _wireEnd);
parts[1] = AxisAlignedBB.getBoundingBox(_wireStart, csd != RedNetConnectionType.None ? 0 : _wireStart, _wireStart, _wireEnd, csu != RedNetConnectionType.None ? 1 : _wireEnd, _wireEnd);
parts[2] = AxisAlignedBB.getBoundingBox(_wireStart, _wireStart, csn != RedNetConnectionType.None ? 0 : _wireStart, _wireEnd, _wireEnd, css != RedNetConnectionType.None ? 1 : _wireEnd);
parts[3] = csw != RedNetConnectionType.PlateSingle && csw != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(0, _plateStart, _plateStart, _plateDepth, _plateEnd, _plateEnd);
parts[4] = cse != RedNetConnectionType.PlateSingle && cse != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(1.0F - _plateDepth, _plateStart, _plateStart, 1.0F, _plateEnd, _plateEnd);
parts[5] = csd != RedNetConnectionType.PlateSingle && csd != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(_plateStart, 0, _plateStart, _plateEnd, _plateDepth, _plateEnd);
parts[6] = csu != RedNetConnectionType.PlateSingle && csu != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(_plateStart, 1.0F - _plateDepth, _plateStart, _plateEnd, 1.0F, _plateEnd);
parts[7] = csn != RedNetConnectionType.PlateSingle && csn != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(_plateStart, _plateStart, 0, _plateEnd, _plateEnd, _plateDepth);
parts[8] = css != RedNetConnectionType.PlateSingle && css != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(_plateStart, _plateStart, 1.0F - _plateDepth, _plateEnd, _plateEnd, 1.0F);
parts[9] = csw != RedNetConnectionType.PlateSingle && csw != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(_bandDepthStart, _bandWidthStart, _bandWidthStart, _bandDepthEnd, _bandWidthEnd, _bandWidthEnd);
parts[10] = cse != RedNetConnectionType.PlateSingle && cse != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(1.0F - _bandDepthEnd, _bandWidthStart, _bandWidthStart, 1.0F - _bandDepthStart, _bandWidthEnd, _bandWidthEnd);
parts[11] = csd != RedNetConnectionType.PlateSingle && csd != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(_bandWidthStart, _bandDepthStart, _bandWidthStart, _bandWidthEnd, _bandDepthEnd, _bandWidthEnd);
parts[12] = csu != RedNetConnectionType.PlateSingle && csu != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(_bandWidthStart, 1.0F - _bandDepthEnd, _bandWidthStart, _bandWidthEnd, 1.0F - _bandDepthStart, _bandWidthEnd);
parts[13] = csn != RedNetConnectionType.PlateSingle && csn != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(_bandWidthStart, _bandWidthStart, _bandDepthStart, _bandWidthEnd, _bandWidthEnd, _bandDepthEnd);
parts[14] = css != RedNetConnectionType.PlateSingle && css != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(_bandWidthStart, _bandWidthStart, 1.0F - _bandDepthEnd, _bandWidthEnd, _bandWidthEnd, 1.0F - _bandDepthStart);
return parts;
}
use of powercrystals.minefactoryreloaded.api.rednet.RedNetConnectionType in project MineFactoryReloaded by powercrystals.
the class TileEntityRedNetCable method updateNetwork.
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 {
int subnet = getSideColor(bp.orientation);
RedNetConnectionType connectionType = getConnectionState(bp.orientation);
if (!worldObj.isAirBlock(bp.x, bp.y, bp.z)) {
if (connectionType == RedNetConnectionType.CableSingle) {
_network.addOrUpdateNode(bp, subnet, false);
} else if (connectionType == RedNetConnectionType.PlateSingle) {
_network.addOrUpdateNode(bp, subnet, true);
} else if (connectionType == RedNetConnectionType.CableAll || connectionType == RedNetConnectionType.PlateAll) {
_network.addOrUpdateNode(bp);
} else {
_network.removeNode(bp);
}
} else {
_network.removeNode(bp);
}
}
}
}
Aggregations