Fix infinite fireworks (#11592) (#11594)

This commit is contained in:
Noah van der Aa 2024-11-08 12:29:40 +01:00
parent 60bed7385b
commit 02cdc61bbc

View file

@ -170,7 +170,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- itemStack.shrink(1);
+ // Paper start - PlayerLaunchProjectileEvent
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) context.getPlayer().getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.projectile().getBukkitEntity());
+ if (!event.callEvent() || fireworkRocketEntity.attemptSpawn()) return InteractionResult.PASS;
+ if (!event.callEvent() || !fireworkRocketEntity.attemptSpawn()) return InteractionResult.PASS;
+ if (event.shouldConsume() && !context.getPlayer().hasInfiniteMaterials()) itemStack.shrink(1);
+ else if (context.getPlayer() instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) context.getPlayer()).getBukkitEntity().updateInventory();
+ // Paper end - PlayerLaunchProjectileEvent