Search in sources :

Example 6 with BlockPart

use of org.terasology.engine.world.block.BlockPart in project Terasology by MovingBlocks.

the class BlockBuilder method constructCustomBlock.

@Override
public Block constructCustomBlock(String defaultName, BlockShape shape, Rotation rotation, SectionDefinitionData section, BlockUri uri, BlockFamily blockFamily) {
    Block block = createRawBlock(defaultName, section);
    block.setRotation(rotation);
    block.setPrimaryAppearance(createAppearance(shape, section.getBlockTiles(), rotation));
    setBlockFullSides(block, shape, rotation);
    block.setCollision(shape.getCollisionOffset(rotation), shape.getCollisionShape(rotation));
    for (BlockPart part : BlockPart.values()) {
        block.setColorSource(part, section.getColorSources().get(part));
        block.setColorOffset(part, new Color().set(section.getColorOffsets().get(part)));
    }
    block.setUri(uri);
    block.setBlockFamily(blockFamily);
    // Lowered mesh for liquids
    if (block.isLiquid()) {
        applyLiquidShapes(block, section.getBlockTiles());
    }
    return block;
}
Also used : BlockPart(org.terasology.engine.world.block.BlockPart) Color(org.terasology.nui.Color) Block(org.terasology.engine.world.block.Block)

Example 7 with BlockPart

use of org.terasology.engine.world.block.BlockPart in project Terasology by MovingBlocks.

the class BlockShapeImpl method doReload.

@Override
protected void doReload(BlockShapeData data) {
    collisionShape.clear();
    displayName = data.getDisplayName();
    for (BlockPart part : BlockPart.values()) {
        this.meshParts.put(part, data.getMeshPart(part));
    }
    for (Side side : Side.values()) {
        this.fullSide[side.ordinal()] = data.isBlockingSide(side);
    }
    this.baseCollisionShape = data.getCollisionShape();
    this.baseCollisionOffset.set(data.getCollisionOffset());
    collisionShape.put(Rotation.none(), baseCollisionShape);
    yawSymmetric = data.isYawSymmetric();
    pitchSymmetric = data.isPitchSymmetric();
    rollSymmetric = data.isRollSymmetric();
}
Also used : BlockPart(org.terasology.engine.world.block.BlockPart) Side(org.terasology.engine.math.Side)

Aggregations

BlockPart (org.terasology.engine.world.block.BlockPart)7 Side (org.terasology.engine.math.Side)3 BlockMeshPart (org.terasology.engine.world.block.shapes.BlockMeshPart)3 BlockTile (org.terasology.engine.world.block.tiles.BlockTile)3 Block (org.terasology.engine.world.block.Block)2 Quaternionf (org.joml.Quaternionf)1 Vector2f (org.joml.Vector2f)1 Vector3f (org.joml.Vector3f)1 Mesh (org.terasology.engine.rendering.assets.mesh.Mesh)1 StandardMeshData (org.terasology.engine.rendering.assets.mesh.StandardMeshData)1 BlockAppearance (org.terasology.engine.world.block.BlockAppearance)1 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)1 Color (org.terasology.nui.Color)1