Advertisement
Guest User

entitycobra

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