Change StructureFeatures in WorldData
This commit is contained in:
parent
0594b9f420
commit
49a47de5f8
2 changed files with 26 additions and 3 deletions
|
@ -52,6 +52,7 @@ import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.StructureFeatureConfiguration;
|
import net.minecraft.world.level.levelgen.feature.configurations.StructureFeatureConfiguration;
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||||
|
import net.minecraft.world.level.storage.WorldData;
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.bclib.BCLib;
|
import ru.bclib.BCLib;
|
||||||
|
@ -170,6 +171,19 @@ public class BiomeAPI {
|
||||||
worldSources.add(source);
|
worldSources.add(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static WorldData worldData;
|
||||||
|
public static void registerWorldData(WorldData w){
|
||||||
|
worldData = w;
|
||||||
|
if (worldData!=null){
|
||||||
|
|
||||||
|
worldData.worldGenSettings().dimensions().forEach(dim->{
|
||||||
|
StructureSettingsAccessor a = (StructureSettingsAccessor)dim.generator().getSettings();
|
||||||
|
STRUCTURE_STARTS.entrySet().forEach(entry -> applyStructureStarts(a, entry.getValue()));
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For internal use only.
|
* For internal use only.
|
||||||
*
|
*
|
||||||
|
@ -894,7 +908,7 @@ public class BiomeAPI {
|
||||||
|
|
||||||
//add back modded structures
|
//add back modded structures
|
||||||
StructureSettingsAccessor a = (StructureSettingsAccessor)settings.structureSettings();
|
StructureSettingsAccessor a = (StructureSettingsAccessor)settings.structureSettings();
|
||||||
STRUCTURE_STARTS.entrySet().forEach(entry -> changeStructureStarts(a, entry.getValue()));
|
STRUCTURE_STARTS.entrySet().forEach(entry -> applyStructureStarts(a, entry.getValue()));
|
||||||
|
|
||||||
//add surface rules
|
//add surface rules
|
||||||
registerNoiseGeneratorAndChangeSurfaceRules(settings);
|
registerNoiseGeneratorAndChangeSurfaceRules(settings);
|
||||||
|
@ -931,12 +945,19 @@ public class BiomeAPI {
|
||||||
|
|
||||||
for (Map.Entry<ResourceKey<NoiseGeneratorSettings>, NoiseGeneratorSettings> entry : chunkGenSettingsRegistry.entrySet()) {
|
for (Map.Entry<ResourceKey<NoiseGeneratorSettings>, NoiseGeneratorSettings> entry : chunkGenSettingsRegistry.entrySet()) {
|
||||||
final StructureSettingsAccessor access = (StructureSettingsAccessor) entry.getValue().structureSettings();
|
final StructureSettingsAccessor access = (StructureSettingsAccessor) entry.getValue().structureSettings();
|
||||||
changeStructureStarts(access, modifier);
|
applyStructureStarts(access, modifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldData!=null){
|
||||||
|
worldData.worldGenSettings().dimensions().forEach(dim->{
|
||||||
|
StructureSettingsAccessor access = (StructureSettingsAccessor)dim.generator().getSettings();
|
||||||
|
applyStructureStarts(access, modifier);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void changeStructureStarts(StructureSettingsAccessor access, BiConsumer<Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>>, Map<StructureFeature<?>, StructureFeatureConfiguration>> modifier) {
|
private static void applyStructureStarts(StructureSettingsAccessor access, BiConsumer<Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>>, Map<StructureFeature<?>, StructureFeatureConfiguration>> modifier) {
|
||||||
Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> structureMap;
|
Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> structureMap;
|
||||||
Map<StructureFeature<?>, StructureFeatureConfiguration> configMap;
|
Map<StructureFeature<?>, StructureFeatureConfiguration> configMap;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import ru.bclib.BCLib;
|
import ru.bclib.BCLib;
|
||||||
|
import ru.bclib.api.biomes.BiomeAPI;
|
||||||
import ru.bclib.api.dataexchange.DataExchangeAPI;
|
import ru.bclib.api.dataexchange.DataExchangeAPI;
|
||||||
import ru.bclib.recipes.BCLRecipeManager;
|
import ru.bclib.recipes.BCLRecipeManager;
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ public class MinecraftServerMixin {
|
||||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||||
private void bclib_onServerInit(Thread thread, RegistryHolder registryHolder, LevelStorageAccess levelStorageAccess, WorldData worldData, PackRepository packRepository, Proxy proxy, DataFixer dataFixer, ServerResources serverResources, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, GameProfileCache gameProfileCache, ChunkProgressListenerFactory chunkProgressListenerFactory, CallbackInfo ci) {
|
private void bclib_onServerInit(Thread thread, RegistryHolder registryHolder, LevelStorageAccess levelStorageAccess, WorldData worldData, PackRepository packRepository, Proxy proxy, DataFixer dataFixer, ServerResources serverResources, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, GameProfileCache gameProfileCache, ChunkProgressListenerFactory chunkProgressListenerFactory, CallbackInfo ci) {
|
||||||
DataExchangeAPI.prepareServerside();
|
DataExchangeAPI.prepareServerside();
|
||||||
|
BiomeAPI.registerWorldData(worldData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true)
|
@Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue