Fabric API

Fabric API

106M Downloads

fabric-entity-events-v1 crash with entities moving through Nether portals

magneticflux- opened this issue ยท 4 comments

commented

When placing an entity in a Nether portal that has not generated an exit, a NullPointerException is thrown because null is returned by L/Entity;moveToWorld(LServerWorld;)LEntity; when the teleportTarget is null.

This line attempts to access the world field on the returned value (which may be null):

ServerEntityWorldChangeEvents.AFTER_ENTITY_CHANGE_WORLD.invoker().afterChangeWorld((Entity) (Object) this, cir.getReturnValue(), (ServerWorld) this.world, (ServerWorld) cir.getReturnValue().world);

Log of an example crash:

java.lang.NullPointerException
    at Not Enough Crashes deobfuscated stack trace.(1.16.4+build.7)
    at net.minecraft.entity.Entity.handler$zgb000$afterWorldChanged(Entity:5150)
    at net.minecraft.entity.Entity.moveToWorld(Entity:2326)
    at net.minecraft.entity.Entity.tickNetherPortal(Entity:1942)
    at net.minecraft.entity.Entity.baseTick(Entity:449)
    at net.minecraft.entity.LivingEntity.baseTick(LivingEntity:324)
    at net.minecraft.entity.mob.MobEntity.baseTick(MobEntity:275)
    at net.minecraft.entity.Entity.tick(Entity:431)
    at net.minecraft.entity.LivingEntity.tick(LivingEntity:2209)
    at net.minecraft.entity.mob.MobEntity.tick(MobEntity:342)
    at net.minecraft.entity.mob.ZombieEntity.tick(ZombieEntity:233)
    at net.minecraft.server.world.ServerWorld.tickEntity(ServerWorld:621)
    at net.minecraft.world.World.tickEntity(World:561)
    at net.minecraft.server.world.ServerWorld.tick(ServerWorld:411)
    at net.minecraft.server.MinecraftServer.redirect$zoi000$ficUpdateSuppressionCrashTick(MinecraftServer:6207)
    at net.minecraft.server.MinecraftServer.tickWorlds(MinecraftServer:871)
    at net.minecraft.server.dedicated.MinecraftDedicatedServer.tickWorlds(MinecraftDedicatedServer:312)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer:811)
    at net.minecraft.server.MinecraftServer.handler$baa000$modifiedRunLoop(MinecraftServer:7310)
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer:651)
    at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer:257)
    at java.lang.Thread.run(Unknown Source)
commented

And here's a crash report from the dev environment: crash-2021-01-02_20.51.27-server.txt

I'm working on a quick PR to fix this right now.

commented

I looked at the mixed in result and the ordinal seems to be wrong:

TeleportTarget teleportTarget = this.getTeleportTarget(destination);
            if (teleportTarget == null) {
                Object var4 = null;
                this.handler$zgf000$afterWorldChanged(destination, new CallbackInfoReturnable("moveToWorld", false, var4));
                return null;
            } else {
                this.world.getProfiler().swap("reloading");
...
                this.method_30076();
                this.world.getProfiler().pop();
                ((ServerWorld)this.world).resetIdleTimeout();
                destination.resetIdleTimeout();
                this.world.getProfiler().pop();
                <===== Desired target - also nullable
                return entity;
            }
commented

Is it? That should be ordinal 1 iirc

commented

The ordinal is 1, checked in IDE and should be 2