Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.robbiemilton.shade.entity;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.entity.ai.EntityAITargetNonTamed;
- import net.minecraft.entity.monster.EntityZombie;
- import net.minecraft.entity.monster.IMob;
- import net.minecraft.entity.passive.EntityWolf;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.util.ChunkCoordinates;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.MathHelper;
- import net.minecraft.village.Village;
- import net.minecraft.world.World;
- public class EntityDarkKnight2 extends EntityWolf{
- private int homeCheckTimer;
- Village villageObj;
- private int attackTimer;
- public EntityDarkKnight2(World world) {
- super(world);
- this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityZombie.class, 200, false));
- // TODO Auto-generated constructor stub
- }
- protected void applyEntityAttributes()
- {
- super.applyEntityAttributes();
- this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D);
- this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D);
- }
- public void setposition() {
- // TODO Auto-generated method stub
- }
- public void setPosition(double d, double e, double f) {
- // TODO Auto-generated method stub
- }
- @SideOnly(Side.CLIENT)
- public boolean getWolfShaking()
- {
- return false;
- }
- @SideOnly(Side.CLIENT)
- public float getShadingWhileShaking(float p_70915_1_)
- {
- return 0;
- }
- @SideOnly(Side.CLIENT)
- public float getShakeAngle(float p_70923_1_, float p_70923_2_)
- {
- return 0;
- }
- public boolean isAIEnabled()
- {
- return true;
- }
- /**
- * main AI tick function, replaces updateEntityActionState
- */
- protected void updateAITick()
- {
- if (--this.homeCheckTimer <= 0)
- {
- this.homeCheckTimer = 70 + this.rand.nextInt(50);
- this.villageObj = this.worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 32);
- if (this.villageObj == null)
- {
- this.detachHome();
- }
- else
- {
- ChunkCoordinates chunkcoordinates = this.villageObj.getCenter();
- this.setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, (int)((float)this.villageObj.getVillageRadius() * 0.6F));
- }
- }
- super.updateAITick();
- }
- /**
- * Decrements the entity's air supply when underwater
- */
- protected int decreaseAirSupply(int p_70682_1_)
- {
- return p_70682_1_;
- }
- protected void collideWithEntity(Entity p_82167_1_)
- {
- if (p_82167_1_ instanceof IMob && this.getRNG().nextInt(20) == 0)
- {
- this.setAttackTarget((EntityLivingBase)p_82167_1_);
- }
- super.collideWithEntity(p_82167_1_);
- }
- /**
- * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
- * use this to react to sunlight and start to burn.
- */
- public void onLivingUpdate()
- {
- super.onLivingUpdate();
- if (this.attackTimer > 0)
- {
- --this.attackTimer;
- }
- if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D && this.rand.nextInt(5) == 0)
- {
- int i = MathHelper.floor_double(this.posX);
- int j = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset);
- int k = MathHelper.floor_double(this.posZ);
- Block block = this.worldObj.getBlock(i, j, k);
- if (block.getMaterial() != Material.air)
- {
- this.worldObj.spawnParticle("blockcrack_" + Block.getIdFromBlock(block) + "_" + this.worldObj.getBlockMetadata(i, j, k), this.posX + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, this.boundingBox.minY + 0.1D, this.posZ + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, 4.0D * ((double)this.rand.nextFloat() - 0.5D), 0.5D, ((double)this.rand.nextFloat() - 0.5D) * 4.0D);
- }
- }
- }
- /**
- * Returns true if this entity can attack entities of the specified class.
- */
- public boolean canAttackClass(Class p_70686_1_)
- {
- return this.isPlayerCreated() && EntityPlayer.class.isAssignableFrom(p_70686_1_) ? false : super.canAttackClass(p_70686_1_);
- }
- /**
- * (abstract) Protected helper method to write subclass entity data to NBT.
- */
- public void writeEntityToNBT(NBTTagCompound p_70014_1_)
- {
- super.writeEntityToNBT(p_70014_1_);
- p_70014_1_.setBoolean("PlayerCreated", this.isPlayerCreated());
- }
- /**
- * (abstract) Protected helper method to read subclass entity data from NBT.
- */
- public void readEntityFromNBT(NBTTagCompound p_70037_1_)
- {
- super.readEntityFromNBT(p_70037_1_);
- this.setPlayerCreated(p_70037_1_.getBoolean("PlayerCreated"));
- }
- public boolean attackEntityAsMob(Entity p_70652_1_)
- {
- this.attackTimer = 10;
- this.worldObj.setEntityState(this, (byte)4);
- boolean flag = p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float)(7 + this.rand.nextInt(15)));
- if (flag)
- {
- p_70652_1_.motionY += 0.4000000059604645D;
- }
- this.playSound("mob.irongolem.throw", 1.0F, 1.0F);
- return flag;
- }
- @SideOnly(Side.CLIENT)
- public int getAttackTimer()
- {
- return this.attackTimer;
- }
- public boolean isPlayerCreated()
- {
- return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0;
- }
- public void setPlayerCreated(boolean p_70849_1_)
- {
- byte b0 = this.dataWatcher.getWatchableObjectByte(16);
- if (p_70849_1_)
- {
- this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1)));
- }
- else
- {
- this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2)));
- }
- }
- public void setTamed(boolean p_70903_1_)
- {
- super.setTamed(p_70903_1_);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment