Search in sources :

Example 1 with FakeEntity

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));
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) FakeEntity(kingdoms.api.entities.FakeEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 2 with FakeEntity

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));
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) FakeEntity(kingdoms.api.entities.FakeEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 3 with FakeEntity

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));
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) FakeEntity(kingdoms.api.entities.FakeEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 4 with FakeEntity

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();
                }
            }
        }
    }
}
Also used : FakeEntity(kingdoms.api.entities.FakeEntity) List(java.util.List) Blocks(net.minecraft.init.Blocks) EntityLiving(net.minecraft.entity.EntityLiving) World(net.minecraft.world.World) FakeEntity(kingdoms.api.entities.FakeEntity) WorldProvider(kingdoms.server.WorldProvider) UltimateHelper(kingdoms.server.handlers.UltimateHelper) Buildings(kingdoms.server.handlers.Buildings) FakeBlock(kingdoms.api.blocks.FakeBlock) ArrayList(java.util.ArrayList) EntityLiving(net.minecraft.entity.EntityLiving) WorldProvider(kingdoms.server.WorldProvider) FakeBlock(kingdoms.api.blocks.FakeBlock)

Aggregations

FakeEntity (kingdoms.api.entities.FakeEntity)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 FakeBlock (kingdoms.api.blocks.FakeBlock)1 WorldProvider (kingdoms.server.WorldProvider)1 Buildings (kingdoms.server.handlers.Buildings)1 UltimateHelper (kingdoms.server.handlers.UltimateHelper)1 EntityLiving (net.minecraft.entity.EntityLiving)1 Blocks (net.minecraft.init.Blocks)1 World (net.minecraft.world.World)1