Guest User

Untitled

a guest
Nov 18th, 2020
31
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.leitedesnatado.examplemod.entities;
  2.  
  3. import com.leitedesnatado.examplemod.init.ModEntityTypes;
  4.  
  5. import net.minecraft.entity.AgeableEntity;
  6. import net.minecraft.entity.EntityType;
  7. import net.minecraft.entity.SharedMonsterAttributes;
  8. import net.minecraft.entity.ai.goal.BreedGoal;
  9. import net.minecraft.entity.ai.goal.FollowParentGoal;
  10. import net.minecraft.entity.ai.goal.LookAtGoal;
  11. import net.minecraft.entity.ai.goal.LookRandomlyGoal;
  12. import net.minecraft.entity.ai.goal.PanicGoal;
  13. import net.minecraft.entity.ai.goal.SwimGoal;
  14. import net.minecraft.entity.passive.AnimalEntity;
  15. import net.minecraft.entity.player.PlayerEntity;
  16. import net.minecraft.item.Items;
  17. import net.minecraft.item.crafting.Ingredient;
  18. import net.minecraft.util.SoundEvent;
  19. import net.minecraft.util.SoundEvents;
  20. import net.minecraft.world.World;
  21.  
  22. public class PenguinEntity extends AnimalEntity {
  23.  
  24. private int exampleTimer;
  25. private static final Ingredient TEMPTATION_ITEMS = Ingredient.fromItems(Items.COD, Items.SALMON);
  26.  
  27. protected PenguinEntity(EntityType<? extends AnimalEntity> type, World worldIn) {
  28. super(type, worldIn);
  29.  
  30. }
  31.  
  32. @Override
  33. public AgeableEntity createChild(AgeableEntity ageable) {
  34. return ModEntityTypes.PENGUIN.get().create(this.world);
  35. }
  36. @Override
  37. protected void registerGoals() {
  38. super.registerGoals();
  39. this.goalSelector.addGoal(0, new SwimGoal(this));
  40. this.goalSelector.addGoal(1, new PanicGoal(this, 1.25D));
  41. this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));
  42. this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1D));
  43. this.goalSelector.addGoal(7, new LookAtGoal(this, PlayerEntity.class, 6.0F));
  44. this.goalSelector.addGoal(8, new LookRandomlyGoal(this));
  45. }
  46.  
  47. @Override
  48. public void livingTick() {
  49. if (this.world.isRemote) {
  50. this.exampleTimer = Math.max(0, this.exampleTimer - 1);
  51. }
  52. super.livingTick();
  53. }
  54.  
  55. @Override
  56. protected void registerAttributes() {
  57. super.registerAttributes();
  58. this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(8.0D);
  59. this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
  60. }
  61.  
  62. @Override
  63. protected int getExperiencePoints(PlayerEntity player) {
  64. return 1 + this.world.rand.nextInt(4);
  65. }
  66.  
  67. @Override
  68. protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_POLAR_BEAR_AMBIENT; }
  69.  
  70. @Override
  71. protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_POLAR_BEAR_DEATH; }
  72.  
  73.  
  74. }
RAW Paste Data