diff options
author | moller21 <42100910+moller21@users.noreply.github.com> | 2020-08-29 13:48:36 +0200 |
---|---|---|
committer | moller21 <42100910+moller21@users.noreply.github.com> | 2020-08-29 13:48:36 +0200 |
commit | 3a8cc3c906b1c5c6ea0ce8595d07712d22912f88 (patch) | |
tree | 46dd0bc1fc45e4aadd8ee026841ddd36c0244ad9 /src/main/java | |
parent | 7f78a91208b9c0a61b63ab1bb18c2719fcb54512 (diff) | |
download | GT5-Unofficial-3a8cc3c906b1c5c6ea0ce8595d07712d22912f88.tar.gz GT5-Unofficial-3a8cc3c906b1c5c6ea0ce8595d07712d22912f88.tar.bz2 GT5-Unofficial-3a8cc3c906b1c5c6ea0ce8595d07712d22912f88.zip |
Move neighbour update to BaseTileEntity
Diffstat (limited to 'src/main/java')
3 files changed, 24 insertions, 40 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index a14e164b48..6025e7eb13 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -309,26 +309,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } if (mNeedsBlockUpdate) { - Block thisBlock = getBlockOffset(0, 0, 0); - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int x1 = xCoord + dir.offsetX, y1 = yCoord + dir.offsetY, z1 = zCoord + dir.offsetZ; - - if (worldObj.blockExists(x1, y1, z1)) { - worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock); - - //update if it was / is strong powered. - if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) { - int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. - - for (ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) { - int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ; - if (dir2.ordinal() != skipUpdateSide && worldObj.blockExists(x2, y2, z2)) - worldObj.notifyBlockOfNeighborChange(x2, y2, z2, thisBlock); - - } - } - } - } + updateNeighbours(mStrongRedstone, oStrongRedstone); oStrongRedstone = mStrongRedstone; mNeedsBlockUpdate = false; } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 8ef7ff0f04..2a275a5354 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -586,26 +586,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } if (mNeedsBlockUpdate) { - Block thisBlock = getBlockOffset(0, 0, 0); - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int x1 = xCoord + dir.offsetX, y1 = yCoord + dir.offsetY, z1 = zCoord + dir.offsetZ; - - if (worldObj.blockExists(x1, y1, z1)) { - worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock); - - //update if it was / is strong powered. - if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) { - int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. - - for (ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) { - int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ; - if (dir2.ordinal() != skipUpdateSide && worldObj.blockExists(x2, y2, z2)) - worldObj.notifyBlockOfNeighborChange(x2, y2, z2, thisBlock); - - } - } - } - } + updateNeighbours(mStrongRedstone, oStrongRedstone); oStrongRedstone = mStrongRedstone; mNeedsBlockUpdate = false; } diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java index f5ba784162..dcaa98f120 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java @@ -427,6 +427,28 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje clearNullMarkersFromTileEntityBuffer(); } + public void updateNeighbours(int mStrongRedstone, int oStrongRedstone) { + Block thisBlock = getBlockOffset(0, 0, 0); + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int x1 = xCoord + dir.offsetX, y1 = yCoord + dir.offsetY, z1 = zCoord + dir.offsetZ; + + if (worldObj.blockExists(x1, y1, z1)) { + worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock); + + //update if it was / is strong powered. + if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) { + int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. Still updates diagonal blocks twice if conditions meet. + + for (ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) { + int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ; + if (dir2.ordinal() != skipUpdateSide && worldObj.blockExists(x2, y2, z2)) + worldObj.notifyBlockOfNeighborChange(x2, y2, z2, thisBlock); + } + } + } + } + } + @Override public final void sendBlockEvent(byte aID, byte aValue) { NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_Block_Event(xCoord, (short) yCoord, zCoord, aID, aValue), xCoord, zCoord); |