use of kingdoms.api.blocks.FakeBlock in project Tale-of-Kingdoms by Ivasik78.
the class Schematic method writeSchematic.
private void writeSchematic(NBTTagCompound compound) {
short height = compound.getShort("Height"), length = compound.getShort("Length"), width = compound.getShort("Width");
byte[] blocksArray = compound.getByteArray("Blocks"), dataArray = compound.getByteArray("Data");
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
for (int z = 0; z < length; ++z) {
int index = y * width * length + z * width + x;
this.blocks.add(new FakeBlock(blocksArray[index], dataArray[index], x, y, z));
}
}
}
}
use of kingdoms.api.blocks.FakeBlock 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