diff options
author | RabbitType99 <luis.be@gmx.de> | 2021-03-09 23:27:30 +0100 |
---|---|---|
committer | RabbitType99 <luis.be@gmx.de> | 2021-03-09 23:27:30 +0100 |
commit | cb5106e11c553108a63b9aa8b44c70a449ef627d (patch) | |
tree | 4a498919931327c7fff10d9891c9551b4181de1b /src/main/java/me/Danker/features/FasterMaddoxCalling.java | |
parent | 87f5d4c76b907da4fb5952e7dff5ebad88b080d8 (diff) | |
parent | e7237307e71c649b4b7c880259ff1781fcc7c435 (diff) | |
download | SkyblockMod-cb5106e11c553108a63b9aa8b44c70a449ef627d.tar.gz SkyblockMod-cb5106e11c553108a63b9aa8b44c70a449ef627d.tar.bz2 SkyblockMod-cb5106e11c553108a63b9aa8b44c70a449ef627d.zip |
Merge branch 'development' into InstallerFrame
# Conflicts:
# build.gradle
Diffstat (limited to 'src/main/java/me/Danker/features/FasterMaddoxCalling.java')
-rw-r--r-- | src/main/java/me/Danker/features/FasterMaddoxCalling.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/features/FasterMaddoxCalling.java b/src/main/java/me/Danker/features/FasterMaddoxCalling.java new file mode 100644 index 0000000..fa8bcb5 --- /dev/null +++ b/src/main/java/me/Danker/features/FasterMaddoxCalling.java @@ -0,0 +1,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); + } + } + +} |