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

项目:DecompiledMinecraft    文件: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.onCraftGuiOpened(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    IChatComponent ichatcomponent = villager.getDisplayName();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:villager", ichatcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:DecompiledMinecraft    文件: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.onCraftGuiOpened(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    IChatComponent ichatcomponent = villager.getDisplayName();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:villager", ichatcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:BaseClient    文件: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.onCraftGuiOpened(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    IChatComponent ichatcomponent = villager.getDisplayName();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:villager", ichatcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:BaseClient    文件: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.onCraftGuiOpened(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    IChatComponent ichatcomponent = villager.getDisplayName();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:villager", ichatcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:Resilience-Client-Source    文件:EntityPlayerMP.java   
public void displayGUIMerchant(IMerchant par1IMerchant, String par2Str)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, par1IMerchant, this.worldObj);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
    InventoryMerchant var3 = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 6, par2Str == null ? "" : par2Str, var3.getSizeInventory(), par2Str != null));
    MerchantRecipeList var4 = par1IMerchant.getRecipes(this);

    if (var4 != null)
    {
        try
        {
            PacketBuffer var5 = new PacketBuffer(Unpooled.buffer());
            var5.writeInt(this.currentWindowId);
            var4.func_151391_a(var5);
            this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", var5));
        }
        catch (IOException var6)
        {
            logger.error("Couldn\'t send trade list", var6);
        }
    }
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void displayGUIWorkbench(int p_71058_1_, int p_71058_2_, int p_71058_3_)
{
    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerWorkbench(this.inventory, this.worldObj, p_71058_1_, p_71058_2_, p_71058_3_));

    if (container == null)
    {
        return;
    }

    // CraftBukkit end
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 1, "Crafting", 9, true));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void displayGUIEnchantment(int p_71002_1_, int p_71002_2_, int p_71002_3_, String p_71002_4_)
{
    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerEnchantment(this.inventory, this.worldObj, p_71002_1_, p_71002_2_, p_71002_3_));

    if (container == null)
    {
        return;
    }

    // CraftBukkit end
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 4, p_71002_4_ == null ? "" : p_71002_4_, 9, p_71002_4_ != null));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void displayGUIAnvil(int p_82244_1_, int p_82244_2_, int p_82244_3_)
{
    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerRepair(this.inventory, this.worldObj, p_82244_1_, p_82244_2_, p_82244_3_, this));

    if (container == null)
    {
        return;
    }

    // CraftBukkit end
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 8, "Repairing", 9, true));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void displayGUIChest(IInventory p_71007_1_)
{
    if (this.openContainer != this.inventoryContainer)
    {
        this.closeScreen();
    }

    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerChest(this.inventory, p_71007_1_));

    if (container == null)
    {
        p_71007_1_.closeInventory(); // Cauldron - prevent chest from being stuck in open state on clients
        return;
    }

    // CraftBukkit end
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 0, p_71007_1_.getInventoryName(), p_71007_1_.getSizeInventory(), p_71007_1_.hasCustomInventoryName()));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void func_146093_a(TileEntityHopper p_146093_1_)
{
    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHopper(this.inventory, p_146093_1_));

    if (container == null)
    {
        p_146093_1_.closeInventory(); // Cauldron - prevent chest from being stuck in open state on clients
        return;
    }

    // CraftBukkit end
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 9, p_146093_1_.getInventoryName(), p_146093_1_.getSizeInventory(), p_146093_1_.hasCustomInventoryName()));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void displayGUIHopperMinecart(EntityMinecartHopper p_96125_1_)
{
    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHopper(this.inventory, p_96125_1_));

    if (container == null)
    {
        p_96125_1_.closeInventory(); // Cauldron - prevent chest from being stuck in open state on clients
        return;
    }

    // CraftBukkit end
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 9, p_96125_1_.getInventoryName(), p_96125_1_.getSizeInventory(), p_96125_1_.hasCustomInventoryName()));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void func_146101_a(TileEntityFurnace p_146101_1_)
{
    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerFurnace(this.inventory, p_146101_1_));

    if (container == null)
    {
        p_146101_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
        return;
    }

    // CraftBukkit end
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 2, p_146101_1_.getInventoryName(), p_146101_1_.getSizeInventory(), p_146101_1_.hasCustomInventoryName()));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void func_146102_a(TileEntityDispenser p_146102_1_)
{
    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerDispenser(this.inventory, p_146102_1_));

    if (container == null)
    {
        p_146102_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
        return;
    }

    // CraftBukkit end
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, p_146102_1_ instanceof TileEntityDropper ? 10 : 3, p_146102_1_.getInventoryName(), p_146102_1_.getSizeInventory(), p_146102_1_.hasCustomInventoryName()));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void func_146098_a(TileEntityBrewingStand p_146098_1_)
{
    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerBrewingStand(this.inventory, p_146098_1_));

    if (container == null)
    {
        p_146098_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
        return;
    }

    // CraftBukkit end
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 5, p_146098_1_.getInventoryName(), p_146098_1_.getSizeInventory(), p_146098_1_.hasCustomInventoryName()));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void func_146104_a(TileEntityBeacon p_146104_1_)
{
    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerBeacon(this.inventory, p_146104_1_));

    if (container == null)
    {
        p_146104_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
        return;
    }

    // CraftBukkit end
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 7, p_146104_1_.getInventoryName(), p_146104_1_.getSizeInventory(), p_146104_1_.hasCustomInventoryName()));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void displayGUIHorse(EntityHorse p_110298_1_, IInventory p_110298_2_)
{
    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorseInventory(this.inventory, p_110298_2_, p_110298_1_));

    if (container == null)
    {
        p_110298_2_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
        return;
    }

    // CraftBukkit end

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

    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 11, p_110298_2_.getInventoryName(), p_110298_2_.getSizeInventory(), p_110298_2_.hasCustomInventoryName(), p_110298_1_.getEntityId()));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:nailed    文件:CommandPlugin.java   
@Command(aliases = "invsee", desc = "Look at the inventory of another player")
@Require("admin")
public void invsee(CommandSender sender, Player player) throws CommandException {
    NailedPlayer p;
    if(sender instanceof Player){
        p = ((NailedPlayer) sender);
    }else{
        throw new CommandException("You are not a player");
    }
    EntityPlayerMP entity = p.getEntity();
    if(entity.openContainer != entity.inventoryContainer){
        entity.closeScreen();
    }
    entity.getNextWindowId();

    InventoryOtherPlayer chest = new InventoryOtherPlayer(((NailedPlayer) player).getEntity(), entity);
    entity.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(entity.currentWindowId, "minecraft:container", chest.getDisplayName(), chest.getSizeInventory()));
    entity.openContainer = new ContainerChest(entity.inventory, chest, entity);
    entity.openContainer.windowId = entity.currentWindowId;
    entity.openContainer.onCraftGuiOpened(entity);
}
项目:BlazeLoader    文件:ApiGui.java   
/**
* Opens a mod added container.
* 
* @param player      The player to open the container for
* @param inventory    The tile entity providing the inventory
*/
  public static void openContainer(EntityPlayerMP player, IModInventory inventory) {
      if (player.openContainer != player.inventoryContainer) player.closeScreen();

      if (inventory instanceof IModLockableInventory) {
          IModLockableInventory lockable = (IModLockableInventory)inventory;
          if (lockable.isLocked() && !player.canOpen(lockable.getLockCode()) && !player.isSpectator()) {
              player.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation(lockable.getLockMessageString(), inventory.getDisplayName()), (byte) 2));
              player.playerNetServerHandler.sendPacket(new S29PacketSoundEffect(lockable.getLockSoundString(), player.posX, player.posY, player.posZ, 1.0F, 1.0F));
              return;
          }
      }

      player.getNextWindowId();
      Container container = inventory.createContainer(player.inventory, player);
      player.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(player.currentWindowId, inventory.getGuiID(), inventory.getDisplayName(), inventory.getSizeInventory()));
      player.openContainer = container;
      player.openContainer.windowId = player.currentWindowId;
      player.openContainer.onCraftGuiOpened(player);
  }
项目:DecompiledMinecraft    文件:EntityPlayerMP.java   
public void displayGui(IInteractionObject guiOwner)
{
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
    this.openContainer = guiOwner.createContainer(this.inventory, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:DecompiledMinecraft    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory. Args: chestInventory
 */
public void displayGUIChest(IInventory chestInventory)
{
    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.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
            this.playerNetServerHandler.sendPacket(new S29PacketSoundEffect("random.door_close", this.posX, this.posY, this.posZ, 1.0F, 1.0F));
            return;
        }
    }

    this.getNextWindowId();

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

    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:DecompiledMinecraft    文件:EntityPlayerMP.java   
public void displayGUIHorse(EntityHorse horse, IInventory horseInventory)
{
    if (this.openContainer != this.inventoryContainer)
    {
        this.closeScreen();
    }

    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "EntityHorse", horseInventory.getDisplayName(), horseInventory.getSizeInventory(), horse.getEntityId()));
    this.openContainer = new ContainerHorseInventory(this.inventory, horseInventory, horse, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:DecompiledMinecraft    文件:EntityPlayerMP.java   
public void displayGui(IInteractionObject guiOwner)
{
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
    this.openContainer = guiOwner.createContainer(this.inventory, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:DecompiledMinecraft    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory. Args: chestInventory
 */
public void displayGUIChest(IInventory chestInventory)
{
    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.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
            this.playerNetServerHandler.sendPacket(new S29PacketSoundEffect("random.door_close", this.posX, this.posY, this.posZ, 1.0F, 1.0F));
            return;
        }
    }

    this.getNextWindowId();

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

    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:DecompiledMinecraft    文件:EntityPlayerMP.java   
public void displayGUIHorse(EntityHorse horse, IInventory horseInventory)
{
    if (this.openContainer != this.inventoryContainer)
    {
        this.closeScreen();
    }

    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "EntityHorse", horseInventory.getDisplayName(), horseInventory.getSizeInventory(), horse.getEntityId()));
    this.openContainer = new ContainerHorseInventory(this.inventory, horseInventory, horse, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:DecompiledMinecraft    文件: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(S2DPacketOpenWindow 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.displayGUIHorse((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
    {
        ContainerLocalMenu containerlocalmenu = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount());
        entityplayersp.displayGUIChest(containerlocalmenu);
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
}
项目:BaseClient    文件:InventoryPlus.java   
@EventTarget
private void onPacketSend(PacketReceiveEvent event) {
    if (event.packet instanceof S2DPacketOpenWindow) {
        shouldCancel = false;
        this.mc.thePlayer.closeScreen();
        shouldCancel = true;
    }
}
项目:BaseClient    文件:EntityPlayerMP.java   
public void displayGui(IInteractionObject guiOwner)
{
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
    this.openContainer = guiOwner.createContainer(this.inventory, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:BaseClient    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory. Args: chestInventory
 */
public void displayGUIChest(IInventory chestInventory)
{
    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.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
            this.playerNetServerHandler.sendPacket(new S29PacketSoundEffect("random.door_close", this.posX, this.posY, this.posZ, 1.0F, 1.0F));
            return;
        }
    }

    this.getNextWindowId();

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

    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:BaseClient    文件:EntityPlayerMP.java   
public void displayGUIHorse(EntityHorse horse, IInventory horseInventory)
{
    if (this.openContainer != this.inventoryContainer)
    {
        this.closeScreen();
    }

    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "EntityHorse", horseInventory.getDisplayName(), horseInventory.getSizeInventory(), horse.getEntityId()));
    this.openContainer = new ContainerHorseInventory(this.inventory, horseInventory, horse, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:BaseClient    文件: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(S2DPacketOpenWindow 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.displayGUIHorse((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
    {
        ContainerLocalMenu containerlocalmenu = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount());
        entityplayersp.displayGUIChest(containerlocalmenu);
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
}
项目:BaseClient    文件:EntityPlayerMP.java   
public void displayGui(IInteractionObject guiOwner)
{
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
    this.openContainer = guiOwner.createContainer(this.inventory, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:BaseClient    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory. Args: chestInventory
 */
public void displayGUIChest(IInventory chestInventory)
{
    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.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
            this.playerNetServerHandler.sendPacket(new S29PacketSoundEffect("random.door_close", this.posX, this.posY, this.posZ, 1.0F, 1.0F));
            return;
        }
    }

    this.getNextWindowId();

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

    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:BaseClient    文件:EntityPlayerMP.java   
public void displayGUIHorse(EntityHorse horse, IInventory horseInventory)
{
    if (this.openContainer != this.inventoryContainer)
    {
        this.closeScreen();
    }

    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "EntityHorse", horseInventory.getDisplayName(), horseInventory.getSizeInventory(), horse.getEntityId()));
    this.openContainer = new ContainerHorseInventory(this.inventory, horseInventory, horse, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
项目:BaseClient    文件: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(S2DPacketOpenWindow 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.displayGUIHorse((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 {
        ContainerLocalMenu containerlocalmenu = new ContainerLocalMenu(packetIn.getGuiId(),
                packetIn.getWindowTitle(), packetIn.getSlotCount());
        entityplayersp.displayGUIChest(containerlocalmenu);
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
}
项目:MeddleAPI    文件:MeddleClientHooks.java   
public static boolean handleOpenWindowHook(EntityPlayerSP player, S2DPacketOpenWindow packet)
{
    if (debug) System.out.println("openWindowHook: " + packet.getGuiId() + " " + packet.getSlotCount());    

    MeddleClient.IDisplayGui handler = MeddleClient.guiHandlers.get(packet.getGuiId());
    if (handler != null) 
    {
        handler.onOpenGui(player, packet.getGuiId(), packet.getWindowTitle(), packet.getSlotCount());
        player.openContainer.windowId = packet.getWindowId();
        return true;
    }       
    else return false;
}
项目:Resilience-Client-Source    文件:EntityPlayerMP.java   
/**
 * Displays the crafting GUI for a workbench.
 */
public void displayGUIWorkbench(int par1, int par2, int par3)
{
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 1, "Crafting", 9, true));
    this.openContainer = new ContainerWorkbench(this.inventory, this.worldObj, par1, par2, par3);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Resilience-Client-Source    文件:EntityPlayerMP.java   
public void displayGUIEnchantment(int par1, int par2, int par3, String par4Str)
{
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 4, par4Str == null ? "" : par4Str, 9, par4Str != null));
    this.openContainer = new ContainerEnchantment(this.inventory, this.worldObj, par1, par2, par3);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Resilience-Client-Source    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with an anvil.
 */
public void displayGUIAnvil(int par1, int par2, int par3)
{
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 8, "Repairing", 9, true));
    this.openContainer = new ContainerRepair(this.inventory, this.worldObj, par1, par2, par3, this);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Resilience-Client-Source    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory. Args: chestInventory
 */
public void displayGUIChest(IInventory par1IInventory)
{
    if (this.openContainer != this.inventoryContainer)
    {
        this.closeScreen();
    }

    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 0, par1IInventory.getInventoryName(), par1IInventory.getSizeInventory(), par1IInventory.isInventoryNameLocalized()));
    this.openContainer = new ContainerChest(this.inventory, par1IInventory);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:Resilience-Client-Source    文件:EntityPlayerMP.java   
public void func_146093_a(TileEntityHopper p_146093_1_)
{
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 9, p_146093_1_.getInventoryName(), p_146093_1_.getSizeInventory(), p_146093_1_.isInventoryNameLocalized()));
    this.openContainer = new ContainerHopper(this.inventory, p_146093_1_);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}