SPIGOT-7856, #1483: End platform not dropping items after replacing blocks

This commit is contained in:
Miles Holder 2024-09-27 12:57:36 +10:00 committed by md_5
parent 2a5572b52b
commit c7d6428f28
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -27,7 +27,7 @@
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
for (int i = -2; i <= 2; ++i) { for (int i = -2; i <= 2; ++i) {
@@ -29,16 +42,33 @@ @@ -29,16 +42,36 @@
BlockPosition.MutableBlockPosition blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(blockposition).move(j, k, i); BlockPosition.MutableBlockPosition blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(blockposition).move(j, k, i);
Block block = k == -1 ? Blocks.OBSIDIAN : Blocks.AIR; Block block = k == -1 ? Blocks.OBSIDIAN : Blocks.AIR;
@ -47,19 +47,22 @@
} }
} }
+ // CraftBukkit start + // CraftBukkit start
+ if (entity == null) { + // SPIGOT-7746: Entity will only be null during world generation, which is async, so just generate without event
+ // SPIGOT-7746: Entity will only be null during world generation, which is async, so just generate without event + if (entity != null) {
+ blockList.updateList(); + org.bukkit.World bworld = worldaccess.getLevel().getWorld();
+ return; + PortalCreateEvent portalEvent = new PortalCreateEvent((List<BlockState>) (List) blockList.getList(), bworld, entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM);
+
+ worldaccess.getLevel().getCraftServer().getPluginManager().callEvent(portalEvent);
+ if (portalEvent.isCancelled()) {
+ return;
+ }
+ } + }
+ +
+ org.bukkit.World bworld = worldaccess.getLevel().getWorld(); + // SPIGOT-7856: End platform not dropping items after replacing blocks
+ PortalCreateEvent portalEvent = new PortalCreateEvent((List<BlockState>) (List) blockList.getList(), bworld, entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); + if (flag) {
+ + blockList.getList().forEach((state) -> worldaccess.destroyBlock(state.getPosition(), true, null));
+ worldaccess.getLevel().getCraftServer().getPluginManager().callEvent(portalEvent);
+ if (!portalEvent.isCancelled()) {
+ blockList.updateList();
+ } + }
+ blockList.updateList();
+ // CraftBukkit end + // CraftBukkit end
} }