use of net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata in project UltraCosmetics by iSach.
the class EntityUtil method sendBlizzard.
@Override
public void sendBlizzard(final Player player, Location loc, boolean affectPlayers, Vector v) {
try {
if (!fakeArmorStandsMap.containsKey(player))
fakeArmorStandsMap.put(player, new ArrayList<>());
if (!cooldownJumpMap.containsKey(player))
cooldownJumpMap.put(player, new ArrayList<>());
final List<EntityArmorStand> fakeArmorStands = fakeArmorStandsMap.get(player);
final List<org.bukkit.entity.Entity> cooldownJump = cooldownJumpMap.get(player);
final EntityArmorStand as = new EntityArmorStand(EntityTypes.ARMOR_STAND, ((CraftWorld) player.getWorld()).getHandle());
as.setInvisible(true);
as.setFlag(5, true);
as.setSmall(true);
as.setNoGravity(true);
as.setArms(true);
as.setHeadPose(new Vector3f((float) (r.nextInt(360)), (float) (r.nextInt(360)), (float) (r.nextInt(360))));
as.setLocation(loc.getX() + MathUtils.randomDouble(-1.5, 1.5), loc.getY() + MathUtils.randomDouble(0, .5) - 0.75, loc.getZ() + MathUtils.randomDouble(-1.5, 1.5), 0, 0);
fakeArmorStands.add(as);
for (Player players : player.getWorld().getPlayers()) {
PacketSender.send(players, new PacketPlayOutSpawnEntityLiving(as));
PacketSender.send(players, new PacketPlayOutEntityMetadata(as.getId(), as.getDataWatcher(), false));
PacketSender.send(players, new PacketPlayOutEntityEquipment(as.getId(), EnumItemSlot.HEAD, CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(org.bukkit.Material.PACKED_ICE))));
}
UtilParticles.display(Particles.CLOUD, loc.clone().add(MathUtils.randomDouble(-1.5, 1.5), MathUtils.randomDouble(0, .5) - 0.75, MathUtils.randomDouble(-1.5, 1.5)), 2, 0.4f);
Bukkit.getScheduler().runTaskLater(UltraCosmeticsData.get().getPlugin(), () -> {
for (Player pl : player.getWorld().getPlayers()) PacketSender.send(pl, new PacketPlayOutEntityDestroy(as.getId()));
fakeArmorStands.remove(as);
}, 20);
if (affectPlayers)
as.getBukkitEntity().getNearbyEntities(0.5, 0.5, 0.5).stream().filter(ent -> !cooldownJump.contains(ent) && ent != player).forEachOrdered(ent -> {
MathUtils.applyVelocity(ent, new Vector(0, 1, 0).add(v));
cooldownJump.add(ent);
Bukkit.getScheduler().runTaskLater(UltraCosmeticsData.get().getPlugin(), () -> cooldownJump.remove(ent), 20);
});
} catch (Exception exc) {
}
}
use of net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata in project MechanicsMain by WeaponMechanics.
the class FakeEntity_1_15_R1 method show.
@Override
public void show(@NotNull Player player) {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
if (connections.contains(connection))
throw new IllegalArgumentException();
connection.sendPacket(type.isAlive() ? new PacketPlayOutSpawnEntityLiving((EntityLiving) entity) : new PacketPlayOutSpawnEntity(entity, type == EntityType.FALLING_BLOCK ? Block.getCombinedId(block) : 0));
connection.sendPacket(new PacketPlayOutEntityMetadata(cache, entity.getDataWatcher(), true));
connection.sendPacket(new PacketPlayOutEntityLook(cache, convertYaw(getYaw()), convertPitch(getPitch()), false));
connection.sendPacket(new PacketPlayOutEntityVelocity(cache, new Vec3D(motion.getX(), motion.getY(), motion.getZ())));
connection.sendPacket(new PacketPlayOutEntityHeadRotation(entity, convertYaw(getYaw())));
PacketPlayOutEntityEquipment[] equipment = getEquipmentPacket();
if (equipment != null) {
for (PacketPlayOutEntityEquipment packet : equipment) {
connection.sendPacket(packet);
}
}
// Inject the player's packet connection into this listener, so we can
// show the player position/velocity/rotation changes
connections.add(connection);
}
use of net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata in project MechanicsMain by WeaponMechanics.
the class FakeEntity_1_15_R1 method show.
public void show() {
// Construct the packets out of the loop to save resources, they will
// be the same for each Player.
Packet<?> spawn = type.isAlive() ? new PacketPlayOutSpawnEntityLiving((EntityLiving) entity) : new PacketPlayOutSpawnEntity(entity, type == EntityType.FALLING_BLOCK ? Block.getCombinedId(block) : 0);
PacketPlayOutEntityMetadata meta = new PacketPlayOutEntityMetadata(cache, entity.getDataWatcher(), true);
PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entity, convertYaw(getYaw()));
PacketPlayOutEntityLook look = new PacketPlayOutEntityLook(cache, convertYaw(getYaw()), convertPitch(getPitch()), false);
PacketPlayOutEntityVelocity velocity = new PacketPlayOutEntityVelocity(cache, new Vec3D(motion.getX(), motion.getY(), motion.getZ()));
for (Player temp : DistanceUtil.getPlayersInRange(location)) {
PlayerConnection connection = ((CraftPlayer) temp).getHandle().playerConnection;
if (connections.contains(connection)) {
continue;
}
connection.sendPacket(spawn);
connection.sendPacket(meta);
connection.sendPacket(head);
connection.sendPacket(velocity);
connection.sendPacket(look);
PacketPlayOutEntityEquipment[] equipment = getEquipmentPacket();
if (equipment != null) {
for (PacketPlayOutEntityEquipment packet : equipment) {
connection.sendPacket(packet);
}
}
connections.add(connection);
}
}
Aggregations