Implement more methods for horse inventories (#11147)
This commit is contained in:
@@ -74,6 +74,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isEmpty() {
|
||||
+ return this.getMainInventory().isEmpty() && this.getArmorInventory().isEmpty();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack[] getContents() {
|
||||
+ ItemStack[] items = new ItemStack[this.getSize()];
|
||||
+
|
||||
+ items[net.minecraft.world.entity.animal.horse.AbstractHorse.INV_SLOT_SADDLE] = this.getSaddle();
|
||||
+ items[net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR] = this.getArmor();
|
||||
+
|
||||
+ for (int i = net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR + 1; i < items.length; i++) {
|
||||
+ net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(i - 1);
|
||||
+ items[i] = item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
|
||||
+ }
|
||||
+
|
||||
+ return items;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ 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());
|
||||
+
|
||||
+ this.setSaddle(org.apache.commons.lang3.ArrayUtils.get(items, net.minecraft.world.entity.animal.horse.AbstractHorse.INV_SLOT_SADDLE));
|
||||
+ this.setArmor(org.apache.commons.lang3.ArrayUtils.get(items, net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR));
|
||||
+
|
||||
+ for (int i = net.minecraft.world.inventory.HorseInventoryMenu.SLOT_BODY_ARMOR + 1; i < this.getSize(); 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);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @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);
|
||||
|
||||
Reference in New Issue
Block a user