add reload resources after reload, still not fixing the issues

This commit is contained in:
gnembon committed 2022-03-23 18:21:15 +01:00
1 parent f213a79639
commit aab3de671e
4 files changed
+26 -2

No files matched your search

@@ -13,5 +13,5 @@ public interface MinecraftServerInterface
void forceTick(BooleanSupplier sup);
LevelStorageSource.LevelStorageAccess getCMSession();
Map<ResourceKey<Level>, ServerLevel> getCMWorlds();
//ServerResources getResourceManager();
void reloadAfterReload();
}
@@ -3,12 +3,16 @@ package carpet.mixins;
import carpet.fakes.MinecraftServerInterface;
import carpet.helpers.TickSpeed;
import net.minecraft.Util;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerFunctionManager;
import net.minecraft.server.TickTask;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.players.PlayerList;
import net.minecraft.util.thread.ReentrantBlockableEventLoop;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import net.minecraft.world.level.storage.LevelStorageSource;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -46,6 +50,16 @@ public abstract class MinecraftServer_scarpetMixin extends ReentrantBlockableEve
//@Shadow private ServerResources resources;
@Shadow private MinecraftServer.ReloadableResources resources;
@Shadow public abstract RegistryAccess.Frozen registryAccess();
@Shadow public abstract PlayerList getPlayerList();
@Shadow @Final private ServerFunctionManager functionManager;
@Shadow @Final private StructureManager structureManager;
@Override
public void forceTick(BooleanSupplier isAhead)
{
@@ -84,5 +98,13 @@ public abstract class MinecraftServer_scarpetMixin extends ReentrantBlockableEve
ENDER_TICK.onTick();
}
@Override
public void reloadAfterReload()
{
resources.managers().updateRegistryTags(registryAccess());
getPlayerList().saveAll();
getPlayerList().reloadResources();
functionManager.replaceLibrary(this.resources.managers().getFunctionLibrary());
structureManager.onResourceManagerReload(this.resources.resourceManager());
}
}
@@ -1154,6 +1154,7 @@ public class Auxiliary {
addeds.add(ValueConversions.of(registryKey.location()));
}
}
((MinecraftServerInterface)server).reloadAfterReload();
return ListValue.wrap(addeds);
});
}