From c0042cfb6b959e0064772d17541da4a3495b48f3 Mon Sep 17 00:00:00 2001 From: dfsek Date: Mon, 17 May 2021 19:39:46 -0700 Subject: [PATCH] switch to DimensionType map --- .../com/dfsek/terra/fabric/TerraFabricPlugin.java | 14 ++++++++------ .../generation/FabricChunkGeneratorWrapper.java | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/TerraFabricPlugin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/TerraFabricPlugin.java index 089bd6b63..673b4c973 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/TerraFabricPlugin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/TerraFabricPlugin.java @@ -53,7 +53,9 @@ import net.minecraft.util.Identifier; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; +import net.minecraft.world.WorldAccess; import net.minecraft.world.biome.Biome; +import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.decorator.Decorator; import net.minecraft.world.gen.decorator.NopeDecoratorConfig; import net.minecraft.world.gen.feature.ConfiguredFeature; @@ -75,7 +77,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer { public static final PopulatorFeature POPULATOR_FEATURE = new PopulatorFeature(DefaultFeatureConfig.CODEC); public static final ConfiguredFeature POPULATOR_CONFIGURED_FEATURE = POPULATOR_FEATURE.configure(FeatureConfig.DEFAULT).decorate(Decorator.NOPE.configure(NopeDecoratorConfig.INSTANCE)); private static TerraFabricPlugin instance; - private final Map worldMap = new HashMap<>(); + private final Map worldMap = new HashMap<>(); private final EventManager eventManager = new TerraEventManager(this); private final GenericLoaders genericLoaders = new GenericLoaders(this); @@ -131,15 +133,15 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer { @Override public TerraWorld getWorld(World world) { - return worldMap.computeIfAbsent(world.getSeed(), w -> { + return worldMap.computeIfAbsent(((WorldAccess) world).getDimension(), w -> { logger.info("Loading world " + w); return new TerraWorld(world, ((FabricChunkGeneratorWrapper) world.getGenerator()).getPack(), this); }); } - public TerraWorld getWorld(long seed) { - TerraWorld world = worldMap.get(seed); - if(world == null) throw new IllegalArgumentException("No world exists with seed " + seed); + public TerraWorld getWorld(DimensionType type) { + TerraWorld world = worldMap.get(type); + if(world == null) throw new IllegalArgumentException("No world exists with dimension type " + type); return world; } @@ -183,7 +185,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer { config.load(this); LangUtil.load(config.getLanguage(), this); // Load language. boolean succeed = registry.loadAll(this); - Map newMap = new HashMap<>(); + Map newMap = new HashMap<>(); worldMap.forEach((seed, tw) -> { tw.getConfig().getSamplerCache().clear(); String packID = tw.getConfig().getTemplate().getID(); diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java index 116c007ad..fb91046a1 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java @@ -11,11 +11,9 @@ import com.dfsek.terra.fabric.TerraFabricPlugin; import com.dfsek.terra.fabric.util.FabricAdapter; import com.dfsek.terra.world.TerraWorld; import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D; -import com.dfsek.terra.world.generation.math.samplers.Sampler; import com.dfsek.terra.world.population.items.TerraStructure; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.jafama.FastMath; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.server.world.ServerWorld; @@ -134,6 +132,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener @Override public int getHeight(int x, int z, Heightmap.Type heightmapType) { + /* TerraWorld world = TerraFabricPlugin.getInstance().getWorld(seed); Sampler sampler = world.getConfig().getSamplerCache().getChunk(FastMath.floorDiv(x, 16), FastMath.floorDiv(z, 16)); int cx = FastMath.floorMod(x, 16); @@ -146,6 +145,9 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener } return height; + + */ + return 0; } @Override