Reverted changes to BiomeModification API
This commit is contained in:
parent
fb79201b51
commit
26fa4bb3fd
4 changed files with 9 additions and 75 deletions
|
@ -82,16 +82,7 @@ public class BiomeAPI {
|
||||||
* @param server - {@link MinecraftServer}
|
* @param server - {@link MinecraftServer}
|
||||||
*/
|
*/
|
||||||
public static void initRegistry(MinecraftServer server) {
|
public static void initRegistry(MinecraftServer server) {
|
||||||
initRegistry(server.registryAccess());
|
biomeRegistry = server.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize registry for current server.
|
|
||||||
*
|
|
||||||
* @param access - {@link RegistryAccess}
|
|
||||||
*/
|
|
||||||
public static void initRegistry(RegistryAccess access) {
|
|
||||||
biomeRegistry = access.registryOrThrow(Registry.BIOME_REGISTRY);
|
|
||||||
CLIENT.clear();
|
CLIENT.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,45 +392,14 @@ public class BiomeAPI {
|
||||||
* @param level
|
* @param level
|
||||||
*/
|
*/
|
||||||
public static void applyModifications(ServerLevel level) {
|
public static void applyModifications(ServerLevel level) {
|
||||||
BiomeSource source = level.getChunkSource().getGenerator().getBiomeSource();
|
List<BiConsumer<ResourceLocation, Biome>> modifications = MODIFICATIONS.get(level.dimension());
|
||||||
Set<Biome> biomes = source.possibleBiomes();
|
|
||||||
|
|
||||||
applyModifications(biomes, level.dimension());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Set<ResourceLocation> modifiedBiomes = new HashSet<>();
|
|
||||||
/**
|
|
||||||
* Will apply biome modifications to world, internal usage only.
|
|
||||||
* @param registryAccess
|
|
||||||
*/
|
|
||||||
public static void applyModifications(RegistryAccess registryAccess) {
|
|
||||||
Registry<Biome> biomeReg = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY);
|
|
||||||
Set<Biome> biomes = biomeReg
|
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.map(e -> e.getValue())
|
|
||||||
.filter(b -> modifiedBiomes.add(getBiomeID(b)))
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
applyModifications(
|
|
||||||
biomes.stream().filter(b->b.getBiomeCategory().equals(BiomeCategory.NETHER)).collect(Collectors.toSet()),
|
|
||||||
Level.NETHER
|
|
||||||
);
|
|
||||||
applyModifications(
|
|
||||||
biomes.stream().filter(b->!b.getBiomeCategory().equals(BiomeCategory.NETHER) && !b.getBiomeCategory().equals(BiomeCategory.THEEND)).collect(Collectors.toSet()),
|
|
||||||
Level.OVERWORLD
|
|
||||||
);
|
|
||||||
applyModifications(
|
|
||||||
biomes.stream().filter(b->b.getBiomeCategory().equals(BiomeCategory.THEEND)).collect(Collectors.toSet()),
|
|
||||||
Level.END
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void applyModifications(Set<Biome> biomes, ResourceKey<Level> dimension) {
|
|
||||||
List<BiConsumer<ResourceLocation, Biome>> modifications = MODIFICATIONS.get(dimension);
|
|
||||||
if (modifications == null) {
|
if (modifications == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BiomeSource source = level.getChunkSource().getGenerator().getBiomeSource();
|
||||||
|
Set<Biome> biomes = source.possibleBiomes();
|
||||||
|
|
||||||
biomes.forEach(biome -> {
|
biomes.forEach(biome -> {
|
||||||
ResourceLocation biomeID = getBiomeID(biome);
|
ResourceLocation biomeID = getBiomeID(biome);
|
||||||
boolean modify = isDatapackBiome(biomeID);
|
boolean modify = isDatapackBiome(biomeID);
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
package ru.bclib.mixin.common;
|
|
||||||
|
|
||||||
import com.mojang.serialization.DynamicOps;
|
|
||||||
import net.minecraft.core.RegistryAccess;
|
|
||||||
import net.minecraft.resources.RegistryReadOps;
|
|
||||||
import net.minecraft.resources.RegistryResourceAccess;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
import ru.bclib.api.biomes.BiomeAPI;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fabrics BiomeModifications API is called at this point. We have to ensure that BCLibs Modification API
|
|
||||||
* runs before Fabric, so we need to hook into the same class.
|
|
||||||
*/
|
|
||||||
@Mixin(RegistryReadOps.class)
|
|
||||||
public class RegistryReadOpsMixin {
|
|
||||||
@Inject(method = "createAndLoad(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/resources/RegistryResourceAccess;Lnet/minecraft/core/RegistryAccess;)Lnet/minecraft/resources/RegistryReadOps;", at = @At("RETURN"))
|
|
||||||
private static <T> void foo(DynamicOps<T> dynamicOps, RegistryResourceAccess registryResourceAccess, RegistryAccess registryAccess, CallbackInfoReturnable<RegistryReadOps<T>> cir){
|
|
||||||
BiomeAPI.initRegistry(registryAccess);
|
|
||||||
BiomeAPI.applyModifications(registryAccess);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -38,9 +38,8 @@ public abstract class ServerLevelMixin extends Level {
|
||||||
ServerLevel world = ServerLevel.class.cast(this);
|
ServerLevel world = ServerLevel.class.cast(this);
|
||||||
LifeCycleAPI._runLevelLoad(world, server, executor, levelStorageAccess, serverLevelData, resourceKey, dimensionType, chunkProgressListener, chunkGenerator, bl, l, list, bl2);
|
LifeCycleAPI._runLevelLoad(world, server, executor, levelStorageAccess, serverLevelData, resourceKey, dimensionType, chunkProgressListener, chunkGenerator, bl, l, list, bl2);
|
||||||
|
|
||||||
//called from RegistryReadOpsMixin for now
|
BiomeAPI.initRegistry(server);
|
||||||
// BiomeAPI.initRegistry(server);
|
BiomeAPI.applyModifications(ServerLevel.class.cast(this));
|
||||||
// BiomeAPI.applyModifications(ServerLevel.class.cast(this));
|
|
||||||
|
|
||||||
if (bclib_lastWorld != null && bclib_lastWorld.equals(levelStorageAccess.getLevelId())) {
|
if (bclib_lastWorld != null && bclib_lastWorld.equals(levelStorageAccess.getLevelId())) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -33,8 +33,7 @@
|
||||||
"AnvilBlockMixin",
|
"AnvilBlockMixin",
|
||||||
"AnvilMenuMixin",
|
"AnvilMenuMixin",
|
||||||
"TagLoaderMixin",
|
"TagLoaderMixin",
|
||||||
"MainMixin",
|
"MainMixin"
|
||||||
"RegistryReadOpsMixin"
|
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue