Advertisement
Corosus

Untitled

Feb 2nd, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 35.25 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.util.Iterator;
  4. import java.util.List;
  5. import net.minecraft.src.AchievementList;
  6. import net.minecraft.src.AxisAlignedBB;
  7. import net.minecraft.src.Block;
  8. import net.minecraft.src.BlockBed;
  9. import net.minecraft.src.ChunkCoordinates;
  10. import net.minecraft.src.Container;
  11. import net.minecraft.src.ContainerPlayer;
  12. import net.minecraft.src.DamageSource;
  13. import net.minecraft.src.Entity;
  14. import net.minecraft.src.EntityArrow;
  15. import net.minecraft.src.EntityBoat;
  16. import net.minecraft.src.EntityCreeper;
  17. import net.minecraft.src.EntityFish;
  18. import net.minecraft.src.EntityGhast;
  19. import net.minecraft.src.EntityItem;
  20. import net.minecraft.src.EntityLiving;
  21. import net.minecraft.src.EntityMinecart;
  22. import net.minecraft.src.EntityMob;
  23. import net.minecraft.src.EntityPig;
  24. import net.minecraft.src.EntityWolf;
  25. import net.minecraft.src.EnumAction;
  26. import net.minecraft.src.EnumStatus;
  27. import net.minecraft.src.FoodStats;
  28. import net.minecraft.src.IChunkProvider;
  29. import net.minecraft.src.IInventory;
  30. import net.minecraft.src.InventoryPlayer;
  31. import net.minecraft.src.Item;
  32. import net.minecraft.src.ItemStack;
  33. import net.minecraft.src.Material;
  34. import net.minecraft.src.MathHelper;
  35. import net.minecraft.src.NBTTagCompound;
  36. import net.minecraft.src.NBTTagList;
  37. import net.minecraft.src.PlayerCapabilities;
  38. import net.minecraft.src.Potion;
  39. import net.minecraft.src.StatBase;
  40. import net.minecraft.src.StatList;
  41. import net.minecraft.src.TileEntityDispenser;
  42. import net.minecraft.src.TileEntityFurnace;
  43. import net.minecraft.src.TileEntitySign;
  44. import net.minecraft.src.Vec3D;
  45. import net.minecraft.src.World;
  46. import net.minecraft.src.mod_ZA;
  47.  
  48. public abstract class EntityPlayer extends EntityLiving {
  49.  
  50.    public InventoryPlayer inventory = new InventoryPlayer(this);
  51.    public Container personalCraftingInventory;
  52.    public Container currentCraftingInventory;
  53.    protected FoodStats foodStats = new FoodStats();
  54.    protected int field_35216_n = 0;
  55.    public byte field_9152_am = 0;
  56.    public int score = 0;
  57.    public float prevCameraYaw;
  58.    public float cameraYaw;
  59.    public boolean isSwinging = false;
  60.    public int swingProgressInt = 0;
  61.    public String username;
  62.    public int dimension;
  63.    public int field_35218_w = 0;
  64.    public double field_20047_ay;
  65.    public double field_20046_az;
  66.    public double field_20051_aA;
  67.    public double field_20050_aB;
  68.    public double field_20049_aC;
  69.    public double field_20048_aD;
  70.    protected boolean sleeping;
  71.    public ChunkCoordinates playerLocation;
  72.    private int sleepTimer;
  73.    public float field_22066_z;
  74.    public float field_22067_A;
  75.    private ChunkCoordinates spawnChunk;
  76.    private ChunkCoordinates startMinecartRidingCoordinate;
  77.    public int timeUntilPortal = 20;
  78.    protected boolean inPortal = false;
  79.    public float timeInPortal;
  80.    public PlayerCapabilities field_35214_K = new PlayerCapabilities();
  81.    public int experience;
  82.    public int experienceLevel;
  83.    public int experienceTotal;
  84.    private ItemStack field_34908_d;
  85.    private int field_34909_e;
  86.    protected float field_35213_O = 0.1F;
  87.    protected float field_35215_P = 0.02F;
  88.    private int damageRemainder = 0;
  89.    public EntityFish fishEntity = null;
  90.  
  91.  
  92.    public EntityPlayer(World var1) {
  93.       super(var1);
  94.       this.personalCraftingInventory = new ContainerPlayer(this.inventory, !var1.singleplayerWorld);
  95.       this.currentCraftingInventory = this.personalCraftingInventory;
  96.       this.yOffset = 1.62F;
  97.       ChunkCoordinates var2 = var1.getSpawnPoint();
  98.       this.setLocationAndAngles((double)var2.posX + 0.5D, (double)(var2.posY + 1), (double)var2.posZ + 0.5D, 0.0F, 0.0F);
  99.       this.health = 20;
  100.       this.entityType = "humanoid";
  101.       this.field_9117_aI = 180.0F;
  102.       this.fireResistance = 20;
  103.       this.texture = "/mob/char.png";
  104.    }
  105.  
  106.    protected void entityInit() {
  107.       super.entityInit();
  108.       this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
  109.       this.dataWatcher.addObject(17, Byte.valueOf((byte)0));
  110.    }
  111.  
  112.    public boolean func_35209_o_() {
  113.       return this.field_34908_d != null;
  114.    }
  115.  
  116.    public void func_35196_E() {
  117.       if(this.field_34908_d != null) {
  118.          this.field_34908_d.func_35613_a(this.worldObj, this, this.field_34909_e);
  119.       }
  120.  
  121.       this.func_35205_F();
  122.    }
  123.  
  124.    public void func_35205_F() {
  125.       this.field_34908_d = null;
  126.       this.field_34909_e = 0;
  127.       if(!this.worldObj.singleplayerWorld) {
  128.          this.func_35148_h(false);
  129.       }
  130.  
  131.    }
  132.  
  133.    public boolean func_35180_G() {
  134.       return this.func_35209_o_() && Item.itemsList[this.field_34908_d.itemID].func_35406_b(this.field_34908_d) == EnumAction.block;
  135.    }
  136.  
  137.    public void onUpdate() {
  138.       if(this.field_34908_d != null) {
  139.          ItemStack var1 = this.inventory.getCurrentItem();
  140.          if(var1 != this.field_34908_d) {
  141.             this.func_35205_F();
  142.          } else {
  143.             if(this.field_34909_e <= 25 && this.field_34909_e % 4 == 0) {
  144.                this.func_35208_b(var1, 5);
  145.             }
  146.  
  147.             if(--this.field_34909_e == 0 && !this.worldObj.singleplayerWorld) {
  148.                this.func_35199_C();
  149.             }
  150.          }
  151.       }
  152.  
  153.       if(this.field_35218_w > 0) {
  154.          --this.field_35218_w;
  155.       }
  156.  
  157.       if(this.isPlayerSleeping()) {
  158.          ++this.sleepTimer;
  159.          if(this.sleepTimer > 100) {
  160.             this.sleepTimer = 100;
  161.          }
  162.  
  163.          if(!this.worldObj.singleplayerWorld) {
  164.             if(!this.isInBed()) {
  165.                this.wakeUpPlayer(true, true, false);
  166.             } else if(this.worldObj.isDaytime()) {
  167.                this.wakeUpPlayer(false, true, true);
  168.             }
  169.          }
  170.       } else if(this.sleepTimer > 0) {
  171.          ++this.sleepTimer;
  172.          if(this.sleepTimer >= 110) {
  173.             this.sleepTimer = 0;
  174.          }
  175.       }
  176.  
  177.       super.onUpdate();
  178.       if(!this.worldObj.singleplayerWorld && this.currentCraftingInventory != null && !this.currentCraftingInventory.canInteractWith(this)) {
  179.          this.usePersonalCraftingInventory();
  180.          this.currentCraftingInventory = this.personalCraftingInventory;
  181.       }
  182.  
  183.       if(this.field_35214_K.isFlying) {
  184.          for(int var9 = 0; var9 < 8; ++var9) {
  185.             ;
  186.          }
  187.       }
  188.  
  189.       if(this.fire > 0 && this.field_35214_K.field_35660_a) {
  190.          this.fire = 0;
  191.       }
  192.  
  193.       this.field_20047_ay = this.field_20050_aB;
  194.       this.field_20046_az = this.field_20049_aC;
  195.       this.field_20051_aA = this.field_20048_aD;
  196.       double var10 = this.posX - this.field_20050_aB;
  197.       double var3 = this.posY - this.field_20049_aC;
  198.       double var5 = this.posZ - this.field_20048_aD;
  199.       double var7 = 10.0D;
  200.       if(var10 > var7) {
  201.          this.field_20047_ay = this.field_20050_aB = this.posX;
  202.       }
  203.  
  204.       if(var5 > var7) {
  205.          this.field_20051_aA = this.field_20048_aD = this.posZ;
  206.       }
  207.  
  208.       if(var3 > var7) {
  209.          this.field_20046_az = this.field_20049_aC = this.posY;
  210.       }
  211.  
  212.       if(var10 < -var7) {
  213.          this.field_20047_ay = this.field_20050_aB = this.posX;
  214.       }
  215.  
  216.       if(var5 < -var7) {
  217.          this.field_20051_aA = this.field_20048_aD = this.posZ;
  218.       }
  219.  
  220.       if(var3 < -var7) {
  221.          this.field_20046_az = this.field_20049_aC = this.posY;
  222.       }
  223.  
  224.       this.field_20050_aB += var10 * 0.25D;
  225.       this.field_20048_aD += var5 * 0.25D;
  226.       this.field_20049_aC += var3 * 0.25D;
  227.       this.addStat(StatList.minutesPlayedStat, 1);
  228.       if(this.ridingEntity == null) {
  229.          this.startMinecartRidingCoordinate = null;
  230.       }
  231.  
  232.       if(!this.worldObj.singleplayerWorld) {
  233.          this.foodStats.update(this);
  234.       }
  235.  
  236.    }
  237.  
  238.    protected void func_35208_b(ItemStack var1, int var2) {
  239.       if(var1.func_35615_m() == EnumAction.eat) {
  240.          for(int var3 = 0; var3 < var2; ++var3) {
  241.             Vec3D var4 = Vec3D.createVector(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
  242.             var4.func_35571_a(-this.rotationPitch * 3.1415927F / 180.0F);
  243.             var4.func_35572_b(-this.rotationYaw * 3.1415927F / 180.0F);
  244.             Vec3D var5 = Vec3D.createVector(((double)this.rand.nextFloat() - 0.5D) * 0.3D, (double)(-this.rand.nextFloat()) * 0.6D - 0.3D, 0.6D);
  245.             var5.func_35571_a(-this.rotationPitch * 3.1415927F / 180.0F);
  246.             var5.func_35572_b(-this.rotationYaw * 3.1415927F / 180.0F);
  247.             var5 = var5.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
  248.             this.worldObj.spawnParticle("iconcrack_" + var1.getItem().shiftedIndex, var5.xCoord, var5.yCoord, var5.zCoord, var4.xCoord, var4.yCoord + 0.05D, var4.zCoord);
  249.          }
  250.  
  251.          this.worldObj.playSoundAtEntity(this, "mob.eat", 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
  252.       }
  253.  
  254.    }
  255.  
  256.    protected void func_35199_C() {
  257.       if(this.field_34908_d != null) {
  258.          this.func_35208_b(this.field_34908_d, 16);
  259.          int var1 = this.field_34908_d.stackSize;
  260.          ItemStack var2 = this.field_34908_d.func_35617_b(this.worldObj, this);
  261.          if(var2 != this.field_34908_d || var2 != null && var2.stackSize != var1) {
  262.             this.inventory.mainInventory[this.inventory.currentItem] = var2;
  263.             if(var2.stackSize == 0) {
  264.                this.inventory.mainInventory[this.inventory.currentItem] = null;
  265.             }
  266.          }
  267.  
  268.          this.func_35205_F();
  269.       }
  270.  
  271.    }
  272.  
  273.    protected boolean isMovementBlocked() {
  274.       return this.health <= 0 || this.isPlayerSleeping();
  275.    }
  276.  
  277.    protected void usePersonalCraftingInventory() {
  278.       this.currentCraftingInventory = this.personalCraftingInventory;
  279.    }
  280.  
  281.    public void updateRidden() {
  282.       double var1 = this.posX;
  283.       double var3 = this.posY;
  284.       double var5 = this.posZ;
  285.       super.updateRidden();
  286.       this.prevCameraYaw = this.cameraYaw;
  287.       this.cameraYaw = 0.0F;
  288.       this.addMountedMovementStat(this.posX - var1, this.posY - var3, this.posZ - var5);
  289.    }
  290.  
  291.    private int func_35204_o() {
  292.       return this.func_35184_a(Potion.digSpeed)?6 - (1 + this.func_35187_b(Potion.digSpeed).func_35652_c()) * 1:(this.func_35184_a(Potion.digSlowdown)?6 + (1 + this.func_35187_b(Potion.digSlowdown).func_35652_c()) * 2:6);
  293.    }
  294.  
  295.    protected void updateEntityActionState() {
  296.       int var1 = this.func_35204_o();
  297.       if(this.isSwinging) {
  298.          ++this.swingProgressInt;
  299.          if(this.swingProgressInt >= var1) {
  300.             this.swingProgressInt = 0;
  301.             this.isSwinging = false;
  302.          }
  303.       } else {
  304.          this.swingProgressInt = 0;
  305.       }
  306.  
  307.       this.swingProgress = (float)this.swingProgressInt / (float)var1;
  308.    }
  309.  
  310.    public void onLivingUpdate() {
  311.       if(this.field_35216_n > 0) {
  312.          --this.field_35216_n;
  313.       }
  314.  
  315.       if(this.worldObj.difficultySetting == 0 && this.health < 20 && this.ticksExisted % 20 * 12 == 0) {
  316.          this.heal(1);
  317.       }
  318.  
  319.       this.inventory.decrementAnimations();
  320.       this.prevCameraYaw = this.cameraYaw;
  321.       super.onLivingUpdate();
  322.       this.field_35194_aj = this.field_35213_O;
  323.       this.field_35193_ak = this.field_35215_P;
  324.       if(this.getSprinting()) {
  325.          this.field_35194_aj = (float)((double)this.field_35194_aj + (double)this.field_35213_O * 0.3D);
  326.          this.field_35193_ak = (float)((double)this.field_35193_ak + (double)this.field_35215_P * 0.3D);
  327.       }
  328.  
  329.       float var1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
  330.       float var2 = (float)Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F;
  331.       if(var1 > 0.1F) {
  332.          var1 = 0.1F;
  333.       }
  334.  
  335.       if(!this.onGround || this.health <= 0) {
  336.          var1 = 0.0F;
  337.       }
  338.  
  339.       if(this.onGround || this.health <= 0) {
  340.          var2 = 0.0F;
  341.       }
  342.  
  343.       this.cameraYaw += (var1 - this.cameraYaw) * 0.4F;
  344.       this.cameraPitch += (var2 - this.cameraPitch) * 0.8F;
  345.       if(this.health > 0) {
  346.          List var3 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(1.0D, 0.0D, 1.0D));
  347.          if(var3 != null) {
  348.             for(int var4 = 0; var4 < var3.size(); ++var4) {
  349.                Entity var5 = (Entity)var3.get(var4);
  350.                if(!var5.isDead) {
  351.                   this.collideWithPlayer(var5);
  352.                }
  353.             }
  354.          }
  355.       }
  356.  
  357.    }
  358.  
  359.    private void collideWithPlayer(Entity var1) {
  360.       var1.onCollideWithPlayer(this);
  361.    }
  362.  
  363.    public void onDeath(DamageSource var1) {
  364.       super.onDeath(var1);
  365.       this.setSize(0.2F, 0.2F);
  366.       this.setPosition(this.posX, this.posY, this.posZ);
  367.       this.motionY = 0.10000000149011612D;
  368.       if(this.username.equals("Notch")) {
  369.          this.dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true);
  370.       }
  371.  
  372.       this.inventory.dropAllItems();
  373.       if(var1 != null) {
  374.          this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * 3.1415927F / 180.0F) * 0.1F);
  375.          this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * 3.1415927F / 180.0F) * 0.1F);
  376.       } else {
  377.          this.motionX = this.motionZ = 0.0D;
  378.       }
  379.  
  380.       this.yOffset = 0.1F;
  381.       this.addStat(StatList.deathsStat, 1);
  382.    }
  383.  
  384.    public void addToPlayerScore(Entity var1, int var2) {
  385.       this.score += var2;
  386.       if(var1 instanceof EntityPlayer) {
  387.          this.addStat(StatList.playerKillsStat, 1);
  388.       } else {
  389.          this.addStat(StatList.mobKillsStat, 1);
  390.       }
  391.  
  392.    }
  393.  
  394.    public void dropCurrentItem() {
  395.       this.dropPlayerItemWithRandomChoice(this.inventory.decrStackSize(this.inventory.currentItem, 1), false);
  396.    }
  397.  
  398.    public void dropPlayerItem(ItemStack var1) {
  399.       this.dropPlayerItemWithRandomChoice(var1, false);
  400.    }
  401.  
  402.    public void dropPlayerItemWithRandomChoice(ItemStack var1, boolean var2) {
  403.       if(var1 != null) {
  404.          EntityItem var3 = new EntityItem(this.worldObj, this.posX, this.posY - 0.30000001192092896D + (double)this.getEyeHeight(), this.posZ, var1);
  405.          var3.delayBeforeCanPickup = 40;
  406.          float var4 = 0.1F;
  407.          float var5;
  408.          if(var2) {
  409.             var5 = this.rand.nextFloat() * 0.5F;
  410.             float var6 = this.rand.nextFloat() * 3.1415927F * 2.0F;
  411.             var3.motionX = (double)(-MathHelper.sin(var6) * var5);
  412.             var3.motionZ = (double)(MathHelper.cos(var6) * var5);
  413.             var3.motionY = 0.20000000298023224D;
  414.          } else {
  415.             var4 = 0.3F;
  416.             var3.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * 3.1415927F) * MathHelper.cos(this.rotationPitch / 180.0F * 3.1415927F) * var4);
  417.             var3.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * 3.1415927F) * MathHelper.cos(this.rotationPitch / 180.0F * 3.1415927F) * var4);
  418.             var3.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * 3.1415927F) * var4 + 0.1F);
  419.             var4 = 0.02F;
  420.             var5 = this.rand.nextFloat() * 3.1415927F * 2.0F;
  421.             var4 *= this.rand.nextFloat();
  422.             var3.motionX += Math.cos((double)var5) * (double)var4;
  423.             var3.motionY += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
  424.             var3.motionZ += Math.sin((double)var5) * (double)var4;
  425.          }
  426.  
  427.          this.joinEntityItemWithWorld(var3);
  428.          this.addStat(StatList.dropStat, 1);
  429.       }
  430.  
  431.    }
  432.  
  433.    protected void joinEntityItemWithWorld(EntityItem var1) {
  434.       this.worldObj.entityJoinedWorld(var1);
  435.    }
  436.  
  437.    public float getCurrentPlayerStrVsBlock(Block var1) {
  438.       float var2 = this.inventory.getStrVsBlock(var1);
  439.       if(this.isInsideOfMaterial(Material.water)) {
  440.          var2 /= 5.0F;
  441.       }
  442.  
  443.       if(!this.onGround) {
  444.          var2 /= 5.0F;
  445.       }
  446.  
  447.       if(this.func_35184_a(Potion.digSpeed)) {
  448.          var2 *= 1.0F + (float)(this.func_35187_b(Potion.digSpeed).func_35652_c() + 1) * 0.2F;
  449.       }
  450.  
  451.       if(this.func_35184_a(Potion.digSlowdown)) {
  452.          var2 *= 1.0F - (float)(this.func_35187_b(Potion.digSlowdown).func_35652_c() + 1) * 0.2F;
  453.       }
  454.  
  455.       return var2;
  456.    }
  457.  
  458.    public boolean canHarvestBlock(Block var1) {
  459.       return this.inventory.canHarvestBlock(var1);
  460.    }
  461.  
  462.    public void readEntityFromNBT(NBTTagCompound var1) {
  463.       super.readEntityFromNBT(var1);
  464.       NBTTagList var2 = var1.getTagList("Inventory");
  465.       this.inventory.readFromNBT(var2);
  466.       this.dimension = var1.getInteger("Dimension");
  467.       this.sleeping = var1.getBoolean("Sleeping");
  468.       this.sleepTimer = var1.getShort("SleepTimer");
  469.       this.experience = var1.getInteger("Xp");
  470.       this.experienceLevel = var1.getInteger("XpLevel");
  471.       this.experienceTotal = var1.getInteger("XpTotal");
  472.       if(this.sleeping) {
  473.          this.playerLocation = new ChunkCoordinates(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ));
  474.          this.wakeUpPlayer(true, true, false);
  475.       }
  476.  
  477.       if(var1.hasKey("SpawnX") && var1.hasKey("SpawnY") && var1.hasKey("SpawnZ")) {
  478.          this.spawnChunk = new ChunkCoordinates(var1.getInteger("SpawnX"), var1.getInteger("SpawnY"), var1.getInteger("SpawnZ"));
  479.       }
  480.  
  481.       this.foodStats.readNBT(var1);
  482.    }
  483.  
  484.    public void writeEntityToNBT(NBTTagCompound var1) {
  485.       super.writeEntityToNBT(var1);
  486.       var1.setTag("Inventory", this.inventory.writeToNBT(new NBTTagList()));
  487.       var1.setInteger("Dimension", this.dimension);
  488.       var1.setBoolean("Sleeping", this.sleeping);
  489.       var1.setShort("SleepTimer", (short)this.sleepTimer);
  490.       var1.setInteger("Xp", this.experience);
  491.       var1.setInteger("XpLevel", this.experienceLevel);
  492.       var1.setInteger("XpTotal", this.experienceTotal);
  493.       if(this.spawnChunk != null) {
  494.          var1.setInteger("SpawnX", this.spawnChunk.posX);
  495.          var1.setInteger("SpawnY", this.spawnChunk.posY);
  496.          var1.setInteger("SpawnZ", this.spawnChunk.posZ);
  497.       }
  498.  
  499.       this.foodStats.writeNBT(var1);
  500.    }
  501.  
  502.    public void displayGUIChest(IInventory var1) {}
  503.  
  504.    public void displayWorkbenchGUI(int var1, int var2, int var3) {}
  505.  
  506.    public void onItemPickup(Entity var1, int var2) {}
  507.  
  508.    public float getEyeHeight() {
  509.       return 0.12F;
  510.    }
  511.  
  512.    protected void resetHeight() {
  513.       this.yOffset = 1.62F;
  514.    }
  515.  
  516.    public boolean attackEntityFrom(DamageSource var1, int var2) {
  517.       mod_ZA.AttackFromHook(this, var1, var2);
  518.       if(this.field_35214_K.field_35660_a && !var1.func_35077_d()) {
  519.          return false;
  520.       } else {
  521.          this.entityAge = 0;
  522.          if(this.health <= 0) {
  523.             return false;
  524.          } else {
  525.             if(this.isPlayerSleeping() && !this.worldObj.singleplayerWorld) {
  526.                this.wakeUpPlayer(true, true, false);
  527.             }
  528.  
  529.             Entity var3 = var1.getEntity();
  530.             if(var3 instanceof EntityMob || var3 instanceof EntityArrow) {
  531.                if(this.worldObj.difficultySetting == 0) {
  532.                   var2 = 0;
  533.                }
  534.  
  535.                if(this.worldObj.difficultySetting == 1) {
  536.                   var2 = var2 / 3 + 1;
  537.                }
  538.  
  539.                if(this.worldObj.difficultySetting == 3) {
  540.                   var2 = var2 * 3 / 2;
  541.                }
  542.             }
  543.  
  544.             if(var2 == 0) {
  545.                return false;
  546.             } else {
  547.                Entity var4 = var3;
  548.                if(var3 instanceof EntityArrow && ((EntityArrow)var3).shootingEntity != null) {
  549.                   var4 = ((EntityArrow)var3).shootingEntity;
  550.                }
  551.  
  552.                if(var4 instanceof EntityLiving) {
  553.                   this.alertWolves((EntityLiving)var4, false);
  554.                }
  555.  
  556.                this.addStat(StatList.damageTakenStat, var2);
  557.                return super.attackEntityFrom(var1, var2);
  558.             }
  559.          }
  560.       }
  561.    }
  562.  
  563.    protected boolean isPVPEnabled() {
  564.       return false;
  565.    }
  566.  
  567.    protected void alertWolves(EntityLiving var1, boolean var2) {
  568.       if(!(var1 instanceof EntityCreeper) && !(var1 instanceof EntityGhast)) {
  569.          if(var1 instanceof EntityWolf) {
  570.             EntityWolf var3 = (EntityWolf)var1;
  571.             if(var3.isTamed() && this.username.equals(var3.getOwner())) {
  572.                return;
  573.             }
  574.          }
  575.  
  576.          if(!(var1 instanceof EntityPlayer) || this.isPVPEnabled()) {
  577.             List var7 = this.worldObj.getEntitiesWithinAABB(EntityWolf.class, AxisAlignedBB.getBoundingBoxFromPool(this.posX, this.posY, this.posZ, this.posX + 1.0D, this.posY + 1.0D, this.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D));
  578.             Iterator var4 = var7.iterator();
  579.  
  580.             while(var4.hasNext()) {
  581.                Entity var5 = (Entity)var4.next();
  582.                EntityWolf var6 = (EntityWolf)var5;
  583.                if(var6.isTamed() && var6.getEntityToAttack() == null && this.username.equals(var6.getOwner()) && (!var2 || !var6.getIsSitting())) {
  584.                   var6.setIsSitting(false);
  585.                   var6.setTarget(var1);
  586.                }
  587.             }
  588.          }
  589.       }
  590.  
  591.    }
  592.  
  593.    protected void damageEntity(DamageSource var1, int var2) {
  594.       if(!var1.func_35083_b() && this.func_35180_G()) {
  595.          var2 = 1 + var2 >> 1;
  596.       }
  597.  
  598.       if(!var1.func_35083_b()) {
  599.          int var3 = 25 - this.inventory.getTotalArmorValue();
  600.          int var4 = var2 * var3 + this.damageRemainder;
  601.          this.inventory.damageArmor(var2);
  602.          var2 = var4 / 25;
  603.          this.damageRemainder = var4 % 25;
  604.       }
  605.  
  606.       this.func_35198_b(var1.func_35074_c());
  607.       super.damageEntity(var1, var2);
  608.    }
  609.  
  610.    public void displayGUIFurnace(TileEntityFurnace var1) {}
  611.  
  612.    public void displayGUIDispenser(TileEntityDispenser var1) {}
  613.  
  614.    public void displayGUIEditSign(TileEntitySign var1) {}
  615.  
  616.    public void useCurrentItemOnEntity(Entity var1) {
  617.       if(!var1.interact(this)) {
  618.          ItemStack var2 = this.getCurrentEquippedItem();
  619.          if(var2 != null && var1 instanceof EntityLiving) {
  620.             var2.useItemOnEntity((EntityLiving)var1);
  621.             if(var2.stackSize <= 0) {
  622.                var2.onItemDestroyedByUse(this);
  623.                this.destroyCurrentEquippedItem();
  624.             }
  625.          }
  626.       }
  627.  
  628.    }
  629.  
  630.    public ItemStack getCurrentEquippedItem() {
  631.       return this.inventory.getCurrentItem();
  632.    }
  633.  
  634.    public void destroyCurrentEquippedItem() {
  635.       this.inventory.setInventorySlotContents(this.inventory.currentItem, (ItemStack)null);
  636.    }
  637.  
  638.    public double getYOffset() {
  639.       return (double)(this.yOffset - 0.5F);
  640.    }
  641.  
  642.    public void swingItem() {
  643.       if(!this.isSwinging || this.swingProgressInt >= this.func_35204_o() / 2 || this.swingProgressInt < 0) {
  644.          this.swingProgressInt = -1;
  645.          this.isSwinging = true;
  646.       }
  647.  
  648.    }
  649.  
  650.    public void attackTargetEntityWithCurrentItem(Entity var1) {
  651.       int var2 = this.inventory.getDamageVsEntity(var1);
  652.       if(var2 > 0) {
  653.          boolean var3 = this.motionY < 0.0D && !this.onGround && !this.isOnLadder() && !this.isInWater();
  654.          if(var3) {
  655.             var2 = var2 * 3 / 2 + 1;
  656.          }
  657.  
  658.          boolean var4 = var1.attackEntityFrom(DamageSource.causePlayerDamage(this), var2);
  659.          if(var4) {
  660.             if(this.getSprinting()) {
  661.                var1.addVelocity((double)(-MathHelper.sin(this.rotationYaw * 3.1415927F / 180.0F) * 1.0F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * 3.1415927F / 180.0F) * 1.0F));
  662.                this.motionX *= 0.6D;
  663.                this.motionZ *= 0.6D;
  664.                this.setSprinting(false);
  665.             }
  666.  
  667.             if(var3) {
  668.                this.func_35202_e(var1);
  669.             }
  670.          }
  671.  
  672.          ItemStack var5 = this.getCurrentEquippedItem();
  673.          if(var5 != null && var1 instanceof EntityLiving) {
  674.             var5.hitEntity((EntityLiving)var1, this);
  675.             if(var5.stackSize <= 0) {
  676.                var5.onItemDestroyedByUse(this);
  677.                this.destroyCurrentEquippedItem();
  678.             }
  679.          }
  680.  
  681.          if(var1 instanceof EntityLiving) {
  682.             if(var1.isEntityAlive()) {
  683.                this.alertWolves((EntityLiving)var1, true);
  684.             }
  685.  
  686.             this.addStat(StatList.damageDealtStat, var2);
  687.          }
  688.  
  689.          this.func_35198_b(0.3F);
  690.       }
  691.  
  692.    }
  693.  
  694.    public void func_35202_e(Entity var1) {}
  695.  
  696.    public void onItemStackChanged(ItemStack var1) {}
  697.  
  698.    public void setEntityDead() {
  699.       super.setEntityDead();
  700.       this.personalCraftingInventory.onCraftGuiClosed(this);
  701.       if(this.currentCraftingInventory != null) {
  702.          this.currentCraftingInventory.onCraftGuiClosed(this);
  703.       }
  704.  
  705.    }
  706.  
  707.    public boolean isEntityInsideOpaqueBlock() {
  708.       return !this.sleeping && super.isEntityInsideOpaqueBlock();
  709.    }
  710.  
  711.    public EnumStatus sleepInBedAt(int var1, int var2, int var3) {
  712.       if(!this.worldObj.singleplayerWorld) {
  713.          if(this.isPlayerSleeping() || !this.isEntityAlive()) {
  714.             return EnumStatus.OTHER_PROBLEM;
  715.          }
  716.  
  717.          if(this.worldObj.worldProvider.canSleepInWorld) {
  718.             return EnumStatus.NOT_POSSIBLE_HERE;
  719.          }
  720.  
  721.          if(this.worldObj.isDaytime()) {
  722.             return EnumStatus.NOT_POSSIBLE_NOW;
  723.          }
  724.  
  725.          if(Math.abs(this.posX - (double)var1) > 3.0D || Math.abs(this.posY - (double)var2) > 2.0D || Math.abs(this.posZ - (double)var3) > 3.0D) {
  726.             return EnumStatus.TOO_FAR_AWAY;
  727.          }
  728.       }
  729.  
  730.       this.setSize(0.2F, 0.2F);
  731.       this.yOffset = 0.2F;
  732.       if(this.worldObj.blockExists(var1, var2, var3)) {
  733.          int var4 = this.worldObj.getBlockMetadata(var1, var2, var3);
  734.          int var5 = BlockBed.getDirectionFromMetadata(var4);
  735.          float var6 = 0.5F;
  736.          float var7 = 0.5F;
  737.          switch(var5) {
  738.          case 0:
  739.             var7 = 0.9F;
  740.             break;
  741.          case 1:
  742.             var6 = 0.1F;
  743.             break;
  744.          case 2:
  745.             var7 = 0.1F;
  746.             break;
  747.          case 3:
  748.             var6 = 0.9F;
  749.          }
  750.  
  751.          this.func_22059_e(var5);
  752.          this.setPosition((double)((float)var1 + var6), (double)((float)var2 + 0.9375F), (double)((float)var3 + var7));
  753.       } else {
  754.          this.setPosition((double)((float)var1 + 0.5F), (double)((float)var2 + 0.9375F), (double)((float)var3 + 0.5F));
  755.       }
  756.  
  757.       this.sleeping = true;
  758.       this.sleepTimer = 0;
  759.       this.playerLocation = new ChunkCoordinates(var1, var2, var3);
  760.       this.motionX = this.motionZ = this.motionY = 0.0D;
  761.       if(!this.worldObj.singleplayerWorld) {
  762.          this.worldObj.updateAllPlayersSleepingFlag();
  763.       }
  764.  
  765.       return EnumStatus.OK;
  766.    }
  767.  
  768.    private void func_22059_e(int var1) {
  769.       this.field_22066_z = 0.0F;
  770.       this.field_22067_A = 0.0F;
  771.       switch(var1) {
  772.       case 0:
  773.          this.field_22067_A = -1.8F;
  774.          break;
  775.       case 1:
  776.          this.field_22066_z = 1.8F;
  777.          break;
  778.       case 2:
  779.          this.field_22067_A = 1.8F;
  780.          break;
  781.       case 3:
  782.          this.field_22066_z = -1.8F;
  783.       }
  784.  
  785.    }
  786.  
  787.    public void wakeUpPlayer(boolean var1, boolean var2, boolean var3) {
  788.       this.setSize(0.6F, 1.8F);
  789.       this.resetHeight();
  790.       ChunkCoordinates var4 = this.playerLocation;
  791.       ChunkCoordinates var5 = this.playerLocation;
  792.       if(var4 != null && this.worldObj.getBlockId(var4.posX, var4.posY, var4.posZ) == Block.bed.blockID) {
  793.          BlockBed.setBedOccupied(this.worldObj, var4.posX, var4.posY, var4.posZ, false);
  794.          var5 = BlockBed.getNearestEmptyChunkCoordinates(this.worldObj, var4.posX, var4.posY, var4.posZ, 0);
  795.          if(var5 == null) {
  796.             var5 = new ChunkCoordinates(var4.posX, var4.posY + 1, var4.posZ);
  797.          }
  798.  
  799.          this.setPosition((double)((float)var5.posX + 0.5F), (double)((float)var5.posY + this.yOffset + 0.1F), (double)((float)var5.posZ + 0.5F));
  800.       }
  801.  
  802.       this.sleeping = false;
  803.       if(!this.worldObj.singleplayerWorld && var2) {
  804.          this.worldObj.updateAllPlayersSleepingFlag();
  805.       }
  806.  
  807.       if(var1) {
  808.          this.sleepTimer = 0;
  809.       } else {
  810.          this.sleepTimer = 100;
  811.       }
  812.  
  813.       if(var3) {
  814.          this.setSpawnChunk(this.playerLocation);
  815.       }
  816.  
  817.    }
  818.  
  819.    private boolean isInBed() {
  820.       return this.worldObj.getBlockId(this.playerLocation.posX, this.playerLocation.posY, this.playerLocation.posZ) == Block.bed.blockID;
  821.    }
  822.  
  823.    public static ChunkCoordinates verifyBedCoordinates(World var0, ChunkCoordinates var1) {
  824.       IChunkProvider var2 = var0.getChunkProvider();
  825.       var2.loadChunk(var1.posX - 3 >> 4, var1.posZ - 3 >> 4);
  826.       var2.loadChunk(var1.posX + 3 >> 4, var1.posZ - 3 >> 4);
  827.       var2.loadChunk(var1.posX - 3 >> 4, var1.posZ + 3 >> 4);
  828.       var2.loadChunk(var1.posX + 3 >> 4, var1.posZ + 3 >> 4);
  829.       if(var0.getBlockId(var1.posX, var1.posY, var1.posZ) != Block.bed.blockID) {
  830.          return null;
  831.       } else {
  832.          ChunkCoordinates var3 = BlockBed.getNearestEmptyChunkCoordinates(var0, var1.posX, var1.posY, var1.posZ, 0);
  833.          return var3;
  834.       }
  835.    }
  836.  
  837.    public boolean isPlayerSleeping() {
  838.       return this.sleeping;
  839.    }
  840.  
  841.    public boolean isPlayerFullyAsleep() {
  842.       return this.sleeping && this.sleepTimer >= 100;
  843.    }
  844.  
  845.    public void addChatMessage(String var1) {}
  846.  
  847.    public ChunkCoordinates getSpawnChunk() {
  848.       return this.spawnChunk;
  849.    }
  850.  
  851.    public void setSpawnChunk(ChunkCoordinates var1) {
  852.       if(var1 != null) {
  853.          this.spawnChunk = new ChunkCoordinates(var1);
  854.       } else {
  855.          this.spawnChunk = null;
  856.       }
  857.  
  858.    }
  859.  
  860.    public void triggerAchievement(StatBase var1) {
  861.       this.addStat(var1, 1);
  862.    }
  863.  
  864.    public void addStat(StatBase var1, int var2) {}
  865.  
  866.    protected void jump() {
  867.       super.jump();
  868.       this.addStat(StatList.jumpStat, 1);
  869.       if(this.getSprinting()) {
  870.          this.func_35198_b(0.8F);
  871.       } else {
  872.          this.func_35198_b(0.2F);
  873.       }
  874.  
  875.    }
  876.  
  877.    public void moveEntityWithHeading(float var1, float var2) {
  878.       double var3 = this.posX;
  879.       double var5 = this.posY;
  880.       double var7 = this.posZ;
  881.       if(this.field_35214_K.isFlying) {
  882.          double var9 = this.motionY;
  883.          float var11 = this.field_35193_ak;
  884.          this.field_35193_ak = 0.05F;
  885.          super.moveEntityWithHeading(var1, var2);
  886.          this.motionY = var9 * 0.6D;
  887.          this.field_35193_ak = var11;
  888.       } else {
  889.          super.moveEntityWithHeading(var1, var2);
  890.       }
  891.  
  892.       this.addMovementStat(this.posX - var3, this.posY - var5, this.posZ - var7);
  893.    }
  894.  
  895.    public void addMovementStat(double var1, double var3, double var5) {
  896.       if(this.ridingEntity == null) {
  897.          int var7;
  898.          if(this.isInsideOfMaterial(Material.water)) {
  899.             var7 = Math.round(MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5) * 100.0F);
  900.             if(var7 > 0) {
  901.                this.addStat(StatList.distanceDoveStat, var7);
  902.                this.func_35198_b(0.015F * (float)var7 * 0.01F);
  903.             }
  904.          } else if(this.isInWater()) {
  905.             var7 = Math.round(MathHelper.sqrt_double(var1 * var1 + var5 * var5) * 100.0F);
  906.             if(var7 > 0) {
  907.                this.addStat(StatList.distanceSwumStat, var7);
  908.                this.func_35198_b(0.015F * (float)var7 * 0.01F);
  909.             }
  910.          } else if(this.isOnLadder()) {
  911.             if(var3 > 0.0D) {
  912.                this.addStat(StatList.distanceClimbedStat, (int)Math.round(var3 * 100.0D));
  913.             }
  914.          } else if(this.onGround) {
  915.             var7 = Math.round(MathHelper.sqrt_double(var1 * var1 + var5 * var5) * 100.0F);
  916.             if(var7 > 0) {
  917.                this.addStat(StatList.distanceWalkedStat, var7);
  918.                if(this.getSprinting()) {
  919.                   this.func_35198_b(0.099999994F * (float)var7 * 0.01F);
  920.                } else {
  921.                   this.func_35198_b(0.01F * (float)var7 * 0.01F);
  922.                }
  923.             }
  924.          } else {
  925.             var7 = Math.round(MathHelper.sqrt_double(var1 * var1 + var5 * var5) * 100.0F);
  926.             if(var7 > 25) {
  927.                this.addStat(StatList.distanceFlownStat, var7);
  928.             }
  929.          }
  930.       }
  931.  
  932.    }
  933.  
  934.    private void addMountedMovementStat(double var1, double var3, double var5) {
  935.       if(this.ridingEntity != null) {
  936.          int var7 = Math.round(MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5) * 100.0F);
  937.          if(var7 > 0) {
  938.             if(this.ridingEntity instanceof EntityMinecart) {
  939.                this.addStat(StatList.distanceByMinecartStat, var7);
  940.                if(this.startMinecartRidingCoordinate == null) {
  941.                   this.startMinecartRidingCoordinate = new ChunkCoordinates(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ));
  942.                } else if(this.startMinecartRidingCoordinate.getSqDistanceTo(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) >= 1000.0D) {
  943.                   this.addStat(AchievementList.onARail, 1);
  944.                }
  945.             } else if(this.ridingEntity instanceof EntityBoat) {
  946.                this.addStat(StatList.distanceByBoatStat, var7);
  947.             } else if(this.ridingEntity instanceof EntityPig) {
  948.                this.addStat(StatList.distanceByPigStat, var7);
  949.             }
  950.          }
  951.       }
  952.  
  953.    }
  954.  
  955.    protected void fall(float var1) {
  956.       if(!this.field_35214_K.field_35659_c) {
  957.          if(var1 >= 2.0F) {
  958.             this.addStat(StatList.distanceFallenStat, (int)Math.round((double)var1 * 100.0D));
  959.          }
  960.  
  961.          super.fall(var1);
  962.       }
  963.  
  964.    }
  965.  
  966.    public void onKillEntity(EntityLiving var1) {
  967.       if(var1 instanceof EntityMob) {
  968.          this.triggerAchievement(AchievementList.killEnemy);
  969.       }
  970.  
  971.    }
  972.  
  973.    public void setInPortal() {
  974.       if(this.timeUntilPortal > 0) {
  975.          this.timeUntilPortal = 10;
  976.       } else {
  977.          this.inPortal = true;
  978.       }
  979.  
  980.    }
  981.  
  982.    public void addExperience(int var1) {
  983.       this.experience += var1;
  984.       this.experienceTotal += var1;
  985.  
  986.       while(this.experience >= this.func_35203_U()) {
  987.          this.experience -= this.func_35203_U();
  988.          this.func_36001_y();
  989.       }
  990.  
  991.    }
  992.  
  993.    public int func_35203_U() {
  994.       return (this.experienceLevel + 1) * 10;
  995.    }
  996.  
  997.    private void func_36001_y() {
  998.       ++this.experienceLevel;
  999.    }
  1000.  
  1001.    public void func_35198_b(float var1) {
  1002.       if(!this.field_35214_K.field_35660_a && !this.worldObj.singleplayerWorld) {
  1003.          this.foodStats.func_35583_a(var1);
  1004.       }
  1005.  
  1006.    }
  1007.  
  1008.    public FoodStats func_35207_V() {
  1009.       return this.foodStats;
  1010.    }
  1011.  
  1012.    public boolean func_35197_c(boolean var1) {
  1013.       return (var1 || this.foodStats.mustEat()) && !this.field_35214_K.field_35660_a;
  1014.    }
  1015.  
  1016.    public boolean mustHeal() {
  1017.       return this.health > 0 && this.health < 20;
  1018.    }
  1019.  
  1020.    public void func_35201_a(ItemStack var1, int var2) {
  1021.       if(var1 != this.field_34908_d) {
  1022.          this.field_34908_d = var1;
  1023.          this.field_34909_e = var2;
  1024.          if(!this.worldObj.singleplayerWorld) {
  1025.             this.func_35148_h(true);
  1026.          }
  1027.       }
  1028.  
  1029.    }
  1030.  
  1031.    public boolean func_35200_c(int var1, int var2, int var3) {
  1032.       return true;
  1033.    }
  1034.  
  1035.    protected int getExperiencePoints(EntityPlayer var1) {
  1036.       return this.experienceTotal >> 1;
  1037.    }
  1038.  
  1039.    protected boolean func_35188_X() {
  1040.       return true;
  1041.    }
  1042.  
  1043.    public String func_35150_Y() {
  1044.       return this.username;
  1045.    }
  1046. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement