From 1c81059335e5e5737883fa3984126375b554b65b Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Wed, 14 Dec 2022 17:46:15 +0100 Subject: [PATCH] fix: storage monitor properly displays if it's upgraded --- austri3Fix.md | 2 -- .../block/legacy/BlockStorageMonitor.java | 6 +++++- .../blocks/RenderBlockStorageMonitor.java | 18 ++---------------- .../appeng/tile/legacy/TileStorageMonitor.java | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/austri3Fix.md b/austri3Fix.md index b669f8c6..1a9f9706 100644 --- a/austri3Fix.md +++ b/austri3Fix.md @@ -1,6 +1,4 @@ - we demultiblocked the transition plane - transition plane doesn't collect items - legacy blocks aren't colorable -- storage monitor doesn't display if it's upgraded - BlockLegacyDisplays don't rotate their faces correctly on the top and bottom -- storage monitors all show the same item diff --git a/src/main/java/appeng/block/legacy/BlockStorageMonitor.java b/src/main/java/appeng/block/legacy/BlockStorageMonitor.java index c2f12370..053b1b46 100644 --- a/src/main/java/appeng/block/legacy/BlockStorageMonitor.java +++ b/src/main/java/appeng/block/legacy/BlockStorageMonitor.java @@ -67,7 +67,7 @@ public class BlockStorageMonitor extends BlockLegacyDisplay { .conversionMatrix() .maybeItem() .get() - && !tile.upgraded && player.isSneaking()) { + && !tile.upgraded) { if (!w.isRemote) { player.inventory.decrStackSize(player.inventory.currentItem, 1); tile.upgraded = true; @@ -185,6 +185,10 @@ public class BlockStorageMonitor extends BlockLegacyDisplay { public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s) { TileStorageMonitor te = (TileStorageMonitor) w.getTileEntity(x, y, z); + System.out.println( + "AAALEC: " + te.upgraded + " " + s + " " + te.getForward().ordinal() + ); + if (te != null && te.upgraded && s == te.getForward().ordinal()) { return ExtraBlockTextures.BlockStorageMonitorFrontMatrix.getIcon(); } diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockStorageMonitor.java b/src/main/java/appeng/client/render/blocks/RenderBlockStorageMonitor.java index 9090655f..375e17df 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockStorageMonitor.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockStorageMonitor.java @@ -9,7 +9,6 @@ import appeng.tile.legacy.TileStorageMonitor; import appeng.util.ReadableNumberConverter; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; @@ -19,19 +18,6 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; public class RenderBlockStorageMonitor extends RenderBlockLegacyDisplay { - private int dspList; - - public RenderBlockStorageMonitor() { - this.dspList = GLAllocation.generateDisplayLists(1); - } - - @Override - protected void finalize() throws Throwable { - super.finalize(); - - GLAllocation.deleteDisplayLists(this.dspList); - } - @Override public boolean hasTESR() { return true; @@ -54,11 +40,11 @@ public class RenderBlockStorageMonitor extends RenderBlockLegacyDisplay { GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); if (tile.updateDisplayList) { tile.updateDisplayList = false; - GL11.glNewList(this.dspList, GL11.GL_COMPILE_AND_EXECUTE); + GL11.glNewList(tile.dspList, GL11.GL_COMPILE_AND_EXECUTE); this.tesrRenderScreen(tile, tess, tile.myItem); GL11.glEndList(); } else { - GL11.glCallList(this.dspList); + GL11.glCallList(tile.dspList); } GL11.glPopMatrix(); } diff --git a/src/main/java/appeng/tile/legacy/TileStorageMonitor.java b/src/main/java/appeng/tile/legacy/TileStorageMonitor.java index 7ff3afc0..1842916b 100644 --- a/src/main/java/appeng/tile/legacy/TileStorageMonitor.java +++ b/src/main/java/appeng/tile/legacy/TileStorageMonitor.java @@ -14,8 +14,10 @@ import appeng.api.storage.data.IItemList; import appeng.me.GridAccessException; import appeng.tile.TileEvent; import appeng.tile.events.TileEventType; +import appeng.util.Platform; import appeng.util.item.AEItemStack; import io.netty.buffer.ByteBuf; +import net.minecraft.client.renderer.GLAllocation; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; @@ -25,12 +27,27 @@ public class TileStorageMonitor extends TileLegacyDisplay implements IStackWatch public IAEItemStack myItem; public boolean updateDisplayList; + public int dspList; + private IStackWatcher watcher; public TileStorageMonitor() { this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL); this.getProxy().setIdlePowerUsage(0.5); this.getProxy().setValidSides(EnumSet.allOf(ForgeDirection.class)); + + if (Platform.isClient()) { + this.dspList = GLAllocation.generateDisplayLists(1); + } + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + + if (Platform.isClient()) { + GLAllocation.deleteDisplayLists(this.dspList); + } } @Override