blob: fa8bcb5dcb923c66c670537dc38758bc92f359b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package me.Danker.features;
import me.Danker.DankersSkyblockMod;
import me.Danker.commands.ToggleCommand;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import org.lwjgl.input.Mouse;
import java.util.List;
public class FasterMaddoxCalling {
static String lastMaddoxCommand = "/cb placeholder";
static double lastMaddoxTime = 0;
@SubscribeEvent
public void onChat(ClientChatReceivedEvent event) {
String message = StringUtils.stripControlCodes(event.message.getUnformattedText());
if (!Utils.inSkyblock) return;
if (message.contains(":")) return;
if (message.contains("[OPEN MENU]")) {
List<IChatComponent> listOfSiblings = event.message.getSiblings();
for (IChatComponent sibling : listOfSiblings) {
if (sibling.getUnformattedText().contains("[OPEN MENU]")) {
lastMaddoxCommand = sibling.getChatStyle().getChatClickEvent().getValue();
lastMaddoxTime = System.currentTimeMillis() / 1000;
}
}
if (ToggleCommand.chatMaddoxToggled) Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Open chat then click anywhere on-screen to open Maddox"));
}
}
@SubscribeEvent
public void onMouseInputPost(GuiScreenEvent.MouseInputEvent.Post event) {
if (!Utils.inSkyblock) return;
if (Mouse.getEventButton() == 0 && event.gui instanceof GuiChat) {
if (ToggleCommand.chatMaddoxToggled && System.currentTimeMillis() / 1000 - lastMaddoxTime < 10) {
Minecraft.getMinecraft().thePlayer.sendChatMessage(lastMaddoxCommand);
}
}
}
@SubscribeEvent
public void onKey(InputEvent.KeyInputEvent event) {
if (!Utils.inSkyblock) return;
EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
if (DankersSkyblockMod.keyBindings[0].isPressed()) {
player.sendChatMessage(lastMaddoxCommand);
}
}
}
|