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 @@ -226,6 +226,12 @@ public enum SpawnReason {
* {@link org.bukkit.potion.PotionType#OOZING}, {@link org.bukkit.potion.PotionType#INFESTED}
*/
POTION_EFFECT,
/**
* When a copper golem statue is turned back into a copper golem
*
* @apiNote Cancel an {@link CreatureSpawnEvent} with this reason not avoid the statue block to being change, you need to use {@link EntityChangeBlockEvent} for that
*/
REANIMATE,
/**
* When a creature is spawned by being rehydrated
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
CopperGolem copperGolem = copperGolemStatueBlockEntity.removeStatue(state);
- stack.hurtAndBreak(1, player, hand.asEquipmentSlot());
if (copperGolem != null) {
+ // Paper start - call EntityChangeBlockEvent
- level.addFreshEntity(copperGolem);
- level.removeBlock(pos, false);
+ // Paper start - call EntityChangeBlockEvent and spawnReason
+ BlockState newState = level.getFluidState(pos).createLegacyBlock();
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, newState)) {
+ return InteractionResult.PASS;
+ }
+ stack.hurtAndBreak(1, player, hand.asEquipmentSlot()); // Paper - moved after event
level.addFreshEntity(copperGolem);
- level.removeBlock(pos, false);
+ level.addFreshEntity(copperGolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.REANIMATE); // Paper - add SpawnReason
+ level.setBlock(pos, newState, 3);
+ // Paper end - call EntityChangeBlockEvent
+ // Paper end - call EntityChangeBlockEvent and spawnReason
return InteractionResult.SUCCESS;
}
}
Loading