3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-16 03:20:07 +01:00
Paper/patches/server/1029-fix-horse-inventories.patch
Bjarne Koll 77a5779e24
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11197)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
2ec53f49 PR-1050: Fix empty result check for Complex Recipes
10671012 PR-1044: Add CrafterCraftEvent
4d87ffe0 Use correct method in JavaDoc
ae5e5817 SPIGOT-7850: Add API for Bogged shear state
46b6d445 SPIGOT-7837: Support data pack banner patterns
d5d0cefc Fix JavaDoc error
b3c2b83d PR-1036: Add API for InventoryView derivatives
1fe2c75a SPIGOT-7809: Add ShieldMeta

CraftBukkit Changes:
8ee6fd1b8 SPIGOT-7857: Improve ItemMeta block data deserialization
8f26c30c6 SPIGOT-7857: Fix spurious internal NBT tag when deserializing BlockStateMeta
759061b93 SPIGOT-7855: Fire does not spread or burn blocks
00fc9fb64 SPIGOT-7853: AnvilInventory#getRepairCost() always returns 0
7501e2e04 PR-1450: Add CrafterCraftEvent
8c51673e7 SPIGOT-5731: PortalCreateEvent#getEntity returns null for nether portals ignited by flint and steel
d53d0d0b1 PR-1456: Fix inverted logic in CraftCrafterView#setSlotDisabled
682a678c8 SPIGOT-7850: Add API for Bogged shear state
fccf5243a SPIGOT-7837: Support data pack banner patterns
9c3bd4390 PR-1431: Add API for InventoryView derivatives
0cc6acbc4 SPIGOT-7849: Fix FoodComponent serialize with "using-converts-to" using null
2c5474952 Don't rely on tags for CraftItemMetas
20d107e46 SPIGOT-7846: Fix ItemMeta for hanging signs
76f59e315 Remove redundant clone in Dropper InventoryMoveItemEvent
e61a53d25 SPIGOT-7817: Call InventoryMoveItemEvent for Crafters
894682e2d SPIGOT-7839: Remove redundant Java version checks
2c12b2187 SPIGOT-7809: Add ShieldMeta and fix setting shield base colours

Spigot Changes:
fb8fb722 Rebuild patches
34bd42b7 SPIGOT-7835: Fix issue with custom hopper settings
2024-08-09 22:05:50 +02:00

183 Zeilen
8.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sat, 6 Jul 2024 13:57:10 -0700
Subject: [PATCH] fix horse inventories
Horse inventories now combine 2 inventories (like
result inventories).
== AT ==
public net/minecraft/world/inventory/HorseInventoryMenu SLOT_BODY_ARMOR
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..abef7f23361e6c5d18243dd18439ffd13ac787ae 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java
@@ -6,17 +6,73 @@ 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(net.minecraft.world.entity.animal.horse.AbstractHorse.INV_SLOT_SADDLE); // Paper
}
@Override
public void setSaddle(ItemStack stack) {
- this.setItem(0, stack);
+ this.setItem(net.minecraft.world.entity.animal.horse.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(net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR);
+ }
+
+ public void setArmor(ItemStack armor) {
+ this.setItem(net.minecraft.world.inventory.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 == net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR) {
+ final net.minecraft.world.item.ItemStack item = this.getArmorInventory().getItem(0);
+ return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
+ } else {
+ 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);
+ }
+ }
+
+ @Override
+ public void setItem(final int index, final ItemStack item) {
+ if (index == net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR) {
+ this.getArmorInventory().setItem(0, CraftItemStack.asNMSCopy(item));
+ } else {
+ 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
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java
index 07a304edc2a7b3450a55728e78a4fe37febdbadc..ebf0da48378b9376b3be2ca731315485003f6a89 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java
@@ -6,21 +6,9 @@ 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);
- }
-
- @Override
- public void setArmor(ItemStack stack) {
- this.bodyArmorInventory.setItem(0, CraftItemStack.asNMSCopy(stack));
+ super(inventory, bodyArmorInventory);
}
+ // Paper end - properly combine both inventories
}
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
}
}