use of kingdoms.server.WorldProvider 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();
}
}
}
}
}
use of kingdoms.server.WorldProvider in project Tale-of-Kingdoms by Ivasik78.
the class SPacketBuild method server.
@Override
public void server(EntityPlayerMP player) {
int id = buf().readByte();
WorldProvider worldProvider = WorldProvider.get(player.worldObj);
if (buf().readBoolean()) {
Schematic schematic = (new Schematic("/schematics/GuildCastle")).setPosition((int) player.posX, (int) player.posY, (int) player.posZ).setSpeed(300);
SchematicHandler.INSTANCE.addBuilding(schematic);
Buildings.INSTANCE.setBuildingTrue(0);
} else {
SchematicRegistry registry = SchematicRegistry.INSTANCE;
if (!registry.isRegistered()) {
registry.registerAllBuildings((int) player.posX, (int) player.posY, (int) player.posZ);
worldProvider.guildPosX = (int) player.posX;
worldProvider.guildPosY = (int) player.posY;
worldProvider.guildPosZ = (int) player.posZ;
worldProvider.markDirty();
}
Schematic schematic = registry.getSchematic(id).setSpeed(300);
SchematicHandler.INSTANCE.addBuilding(schematic);
Buildings.INSTANCE.setBuildingTrue(id);
}
}
Aggregations