use of net.minecraft.server.level.EntityPlayer in project InventoryShare by the-sugar-tree.
the class Inventory method invApplyAll.
public static void invApplyAll(@NotNull Player p) {
EntityPlayer entityPlayer = ((CraftPlayer) p).getHandle();
PlayerInventory playerInventory = entityPlayer.fq();
try {
setField(playerInventory, "h", items);
setField(playerInventory, "i", armor);
setField(playerInventory, "j", extraSlots);
setField(playerInventory, "n", contents);
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.minecraft.server.level.EntityPlayer in project BedWars1058 by andrei1058.
the class v1_17_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.getById(0))));
hands.add(new Pair<>(EnumItemSlot.b, new ItemStack(Item.getById(0))));
items.add(new Pair<>(EnumItemSlot.f, new ItemStack(Item.getById(0))));
items.add(new Pair<>(EnumItemSlot.e, new ItemStack(Item.getById(0))));
items.add(new Pair<>(EnumItemSlot.d, new ItemStack(Item.getById(0))));
items.add(new Pair<>(EnumItemSlot.c, new ItemStack(Item.getById(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.sendPacket(packet2);
}
pc.b.sendPacket(packet1);
}
use of net.minecraft.server.level.EntityPlayer in project BedWars1058 by andrei1058.
the class v1_17_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.sendPacket(packet2);
}
pc.b.sendPacket(packet1);
}
use of net.minecraft.server.level.EntityPlayer in project BedWars1058 by andrei1058.
the class v1_18_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.b(EnumItemSlot.a)));
list.add(new Pair<>(EnumItemSlot.b, entityPlayer.b(EnumItemSlot.b)));
list.add(new Pair<>(EnumItemSlot.f, entityPlayer.b(EnumItemSlot.f)));
list.add(new Pair<>(EnumItemSlot.e, entityPlayer.b(EnumItemSlot.e)));
list.add(new Pair<>(EnumItemSlot.d, entityPlayer.b(EnumItemSlot.d)));
list.add(new Pair<>(EnumItemSlot.c, entityPlayer.b(EnumItemSlot.c)));
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.a(show);
boundTo.b.a(head);
boundTo.b.a(playerVelocity);
boundTo.b.a(new PacketPlayOutEntityEquipment(respawned.getEntityId(), 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.a(show2);
entityPlayer.b.a(playerVelocity2);
entityPlayer.b.a(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.a(show);
boundTo.b.a(playerVelocity);
boundTo.b.a(new PacketPlayOutEntityEquipment(respawned.getEntityId(), list));
boundTo.b.a(new PacketPlayOutEntityHeadRotation(entityPlayer, getCompressedAngle(entityPlayer.getBukkitYaw())));
}
}
}
}
use of net.minecraft.server.level.EntityPlayer in project InventoryShare by the-sugar-tree.
the class Inventory method invDisApply.
@SuppressWarnings("SuspiciousMethodCalls")
public static void invDisApply(@NotNull Player p) {
EntityPlayer entityPlayer = ((CraftPlayer) p).getHandle();
PlayerInventory playerInventory = entityPlayer.fq();
if (invList.containsKey(entityPlayer.cm())) {
try {
NonNullList<ItemStack> items1 = invList.get(entityPlayer.cm()).h;
NonNullList<ItemStack> armor1 = invList.get(entityPlayer.cm()).i;
NonNullList<ItemStack> extraSlots1 = invList.get(entityPlayer.cm()).j;
List<NonNullList<ItemStack>> contents1 = ImmutableList.of(items1, armor1, extraSlots1);
setField(playerInventory, "h", items1);
setField(playerInventory, "i", armor1);
setField(playerInventory, "j", extraSlots1);
setField(playerInventory, "n", contents1);
} catch (Exception e) {
e.printStackTrace();
}
} else {
// 사용될 일이 없지만, 혹시 모른 버그 방지
try {
NonNullList<ItemStack> items1 = NonNullList.a(36, ItemStack.b);
NonNullList<ItemStack> armor1 = NonNullList.a(36, ItemStack.b);
NonNullList<ItemStack> extraSlots1 = NonNullList.a(36, ItemStack.b);
List<NonNullList<ItemStack>> contents1 = ImmutableList.of(items1, armor1, extraSlots1);
setField(playerInventory, "h", items1);
setField(playerInventory, "i", armor1);
setField(playerInventory, "j", extraSlots1);
setField(playerInventory, "n", contents1);
} catch (Exception e) {
e.printStackTrace();
}
}
invList.remove(entityPlayer);
}
Aggregations