Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public enum CreateReason {
* When the target end platform is created as a result of a player
* entering an end portal.
*/
END_PLATFORM
END_PLATFORM,
/**
* When the blocks inside an end portal are created due to an end portal
* frame being completed with all ender eyes.
*/
ENDER_EYE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@
Block.pushEntitiesUp(targetState, newState, level, pos);
level.setBlock(pos, newState, Block.UPDATE_CLIENTS);
level.updateNeighbourForOutputSignal(pos, Blocks.END_PORTAL_FRAME);
@@ -56,6 +_,23 @@
if (match != null) {
BlockPos blockPos = match.getFrontTopLeft().offset(-3, 0, -3);

+ // Paper start - Trigger PortalCreateEvent on end portal creation
+ org.bukkit.craftbukkit.util.BlockStateListPopulator populator = new org.bukkit.craftbukkit.util.BlockStateListPopulator(level.getMinecraftWorld());
+ // Copy below for loop

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you can just replace the destroyBlock/setBlock using BlockStateListPopulator like the other clases rather than copy the logic because are still called later

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I took that from PortalShape L203, where the other portal event is located, which copies the forEach from below.
I'll look at other usages of BlockStateListPopulator, since I only saw that one to make this commit. I'll make another commit once I'm done.

+ for (int x = 0; x < 3; x++) {
+ for (int z = 0; z < 3; z++) {
+ BlockPos portalBlockPos = blockPos.offset(x, 0, z);
+ populator.setBlock(portalBlockPos, Blocks.END_PORTAL.defaultBlockState(), Block.UPDATE_CLIENTS);
+ }
+ }
+ Player portalCreator = context.getPlayer();
+ org.bukkit.World bworld = level.getMinecraftWorld().getWorld();
+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) populator.getSnapshotBlocks(), bworld, (portalCreator == null) ? null : portalCreator.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.ENDER_EYE);
+ if (!event.callEvent()) {
+ return InteractionResult.PASS;
+ }
+ // Paper end - Trigger PortalCreateEvent on end portal creation
for (int x = 0; x < 3; x++) {
for (int z = 0; z < 3; z++) {
BlockPos portalBlockPos = blockPos.offset(x, 0, z);
@@ -64,7 +_,27 @@
}
}
Expand Down
Loading