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);
}
}
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));
}
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);
}
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);
}
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();
}
}
Aggregations