类net.minecraft.inventory.ContainerChest源码实例Demo

下面列出了怎么用net.minecraft.inventory.ContainerChest的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: EssentialCmds   文件: InvSeeExecutor.java
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();
}
 
源代码2 项目: SkyblockAddons   文件: GuiScreenHook.java
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();
    }
}
 
源代码3 项目: NotEnoughItems   文件: NEIChestGuiHandler.java
public int chestSize(GuiContainer gui) {
    return ((ContainerChest) gui.inventorySlots).getLowerChestInventory().getSizeInventory();
}
 
源代码4 项目: NotEnoughItems   文件: NEIChestGuiHandler.java
public int chestSize(GuiContainer gui) {
    return ((ContainerChest) gui.inventorySlots).getLowerChestInventory().getSizeInventory();
}