48 lines
2.4 KiB
Java
48 lines
2.4 KiB
Java
|
package com.thebrokenrail.energonrelics.mixin;
|
||
|
|
||
|
import com.mojang.authlib.GameProfileRepository;
|
||
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||
|
import com.mojang.datafixers.DataFixer;
|
||
|
import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock;
|
||
|
import net.minecraft.resource.ResourcePackManager;
|
||
|
import net.minecraft.resource.ServerResourceManager;
|
||
|
import net.minecraft.server.MinecraftServer;
|
||
|
import net.minecraft.server.WorldGenerationProgressListenerFactory;
|
||
|
import net.minecraft.util.UserCache;
|
||
|
import net.minecraft.util.registry.DynamicRegistryManager;
|
||
|
import net.minecraft.util.registry.Registry;
|
||
|
import net.minecraft.world.SaveProperties;
|
||
|
import net.minecraft.world.biome.Biome;
|
||
|
import net.minecraft.world.gen.feature.StructureFeature;
|
||
|
import net.minecraft.world.level.storage.LevelStorage;
|
||
|
import org.spongepowered.asm.mixin.Final;
|
||
|
import org.spongepowered.asm.mixin.Mixin;
|
||
|
import org.spongepowered.asm.mixin.Shadow;
|
||
|
import org.spongepowered.asm.mixin.injection.At;
|
||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||
|
|
||
|
import java.net.Proxy;
|
||
|
import java.util.ArrayList;
|
||
|
|
||
|
@Mixin(MinecraftServer.class)
|
||
|
public class MixinMinecraftServer {
|
||
|
@Shadow
|
||
|
@Final
|
||
|
protected DynamicRegistryManager.Impl registryManager;
|
||
|
|
||
|
@Inject(at = @At("TAIL"), method = "<init>")
|
||
|
private void init(Thread thread, DynamicRegistryManager.Impl impl, LevelStorage.Session session, SaveProperties saveProperties, ResourcePackManager resourcePackManager, Proxy proxy, DataFixer dataFixer, ServerResourceManager serverResourceManager, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, UserCache userCache, WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory, CallbackInfo info) {
|
||
|
if (registryManager.getOptional(Registry.BIOME_KEY).isPresent()) {
|
||
|
for (Biome biome : registryManager.getOptional(Registry.BIOME_KEY).get()) {
|
||
|
// Make Mutable
|
||
|
((GenerationSettingsAccessor) biome.getGenerationSettings()).setStructureFeatures(new ArrayList<>(((GenerationSettingsAccessor) biome.getGenerationSettings()).getStructureFeatures()));
|
||
|
|
||
|
if (biome.getGenerationSettings().hasStructureFeature(StructureFeature.MINESHAFT)) {
|
||
|
StructureGeneratorBlock.addToBiome(biome);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|