Search in sources :

Example 1 with EntityLiving

use of net.minecraft.world.entity.EntityLiving 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 EntityLiving

use of net.minecraft.world.entity.EntityLiving 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)

Example 3 with EntityLiving

use of net.minecraft.world.entity.EntityLiving in project BedWars1058 by andrei1058.

the class v1_17_R1 method setSource.

@Override
public void setSource(TNTPrimed tnt, Player owner) {
    EntityLiving nmsEntityLiving = (((CraftLivingEntity) owner).getHandle());
    EntityTNTPrimed nmsTNT = (((CraftTNTPrimed) tnt).getHandle());
    try {
        // noinspection JavaReflectionMemberAccess
        Field sourceField = EntityTNTPrimed.class.getDeclaredField("source");
        sourceField.setAccessible(true);
        sourceField.set(nmsTNT, nmsEntityLiving);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) EntityLiving(net.minecraft.world.entity.EntityLiving) EntityTNTPrimed(net.minecraft.world.entity.item.EntityTNTPrimed)

Example 4 with EntityLiving

use of net.minecraft.world.entity.EntityLiving in project BedWars1058 by andrei1058.

the class v1_18_R1 method setSource.

@Override
public void setSource(TNTPrimed tnt, Player owner) {
    EntityLiving nmsEntityLiving = (((CraftLivingEntity) owner).getHandle());
    EntityTNTPrimed nmsTNT = (((CraftTNTPrimed) tnt).getHandle());
    try {
        // noinspection JavaReflectionMemberAccess
        Field sourceField = EntityTNTPrimed.class.getDeclaredField("source");
        sourceField.setAccessible(true);
        sourceField.set(nmsTNT, nmsEntityLiving);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) EntityLiving(net.minecraft.world.entity.EntityLiving) EntityTNTPrimed(net.minecraft.world.entity.item.EntityTNTPrimed)

Aggregations

EntityLiving (net.minecraft.world.entity.EntityLiving)4 Field (java.lang.reflect.Field)2 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 EntityTNTPrimed (net.minecraft.world.entity.item.EntityTNTPrimed)2 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)1