Search in sources :

Example 1 with MultiBlockTileEntity

use of minechem.tileentity.multiblock.MultiBlockTileEntity in project Minechem by iopleke.

the class BlueprintProjectorTileEntity method projectBlueprint.

private void projectBlueprint() {
    int facing = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
    ForgeDirection direction = MinechemUtil.getDirectionFromFacing(facing);
    LocalPosition position = new LocalPosition(xCoord, yCoord, zCoord, direction);
    position.moveForwards(blueprint.zSize + 1);
    position.moveLeft(Math.floor(blueprint.xSize / 2));
    boolean shouldProjectGhostBlocks = true;
    int totalIncorrectCount = blueprint.getTotalSize();
    for (int x = 0; x < blueprint.xSize; x++) {
        int verticalIncorrectCount = blueprint.getVerticalSliceSize();
        for (int y = 0; y < blueprint.ySize; y++) {
            for (int z = 0; z < blueprint.zSize; z++) {
                if (shouldProjectGhostBlocks) {
                    MultiBlockStatusEnum multiBlockStatusEnum;
                    if (isManagerBlock(x, y, z)) {
                        multiBlockStatusEnum = MultiBlockStatusEnum.CORRECT;
                    } else {
                        multiBlockStatusEnum = projectGhostBlock(x, y, z, position);
                    }
                    if (multiBlockStatusEnum == MultiBlockStatusEnum.CORRECT) {
                        verticalIncorrectCount--;
                        totalIncorrectCount--;
                    }
                } else {
                    destroyGhostBlock(x, y, z, position);
                }
            }
        }
        if (verticalIncorrectCount != 0) {
            shouldProjectGhostBlocks = false;
        }
    }
    if (totalIncorrectCount == 0 && (!isComplete || !(worldObj.getTileEntity(blueprint.getManagerPosX(), blueprint.getManagerPosY(), blueprint.getManagerPosZ()) instanceof MultiBlockTileEntity))) {
        isComplete = true;
        buildStructure(position);
    }
}
Also used : MultiBlockStatusEnum(minechem.tileentity.multiblock.MultiBlockStatusEnum) MultiBlockTileEntity(minechem.tileentity.multiblock.MultiBlockTileEntity) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LocalPosition(minechem.utils.LocalPosition) MinechemBlueprint(minechem.item.blueprint.MinechemBlueprint)

Aggregations

MinechemBlueprint (minechem.item.blueprint.MinechemBlueprint)1 MultiBlockStatusEnum (minechem.tileentity.multiblock.MultiBlockStatusEnum)1 MultiBlockTileEntity (minechem.tileentity.multiblock.MultiBlockTileEntity)1 LocalPosition (minechem.utils.LocalPosition)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1