Search in sources :

Example 6 with EntityPlayer

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

the class ContainerManager_v1_18_R2 method broadcastPacket.

private void broadcastPacket(Player origin, Packet<?> packet) {
    Location location = origin.getLocation();
    for (Player player : Bukkit.getOnlinePlayers()) {
        if (player == origin) {
            continue;
        }
        Location ploc = player.getLocation();
        if (ploc.getWorld() != location.getWorld()) {
            continue;
        }
        if (ploc.distanceSquared(location) > 128) {
            continue;
        }
        EntityPlayer NMSPlayer = ((CraftPlayer) player).getHandle();
        NMSPlayer.b.a(packet);
    }
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) EntityPlayer(net.minecraft.server.level.EntityPlayer) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) Location(org.bukkit.Location)

Example 7 with EntityPlayer

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

the class ContainerManager_v1_18_R2 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_R2.entity.CraftPlayer) PacketPlayOutAnimation(net.minecraft.network.protocol.game.PacketPlayOutAnimation)

Example 8 with EntityPlayer

use of net.minecraft.server.level.EntityPlayer in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_17_R1 method simulateToolBreak.

@Override
public void simulateToolBreak(Player bukkitPlayer, org.bukkit.block.Block bukkitBlock) {
    EntityPlayer entityPlayer = ((CraftPlayer) bukkitPlayer).getHandle();
    ItemStack itemStack = entityPlayer.getItemInMainHand();
    WorldServer worldServer = ((CraftWorld) bukkitBlock.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    itemStack.a(worldServer, blockData, blockPosition, entityPlayer);
}
Also used : IBlockData(net.minecraft.world.level.block.state.IBlockData) BlockPosition(net.minecraft.core.BlockPosition) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) WorldServer(net.minecraft.server.level.WorldServer) ItemStack(net.minecraft.world.item.ItemStack) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 9 with EntityPlayer

use of net.minecraft.server.level.EntityPlayer in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_18_R1 method simulateToolBreak.

@Override
public void simulateToolBreak(Player bukkitPlayer, org.bukkit.block.Block bukkitBlock) {
    EntityPlayer entityPlayer = ((CraftPlayer) bukkitPlayer).getHandle();
    ItemStack itemStack = entityPlayer.er();
    WorldServer worldServer = ((CraftWorld) bukkitBlock.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
    IBlockData blockData = worldServer.a_(blockPosition);
    itemStack.a(worldServer, blockData, blockPosition, entityPlayer);
}
Also used : IBlockData(net.minecraft.world.level.block.state.IBlockData) BlockPosition(net.minecraft.core.BlockPosition) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer) WorldServer(net.minecraft.server.level.WorldServer) ItemStack(net.minecraft.world.item.ItemStack) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 10 with EntityPlayer

use of net.minecraft.server.level.EntityPlayer in project InventoryShare by the-sugar-tree.

the class Inventory method invApply.

@SuppressWarnings("ConstantConditions")
public static void invApply(@NotNull Player p) {
    if (!(teaminventory)) {
        invApplyAll(p);
        return;
    }
    if (plugin.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(p) == null) {
        invApplyAll(p);
        return;
    }
    String teamName = plugin.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(p).getName();
    NonNullList<ItemStack> itemsT;
    NonNullList<ItemStack> armorT;
    NonNullList<ItemStack> extraSlotsT;
    if (!InventoryList.containsKey(teamName)) {
        Map<String, NonNullList<ItemStack>> map = new HashMap<>();
        itemsT = NonNullList.a(36, ItemStack.b);
        armorT = NonNullList.a(4, ItemStack.b);
        extraSlotsT = NonNullList.a(1, ItemStack.b);
        map.put("items", itemsT);
        map.put("armor", armorT);
        map.put("extraSlots", extraSlotsT);
        InventoryList.put(teamName, map);
    } else {
        Map<String, NonNullList<ItemStack>> map = InventoryList.get(teamName);
        itemsT = map.get("items");
        armorT = map.get("armor");
        extraSlotsT = map.get("extraSlots");
    }
    List<NonNullList<ItemStack>> contentsT = ImmutableList.of(itemsT, armorT, extraSlotsT);
    EntityPlayer entityPlayer = ((CraftPlayer) p).getHandle();
    PlayerInventory playerInventory = entityPlayer.fq();
    try {
        setField(playerInventory, "h", itemsT);
        setField(playerInventory, "i", armorT);
        setField(playerInventory, "j", extraSlotsT);
        setField(playerInventory, "n", contentsT);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : HashMap(java.util.HashMap) NonNullList(net.minecraft.core.NonNullList) EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer) PlayerInventory(net.minecraft.world.entity.player.PlayerInventory) ItemStack(net.minecraft.world.item.ItemStack)

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