@@ -40,6 +40,7 @@ class AnvilInputNMS {
4040 private static final MethodHandle SET_PLAYER_ACTIVE_CONTAINER ;
4141 private static final MethodHandle ADD_CONTAINER_SLOT_LISTENER ;
4242 private static final MethodHandle INIT_MENU ;
43+ private static final MethodHandle GET_TOP_INVENTORY ;
4344
4445 // FIELDS
4546 private static final MethodHandle CONTAINER_CHECK_REACHABLE ;
@@ -73,6 +74,8 @@ class AnvilInputNMS {
7374 ADD_CONTAINER_SLOT_LISTENER = getMethod (
7475 CONTAINER , "a" , MethodType .methodType (void .class , getNMSClass ("world.inventory.ICrafting" )));
7576 INIT_MENU = getMethod (ENTITY_PLAYER , "a" , MethodType .methodType (void .class , CONTAINER ));
77+
78+ GET_TOP_INVENTORY = getMethod (InventoryView .class , "getTopInventory" , MethodType .methodType (Inventory .class ));
7679 } catch (Exception exception ) {
7780 throw new RuntimeException (
7881 "Unsupported version for Anvil Input feature: " + ReflectionUtils .getVersionInformation (),
@@ -92,8 +95,7 @@ public static Inventory open(Player player, Object title, String initialInput) {
9295 final Object anvilContainer = ANVIL_CONSTRUCTOR .invoke (windowId , GET_PLAYER_INVENTORY .invoke (entityPlayer ));
9396 CONTAINER_CHECK_REACHABLE .invoke (anvilContainer , false );
9497
95- final AnvilInventory inventory = (AnvilInventory )
96- ((InventoryView ) InventoryUpdate .getBukkitView .invoke (anvilContainer )).getTopInventory ();
98+ final AnvilInventory inventory = (AnvilInventory ) GET_TOP_INVENTORY .invoke (InventoryUpdate .getBukkitView .invoke (anvilContainer ));
9799
98100 inventory .setMaximumRepairCost (0 );
99101
0 commit comments