Skip to content

Commit

Permalink
push changes
Browse files Browse the repository at this point in the history
  • Loading branch information
duplexsystem committed Dec 21, 2023
1 parent 27a967f commit 50ba1c6
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.dfsek.tectonic.api.exception.LoadException;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.boss.dragon.EnderDragonFight;
import net.minecraft.registry.Registry;
import net.minecraft.server.MinecraftServer;
import net.minecraft.sound.BiomeAdditionsSound;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ public class VanillaWorldProperties implements ConfigTemplate, Properties {

@Value("minecraft.sealevel")
@Default
private Integer sealevel = 62; //TODO AUTO PULL DEFAULT
private Integer sealevel = null;

@Value("minecraft.spawn-height")
@Default
private Integer spawnHeight = 64;

public String getVanillaDimension() {
return vanillaDimension;
Expand Down Expand Up @@ -160,4 +164,8 @@ public Boolean getMobGeneration() {
public Integer getSealevel() {
return sealevel;
}

public Integer getSpawnHeight() {
return spawnHeight;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public final class Codecs {
public static final Codec<GenerationSettings> TERRA_GENERATION_SETTINGS = RecordCodecBuilder
.create(instance -> instance.group(
TERRA_CONSTANT_RANGE.fieldOf("height").stable().forGetter(GenerationSettings::height),
Codec.INT.fieldOf("sealevel").forGetter(GenerationSettings::sealevel),
Codec.BOOL.fieldOf("mob_generation").forGetter(GenerationSettings::mobGeneration))
Codec.INT.fieldOf("sea_level").forGetter(GenerationSettings::sealevel),
Codec.BOOL.fieldOf("mob_generation").forGetter(GenerationSettings::mobGeneration),
Codec.INT.fieldOf("spawn_height").forGetter(GenerationSettings::sealevel))
.apply(instance, instance.stable(GenerationSettings::new)));


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import com.dfsek.terra.api.util.ConstantRange;


public record GenerationSettings(ConstantRange height, Integer sealevel, Boolean mobGeneration) {
public record GenerationSettings(ConstantRange height, Integer sealevel, Boolean mobGeneration, Integer spawnHeight) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeAccess;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.dimension.NetherPortal;
import net.minecraft.world.gen.GenerationStep.Carver;
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.StructureWeightSampler;
Expand Down Expand Up @@ -105,12 +106,6 @@ public void populateEntities(ChunkRegion region) {
}
}

@Override
public int getWorldHeight() {
return settings.height().getRange();
}


@Override
public CompletableFuture<Chunk> populateNoise(Executor executor, Blender blender, NoiseConfig noiseConfig,
StructureAccessor structureAccessor, Chunk chunk) {
Expand Down Expand Up @@ -165,6 +160,11 @@ public void generateFeatures(StructureWorldAccess world, Chunk chunk, StructureA
});
}

@Override
public int getWorldHeight() {
return settings.height().getRange();
}

@Override
public int getSeaLevel() {
return settings.sealevel();
Expand All @@ -175,6 +175,11 @@ public int getMinimumY() {
return settings.height().getMin();
}

@Override
public int getSpawnHeight(HeightLimitView world) {
return settings.spawnHeight();
}

@Override
public int getHeight(int x, int z, Type heightmap, HeightLimitView height, NoiseConfig noiseConfig) {
WorldProperties properties = MinecraftAdapter.adapt(height, SeedHack.getSeed(noiseConfig.getMultiNoiseSampler()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.dfsek.terra.mod.mixin.generalize;


import net.minecraft.block.entity.SignText;
import net.minecraft.client.render.DimensionEffects;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.WorldGenerationProgressListener;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.random.RandomSequencesState;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.village.raid.RaidManager;
import net.minecraft.world.MutableWorldProperties;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionOptions;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.dimension.DimensionTypes;
import net.minecraft.world.level.ServerWorldProperties;
import net.minecraft.world.level.storage.LevelStorage;
import net.minecraft.world.level.storage.LevelStorage.Session;
import net.minecraft.world.spawner.SpecialSpawner;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import java.util.List;
import java.util.concurrent.Executor;
import java.util.function.Supplier;


@Mixin(ServerWorld.class)
public abstract class ServerWorldMixin extends World {
protected ServerWorldMixin(MutableWorldProperties properties, RegistryKey<World> registryRef, DynamicRegistryManager registryManager,
RegistryEntry<DimensionType> dimensionEntry, Supplier<Profiler> profiler, boolean isClient,
boolean debugWorld, long biomeAccess, int maxChainedNeighborUpdates) {
super(properties, registryRef, registryManager, dimensionEntry, profiler, isClient, debugWorld, biomeAccess,
maxChainedNeighborUpdates);
}

@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/registry/entry/RegistryEntry;matchesKey(Lnet/minecraft/registry/RegistryKey;)Z"))
public <T> boolean matchesKeyProxy(RegistryEntry<T> instance, RegistryKey<T> tRegistryKey) {
if (tRegistryKey == DimensionTypes.THE_END) {
return (this.getRegistryKey() == World.END);
}
return instance.matchesKey(tRegistryKey);
}

@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/village/raid/RaidManager;nameFor(Lnet/minecraft/registry/entry/RegistryEntry;)Ljava/lang/String;"))
public String nameForProxy(RegistryEntry<DimensionType> dimensionTypeEntry) {
RegistryEntry<DimensionType> entry = dimensionTypeEntry;
if (this.getRegistryKey() == World.END) {
entry = getRegistryManager().get(RegistryKeys.DIMENSION_TYPE).getEntry(DimensionTypes.THE_NETHER).orElseThrow();
}
return RaidManager.nameFor(entry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ private static void insertCustom(ModPlatform platform, String key, ConfigPack pa
: vanillaWorldProperties.getSealevel(),
vanillaWorldProperties.getMobGeneration() == null
? !defaultGeneratorSettings.value().mobGenerationDisabled()
: vanillaWorldProperties.getMobGeneration());
: vanillaWorldProperties.getMobGeneration(),
vanillaWorldProperties.getSpawnHeight());

ChunkGenerator generator = new MinecraftChunkGeneratorWrapper(biomeSource, pack, generatorSettings);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static <T> Map<TagKey<T>, List<RegistryEntry<T>>> tagsToMutableMap(Regis
}

public static void registerWorldPresetTags(Registry<WorldPreset> registry) {
logger.info("Doing preset tag garbage....");
logger.info("Registering Preset Tags.");
Map<TagKey<WorldPreset>, List<RegistryEntry<WorldPreset>>> collect = tagsToMutableMap(registry);

PresetUtil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"access.StructureAccessorAccessor",
"access.VillagerTypeAccessor",
"fix.BeeMoveGoalsUnsynchronizedRandomAccessFix",
"generalize.ServerWorldMixin",
"implementations.compat.GenerationSettingsFloraFeaturesMixin",
"implementations.terra.BiomeMixin",
"implementations.terra.HandleImplementationMixin",
Expand Down

0 comments on commit 50ba1c6

Please sign in to comment.