Skip to content

Commit

Permalink
feat(game.world): methods for getting level display name
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Oct 27, 2022
1 parent c5c82b2 commit 06bcf3e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/org/auioc/mcmod/arnicalib/game/world/LevelUtils.java
@@ -1,8 +1,12 @@
package org.auioc.mcmod.arnicalib.game.world;

import java.util.function.Function;
import org.auioc.mcmod.arnicalib.game.chat.TextUtils;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.Vec3i;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
Expand Down Expand Up @@ -56,4 +60,17 @@ public static ITeleporter createSimpleTeleporter(double x, double y, double z) {
return createSimpleTeleporter(new Vec3(x, y, z), false);
}

public static Component getMoonphaseName(Level level) {
return TextUtils.translatable("moonphase." + level.getMoonPhase());
}

public static Component getDimensionName(Level level) {
return TextUtils.translatable(Util.makeDescriptionId("dimension", level.dimension().getRegistryName()));
}

public static Component getBiomeName(Level level, BlockPos pos) {
var b = level.getBiome(pos).unwrapKey();
return (b.isPresent()) ? TextUtils.translatable(Util.makeDescriptionId("biome", b.get().location())) : TextUtils.empty();
}

}

0 comments on commit 06bcf3e

Please sign in to comment.