public static void drawPotionEffect(PotionEffect potion, int x, int y) { int index = potion.getPotion().getStatusIconIndex(); GlStateManager.pushMatrix(); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.disableLighting(); GlStateManager.enableRescaleNormal(); GlStateManager.enableColorMaterial(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.color(1.f, 1.f, 1.f, 1.f); MC.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND); drawTexturedRect(x, y, index % 8 * 18, 198 + index / 8 * 18, 18, 18, 100); potion.getPotion().renderHUDEffect(x, y, potion, MC, 255); GlStateManager.disableLighting(); GlStateManager.enableDepth(); GlStateManager.color(1.f, 1.f, 1.f, 1.f); GlStateManager.popMatrix(); }
public ModuleChestStealer() { super("ChestStealer", "steals chest", Ordering.OTHER, 0, 0); addValue(mode, delay, validate, itemFilter, itemFilterMode); addTicker(new Ticker("cheststealer_ticker", () -> { if (Wrapper.theWorld() == null) return; if (Wrapper.currentScreen() == null || !(Wrapper.currentScreen() instanceof GuiChest)) return; GuiChest chest = (GuiChest) Wrapper.currentScreen(); if (validate.getValue() && !ItemUtil.isValidChest(chest)) return; int item = (mode.getCurrent().equalsIgnoreCase("vertical") ? getItemVertical(chest) : mode.getCurrent().equalsIgnoreCase("horizontal") ? getItemHorizontal(chest) : getItemRandom(chest)); if (item == -1 || ItemUtil.isChestEmpty(chest) || ItemUtil.player_inventoryFull()) { try { Thread.sleep(100, 150); } catch (InterruptedException e) { } Wrapper.displayGuiScreen(null); return; } sleep((long) Math.floor(delay.getValue() / 1.5 + ThreadLocalRandom.current().nextInt((int) delay.getValue() / 4, (int) delay.getValue() / 3))); Wrapper.windowClick(Wrapper.inventoryId((Container) ReflectionUtil.getFieldValue("field_147002_h", chest, GuiContainer.class)), item, 0, ClickMode.QUICK_MOVE); })); }
private boolean checks() { if (!Mouse.isButtonDown(Wrapper.convertKeyToLWJGL(Wrapper.getKeyCode(Wrapper.keybindAttack())))) return false; if (Wrapper.theWorld() == null || Wrapper.thePlayer() == null) return false; if (Bit.getInstance().getGlobalValueManager().find_bool("weapon only").getValue() && !Wrapper.isHoldingWeapon() && Wrapper.currentScreen() == null) return false; if ((Wrapper.currentScreen() != null && !inventory.getValue()) || (inventory.getValue() && Wrapper.currentScreen() != null && !(Wrapper.currentScreen() instanceof GuiContainer))) return false; if (Wrapper.player_isUsingItem() || Wrapper.player_isBlocking()) return false; return true; }
@SubscribeEvent(priority = EventPriority.LOW) public void onItemStackTooltip(RenderTooltipEvent.Pre event) { if (!Config.isToggledEnabled() && !isEnableKeyHeld()) { return; } ItemStack itemStack = event.getStack(); //noinspection ConstantConditions if (itemStack == null || itemStack.isEmpty()) { return; } if (Config.isJeiOnly() && !ItemStack.areItemStacksEqual(itemStack, JeiCompat.getStackUnderMouse())) { return; } Minecraft minecraft = Minecraft.getMinecraft(); GuiScreen currentScreen = minecraft.currentScreen; if (currentScreen instanceof GuiContainer) { GuiContainer guiContainer = (GuiContainer) currentScreen; renderZoomedStack(itemStack, guiContainer, minecraft); } }
@Override public void load(GuiContainer gui) { if (isEnabled()) { setInputFocused(null); ItemList.loadItems.restart(); getLayoutStyle().init(); layout(gui); } NEIController.load(gui); if (checkCreativeInv(gui) && gui.mc.currentScreen instanceof GuiContainerCreative)//override creative with creative+ { gui.mc.displayGuiScreen(null);//close the screen and wait for the server to open it for us } }
private static boolean clearCraftingGridOfItems(GuiContainer gui, SlotRange range, RecipeStorage recipes, boolean nonMatchingOnly) { int numSlots = gui.inventorySlots.inventorySlots.size(); for (int i = 0, slotNum = range.getFirst(); i < range.getSlotCount() && i < recipes.getSelectedRecipe().getRecipeLength() && slotNum < numSlots; i++, slotNum++) { Slot slotTmp = gui.inventorySlots.getSlot(slotNum); if (slotTmp != null && slotTmp.getHasStack() && (nonMatchingOnly == false || areStacksEqual(recipes.getSelectedRecipe().getRecipe()[i], slotTmp.getStack()) == false)) { shiftClickSlot(gui, slotNum); // Failed to clear the slot if (slotTmp.getHasStack()) { return false; } } } return true; }
@Override public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) { ItemStack stackover = GuiContainerManager.getStackMouseOver(gui); if (stackover == null || !(gui instanceof GuiRecipe)) { return false; } if (button == 0) { return GuiCraftingRecipe.openRecipeGui("item", stackover.copy()); } if (button == 1) { return GuiUsageRecipe.openRecipeGui("item", stackover.copy()); } return false; }
@Override public void load(GuiContainer gui) { if (isEnabled()) { setInputFocused(null); ItemList.loadItems.restart(); overlayRenderer = null; getLayoutStyle().init(); layout(gui); } NEIController.load(gui); if (checkCreativeInv(gui) && gui.mc.currentScreen instanceof GuiContainerCreative)//override creative with creative+ gui.mc.displayGuiScreen(null);//close the screen and wait for the server to open it for us }
@SubscribeEvent public void foregroundRenderEvent(GuiContainerEvent.DrawForeground event) { GuiContainer container = event.getGuiContainer(); GlStateTracker.pushState(); Point mousePos = GuiDraw.getMousePosition(); GlStateManager.translate(-container.getGuiLeft(), -container.getGuiTop(), 100F); drawHandlers.forEach(handler -> handler.renderObjects(container, mousePos.x, mousePos.y)); drawHandlers.forEach(handler -> handler.postRenderObjects(container, mousePos.x, mousePos.y)); GlStateManager.translate(container.getGuiLeft(), container.getGuiTop(), -100F); GuiHelper.enable3DRender(); GlStateManager.pushMatrix(); for (Slot slot : container.inventorySlots.inventorySlots) { GlStateTracker.pushState(); drawHandlers.forEach(handler -> handler.renderSlotOverlay(container, slot)); GlStateTracker.popState(); } GlStateManager.popMatrix(); GlStateTracker.popState(); }
@Override public List<String> handleItemDisplayName(GuiContainer gui, ItemStack stack, List<String> currenttip) { String overridename = ItemInfo.getNameOverride(stack); if (overridename != null) currenttip.set(0, overridename); String mainname = currenttip.get(0); if (showIDs()) { mainname += " " + Item.getIdFromItem(stack.getItem()); if (stack.getItemDamage() != 0) mainname += ":" + stack.getItemDamage(); currenttip.set(0, mainname); } return currenttip; }
@SuppressWarnings("unchecked") public Slot[][] mapIngredSlots(GuiContainer gui, List<PositionedStack> ingredients) { Slot[][] recipeSlotList = new Slot[ingredients.size()][]; for(int i = 0; i < ingredients.size(); i++)//identify slots { LinkedList<Slot> recipeSlots = new LinkedList<Slot>(); PositionedStack pstack = ingredients.get(i); for(Slot slot : (List<Slot>)gui.inventorySlots.inventorySlots) { if(slot.xDisplayPosition == pstack.relx+offsetx && slot.yDisplayPosition == pstack.rely+offsety) { recipeSlots.add(slot); break; } } recipeSlotList[i] = recipeSlots.toArray(new Slot[0]); } return recipeSlotList; }
public void overlayRecipe(final GuiContainer gui, final IRecipeHandler recipe, final int recipeIndex, final boolean shift) { final List<PositionedStack> ingredients = (List<PositionedStack>)recipe.getIngredientStacks(recipeIndex); final List<DistributedIngred> ingredStacks = this.getPermutationIngredients(ingredients); if (!this.clearIngredients(gui, ingredients)) { return; } this.findInventoryQuantities(gui, ingredStacks); final List<IngredientDistribution> assignedIngredients = this.assignIngredients(ingredients, ingredStacks); if (assignedIngredients == null) { return; } this.assignIngredSlots(gui, ingredients, assignedIngredients); final int quantity = this.calculateRecipeQuantity(assignedIngredients); if (quantity != 0) { this.moveIngredients(gui, assignedIngredients, quantity); } }
public void setExternalGuiPosition(GuiScreen gui) { if (gui instanceof GuiContainer) { final int candidateGuiLeft = ((GuiContainer) gui).getGuiLeft(); final int candidateGuiTop = ((GuiContainer) gui).getGuiTop(); // -- NOTE -- // The creative inventory would cause this method to be fired twice, once for // net.minecraft.client.gui.inventory.GuiContainerCreative (with correct values) // and once for net.minecraft.client.gui.inventory.GuiInventory (with wrong values). // // I ignore the second call so the gui overlay preserves the correct values. if (gui instanceof GuiInventory && candidateGuiLeft == 0 && candidateGuiTop == 0) { return; } this._externalGuiLeft = candidateGuiLeft; this._externalGuiTop = candidateGuiTop; } else { this._externalGuiLeft = -1; this._externalGuiTop = -1; } LogHelper.trace("GuiExtraSlotsOverlay.setExternalGuiPosition() - left: %d, top: %d", this._externalGuiLeft, this._externalGuiTop); }
@Override public void renderObjects(GuiContainer gui, int mousex, int mousey) { if (!isHidden()) { layout(gui); if (isEnabled()) { getLayoutStyle().drawBackground(gui); for (Widget widget : drawWidgets) { widget.draw(mousex, mousey); } } else { options.draw(mousex, mousey); } GlStateManager.enableLighting(); GlStateManager.disableDepth(); } else { showItemPanel = false; } }
@SuppressWarnings ("unchecked") public Slot[][] mapIngredSlots(GuiContainer gui, List<PositionedStack> ingredients) { Slot[][] recipeSlotList = new Slot[ingredients.size()][]; for (int i = 0; i < ingredients.size(); i++)//identify slots { LinkedList<Slot> recipeSlots = new LinkedList<>(); PositionedStack pstack = ingredients.get(i); for (Slot slot : gui.inventorySlots.inventorySlots) { if (slot.xPos == pstack.relx + offsetx && slot.yPos == pstack.rely + offsety) { recipeSlots.add(slot); break; } } recipeSlotList[i] = recipeSlots.toArray(new Slot[0]); } return recipeSlotList; }
@SubscribeEvent public void preKeyboardInput(GuiScreenEvent.KeyboardInputEvent.Pre event) { if (event.getGui() instanceof GuiContainer && playerHasBook()) { GuiContainer gui = (GuiContainer) event.getGui(); Slot slot = gui.getSlotUnderMouse(); if (slot != null && slot.getHasStack()) { if (Keyboard.getEventKey() == ProxyClient.recipeKey.getKeyCode() && RecipeManager.hasRecipes(slot.getStack())) { GuideBookGui.onOpenCmd = "recipe"; GuideBookGui.onOpenArg = slot.getStack(); Minecraft.getMinecraft().player.openGui(GuideBookMod.instance, 0, Minecraft.getMinecraft().world, 0, 0, 0); } else if(Keyboard.getEventKey() == ProxyClient.usageKey.getKeyCode() && RecipeManager.hasUsages(slot.getStack())) { GuideBookGui.onOpenCmd = "usage"; GuideBookGui.onOpenArg = slot.getStack(); Minecraft.getMinecraft().player.openGui(GuideBookMod.instance, 0, Minecraft.getMinecraft().world, 0, 0, 0); } } } }
@SubscribeEvent public void drawScreenPost(DrawScreenEvent.Post event) { GuiScreen screen = event.getGui(); Point mousePos = GuiDraw.getMousePosition(); List<String> tooltip = new LinkedList<>(); ItemStack stack = ItemStack.EMPTY; if (instanceTooltipHandlers != null) { instanceTooltipHandlers.forEach(handler -> handler.handleTooltip(screen, mousePos.x, mousePos.y, tooltip)); } if (screen instanceof GuiContainer) { if (tooltip.isEmpty() && GuiHelper.shouldShowTooltip(screen)) { GuiContainer container = ((GuiContainer) screen); stack = GuiHelper.getStackMouseOver(container, false); if (!stack.isEmpty()) { tooltip.clear(); tooltip.addAll(GuiHelper.itemDisplayNameMultiline(stack, container, false)); } } } GuiDraw.drawMultiLineTip(stack, mousePos.x + 10, mousePos.y - 12, tooltip); }
@SubscribeEvent public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) { if (event.getGui() instanceof GuiInventory || event.getGui() instanceof GuiPlayerInventoryExtended){ GuiContainer gui = (GuiContainer) event.getGui(); event.getButtonList().add(new GuiHarshenButton(8178, gui, 140, 51, 24, 24, I18n.translateToLocalFormatted((event.getGui() instanceof GuiInventory) ? "button.harsheninventory" : "button.normal"), event.getGui() instanceof GuiInventory)); } }
private void initMECTHandlers() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException { for (String ctName : Config.CRAFTING_TABLE_NAMES) { String camelCaseCTName = new StringBuilder(ctName) .replace(0, 1, Character.toString(Character.toUpperCase(ctName.charAt(0)))).toString(); List<IRecipe> recipes = (List<IRecipe>) LOTRRecipes.class .getDeclaredField((ctName.equals("blueDwarven") ? "blueMountains" : ctName).concat("Recipes")) .get(null); Class<? extends GuiContainer> guiClass = (Class<? extends GuiContainer>) Class .forName("lotr.client.gui.LOTRGuiCraftingTable$".concat(camelCaseCTName)); List<RecipeAntihandler> antihandlers = getAntihandlersForMECT(ctName); if (NeiLotr.mod.getConfig().isShapedMECTRecipeHandlerEnabled(ctName)) { BasicCTShapedRecipeHandler shapedHandler = new BasicCTShapedRecipeHandler(nextId(), guiClass, ctName); antihandlers.forEach(shapedHandler::addAntihandler); recipeLoader.registerStaticRecipeLoaderWithIRecipe(shapedHandler, recipes); registeredHandlers.add(shapedHandler); } if (NeiLotr.mod.getConfig().isShapelessMECTRecipeHandlerEnabled(ctName)) { BasicCTShapelessRecipeHandler shapelessHandler = new BasicCTShapelessRecipeHandler(nextId(), guiClass, ctName); getSubhandlersForMECT(ctName, shapelessHandler).forEach(shapelessHandler::addSubhandler); antihandlers.forEach(shapelessHandler::addAntihandler); recipeLoader.registerStaticRecipeLoaderWithIRecipe(shapelessHandler, recipes); registeredHandlers.add(shapelessHandler); } } }
private void clickInventory(int k, boolean state) { try { GuiContainer inventory = (GuiContainer) Wrapper.currentScreen(); int x = Mouse.getX() * inventory.field_146294_l / inventory.field_146297_k.field_71443_c; int y = inventory.field_146295_m - Mouse.getY() * inventory.field_146295_m / inventory.field_146297_k.field_71440_d - 1; int touchValue = (int) ReflectionUtil.getFieldValue("field_146298_h", inventory, GuiScreen.class); if (state) { if (inventory.field_146297_k.field_71474_y.field_85185_A && touchValue++ > 0) return; ReflectionUtil.setField("field_146287_f", GuiScreen.class, inventory, k); ReflectionUtil.setField("field_146288_g", GuiScreen.class, inventory, Minecraft.func_71386_F()); int eventButton = (int) ReflectionUtil.getFieldValue("field_146287_f", inventory, GuiScreen.class); ReflectionUtil.invokeMethod("func_73864_a", GuiScreen.class, inventory, new Object[]{x, y, eventButton}, int.class, int.class, int.class); } else if (k != -1) { if (inventory.field_146297_k.field_71474_y.field_85185_A && touchValue-- > 0) return; ReflectionUtil.setField("field_146287_f", GuiScreen.class, inventory, -1); ReflectionUtil.invokeMethod("func_146286_b", GuiScreen.class, inventory, new Object[]{x, y, k}, int.class, int.class, int.class); } else if ((int) ReflectionUtil.getFieldValue("field_146287_f", inventory, GuiScreen.class) != -1 && (long) ReflectionUtil.getFieldValue("field_146288_g", inventory, GuiScreen.class) > 0L) { long l = Minecraft.func_71386_F() - (long) ReflectionUtil.getFieldValue("field_146288_g", inventory, GuiScreen.class); ReflectionUtil.invokeMethod("func_146273_a", GuiScreen.class, inventory, new Object[]{x, y, (int) ReflectionUtil.getFieldValue("field_146287_f", inventory, GuiScreen.class), l}, int.class, int.class, int.class, long.class); } } catch (Exception e) { } }
public static ItemStack getGridItem(int nr) { GuiContainer menu = (GuiContainer)getMenu(); Container slots = menu.inventorySlots; if (menu instanceof GuiCrafting) { return ((ContainerWorkbench)slots).craftMatrix.getStackInSlot(nr); } else if (menu instanceof GuiInventory) { return ((ContainerPlayer)slots).craftMatrix.getStackInSlot(nr); } return null; }
private static void renderZoomedStack(ItemStack itemStack, GuiContainer guiContainer, Minecraft minecraft) { ScaledResolution scaledResolution = new ScaledResolution(minecraft); final float scale = Config.getZoomAmount() / 100f * guiContainer.getGuiLeft() / 17f; // item is 16 wide, give it some extra space on each side final float xPosition = (guiContainer.getGuiLeft() / scale - 16f) / 2f; final float yPosition = (scaledResolution.getScaledHeight() / scale - 16f) / 2f; FontRenderer font = getFontRenderer(minecraft, itemStack); GlStateManager.pushMatrix(); GlStateManager.scale(scale, scale, 1); GlStateManager.translate(xPosition, yPosition, 0); ZoomRenderHelper.enableGUIStandardItemLighting(scale); minecraft.getRenderItem().zLevel += 100; minecraft.getRenderItem().renderItemAndEffectIntoGUI(minecraft.player, itemStack, 0, 0); renderItemOverlayIntoGUI(font, itemStack); minecraft.getRenderItem().zLevel -= 100; GlStateManager.disableBlend(); RenderHelper.disableStandardItemLighting(); GlStateManager.popMatrix(); if (Config.showHelpText()) { String modName = ItemZoom.MOD_NAME; int stringWidth = font.getStringWidth(modName); int x = (guiContainer.getGuiLeft() - stringWidth) / 2; int y = (scaledResolution.getScaledHeight() + Math.round(17 * scale)) / 2; font.drawString(modName, x, y, 4210752); if (Config.isToggledEnabled()) { String toggleText = KeyBindings.TOGGLE.getDisplayName(); stringWidth = font.getStringWidth(toggleText); x = (guiContainer.getGuiLeft() - stringWidth) / 2; y += font.FONT_HEIGHT; font.drawString(toggleText, x, y, 4210752); } } }
public static boolean isContainerOpen() { if (Minecraft.getMinecraft().currentScreen != null) { if (Minecraft.getMinecraft().currentScreen instanceof GuiContainer && !(Minecraft.getMinecraft().currentScreen instanceof GuiInventory)) { return true; } } return false; }
public static boolean isInventoryOpen() { if (Minecraft.getMinecraft().currentScreen != null) { if (Minecraft.getMinecraft().currentScreen instanceof GuiContainer && (Minecraft.getMinecraft().currentScreen instanceof GuiInventory || Minecraft.getMinecraft().currentScreen instanceof GuiContainerCreative)) { return true; } } return false; }
@SubscribeEvent public static void onDrawGui(GuiScreenEvent.DrawScreenEvent.Pre event) { if (!SettingsFlags.instance.enableCustomInventory) { return; } if (event.getGui() instanceof GuiContainer) { PlayerInventoryRenderer.render(Minecraft.getMinecraft().player, event.getGui()); } }
@Override public ItemStack getStackUnderMouse(GuiContainer gui, int mousex, int mousey) { if (!isHidden() && isEnabled()) { for (Widget widget : controlWidgets) { ItemStack stack = widget.getStackMouseOver(mousex, mousey); if (stack != null) return stack; } } return null; }
private boolean transferRect(GuiContainer gui, boolean usage) { int[] offset = RecipeInfo.getGuiOffset(gui); try { Class clazzTemplateRecipeHandler = Class.forName("codechicken.nei.recipe.TemplateRecipeHandler"); Method methodTransferRect = clazzTemplateRecipeHandler.getDeclaredMethod("transferRect", GuiContainer.class, Collection.class, int.class, int.class, boolean.class); methodTransferRect.setAccessible(true); return (Boolean) methodTransferRect.invoke(null, gui, getRecieTransferRect(gui), offset[0], offset[1], usage); } catch (Exception e) {return false;} }
@Override public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) { Slot slot = gui.getSlotAtPosition(mouseX, mouseY); if (slot instanceof SlotDummy && slot.isItemValid(draggedStack) && gui.inventorySlots instanceof ContainerExtended) { ((SlotDummy) slot).slotClick(draggedStack, button, NEIClientUtils.shiftKey()); NEIClientPacketHandler.sendDummySlotSet(slot.slotNumber, slot.getStack()); return true; } return false; }
public void renderObjects(GuiContainer gui, int mousex, int mousey) { if (!isHidden()) { layout(gui); if (isEnabled()) { getLayoutStyle().drawBackground(GuiContainerManager.getManager(gui)); for (Widget widget : drawWidgets) widget.draw(mousex, mousey); } else { options.draw(mousex, mousey); } GlStateManager.enableLighting(); GlStateManager.disableDepth(); } }
@Override public void onPreDraw(GuiContainer gui) { if (!isHidden() && isEnabled() && gui instanceof InventoryEffectRenderer)//Reset the gui to the center of the screen, for potion effect offsets etc { gui.guiLeft = (gui.width - gui.xSize) / 2; gui.guiTop = (gui.height - gui.ySize) / 2; if (gui instanceof GuiContainerCreative && gui.buttonList.size() >= 2) { GuiButton button1 = (GuiButton) gui.buttonList.get(0); GuiButton button2 = (GuiButton) gui.buttonList.get(1); button1.xPosition = gui.guiLeft; button2.xPosition = gui.guiLeft + gui.xSize - 20; } } }
private void checkForGuiChanges(GuiContainer cont) { int yPos = 0; int width = (int) ((cont.width - ((IGuiContainer) cont).getXSize()) / (3f / 2f)); width = (width / DASH_ICON_W) * DASH_ICON_W; int height = cont.height; int xPos; int tick = mc.ingameGUI.getUpdateCounter() - this.toggleTimer; EasingType easing = EasingsFactory.getInstance().quadratic(); final float time = 10; if (!isVisible()) { xPos = cont.width - width; if (tick < time) xPos = (int) easing.in().ease(tick, xPos, width, time); else xPos = cont.width; } else { xPos = cont.width; if (tick < time) xPos = (int) easing.in().ease(tick, xPos, -width, time); else xPos = cont.width - width; } if (this.xPos != xPos || this.yPos != yPos || this.width != width || this.height != height) { this.dirty |= width != this.width || height != this.height; this.xPos = xPos; this.yPos = yPos; this.width = width - 15; this.height = height; this.currentDash.update(xPos, yPos, width, height); } }
@Override public void onMouseClicked(GuiScreen gui, int mouseX, int mouseY, int button) { if (gui instanceof GuiContainer) { Slot slot = GuiHelper.getSlotMouseOver(((GuiContainer) gui)); if (slot != null) { //Holding tracker. heldTracker = NEIClientUtils.getHeldItem(); } } }
public PluginMachineRecipe(ComponentRectangle rectangle, String recipeIdentifier, String guiNameCS2, Class<? extends GuiContainer> guiContainerClass) { this.rectangle = rectangle; this.recipeIdentifier = recipeIdentifier; this.guiNameCS2 = guiNameCS2; this.guiContainerClass = guiContainerClass; // We need to run the constructor of the parent class again. // Since it was executed before we initialize our plugin. loadTransferRects(); // We use our CustomRecipeTransferRectHandler instead of the origin RecipeTransferRectHandler if (this.guiNameCS2 != null) CustomRecipeTransferRectHandler.registerRectsToGuis(this.guiNameCS2, transferRects); else CustomRecipeTransferRectHandler.registerRectsToGuis(getCustomRecipeTransferRectGuis(), transferRects); }
@Override public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) { if (!canHandle(gui)) return false; if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) return transferRect(gui, false); else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) return transferRect(gui, true); return false; }
private static boolean shiftClickSlotWithCheck(GuiContainer gui, int slotNum) { Slot slot = gui.inventorySlots.getSlot(slotNum); if (slot == null || slot.getHasStack() == false) { return false; } int sizeOrig = getStackSize(slot.getStack()); shiftClickSlot(gui, slotNum); return slot.getHasStack() == false || getStackSize(slot.getStack()) != sizeOrig; }
@Override public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) { if (!canHandle(gui)) { return currenttip; } if (GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) { int[] offset = RecipeInfo.getGuiOffset(gui); currenttip = TemplateRecipeHandler.transferRectTooltip(gui, guiMap.get(gui.getClass()), offset[0], offset[1], currenttip); } return currenttip; }
@Override public void onMouseDragged(GuiContainer gui, int mx, int my, int button, long heldTime) { if (!isHidden() && isEnabled()) { for (Widget widget : controlWidgets) widget.mouseDragged(mx, my, button, heldTime); } }
@Override public boolean objectUnderMouse(GuiContainer gui, int mousex, int mousey) { if (!isHidden() && isEnabled()) for (Widget widget : controlWidgets) if (widget.contains(mousex, mousey)) return true; return false; }
private boolean dragMoveFromSlotAtPosition(GuiContainer gui, int x, int y, boolean leaveOneItem, boolean moveOnlyOne) { Slot slot = this.getSlotAtPosition(gui, x, y); boolean flag = slot != null && InventoryUtils.isValidSlot(slot, gui, true) && slot.canTakeStack(gui.mc.player); boolean cancel = flag && (leaveOneItem || moveOnlyOne); if (flag && slot.slotNumber != this.slotNumberLast && this.draggedSlots.contains(slot.slotNumber) == false) { if (moveOnlyOne) { cancel = InventoryUtils.tryMoveSingleItemToOtherInventory(slot, gui); } else if (leaveOneItem) { cancel = InventoryUtils.tryMoveAllButOneItemToOtherInventory(slot, gui); } else { InventoryUtils.shiftClickSlot(gui, slot.slotNumber); cancel = true; } this.draggedSlots.add(slot.slotNumber); } return cancel; }
private static List<String> transferRectTooltip(GuiContainer gui, Collection<RecipeTransferRect> transferRects, int offsetx, int offsety, List<String> currenttip) { Point pos = getMousePosition(); Point relMouse = new Point(pos.x - gui.guiLeft - offsetx, pos.y - gui.guiTop - offsety); for (RecipeTransferRect rect : transferRects) { if (rect.rect.contains(relMouse)) { currenttip.add("Recipes"); break; } } return currenttip; }