From db1e10846425b0bcd3881fe68356e2cead9ddde5 Mon Sep 17 00:00:00 2001 From: Felix Cravic Date: Wed, 29 Apr 2020 11:40:58 +0200 Subject: [PATCH] Fixed PlayerInventory craft result slot --- .../server/inventory/PlayerInventory.java | 2 +- .../utils/inventory/PlayerInventoryUtils.java | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/minestom/server/inventory/PlayerInventory.java b/src/main/java/net/minestom/server/inventory/PlayerInventory.java index 4b53f1d77..06483ce24 100644 --- a/src/main/java/net/minestom/server/inventory/PlayerInventory.java +++ b/src/main/java/net/minestom/server/inventory/PlayerInventory.java @@ -242,7 +242,7 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler slot = slot + 36; } else if (slot > 8 && slot < 36) { // Inventory 9-35 slot = slot; - } else if (slot >= CRAFT_SLOT_1 && slot <= CRAFT_RESULT) { // Crafting 36-40 + } else if (slot >= CRAFT_RESULT && slot <= CRAFT_SLOT_4) { // Crafting 36-40 slot = slot - 36; } else if (slot >= HELMET_SLOT && slot <= BOOTS_SLOT) { // Armor 41-44 slot = slot - 36; diff --git a/src/main/java/net/minestom/server/utils/inventory/PlayerInventoryUtils.java b/src/main/java/net/minestom/server/utils/inventory/PlayerInventoryUtils.java index ebc8b1249..9fb9a9fd8 100644 --- a/src/main/java/net/minestom/server/utils/inventory/PlayerInventoryUtils.java +++ b/src/main/java/net/minestom/server/utils/inventory/PlayerInventoryUtils.java @@ -4,11 +4,12 @@ public class PlayerInventoryUtils { public static final int OFFSET = 9; - public static final int CRAFT_SLOT_1 = 36; - public static final int CRAFT_SLOT_2 = 37; - public static final int CRAFT_SLOT_3 = 38; - public static final int CRAFT_SLOT_4 = 39; - public static final int CRAFT_RESULT = 40; + public static final int CRAFT_RESULT = 36; + public static final int CRAFT_SLOT_1 = 37; + public static final int CRAFT_SLOT_2 = 38; + public static final int CRAFT_SLOT_3 = 39; + public static final int CRAFT_SLOT_4 = 40; + public static final int HELMET_SLOT = 41; public static final int CHESTPLATE_SLOT = 42; public static final int LEGGINGS_SLOT = 43; @@ -17,14 +18,16 @@ public class PlayerInventoryUtils { public static int convertSlot(int slot, int offset) { switch (slot) { + case 0: + return CRAFT_RESULT; case 1: - return CRAFT_SLOT_1 + 1; + return CRAFT_SLOT_1; case 2: - return CRAFT_SLOT_2 + 1; + return CRAFT_SLOT_2; case 3: - return CRAFT_SLOT_3 + 1; + return CRAFT_SLOT_3; case 4: - return CRAFT_SLOT_4 + 1; + return CRAFT_SLOT_4; case 5: return HELMET_SLOT; case 6: