[Fix] Prevent FAPIs forced registry path prefix introduced in 0.86 for our Registries (quiqueck/BetterEnd#273)
This commit is contained in:
parent
ad13bcac92
commit
a42ed2a414
1 changed files with 15 additions and 3 deletions
|
@ -1,9 +1,12 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeData;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
|
||||
import net.minecraft.resources.RegistryDataLoader;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
|
@ -11,11 +14,12 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
|||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(RegistryDataLoader.class)
|
||||
@Mixin(value = RegistryDataLoader.class, priority = 500)
|
||||
public class RegistryDataLoaderMixin {
|
||||
@Accessor("WORLDGEN_REGISTRIES")
|
||||
@Mutable
|
||||
|
@ -24,14 +28,22 @@ public class RegistryDataLoaderMixin {
|
|||
}
|
||||
|
||||
@Inject(method = "<clinit>", at = @At("TAIL"))
|
||||
private static void wt_init(CallbackInfo ci) {
|
||||
private static void bcl_init(CallbackInfo ci) {
|
||||
//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);
|
||||
enhanced.add(new RegistryDataLoader.RegistryData<>(
|
||||
BCLBiomeRegistry.BCL_BIOMES_REGISTRY, BiomeData.CODEC
|
||||
));
|
||||
enhanced.addAll(RegistryDataLoader.WORLDGEN_REGISTRIES);
|
||||
|
||||
wt_set_WORLDGEN_REGISTRIES(enhanced);
|
||||
}
|
||||
|
||||
// Fabric force changes the directory path for all modded registries to be prefixed with the mod id.
|
||||
// We do not want this for our BCL-Biome/Surface Rule Registry, so we remove the prefix here.
|
||||
@Inject(method = "registryDirPath", at = @At("RETURN"), cancellable = true)
|
||||
private static void prependDirectoryWithNamespace(ResourceLocation id, CallbackInfoReturnable<String> info) {
|
||||
if (id.getNamespace().equals(WorldsTogether.MOD_ID) || id.getNamespace().equals(BCLib.MOD_ID)) {
|
||||
info.setReturnValue(info.getReturnValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue