Plugin causing client to crash?

Discussion in 'Spigot Plugin Development' started by KuramaStone, Jul 28, 2017.

  1. I have made a custom entity with a different method than normal and now it causes my client to crash. I get the following error in my client console:

    Code (Text):

    09:27:03 sg Skipping Entity with id 0
    09:27:04 bao Reported exception thrown! s: Ticking screen
    at bao.p(SourceFile:1353)
    at bao.ak(SourceFile:774)
    at bao.f(SourceFile:728) at net.minecraft.client.main.Main.main(SourceFile:148)
    Caused by: java.lang.NullPointerException at bjb.a(SourceFile:514)
    at fz.a(SourceFile:97) at fz.a(SourceFile:15)
    at ej.a(SourceFile:174) at bcx.e(SourceFile:78)
    at bao.p(SourceFile:1343) ... 3 more
     
    and no errors within the server. I have just installed MC once again on this laptop and I am not sure if it is the plugin or the client. I'd wager with the plugin but it is pretty basic.

    Here is the CustomEntityType class where I register the entity: https://hastebin.com/orecozuyag.cpp

    Here is the CustomEntity:

    Code (Text):
    import java.lang.reflect.Field;

    import org.bukkit.ChatColor;
    import org.bukkit.craftbukkit.v1_7_R4.util.UnsafeList;

    import net.minecraft.server.v1_7_R4.EntityCreeper;
    import net.minecraft.server.v1_7_R4.EntityHuman;
    import net.minecraft.server.v1_7_R4.EntityOcelot;
    import net.minecraft.server.v1_7_R4.PathfinderGoalAvoidPlayer;
    import net.minecraft.server.v1_7_R4.PathfinderGoalFloat;
    import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer;
    import net.minecraft.server.v1_7_R4.PathfinderGoalMeleeAttack;
    import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround;
    import net.minecraft.server.v1_7_R4.PathfinderGoalRandomStroll;
    import net.minecraft.server.v1_7_R4.PathfinderGoalSelector;
    import net.minecraft.server.v1_7_R4.World;

    public class NiceCreeper extends EntityCreeper {

        public NiceCreeper(World world) {
            super(world);
            clearGoals();
            this.goalSelector.a(1, new PathfinderGoalFloat(this));
            this.goalSelector.a(3, new PathfinderGoalAvoidPlayer(this, EntityOcelot.class, 6.0F, 1.0D, 1.2D));
            this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, 1.0D, false));
            this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, 0.8D));
            this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
            this.goalSelector.a(6, new PathfinderGoalRandomLookaround(this));

            super.setCustomName(ChatColor.GREEN + "Nice Creeper!");
            super.setCustomNameVisible(true);
        }

        private void clearGoals() {
            try {
                Field bField = PathfinderGoalSelector.class.getDeclaredField("b");
                bField.setAccessible(true);
                Field cField = PathfinderGoalSelector.class.getDeclaredField("c");
                cField.setAccessible(true);
                bField.set(goalSelector, new UnsafeList<PathfinderGoalSelector>());
                bField.set(targetSelector, new UnsafeList<PathfinderGoalSelector>());
                cField.set(goalSelector, new UnsafeList<PathfinderGoalSelector>());
                cField.set(targetSelector, new UnsafeList<PathfinderGoalSelector>());
            }
            catch(Exception exc) {
                exc.printStackTrace();
            }
        }
       
        @Override
        protected boolean a(EntityHuman entityhuman) {
            return false;
        }

    }
    It merely stops Creepers from exploding. My main is simply registering and deregistering the entities:

    Code (Text):

    public class Creepers extends JavaPlugin {

        @Override
        public void onEnable() {
            CustomEntityType.registerEntities();
        }

        @Override
        public void onDisable() {
            CustomEntityType.unregisterEntities();
        }

    }
    Why is the error occurring, is it just my client or a flaw within the plugin?