[Feature] /bclib print dimensions command

This commit is contained in:
Frank 2022-07-10 01:06:22 +02:00
parent 8f9c33e378
commit f6aa62547f
3 changed files with 62 additions and 4 deletions

View file

@ -0,0 +1,40 @@
package org.betterx.bclib.commands;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.ChatFormatting;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
import net.minecraft.world.level.Level;
public class PrintInfo {
static int printDimensions(CommandContext<CommandSourceStack> ctx) {
MutableComponent result = Component.literal("World Dimensions: ")
.setStyle(Style.EMPTY.withBold(true).withColor(ChatFormatting.BLUE));
for (var serverLevel : ctx.getSource().getLevel().getServer().getAllLevels()) {
var generator = serverLevel.getChunkSource().getGenerator();
String output = "\n - " + serverLevel.dimension().location().toString() + ": " +
"\n " + generator.toString().trim() + " " +
generator
.getBiomeSource()
.toString()
.replace("\n", "\n ");
var cl = ChatFormatting.LIGHT_PURPLE;
if (serverLevel.dimension().location().equals(Level.OVERWORLD.location()))
cl = ChatFormatting.WHITE;
else if (serverLevel.dimension().location().equals(Level.NETHER.location()))
cl = ChatFormatting.RED;
if (serverLevel.dimension().location().equals(Level.END.location()))
cl = ChatFormatting.YELLOW;
Component dimComponent = Component.literal(output)
.setStyle(Style.EMPTY.withBold(false).withColor(cl));
result.append(dimComponent);
}
ctx.getSource().sendSuccess(result, false);
return Command.SINGLE_SUCCESS;
}
}