summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityEnderman.patch
blob: 95914e9110f177c9dea839f70e65e123e04e395f (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
52
53
54
55
56
57
58
59
60
61
62
--- /home/matt/mc-dev-private//net/minecraft/server/EntityEnderman.java	2015-02-26 22:40:22.519608140 +0000
+++ src/main/java/net/minecraft/server/EntityEnderman.java	2015-02-26 22:40:22.519608140 +0000
@@ -8,6 +8,12 @@
 import java.util.Set;
 import java.util.UUID;
 
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTeleportEvent;
+// CraftBukkit end
+
 public class EntityEnderman extends EntityMonster {
 
     private static final UUID a = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
@@ -177,7 +183,17 @@
             }
 
             if (flag1) {
-                super.enderTeleportTo(this.locX, this.locY, this.locZ);
+                // CraftBukkit start - Teleport event
+                // super.enderTeleportTo(this.locX, this.locY, this.locZ);
+                EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), this.locX, this.locY, this.locZ));
+                this.world.getServer().getPluginManager().callEvent(teleport);
+                if (teleport.isCancelled()) {
+                    return false;
+                }
+
+                Location to = teleport.getTo();
+                this.enderTeleportTo(to.getX(), to.getY(), to.getZ());
+                // CraftBukkit end
                 if (this.world.getCubes(this, this.getBoundingBox()).isEmpty() && !this.world.containsLiquid(this.getBoundingBox())) {
                     flag = true;
                 }
@@ -333,8 +349,12 @@
             Block block = iblockdata.getBlock();
 
             if (EntityEnderman.c.contains(block)) {
-                this.enderman.setCarried(iblockdata);
-                world.setTypeUpdate(blockposition, Blocks.AIR.getBlockData());
+                // CraftBukkit start - Pickup event
+                if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, this.enderman.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), org.bukkit.Material.AIR).isCancelled()) {
+                    this.enderman.setCarried(iblockdata);
+                    world.setTypeUpdate(blockposition, Blocks.AIR.getBlockData());
+                }
+                // CraftBukkit end
             }
 
         }
@@ -363,8 +383,12 @@
             Block block1 = world.getType(blockposition.down()).getBlock();
 
             if (this.a(world, blockposition, this.a.getCarried().getBlock(), block, block1)) {
+                // CraftBukkit start - Place event
+                if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.a.getCarried().getBlock(), this.a.getCarried().getBlock().toLegacyData(this.a.getCarried())).isCancelled()) {
                 world.setTypeAndData(blockposition, this.a.getCarried(), 3);
                 this.a.setCarried(Blocks.AIR.getBlockData());
+                }
+                // CraftBukkit end
             }
 
         }