mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 21:20:06 +00:00
Merge branch 'master' of github.com:mDiyo/TinkersConstruct
This commit is contained in:
commit
593fa44dde
7 files changed
+242
-138
No files matched your search
@@ -62,7 +62,7 @@ public class SignalBus extends Block implements ITileEntityProvider {
|
||||
public static double cable_corner_min = cable_high_offset - 1;
|
||||
public static double cable_corner_max = cable_low_height + 1;
|
||||
|
||||
public static double zfight = 0.0000001D;
|
||||
public static double zfight = 0.00001D;
|
||||
}
|
||||
|
||||
public static int HITBOXES = 6;
|
||||
@@ -524,7 +524,7 @@ public class SignalBus extends Block implements ITileEntityProvider {
|
||||
{
|
||||
super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
|
||||
|
||||
if (par5 == this.blockID)
|
||||
if (par5 == this.blockID || par1World.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import tconstruct.library.util.CoordTuple;
|
||||
public class SignalBusMasterLogic extends MultiblockMasterBaseLogic
|
||||
{
|
||||
private boolean forceUpdate = false;
|
||||
private boolean forceSouthboundUpdates = false;
|
||||
private boolean signalUpdate = false;
|
||||
private byte[] masterSignals = new byte[16];
|
||||
private CoordTuple[] signalProviderCoords = new CoordTuple[16];
|
||||
@@ -56,7 +57,7 @@ public class SignalBusMasterLogic extends MultiblockMasterBaseLogic
|
||||
calcSignals(signals);
|
||||
}
|
||||
|
||||
if (!Arrays.equals(oldSignals, masterSignals))
|
||||
if (forceSouthboundUpdates || !Arrays.equals(oldSignals, masterSignals))
|
||||
{
|
||||
// Send updates to SignalBuses
|
||||
for (CoordTuple coord : tetheredBuses.keySet())
|
||||
@@ -120,11 +121,15 @@ public class SignalBusMasterLogic extends MultiblockMasterBaseLogic
|
||||
|
||||
((SignalBusMasterLogic) newMaster).calcSignals(masterSignals);
|
||||
|
||||
if (!Arrays.equals(oldSignals, ((SignalBusMasterLogic) newMaster).getSignals()))
|
||||
{
|
||||
((SignalBusMasterLogic) newMaster).forceUpdate();
|
||||
}
|
||||
((SignalBusMasterLogic) newMaster).forceUpdate();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endMerging ()
|
||||
{
|
||||
forceSouthboundUpdates = true;
|
||||
}
|
||||
|
||||
protected void calcSignals (byte[] signals)
|
||||
|
||||
@@ -43,6 +43,7 @@ public class SignalBusLogic extends MultiblockBaseLogic implements IActiveLogic,
|
||||
private Map<CoordTuple, byte[]> transceivers = new HashMap<CoordTuple, byte[]>();
|
||||
private byte[] localHighSignals = new byte[16];
|
||||
private byte[] cachedReceivedSignals = new byte[16];
|
||||
private int cachedConnectableCount = 0;
|
||||
|
||||
private boolean southboundSignalsChanged = false;
|
||||
private boolean northboundSignalsChanged = false;
|
||||
@@ -92,7 +93,7 @@ public class SignalBusLogic extends MultiblockBaseLogic implements IActiveLogic,
|
||||
tY += ForgeDirection.VALID_DIRECTIONS[i].offsetY;
|
||||
tZ += ForgeDirection.VALID_DIRECTIONS[i].offsetZ;
|
||||
te = worldObj.getBlockTileEntity(tX, tY, tZ);
|
||||
if (te instanceof IMultiblockMember && ((IMultiblockMember) te).isCompatible((Object) this))
|
||||
if (te instanceof IMultiblockMember && ((IMultiblockMember) te).isCompatible((Object) this) && ((IMultiblockMember) te).willConnect(getCoordInWorld()))
|
||||
{
|
||||
corners.add((IMultiblockMember) te);
|
||||
}
|
||||
@@ -146,9 +147,14 @@ public class SignalBusLogic extends MultiblockBaseLogic implements IActiveLogic,
|
||||
|
||||
if (forceCheck)
|
||||
{
|
||||
int connectableCount = this.getNeighboringMembers().length;
|
||||
forceCheck = false;
|
||||
super.onBlockAdded(worldObj, xCoord, yCoord, zCoord);
|
||||
this.getMultiblockMaster().revisitBlocks();
|
||||
if (connectableCount != cachedConnectableCount)
|
||||
{
|
||||
cachedConnectableCount = connectableCount;
|
||||
super.onBlockAdded(worldObj, xCoord, yCoord, zCoord);
|
||||
// this.getMultiblockMaster().revisitBlocks();
|
||||
}
|
||||
}
|
||||
|
||||
if (northboundSignalsChanged)
|
||||
@@ -504,7 +510,10 @@ public class SignalBusLogic extends MultiblockBaseLogic implements IActiveLogic,
|
||||
public void addPlacedSide (int side)
|
||||
{
|
||||
placedSides[side] = true;
|
||||
forceCheck = true;
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
forceCheck = true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean[] getRenderCorners (ForgeDirection fromFace)
|
||||
@@ -568,7 +577,7 @@ public class SignalBusLogic extends MultiblockBaseLogic implements IActiveLogic,
|
||||
|
||||
for (j = 0; j < 6; ++j)
|
||||
{
|
||||
if (placedSides[j] || j == i || j == i || j == iDir.getOpposite().ordinal())
|
||||
if (placedSides[j] || j == i || j == iDir.getOpposite().ordinal())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -585,7 +594,7 @@ public class SignalBusLogic extends MultiblockBaseLogic implements IActiveLogic,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (xCoord + iDir.offsetX + jDir.offsetX == coord.x && yCoord + iDir.offsetY + jDir.offsetY == coord.y && xCoord + iDir.offsetZ + jDir.offsetZ == coord.z)
|
||||
if (xCoord + iDir.offsetX + jDir.offsetX == coord.x && yCoord + iDir.offsetY + jDir.offsetY == coord.y && zCoord + iDir.offsetZ + jDir.offsetZ == coord.z)
|
||||
{
|
||||
te = worldObj.getBlockTileEntity(xCoord + iDir.offsetX + jDir.offsetX, yCoord + iDir.offsetY + jDir.offsetY, zCoord + iDir.offsetZ + jDir.offsetZ);
|
||||
if (te instanceof ISignalBusConnectable && ((ISignalBusConnectable)te).connectableOnCorner(iDir.getOpposite(), jDir.getOpposite()))
|
||||
@@ -625,7 +634,7 @@ public class SignalBusLogic extends MultiblockBaseLogic implements IActiveLogic,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
coord = new CoordTuple(xCoord + iDir.offsetX + jDir.offsetX, yCoord + iDir.offsetY + jDir.offsetY, zCoord + iDir.offsetZ + jDir.offsetZ);
|
||||
cornerCoords.add(new CoordTuple(xCoord + iDir.offsetX + jDir.offsetX, yCoord + iDir.offsetY + jDir.offsetY, zCoord + iDir.offsetZ + jDir.offsetZ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,6 +689,22 @@ public class SignalBusLogic extends MultiblockBaseLogic implements IActiveLogic,
|
||||
((ISignalTransceiver) te).doUnregister(true);
|
||||
}
|
||||
}
|
||||
this.detachSelf(false);
|
||||
this.destroySelf();
|
||||
}
|
||||
|
||||
public boolean canPlaceOnSide (int side)
|
||||
{
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
if (i == side || i == ForgeDirection.OPPOSITES[side])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (placedSides[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -18,19 +18,6 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
// public static double cable_width_min = 0.375D;
|
||||
// public static double cable_width_max = 1 - cable_width_min;
|
||||
// public static double cable_low_height = 0.2D;
|
||||
// public static double cable_low_offset = 0.0D;
|
||||
//
|
||||
// public static double cable_high_height = 1.0D;
|
||||
// public static double cable_high_offset = 1 - cable_low_height;
|
||||
//
|
||||
// public static double cable_extend_min = 0.0D;
|
||||
// public static double cable_extend_max = 1.0D;
|
||||
//
|
||||
// public static double zfight = 0.0000001D;
|
||||
//
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
@@ -93,7 +80,6 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
double maxX = 1D;
|
||||
double maxY = 1D;
|
||||
double maxZ = 1D;
|
||||
int renderCount = 0;
|
||||
|
||||
boolean[] renderDir = {
|
||||
(connectedSides[0] || placed[0] || corners[0]),
|
||||
@@ -122,9 +108,11 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
minX = (corners[ForgeDirection.WEST.ordinal()]) ? Geometry.cable_corner_min : minX;
|
||||
maxX = (corners[ForgeDirection.EAST.ordinal()]) ? Geometry.cable_corner_max : maxX;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, Geometry.cable_width_min, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(Geometry.cable_width_max, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
// Render North/South
|
||||
if (renderDir[ForgeDirection.NORTH.ordinal()] || renderDir[ForgeDirection.SOUTH.ordinal()])
|
||||
@@ -139,22 +127,23 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
minZ = (corners[ForgeDirection.NORTH.ordinal()]) ? Geometry.cable_corner_min : minZ;
|
||||
maxZ = (corners[ForgeDirection.SOUTH.ordinal()]) ? Geometry.cable_corner_max : maxZ;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, Geometry.cable_width_min);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
if (renderCount == 0)
|
||||
{
|
||||
minX = Geometry.cable_width_min;
|
||||
minY = Geometry.cable_low_offset;
|
||||
minZ = Geometry.cable_width_min;
|
||||
maxX = Geometry.cable_width_max;
|
||||
maxY = Geometry.cable_low_height;
|
||||
maxZ = Geometry.cable_width_max;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, Geometry.cable_width_max, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
minX = Geometry.cable_width_min;
|
||||
minY = Geometry.cable_low_offset;
|
||||
minZ = Geometry.cable_width_min;
|
||||
maxX = Geometry.cable_width_max;
|
||||
maxY = Geometry.cable_low_height;
|
||||
maxZ = Geometry.cable_width_max;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
break;
|
||||
case 1: // UP
|
||||
// Render East/West
|
||||
@@ -172,9 +161,11 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
minX = (corners[ForgeDirection.WEST.ordinal()]) ? Geometry.cable_corner_min : minX;
|
||||
maxX = (corners[ForgeDirection.EAST.ordinal()]) ? Geometry.cable_corner_max : maxX;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, Geometry.cable_width_min, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(Geometry.cable_width_max, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
// Render North/South
|
||||
if (renderDir[ForgeDirection.NORTH.ordinal()] || renderDir[ForgeDirection.SOUTH.ordinal()])
|
||||
@@ -189,22 +180,23 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
minZ = (corners[ForgeDirection.NORTH.ordinal()]) ? Geometry.cable_corner_min : minZ;
|
||||
maxZ = (corners[ForgeDirection.SOUTH.ordinal()]) ? Geometry.cable_corner_max : maxZ;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, Geometry.cable_width_min);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
if (renderCount == 0)
|
||||
{
|
||||
minX = Geometry.cable_width_min;
|
||||
minY = Geometry.cable_high_offset;
|
||||
minZ = Geometry.cable_width_min;
|
||||
maxX = Geometry.cable_width_max;
|
||||
maxY = Geometry.cable_high_height;
|
||||
maxZ = Geometry.cable_width_max;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, Geometry.cable_width_max, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
minX = Geometry.cable_width_min;
|
||||
minY = Geometry.cable_high_offset;
|
||||
minZ = Geometry.cable_width_min;
|
||||
maxX = Geometry.cable_width_max;
|
||||
maxY = Geometry.cable_high_height;
|
||||
maxZ = Geometry.cable_width_max;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
break;
|
||||
case 2: // NORTH
|
||||
// Render East/West
|
||||
@@ -217,14 +209,14 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_low_height;
|
||||
|
||||
maxZ += Geometry.zfight;
|
||||
|
||||
minX = (corners[ForgeDirection.WEST.ordinal()]) ? Geometry.cable_corner_min : minX;
|
||||
maxX = (corners[ForgeDirection.EAST.ordinal()]) ? Geometry.cable_corner_max : maxX;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, Geometry.cable_width_min, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(Geometry.cable_width_max, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
// Render Up/Down
|
||||
if (renderDir[ForgeDirection.DOWN.ordinal()] || renderDir[ForgeDirection.UP.ordinal()])
|
||||
@@ -236,25 +228,26 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
maxY = (renderDir[ForgeDirection.UP.ordinal()]) ? Geometry.cable_extend_max : Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_low_height;
|
||||
|
||||
minY = (corners[ForgeDirection.DOWN.ordinal()]) ? Geometry.cable_corner_min : minY;
|
||||
maxY = (corners[ForgeDirection.UP.ordinal()]) ? Geometry.cable_corner_max : maxY;
|
||||
minY += (placed[ForgeDirection.DOWN.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
maxY -= (placed[ForgeDirection.UP.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, Geometry.cable_width_max, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
if (renderCount == 0)
|
||||
{
|
||||
minX = Geometry.cable_width_min;
|
||||
minY = Geometry.cable_width_min;
|
||||
minZ = Geometry.cable_low_offset;
|
||||
maxX = Geometry.cable_width_max;
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_low_height;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, Geometry.cable_width_min, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
minX = Geometry.cable_width_min;
|
||||
minY = Geometry.cable_width_min;
|
||||
minZ = Geometry.cable_low_offset;
|
||||
maxX = Geometry.cable_width_max;
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_low_height;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
break;
|
||||
case 3: // SOUTH
|
||||
// Render East/West
|
||||
@@ -267,14 +260,14 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_high_height;
|
||||
|
||||
minZ -= Geometry.zfight;
|
||||
|
||||
minX = (corners[ForgeDirection.WEST.ordinal()]) ? Geometry.cable_corner_min : minX;
|
||||
maxX = (corners[ForgeDirection.EAST.ordinal()]) ? Geometry.cable_corner_max : maxX;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, Geometry.cable_width_min, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(Geometry.cable_width_max, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
// Render Up/Down
|
||||
if (renderDir[ForgeDirection.DOWN.ordinal()] || renderDir[ForgeDirection.UP.ordinal()])
|
||||
@@ -286,25 +279,26 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
maxY = (renderDir[ForgeDirection.UP.ordinal()]) ? Geometry.cable_extend_max : Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_high_height;
|
||||
|
||||
minY = (corners[ForgeDirection.DOWN.ordinal()]) ? Geometry.cable_corner_min : minY;
|
||||
maxY = (corners[ForgeDirection.UP.ordinal()]) ? Geometry.cable_corner_max : maxY;
|
||||
minY += (placed[ForgeDirection.DOWN.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
maxY -= (placed[ForgeDirection.UP.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, Geometry.cable_width_max, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
if (renderCount == 0)
|
||||
{
|
||||
minX = Geometry.cable_width_min;
|
||||
minY = Geometry.cable_width_min;
|
||||
minZ = Geometry.cable_high_offset;
|
||||
maxX = Geometry.cable_width_max;
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_high_height;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, Geometry.cable_width_min, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
minX = Geometry.cable_width_min;
|
||||
minY = Geometry.cable_width_min;
|
||||
minZ = Geometry.cable_high_offset;
|
||||
maxX = Geometry.cable_width_max;
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_high_height;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
break;
|
||||
case 4: // WEST
|
||||
// Render North/South
|
||||
@@ -317,14 +311,14 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = (renderDir[ForgeDirection.SOUTH.ordinal()]) ? Geometry.cable_extend_max : Geometry.cable_width_max;
|
||||
|
||||
maxX += Geometry.zfight;
|
||||
minZ += (placed[ForgeDirection.NORTH.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
maxZ -= (placed[ForgeDirection.SOUTH.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
|
||||
minZ = (corners[ForgeDirection.NORTH.ordinal()]) ? Geometry.cable_corner_min : minZ;
|
||||
maxZ = (corners[ForgeDirection.SOUTH.ordinal()]) ? Geometry.cable_corner_max : maxZ;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, Geometry.cable_width_min);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(minX, minY, Geometry.cable_width_max, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
// Render Up/Down
|
||||
if (renderDir[ForgeDirection.DOWN.ordinal()] || renderDir[ForgeDirection.UP.ordinal()])
|
||||
@@ -336,25 +330,26 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
maxY = (renderDir[ForgeDirection.UP.ordinal()]) ? Geometry.cable_extend_max : Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_width_max;
|
||||
|
||||
minY = (corners[ForgeDirection.DOWN.ordinal()]) ? Geometry.cable_corner_min : minY;
|
||||
maxY = (corners[ForgeDirection.UP.ordinal()]) ? Geometry.cable_corner_max : maxY;
|
||||
minY += (placed[ForgeDirection.DOWN.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
maxY -= (placed[ForgeDirection.UP.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, Geometry.cable_width_max, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
if (renderCount == 0)
|
||||
{
|
||||
minX = Geometry.cable_low_offset;
|
||||
minY = Geometry.cable_width_min;
|
||||
minZ = Geometry.cable_width_min;
|
||||
maxX = Geometry.cable_low_height;
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_width_max;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, Geometry.cable_width_min, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
minX = Geometry.cable_low_offset;
|
||||
minY = Geometry.cable_width_min;
|
||||
minZ = Geometry.cable_width_min;
|
||||
maxX = Geometry.cable_low_height;
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_width_max;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
break;
|
||||
case 5: // EAST
|
||||
// Render North/South
|
||||
@@ -367,14 +362,14 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = (renderDir[ForgeDirection.SOUTH.ordinal()]) ? Geometry.cable_extend_max : Geometry.cable_width_max;
|
||||
|
||||
minX -= Geometry.zfight;
|
||||
minZ += (placed[ForgeDirection.NORTH.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
maxZ -= (placed[ForgeDirection.SOUTH.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
|
||||
minZ = (corners[ForgeDirection.NORTH.ordinal()]) ? Geometry.cable_corner_min : minZ;
|
||||
maxZ = (corners[ForgeDirection.SOUTH.ordinal()]) ? Geometry.cable_corner_max : maxZ;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, Geometry.cable_width_min);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(minX, minY, Geometry.cable_width_max, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
// Render Up/Down
|
||||
if (renderDir[ForgeDirection.DOWN.ordinal()] || renderDir[ForgeDirection.UP.ordinal()])
|
||||
@@ -386,25 +381,26 @@ public class SignalBusRender implements ISimpleBlockRenderingHandler
|
||||
maxY = (renderDir[ForgeDirection.UP.ordinal()]) ? Geometry.cable_extend_max : Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_width_max;
|
||||
|
||||
minY = (corners[ForgeDirection.DOWN.ordinal()]) ? Geometry.cable_corner_min : minY;
|
||||
maxY = (corners[ForgeDirection.UP.ordinal()]) ? Geometry.cable_corner_max : maxY;
|
||||
minY += (placed[ForgeDirection.DOWN.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
maxY -= (placed[ForgeDirection.UP.ordinal()]) ? Geometry.cable_low_height : 0;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, Geometry.cable_width_max, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
++renderCount;
|
||||
}
|
||||
if (renderCount == 0)
|
||||
{
|
||||
minX = Geometry.cable_high_offset;
|
||||
minY = Geometry.cable_width_min;
|
||||
minZ = Geometry.cable_width_min;
|
||||
maxX = Geometry.cable_high_height;
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_width_max;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, Geometry.cable_width_min, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
minX = Geometry.cable_high_offset;
|
||||
minY = Geometry.cable_width_min;
|
||||
minZ = Geometry.cable_width_min;
|
||||
maxX = Geometry.cable_high_height;
|
||||
maxY = Geometry.cable_width_max;
|
||||
maxZ = Geometry.cable_width_max;
|
||||
|
||||
renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
@@ -159,7 +159,7 @@ public class SignalBusItem extends ItemBlock
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return ((SignalBusLogic)te).canPlaceOnSide(ForgeDirection.OPPOSITES[side]);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -23,6 +23,7 @@ public abstract class MultiblockBaseLogic extends TileEntity implements IMultibl
|
||||
private boolean saveMultiblockData;
|
||||
private NBTTagCompound cachedMultiblockData;
|
||||
private boolean doUpdate;
|
||||
private boolean pendingDestroy = false;
|
||||
|
||||
public MultiblockBaseLogic()
|
||||
{
|
||||
@@ -114,7 +115,7 @@ public abstract class MultiblockBaseLogic extends TileEntity implements IMultibl
|
||||
@Override
|
||||
public boolean isVisited ()
|
||||
{
|
||||
return this.visited != kUnvisited;
|
||||
return (this.visited != kUnvisited || pendingDestroy);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,6 +161,11 @@ public abstract class MultiblockBaseLogic extends TileEntity implements IMultibl
|
||||
@Override
|
||||
public void onBlockAdded (World world, int x, int y, int z)
|
||||
{
|
||||
if (pendingDestroy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IMultiblockMember[] neighbors = getNeighboringMembers();
|
||||
|
||||
List<MultiblockMasterBaseLogic> masters = new LinkedList<MultiblockMasterBaseLogic>();
|
||||
@@ -226,7 +232,7 @@ public abstract class MultiblockBaseLogic extends TileEntity implements IMultibl
|
||||
@Override
|
||||
public void onOrphaned ()
|
||||
{
|
||||
if (this.isConnected())
|
||||
if (this.isConnected() || pendingDestroy)
|
||||
{
|
||||
// Turns out, we're not an orphan after all
|
||||
return;
|
||||
@@ -385,6 +391,13 @@ public abstract class MultiblockBaseLogic extends TileEntity implements IMultibl
|
||||
this.master = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void destroySelf ()
|
||||
{
|
||||
pendingDestroy = true;
|
||||
// this.detachSelf(false);
|
||||
this.getMultiblockMaster().scheduleRemoveAndRevisit(this);
|
||||
}
|
||||
|
||||
protected CoordTuple[] getNeighborCoords ()
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeChunkManager.ForceChunkEvent;
|
||||
|
||||
import tconstruct.library.util.CoordTuple;
|
||||
|
||||
@@ -17,10 +18,12 @@ public abstract class MultiblockMasterBaseLogic
|
||||
{
|
||||
protected World worldObj;
|
||||
protected Set<CoordTuple> connectedBlocks;
|
||||
protected LinkedList<CoordTuple> pendingRemovalBlocks;
|
||||
protected CoordTuple referenceCoord;
|
||||
protected CoordTuple minimumCoord;
|
||||
protected CoordTuple maximumCoord;
|
||||
protected boolean forceRecheck;
|
||||
protected boolean forceRevisit;
|
||||
protected boolean chunksHaveLoaded;
|
||||
protected boolean doUpdates;
|
||||
|
||||
@@ -28,6 +31,7 @@ public abstract class MultiblockMasterBaseLogic
|
||||
{
|
||||
worldObj = world;
|
||||
connectedBlocks = new CopyOnWriteArraySet<CoordTuple>();
|
||||
pendingRemovalBlocks = new LinkedList<CoordTuple>();
|
||||
referenceCoord = null;
|
||||
|
||||
minimumCoord = new CoordTuple(0, 0, 0);
|
||||
@@ -219,7 +223,10 @@ public abstract class MultiblockMasterBaseLogic
|
||||
if (referenceCoord != null)
|
||||
{
|
||||
TileEntity te = this.worldObj.getBlockTileEntity(referenceCoord.x, referenceCoord.y, referenceCoord.z);
|
||||
((IMultiblockMember) te).forfeitMultiblockSaveDelegate();
|
||||
if (te instanceof IMultiblockMember)
|
||||
{
|
||||
((IMultiblockMember) te).forfeitMultiblockSaveDelegate();
|
||||
}
|
||||
this.referenceCoord = null;
|
||||
}
|
||||
|
||||
@@ -237,6 +244,58 @@ public abstract class MultiblockMasterBaseLogic
|
||||
|
||||
public final void doMultiblockTick ()
|
||||
{
|
||||
if (forceRevisit)
|
||||
{
|
||||
CoordTuple deadCoords;
|
||||
|
||||
forceRevisit = false;
|
||||
while (!pendingRemovalBlocks.isEmpty())
|
||||
{
|
||||
deadCoords = pendingRemovalBlocks.removeFirst();
|
||||
if (connectedBlocks.contains(deadCoords))
|
||||
{
|
||||
if (referenceCoord.equals(deadCoords))
|
||||
{
|
||||
referenceCoord = null;
|
||||
}
|
||||
connectedBlocks.remove(deadCoords);
|
||||
}
|
||||
}
|
||||
if (referenceCoord == null)
|
||||
{
|
||||
if (!this.connectedBlocks.isEmpty())
|
||||
{
|
||||
for (CoordTuple tcoord : connectedBlocks)
|
||||
{
|
||||
TileEntity te = this.worldObj.getBlockTileEntity(tcoord.x, tcoord.y, tcoord.z);
|
||||
if (!(te instanceof IMultiblockMember))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (referenceCoord == null)
|
||||
{
|
||||
referenceCoord = tcoord;
|
||||
}
|
||||
else if (tcoord.compareTo(referenceCoord) < 0)
|
||||
{
|
||||
referenceCoord = tcoord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (referenceCoord != null)
|
||||
{
|
||||
TileEntity te = this.worldObj.getBlockTileEntity(referenceCoord.x, referenceCoord.y, referenceCoord.z);
|
||||
((IMultiblockMember) te).becomeMultiblockSaveDelegate();
|
||||
}
|
||||
}
|
||||
|
||||
this.revisitBlocks();
|
||||
|
||||
forceRecheck = true;
|
||||
}
|
||||
|
||||
if (this.connectedBlocks.isEmpty())
|
||||
{
|
||||
MultiblockRegistry.unregister(this);
|
||||
@@ -289,7 +348,7 @@ public abstract class MultiblockMasterBaseLogic
|
||||
}
|
||||
|
||||
te = this.worldObj.getBlockTileEntity(coord.x, coord.y, coord.z);
|
||||
if (te == null)
|
||||
if (!(te instanceof IMultiblockMember))
|
||||
{
|
||||
continue;
|
||||
} // this happens during chunk unload; ignore it
|
||||
@@ -392,4 +451,10 @@ public abstract class MultiblockMasterBaseLogic
|
||||
public abstract void formatDescriptionPacket (NBTTagCompound data);
|
||||
|
||||
public abstract void decodeDescriptionPacket (NBTTagCompound data);
|
||||
|
||||
public void scheduleRemoveAndRevisit (IMultiblockMember remove)
|
||||
{
|
||||
forceRevisit = true;
|
||||
pendingRemovalBlocks.add(remove.getCoordInWorld());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user