mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
apply vanilla biome flower feature supplier to terra biomes
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package com.dfsek.terra.fabric.mixin.access;
|
||||||
|
|
||||||
|
import net.minecraft.world.biome.GenerationSettings;
|
||||||
|
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Mutable;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
|
||||||
|
@Mixin(GenerationSettings.class)
|
||||||
|
public interface GenerationSettingsAccessor {
|
||||||
|
@Mutable
|
||||||
|
@Accessor("flowerFeatures")
|
||||||
|
void setFlowerFeatures(Supplier<List<ConfiguredFeature<?, ?>>> flowerFeatures);
|
||||||
|
|
||||||
|
@Accessor("flowerFeatures")
|
||||||
|
Supplier<List<ConfiguredFeature<?, ?>>> getFlowerFeaturesSupplier();
|
||||||
|
}
|
||||||
+4
-1
@@ -1,9 +1,11 @@
|
|||||||
package com.dfsek.terra.fabric.mixin.lifecycle;
|
package com.dfsek.terra.fabric.mixin.lifecycle;
|
||||||
|
|
||||||
|
import com.dfsek.terra.fabric.util.BiomeUtil;
|
||||||
import com.dfsek.terra.fabric.util.TagUtil;
|
import com.dfsek.terra.fabric.util.TagUtil;
|
||||||
import net.minecraft.server.DataPackContents;
|
import net.minecraft.server.DataPackContents;
|
||||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -17,6 +19,7 @@ public class DataPackContentsMixin {
|
|||||||
*/
|
*/
|
||||||
@Inject(method = "refresh(Lnet/minecraft/util/registry/DynamicRegistryManager;)V", at = @At("RETURN"))
|
@Inject(method = "refresh(Lnet/minecraft/util/registry/DynamicRegistryManager;)V", at = @At("RETURN"))
|
||||||
private void injectReload(DynamicRegistryManager dynamicRegistryManager, CallbackInfo ci) {
|
private void injectReload(DynamicRegistryManager dynamicRegistryManager, CallbackInfo ci) {
|
||||||
TagUtil.registerTags(dynamicRegistryManager.get(Registry.BIOME_KEY));
|
Registry<Biome> biomeRegistry = dynamicRegistryManager.get(Registry.BIOME_KEY);
|
||||||
|
TagUtil.registerTags(biomeRegistry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.dfsek.terra.api.world.biome.Biome;
|
|||||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||||
import com.dfsek.terra.fabric.config.PreLoadCompatibilityOptions;
|
import com.dfsek.terra.fabric.config.PreLoadCompatibilityOptions;
|
||||||
import com.dfsek.terra.fabric.config.VanillaBiomeProperties;
|
import com.dfsek.terra.fabric.config.VanillaBiomeProperties;
|
||||||
|
import com.dfsek.terra.fabric.mixin.access.GenerationSettingsAccessor;
|
||||||
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.BuiltinRegistries;
|
import net.minecraft.util.registry.BuiltinRegistries;
|
||||||
@@ -16,12 +17,7 @@ import net.minecraft.world.biome.GenerationSettings;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
|
|
||||||
public final class BiomeUtil {
|
public final class BiomeUtil {
|
||||||
@@ -137,12 +133,18 @@ public final class BiomeUtil {
|
|||||||
.category(vanilla.getCategory());
|
.category(vanilla.getCategory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GenerationSettings settings = generationSettings.build();
|
||||||
|
|
||||||
|
((GenerationSettingsAccessor) settings)
|
||||||
|
.setFlowerFeatures(((GenerationSettingsAccessor) vanilla.getGenerationSettings())
|
||||||
|
.getFlowerFeaturesSupplier());
|
||||||
|
|
||||||
return builder
|
return builder
|
||||||
.temperature(vanilla.getTemperature())
|
.temperature(vanilla.getTemperature())
|
||||||
.downfall(vanilla.getDownfall())
|
.downfall(vanilla.getDownfall())
|
||||||
.effects(effects.build())
|
.effects(effects.build())
|
||||||
.spawnSettings(vanilla.getSpawnSettings())
|
.spawnSettings(vanilla.getSpawnSettings())
|
||||||
.generationSettings(generationSettings.build())
|
.generationSettings(settings)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public final class TagUtil {
|
public final class TagUtil {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TagUtil.class);
|
private static final Logger logger = LoggerFactory.getLogger(TagUtil.class);
|
||||||
|
|
||||||
private TagUtil() {
|
private TagUtil() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -29,25 +30,45 @@ public final class TagUtil {
|
|||||||
map.put(pair.getFirst(), new ArrayList<>(pair.getSecond().stream().toList())),
|
map.put(pair.getFirst(), new ArrayList<>(pair.getSecond().stream().toList())),
|
||||||
HashMap::putAll);
|
HashMap::putAll);
|
||||||
|
|
||||||
BiomeUtil.getTerraBiomeMap().forEach((vb, terraBiomes) -> FabricUtil.getEntry(registry, vb)
|
BiomeUtil
|
||||||
.ifPresentOrElse(vanilla -> terraBiomes.forEach(tb -> FabricUtil.getEntry(registry, tb)
|
.getTerraBiomeMap()
|
||||||
|
.forEach((vb, terraBiomes) ->
|
||||||
|
FabricUtil.getEntry(registry, vb)
|
||||||
|
.ifPresentOrElse(vanilla -> terraBiomes
|
||||||
|
.forEach(tb -> FabricUtil
|
||||||
|
.getEntry(registry, tb)
|
||||||
.ifPresentOrElse(
|
.ifPresentOrElse(
|
||||||
terra -> {
|
terra -> {
|
||||||
logger.debug(vanilla.getKey().orElseThrow().getValue() + " (vanilla for " +
|
logger.debug(
|
||||||
terra.getKey().orElseThrow().getValue() + ": " +
|
vanilla.getKey()
|
||||||
vanilla.streamTags().toList());
|
.orElseThrow()
|
||||||
|
.getValue() +
|
||||||
|
" (vanilla for " +
|
||||||
|
terra.getKey()
|
||||||
|
.orElseThrow()
|
||||||
|
.getValue() +
|
||||||
|
": " +
|
||||||
|
vanilla.streamTags()
|
||||||
|
.toList());
|
||||||
|
|
||||||
vanilla.streamTags()
|
vanilla.streamTags()
|
||||||
.forEach(
|
.forEach(
|
||||||
tag -> collect
|
tag -> collect
|
||||||
.computeIfAbsent(tag, t -> new ArrayList<>())
|
.computeIfAbsent(
|
||||||
.add(FabricUtil.getEntry(registry,
|
tag,
|
||||||
|
t -> new ArrayList<>())
|
||||||
|
.add(FabricUtil
|
||||||
|
.getEntry(
|
||||||
|
registry,
|
||||||
terra.getKey()
|
terra.getKey()
|
||||||
.orElseThrow()
|
.orElseThrow()
|
||||||
.getValue()).orElseThrow()));
|
.getValue())
|
||||||
|
.orElseThrow()));
|
||||||
|
|
||||||
},
|
},
|
||||||
() -> logger.error("No such biome: {}", tb))),
|
() -> logger.error(
|
||||||
|
"No such biome: {}",
|
||||||
|
tb))),
|
||||||
() -> logger.error("No vanilla biome: {}", vb)));
|
() -> logger.error("No vanilla biome: {}", vb)));
|
||||||
|
|
||||||
registry.clearTags();
|
registry.clearTags();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"package": "com.dfsek.terra.fabric.mixin",
|
"package": "com.dfsek.terra.fabric.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"access.GenerationSettingsAccessor",
|
||||||
"access.MobSpawnerLogicAccessor",
|
"access.MobSpawnerLogicAccessor",
|
||||||
"access.StateAccessor",
|
"access.StateAccessor",
|
||||||
"access.StructureAccessorAccessor",
|
"access.StructureAccessorAccessor",
|
||||||
|
|||||||
Reference in New Issue
Block a user