package com.madalchemist.betterzombies.zombies;
import com.madalchemist.betterzombies.ai.ModdedZombieAttackGoal;
import net.minecraft.block.BlockState;
import net.minecraft.entity.CreatureAttribute;
import net.minecraft.entity.EntitySize;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.Pose;
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.merchant.villager.AbstractVillagerEntity;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.monster.ZombifiedPiglinEntity;
import net.minecraft.entity.passive.IronGolemEntity;
import net.minecraft.entity.passive.TurtleEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.pathfinding.GroundPathNavigator;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class BasicZombie extends MonsterEntity {
public BasicZombie(EntityType<? extends BasicZombie> zombie, World world) {
super(zombie, world);
}
public static AttributeModifierMap.MutableAttribute createAttributes() {
return MonsterEntity.createMonsterAttributes()
.add(Attributes.FOLLOW_RANGE, 35.0D)
.add(Attributes.MOVEMENT_SPEED, (double)0.1F)
.add(Attributes.ATTACK_DAMAGE, 1.0D)
.add(Attributes.ARMOR, 2.0D)
.add(Attributes.SPAWN_REINFORCEMENTS_CHANCE);
}
protected SoundEvent getAmbientSound() {
return SoundEvents.ZOMBIE_AMBIENT;
}
protected SoundEvent getHurtSound(DamageSource p_184601_1_) {
return SoundEvents.ZOMBIE_HURT;
}
protected SoundEvent getDeathSound() {
return SoundEvents.ZOMBIE_DEATH;
}
protected SoundEvent getStepSound() {
return SoundEvents.ZOMBIE_STEP;
}
protected void playStepSound(BlockPos p_180429_1_, BlockState p_180429_2_) {
this.playSound(this.getStepSound(), 0.15F, 1.0F);
}
protected void registerGoals() {
//this.goalSelector.addGoal(8, new RandomWalkingGoal(this, 0.1D));
this.goalSelector.addGoal(8, new LookAtGoal(this, PlayerEntity.class, 8.0F));
this.goalSelector.addGoal(8, new LookRandomlyGoal(this));
this.goalSelector.addGoal(2, new ModdedZombieAttackGoal(this, 1.0D, false));
this.goalSelector.addGoal(6, new MoveThroughVillageGoal(this, 1.0D, true, 4, this::canBreakDoors));
this.goalSelector.addGoal(5, new MoveTowardsTargetGoal(this, 1, 1.0f));
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, AbstractVillagerEntity.class, false));
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolemEntity.class, true));
this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, TurtleEntity.class, 10, true, false, TurtleEntity.BABY_ON_LAND_SELECTOR));
}
@Override
public void aiStep() {
super.aiStep();
}
public boolean canBreakDoors(){
return true;
}
@Override
protected int getExperienceReward(@Nonnull PlayerEntity player) {
return 2;
}
@Override
public boolean canBreatheUnderwater() {
return true;
}
@Override
@Nonnull
public ResourceLocation getDefaultLootTable() {
return super.getDefaultLootTable();
}
@Override
protected float getStandingEyeHeight(@Nonnull Pose pose, @Nonnull EntitySize size) {
return 0.9F;
}
public CreatureAttribute getMobType() {
return CreatureAttribute.UNDEAD;
}
}