ChoiceIsMe

ExampleEntity

Aug 3rd, 2021
48
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package io.github.choiceisme.common.entity;
  2.  
  3.  
  4.  
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.entity.EntityType;
  7. import net.minecraft.entity.MobEntity;
  8. import net.minecraft.entity.ai.attributes.AttributeModifierMap;
  9. import net.minecraft.entity.ai.attributes.Attributes;
  10. import net.minecraft.entity.ai.goal.LookAtGoal;
  11. import net.minecraft.entity.ai.goal.LookRandomlyGoal;
  12. import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
  13. import net.minecraft.entity.player.PlayerEntity;
  14. import net.minecraft.network.IPacket;
  15. import net.minecraft.util.SoundEvent;
  16. import net.minecraft.util.SoundEvents;
  17. import net.minecraft.world.World;
  18. import net.minecraftforge.fml.network.NetworkHooks;
  19.  
  20. public class ExampleEntity extends MobEntity {
  21.  
  22. public ExampleEntity(EntityType<? extends MobEntity> p_i48549_1_, World p_i48549_2_) {
  23. super(p_i48549_1_, p_i48549_2_);
  24.  
  25. }
  26.  
  27. public static AttributeModifierMap.MutableAttribute setAttributes() {
  28. return MobEntity.createMobAttributes()
  29. .add(Attributes.MAX_HEALTH, 20.0f)
  30. .add(Attributes.ATTACK_DAMAGE, 5.0f)
  31. .add(Attributes.ATTACK_SPEED, 2.0f)
  32. .add(Attributes.ATTACK_KNOCKBACK, 3.0f)
  33. .add(Attributes.JUMP_STRENGTH, 5.0f)
  34. .add(Attributes.MOVEMENT_SPEED, 5.0f)
  35. .add(Attributes.ARMOR, 5.0f)
  36. .add(Attributes.FOLLOW_RANGE, 35.0D);
  37.  
  38.  
  39. }
  40.  
  41. @Override
  42. protected void registerGoals() {
  43. super.registerGoals();
  44.  
  45. this.goalSelector.addGoal(1, new LookRandomlyGoal(this));
  46. this.goalSelector.addGoal(2, new LookAtGoal(this, PlayerEntity.class, 8.0f));
  47.  
  48. this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
  49. }
  50.  
  51.  
  52. @Override
  53. protected SoundEvent getDeathSound() {
  54. return SoundEvents.POLAR_BEAR_DEATH;
  55. }
  56.  
  57.  
  58. @Override
  59. public IPacket<?> getAddEntityPacket() {
  60. return NetworkHooks.getEntitySpawningPacket(this);
  61. }
  62.  
  63. }
RAW Paste Data