예제 #1
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);
          }
        }
      }
    }
  }
예제 #2
0
  private void func_74227_b(CreativeTabs par1CreativeTabs) {
    if (par1CreativeTabs == null) {
      return;
    }

    int var2 = selectedTabIndex;
    selectedTabIndex = par1CreativeTabs.getTabIndex();
    ContainerCreative var3 = (ContainerCreative) this.inventorySlots;
    var3.itemList.clear();
    par1CreativeTabs.displayAllReleventItems(var3.itemList);

    if (par1CreativeTabs == CreativeTabs.tabInventory) {
      Container var4 = this.mc.thePlayer.inventoryContainer;

      if (this.field_74236_u == null) {
        this.field_74236_u = var3.inventorySlots;
      }

      var3.inventorySlots = new ArrayList();

      for (int var5 = 0; var5 < var4.inventorySlots.size(); ++var5) {
        SlotCreativeInventory var6 =
            new SlotCreativeInventory(this, (Slot) var4.inventorySlots.get(var5), var5);
        var3.inventorySlots.add(var6);
        int var7;
        int var8;
        int var9;

        if (var5 >= 5 && var5 < 9) {
          var7 = var5 - 5;
          var8 = var7 / 2;
          var9 = var7 % 2;
          var6.xDisplayPosition = 9 + var8 * 54;
          var6.yDisplayPosition = 6 + var9 * 27;
        } else if (var5 >= 0 && var5 < 5) {
          var6.yDisplayPosition = -2000;
          var6.xDisplayPosition = -2000;
        } else if (var5 < var4.inventorySlots.size()) {
          var7 = var5 - 9;
          var8 = var7 % 9;
          var9 = var7 / 9;
          var6.xDisplayPosition = 9 + var8 * 18;

          if (var5 >= 36) {
            var6.yDisplayPosition = 112;
          } else {
            var6.yDisplayPosition = 54 + var9 * 18;
          }
        }
      }

      this.field_74235_v = new Slot(inventory, 0, 173, 112);
      var3.inventorySlots.add(this.field_74235_v);
    } else if (var2 == CreativeTabs.tabInventory.getTabIndex()) {
      var3.inventorySlots = this.field_74236_u;
      this.field_74236_u = null;
    }

    if (this.searchField != null) {
      if (par1CreativeTabs == CreativeTabs.tabAllSearch) {
        this.searchField.setVisible(true);
        this.searchField.setCanLoseFocus(false);
        this.searchField.setFocused(true);
        this.searchField.setText("");
        this.updateCreativeSearch();
      } else {
        this.searchField.setVisible(false);
        this.searchField.setCanLoseFocus(true);
        this.searchField.setFocused(false);
      }
    }

    this.currentScroll = 0.0F;
    var3.scrollTo(0.0F);
  }