net.minecraft.inventory.ContainerPlayer Java Examples
The following examples show how to use
net.minecraft.inventory.ContainerPlayer.
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: GuiContainerHook.java From SkyblockAddons with MIT License | 6 votes |
public static void drawGradientRect(GuiContainer guiContainer, int left, int top, int right, int bottom, int startColor, int endColor, Slot theSlot) { if (freezeBackpack) return; SkyblockAddons main = SkyblockAddons.getInstance(); Container container = Minecraft.getMinecraft().thePlayer.openContainer; if (theSlot != null) { int slotNum = theSlot.slotNumber + main.getInventoryUtils().getSlotDifference(container); main.getUtils().setLastHoveredSlot(slotNum); if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && main.getUtils().isOnSkyblock() && main.getConfigValues().getLockedSlots().contains(slotNum) && (slotNum >= 9 || container instanceof ContainerPlayer && slotNum >= 5)) { drawRightGradientRect(guiContainer, left, top, right, bottom, OVERLAY_RED, OVERLAY_RED); return; } } drawRightGradientRect(guiContainer, left, top, right, bottom, startColor, endColor); }
Example #2
Source File: MinecraftHook.java From SkyblockAddons with MIT License | 6 votes |
public static void updatedCurrentItem() { Minecraft mc = Minecraft.getMinecraft(); SkyblockAddons main = SkyblockAddons.getInstance(); if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && (main.getUtils().isOnSkyblock() || main.getPlayerListener().aboutToJoinSkyblockServer())) { int slot = mc.thePlayer.inventory.currentItem + 36; if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && main.getConfigValues().getLockedSlots().contains(slot) && (slot >= 9 || mc.thePlayer.openContainer instanceof ContainerPlayer && slot >= 5)) { MinecraftHook.lastLockedSlotItemChange = System.currentTimeMillis(); } ItemStack heldItemStack = mc.thePlayer.getHeldItem(); if (heldItemStack != null && main.getConfigValues().isEnabled(Feature.STOP_DROPPING_SELLING_RARE_ITEMS) && !main.getUtils().isInDungeon() && !main.getUtils().getItemDropChecker().canDropItem(heldItemStack, true, false)) { MinecraftHook.lastLockedSlotItemChange = System.currentTimeMillis(); } } }
Example #3
Source File: GuiContainerHook.java From SkyblockAddons with MIT License | 5 votes |
public static void keyTyped(GuiContainer guiContainer, int keyCode, Slot theSlot, ReturnValue<?> returnValue) { SkyblockAddons main = SkyblockAddons.getInstance(); Minecraft mc = Minecraft.getMinecraft(); if (main.getUtils().isOnSkyblock()) { if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && (keyCode != 1 && keyCode != mc.gameSettings.keyBindInventory.getKeyCode())) { int slot = main.getUtils().getLastHoveredSlot(); if (mc.thePlayer.inventory.getItemStack() == null && theSlot != null) { for (int i = 0; i < 9; ++i) { if (keyCode == mc.gameSettings.keyBindsHotbar[i].getKeyCode()) { slot = i + 36; // They are hotkeying, the actual slot is the targeted one, +36 because } } } if (slot >= 9 || mc.thePlayer.openContainer instanceof ContainerPlayer && slot >= 5) { if (main.getConfigValues().getLockedSlots().contains(slot)) { if (main.getLockSlotKey().getKeyCode() == keyCode) { main.getUtils().playLoudSound("random.orb", 1); main.getConfigValues().getLockedSlots().remove(slot); main.getConfigValues().saveConfig(); } else { main.getUtils().playLoudSound("note.bass", 0.5); returnValue.cancel(); // slot is locked return; } } else { if (main.getLockSlotKey().getKeyCode() == keyCode) { main.getUtils().playLoudSound("random.orb", 0.1); main.getConfigValues().getLockedSlots().add(slot); main.getConfigValues().saveConfig(); } } } } if (mc.gameSettings.keyBindDrop.getKeyCode() == keyCode && main.getConfigValues().isEnabled(Feature.STOP_DROPPING_SELLING_RARE_ITEMS) && !main.getUtils().isInDungeon()) { if (!main.getUtils().getItemDropChecker().canDropItem(theSlot)) returnValue.cancel(); } } }
Example #4
Source File: AutoMend.java From ForgeHax with MIT License | 5 votes |
@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 #5
Source File: GuiContainerHook.java From SkyblockAddons with MIT License | 4 votes |
public static void drawSlot(GuiContainer guiContainer, Slot slot) { SkyblockAddons main = SkyblockAddons.getInstance(); Minecraft mc = Minecraft.getMinecraft(); Container container = mc.thePlayer.openContainer; if (slot != null) { // Draw crafting pattern overlays inside the crafting grid. if (main.getConfigValues().isEnabled(Feature.CRAFTING_PATTERNS) && main.getUtils().isOnSkyblock() && slot.inventory.getDisplayName().getUnformattedText().equals(CraftingPattern.CRAFTING_TABLE_DISPLAYNAME) && main.getPersistentValues().getSelectedCraftingPattern() != CraftingPattern.FREE) { int craftingGridIndex = CraftingPattern.slotToCraftingGridIndex(slot.getSlotIndex()); if (craftingGridIndex >= 0) { int slotLeft = slot.xDisplayPosition; int slotTop = slot.yDisplayPosition; int slotRight = slotLeft + 16; int slotBottom = slotTop + 16; if (main.getPersistentValues().getSelectedCraftingPattern().isSlotInPattern(craftingGridIndex)) { if (!slot.getHasStack()) { drawRightGradientRect(guiContainer, slotLeft, slotTop, slotRight, slotBottom, OVERLAY_GREEN, OVERLAY_GREEN); } } else { if (slot.getHasStack()) { drawRightGradientRect(guiContainer, slotLeft, slotTop, slotRight, slotBottom, OVERLAY_RED, OVERLAY_RED); } } } } if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && main.getUtils().isOnSkyblock()) { int slotNum = slot.slotNumber + main.getInventoryUtils().getSlotDifference(container); if (main.getConfigValues().getLockedSlots().contains(slotNum) && (slotNum >= 9 || container instanceof ContainerPlayer && slotNum >= 5)) { GlStateManager.disableLighting(); GlStateManager.disableDepth(); GlStateManager.color(1,1,1,0.4F); GlStateManager.enableBlend(); mc.getTextureManager().bindTexture(LOCK); mc.ingameGUI.drawTexturedModalRect(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16); GlStateManager.enableLighting(); GlStateManager.enableDepth(); } } } }
Example #6
Source File: EntityPlayerSPHook.java From SkyblockAddons with MIT License | 4 votes |
public static EntityItem dropOneItemConfirmation(ReturnValue<?> returnValue) { SkyblockAddons main = SkyblockAddons.getInstance(); Minecraft mc = Minecraft.getMinecraft(); ItemStack heldItemStack = mc.thePlayer.getHeldItem(); if ((main.getUtils().isOnSkyblock() || main.getPlayerListener().aboutToJoinSkyblockServer())) { if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && !main.getUtils().isInDungeon()) { int slot = mc.thePlayer.inventory.currentItem + 36; if (main.getConfigValues().getLockedSlots().contains(slot) && (slot >= 9 || mc.thePlayer.openContainer instanceof ContainerPlayer && slot >= 5)) { main.getUtils().playLoudSound("note.bass", 0.5); SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_SLOT_LOCKED.getMessage()); returnValue.cancel(); return null; } if (System.currentTimeMillis() - MinecraftHook.getLastLockedSlotItemChange() < 200) { main.getUtils().playLoudSound("note.bass", 0.5); SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_SWITCHED_SLOTS.getMessage()); returnValue.cancel(); return null; } } if (heldItemStack != null && main.getConfigValues().isEnabled(Feature.STOP_DROPPING_SELLING_RARE_ITEMS) && !main.getUtils().isInDungeon()) { if (!main.getUtils().getItemDropChecker().canDropItem(heldItemStack, true)) { main.getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.STOP_DROPPING_SELLING_RARE_ITEMS) + Message.MESSAGE_CANCELLED_DROPPING.getMessage()); returnValue.cancel(); return null; } if (System.currentTimeMillis() - MinecraftHook.getLastLockedSlotItemChange() < 200) { main.getUtils().playLoudSound("note.bass", 0.5); SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_SWITCHED_SLOTS.getMessage()); returnValue.cancel(); return null; } } } if (heldItemStack != null && main.getConfigValues().isEnabled(Feature.DROP_CONFIRMATION) && !main.getUtils().isInDungeon() && (main.getUtils().isOnSkyblock() || main.getPlayerListener().aboutToJoinSkyblockServer() || main.getConfigValues().isEnabled(Feature.DOUBLE_DROP_IN_OTHER_GAMES))) { lastDrop = Minecraft.getSystemTime(); String heldItemName = heldItemStack.hasDisplayName() ? heldItemStack.getDisplayName() : heldItemStack.getUnlocalizedName(); if (lastItemName == null || !lastItemName.equals(heldItemName) || Minecraft.getSystemTime() - lastDrop >= 3000L) { SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_DROP_CONFIRMATION.getMessage()); lastItemName = heldItemName; returnValue.cancel(); } } return null; }
Example #7
Source File: ExtraInventory.java From ForgeHax with MIT License | 4 votes |
private static Optional<ContainerPlayer> getPlayerContainer() { return Optional.ofNullable(getCurrentContainer()) .filter(ContainerPlayer.class::isInstance) .map(ContainerPlayer.class::cast); }