Skip to content

Commit 1e67ca8

Browse files
Doc94jpenilla
andauthored
Add SpawnReason for REANIMATE a Copper Golem Statue (#13126)
Co-authored-by: Jason Penilla <[email protected]>
1 parent 7845cba commit 1e67ca8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ public enum SpawnReason {
226226
* {@link org.bukkit.potion.PotionType#OOZING}, {@link org.bukkit.potion.PotionType#INFESTED}
227227
*/
228228
POTION_EFFECT,
229+
/**
230+
* When a Copper Golem Statue turns back into a Copper Golem
231+
*
232+
* @apiNote Canceling a {@link CreatureSpawnEvent} with this reason does not prevent the statue block from being removed, use {@link EntityChangeBlockEvent} to account for all side effects
233+
*/
234+
REANIMATE,
229235
/**
230236
* When a creature is spawned by being rehydrated
231237
*/

paper-server/patches/sources/net/minecraft/world/level/block/WeatheringCopperGolemStatueBlock.java.patch

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
CopperGolem copperGolem = copperGolemStatueBlockEntity.removeStatue(state);
1414
- stack.hurtAndBreak(1, player, hand.asEquipmentSlot());
1515
if (copperGolem != null) {
16-
+ // Paper start - call EntityChangeBlockEvent
16+
- level.addFreshEntity(copperGolem);
17+
- level.removeBlock(pos, false);
18+
+ // Paper start - call EntityChangeBlockEvent and spawnReason
1719
+ BlockState newState = level.getFluidState(pos).createLegacyBlock();
1820
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, newState)) {
1921
+ return InteractionResult.PASS;
2022
+ }
2123
+ stack.hurtAndBreak(1, player, hand.asEquipmentSlot()); // Paper - moved after event
22-
level.addFreshEntity(copperGolem);
23-
- level.removeBlock(pos, false);
24+
+ level.addFreshEntity(copperGolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.REANIMATE); // Paper - add SpawnReason
2425
+ level.setBlock(pos, newState, 3);
25-
+ // Paper end - call EntityChangeBlockEvent
26+
+ // Paper end - call EntityChangeBlockEvent and spawnReason
2627
return InteractionResult.SUCCESS;
2728
}
2829
}

0 commit comments

Comments
 (0)