Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ChaoticSoul.MoreArmor.entity;
- import net.minecraft.entity.EntityLiving;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.IRangedAttackMob;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.entity.ai.EntityAIAttackRanged;
- import net.minecraft.entity.ai.EntityAIFollow;
- import net.minecraft.entity.ai.EntityAILookIdle;
- import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
- import net.minecraft.entity.ai.EntityAISit;
- import net.minecraft.entity.ai.EntityAIWatchClosest;
- import net.minecraft.entity.monster.IMob;
- import net.minecraft.entity.passive.EntityWolf;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.MobEffects;
- import net.minecraft.init.SoundEvents;
- import net.minecraft.potion.Potion;
- import net.minecraft.potion.PotionEffect;
- import net.minecraft.util.math.MathHelper;
- import net.minecraft.world.World;
- public class EntityCobra extends EntityWolf implements IRangedAttackMob
- {
- public EntityCobra(World worldIn) {
- super(worldIn);
- // TODO Auto-generated constructor stub
- }
- private boolean didSpit;
- @Override
- protected void initEntityAI()
- {
- this.tasks.addTask(1, new EntityAISit(this));
- this.tasks.addTask(1, new EntityAIAttackRanged(this, 1.25D, 40, 10.0F));
- this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
- this.tasks.addTask(4, new EntityAILookIdle(this));
- this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 10, true, false, IMob.MOB_SELECTOR));
- this.tasks.addTask(1, new EntityAIFollow(this, 2.0D, 3.0F, 7.0F));
- }
- private void spit(EntityLivingBase target)
- {
- EntityVenom entityvenom = new EntityVenom(this.world, this);
- double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
- double d1 = target.posX - this.posX;
- double d2 = d0 - entityvenom.posY;
- double d3 = target.posZ - this.posZ;
- float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
- entityvenom.shoot(d1, d2 + (double)f, d3, 1.6F, 12.0F);
- this.playSound(SoundEvents.ENTITY_LLAMA_SPIT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
- this.world.spawnEntity(entityvenom);
- PotionEffect potion = new PotionEffect(MobEffects.POISON,100,4);
- if(target.hitByEntity(entityvenom)==true)
- {
- target.addPotionEffect(potion);
- }
- }
- @Override
- public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
- this.spit(target);
- }
- private void setDidSpit(boolean didSpitIn)
- {
- this.didSpit = didSpitIn;
- }
- @Override
- public void setSwingingArms(boolean swingingArms) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement