From c54ba03b4bde3d00e9cb07165a3a30956a6db79b Mon Sep 17 00:00:00 2001 From: Technus Date: Fri, 28 Jul 2017 12:56:47 +0200 Subject: [PATCH 01/10] Texture overhaul, allows for more textures to be added for casing, with extra byte of data for paging. Just change the value of mTexturePage at the same time you change mMachineBlock. --- .../metatileentity/BaseMetaTileEntity.java | 52 +++++++++++++++++-- .../GT_MetaTileEntity_Hatch.java | 19 +++++-- .../GT_MetaTileEntity_MultiBlockBase.java | 12 ++++- .../api/net/GT_Packet_TileEntity.java | 31 +++++++++-- .../multi/GT_MetaTileEntity_AssemblyLine.java | 1 + .../multi/GT_MetaTileEntity_DieselEngine.java | 1 + .../GT_MetaTileEntity_FusionComputer.java | 3 ++ .../GT_MetaTileEntity_HeatExchanger.java | 2 + .../multi/GT_MetaTileEntity_LargeTurbine.java | 1 + 9 files changed, 109 insertions(+), 13 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 177810f9..aaff0bdc 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -9,6 +9,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IEnergyConnected; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.net.GT_Packet_TileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.*; @@ -58,7 +59,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, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; + 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 int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; private short mID = 0; private long mTickTimer = 0, oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE; @@ -513,7 +514,15 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (aSideServer) { if (mTickTimer % 10 == 0) { if (mSendClientData) { - NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)), oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), oColor = mColor), xCoord, zCoord); + NW.sendPacketToAllPlayersInRange(worldObj, + new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, + mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], + oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)), + oTexturePage = (hasValidMetaTileEntity() && mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) ? ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage() : 0, + oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, + oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), + oColor = mColor), + xCoord, zCoord); mSendClientData = false; } } @@ -521,8 +530,13 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (mTickTimer > 10) { byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)); if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData); + tData = mMetaTileEntity.getUpdateData(); if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); + if(mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + tData = ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage(); + if (tData != oTexturePage) sendBlockEvent((byte) 1, (byte)((oTexturePage = tData)|0x80));//set last bit as a flag for page + } if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)); if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); @@ -571,6 +585,30 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE return null; } + public final void receiveMetaTileEntityData(short aID, int aCover0, int aCover1, int aCover2, int aCover3, int aCover4, int aCover5, byte aTextureData, byte aTexturePage, byte aUpdateData, byte aRedstoneData, byte aColorData) { + issueTextureUpdate(); + if (mID != aID && aID > 0) { + mID = aID; + createNewMetatileEntity(mID); + } + + mCoverSides[0] = aCover0; + mCoverSides[1] = aCover1; + mCoverSides[2] = aCover2; + mCoverSides[3] = aCover3; + mCoverSides[4] = aCover4; + mCoverSides[5] = aCover5; + + for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); + + receiveClientEvent(0, aTextureData); + receiveClientEvent(1, aUpdateData & 0x7F); + receiveClientEvent(1, aTexturePage | 0x80); + receiveClientEvent(2, aColorData); + receiveClientEvent(3, aRedstoneData); + } + + @Deprecated public final void receiveMetaTileEntityData(short aID, int aCover0, int aCover1, int aCover2, int aCover3, int aCover4, int aCover5, byte aTextureData, byte aUpdateData, byte aRedstoneData, byte aColorData) { issueTextureUpdate(); if (mID != aID && aID > 0) { @@ -588,7 +626,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); receiveClientEvent(0, aTextureData); - receiveClientEvent(1, aUpdateData); + receiveClientEvent(1, aUpdateData & 0x7F); + receiveClientEvent(1, 0x80); receiveClientEvent(2, aColorData); receiveClientEvent(3, aRedstoneData); } @@ -616,7 +655,12 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE //mLockUpgrade = ((aValue&32) != 0); break; case 1: - if (hasValidMetaTileEntity()) mMetaTileEntity.onValueUpdate((byte) aValue); + if (hasValidMetaTileEntity()) { + if ((aValue & 0x80) == 0) //Is texture index + mMetaTileEntity.onValueUpdate((byte) (aValue & 0x7F)); + else if (mMetaTileEntity instanceof GT_MetaTileEntity_Hatch)//is texture page and hatch + ((GT_MetaTileEntity_Hatch) mMetaTileEntity).onTexturePageUpdate((byte) (aValue & 0x7F)); + } break; case 2: if (aValue > 16 || aValue < 0) aValue = 0; 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 9c13aa1d..9a4402c3 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 @@ -6,8 +6,8 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.nbt.NBTTagCompound; public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTank { - public byte mMachineBlock = 0; + public byte mTexturePage = 0; public GT_MetaTileEntity_Hatch(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); @@ -36,29 +36,40 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return aSide != aFacing ? mMachineBlock > 0 ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[mMachineBlock]} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]} : mMachineBlock > 0 ? aActive ? getTexturesActive(Textures.BlockIcons.CASING_BLOCKS[mMachineBlock]) : getTexturesInactive(Textures.BlockIcons.CASING_BLOCKS[mMachineBlock]) : aActive ? getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]) : getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]); + int textureIndex=mMachineBlock|(mTexturePage<<7);//Shift seven since one page is 128 textures! + return aSide != aFacing ? (textureIndex > 0) ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureIndex]} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]} : textureIndex > 0 ? aActive ? getTexturesActive(Textures.BlockIcons.CASING_BLOCKS[textureIndex]) : getTexturesInactive(Textures.BlockIcons.CASING_BLOCKS[textureIndex]) : aActive ? getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]) : getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]); } @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setByte("mMachineBlock", mMachineBlock); + aNBT.setByte("mTexturePage", mTexturePage); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); mMachineBlock = aNBT.getByte("mMachineBlock"); + mTexturePage = aNBT.getByte("mTexturePage"); } @Override public final void onValueUpdate(byte aValue) { - mMachineBlock = (byte) (aValue & 127); + mMachineBlock = (byte)(aValue & 0x7F); } @Override public final byte getUpdateData() { - return (byte) (mMachineBlock & 127); + return (byte)(mMachineBlock & 0x7F); + } + + public final void onTexturePageUpdate(byte aValue) { + mTexturePage = (byte)(aValue & 0x7F); + } + + public final byte getTexturePage() { + return (byte)(mTexturePage & 0x7F); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index a02a5568..a95ae7f1 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -709,8 +709,10 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aTileEntity == null) return false; IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) @@ -736,6 +738,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); } return false; @@ -749,6 +752,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); } return false; @@ -760,6 +764,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); } return false; @@ -771,6 +776,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); } return false; @@ -782,11 +788,13 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap(); return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); } @@ -799,10 +807,12 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); } return false; diff --git a/src/main/java/gregtech/api/net/GT_Packet_TileEntity.java b/src/main/java/gregtech/api/net/GT_Packet_TileEntity.java index b916da27..457bd7f2 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_TileEntity.java +++ b/src/main/java/gregtech/api/net/GT_Packet_TileEntity.java @@ -11,12 +11,33 @@ import net.minecraft.world.IBlockAccess; public class GT_Packet_TileEntity extends GT_Packet { private int mX, mZ, mC0, mC1, mC2, mC3, mC4, mC5; private short mY, mID; - private byte mTexture, mUpdate, mRedstone, mColor; + private byte mTexture, mTexturePage, mUpdate, mRedstone, mColor; public GT_Packet_TileEntity() { super(true); } + //For tiles + public GT_Packet_TileEntity(int aX, short aY, int aZ, short aID, int aC0, int aC1, int aC2, int aC3, int aC4, int aC5, byte aTexture, byte aTexturePage, byte aUpdate, byte aRedstone, byte aColor) { + super(false); + mX = aX; + mY = aY; + mZ = aZ; + mC0 = aC0; + mC1 = aC1; + mC2 = aC2; + mC3 = aC3; + mC4 = aC4; + mC5 = aC5; + mID = aID; + mTexture = aTexture; + mTexturePage=aTexturePage; + mUpdate = aUpdate; + mRedstone = aRedstone; + mColor = aColor; + } + + //For pipes public GT_Packet_TileEntity(int aX, short aY, int aZ, short aID, int aC0, int aC1, int aC2, int aC3, int aC4, int aC5, byte aTexture, byte aUpdate, byte aRedstone, byte aColor) { super(false); mX = aX; @@ -30,6 +51,7 @@ public class GT_Packet_TileEntity extends GT_Packet { mC5 = aC5; mID = aID; mTexture = aTexture; + mTexturePage=0; mUpdate = aUpdate; mRedstone = aRedstone; mColor = aColor; @@ -37,7 +59,7 @@ public class GT_Packet_TileEntity extends GT_Packet { @Override public byte[] encode() { - ByteArrayDataOutput tOut = ByteStreams.newDataOutput(40); + ByteArrayDataOutput tOut = ByteStreams.newDataOutput(41); tOut.writeInt(mX); tOut.writeShort(mY); @@ -52,6 +74,7 @@ public class GT_Packet_TileEntity extends GT_Packet { tOut.writeInt(mC5); tOut.writeByte(mTexture); + tOut.writeByte(mTexturePage); tOut.writeByte(mUpdate); tOut.writeByte(mRedstone); tOut.writeByte(mColor); @@ -61,7 +84,7 @@ public class GT_Packet_TileEntity extends GT_Packet { @Override public GT_Packet decode(ByteArrayDataInput aData) { - return new GT_Packet_TileEntity(aData.readInt(), aData.readShort(), aData.readInt(), aData.readShort(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readByte(), aData.readByte(), aData.readByte(), aData.readByte()); + return new GT_Packet_TileEntity(aData.readInt(), aData.readShort(), aData.readInt(), aData.readShort(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readByte(), aData.readByte(), aData.readByte(), aData.readByte(), aData.readByte()); } @Override @@ -70,7 +93,7 @@ public class GT_Packet_TileEntity extends GT_Packet { TileEntity tTileEntity = aWorld.getTileEntity(mX, mY, mZ); if (tTileEntity != null) { if (tTileEntity instanceof BaseMetaTileEntity) - ((BaseMetaTileEntity) tTileEntity).receiveMetaTileEntityData(mID, mC0, mC1, mC2, mC3, mC4, mC5, mTexture, mUpdate, mRedstone, mColor); + ((BaseMetaTileEntity) tTileEntity).receiveMetaTileEntityData(mID, mC0, mC1, mC2, mC3, mC4, mC5, mTexture, mTexturePage, mUpdate, mRedstone, mColor); else if (tTileEntity instanceof BaseMetaPipeEntity) ((BaseMetaPipeEntity) tTileEntity).receiveMetaTileEntityData(mID, mC0, mC1, mC2, mC3, mC4, mC5, mTexture, mUpdate, mRedstone, mColor); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index 64359518..d2521bdd 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -354,6 +354,7 @@ public class GT_MetaTileEntity_AssemblyLine if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); } return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java index ff382c36..9300f773 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -155,6 +155,7 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlock if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mTexturePage = (byte) 0; } else { return false; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java index 82384bd0..2889cb5b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -280,16 +280,19 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity if (this.mEnergyHatches != null) { for (GT_MetaTileEntity_Hatch_Energy hatch : this.mEnergyHatches) { hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; + hatch.mTexturePage=0; } } if (this.mOutputHatches != null) { for (GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; + hatch.mTexturePage=0; } } if (this.mInputHatches != null) { for (GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; + hatch.mTexturePage=0; } } return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index 8bf054d8..7a003960 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -225,6 +225,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; mOutputColdFluidHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; return true; } @@ -237,6 +238,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); mInputHotFluidHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java index 74daf36a..db17bad9 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -91,6 +91,7 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mTexturePage = (byte) 0; } else { return false; } From 281254348e714ea68c880dae1129499ca2024076 Mon Sep 17 00:00:00 2001 From: Technus Date: Wed, 2 Aug 2017 18:49:42 +0200 Subject: [PATCH 02/10] Expand to add proper texture paging support. --- .../GT_MetaTileEntity_MultiBlockBase.java | 18 +++++++++--------- .../multi/GT_MetaTileEntity_AssemblyLine.java | 2 +- .../multi/GT_MetaTileEntity_DieselEngine.java | 2 +- .../GT_MetaTileEntity_FusionComputer.java | 6 +++--- .../multi/GT_MetaTileEntity_HeatExchanger.java | 4 ++-- .../multi/GT_MetaTileEntity_LargeTurbine.java | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index a95ae7f1..f31a534b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -711,7 +711,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); @@ -738,7 +738,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); } return false; @@ -752,7 +752,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); } return false; @@ -764,7 +764,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); } return false; @@ -776,7 +776,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); } return false; @@ -788,13 +788,13 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap(); return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); } @@ -807,12 +807,12 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); } return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index d2521bdd..535abf3e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -354,7 +354,7 @@ public class GT_MetaTileEntity_AssemblyLine if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); } return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java index 9300f773..2e5f316a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -155,7 +155,7 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlock if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mTexturePage = (byte) 0;//FORCED TO 0 } else { return false; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java index 2889cb5b..b1334527 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -280,19 +280,19 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity if (this.mEnergyHatches != null) { for (GT_MetaTileEntity_Hatch_Energy hatch : this.mEnergyHatches) { hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; - hatch.mTexturePage=0; + hatch.mTexturePage=0;//FORCED TO 0 } } if (this.mOutputHatches != null) { for (GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; - hatch.mTexturePage=0; + hatch.mTexturePage=0;//FORCED TO 0 } } if (this.mInputHatches != null) { for (GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; - hatch.mTexturePage=0; + hatch.mTexturePage=0;//FORCED TO 0 } } return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index 7a003960..f7804849 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -225,7 +225,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); mOutputColdFluidHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; return true; } @@ -238,7 +238,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); mInputHotFluidHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java index db17bad9..4d5b0190 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -91,7 +91,7 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mTexturePage = (byte) 0; + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mTexturePage = (byte) 0;//FORCED TO 0 } else { return false; } From 85479e17795a58a027fbdd16130784fa9bf9302d Mon Sep 17 00:00:00 2001 From: Technus Date: Wed, 2 Aug 2017 19:03:36 +0200 Subject: [PATCH 03/10] Add pages to array --- src/main/java/gregtech/api/enums/Textures.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index 3154c4dc..b2f7bcb2 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -612,7 +612,7 @@ public class Textures { new GT_RenderedTexture(OVERLAY_LOCKER_012), new GT_RenderedTexture(OVERLAY_LOCKER_013), }, - CASING_BLOCKS = new ITexture[128], + CASING_BLOCKS = new ITexture[128*16],//16 Pages available 0-15 - each can hold 128 textures 0-127 MACHINE_CASINGS[] = new ITexture[10][17]; static { From 94ed98cbbdfa25987befa965cfbf32437bcff2e4 Mon Sep 17 00:00:00 2001 From: Technus Date: Thu, 3 Aug 2017 22:46:39 +0200 Subject: [PATCH 04/10] More compatible attempt --- .../java/gregtech/api/enums/Textures.java | 7 ++- .../GT_MetaTileEntity_Hatch.java | 49 ++++++++++++++++--- .../GT_MetaTileEntity_MultiBlockBase.java | 27 ++++------ .../multi/GT_MetaTileEntity_AssemblyLine.java | 3 +- .../multi/GT_MetaTileEntity_DieselEngine.java | 3 +- .../GT_MetaTileEntity_FusionComputer.java | 9 ++-- .../GT_MetaTileEntity_HeatExchanger.java | 6 +-- .../multi/GT_MetaTileEntity_LargeTurbine.java | 3 +- 8 files changed, 63 insertions(+), 44 deletions(-) diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index b2f7bcb2..6927d4f8 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -612,13 +612,16 @@ public class Textures { new GT_RenderedTexture(OVERLAY_LOCKER_012), new GT_RenderedTexture(OVERLAY_LOCKER_013), }, - CASING_BLOCKS = new ITexture[128*16],//16 Pages available 0-15 - each can hold 128 textures 0-127 - MACHINE_CASINGS[] = new ITexture[10][17]; + CASING_BLOCKS = new ITexture[128],//original variable still limited to 128 + MACHINE_CASINGS[] = new ITexture[16][17]; + + public static ITexture[][] casingTexturePages = new ITexture[128][];//page holder so we don't make an short long array static { for (byte i = 0; i < MACHINE_CASINGS.length; i++) for (byte j = 0; j < MACHINE_CASINGS[i].length; j++) MACHINE_CASINGS[i][j] = new GT_SidedTexture(MACHINECASINGS_BOTTOM[i], MACHINECASINGS_TOP[i], MACHINECASINGS_SIDE[i], Dyes.getModulation(j - 1, Dyes.MACHINE_METAL.mRGBa)); + casingTexturePages[0]=CASING_BLOCKS; } protected IIcon mIcon; 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 9a4402c3..3407eea9 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 @@ -6,8 +6,10 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.nbt.NBTTagCompound; public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTank { + @Deprecated //Use texture changing method public byte mMachineBlock = 0; - public byte mTexturePage = 0; + private byte mTexturePage = 0; + private byte actualTexture = 0; public GT_MetaTileEntity_Hatch(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); @@ -36,32 +38,52 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - int textureIndex=mMachineBlock|(mTexturePage<<7);//Shift seven since one page is 128 textures! - return aSide != aFacing ? (textureIndex > 0) ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureIndex]} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]} : textureIndex > 0 ? aActive ? getTexturesActive(Textures.BlockIcons.CASING_BLOCKS[textureIndex]) : getTexturesInactive(Textures.BlockIcons.CASING_BLOCKS[textureIndex]) : aActive ? getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]) : getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]); + int textureIndex=actualTexture|(mTexturePage<<7);//Shift seven since one page is 128 textures! + return aSide != aFacing ? + textureIndex > 0 ? + new ITexture[]{Textures.BlockIcons.casingTexturePages[mTexturePage][actualTexture]} : + new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]} : + textureIndex > 0 ? + aActive ? + getTexturesActive(Textures.BlockIcons.casingTexturePages[mTexturePage][actualTexture]) : + getTexturesInactive(Textures.BlockIcons.casingTexturePages[mTexturePage][actualTexture]) : + aActive ? + getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]) : + getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]); } @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setByte("mMachineBlock", mMachineBlock); + aNBT.setByte("mMachineBlock", actualTexture); aNBT.setByte("mTexturePage", mTexturePage); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - mMachineBlock = aNBT.getByte("mMachineBlock"); - mTexturePage = aNBT.getByte("mTexturePage"); + mMachineBlock=actualTexture=aNBT.getByte("mMachineBlock"); + mTexturePage=aNBT.getByte("mTexturePage"); + } + + public final void updateTexture(int textureIndex){ + onValueUpdate((byte) textureIndex); + onTexturePageUpdate((byte) (textureIndex>>7)); + } + + public final void updateTexture(byte texturePage, byte machineBlock){ + onValueUpdate(machineBlock); + onTexturePageUpdate(texturePage); } @Override public final void onValueUpdate(byte aValue) { - mMachineBlock = (byte)(aValue & 0x7F); + mMachineBlock=actualTexture=(byte)(aValue & 0x7F); } @Override public final byte getUpdateData() { - return (byte)(mMachineBlock & 0x7F); + return (byte)(actualTexture & 0x7F); } public final void onTexturePageUpdate(byte aValue) { @@ -101,4 +123,15 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan public boolean displaysStackSize() { return false; } + + @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 + mTexturePage=0;//assuming old code only supports page 0 + } + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + //To change to other page -> use the setter method -> updateTexture } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index f31a534b..68457e97 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -710,8 +710,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); @@ -737,8 +736,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); } return false; @@ -751,8 +749,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); } return false; @@ -763,8 +760,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); } return false; @@ -775,8 +771,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); } return false; @@ -787,14 +782,12 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap(); return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); } @@ -806,13 +799,11 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); } return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index 535abf3e..a5b938a3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -353,8 +353,7 @@ public class GT_MetaTileEntity_AssemblyLine IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); } return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java index 2e5f316a..826cab56 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -154,8 +154,7 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlock if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mTexturePage = (byte) 0;//FORCED TO 0 + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).updateTexture(getCasingTextureIndex()); } else { return false; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java index b1334527..92301a7e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -279,20 +279,17 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity public boolean turnCasingActive(boolean status) { if (this.mEnergyHatches != null) { for (GT_MetaTileEntity_Hatch_Energy hatch : this.mEnergyHatches) { - hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; - hatch.mTexturePage=0;//FORCED TO 0 + hatch.updateTexture(status ? 52 : 53); } } if (this.mOutputHatches != null) { for (GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { - hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; - hatch.mTexturePage=0;//FORCED TO 0 + hatch.updateTexture(status ? 52 : 53); } } if (this.mInputHatches != null) { for (GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { - hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; - hatch.mTexturePage=0;//FORCED TO 0 + hatch.updateTexture(status ? 52 : 53); } } return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index f7804849..b258a642 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -224,8 +224,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); mOutputColdFluidHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; return true; } @@ -237,8 +236,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTexturePage = (byte) (aBaseCasingIndex>>7); + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); mInputHotFluidHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java index 4d5b0190..9806f339 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -90,8 +90,7 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mTexturePage = (byte) 0;//FORCED TO 0 + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).updateTexture(getCasingTextureIndex()); } else { return false; } From c0b1f74e083d9c0e3ade1d227fa88d93ef52e905 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 3 Aug 2017 22:54:36 +0200 Subject: [PATCH 05/10] Minor error correction We have 16 tiers of textures. --- src/main/java/gregtech/api/enums/Textures.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index 6927d4f8..f60fa257 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -613,7 +613,7 @@ public class Textures { new GT_RenderedTexture(OVERLAY_LOCKER_013), }, CASING_BLOCKS = new ITexture[128],//original variable still limited to 128 - MACHINE_CASINGS[] = new ITexture[16][17]; + MACHINE_CASINGS[] = new ITexture[10][17]; public static ITexture[][] casingTexturePages = new ITexture[128][];//page holder so we don't make an short long array From bf4f19557a7e778560011b3cf20fbc0a0d94a501 Mon Sep 17 00:00:00 2001 From: Technus Date: Thu, 3 Aug 2017 23:15:52 +0200 Subject: [PATCH 06/10] Fix one missing spot in deprecated api. (for texture change use that is) --- .../metatileentity/implementations/GT_MetaTileEntity_Hatch.java | 1 + 1 file changed, 1 insertion(+) 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 3407eea9..3aa57732 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 @@ -79,6 +79,7 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan @Override public final void onValueUpdate(byte aValue) { mMachineBlock=actualTexture=(byte)(aValue & 0x7F); + mTexturePage=0; } @Override From fc08b67f7d973d1b83d2027102ec385b29bfba89 Mon Sep 17 00:00:00 2001 From: Technus Date: Fri, 4 Aug 2017 22:03:59 +0200 Subject: [PATCH 07/10] Fix rare case of texture not updating when: Changing texture from page x to page 0 without changing the texture id --- .../GT_MetaTileEntity_Hatch.java | 19 +++++++++++++++---- 1 file 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 3aa57732..184e6129 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); From c9ea7f7727be3ebd7714283626f00cb0ab529b1b Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 4 Aug 2017 23:02:16 +0200 Subject: [PATCH 08/10] Update commentary --- .../implementations/GT_MetaTileEntity_Hatch.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 184e6129..9695e71c 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 @@ -66,7 +66,7 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan mTexturePage=aNBT.getByte("mTexturePage"); if(mTexturePage!=0 && getBaseMetaTileEntity().isServerSide()) - actualTexture|=0x80;//<- lets just hope no one needs the correct value for that in client + actualTexture|=0x80;//<- lets just hope no one needs the correct value for that on server mMachineBlock=actualTexture; } @@ -95,7 +95,7 @@ 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 + mMachineBlock|=0x80;//<- lets just hope no one needs the correct value for that on server 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 From 1751ec494c85b66b43111f064dc4c3234fdac0c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=A4=C3=9Fler?= Date: Fri, 4 Aug 2017 10:47:54 +0200 Subject: [PATCH 09/10] Just in case the number goes negative --- .../implementations/GT_MetaTileEntity_Hatch.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 9695e71c..c6fa890b 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 @@ -39,14 +39,15 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { int textureIndex=actualTexture|(mTexturePage<<7);//Shift seven since one page is 128 textures! + int texturePointer=(byte)(actualTexture&0x7F);//just to be sure, from my testing the 8th bit cannot be set clientside return aSide != aFacing ? textureIndex > 0 ? - new ITexture[]{Textures.BlockIcons.casingTexturePages[mTexturePage][actualTexture]} : + new ITexture[]{Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]} : textureIndex > 0 ? aActive ? - getTexturesActive(Textures.BlockIcons.casingTexturePages[mTexturePage][actualTexture]) : - getTexturesInactive(Textures.BlockIcons.casingTexturePages[mTexturePage][actualTexture]) : + getTexturesActive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]) : + getTexturesInactive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]) : aActive ? getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]) : getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]); From 8eade43a195ac74ee28880d8833eeaf7dbd7d64f Mon Sep 17 00:00:00 2001 From: Technus Date: Sat, 12 Aug 2017 15:07:28 +0200 Subject: [PATCH 10/10] Fix NPE, GREG why u no crash game! --- .../implementations/GT_MetaTileEntity_Hatch.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 c6fa890b..f7fcda19 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 @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -66,7 +68,7 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan actualTexture=aNBT.getByte("mMachineBlock"); mTexturePage=aNBT.getByte("mTexturePage"); - if(mTexturePage!=0 && getBaseMetaTileEntity().isServerSide()) + if(mTexturePage!=0 && GT_Values.GT.isServerSide()) actualTexture|=0x80;//<- lets just hope no one needs the correct value for that on server mMachineBlock=actualTexture; }