Search in sources :

Example 21 with EntityPlayer

use of net.minecraft.server.level.EntityPlayer 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)

Example 22 with EntityPlayer

use of net.minecraft.server.level.EntityPlayer in project PublicCrafters by BananaPuncher714.

the class ContainerManager_v1_18_R1 method animate.

@Override
public void animate(Player player) {
    EntityPlayer NMSPlayer = ((CraftPlayer) player).getHandle();
    broadcastPacket(player, new PacketPlayOutAnimation(NMSPlayer, ThreadLocalRandom.current().nextInt(2) == 1 ? 0 : 3));
}
Also used : EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer) PacketPlayOutAnimation(net.minecraft.network.protocol.game.PacketPlayOutAnimation)

Aggregations

EntityPlayer (net.minecraft.server.level.EntityPlayer)22 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)10 CraftPlayer (org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer)10 Pair (com.mojang.datafixers.util.Pair)6 ArrayList (java.util.ArrayList)6 PacketPlayOutAnimation (net.minecraft.network.protocol.game.PacketPlayOutAnimation)4 ItemStack (net.minecraft.world.item.ItemStack)4 Location (org.bukkit.Location)4 Player (org.bukkit.entity.Player)4 PlayerInventory (net.minecraft.world.entity.player.PlayerInventory)3 Channel (io.netty.channel.Channel)2 ChannelPipeline (io.netty.channel.ChannelPipeline)2 BlockPosition (net.minecraft.core.BlockPosition)2 NonNullList (net.minecraft.core.NonNullList)2 WorldServer (net.minecraft.server.level.WorldServer)2 IBlockData (net.minecraft.world.level.block.state.IBlockData)2 CraftPlayer (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer)2 TileEntityContainer (com.bgsoftware.wildchests.objects.containers.TileEntityContainer)1 HashMap (java.util.HashMap)1 ChatComponentText (net.minecraft.network.chat.ChatComponentText)1