Java 类net.minecraft.network.play.server.SPacketOpenWindow 实例源码

项目:Zombe-Modpack    文件:EntityPlayerMP.java   
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.world);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.world);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
public void displayGui(IInteractionObject guiOwner)
{
    if (guiOwner instanceof ILootContainer && ((ILootContainer)guiOwner).getLootTable() != null && this.isSpectator())
    {
        this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
    }
    else
    {
        this.getNextWindowId();
        this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
        this.openContainer = guiOwner.createContainer(this.inventory, this);
        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    }
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
public void displayGui(IInteractionObject guiOwner)
{
    if (guiOwner instanceof ILootContainer && ((ILootContainer)guiOwner).getLootTable() != null && this.isSpectator())
    {
        this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
    }
    else
    {
        this.getNextWindowId();
        this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
        this.openContainer = guiOwner.createContainer(this.inventory, this);
        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    }
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:VirtualTool    文件:Invs.java   
public CommandResult Open(CommandSource src, Container opencon, String inventoryTypeIn, String title) {
    final Player player = Tools.getPlayer(src, vt);
    final EntityPlayerMP MPlayer = (EntityPlayerMP) player;
    MPlayer.getNextWindowId();
    MPlayer.connection.sendPacket(new SPacketOpenWindow(MPlayer.currentWindowId, inventoryTypeIn, new TextComponentString(title)));
    MPlayer.openContainer = opencon;
    MPlayer.openContainer.windowId = MPlayer.currentWindowId;
    MPlayer.openContainer.addListener(MPlayer);

    return CommandResult.success();
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
public void displayGui(IInteractionObject guiOwner)
{
    if (guiOwner instanceof ILootContainer && ((ILootContainer)guiOwner).getLootTable() != null && this.isSpectator())
    {
        this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
    }
    else
    {
        this.getNextWindowId();
        this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
        this.openContainer = guiOwner.createContainer(this.inventory, this);
        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
    }
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
public void openGuiHorseInventory(AbstractHorse horse, IInventory inventoryIn)
{
    if (this.openContainer != this.inventoryContainer)
    {
        this.closeScreen();
    }

    this.getNextWindowId();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "EntityHorse", inventoryIn.getDisplayName(), inventoryIn.getSizeInventory(), horse.getEntityId()));
    this.openContainer = new ContainerHorseInventory(this.inventory, inventoryIn, horse, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
}
项目:Zombe-Modpack    文件:NetHandlerPlayClient.java   
/**
 * Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
 * Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
 */
public void handleOpenWindow(SPacketOpenWindow packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayerSP entityplayersp = this.gameController.player;

    if ("minecraft:container".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayGUIChest(new InventoryBasic(packetIn.getWindowTitle(), packetIn.getSlotCount()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("minecraft:villager".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayVillagerTradeGui(new NpcMerchant(entityplayersp, packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("EntityHorse".equals(packetIn.getGuiId()))
    {
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

        if (entity instanceof AbstractHorse)
        {
            entityplayersp.openGuiHorseInventory((AbstractHorse)entity, new ContainerHorseChest(packetIn.getWindowTitle(), packetIn.getSlotCount()));
            entityplayersp.openContainer.windowId = packetIn.getWindowId();
        }
    }
    else if (!packetIn.hasSlots())
    {
        entityplayersp.displayGui(new LocalBlockIntercommunication(packetIn.getGuiId(), packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else
    {
        IInventory iinventory = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount());
        entityplayersp.displayGUIChest(iinventory);
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
public void displayGui(IInteractionObject guiOwner)
{
    if (guiOwner instanceof ILootContainer && ((ILootContainer)guiOwner).getLootTable() != null && this.isSpectator())
    {
        this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
    }
    else
    {
        this.getNextWindowId();
        this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
        this.openContainer = guiOwner.createContainer(this.inventory, this);
        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
public void openGuiHorseInventory(AbstractHorse horse, IInventory inventoryIn)
{
    if (this.openContainer != this.inventoryContainer)
    {
        this.closeScreen();
    }

    this.getNextWindowId();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "EntityHorse", inventoryIn.getDisplayName(), inventoryIn.getSizeInventory(), horse.getEntityId()));
    this.openContainer = new ContainerHorseInventory(this.inventory, inventoryIn, horse, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
}
项目:Backmemed    文件:NetHandlerPlayClient.java   
/**
 * Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
 * Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
 */
public void handleOpenWindow(SPacketOpenWindow packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayerSP entityplayersp = this.gameController.player;

    if ("minecraft:container".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayGUIChest(new InventoryBasic(packetIn.getWindowTitle(), packetIn.getSlotCount()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("minecraft:villager".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayVillagerTradeGui(new NpcMerchant(entityplayersp, packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("EntityHorse".equals(packetIn.getGuiId()))
    {
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

        if (entity instanceof AbstractHorse)
        {
            entityplayersp.openGuiHorseInventory((AbstractHorse)entity, new ContainerHorseChest(packetIn.getWindowTitle(), packetIn.getSlotCount()));
            entityplayersp.openContainer.windowId = packetIn.getWindowId();
        }
    }
    else if (!packetIn.hasSlots())
    {
        entityplayersp.displayGui(new LocalBlockIntercommunication(packetIn.getGuiId(), packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else
    {
        IInventory iinventory = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount());
        entityplayersp.displayGUIChest(iinventory);
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
public void openGuiHorseInventory(EntityHorse horse, IInventory inventoryIn)
{
    if (this.openContainer != this.inventoryContainer)
    {
        this.closeScreen();
    }

    this.getNextWindowId();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "EntityHorse", inventoryIn.getDisplayName(), inventoryIn.getSizeInventory(), horse.getEntityId()));
    this.openContainer = new ContainerHorseInventory(this.inventory, inventoryIn, horse, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
}
项目:CustomWorldGen    文件:NetHandlerPlayClient.java   
/**
 * Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
 * Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
 */
public void handleOpenWindow(SPacketOpenWindow packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayerSP entityplayersp = this.gameController.thePlayer;

    if ("minecraft:container".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayGUIChest(new InventoryBasic(packetIn.getWindowTitle(), packetIn.getSlotCount()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("minecraft:villager".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayVillagerTradeGui(new NpcMerchant(entityplayersp, packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("EntityHorse".equals(packetIn.getGuiId()))
    {
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

        if (entity instanceof EntityHorse)
        {
            entityplayersp.openGuiHorseInventory((EntityHorse)entity, new AnimalChest(packetIn.getWindowTitle(), packetIn.getSlotCount()));
            entityplayersp.openContainer.windowId = packetIn.getWindowId();
        }
    }
    else if (!packetIn.hasSlots())
    {
        entityplayersp.displayGui(new LocalBlockIntercommunication(packetIn.getGuiId(), packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else
    {
        IInventory iinventory = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount());
        entityplayersp.displayGUIChest(iinventory);
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
}
项目: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();
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
public void openGuiHorseInventory(EntityHorse horse, IInventory inventoryIn)
{
    if (this.openContainer != this.inventoryContainer)
    {
        this.closeScreen();
    }

    this.getNextWindowId();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "EntityHorse", inventoryIn.getDisplayName(), inventoryIn.getSizeInventory(), horse.getEntityId()));
    this.openContainer = new ContainerHorseInventory(this.inventory, inventoryIn, horse, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
}
项目:ExpandedRailsMod    文件:NetHandlerPlayClient.java   
/**
 * Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
 * Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
 */
public void handleOpenWindow(SPacketOpenWindow packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayerSP entityplayersp = this.gameController.thePlayer;

    if ("minecraft:container".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayGUIChest(new InventoryBasic(packetIn.getWindowTitle(), packetIn.getSlotCount()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("minecraft:villager".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayVillagerTradeGui(new NpcMerchant(entityplayersp, packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("EntityHorse".equals(packetIn.getGuiId()))
    {
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

        if (entity instanceof EntityHorse)
        {
            entityplayersp.openGuiHorseInventory((EntityHorse)entity, new AnimalChest(packetIn.getWindowTitle(), packetIn.getSlotCount()));
            entityplayersp.openContainer.windowId = packetIn.getWindowId();
        }
    }
    else if (!packetIn.hasSlots())
    {
        entityplayersp.displayGui(new LocalBlockIntercommunication(packetIn.getGuiId(), packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else
    {
        IInventory iinventory = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount());
        entityplayersp.displayGUIChest(iinventory);
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory.
 */
public void displayGUIChest(IInventory chestInventory)
{
    if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
    {
        this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
    }
    else
    {
        if (this.openContainer != this.inventoryContainer)
        {
            this.closeScreen();
        }

        if (chestInventory instanceof ILockableContainer)
        {
            ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;

            if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
            {
                this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
                this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
                return;
            }
        }

        this.getNextWindowId();

        if (chestInventory instanceof IInteractionObject)
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
        }
        else
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
        }

        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory.
 */
public void displayGUIChest(IInventory chestInventory)
{
    if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
    {
        this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
    }
    else
    {
        if (this.openContainer != this.inventoryContainer)
        {
            this.closeScreen();
        }

        if (chestInventory instanceof ILockableContainer)
        {
            ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;

            if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
            {
                this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
                this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
                return;
            }
        }

        this.getNextWindowId();

        if (chestInventory instanceof IInteractionObject)
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
        }
        else
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
        }

        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
    }
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory.
 */
public void displayGUIChest(IInventory chestInventory)
{
    if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
    {
        this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
    }
    else
    {
        if (this.openContainer != this.inventoryContainer)
        {
            this.closeScreen();
        }

        if (chestInventory instanceof ILockableContainer)
        {
            ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;

            if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
            {
                this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
                this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
                return;
            }
        }

        this.getNextWindowId();

        if (chestInventory instanceof IInteractionObject)
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
        }
        else
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
        }

        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    }
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory.
 */
public void displayGUIChest(IInventory chestInventory)
{
    if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
    {
        this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
    }
    else
    {
        if (this.openContainer != this.inventoryContainer)
        {
            this.closeScreen();
        }

        if (chestInventory instanceof ILockableContainer)
        {
            ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;

            if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
            {
                this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
                this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
                return;
            }
        }

        this.getNextWindowId();

        if (chestInventory instanceof IInteractionObject)
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
        }
        else
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
        }

        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    }
}
项目:Backmemed    文件:INetHandlerPlayClient.java   
/**
 * Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
 * Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
 */
void handleOpenWindow(SPacketOpenWindow packetIn);
项目:CustomWorldGen    文件:INetHandlerPlayClient.java   
/**
 * Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
 * Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
 */
void handleOpenWindow(SPacketOpenWindow packetIn);