net.minecraft.inventory.ContainerChest Java Examples

The following examples show how to use net.minecraft.inventory.ContainerChest. 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: InvSeeExecutor.java    From EssentialCmds with MIT License 5 votes vote down vote up
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
{
	Player target = ctx.<Player> getOne("target").get();

	if (src instanceof Player)
	{
		Player player = (Player) src;
		EntityPlayerMP playerMP = ((EntityPlayerMP) (Object) player);
		EntityPlayerMP targetMP = ((EntityPlayerMP) (Object) target);

		InventoryPlayer inventory = targetMP.inventory;
		ContainerChest container = new ContainerChest(playerMP.inventory, inventory, playerMP);

		if (playerMP.openContainer != playerMP.inventoryContainer)
		{
			playerMP.closeScreen();
		}

		playerMP.getNextWindowId();

		playerMP.connection.sendPacket(new SPacketOpenWindow(playerMP.currentWindowId, "minecraft:container", inventory.getDisplayName(), inventory.getSizeInventory()));
		playerMP.openContainer = container;

		playerMP.openContainer.windowId = playerMP.currentWindowId;
		playerMP.openContainer.addListener(playerMP);
	}
	else
	{
		src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be a player to see other inventories."));
	}

	return CommandResult.success();
}
 
Example #2
Source File: GuiScreenHook.java    From SkyblockAddons with MIT License 4 votes vote down vote up
public static void renderBackpack(ItemStack stack, int x, int y, ReturnValue<?> returnValue) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    if (stack.getItem().equals(Items.skull) && main.getConfigValues().isEnabled(Feature.SHOW_BACKPACK_PREVIEW)) {
        if (main.getConfigValues().isEnabled(Feature.SHOW_BACKPACK_HOLDING_SHIFT) && !GuiScreen.isShiftKeyDown()) {
            return;
        }

        Container playerContainer = Minecraft.getMinecraft().thePlayer.openContainer;
        if (playerContainer instanceof ContainerChest) { // Avoid showing backpack preview in auction stuff.
            IInventory chestInventory = ((ContainerChest) playerContainer).getLowerChestInventory();
            if (chestInventory.hasCustomName()) {
                String chestName = chestInventory.getDisplayName().getUnformattedText();
                if (chestName.contains("Auction") || "Your Bids".equals(chestName)) {

                    // Show preview for backpacks in player inventory if enabled.
                    if (!main.getConfigValues().isEnabled(Feature.BACKPACK_PREVIEW_AH)) {
                        return;
                    }

                    /*
                    If the backpack is in the auction house window, ignore it.
                    Empty backpacks can't be listed in the auction.
                     */
                    for (int i = 0; i < chestInventory.getSizeInventory(); i++) {
                        if (ItemStack.areItemStackTagsEqual(chestInventory.getStackInSlot(i), stack)) {
                            return;
                        }
                    }
                }
            }
        }

        Backpack backpack = BackpackManager.getFromItem(stack);
        if (backpack != null) {
            backpack.setX(x);
            backpack.setY(y);
            if (isFreezeKeyDown() && System.currentTimeMillis() - lastBackpackFreezeKey > 500) {
                lastBackpackFreezeKey = System.currentTimeMillis();
                GuiContainerHook.setFreezeBackpack(!GuiContainerHook.isFreezeBackpack());
                main.getUtils().setBackpackToPreview(backpack);
            }
            if (!GuiContainerHook.isFreezeBackpack()) {
                main.getUtils().setBackpackToPreview(backpack);
            }
            main.getPlayerListener().onItemTooltip(new ItemTooltipEvent(stack, null, null, false));
            returnValue.cancel();
        }
    }
    if (GuiContainerHook.isFreezeBackpack()) {
        returnValue.cancel();
    }
}
 
Example #3
Source File: NEIChestGuiHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public int chestSize(GuiContainer gui) {
    return ((ContainerChest) gui.inventorySlots).getLowerChestInventory().getSizeInventory();
}
 
Example #4
Source File: NEIChestGuiHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public int chestSize(GuiContainer gui) {
    return ((ContainerChest) gui.inventorySlots).getLowerChestInventory().getSizeInventory();
}