From 1f88247729fe0196d05417ff88f9f5f5ec18bf25 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Mon, 22 Jul 2024 15:17:25 +0200 Subject: [PATCH] Fix horse inventories indices (#11139) --- patches/server/fix-horse-inventories.patch | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/patches/server/fix-horse-inventories.patch b/patches/server/fix-horse-inventories.patch index a239957aca..52d8b5d303 100644 --- a/patches/server/fix-horse-inventories.patch +++ b/patches/server/fix-horse-inventories.patch @@ -76,10 +76,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public ItemStack getItem(final int index) { + if (index == net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR) { -+ final net.minecraft.world.item.ItemStack item = this.getArmorInventory().getItem(index); ++ final net.minecraft.world.item.ItemStack item = this.getArmorInventory().getItem(0); + return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); + } else { -+ final net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(index); ++ int shiftedIndex = index; ++ if (index > net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR) { ++ shiftedIndex--; ++ } ++ ++ final net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(shiftedIndex); + return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); + } + } @@ -87,9 +92,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public void setItem(final int index, final ItemStack item) { + if (index == net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR) { -+ this.getArmorInventory().setItem(index, CraftItemStack.asNMSCopy(item)); ++ this.getArmorInventory().setItem(0, CraftItemStack.asNMSCopy(item)); + } else { -+ this.getMainInventory().setItem(index, CraftItemStack.asNMSCopy(item)); ++ int shiftedIndex = index; ++ if (index > net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR) { ++ shiftedIndex--; ++ } ++ this.getMainInventory().setItem(shiftedIndex, CraftItemStack.asNMSCopy(item)); + } + } + // Paper end - combine both horse inventories