- 198
- 1
- 24
Пытаюсь сделать зомби-волка. Нападать он должен, в т.ч., на нормальных волков. Но, конечно же, не на других зомби-волков. А он это делает! Я так понимаю, это из-за того, я расширил класс ванильного волка, заменив ИИ?
Вот его код:
Есть ли простой способ избавиться от этого (т.е. оставив родительский класс как есть, чтобы использовать рендер ванильного волка)?
Вот его код:
ZombieWolf.java:
public class ZombieWolf extends WolfEntity {
public ZombieWolf(EntityType<? extends ZombieWolf> zombie, World world) {
super(zombie, world);
}
public static AttributeModifierMap.MutableAttribute createAttributes() {
return MobEntity.createMobAttributes().add(Attributes.MOVEMENT_SPEED, (double)0.3F).add(Attributes.MAX_HEALTH, 20.0D).add(Attributes.ATTACK_DAMAGE, 2.0D);
}
@Override
protected void registerGoals() {
this.goalSelector.addGoal(1, new SwimGoal(this));
this.goalSelector.addGoal(2, new SitGoal(this));
this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, 0.4F));
this.goalSelector.addGoal(5, new MeleeAttackGoal(this, 1.0D, true));
this.goalSelector.addGoal(8, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
this.goalSelector.addGoal(10, new LookAtGoal(this, PlayerEntity.class, 8.0F));
this.goalSelector.addGoal(10, new LookRandomlyGoal(this));
this.targetSelector.addGoal(3, (new HurtByTargetGoal(this)).setAlertOthers());
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, false));
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, WolfEntity.class, false));
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, VillagerEntity.class, false));
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, IronGolemEntity.class, false));
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, SheepEntity.class, false));
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, RabbitEntity.class, false));
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, TurtleEntity.class, false));
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, CatEntity.class, false));
}
protected SoundEvent getAmbientSound() {
return SoundEvents.WOLF_HOWL;
}
protected SoundEvent getHurtSound(DamageSource p_184601_1_) {
return SoundEvents.WOLF_GROWL;
}
protected SoundEvent getDeathSound() {
return SoundEvents.WOLF_DEATH;
}
protected SoundEvent getStepSound() {
return SoundEvents.WOLF_STEP;
}
protected void playStepSound(BlockPos p_180429_1_, BlockState p_180429_2_) {
this.playSound(this.getStepSound(), 0.15F, 1.0F);
}
public boolean checkSpawnRules(IServerWorld world, SpawnReason reason) {
return super.checkSpawnRules(world, reason);
}
}