package com.irtimaled.bbor.client.interop;
import com.irtimaled.bbor.client.PlayerCoords;
+import com.irtimaled.bbor.client.commands.SeedCommand;
import com.irtimaled.bbor.client.events.DisconnectedFromRemoteServer;
import com.irtimaled.bbor.client.events.Render;
import com.irtimaled.bbor.client.events.UpdateWorldSpawnReceived;
import com.irtimaled.bbor.client.providers.SlimeChunkProvider;
import com.irtimaled.bbor.common.EventBus;
import com.irtimaled.bbor.common.TypeHelper;
+import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.network.NetHandlerPlayClient;
+import net.minecraft.command.ISuggestionProvider;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
}
public static boolean interceptChatMessage(String message) {
- if (message.startsWith("/bbor:seed")) {
- if (message.length() > 11) {
- String argument = message.substring(11);
- Long seed = parseNumericSeed(argument);
- if (seed == null) {
- seed = (long) argument.hashCode();
+ if (message.startsWith("/bbor:")) {
+ NetHandlerPlayClient connection = Minecraft.getInstance().getConnection();
+ if (connection != null) {
+ CommandDispatcher<ISuggestionProvider> commandDispatcher = connection.func_195515_i();
+ try {
+ commandDispatcher.execute(message.substring(1), Minecraft.getInstance().player.getCommandSource());
+ } catch (CommandSyntaxException ignored) {
}
- SlimeChunkProvider.setSeed(seed);
}
return true;
- }
- return false;
- }
- private static Long parseNumericSeed(String argument) {
- try {
- return Long.parseLong(argument);
- } catch (final NumberFormatException ex) {
- return null;
}
+ return false;
}
public static void updateWorldSpawnReceived(BlockPos blockPos) {
}
});
}
+
+ public static void registerClientCommands(CommandDispatcher<ISuggestionProvider> commandDispatcher) {
+ SeedCommand.register(commandDispatcher);
+ }
}