more wip changes

This commit is contained in:
Zoë Gidiere 2023-12-12 15:48:31 -07:00
parent e11a235386
commit 033181d7c8
6 changed files with 147 additions and 115 deletions

View File

@ -0,0 +1,53 @@
package com.dfsek.terra.mod.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import com.dfsek.terra.api.util.Range;
import com.dfsek.terra.mod.implmentation.TerraIntProvider;
import net.minecraft.world.dimension.DimensionType.MonsterSettings;
public class MonsterSettingsConfig implements ObjectTemplate<MonsterSettingsConfig> {
@Value("piglin-safe")
@Default
private Boolean piglinSafe = null;
@Value("has-raids")
@Default
private Boolean hasRaids = null;
@Value("monster-spawn-light")
@Default
private Range monsterSpawnLight = null;
@Value("monster-spawn-block-light-limit")
@Default
private Integer monsterSpawnBlockLightLimit = null;
public Boolean getPiglinSafe() {
return piglinSafe;
}
public Boolean getHasRaids() {
return hasRaids;
}
public Range getMonsterSpawnLight() {
return monsterSpawnLight;
}
public Integer getMonsterSpawnBlockLightLimit() {
return monsterSpawnBlockLightLimit;
}
@Override
public MonsterSettingsConfig get() {
return this;
}
}

View File

@ -1,38 +0,0 @@
package com.dfsek.terra.mod.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import com.dfsek.terra.api.util.ConstantRange;
import com.dfsek.terra.api.util.Range;
import com.dfsek.terra.mod.implmentation.TerraIntProvider;
import net.minecraft.world.dimension.DimensionType.MonsterSettings;
public class MonsterSettingsTemplate implements ObjectTemplate<MonsterSettings> {
@Value("piglin-safe")
@Default
private Boolean piglinSafe = false;
@Value("has-raids")
@Default
private Boolean hasRaids = false;
@Value("monster-spawn-light")
@Default
private Range monsterSpawnLight = new ConstantRange(0, 1);
@Value("monster-spawn-block-light-limit")
@Default
private int monsterSpawnBlockLightLimit = 0;
@Override
public MonsterSettings get() {
return new MonsterSettings(piglinSafe, hasRaids, new TerraIntProvider(monsterSpawnLight), monsterSpawnBlockLightLimit);
}
}

View File

@ -19,65 +19,75 @@ import com.dfsek.terra.api.util.Range;
public class VanillaWorldProperties implements ConfigTemplate, Properties { public class VanillaWorldProperties implements ConfigTemplate, Properties {
@Value("vanilla")
@Default
private String vanillaDimension = "minecraft:overworld";
@Value("minecraft.fixed-time") @Value("minecraft.fixed-time")
@Default @Default
private Long fixedTime = null; private Long fixedTime = null;
@Value("minecraft.has-sky-light") @Value("minecraft.has-sky-light")
@Default @Default
private Boolean hasSkyLight = false; private Boolean hasSkyLight = null;
@Value("minecraft.has-ceiling") @Value("minecraft.has-ceiling")
@Default @Default
private Boolean hasCeiling = false; private Boolean hasCeiling = null;
@Value("minecraft.ultra-warm") @Value("minecraft.ultra-warm")
@Default @Default
private Boolean ultraWarm = false; private Boolean ultraWarm = null;
@Value("minecraft.natural") @Value("minecraft.natural")
@Default @Default
private Boolean natural = false; private Boolean natural = null;
@Value("minecraft.coordinate-scale") @Value("minecraft.coordinate-scale")
@Default @Default
private Double coordinateScale = 1.0E-5d; private Double coordinateScale = null;
@Value("minecraft.bed-works") @Value("minecraft.bed-works")
@Default @Default
private Boolean bedWorks = false; private Boolean bedWorks = null;
@Value("minecraft.respawn-anchor-works") @Value("minecraft.respawn-anchor-works")
@Default @Default
private Boolean respawnAnchorWorks = false; private Boolean respawnAnchorWorks = null;
@Value("minecraft.height") @Value("minecraft.height")
@Default @Default
private Range height = new ConstantRange(0, 16); private Range height = null;
@Value("minecraft.height.logical") @Value("minecraft.height.logical")
@Default @Default
private Integer logicalHeight = 0; private Integer logicalHeight = null;
@Value("minecraft.infiniburn") @Value("minecraft.infiniburn")
@Default @Default
private Identifier infiniburn = new Identifier(""); private Identifier infiniburn = null;
@Value("minecraft.effects") @Value("minecraft.effects")
@Default @Default
private Identifier effects = new Identifier(""); private Identifier effects = null;
@Value("minecraft.ambient-light") @Value("minecraft.ambient-light")
@Default @Default
private Float ambientLight = Float.MAX_VALUE; private Float ambientLight = null;
@Value("minecraft.monster-settings") @Value("minecraft.monster-settings")
@Default @Default
private MonsterSettings monsterSettings = new MonsterSettings(false, false, new TerraIntProvider(new ConstantRange(0, 1)), 0); private MonsterSettingsConfig monsterSettings = null;
@Value("minecraft.sealevel") @Value("minecraft.sealevel")
@Default @Default
private Integer sealevel = 0; private Integer sealevel = 62; //TODO AUTO PULL DEFAULT
public String getVanillaDimension() {
return vanillaDimension;
}
public Long getFixedTime() { public Long getFixedTime() {
return fixedTime; return fixedTime;
@ -131,7 +141,7 @@ public class VanillaWorldProperties implements ConfigTemplate, Properties {
return ambientLight; return ambientLight;
} }
public MonsterSettings getMonsterSettings() { public MonsterSettingsConfig getMonsterSettings() {
return monsterSettings; return monsterSettings;
} }

View File

@ -1,62 +1,85 @@
package com.dfsek.terra.mod.util; package com.dfsek.terra.mod.util;
import com.dfsek.terra.api.config.ConfigPack; import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.mod.ModPlatform;
import com.dfsek.terra.mod.config.MonsterSettingsConfig;
import com.dfsek.terra.mod.config.VanillaBiomeProperties; import com.dfsek.terra.mod.config.VanillaBiomeProperties;
import com.dfsek.terra.mod.config.VanillaWorldProperties; import com.dfsek.terra.mod.config.VanillaWorldProperties;
import net.minecraft.tag.TagKey; import com.dfsek.terra.mod.implmentation.TerraIntProvider;
import net.minecraft.registry.BuiltinRegistries;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier; 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.dimension.DimensionOptions; import net.minecraft.world.dimension.DimensionOptions;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.dimension.DimensionType.MonsterSettings;
import org.jetbrains.annotations.NotNull;
import java.util.OptionalLong; import java.util.OptionalLong;
public class DimensionUtil { public class DimensionUtil {
protected static RegistryKey<DimensionType> registerDimension(Identifier identifier, public static DimensionType createDimension(ConfigPack pack, ModPlatform platform) {
DimensionType dimension) {
BuiltinRegistries.add(BuiltinRegistries.DIMENSION_TYPE,
registerKey(identifier)
.getValue(),
dimension);
return getDimensionKey(identifier);
}
public static RegistryKey<DimensionOptions> registerKey(Identifier identifier) {
return RegistryKey.of(Registry.DIMENSION_KEY, identifier);
}
public static RegistryKey<DimensionType> getDimensionKey(Identifier identifier) {
return BuiltinRegistries.DIMENSION_TYPE.getKey(BuiltinRegistries.DIMENSION_TYPE.get(identifier)).orElseThrow();
}
protected static RegistryKey<DimensionType> registerDimension(ConfigPack pack) {
VanillaWorldProperties vanillaWorldProperties; VanillaWorldProperties vanillaWorldProperties;
MonsterSettingsConfig monsterSettingsConfig;
if (pack.getContext().has(VanillaBiomeProperties.class)) { if (pack.getContext().has(VanillaBiomeProperties.class)) {
vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class); vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class);
} else { } else {
vanillaWorldProperties = new VanillaWorldProperties(); vanillaWorldProperties = new VanillaWorldProperties();
} }
if (vanillaWorldProperties.getMonsterSettings() != null) {
monsterSettingsConfig = vanillaWorldProperties.getMonsterSettings();
} else {
monsterSettingsConfig = new MonsterSettingsConfig();
}
DimensionType overworldDimensionType = new DimensionType( Registry<DimensionType> dimensionTypeRegistry = platform.dimensionTypeRegistry();
vanillaWorldProperties.getFixedTime() == null ? OptionalLong.empty() : OptionalLong.of(vanillaWorldProperties.getFixedTime()),
vanillaWorldProperties.getHasSkyLight(),
vanillaWorldProperties.getHasCeiling(),
vanillaWorldProperties.getUltraWarm(),
vanillaWorldProperties.getNatural(),
vanillaWorldProperties.getCoordinateScale(),
vanillaWorldProperties.getBedWorks(),
vanillaWorldProperties.getRespawnAnchorWorks(),
vanillaWorldProperties.getHeight().getMin(),
vanillaWorldProperties.getHeight().getMax(),
vanillaWorldProperties.getLogicalHeight(),
TagKey.of(Registry.BLOCK_KEY, vanillaWorldProperties.getInfiniburn()),
vanillaWorldProperties.getEffects(),
vanillaWorldProperties.getAmbientLight(),
vanillaWorldProperties.getMonsterSettings());
return registerDimension(new Identifier("terra", pack.getID().toLowerCase()), overworldDimensionType); DimensionType defaultDimension = dimensionTypeRegistry.get(new Identifier(vanillaWorldProperties.getVanillaDimension()));
assert defaultDimension != null;
MonsterSettings monsterSettings = getMonsterSettings(defaultDimension, monsterSettingsConfig);
DimensionType dimension = new DimensionType(
vanillaWorldProperties.getFixedTime() == null ? defaultDimension.fixedTime() : OptionalLong.of(
vanillaWorldProperties.getFixedTime()),
vanillaWorldProperties.getHasSkyLight() == null ? defaultDimension.hasSkyLight() : vanillaWorldProperties.getHasSkyLight(),
vanillaWorldProperties.getHasCeiling() == null ? defaultDimension.hasCeiling() : vanillaWorldProperties.getHasCeiling(),
vanillaWorldProperties.getUltraWarm() == null ? defaultDimension.ultrawarm() : vanillaWorldProperties.getUltraWarm(),
vanillaWorldProperties.getNatural() == null ? defaultDimension.natural() : vanillaWorldProperties.getNatural(),
vanillaWorldProperties.getCoordinateScale() == null ? defaultDimension.coordinateScale() : vanillaWorldProperties.getCoordinateScale(),
vanillaWorldProperties.getBedWorks() == null ? defaultDimension.bedWorks() : vanillaWorldProperties.getBedWorks(),
vanillaWorldProperties.getRespawnAnchorWorks() == null ? defaultDimension.respawnAnchorWorks() : vanillaWorldProperties.getRespawnAnchorWorks(),
vanillaWorldProperties.getHeight() == null ? defaultDimension.minY() : vanillaWorldProperties.getHeight().getMin(),
vanillaWorldProperties.getHeight() == null ? defaultDimension.height() : vanillaWorldProperties.getHeight().getMax(),
vanillaWorldProperties.getLogicalHeight() == null ? defaultDimension.logicalHeight() : vanillaWorldProperties.getLogicalHeight(),
vanillaWorldProperties.getInfiniburn() == null ? defaultDimension.infiniburn() : TagKey.of(RegistryKeys.BLOCK, vanillaWorldProperties.getInfiniburn()),
vanillaWorldProperties.getEffects() == null ? defaultDimension.effects() : vanillaWorldProperties.getEffects(),
vanillaWorldProperties.getAmbientLight() == null ? defaultDimension.ambientLight() : vanillaWorldProperties.getAmbientLight(),
monsterSettings
);
return dimension;
}
@NotNull
private static MonsterSettings getMonsterSettings(DimensionType defaultDimension, MonsterSettingsConfig monsterSettingsConfig) {
MonsterSettings defaultMonsterSettings = defaultDimension.monsterSettings();
MonsterSettings monsterSettings = new MonsterSettings(
monsterSettingsConfig.getPiglinSafe() == null ? defaultMonsterSettings.piglinSafe() : monsterSettingsConfig.getPiglinSafe(),
monsterSettingsConfig.getHasRaids() == null ? defaultMonsterSettings.hasRaids() : monsterSettingsConfig.getHasRaids(),
monsterSettingsConfig.getMonsterSpawnLight() == null ? defaultMonsterSettings.monsterSpawnLightTest() : new TerraIntProvider(
monsterSettingsConfig.getMonsterSpawnLight()),
monsterSettingsConfig.getMonsterSpawnBlockLightLimit() == null ? defaultMonsterSettings.monsterSpawnBlockLightLimit() : monsterSettingsConfig.getMonsterSpawnBlockLightLimit()
);
return monsterSettings;
} }
} }

View File

@ -15,16 +15,14 @@ import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.intprovider.ConstantIntProvider;
import net.minecraft.util.math.intprovider.IntProviderType; import net.minecraft.util.math.intprovider.IntProviderType;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.Builder; import net.minecraft.world.biome.Biome.Builder;
import net.minecraft.world.biome.BiomeEffects; import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.biome.BiomeEffects.GrassColorModifier;
import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredFeature;
import org.slf4j.Logger; import org.slf4j.Logger;

View File

@ -4,17 +4,7 @@ import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.client.gui.screen.CustomizeBuffetLevelScreen;
import net.minecraft.client.gui.screen.CustomizeFlatLevelScreen;
import net.minecraft.client.gui.screen.world.LevelScreenProvider;
import net.minecraft.structure.StructureSet;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.noise.DoublePerlinNoiseSampler.NoiseParameters;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.DynamicRegistryManager;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.DimensionOptions; import net.minecraft.world.dimension.DimensionOptions;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.dimension.DimensionType;
@ -75,10 +65,6 @@ public class PresetUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(PresetUtil.class); private static final Logger LOGGER = LoggerFactory.getLogger(PresetUtil.class);
private static final List<Identifier> PRESETS = new ArrayList<>(); private static final List<Identifier> PRESETS = new ArrayList<>();
public static RegistryKey<WorldPreset> getPresetKey(Identifier identifier) {
return RegistryKey.of(Registry.WORLD_PRESET_KEY, identifier);
}
public static Pair<Identifier, WorldPreset> createDefault(ConfigPack pack, ModPlatform platform) { public static Pair<Identifier, WorldPreset> createDefault(ConfigPack pack, ModPlatform platform) {
Registry<DimensionType> dimensionTypeRegistry = platform.dimensionTypeRegistry(); Registry<DimensionType> dimensionTypeRegistry = platform.dimensionTypeRegistry();
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = platform.chunkGeneratorSettingsRegistry(); Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = platform.chunkGeneratorSettingsRegistry();
@ -127,7 +113,7 @@ public class PresetUtil {
metaPack.packs().forEach((key, pack) -> { metaPack.packs().forEach((key, pack) -> {
Identifier demensionIdentifier = new Identifier(key); Identifier demensionIdentifier = new Identifier(key);
DimensionType dimensionType = dimensionTypeRegistry.get(demensionIdentifier); DimensionType dimensionType = DimensionUtil.createDimension(pack, platform);
RegistryEntry<DimensionType> dimensionTypeRegistryEntry = dimensionTypeRegistry.getEntry(dimensionType); RegistryEntry<DimensionType> dimensionTypeRegistryEntry = dimensionTypeRegistry.getEntry(dimensionType);
TerraBiomeSource biomeSource = new TerraBiomeSource(pack); TerraBiomeSource biomeSource = new TerraBiomeSource(pack);