summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockPortal.patch
blob: 4cae10f160559997ff902774be28dd16970b0fcd (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
--- ../work/decompile-8eb82bde//net/minecraft/server/BlockPortal.java	2014-11-28 17:43:42.933707439 +0000
+++ src/main/java/net/minecraft/server/BlockPortal.java	2014-11-28 17:38:18.000000000 +0000
@@ -2,6 +2,8 @@
 
 import java.util.Random;
 
+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit
+
 public class BlockPortal extends BlockHalfTransparent {
 
     public static final BlockStateEnum AXIS = BlockStateEnum.of("axis", EnumAxis.class, new EnumAxis[] { EnumAxis.X, EnumAxis.Z});
@@ -24,7 +26,8 @@
             }
 
             if (i > 0 && !world.getType(blockposition1.up()).getBlock().isOccluding()) {
-                Entity entity = ItemMonsterEgg.a(world, 57, (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D);
+                // CraftBukkit - set spawn reason to NETHER_PORTAL
+                Entity entity = ItemMonsterEgg.spawnCreature(world, 57, (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
 
                 if (entity != null) {
                     entity.portalCooldown = entity.ar();
@@ -66,14 +69,16 @@
         PortalCreator portalcreator = new PortalCreator(world, blockposition, EnumAxis.X);
 
         if (portalcreator.b() && PortalCreator.a(portalcreator) == 0) {
-            portalcreator.c();
-            return true;
+            // CraftBukkit start - return portalcreator
+            return portalcreator.c();
+            // return true;
         } else {
             PortalCreator portalcreator1 = new PortalCreator(world, blockposition, EnumAxis.Z);
 
             if (portalcreator1.b() && PortalCreator.a(portalcreator1) == 0) {
-                portalcreator1.c();
-                return true;
+                return portalcreator1.c();
+                // return true;
+                // CraftBukkit end
             } else {
                 return false;
             }
@@ -104,6 +109,10 @@
 
     public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
         if (entity.vehicle == null && entity.passenger == null) {
+            // CraftBukkit start - Entity in portal
+            EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+            world.getServer().getPluginManager().callEvent(event);
+            // CraftBukkit end
             entity.aq();
         }