mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
provide platform with server instance to redeclare platform biomes
This commit is contained in:
@@ -27,6 +27,7 @@ import net.fabricmc.loader.api.FabricLoader;
|
|||||||
import net.minecraft.MinecraftVersion;
|
import net.minecraft.MinecraftVersion;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.BuiltinRegistries;
|
import net.minecraft.util.registry.BuiltinRegistries;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -68,12 +69,26 @@ public class PlatformImpl extends AbstractPlatform {
|
|||||||
worlds.add(world);
|
worlds.add(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MinecraftServer server;
|
||||||
|
|
||||||
|
public void setServer(MinecraftServer server) {
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean reload() {
|
public boolean reload() {
|
||||||
getTerraConfig().load(this);
|
getTerraConfig().load(this);
|
||||||
getRawConfigRegistry().clear();
|
getRawConfigRegistry().clear();
|
||||||
boolean succeed = getRawConfigRegistry().loadAll(this);
|
boolean succeed = getRawConfigRegistry().loadAll(this);
|
||||||
|
|
||||||
|
if(server != null) {
|
||||||
|
server.reloadResources(server.getDataPackManager().getNames()).exceptionally(throwable -> {
|
||||||
|
LOGGER.warn("Failed to execute reload", throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
worlds.forEach(world -> {
|
worlds.forEach(world -> {
|
||||||
FabricChunkGeneratorWrapper chunkGeneratorWrapper = ((FabricChunkGeneratorWrapper) world.getChunkManager().getChunkGenerator());
|
FabricChunkGeneratorWrapper chunkGeneratorWrapper = ((FabricChunkGeneratorWrapper) world.getChunkManager().getChunkGenerator());
|
||||||
chunkGeneratorWrapper.setPack(getConfigRegistry().get(chunkGeneratorWrapper.getPack().getRegistryKey()).orElseThrow());
|
chunkGeneratorWrapper.setPack(getConfigRegistry().get(chunkGeneratorWrapper.getPack().getRegistryKey()).orElseThrow());
|
||||||
|
|||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
package com.dfsek.terra.fabric.mixin.lifecycle;
|
||||||
|
|
||||||
|
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfileRepository;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import com.mojang.datafixers.DataFixer;
|
||||||
|
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.world.SaveProperties;
|
||||||
|
import net.minecraft.world.level.storage.LevelStorage;
|
||||||
|
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.CallbackInfo;
|
||||||
|
|
||||||
|
import java.net.Proxy;
|
||||||
|
|
||||||
|
|
||||||
|
@Mixin(MinecraftServer.class)
|
||||||
|
public class MinecraftServerMixin {
|
||||||
|
@Inject(method = "<init>(Ljava/lang/Thread;Lnet/minecraft/util/registry/DynamicRegistryManager$Impl;" +
|
||||||
|
"Lnet/minecraft/world/level/storage/LevelStorage$Session;Lnet/minecraft/world/SaveProperties;" +
|
||||||
|
"Lnet/minecraft/resource/ResourcePackManager;Ljava/net/Proxy;Lcom/mojang/datafixers/DataFixer;" +
|
||||||
|
"Lnet/minecraft/resource/ServerResourceManager;Lcom/mojang/authlib/minecraft/MinecraftSessionService;" +
|
||||||
|
"Lcom/mojang/authlib/GameProfileRepository;Lnet/minecraft/util/UserCache;" +
|
||||||
|
"Lnet/minecraft/server/WorldGenerationProgressListenerFactory;)V",
|
||||||
|
at = @At("RETURN"))
|
||||||
|
private void injectConstructor(Thread serverThread, DynamicRegistryManager.Impl registryManager, LevelStorage.Session session,
|
||||||
|
SaveProperties saveProperties, ResourcePackManager dataPackManager, Proxy proxy, DataFixer dataFixer,
|
||||||
|
ServerResourceManager serverResourceManager, MinecraftSessionService sessionService,
|
||||||
|
GameProfileRepository gameProfileRepo, UserCache userCache,
|
||||||
|
WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory, CallbackInfo ci) {
|
||||||
|
FabricEntryPoint.getPlatform().setServer((MinecraftServer) (Object) this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -143,7 +143,9 @@ public final class FabricUtil {
|
|||||||
.build();
|
.build();
|
||||||
Identifier identifier = new Identifier("terra", FabricUtil.createBiomeID(pack, id));
|
Identifier identifier = new Identifier("terra", FabricUtil.createBiomeID(pack, id));
|
||||||
|
|
||||||
if(!biomeRegistry.containsId(identifier)) {
|
if(biomeRegistry.containsId(identifier)) {
|
||||||
|
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(biomeRegistry.get(identifier));
|
||||||
|
} else {
|
||||||
Registry.register(biomeRegistry, identifier, minecraftBiome);
|
Registry.register(biomeRegistry, identifier, minecraftBiome);
|
||||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(minecraftBiome);
|
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(minecraftBiome);
|
||||||
terraVanillaBiomes.computeIfAbsent(biomeRegistry.getKey(vanilla).orElseThrow(), b -> new ArrayList<>()).add(
|
terraVanillaBiomes.computeIfAbsent(biomeRegistry.getKey(vanilla).orElseThrow(), b -> new ArrayList<>()).add(
|
||||||
|
|||||||
@@ -1,51 +1,52 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "com.dfsek.terra.fabric.mixin",
|
"package": "com.dfsek.terra.fabric.mixin",
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"ConfiguredStructureFeaturesMixin",
|
"ConfiguredStructureFeaturesMixin",
|
||||||
"ServerWorldMixin",
|
"ServerWorldMixin",
|
||||||
"access.BiomeEffectsAccessor",
|
"access.BiomeEffectsAccessor",
|
||||||
"access.MobSpawnerLogicAccessor",
|
"access.MobSpawnerLogicAccessor",
|
||||||
"access.StateAccessor",
|
"access.StateAccessor",
|
||||||
"access.StructureAccessorAccessor",
|
"access.StructureAccessorAccessor",
|
||||||
"implementations.BiomeMixin",
|
"implementations.BiomeMixin",
|
||||||
"implementations.HandleImplementationMixin",
|
"implementations.HandleImplementationMixin",
|
||||||
"implementations.block.BlockMixin",
|
"implementations.block.BlockMixin",
|
||||||
"implementations.block.entity.BlockEntityMixin",
|
"implementations.block.entity.BlockEntityMixin",
|
||||||
"implementations.block.entity.LootableContainerBlockEntityMixin",
|
"implementations.block.entity.LootableContainerBlockEntityMixin",
|
||||||
"implementations.block.entity.MobSpawnerBlockEntityMixin",
|
"implementations.block.entity.MobSpawnerBlockEntityMixin",
|
||||||
"implementations.block.entity.SignBlockEntityMixin",
|
"implementations.block.entity.SignBlockEntityMixin",
|
||||||
"implementations.block.state.BlockStateMixin",
|
"implementations.block.state.BlockStateMixin",
|
||||||
"implementations.block.state.PropertyMixin",
|
"implementations.block.state.PropertyMixin",
|
||||||
"implementations.chunk.ChunkRegionMixin",
|
"implementations.chunk.ChunkRegionMixin",
|
||||||
"implementations.chunk.WorldChunkMixin",
|
"implementations.chunk.WorldChunkMixin",
|
||||||
"implementations.chunk.data.ProtoChunkMixin",
|
"implementations.chunk.data.ProtoChunkMixin",
|
||||||
"implementations.entity.EntityMixin",
|
"implementations.entity.EntityMixin",
|
||||||
"implementations.entity.EntityTypeMixin",
|
"implementations.entity.EntityTypeMixin",
|
||||||
"implementations.entity.PlayerEntityMixin",
|
"implementations.entity.PlayerEntityMixin",
|
||||||
"implementations.entity.ServerCommandSourceMixin",
|
"implementations.entity.ServerCommandSourceMixin",
|
||||||
"implementations.inventory.LockableContainerBlockEntityMixin",
|
"implementations.inventory.LockableContainerBlockEntityMixin",
|
||||||
"implementations.inventory.item.ItemMixin",
|
"implementations.inventory.item.ItemMixin",
|
||||||
"implementations.inventory.item.ItemStackMixin",
|
"implementations.inventory.item.ItemStackMixin",
|
||||||
"implementations.inventory.meta.EnchantmentMixin",
|
"implementations.inventory.meta.EnchantmentMixin",
|
||||||
"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"
|
"lifecycle.MinecraftServerMixin",
|
||||||
],
|
"lifecycle.ServerResourceManagerMixin"
|
||||||
"client": [
|
],
|
||||||
"access.GeneratorTypeAccessor",
|
"client": [
|
||||||
"lifecycle.client.MinecraftClientMixin"
|
"access.GeneratorTypeAccessor",
|
||||||
],
|
"lifecycle.client.MinecraftClientMixin"
|
||||||
"server": [
|
],
|
||||||
"lifecycle.server.GeneratorOptionsMixin",
|
"server": [
|
||||||
"lifecycle.server.ServerMainMixin"
|
"lifecycle.server.GeneratorOptionsMixin",
|
||||||
],
|
"lifecycle.server.ServerMainMixin"
|
||||||
"injectors": {
|
],
|
||||||
"defaultRequire": 1
|
"injectors": {
|
||||||
},
|
"defaultRequire": 1
|
||||||
"refmap": "terra-refmap.json"
|
},
|
||||||
|
"refmap": "terra-refmap.json"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user