Search in sources :

Example 1 with PacketPlayOutSpawnEntityLiving

use of net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving in project FunnyGuilds by FunnyGuilds.

the class V1_17EntityAccessor 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!");
    }
    net.minecraft.world.entity.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) PacketPlayOutSpawnEntityLiving(net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving) PacketPlayOutSpawnEntityLiving(net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving) EntityLiving(net.minecraft.world.entity.EntityLiving) PacketPlayOutSpawnEntity(net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 2 with PacketPlayOutSpawnEntityLiving

use of net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving in project FunnyGuilds by FunnyGuilds.

the class V1_18EntityAccessor 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!");
    }
    net.minecraft.world.entity.Entity entity = world.createEntity(location, entityType.getEntityClass());
    Packet<?> spawnEntityPacket;
    if (entity instanceof EntityLiving) {
        spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
    } else {
        spawnEntityPacket = new PacketPlayOutSpawnEntity(entity);
    }
    // ae() zwraca aT czyli chyba getId
    return new FakeEntity(entity.ae(), spawnEntityPacket);
}
Also used : FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) PacketPlayOutSpawnEntityLiving(net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving) PacketPlayOutSpawnEntityLiving(net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving) EntityLiving(net.minecraft.world.entity.EntityLiving) PacketPlayOutSpawnEntity(net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Aggregations

FakeEntity (net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity)2 PacketPlayOutSpawnEntity (net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity)2 PacketPlayOutSpawnEntityLiving (net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving)2 EntityLiving (net.minecraft.world.entity.EntityLiving)2 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)1