#1433: HumanEntity#openInventory(InventoryView) should only support views belonging to the player

This commit is contained in:
Miles Holder 2024-06-22 18:48:51 +10:00 committed by md_5
parent 764a541c5b
commit ab29122cf1
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -371,6 +371,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override @Override
public void openInventory(InventoryView inventory) { public void openInventory(InventoryView inventory) {
Preconditions.checkArgument(this.equals(inventory.getPlayer()), "InventoryView must belong to the opening player");
if (!(getHandle() instanceof EntityPlayer)) return; // TODO: NPC support? if (!(getHandle() instanceof EntityPlayer)) return; // TODO: NPC support?
if (((EntityPlayer) getHandle()).connection == null) return; if (((EntityPlayer) getHandle()).connection == null) return;
if (getHandle().containerMenu != getHandle().inventoryMenu) { if (getHandle().containerMenu != getHandle().inventoryMenu) {