Advertisement
Guest User

entitycobra

a guest
Jul 4th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. package com.ChaoticSoul.MoreArmor.entity;
  2.  
  3. import net.minecraft.entity.EntityLiving;
  4. import net.minecraft.entity.EntityLivingBase;
  5. import net.minecraft.entity.IRangedAttackMob;
  6. import net.minecraft.entity.SharedMonsterAttributes;
  7. import net.minecraft.entity.ai.EntityAIAttackRanged;
  8. import net.minecraft.entity.ai.EntityAIFollow;
  9. import net.minecraft.entity.ai.EntityAILookIdle;
  10. import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
  11. import net.minecraft.entity.ai.EntityAISit;
  12. import net.minecraft.entity.ai.EntityAIWatchClosest;
  13. import net.minecraft.entity.monster.IMob;
  14. import net.minecraft.entity.passive.EntityWolf;
  15. import net.minecraft.entity.player.EntityPlayer;
  16. import net.minecraft.init.MobEffects;
  17. import net.minecraft.init.SoundEvents;
  18. import net.minecraft.potion.Potion;
  19. import net.minecraft.potion.PotionEffect;
  20. import net.minecraft.util.math.MathHelper;
  21. import net.minecraft.world.World;
  22.  
  23. public class EntityCobra extends EntityWolf implements IRangedAttackMob
  24. {
  25.  
  26. public EntityCobra(World worldIn) {
  27. super(worldIn);
  28. // TODO Auto-generated constructor stub
  29. }
  30. private boolean didSpit;
  31.  
  32. @Override
  33. protected void initEntityAI()
  34. {
  35. this.tasks.addTask(1, new EntityAISit(this));
  36. this.tasks.addTask(1, new EntityAIAttackRanged(this, 1.25D, 40, 10.0F));
  37. this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
  38. this.tasks.addTask(4, new EntityAILookIdle(this));
  39. this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 10, true, false, IMob.MOB_SELECTOR));
  40. this.tasks.addTask(1, new EntityAIFollow(this, 2.0D, 3.0F, 7.0F));
  41. }
  42.  
  43.  
  44. private void spit(EntityLivingBase target)
  45. {
  46. EntityVenom entityvenom = new EntityVenom(this.world, this);
  47. double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
  48. double d1 = target.posX - this.posX;
  49. double d2 = d0 - entityvenom.posY;
  50. double d3 = target.posZ - this.posZ;
  51. float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
  52. entityvenom.shoot(d1, d2 + (double)f, d3, 1.6F, 12.0F);
  53. this.playSound(SoundEvents.ENTITY_LLAMA_SPIT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
  54. this.world.spawnEntity(entityvenom);
  55. PotionEffect potion = new PotionEffect(MobEffects.POISON,100,4);
  56. if(target.hitByEntity(entityvenom)==true)
  57. {
  58. target.addPotionEffect(potion);
  59. }
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66. }
  67.  
  68. @Override
  69. public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
  70. this.spit(target);
  71. }
  72. private void setDidSpit(boolean didSpitIn)
  73. {
  74. this.didSpit = didSpitIn;
  75.  
  76. }
  77.  
  78. @Override
  79. public void setSwingingArms(boolean swingingArms) {
  80. // TODO Auto-generated method stub
  81.  
  82. }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement