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);
}
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);
}
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();
}
}
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();
}
}
Aggregations