Reputation: 1
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.text.LiteralText;
import org.lwjgl.glfw.GLFW;
public class ModInitializer implements ModInitializer {
private static KeyBinding keyBinding;
private static boolean isClickerActive = false;
private static int clicksPerMillisecond = 1;
@Override
public void onInitialize() {
keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.autoclickermod.toggle",
GLFW.GLFW_KEY_UNKNOWN,
"category.autoclickermod"
));
ClientCommandManager.DISPATCHER.register(ClientCommandManager.literal("bind")
.then(ClientCommandManager.argument("key", StringArgumentType.word())
.executes(context -> {
String keyName = StringArgumentType.getString(context, "key");
int keyCode = GLFW.glfwGetKeyScancode(GLFW.glfwGetKeyName(keyName));
keyBinding.setBoundKey(keyCode);
MinecraftClient.getInstance().player.sendMessage(new LiteralText("Bound clicker toggle to key: " + keyName), false);
return 1;
})));
ClientCommandManager.DISPATCHER.register(ClientCommandManager.literal("cpms")
.then(ClientCommandManager.argument("rate", IntegerArgumentType.integer(1))
.executes(context -> {
clicksPerMillisecond = IntegerArgumentType.getInteger(context, "rate");
MinecraftClient.getInstance().player.sendMessage(new LiteralText("Set clicks per millisecond to: " + clicksPerMillisecond), false);
return 1;
})));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (keyBinding.wasPressed()) {
isClickerActive = !isClickerActive;
client.player.sendMessage(new LiteralText("Auto-clicker " + (isClickerActive ? "enabled" : "disabled")), false);
}
if (isClickerActive) {
for (int i = 0; i < clicksPerMillisecond; i++) {
client.mouse.click(MouseHelper.ClickType.LEFT);
}
}
});
}
}
I have problem with importing
net.fabricmc.fabric.api.client.command.v1.ClientCommandManager
and
net.minecraft.text.LiteralText
issues: Cannot resolve symbol 'v1' Cannot resolve symbol 'LiteralText'
im trying to write a clicker for minecraft but I cant solve this problem:\
Upvotes: 0
Views: 137