Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.arisux.avp.entities.mob;
- import java.util.Random;
- import com.arisux.avp.AliensVsPredator;
- import com.arisux.avp.entities.EntityAcidPool;
- import com.arisux.avp.entities.EntityAcidProjectile;
- import net.minecraft.entity.*;
- import net.minecraft.entity.ai.*;
- import net.minecraft.entity.passive.EntityAnimal;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.world.World;
- public class EntitySpitter extends EntityXenomorph implements IRangedAttackMob
- {
- public EntitySpitter(World par1World)
- {
- super(par1World);
- this.experienceValue = 275;
- this.setSize(1.0F, 3.0F);
- }
- @Override
- protected void applyEntityAttributes()
- {
- super.applyEntityAttributes();
- this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(30.0D);
- this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5500000238418579D);
- this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D);
- }
- @Override
- protected boolean isAIEnabled()
- {
- return true;
- }
- @Override
- protected String getHurtSound()
- {
- return AliensVsPredator.properties().SOUND_SPITTER_HURT;
- }
- @Override
- protected String getLivingSound()
- {
- return AliensVsPredator.properties().SOUND_SPITTER_LIVING;
- }
- @Override
- protected String getDeathSound()
- {
- return AliensVsPredator.properties().SOUND_SPITTER_DEATH;
- }
- @Override
- public int getTotalArmorValue()
- {
- return 2;
- }
- @Override
- public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float f)
- {
- if (!par1EntityLivingBase.isDead)
- {
- this.getLookHelper().setLookPosition(par1EntityLivingBase.posX, par1EntityLivingBase.posY + par1EntityLivingBase.getEyeHeight(), par1EntityLivingBase.posZ, 10.0F, this.getVerticalFaceSpeed());
- if (this.canEntityBeSeen(par1EntityLivingBase))
- {
- int attackDamage = 2;
- EntityAcidProjectile entityacid = new EntityAcidProjectile(this.worldObj, this, par1EntityLivingBase, 1.6F, 14 - attackDamage * 4);
- entityacid.setDamage(f * 2.0F + this.rand.nextGaussian() * 0.25D + attackDamage * 0.11F);
- this.worldObj.spawnEntityInWorld(entityacid);
- }
- }
- }
- @Override
- protected void dropRareDrop(int par1)
- {
- if (new Random().nextInt(4) == 1)
- this.entityDropItem(new ItemStack(AliensVsPredator.items().helmXeno), 1);
- if (new Random().nextInt(4) == 1)
- this.entityDropItem(new ItemStack(AliensVsPredator.items().plateXeno), 1);
- if (new Random().nextInt(4) == 1)
- this.entityDropItem(new ItemStack(AliensVsPredator.items().legsXeno), 1);
- if (new Random().nextInt(4) == 1)
- this.entityDropItem(new ItemStack(AliensVsPredator.items().bootsXeno), 1);
- super.dropRareDrop(par1);
- }
- @Override
- public void attackAI()
- {
- if (worldObj.getWorldInfo().getWorldTime() % 70 == 0)
- {
- double range = this.getEntityAttribute(SharedMonsterAttributes.followRange).getAttributeValue();
- Entity targetEntity = (this.worldObj.findNearestEntityWithinAABB(EntityLiving.class, this.boundingBox.expand(range * 2, 64.0D, range * 2), this));
- Entity targetPlayer = (this.worldObj.findNearestEntityWithinAABB(EntityPlayer.class, this.boundingBox.expand(range * 2, 64.0D, range * 2), this));
- if (targetPlayer != null && !((EntityPlayer) targetPlayer).capabilities.isCreativeMode)
- {
- this.setAttackTarget((EntityLivingBase) targetPlayer);
- this.getMoveHelper().setMoveTo(this.getAttackTarget().posX, this.getAttackTarget().posY, this.getAttackTarget().posZ, 1D);
- if (this.isCollidedHorizontally)
- {
- this.addVelocity(0, 0.6D, 0);
- }
- }
- else if (targetEntity != null && !(targetEntity instanceof EntityAcidPool) && !(targetEntity.getClass().getSuperclass().getSuperclass() == EntitySpeciesAlien.class) && !(targetEntity.getClass().getSuperclass() == EntitySpeciesAlien.class))
- {
- this.setAttackTarget((EntityLivingBase) targetEntity);
- this.getMoveHelper().setMoveTo(this.getAttackTarget().posX, this.getAttackTarget().posY, this.getAttackTarget().posZ, 1D);
- if (this.isCollidedHorizontally)
- {
- this.addVelocity(0, 0.6D, 0);
- }
- }
- else
- {
- this.setAttackTarget(null);
- }
- }
- }
- @Override
- public void onUpdate()
- {
- //Finds Target
- this.attackAI();
- //Checks if it's dead or not
- if(this.getAttackTarget() != null && this.getAttackTarget().isDead)
- {
- this.setAttackTarget(null);
- }
- //Attacks it
- else if(this.getAttackTarget() != null)
- {
- if(this.getAttackTarget() instanceof EntityPlayer)
- {
- EntityPlayer target = (EntityPlayer) this.getAttackTarget();
- //If it's in creative mode stop attacking
- if(target.capabilities.isCreativeMode)
- {
- this.setAttackTarget(null);
- return;
- }
- else
- {
- if(this.getDistance(this.getAttackTarget().posX, this.getAttackTarget().posY, this.getAttackTarget().posZ) < 10)
- {
- this.attackEntityWithRangedAttack(this.getAttackTarget(), 0.05F);
- }
- }
- }
- if(this.getDistance(this.getAttackTarget().posX, this.getAttackTarget().posY, this.getAttackTarget().posZ) < 10)
- {
- this.attackEntityWithRangedAttack(this.getAttackTarget(), 0.05F);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement