2013-08-30 11:38:54 +00:00
|
|
|
package biomesoplenty.entities;
|
|
|
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.SharedMonsterAttributes;
|
|
|
|
import net.minecraft.entity.monster.EntityMob;
|
2013-08-30 12:01:17 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2013-08-30 11:38:54 +00:00
|
|
|
import net.minecraft.potion.PotionEffect;
|
2013-08-30 23:52:38 +00:00
|
|
|
import net.minecraft.util.DamageSource;
|
2013-08-30 11:38:54 +00:00
|
|
|
import net.minecraft.world.World;
|
2013-08-30 12:01:17 +00:00
|
|
|
import biomesoplenty.api.Items;
|
2013-08-30 11:38:54 +00:00
|
|
|
import biomesoplenty.api.Potions;
|
|
|
|
|
|
|
|
public class EntityPhantom extends EntityMob
|
|
|
|
{
|
|
|
|
public EntityPhantom(World world)
|
|
|
|
{
|
|
|
|
super(world);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-09-13 08:17:21 +00:00
|
|
|
protected void applyEntityAttributes()
|
2013-08-30 11:38:54 +00:00
|
|
|
{
|
2013-09-13 08:17:21 +00:00
|
|
|
super.applyEntityAttributes();
|
|
|
|
|
|
|
|
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(20.0D);
|
|
|
|
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.45D);
|
2013-08-30 11:38:54 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 23:52:38 +00:00
|
|
|
@Override
|
|
|
|
public void onLivingUpdate()
|
|
|
|
{
|
|
|
|
super.onLivingUpdate();
|
|
|
|
|
|
|
|
if (!this.onGround && this.motionY < 0.0D)
|
|
|
|
{
|
|
|
|
this.motionY *= 0.6D;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.fallDistance = 0.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void fall(float par1) {}
|
|
|
|
|
2013-08-30 11:38:54 +00:00
|
|
|
@Override
|
|
|
|
public void onEntityUpdate()
|
|
|
|
{
|
|
|
|
super.onEntityUpdate();
|
|
|
|
|
2013-08-30 13:59:26 +00:00
|
|
|
for (int i = 0; i < 9; i++)
|
2013-08-30 11:38:54 +00:00
|
|
|
{
|
2013-08-30 13:59:26 +00:00
|
|
|
this.worldObj.spawnParticle("mobSpell", this.posX + (this.rand.nextDouble()) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - (double)this.yOffset, this.posZ + (this.rand.nextDouble()) * (double)this.width, 0, 0, 0);
|
2013-08-30 11:38:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean attackEntityAsMob(Entity par1Entity)
|
|
|
|
{
|
|
|
|
if (super.attackEntityAsMob(par1Entity))
|
|
|
|
{
|
|
|
|
if (par1Entity instanceof EntityLivingBase)
|
|
|
|
{
|
|
|
|
if (worldObj.difficultySetting > 1)
|
|
|
|
{
|
2013-08-30 23:52:38 +00:00
|
|
|
((EntityLivingBase)par1Entity).addPotionEffect(new PotionEffect(Potions.possession.get().id, 30, 0));
|
2013-08-30 11:38:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-30 23:52:38 +00:00
|
|
|
@Override
|
|
|
|
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 9; i++)
|
|
|
|
{
|
|
|
|
this.worldObj.spawnParticle("mobSpell", this.posX + (this.rand.nextDouble()) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - (double)this.yOffset, this.posZ + (this.rand.nextDouble()) * (double)this.width, 66, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.attackEntityFrom(par1DamageSource, par2);
|
|
|
|
}
|
|
|
|
|
2013-08-30 12:01:17 +00:00
|
|
|
@Override
|
|
|
|
protected void dropFewItems(boolean par1, int par2)
|
|
|
|
{
|
|
|
|
super.dropFewItems(par1, par2);
|
|
|
|
|
|
|
|
if (par1 && (this.rand.nextInt(3) == 0 || this.rand.nextInt(1 + par2) > 0))
|
|
|
|
{
|
2013-11-13 09:27:47 +00:00
|
|
|
this.entityDropItem(new ItemStack(Items.miscItems.get().itemID, 1, 10), 1);
|
2013-08-30 12:01:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-31 00:41:20 +00:00
|
|
|
@Override
|
|
|
|
public boolean getCanSpawnHere()
|
|
|
|
{
|
|
|
|
return this.worldObj.difficultySetting > 0 && this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox);
|
|
|
|
}
|
|
|
|
|
2013-08-30 11:38:54 +00:00
|
|
|
@Override
|
|
|
|
protected String getLivingSound()
|
|
|
|
{
|
|
|
|
return "biomesoplenty:mob.phantom.say";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String getHurtSound()
|
|
|
|
{
|
|
|
|
return "biomesoplenty:mob.phantom.hurt";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String getDeathSound()
|
|
|
|
{
|
|
|
|
return "biomesoplenty:mob.phantom.death";
|
|
|
|
}
|
|
|
|
}
|