DesertUpdateMod/src/main/java/net/voltexstudios/entity/custom/VultureEntity.java
paisc b4c75acaec
Some checks failed
build / build (21) (push) Has been cancelled
added vulture entity
2025-01-23 12:32:09 +01:00

75 lines
2.5 KiB
Java

package net.voltexstudios.entity.custom;
import net.minecraft.entity.AnimationState;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.goal.LookAroundGoal;
import net.minecraft.entity.ai.goal.LookAtEntityGoal;
import net.minecraft.entity.ai.goal.WanderAroundGoal;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.passive.PassiveEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
import net.voltexstudios.entity.ModEntities;
import org.jetbrains.annotations.Nullable;
public class VultureEntity extends AnimalEntity {
public final AnimationState idleAnimationState = new AnimationState();
private int idleAnimationTimeout;
public VultureEntity(EntityType<? extends AnimalEntity> entityType, World world) {
super(entityType, world);
}
@Override
protected void initGoals() {
this.goalSelector.add(0, new WanderAroundGoal(this, 1.0));
this.goalSelector.add(1, new LookAtEntityGoal(this, PlayerEntity.class, 6.0F));
this.goalSelector.add(2, new LookAroundGoal(this));
}
private void setupAnimationStates() {
if (this.idleAnimationTimeout <= 0) {
this.idleAnimationTimeout = 40;
this.idleAnimationState.start(this.age);
} else {
--this.idleAnimationTimeout;
}
}
@Override
public void tick() {
super.tick();
if (this.getWorld().isClient()) {
this.setupAnimationStates();
}
}
//TODO alter attributes
public static DefaultAttributeContainer.Builder createAttributes() {
return MobEntity.createMobAttributes()
.add(EntityAttributes.GENERIC_MAX_HEALTH, 10.0)
.add(EntityAttributes.GENERIC_FLYING_SPEED, 1.5F)
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.6F)
.add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 10.0)
.add(EntityAttributes.GENERIC_FOLLOW_RANGE, 48.0);
}
@Override
public boolean isBreedingItem(ItemStack stack) {
return false;
}
@Nullable
@Override
public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) {
return ModEntities.VULTURE_ENTITY.create(world);
}
}