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);
    }
  }
 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 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);
        }
      }
    }
  }
 public void setBlueprint(MinechemBlueprint blueprint) {
   if (blueprint != null) {
     this.blueprint = blueprint;
     this.structure = blueprint.getStructure();
   } else {
     destroyProjection();
     this.blueprint = null;
     this.structure = null;
     this.isComplete = false;
   }
 }
Ejemplo n.º 5
0
 private void drawBlueprintInfo(ItemStack blueprintStack) {
   MinechemBlueprint blueprint = MinechemItems.blueprint.getBlueprint(blueprintStack);
   if (blueprint == null) {
     System.out.println("NULL blueprint");
     return;
   }
   String name = blueprintStack.getDisplayName().replace("Blueprint", "");
   this.fontRenderer.drawStringWithShadow(name, 64, 12, 0xFFFFFF);
   HashMap<Integer, Integer> blockCount = getBlockCount(blueprint);
   HashMap<Integer, BlueprintBlock> blockLookup = blueprint.getBlockLookup();
   int y = 23;
   Iterator<Entry<Integer, Integer>> it = blockCount.entrySet().iterator();
   while (it.hasNext()) {
     Map.Entry<Integer, Integer> entry = it.next();
     BlueprintBlock block = blockLookup.get(entry.getKey());
     if (block != null) {
       ItemStack itemstack = new ItemStack(block.block, 1, block.metadata);
       String info = String.format("%dx%s", entry.getValue(), itemstack.getDisplayName());
       this.fontRenderer.drawString(info, 64, y, 0xDDDDDD);
       y += 10;
     }
   }
 }
Ejemplo n.º 6
0
  private HashMap<Integer, Integer> getBlockCount(MinechemBlueprint blueprint) {
    HashMap<Integer, Integer> blockCount = new HashMap<Integer, Integer>();

    for (int x = 0; x < blueprint.xSize; x++) {
      for (int y = 0; y < blueprint.ySize; y++) {
        for (int z = 0; z < blueprint.zSize; z++) {
          int structureID = blueprint.getStructure()[y][x][z];
          int count = 0;
          if (blockCount.get(structureID) != null) count = (int) blockCount.get(structureID);
          count++;
          blockCount.put(structureID, count);
        }
      }
    }

    return blockCount;
  }
 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;
     }
   }
 }
 private boolean isManagerBlock(int x, int y, int z) {
   return x == blueprint.getManagerPosX()
       && y == blueprint.getManagerPosY()
       && z == blueprint.getManagerPosZ();
 }