From 970bd1abb1f4c21b507658ee31494a6da45d75a9 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sun, 15 Jan 2017 22:36:35 -1000 Subject: [PATCH] Eliminate pointless redraws in receiveMetaTileEntityData --- .../metatileentity/BaseMetaPipeEntity.java | 36 +++++++++++++++---- .../metatileentity/BaseMetaTileEntity.java | 36 +++++++++++++++---- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 0d72f60e..7ad7e409 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -327,18 +327,38 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } 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(); + boolean tNeedsRedraw = false; if (aID > 0 && mID != aID) { mID = aID; createNewMetatileEntity(mID); + tNeedsRedraw = true; } - mCoverSides[0] = aCover0; - mCoverSides[1] = aCover1; - mCoverSides[2] = aCover2; - mCoverSides[3] = aCover3; - mCoverSides[4] = aCover4; - mCoverSides[5] = aCover5; + + if (mCoverSides[0] != aCover0) { + mCoverSides[0] = aCover0; + tNeedsRedraw = true; + } + if (mCoverSides[1] != aCover1) { + mCoverSides[1] = aCover1; + tNeedsRedraw = true; + } + if (mCoverSides[2] != aCover2) { + mCoverSides[2] = aCover2; + tNeedsRedraw = true; + } + if (mCoverSides[3] != aCover3) { + mCoverSides[3] = aCover3; + tNeedsRedraw = true; + } + if (mCoverSides[4] != aCover4) { + mCoverSides[4] = aCover4; + tNeedsRedraw = true; + } + if (mCoverSides[5] != aCover5) { + mCoverSides[5] = aCover5; + tNeedsRedraw = true; + } for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); @@ -346,6 +366,8 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE receiveClientEvent(1, aUpdateData); receiveClientEvent(2, aColorData); receiveClientEvent(3, aRedstoneData); + + if (tNeedsRedraw) issueTextureUpdate(); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index deaba416..1ae432cf 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -594,19 +594,38 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } 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(); + boolean tNeedsRedraw = false; if (mID != aID && aID > 0) { mID = aID; createNewMetatileEntity(mID); + tNeedsRedraw = true; } - mCoverSides[0] = aCover0; - mCoverSides[1] = aCover1; - mCoverSides[2] = aCover2; - mCoverSides[3] = aCover3; - mCoverSides[4] = aCover4; - mCoverSides[5] = aCover5; + if (mCoverSides[0] != aCover0) { + mCoverSides[0] = aCover0; + tNeedsRedraw = true; + } + if (mCoverSides[1] != aCover1) { + mCoverSides[1] = aCover1; + tNeedsRedraw = true; + } + if (mCoverSides[2] != aCover2) { + mCoverSides[2] = aCover2; + tNeedsRedraw = true; + } + if (mCoverSides[3] != aCover3) { + mCoverSides[3] = aCover3; + tNeedsRedraw = true; + } + if (mCoverSides[4] != aCover4) { + mCoverSides[4] = aCover4; + tNeedsRedraw = true; + } + if (mCoverSides[5] != aCover5) { + mCoverSides[5] = aCover5; + tNeedsRedraw = true; + } for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); @@ -614,6 +633,9 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE receiveClientEvent(1, aUpdateData); receiveClientEvent(2, aColorData); receiveClientEvent(3, aRedstoneData); + + if (tNeedsRedraw) issueTextureUpdate(); + } @Override