aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity/implementations
diff options
context:
space:
mode:
authorTechnus <daniel112092@gmail.com>2017-08-04 22:03:59 +0200
committerTechnus <daniel112092@gmail.com>2017-08-04 22:04:24 +0200
commitb72d2e693d6492ca1c62bb814091c76295fbad53 (patch)
treef28f63fc0742fbfb734779da3fee7ff39a8a1530 /src/main/java/gregtech/api/metatileentity/implementations
parentc0c14d63bc369331385d121fa6440c9821947338 (diff)
downloadGT5-Unofficial-b72d2e693d6492ca1c62bb814091c76295fbad53.tar.gz
GT5-Unofficial-b72d2e693d6492ca1c62bb814091c76295fbad53.tar.bz2
GT5-Unofficial-b72d2e693d6492ca1c62bb814091c76295fbad53.zip
Fix rare case of texture not updating when:
Changing texture from page x to page 0 without changing the texture id
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity/implementations')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java
index 3aa5773256..184e612906 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java
@@ -62,8 +62,12 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan
@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
- mMachineBlock=actualTexture=aNBT.getByte("mMachineBlock");
+ actualTexture=aNBT.getByte("mMachineBlock");
mTexturePage=aNBT.getByte("mTexturePage");
+
+ if(mTexturePage!=0 && getBaseMetaTileEntity().isServerSide())
+ actualTexture|=0x80;//<- lets just hope no one needs the correct value for that in client
+ mMachineBlock=actualTexture;
}
public final void updateTexture(int textureIndex){
@@ -78,7 +82,8 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan
@Override
public final void onValueUpdate(byte aValue) {
- mMachineBlock=actualTexture=(byte)(aValue & 0x7F);
+ actualTexture=(byte)(aValue & 0x7F);
+ mMachineBlock=actualTexture;
mTexturePage=0;
}
@@ -89,6 +94,11 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan
public final void onTexturePageUpdate(byte aValue) {
mTexturePage = (byte)(aValue & 0x7F);
+ if(mTexturePage!=0 && getBaseMetaTileEntity().isServerSide()) {//just to be sure
+ mMachineBlock|=0x80;//<- lets just hope no one needs the correct value for that in client
+ actualTexture=mMachineBlock;
+ }
+ //set last bit to allow working of the page reset-er to 0 in rare case when texture id is the same but page changes to 0
}
public final byte getTexturePage() {
@@ -127,8 +137,9 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan
@Override
public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {//in that method since it is usually not overriden, especially for hatches.
- if(actualTexture!=mMachineBlock){//revert to page 0 on edition of the field - old code
- mMachineBlock=actualTexture=(byte)(mMachineBlock & 0x7F);//assign back to mMachineBlock just in case the number was negative
+ if(actualTexture!=mMachineBlock){//revert to page 0 on edition of the field - old code way
+ actualTexture=(byte)(mMachineBlock & 0x7F);
+ mMachineBlock=actualTexture;//clear last bit in mMachineBlock since now we are at page 0 after the direct field change
mTexturePage=0;//assuming old code only supports page 0
}
super.onPreTick(aBaseMetaTileEntity, aTick);