Skip to content

Fishing Hook NPCs not rendering #1702

@mcmonkey4eva

Description

@mcmonkey4eva

Transferring and detailing user error from error log posted on Discord

Citizens version: Citizens v2.0.24-SNAPSHOT (build 1617)
Spigot version: 1.13.2 - Paper build 524

(Both latest at time of posting)

User error message report (snipped for length):


[00:00:51] java.lang.reflect.InvocationTargetException
(...)
net.citizensnpcs.nms.v1_13_R2.entity.MobEntityController.createEntityFromClass(MobEntityController.java:42)
[00:00:51] at net.citizensnpcs.nms.v1_13_R2.entity.MobEntityController.createEntity(MobEntityController.java:27)
[00:00:51] at net.citizensnpcs.npc.AbstractEntityController.spawn(AbstractEntityController.java:41)
[00:00:51] at net.citizensnpcs.npc.CitizensNPC.spawn(CitizensNPC.java:209)
[00:00:51] at net.citizensnpcs.npc.CitizensNPC.load(CitizensNPC.java:143)
[00:00:51] at net.citizensnpcs.api.npc.SimpleNPCDataStore.loadInto(SimpleNPCDataStore.java:59)
[00:00:51] at net.citizensnpcs.Citizens$3.run(Citizens.java:331)
[00:00:51] at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftTask.run(CraftTask.java:82)
(...)
[00:00:51] Caused by: java.lang.NullPointerException
[00:00:51] at net.minecraft.server.v1_13_R2.EntityFishingHook.a(EntityFishingHook.java:43)
[00:00:51] at net.minecraft.server.v1_13_R2.EntityFishingHook.<init>(EntityFishingHook.java:35)
[00:00:51] at net.citizensnpcs.nms.v1_13_R2.entity.nonliving.FishingHookController$EntityFishingHookNPC.<init>(FishingHookController.java:38)
[00:00:51] ... 18 more
[00:00:51] [Citizens] Task #66 for Citizens v2.0.24-SNAPSHOT (build 1617) generated an exception
[00:00:51] java.lang.NullPointerException: null
[00:00:51] at net.citizensnpcs.nms.v1_13_R2.entity.MobEntityController.createEntity(MobEntityController.java:29) ~[?:?]
[00:00:51] at net.citizensnpcs.npc.AbstractEntityController.spawn(AbstractEntityController.java:41) ~[?:?]
[00:00:51] at net.citizensnpcs.npc.CitizensNPC.spawn(CitizensNPC.java:209) ~[?:?]
[00:00:51] at net.citizensnpcs.npc.CitizensNPC.load(CitizensNPC.java:143) ~[?:?]
[00:00:51] at net.citizensnpcs.api.npc.SimpleNPCDataStore.loadInto(SimpleNPCDataStore.java:59) ~[?:?]
[00:00:51] at net.citizensnpcs.Citizens$3.run(Citizens.java:331) ~[?:?]
[00:00:51] at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftTask.run(CraftTask.java:82) ~[patched_1.13.2.jar:git-Paper-524]
(...)

Source tracing:

This code is invalid:

public EntityFishingHookNPC(World world) {
this(world, null);
}
public EntityFishingHookNPC(World world, NPC npc) {
super(world, null);
this.npc = (CitizensNPC) npc;
}

The super(world, null); calls to this NMS method:

    public EntityFishingHook(World world, EntityHuman entityhuman) {
        this(world);
        this.a(entityhuman);
        this.k();
    }
    private void a(EntityHuman entityhuman) {
        this.setSize(0.25F, 0.25F);
        this.ak = true;
        this.owner = entityhuman;
        this.owner.hookedFish = this;
    }

Note that it necessarily requires the entityhuman input to be non-null on the very last line (setting owner.hookedFish, where owner is set as entityhuman.
Since the Citizens code always feeds null, it is always an error.

The only other constructor available for EntityFishingHook is:

    private EntityFishingHook(World world) {
        super(EntityTypes.FISHING_BOBBER, world);
        this.ay = EntityFishingHook.HookState.FLYING;
    }

Which is private (making it rather difficult to use).
The a(...) method is also private, making it unavailable to override.

Possible solutions:

  • A placeholder / fake EntityHuman object to feed to the superconstructor to avoid the NPE (doesn't need to be spawned into the world I'm pretty sure, just have a Java object of that type)

Methods throughout the inside of EntityFishingHook require owner be a valid EntityHuman, so having a placeholder human to send in is probably the best solution here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Confirmed BugA bug was reported and confirmed by experienced users.Research To DoThe development team needs to research the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions