Example #1
0
 public void func_75134_a(EntityPlayer p_75134_1_) {
   InventoryPlayer var2 = p_75134_1_.field_71071_by;
   if (var2.func_70445_o() != null) {
     p_75134_1_.func_71021_b(var2.func_70445_o());
     var2.func_70437_b((ItemStack) null);
   }
 }
Example #2
0
  /** Callback for when the crafting gui is closed. */
  public void onCraftGuiClosed(EntityPlayer par1EntityPlayer) {
    InventoryPlayer var2 = par1EntityPlayer.inventory;

    if (var2.getItemStack() != null) {
      par1EntityPlayer.dropPlayerItem(var2.getItemStack());
      var2.setItemStack((ItemStack) null);
    }
  }
Example #3
0
 /** Called when player presses the drop item key */
 public EntityItem dropOneItem() {
   ItemStack stack = inventory.getCurrentItem();
   if (stack == null) {
     return null;
   }
   if (stack.getItem().onDroppedByPlayer(stack, this)) {
     return dropPlayerItemWithRandomChoice(
         inventory.decrStackSize(inventory.currentItem, 1), false);
   }
   return null;
 }
 public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
   super.readEntityFromNBT(nbttagcompound);
   NBTTagList nbttaglist = nbttagcompound.getTagList("Inventory");
   inventory.readFromNBT(nbttaglist);
   dimension = nbttagcompound.getInteger("Dimension");
   sleeping = nbttagcompound.getBoolean("Sleeping");
   sleepTimer = nbttagcompound.getShort("SleepTimer");
   currentXP = nbttagcompound.getFloat("XpP");
   playerLevel = nbttagcompound.getInteger("XpLevel");
   totalXP = nbttagcompound.getInteger("XpTotal");
   if (sleeping) {
     bedChunkCoordinates =
         new ChunkCoordinates(
             MathHelper.floor_double(posX),
             MathHelper.floor_double(posY),
             MathHelper.floor_double(posZ));
     wakeUpPlayer(true, true, false);
   }
   if (nbttagcompound.hasKey("SpawnX")
       && nbttagcompound.hasKey("SpawnY")
       && nbttagcompound.hasKey("SpawnZ")) {
     playerSpawnCoordinate =
         new ChunkCoordinates(
             nbttagcompound.getInteger("SpawnX"),
             nbttagcompound.getInteger("SpawnY"),
             nbttagcompound.getInteger("SpawnZ"));
   }
   foodStats.readStatsFromNBT(nbttagcompound);
   capabilities.readCapabilitiesFromNBT(nbttagcompound);
 }
Example #5
0
  public float getCurrentPlayerStrVsBlock(Block par1Block, int meta) {
    ItemStack stack = inventory.getCurrentItem();
    float var2 = (stack == null ? 1.0F : stack.getItem().getStrVsBlock(stack, par1Block, meta));
    float var3 = var2;
    int var4 = EnchantmentHelper.getEfficiencyModifier(this.inventory);

    if (var4 > 0 && this.inventory.canHarvestBlock(par1Block)) {
      var3 = var2 + (float) (var4 * var4 + 1);
    }

    if (this.isPotionActive(Potion.digSpeed)) {
      var3 *=
          1.0F + (float) (this.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F;
    }

    if (this.isPotionActive(Potion.digSlowdown)) {
      var3 *=
          1.0F - (float) (this.getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F;
    }

    if (this.isInsideOfMaterial(Material.water)
        && !EnchantmentHelper.getAquaAffinityModifier(this.inventory)) {
      var3 /= 5.0F;
    }

    if (!this.onGround) {
      var3 /= 5.0F;
    }

    return var3;
  }
 public static int func_77512_a(InventoryPlayer p_77512_0_, EntityLiving p_77512_1_) {
   field_77521_c.field_77495_a = 0;
   field_77521_c.field_77494_b = p_77512_1_;
   func_77518_a(field_77521_c, p_77512_0_.func_70448_g());
   return field_77521_c.field_77495_a > 0
       ? 1 + field_77522_a.nextInt(field_77521_c.field_77495_a)
       : 0;
 }
Example #7
0
 public void handleBlockItemSwitch(Packet16BlockItemSwitch par1Packet16BlockItemSwitch) {
   if (par1Packet16BlockItemSwitch.id >= 0
       && par1Packet16BlockItemSwitch.id < InventoryPlayer.func_70451_h()) {
     this.playerEntity.inventory.currentItem = par1Packet16BlockItemSwitch.id;
   } else {
     logger.warning(this.playerEntity.username + " tried to set an invalid carried item");
   }
 }
 public void copyPlayer(EntityPlayer entityplayer) {
   inventory.copyInventory(entityplayer.inventory);
   health = entityplayer.health;
   foodStats = entityplayer.foodStats;
   playerLevel = entityplayer.playerLevel;
   totalXP = entityplayer.totalXP;
   currentXP = entityplayer.currentXP;
   score = entityplayer.score;
 }
 public void func_72502_a(Packet16BlockItemSwitch p_72502_1_) {
   if (p_72502_1_.field_73386_a >= 0
       && p_72502_1_.field_73386_a < InventoryPlayer.func_70451_h()) {
     this.field_72574_e.field_71071_by.field_70461_c = p_72502_1_.field_73386_a;
   } else {
     this.field_72573_d
         .func_98033_al()
         .func_98236_b(
             this.field_72574_e.field_71092_bJ + " tried to set an invalid carried item");
   }
 }
 public float getCurrentPlayerStrVsBlock(Block block) {
   float f = inventory.getStrVsBlock(block);
   float f1 = f;
   int i = EnchantmentHelper.getEfficiencyModifier(inventory);
   if (i > 0 && inventory.canHarvestBlock(block)) {
     f1 += i * i + 1;
   }
   if (isPotionActive(Potion.digSpeed)) {
     f1 *= 1.0F + (float) (getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F;
   }
   if (isPotionActive(Potion.digSlowdown)) {
     f1 *= 1.0F - (float) (getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F;
   }
   if (isInsideOfMaterial(Material.water)
       && !EnchantmentHelper.getAquaAffinityModifier(inventory)) {
     f1 /= 5F;
   }
   if (!onGround) {
     f1 /= 5F;
   }
   return f1;
 }
 public void handleBlockItemSwitch(Packet16BlockItemSwitch par1Packet16BlockItemSwitch) {
   if (par1Packet16BlockItemSwitch.id < 0
       || par1Packet16BlockItemSwitch.id >= InventoryPlayer.func_70451_h()) {
     logger.warning(
         (new StringBuilder())
             .append(playerEntity.username)
             .append(" tried to set an invalid carried item")
             .toString());
     return;
   } else {
     playerEntity.inventory.currentItem = par1Packet16BlockItemSwitch.id;
     return;
   }
 }
 public void writeEntityToNBT(NBTTagCompound nbttagcompound) {
   super.writeEntityToNBT(nbttagcompound);
   nbttagcompound.setTag("Inventory", inventory.writeToNBT(new NBTTagList()));
   nbttagcompound.setInteger("Dimension", dimension);
   nbttagcompound.setBoolean("Sleeping", sleeping);
   nbttagcompound.setShort("SleepTimer", (short) sleepTimer);
   nbttagcompound.setFloat("XpP", currentXP);
   nbttagcompound.setInteger("XpLevel", playerLevel);
   nbttagcompound.setInteger("XpTotal", totalXP);
   if (playerSpawnCoordinate != null) {
     nbttagcompound.setInteger("SpawnX", playerSpawnCoordinate.posX);
     nbttagcompound.setInteger("SpawnY", playerSpawnCoordinate.posY);
     nbttagcompound.setInteger("SpawnZ", playerSpawnCoordinate.posZ);
   }
   foodStats.writeStatsToNBT(nbttagcompound);
   capabilities.writeCapabilitiesToNBT(nbttagcompound);
 }
 public void onDeath(DamageSource damagesource) {
   super.onDeath(damagesource);
   setSize(0.2F, 0.2F);
   setPosition(posX, posY, posZ);
   motionY = 0.10000000149011612D;
   if (username.equals("Notch")) {
     dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true);
   }
   inventory.dropAllItems();
   if (damagesource != null) {
     motionX = -MathHelper.cos(((attackedAtYaw + rotationYaw) * 3.141593F) / 180F) * 0.1F;
     motionZ = -MathHelper.sin(((attackedAtYaw + rotationYaw) * 3.141593F) / 180F) * 0.1F;
   } else {
     motionX = motionZ = 0.0D;
   }
   yOffset = 0.1F;
   addStat(StatList.deathsStat, 1);
 }
 public void onLivingUpdate() {
   if (flyToggleTimer > 0) {
     flyToggleTimer--;
   }
   if (worldObj.difficultySetting == 0
       && getEntityHealth() < getMaxHealth()
       && (ticksExisted % 20) * 12 == 0) {
     heal(1);
   }
   inventory.decrementAnimations();
   prevCameraYaw = cameraYaw;
   super.onLivingUpdate();
   landMovementFactor = speedOnGround;
   jumpMovementFactor = speedInAir;
   if (isSprinting()) {
     landMovementFactor += (double) speedOnGround * 0.29999999999999999D;
     jumpMovementFactor += (double) speedInAir * 0.29999999999999999D;
   }
   float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
   float f1 = (float) Math.atan(-motionY * 0.20000000298023224D) * 15F;
   if (f > 0.1F) {
     f = 0.1F;
   }
   if (!onGround || getEntityHealth() <= 0) {
     f = 0.0F;
   }
   if (onGround || getEntityHealth() <= 0) {
     f1 = 0.0F;
   }
   cameraYaw += (f - cameraYaw) * 0.4F;
   cameraPitch += (f1 - cameraPitch) * 0.8F;
   if (getEntityHealth() > 0) {
     List list =
         worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D));
     if (list != null) {
       for (int i = 0; i < list.size(); i++) {
         Entity entity = (Entity) list.get(i);
         if (!entity.isDead) {
           collideWithPlayer(entity);
         }
       }
     }
   }
 }
Example #15
0
  /** Handle a creative slot packet. */
  public void handleCreativeSetSlot(Packet107CreativeSetSlot par1Packet107CreativeSetSlot) {
    if (this.playerEntity.theItemInWorldManager.isCreative()) {
      boolean var2 = par1Packet107CreativeSetSlot.slot < 0;
      ItemStack var3 = par1Packet107CreativeSetSlot.itemStack;
      boolean var4 =
          par1Packet107CreativeSetSlot.slot >= 1
              && par1Packet107CreativeSetSlot.slot < 36 + InventoryPlayer.func_70451_h();
      boolean var5 =
          var3 == null
              || var3.itemID < Item.itemsList.length
                  && var3.itemID >= 0
                  && Item.itemsList[var3.itemID] != null;
      boolean var6 =
          var3 == null
              || var3.getItemDamage() >= 0
                  && var3.getItemDamage() >= 0
                  && var3.stackSize <= 64
                  && var3.stackSize > 0;

      if (var4 && var5 && var6) {
        if (var3 == null) {
          this.playerEntity.inventorySlots.putStackInSlot(
              par1Packet107CreativeSetSlot.slot, (ItemStack) null);
        } else {
          this.playerEntity.inventorySlots.putStackInSlot(par1Packet107CreativeSetSlot.slot, var3);
        }

        this.playerEntity.inventorySlots.setCanCraft(this.playerEntity, true);
      } else if (var2 && var5 && var6 && this.field_72578_n < 200) {
        this.field_72578_n += 20;
        EntityItem var7 = this.playerEntity.dropPlayerItem(var3);

        if (var7 != null) {
          var7.func_70288_d();
        }
      }
    }
  }
  /** Handle a creative slot packet. */
  public void handleCreativeSetSlot(Packet107CreativeSetSlot par1Packet107CreativeSetSlot) {
    if (playerEntity.theItemInWorldManager.isCreative()) {
      boolean flag = par1Packet107CreativeSetSlot.slot < 0;
      ItemStack itemstack = par1Packet107CreativeSetSlot.itemStack;
      boolean flag1 =
          par1Packet107CreativeSetSlot.slot >= 1
              && par1Packet107CreativeSetSlot.slot < 36 + InventoryPlayer.func_70451_h();
      boolean flag2 =
          itemstack == null
              || itemstack.itemID < Item.itemsList.length
                  && itemstack.itemID >= 0
                  && Item.itemsList[itemstack.itemID] != null;
      boolean flag3 =
          itemstack == null
              || itemstack.getItemDamage() >= 0
                  && itemstack.getItemDamage() >= 0
                  && itemstack.stackSize <= 64
                  && itemstack.stackSize > 0;

      if (flag1 && flag2 && flag3) {
        if (itemstack == null) {
          playerEntity.inventorySlots.putStackInSlot(par1Packet107CreativeSetSlot.slot, null);
        } else {
          playerEntity.inventorySlots.putStackInSlot(par1Packet107CreativeSetSlot.slot, itemstack);
        }

        playerEntity.inventorySlots.setPlayerIsPresent(playerEntity, true);
      } else if (flag && flag2 && flag3 && creativeItemCreationSpamThresholdTally < 200) {
        creativeItemCreationSpamThresholdTally += 20;
        EntityItem entityitem = playerEntity.dropPlayerItem(itemstack);

        if (entityitem != null) {
          entityitem.func_70288_d();
        }
      }
    }
  }
  public void func_72464_a(Packet107CreativeSetSlot p_72464_1_) {
    if (this.field_72574_e.field_71134_c.func_73083_d()) {
      boolean var2 = p_72464_1_.field_73385_a < 0;
      ItemStack var3 = p_72464_1_.field_73384_b;
      boolean var4 =
          p_72464_1_.field_73385_a >= 1
              && p_72464_1_.field_73385_a < 36 + InventoryPlayer.func_70451_h();
      boolean var5 =
          var3 == null
              || var3.field_77993_c < Item.field_77698_e.length
                  && var3.field_77993_c >= 0
                  && Item.field_77698_e[var3.field_77993_c] != null;
      boolean var6 =
          var3 == null
              || var3.func_77960_j() >= 0
                  && var3.func_77960_j() >= 0
                  && var3.field_77994_a <= 64
                  && var3.field_77994_a > 0;
      if (var4 && var5 && var6) {
        if (var3 == null) {
          this.field_72574_e.field_71069_bz.func_75141_a(
              p_72464_1_.field_73385_a, (ItemStack) null);
        } else {
          this.field_72574_e.field_71069_bz.func_75141_a(p_72464_1_.field_73385_a, var3);
        }

        this.field_72574_e.field_71069_bz.func_75128_a(this.field_72574_e, true);
      } else if (var2 && var5 && var6 && this.field_72578_n < 200) {
        this.field_72578_n += 20;
        EntityItem var7 = this.field_72574_e.func_71021_b(var3);
        if (var7 != null) {
          var7.func_70288_d();
        }
      }
    }
  }
Example #18
0
  public ItemStack slotClick(int par1, int par2, boolean par3, EntityPlayer par4EntityPlayer) {
    ItemStack var5 = null;

    if (par2 > 1) {
      return null;
    } else {
      if (par2 == 0 || par2 == 1) {
        InventoryPlayer var6 = par4EntityPlayer.inventory;

        if (par1 == -999) {
          if (var6.getItemStack() != null && par1 == -999) {
            if (par2 == 0) {
              par4EntityPlayer.dropPlayerItem(var6.getItemStack());
              var6.setItemStack((ItemStack) null);
            }

            if (par2 == 1) {
              par4EntityPlayer.dropPlayerItem(var6.getItemStack().splitStack(1));

              if (var6.getItemStack().stackSize == 0) {
                var6.setItemStack((ItemStack) null);
              }
            }
          }
        } else if (par3) {
          ItemStack var7 = this.transferStackInSlot(par1);

          if (var7 != null) {
            int var8 = var7.itemID;
            var5 = var7.copy();
            Slot var9 = (Slot) this.inventorySlots.get(par1);

            if (var9 != null && var9.getStack() != null && var9.getStack().itemID == var8) {
              this.retrySlotClick(par1, par2, par3, par4EntityPlayer);
            }
          }
        } else {
          if (par1 < 0) {
            return null;
          }

          Slot var12 = (Slot) this.inventorySlots.get(par1);

          if (var12 != null) {
            ItemStack var13 = var12.getStack();
            ItemStack var14 = var6.getItemStack();

            if (var13 != null) {
              var5 = var13.copy();
            }

            int var10;

            if (var13 == null) {
              if (var14 != null && var12.isItemValid(var14)) {
                var10 = par2 == 0 ? var14.stackSize : 1;

                if (var10 > var12.getSlotStackLimit()) {
                  var10 = var12.getSlotStackLimit();
                }

                var12.putStack(var14.splitStack(var10));

                if (var14.stackSize == 0) {
                  var6.setItemStack((ItemStack) null);
                }
              }
            } else if (var14 == null) {
              var10 = par2 == 0 ? var13.stackSize : (var13.stackSize + 1) / 2;
              ItemStack var11 = var12.decrStackSize(var10);
              var6.setItemStack(var11);

              if (var13.stackSize == 0) {
                var12.putStack((ItemStack) null);
              }

              var12.onPickupFromSlot(var6.getItemStack());
            } else if (var12.isItemValid(var14)) {
              if (var13.itemID == var14.itemID
                  && (!var13.getHasSubtypes() || var13.getItemDamage() == var14.getItemDamage())
                  && ItemStack.func_77970_a(var13, var14)) {
                var10 = par2 == 0 ? var14.stackSize : 1;

                if (var10 > var12.getSlotStackLimit() - var13.stackSize) {
                  var10 = var12.getSlotStackLimit() - var13.stackSize;
                }

                if (var10 > var14.getMaxStackSize() - var13.stackSize) {
                  var10 = var14.getMaxStackSize() - var13.stackSize;
                }

                var14.splitStack(var10);

                if (var14.stackSize == 0) {
                  var6.setItemStack((ItemStack) null);
                }

                var13.stackSize += var10;
              } else if (var14.stackSize <= var12.getSlotStackLimit()) {
                var12.putStack(var14);
                var6.setItemStack(var13);
              }
            } else if (var13.itemID == var14.itemID
                && var14.getMaxStackSize() > 1
                && (!var13.getHasSubtypes() || var13.getItemDamage() == var14.getItemDamage())
                && ItemStack.func_77970_a(var13, var14)) {
              var10 = var13.stackSize;

              if (var10 > 0 && var10 + var14.stackSize <= var14.getMaxStackSize()) {
                var14.stackSize += var10;
                var13 = var12.decrStackSize(var10);

                if (var13.stackSize == 0) {
                  var12.putStack((ItemStack) null);
                }

                var12.onPickupFromSlot(var6.getItemStack());
              }
            }

            var12.onSlotChanged();
          }
        }
      }

      return var5;
    }
  }
Example #19
0
  public ItemStack func_75144_a(
      int p_75144_1_, int p_75144_2_, int p_75144_3_, EntityPlayer p_75144_4_) {
    ItemStack var5 = null;
    InventoryPlayer var6 = p_75144_4_.field_71071_by;
    Slot var7;
    ItemStack var8;
    int var10;
    ItemStack var11;
    if ((p_75144_3_ == 0 || p_75144_3_ == 1) && (p_75144_2_ == 0 || p_75144_2_ == 1)) {
      if (p_75144_1_ == -999) {
        if (var6.func_70445_o() != null && p_75144_1_ == -999) {
          if (p_75144_2_ == 0) {
            p_75144_4_.func_71021_b(var6.func_70445_o());
            var6.func_70437_b((ItemStack) null);
          }

          if (p_75144_2_ == 1) {
            p_75144_4_.func_71021_b(var6.func_70445_o().func_77979_a(1));
            if (var6.func_70445_o().field_77994_a == 0) {
              var6.func_70437_b((ItemStack) null);
            }
          }
        }
      } else if (p_75144_3_ == 1) {
        var7 = (Slot) this.field_75151_b.get(p_75144_1_);
        if (var7 != null && var7.func_82869_a(p_75144_4_)) {
          var8 = this.func_82846_b(p_75144_4_, p_75144_1_);
          if (var8 != null) {
            int var12 = var8.field_77993_c;
            var5 = var8.func_77946_l();
            if (var7 != null
                && var7.func_75211_c() != null
                && var7.func_75211_c().field_77993_c == var12) {
              this.func_75133_b(p_75144_1_, p_75144_2_, true, p_75144_4_);
            }
          }
        }
      } else {
        if (p_75144_1_ < 0) {
          return null;
        }

        var7 = (Slot) this.field_75151_b.get(p_75144_1_);
        if (var7 != null) {
          var8 = var7.func_75211_c();
          ItemStack var13 = var6.func_70445_o();
          if (var8 != null) {
            var5 = var8.func_77946_l();
          }

          if (var8 == null) {
            if (var13 != null && var7.func_75214_a(var13)) {
              var10 = p_75144_2_ == 0 ? var13.field_77994_a : 1;
              if (var10 > var7.func_75219_a()) {
                var10 = var7.func_75219_a();
              }

              var7.func_75215_d(var13.func_77979_a(var10));
              if (var13.field_77994_a == 0) {
                var6.func_70437_b((ItemStack) null);
              }
            }
          } else if (var7.func_82869_a(p_75144_4_)) {
            if (var13 == null) {
              var10 = p_75144_2_ == 0 ? var8.field_77994_a : (var8.field_77994_a + 1) / 2;
              var11 = var7.func_75209_a(var10);
              var6.func_70437_b(var11);
              if (var8.field_77994_a == 0) {
                var7.func_75215_d((ItemStack) null);
              }

              var7.func_82870_a(p_75144_4_, var6.func_70445_o());
            } else if (var7.func_75214_a(var13)) {
              if (var8.field_77993_c == var13.field_77993_c
                  && (!var8.func_77981_g() || var8.func_77960_j() == var13.func_77960_j())
                  && ItemStack.func_77970_a(var8, var13)) {
                var10 = p_75144_2_ == 0 ? var13.field_77994_a : 1;
                if (var10 > var7.func_75219_a() - var8.field_77994_a) {
                  var10 = var7.func_75219_a() - var8.field_77994_a;
                }

                if (var10 > var13.func_77976_d() - var8.field_77994_a) {
                  var10 = var13.func_77976_d() - var8.field_77994_a;
                }

                var13.func_77979_a(var10);
                if (var13.field_77994_a == 0) {
                  var6.func_70437_b((ItemStack) null);
                }

                var8.field_77994_a += var10;
              } else if (var13.field_77994_a <= var7.func_75219_a()) {
                var7.func_75215_d(var13);
                var6.func_70437_b(var8);
              }
            } else if (var8.field_77993_c == var13.field_77993_c
                && var13.func_77976_d() > 1
                && (!var8.func_77981_g() || var8.func_77960_j() == var13.func_77960_j())
                && ItemStack.func_77970_a(var8, var13)) {
              var10 = var8.field_77994_a;
              if (var10 > 0 && var10 + var13.field_77994_a <= var13.func_77976_d()) {
                var13.field_77994_a += var10;
                var8 = var7.func_75209_a(var10);
                if (var8.field_77994_a == 0) {
                  var7.func_75215_d((ItemStack) null);
                }

                var7.func_82870_a(p_75144_4_, var6.func_70445_o());
              }
            }
          }

          var7.func_75218_e();
        }
      }
    } else if (p_75144_3_ == 2 && p_75144_2_ >= 0 && p_75144_2_ < 9) {
      var7 = (Slot) this.field_75151_b.get(p_75144_1_);
      if (var7.func_82869_a(p_75144_4_)) {
        var8 = var6.func_70301_a(p_75144_2_);
        boolean var9 = var8 == null || var7.field_75224_c == var6 && var7.func_75214_a(var8);
        var10 = -1;
        if (!var9) {
          var10 = var6.func_70447_i();
          var9 |= var10 > -1;
        }

        if (var7.func_75216_d() && var9) {
          var11 = var7.func_75211_c();
          var6.func_70299_a(p_75144_2_, var11);
          if ((var7.field_75224_c != var6 || !var7.func_75214_a(var8)) && var8 != null) {
            if (var10 > -1) {
              var6.func_70441_a(var8);
              var7.func_75215_d((ItemStack) null);
              var7.func_82870_a(p_75144_4_, var11);
            }
          } else {
            var7.func_75215_d(var8);
            var7.func_82870_a(p_75144_4_, var11);
          }
        } else if (!var7.func_75216_d() && var8 != null && var7.func_75214_a(var8)) {
          var6.func_70299_a(p_75144_2_, (ItemStack) null);
          var7.func_75215_d(var8);
        }
      }
    } else if (p_75144_3_ == 3
        && p_75144_4_.field_71075_bZ.field_75098_d
        && var6.func_70445_o() == null
        && p_75144_1_ >= 0) {
      var7 = (Slot) this.field_75151_b.get(p_75144_1_);
      if (var7 != null && var7.func_75216_d()) {
        var8 = var7.func_75211_c().func_77946_l();
        var8.field_77994_a = var8.func_77976_d();
        var6.func_70437_b(var8);
      }
    }

    return var5;
  }
Example #20
0
 public static int func_77517_e(InventoryPlayer p_77517_0_) {
   return func_77506_a(Enchantment.field_77346_s.field_77352_x, p_77517_0_.func_70448_g());
 }
 public void attackTargetEntityWithCurrentItem(Entity entity) {
   int i = inventory.getDamageVsEntity(entity);
   if (isPotionActive(Potion.damageBoost)) {
     i += 3 << getActivePotionEffect(Potion.damageBoost).getAmplifier();
   }
   if (isPotionActive(Potion.weakness)) {
     i -= 2 << getActivePotionEffect(Potion.weakness).getAmplifier();
   }
   int j = 0;
   int k = 0;
   if (entity instanceof EntityLiving) {
     k = EnchantmentHelper.getEnchantmentModifierLiving(inventory, (EntityLiving) entity);
     j += EnchantmentHelper.getKnockbackModifier(inventory, (EntityLiving) entity);
   }
   if (isSprinting()) {
     j++;
   }
   if (i > 0 || k > 0) {
     boolean flag =
         fallDistance > 0.0F
             && !onGround
             && !isOnLadder()
             && !isInWater()
             && !isPotionActive(Potion.blindness)
             && ridingEntity == null
             && (entity instanceof EntityLiving);
     if (flag) {
       i += rand.nextInt(i / 2 + 2);
     }
     i += k;
     boolean flag1 = entity.attackEntityFrom(DamageSource.causePlayerDamage(this), i);
     if (flag1) {
       if (j > 0) {
         entity.addVelocity(
             -MathHelper.sin((rotationYaw * 3.141593F) / 180F) * (float) j * 0.5F,
             0.10000000000000001D,
             MathHelper.cos((rotationYaw * 3.141593F) / 180F) * (float) j * 0.5F);
         motionX *= 0.59999999999999998D;
         motionZ *= 0.59999999999999998D;
         setSprinting(false);
       }
       if (flag) {
         onCriticalHit(entity);
       }
       if (k > 0) {
         func_40183_c(entity);
       }
       if (i >= 18) {
         triggerAchievement(AchievementList.overkill);
       }
     }
     ItemStack itemstack = getCurrentEquippedItem();
     if (itemstack != null && (entity instanceof EntityLiving)) {
       itemstack.hitEntity((EntityLiving) entity, this);
       if (itemstack.stackSize <= 0) {
         itemstack.onItemDestroyedByUse(this);
         destroyCurrentEquippedItem();
       }
     }
     if (entity instanceof EntityLiving) {
       if (entity.isEntityAlive()) {
         alertWolves((EntityLiving) entity, true);
       }
       addStat(StatList.damageDealtStat, i);
       int l = EnchantmentHelper.getFireAspectModifier(inventory, (EntityLiving) entity);
       if (l > 0) {
         entity.setFire(l * 4);
       }
     }
     addExhaustion(0.3F);
   }
 }
 public void destroyCurrentEquippedItem() {
   inventory.setInventorySlotContents(inventory.currentItem, null);
 }
 public ItemStack getCurrentEquippedItem() {
   return inventory.getCurrentItem();
 }
 public int getTotalArmorValue() {
   return inventory.getTotalArmorValue();
 }
 protected void func_40125_g(int i) {
   inventory.damageArmor(i);
 }
 public void onUpdate() {
   if (itemInUse != null) {
     ItemStack itemstack = inventory.getCurrentItem();
     if (itemstack != itemInUse) {
       clearItemInUse();
     } else {
       if (itemInUseCount <= 25 && itemInUseCount % 4 == 0) {
         func_35201_a(itemstack, 5);
       }
       if (--itemInUseCount == 0 && !worldObj.multiplayerWorld) {
         func_35208_ae();
       }
     }
   }
   if (xpCooldown > 0) {
     xpCooldown--;
   }
   if (isPlayerSleeping()) {
     sleepTimer++;
     if (sleepTimer > 100) {
       sleepTimer = 100;
     }
     if (!worldObj.multiplayerWorld) {
       if (!isInBed()) {
         wakeUpPlayer(true, true, false);
       } else if (worldObj.isDaytime()) {
         wakeUpPlayer(false, true, true);
       }
     }
   } else if (sleepTimer > 0) {
     sleepTimer++;
     if (sleepTimer >= 110) {
       sleepTimer = 0;
     }
   }
   super.onUpdate();
   if (!worldObj.multiplayerWorld
       && craftingInventory != null
       && !craftingInventory.canInteractWith(this)) {
     closeScreen();
     craftingInventory = inventorySlots;
   }
   if (capabilities.isFlying) {
     for (int i = 0; i < 8; i++) {}
   }
   if (isBurning() && capabilities.disableDamage) {
     extinguish();
   }
   field_20066_r = field_20063_u;
   field_20065_s = field_20062_v;
   field_20064_t = field_20061_w;
   double d = posX - field_20063_u;
   double d1 = posY - field_20062_v;
   double d2 = posZ - field_20061_w;
   double d3 = 10D;
   if (d > d3) {
     field_20066_r = field_20063_u = posX;
   }
   if (d2 > d3) {
     field_20064_t = field_20061_w = posZ;
   }
   if (d1 > d3) {
     field_20065_s = field_20062_v = posY;
   }
   if (d < -d3) {
     field_20066_r = field_20063_u = posX;
   }
   if (d2 < -d3) {
     field_20064_t = field_20061_w = posZ;
   }
   if (d1 < -d3) {
     field_20065_s = field_20062_v = posY;
   }
   field_20063_u += d * 0.25D;
   field_20061_w += d2 * 0.25D;
   field_20062_v += d1 * 0.25D;
   addStat(StatList.minutesPlayedStat, 1);
   if (ridingEntity == null) {
     startMinecartRidingCoordinate = null;
   }
   if (!worldObj.multiplayerWorld) {
     foodStats.onUpdate(this);
   }
 }
Example #27
0
 public static int func_77519_f(InventoryPlayer p_77519_0_) {
   return func_77506_a(Enchantment.field_77335_o.field_77352_x, p_77519_0_.func_70448_g());
 }
 public boolean canHarvestBlock(Block block) {
   return inventory.canHarvestBlock(block);
 }
Example #29
0
  protected void handleMouseClick(Slot par1Slot, int par2, int par3, int par4) {
    this.field_74234_w = true;
    boolean var5 = par4 == 1;
    InventoryPlayer var6;
    ItemStack var7;

    if (par1Slot != null) {
      if (par1Slot == this.field_74235_v && var5) {
        for (int var10 = 0;
            var10 < this.mc.thePlayer.inventoryContainer.getInventory().size();
            ++var10) {
          this.mc.playerController.sendSlotPacket((ItemStack) null, var10);
        }
      } else if (selectedTabIndex == CreativeTabs.tabInventory.getTabIndex()) {
        if (par1Slot == this.field_74235_v) {
          this.mc.thePlayer.inventory.setItemStack((ItemStack) null);
        } else {
          this.mc.thePlayer.inventoryContainer.slotClick(
              SlotCreativeInventory.func_75240_a((SlotCreativeInventory) par1Slot).slotNumber,
              par3,
              par4,
              this.mc.thePlayer);
          this.mc.thePlayer.inventoryContainer.updateCraftingResults();
        }
      } else if (par1Slot.inventory == inventory) {
        var6 = this.mc.thePlayer.inventory;
        var7 = var6.getItemStack();
        ItemStack var8 = par1Slot.getStack();
        ItemStack var9;

        if (par4 == 2) {
          if (var8 != null && par3 >= 0 && par3 < 9) {
            var9 = var8.copy();
            var9.stackSize = var9.getMaxStackSize();
            this.mc.thePlayer.inventory.setInventorySlotContents(par3, var9);
            this.mc.thePlayer.inventoryContainer.updateCraftingResults();
          }

          return;
        }

        if (par4 == 3) {
          if (var6.getItemStack() == null && par1Slot.getHasStack()) {
            var9 = par1Slot.getStack().copy();
            var9.stackSize = var9.getMaxStackSize();
            var6.setItemStack(var9);
          }

          return;
        }

        if (var7 != null && var8 != null && var7.isItemEqual(var8)) {
          if (par3 == 0) {
            if (var5) {
              var7.stackSize = var7.getMaxStackSize();
            } else if (var7.stackSize < var7.getMaxStackSize()) {
              ++var7.stackSize;
            }
          } else if (var7.stackSize <= 1) {
            var6.setItemStack((ItemStack) null);
          } else {
            --var7.stackSize;
          }
        } else if (var8 != null && var7 == null) {
          var6.setItemStack(ItemStack.copyItemStack(var8));
          var7 = var6.getItemStack();

          if (var5) {
            var7.stackSize = var7.getMaxStackSize();
          }
        } else {
          var6.setItemStack((ItemStack) null);
        }
      } else {
        this.inventorySlots.slotClick(par1Slot.slotNumber, par3, par4, this.mc.thePlayer);
        ItemStack var11 = this.inventorySlots.getSlot(par1Slot.slotNumber).getStack();
        this.mc.playerController.sendSlotPacket(
            var11, par1Slot.slotNumber - this.inventorySlots.inventorySlots.size() + 9 + 36);
      }
    } else {
      var6 = this.mc.thePlayer.inventory;

      if (var6.getItemStack() != null) {
        if (par3 == 0) {
          this.mc.thePlayer.dropPlayerItem(var6.getItemStack());
          this.mc.playerController.func_78752_a(var6.getItemStack());
          var6.setItemStack((ItemStack) null);
        }

        if (par3 == 1) {
          var7 = var6.getItemStack().splitStack(1);
          this.mc.thePlayer.dropPlayerItem(var7);
          this.mc.playerController.func_78752_a(var7);

          if (var6.getItemStack().stackSize == 0) {
            var6.setItemStack((ItemStack) null);
          }
        }
      }
    }
  }
 public void dropCurrentItem() {
   dropPlayerItemWithRandomChoice(inventory.decrStackSize(inventory.currentItem, 1), false);
 }