diff --git a/src/main/java/io/github/null2264/cobblegen/compat/LoaderCompat.java b/src/main/java/io/github/null2264/cobblegen/compat/LoaderCompat.java index 1c23f74..a2d9d85 100644 --- a/src/main/java/io/github/null2264/cobblegen/compat/LoaderCompat.java +++ b/src/main/java/io/github/null2264/cobblegen/compat/LoaderCompat.java @@ -1,24 +1,25 @@ package io.github.null2264.cobblegen.compat; +import java.nio.file.Path; + //#if FABRIC>=1 import net.fabricmc.loader.api.FabricLoader; - //#if MC<=1.16.5 - //$$ import java.io.IOException; - //$$ import java.nio.file.Files; - //#endif +//#if MC<=1.16.5 +//$$ import java.io.IOException; +//$$ import java.nio.file.FileSystems; +//$$ import java.nio.file.Files; +//#endif +//#else +//#if FORGE>=2 && MC>=1.20.2 +//$$ import net.neoforged.fml.loading.FMLPaths; +//$$ import net.neoforged.fml.ModList; +//$$ import net.neoforged.fml.loading.LoadingModList; //#else - //#if FORGE>=2 && MC>=1.20.2 - //$$ import net.neoforged.fml.loading.FMLPaths; - //$$ import net.neoforged.fml.ModList; - //$$ import net.neoforged.fml.loading.LoadingModList; - //#else - //$$ import net.minecraftforge.fml.loading.FMLPaths; - //$$ import net.minecraftforge.fml.ModList; - //$$ import net.minecraftforge.fml.loading.LoadingModList; - //#endif +//$$ import net.minecraftforge.fml.loading.FMLPaths; +//$$ import net.minecraftforge.fml.ModList; +//$$ import net.minecraftforge.fml.loading.LoadingModList; +//#endif //#endif - -import java.nio.file.Path; public class LoaderCompat { public static boolean isModLoaded(String mod) { @@ -38,7 +39,7 @@ public static Path getConfigDir() { return FabricLoader.getInstance().getConfigDir(); //#else // Not ideal, but configDir is null somehow in 1.16.5 - //$$ Path configDir = Path.of(".", "config"); + //$$ Path configDir = FileSystems.getDefault().getPath(".", "config"); //$$ if (!Files.exists(configDir)) { // Stolen from fabric loader //$$ try { //$$ Files.createDirectories(configDir); diff --git a/src/main/java/io/github/null2264/cobblegen/data/FluidInteractionHelper.java b/src/main/java/io/github/null2264/cobblegen/data/FluidInteractionHelper.java index a4ac6ab..e213ada 100644 --- a/src/main/java/io/github/null2264/cobblegen/data/FluidInteractionHelper.java +++ b/src/main/java/io/github/null2264/cobblegen/data/FluidInteractionHelper.java @@ -25,6 +25,7 @@ import java.util.*; import java.util.concurrent.atomic.AtomicInteger; +import static io.github.null2264.cobblegen.compat.CollectionCompat.listOf; import static io.github.null2264.cobblegen.util.Constants.LAVA_FIZZ; import static io.github.null2264.cobblegen.util.Util.notNullOr; @@ -149,7 +150,7 @@ public boolean interact(LevelAccessor level, BlockPos pos, BlockState state) { public boolean interact(LevelAccessor level, BlockPos pos, BlockState state, boolean fromTop) { FluidState fluidState = state.getFluidState(); Fluid fluid = Generator.getStillFluid(fluidState); - final List generators = generatorMap.getOrDefault(fluid, List.of()); + final List generators = generatorMap.getOrDefault(fluid, listOf()); for (Generator generator : generators) { if (!generator.check(level, pos, state, fromTop)) continue; diff --git a/src/main/java/io/github/null2264/cobblegen/data/generator/CobbleGenerator.java b/src/main/java/io/github/null2264/cobblegen/data/generator/CobbleGenerator.java index b9d5f21..fc4fcd5 100644 --- a/src/main/java/io/github/null2264/cobblegen/data/generator/CobbleGenerator.java +++ b/src/main/java/io/github/null2264/cobblegen/data/generator/CobbleGenerator.java @@ -33,7 +33,7 @@ public class CobbleGenerator extends BlockGenerator private final boolean silent; public CobbleGenerator(List possibleBlocks, Fluid fluid, boolean silent) { - this(possibleBlocks, fluid, silent, Map.of()); + this(possibleBlocks, fluid, silent, mapOf()); } public CobbleGenerator(List possibleBlocks, Fluid fluid, boolean silent, Map> obsidianReplacements) { diff --git a/src/main/java/io/github/null2264/cobblegen/data/model/BlockGenerator.java b/src/main/java/io/github/null2264/cobblegen/data/model/BlockGenerator.java index f4dc453..e50dfbf 100644 --- a/src/main/java/io/github/null2264/cobblegen/data/model/BlockGenerator.java +++ b/src/main/java/io/github/null2264/cobblegen/data/model/BlockGenerator.java @@ -19,7 +19,7 @@ public abstract class BlockGenerator implements BuiltInGenerator public Optional tryGenerate(LevelAccessor level, BlockPos pos, BlockState state) { for (Direction direction : FLOW_DIRECTIONS) { final Optional candidate = tryGenerate(level, pos, state, direction); - if (candidate.isEmpty()) continue; + if (!candidate.isPresent()) continue; return candidate; } diff --git a/src/main/java/io/github/null2264/cobblegen/data/model/Generator.java b/src/main/java/io/github/null2264/cobblegen/data/model/Generator.java index aac7c77..1d143bd 100644 --- a/src/main/java/io/github/null2264/cobblegen/data/model/Generator.java +++ b/src/main/java/io/github/null2264/cobblegen/data/model/Generator.java @@ -21,6 +21,8 @@ import java.util.Map; import java.util.Optional; +import static io.github.null2264.cobblegen.compat.CollectionCompat.mapOf; + public interface Generator extends PacketSerializable { static Fluid getStillFluid(FluidState fluidState) { @@ -57,7 +59,7 @@ default Optional tryGenerate(LevelAccessor level, BlockPos pos, Flui * @return The output block when a source fluid met another fluid (e.g. Water -> Stone / Lava -> Obsidian) */ default Map> getObsidianOutput() { - return Map.of(); + return mapOf(); } @NotNull