diff options
author | Jake Potrebic <[email protected]> | 2024-07-06 13:57:30 -0700 |
---|---|---|
committer | Jake Potrebic <[email protected]> | 2024-07-06 13:57:30 -0700 |
commit | d359a9f46e9282698f0be10f6b946d6d295dfe51 (patch) | |
tree | 7a8129a9914844504fdfde83c493c2f64100bbad | |
parent | 4d20922b79f5b3976e240932d087357a3808fde4 (diff) | |
download | Paper-fix/horse-inventories.tar.gz Paper-fix/horse-inventories.zip |
Fix horse inventoriesfix/horse-inventories
-rw-r--r-- | patches/server/1035-fix.patch | 191 |
1 files changed, 191 insertions, 0 deletions
diff --git a/patches/server/1035-fix.patch b/patches/server/1035-fix.patch new file mode 100644 index 0000000000..a2973b306d --- /dev/null +++ b/patches/server/1035-fix.patch @@ -0,0 +1,191 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic <[email protected]> +Date: Sat, 6 Jul 2024 13:57:10 -0700 +Subject: [PATCH] fix + + +diff --git a/src/main/java/net/minecraft/world/inventory/HorseInventoryMenu.java b/src/main/java/net/minecraft/world/inventory/HorseInventoryMenu.java +index e145e11ffeed6d96dbcd3d8c5e2a491883dcf27f..6e5cb3d09bbc69db53e47b387b4b65e80c6bce06 100644 +--- a/src/main/java/net/minecraft/world/inventory/HorseInventoryMenu.java ++++ b/src/main/java/net/minecraft/world/inventory/HorseInventoryMenu.java +@@ -20,8 +20,8 @@ public class HorseInventoryMenu extends AbstractContainerMenu { + private final Container horseContainer; + private final Container armorContainer; + private final AbstractHorse horse; +- private static final int SLOT_BODY_ARMOR = 1; +- private static final int SLOT_HORSE_INVENTORY_START = 2; ++ public static final int SLOT_BODY_ARMOR = 1; ++ public static final int SLOT_HORSE_INVENTORY_START = 2; + + // CraftBukkit start + org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity; +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +index 9bcc0931510607b8fbd01233e2b3c346369b214d..467693a60786688b753cebac3b0a88898e332eee 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +@@ -112,7 +112,7 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac + + @Override + public AbstractHorseInventory getInventory() { +- return new CraftSaddledInventory(getHandle().inventory); ++ return new CraftSaddledInventory(getHandle().inventory, this.getHandle().getBodyArmorAccess()); // Paper - use both inventories + } + + // Paper start - Horse API +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java +index 4946da593713f4d11d88ac1bb68a089f2f6d5ae0..9a148dbfc0d9baa2cf296497ab2e92b3c463b0c1 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java +@@ -1,22 +1,71 @@ + package org.bukkit.craftbukkit.inventory; + + import net.minecraft.world.Container; ++import net.minecraft.world.entity.animal.horse.AbstractHorse; ++import net.minecraft.world.inventory.HorseInventoryMenu; + import org.bukkit.inventory.AbstractHorseInventory; + import org.bukkit.inventory.ItemStack; + + public class CraftInventoryAbstractHorse extends CraftInventory implements AbstractHorseInventory { + +- public CraftInventoryAbstractHorse(Container inventory) { ++ // Paper start - combine both horse inventories ++ private final Container bodyArmor; ++ public CraftInventoryAbstractHorse(Container inventory, final Container bodyArmor) { + super(inventory); ++ this.bodyArmor = bodyArmor; ++ // Paper end - combine both horse inventories + } + + @Override + public ItemStack getSaddle() { +- return this.getItem(0); ++ return this.getItem(AbstractHorse.INV_SLOT_SADDLE); // Paper + } + + @Override + public void setSaddle(ItemStack stack) { +- this.setItem(0, stack); ++ this.setItem(AbstractHorse.INV_SLOT_SADDLE, stack); // Paper + } ++ ++ // Paper start - combine both horse inventories ++ public Container getMainInventory() { ++ return this.inventory; ++ } ++ ++ public Container getArmorInventory() { ++ return this.bodyArmor; ++ } ++ ++ public ItemStack getArmor() { ++ return this.getItem(HorseInventoryMenu.SLOT_BODY_ARMOR); ++ } ++ ++ public void setArmor(ItemStack armor) { ++ this.setItem(HorseInventoryMenu.SLOT_BODY_ARMOR, armor); ++ } ++ ++ @Override ++ public int getSize() { ++ return this.getMainInventory().getContainerSize() + this.getArmorInventory().getContainerSize(); ++ } ++ ++ @Override ++ public ItemStack getItem(final int index) { ++ if (index == HorseInventoryMenu.SLOT_BODY_ARMOR) { ++ final net.minecraft.world.item.ItemStack item = this.getArmorInventory().getItem(index); ++ return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); ++ } else { ++ final net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(index); ++ return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); ++ } ++ } ++ ++ @Override ++ public void setItem(final int index, final ItemStack item) { ++ if (index == HorseInventoryMenu.SLOT_BODY_ARMOR) { ++ this.getArmorInventory().setItem(index, CraftItemStack.asNMSCopy(item)); ++ } else { ++ this.getMainInventory().setItem(index, CraftItemStack.asNMSCopy(item)); ++ } ++ } ++ // Paper end - combine both horse inventories + } +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java +index 07a304edc2a7b3450a55728e78a4fe37febdbadc..bb67d796eaed1d007f4d3bf4f009970b8a505924 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java +@@ -6,21 +6,11 @@ import org.bukkit.inventory.ItemStack; + + public class CraftInventoryHorse extends CraftSaddledInventory implements HorseInventory { + +- private final Container bodyArmorInventory; +- ++ // Paper start - properly combine both inventories + public CraftInventoryHorse(Container inventory, Container bodyArmorInventory) { +- super(inventory); +- this.bodyArmorInventory = bodyArmorInventory; +- } +- +- @Override +- public ItemStack getArmor() { +- net.minecraft.world.item.ItemStack item = this.bodyArmorInventory.getItem(0); +- return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); ++ super(inventory, bodyArmorInventory); ++ // Paper end - properly combine both inventories + } + +- @Override +- public void setArmor(ItemStack stack) { +- this.bodyArmorInventory.setItem(0, CraftItemStack.asNMSCopy(stack)); +- } ++ // Paper - moved to CraftInventoryAbstractHorse + } +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java +index dcbc80646ebfc384c4f6ab1beee46a4b71a67af8..0804b642d966f2cb09f4101410e2ff1d154ea594 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java +@@ -6,21 +6,19 @@ import org.bukkit.inventory.LlamaInventory; + + public class CraftInventoryLlama extends CraftInventoryAbstractHorse implements LlamaInventory { + +- private final Container bodyArmorInventory; +- ++ // Paper start - properly combine both inventories + public CraftInventoryLlama(Container inventory, Container bodyArmorInventory) { +- super(inventory); +- this.bodyArmorInventory = bodyArmorInventory; ++ super(inventory, bodyArmorInventory); ++ // Paper end - properly combine both inventories + } + + @Override + public ItemStack getDecor() { +- net.minecraft.world.item.ItemStack item = this.bodyArmorInventory.getItem(0); +- return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); ++ return this.getArmor(); // Paper + } + + @Override + public void setDecor(ItemStack stack) { +- this.bodyArmorInventory.setItem(0, CraftItemStack.asNMSCopy(stack)); ++ this.setArmor(stack); // Paper + } + } +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java +index 3a617c07d445bacf5a13e0e3ff6481823cfc8477..1c100c7c210485c1d3510745de7d18f58ba72557 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java +@@ -5,8 +5,10 @@ import org.bukkit.inventory.SaddledHorseInventory; + + public class CraftSaddledInventory extends CraftInventoryAbstractHorse implements SaddledHorseInventory { + +- public CraftSaddledInventory(Container inventory) { +- super(inventory); ++ // Paper start - combine both inventories ++ public CraftSaddledInventory(Container inventory, final Container bodyArmor) { ++ super(inventory, bodyArmor); ++ // Paper end - combine both inventories + } + + } |