mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-27 02:13:52 -07:00
@@ -115,7 +115,11 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractHorseInventory getInventory() {
|
public AbstractHorseInventory getInventory() {
|
||||||
return new CraftSaddledInventory(getHandle().inventory, this.getHandle().createEquipmentSlotContainer(EquipmentSlot.BODY));
|
return new CraftSaddledInventory(
|
||||||
|
this.getHandle().inventory,
|
||||||
|
this.getHandle().createEquipmentSlotContainer(EquipmentSlot.BODY),
|
||||||
|
this.getHandle().createEquipmentSlotContainer(EquipmentSlot.SADDLE)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -58,7 +58,10 @@ public class CraftHorse extends CraftAbstractHorse implements Horse {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HorseInventory getInventory() {
|
public HorseInventory getInventory() {
|
||||||
return new CraftInventoryHorse(this.getHandle().inventory, this.getHandle().createEquipmentSlotContainer(EquipmentSlot.BODY));
|
return new CraftInventoryHorse(this.getHandle().inventory,
|
||||||
|
this.getHandle().createEquipmentSlotContainer(EquipmentSlot.BODY),
|
||||||
|
this.getHandle().createEquipmentSlotContainer(EquipmentSlot.SADDLE)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -34,7 +34,10 @@ public class CraftLlama extends CraftChestedHorse implements Llama, com.destroys
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LlamaInventory getInventory() {
|
public LlamaInventory getInventory() {
|
||||||
return new CraftInventoryLlama(this.getHandle().inventory, this.getHandle().createEquipmentSlotContainer(EquipmentSlot.BODY));
|
return new CraftInventoryLlama(this.getHandle().inventory,
|
||||||
|
this.getHandle().createEquipmentSlotContainer(EquipmentSlot.BODY),
|
||||||
|
this.getHandle().createEquipmentSlotContainer(EquipmentSlot.SADDLE)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -1,18 +1,21 @@
|
|||||||
package org.bukkit.craftbukkit.inventory;
|
package org.bukkit.craftbukkit.inventory;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import net.minecraft.world.Container;
|
import net.minecraft.world.Container;
|
||||||
import net.minecraft.world.inventory.HorseInventoryMenu;
|
import net.minecraft.world.inventory.HorseInventoryMenu;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.bukkit.inventory.AbstractHorseInventory;
|
import org.bukkit.inventory.AbstractHorseInventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class CraftInventoryAbstractHorse extends CraftInventory implements AbstractHorseInventory {
|
public class CraftInventoryAbstractHorse extends CraftInventory implements AbstractHorseInventory {
|
||||||
|
|
||||||
// Paper start - combine both horse inventories
|
private final Container bodyArmorInventory;
|
||||||
private final Container bodyArmor;
|
private final Container saddleInventory;
|
||||||
public CraftInventoryAbstractHorse(Container inventory, final Container bodyArmor) {
|
|
||||||
|
public CraftInventoryAbstractHorse(Container inventory, final Container bodyArmorInventory, final Container saddleInventory) {
|
||||||
super(inventory);
|
super(inventory);
|
||||||
this.bodyArmor = bodyArmor;
|
this.bodyArmorInventory = bodyArmorInventory;
|
||||||
// Paper end - combine both horse inventories
|
this.saddleInventory = saddleInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -25,21 +28,24 @@ public class CraftInventoryAbstractHorse extends CraftInventory implements Abstr
|
|||||||
this.setItem(HorseInventoryMenu.SLOT_SADDLE, stack); // Paper
|
this.setItem(HorseInventoryMenu.SLOT_SADDLE, stack); // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paper start - combine both horse inventories
|
|
||||||
public Container getMainInventory() {
|
public Container getMainInventory() {
|
||||||
return this.inventory;
|
return this.inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Container getArmorInventory() {
|
public Container getArmorInventory() {
|
||||||
return this.bodyArmor;
|
return this.bodyArmorInventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Container getSaddleInventory() {
|
||||||
|
return this.saddleInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getArmor() {
|
public ItemStack getArmor() {
|
||||||
return this.getItem(net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR);
|
return this.getItem(HorseInventoryMenu.SLOT_BODY_ARMOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArmor(ItemStack armor) {
|
public void setArmor(ItemStack armor) {
|
||||||
this.setItem(net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR, armor);
|
this.setItem(HorseInventoryMenu.SLOT_BODY_ARMOR, armor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,7 +66,7 @@ public class CraftInventoryAbstractHorse extends CraftInventory implements Abstr
|
|||||||
items[HorseInventoryMenu.SLOT_BODY_ARMOR] = this.getArmor();
|
items[HorseInventoryMenu.SLOT_BODY_ARMOR] = this.getArmor();
|
||||||
|
|
||||||
for (int i = HorseInventoryMenu.SLOT_HORSE_INVENTORY_START; i < items.length; i++) {
|
for (int i = HorseInventoryMenu.SLOT_HORSE_INVENTORY_START; i < items.length; i++) {
|
||||||
net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(i - 1);
|
net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(i - HorseInventoryMenu.SLOT_HORSE_INVENTORY_START);
|
||||||
items[i] = item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
|
items[i] = item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,14 +75,14 @@ public class CraftInventoryAbstractHorse extends CraftInventory implements Abstr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContents(ItemStack[] items) {
|
public void setContents(ItemStack[] items) {
|
||||||
com.google.common.base.Preconditions.checkArgument(items.length <= this.getSize(), "Invalid inventory size (%s); expected %s or less", items.length, this.getSize());
|
Preconditions.checkArgument(items.length <= this.getSize(), "Invalid inventory size (%s); expected %s or less", items.length, this.getSize());
|
||||||
|
|
||||||
this.setSaddle(org.apache.commons.lang3.ArrayUtils.get(items, HorseInventoryMenu.SLOT_SADDLE));
|
this.setSaddle(ArrayUtils.get(items, HorseInventoryMenu.SLOT_SADDLE));
|
||||||
this.setArmor(org.apache.commons.lang3.ArrayUtils.get(items, HorseInventoryMenu.SLOT_BODY_ARMOR));
|
this.setArmor(ArrayUtils.get(items, HorseInventoryMenu.SLOT_BODY_ARMOR));
|
||||||
|
|
||||||
for (int i = HorseInventoryMenu.SLOT_BODY_ARMOR + 1; i < this.getSize(); i++) {
|
for (int i = HorseInventoryMenu.SLOT_HORSE_INVENTORY_START; i < this.getSize(); i++) {
|
||||||
net.minecraft.world.item.ItemStack item = i >= items.length ? net.minecraft.world.item.ItemStack.EMPTY : CraftItemStack.asNMSCopy(items[i]);
|
net.minecraft.world.item.ItemStack item = i >= items.length ? net.minecraft.world.item.ItemStack.EMPTY : CraftItemStack.asNMSCopy(items[i]);
|
||||||
this.getMainInventory().setItem(i - 1, item);
|
this.getMainInventory().setItem(i - HorseInventoryMenu.SLOT_HORSE_INVENTORY_START, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +91,9 @@ public class CraftInventoryAbstractHorse extends CraftInventory implements Abstr
|
|||||||
if (index == HorseInventoryMenu.SLOT_BODY_ARMOR) {
|
if (index == HorseInventoryMenu.SLOT_BODY_ARMOR) {
|
||||||
final net.minecraft.world.item.ItemStack item = this.getArmorInventory().getItem(0);
|
final net.minecraft.world.item.ItemStack item = this.getArmorInventory().getItem(0);
|
||||||
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
|
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
|
||||||
|
} else if (index == HorseInventoryMenu.SLOT_SADDLE) {
|
||||||
|
final net.minecraft.world.item.ItemStack item = this.getSaddleInventory().getItem(0);
|
||||||
|
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
|
||||||
} else {
|
} else {
|
||||||
int shiftedIndex = index;
|
int shiftedIndex = index;
|
||||||
if (index > HorseInventoryMenu.SLOT_BODY_ARMOR) {
|
if (index > HorseInventoryMenu.SLOT_BODY_ARMOR) {
|
||||||
@@ -100,6 +109,8 @@ public class CraftInventoryAbstractHorse extends CraftInventory implements Abstr
|
|||||||
public void setItem(final int index, final ItemStack item) {
|
public void setItem(final int index, final ItemStack item) {
|
||||||
if (index == HorseInventoryMenu.SLOT_BODY_ARMOR) {
|
if (index == HorseInventoryMenu.SLOT_BODY_ARMOR) {
|
||||||
this.getArmorInventory().setItem(0, CraftItemStack.asNMSCopy(item));
|
this.getArmorInventory().setItem(0, CraftItemStack.asNMSCopy(item));
|
||||||
|
} else if (index == HorseInventoryMenu.SLOT_SADDLE) {
|
||||||
|
this.getSaddleInventory().setItem(0, CraftItemStack.asNMSCopy(item));
|
||||||
} else {
|
} else {
|
||||||
int shiftedIndex = index;
|
int shiftedIndex = index;
|
||||||
if (index > HorseInventoryMenu.SLOT_BODY_ARMOR) {
|
if (index > HorseInventoryMenu.SLOT_BODY_ARMOR) {
|
||||||
|
@@ -6,9 +6,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class CraftInventoryHorse extends CraftSaddledInventory implements HorseInventory {
|
public class CraftInventoryHorse extends CraftSaddledInventory implements HorseInventory {
|
||||||
|
|
||||||
// Paper start - properly combine both inventories
|
public CraftInventoryHorse(Container inventory, Container bodyArmorInventory, Container saddleInventory) {
|
||||||
public CraftInventoryHorse(Container inventory, Container bodyArmorInventory) {
|
super(inventory, bodyArmorInventory, saddleInventory);
|
||||||
super(inventory, bodyArmorInventory);
|
|
||||||
}
|
}
|
||||||
// Paper end - properly combine both inventories
|
|
||||||
}
|
}
|
||||||
|
@@ -6,10 +6,8 @@ import org.bukkit.inventory.LlamaInventory;
|
|||||||
|
|
||||||
public class CraftInventoryLlama extends CraftInventoryAbstractHorse implements LlamaInventory {
|
public class CraftInventoryLlama extends CraftInventoryAbstractHorse implements LlamaInventory {
|
||||||
|
|
||||||
// Paper start - properly combine both inventories
|
public CraftInventoryLlama(Container inventory, Container bodyArmorInventory, Container saddleInventory) {
|
||||||
public CraftInventoryLlama(Container inventory, Container bodyArmorInventory) {
|
super(inventory, bodyArmorInventory, saddleInventory);
|
||||||
super(inventory, bodyArmorInventory);
|
|
||||||
// Paper end - properly combine both inventories
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -5,10 +5,8 @@ import org.bukkit.inventory.SaddledHorseInventory;
|
|||||||
|
|
||||||
public class CraftSaddledInventory extends CraftInventoryAbstractHorse implements SaddledHorseInventory {
|
public class CraftSaddledInventory extends CraftInventoryAbstractHorse implements SaddledHorseInventory {
|
||||||
|
|
||||||
// Paper start - combine both inventories
|
public CraftSaddledInventory(Container inventory, final Container bodyArmorInventory, final Container saddleInventory) {
|
||||||
public CraftSaddledInventory(Container inventory, final Container bodyArmor) {
|
super(inventory, bodyArmorInventory, saddleInventory);
|
||||||
super(inventory, bodyArmor);
|
|
||||||
// Paper end - combine both inventories
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user