Search in sources :

Example 1 with ChatComponentText

use of net.minecraft.network.chat.ChatComponentText in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_17_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.nextContainerCounter(), entityPlayer.getInventory(), inventory);
    container.setTitle(new ChatComponentText(title));
    // Cursor item is not updated, so we need to update it manually
    org.bukkit.inventory.ItemStack cursorItem = player.getItemOnCursor();
    entityPlayer.b.sendPacket(new PacketPlayOutOpenWindow(container.j, container.getType(), container.getTitle()));
    entityPlayer.bV = container;
    entityPlayer.initMenu(container);
    player.setItemOnCursor(cursorItem);
}
Also used : Container(net.minecraft.world.inventory.Container) TileEntityContainer(com.bgsoftware.wildchests.objects.containers.TileEntityContainer) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) PacketPlayOutOpenWindow(net.minecraft.network.protocol.game.PacketPlayOutOpenWindow) ChatComponentText(net.minecraft.network.chat.ChatComponentText)

Aggregations

TileEntityContainer (com.bgsoftware.wildchests.objects.containers.TileEntityContainer)1 ChatComponentText (net.minecraft.network.chat.ChatComponentText)1 PacketPlayOutOpenWindow (net.minecraft.network.protocol.game.PacketPlayOutOpenWindow)1 EntityPlayer (net.minecraft.server.level.EntityPlayer)1 Container (net.minecraft.world.inventory.Container)1 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)1