Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.chickenspeed.joshsmobs.entity.custom;
- import net.minecraft.core.BlockPos;
- import net.minecraft.server.level.ServerLevel;
- import net.minecraft.sounds.SoundEvent;
- import net.minecraft.sounds.SoundEvents;
- import net.minecraft.world.damagesource.DamageSource;
- import net.minecraft.world.entity.AgeableMob;
- import net.minecraft.world.entity.EntityType;
- import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
- import net.minecraft.world.entity.ai.attributes.Attributes;
- import net.minecraft.world.entity.ai.goal.*;
- import net.minecraft.world.entity.animal.Animal;
- import net.minecraft.world.level.Level;
- import net.minecraft.world.level.block.Blocks;
- import net.minecraft.world.level.block.state.BlockState;
- import org.jetbrains.annotations.Nullable;
- import software.bernie.geckolib3.core.IAnimatable;
- import software.bernie.geckolib3.core.PlayState;
- import software.bernie.geckolib3.core.builder.AnimationBuilder;
- import software.bernie.geckolib3.core.controller.AnimationController;
- import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
- import software.bernie.geckolib3.core.manager.AnimationData;
- import software.bernie.geckolib3.core.manager.AnimationFactory;
- import software.bernie.geckolib3.util.GeckoLibUtil;
- public class PrairieDogEntity extends Animal implements IAnimatable {
- private AnimationFactory factory = AnimationFactory(this);
- public PrairieDogEntity(EntityType<? extends Animal> type, Level level) {
- super(type, level);
- }
- public static AttributeSupplier setAttributes() {
- return Animal.createMobAttributes()
- .add(Attributes.MAX_HEALTH, 10.0D)
- .add(Attributes.MOVEMENT_SPEED, 1f).build();
- }
- @Override
- protected void registerGoals()
- {
- this.goalSelector.addGoal(1, new FloatGoal(this));
- this.goalSelector.addGoal(2, new FollowParentGoal(this, 1f));
- this.goalSelector.addGoal(3, new RandomLookAroundGoal(this));
- this.goalSelector.addGoal(4, new RandomStrollGoal(this, 1f, 1));
- this.goalSelector.addGoal(5, new RemoveBlockGoal(Blocks.GRASS, this, 1, 1));
- }
- @Nullable
- @Override
- public AgeableMob getBreedOffspring(ServerLevel p_146743_, AgeableMob p_146744_) {
- return null;
- }
- private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
- if (event.isMoving()) {
- event.getController().setAnimation(new AnimationBuilder().addRepeatingAnimation("animation.PrairieDog.idle", 1));
- return PlayState.CONTINUE;
- }
- event.getController().setAnimation(new AnimationBuilder().addRepeatingAnimation("animation.PrairieDog.walk", 1));
- return PlayState.CONTINUE;
- }
- @Override
- public void registerControllers(AnimationData data) {
- data.addAnimationController(new AnimationController(this, "controller",
- 0, this::predicate));
- }
- @Override
- public AnimationFactory getFactory() {
- return null;
- }
- protected void playStepSound(BlockPos pos, BlockState blockIn) {
- this.playSound(SoundEvents.GRASS_STEP, 0.15F, 1.0F);
- }
- protected SoundEvent getAmbientSound() {
- return SoundEvents.FOX_AMBIENT;
- }
- protected SoundEvent getHurtSound(DamageSource damageSourceIn) {
- return SoundEvents.WOLF_WHINE;
- }
- protected SoundEvent getDeathSound() {
- return SoundEvents.WOLF_DEATH;
- }
- protected float getSoundVolume() {
- return 0.2F;
- }
- }
Add Comment
Please, Sign In to add comment