Ejemplo n.º 1
0
  private void generateBlueprint() {
    if (_selectedBlocks.size() < 2) return;

    int maxX = Math.max(_selectedBlocks.get(0).x, _selectedBlocks.get(1).x);
    int minX = Math.min(_selectedBlocks.get(0).x, _selectedBlocks.get(1).x);
    int maxY = Math.max(_selectedBlocks.get(0).y, _selectedBlocks.get(1).y);
    int minY = Math.min(_selectedBlocks.get(0).y, _selectedBlocks.get(1).y);
    int maxZ = Math.max(_selectedBlocks.get(0).z, _selectedBlocks.get(1).z);
    int minZ = Math.min(_selectedBlocks.get(0).z, _selectedBlocks.get(1).z);

    for (int x = minX; x <= maxX; x++) {
      for (int y = minY; y <= maxY; y++) {
        for (int z = minZ; z <= maxZ; z++) {
          if (_player.getParent().getWorldProvider().getBlock(x, y, z) != 0x0) {
            BlockPosition bp = new BlockPosition(x, y, z);

            _selectedBlocks.add(bp);
            Terasology.getInstance().getActiveWorldRenderer().getBlockGrid().addGridPosition(bp);
          }
        }
      }
    }

    if (ItemBlueprint.class.isInstance(_player.getActiveItem())) {
      ItemBlueprint bpItem = (ItemBlueprint) _player.getActiveItem();
      bpItem.setBlueprint(
          BlueprintManager.getInstance()
              .generateBlueprint(_player.getParent().getWorldProvider(), _selectedBlocks));
    }
  }
Ejemplo n.º 2
0
  public void executeLeftClickAction() {
    RayBlockIntersection.Intersection selectedBlock = _player.getSelectedBlock();

    if (ItemBlueprint.class.isInstance(_player.getActiveItem()) && selectedBlock != null) {
      ItemBlueprint bpItem = (ItemBlueprint) _player.getActiveItem();

      if (bpItem.getBlueprint() == null) {
        addBlock(selectedBlock.getBlockPosition());
      } else {
        bpItem
            .getBlueprint()
            .build(_player.getParent().getWorldProvider(), selectedBlock.getBlockPosition());
      }
    }
  }
Ejemplo n.º 3
0
 public void executeRightClickAction() {
   if (ItemBlueprint.class.isInstance(_player.getActiveItem())) {
     ItemBlueprint bpItem = (ItemBlueprint) _player.getActiveItem();
     bpItem.setBlueprint(null);
   }
 }