Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.src;
- import java.util.List;
- public class MoNature_EntityDruid extends EntityMob
- {
- public MoNature_EntityDruid(World world)
- {
- super(world);
- texture = "/MoOres/DruidSkin.png";
- setSize(1.5F, 1.9F);
- targetedEntity = null;
- isImmuneToFire = true;
- angerLevel = 0;
- }
- public void writeEntityToNBT(NBTTagCompound nbttagcompound)
- {
- super.writeEntityToNBT(nbttagcompound);
- nbttagcompound.setShort("Anger", (short)angerLevel);
- }
- public void readEntityFromNBT(NBTTagCompound nbttagcompound)
- {
- super.readEntityFromNBT(nbttagcompound);
- angerLevel = nbttagcompound.getShort("Anger");
- }
- protected Entity findPlayerToAttack()
- {
- if(angerLevel == 0)
- {
- return null;
- } else
- {
- return super.findPlayerToAttack();
- }
- }
- public boolean attackEntityFrom(DamageSource damagesource, int i)
- {
- Entity entity = damagesource.getEntity();
- if(entity instanceof EntityPlayer)
- {
- List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(2D, 2D, 2D));
- for(int j = 0; j < list.size(); j++)
- {
- Entity entity1 = (Entity)list.get(j);
- if(entity1 instanceof MoNature_EntityDruid)
- {
- MoNature_EntityDruid entitypigzombie = (MoNature_EntityDruid)entity1;
- entitypigzombie.becomeAngryAt(entity);
- }
- }
- becomeAngryAt(entity);
- }
- return super.attackEntityFrom(damagesource, i);
- }
- private void becomeAngryAt(Entity entity)
- {
- entityToAttack = entity;
- angerLevel = 400 + rand.nextInt(400);
- }
- public void onLivingUpdate(){
- super.onLivingUpdate();
- if(entityToAttack!=null){
- ModLoader.getMinecraftInstance().theWorld.setRainStrength(1F);
- }
- }
- protected void updateEntityActionState()
- {
- if(targetedEntity != null && targetedEntity.isDead)
- {
- targetedEntity = null;
- }
- if(targetedEntity == null)
- {
- targetedEntity = worldObj.getClosestPlayerToEntity(this, 100D);
- }
- double d4 = 64D;
- if(targetedEntity != null && targetedEntity.getDistanceSqToEntity(this) < d4 * d4)
- {
- double d5 = targetedEntity.posX - posX;
- double d6 = (targetedEntity.boundingBox.minY + (double)(targetedEntity.height / 2.0F)) - (posY + (double)(height / 2.0F));
- double d7 = targetedEntity.posZ - posZ;
- renderYawOffset = rotationYaw = (-(float)Math.atan2(d5, d7) * 180F) / 3.141593F;
- if(canEntityBeSeen(targetedEntity))
- {
- {
- EntityLightningBolt entityfireball = new EntityLightningBolt(worldObj, d5, d6, d7);
- double d8 = 4D;
- Vec3D vec3d = getLook(1.0F);
- entityfireball.posX = posX + vec3d.xCoord * d8;
- entityfireball.posY = posY + (double)(height / 2.0F) + 0.5D;
- entityfireball.posZ = posZ + vec3d.zCoord * d8;
- worldObj.entityJoinedWorld(entityfireball);
- }
- }
- } else
- {
- renderYawOffset = rotationYaw = (-(float)Math.atan2(motionX, motionZ) * 180F) / 3.141593F;
- }
- }
- protected String getLivingSound()
- {
- return null;
- }
- protected String getHurtSound()
- {
- return null;
- }
- protected String getDeathSound()
- {
- return null;
- }
- protected float getSoundVolume()
- {
- return 0.4F;
- }
- public ItemStack getHeldItem()
- {
- return defaultHeldItem;
- }
- protected int getDropItemId()
- {
- return 352;
- }
- private static final ItemStack defaultHeldItem;
- static
- {
- defaultHeldItem = new ItemStack(Item.stick, 1);
- }
- private int angerLevel;
- private Entity targetedEntity;
- }
Add Comment
Please, Sign In to add comment