Fix horse inventories indices (#11139)

This commit is contained in:
Lulu13022002 2024-07-22 15:17:25 +02:00
parent cb5526fec2
commit 1f88247729

View file

@ -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