Advertisement
ChoiceIsMe

ExampleEntity

Aug 6th, 2021
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. package io.github.choiceisme.common.entity;
  2.  
  3.  
  4.  
  5. import net.minecraft.entity.EntityType;
  6. import net.minecraft.entity.MobEntity;
  7. import net.minecraft.entity.ai.attributes.AttributeModifierMap;
  8. import net.minecraft.entity.ai.attributes.Attributes;
  9. import net.minecraft.entity.ai.goal.LookAtGoal;
  10. import net.minecraft.entity.ai.goal.LookRandomlyGoal;
  11. import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
  12. import net.minecraft.entity.ai.goal.RandomWalkingGoal;
  13. import net.minecraft.entity.ai.goal.SwimGoal;
  14. import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
  15. import net.minecraft.entity.passive.IronGolemEntity;
  16. import net.minecraft.entity.player.PlayerEntity;
  17. import net.minecraft.network.IPacket;
  18. import net.minecraft.util.SoundEvent;
  19. import net.minecraft.util.SoundEvents;
  20. import net.minecraft.world.World;
  21. import net.minecraftforge.fml.network.NetworkHooks;
  22.  
  23. public class ExampleEntity extends MobEntity {
  24.  
  25. public ExampleEntity(EntityType<? extends MobEntity> p_i48549_1_, World p_i48549_2_) {
  26. super(p_i48549_1_, p_i48549_2_);
  27.  
  28. }
  29.  
  30. public static AttributeModifierMap.MutableAttribute setAttributes() {
  31. return MobEntity.createMobAttributes()
  32. .add(Attributes.MAX_HEALTH, 30.0f)
  33. .add(Attributes.ATTACK_DAMAGE, 5.0f)
  34. .add(Attributes.ATTACK_SPEED, 2.0f)
  35. .add(Attributes.ATTACK_KNOCKBACK, 3.0f)
  36. .add(Attributes.JUMP_STRENGTH, 5.0f)
  37. .add(Attributes.MOVEMENT_SPEED, 5.0f)
  38. .add(Attributes.ARMOR, 5.0f)
  39. .add(Attributes.FOLLOW_RANGE, 35.0D)
  40. .add(Attributes.SPAWN_REINFORCEMENTS_CHANCE, 5.0f);
  41.  
  42.  
  43. }
  44.  
  45. @Override
  46. protected void registerGoals() {
  47. super.registerGoals();
  48.  
  49. this.goalSelector.addGoal(6, new LookRandomlyGoal(this));
  50. this.goalSelector.addGoal(4, new LookAtGoal(this, PlayerEntity.class, 8.0f));
  51. this.goalSelector.addGoal(4, new RandomWalkingGoal(this, 1.0D));
  52. this.goalSelector.addGoal(0, new SwimGoal(this));
  53. this.addBehaviourGoals();
  54.  
  55. }
  56.  
  57. protected void addBehaviourGoals() {
  58. this.goalSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
  59. this.goalSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, IronGolemEntity.class, true));
  60.  
  61.  
  62. }
  63.  
  64.  
  65. @Override
  66. protected SoundEvent getDeathSound() {
  67. return SoundEvents.POLAR_BEAR_DEATH;
  68. }
  69.  
  70.  
  71. @Override
  72. public IPacket<?> getAddEntityPacket() {
  73. return NetworkHooks.getEntitySpawningPacket(this);
  74. }
  75.  
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement