Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fishing Hook NPCs not rendering #1702

Open
mcmonkey4eva opened this issue Feb 16, 2019 · 3 comments
Open

Fishing Hook NPCs not rendering #1702

mcmonkey4eva opened this issue Feb 16, 2019 · 3 comments
Labels
Confirmed Bug A bug was reported and confirmed by experienced users. Research To Do The development team needs to research the issue.

Comments

@mcmonkey4eva
Copy link
Member

mcmonkey4eva commented Feb 16, 2019

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.

@mcmonkey4eva mcmonkey4eva added Bug Report A bug was reported. Research To Do The development team needs to research the issue. labels Feb 16, 2019
@fullwall
Copy link
Member

This gets even harder in 1.14.

@fullwall
Copy link
Member

fullwall commented Apr 25, 2019

Fixed the NPE, can't get the thing to render though. Possible needs an owner at a reasonable location?

@fullwall fullwall changed the title Fishing Hook NPCs cause an NPE if used Fishing Hook NPCs not rendering Feb 25, 2020
@mcmonkey4eva mcmonkey4eva added Confirmed Bug A bug was reported and confirmed by experienced users. and removed Bug Report A bug was reported. labels May 2, 2020
@mcmonkey4eva
Copy link
Member Author

User log post https://paste.denizenscript.com/View/82267 today contained error log:

java.lang.IllegalArgumentException: unable to find valid entity superclass for class
class net.citizensnpcs.nms.v1_16_R3.entity.nonliving.FishingHookController$EntityFishingHookNPC
    at net.citizensnpcs.nms.v1_16_R3.util.NMSImpl.registerEntityClass(NMSImpl.java:993)
    at net.citizensnpcs.util.NMS.registerEntityClass(NMS.java:344)
    at net.citizensnpcs.npc.AbstractEntityController.<init>(AbstractEntityController.java:16)
    at net.citizensnpcs.nms.v1_16_R3.entity.MobEntityController.<init>(MobEntityController.java:26)
    at net.citizensnpcs.nms.v1_16_R3.entity.nonliving.FishingHookController.<init>(FishingHookController.java:37)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at net.citizensnpcs.npc.EntityControllers.createForType(EntityControllers.java:20)
    at net.citizensnpcs.npc.CitizensNPCRegistry.getByType(CitizensNPCRegistry.java:128)
    at net.citizensnpcs.npc.CitizensNPCRegistry.createNPC(CitizensNPCRegistry.java:58)
    at net.citizensnpcs.api.npc.SimpleNPCDataStore.loadInto(SimpleNPCDataStore.java:56)
    at net.citizensnpcs.Citizens$CitizensLoadTask.run(Citizens.java:501)
    at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:100)
    at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:468)
    at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:952)
    at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:177)
    at java.lang.Thread.run(Thread.java:748)

which appears to be a new load-time error from fishing hook NPCs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Confirmed Bug A bug was reported and confirmed by experienced users. Research To Do The development team needs to research the issue.
Projects
None yet
Development

No branches or pull requests

2 participants