From e047ec18de468ccd8be7edc21c3fa258ea8a15f6 Mon Sep 17 00:00:00 2001 From: Andrei Laiff Date: Tue, 17 Oct 2023 13:40:48 +0300 Subject: [PATCH 1/4] Fix rendering numbers bigger than 2.1G through `aeRenderItem` --- dependencies.gradle | 2 +- .../github/client/gui/GuiLevelMaintainer.java | 5 ++++- .../glodblock/github/client/gui/GuiLevelTerminal.java | 10 +++++++--- .../client/gui/container/ContainerLevelMaintainer.java | 10 ++++++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 5bc837c28..25fa32aa5 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,7 +2,7 @@ dependencies { api('com.github.GTNewHorizons:NotEnoughItems:2.4.3-GTNH:dev') - api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-266-GTNH-pre:dev') + api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-268-GTNH-pre:dev') api('curse.maven:cofh-core-69162:2388751') api('com.github.GTNewHorizons:waila:1.6.0:dev') api("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.0:dev") diff --git a/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java index 16a7cb0be..7f3ec8965 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java @@ -225,6 +225,7 @@ public boolean drawSlot0(Slot slot) { fake.setStackSize(0); } GL11.glTranslatef(0.0f, 0.0f, 200.0f); + aeRenderItem.setAeStack(fake); aeRenderItem.renderItemOverlayIntoGUI( fontRendererObj, mc.getTextureManager(), @@ -344,9 +345,11 @@ private Rectangle getSlotArea(SlotFake slot) { @Override public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) { - for (SlotFluidConvertingFake slot : this.cont.getRequestSlots()) { + for (int i = 0; i < this.cont.getRequestSlots().length; i++) { + SlotFluidConvertingFake slot = this.cont.getRequestSlots()[i]; if (getSlotArea(slot).contains(mouseX, mouseY)) { ItemStack itemStack = createLevelValues(draggedStack.copy()); + itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i); slot.putStack(itemStack); NetworkHandler.instance.sendToServer(new PacketNEIDragClick(itemStack, slot.getSlotIndex())); this.updateAmount(slot.getSlotIndex(), itemStack.stackSize); diff --git a/src/main/java/com/glodblock/github/client/gui/GuiLevelTerminal.java b/src/main/java/com/glodblock/github/client/gui/GuiLevelTerminal.java index 98db8ce30..023e0aa12 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiLevelTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiLevelTerminal.java @@ -569,6 +569,7 @@ private int drawEntry(LevelTerminalEntry entry, int viewY, int titleBottom, int && relMouseY < Math.min(viewY + rowYBot, viewHeight); if (stack != null) { + AEItemStack aeItemStack = AEItemStack.create(stack); NBTTagCompound data = stack.getTagCompound(); ItemStack itemStack = data.hasKey(TLMTags.Stack.tagName) ? ItemStack.loadItemStackFromNBT(data.getCompoundTag(TLMTags.Stack.tagName)) @@ -582,15 +583,18 @@ private int drawEntry(LevelTerminalEntry entry, int viewY, int titleBottom, int GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z); GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); - aeRenderItem.setAeStack(null); + aeItemStack.setStackSize(1); + aeRenderItem.setAeStack(aeItemStack); aeRenderItem.zLevel = 3.0f - 50.0f; aeRenderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0); aeRenderItem.zLevel = 0.0f; GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z); - itemStack.stackSize = (int) quantity; + aeItemStack.setStackSize(quantity); + aeRenderItem.setAeStack(aeItemStack); aeRenderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0); if (batch > 0) { - itemStack.stackSize = (int) batch; + aeItemStack.setStackSize(batch); + aeRenderItem.setAeStack(aeItemStack); aeRenderItem .renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, -11); } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java index 030d68a5a..9e3962d9f 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java @@ -105,10 +105,13 @@ public ItemStack transferStackInSlot(EntityPlayer player, int idx) { return null; } - for (SlotFluidConvertingFake slot : this.getRequestSlots()) { + for (int i = 0; i < this.getRequestSlots().length; i++) { + SlotFluidConvertingFake slot = this.getRequestSlots()[i]; if (!slot.getHasStack()) { ItemStack itemStack = ((Slot) this.inventorySlots.get(idx)).getStack(); - slot.putConvertedStack(createLevelValues(itemStack.copy())); + ItemStack configuration = createLevelValues(itemStack.copy()); + configuration.getTagCompound().setInteger(TLMTags.Index.tagName, i); + slot.putConvertedStack(configuration); break; } } @@ -140,6 +143,9 @@ public static ItemStack createLevelValues(ItemStack itemStack) { if (!data.hasKey(TLMTags.Enable.tagName)) { data.setBoolean(TLMTags.Enable.tagName, false); } + if (data.hasKey(TLMTags.Index.tagName)) { + data.removeTag(TLMTags.Index.tagName); + } data.setInteger(TLMTags.State.tagName, State.None.ordinal()); itemStack.setTagCompound(data); From 12ebc6cc3e57af2204783c7c29d976fd95e65285 Mon Sep 17 00:00:00 2001 From: Andrei Laiff Date: Tue, 17 Oct 2023 15:24:32 +0300 Subject: [PATCH 2/4] Fix fails on `getCraftingItem` no root cause was found --- .../com/glodblock/github/common/tile/TileLevelMaintainer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java b/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java index 83d2ffb7c..3464f1f31 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java @@ -607,7 +607,9 @@ public long getBatchSize(int idx) { public IAEItemStack getCraftItem(int idx) { IAEItemStack is = requestStacks.getStack(idx); if (is == null) return null; + if (is.getItemStack() == null) return null; ItemStack qis = loadItemStackFromTag(is.getItemStack()); + if (qis == null) return null; IAEItemStack qais = AEItemStack.create(qis); qais.setStackSize(getBatchSize(idx)); From 30462390c62ddd72e31d8c08b2c7b67e2775d111 Mon Sep 17 00:00:00 2001 From: Andrei Laiff Date: Tue, 17 Oct 2023 18:19:19 +0300 Subject: [PATCH 3/4] Fix add packet logging and try to not fail after receive corrupted packet --- dependencies.gradle | 10 +-- .../network/SPacketLevelTerminalUpdate.java | 88 +++++++++++++++++++ 2 files changed, 93 insertions(+), 5 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 25fa32aa5..6a5b54134 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,19 +1,19 @@ // Add your dependencies here dependencies { - api('com.github.GTNewHorizons:NotEnoughItems:2.4.3-GTNH:dev') + api('com.github.GTNewHorizons:NotEnoughItems:2.4.5-GTNH:dev') api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-268-GTNH-pre:dev') api('curse.maven:cofh-core-69162:2388751') api('com.github.GTNewHorizons:waila:1.6.0:dev') - api("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.0:dev") + api("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.1:dev") compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev') compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.34:dev') { transitive = false } compileOnly('com.github.GTNewHorizons:ForestryMC:4.6.14:dev') - compileOnly('com.github.GTNewHorizons:EnderIO:2.5.2:dev') - compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.36:dev') { + compileOnly('com.github.GTNewHorizons:EnderIO:2.5.3:dev') + compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.49:dev') { exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework' } compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev') @@ -21,5 +21,5 @@ dependencies { compileOnly('com.github.GTNewHorizons:OpenComputers:1.9.17-GTNH:dev') { transitive = false } compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.4.13-GTNH:dev') { transitive = false } compileOnly('com.github.GTNewHorizons:GTplusplus:1.10.17:dev') { transitive = false } - compileOnly("com.github.GTNewHorizons:Hodgepodge:2.3.9:dev") { transitive = false } + compileOnly("com.github.GTNewHorizons:Hodgepodge:2.3.14:dev") { transitive = false } } diff --git a/src/main/java/com/glodblock/github/network/SPacketLevelTerminalUpdate.java b/src/main/java/com/glodblock/github/network/SPacketLevelTerminalUpdate.java index 7e49efa4f..91ba91667 100644 --- a/src/main/java/com/glodblock/github/network/SPacketLevelTerminalUpdate.java +++ b/src/main/java/com/glodblock/github/network/SPacketLevelTerminalUpdate.java @@ -2,7 +2,9 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; import javax.annotation.Nullable; @@ -16,7 +18,9 @@ import com.glodblock.github.client.gui.GuiLevelTerminal; +import appeng.core.AEConfig; import appeng.core.AELog; +import appeng.core.features.AEFeature; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; @@ -45,6 +49,21 @@ public void fromBytes(ByteBuf buf) { int numEntries = buf.readInt(); for (int i = 0; i < numEntries; ++i) { + if (buf.readableBytes() == 0) { + if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) { + AELog.info( + "Corrupted packet commands: (" + i + + ") of (" + + numEntries + + ") -> " + + this.commands.size() + + " : " + + this.commands.stream().map(packetEntry -> packetEntry.getClass().getSimpleName()) + .collect(Collectors.groupingBy(String::new, Collectors.counting()))); + AELog.info("Parsed content: -> " + this.commands); + } + return; + } PacketType type = PacketType.values()[buf.readByte()]; try { @@ -135,6 +154,14 @@ public IMessage onMessage(SPacketLevelTerminalUpdate message, MessageContext ctx final GuiScreen gs = Minecraft.getMinecraft().currentScreen; if (gs instanceof GuiLevelTerminal levelTerminal) { + if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) { + AELog.info( + "Received commands -> " + message.commands.size() + + " : " + + message.commands.stream() + .map(packetEntry -> packetEntry.getClass().getSimpleName()) + .collect(Collectors.groupingBy(String::new, Collectors.counting()))); + } levelTerminal.postUpdate(message.commands, message.statusFlags); } @@ -282,6 +309,38 @@ protected void read(ByteBuf buf) throws IOException { this.items = payload.getTagList("data", NBT.TAG_COMPOUND); } } + + @Override + public String toString() { + return "PacketAdd{" + "name='" + + name + + '\'' + + ", x=" + + x + + ", y=" + + y + + ", z=" + + z + + ", dim=" + + dim + + ", side=" + + side + + ", rows=" + + rows + + ", rowSize=" + + rowSize + + ", online=" + + online + + ", selfItemStack=" + + selfItemStack + + ", displayItemStack=" + + displayItemStack + + ", items=" + + items + + ", entryId=" + + entryId + + '}'; + } } public static class PacketRemove extends PacketEntry { @@ -302,6 +361,11 @@ protected void write(ByteBuf buf) { @Override protected void read(ByteBuf buf) {} + + @Override + public String toString() { + return "PacketRemove{" + "entryId=" + entryId + '}'; + } } /** @@ -417,6 +481,25 @@ protected void read(ByteBuf buf) throws IOException { } } } + + @Override + public String toString() { + return "PacketOverwrite{" + "onlineValid=" + + onlineValid + + ", online=" + + online + + ", itemsValid=" + + itemsValid + + ", allItemUpdate=" + + allItemUpdate + + ", validIndices=" + + Arrays.toString(validIndices) + + ", items=" + + items + + ", entryId=" + + entryId + + '}'; + } } /** @@ -446,5 +529,10 @@ protected void write(ByteBuf buf) { protected void read(ByteBuf buf) { newName = ByteBufUtils.readUTF8String(buf); } + + @Override + public String toString() { + return "PacketRename{" + "newName='" + newName + '\'' + ", entryId=" + entryId + '}'; + } } } From 75a06d0cc35f8017febf354b61e9e4bd0f5e805e Mon Sep 17 00:00:00 2001 From: Andrei Laiff Date: Tue, 17 Oct 2023 18:36:12 +0300 Subject: [PATCH 4/4] Fix add logging around empty configuration --- .../glodblock/github/client/gui/GuiLevelMaintainer.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java index 7f3ec8965..a6482bac4 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java @@ -47,6 +47,9 @@ import appeng.client.gui.widgets.GuiTabButton; import appeng.container.AEBaseContainer; import appeng.container.slot.SlotFake; +import appeng.core.AEConfig; +import appeng.core.AELog; +import appeng.core.features.AEFeature; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketNEIDragClick; import codechicken.nei.VisiblityData; @@ -130,6 +133,12 @@ public void postUpdate(List list) { } for (IAEItemStack is : list) { NBTTagCompound data = is.getItemStack().getTagCompound(); + if (data == null) { + if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) { + AELog.info("Received empty configuration: ", is); + } + continue; + } long batch = data.getLong(TLMTags.Batch.tagName); long quantity = data.getLong(TLMTags.Quantity.tagName); int idx = data.getInteger(TLMTags.Index.tagName);