Skip to content

update to 26.1.2#403

Open
feeeedox wants to merge 8 commits intoWesJD:masterfrom
feeeedox:master
Open

update to 26.1.2#403
feeeedox wants to merge 8 commits intoWesJD:masterfrom
feeeedox:master

Conversation

@feeeedox
Copy link
Copy Markdown

Fixes #401

@feeeedox
Copy link
Copy Markdown
Author

maven("https://jitpack.io")
implementation("com.github.feeeedox.AnvilGUI:anvilgui:8d6ec7efad")

@Ghosty920
Copy link
Copy Markdown
Contributor

the jitpack file is useless for a PR btw, since @WesJD doesn't use it anyway

@feeeedox
Copy link
Copy Markdown
Author

the jitpack file is useless for a PR btw, since @WesJD doesn't use it anyway

Yeah, he can remove it. I just added it, so im able to use it in my projects without referring to a local jar file.

Copy link
Copy Markdown
Owner

@WesJD WesJD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this! Just a few things to fix and this is good to merge.

Comment thread api/src/main/java/net/wesjd/anvilgui/version/VersionMatcher.java Outdated
Comment thread api/pom.xml Outdated
Comment thread jitpack.yml Outdated
@feeeedox feeeedox requested a review from WesJD April 28, 2026 20:24
@0dinD
Copy link
Copy Markdown
Collaborator

0dinD commented Apr 28, 2026

@WesJD @feeeedox I could be wrong because I don't have time to test/investigate this for a few days, but my initial reaction is that this seems like the wrong way to fix #401.

This is the diff between the 26_R1 wrapper and the 26_R2 wrapper:

diff --git a/Wrapper26_R1.java b/Wrapper26_R2.java
index 020216b..a1ad266 100644
--- a/Wrapper26_R1.java
+++ b/Wrapper26_R2.java
@@ -9,11 +9,7 @@ import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
 import net.minecraft.network.protocol.game.ClientboundSetExperiencePacket;
 import net.minecraft.server.level.ServerPlayer;
 import net.minecraft.world.Container;
-import net.minecraft.world.inventory.AbstractContainerMenu;
-import net.minecraft.world.inventory.AnvilMenu;
-import net.minecraft.world.inventory.ContainerLevelAccess;
-import net.minecraft.world.inventory.MenuType;
-import net.minecraft.world.inventory.Slot;
+import net.minecraft.world.inventory.*;
 import org.bukkit.craftbukkit.CraftWorld;
 import org.bukkit.craftbukkit.entity.CraftPlayer;
 import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -21,7 +17,7 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
 import org.bukkit.entity.Player;
 import org.bukkit.inventory.Inventory;
 
-public final class Wrapper26_R1 implements VersionWrapper {
+public final class Wrapper26_R2 implements VersionWrapper {
     private int getRealNextContainerId(Player player) {
         return toNMS(player).nextContainerCounter();
     }
@@ -51,14 +47,18 @@ public final class Wrapper26_R1 implements VersionWrapper {
         } catch (NoSuchMethodError ignored) {
             // Workaround for Paper servers
             try {
-                Class<?> inventoryCloseEventReasonClass =
-                        Class.forName("org.bukkit.event.inventory.InventoryCloseEvent$Reason");
+                ServerPlayer nmsPlayer = toNMS(player);
+
+                Object reasonPlugin = Enum.valueOf(
+                        (Class<? extends Enum>) Class.forName("org.bukkit.event.inventory.InventoryCloseEvent$Reason"),
+                        "PLUGIN");
+
                 Method handleInventoryCloseEventMethod = CraftEventFactory.class.getMethod(
-                        "handleInventoryCloseEvent", ServerPlayer.class, inventoryCloseEventReasonClass);
-                handleInventoryCloseEventMethod.invoke(
-                        null,
-                        toNMS(player),
-                        inventoryCloseEventReasonClass.getField("UNKNOWN").get(null));
+                        "handleInventoryCloseEvent",
+                        net.minecraft.world.entity.player.Player.class,
+                        Class.forName("org.bukkit.event.inventory.InventoryCloseEvent$Reason"));
+
+                handleInventoryCloseEventMethod.invoke(null, nmsPlayer, reasonPlugin);
             } catch (ReflectiveOperationException e) {
                 throw new RuntimeException(e);
             }

The only meaningful changes I see are:

  • The close reason was changed from UNKNOWN to PLUGIN. Why? That seems wrong to me at first glance.
  • The signature of handleInventoryCloseEvent was changed from net.minecraft.server.level.ServerPlayer.class to net.minecraft.world.entity.player.Player.class. This looks right, but I don't think it should ever have been net.minecraft.server.level.ServerPlayer.class in the 26_R1 wrapper to begin with.

@WesJD did you ever test #398 on a Paper 26.1.1 server? The PR message seems to indicate that you only tested on Spigot because Paper was not released at that time? Again, I haven't had time to test, but my suspicion is that #401 affects 26_R1 (26.1.1) as well, not just 26.1.2. In that case, we should fix the 26_R1 wrapper, not add a new 26_R2 wrapper.

For context, in the 1_21_R7 wrapper, net.minecraft.world.entity.player.EntityHuman.class is used, which would translate to net.minecraft.world.entity.player.Player.class, not net.minecraft.server.level.ServerPlayer.class: https://mappings.dev/1.21.11/net/minecraft/world/entity/player/Player.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paper 26.1.2, cannot open inventory

4 participants