use of kingdoms.api.entities.FakeEntity in project Tale-of-Kingdoms by Ivasik78.
the class Schematic method writeEntities.
private void writeEntities(NBTTagCompound compound) {
NBTTagList list = compound.getTagList("Entities", 10);
int bound = list.tagCount();
for (int i = 0; i < bound; i++) {
NBTTagCompound nbt = list.getCompoundTagAt(i);
String s = nbt.getString("EntityName");
double posX = nbt.getDouble("posX");
double posY = nbt.getDouble("posY");
double posZ = nbt.getDouble("posZ");
this.entities.add(new FakeEntity(s, posX, posY, posZ));
}
}
use of kingdoms.api.entities.FakeEntity in project Tale-of-Kingdoms by Ivasik78.
the class Schematic method writeEntitiesTier3.
private void writeEntitiesTier3(NBTTagCompound compound) {
NBTTagList list = compound.getTagList("Entities", 10);
int bound = list.tagCount();
for (int i = 0; i < bound; i++) {
NBTTagCompound nbt = list.getCompoundTagAt(i);
String s = nbt.getString("EntityName");
double posX = nbt.getDouble("posX");
double posY = nbt.getDouble("posY");
double posZ = nbt.getDouble("posZ");
this.entities.add(new FakeEntity(s, posX - 10.0D, posY, posZ - 5.0D));
}
}
use of kingdoms.api.entities.FakeEntity in project Tale-of-Kingdoms by Ivasik78.
the class Schematic method writeEntitiesTier4.
private void writeEntitiesTier4(NBTTagCompound compound) {
NBTTagList list = compound.getTagList("Entities", 10);
int bound = list.tagCount();
for (int i = 0; i < bound; i++) {
NBTTagCompound nbt = list.getCompoundTagAt(i);
String s = nbt.getString("EntityName");
double posX = nbt.getDouble("posX");
double posY = nbt.getDouble("posY");
double posZ = nbt.getDouble("posZ");
this.entities.add(new FakeEntity(s, posX + 10.0D, posY, posZ + 5.0D));
}
}
use of kingdoms.api.entities.FakeEntity in project Tale-of-Kingdoms by Ivasik78.
the class SchematicHandler method update.
public void update(World world) {
if (!this.buildingList.isEmpty()) {
Schematic first = this.buildingList.get(0);
if (first != null) {
List<FakeBlock> blocks = first.getBlockList();
List<FakeEntity> entities = first.getEntityList();
for (int i = 0; i < first.speed; ++i) {
if (index < blocks.size()) {
FakeBlock fakeBlock = blocks.get(index);
if (fakeBlock != null && world.getBlock(first.x + fakeBlock.posX, first.y + fakeBlock.posY, first.z + fakeBlock.posZ) != fakeBlock.block) {
if (fakeBlock.block == Blocks.air)
world.setBlockToAir(first.x + fakeBlock.posX, first.y + fakeBlock.posY, first.z + fakeBlock.posZ);
if (fakeBlock.block != Blocks.torch && fakeBlock.block != Blocks.wooden_door && fakeBlock.block != Blocks.ladder && fakeBlock.block != Blocks.trapdoor) {
world.setBlock(first.x + fakeBlock.posX, first.y + fakeBlock.posY, first.z + fakeBlock.posZ, fakeBlock.block, fakeBlock.metadata, 3);
} else
this.torchList.add(fakeBlock);
}
++index;
} else if (index < blocks.size() + entities.size()) {
FakeEntity entity = entities.get(index - blocks.size());
WorldProvider worldProvider = WorldProvider.get(world);
EntityLiving entity1 = (EntityLiving) UltimateHelper.INSTANCE.getEntity(entity.entityName, world);
if (entity1 != null) {
if (Buildings.INSTANCE.getBuilding(1)) {
entity1.setPosition((double) worldProvider.guildPosX + entity.posX, (double) worldProvider.guildPosY + entity.posY, (double) worldProvider.guildPosZ + entity.posZ);
} else {
entity1.setPosition((double) first.x + entity.posX, (double) first.y + entity.posY + 1.5D, (double) first.z + entity.posZ);
}
world.spawnEntityInWorld(entity1);
}
++index;
} else {
this.torchList.forEach(block -> world.setBlock(first.x + block.posX, first.y + block.posY, first.z + block.posZ, block.block, block.metadata, 3));
index = 0;
if (!this.buildingList.isEmpty())
this.buildingList.remove(0);
this.torchList.clear();
}
}
}
}
}
Aggregations