SPIGOT-7666: Fix access to llama and horse special slot

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-05-10 19:23:01 +10:00
parent 54f230de84
commit 317917800c
4 changed files with 16 additions and 8 deletions

View file

@ -59,7 +59,7 @@ public class CraftHorse extends CraftAbstractHorse implements Horse {
@Override
public HorseInventory getInventory() {
return new CraftInventoryHorse(getHandle().inventory);
return new CraftInventoryHorse(getHandle().inventory, getHandle().getBodyArmorAccess());
}
@Override

View file

@ -34,7 +34,7 @@ public class CraftLlama extends CraftChestedHorse implements Llama {
@Override
public LlamaInventory getInventory() {
return new CraftInventoryLlama(getHandle().inventory);
return new CraftInventoryLlama(getHandle().inventory, getHandle().getBodyArmorAccess());
}
@Override

View file

@ -6,17 +6,21 @@ import org.bukkit.inventory.ItemStack;
public class CraftInventoryHorse extends CraftInventoryAbstractHorse implements HorseInventory {
public CraftInventoryHorse(IInventory inventory) {
private final IInventory bodyArmorInventory;
public CraftInventoryHorse(IInventory inventory, IInventory bodyArmorInventory) {
super(inventory);
this.bodyArmorInventory = bodyArmorInventory;
}
@Override
public ItemStack getArmor() {
return getItem(1);
net.minecraft.world.item.ItemStack item = bodyArmorInventory.getItem(0);
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
}
@Override
public void setArmor(ItemStack stack) {
setItem(1, stack);
bodyArmorInventory.setItem(0, CraftItemStack.asNMSCopy(stack));
}
}

View file

@ -6,17 +6,21 @@ import org.bukkit.inventory.LlamaInventory;
public class CraftInventoryLlama extends CraftInventoryAbstractHorse implements LlamaInventory {
public CraftInventoryLlama(IInventory inventory) {
private final IInventory bodyArmorInventory;
public CraftInventoryLlama(IInventory inventory, IInventory bodyArmorInventory) {
super(inventory);
this.bodyArmorInventory = bodyArmorInventory;
}
@Override
public ItemStack getDecor() {
return getItem(1);
net.minecraft.world.item.ItemStack item = bodyArmorInventory.getItem(0);
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
}
@Override
public void setDecor(ItemStack stack) {
setItem(1, stack);
bodyArmorInventory.setItem(0, CraftItemStack.asNMSCopy(stack));
}
}