Java 类net.minecraft.server.PacketPlayOutOpenWindow 实例源码

项目:CraftBukkit    文件:CraftHumanEntity.java   
private void openCustomInventory(Inventory inventory, EntityPlayer player, int windowType) {
    if (player.playerConnection == null) return;
    Container container = new CraftContainer(inventory, this, player.nextContainerCounter());

    container = CraftEventFactory.callInventoryOpenEvent(player, container);
    if(container == null) return;

    String title = container.getBukkitView().getTitle();
    int size = container.getBukkitView().getTopInventory().getSize();

    player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, title, size, true));
    getHandle().activeContainer = container;
    getHandle().activeContainer.addSlotListener(player);
}
项目:CraftBukkit    文件:CraftContainer.java   
@Override
public boolean c(EntityHuman entityhuman) {
    if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
        return true;
    }
    // If the window type has changed for some reason, update the player
    // This method will be called every tick or something, so it's
    // as good a place as any to put something like this.
    boolean typeChanged = (cachedType != view.getType());
    cachedType = view.getType();
    cachedTitle = view.getTitle();
    if (view.getPlayer() instanceof CraftPlayer) {
        CraftPlayer player = (CraftPlayer) view.getPlayer();
        int type = getNotchInventoryType(cachedType);
        IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
        IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
        this.b.clear();
        this.c.clear();
        if (typeChanged) {
            setupSlots(top, bottom);
        }
        int size = getSize();
        player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, cachedTitle, size, true));
        player.updateInventory();
    }
    return true;
}
项目:Craftbukkit    文件:CraftContainer.java   
@Override
public boolean c(EntityHuman entityhuman) {
    if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
        return true;
    }
    // If the window type has changed for some reason, update the player
    // This method will be called every tick or something, so it's
    // as good a place as any to put something like this.
    boolean typeChanged = (cachedType != view.getType());
    cachedType = view.getType();
    cachedTitle = view.getTitle();
    if (view.getPlayer() instanceof CraftPlayer) {
        CraftPlayer player = (CraftPlayer) view.getPlayer();
        String type = getNotchInventoryType(cachedType);
        IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
        IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
        this.b.clear();
        this.c.clear();
        if (typeChanged) {
            setupSlots(top, bottom);
        }
        int size = getSize();
        player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle), size));
        player.updateInventory();
    }
    return true;
}
项目:Tweakkit-Server    文件:CraftHumanEntity.java   
private void openCustomInventory(Inventory inventory, EntityPlayer player, int windowType) {
    if (player.playerConnection == null) return;
    Container container = new CraftContainer(inventory, this, player.nextContainerCounter());

    container = CraftEventFactory.callInventoryOpenEvent(player, container);
    if(container == null) return;

    String title = container.getBukkitView().getTitle();
    int size = container.getBukkitView().getTopInventory().getSize();

    player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, title, size, true));
    getHandle().activeContainer = container;
    getHandle().activeContainer.addSlotListener(player);
}
项目:Tweakkit-Server    文件:CraftContainer.java   
@Override
public boolean c(EntityHuman entityhuman) {
    if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
        return true;
    }
    // If the window type has changed for some reason, update the player
    // This method will be called every tick or something, so it's
    // as good a place as any to put something like this.
    boolean typeChanged = (cachedType != view.getType());
    cachedType = view.getType();
    cachedTitle = view.getTitle();
    if (view.getPlayer() instanceof CraftPlayer) {
        CraftPlayer player = (CraftPlayer) view.getPlayer();
        int type = getNotchInventoryType(cachedType);
        IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
        IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
        this.b.clear();
        this.c.clear();
        if (typeChanged) {
            setupSlots(top, bottom);
        }
        int size = getSize();
        player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, cachedTitle, size, true));
        player.updateInventory();
    }
    return true;
}
项目:SpigotSource    文件:CraftContainer.java   
@Override
public boolean c(EntityHuman entityhuman) {
    if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
        return true;
    }
    // If the window type has changed for some reason, update the player
    // This method will be called every tick or something, so it's
    // as good a place as any to put something like this.
    boolean typeChanged = (cachedType != view.getType());
    cachedType = view.getType();
    cachedTitle = view.getTitle();
    if (view.getPlayer() instanceof CraftPlayer) {
        CraftPlayer player = (CraftPlayer) view.getPlayer();
        String type = getNotchInventoryType(cachedType);
        IInventory top = ((CraftInventory) view.getTopInventory()).getInventory();
        IInventory bottom = ((CraftInventory) view.getBottomInventory()).getInventory();
        this.b.clear();
        this.c.clear();
        if (typeChanged) {
            setupSlots(top, bottom);
        }
        int size = getSize();
        player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle), size));
        player.updateInventory();
    }
    return true;
}