From d5a02f56b10578051ebb0dc76612a43ed99963ea Mon Sep 17 00:00:00 2001 From: SCsupercraft <103709272+SCsupercraft@users.noreply.github.com> Date: Thu, 2 Oct 2025 17:55:15 +0100 Subject: [PATCH] Move over container listeners Fixes incompatibilities with other mods such as FTB Quests. --- .../petrolpark/core/extendedinventory/ExtendedInventory.java | 5 ++++- src/main/resources/META-INF/accesstransformer.cfg | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/petrolpark/core/extendedinventory/ExtendedInventory.java b/src/main/java/com/petrolpark/core/extendedinventory/ExtendedInventory.java index 39cd1fa..ba64512 100644 --- a/src/main/java/com/petrolpark/core/extendedinventory/ExtendedInventory.java +++ b/src/main/java/com/petrolpark/core/extendedinventory/ExtendedInventory.java @@ -134,10 +134,13 @@ public void updateSize(boolean forceSync) { * @see ExtendedInventory#refreshPlayerInventoryMenuServer(Player) Refresh the Inventory Menu with the Slots in unknown positions (possible on the server side) */ public static void refreshPlayerInventoryMenu(Player player, int columns, int invX, int invY, int leftHotbarSlots, int leftHotbarX, int leftHotbarY, int rightHotbarX, int rightHotbarY) { - player.inventoryMenu = new InventoryMenu(player.getInventory(), !player.level().isClientSide(), player); // Usually this field would be final; don't tell anybody I did this + InventoryMenu oldMenu = player.inventoryMenu; + InventoryMenu newMenu = new InventoryMenu(player.getInventory(), !player.level().isClientSide(), player); // Usually this field would be final; don't tell anybody I did this + player.inventoryMenu = newMenu; get(player).ifPresent(inv -> inv.addExtraInventorySlotsToMenu(player.inventoryMenu, columns, invX, invY, leftHotbarSlots, leftHotbarX, leftHotbarY, rightHotbarX, rightHotbarY)); player.containerMenu = player.inventoryMenu; if (player instanceof ServerPlayer sp && sp.containerSynchronizer != null && sp.containerListener != null) sp.initInventoryMenu(); + newMenu.containerListeners.addAll(oldMenu.containerListeners); }; /** diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index bcb6fad..97c8e9a 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -38,6 +38,7 @@ private-f net.minecraft.world.entity.player.Player inventory public-f net.minecraft.world.entity.player.Player inventoryMenu public net.minecraft.server.level.ServerPlayer containerSynchronizer public net.minecraft.server.level.ServerPlayer containerListener +public net.minecraft.world.inventory.AbstractContainerMenu containerListeners public net.minecraft.world.inventory.AbstractContainerMenu lastSlots public net.minecraft.world.inventory.AbstractContainerMenu remoteSlots public net.minecraft.world.inventory.AbstractContainerMenu addSlot(Lnet/minecraft/world/inventory/Slot;)Lnet/minecraft/world/inventory/Slot;