Search in sources :

Example 6 with PacketPlayOutSpawnEntityLiving

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

the class V1_16R3EntityAccessor 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);
    }
    return new FakeEntity(entity.getId(), spawnEntityPacket);
}
Also used : FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) Entity(net.minecraft.server.v1_16_R3.Entity) PacketPlayOutSpawnEntity(net.minecraft.server.v1_16_R3.PacketPlayOutSpawnEntity) FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_16_R3.PacketPlayOutSpawnEntityLiving) EntityLiving(net.minecraft.server.v1_16_R3.EntityLiving) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_16_R3.PacketPlayOutSpawnEntityLiving) PacketPlayOutSpawnEntity(net.minecraft.server.v1_16_R3.PacketPlayOutSpawnEntity) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 7 with PacketPlayOutSpawnEntityLiving

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

the class V1_10R1EntityAccessor 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_10_R1.PacketPlayOutSpawnEntity) FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) Entity(net.minecraft.server.v1_10_R1.Entity) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving) EntityLiving(net.minecraft.server.v1_10_R1.EntityLiving) PacketPlayOutSpawnEntity(net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntity) CraftWorld(org.bukkit.craftbukkit.v1_10_R1.CraftWorld)

Example 8 with PacketPlayOutSpawnEntityLiving

use of net.minecraft.server.v1_12_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) {
    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(((CraftWorld) player.getWorld()).getHandle());
        as.setInvisible(true);
        as.setSmall(true);
        as.setNoGravity(true);
        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(), 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) {
    }
}
Also used : MathUtils(be.isach.ultracosmetics.util.MathUtils) java.util(java.util) Wither(org.bukkit.entity.Wither) UtilParticles(be.isach.ultracosmetics.util.UtilParticles) net.minecraft.server.v1_12_R1(net.minecraft.server.v1_12_R1) Player(org.bukkit.entity.Player) Inventory(org.bukkit.inventory.Inventory) CraftInventory(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory) Block(org.bukkit.block.Block) Location(org.bukkit.Location) UltraCosmeticsData(be.isach.ultracosmetics.UltraCosmeticsData) CustomPathFinderGoalPanic(be.isach.ultracosmetics.v1_12_R1.pathfinders.CustomPathFinderGoalPanic) Particles(be.isach.ultracosmetics.util.Particles) TreasureChestDesign(be.isach.ultracosmetics.treasurechests.TreasureChestDesign) Creature(org.bukkit.entity.Creature) Bukkit(org.bukkit.Bukkit) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) org.bukkit.craftbukkit.v1_12_R1.entity(org.bukkit.craftbukkit.v1_12_R1.entity) Field(java.lang.reflect.Field) Sets(com.google.common.collect.Sets) Vector(org.bukkit.util.Vector) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) IEntityUtil(be.isach.ultracosmetics.version.IEntityUtil) ChestType(be.isach.ultracosmetics.treasurechests.ChestType) PacketSender(be.isach.ultracosmetics.util.PacketSender) Player(org.bukkit.entity.Player) Vector(org.bukkit.util.Vector)

Example 9 with PacketPlayOutSpawnEntityLiving

use of net.minecraft.server.v1_12_R1.PacketPlayOutSpawnEntityLiving in project Denizen-For-Bukkit by DenizenScript.

the class BossBar_v1_8_R3 method showBossBar.

public static void showBossBar(Player player, String text, int health) {
    wither.setCustomName(text);
    wither.setHealth(health);
    Location location = player.getLocation().clone();
    location.add(player.getLocation().getDirection().multiply(30));
    wither.setPosition(location.getX(), location.getY(), location.getZ());
    PacketHelper_v1_8_R3.sendPacket(player, new PacketPlayOutSpawnEntityLiving(wither));
    hasHealthBar.put(player.getName(), true);
    playersWithHealthBar.add(player);
}
Also used : PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving) Location(org.bukkit.Location)

Example 10 with PacketPlayOutSpawnEntityLiving

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

the class V1_8R3EntityAccessor 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_8_R3.PacketPlayOutSpawnEntity) Entity(net.minecraft.server.v1_8_R3.Entity) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving) EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving) PacketPlayOutSpawnEntity(net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Aggregations

FakeEntity (net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity)9 PacketPlayOutSpawnEntityLiving (net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving)4 Location (org.bukkit.Location)3 PacketPlayOutEntityLook (net.minecraft.server.v1_12_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)2 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)2 Player (org.bukkit.entity.Player)2 UltraCosmeticsData (be.isach.ultracosmetics.UltraCosmeticsData)1 ChestType (be.isach.ultracosmetics.treasurechests.ChestType)1 TreasureChestDesign (be.isach.ultracosmetics.treasurechests.TreasureChestDesign)1 MathUtils (be.isach.ultracosmetics.util.MathUtils)1 PacketSender (be.isach.ultracosmetics.util.PacketSender)1 Particles (be.isach.ultracosmetics.util.Particles)1 UtilParticles (be.isach.ultracosmetics.util.UtilParticles)1 CustomPathFinderGoalPanic (be.isach.ultracosmetics.v1_12_R1.pathfinders.CustomPathFinderGoalPanic)1 IEntityUtil (be.isach.ultracosmetics.version.IEntityUtil)1 Sets (com.google.common.collect.Sets)1 Field (java.lang.reflect.Field)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Entity (net.minecraft.server.v1_10_R1.Entity)1