aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0411-Add-additional-open-container-api-to-HumanEntity.patch
diff options
context:
space:
mode:
authorSpottedleaf <[email protected]>2024-07-17 10:24:53 -0700
committerSpottedleaf <[email protected]>2024-07-17 10:28:32 -0700
commit00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6 (patch)
tree82639515bc5e9ae00c1e639e72137ed51e1ac688 /patches/server/0411-Add-additional-open-container-api-to-HumanEntity.patch
parent967f98aa81da851740aeb429778e46159fd188df (diff)
downloadPaper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.tar.gz
Paper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.zip
Remove Moonrise utils to MCUtils, remove duplicated/unused utils
Diffstat (limited to 'patches/server/0411-Add-additional-open-container-api-to-HumanEntity.patch')
-rw-r--r--patches/server/0411-Add-additional-open-container-api-to-HumanEntity.patch83
1 files changed, 83 insertions, 0 deletions
diff --git a/patches/server/0411-Add-additional-open-container-api-to-HumanEntity.patch b/patches/server/0411-Add-additional-open-container-api-to-HumanEntity.patch
new file mode 100644
index 0000000000..be29dd6b1c
--- /dev/null
+++ b/patches/server/0411-Add-additional-open-container-api-to-HumanEntity.patch
@@ -0,0 +1,83 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: JRoy <[email protected]>
+Date: Wed, 26 Aug 2020 02:12:31 -0400
+Subject: [PATCH] Add additional open container api to HumanEntity
+
+== AT ==
+public net/minecraft/world/level/block/state/BlockBehaviour getMenuProvider(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/MenuProvider;
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+index 084938fa2ffa7ee462766bf03f8e2b4c0fd4bf6b..8f4c4fed41676157b717c20a5ccbfe6ad4bdb3c4 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+@@ -463,6 +463,70 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
+ return this.getHandle().containerMenu.getBukkitView();
+ }
+
++ // Paper start - Add additional containers
++ @Override
++ public InventoryView openAnvil(Location location, boolean force) {
++ return this.openInventory(location, force, Material.ANVIL);
++ }
++
++ @Override
++ public InventoryView openCartographyTable(Location location, boolean force) {
++ return this.openInventory(location, force, Material.CARTOGRAPHY_TABLE);
++ }
++
++ @Override
++ public InventoryView openGrindstone(Location location, boolean force) {
++ return this.openInventory(location, force, Material.GRINDSTONE);
++ }
++
++ @Override
++ public InventoryView openLoom(Location location, boolean force) {
++ return this.openInventory(location, force, Material.LOOM);
++ }
++
++ @Override
++ public InventoryView openSmithingTable(Location location, boolean force) {
++ return this.openInventory(location, force, Material.SMITHING_TABLE);
++ }
++
++ @Override
++ public InventoryView openStonecutter(Location location, boolean force) {
++ return this.openInventory(location, force, Material.STONECUTTER);
++ }
++
++ private InventoryView openInventory(Location location, boolean force, Material material) {
++ org.spigotmc.AsyncCatcher.catchOp("open" + material);
++ if (location == null) {
++ location = this.getLocation();
++ }
++ if (!force) {
++ Block block = location.getBlock();
++ if (block.getType() != material) {
++ return null;
++ }
++ }
++ net.minecraft.world.level.block.Block block;
++ 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);
++ }
++ this.getHandle().openMenu(block.getMenuProvider(null, this.getHandle().level(), new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ())));
++ this.getHandle().containerMenu.checkReachable = !force;
++ return this.getHandle().containerMenu.getBukkitView();
++ }
++ // Paper end
++
+ @Override
+ public void closeInventory() {
+ // Paper start - Inventory close reason