Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.src;
- // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
- // Jad home page: http://www.kpdus.com/jad.html
- // Decompiler options: packimports(3) braces deadcode
- import java.util.List;
- import java.util.LinkedList;
- import java.util.Random;
- public class EntityTropicraftPlayerProxy extends EntityAnimal {
- public MovingObjectPosition aimHit = null;
- public int blockID = Block.ladder.blockID;
- public boolean forcejump;
- public boolean mining;
- public int mineDelay;
- public int noMoveTicks;
- public int curCooldown_Melee;
- public int curCooldown_Ranged;
- public int pfTimeout;
- //EntityCreature overrides
- private PathEntity pathToEntity;
- protected Entity entityToAttack;
- protected boolean hasAttacked;
- protected int findNewPathTick;
- //Customizable item use vars
- public int cooldown_Melee;
- public int cooldown_Ranged;
- public int slot_Melee;
- public int slot_Ranged;
- public float maxReach_Melee;
- public float maxReach_Ranged;
- public int itemSearchRange;
- public List wantedItems;
- //Player Faking vars
- public InventoryPlayer inventory;
- public EntityPlayer fakePlayer;
- //something that should be moved?
- public EntityTropicalFishHook fishEntity;
- public float castingStrength = 1F;
- public EntityTropicraftPlayerProxy(World world) {
- super(world);
- swingArm = false;
- swingTick = 0;
- //texture = "/mob/zombie.png";
- //moveSpeed = 0.8F;
- //attackStrength = 5;
- //health = 40;
- try {
- fakePlayer = new EntityPlayerSP(ModLoader.getMinecraftInstance(), world, ModLoader.getMinecraftInstance().session, world.worldProvider.worldType);
- } catch (Exception ex) {
- return;
- }
- inventory = fakePlayer.inventory;
- sync();
- wantedItems = new LinkedList();
- slot_Melee = 0;
- slot_Ranged = 1;
- cooldown_Melee = 10;
- cooldown_Ranged = 40;
- maxReach_Melee = 2F;
- maxReach_Ranged = 24F;
- itemSearchRange = 5;
- //custom mob code init
- //inventory.addItemStackToInventory(new ItemStack(Item.swordDiamond, 1));
- //inventory.addItemStackToInventory(new ItemStack(Item.bow, 1));
- //inventory.addItemStackToInventory(new ItemStack(Item.arrow, 32));
- wantedItems.add(Item.arrow.shiftedIndex);
- //use canClimb() instead
- //pf.canClimb = true;
- }
- protected EntityAnimal spawnBabyAnimal(EntityAnimal entityanimal)
- {
- return new EntityCow(worldObj);
- }
- protected void attackEntity(Entity var1, float var2) {
- sync();
- aimAtEnt(var1);
- if (isAimedAtTarget(var1)) {
- if (var2 < maxReach_Melee && var1.boundingBox.maxY > this.boundingBox.minY && var1.boundingBox.minY < this.boundingBox.maxY) {
- if (curCooldown_Melee <= 0) {
- this.setCurrentSlot(slot_Melee);
- leftClickItem(var1);
- this.curCooldown_Melee = cooldown_Melee;
- }
- } else if (var2 < maxReach_Ranged) {
- if (curCooldown_Ranged <= 0) {
- this.setCurrentSlot(slot_Ranged);
- rightClickItem();
- this.curCooldown_Ranged = cooldown_Ranged;
- }
- }
- }
- }
- public void leftClickItem(Entity var1) {
- fakePlayer.attackTargetEntityWithCurrentItem(var1);
- swingItem();
- }
- public void rightClickItem() {
- ItemStack itemToUse = this.getCurrentEquippedItem();
- if (itemToUse != null) {
- Item ii = itemToUse.getItem();
- if (ii != null) {
- if (itemToUse.getItem() instanceof ItemTropicalFishingRod) {
- ((ItemTropicalFishingRod)itemToUse.getItem()).onItemRightClick2(itemToUse, worldObj, this, castingStrength);
- } else {
- itemToUse.useItemRightClick(worldObj, fakePlayer);
- if (itemToUse.getItem() instanceof ItemBow) {
- //fakePlayer.itemInUseCount = 0;
- try {
- ModLoader.setPrivateValue(EntityPlayer.class, fakePlayer, "e", 0);
- } catch (Exception ex) {
- try {
- ModLoader.setPrivateValue(EntityPlayer.class, fakePlayer, "itemInUseCount", 0);
- } catch (Exception ex2) {
- }
- }
- fakePlayer.stopUsingItem();
- }
- //useInvItem(itemToUse);
- }
- setPrjOwner();
- }
- }
- swingItem();
- }
- public void switchItem(int id) {
- if (Item.swordDiamond.shiftedIndex == id) {
- curCooldown_Melee = 0;
- } else if (Item.bow.shiftedIndex == id) {
- }
- this.setCurrentItem(id);
- }
- public void dropCurrentItem()
- {
- dropPlayerItemWithRandomChoice(inventory.decrStackSize(inventory.currentItem, 1), false);
- }
- public void dropPlayerItem(ItemStack itemstack)
- {
- dropPlayerItemWithRandomChoice(itemstack, false);
- }
- public void dropPlayerItemWithRandomChoice(ItemStack itemstack, boolean flag)
- {
- if(itemstack == null)
- {
- return;
- }
- EntityItem entityitem = new EntityItem(worldObj, posX, (posY - 0.30000001192092896D) + (double)getEyeHeight(), posZ, itemstack);
- entityitem.delayBeforeCanPickup = 40;
- float f = 0.1F;
- if(flag)
- {
- float f2 = rand.nextFloat() * 0.5F;
- float f4 = rand.nextFloat() * 3.141593F * 2.0F;
- entityitem.motionX = -MathHelper.sin(f4) * f2;
- entityitem.motionZ = MathHelper.cos(f4) * f2;
- entityitem.motionY = 0.20000000298023224D;
- } else
- {
- float f1 = 0.3F;
- entityitem.motionX = -MathHelper.sin((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F) * f1;
- entityitem.motionZ = MathHelper.cos((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F) * f1;
- entityitem.motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F) * f1 + 0.1F;
- f1 = 0.02F;
- float f3 = rand.nextFloat() * 3.141593F * 2.0F;
- f1 *= rand.nextFloat();
- entityitem.motionX += Math.cos(f3) * (double)f1;
- entityitem.motionY += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
- entityitem.motionZ += Math.sin(f3) * (double)f1;
- }
- worldObj.spawnEntityInWorld(entityitem);
- }
- public void aimAtEnt(Entity ent) {
- this.faceEntity(ent, 180, 180);
- }
- public boolean isAimedAtTarget(Entity ent) {
- //eventually put an 'is facing' angle check or something, prevent shooting before turning
- return true;
- }
- public void faceCoord(int x, int y, int z, float f, float f1)
- {
- double d = x - posX;
- double d2 = z - posZ;
- double d1;
- d1 = y - (posY + (double)getEyeHeight());
- double d3 = MathHelper.sqrt_double(d * d + d2 * d2);
- float f2 = (float)((Math.atan2(d2, d) * 180D) / 3.1415927410125732D) - 90F;
- float f3 = (float)(-((Math.atan2(d1, d3) * 180D) / 3.1415927410125732D));
- rotationPitch = -updateRotation(rotationPitch, f3, f1);
- rotationYaw = updateRotation(rotationYaw, f2, f);
- }
- private float updateRotation(float f, float f1, float f2)
- {
- float f3;
- for(f3 = f1 - f; f3 < -180F; f3 += 360F) { }
- for(; f3 >= 180F; f3 -= 360F) { }
- if(f3 > f2)
- {
- f3 = f2;
- }
- if(f3 < -f2)
- {
- f3 = -f2;
- }
- return f + f3;
- }
- public void swingItem()
- {
- swingArm = true;
- }
- public boolean canClimb() {
- return true;
- }
- protected Entity findPlayerToAttack()
- {
- EntityPlayer entityplayer = worldObj.getClosestPlayerToEntity(this, 16D);
- if(entityplayer != null && canEntityBeSeen(entityplayer))
- {
- //NO!
- return null;
- } else
- {
- return null;
- }
- }
- public void getPathOrWalkableBlock(Entity entity, float f)
- {
- PathEntity pathentity = worldObj.getPathToEntity(this, entity, 16F);
- if(pathentity == null && f > 12F)
- {
- int i = MathHelper.floor_double(entity.posX) - 2;
- int j = MathHelper.floor_double(entity.posZ) - 2;
- int k = MathHelper.floor_double(entity.boundingBox.minY);
- for(int l = 0; l <= 4; l++)
- {
- for(int i1 = 0; i1 <= 4; i1++)
- {
- if((l < 1 || i1 < 1 || l > 3 || i1 > 3) && worldObj.isBlockNormalCube(i + l, k - 1, j + i1) && !worldObj.isBlockNormalCube(i + l, k, j + i1) && !worldObj.isBlockNormalCube(i + l, k + 1, j + i1))
- {
- setLocationAndAngles((float)(i + l) + 0.5F, k, (float)(j + i1) + 0.5F, rotationYaw, rotationPitch);
- return;
- }
- }
- }
- } else
- {
- setPathToEntity(pathentity);
- }
- }
- public void onLivingUpdate() {
- aimHit = rayTrace(1.0D, 1.0F);
- if(!handleWaterMovement()/* && !mod_MinerZombie.isSameTeam(this)*/) {
- forcejump = false;
- mineDelay--;
- if(mineDelay < 1 && noMoveTicks > 10) {
- mineDelay = 3;
- mining = true;
- if (entityToAttack instanceof EntityLiving) {
- ItemStack itemToUse = inventory.mainInventory[0];
- //if (itemToUse.getItem() instanceof ItemBlock) {
- //mod_MinerZombie.tryDig(this, (EntityLiving)entityToAttack);
- if (aimHit != null && aimHit.typeOfHit == EnumMovingObjectType.TILE) {
- if (worldObj.getBlockId(aimHit.blockX, aimHit.blockY, aimHit.blockZ) != 0 && worldObj.getBlockId(aimHit.blockX, aimHit.blockY, aimHit.blockZ) != Block.ladder.blockID) {
- //sync();
- //int var8 = itemToUse.getBlockId(var4, var5, var6);
- //if (!itemToUse.useItem(fakePlayer, worldObj, aimHit.blockX, aimHit.blockY, aimHit.blockZ, aimHit.sideHit)) {
- //useInvItem(itemToUse);
- //}
- //setPrjOwner();
- //System.out.println(worldObj.loadedEntityList.get(worldObj.loadedEntityList.size()-1));
- //itemToUse.useItem(itemToUse, this, this.worldObj, aimHit.blockX, aimHit.blockY, aimHit.blockZ, aimHit.sideHit);
- }
- }
- /*} else {
- useInvItem(itemToUse);
- setPrjOwner();
- }*/
- }
- }
- //aimHit.entityHit
- //info = noMoveTicks;
- } else {
- if(this.isCollidedHorizontally && !forcejump) {
- this.isJumping = true;
- } else {
- this.isJumping = false;
- }
- }
- /*if(!mod_MinerZombie.hostilesBreakWallsB.get()) {
- setEntityDead();
- }*/
- if(swingArm) {
- swingTick++;
- if(swingTick == 8) {
- swingTick = 0;
- swingArm = false;
- }
- } else {
- swingTick = 0;
- }
- swingProgress = (float)swingTick / 8F;
- //Cooldowns
- if (curCooldown_Melee > 0) { curCooldown_Melee--; }
- if (curCooldown_Ranged > 0) { curCooldown_Ranged--; }
- if(fakePlayer.xpCooldown > 0) {
- --fakePlayer.xpCooldown;
- }
- super.onLivingUpdate();
- if(this.health > 0) {
- List var3 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(1.0D, 0.0D, 1.0D));
- if(var3 != null) {
- for(int var4 = 0; var4 < var3.size(); ++var4) {
- Entity var5 = (Entity)var3.get(var4);
- if(!var5.isDead) {
- var5.onCollideWithPlayer(fakePlayer);
- }
- }
- }
- }
- }
- public void useInvItem(ItemStack itemstack) {
- //sync();
- }
- public float getEyeHeight()
- {
- return 0.62F;
- }
- protected void resetHeight()
- {
- yOffset = 1.62F;
- }
- public void setPrjOwner() {
- Entity ent = (Entity)worldObj.loadedEntityList.get(worldObj.loadedEntityList.size()-1);
- if (ent instanceof EntitySnowball) {
- try {
- //FIX ME
- ModLoader.setPrivateValue(EntitySnowball.class, ent, "i have no idea", this);
- } catch (Exception ex) {
- try {
- ModLoader.setPrivateValue(EntitySnowball.class, ent, "shootingEntity", this);
- } catch (Exception ex2) {
- }
- }
- } else if (ent instanceof EntityArrow) {
- ((EntityArrow) ent).posY += 1F;
- ((EntityArrow) ent).shootingEntity = this;
- ((EntityArrow) ent).doesArrowBelongToPlayer = false;
- } else if (ent instanceof EntityTropicalFishHook) {
- ((EntityTropicalFishHook) ent).angler = this;
- }
- //System.out.println(worldObj.loadedEntityList.get(worldObj.loadedEntityList.size()-1));
- }
- public void sync() {
- fakePlayer.posX = posX;
- fakePlayer.posY = posY;
- fakePlayer.posZ = posZ;
- fakePlayer.prevPosX = prevPosX;
- fakePlayer.prevPosY = prevPosY;
- fakePlayer.prevPosZ = prevPosZ;
- fakePlayer.rotationPitch = this.rotationPitch;
- fakePlayer.rotationYaw = this.rotationYaw;
- fakePlayer.prevRotationPitch = prevRotationPitch;
- fakePlayer.prevRotationYaw = prevRotationYaw;
- }
- public int getAimBlockID(int yOffset) {
- EntityLiving entityliving = this;
- float f = 1.0F;
- float f1 = entityliving.prevRotationPitch + (entityliving.rotationPitch - entityliving.prevRotationPitch) * f;
- float f3 = entityliving.prevRotationYaw + (entityliving.rotationYaw - entityliving.prevRotationYaw) * f;
- //int i = (int)Math.floor((double)(f3 / 90F) + 0.5D);
- //f3 = (float)i * 90F;
- double d = entityliving.prevPosX + (entityliving.posX - entityliving.prevPosX) * (double)f;
- double d1 = (entityliving.prevPosY + (entityliving.posY - entityliving.prevPosY) * (double)f + 1.6200000000000001D) - (double)entityliving.yOffset + yOffset;
- double d2 = entityliving.prevPosZ + (entityliving.posZ - entityliving.prevPosZ) * (double)f;
- Vec3D vec3d = Vec3D.createVector(d, d1, d2);
- float f4 = MathHelper.cos(-f3 * 0.01745329F - 3.141593F);
- float f5 = MathHelper.sin(-f3 * 0.01745329F - 3.141593F);
- float f6 = -MathHelper.cos(-f1 * 0.01745329F - 0.7853982F);
- float f7 = MathHelper.sin(-f1 * 0.01745329F - 0.7853982F);
- float f8 = f5 * f6;
- float f9 = f7;
- float f10 = f4 * f6;
- //entityliving.info = f3;
- double d3 = 1.0D;
- Vec3D vec3d1 = vec3d.addVector((double)f8 * d3, (double)f9 * d3, (double)f10 * d3);
- MovingObjectPosition movingobjectposition = entityliving.worldObj.rayTraceBlocks_do(vec3d, vec3d1, true);
- int id = -1;
- if(movingobjectposition == null) {
- return id;
- }
- if(movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) {
- id = worldObj.getBlockId(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
- //System.out.println(movingobjectposition.blockX + " - " + movingobjectposition.blockY + " - " + movingobjectposition.blockZ);
- }
- return id;
- }
- public void tryPlace(EntityCreature entityliving) {
- float f = 2.0F;
- float f1 = entityliving.prevRotationPitch + (entityliving.rotationPitch - entityliving.prevRotationPitch) * f;
- float f2 = entityliving.prevRotationPitch + (entityliving.rotationPitch - entityliving.prevRotationPitch) * f;
- f1 = 0.0F;
- float f3 = entityliving.prevRotationYaw + (entityliving.rotationYaw - entityliving.prevRotationYaw) * f;
- int i = (int)Math.floor((double)(f3 / 90F) + 0.5D);
- f3 = (float)i * 90F;
- double d = entityliving.prevPosX + (entityliving.posX - entityliving.prevPosX) * (double)f;
- double d1 = (entityliving.prevPosY + (entityliving.posY - entityliving.prevPosY) * (double)f + 1.6200000000000001D) - (double)entityliving.yOffset;
- double d2 = entityliving.prevPosZ + (entityliving.posZ - entityliving.prevPosZ) * (double)f;
- Vec3D vec3d = Vec3D.createVector(d, d1, d2);
- float f4 = MathHelper.cos(-f3 * 0.01745329F - 3.141593F);
- float f5 = MathHelper.sin(-f3 * 0.01745329F - 3.141593F);
- float f6 = -MathHelper.cos(-f1 * 0.01745329F - 0.7853982F);
- float f7 = MathHelper.sin(-f1 * 0.01745329F - 0.7853982F);
- float f8 = f5 * f6;
- float f9 = f7;
- float f10 = f4 * f6;
- //entityliving.info = f3;
- double d3 = 1.0D;
- double d4 = 1.8D;
- double d5 = 0.050000000000000003D;
- Vec3D vec3d1 = vec3d.addVector((double)f8 * d3, (double)f9 * d3, (double)f10 * d3);
- MovingObjectPosition movingobjectposition = entityliving.worldObj.rayTraceBlocks_do(vec3d, vec3d1, true);
- if(movingobjectposition == null) {
- return;
- }
- boolean flag = false;
- /*int j = MathHelper.floor_float((float)(entityliving.posX - entityliving1.posX));
- int k = (int)(entityliving.posY - entityliving1.posY);
- int l = MathHelper.floor_float((float)(entityliving.posZ - entityliving1.posZ));
- if(j + l > 0) {
- if((float)(k / (j + l)) > 1.0F) {
- flag = true;
- }
- } else if(k > 2) {
- flag = true;
- }*/
- if(movingobjectposition.typeOfHit == EnumMovingObjectType.TILE || flag) {
- int i2 = f2 >= -20F ? 0 : 1;
- int i1;
- int j1;
- int k1;
- if(flag) {
- i1 = (int)entityliving.posX;
- j1 = (int)entityliving.posZ - 1;
- k1 = (int)entityliving.posZ;
- } else {
- i1 = movingobjectposition.blockX;
- j1 = movingobjectposition.blockY + i2;
- k1 = movingobjectposition.blockZ;
- }
- int l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
- if(l1 == 0 && (i2 == 1 || flag)) {
- j1--;
- l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
- if(l1 == 0 && i2 == 1) {
- j1--;
- l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
- }
- }
- /*if(i1 != entityliving.curBlockX || j1 != entityliving.curBlockZ) {
- entityliving.curBlockDmg = 0.0F;
- entityliving.curBlockX = i1;
- entityliving.curBlockZ = j1;
- }*/
- Block block = Block.blocksList[l1];
- //float f11 = MiningZombieDigPower.get() * (float)(entityliving.nearbyMinerCount + 1);
- if(block != null) {
- if(entityliving instanceof EntityTropicraftPlayerProxy) {
- ((EntityTropicraftPlayerProxy)entityliving).swingArm = true;
- }
- //worldRef.setBlock(i1, j1, k1, Block.ladder.blockID);
- //Block.blocksList[Block.ladder.blockID].onBlockPlaced(worldRef, (int)player.posX+1, yy, (int)player.posZ, 5);
- }
- }
- }
- public boolean onItemUse(ItemStack var1, EntityLiving var2, World var3, int var4, int var5, int var6, int var7) {
- int var8 = var3.getBlockId(var4, var5, var6);
- if(var8 == Block.snow.blockID) {
- var7 = 0;
- } else if(var8 != Block.vine.blockID) {
- if(var7 == 0) {
- --var5;
- }
- if(var7 == 1) {
- ++var5;
- }
- if(var7 == 2) {
- --var6;
- }
- if(var7 == 3) {
- ++var6;
- }
- if(var7 == 4) {
- --var4;
- }
- if(var7 == 5) {
- ++var4;
- }
- }
- int id = var3.getBlockId(var4, var5, var6);
- if(var1.stackSize == 0) {
- return false;
- } else {
- var3.getClass();
- if(var5 == 128 - 1 && Block.blocksList[this.blockID].blockMaterial.isSolid()) {
- return false;
- } else if(/*id != 0 && */id != Block.ladder.blockID/* || var3.canBlockBePlacedAt(this.blockID, var4, var5, var6, false, var7)*/) {
- Block var9 = Block.blocksList[this.blockID];
- if(var3.setBlockAndMetadataWithNotify(var4, var5, var6, this.blockID, 5)) {
- if(var3.getBlockId(var4, var5, var6) == this.blockID) {
- Block.blocksList[this.blockID].onBlockPlaced(var3, var4, var5, var6, var7);
- Block.blocksList[this.blockID].onBlockPlacedBy(var3, var4, var5, var6, var2);
- }
- var3.playSoundEffect((double)((float)var4 + 0.5F), (double)((float)var5 + 0.5F), (double)((float)var6 + 0.5F), var9.stepSound.stepSoundDir2(), (var9.stepSound.getVolume() + 1.0F) / 2.0F, var9.stepSound.getPitch() * 0.8F);
- --var1.stackSize;
- }
- return true;
- } else {
- return false;
- }
- }
- }
- protected String getLivingSound() {
- return "mob.zombie";
- }
- protected String getHurtSound() {
- return "mob.zombiehurt";
- }
- protected String getDeathSound() {
- return "mob.zombiedeath";
- }
- protected int getDropItemId() {
- return 0;
- }
- public ItemStack getHeldItem() {
- if (getCurrentEquippedItem() != null) { return getCurrentEquippedItem(); } else { return new ItemStack(Item.stick, 1); }
- //return new ItemStack(Block.ladder, 1);
- }
- public ItemStack getCurrentEquippedItem()
- {
- return inventory.getCurrentItem();
- }
- public void setCurrentItem(int slot) {
- inventory.setCurrentItem(slot, 0, false, false);
- //sync();
- }
- public void setCurrentSlot(int slot) {
- inventory.currentItem = slot;
- //sync();
- }
- /*public boolean getCanSpawnHere() {
- if(rand.nextInt(15) == 0) {
- int i = MathHelper.floor_double(posX);
- int j = MathHelper.floor_double(boundingBox.minY);
- int k = MathHelper.floor_double(posZ);
- if(worldObj.getSavedLightValue(EnumSkyBlock.Sky, i, j, k) > rand.nextInt(32)) {
- return false;
- } else {
- int l = worldObj.getBlockLightValue(i, j, k);
- return l <= rand.nextInt(8) && super.getCanSpawnHere();
- }
- } else {
- return false;
- }
- }*/
- @Override
- protected void updateEntityActionState()
- {
- if(findNewPathTick > 0)
- {
- findNewPathTick--;
- }
- hasAttacked = isMovementCeased();
- float f = 16F;
- if(entityToAttack == null)
- {
- entityToAttack = findPlayerToAttack();
- if(entityToAttack != null)
- {
- tryPath(entityToAttack, f);
- //pathToEntity = worldObj.getPathToEntity(this, entityToAttack, f);
- }
- } else
- if(!entityToAttack.isEntityAlive())
- {
- entityToAttack = null;
- } else
- {
- float f1 = entityToAttack.getDistanceToEntity(this);
- if(canEntityBeSeen(entityToAttack))
- {
- attackEntity(entityToAttack, f1);
- } else
- {
- attackBlockedEntity(entityToAttack, f1);
- }
- }
- if(!hasAttacked && entityToAttack != null && (pathToEntity == null/* || rand.nextInt(20) == 0*/))
- {
- tryPath(entityToAttack, f);
- //pathToEntity = worldObj.getPathToEntity(this, entityToAttack, f);
- }
- int i = MathHelper.floor_double(boundingBox.minY + 0.5D);
- boolean flag = isInWater();
- boolean flag1 = handleLavaMovement();
- rotationPitch = 0.0F;
- if(pathToEntity == null/* || rand.nextInt(100) == 0*/)
- {
- //Swticheroo
- //super.updateEntityActionState();
- livingAIUpdate();
- pathToEntity = null;
- return;
- }
- Vec3D vec3d = pathToEntity.getPosition(this);
- for(double d = width * 1.2F; vec3d != null && vec3d.squareDistanceTo(posX, vec3d.yCoord, posZ) < d * d;)
- {
- pathToEntity.incrementPathIndex();
- if(pathToEntity.isFinished())
- {
- vec3d = null;
- pathToEntity = null;
- } else
- {
- vec3d = pathToEntity.getPosition(this);
- }
- }
- isJumping = false;
- if(vec3d != null)
- {
- double d1 = vec3d.xCoord - posX;
- double d2 = vec3d.zCoord - posZ;
- double d3 = vec3d.yCoord - (double)i;
- float f2 = (float)((Math.atan2(d2, d1) * 180D) / 3.1415927410125732D) - 90F;
- float f3 = f2 - rotationYaw;
- moveForward = moveSpeed;
- for(; f3 < -180F; f3 += 360F) { }
- for(; f3 >= 180F; f3 -= 360F) { }
- if(f3 > 30F)
- {
- f3 = 30F;
- }
- if(f3 < -30F)
- {
- f3 = -30F;
- }
- rotationYaw += f3;
- if(hasAttacked && entityToAttack != null)
- {
- double d4 = entityToAttack.posX - posX;
- double d5 = entityToAttack.posZ - posZ;
- float f5 = rotationYaw;
- rotationYaw = (float)((Math.atan2(d5, d4) * 180D) / 3.1415927410125732D) - 90F;
- float f4 = (((f5 - rotationYaw) + 90F) * 3.141593F) / 180F;
- moveStrafing = -MathHelper.sin(f4) * moveForward * 1.0F;
- moveForward = MathHelper.cos(f4) * moveForward * 1.0F;
- }
- if(d3 > 0.0D)
- {
- isJumping = true;
- }
- }
- if(entityToAttack != null)
- {
- faceEntity(entityToAttack, 30F, 30F);
- }
- if(isCollidedHorizontally/* && !hasPath()*/)
- {
- isJumping = true;
- }
- if(rand.nextFloat() < 0.8F && (flag || flag1))
- {
- isJumping = true;
- }
- }
- Entity currentTarget;
- public void livingAIUpdate() {
- entityAge++;
- EntityPlayer entityplayer = worldObj.getClosestPlayerToEntity(this, -1D);
- despawnEntity();
- moveStrafing = 0.0F;
- moveForward = 0.0F;
- boolean flag = isInWater();
- boolean flag1 = handleLavaMovement();
- if(flag || flag1)
- {
- isJumping = rand.nextFloat() < 0.8F;
- }
- //Look code
- if (true) return;
- float f = 8F;
- if(rand.nextFloat() < 0.02F)
- {
- EntityPlayer entityplayer1 = worldObj.getClosestPlayerToEntity(this, f);
- if(entityplayer1 != null)
- {
- currentTarget = entityplayer1;
- numTicksToChaseTarget = 10 + rand.nextInt(20);
- } else
- {
- randomYawVelocity = (rand.nextFloat() - 0.5F) * 20F;
- }
- }
- if(currentTarget != null)
- {
- faceEntity(currentTarget, 10F, getVerticalFaceSpeed());
- if(numTicksToChaseTarget-- <= 0 || currentTarget.isDead || currentTarget.getDistanceSqToEntity(this) > (double)(f * f))
- {
- currentTarget = null;
- }
- } else
- {
- if(rand.nextFloat() < 0.05F)
- {
- randomYawVelocity = (rand.nextFloat() - 0.5F) * 20F;
- }
- rotationYaw += randomYawVelocity;
- rotationPitch = defaultPitch;
- }
- }
- public boolean getCanSpawnHere()
- {
- int i = MathHelper.floor_double(posX);
- int j = MathHelper.floor_double(boundingBox.minY);
- int k = MathHelper.floor_double(posZ);
- return super.getCanSpawnHere() && getBlockPathWeight(i, j, k) >= 0.0F;
- }
- public boolean hasPath()
- {
- return pathToEntity != null;
- }
- //Addition
- public PathEntity getPath() {
- return this.pathToEntity;
- }
- public void setPathToEntity(PathEntity pathentity)
- {
- pathToEntity = pathentity;
- }
- public boolean tryPath(Entity var1, float var2) {
- if(var1 != null) {
- return tryPath((int)(var1.posX+0.5F), (int)(var1.boundingBox.minY), (int)(var1.posZ+0.5F), var2, false);
- } else {
- return false;
- }
- }
- public boolean tryPath(int x, int y, int z, float var2) {
- return tryPath(x, y, z, var2, false);
- }
- public boolean tryPath(int x, int y, int z, float var2, boolean override) {
- if (pfTimeout > 0 && !override) {
- return false;
- }
- //System.out.println("repathing, if this message spams, very bad");
- //Get distance
- float var3 = (float)this.getDistance(x, y, z);
- //float var3 = this.getDistanceToEntity(var1);
- //If too far, return 1 pathpoint with coords of endpoint
- if(var3 > var2) {
- setPathToEntity(getEndPoint(x, y, z));
- pfTimeout = 10;
- return false;
- } else {
- pfTimeout = (int)var2*2 + rand.nextInt(50);
- setPathToEntity(worldObj.getEntityPathToXYZ(this, x, y, z, var2));
- if(this.getPath() == null) {
- pfTimeout = (int)var2*2 + rand.nextInt(200);
- }
- return true;
- }
- }
- public PathEntity getEndPoint(Entity var1) {
- PathPoint points[] = new PathPoint[1];
- points[0] = new PathPoint((int)(var1.posX-0.5), (int)(var1.posY + 0D), (int)(var1.posZ-0.5));
- return new PathEntity(points);
- }
- public PathEntity getEndPoint(int x, int y, int z) {
- PathPoint points[] = new PathPoint[1];
- points[0] = new PathPoint(x, y, z);
- return new PathEntity(points);
- }
- public Entity getEntityToAttack()
- {
- return entityToAttack;
- }
- public void setEntityToAttack(Entity entity)
- {
- entityToAttack = entity;
- }
- protected float getSpeedModifier()
- {
- float f = super.getSpeedModifier();
- if(findNewPathTick > 0)
- {
- f *= 2.0F;
- }
- return f;
- }
- public boolean canCoordBeSeen(int x, int y, int z)
- {
- return worldObj.rayTraceBlocks(Vec3D.createVector(posX, posY + (double)getEyeHeight(), posZ), Vec3D.createVector(x, y, z)) == null;
- }
- public boolean canCoordBeSeenFromFeet(int x, int y, int z)
- {
- return worldObj.rayTraceBlocks(Vec3D.createVector(posX, this.boundingBox.minY+0.15, posZ), Vec3D.createVector(x, y, z)) == null;
- }
- //For mc 1.0
- public int getMaxHealth() {
- return 20;
- }
- public boolean swingArm;
- public int swingTick;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement