2023-03-16 19:47:05 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
|
|
Date: Wed, 15 Mar 2023 18:29:45 -0700
|
2024-01-15 12:38:39 +01:00
|
|
|
Subject: [PATCH] Fix inventories returning null Locations
|
2023-03-16 19:47:05 +01:00
|
|
|
|
2023-08-21 06:49:29 +02:00
|
|
|
Wandering Trader, AbstractHorse, Beacon and Composter inventories returned null locations
|
2023-03-16 19:47:05 +01:00
|
|
|
when a block or entity location is readily available
|
|
|
|
|
2023-08-21 06:49:29 +02:00
|
|
|
Co-authored-by: Lukas Planz <lukas.planz@web.de>
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/SimpleContainer.java b/src/main/java/net/minecraft/world/SimpleContainer.java
|
2024-01-15 12:38:39 +01:00
|
|
|
index d5eeb2fcb119b815213aeffb3811d4a843502e50..ff1aba1e69cfde633fd01724f1a8d0af7f59437f 100644
|
2023-08-21 06:49:29 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/SimpleContainer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/SimpleContainer.java
|
|
|
|
@@ -63,6 +63,16 @@ public class SimpleContainer implements Container, StackedContentsCompatible {
|
2023-03-16 19:47:05 +01:00
|
|
|
|
2023-08-21 06:49:29 +02:00
|
|
|
@Override
|
|
|
|
public Location getLocation() {
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper start - Fix inventories returning null Locations
|
2023-08-21 06:49:29 +02:00
|
|
|
+ // When the block inventory does not have a tile state that implements getLocation, e. g. composters
|
|
|
|
+ if (this.bukkitOwner instanceof org.bukkit.inventory.BlockInventoryHolder blockInventoryHolder) {
|
|
|
|
+ return blockInventoryHolder.getBlock().getLocation();
|
|
|
|
+ }
|
|
|
|
+ // When the bukkit owner is a bukkit entity, but does not implement Container itself, e. g. horses
|
|
|
|
+ if (this.bukkitOwner instanceof org.bukkit.entity.Entity entity) {
|
|
|
|
+ return entity.getLocation();
|
|
|
|
+ }
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper end - Fix inventories returning null Locations
|
2023-08-21 06:49:29 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-03-16 19:47:05 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
|
2024-01-21 19:37:09 +01:00
|
|
|
index de919d72e6e3ef160c7d22ca6a4e9f79a1fe493e..86199457586dc4d4f0d8ccaac812e8340aaac957 100644
|
2023-03-16 19:47:05 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
|
2023-09-22 18:11:35 +02:00
|
|
|
@@ -51,6 +51,12 @@ public class BeaconMenu extends AbstractContainerMenu {
|
2023-03-16 19:47:05 +01:00
|
|
|
public int getMaxStackSize() {
|
|
|
|
return 1;
|
|
|
|
}
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper start - Fix inventories returning null Locations
|
2023-03-16 19:47:05 +01:00
|
|
|
+ @Override
|
|
|
|
+ public org.bukkit.Location getLocation() {
|
|
|
|
+ return context.getLocation();
|
|
|
|
+ }
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper end - Fix inventories returning null Locations
|
2023-03-16 19:47:05 +01:00
|
|
|
};
|
|
|
|
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
|
2024-01-15 12:38:39 +01:00
|
|
|
index 083e50e27685f441ede4c75e913d671fe45d1d15..ac4ec7157cf93b0cbc4472dc42fbbbff3402335a 100644
|
2023-03-16 19:47:05 +01:00
|
|
|
--- 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;
|
2024-01-15 12:38:39 +01:00
|
|
|
+ return (this.merchant instanceof AbstractVillager) ? ((AbstractVillager) this.merchant).getBukkitEntity().getLocation() : null; // Paper - Fix inventories returning null Locations
|
2023-03-16 19:47:05 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|