mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
inject biomes when datapack resources are loaded
This commit is contained in:
parent
5f993cca57
commit
c21ebddfb6
@ -39,14 +39,6 @@ public class TerraGeneratorType extends GeneratorType {
|
|||||||
this.pack = pack;
|
this.pack = pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public GeneratorOptions createDefaultOptions(DynamicRegistryManager.Impl registryManager, long seed, boolean generateStructures,
|
|
||||||
boolean bonusChest) {
|
|
||||||
GeneratorOptions options = super.createDefaultOptions(registryManager, seed, generateStructures, bonusChest);
|
|
||||||
FabricEntryPoint.getPlatform().getEventManager().callEvent(new BiomeRegistrationEvent(registryManager)); // register biomes
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ChunkGenerator getChunkGenerator(DynamicRegistryManager manager, long seed) {
|
protected ChunkGenerator getChunkGenerator(DynamicRegistryManager manager, long seed) {
|
||||||
return new FabricChunkGeneratorWrapper(new TerraBiomeSource(manager.get(Registry.BIOME_KEY), seed, pack), seed, pack);
|
return new FabricChunkGeneratorWrapper(new TerraBiomeSource(manager.get(Registry.BIOME_KEY), seed, pack), seed, pack);
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.dfsek.terra.fabric.mixin.lifecycle;
|
||||||
|
|
||||||
|
import net.minecraft.resource.ResourcePack;
|
||||||
|
import net.minecraft.resource.ServerResourceManager;
|
||||||
|
import net.minecraft.server.command.CommandManager;
|
||||||
|
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||||
|
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 java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||||
|
import com.dfsek.terra.fabric.event.BiomeRegistrationEvent;
|
||||||
|
|
||||||
|
|
||||||
|
@Mixin(ServerResourceManager.class)
|
||||||
|
public class ServerResourceManagerMixin {
|
||||||
|
@Inject(method = "reload(Ljava/util/List;Lnet/minecraft/util/registry/DynamicRegistryManager;" +
|
||||||
|
"Lnet/minecraft/server/command/CommandManager$RegistrationEnvironment;ILjava/util/concurrent/Executor;" +
|
||||||
|
"Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;",
|
||||||
|
at = @At("HEAD"))
|
||||||
|
private static void inject(List<ResourcePack> packs, DynamicRegistryManager registryManager,
|
||||||
|
CommandManager.RegistrationEnvironment commandEnvironment, int functionPermissionLevel,
|
||||||
|
Executor prepareExecutor,
|
||||||
|
Executor applyExecutor, CallbackInfoReturnable<CompletableFuture<ServerResourceManager>> cir) {
|
||||||
|
FabricEntryPoint.getPlatform().getEventManager().callEvent(new BiomeRegistrationEvent(registryManager)); // register biomes
|
||||||
|
}
|
||||||
|
}
|
@ -83,8 +83,6 @@ public abstract class GeneratorOptionsMixin {
|
|||||||
ConfigPack config = main.getConfigRegistry().get(prop).orElseThrow(() -> new IllegalArgumentException(
|
ConfigPack config = main.getConfigRegistry().get(prop).orElseThrow(() -> new IllegalArgumentException(
|
||||||
"No such pack " + finalProp));
|
"No such pack " + finalProp));
|
||||||
|
|
||||||
main.getEventManager().callEvent(new BiomeRegistrationEvent(registryManager)); // register biomes
|
|
||||||
|
|
||||||
cir.setReturnValue(new GeneratorOptions(l, generateStructures, false,
|
cir.setReturnValue(new GeneratorOptions(l, generateStructures, false,
|
||||||
GeneratorOptions.getRegistryWithReplacedOverworldGenerator(dimensionTypes,
|
GeneratorOptions.getRegistryWithReplacedOverworldGenerator(dimensionTypes,
|
||||||
dimensionOptions,
|
dimensionOptions,
|
||||||
|
@ -33,7 +33,8 @@
|
|||||||
"implementations.inventory.meta.ItemStackDamageableMixin",
|
"implementations.inventory.meta.ItemStackDamageableMixin",
|
||||||
"implementations.inventory.meta.ItemStackMetaMixin",
|
"implementations.inventory.meta.ItemStackMetaMixin",
|
||||||
"implementations.world.ChunkRegionMixin",
|
"implementations.world.ChunkRegionMixin",
|
||||||
"implementations.world.ServerWorldMixin"
|
"implementations.world.ServerWorldMixin",
|
||||||
|
"lifecycle.ServerResourceManagerMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"access.GeneratorTypeAccessor",
|
"access.GeneratorTypeAccessor",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user