Search in sources :

Example 1 with UpdatesWithNeighboursFamily

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

the class NeighbourBlockFamilyUpdateSystem method processUpdateForBlockLocation.

private void processUpdateForBlockLocation(Vector3ic blockLocation) {
    for (Side side : Side.values()) {
        Vector3i neighborLocation = blockLocation.add(side.direction(), new Vector3i());
        if (worldProvider.isBlockRelevant(neighborLocation)) {
            Block neighborBlock = worldProvider.getBlock(neighborLocation);
            final BlockFamily blockFamily = neighborBlock.getBlockFamily();
            if (blockFamily instanceof UpdatesWithNeighboursFamily) {
                UpdatesWithNeighboursFamily neighboursFamily = (UpdatesWithNeighboursFamily) blockFamily;
                Block neighborBlockAfterUpdate = neighboursFamily.getBlockForNeighborUpdate(neighborLocation, neighborBlock);
                if (neighborBlock != neighborBlockAfterUpdate) {
                    worldProvider.setBlock(neighborLocation, neighborBlockAfterUpdate);
                }
            }
        }
    }
}
Also used : Side(org.terasology.engine.math.Side) UpdatesWithNeighboursFamily(org.terasology.engine.world.block.family.UpdatesWithNeighboursFamily) Vector3i(org.joml.Vector3i) OnChangedBlock(org.terasology.engine.world.OnChangedBlock) Block(org.terasology.engine.world.block.Block) BlockFamily(org.terasology.engine.world.block.family.BlockFamily)

Aggregations

Vector3i (org.joml.Vector3i)1 Side (org.terasology.engine.math.Side)1 OnChangedBlock (org.terasology.engine.world.OnChangedBlock)1 Block (org.terasology.engine.world.block.Block)1 BlockFamily (org.terasology.engine.world.block.family.BlockFamily)1 UpdatesWithNeighboursFamily (org.terasology.engine.world.block.family.UpdatesWithNeighboursFamily)1