Start work on detaching dimensions from json
Changes to be committed: new file: src/main/java/org/dimdev/dimdoors/mixin/ChunkGeneratorSettingsAccessor.java modified: src/main/java/org/dimdev/dimdoors/rift/targets/EscapeTarget.java modified: src/main/java/org/dimdev/dimdoors/world/ModDimensions.java modified: src/main/java/org/dimdev/dimdoors/world/limbo/LimboChunkGenerator.java modified: src/main/resources/data/dimdoors/dimension/limbo.json modified: src/main/resources/dimdoors.mixins.json
This commit is contained in:
parent
502d86f514
commit
e8d86f7461
6 changed files with 60 additions and 26 deletions
|
@ -0,0 +1,17 @@
|
|||
package org.dimdev.dimdoors.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
|
||||
import net.minecraft.world.gen.chunk.GenerationShapeConfig;
|
||||
import net.minecraft.world.gen.chunk.StructuresConfig;
|
||||
|
||||
@Mixin(ChunkGeneratorSettings.class)
|
||||
public interface ChunkGeneratorSettingsAccessor {
|
||||
@Invoker("<init>")
|
||||
static ChunkGeneratorSettings invokeInit(StructuresConfig structuresConfig, GenerationShapeConfig generationShapeConfig, BlockState defaultBlock, BlockState defaultFluid, int bedrockCeilingY, int bedrockFloorY, int seaLevel, boolean mobGenerationDisabled) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
|
@ -54,8 +54,8 @@ public class EscapeTarget extends VirtualTarget implements EntityTarget { // TOD
|
|||
chat(entity, new TranslatableText("rifts.destinations.escape.rift_has_closed"));
|
||||
}
|
||||
if (!entity.getEntityWorld().isClient) {
|
||||
if (ModDimensions.limboDimension != null) {
|
||||
entity.moveToWorld(ModDimensions.limboDimension);
|
||||
if (ModDimensions.LIMBO_DIMENSION != null) {
|
||||
entity.moveToWorld(ModDimensions.LIMBO_DIMENSION);
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package org.dimdev.dimdoors.world;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.dimdev.dimdoors.block.ModBlocks;
|
||||
import org.dimdev.dimdoors.mixin.ChunkGeneratorSettingsAccessor;
|
||||
import org.dimdev.dimdoors.mixin.DimensionTypeAccessor;
|
||||
import org.dimdev.dimdoors.world.limbo.LimboBiomeSource;
|
||||
import org.dimdev.dimdoors.world.limbo.LimboChunkGenerator;
|
||||
|
@ -14,6 +18,11 @@ import net.minecraft.util.registry.Registry;
|
|||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
|
||||
import net.minecraft.world.gen.chunk.GenerationShapeConfig;
|
||||
import net.minecraft.world.gen.chunk.NoiseSamplingConfig;
|
||||
import net.minecraft.world.gen.chunk.SlideConfig;
|
||||
import net.minecraft.world.gen.chunk.StructuresConfig;
|
||||
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
|
||||
|
@ -26,13 +35,15 @@ public final class ModDimensions {
|
|||
public static final RegistryKey<DimensionType> LIMBO_TYPE = RegistryKey.of(Registry.DIMENSION_TYPE_KEY, new Identifier("dimdoors:limbo"));
|
||||
public static final RegistryKey<DimensionType> POCKET_TYPE = RegistryKey.of(Registry.DIMENSION_TYPE_KEY, new Identifier("dimdoors:personal_pockets"));
|
||||
|
||||
public static DimensionType limboDimensionType = DimensionTypeAccessor.invokeInit(OptionalLong.of(6000), false, false, false, false, 4.0, false, false, true, false, 256, BlockTags.INFINIBURN_OVERWORLD.getId(), DimensionType.THE_END_ID, 0.1F);
|
||||
public static DimensionType pocketDimensionType = DimensionTypeAccessor.invokeInit(OptionalLong.empty(), true, false, false, false, 4.0, false, false, true, false, 256, BlockTags.INFINIBURN_OVERWORLD.getId(), DimensionType.THE_END_ID, 0.1F);
|
||||
public static DimensionType LIMBO_DIMENSION_TYPE = DimensionTypeAccessor.invokeInit(OptionalLong.of(6000), false, false, false, false, 4.0, false, false, true, false, 256, BlockTags.INFINIBURN_OVERWORLD.getId(), DimensionType.THE_END_ID, 0.1F);
|
||||
public static DimensionType POCKET_DIMENSION_TYPE = DimensionTypeAccessor.invokeInit(OptionalLong.empty(), true, false, false, false, 4.0, false, false, true, false, 256, BlockTags.INFINIBURN_OVERWORLD.getId(), DimensionType.THE_END_ID, 0.1F);
|
||||
|
||||
public static ServerWorld limboDimension;
|
||||
public static ServerWorld personalPocketDimension;
|
||||
public static ServerWorld publicPocketDimension;
|
||||
public static ServerWorld dungeonPocketDimension;
|
||||
public static final ChunkGeneratorSettings LIMBO_CHUNK_GENERATOR_SETTINGS;
|
||||
|
||||
public static ServerWorld LIMBO_DIMENSION;
|
||||
public static ServerWorld PERSONAL_POCKET_DIMENSION;
|
||||
public static ServerWorld PUBLIC_POCKET_DIMENSION;
|
||||
public static ServerWorld DUNGEON_POCKET_DIMENSION;
|
||||
|
||||
public static boolean isDimDoorsPocketDimension(World world) {
|
||||
return isDimDoorsPocketDimension(world.getRegistryKey());
|
||||
|
@ -43,20 +54,26 @@ public final class ModDimensions {
|
|||
}
|
||||
|
||||
public static boolean isLimboDimension(World world) {
|
||||
return world.getRegistryKey() == LIMBO || world.getDimension() == limboDimensionType || world == limboDimension;
|
||||
return world.getRegistryKey() == LIMBO || world.getDimension() == LIMBO_DIMENSION_TYPE || world == LIMBO_DIMENSION;
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
|
||||
ModDimensions.limboDimensionType = server.getRegistryManager().getDimensionTypes().get(LIMBO_TYPE);
|
||||
ModDimensions.pocketDimensionType = server.getRegistryManager().getDimensionTypes().get(POCKET_TYPE);
|
||||
ModDimensions.limboDimension = server.getWorld(LIMBO);
|
||||
ModDimensions.personalPocketDimension = server.getWorld(PERSONAL);
|
||||
ModDimensions.publicPocketDimension = server.getWorld(PUBLIC);
|
||||
ModDimensions.dungeonPocketDimension = server.getWorld(DUNGEON);
|
||||
ModDimensions.LIMBO_DIMENSION_TYPE = server.getRegistryManager().getDimensionTypes().get(LIMBO_TYPE);
|
||||
ModDimensions.POCKET_DIMENSION_TYPE = server.getRegistryManager().getDimensionTypes().get(POCKET_TYPE);
|
||||
ModDimensions.LIMBO_DIMENSION = server.getWorld(LIMBO);
|
||||
ModDimensions.PERSONAL_POCKET_DIMENSION = server.getWorld(PERSONAL);
|
||||
ModDimensions.PUBLIC_POCKET_DIMENSION = server.getWorld(PUBLIC);
|
||||
ModDimensions.DUNGEON_POCKET_DIMENSION = server.getWorld(DUNGEON);
|
||||
});
|
||||
Registry.register(Registry.CHUNK_GENERATOR, new Identifier("dimdoors", "blank"), BlankChunkGenerator.CODEC);
|
||||
Registry.register(Registry.CHUNK_GENERATOR, new Identifier("dimdoors", "limbo_chunk_generator"), LimboChunkGenerator.CODEC);
|
||||
Registry.register(Registry.BIOME_SOURCE, new Identifier("dimdoors", "limbo_biome_source"), LimboBiomeSource.CODEC);
|
||||
}
|
||||
|
||||
static {
|
||||
StructuresConfig limboStructuresConfig = new StructuresConfig(Optional.of(StructuresConfig.DEFAULT_STRONGHOLD), ImmutableMap.of());
|
||||
GenerationShapeConfig limboShapeConfig = new GenerationShapeConfig(128, new NoiseSamplingConfig(0.94213419649817745, 1.102539814507745, 80, 120), new SlideConfig(-1, 3, 0), new SlideConfig(60, 2, 2), 2, 4, 1, -0.16875, true, true, true, true);
|
||||
LIMBO_CHUNK_GENERATOR_SETTINGS = ChunkGeneratorSettingsAccessor.invokeInit(limboStructuresConfig, limboShapeConfig, ModBlocks.UNRAVELLED_FABRIC.getDefaultState(), ModBlocks.ETERNAL_FLUID.getDefaultState(), 5, -1, 8, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.mojang.serialization.Codec;
|
|||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import org.dimdev.dimdoors.block.ModBlocks;
|
||||
import org.dimdev.dimdoors.mixin.ChunkGeneratorAccessor;
|
||||
import org.dimdev.dimdoors.world.ModDimensions;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -58,8 +59,6 @@ public class LimboChunkGenerator extends ChunkGenerator {
|
|||
public static final Codec<LimboChunkGenerator> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
return instance.group(BiomeSource.CODEC.fieldOf("biome_source").forGetter((chunkGenerator) -> {
|
||||
return chunkGenerator.biomeSource;
|
||||
}), ChunkGeneratorSettings.REGISTRY_CODEC.fieldOf("settings").forGetter((chunkGenerator) -> {
|
||||
return chunkGenerator.settings;
|
||||
})).apply(instance, instance.stable(LimboChunkGenerator::new));
|
||||
});
|
||||
private static final float[] NOISE_WEIGHT_TABLE = Util.make(new float[13824], (array) -> {
|
||||
|
@ -99,15 +98,15 @@ public class LimboChunkGenerator extends ChunkGenerator {
|
|||
private final long worldSeed;
|
||||
private final int worldHeight;
|
||||
|
||||
public LimboChunkGenerator(BiomeSource biomeSource, Supplier<ChunkGeneratorSettings> supplier) {
|
||||
this(biomeSource, biomeSource, supplier);
|
||||
public LimboChunkGenerator(BiomeSource biomeSource) {
|
||||
this(biomeSource, biomeSource);
|
||||
}
|
||||
|
||||
private LimboChunkGenerator(BiomeSource biomeSource, BiomeSource biomeSource2, Supplier<ChunkGeneratorSettings> supplier) {
|
||||
super(biomeSource, biomeSource2, supplier.get().getStructuresConfig(), new Random().nextLong());
|
||||
private LimboChunkGenerator(BiomeSource biomeSource, BiomeSource biomeSource2) {
|
||||
super(biomeSource, biomeSource2, ModDimensions.LIMBO_CHUNK_GENERATOR_SETTINGS.getStructuresConfig(), new Random().nextLong());
|
||||
this.worldSeed = ((ChunkGeneratorAccessor) this).getWorldSeed();
|
||||
ChunkGeneratorSettings chunkGeneratorSettings = supplier.get();
|
||||
this.settings = supplier;
|
||||
ChunkGeneratorSettings chunkGeneratorSettings = ModDimensions.LIMBO_CHUNK_GENERATOR_SETTINGS;
|
||||
this.settings = () -> ModDimensions.LIMBO_CHUNK_GENERATOR_SETTINGS;
|
||||
GenerationShapeConfig generationShapeConfig = chunkGeneratorSettings.getGenerationShapeConfig();
|
||||
this.worldHeight = generationShapeConfig.getHeight();
|
||||
this.verticalNoiseResolution = generationShapeConfig.getSizeVertical() * 4;
|
||||
|
@ -164,7 +163,7 @@ public class LimboChunkGenerator extends ChunkGenerator {
|
|||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public ChunkGenerator withSeed(long seed) {
|
||||
return new LimboChunkGenerator(this.biomeSource.withSeed(seed), this.settings);
|
||||
return new LimboChunkGenerator(this.biomeSource.withSeed(seed));
|
||||
}
|
||||
|
||||
private double sampleNoise(int x, int y, int z, double horizontalScale, double verticalScale, double horizontalStretch, double verticalStretch) {
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
"size_vertical": 4,
|
||||
"height": 128,
|
||||
"sampling": {
|
||||
"xz_scale": 0.9999999814507745,
|
||||
"y_scale": 1.502539814507745,
|
||||
"xz_scale": 0.94213419649817745,
|
||||
"y_scale": 1.102539814507745,
|
||||
"xz_factor": 80,
|
||||
"y_factor": 120
|
||||
},
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"mixins": [
|
||||
"BuiltinBiomesAccessor",
|
||||
"ChunkGeneratorAccessor",
|
||||
"ChunkGeneratorSettingsAccessor",
|
||||
"DefaultBiomeFeaturesMixin",
|
||||
"DimensionTypeAccessor",
|
||||
"DirectionAccessor",
|
||||
|
|
Loading…
Reference in a new issue