Skip to content

Commit

Permalink
refactor: Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
null2264 committed Jun 23, 2023
1 parent 8c7e15e commit 49ba599
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.null2264.cobblegen.data.generator;

import io.github.null2264.cobblegen.CobbleGen;
import io.github.null2264.cobblegen.config.ConfigMetaData;
import io.github.null2264.cobblegen.config.WeightedBlock;
import io.github.null2264.cobblegen.data.model.BlockGenerator;
import io.github.null2264.cobblegen.data.model.Generator;
Expand Down Expand Up @@ -31,7 +32,7 @@ public class CobbleGenerator extends BlockGenerator
private final boolean silent;

public CobbleGenerator(List<WeightedBlock> possibleBlocks, Fluid fluid, boolean silent) {
this(Map.of("*", possibleBlocks), fluid, silent, Map.of());
this(possibleBlocks, fluid, silent, Map.of());
}

public CobbleGenerator(List<WeightedBlock> possibleBlocks, Fluid fluid, boolean silent, Map<String, List<WeightedBlock>> obsidianReplacements) {
Expand Down Expand Up @@ -89,10 +90,8 @@ public Optional<BlockState> tryGenerate(LevelAccessor level, BlockPos pos, Block
@Override
public Optional<BlockState> tryGenerate(LevelAccessor level, BlockPos pos, FluidState source, FluidState neighbour) {
if (Generator.getStillFluid(neighbour) == getFluid()) {
AtomicReference<Boolean> isExperimentalEnabled = new AtomicReference<>(false);
Util.optional(CobbleGen.META_CONFIG).ifPresent((e) -> isExperimentalEnabled.set(e.enableExperimentalFeatures));
if (source.getType() == Fluids.LAVA && source.isSource()) {
if (isExperimentalEnabled.get())
if (Util.optional(CobbleGen.META_CONFIG).orElse(new ConfigMetaData()).enableExperimentalFeatures)
return getBlockCandidate(level, pos, getObsidianOutput(), Blocks.OBSIDIAN);
return Optional.of(Blocks.OBSIDIAN.defaultBlockState());
}
Expand Down

0 comments on commit 49ba599

Please sign in to comment.