Fix inventories returning null Locations

Wandering Trader, AbstractHorse, Beacon and Composter inventories returned null locations
when a block or entity location is readily available

Co-authored-by: Lukas Planz <lukas.planz@web.de>
This commit is contained in:
Jake Potrebic
2023-03-15 18:29:45 -07:00
parent 7139479d40
commit 6e271dc9e4
3 changed files with 30 additions and 7 deletions

View File

@@ -35,7 +35,20 @@
@Override
public boolean canPlaceItem(int slot, ItemStack stack) {
return stack.is(ItemTags.BEACON_PAYMENT_ITEMS);
@@ -69,6 +77,7 @@
@@ -44,6 +52,12 @@
public int getMaxStackSize() {
return 1;
}
+ // Paper start - Fix inventories returning null Locations
+ @Override
+ public org.bukkit.Location getLocation() {
+ return context.getLocation();
+ }
+ // Paper end - Fix inventories returning null Locations
};
checkContainerDataCount(propertyDelegate, 3);
this.beaconData = propertyDelegate;
@@ -69,6 +83,7 @@
@Override
public boolean stillValid(Player player) {
@@ -43,7 +56,7 @@
return stillValid(this.access, player, Blocks.BEACON);
}
@@ -148,12 +157,30 @@
@@ -148,12 +163,30 @@
return BeaconMenu.decodeEffect(this.beaconData.get(2));
}
@@ -76,7 +89,7 @@
}
}
@@ -178,4 +205,17 @@
@@ -178,4 +211,17 @@
return 1;
}
}

View File

@@ -61,7 +61,7 @@
+
+ @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 - Fix inventories returning null Locations
+ }
+ // CraftBukkit end
+