Ejemplo n.º 1
0
  @Override
  public Block constructTransformedBlock(
      AssetUri blockDefUri, BlockDefinition blockDef, Rotation rotation) {
    Map<BlockPart, AssetUri> tileUris = prepareTiles(blockDef, blockDefUri);
    Map<BlockPart, Block.ColorSource> colorSourceMap = prepareColorSources(blockDef);
    Map<BlockPart, Vector4f> colorOffsetsMap = prepareColorOffsets(blockDef);
    BlockShape shape = getShape(blockDef);

    Block block = createRawBlock(blockDef, blockDefUri.getAssetName());
    block.setDirection(rotation.rotate(Side.FRONT));
    block.setPrimaryAppearance(createAppearance(shape, tileUris, rotation));
    setBlockFullSides(block, shape, rotation);
    block.setCollision(shape.getCollisionOffset(rotation), shape.getCollisionShape(rotation));

    for (BlockPart part : BlockPart.values()) {
      block.setColorSource(part, colorSourceMap.get(part));
      block.setColorOffset(part, colorOffsetsMap.get(part));
    }

    return block;
  }
Ejemplo n.º 2
0
  private Block constructSingleBlock(AssetUri blockDefUri, BlockDefinition blockDef) {
    Map<BlockPart, AssetUri> tileUris = prepareTiles(blockDef, blockDefUri);
    Map<BlockPart, Block.ColorSource> colorSourceMap = prepareColorSources(blockDef);
    Map<BlockPart, Vector4f> colorOffsetsMap = prepareColorOffsets(blockDef);
    BlockShape shape = getShape(blockDef);

    Block block = createRawBlock(blockDef, blockDefUri.getAssetName());
    block.setPrimaryAppearance(createAppearance(shape, tileUris, Rotation.none()));
    setBlockFullSides(block, shape, Rotation.none());
    block.setCollision(
        shape.getCollisionOffset(Rotation.none()), shape.getCollisionShape(Rotation.none()));

    for (BlockPart part : BlockPart.values()) {
      block.setColorSource(part, colorSourceMap.get(part));
      block.setColorOffset(part, colorOffsetsMap.get(part));
    }

    // Lowered mesh for liquids
    if (block.isLiquid()) {
      applyLoweredShape(block, loweredShape, tileUris);
    }
    return block;
  }