Adjust nether biomes injection point (#2666)

Co-authored-by: apple502j <33279053+apple502j@users.noreply.github.com>
This commit is contained in:
modmuss50 2022-11-20 13:19:53 +00:00 committed by GitHub
parent 1f9b83131f
commit 3dd584b41f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,14 +24,14 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.WorldGenerationProgressListener;
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.SaveProperties; import net.minecraft.world.SaveProperties;
import net.fabricmc.fabric.impl.biome.NetherBiomeData; import net.fabricmc.fabric.impl.biome.NetherBiomeData;
@Mixin(MinecraftServer.class) // Priority set just below biome modification mixin's
@Mixin(value = MinecraftServer.class, priority = 990)
public class MinecraftServerMixin { public class MinecraftServerMixin {
@Shadow @Shadow
@Final @Final
@ -41,11 +41,8 @@ public class MinecraftServerMixin {
@Final @Final
private DynamicRegistryManager.Immutable registryManager; private DynamicRegistryManager.Immutable registryManager;
@Inject(method = "createWorlds", at = @At("HEAD")) @Inject(method = "<init>", at = @At("RETURN"))
private void addNetherBiomes(WorldGenerationProgressListener worldGenerationProgressListener, CallbackInfo ci) { private void addNetherBiomes(CallbackInfo ci) {
// This is the last point where we can safely modify worldgen related things
// plus, this is server-side only, and DRM is easily accessible
// please blame Mojang for using dynamic registry
this.saveProperties.getGeneratorOptions().getDimensions().stream().forEach(dimensionOptions -> NetherBiomeData.modifyBiomeSource(this.registryManager.get(Registry.BIOME_KEY), dimensionOptions.getChunkGenerator().getBiomeSource())); this.saveProperties.getGeneratorOptions().getDimensions().stream().forEach(dimensionOptions -> NetherBiomeData.modifyBiomeSource(this.registryManager.get(Registry.BIOME_KEY), dimensionOptions.getChunkGenerator().getBiomeSource()));
} }
} }