From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 15 Mar 2023 18:29:45 -0700 Subject: [PATCH] Fix certain inventories returning null Locations Wandering Trader, AbstractHorse, and Beacon inventories returned null locations when a block or entity location is readily available diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java index f9496f757bcf7000fab1f16386e775d54d96e47a..47cd69f91bbc2e2be9ec970674adc522e21593c8 100644 --- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java @@ -346,7 +346,15 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, public void createInventory() { SimpleContainer inventorysubcontainer = this.inventory; - this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit + // Paper start + this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()) // CraftBukkit + { + @Override + public org.bukkit.Location getLocation() { + return AbstractHorse.this.getBukkitEntity().getLocation(); + } + }; + // Paper end if (inventorysubcontainer != null) { inventorysubcontainer.removeListener(this); int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize()); diff --git a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java index 1ffbb43bfdb173689fdd9d2398b021846e0246fa..e56ddc7983f58f5b7634b8a6efbb67fa64703ab7 100644 --- a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java +++ b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java @@ -49,6 +49,12 @@ public class BeaconMenu extends AbstractContainerMenu { public int getMaxStackSize() { return 1; } + // Paper start + @Override + public org.bukkit.Location getLocation() { + return context.getLocation(); + } + // Paper end }; checkContainerDataCount(propertyDelegate, 3); this.beaconData = propertyDelegate; diff --git a/src/main/java/net/minecraft/world/inventory/MerchantContainer.java b/src/main/java/net/minecraft/world/inventory/MerchantContainer.java index 083e50e27685f441ede4c75e913d671fe45d1d15..98cbcf67d8fdb1c80fb7ba8ba7734821e2818da6 100644 --- a/src/main/java/net/minecraft/world/inventory/MerchantContainer.java +++ b/src/main/java/net/minecraft/world/inventory/MerchantContainer.java @@ -65,7 +65,7 @@ public class MerchantContainer implements Container { @Override public Location getLocation() { - return (this.merchant instanceof Villager) ? ((Villager) this.merchant).getBukkitEntity().getLocation() : null; + return (this.merchant instanceof AbstractVillager) ? ((AbstractVillager) this.merchant).getBukkitEntity().getLocation() : null; // Paper } // CraftBukkit end