diff --git a/patches/api/0028-Add-EntityPortalReadyEvent.patch b/patches/api/0028-Add-EntityPortalReadyEvent.patch new file mode 100644 index 000000000..2b057b6c5 --- /dev/null +++ b/patches/api/0028-Add-EntityPortalReadyEvent.patch @@ -0,0 +1,59 @@ +From 4caa1b9ad55df3d7d832905898fd2866d9871f13 Mon Sep 17 00:00:00 2001 +From: William Blake Galbreath +Date: Sat, 11 Jan 2020 23:12:00 -0600 +Subject: [PATCH] Add EntityPortalReadyEvent + +--- + .../event/entity/EntityPortalReadyEvent.java | 40 +++++++++++++++++++ + 1 file changed, 40 insertions(+) + create mode 100644 src/main/java/net/pl3x/purpur/event/entity/EntityPortalReadyEvent.java + +diff --git a/src/main/java/net/pl3x/purpur/event/entity/EntityPortalReadyEvent.java b/src/main/java/net/pl3x/purpur/event/entity/EntityPortalReadyEvent.java +new file mode 100644 +index 000000000..37f11c104 +--- /dev/null ++++ b/src/main/java/net/pl3x/purpur/event/entity/EntityPortalReadyEvent.java +@@ -0,0 +1,40 @@ ++package net.pl3x.purpur.event.entity; ++ ++import org.bukkit.entity.Entity; ++import org.bukkit.event.Cancellable; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.NotNull; ++ ++/** ++ * Called when an entity is ready to travel through a portal ++ */ ++public class EntityPortalReadyEvent extends EntityEvent implements Cancellable { ++ private static final HandlerList handlers = new HandlerList(); ++ private boolean cancelled = false; ++ ++ public EntityPortalReadyEvent(@NotNull Entity entity) { ++ super(entity); ++ } ++ ++ @Override ++ public boolean isCancelled() { ++ return cancelled; ++ } ++ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +-- +2.24.0 + diff --git a/patches/server/0100-Add-EntityPortalReadyEvent.patch b/patches/server/0100-Add-EntityPortalReadyEvent.patch new file mode 100644 index 000000000..f764494d1 --- /dev/null +++ b/patches/server/0100-Add-EntityPortalReadyEvent.patch @@ -0,0 +1,158 @@ +From 28c39c0411f3142b5be8737704637f3bc95980ed Mon Sep 17 00:00:00 2001 +From: William Blake Galbreath +Date: Sat, 11 Jan 2020 23:12:52 -0600 +Subject: [PATCH] Add EntityPortalReadyEvent + +--- + .../java/net/minecraft/server/BlockPortal.java | 16 +++++++++------- + src/main/java/net/minecraft/server/Entity.java | 7 ++++--- + .../net/minecraft/server/PortalTravelAgent.java | 5 +++-- + .../java/net/minecraft/server/WorldServer.java | 2 +- + 4 files changed, 17 insertions(+), 13 deletions(-) + +diff --git a/src/main/java/net/minecraft/server/BlockPortal.java b/src/main/java/net/minecraft/server/BlockPortal.java +index 2dc3ab4cfa..1c0df77c2b 100644 +--- a/src/main/java/net/minecraft/server/BlockPortal.java ++++ b/src/main/java/net/minecraft/server/BlockPortal.java +@@ -52,6 +52,7 @@ public class BlockPortal extends Block { + + } + ++ public boolean createPortal(GeneratorAccess generatoraccess, BlockPosition blockposition) { return a(generatoraccess, blockposition); } // Purpur - OBFHELPER + public boolean a(GeneratorAccess generatoraccess, BlockPosition blockposition) { + BlockPortal.Shape blockportal_shape = this.b(generatoraccess, blockposition); + +@@ -65,8 +66,8 @@ public class BlockPortal extends Block { + } + } + +- @Nullable +- public BlockPortal.Shape b(GeneratorAccess generatoraccess, BlockPosition blockposition) { ++ public BlockPortal.Shape createShape(GeneratorAccess generatoraccess, BlockPosition blockposition) { return b(generatoraccess, blockposition); } // Purpur - OBFHELPER ++ @Nullable public BlockPortal.Shape b(GeneratorAccess generatoraccess, BlockPosition blockposition) { + BlockPortal.Shape blockportal_shape = new BlockPortal.Shape(generatoraccess, blockposition, EnumDirection.EnumAxis.X); + + if (blockportal_shape.d() && blockportal_shape.e == 0) { +@@ -187,6 +188,7 @@ public class BlockPortal extends Block { + private int height; + private int width; + java.util.List blocks = new java.util.ArrayList(); // CraftBukkit - add field ++ public static Block FRAME_BLOCK = Blocks.OBSIDIAN; // Purpur + + public Shape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { + this.a = generatoraccess; +@@ -226,14 +228,14 @@ public class BlockPortal extends Block { + for (i = 0; i < 22; ++i) { + BlockPosition blockposition1 = blockposition.shift(enumdirection, i); + +- if (!this.a(this.a.getType(blockposition1)) || this.a.getType(blockposition1.down()).getBlock() != Blocks.OBSIDIAN) { ++ if (!this.a(this.a.getType(blockposition1)) || this.a.getType(blockposition1.down()).getBlock() != FRAME_BLOCK) { // Purpur + break; + } + } + + Block block = this.a.getType(blockposition.shift(enumdirection, i)).getBlock(); + +- return block == Blocks.OBSIDIAN ? i : 0; ++ return block == FRAME_BLOCK ? i : 0; // Purpur + } + + public int a() { +@@ -268,7 +270,7 @@ public class BlockPortal extends Block { + + if (i == 0) { + block = this.a.getType(blockposition.shift(this.d)).getBlock(); +- if (block != Blocks.OBSIDIAN) { ++ if (block != FRAME_BLOCK) { // Purpur + break label56; + // CraftBukkit start - add the block to our list + } else { +@@ -278,7 +280,7 @@ public class BlockPortal extends Block { + } + } else if (i == this.width - 1) { + block = this.a.getType(blockposition.shift(this.c)).getBlock(); +- if (block != Blocks.OBSIDIAN) { ++ if (block != FRAME_BLOCK) { // Purpur + break label56; + // CraftBukkit start - add the block to our list + } else { +@@ -291,7 +293,7 @@ public class BlockPortal extends Block { + } + + for (i = 0; i < this.width; ++i) { +- if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) { ++ if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != FRAME_BLOCK) { // Purpur + this.height = 0; + break; + // CraftBukkit start - add the block to our list +diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java +index 5e99ad8144..42590e2977 100644 +--- a/src/main/java/net/minecraft/server/Entity.java ++++ b/src/main/java/net/minecraft/server/Entity.java +@@ -171,9 +171,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + protected boolean af; public final boolean inPortal() { return this.af; } // Paper - OBFHELPER + protected int ag; + public DimensionManager dimension; +- protected BlockPosition ai; +- protected Vec3D aj; +- protected EnumDirection ak; ++ public BlockPosition ai; // Purpur - protected -> public ++ public Vec3D aj; // Purpur - protected -> public ++ public EnumDirection ak; // Purpur - protected -> public + private boolean invulnerable; + protected UUID uniqueID; + protected String am; +@@ -2215,6 +2215,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + this.world.getMethodProfiler().enter("portal"); + this.ag = i; + this.portalCooldown = this.ba(); ++ if (new net.pl3x.purpur.event.entity.EntityPortalReadyEvent(getBukkitEntity()).callEvent()) // Purpur + // CraftBukkit start + if (this instanceof EntityPlayer) { + ((EntityPlayer) this).a(this.world.worldProvider.getDimensionManager().getType() == DimensionManager.NETHER ? DimensionManager.OVERWORLD : DimensionManager.NETHER, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); +diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java +index 25b694e7df..3712a0410f 100644 +--- a/src/main/java/net/minecraft/server/PortalTravelAgent.java ++++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java +@@ -11,6 +11,7 @@ public class PortalTravelAgent { + + private final WorldServer world; + private final Random b; ++ public Block FRAME_BLOCK = Blocks.OBSIDIAN; // Purpur + + public PortalTravelAgent(WorldServer worldserver) { + this.world = worldserver; +@@ -211,7 +212,7 @@ public class PortalTravelAgent { + boolean flag1 = l2 < 0; + + blockposition_mutableblockposition.d(j3, l3, i4); +- blockList.setTypeAndData(blockposition_mutableblockposition, flag1 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData(), 3); // CraftBukkit ++ blockList.setTypeAndData(blockposition_mutableblockposition, flag1 ? FRAME_BLOCK.getBlockData() : Blocks.AIR.getBlockData(), 3); // CraftBukkit // Purpur + } + } + } +@@ -221,7 +222,7 @@ public class PortalTravelAgent { + for (i3 = -1; i3 < 4; ++i3) { + if (k2 == -1 || k2 == 2 || i3 == -1 || i3 == 3) { + blockposition_mutableblockposition.d(i5 + k2 * k5, j5 + i3, j2 + k2 * l5); +- blockList.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3); // CraftBukkit ++ blockList.setTypeAndData(blockposition_mutableblockposition, FRAME_BLOCK.getBlockData(), 3); // CraftBukkit // Purpur + } + } + } +diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java +index 8ae7b7784c..accf6a730e 100644 +--- a/src/main/java/net/minecraft/server/WorldServer.java ++++ b/src/main/java/net/minecraft/server/WorldServer.java +@@ -65,7 +65,7 @@ public class WorldServer extends World { + public boolean savingDisabled; + private boolean C; + private int emptyTime; +- private final PortalTravelAgent portalTravelAgent; ++ public PortalTravelAgent portalTravelAgent; // Purpur - private final -> public non-final + private final TickListServer nextTickListBlock; + private final TickListServer nextTickListFluid; + private final Set navigators; +-- +2.24.0 +