mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-30 19:40:37 +01:00
Fix Inventory#getLocation not working for the composter (#9596)
This commit is contained in:
parent
7e6bdb92a4
commit
a2846ba80b
1 changed files with 20 additions and 18 deletions
|
@ -3,30 +3,32 @@ From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|||
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
|
||||
Wandering Trader, AbstractHorse, Beacon and Composter 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
|
||||
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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
|
||||
@@ -0,0 +0,0 @@ public abstract class AbstractHorse extends Animal implements ContainerListener,
|
||||
public void createInventory() {
|
||||
SimpleContainer inventorysubcontainer = this.inventory;
|
||||
--- a/src/main/java/net/minecraft/world/SimpleContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/SimpleContainer.java
|
||||
@@ -0,0 +0,0 @@ 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
|
||||
+ this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()) // CraftBukkit
|
||||
+ {
|
||||
+ @Override
|
||||
+ public org.bukkit.Location getLocation() {
|
||||
+ return AbstractHorse.this.getBukkitEntity().getLocation();
|
||||
+ }
|
||||
+ };
|
||||
+ // 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();
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (inventorysubcontainer != null) {
|
||||
inventorysubcontainer.removeListener(this);
|
||||
int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize());
|
||||
return null;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
|
||||
|
|
Loading…
Add table
Reference in a new issue