mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
Fix horse inventories indices (#11139)
This commit is contained in:
parent
cb5526fec2
commit
1f88247729
1 changed files with 13 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue