MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a npc companion"
/* First, create a custom class for your NPC companion that extends the base CreatureEntity class. Then, override the necessary methods and add any custom behavior you want for your companion. */ public class NPCCompanionEntity extends CreatureEntity { public NPCCompanionEntity(EntityType<? extends CreatureEntity> type, World worldIn) { super(type, worldIn); } @Override protected void registerGoals() { super.registerGoals(); /* Add your custom goals and behaviors here, for example: */ this.goalSelector.addGoal(0, new SwimGoal(this)); this.goalSelector.addGoal(1, new FollowOwnerGoal(this, 1.0D, 10.0F, 2.0F, false)); this.goalSelector.addGoal(2, new LookAtGoal(this, PlayerEntity.class, 8.0F)); this.goalSelector.addGoal(3, new RandomWalkingGoal(this, 1.0D)); } /* Register your entity attributes here */ public static AttributeModifierMap.MutableAttribute createAttributes() { return MobEntity.createMobAttributes() .add(Attributes.MAX_HEALTH, 20.0D) .add(Attributes.MOVEMENT_SPEED, 0.25D); } /* Add any other custom behavior or methods for your NPC companion here */ } /* Next, make sure to register your custom entity in your mod's entity registry. */