Search in sources :

Example 1 with CasingType

use of mekanism.common.lib.multiblock.FormationProtocol.CasingType in project Mekanism by mekanism.

the class CuboidStructureValidator method validateNode.

/**
 * @param pos Mutable BlockPos
 */
protected FormationResult validateNode(FormationProtocol<T> ctx, Long2ObjectMap<IChunk> chunkMap, BlockPos pos) {
    Optional<BlockState> optionalState = WorldUtils.getBlockState(world, chunkMap, pos);
    if (!optionalState.isPresent()) {
        // If the position is not in a loaded chunk or out of bounds of the world, fail
        return FormationResult.FAIL;
    }
    BlockState state = optionalState.get();
    StructureRequirement requirement = getStructureRequirement(pos);
    if (requirement.isCasing()) {
        CasingType type = getCasingType(state);
        FormationResult ret = validateFrame(ctx, pos, state, type, requirement.needsFrame());
        if (requirement != StructureRequirement.IGNORED && !ret.isFormed()) {
            return ret;
        }
    } else if (!validateInner(state, chunkMap, pos)) {
        return FormationResult.fail(MekanismLang.MULTIBLOCK_INVALID_INNER, pos);
    } else if (!state.isAir(world, pos)) {
        // Make sure the position is immutable before we store it
        ctx.innerNodes.add(pos.immutable());
    }
    return FormationResult.SUCCESS;
}
Also used : BlockState(net.minecraft.block.BlockState) CasingType(mekanism.common.lib.multiblock.FormationProtocol.CasingType) FormationResult(mekanism.common.lib.multiblock.FormationProtocol.FormationResult) StructureRequirement(mekanism.common.lib.multiblock.FormationProtocol.StructureRequirement)

Aggregations

CasingType (mekanism.common.lib.multiblock.FormationProtocol.CasingType)1 FormationResult (mekanism.common.lib.multiblock.FormationProtocol.FormationResult)1 StructureRequirement (mekanism.common.lib.multiblock.FormationProtocol.StructureRequirement)1 BlockState (net.minecraft.block.BlockState)1