MineColonies

MineColonies

59M Downloads

[BUG] Error and Server Crash if Spawner block is broken before its SpawnData has been set

TigerWalts opened this issue ยท 0 comments

commented

Is there an existing issue for this?

  • I have searched the existing issues

Are you using the latest MineColonies Version?

  • I am running the latest beta version of MineColonies for my Minecraft version.

Did you check on the Wiki? or ask on Discord?

  • I checked the MineColonies Wiki and made sure my issue is not covered there. Or I was sent from discord to open an issue here.

What were you playing at the time? Were you able to reproduce it in both settings?

  • Single Player
  • Multi Player

Minecraft Version

1.20.1

MineColonies Version

1.20.1-1.1.647-beta

Structurize Version

1.20.1-1.0.742

Related Mods and their Versions

  • Forge - 47.3.0
  • BlockUI - 1.20.1-1.0.156
  • Domum Ornamentum - 1.20.1-1.0.186

Current Behavior

Single Player

Block breaks but is still there and invisible, will re-appear on a block update.
Error in the log file, but no crash:

java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.SpawnData.m_186567_()" because "net.minecraft.world.level.block.entity.SpawnerBlockEntity.m_59801_().f_45444_" is null
	at TRANSFORMER/[email protected]/com.minecolonies.core.event.EventHandler.onBlockBreak(EventHandler.java:607)
	at TRANSFORMER/[email protected]/com.minecolonies.core.event.__EventHandler_onBlockBreak_BreakEvent.invoke(.dynamic)
	at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73)
	at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:315)
	at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:296)
	at TRANSFORMER/[email protected]/net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(ForgeHooks.java:543)
	...

Multiplayer

Server Crash with the same error as in SP

Expected Behavior

No error, no crash.

Reproduction Steps

  1. Switch to Creative Mode
    This will allow you to break the spawner quick enough
  2. Give yourself an empty spawner
  3. Place the spawner and immediately break it

Logs

https://gist.github.com/TigerWalts/caf2450b1e24ad1819fdbe30fdd9074e

Anything else?

The crash happens because nextSpawnData here is null:

if (colony != null)
{
colony.getEventManager().onTileEntityBreak(((SpawnerBlockEntity) spawner).getSpawner().nextSpawnData.getEntityToSpawn().getInt(TAG_EVENT_ID), spawner);
}

nextSpawnData may be null for the first few ticks after the spawner is placed. I believe that this is set after being generated in an off thread task to avoid latency from spawn and loot table lookups.

In normal play a spawner being broken immediately after being placed is an incredibly low chance. However we had a player manage to do this by using a QuarryPlus quarry.


  • Add a thumbs-up to the bug report if you are also affected. This helps the bug report become more visible to the team and doesn't clutter the comments.
  • Add a comment if you have any insights or background information that isn't already part of the conversation.