Search in sources :

Example 1 with BlueprintBlock

use of minechem.item.blueprint.BlueprintBlock in project Minechem by iopleke.

the class BlueprintProjectorTileEntity method buildManagerBlock.

private TileEntity buildManagerBlock(LocalPosition position) {
    BlueprintBlock managerBlock = blueprint.getManagerBlock();
    if (managerBlock != null) {
        Pos3 worldPos = position.getLocalPos(blueprint.getManagerPosX(), blueprint.getManagerPosY(), blueprint.getManagerPosZ());
        worldObj.setBlock(worldPos.x, worldPos.y, worldPos.z, managerBlock.block, managerBlock.metadata, 3);
        if (this.blueprint == MinechemBlueprint.fusion && worldObj.getTileEntity(worldPos.x, worldPos.y, worldPos.z) == null) {
            FusionTileEntity fusion = new FusionTileEntity();
            fusion.setWorldObj(this.worldObj);
            fusion.xCoord = worldPos.x;
            fusion.yCoord = worldPos.y;
            fusion.zCoord = worldPos.z;
            fusion.blockType = MinechemBlocksGeneration.fusion;
            worldObj.addTileEntity(fusion);
        }
        return worldObj.getTileEntity(worldPos.x, worldPos.y, worldPos.z);
    } else {
        return null;
    }
}
Also used : BlueprintBlock(minechem.item.blueprint.BlueprintBlock) FusionTileEntity(minechem.tileentity.multiblock.fusion.FusionTileEntity) Pos3(minechem.utils.LocalPosition.Pos3)

Example 2 with BlueprintBlock

use of minechem.item.blueprint.BlueprintBlock in project Minechem by iopleke.

the class BlueprintProjectorTileEntity method buildStructure.

private void buildStructure(LocalPosition position) {
    Integer[][][] resultStructure = blueprint.getResultStructure();
    HashMap<Integer, BlueprintBlock> blockLookup = blueprint.getBlockLookup();
    TileEntity managerTileEntity = buildManagerBlock(position);
    for (int x = 0; x < blueprint.xSize; x++) {
        for (int y = 0; y < blueprint.ySize; y++) {
            for (int z = 0; z < blueprint.zSize; z++) {
                if (isManagerBlock(x, y, z)) {
                    continue;
                }
                int structureId = resultStructure[y][x][z];
                setBlock(x, y, z, position, structureId, blockLookup, managerTileEntity);
            }
        }
    }
}
Also used : BlueprintBlock(minechem.item.blueprint.BlueprintBlock) GhostBlockTileEntity(minechem.tileentity.multiblock.ghostblock.GhostBlockTileEntity) FusionTileEntity(minechem.tileentity.multiblock.fusion.FusionTileEntity) MultiBlockTileEntity(minechem.tileentity.multiblock.MultiBlockTileEntity) MinechemTileEntity(minechem.tileentity.prefab.MinechemTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) MinechemBlueprint(minechem.item.blueprint.MinechemBlueprint)

Example 3 with BlueprintBlock

use of minechem.item.blueprint.BlueprintBlock in project Minechem by iopleke.

the class BlueprintProjectorTileEntity method setBlock.

private void setBlock(int x, int y, int z, LocalPosition position, int structureId, HashMap<Integer, BlueprintBlock> blockLookup, TileEntity managerTileEntity) {
    Pos3 worldPos = position.getLocalPos(x, y, z);
    if (structureId == MinechemBlueprint.wildcard) {
        return;
    }
    if (structureId == air) {
        worldObj.setBlockToAir(worldPos.x, worldPos.y, worldPos.z);
    } else {
        BlueprintBlock blueprintBlock = blockLookup.get(structureId);
        if (blueprintBlock.type == Type.MANAGER) {
            return;
        }
        worldObj.setBlock(worldPos.x, worldPos.y, worldPos.z, blueprintBlock.block, blueprintBlock.metadata, 3);
        if (blueprintBlock.type == Type.PROXY) {
            TileEntity te = worldObj.getTileEntity(worldPos.x, worldPos.y, worldPos.z);
            if (te instanceof TileEntityProxy) {
                TileEntityProxy proxy = (TileEntityProxy) te;
            }
        }
    }
}
Also used : BlueprintBlock(minechem.item.blueprint.BlueprintBlock) GhostBlockTileEntity(minechem.tileentity.multiblock.ghostblock.GhostBlockTileEntity) FusionTileEntity(minechem.tileentity.multiblock.fusion.FusionTileEntity) MultiBlockTileEntity(minechem.tileentity.multiblock.MultiBlockTileEntity) MinechemTileEntity(minechem.tileentity.prefab.MinechemTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityProxy(minechem.tileentity.prefab.TileEntityProxy) Pos3(minechem.utils.LocalPosition.Pos3)

Example 4 with BlueprintBlock

use of minechem.item.blueprint.BlueprintBlock in project Minechem by iopleke.

the class BlueprintProjectorTileEntity method projectGhostBlock.

private MultiBlockStatusEnum projectGhostBlock(int x, int y, int z, LocalPosition position) {
    Pos3 worldPos = position.getLocalPos(x, y, z);
    Integer structureID = structure[y][x][z];
    Block block = worldObj.getBlock(worldPos.x, worldPos.y, worldPos.z);
    int blockMetadata = worldObj.getBlockMetadata(worldPos.x, worldPos.y, worldPos.z);
    if (structureID == MinechemBlueprint.wildcard) {
        return MultiBlockStatusEnum.CORRECT;
    } else if (structureID == air) {
        if (block.isAir(worldObj, x, y, z)) {
            return MultiBlockStatusEnum.CORRECT;
        } else {
            return MultiBlockStatusEnum.INCORRECT;
        }
    } else {
        HashMap<Integer, BlueprintBlock> lut = blueprint.getBlockLookup();
        BlueprintBlock blueprintBlock = lut.get(structureID);
        if (block.isAir(worldObj, x, y, z)) {
            createGhostBlock(worldPos.x, worldPos.y, worldPos.z, structureID);
            return MultiBlockStatusEnum.INCORRECT;
        } else if (block == blueprintBlock.block && (blockMetadata == blueprintBlock.metadata || blueprintBlock.metadata == -1)) {
            return MultiBlockStatusEnum.CORRECT;
        } else {
            return MultiBlockStatusEnum.INCORRECT;
        }
    }
}
Also used : BlueprintBlock(minechem.item.blueprint.BlueprintBlock) HashMap(java.util.HashMap) Pos3(minechem.utils.LocalPosition.Pos3) BlueprintBlock(minechem.item.blueprint.BlueprintBlock) Block(net.minecraft.block.Block) MinechemBlueprint(minechem.item.blueprint.MinechemBlueprint)

Example 5 with BlueprintBlock

use of minechem.item.blueprint.BlueprintBlock in project Minechem by iopleke.

the class MultiBlockTileEntity method linkProxy.

private void linkProxy(int x, int y, int z) {
    int worldX = xCoord + offsetX + x;
    int worldY = yCoord + offsetY + y;
    int worldZ = zCoord + offsetZ + z;
    HashMap<Integer, BlueprintBlock> lut = blueprint.getBlockLookup();
    TileEntity tileEntity = worldObj.getTileEntity(worldX, worldY, worldZ);
    if (tileEntity != null && tileEntity instanceof TileEntityProxy) {
        ((TileEntityProxy) tileEntity).setManager(this);
    }
}
Also used : BlueprintBlock(minechem.item.blueprint.BlueprintBlock) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityProxy(minechem.tileentity.prefab.TileEntityProxy) MinechemBlueprint(minechem.item.blueprint.MinechemBlueprint)

Aggregations

BlueprintBlock (minechem.item.blueprint.BlueprintBlock)7 MinechemBlueprint (minechem.item.blueprint.MinechemBlueprint)5 HashMap (java.util.HashMap)3 FusionTileEntity (minechem.tileentity.multiblock.fusion.FusionTileEntity)3 Pos3 (minechem.utils.LocalPosition.Pos3)3 TileEntity (net.minecraft.tileentity.TileEntity)3 MultiBlockTileEntity (minechem.tileentity.multiblock.MultiBlockTileEntity)2 GhostBlockTileEntity (minechem.tileentity.multiblock.ghostblock.GhostBlockTileEntity)2 MinechemTileEntity (minechem.tileentity.prefab.MinechemTileEntity)2 TileEntityProxy (minechem.tileentity.prefab.TileEntityProxy)2 Block (net.minecraft.block.Block)2 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 ItemStack (net.minecraft.item.ItemStack)1