mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 03:55:14 +01:00
Fix Inventory#getLocation not working for the composter (#9596)
This commit is contained in:
parent
d12916255a
commit
67a1a8caf8
@ -3,30 +3,32 @@ From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|||||||
Date: Wed, 15 Mar 2023 18:29:45 -0700
|
Date: Wed, 15 Mar 2023 18:29:45 -0700
|
||||||
Subject: [PATCH] Fix certain inventories returning null Locations
|
Subject: [PATCH] Fix certain inventories returning null Locations
|
||||||
|
|
||||||
Wandering Trader, AbstractHorse, and Beacon inventories returned null locations
|
Wandering Trader, AbstractHorse, Beacon and Composter inventories returned null locations
|
||||||
when a block or entity location is readily available
|
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
|
Co-authored-by: Lukas Planz <lukas.planz@web.de>
|
||||||
index 49d7109b6ca63c8073db777549a65b2fcb70967e..9b35a50eb99551f28d45fd5114e0401b4c54646e 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
diff --git a/src/main/java/net/minecraft/world/SimpleContainer.java b/src/main/java/net/minecraft/world/SimpleContainer.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
index e938e46a142f3764f8224a1fd035e7d541b59c56..9d1ee40456a8d7001eee654a62e62cab2626305a 100644
|
||||||
@@ -345,7 +345,15 @@ public abstract class AbstractHorse extends Animal implements ContainerListener,
|
--- a/src/main/java/net/minecraft/world/SimpleContainer.java
|
||||||
public void createInventory() {
|
+++ b/src/main/java/net/minecraft/world/SimpleContainer.java
|
||||||
SimpleContainer inventorysubcontainer = this.inventory;
|
@@ -63,6 +63,16 @@ public class SimpleContainer implements Container, StackedContentsCompatible {
|
||||||
|
|
||||||
- this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()) // CraftBukkit
|
+ // 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) {
|
||||||
+ @Override
|
+ return blockInventoryHolder.getBlock().getLocation();
|
||||||
+ public org.bukkit.Location getLocation() {
|
+ }
|
||||||
+ return AbstractHorse.this.getBukkitEntity().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();
|
||||||
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
if (inventorysubcontainer != null) {
|
return 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
|
diff --git a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
|
||||||
index 335d0a85378c04dd466fafd42048b2474c815cb9..fb1d71143a0344432af9dc5c3085e217a2778f10 100644
|
index 335d0a85378c04dd466fafd42048b2474c815cb9..fb1d71143a0344432af9dc5c3085e217a2778f10 100644
|
||||||
--- a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
|
--- a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
|
||||||
|
Loading…
Reference in New Issue
Block a user