Search in sources :

Example 16 with EntityPlayer

use of net.minecraft.server.level.EntityPlayer in project FunnyGuilds by FunnyGuilds.

the class V1_18PacketAccessor method getOrInstallChannelHandler.

@Override
public FunnyGuildsChannelHandler getOrInstallChannelHandler(Player player) {
    final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    // entityPlayer.playerConnection.networkManager.channel
    final Channel channel = entityPlayer.b.a.k;
    final ChannelPipeline pipeline = channel.pipeline();
    return this.channelHandlerInstaller.installChannelHandlerInPipeline(pipeline);
}
Also used : Channel(io.netty.channel.Channel) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 17 with EntityPlayer

use of net.minecraft.server.level.EntityPlayer in project FunnyGuilds by FunnyGuilds.

the class V1_17PacketAccessor method getOrInstallChannelHandler.

@Override
public FunnyGuildsChannelHandler getOrInstallChannelHandler(Player player) {
    final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    // entityPlayer.playerConnection.networkManager.channel
    final Channel channel = entityPlayer.b.a.k;
    final ChannelPipeline pipeline = channel.pipeline();
    return this.channelHandlerInstaller.installChannelHandlerInPipeline(pipeline);
}
Also used : Channel(io.netty.channel.Channel) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 18 with EntityPlayer

use of net.minecraft.server.level.EntityPlayer in project BedWars1058 by andrei1058.

the class v1_17_R1 method sendPlayerSpawnPackets.

@Override
public void sendPlayerSpawnPackets(Player respawned, IArena arena) {
    if (respawned == null)
        return;
    if (arena == null)
        return;
    if (!arena.isPlayer(respawned))
        return;
    // if method was used when the player was still in re-spawning screen
    if (arena.getRespawnSessions().containsKey(respawned))
        return;
    EntityPlayer entityPlayer = ((CraftPlayer) respawned).getHandle();
    PacketPlayOutNamedEntitySpawn show = new PacketPlayOutNamedEntitySpawn(entityPlayer);
    PacketPlayOutEntityVelocity playerVelocity = new PacketPlayOutEntityVelocity(entityPlayer);
    PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entityPlayer, getCompressedAngle(entityPlayer.getBukkitYaw()));
    List<Pair<EnumItemSlot, ItemStack>> list = new ArrayList<>();
    list.add(new Pair<>(EnumItemSlot.a, entityPlayer.getItemInMainHand()));
    list.add(new Pair<>(EnumItemSlot.b, entityPlayer.getItemInOffHand()));
    list.add(new Pair<>(EnumItemSlot.f, entityPlayer.getInventory().getArmorContents().get(3)));
    list.add(new Pair<>(EnumItemSlot.e, entityPlayer.getInventory().getArmorContents().get(2)));
    list.add(new Pair<>(EnumItemSlot.d, entityPlayer.getInventory().getArmorContents().get(1)));
    list.add(new Pair<>(EnumItemSlot.c, entityPlayer.getInventory().getArmorContents().get(0)));
    for (Player p : arena.getPlayers()) {
        if (p == null)
            continue;
        if (p.equals(respawned))
            continue;
        // if p is in re-spawning screen continue
        if (arena.getRespawnSessions().containsKey(p))
            continue;
        EntityPlayer boundTo = ((CraftPlayer) p).getHandle();
        if (p.getWorld().equals(respawned.getWorld())) {
            if (respawned.getLocation().distance(p.getLocation()) <= arena.getRenderDistance()) {
                // send respawned player to regular players
                boundTo.b.sendPacket(show);
                boundTo.b.sendPacket(head);
                boundTo.b.sendPacket(playerVelocity);
                boundTo.b.sendPacket(new PacketPlayOutEntityEquipment(entityPlayer.getId(), list));
                // if the player has invisibility hide armor
                if (p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
                    hideArmor(p, respawned);
                } else {
                    PacketPlayOutNamedEntitySpawn show2 = new PacketPlayOutNamedEntitySpawn(boundTo);
                    PacketPlayOutEntityVelocity playerVelocity2 = new PacketPlayOutEntityVelocity(boundTo);
                    PacketPlayOutEntityHeadRotation head2 = new PacketPlayOutEntityHeadRotation(boundTo, getCompressedAngle(boundTo.getBukkitYaw()));
                    entityPlayer.b.sendPacket(show2);
                    entityPlayer.b.sendPacket(playerVelocity2);
                    entityPlayer.b.sendPacket(head2);
                    showArmor(p, respawned);
                }
            }
        }
    }
    for (Player spectator : arena.getSpectators()) {
        if (spectator == null)
            continue;
        if (spectator.equals(respawned))
            continue;
        EntityPlayer boundTo = ((CraftPlayer) spectator).getHandle();
        respawned.hidePlayer(getPlugin(), spectator);
        if (spectator.getWorld().equals(respawned.getWorld())) {
            if (respawned.getLocation().distance(spectator.getLocation()) <= arena.getRenderDistance()) {
                // send respawned player to spectator
                boundTo.b.sendPacket(show);
                boundTo.b.sendPacket(playerVelocity);
                boundTo.b.sendPacket(new PacketPlayOutEntityEquipment(entityPlayer.getId(), list));
                boundTo.b.sendPacket(new PacketPlayOutEntityHeadRotation(entityPlayer, getCompressedAngle(entityPlayer.getBukkitYaw())));
            }
        }
    }
}
Also used : CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) EntityPlayer(net.minecraft.server.level.EntityPlayer) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) Pair(com.mojang.datafixers.util.Pair)

Example 19 with EntityPlayer

use of net.minecraft.server.level.EntityPlayer in project BedWars1058 by andrei1058.

the class v1_18_R1 method hideArmor.

@Override
public void hideArmor(Player victim, Player receiver) {
    List<Pair<EnumItemSlot, ItemStack>> items = new ArrayList<>();
    List<Pair<EnumItemSlot, ItemStack>> hands = new ArrayList<>();
    hands.add(new Pair<>(EnumItemSlot.a, new ItemStack(Item.b(0))));
    hands.add(new Pair<>(EnumItemSlot.b, new ItemStack(Item.b(0))));
    items.add(new Pair<>(EnumItemSlot.f, new ItemStack(Item.b(0))));
    items.add(new Pair<>(EnumItemSlot.e, new ItemStack(Item.b(0))));
    items.add(new Pair<>(EnumItemSlot.d, new ItemStack(Item.b(0))));
    items.add(new Pair<>(EnumItemSlot.c, new ItemStack(Item.b(0))));
    PacketPlayOutEntityEquipment packet1 = new PacketPlayOutEntityEquipment(victim.getEntityId(), items);
    PacketPlayOutEntityEquipment packet2 = new PacketPlayOutEntityEquipment(victim.getEntityId(), hands);
    EntityPlayer pc = ((CraftPlayer) receiver).getHandle();
    if (victim != receiver) {
        pc.b.a(packet2);
    }
    pc.b.a(packet1);
}
Also used : ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer) CraftItemStack(org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack) Pair(com.mojang.datafixers.util.Pair)

Example 20 with EntityPlayer

use of net.minecraft.server.level.EntityPlayer in project BedWars1058 by andrei1058.

the class v1_18_R1 method showArmor.

@Override
public void showArmor(Player victim, Player receiver) {
    List<Pair<EnumItemSlot, ItemStack>> items = new ArrayList<>();
    List<Pair<EnumItemSlot, ItemStack>> hands = new ArrayList<>();
    hands.add(new Pair<>(EnumItemSlot.a, CraftItemStack.asNMSCopy(victim.getInventory().getItemInMainHand())));
    hands.add(new Pair<>(EnumItemSlot.b, CraftItemStack.asNMSCopy(victim.getInventory().getItemInOffHand())));
    items.add(new Pair<>(EnumItemSlot.f, CraftItemStack.asNMSCopy(victim.getInventory().getHelmet())));
    items.add(new Pair<>(EnumItemSlot.e, CraftItemStack.asNMSCopy(victim.getInventory().getChestplate())));
    items.add(new Pair<>(EnumItemSlot.d, CraftItemStack.asNMSCopy(victim.getInventory().getLeggings())));
    items.add(new Pair<>(EnumItemSlot.c, CraftItemStack.asNMSCopy(victim.getInventory().getBoots())));
    PacketPlayOutEntityEquipment packet1 = new PacketPlayOutEntityEquipment(victim.getEntityId(), items);
    PacketPlayOutEntityEquipment packet2 = new PacketPlayOutEntityEquipment(victim.getEntityId(), hands);
    EntityPlayer pc = ((CraftPlayer) receiver).getHandle();
    if (victim != receiver) {
        pc.b.a(packet2);
    }
    pc.b.a(packet1);
}
Also used : ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer) Pair(com.mojang.datafixers.util.Pair)

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