aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoller21 <42100910+moller21@users.noreply.github.com>2020-08-25 22:34:26 +0200
committermoller21 <42100910+moller21@users.noreply.github.com>2020-08-25 22:34:26 +0200
commit7f78a91208b9c0a61b63ab1bb18c2719fcb54512 (patch)
treedbb423cb7f111969d18bbca1613a53be46806fb0
parentb403f91a2f38ca5f8ea94732cab4e776e46c4e7a (diff)
downloadGT5-Unofficial-7f78a91208b9c0a61b63ab1bb18c2719fcb54512.tar.gz
GT5-Unofficial-7f78a91208b9c0a61b63ab1bb18c2719fcb54512.tar.bz2
GT5-Unofficial-7f78a91208b9c0a61b63ab1bb18c2719fcb54512.zip
Redstone, power, strong, signal, cover
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java31
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java25
2 files changed, 49 insertions, 7 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
index b9c8641a86..a14e164b48 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
@@ -54,7 +54,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING];
private boolean mInventoryChanged = false, mWorkUpdate = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false;
private boolean mCheckConnections = false;
- private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0;
+ private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0;
private int oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0;
private short mID = 0;
private long mTickTimer = 0;
@@ -308,11 +308,31 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData);
}
- if (mNeedsBlockUpdate) {
- worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0));
- mNeedsBlockUpdate = false;
+ 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);
+
+ }
+ }
+ }
+ }
+ oStrongRedstone = mStrongRedstone;
+ mNeedsBlockUpdate = false;
+ }
}
- }
default:
tCode = -1;
break;
@@ -907,6 +927,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
mStrongRedstone ^= (1 << tSide);
GT_Utility.sendChatToPlayer(aPlayer, trans("091","Redstone Output at Side ") + tSide + trans("092"," set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? trans("093","Strong") : trans("094","Weak")));
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord);
+ issueBlockUpdate();
}
doEnetUpdate();
return true;
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index 9e37141bc6..8ef7ff0f04 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -62,7 +62,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15};
private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING];
private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false, mActive = false, mRedstone = false, mWorkUpdate = false, mSteamConverter = false, mInventoryChanged = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false, oRedstone = false;
- private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage=0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0;
+ private byte mColor = 0, oColor = 0, oStrongRedstone = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage=0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0;
private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0;
private short mID = 0;
public long mTickTimer = 0;
@@ -586,7 +586,27 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
if (mNeedsBlockUpdate) {
- worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0));
+ 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);
+
+ }
+ }
+ }
+ }
+ oStrongRedstone = mStrongRedstone;
mNeedsBlockUpdate = false;
}
}
@@ -1399,6 +1419,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mStrongRedstone ^= (1 << tSide);
GT_Utility.sendChatToPlayer(aPlayer, trans("091","Redstone Output at Side ") + tSide + trans("092"," set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? trans("093","Strong") : trans("094","Weak")));
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord);
+ issueBlockUpdate();
}
doEnetUpdate();
return true;