Posted May 29, 20214 yr Here is a clip to explain: https://streamable.com/5xjofu Basically, when I walk out of range, I get a NullPointerException at LookController#setLookAt when it's being called from MeleeAttackGoal#tick. Here is the log: https://privatebin.net/?05d1c1f8826d8bb2#79SvshoEzUji3NxL2oqTR2fi3CVzq66JPfps4HV1xTDb Here is the class of the entity in question: package com.isensehostility.entity_testing.entities; import net.minecraft.entity.*; import net.minecraft.entity.ai.attributes.AttributeModifierMap; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.ai.goal.*; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import javax.annotation.Nullable; public class GobletEntity extends CreatureEntity { public GobletEntity(EntityType<? extends CreatureEntity> type, World worldIn) { super(type, worldIn); } @Override protected void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(0, new SwimGoal(this)); this.goalSelector.addGoal(7, new WaterAvoidingRandomWalkingGoal(this, 1.0d)); this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.3D, true)); this.goalSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true)); } public static AttributeModifierMap.MutableAttribute setAttributes() { return MobEntity.createMobAttributes() .add(Attributes.MAX_HEALTH, 1.0D) .add(Attributes.MOVEMENT_SPEED, 0.25D) .add(Attributes.ATTACK_DAMAGE, 2.0D); } } I'm not sure what is causing the error, or how to fix it. Any help is appreciated.
May 30, 20214 yr 8 hours ago, ISenseHostility said: Here is the class of the entity in question Well, you should definitely add the NearestAttackableTargetGoal to the targetSelector and not the goalSelector, but I am not sure that will fix problem.
May 30, 20214 yr Author 4 hours ago, vemerion said: add the NearestAttackableTargetGoal to the targetSelector and not the goalSelector This fixed it, thank you!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.