Guest User

EntityPegasus

a guest
Jul 1st, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. package com.ChaoticSoul.MoreArmor.entity;
  2.  
  3. import java.util.Set;
  4.  
  5. import com.ChaoticSoul.MoreArmor.init.ModItems;
  6. import com.google.common.collect.Sets;
  7.  
  8. import net.minecraft.entity.EntityLiving;
  9. import net.minecraft.entity.EntityLivingBase;
  10. import net.minecraft.entity.IRangedAttackMob;
  11. import net.minecraft.entity.SharedMonsterAttributes;
  12. import net.minecraft.entity.ai.EntityAIAttackRanged;
  13. import net.minecraft.entity.ai.EntityAIFollow;
  14. import net.minecraft.entity.ai.EntityAIFollowOwnerFlying;
  15. import net.minecraft.entity.ai.EntityAILookIdle;
  16. import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
  17. import net.minecraft.entity.ai.EntityAISit;
  18. import net.minecraft.entity.ai.EntityAIWanderAvoidWater;
  19. import net.minecraft.entity.ai.EntityAIWatchClosest;
  20. import net.minecraft.entity.monster.IMob;
  21. import net.minecraft.entity.passive.EntityParrot;
  22. import net.minecraft.entity.player.EntityPlayer;
  23. import net.minecraft.entity.projectile.EntityTippedArrow;
  24. import net.minecraft.init.Items;
  25. import net.minecraft.init.SoundEvents;
  26. import net.minecraft.item.Item;
  27. import net.minecraft.potion.Potion;
  28. import net.minecraft.potion.PotionEffect;
  29. import net.minecraft.util.EnumHand;
  30. import net.minecraft.util.math.MathHelper;
  31. import net.minecraft.world.World;
  32.  
  33. public class EntityPegasus extends EntityParrot implements IRangedAttackMob{
  34.  
  35.  
  36. public EntityPegasus(World worldIn) {
  37. super(worldIn);
  38.  
  39.  
  40. }
  41. protected void applyEntityAttributes()
  42. {
  43. super.applyEntityAttributes();
  44. this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(50.0D);
  45. this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(10);
  46. this.getEntityAttribute(SharedMonsterAttributes.FLYING_SPEED).setBaseValue(0.8D);
  47. this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D);
  48. this.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).setBaseValue(10);
  49.  
  50.  
  51.  
  52.  
  53. }
  54.  
  55. private static final Set<Item> TAME_ITEMS = Sets.newHashSet(ModItems.SAPPHIRE);
  56.  
  57.  
  58.  
  59. protected void initEntityAI()
  60. {
  61. this.tasks.addTask(2, new EntityAIFollowOwnerFlying(this, 1.0D, 5.0F, 1.0F));
  62. this.tasks.addTask(1, new EntityAISit(this));
  63. this.tasks.addTask(1, new EntityAIAttackRanged(this, 1.25D, 20, 10.0F));
  64. this.tasks.addTask(2, new EntityAIWanderAvoidWater(this, 1.0D, 1.0000001E-5F));
  65. this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
  66. this.tasks.addTask(4, new EntityAILookIdle(this));
  67. this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 10, true, false, IMob.MOB_SELECTOR));
  68. this.tasks.addTask(3, new EntityAIFollow(this, 1.0D, 3.0F, 7.0F));
  69. }
  70.  
  71. @Override
  72. public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
  73. {
  74.  
  75.  
  76. EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.world, this);
  77. double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
  78. double d1 = target.posX - this.posX;
  79. double d2 = d0 - entitytippedarrow.posY;
  80. double d3 = target.posZ - this.posZ;
  81. float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
  82. entitytippedarrow.shoot(d1, d2 + (double)f, d3, 1.6F, 12.0F);
  83. this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
  84. this.world.spawnEntity(entitytippedarrow);
  85. PotionEffect potion = new PotionEffect(Potion.getPotionById(2), 100, 2);
  86.  
  87. if(target.hitByEntity(entitytippedarrow)==true)
  88. {
  89. target.addPotionEffect(potion);
  90. }
  91. }
  92. private void setHeldItem(EnumHand offHand, Item tippedArrow) {
  93. // TODO Auto-generated method stub
  94.  
  95. }
  96. @Override
  97. public void setSwingingArms(boolean swingingArms) {
  98. // TODO Auto-generated method stub
  99.  
  100. }}
Advertisement
Add Comment
Please, Sign In to add comment