Skip to content

Commit

Permalink
Use LevelData as WorldData only when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeregorix committed Feb 14, 2025
1 parent b8fc74d commit 8ca60d6
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.storage.LevelData;
import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.PrimaryLevelData;
import net.minecraft.world.level.storage.ServerLevelData;
Expand Down Expand Up @@ -312,7 +313,11 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerLevel
"enabledFeatures"
}, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getWorldData()Lnet/minecraft/world/level/storage/WorldData;"))
private WorldData impl$usePerWorldLevelData(final MinecraftServer server) {
return (WorldData) this.shadow$getLevelData();
final LevelData levelData = this.shadow$getLevelData();
if (levelData instanceof final WorldData worldData) {
return worldData;
}
return server.getWorldData();
}

@Redirect(method = "setDefaultSpawnPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
Expand Down

0 comments on commit 8ca60d6

Please sign in to comment.