summaryrefslogtreecommitdiffstats
path: root/nms-patches/ContainerAnvil.patch
blob: 2c8d693f44b183702c19c14af03428f2c56da590 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--- /home/matt/mc-dev-private//net/minecraft/server/ContainerAnvil.java	2015-02-26 22:40:22.375608142 +0000
+++ src/main/java/net/minecraft/server/ContainerAnvil.java	2015-02-26 22:40:22.375608142 +0000
@@ -6,6 +6,8 @@
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+
 public class ContainerAnvil extends Container {
 
     private static final Logger f = LogManager.getLogger();
@@ -22,8 +24,13 @@
     private int k;
     private String l;
     private final EntityHuman m;
+    // CraftBukkit start
+    private CraftInventoryView bukkitEntity = null;
+    private PlayerInventory player;
+    // CraftBukkit end
 
     public ContainerAnvil(PlayerInventory playerinventory, final World world, final BlockPosition blockposition, EntityHuman entityhuman) {
+        this.player = playerinventory; // CraftBukkit
         this.j = blockposition;
         this.i = world;
         this.m = entityhuman;
@@ -317,6 +324,7 @@
     }
 
     public boolean a(EntityHuman entityhuman) {
+        if (!this.checkReachable) return true; // CraftBukkit
         return this.i.getType(this.j).getBlock() != Blocks.ANVIL ? false : entityhuman.e((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D;
     }
 
@@ -372,4 +380,17 @@
 
         this.e();
     }
+
+    // CraftBukkit start
+    @Override
+    public CraftInventoryView getBukkitView() {
+        if (bukkitEntity != null) {
+            return bukkitEntity;
+        }
+
+        org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil(this.h, this.g);
+        bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+        return bukkitEntity;
+    }
+    // CraftBukkit end
 }