package wtf.hak.survivalfabric.commands; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.context.CommandContext; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.math.random.CheckedRandom; import net.minecraft.util.math.random.ChunkRandom; import net.minecraft.util.math.random.Random; import net.minecraft.world.chunk.Chunk; import wtf.hak.survivalfabric.config.ConfigManager; import static wtf.hak.survivalfabric.config.ConfigManager.getConfig; public class SlimeChunkCommand { public static void register(CommandDispatcher dispatcher, String... aliases) { for (String str : aliases) dispatcher.register(CommandManager.literal(str) .executes(SlimeChunkCommand::execute)); } private static int execute(CommandContext context) { ServerCommandSource source = context.getSource(); if (source.getEntity() == null) { source.sendMessage(Text.literal("Console cannot go into spectator mode!")); return 0; } ServerPlayerEntity p = (ServerPlayerEntity) source.getEntity(); Chunk chunk = p.getServerWorld().getChunk(p.getBlockPos()); Random slimeRandom = ChunkRandom.getSlimeRandom(chunk.getPos().x, chunk.getPos().z, p.getServerWorld().getSeed(), 987234911L); if(slimeRandom.nextInt(10) == 0) { p.sendMessage(Text.literal(getConfig().inSlimeChunkMessage)); } else p.sendMessage(Text.literal(getConfig().notInSlimeChunkMessage)); return 1; } }