Search in sources :

Example 11 with PacketPlayOutSpawnEntityLiving

use of net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving in project FunnyGuilds by FunnyGuilds.

the class V1_14R1EntityAccessor method createFakeEntity.

@Override
public FakeEntity createFakeEntity(EntityType entityType, Location location) {
    Preconditions.checkNotNull(entityType, "entity type can't be null!");
    Preconditions.checkNotNull(location, "location can't be null!");
    Preconditions.checkArgument(entityType.isSpawnable(), "entity type is not spawnable!");
    CraftWorld world = ((CraftWorld) location.getWorld());
    if (world == null) {
        throw new IllegalStateException("location's world is null!");
    }
    Entity entity = world.createEntity(location, entityType.getEntityClass());
    Packet<?> spawnEntityPacket;
    if (entity instanceof EntityLiving) {
        spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
    } else {
        spawnEntityPacket = new PacketPlayOutSpawnEntity(entity, ObjectType.getIdFor(entityType));
    }
    return new FakeEntity(entity.getId(), spawnEntityPacket);
}
Also used : FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) PacketPlayOutSpawnEntity(net.minecraft.server.v1_14_R1.PacketPlayOutSpawnEntity) FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) Entity(net.minecraft.server.v1_14_R1.Entity) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_14_R1.PacketPlayOutSpawnEntityLiving) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_14_R1.PacketPlayOutSpawnEntityLiving) EntityLiving(net.minecraft.server.v1_14_R1.EntityLiving) PacketPlayOutSpawnEntity(net.minecraft.server.v1_14_R1.PacketPlayOutSpawnEntity) CraftWorld(org.bukkit.craftbukkit.v1_14_R1.CraftWorld)

Example 12 with PacketPlayOutSpawnEntityLiving

use of net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving in project FunnyGuilds by FunnyGuilds.

the class V1_15R1EntityAccessor method createFakeEntity.

@Override
public FakeEntity createFakeEntity(EntityType entityType, Location location) {
    Preconditions.checkNotNull(entityType, "entity type can't be null!");
    Preconditions.checkNotNull(location, "location can't be null!");
    Preconditions.checkArgument(entityType.isSpawnable(), "entity type is not spawnable!");
    CraftWorld world = ((CraftWorld) location.getWorld());
    if (world == null) {
        throw new IllegalStateException("location's world is null!");
    }
    Entity entity = world.createEntity(location, entityType.getEntityClass());
    Packet<?> spawnEntityPacket;
    if (entity instanceof EntityLiving) {
        spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
    } else {
        spawnEntityPacket = new PacketPlayOutSpawnEntity(entity, ObjectType.getIdFor(entityType));
    }
    return new FakeEntity(entity.getId(), spawnEntityPacket);
}
Also used : FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) PacketPlayOutSpawnEntity(net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntity) Entity(net.minecraft.server.v1_15_R1.Entity) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntityLiving) EntityLiving(net.minecraft.server.v1_15_R1.EntityLiving) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntityLiving) PacketPlayOutSpawnEntity(net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntity) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Example 13 with PacketPlayOutSpawnEntityLiving

use of net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving in project UltraCosmetics by iSach.

the class EntityUtil method sendBlizzard.

@Override
public void sendBlizzard(final Player player, Location loc, boolean affectPlayers, Vector v) {
    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<Entity> cooldownJump = cooldownJumpMap.get(player);
    final EntityArmorStand as = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle());
    as.setInvisible(true);
    as.setSmall(true);
    as.setGravity(false);
    as.setArms(true);
    as.setHeadPose(new Vector3f(r.nextInt(360), r.nextInt(360), 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 PacketPlayOutEntityEquipment(as.getId(), 4, CraftItemStack.asNMSCopy(new 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()) {
            if (as == null) {
                continue;
            }
            PacketSender.send(pl, new PacketPlayOutEntityDestroy(as.getId()));
        }
        fakeArmorStands.remove(as);
    }, 20);
    if (affectPlayers)
        for (final Entity ent : as.getBukkitEntity().getNearbyEntities(0.5, 0.5, 0.5)) {
            if (!cooldownJump.contains(ent) && ent != player) {
                MathUtils.applyVelocity(ent, new Vector(0, 1, 0).add(v));
                cooldownJump.add(ent);
                Bukkit.getScheduler().runTaskLater(UltraCosmeticsData.get().getPlugin(), () -> cooldownJump.remove(ent), 20);
            }
        }
}
Also used : PathEntity(net.minecraft.server.v1_8_R3.PathEntity) Entity(org.bukkit.entity.Entity) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) PacketPlayOutEntityDestroy(net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy) Vector3f(net.minecraft.server.v1_8_R3.Vector3f) ArrayList(java.util.ArrayList) EntityArmorStand(net.minecraft.server.v1_8_R3.EntityArmorStand) PacketPlayOutEntityEquipment(net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) Vector(org.bukkit.util.Vector)

Example 14 with PacketPlayOutSpawnEntityLiving

use of net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving in project MechanicsMain by WeaponMechanics.

the class FakeEntity_1_10_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, 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);
}
Also used : PacketPlayOutEntityLook(net.minecraft.server.v1_10_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)

Aggregations

FakeEntity (net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity)9 PacketPlayOutSpawnEntityLiving (net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving)4 PacketPlayOutEntityLook (net.minecraft.server.v1_10_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)2 Location (org.bukkit.Location)2 Player (org.bukkit.entity.Player)2 ArrayList (java.util.ArrayList)1 Entity (net.minecraft.server.v1_10_R1.Entity)1 EntityLiving (net.minecraft.server.v1_10_R1.EntityLiving)1 PacketPlayOutSpawnEntity (net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntity)1 PacketPlayOutSpawnEntityLiving (net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving)1 Entity (net.minecraft.server.v1_11_R1.Entity)1 EntityLiving (net.minecraft.server.v1_11_R1.EntityLiving)1 PacketPlayOutSpawnEntity (net.minecraft.server.v1_11_R1.PacketPlayOutSpawnEntity)1 PacketPlayOutSpawnEntityLiving (net.minecraft.server.v1_11_R1.PacketPlayOutSpawnEntityLiving)1 Entity (net.minecraft.server.v1_12_R1.Entity)1 EntityLiving (net.minecraft.server.v1_12_R1.EntityLiving)1 PacketPlayOutSpawnEntity (net.minecraft.server.v1_12_R1.PacketPlayOutSpawnEntity)1 PacketPlayOutSpawnEntityLiving (net.minecraft.server.v1_12_R1.PacketPlayOutSpawnEntityLiving)1 Entity (net.minecraft.server.v1_13_R2.Entity)1 EntityLiving (net.minecraft.server.v1_13_R2.EntityLiving)1