Search in sources :

Example 1 with PacketPlayOutOpenWindow

use of net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_16_R3 method openPage.

@Override
public void openPage(Player player, com.bgsoftware.wildchests.objects.inventory.CraftWildInventory inventory) {
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    String title = inventory.getTitle();
    Container container = createContainer(entityPlayer.nextContainerCounter(), entityPlayer.inventory, inventory);
    container.setTitle(new ChatComponentText(title));
    entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(), container.getTitle()));
    entityPlayer.activeContainer = container;
    entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
Also used : Container(net.minecraft.server.v1_16_R3.Container) TileEntityContainer(com.bgsoftware.wildchests.objects.containers.TileEntityContainer) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) PacketPlayOutOpenWindow(net.minecraft.server.v1_16_R3.PacketPlayOutOpenWindow) ChatComponentText(net.minecraft.server.v1_16_R3.ChatComponentText)

Example 2 with PacketPlayOutOpenWindow

use of net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_12_R1 method openPage.

@Override
public void openPage(Player player, com.bgsoftware.wildchests.objects.inventory.CraftWildInventory inventory) {
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    String title = inventory.getTitle();
    Container container = createContainer(entityPlayer.inventory, entityPlayer, inventory);
    container.windowId = entityPlayer.nextContainerCounter();
    TileEntityWildChest tileEntityWildChest = getTileEntity(inventory.getOwner());
    entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, tileEntityWildChest.getContainerName(), new ChatComponentText(title), inventory.getSize()));
    entityPlayer.activeContainer = container;
    entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
Also used : Container(net.minecraft.server.v1_12_R1.Container) TileEntityContainer(com.bgsoftware.wildchests.objects.containers.TileEntityContainer) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) PacketPlayOutOpenWindow(net.minecraft.server.v1_12_R1.PacketPlayOutOpenWindow) ChatComponentText(net.minecraft.server.v1_12_R1.ChatComponentText)

Example 3 with PacketPlayOutOpenWindow

use of net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_8_R3 method openPage.

@Override
public void openPage(Player player, com.bgsoftware.wildchests.objects.inventory.CraftWildInventory inventory) {
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    String title = inventory.getTitle();
    Container container = createContainer(entityPlayer.inventory, entityPlayer, inventory);
    container.windowId = entityPlayer.nextContainerCounter();
    TileEntityWildChest tileEntityWildChest = getTileEntity(inventory.getOwner());
    entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, tileEntityWildChest.getContainerName(), new ChatComponentText(title), inventory.getSize()));
    entityPlayer.activeContainer = container;
    entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
Also used : TileEntityContainer(com.bgsoftware.wildchests.objects.containers.TileEntityContainer) Container(net.minecraft.server.v1_8_R3.Container) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) PacketPlayOutOpenWindow(net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow) ChatComponentText(net.minecraft.server.v1_8_R3.ChatComponentText)

Example 4 with PacketPlayOutOpenWindow

use of net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow in project PaperDev by Kamillaova.

the class CraftContainer method c.

@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();
        PlayerInventory bottom = (PlayerInventory) ((CraftInventory) view.getBottomInventory()).getInventory();
        this.items.clear();
        this.slots.clear();
        if (typeChanged) {
            setupSlots(top, bottom, player.getHandle());
        }
        int size = getSize();
        player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle), size));
        player.updateInventory();
    }
    return true;
}
Also used : IInventory(net.minecraft.server.v1_12_R1.IInventory) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) PlayerInventory(net.minecraft.server.v1_12_R1.PlayerInventory) PacketPlayOutOpenWindow(net.minecraft.server.v1_12_R1.PacketPlayOutOpenWindow) ChatComponentText(net.minecraft.server.v1_12_R1.ChatComponentText)

Aggregations

TileEntityContainer (com.bgsoftware.wildchests.objects.containers.TileEntityContainer)3 ChatComponentText (net.minecraft.server.v1_12_R1.ChatComponentText)2 PacketPlayOutOpenWindow (net.minecraft.server.v1_12_R1.PacketPlayOutOpenWindow)2 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)2 Container (net.minecraft.server.v1_12_R1.Container)1 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)1 IInventory (net.minecraft.server.v1_12_R1.IInventory)1 PlayerInventory (net.minecraft.server.v1_12_R1.PlayerInventory)1 ChatComponentText (net.minecraft.server.v1_16_R3.ChatComponentText)1 Container (net.minecraft.server.v1_16_R3.Container)1 EntityPlayer (net.minecraft.server.v1_16_R3.EntityPlayer)1 PacketPlayOutOpenWindow (net.minecraft.server.v1_16_R3.PacketPlayOutOpenWindow)1 ChatComponentText (net.minecraft.server.v1_8_R3.ChatComponentText)1 Container (net.minecraft.server.v1_8_R3.Container)1 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)1 PacketPlayOutOpenWindow (net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow)1 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)1