package me.km.world; import me.km.utils.ReflectionUtils; import me.km.utils.Utils; import net.minecraft.world.server.ServerWorld; import net.minecraft.world.storage.DerivedWorldInfo; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; public class WorldEvents { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onWorldLoad(WorldEvent.Load e) { if(!(e.getWorld() instanceof ServerWorld)) { return; } ServerWorld w = (ServerWorld) e.getWorld(); if(w.getLevelData() instanceof DerivedWorldInfo) { DerivedWorldInfo info = (DerivedWorldInfo) w.getLevelData(); ReflectionUtils.setWorldInfo(w, new ModWorldInfo(info)); System.out.println(String.format("updated world info of %s to mod world info", Utils.getWorldName(w))); } } }