Skip to content

Entity component containers are set at RETURN #220

@TropheusJ

Description

@TropheusJ

Relevant code

It's possible for components to be queried during entity construction, which can cause a very weird NPE:

[16:26:48] [Server thread/ERROR] (Minecraft) Couldn't place player in world
 java.lang.NullPointerException: Cannot invoke "dev.onyxstudios.cca._generated_.GeneratedComponentContainer.get$enchancement$frozen()" because "<parameter1>" is null
	at dev.onyxstudios.cca._generated_.ComponentType$enchancement$frozen.getInternal(Unknown Source) ~[?:?]
	at dev.onyxstudios.cca.api.v3.component.ComponentKey.get(ComponentKey.java:86) ~[cardinal-components-base-5.2.2-9148ba1f751e9e24.jar:?]
	at net.minecraft.entity.LivingEntity.handler$bgo000$enchancement$frostbiteAlive(LivingEntity.java:20147) ~[minecraft-merged-9c8cdf306d-1.20.1-net.fabricmc.yarn.1_20_1.1.20.1+build.10-v2.jar:?]
	at net.minecraft.entity.LivingEntity.isAlive(LivingEntity.java) ~[minecraft-merged-9c8cdf306d-1.20.1-net.fabricmc.yarn.1_20_1.1.20.1+build.10-v2.jar:?]
	at com.simibubi.create.content.equipment.armor.CardboardArmorHandler.playerHitboxChangesWhenHidingAsBox(CardboardArmorHandler.java:26) ~[create-6.0.7.0+build.1728-mc1.20.1-64b5720b4b825f21.jar:?]
	at io.github.fabricators_of_create.porting_lib.entity.events.EntityEvents.lambda$static$2(EntityEvents.java:40) ~[porting_lib_entity-2.3.12+1.20.1-2ce8c1a18327993e.jar:?]
	at io.github.fabricators_of_create.porting_lib.entity.events.EntityEvents$Size.sendEvent(EntityEvents.java:238) ~[porting_lib_entity-2.3.12+1.20.1-2ce8c1a18327993e.jar:?]
	at net.minecraft.entity.Entity.wrapOperation$zln000$porting_lib_entity$entitySizeConstructEvent(Entity.java:5855) ~[minecraft-merged-9c8cdf306d-1.20.1-net.fabricmc.yarn.1_20_1.1.20.1+build.10-v2.jar:?]
	at net.minecraft.entity.Entity.<init>(Entity.java:301) ~[minecraft-merged-9c8cdf306d-1.20.1-net.fabricmc.yarn.1_20_1.1.20.1+build.10-v2.jar:?]

Create is triggering this in combination with Enchancement.

  • Create listens for Porting Lib's EntityEvents.Size, which fires during Entity construction
  • Create checks isAlive
  • Enchancement has a hook into isAlive that checks for a component
  • Game crashes with this weird NPE

It may be possible to simply move the injection higher, but I'm not familiar enough with the codebase to say so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions