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

By: Miles Holder <mwholder@proton.me>
This commit is contained in:
CraftBukkit/Spigot 2024-09-27 12:57:36 +10:00
parent 2c7ce2505b
commit 08fdfd6434

View file

@ -27,7 +27,7 @@
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
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);
Block block = k == -1 ? Blocks.OBSIDIAN : Blocks.AIR;
@ -47,19 +47,22 @@
}
}
+ // CraftBukkit start
+ if (entity == null) {
+ // SPIGOT-7746: Entity will only be null during world generation, which is async, so just generate without event
+ blockList.updateList();
+ return;
+ // SPIGOT-7746: Entity will only be null during world generation, which is async, so just generate without event
+ if (entity != null) {
+ org.bukkit.World bworld = worldaccess.getLevel().getWorld();
+ 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();
+ 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()) {
+ blockList.updateList();
+ // SPIGOT-7856: End platform not dropping items after replacing blocks
+ if (flag) {
+ blockList.getList().forEach((state) -> worldaccess.destroyBlock(state.getPosition(), true, null));
+ }
+ blockList.updateList();
+ // CraftBukkit end
}