2020-08-26 08:30:08 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: JRoy <joshroy126@gmail.com>
|
|
|
|
Date: Wed, 26 Aug 2020 02:12:31 -0400
|
|
|
|
Subject: [PATCH] Add additional open container api to HumanEntity
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
2021-03-16 16:50:45 +01:00
|
|
|
index 92501a415813b3b0f2be492a4711962320264a76..b99423b3b413fc6364c6530a99e3c74dd406e1b4 100644
|
2020-08-26 08:30:08 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
2021-03-16 16:50:45 +01:00
|
|
|
@@ -458,6 +458,70 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
2020-08-26 08:30:08 +02:00
|
|
|
return this.getHandle().activeContainer.getBukkitView();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Add additional containers
|
|
|
|
+ @Override
|
|
|
|
+ public InventoryView openAnvil(Location location, boolean force) {
|
|
|
|
+ return openInventory(location, force, Material.ANVIL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public InventoryView openCartographyTable(Location location, boolean force) {
|
|
|
|
+ return openInventory(location, force, Material.CARTOGRAPHY_TABLE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public InventoryView openGrindstone(Location location, boolean force) {
|
|
|
|
+ return openInventory(location, force, Material.GRINDSTONE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public InventoryView openLoom(Location location, boolean force) {
|
|
|
|
+ return openInventory(location, force, Material.LOOM);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public InventoryView openSmithingTable(Location location, boolean force) {
|
|
|
|
+ return openInventory(location, force, Material.SMITHING_TABLE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public InventoryView openStonecutter(Location location, boolean force) {
|
|
|
|
+ return openInventory(location, force, Material.STONECUTTER);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private InventoryView openInventory(Location location, boolean force, Material material) {
|
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("open" + material);
|
|
|
|
+ if (location == null) {
|
|
|
|
+ location = getLocation();
|
|
|
|
+ }
|
|
|
|
+ if (!force) {
|
|
|
|
+ Block block = location.getBlock();
|
|
|
|
+ if (block.getType() != material) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
2021-03-16 16:50:45 +01:00
|
|
|
+ net.minecraft.world.level.block.Block block;
|
2020-08-26 08:30:08 +02:00
|
|
|
+ if (material == Material.ANVIL) {
|
|
|
|
+ block = Blocks.ANVIL;
|
|
|
|
+ } else if (material == Material.CARTOGRAPHY_TABLE) {
|
|
|
|
+ block = Blocks.CARTOGRAPHY_TABLE;
|
|
|
|
+ } else if (material == Material.GRINDSTONE) {
|
|
|
|
+ block = Blocks.GRINDSTONE;
|
|
|
|
+ } else if (material == Material.LOOM) {
|
|
|
|
+ block = Blocks.LOOM;
|
|
|
|
+ } else if (material == Material.SMITHING_TABLE) {
|
|
|
|
+ block = Blocks.SMITHING_TABLE;
|
|
|
|
+ } else if (material == Material.STONECUTTER) {
|
|
|
|
+ block = Blocks.STONECUTTER;
|
|
|
|
+ } else {
|
|
|
|
+ throw new IllegalArgumentException("Unsupported inventory type: " + material);
|
|
|
|
+ }
|
|
|
|
+ getHandle().openContainer(block.getInventory(null, getHandle().world, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())));
|
|
|
|
+ getHandle().activeContainer.checkReachable = !force;
|
|
|
|
+ return getHandle().activeContainer.getBukkitView();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void closeInventory() {
|
|
|
|
// Paper start
|