private void projectBlueprint() { int facing = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); ForgeDirection direction = MinechemHelper.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) { BlockStatus blockStatus; if (isManagerBlock(x, y, z)) blockStatus = BlockStatus.CORRECT; else blockStatus = projectGhostBlock(x, y, z, position); if (blockStatus == BlockStatus.CORRECT) { verticalIncorrectCount--; totalIncorrectCount--; } } else { destroyGhostBlock(x, y, z, position); } } } if (verticalIncorrectCount != 0) shouldProjectGhostBlocks = false; } if (totalIncorrectCount == 0 && !isComplete) { isComplete = true; buildStructure(position); } }
public void destroyProjection() { if (this.blueprint == null) return; int facing = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); ForgeDirection direction = MinechemHelper.getDirectionFromFacing(facing); LocalPosition position = new LocalPosition(xCoord, yCoord, zCoord, direction); position.moveForwards(blueprint.zSize + 1); position.moveLeft(Math.floor(blueprint.xSize / 2)); for (int x = 0; x < blueprint.xSize; x++) { for (int y = 0; y < blueprint.ySize; y++) { for (int z = 0; z < blueprint.zSize; z++) { destroyGhostBlock(x, y, z, position); } } } }
private void destroyGhostBlock(int x, int y, int z, LocalPosition position) { Pos3 worldPos = position.getLocalPos(x, y, z); int blockID = worldObj.getBlockId(worldPos.x, worldPos.y, worldPos.z); if (blockID == MinechemBlocks.ghostBlock.blockID) { worldObj.func_94575_c(worldPos.x, worldPos.y, worldPos.z, 0); } }
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.func_94575_c(worldPos.x, worldPos.y, worldPos.z, 0); } else { BlueprintBlock blueprintBlock = blockLookup.get(structureId); if (blueprintBlock.type == Type.MANAGER) return; worldObj.setBlockAndMetadataWithNotify( worldPos.x, worldPos.y, worldPos.z, blueprintBlock.block.blockID, blueprintBlock.metadata, 3); if (blueprintBlock.type == Type.PROXY) { TileEntityProxy proxy = (TileEntityProxy) worldObj.getBlockTileEntity(worldPos.x, worldPos.y, worldPos.z); if (proxy != null) proxy.setManager(managerTileEntity); } } }
private TileEntity buildManagerBlock(LocalPosition position) { BlueprintBlock managerBlock = blueprint.getManagerBlock(); if (managerBlock != null) { Pos3 worldPos = position.getLocalPos( blueprint.getManagerPosX(), blueprint.getManagerPosY(), blueprint.getManagerPosZ()); worldObj.setBlockAndMetadataWithNotify( worldPos.x, worldPos.y, worldPos.z, managerBlock.block.blockID, managerBlock.metadata, 3); return worldObj.getBlockTileEntity(worldPos.x, worldPos.y, worldPos.z); } else { return null; } }
private BlockStatus projectGhostBlock(int x, int y, int z, LocalPosition position) { Pos3 worldPos = position.getLocalPos(x, y, z); Integer structureID = structure[y][x][z]; int blockID = worldObj.getBlockId(worldPos.x, worldPos.y, worldPos.z); int blockMetadata = worldObj.getBlockMetadata(worldPos.x, worldPos.y, worldPos.z); if (structureID == MinechemBlueprint.wildcard) { return BlockStatus.CORRECT; } else if (structureID == air) { if (blockID == air) return BlockStatus.CORRECT; else return BlockStatus.INCORRECT; } else { HashMap<Integer, BlueprintBlock> lut = blueprint.getBlockLookup(); BlueprintBlock blueprintBlock = lut.get(structureID); if (blockID == air) { createGhostBlock(worldPos.x, worldPos.y, worldPos.z, structureID); return BlockStatus.INCORRECT; } else if (blockID == blueprintBlock.block.blockID && (blockMetadata == blueprintBlock.metadata || blueprintBlock.metadata == -1)) { return BlockStatus.CORRECT; } else { return BlockStatus.INCORRECT; } } }