Advertisement
Guest User

GrassmanEntity

a guest
Nov 13th, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. package com.mojius.mojiusmod.entities;
  2.  
  3. import net.minecraft.entity.EntityType;
  4. import net.minecraft.entity.SharedMonsterAttributes;
  5. import net.minecraft.entity.ai.goal.HurtByTargetGoal;
  6. import net.minecraft.entity.ai.goal.LookAtGoal;
  7. import net.minecraft.entity.ai.goal.LookRandomlyGoal;
  8. import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
  9. import net.minecraft.entity.ai.goal.RandomWalkingGoal;
  10. import net.minecraft.entity.ai.goal.SwimGoal;
  11. import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
  12. import net.minecraft.entity.monster.MonsterEntity;
  13. import net.minecraft.entity.player.PlayerEntity;
  14. import net.minecraft.world.World;
  15.  
  16. public class GrassmanEntity extends MonsterEntity {
  17.  
  18. public GrassmanEntity(EntityType<? extends MonsterEntity> type, World worldIn)
  19. {
  20. super (type, worldIn);
  21. }
  22.  
  23. @Override
  24. protected void registerGoals()
  25. {
  26. this.goalSelector.addGoal(0, new SwimGoal(this));
  27.  
  28. this.goalSelector.addGoal(1, new RandomWalkingGoal(this, 0.4d));
  29. this.goalSelector.addGoal(2, new LookRandomlyGoal(this));
  30. this.goalSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
  31. }
  32.  
  33. protected void applyEntityAI() {
  34. this.goalSelector.addGoal(5, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
  35. this.goalSelector.addGoal(6, new LookAtGoal(this, PlayerEntity.class, 8.0F));
  36. this.goalSelector.addGoal(6, new LookRandomlyGoal(this));
  37. this.targetSelector.addGoal(1, new HurtByTargetGoal(this));
  38. this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
  39. }
  40.  
  41. protected void registerAttributes()
  42. {
  43. super.registerAttributes();
  44. this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(15.0d);
  45. this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3.0d);
  46. this.getAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0d);
  47. this.getAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(2.0d);
  48. }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement