Advertisement
Corosus

EntityPlayerProxy

Feb 2nd, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 31.06 KB | None | 0 0
  1. package net.minecraft.src;
  2. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
  3. // Jad home page: http://www.kpdus.com/jad.html
  4. // Decompiler options: packimports(3) braces deadcode
  5.  
  6. import java.util.List;
  7. import java.util.LinkedList;
  8. import java.util.Random;
  9.  
  10. public class EntityTropicraftPlayerProxy extends EntityAnimal {
  11.  
  12.     public MovingObjectPosition aimHit = null;
  13.     public int blockID = Block.ladder.blockID;
  14.    
  15.     public boolean forcejump;
  16.     public boolean mining;
  17.     public int mineDelay;
  18.     public int noMoveTicks;
  19.     public int curCooldown_Melee;
  20.     public int curCooldown_Ranged;
  21.     public int pfTimeout;
  22.    
  23.     //EntityCreature overrides
  24.     private PathEntity pathToEntity;
  25.     protected Entity entityToAttack;
  26.     protected boolean hasAttacked;
  27.     protected int findNewPathTick;
  28.    
  29.     //Customizable item use vars
  30.     public int cooldown_Melee;
  31.     public int cooldown_Ranged;
  32.     public int slot_Melee;
  33.     public int slot_Ranged;
  34.     public float maxReach_Melee;
  35.     public float maxReach_Ranged;
  36.     public int itemSearchRange;
  37.     public List wantedItems;
  38.    
  39.     //Player Faking vars
  40.     public InventoryPlayer inventory;
  41.     public EntityPlayer fakePlayer;
  42.    
  43.     //something that should be moved?
  44.     public EntityTropicalFishHook fishEntity;
  45.     public float castingStrength = 1F;
  46.    
  47.     public EntityTropicraftPlayerProxy(World world) {
  48.         super(world);
  49.         swingArm = false;
  50.         swingTick = 0;
  51.         //texture = "/mob/zombie.png";
  52.         //moveSpeed = 0.8F;
  53.         //attackStrength = 5;
  54.         //health = 40;
  55.         try {
  56.             fakePlayer = new EntityPlayerSP(ModLoader.getMinecraftInstance(), world, ModLoader.getMinecraftInstance().session, world.worldProvider.worldType);
  57.         } catch (Exception ex) {
  58.             return;
  59.         }
  60.  
  61.         inventory = fakePlayer.inventory;      
  62.         sync();
  63.         wantedItems = new LinkedList();
  64.         slot_Melee = 0;
  65.         slot_Ranged = 1;
  66.         cooldown_Melee = 10;
  67.         cooldown_Ranged = 40;
  68.         maxReach_Melee = 2F;
  69.         maxReach_Ranged = 24F;
  70.         itemSearchRange = 5;
  71.        
  72.         //custom mob code init
  73.         //inventory.addItemStackToInventory(new ItemStack(Item.swordDiamond, 1));
  74.         //inventory.addItemStackToInventory(new ItemStack(Item.bow, 1));
  75.         //inventory.addItemStackToInventory(new ItemStack(Item.arrow, 32));
  76.         wantedItems.add(Item.arrow.shiftedIndex);
  77.        
  78.        
  79.         //use canClimb() instead
  80.         //pf.canClimb = true;
  81.     }
  82.    
  83.     protected EntityAnimal spawnBabyAnimal(EntityAnimal entityanimal)
  84.     {
  85.         return new EntityCow(worldObj);
  86.     }
  87.    
  88.     protected void attackEntity(Entity var1, float var2) {
  89.         sync();
  90.         aimAtEnt(var1);
  91.         if (isAimedAtTarget(var1)) {
  92.             if (var2 < maxReach_Melee && var1.boundingBox.maxY > this.boundingBox.minY && var1.boundingBox.minY < this.boundingBox.maxY) {
  93.                 if (curCooldown_Melee <= 0) {
  94.                     this.setCurrentSlot(slot_Melee);
  95.                     leftClickItem(var1);
  96.                     this.curCooldown_Melee = cooldown_Melee;
  97.                 }
  98.             } else if (var2 < maxReach_Ranged) {
  99.                 if (curCooldown_Ranged <= 0) {
  100.                     this.setCurrentSlot(slot_Ranged);
  101.                     rightClickItem();
  102.                     this.curCooldown_Ranged = cooldown_Ranged;
  103.                 }
  104.             }
  105.         }
  106.     }
  107.    
  108.     public void leftClickItem(Entity var1) {
  109.         fakePlayer.attackTargetEntityWithCurrentItem(var1);
  110.         swingItem();
  111.     }
  112.    
  113.     public void rightClickItem() {
  114.         ItemStack itemToUse = this.getCurrentEquippedItem();
  115.         if (itemToUse != null) {
  116.             Item ii = itemToUse.getItem();
  117.             if (ii != null) {
  118.                 if (itemToUse.getItem() instanceof ItemTropicalFishingRod) {
  119.                     ((ItemTropicalFishingRod)itemToUse.getItem()).onItemRightClick2(itemToUse, worldObj, this, castingStrength);
  120.                 } else {
  121.                     itemToUse.useItemRightClick(worldObj, fakePlayer);
  122.                     if (itemToUse.getItem() instanceof ItemBow) {
  123.                         //fakePlayer.itemInUseCount = 0;
  124.                         try {
  125.                             ModLoader.setPrivateValue(EntityPlayer.class, fakePlayer, "e", 0);
  126.                         } catch (Exception ex) {
  127.                             try {
  128.                                 ModLoader.setPrivateValue(EntityPlayer.class, fakePlayer, "itemInUseCount", 0);
  129.                             } catch (Exception ex2) {
  130.                                
  131.                             }
  132.                         }
  133.                         fakePlayer.stopUsingItem();
  134.                     }
  135.                     //useInvItem(itemToUse);
  136.                 }
  137.                 setPrjOwner();
  138.             }
  139.         }
  140.         swingItem();
  141.     }
  142.    
  143.     public void switchItem(int id) {
  144.         if (Item.swordDiamond.shiftedIndex == id) {
  145.             curCooldown_Melee = 0;
  146.         } else if (Item.bow.shiftedIndex == id) {
  147.            
  148.         }
  149.        
  150.         this.setCurrentItem(id);
  151.     }
  152.    
  153.     public void dropCurrentItem()
  154.     {
  155.         dropPlayerItemWithRandomChoice(inventory.decrStackSize(inventory.currentItem, 1), false);
  156.     }
  157.  
  158.     public void dropPlayerItem(ItemStack itemstack)
  159.     {
  160.         dropPlayerItemWithRandomChoice(itemstack, false);
  161.     }
  162.  
  163.     public void dropPlayerItemWithRandomChoice(ItemStack itemstack, boolean flag)
  164.     {
  165.         if(itemstack == null)
  166.         {
  167.             return;
  168.         }
  169.         EntityItem entityitem = new EntityItem(worldObj, posX, (posY - 0.30000001192092896D) + (double)getEyeHeight(), posZ, itemstack);
  170.         entityitem.delayBeforeCanPickup = 40;
  171.         float f = 0.1F;
  172.         if(flag)
  173.         {
  174.             float f2 = rand.nextFloat() * 0.5F;
  175.             float f4 = rand.nextFloat() * 3.141593F * 2.0F;
  176.             entityitem.motionX = -MathHelper.sin(f4) * f2;
  177.             entityitem.motionZ = MathHelper.cos(f4) * f2;
  178.             entityitem.motionY = 0.20000000298023224D;
  179.         } else
  180.         {
  181.             float f1 = 0.3F;
  182.             entityitem.motionX = -MathHelper.sin((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F) * f1;
  183.             entityitem.motionZ = MathHelper.cos((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F) * f1;
  184.             entityitem.motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F) * f1 + 0.1F;
  185.             f1 = 0.02F;
  186.             float f3 = rand.nextFloat() * 3.141593F * 2.0F;
  187.             f1 *= rand.nextFloat();
  188.             entityitem.motionX += Math.cos(f3) * (double)f1;
  189.             entityitem.motionY += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
  190.             entityitem.motionZ += Math.sin(f3) * (double)f1;
  191.         }
  192.         worldObj.spawnEntityInWorld(entityitem);
  193.     }
  194.    
  195.     public void aimAtEnt(Entity ent) {
  196.         this.faceEntity(ent, 180, 180);
  197.     }
  198.    
  199.     public boolean isAimedAtTarget(Entity ent) {
  200.         //eventually put an 'is facing' angle check or something, prevent shooting before turning
  201.         return true;
  202.     }
  203.    
  204.     public void faceCoord(int x, int y, int z, float f, float f1)
  205.     {
  206.         double d = x - posX;
  207.         double d2 = z - posZ;
  208.         double d1;
  209.         d1 = y - (posY + (double)getEyeHeight());
  210.        
  211.         double d3 = MathHelper.sqrt_double(d * d + d2 * d2);
  212.         float f2 = (float)((Math.atan2(d2, d) * 180D) / 3.1415927410125732D) - 90F;
  213.         float f3 = (float)(-((Math.atan2(d1, d3) * 180D) / 3.1415927410125732D));
  214.         rotationPitch = -updateRotation(rotationPitch, f3, f1);
  215.         rotationYaw = updateRotation(rotationYaw, f2, f);
  216.     }
  217.    
  218.     private float updateRotation(float f, float f1, float f2)
  219.     {
  220.         float f3;
  221.         for(f3 = f1 - f; f3 < -180F; f3 += 360F) { }
  222.         for(; f3 >= 180F; f3 -= 360F) { }
  223.         if(f3 > f2)
  224.         {
  225.             f3 = f2;
  226.         }
  227.         if(f3 < -f2)
  228.         {
  229.             f3 = -f2;
  230.         }
  231.         return f + f3;
  232.     }
  233.    
  234.     public void swingItem()
  235.     {
  236.         swingArm = true;
  237.     }
  238.    
  239.     public boolean canClimb() {
  240.         return true;
  241.     }
  242.    
  243.     protected Entity findPlayerToAttack()
  244.     {
  245.         EntityPlayer entityplayer = worldObj.getClosestPlayerToEntity(this, 16D);
  246.         if(entityplayer != null && canEntityBeSeen(entityplayer))
  247.         {
  248.             //NO!
  249.             return null;
  250.         } else
  251.         {
  252.             return null;
  253.         }
  254.     }
  255.    
  256.     public void getPathOrWalkableBlock(Entity entity, float f)
  257.     {
  258.         PathEntity pathentity = worldObj.getPathToEntity(this, entity, 16F);
  259.         if(pathentity == null && f > 12F)
  260.         {
  261.             int i = MathHelper.floor_double(entity.posX) - 2;
  262.             int j = MathHelper.floor_double(entity.posZ) - 2;
  263.             int k = MathHelper.floor_double(entity.boundingBox.minY);
  264.             for(int l = 0; l <= 4; l++)
  265.             {
  266.                 for(int i1 = 0; i1 <= 4; i1++)
  267.                 {
  268.                     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))
  269.                     {
  270.                         setLocationAndAngles((float)(i + l) + 0.5F, k, (float)(j + i1) + 0.5F, rotationYaw, rotationPitch);
  271.                         return;
  272.                     }
  273.                 }
  274.  
  275.             }
  276.  
  277.         } else
  278.         {
  279.             setPathToEntity(pathentity);
  280.         }
  281.     }
  282.  
  283.     public void onLivingUpdate() {
  284.        
  285.         aimHit = rayTrace(1.0D, 1.0F);
  286.        
  287.         if(!handleWaterMovement()/* && !mod_MinerZombie.isSameTeam(this)*/) {
  288.             forcejump = false;
  289.             mineDelay--;
  290.  
  291.             if(mineDelay < 1 && noMoveTicks > 10) {
  292.                 mineDelay = 3;
  293.                 mining = true;
  294.                 if (entityToAttack instanceof EntityLiving) {
  295.                     ItemStack itemToUse = inventory.mainInventory[0];
  296.                     //if (itemToUse.getItem() instanceof ItemBlock) {
  297.                     //mod_MinerZombie.tryDig(this, (EntityLiving)entityToAttack);
  298.                         if (aimHit != null && aimHit.typeOfHit == EnumMovingObjectType.TILE) {
  299.                             if (worldObj.getBlockId(aimHit.blockX, aimHit.blockY, aimHit.blockZ) != 0 && worldObj.getBlockId(aimHit.blockX, aimHit.blockY, aimHit.blockZ) != Block.ladder.blockID) {
  300.                                 //sync();
  301.                                 //int var8 = itemToUse.getBlockId(var4, var5, var6);
  302.                                 //if (!itemToUse.useItem(fakePlayer, worldObj, aimHit.blockX, aimHit.blockY, aimHit.blockZ, aimHit.sideHit)) {
  303.                                     //useInvItem(itemToUse);
  304.                                    
  305.                                 //}
  306.                                 //setPrjOwner();
  307.                                 //System.out.println(worldObj.loadedEntityList.get(worldObj.loadedEntityList.size()-1));
  308.                                 //itemToUse.useItem(itemToUse, this, this.worldObj, aimHit.blockX, aimHit.blockY, aimHit.blockZ, aimHit.sideHit);
  309.                             }
  310.                         }
  311.                     /*} else {
  312.                         useInvItem(itemToUse);
  313.                         setPrjOwner();
  314.                     }*/
  315.                 }
  316.             }
  317. //aimHit.entityHit
  318.             //info = noMoveTicks;
  319.         } else {
  320.             if(this.isCollidedHorizontally && !forcejump) {
  321.                 this.isJumping = true;
  322.             } else {
  323.                 this.isJumping = false;
  324.             }
  325.         }
  326.  
  327.         /*if(!mod_MinerZombie.hostilesBreakWallsB.get()) {
  328.             setEntityDead();
  329.         }*/
  330.  
  331.         if(swingArm) {
  332.             swingTick++;
  333.  
  334.             if(swingTick == 8) {
  335.                 swingTick = 0;
  336.                 swingArm = false;
  337.             }
  338.         } else {
  339.             swingTick = 0;
  340.         }
  341.  
  342.         swingProgress = (float)swingTick / 8F;
  343.        
  344.         //Cooldowns
  345.         if (curCooldown_Melee > 0) { curCooldown_Melee--; }
  346.         if (curCooldown_Ranged > 0) { curCooldown_Ranged--; }
  347.         if(fakePlayer.xpCooldown > 0) {
  348.             --fakePlayer.xpCooldown;
  349.         }
  350.        
  351.         super.onLivingUpdate();
  352.        
  353.         if(this.health > 0) {
  354.             List var3 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(1.0D, 0.0D, 1.0D));
  355.  
  356.             if(var3 != null) {
  357.                 for(int var4 = 0; var4 < var3.size(); ++var4) {
  358.                     Entity var5 = (Entity)var3.get(var4);
  359.  
  360.                     if(!var5.isDead) {
  361.                         var5.onCollideWithPlayer(fakePlayer);
  362.                     }
  363.                 }
  364.             }
  365.         }
  366.     }
  367.    
  368.     public void useInvItem(ItemStack itemstack) {
  369.         //sync();
  370.        
  371.     }
  372.    
  373.     public float getEyeHeight()
  374.     {
  375.         return 0.62F;
  376.     }
  377.  
  378.     protected void resetHeight()
  379.     {
  380.         yOffset = 1.62F;
  381.     }
  382.    
  383.     public void setPrjOwner() {
  384.         Entity ent = (Entity)worldObj.loadedEntityList.get(worldObj.loadedEntityList.size()-1);
  385.         if (ent instanceof EntitySnowball) {
  386.             try {
  387.                 //FIX ME
  388.                 ModLoader.setPrivateValue(EntitySnowball.class, ent, "i have no idea", this);
  389.             } catch (Exception ex) {
  390.                 try {
  391.                     ModLoader.setPrivateValue(EntitySnowball.class, ent, "shootingEntity", this);
  392.                 } catch (Exception ex2) {
  393.                    
  394.                 }
  395.             }
  396.         } else if (ent instanceof EntityArrow) {
  397.             ((EntityArrow) ent).posY += 1F;
  398.             ((EntityArrow) ent).shootingEntity = this;
  399.             ((EntityArrow) ent).doesArrowBelongToPlayer = false;
  400.         } else if (ent instanceof EntityTropicalFishHook) {
  401.             ((EntityTropicalFishHook) ent).angler = this;
  402.         }
  403.        
  404.         //System.out.println(worldObj.loadedEntityList.get(worldObj.loadedEntityList.size()-1));
  405.     }
  406.    
  407.     public void sync() {
  408.         fakePlayer.posX = posX;
  409.         fakePlayer.posY = posY;
  410.         fakePlayer.posZ = posZ;
  411.         fakePlayer.prevPosX = prevPosX;
  412.         fakePlayer.prevPosY = prevPosY;
  413.         fakePlayer.prevPosZ = prevPosZ;
  414.         fakePlayer.rotationPitch = this.rotationPitch;
  415.         fakePlayer.rotationYaw = this.rotationYaw;
  416.         fakePlayer.prevRotationPitch = prevRotationPitch;
  417.         fakePlayer.prevRotationYaw = prevRotationYaw;
  418.        
  419.     }
  420.    
  421.     public int getAimBlockID(int yOffset) {
  422.         EntityLiving entityliving = this;
  423.         float f = 1.0F;
  424.         float f1 = entityliving.prevRotationPitch + (entityliving.rotationPitch - entityliving.prevRotationPitch) * f;
  425.         float f3 = entityliving.prevRotationYaw + (entityliving.rotationYaw - entityliving.prevRotationYaw) * f;
  426.         //int i = (int)Math.floor((double)(f3 / 90F) + 0.5D);
  427.         //f3 = (float)i * 90F;
  428.         double d = entityliving.prevPosX + (entityliving.posX - entityliving.prevPosX) * (double)f;
  429.         double d1 = (entityliving.prevPosY + (entityliving.posY - entityliving.prevPosY) * (double)f + 1.6200000000000001D) - (double)entityliving.yOffset + yOffset;
  430.         double d2 = entityliving.prevPosZ + (entityliving.posZ - entityliving.prevPosZ) * (double)f;
  431.         Vec3D vec3d = Vec3D.createVector(d, d1, d2);
  432.         float f4 = MathHelper.cos(-f3 * 0.01745329F - 3.141593F);
  433.         float f5 = MathHelper.sin(-f3 * 0.01745329F - 3.141593F);
  434.         float f6 = -MathHelper.cos(-f1 * 0.01745329F - 0.7853982F);
  435.         float f7 = MathHelper.sin(-f1 * 0.01745329F - 0.7853982F);
  436.         float f8 = f5 * f6;
  437.         float f9 = f7;
  438.         float f10 = f4 * f6;
  439.         //entityliving.info = f3;
  440.         double d3 = 1.0D;
  441.         Vec3D vec3d1 = vec3d.addVector((double)f8 * d3, (double)f9 * d3, (double)f10 * d3);
  442.         MovingObjectPosition movingobjectposition = entityliving.worldObj.rayTraceBlocks_do(vec3d, vec3d1, true);
  443.  
  444.         int id = -1;
  445.        
  446.         if(movingobjectposition == null) {
  447.             return id;
  448.         }
  449.        
  450.         if(movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) {
  451.             id = worldObj.getBlockId(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
  452.             //System.out.println(movingobjectposition.blockX + " - " + movingobjectposition.blockY + " - " + movingobjectposition.blockZ);
  453.         }
  454.        
  455.         return id;
  456.     }
  457.    
  458.     public void tryPlace(EntityCreature entityliving) {
  459.  
  460.         float f = 2.0F;
  461.         float f1 = entityliving.prevRotationPitch + (entityliving.rotationPitch - entityliving.prevRotationPitch) * f;
  462.         float f2 = entityliving.prevRotationPitch + (entityliving.rotationPitch - entityliving.prevRotationPitch) * f;
  463.         f1 = 0.0F;
  464.         float f3 = entityliving.prevRotationYaw + (entityliving.rotationYaw - entityliving.prevRotationYaw) * f;
  465.         int i = (int)Math.floor((double)(f3 / 90F) + 0.5D);
  466.         f3 = (float)i * 90F;
  467.         double d = entityliving.prevPosX + (entityliving.posX - entityliving.prevPosX) * (double)f;
  468.         double d1 = (entityliving.prevPosY + (entityliving.posY - entityliving.prevPosY) * (double)f + 1.6200000000000001D) - (double)entityliving.yOffset;
  469.         double d2 = entityliving.prevPosZ + (entityliving.posZ - entityliving.prevPosZ) * (double)f;
  470.         Vec3D vec3d = Vec3D.createVector(d, d1, d2);
  471.         float f4 = MathHelper.cos(-f3 * 0.01745329F - 3.141593F);
  472.         float f5 = MathHelper.sin(-f3 * 0.01745329F - 3.141593F);
  473.         float f6 = -MathHelper.cos(-f1 * 0.01745329F - 0.7853982F);
  474.         float f7 = MathHelper.sin(-f1 * 0.01745329F - 0.7853982F);
  475.         float f8 = f5 * f6;
  476.         float f9 = f7;
  477.         float f10 = f4 * f6;
  478.         //entityliving.info = f3;
  479.         double d3 = 1.0D;
  480.         double d4 = 1.8D;
  481.         double d5 = 0.050000000000000003D;
  482.         Vec3D vec3d1 = vec3d.addVector((double)f8 * d3, (double)f9 * d3, (double)f10 * d3);
  483.         MovingObjectPosition movingobjectposition = entityliving.worldObj.rayTraceBlocks_do(vec3d, vec3d1, true);
  484.  
  485.         if(movingobjectposition == null) {
  486.             return;
  487.         }
  488.  
  489.         boolean flag = false;
  490.        
  491.         /*int j = MathHelper.floor_float((float)(entityliving.posX - entityliving1.posX));
  492.         int k = (int)(entityliving.posY - entityliving1.posY);
  493.         int l = MathHelper.floor_float((float)(entityliving.posZ - entityliving1.posZ));
  494.        
  495.  
  496.         if(j + l > 0) {
  497.             if((float)(k / (j + l)) > 1.0F) {
  498.                 flag = true;
  499.             }
  500.         } else if(k > 2) {
  501.             flag = true;
  502.         }*/
  503.  
  504.         if(movingobjectposition.typeOfHit == EnumMovingObjectType.TILE || flag) {
  505.             int i2 = f2 >= -20F ? 0 : 1;
  506.             int i1;
  507.             int j1;
  508.             int k1;
  509.  
  510.             if(flag) {
  511.                 i1 = (int)entityliving.posX;
  512.                 j1 = (int)entityliving.posZ - 1;
  513.                 k1 = (int)entityliving.posZ;
  514.             } else {
  515.                
  516.                
  517.                
  518.                 i1 = movingobjectposition.blockX;
  519.                 j1 = movingobjectposition.blockY + i2;
  520.                 k1 = movingobjectposition.blockZ;
  521.             }
  522.  
  523.             int l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
  524.  
  525.             if(l1 == 0 && (i2 == 1 || flag)) {
  526.                 j1--;
  527.                 l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
  528.  
  529.                 if(l1 == 0 && i2 == 1) {
  530.                     j1--;
  531.                     l1 = entityliving.worldObj.getBlockId(i1, j1, k1);
  532.                 }
  533.             }
  534.  
  535.             /*if(i1 != entityliving.curBlockX || j1 != entityliving.curBlockZ) {
  536.                 entityliving.curBlockDmg = 0.0F;
  537.                 entityliving.curBlockX = i1;
  538.                 entityliving.curBlockZ = j1;
  539.             }*/
  540.  
  541.             Block block = Block.blocksList[l1];
  542.             //float f11 = MiningZombieDigPower.get() * (float)(entityliving.nearbyMinerCount + 1);
  543.  
  544.             if(block != null) {
  545.                 if(entityliving instanceof EntityTropicraftPlayerProxy) {
  546.                     ((EntityTropicraftPlayerProxy)entityliving).swingArm = true;
  547.                 }
  548.  
  549.                
  550.                 //worldRef.setBlock(i1, j1, k1, Block.ladder.blockID);
  551.                 //Block.blocksList[Block.ladder.blockID].onBlockPlaced(worldRef, (int)player.posX+1, yy, (int)player.posZ, 5);
  552.             }
  553.         }
  554.     }
  555.    
  556.     public boolean onItemUse(ItemStack var1, EntityLiving var2, World var3, int var4, int var5, int var6, int var7) {
  557.         int var8 = var3.getBlockId(var4, var5, var6);
  558.         if(var8 == Block.snow.blockID) {
  559.            var7 = 0;
  560.         } else if(var8 != Block.vine.blockID) {
  561.            if(var7 == 0) {
  562.               --var5;
  563.            }
  564.  
  565.            if(var7 == 1) {
  566.               ++var5;
  567.            }
  568.  
  569.            if(var7 == 2) {
  570.               --var6;
  571.            }
  572.  
  573.            if(var7 == 3) {
  574.               ++var6;
  575.            }
  576.  
  577.            if(var7 == 4) {
  578.               --var4;
  579.            }
  580.  
  581.            if(var7 == 5) {
  582.               ++var4;
  583.            }
  584.         }
  585.  
  586.         int id = var3.getBlockId(var4, var5, var6);
  587.        
  588.         if(var1.stackSize == 0) {
  589.            return false;
  590.         } else {
  591.            var3.getClass();
  592.            if(var5 == 128 - 1 && Block.blocksList[this.blockID].blockMaterial.isSolid()) {
  593.               return false;
  594.            } else if(/*id != 0 && */id != Block.ladder.blockID/* || var3.canBlockBePlacedAt(this.blockID, var4, var5, var6, false, var7)*/) {
  595.               Block var9 = Block.blocksList[this.blockID];
  596.               if(var3.setBlockAndMetadataWithNotify(var4, var5, var6, this.blockID, 5)) {
  597.                  if(var3.getBlockId(var4, var5, var6) == this.blockID) {
  598.                     Block.blocksList[this.blockID].onBlockPlaced(var3, var4, var5, var6, var7);
  599.                     Block.blocksList[this.blockID].onBlockPlacedBy(var3, var4, var5, var6, var2);
  600.                  }
  601.  
  602.                  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);
  603.                  --var1.stackSize;
  604.               }
  605.  
  606.               return true;
  607.            } else {
  608.               return false;
  609.            }
  610.         }
  611.      }
  612.  
  613.     protected String getLivingSound() {
  614.         return "mob.zombie";
  615.     }
  616.  
  617.     protected String getHurtSound() {
  618.         return "mob.zombiehurt";
  619.     }
  620.  
  621.     protected String getDeathSound() {
  622.         return "mob.zombiedeath";
  623.     }
  624.  
  625.     protected int getDropItemId() {
  626.         return 0;
  627.     }
  628.  
  629.     public ItemStack getHeldItem() {
  630.         if (getCurrentEquippedItem() != null) { return getCurrentEquippedItem(); } else { return new ItemStack(Item.stick, 1); }
  631.         //return new ItemStack(Block.ladder, 1);
  632.     }
  633.    
  634.     public ItemStack getCurrentEquippedItem()
  635.     {
  636.         return inventory.getCurrentItem();
  637.     }
  638.    
  639.     public void setCurrentItem(int slot) {
  640.         inventory.setCurrentItem(slot, 0, false, false);
  641.         //sync();
  642.     }
  643.    
  644.     public void setCurrentSlot(int slot) {
  645.         inventory.currentItem = slot;
  646.         //sync();
  647.     }
  648.  
  649.     /*public boolean getCanSpawnHere() {
  650.         if(rand.nextInt(15) == 0) {
  651.             int i = MathHelper.floor_double(posX);
  652.             int j = MathHelper.floor_double(boundingBox.minY);
  653.             int k = MathHelper.floor_double(posZ);
  654.  
  655.             if(worldObj.getSavedLightValue(EnumSkyBlock.Sky, i, j, k) > rand.nextInt(32)) {
  656.                 return false;
  657.             } else {
  658.                 int l = worldObj.getBlockLightValue(i, j, k);
  659.                 return l <= rand.nextInt(8) && super.getCanSpawnHere();
  660.             }
  661.         } else {
  662.             return false;
  663.         }
  664.     }*/
  665.    
  666.     @Override
  667.     protected void updateEntityActionState()
  668.     {
  669.         if(findNewPathTick > 0)
  670.         {
  671.             findNewPathTick--;
  672.         }
  673.         hasAttacked = isMovementCeased();
  674.         float f = 16F;
  675.         if(entityToAttack == null)
  676.         {
  677.             entityToAttack = findPlayerToAttack();
  678.             if(entityToAttack != null)
  679.             {
  680.                 tryPath(entityToAttack, f);
  681.                 //pathToEntity = worldObj.getPathToEntity(this, entityToAttack, f);
  682.             }
  683.         } else
  684.         if(!entityToAttack.isEntityAlive())
  685.         {
  686.             entityToAttack = null;
  687.         } else
  688.         {
  689.             float f1 = entityToAttack.getDistanceToEntity(this);
  690.             if(canEntityBeSeen(entityToAttack))
  691.             {
  692.                 attackEntity(entityToAttack, f1);
  693.             } else
  694.             {
  695.                 attackBlockedEntity(entityToAttack, f1);
  696.             }
  697.         }
  698.         if(!hasAttacked && entityToAttack != null && (pathToEntity == null/* || rand.nextInt(20) == 0*/))
  699.         {
  700.             tryPath(entityToAttack, f);
  701.             //pathToEntity = worldObj.getPathToEntity(this, entityToAttack, f);
  702.         }
  703.         int i = MathHelper.floor_double(boundingBox.minY + 0.5D);
  704.         boolean flag = isInWater();
  705.         boolean flag1 = handleLavaMovement();
  706.         rotationPitch = 0.0F;
  707.         if(pathToEntity == null/* || rand.nextInt(100) == 0*/)
  708.         {
  709.             //Swticheroo
  710.             //super.updateEntityActionState();
  711.             livingAIUpdate();
  712.             pathToEntity = null;
  713.             return;
  714.         }
  715.         Vec3D vec3d = pathToEntity.getPosition(this);
  716.         for(double d = width * 1.2F; vec3d != null && vec3d.squareDistanceTo(posX, vec3d.yCoord, posZ) < d * d;)
  717.         {
  718.             pathToEntity.incrementPathIndex();
  719.             if(pathToEntity.isFinished())
  720.             {
  721.                 vec3d = null;
  722.                 pathToEntity = null;
  723.             } else
  724.             {
  725.                 vec3d = pathToEntity.getPosition(this);
  726.             }
  727.         }
  728.  
  729.         isJumping = false;
  730.         if(vec3d != null)
  731.         {
  732.             double d1 = vec3d.xCoord - posX;
  733.             double d2 = vec3d.zCoord - posZ;
  734.             double d3 = vec3d.yCoord - (double)i;
  735.             float f2 = (float)((Math.atan2(d2, d1) * 180D) / 3.1415927410125732D) - 90F;
  736.             float f3 = f2 - rotationYaw;
  737.             moveForward = moveSpeed;
  738.             for(; f3 < -180F; f3 += 360F) { }
  739.             for(; f3 >= 180F; f3 -= 360F) { }
  740.             if(f3 > 30F)
  741.             {
  742.                 f3 = 30F;
  743.             }
  744.             if(f3 < -30F)
  745.             {
  746.                 f3 = -30F;
  747.             }
  748.             rotationYaw += f3;
  749.             if(hasAttacked && entityToAttack != null)
  750.             {
  751.                 double d4 = entityToAttack.posX - posX;
  752.                 double d5 = entityToAttack.posZ - posZ;
  753.                 float f5 = rotationYaw;
  754.                 rotationYaw = (float)((Math.atan2(d5, d4) * 180D) / 3.1415927410125732D) - 90F;
  755.                 float f4 = (((f5 - rotationYaw) + 90F) * 3.141593F) / 180F;
  756.                 moveStrafing = -MathHelper.sin(f4) * moveForward * 1.0F;
  757.                 moveForward = MathHelper.cos(f4) * moveForward * 1.0F;
  758.             }
  759.             if(d3 > 0.0D)
  760.             {
  761.                 isJumping = true;
  762.             }
  763.         }
  764.         if(entityToAttack != null)
  765.         {
  766.             faceEntity(entityToAttack, 30F, 30F);
  767.         }
  768.         if(isCollidedHorizontally/* && !hasPath()*/)
  769.         {
  770.             isJumping = true;
  771.         }
  772.         if(rand.nextFloat() < 0.8F && (flag || flag1))
  773.         {
  774.             isJumping = true;
  775.         }
  776.     }
  777.    
  778.     Entity currentTarget;
  779.     public void livingAIUpdate() {
  780.         entityAge++;
  781.         EntityPlayer entityplayer = worldObj.getClosestPlayerToEntity(this, -1D);
  782.         despawnEntity();
  783.         moveStrafing = 0.0F;
  784.         moveForward = 0.0F;
  785.        
  786.         boolean flag = isInWater();
  787.         boolean flag1 = handleLavaMovement();
  788.         if(flag || flag1)
  789.         {
  790.             isJumping = rand.nextFloat() < 0.8F;
  791.         }
  792.        
  793.         //Look code
  794.         if (true) return;
  795.         float f = 8F;
  796.         if(rand.nextFloat() < 0.02F)
  797.         {
  798.             EntityPlayer entityplayer1 = worldObj.getClosestPlayerToEntity(this, f);
  799.             if(entityplayer1 != null)
  800.             {
  801.                
  802.                 currentTarget = entityplayer1;
  803.                 numTicksToChaseTarget = 10 + rand.nextInt(20);
  804.             } else
  805.             {
  806.                 randomYawVelocity = (rand.nextFloat() - 0.5F) * 20F;
  807.             }
  808.         }
  809.         if(currentTarget != null)
  810.         {
  811.             faceEntity(currentTarget, 10F, getVerticalFaceSpeed());
  812.             if(numTicksToChaseTarget-- <= 0 || currentTarget.isDead || currentTarget.getDistanceSqToEntity(this) > (double)(f * f))
  813.             {
  814.                 currentTarget = null;
  815.             }
  816.         } else
  817.         {
  818.             if(rand.nextFloat() < 0.05F)
  819.             {
  820.                 randomYawVelocity = (rand.nextFloat() - 0.5F) * 20F;
  821.             }
  822.             rotationYaw += randomYawVelocity;
  823.             rotationPitch = defaultPitch;
  824.         }
  825.     }
  826.    
  827.     public boolean getCanSpawnHere()
  828.     {
  829.         int i = MathHelper.floor_double(posX);
  830.         int j = MathHelper.floor_double(boundingBox.minY);
  831.         int k = MathHelper.floor_double(posZ);
  832.         return super.getCanSpawnHere() && getBlockPathWeight(i, j, k) >= 0.0F;
  833.     }
  834.  
  835.     public boolean hasPath()
  836.     {
  837.         return pathToEntity != null;
  838.     }
  839.    
  840.     //Addition
  841.     public PathEntity getPath() {
  842.         return this.pathToEntity;
  843.     }
  844.  
  845.     public void setPathToEntity(PathEntity pathentity)
  846.     {
  847.         pathToEntity = pathentity;
  848.     }
  849.    
  850.     public boolean tryPath(Entity var1, float var2) {
  851.         if(var1 != null) {
  852.             return tryPath((int)(var1.posX+0.5F), (int)(var1.boundingBox.minY), (int)(var1.posZ+0.5F), var2, false);
  853.         } else {
  854.             return false;
  855.         }
  856.     }
  857.    
  858.     public boolean tryPath(int x, int y, int z, float var2) {
  859.         return tryPath(x, y, z, var2, false);
  860.     }
  861.  
  862.     public boolean tryPath(int x, int y, int z, float var2, boolean override) {
  863.         if (pfTimeout > 0 && !override) {
  864.             return false;
  865.         }
  866.         //System.out.println("repathing, if this message spams, very bad");
  867.         //Get distance
  868.         float var3 = (float)this.getDistance(x, y, z);
  869.         //float var3 = this.getDistanceToEntity(var1);
  870.  
  871.         //If too far, return 1 pathpoint with coords of endpoint
  872.         if(var3 > var2) {
  873.             setPathToEntity(getEndPoint(x, y, z));
  874.             pfTimeout = 10;
  875.             return false;
  876.         } else {
  877.             pfTimeout = (int)var2*2 + rand.nextInt(50);
  878.             setPathToEntity(worldObj.getEntityPathToXYZ(this, x, y, z, var2));
  879.             if(this.getPath() == null) {
  880.                 pfTimeout = (int)var2*2 + rand.nextInt(200);
  881.             }
  882.  
  883.             return true;
  884.         }
  885.     }
  886.    
  887.     public PathEntity getEndPoint(Entity var1) {
  888.         PathPoint points[] = new PathPoint[1];
  889.         points[0] = new PathPoint((int)(var1.posX-0.5), (int)(var1.posY + 0D), (int)(var1.posZ-0.5));
  890.         return new PathEntity(points);
  891.     }
  892.    
  893.     public PathEntity getEndPoint(int x, int y, int z) {
  894.         PathPoint points[] = new PathPoint[1];
  895.         points[0] = new PathPoint(x, y, z);
  896.         return new PathEntity(points);
  897.     }
  898.  
  899.     public Entity getEntityToAttack()
  900.     {
  901.         return entityToAttack;
  902.     }
  903.  
  904.     public void setEntityToAttack(Entity entity)
  905.     {
  906.         entityToAttack = entity;
  907.     }
  908.  
  909.     protected float getSpeedModifier()
  910.     {
  911.         float f = super.getSpeedModifier();
  912.         if(findNewPathTick > 0)
  913.         {
  914.             f *= 2.0F;
  915.         }
  916.         return f;
  917.     }
  918.    
  919.     public boolean canCoordBeSeen(int x, int y, int z)
  920.     {
  921.         return worldObj.rayTraceBlocks(Vec3D.createVector(posX, posY + (double)getEyeHeight(), posZ), Vec3D.createVector(x, y, z)) == null;
  922.     }
  923.    
  924.     public boolean canCoordBeSeenFromFeet(int x, int y, int z)
  925.     {
  926.         return worldObj.rayTraceBlocks(Vec3D.createVector(posX, this.boundingBox.minY+0.15, posZ), Vec3D.createVector(x, y, z)) == null;
  927.     }
  928.    
  929.     //For mc 1.0
  930.     public int getMaxHealth() {
  931.         return 20;
  932.     }
  933.  
  934.     public boolean swingArm;
  935.     public int swingTick;
  936. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement