Skip to content

[Bug] Server crash in SoundConfig due to missing null/validity check on ResourceLocation (PlayerRevive) #304

@XColorful

Description

@XColorful

Description

I have identified a critical issue in CreativeCore (specifically used by PlayerRevive) where the server crashes if the SoundConfig's ResourceLocation is empty or invalid. While an empty sound string might be saved as "minecraft:" in the config, the current implementation fails to validate the registry lookup, leading to a crash in specific death scenarios.

I am reporting this here because CreativeCore is a dependency for multiple mods, and this lack of validation in the premade SoundConfig class could affect any mod using it.

The Logic Issue

In team.creative.creativecore.common.config.premade.SoundConfig, the play method calls BuiltInRegistries.SOUND_EVENT.get(event) without checking if the result is null before passing it to playSound.

Steps to Reproduce / Test Results (Dedicated Server)

The crash is specifically tied to how the player dies.

Scenario Result
Player is killed by another player while downed Log spam (Error), but no crash
A player falls into the void, but manually "Gives Up" (Left-click/Self-terminate) Log spam (Error), but no crash
A player falls into the void and is killed by void damage NullPointerException (Crash)
Player dies automatically due to timeout while downed ServerHangWatchdog (Crash)

Config context:

Users might naturally leave the sound path empty or use an invalid string intending to "disable" the sound. While adding a boolean toggle or checking for empty strings is a common way to "turn off" a feature, the code should nonetheless perform a safety check to prevent a total server collapse.

Source Code Reference:

SoundConfig.java

public void play(Entity entity, SoundSource category) {
    // If 'event' is invalid/empty, get() returns null, causing NPE in playSound
    entity.level().playSound(null, entity, BuiltInRegistries.SOUND_EVENT.get(event), category, volume, pitch);
}

Crash Log excerpt

---- Minecraft Crash Report ----
// Who set us up the TNT?

Time: 2026-04-01 23:00:55
Description: Exception in server tick loop

java.lang.NullPointerException: Cannot invoke "net.minecraft.sounds.SoundEvent.m_215668_(float)" because the return value of "net.minecraft.core.Holder.m_203334_()" is null
	at net.minecraft.server.level.ServerLevel.m_213890_(ServerLevel.java:918) ~[server-1.20.1-20230612.114412-srg.jar%23151!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:cupboard.mixins.json:ServerAddEntityMixin,pl:mixin:APP:physicsmod.mixins.json:fabricapi.MixinServerWorld,pl:mixin:APP:modernfix-modernfix.mixins.json:perf.cache_strongholds.ServerLevelMixin,pl:mixin:APP:modernfix-modernfix.mixins.json:perf.faster_structure_location.ServerLevelMixin,pl:mixin:APP:starlight.mixins.json:common.world.ServerWorldMixin,pl:mixin:A}
	at net.minecraft.world.level.Level.m_6269_(Level.java:405) ~[server-1.20.1-20230612.114412-srg.jar%23151!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:starlight.mixins.json:common.world.LevelMixin,pl:mixin:A}
	at team.creative.creativecore.common.config.premade.SoundConfig.play(SoundConfig.java:26) ~[CreativeCore_FORGE_v2.12.35_mc1.20.1.jar%23129!/:2.12.35] {re:classloading}
	at team.creative.playerrevive.server.ReviveEventServer.playerDied(ReviveEventServer.java:173) ~[PlayerRevive_FORGE_v2.0.31_mc1.20.1.jar%23140!/:2.0.31] {re:classloading}
	at team.creative.playerrevive.server.__ReviveEventServer_playerDied_LivingDeathEvent.invoke(.dynamic) ~[PlayerRevive_FORGE_v2.0.31_mc1.20.1.jar%23140!/:2.0.31] {re:classloading,pl:eventbus:B}
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:55) ~[eventbus-6.2.33.jar%2352!/:?] {}

The crash report & ./config/playerrevive.json

crash-2026-04-01_23.00.55-server.txt
playerrevive.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions