Commits

Phoenix616 authored and md_5 committed 1e76d09fad5
#724: Re-implement player portal event search radius and creation API

This also fixes that the nether/end portals would be created even if the event was cancelled as well as that the EntityPortalEvent would be called for player portal usage which is not according to its API specification
No tags

nms-patches/BlockPortalShape.patch

Modified
1 1 --- a/net/minecraft/server/BlockPortalShape.java
2 2 +++ b/net/minecraft/server/BlockPortalShape.java
3 3 @@ -4,6 +4,13 @@
4 4 import java.util.function.Predicate;
5 5 import javax.annotation.Nullable;
6 6
7 7 +// CraftBukkit start
8 8 +import org.bukkit.craftbukkit.block.CraftBlock;
9 9 +import org.bukkit.craftbukkit.block.CraftBlockState;
10 -+import org.bukkit.event.entity.EntityPortalEnterEvent;
10 ++import org.bukkit.craftbukkit.event.CraftPortalEvent;
11 11 +import org.bukkit.event.world.PortalCreateEvent;
12 12 +// CraftBukkit end
13 13 +
14 14 public class BlockPortalShape {
15 15
16 16 private static final BlockBase.e a = (iblockdata, iblockaccess, blockposition) -> {
17 17 @@ -17,6 +24,7 @@
18 18 private BlockPosition position;
19 19 private int height;
20 20 private int width;
55 55 + return false;
56 56 + }
57 57 + // CraftBukkit end
58 58 + BlockPosition.a(this.position, this.position.shift(EnumDirection.UP, this.height - 1).shift(this.d, this.width - 1)).forEach((blockposition) -> {
59 59 this.b.setTypeAndData(blockposition, iblockdata, 18);
60 60 });
61 61 + return true; // CraftBukkit
62 62 }
63 63
64 64 public boolean c() {
65 +@@ -194,7 +221,7 @@
66 + return new Vec3D(d2, d3, d4);
67 + }
68 +
69 +- public static ShapeDetectorShape a(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, EntitySize entitysize, Vec3D vec3d1, float f, float f1) {
70 ++ public static ShapeDetectorShape a(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, EntitySize entitysize, Vec3D vec3d1, float f, float f1, CraftPortalEvent portalEventInfo) { // CraftBukkit // PAIL rename toDetectorShape
71 + BlockPosition blockposition = blockutil_rectangle.origin;
72 + IBlockData iblockdata = worldserver.getType(blockposition);
73 + EnumDirection.EnumAxis enumdirection_enumaxis1 = (EnumDirection.EnumAxis) iblockdata.get(BlockProperties.E);
65 74 @@ -208,6 +235,6 @@
66 75 boolean flag = enumdirection_enumaxis1 == EnumDirection.EnumAxis.X;
67 76 Vec3D vec3d3 = new Vec3D((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2));
68 77
69 78 - return new ShapeDetectorShape(vec3d3, vec3d2, f + (float) i, f1);
70 -+ return new ShapeDetectorShape(vec3d3, vec3d2, f + (float) i, f1, worldserver); // CraftBukkit
79 ++ return new ShapeDetectorShape(vec3d3, vec3d2, f + (float) i, f1, worldserver, portalEventInfo); // CraftBukkit
71 80 }
72 81 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut