[Change] BCLBiomeRegistry
is used to populate Fabric Biomes
This commit is contained in:
parent
c4af9dfa0a
commit
48dd6a3274
2 changed files with 46 additions and 1 deletions
|
@ -16,11 +16,16 @@ import net.minecraft.util.KeyDispatchDataCodec;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.biome.Biomes;
|
import net.minecraft.world.level.biome.Biomes;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.biome.v1.NetherBiomes;
|
||||||
|
import net.fabricmc.fabric.api.biome.v1.TheEndBiomes;
|
||||||
|
import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback;
|
||||||
import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder;
|
import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder;
|
||||||
import net.fabricmc.fabric.api.event.registry.RegistryAttribute;
|
import net.fabricmc.fabric.api.event.registry.RegistryAttribute;
|
||||||
|
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
@ -200,4 +205,43 @@ public class BCLBiomeRegistry {
|
||||||
ctx.register(e.getKey(), e.getValue());
|
ctx.register(e.getKey(), e.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void onBiomeLoad(Registry<BCLBiome> registry, int rawID, ResourceLocation id, BCLBiome biome) {
|
||||||
|
//this ensures that all BCL Manage Biomes get added to the fabric Biome-API on load
|
||||||
|
if (!"minecraft".equals(id.getNamespace())) {
|
||||||
|
if (biome.getIntendedType().is(BiomeAPI.BiomeType.BCL_NETHER)) {
|
||||||
|
for (var params : biome.parameterPoints) {
|
||||||
|
NetherBiomes.addNetherBiome(biome.getBiomeKey(), params);
|
||||||
|
}
|
||||||
|
} else if (biome.getIntendedType().is(BiomeAPI.BiomeType.BCL_END_CENTER)) {
|
||||||
|
TheEndBiomes.addMainIslandBiome(biome.getBiomeKey(), 1.0);
|
||||||
|
} else if (biome.getIntendedType().is(BiomeAPI.BiomeType.BCL_END_BARRENS)) {
|
||||||
|
TheEndBiomes.addBarrensBiome(biome.getParentBiome().getBiomeKey(), biome.getBiomeKey(), 1.0);
|
||||||
|
} else if (biome.getIntendedType().is(BiomeAPI.BiomeType.BCL_END_LAND)) {
|
||||||
|
TheEndBiomes.addHighlandsBiome(biome.getBiomeKey(), 1.0);
|
||||||
|
TheEndBiomes.addMidlandsBiome(biome.getBiomeKey(), biome.getBiomeKey(), 1.0);
|
||||||
|
} else if (biome.getIntendedType().is(BiomeAPI.BiomeType.BCL_END_VOID)) {
|
||||||
|
TheEndBiomes.addSmallIslandsBiome(biome.getBiomeKey(), 1.0);
|
||||||
|
} else {
|
||||||
|
BCLib.LOGGER.info("Did not manage biome " + biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Loaded " + biome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
DynamicRegistrySetupCallback.EVENT.register(registryManager -> {
|
||||||
|
Optional<? extends Registry<BCLBiome>> oBCLBiomeRegistry = registryManager.asDynamicRegistryManager()
|
||||||
|
.registry(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
||||||
|
if (oBCLBiomeRegistry.isPresent()) {
|
||||||
|
final Registry<BCLBiome> registry = oBCLBiomeRegistry.orElseThrow();
|
||||||
|
RegistryEntryAddedCallback
|
||||||
|
.event(oBCLBiomeRegistry.get())
|
||||||
|
.register((rawId, loc, biome) -> BCLBiomeRegistry.onBiomeLoad(registry, rawId, loc, biome));
|
||||||
|
} else {
|
||||||
|
BCLib.LOGGER.warning("No valid BCLBiome Registry available!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,11 @@ public class RegistryDataLoaderMixin {
|
||||||
private static void wt_init(CallbackInfo ci) {
|
private static void wt_init(CallbackInfo ci) {
|
||||||
//we need this to ensure, that the BCL-Biome Registry is loaded at the correct time
|
//we need this to ensure, that the BCL-Biome Registry is loaded at the correct time
|
||||||
List<RegistryDataLoader.RegistryData<?>> enhanced = new ArrayList(RegistryDataLoader.WORLDGEN_REGISTRIES.size() + 1);
|
List<RegistryDataLoader.RegistryData<?>> enhanced = new ArrayList(RegistryDataLoader.WORLDGEN_REGISTRIES.size() + 1);
|
||||||
enhanced.addAll(RegistryDataLoader.WORLDGEN_REGISTRIES);
|
|
||||||
enhanced.add(new RegistryDataLoader.RegistryData<>(
|
enhanced.add(new RegistryDataLoader.RegistryData<>(
|
||||||
BCLBiomeRegistry.BCL_BIOMES_REGISTRY, BiomeData.CODEC
|
BCLBiomeRegistry.BCL_BIOMES_REGISTRY, BiomeData.CODEC
|
||||||
));
|
));
|
||||||
|
enhanced.addAll(RegistryDataLoader.WORLDGEN_REGISTRIES);
|
||||||
|
|
||||||
wt_set_WORLDGEN_REGISTRIES(enhanced);
|
wt_set_WORLDGEN_REGISTRIES(enhanced);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue