net.minecraft.inventory.ClickType Java Examples

The following examples show how to use net.minecraft.inventory.ClickType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SlotUtil.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static void adjustPhantomSlot(Slot slot, int mouseButton, ClickType clickTypeIn) {
    ItemStack stackSlot = slot.getStack();
    int stackSize;
    if (clickTypeIn == ClickType.QUICK_MOVE) {
        stackSize = mouseButton == 0 ? (stackSlot.getCount() + 1) / 2 : stackSlot.getCount() * 2;
    } else {
        stackSize = mouseButton == 0 ? stackSlot.getCount() - 1 : stackSlot.getCount() + 1;
    }

    if (stackSize > slot.getSlotStackLimit()) {
        stackSize = slot.getSlotStackLimit();
    }

    stackSlot.setCount(stackSize);

    slot.putStack(stackSlot);
}
 
Example #2
Source File: GuiContainer.java    From NotEnoughItems with MIT License 6 votes vote down vote up
/**
 * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
 * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
 */
protected void keyTyped(char typedChar, int keyCode) throws IOException {

    if (manager.lastKeyTyped(keyCode, typedChar)) {
        return;
    }

    if (keyCode == 1 || this.mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode)) {
        this.mc.thePlayer.closeScreen();
    }

    this.checkHotbarKeys(keyCode);

    if (this.theSlot != null && this.theSlot.getHasStack()) {
        if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(keyCode)) {
            managerHandleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, ClickType.CLONE);
        } else if (this.mc.gameSettings.keyBindDrop.isActiveAndMatches(keyCode)) {
            managerHandleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, ClickType.THROW);
        }
    }
}
 
Example #3
Source File: ContainerQuickStacker.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player)
{
    ItemStack stack = ItemQuickStacker.getEnabledItem(player);

    // Middle click
    if (clickType == ClickType.CLONE && dragType == 2 && stack.isEmpty() == false)
    {
        int invSlotNum = this.getSlot(slotNum) != null ? this.getSlot(slotNum).getSlotIndex() : -1;

        if (invSlotNum != -1)
        {
            byte selected = NBTUtils.getByte(stack, ItemQuickStacker.TAG_NAME_CONTAINER, ItemQuickStacker.TAG_NAME_PRESET_SELECTION);
            long mask = NBTUtils.getLong(stack, ItemQuickStacker.TAG_NAME_CONTAINER, ItemQuickStacker.TAG_NAME_PRESET + selected);
            mask ^= (0x1L << invSlotNum);
            NBTUtils.setLong(stack, ItemQuickStacker.TAG_NAME_CONTAINER, ItemQuickStacker.TAG_NAME_PRESET + selected, mask);
        }

        return ItemStack.EMPTY;
    }

    return super.slotClick(slotNum, dragType, clickType, player);
}
 
Example #4
Source File: GTContainerTranslocatorFluid.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
	if (slotId == 0) {
		ItemStack stack = player.inventory.getItemStack();
		if (stack.isEmpty()) {
			this.block.setStackInSlot(0, ItemStack.EMPTY);
			this.block.filter = null;
			return ItemStack.EMPTY;
		}
		if (FluidUtil.getFluidContained(stack) != null) {
			FluidStack fluidStack = FluidUtil.getFluidContained(stack);
			FluidStack newStack = new FluidStack(fluidStack.getFluid(), 1000);
			this.block.setStackInSlot(0, ItemDisplayIcon.createWithFluidStack(newStack));
			this.block.filter = newStack;
		}
		return ItemStack.EMPTY;
	}
	return super.slotClick(slotId, dragType, clickTypeIn, player);
}
 
Example #5
Source File: GuiEnderUtilities.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
    if (keyCode == Keyboard.KEY_ESCAPE || this.mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode))
    {
        this.mc.player.closeScreen();
    }

    this.checkHotbarKeys(keyCode);

    Slot slot = this.getSlotUnderMouse();

    if (slot != null)
    {
        if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(keyCode))
        {
            this.handleMouseClick(slot, slot.slotNumber, 0, ClickType.CLONE);
        }
        else if (this.mc.gameSettings.keyBindDrop.isActiveAndMatches(keyCode))
        {
            this.handleMouseClick(slot, slot.slotNumber, isCtrlKeyDown() ? 1 : 0, ClickType.THROW);
        }
    }
}
 
Example #6
Source File: ContainerOreMappingSatallite.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public ItemStack slotClick(int slot, int dragType, ClickType clickTypeIn,
		EntityPlayer player) {
	//Check if slot exists
			ItemStack stack;
			if(slot != -999)
				stack =  player.inventory.getStackInSlot(slot);
			else stack = null;

			if(inv != null && dragType == 0)
				//Check if anything is in the slot and set the slot value if it is
				if(stack == null) {
					inv.setSelectedSlot(-1);
				}
				else
					for(int id : OreDictionary.getOreIDs(stack)) {
						if(OreDictionary.getOreName(id).startsWith("ore") || OreDictionary.getOreName(id).startsWith("gem") || OreDictionary.getOreName(id).startsWith("dust")) {
							inv.setSelectedSlot(slot);
						}

					}

			return stack;

}
 
Example #7
Source File: GuiEnderUtilities.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void handleMouseClick(Slot slotIn, int slotId, int mouseButton, ClickType type)
{
    // Custom: middle click on a slot, with a modifier key active
    if (type == ClickType.CLONE && (isShiftKeyDown() || isCtrlKeyDown() || isAltKeyDown()))
    {
        if (slotIn != null)
        {
            slotId = slotIn.slotNumber;
        }

        int action = HotKeys.KEYCODE_MIDDLE_CLICK | HotKeys.getActiveModifierMask();

        // Send a packet to the server
        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(0, BlockPos.ORIGIN,
                ReferenceGuiIds.GUI_ID_CONTAINER_GENERIC, action, slotId));
    }
    else
    {
        super.handleMouseClick(slotIn, slotId, mouseButton, type);
    }
}
 
Example #8
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public ItemStack slotClick(ContainerExtended container, EntityPlayer player, int button, ClickType clickType) {
    ItemStack held = player.inventory.getItemStack();
    if (button == 0 && clickType == ClickType.QUICK_MOVE) {
        NEIClientUtils.cheatItem(getStack(), button, -1);
    } else if (button == 1) {
        putStack(ItemStack.EMPTY);
    } else if (!held.isEmpty()) {
        if (isItemValid(held)) {
            putStack(ItemUtils.copyStack(held, 1));
            player.inventory.setItemStack(ItemStack.EMPTY);
        }
    } else if (getHasStack()) {
        player.inventory.setItemStack(getStack());
    }

    return ItemStack.EMPTY;
}
 
Example #9
Source File: DupeCommand.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void exec(String input) {
    if (!this.clamp(input, 1, 1)) {
        this.printUsage();
        return;
    }

    final Minecraft mc = Minecraft.getMinecraft();

    if(mc.player != null) {
        for (int i = 0; i <= 45; i++) {
            mc.playerController.windowClick(mc.player.inventoryContainer.windowId, i, -1, ClickType.THROW, mc.player);
        }

        mc.player.connection.sendPacket(new CPacketUseEntity(mc.player));
    }
}
 
Example #10
Source File: AutoCraftModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onUpdate(EventPlayerUpdate event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final Minecraft mc = Minecraft.getMinecraft();

        if (this.recipe.getValue().length() > 0 && this.timer.passed(this.delay.getValue())) {
            if (mc.currentScreen == null || mc.currentScreen instanceof GuiInventory || mc.currentScreen instanceof GuiCrafting) {
                mc.player.connection.sendPacket(new CPacketPlaceRecipe(mc.player.openContainer.windowId, CraftingManager.getRecipe(new ResourceLocation(this.recipe.getValue().toLowerCase())), true));

                mc.playerController.windowClick(mc.player.openContainer.windowId, 0, 0, this.drop.getValue() ? ClickType.THROW : ClickType.QUICK_MOVE, mc.player);
                mc.playerController.updateController();
            }

            this.timer.reset();
        }
    }
}
 
Example #11
Source File: QuickCraftModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onReceivePacket (EventReceivePacket event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        if (event.getPacket() instanceof SPacketSetSlot) {
            // Check if this packet updates the recipe result and if the result is not empty
            if (((SPacketSetSlot) event.getPacket()).getSlot() == 0 && ((SPacketSetSlot) event.getPacket()).getStack().getItem() != Items.AIR) {
                Minecraft mc = Minecraft.getMinecraft();

                if (mc.currentScreen instanceof GuiInventory || mc.currentScreen instanceof GuiCrafting) {
                    mc.playerController.windowClick(mc.player.openContainer.windowId, 0, 0, ClickType.QUICK_MOVE, mc.player);
                    mc.playerController.updateController();
                }
            }
        }
    }
}
 
Example #12
Source File: FakeSlot.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public ItemStack onClick(EntityPlayer player, int dragType, ClickType clickType) {
	if (clickType == ClickType.CLONE && player.capabilities.isCreativeMode) {
		ItemStack contents = getStack();
		if (!contents.isEmpty()) {
			ItemStack tmp = contents.copy();
			tmp.setCount(tmp.getMaxStackSize());
			player.inventory.setItemStack(tmp);
			return tmp;
		}
	}

	ItemStack held = player.inventory.getItemStack();

	ItemStack place = ItemStack.EMPTY;

	if (!held.isEmpty()) {
		place = held.copy();
		if (!keepSize) place.setCount(1);
	}

	inventory.setInventorySlotContents(slotNumber, place);
	onSlotChanged();
	return place;
}
 
Example #13
Source File: DefaultOverlayHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@SuppressWarnings ("unchecked")
private boolean clearIngredients(GuiContainer gui, List<PositionedStack> ingreds) {
    for (PositionedStack pstack : ingreds) {
        for (Slot slot : gui.inventorySlots.inventorySlots) {
            if (slot.xPos == pstack.relx + offsetx && slot.yPos == pstack.rely + offsety) {
                if (!slot.getHasStack()) {
                    continue;
                }

                FastTransferManager.clickSlot(gui, slot.slotNumber, 0, ClickType.QUICK_MOVE);
                if (slot.getHasStack()) {
                    return false;
                }
            }
        }
    }

    return true;
}
 
Example #14
Source File: AutoTotemModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onUpdate(EventPlayerUpdate event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final Minecraft mc = Minecraft.getMinecraft();

        if(mc.currentScreen == null || mc.currentScreen instanceof GuiInventory) {
            if(mc.player.getHealth() <= this.health.getValue()) {
                final ItemStack offHand = mc.player.getHeldItemOffhand();

                if (offHand.getItem() == Items.TOTEM_OF_UNDYING) {
                    return;
                }

                final int slot = this.getItemSlot(Items.TOTEM_OF_UNDYING);

                if(slot != -1) {
                    mc.playerController.windowClick(mc.player.inventoryContainer.windowId, slot, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(mc.player.inventoryContainer.windowId, 45, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(mc.player.inventoryContainer.windowId, slot, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.updateController();
                }
            }
        }
    }
}
 
Example #15
Source File: AutoMend.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onUpdate(LocalPlayerUpdateEvent event) {
  if (!(LocalPlayerInventory.getOpenContainer() instanceof ContainerPlayer)) {
    return;
  }
  
  InvItem current = LocalPlayerInventory.getSelected();
  
  Optional.of(LocalPlayerInventory.getOffhand())
      .filter(this::isMendable)
      .filter(item -> !isDamaged(item))
      .ifPresent(
          offhand ->
              LocalPlayerInventory.getSlotInventory()
                  .stream()
                  .filter(this::isMendable)
                  .filter(this::isDamaged)
                  .filter(inv -> inv.getIndex() != current.getIndex())
                  .max(Comparator.comparingInt(InvItem::getDamage))
                  .ifPresent(
                      inv -> {
                        // pick up
                        LocalPlayerInventory.sendWindowClick(inv, 0, ClickType.PICKUP);
                        // place in offhand
                        LocalPlayerInventory.sendWindowClick(offhand, 0, ClickType.PICKUP);
                        // place shovel back
                        LocalPlayerInventory.sendWindowClick(inv, 0, ClickType.PICKUP);
                      }));
}
 
Example #16
Source File: AutoBucketFallMod.java    From ForgeHax with MIT License 5 votes vote down vote up
private void swap(final int slot, final int hotbarNum) {
  MC.playerController.windowClick(
      getLocalPlayer().inventoryContainer.windowId,
      slot,
      hotbarNum,
      ClickType.SWAP,
      getLocalPlayer());
}
 
Example #17
Source File: ExtraInventory.java    From ForgeHax with MIT License 5 votes vote down vote up
private static CPacketClickWindow newClickPacket(
    int slotIdIn, int usedButtonIn, ClickType modeIn, ItemStack clickedItemIn) {
  return new CPacketClickWindow(
      GUI_INVENTORY_ID,
      slotIdIn,
      usedButtonIn,
      modeIn,
      clickedItemIn,
      getCurrentContainer().getNextTransactionID(LocalPlayerInventory.getInventory()));
}
 
Example #18
Source File: PhantomSlotWidget.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void handleClientAction(int id, PacketBuffer buffer) {
    if (id == 1) {
        ItemStack stackHeld;
        try {
            stackHeld = buffer.readItemStack();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        int mouseButton = buffer.readVarInt();
        boolean shiftKeyDown = buffer.readBoolean();
        ClickType clickType = shiftKeyDown ? ClickType.QUICK_MOVE : ClickType.PICKUP;
        SlotUtil.slotClickPhantom(slotReference, mouseButton, clickType, stackHeld);
    }
}
 
Example #19
Source File: ContainerHandyBag.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player)
{
    super.slotClick(slotNum, dragType, clickType, player);

    if (this.isClient == false && slotNum == this.craftingSlot)
    {
        this.syncSlotToClient(this.craftingSlot);
        this.syncCursorStackToClient();
    }

    return ItemStack.EMPTY;
}
 
Example #20
Source File: AutoHotbarReplenish.java    From ForgeHax with MIT License 5 votes vote down vote up
private static ItemStack click(InvItem item, int usedButtonIn, ClickType modeIn) {
  if (item.getIndex() == -1) {
    throw new IllegalArgumentException();
  }
  ItemStack ret;
  clickWindow(
      item.getSlotNumber(),
      usedButtonIn,
      modeIn,
      ret = LocalPlayerInventory.getOpenContainer()
              .slotClick(item.getSlotNumber(), usedButtonIn, modeIn, getLocalPlayer()));
  return ret;
}
 
Example #21
Source File: AutoHotbarReplenish.java    From ForgeHax with MIT License 5 votes vote down vote up
private static void clickWindow(
    int slotIdIn, int usedButtonIn, ClickType modeIn, ItemStack clickedItemIn) {
  getNetworkManager()
      .sendPacket(
          new CPacketClickWindow(
              0,
              slotIdIn,
              usedButtonIn,
              modeIn,
              clickedItemIn,
              LocalPlayerInventory.getOpenContainer().getNextTransactionID(LocalPlayerInventory.getInventory()))
      );
}
 
Example #22
Source File: AutoHotbarReplenish.java    From ForgeHax with MIT License 5 votes vote down vote up
private void tryPlacingHeldItem() {
  InvItem holding = LocalPlayerInventory.getMouseHeld();
  
  if (holding.isEmpty()) // all is good
  {
    return;
  }
  
  InvItem item;
  if (holding.isDamageable()) {
    item =
        LocalPlayerInventory.getSlotStorageInventory()
            .stream()
            .filter(InvItem::isNull)
            .findAny()
            .orElse(InvItem.EMPTY);
  } else {
    item =
        LocalPlayerInventory.getSlotStorageInventory()
            .stream()
            .filter(inv -> inv.isNull() || holding.isItemsEqual(inv))
            .filter(inv -> inv.isNull() || !inv.isStackMaxed())
            .max(Comparator.comparing(InvItem::getStackCount))
            .orElse(InvItem.EMPTY);
  }
  
  if (item == InvItem.EMPTY) {
    click(holding, 0, ClickType.PICKUP);
  } else {
    click(item, 0, ClickType.PICKUP);
    if (LocalPlayerInventory.getMouseHeld().nonEmpty()) {
      throw new RuntimeException();
    }
  }
}
 
Example #23
Source File: LocalPlayerInventory.java    From ForgeHax with MIT License 5 votes vote down vote up
public static void sendWindowClick(
    int slotIdIn, int usedButtonIn, ClickType modeIn, ItemStack clickedItemIn) {
  getNetworkManager()
      .sendPacket(
          new CPacketClickWindow(
              0,
              slotIdIn,
              usedButtonIn,
              modeIn,
              clickedItemIn,
              getOpenContainer().getNextTransactionID(getInventory())));
}
 
Example #24
Source File: LocalPlayerInventory.java    From ForgeHax with MIT License 5 votes vote down vote up
public static ItemStack sendWindowClick(InvItem item, int usedButtonIn, ClickType modeIn) {
  if (item.getIndex() == -1) {
    throw new IllegalArgumentException();
  }
  ItemStack ret;
  sendWindowClick(
      item.getSlotNumber(),
      usedButtonIn,
      modeIn,
      ret =
          getOpenContainer()
              .slotClick(item.getSlotNumber(), usedButtonIn, modeIn, getLocalPlayer()));
  return ret;
}
 
Example #25
Source File: GuiSurgery.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
protected void handleMouseClick(Slot slotIn, int slotId, int mouseButton, ClickType type)
{
	if (slotIn != null && (slotIn instanceof SlotSurgery) && !isSlotAccessible((SlotSurgery) slotIn))
	{
		return;
	}
	
	if (slotIn instanceof SlotSurgery)
	{
		SlotSurgery surgerySlot = (SlotSurgery) slotIn;
		if (surgerySlot.getStack() == null && surgerySlot.getPlayerStack() != null && this.mc.thePlayer.inventory.getItemStack() == null)
		{
			int number = surgerySlot.slotNumber;
			
			ItemStack playerSlotItem = surgerySlot.getPlayerStack();
			if (surgerySlot.slotDiscarded())
			{
				if (!surgery.doesItemConflict(playerSlotItem, ((SlotSurgery) slotIn).slot, number % LibConstants.WARE_PER_SLOT))
				{
					surgerySlot.setDiscarded(false);
					surgery.enableDependsOn(playerSlotItem, ((SlotSurgery) slotIn).slot, number % LibConstants.WARE_PER_SLOT);
					CyberwarePacketHandler.INSTANCE.sendToServer(new SurgeryRemovePacket(surgery.getPos(), surgery.getWorld().provider.getDimension(), number, false));
				}
			}
			else
			{
				if (surgery.canDisableItem(playerSlotItem, ((SlotSurgery) slotIn).slot, number % LibConstants.WARE_PER_SLOT))
				{
					surgerySlot.setDiscarded(true);
					surgery.disableDependants(playerSlotItem, ((SlotSurgery) slotIn).slot, number % LibConstants.WARE_PER_SLOT);
					CyberwarePacketHandler.INSTANCE.sendToServer(new SurgeryRemovePacket(surgery.getPos(), surgery.getWorld().provider.getDimension(), number, true));
				}
			}

		}
	}
	
	super.handleMouseClick(slotIn, slotId, mouseButton, type);
}
 
Example #26
Source File: ContainerInserter.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player)
{
    if (this.tef.isFiltered())
    {
        if (this.filterSlots.contains(slotNum))
        {
            this.fakeSlotClick(slotNum, dragType, clickType, player);
            return ItemStack.EMPTY;
        }

        // (Starting) or ending a drag and the dragged slots include at least one of our fake slots
        if (clickType == ClickType.QUICK_CRAFT && slotNum == -999)
        {
            for (int i : this.draggedSlots)
            {
                if (this.filterSlots.contains(i))
                {
                    this.fakeSlotClick(i, dragType, clickType, player);
                    return ItemStack.EMPTY;
                }
            }
        }
    }

    return super.slotClick(slotNum, dragType, clickType, player);
}
 
Example #27
Source File: GuiContainer.java    From NotEnoughItems with MIT License 5 votes vote down vote up
/**
 * Called when a mouse button is pressed and the mouse is moved around. Parameters are : mouseX, mouseY,
 * lastButtonClicked & timeSinceMouseClick.
 */
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
    Slot slot = this.getSlotAtPosition(mouseX, mouseY);
    ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();

    manager.mouseDragged(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);

    if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) {
        if (clickedMouseButton == 0 || clickedMouseButton == 1) {
            if (this.draggedStack == null) {
                if (slot != this.clickedSlot && this.clickedSlot.getStack() != null) {
                    this.draggedStack = this.clickedSlot.getStack().copy();
                }
            } else if (this.draggedStack.stackSize > 1 && slot != null && Container.canAddItemToSlot(slot, this.draggedStack, false)) {
                long i = Minecraft.getSystemTime();

                if (this.currentDragTargetSlot == slot) {
                    if (i - this.dragItemDropDelay > 500L) {
                        managerHandleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
                        managerHandleMouseClick(slot, slot.slotNumber, 1, ClickType.PICKUP);
                        managerHandleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
                        this.dragItemDropDelay = i + 750L;
                        --this.draggedStack.stackSize;
                    }
                } else {
                    this.currentDragTargetSlot = slot;
                    this.dragItemDropDelay = i;
                }
            }
        }
    } else if (this.dragSplitting && slot != null && itemstack != null && itemstack.stackSize > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot)) {
        this.dragSplittingSlots.add(slot);
        this.updateActivePotionEffects();
    }
}
 
Example #28
Source File: GuiContainer.java    From NotEnoughItems with MIT License 5 votes vote down vote up
/**
 * Checks whether a hotbar key (to swap the hovered item with an item in the hotbar) has been pressed. If so, it
 * swaps the given items.
 * Returns true if a hotbar key was pressed.
 *
 * @param keyCode The LWJGL keycode for the key that was pressed.
 */
protected boolean checkHotbarKeys(int keyCode) {
    if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null) {
        for (int i = 0; i < 9; ++i) {
            if (this.mc.gameSettings.keyBindsHotbar[i].isActiveAndMatches(keyCode)) {
                managerHandleMouseClick(this.theSlot, this.theSlot.slotNumber, i, ClickType.SWAP);
                return true;
            }
        }
    }

    return false;
}
 
Example #29
Source File: DefaultSlotClickHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public boolean handleSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, ClickType clickType, boolean eventConsumed) {
    if (!eventConsumed) {
        callHandleMouseClick(gui, slot, slotIndex, button, clickType);
    }

    return true;
}
 
Example #30
Source File: FastTransferManager.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public void restoreContainer(Container container, LinkedList<ItemStack> items) {
    for (int i = 0; i < container.inventorySlots.size(); i++) {
        container.getSlot(i).putStack(items.get(i));
    }

    container.slotClick(-999, 0, ClickType.PICKUP, Minecraft.getMinecraft().player);
}