Guest User

Untitled

a guest
Nov 1st, 2023
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. package com.chickenspeed.joshsmobs.entity.custom;
  2.  
  3. import net.minecraft.core.BlockPos;
  4. import net.minecraft.server.level.ServerLevel;
  5. import net.minecraft.sounds.SoundEvent;
  6. import net.minecraft.sounds.SoundEvents;
  7. import net.minecraft.world.damagesource.DamageSource;
  8. import net.minecraft.world.entity.AgeableMob;
  9. import net.minecraft.world.entity.EntityType;
  10. import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
  11. import net.minecraft.world.entity.ai.attributes.Attributes;
  12. import net.minecraft.world.entity.ai.goal.*;
  13. import net.minecraft.world.entity.animal.Animal;
  14. import net.minecraft.world.level.Level;
  15. import net.minecraft.world.level.block.Blocks;
  16. import net.minecraft.world.level.block.state.BlockState;
  17. import org.jetbrains.annotations.Nullable;
  18. import software.bernie.geckolib3.core.IAnimatable;
  19. import software.bernie.geckolib3.core.PlayState;
  20. import software.bernie.geckolib3.core.builder.AnimationBuilder;
  21. import software.bernie.geckolib3.core.controller.AnimationController;
  22. import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
  23. import software.bernie.geckolib3.core.manager.AnimationData;
  24. import software.bernie.geckolib3.core.manager.AnimationFactory;
  25. import software.bernie.geckolib3.util.GeckoLibUtil;
  26.  
  27. public class PrairieDogEntity extends Animal implements IAnimatable {
  28. private AnimationFactory factory = AnimationFactory(this);
  29.  
  30. public PrairieDogEntity(EntityType<? extends Animal> type, Level level) {
  31. super(type, level);
  32. }
  33. public static AttributeSupplier setAttributes() {
  34. return Animal.createMobAttributes()
  35. .add(Attributes.MAX_HEALTH, 10.0D)
  36. .add(Attributes.MOVEMENT_SPEED, 1f).build();
  37. }
  38.  
  39. @Override
  40. protected void registerGoals()
  41. {
  42. this.goalSelector.addGoal(1, new FloatGoal(this));
  43. this.goalSelector.addGoal(2, new FollowParentGoal(this, 1f));
  44. this.goalSelector.addGoal(3, new RandomLookAroundGoal(this));
  45. this.goalSelector.addGoal(4, new RandomStrollGoal(this, 1f, 1));
  46. this.goalSelector.addGoal(5, new RemoveBlockGoal(Blocks.GRASS, this, 1, 1));
  47. }
  48.  
  49. @Nullable
  50. @Override
  51. public AgeableMob getBreedOffspring(ServerLevel p_146743_, AgeableMob p_146744_) {
  52. return null;
  53. }
  54. private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
  55. if (event.isMoving()) {
  56. event.getController().setAnimation(new AnimationBuilder().addRepeatingAnimation("animation.PrairieDog.idle", 1));
  57. return PlayState.CONTINUE;
  58. }
  59.  
  60. event.getController().setAnimation(new AnimationBuilder().addRepeatingAnimation("animation.PrairieDog.walk", 1));
  61. return PlayState.CONTINUE;
  62.  
  63. }
  64. @Override
  65. public void registerControllers(AnimationData data) {
  66. data.addAnimationController(new AnimationController(this, "controller",
  67. 0, this::predicate));
  68. }
  69.  
  70. @Override
  71. public AnimationFactory getFactory() {
  72. return null;
  73. }
  74.  
  75.  
  76. protected void playStepSound(BlockPos pos, BlockState blockIn) {
  77. this.playSound(SoundEvents.GRASS_STEP, 0.15F, 1.0F);
  78. }
  79.  
  80. protected SoundEvent getAmbientSound() {
  81. return SoundEvents.FOX_AMBIENT;
  82. }
  83.  
  84. protected SoundEvent getHurtSound(DamageSource damageSourceIn) {
  85. return SoundEvents.WOLF_WHINE;
  86. }
  87.  
  88. protected SoundEvent getDeathSound() {
  89. return SoundEvents.WOLF_DEATH;
  90. }
  91.  
  92. protected float getSoundVolume() {
  93. return 0.2F;
  94. }
  95.  
  96. }
  97.  
Add Comment
Please, Sign In to add comment