some fixes

This commit is contained in:
Zoë
2022-08-22 22:41:26 -05:00
parent 9aa124605c
commit 08df8b1652
5 changed files with 23 additions and 29 deletions

View File

@@ -22,6 +22,7 @@ import ca.solostudios.strata.version.Version;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.event.events.PackEvent;
import com.dfsek.terra.mod.config.VanillaWorldProperties;
import com.dfsek.terra.mod.util.MinecraftUtil;
@@ -53,12 +54,8 @@ public abstract class MinecraftAddon implements BaseAddon {
public void initialize() {
modPlatform.getEventManager()
.getHandler(FunctionalEventHandler.class)
.register(this, ConfigurationLoadEvent.class)
.then(event -> {
if(event.is(ConfigPack.class)) {
event.getLoadedObject(ConfigPack.class).getContext().put(event.load(new VanillaWorldProperties()));
}
})
.register(this, ConfigPackPreLoadEvent.class)
.then(event -> event.loadTemplate(new VanillaWorldProperties()))
.global();
modPlatform.getEventManager()
.getHandler(FunctionalEventHandler.class)

View File

@@ -51,7 +51,7 @@ public class VanillaWorldProperties implements ConfigTemplate, Properties {
@Default
private Boolean respawnAnchorWorks = false;
@Value("minecraft.height")
@Value("minecraft.height.range")
@Default
private Range height = new ConstantRange(0, 16);

View File

@@ -41,12 +41,18 @@ public class BiomeUtil {
logger.info("Terra biomes registered.");
}
public static RegistryKey<net.minecraft.world.biome.Biome> registerKey(Identifier identifier) {
return RegistryKey.of(Registry.BIOME_KEY, identifier);
}
protected static RegistryKey<net.minecraft.world.biome.Biome> registerBiome(Identifier identifier,
net.minecraft.world.biome.Biome biome) {
BuiltinRegistries.add(BuiltinRegistries.BIOME,
MinecraftUtil.registerKey(identifier)
.getValue(),
biome);
RegistryKey key = registerKey(identifier);
if(!BuiltinRegistries.BIOME.contains(key)) {
BuiltinRegistries.add(BuiltinRegistries.BIOME,
key.getValue(),
biome);
}
return getBiomeKey(identifier);
}
@@ -63,11 +69,7 @@ public class BiomeUtil {
protected static void registerBiome(Biome biome, ConfigPack pack,
com.dfsek.terra.api.registry.key.RegistryKey id) {
VanillaBiomeProperties vanillaBiomeProperties;
if (biome.getContext().has(VanillaBiomeProperties.class)) {
vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
} else {
vanillaBiomeProperties = new VanillaBiomeProperties();
}
vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(vanillaBiomeProperties);

View File

@@ -18,10 +18,13 @@ import java.util.OptionalLong;
public class DimensionUtil {
protected static RegistryKey<DimensionType> registerDimension(Identifier identifier,
DimensionType dimension) {
BuiltinRegistries.add(BuiltinRegistries.DIMENSION_TYPE,
registerKey(identifier)
.getValue(),
dimension);
RegistryKey key = registerKey(identifier);
if(!BuiltinRegistries.BIOME.contains(key)) {
BuiltinRegistries.add(BuiltinRegistries.DIMENSION_TYPE,
key
.getValue(),
dimension);
}
return getDimensionKey(identifier);
}
@@ -34,11 +37,7 @@ public class DimensionUtil {
protected static RegistryKey<DimensionType> registerDimension(ConfigPack pack) {
VanillaWorldProperties vanillaWorldProperties;
if (pack.getContext().has(VanillaBiomeProperties.class)) {
vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class);
} else {
vanillaWorldProperties = new VanillaWorldProperties();
}
vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class);
DimensionType overworldDimensionType = new DimensionType(
vanillaWorldProperties.getFixedTime() == null ? OptionalLong.empty() : OptionalLong.of(vanillaWorldProperties.getFixedTime()),

View File

@@ -69,10 +69,6 @@ public final class MinecraftUtil {
TerraIntProvider.TERRA_RANGE_TYPE_TO_INT_PROVIDER_TYPE.put(ConstantRange.class, CONSTANT);
}
public static RegistryKey<Biome> registerKey(Identifier identifier) {
return RegistryKey.of(Registry.BIOME_KEY, identifier);
}
public static Biome createBiome(VanillaBiomeProperties vanillaBiomeProperties) {
GenerationSettings.Builder generationSettings = new GenerationSettings.Builder();