#Spigot AI Error
1 messages · Page 1 of 1 (latest)
My code : ```java
public class TestMob extends EntityGiantZombie {
public TestMob(final World w, String name, float health, double speed, double damage, double range, boolean grief, boolean projectile) {
super(EntityTypes.G, ((CraftWorld)w).getHandle());
}
protected void initPathfinder() {
this.bQ.a(1, new PathfinderGoalMeleeAttack(this, 0.5, true));
this.bQ.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, false));
}
public TestMob spawn(final Location loc) {
this.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
((CraftWorld)loc.getWorld()).getHandle().addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
return this;
}
}```
And the giant is removed from the world
anyone know why?
Why are you using unmapped
why not?
A pain to write and a pain to read
just use mapped
that's not going to solve my problem
Sorry no one now adays wants to deal with obfuscated you're young to be more likely to get help if you switch
Not to mention this is NMS and is not an API error
Also you're on an outdated version even if it was an API error :P
i used api from https://repo.codemc.io/repository/nms/
how can it be obsolete
and I don't see the problem that there are 2 pieces of obfuscated code
If you don't know how to help me, say so instead of blaming me.
Yes using an illegal code hosting repository
💯
Anyways you're suffering from a null pointer considering none of your code shows up in the stack trace you forgot to set some value
Easiest method is to reverse engineer and figure out what var0 is
I reccomend you legally obtain and use the NMS code as given by BuildTools
oh I didn't know that
I'll try thank
You can decompile the given jars in your .m2 to look through the code alternatively you can look at CraftBukkit
Here is my code with the remapped version : ```java
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.monster.Giant;
import net.minecraft.world.entity.player.Player;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.event.entity.CreatureSpawnEvent;
public class TestTitan extends Giant {
public TestTitan(final World w, String name, float health, double speed, double damage, double range, boolean grief, boolean projectile) {
super(EntityType.GIANT, ((CraftWorld)w).getHandle());
}
protected void initPathfinder() {
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 0.5, true));
this.goalSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, false));
}
public TestTitan spawn(final Location loc) {
setPos(loc.getX(), loc.getY(), loc.getZ());
((CraftWorld)loc.getWorld()).getHandle().addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
return this;
}
}
i still have this error
which crashes the server
according to the logs the error occurred at line 33
var0 is the goal target of the PathfinderGoalMeleeAttack
The given entity being passed to that function is null somehow
Weird have you tried looking at how mojang uses the goal
not yet, I'll look later
but from what I see it really comes from Minecraft and not from my plugin
just one question, does PathfinderGoalMeleeAttack still need NearestAttackableTargetGoal to work?
because I just saw that I register PathfinderGoalMeleeAttack in first position in the goalSelector. Maybe this is the cause
I'm not very experienced in goals I'd say if they are used in conjunction with eachother naturally I'd assume that'd be the case
I'd assume attackable goal finds a target and pathfinder walks towards the target?
yes I think the MeleeAttackGoal needs NearestAttackableTargetGoal because the MeleeAttackGoal does not take any entity type as parameter
i will try to put NearestAttackableTargetGoal in first position
AND IT'S WORKK!!!! no more errors
oh i'm so happy
I spent so much time on this bug lol