Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package uk.co.ijay.earlyfuture.entity;
- import java.lang.reflect.Field;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockCarrot;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityAgeable;
- import net.minecraft.entity.EntityLiving;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.IEntityLivingData;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.entity.ai.EntityAIAttackOnCollide;
- import net.minecraft.entity.ai.EntityAIAvoidEntity;
- import net.minecraft.entity.ai.EntityAIHurtByTarget;
- import net.minecraft.entity.ai.EntityAIMate;
- import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
- import net.minecraft.entity.ai.EntityAIPanic;
- import net.minecraft.entity.ai.EntityAISwimming;
- import net.minecraft.entity.ai.EntityAITempt;
- import net.minecraft.entity.ai.EntityAIWander;
- import net.minecraft.entity.ai.EntityAIWatchClosest;
- import net.minecraft.entity.ai.EntityJumpHelper;
- import net.minecraft.entity.ai.EntityMoveHelper;
- import net.minecraft.entity.passive.EntityAnimal;
- import net.minecraft.entity.passive.EntityWolf;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.init.Items;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.pathfinding.PathEntity;
- import net.minecraft.potion.Potion;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.MathHelper;
- import net.minecraft.util.StatCollector;
- import net.minecraft.util.Vec3;
- import net.minecraft.world.World;
- import net.minecraftforge.common.ForgeHooks;
- import uk.co.ijay.earlyfuture.EarlyFuture;
- import uk.co.ijay.earlyfuture.ObfMemberException;
- import uk.co.ijay.earlyfuture.entity.ai.EntityAIMoveToBlock;
- import uk.co.ijay.earlyfuture.init.EarlyFutureItems;
- import com.google.common.base.Predicate;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- public class EntityRabbit extends EntityAnimal
- {
- private EntityRabbit.AIAvoidEntity avoidEntityAI;
- private int field_175540_bm = 0;
- private int field_175535_bn = 0;
- private boolean isJumping = false;
- private boolean field_175537_bp = false;
- private int field_175538_bq = 0;
- private EntityRabbit.EnumMoveType moveType;
- private int carrotTicks;
- private EntityPlayer uselessPlayer;
- private static final String __OBFID = "CL_00002242";
- private static Field jumpHelperField;
- private static Field moveHelperField;
- private static Field moveHelperPosXField;
- private static Field moveHelperPosYField;
- private static Field moveHelperPosZField;
- private static Field entityAIPanicSpeedField;
- private static Field entityJumpHelperIsJumpingField;
- static
- {
- try
- {
- jumpHelperField = EntityLiving.class.getDeclaredField("field_70767_i");
- moveHelperField = EntityLiving.class.getDeclaredField("field_70765_h");
- moveHelperPosXField = EntityMoveHelper.class.getDeclaredField("field_75646_b");
- moveHelperPosYField = EntityMoveHelper.class.getDeclaredField("field_75647_c");
- moveHelperPosZField = EntityMoveHelper.class.getDeclaredField("field_75644_d");
- entityAIPanicSpeedField = EntityAIPanic.class.getDeclaredField("field_75265_b");
- entityJumpHelperIsJumpingField = EntityJumpHelper.class.getDeclaredField("field_75662_b");
- }
- catch (Exception e)
- {
- try
- {
- jumpHelperField = EntityLiving.class.getDeclaredField("jumpHelper");
- moveHelperField = EntityLiving.class.getDeclaredField("moveHelper");
- moveHelperPosXField = EntityMoveHelper.class.getDeclaredField("posX");
- moveHelperPosYField = EntityMoveHelper.class.getDeclaredField("posY");
- moveHelperPosZField = EntityMoveHelper.class.getDeclaredField("posZ");
- entityAIPanicSpeedField = EntityAIPanic.class.getDeclaredField("speed");
- entityJumpHelperIsJumpingField = EntityJumpHelper.class.getDeclaredField("isJumping");
- }
- catch (Exception e1)
- {
- throw new ObfMemberException(e, e1);
- }
- }
- jumpHelperField.setAccessible(true);
- moveHelperField.setAccessible(true);
- moveHelperPosXField.setAccessible(true);
- moveHelperPosYField.setAccessible(true);
- moveHelperPosZField.setAccessible(true);
- entityAIPanicSpeedField.setAccessible(true);
- entityJumpHelperIsJumpingField.setAccessible(true);
- }
- public EntityRabbit(World worldIn)
- {
- super(worldIn);
- this.moveType = EntityRabbit.EnumMoveType.HOP;
- this.carrotTicks = 0;
- this.uselessPlayer = null;
- this.setSize(0.6F, 0.7F);
- try
- {
- jumpHelperField.set(this, new EntityRabbit.RabbitJumpHelper(this));
- moveHelperField.set(this, new EntityRabbit.RabbitMoveHelper());
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- //((PathNavigateGround)this.getNavigator()).func_179690_a(true);
- // \/ \/
- getNavigator().setAvoidsWater(true);
- //this.getNavigator().func_179678_a(2.5F);
- this.tasks.addTask(1, new EntityAISwimming(this));
- this.tasks.addTask(1, new EntityRabbit.AIPanic(1.33D));
- this.tasks.addTask(2, new EntityAITempt(this, 1.0D, Items.carrot, false));
- this.tasks.addTask(3, new EntityAIMate(this, 0.8D));
- this.tasks.addTask(5, new EntityRabbit.AIRaidFarm());
- this.tasks.addTask(5, new EntityAIWander(this, 0.6D));
- this.tasks.addTask(11, new EntityAIWatchClosest(this, EntityPlayer.class, 10.0F));
- this.avoidEntityAI = new EntityRabbit.AIAvoidEntity(new Predicate() {
- private static final String __OBFID = "CL_00002241";
- public boolean apply(Entity p_180086_1_)
- {
- return p_180086_1_ instanceof EntityWolf;
- }
- @Override
- public boolean apply(Object p_apply_1_)
- {
- return this.apply((Entity) p_apply_1_);
- }
- }, 16.0F, 1.33D, 1.33D);
- this.tasks.addTask(4, this.avoidEntityAI);
- this.setSpeed(0.0D);
- }
- @Override
- public boolean isAIEnabled()
- {
- return true;
- }
- public float getJumpHeight()
- {
- try
- {
- return ((EntityMoveHelper) moveHelperField.get(this)).isUpdating()
- && ((Double) moveHelperPosYField.get((EntityMoveHelper) moveHelperField.get(this))) > this.posY + 0.5D ? 0.5F
- : this.moveType.getJumpHeight();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- @Override
- public void jump()
- {
- this.motionY = (double) this.getJumpHeight();
- if(this.isPotionActive(Potion.jump))
- {
- this.motionY += (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
- }
- if(this.isSprinting())
- {
- float f = this.rotationYaw * 0.017453292F;
- this.motionX -= (double) (MathHelper.sin(f) * 0.2F);
- this.motionZ += (double) (MathHelper.cos(f) * 0.2F);
- }
- this.isAirBorne = true;
- ForgeHooks.onLivingJump(this);
- }
- public void setMoveType(EntityRabbit.EnumMoveType moveType)
- {
- this.moveType = moveType;
- }
- @SideOnly(Side.CLIENT)
- public float func_175521_o(float p_175521_1_)
- {
- return this.field_175535_bn == 0 ? 0.0F : ((float) this.field_175540_bm + p_175521_1_)
- / (float) this.field_175535_bn;
- }
- public void setSpeed(double speed)
- {
- this.getNavigator().setSpeed(speed);
- try
- {
- ((EntityMoveHelper) moveHelperField.get(this)).setMoveTo(
- (Double) moveHelperPosXField.get((EntityMoveHelper) moveHelperField.get(this)),
- (Double) moveHelperPosYField.get((EntityMoveHelper) moveHelperField.get(this)),
- (Double) moveHelperPosZField.get((EntityMoveHelper) moveHelperField.get(this)), speed);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- public void applyMoveType(boolean jumping, EntityRabbit.EnumMoveType moveType)
- {
- super.setJumping(jumping);
- if(!jumping)
- {
- if(this.moveType == EntityRabbit.EnumMoveType.ATTACK)
- {
- this.moveType = EntityRabbit.EnumMoveType.HOP;
- }
- }
- else
- {
- this.setSpeed(1.5D * (double) moveType.getSpeedMultiplier());
- this.playSound(this.getHoppingSound(), this.getSoundVolume(),
- ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 0.8F);
- }
- this.isJumping = jumping;
- }
- public void applyMoveType(EntityRabbit.EnumMoveType moveType)
- {
- this.applyMoveType(true, moveType);
- this.field_175535_bn = moveType.func_180073_d();
- this.field_175540_bm = 0;
- }
- public boolean getJumping()
- {
- return this.isJumping;
- }
- @Override
- protected void entityInit()
- {
- super.entityInit();
- this.dataWatcher.addObject(18, Byte.valueOf((byte) 0));
- }
- @Override
- public void updateAITasks()
- {
- try
- {
- if(((EntityMoveHelper) moveHelperField.get(this)).getSpeed() > 0.8D)
- {
- this.setMoveType(EntityRabbit.EnumMoveType.SPRINT);
- }
- else if(this.moveType != EntityRabbit.EnumMoveType.ATTACK)
- {
- this.setMoveType(EntityRabbit.EnumMoveType.HOP);
- }
- if(this.field_175538_bq > 0)
- {
- --this.field_175538_bq;
- }
- if(this.carrotTicks > 0)
- {
- this.carrotTicks -= this.rand.nextInt(3);
- if(this.carrotTicks < 0)
- {
- this.carrotTicks = 0;
- }
- }
- if(this.onGround)
- {
- if(!this.field_175537_bp)
- {
- this.applyMoveType(false, EntityRabbit.EnumMoveType.NONE);
- this.func_175517_cu();
- }
- if(this.getRabbitType() == 99 && this.field_175538_bq == 0)
- {
- EntityLivingBase entitylivingbase = this.getAttackTarget();
- if(entitylivingbase != null && this.getDistanceSqToEntity(entitylivingbase) < 16.0D)
- {
- this.faceXAndZ(entitylivingbase.posX, entitylivingbase.posZ);
- ((EntityMoveHelper) moveHelperField.get(this)).setMoveTo(entitylivingbase.posX,
- entitylivingbase.posY, entitylivingbase.posZ,
- ((EntityMoveHelper) moveHelperField.get(this)).getSpeed());
- this.applyMoveType(EntityRabbit.EnumMoveType.ATTACK);
- this.field_175537_bp = true;
- }
- }
- EntityRabbit.RabbitJumpHelper rabbitjumphelper = (EntityRabbit.RabbitJumpHelper) jumpHelperField
- .get(this);
- if(!rabbitjumphelper.getJumping())
- {
- if(((EntityMoveHelper) moveHelperField.get(this)).isUpdating() && this.field_175538_bq == 0)
- {
- PathEntity pathentity = this.getNavigator().getPath();
- Vec3 vec3 = Vec3.createVectorHelper(
- (Double) moveHelperPosXField.get((EntityMoveHelper) moveHelperField.get(this)),
- (Double) moveHelperPosYField.get((EntityMoveHelper) moveHelperField.get(this)),
- (Double) moveHelperPosZField.get((EntityMoveHelper) moveHelperField.get(this)));
- if(pathentity != null && pathentity.getCurrentPathIndex() < pathentity.getCurrentPathLength())
- {
- vec3 = pathentity.getPosition(this);
- }
- this.faceXAndZ(vec3.xCoord, vec3.zCoord);
- this.applyMoveType(this.moveType);
- }
- }
- else if(!rabbitjumphelper.func_180065_d())
- {
- this.func_175518_cr();
- }
- }
- this.field_175537_bp = this.onGround;
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- /** Unfortunately there doesn't seem to be a way to stop the rabbit from spawning running particles. Dead code, but
- * left in to remind us that's it's still a minor issue */
- public void spawnRunningParticles()
- {
- }
- private void faceXAndZ(double x, double z)
- {
- this.rotationYaw = (float) (Math.atan2(z - this.posZ, x - this.posX) * 180.0D / Math.PI) - 90.0F;
- }
- private void func_175518_cr()
- {
- try
- {
- ((EntityRabbit.RabbitJumpHelper) jumpHelperField.get(this)).func_180066_a(true);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- private void func_175520_cs()
- {
- try
- {
- ((EntityRabbit.RabbitJumpHelper) jumpHelperField.get(this)).func_180066_a(false);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- private void func_175530_ct()
- {
- this.field_175538_bq = this.func_175532_cm();
- }
- private void func_175517_cu()
- {
- this.func_175530_ct();
- this.func_175520_cs();
- }
- @Override
- public void onLivingUpdate()
- {
- super.onLivingUpdate();
- if(this.field_175540_bm != this.field_175535_bn)
- {
- if(this.field_175540_bm == 0 && !this.worldObj.isRemote)
- {
- this.worldObj.setEntityState(this, (byte) 1);
- }
- ++this.field_175540_bm;
- }
- else if(this.field_175535_bn != 0)
- {
- this.field_175540_bm = 0;
- this.field_175535_bn = 0;
- }
- }
- @Override
- protected void applyEntityAttributes()
- {
- super.applyEntityAttributes();
- this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
- this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);
- }
- @Override
- public void writeEntityToNBT(NBTTagCompound tagCompound)
- {
- super.writeEntityToNBT(tagCompound);
- tagCompound.setInteger("RabbitType", this.getRabbitType());
- tagCompound.setInteger("MoreCarrotTicks", this.carrotTicks);
- }
- @Override
- public void readEntityFromNBT(NBTTagCompound tagCompund)
- {
- super.readEntityFromNBT(tagCompund);
- this.setRabbitType(tagCompund.getInteger("RabbitType"));
- this.carrotTicks = tagCompund.getInteger("MoreCarrotTicks");
- }
- protected String getHoppingSound()
- {
- return EarlyFuture.ID + ":mob.rabbit.hop";
- }
- @Override
- protected String getLivingSound()
- {
- return EarlyFuture.ID + ":mob.rabbit.idle";
- }
- @Override
- protected String getHurtSound()
- {
- return EarlyFuture.ID + ":mob.rabbit.hurt";
- }
- @Override
- protected String getDeathSound()
- {
- return EarlyFuture.ID + ":mob.rabbit.death";
- }
- @Override
- public boolean attackEntityAsMob(Entity p_70652_1_)
- {
- if(this.getRabbitType() == 99)
- {
- this.playSound("mob.attack", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
- return p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), 8.0F);
- }
- else
- {
- return p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), 3.0F);
- }
- }
- @Override
- public int getTotalArmorValue()
- {
- return this.getRabbitType() == 99 ? 8 : super.getTotalArmorValue();
- }
- @Override
- public boolean attackEntityFrom(DamageSource source, float amount)
- {
- return this.isEntityInvulnerable() ? false : super.attackEntityFrom(source, amount);
- }
- @Override
- protected void addRandomArmor()
- {
- this.entityDropItem(new ItemStack(EarlyFutureItems.rabbit_foot, 1), 0.0F);
- }
- @Override
- protected void dropFewItems(boolean hitByPlayer, int looting)
- {
- int j = this.rand.nextInt(2) + this.rand.nextInt(1 + looting);
- int k;
- for(k = 0; k < j; ++k)
- {
- this.dropItem(EarlyFutureItems.rabbit_hide, 1);
- }
- j = this.rand.nextInt(2);
- for(k = 0; k < j; ++k)
- {
- if(this.isBurning())
- {
- this.dropItem(EarlyFutureItems.cooked_rabbit, 1);
- }
- else
- {
- this.dropItem(EarlyFutureItems.raw_rabbit, 1);
- }
- }
- }
- private boolean isAttractedTo(Item item)
- {
- return item == Items.carrot || item == Items.golden_carrot
- || item == Item.getItemFromBlock(Blocks.yellow_flower);
- }
- public EntityRabbit getChild(EntityAgeable p_175526_1_)
- {
- EntityRabbit entityrabbit = new EntityRabbit(this.worldObj);
- if(p_175526_1_ instanceof EntityRabbit)
- {
- entityrabbit.setRabbitType(this.rand.nextBoolean() ? this.getRabbitType() : ((EntityRabbit) p_175526_1_)
- .getRabbitType());
- }
- return entityrabbit;
- }
- @Override
- public boolean isBreedingItem(ItemStack stack)
- {
- return stack != null && this.isAttractedTo(stack.getItem());
- }
- public int getRabbitType()
- {
- return this.dataWatcher.getWatchableObjectByte(18);
- }
- public void setRabbitType(int rabbitTypeId)
- {
- if(rabbitTypeId == 99)
- {
- this.tasks.removeTask(this.avoidEntityAI);
- this.tasks.addTask(4, new EntityRabbit.AIEvilAttack());
- this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
- this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 10, true));
- this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityWolf.class, 10, true));
- if(!this.hasCustomNameTag())
- {
- this.setCustomNameTag(StatCollector.translateToLocal("entity.KillerBunny.name"));
- }
- }
- this.dataWatcher.updateObject(18, Byte.valueOf((byte) rabbitTypeId));
- }
- @Override
- public IEntityLivingData onSpawnWithEgg(IEntityLivingData livingData)
- {
- Object liningDataObject = livingData;
- int type = this.rand.nextInt(6);
- boolean isRabbitTypeData = false;
- if(liningDataObject instanceof EntityRabbit.RabbitTypeData)
- {
- type = ((EntityRabbit.RabbitTypeData) liningDataObject).rabbitType;
- isRabbitTypeData = true;
- }
- else
- {
- liningDataObject = new EntityRabbit.RabbitTypeData(type);
- }
- this.setRabbitType(type);
- if(isRabbitTypeData)
- {
- this.setGrowingAge(-24000);
- }
- return (IEntityLivingData) liningDataObject;
- }
- private boolean func_175534_cv()
- {
- return this.carrotTicks == 0;
- }
- protected int func_175532_cm()
- {
- return this.moveType.func_180075_c();
- }
- protected void func_175528_cn()
- {
- this.worldObj.spawnParticle("blockdust_28813", this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F)
- - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ
- + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, 0.0D, 0.0D, 0.0D);
- this.carrotTicks = 100;
- }
- @Override
- @SideOnly(Side.CLIENT)
- public void handleHealthUpdate(byte p_70103_1_)
- {
- if(p_70103_1_ == 1)
- {
- this.spawnRunningParticles();
- this.field_175535_bn = 10;
- this.field_175540_bm = 0;
- }
- else
- {
- super.handleHealthUpdate(p_70103_1_);
- }
- }
- @Override
- public EntityAgeable createChild(EntityAgeable ageable)
- {
- return this.getChild(ageable);
- }
- class AIAvoidEntity extends EntityAIAvoidEntity
- {
- private EntityRabbit entityInstance = EntityRabbit.this;
- private static final String __OBFID = "CL_00002238";
- public AIAvoidEntity(Predicate avoidPredicate, float p_i45865_3_, double p_i45865_4_, double p_i45865_6_)
- {
- super(EntityRabbit.this, EntityRabbit.class, p_i45865_3_, p_i45865_4_, p_i45865_6_);
- }
- @Override
- public void updateTask()
- {
- super.updateTask();
- }
- }
- class AIEvilAttack extends EntityAIAttackOnCollide
- {
- private static final String __OBFID = "CL_00002240";
- public AIEvilAttack()
- {
- super(EntityRabbit.this, EntityLivingBase.class, 1.4D, true);
- }
- /** Unfortunately cannot modify this
- * @param p_179512_1_
- * @return */
- protected double func_179512_a(EntityLivingBase p_179512_1_)
- {
- return (double) (4.0F + p_179512_1_.width);
- }
- }
- class AIPanic extends EntityAIPanic
- {
- private EntityRabbit field_179486_b = EntityRabbit.this;
- private static final String __OBFID = "CL_00002234";
- public AIPanic(double p_i45861_2_)
- {
- super(EntityRabbit.this, p_i45861_2_);
- }
- @Override
- public void updateTask()
- {
- super.updateTask();
- try
- {
- this.field_179486_b.setSpeed((Double) entityAIPanicSpeedField.get(this));
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- }
- static enum EnumMoveType
- {
- NONE(0.0F, 0.0F, 30, 1), HOP(0.8F, 0.2F, 20, 10), STEP(1.0F, 0.45F, 14, 14), SPRINT(1.75F, 0.4F, 1, 8), ATTACK(
- 2.0F, 0.7F, 7, 8);
- private final float speedMultiplier;
- private final float jumpHeight;
- private final int field_180084_h;
- private final int field_180085_i;
- private static final String __OBFID = "CL_00002239";
- private EnumMoveType(float speedMultiplier, float jumpHeight, int p_i45866_5_, int p_i45866_6_)
- {
- this.speedMultiplier = speedMultiplier;
- this.jumpHeight = jumpHeight;
- this.field_180084_h = p_i45866_5_;
- this.field_180085_i = p_i45866_6_;
- }
- public float getSpeedMultiplier()
- {
- return this.speedMultiplier;
- }
- public float getJumpHeight()
- {
- return this.jumpHeight;
- }
- public int func_180075_c()
- {
- return this.field_180084_h;
- }
- public int func_180073_d()
- {
- return this.field_180085_i;
- }
- }
- public class RabbitJumpHelper extends EntityJumpHelper
- {
- private EntityRabbit rabbit;
- private boolean field_180068_d = false;
- private static final String __OBFID = "CL_00002236";
- public RabbitJumpHelper(EntityRabbit rabbit)
- {
- super(rabbit);
- this.rabbit = rabbit;
- }
- public boolean getJumping()
- {
- try
- {
- return (Boolean) entityJumpHelperIsJumpingField.get(this);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- public boolean func_180065_d()
- {
- return this.field_180068_d;
- }
- public void func_180066_a(boolean p_180066_1_)
- {
- this.field_180068_d = p_180066_1_;
- }
- @Override
- public void doJump()
- {
- try
- {
- if((Boolean) entityJumpHelperIsJumpingField.get(this))
- {
- this.rabbit.applyMoveType(EntityRabbit.EnumMoveType.STEP);
- entityJumpHelperIsJumpingField.set(this, false);
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- }
- class RabbitMoveHelper extends EntityMoveHelper
- {
- private EntityRabbit rabbit = EntityRabbit.this;
- private static final String __OBFID = "CL_00002235";
- public RabbitMoveHelper()
- {
- super(EntityRabbit.this);
- }
- @Override
- public void onUpdateMoveHelper()
- {
- if(this.rabbit.onGround && !this.rabbit.getJumping())
- {
- this.rabbit.setSpeed(0.0D);
- }
- super.onUpdateMoveHelper();
- }
- }
- public static class RabbitTypeData implements IEntityLivingData
- {
- public int rabbitType;
- private static final String __OBFID = "CL_00002237";
- public RabbitTypeData(int rabbitType)
- {
- this.rabbitType = rabbitType;
- }
- }
- class AIRaidFarm extends EntityAIMoveToBlock
- {
- private boolean field_179498_d;
- private boolean field_179499_e = false;
- private static final String __OBFID = "CL_00002233";
- public AIRaidFarm()
- {
- super(EntityRabbit.this, 0.699999988079071D, 16);
- }
- @Override
- public boolean shouldExecute()
- {
- if(this.field_179496_a <= 0)
- {
- if(!EntityRabbit.this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")){ return false; }
- this.field_179499_e = false;
- this.field_179498_d = EntityRabbit.this.func_175534_cv();
- }
- return super.shouldExecute();
- }
- @Override
- public boolean continueExecuting()
- {
- return this.field_179499_e && super.continueExecuting();
- }
- @Override
- public void startExecuting()
- {
- super.startExecuting();
- }
- @Override
- public void resetTask()
- {
- super.resetTask();
- }
- @Override
- public void updateTask()
- {
- EarlyFuture.LOG.info("Updating task");
- super.updateTask();
- EntityRabbit.this.getLookHelper().setLookPosition((double) this.destinationBlockX + 0.5D,
- (double) (this.destinationBlockY + 1), (double) this.destinationBlockZ + 0.5D, 10.0F,
- (float) EntityRabbit.this.getVerticalFaceSpeed());
- if(this.func_179487_f())
- {
- World world = EntityRabbit.this.worldObj;
- int posY = this.destinationBlockY + 1;
- Block block = world.getBlock(this.destinationBlockX, posY, this.destinationBlockZ);
- if(this.field_179499_e && block instanceof BlockCarrot
- && world.getBlockMetadata(this.destinationBlockX, posY, this.destinationBlockZ) == 7)
- {
- EarlyFuture.LOG.info("Attempting to destroy block");
- world.playAuxSFX(2001, this.destinationBlockX, posY, this.destinationBlockZ, 0);
- block.dropBlockAsItem(world, this.destinationBlockX, posY, this.destinationBlockZ, 7, 0);
- world.setBlock(this.destinationBlockX, posY, this.destinationBlockZ, Blocks.air, 0, 3);
- EntityRabbit.this.func_175528_cn();
- }
- else EarlyFuture.LOG.info("Not a fully grown carrot, sorry!");
- this.field_179499_e = false;
- this.field_179496_a = 10;
- }
- else EarlyFuture.LOG.info("Not on the block!");
- }
- @Override
- protected boolean isTargetBlock(World worldIn, double posX, double posY, double posZ)
- {
- Block block = worldIn.getBlock((int) posX, (int) posY, (int) posZ);
- if(block == Blocks.farmland)
- {
- block = worldIn.getBlock((int) posX, (int) ++posY, (int) posZ);
- if(block instanceof BlockCarrot && worldIn.getBlockMetadata((int) posX, (int) posY, (int) posZ) == 7
- && this.field_179498_d && !this.field_179499_e)
- {
- this.field_179499_e = true;
- return true;
- }
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment