From 49657c4fd15c80b6f022c905a80435669a564d2d Mon Sep 17 00:00:00 2001 From: NK Date: Sat, 25 Feb 2023 12:58:40 +0000 Subject: [PATCH 1/6] Using more OOPs, so I would at least increase a bit of performance rather than static abuse --- build.gradle | 1 - src/main/java/me/night0721/lilase/Lilase.java | 8 ++--- .../lilase/events/SniperFlipperEvents.java | 23 +++++++------ .../{config => features/ah}/AHConfig.java | 2 +- .../lilase/features/ah/AuctionHouse.java | 34 +++++++++++++------ .../lilase/features/flip/Flipper.java | 17 ++++++---- src/main/resources/mixins.night0721.json | 1 + 7 files changed, 53 insertions(+), 33 deletions(-) rename src/main/java/me/night0721/lilase/{config => features/ah}/AHConfig.java (99%) diff --git a/build.gradle b/build.gradle index 598e250..beedce2 100644 --- a/build.gradle +++ b/build.gradle @@ -81,7 +81,6 @@ jar { "ForceLoadAsMod": true, "MixinConfigs": "mixins.night0721.json", "ModSide": "CLIENT", -// "TweakClass": "gg.essential.loader.stage0.EssentialSetupTweaker", "TweakClass": "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker", "TweakOrder": "0") enabled = false diff --git a/src/main/java/me/night0721/lilase/Lilase.java b/src/main/java/me/night0721/lilase/Lilase.java index 6699458..74a8e24 100644 --- a/src/main/java/me/night0721/lilase/Lilase.java +++ b/src/main/java/me/night0721/lilase/Lilase.java @@ -4,7 +4,7 @@ import cc.polyfrost.oneconfig.events.EventManager; import cc.polyfrost.oneconfig.events.event.InitializationEvent; import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; import com.mojang.realmsclient.gui.ChatFormatting; -import me.night0721.lilase.config.AHConfig; +import me.night0721.lilase.features.ah.AHConfig; import me.night0721.lilase.events.PacketReceivedEvent; import me.night0721.lilase.features.ah.AuctionHouse; import me.night0721.lilase.features.flip.Flipper; @@ -29,8 +29,8 @@ import org.lwjgl.opengl.Display; import java.io.IOException; -import static me.night0721.lilase.config.AHConfig.AUCTION_HOUSE_DELAY; -import static me.night0721.lilase.config.AHConfig.RECONNECT_DELAY; +import static me.night0721.lilase.features.ah.AHConfig.AUCTION_HOUSE_DELAY; +import static me.night0721.lilase.features.ah.AHConfig.RECONNECT_DELAY; @Mod(modid = Lilase.MODID, name = Lilase.MOD_NAME, version = Lilase.VERSION, acceptedMinecraftVersions = "[1.8.9]") public class Lilase { @@ -73,7 +73,7 @@ public class Lilase { if (tickAmount % 2400 == 0) { ConfigUtils.checkWebhookAndAPI(); } - Flipper.switchStates(); + AuctionHouse.flipper.switchStates(); if ((mc.currentScreen instanceof GuiDisconnected)) { if (waitTime >= (RECONNECT_DELAY * 20)) { waitTime = 0; diff --git a/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java b/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java index b6efc97..9afb09c 100644 --- a/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java +++ b/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java @@ -1,7 +1,7 @@ package me.night0721.lilase.events; import me.night0721.lilase.Lilase; -import me.night0721.lilase.config.AHConfig; +import me.night0721.lilase.features.ah.AHConfig; import me.night0721.lilase.features.flip.Flipper; import me.night0721.lilase.features.flip.FlipperState; import me.night0721.lilase.gui.TextRenderer; @@ -27,17 +27,15 @@ import java.io.IOException; import java.util.Calendar; import java.util.TimeZone; -import static me.night0721.lilase.config.AHConfig.GUI_COLOR; +import static me.night0721.lilase.features.ah.AHConfig.GUI_COLOR; import static me.night0721.lilase.features.ah.AuctionHouse.flipper; -import static me.night0721.lilase.features.ah.AuctionHouse.webhook; import static me.night0721.lilase.features.flip.Flipper.rotation; import static me.night0721.lilase.features.flip.FlipperState.START; import static me.night0721.lilase.utils.PlayerUtils.sendPacketWithoutEvent; public class SniperFlipperEvents { - Thread bzchillingthread; - private static int windowId = 1; - private static boolean buying = false; + private int windowId = 1; + private boolean buying = false; @SubscribeEvent public void onChat(ClientChatReceivedEvent event) throws InterruptedException, IOException { @@ -56,7 +54,7 @@ public class SniperFlipperEvents { ConfigUtils.writeStringConfig("main", "APIKey", apiKey); } else if (message.equals("Claiming BIN auction...") && buying) { Utils.debugLog("[Sniper] Bought an item, starting to sell"); - webhook.execute(); + Lilase.auctionHouse.webhook.execute(); flipper.sellItem(); } else if (message.equals("Your starting bid must be at least 10 coins!")) { InventoryUtils.clickOpenContainerSlot(13); @@ -72,10 +70,10 @@ public class SniperFlipperEvents { } else if (message.contains("You were spawned in Limbo")) { Utils.sendMessage("Detected in Limbo, stopping everything for 5 minutes"); Flipper.state = FlipperState.NONE; - if (Lilase.auctionHouse.open) Lilase.auctionHouse.toggleAuction(); + if (Lilase.auctionHouse.getOpen()) Lilase.auctionHouse.toggleAuction(); Thread.sleep(5000); Utils.sendServerMessage("/hub"); - bzchillingthread = new Thread(bazaarChilling); + Thread bzchillingthread = new Thread(bazaarChilling); bzchillingthread.start(); } } @@ -161,7 +159,12 @@ public class SniperFlipperEvents { int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); String time = String.format("%02d:%02d", hour, minute); - String lines = "X: " + Math.round(PlayerUtils.mc.thePlayer.posX) + "\n" + "Y: " + Math.round(PlayerUtils.mc.thePlayer.posY) + "\n" + "Z: " + Math.round(PlayerUtils.mc.thePlayer.posZ) + "\n" + time + "\n" + "FPS: " + Minecraft.getDebugFPS(); + String lines = "X: " + Math.round(PlayerUtils.mc.thePlayer.posX) + "\n" + + "Y: " + Math.round(PlayerUtils.mc.thePlayer.posY) + "\n" + + "Z: " + Math.round(PlayerUtils.mc.thePlayer.posZ) + "\n" + + time + "\n" + + "FPS: " + Minecraft.getDebugFPS() + "\n" + + "Auctions Sniped" + Lilase.auctionHouse.getAuctionsSniped(); TextRenderer.drawString(lines, 0, 0, 1.5, GUI_COLOR.getRGB()); } } diff --git a/src/main/java/me/night0721/lilase/config/AHConfig.java b/src/main/java/me/night0721/lilase/features/ah/AHConfig.java similarity index 99% rename from src/main/java/me/night0721/lilase/config/AHConfig.java rename to src/main/java/me/night0721/lilase/features/ah/AHConfig.java index 19f58d4..ad49cd1 100644 --- a/src/main/java/me/night0721/lilase/config/AHConfig.java +++ b/src/main/java/me/night0721/lilase/features/ah/AHConfig.java @@ -1,4 +1,4 @@ -package me.night0721.lilase.config; +package me.night0721.lilase.features.ah; import cc.polyfrost.oneconfig.config.Config; import cc.polyfrost.oneconfig.config.annotations.Number; diff --git a/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java b/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java index 43043d5..9ea48a6 100644 --- a/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java +++ b/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java @@ -23,14 +23,14 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class AuctionHouse { - private static String uuid; - private static String message_toSend; - public static Flipper flipper; - public static final DiscordWebhook webhook = new DiscordWebhook(ConfigUtils.getString("main", "Webhook")); - - public Boolean open = false; + private String uuid; + private String message_toSend; + private Boolean open = false; + private int auctionsSniped = 0; + public DiscordWebhook webhook = new DiscordWebhook(ConfigUtils.getString("main", "Webhook")); private final List items = new ArrayList<>(); private final List posted = new ArrayList<>(); + public static Flipper flipper; public AuctionHouse() { if (!ConfigUtils.getString("item1", "Name").equals("") && !ConfigUtils.getString("item1", "Type").equals("") && !ConfigUtils.getString("item1", "Tier").equals("") && ConfigUtils.getInt("item1", "Price") != 0) @@ -166,7 +166,7 @@ public class AuctionHouse { } } - public static void sendAuction() { + private void sendAuction() { Utils.sendServerMessage("/viewauction " + uuid); Utils.sendMessage(message_toSend); } @@ -175,7 +175,6 @@ public class AuctionHouse { private final List timesString = Arrays.asList("year", "month", "day", "hour", "minute", "second"); public String toDuration(long duration) { - StringBuilder res = new StringBuilder(); for (int i = 0; i < times.size(); i++) { Long current = times.get(i); @@ -189,12 +188,11 @@ public class AuctionHouse { else return res.toString(); } - private static String getTimeSinceDate(long timeSinceDate) { + private String getTimeSinceDate(long timeSinceDate) { long seconds = TimeUnit.MILLISECONDS.toSeconds(timeSinceDate); long minutes = TimeUnit.MILLISECONDS.toMinutes(timeSinceDate); long hours = TimeUnit.MILLISECONDS.toHours(timeSinceDate); long days = TimeUnit.MILLISECONDS.toDays(timeSinceDate); - if (seconds < 60) return "in " + seconds + " seconds"; else if (minutes < 60) return "in " + minutes + " minutes"; else if (hours < 24) return "in " + hours + " hours"; @@ -215,6 +213,22 @@ public class AuctionHouse { } else Utils.sendMessage("Detected not in hub, please go to hub to start"); } } + + public Boolean getOpen() { + return open; + } + + public void setOpen(Boolean open) { + this.open = open; + } + + public int getAuctionsSniped() { + return auctionsSniped; + } + + public void incrementAuctionsSniped() { + this.auctionsSniped += 1; + } } diff --git a/src/main/java/me/night0721/lilase/features/flip/Flipper.java b/src/main/java/me/night0721/lilase/features/flip/Flipper.java index 1f02cba..2a992d2 100644 --- a/src/main/java/me/night0721/lilase/features/flip/Flipper.java +++ b/src/main/java/me/night0721/lilase/features/flip/Flipper.java @@ -22,7 +22,7 @@ public class Flipper { private final int itemprice; public static FlipperState state = FlipperState.NONE; public static final Rotation rotation = new Rotation(); - private static final Clock buyWait = new Clock(); + private final Clock buyWait = new Clock(); public Flipper(String name, String data, int price) { itemname = name; @@ -42,13 +42,13 @@ public class Flipper { public void sellItem() { Utils.sendMessage("Flipper is running, stopping, will resume when flipper is done"); - if (Lilase.auctionHouse.open) Lilase.auctionHouse.toggleAuction(); + if (Lilase.auctionHouse.getOpen()) Lilase.auctionHouse.toggleAuction(); UngrabUtils.ungrabMouse(); Utils.sendServerMessage("/hub"); state = FlipperState.WALKING_TO_FIRST_POINT; } - public static void switchStates() { + public void switchStates() { switch (state) { case WALKING_TO_FIRST_POINT: if (PlayerUtils.mc.currentScreen != null) { @@ -99,7 +99,7 @@ public class Flipper { if (InventoryUtils.getSlotForItem(itemname) == -1) { Utils.sendMessage("Cannot find item in inventory, stopping flipper"); state = FlipperState.NONE; - Lilase.auctionHouse.open = true; + Lilase.auctionHouse.setOpen(true); return; } InventoryUtils.clickOpenContainerSlot(InventoryUtils.getSlotForItem(itemname)); @@ -125,7 +125,10 @@ public class Flipper { buyWait.schedule(1000); } else if (InventoryUtils.inventoryNameContains("BIN Auction View") && buyWait.passed()) { InventoryUtils.clickOpenContainerSlot(49); + Lilase.auctionHouse.incrementAuctionsSniped(); + buyWait.schedule(500); PlayerUtils.mc.thePlayer.closeScreen(); + buyWait.schedule(500); Utils.sendMessage("Posted item on Auction House, continue sniping now"); state = FlipperState.NONE; Lilase.auctionHouse.toggleAuction(); @@ -158,15 +161,15 @@ public class Flipper { return new JSONObject(content.toString()); } - private static float distanceToFirstPoint() { + private float distanceToFirstPoint() { return (float) Math.sqrt(Math.pow(PlayerUtils.mc.thePlayer.posX - (-2.5), 2) + Math.pow(PlayerUtils.mc.thePlayer.posZ - (-91.5), 2)); } - private static float distanceToAuctionMaster() { + private float distanceToAuctionMaster() { return (float) Math.sqrt(Math.pow(PlayerUtils.mc.thePlayer.posX - (-45), 2) + Math.pow(PlayerUtils.mc.thePlayer.posZ - (-90), 2)); } - private static Entity getAuctionMaster() { + private Entity getAuctionMaster() { for (final Entity e : PlayerUtils.mc.theWorld.loadedEntityList) { if (e instanceof EntityArmorStand) { final String name = StringUtils.stripControlCodes(e.getDisplayName().getUnformattedText()); diff --git a/src/main/resources/mixins.night0721.json b/src/main/resources/mixins.night0721.json index e6835e2..e2b15b4 100644 --- a/src/main/resources/mixins.night0721.json +++ b/src/main/resources/mixins.night0721.json @@ -3,6 +3,7 @@ "package": "me.night0721.lilase.mixins", "refmap": "mixins.night0721.refmap.json", "compatibilityLevel": "JAVA_8", + "minVersion": "0.8.2", "mixins": [ "MixinNetworkManager" ] From 2547cf6c8b740bb4a150f8a17abe299c3ece4b8e Mon Sep 17 00:00:00 2001 From: NK Date: Sat, 25 Feb 2023 23:26:56 +0000 Subject: [PATCH 2/6] Some bug fixes and Title display when game starts --- src/main/java/me/night0721/lilase/Lilase.java | 14 ++++++-------- .../lilase/events/SniperFlipperEvents.java | 2 +- .../lilase/features/ah/AuctionHouse.java | 4 ++-- .../lilase/mixins/MixinMinecraft.java | 18 ++++++++++++++++++ .../lilase/utils/KeyBindingManager.java | 6 +++--- src/main/resources/mixins.night0721.json | 3 +++ 6 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 src/main/java/me/night0721/lilase/mixins/MixinMinecraft.java diff --git a/src/main/java/me/night0721/lilase/Lilase.java b/src/main/java/me/night0721/lilase/Lilase.java index 74a8e24..1e41d58 100644 --- a/src/main/java/me/night0721/lilase/Lilase.java +++ b/src/main/java/me/night0721/lilase/Lilase.java @@ -4,13 +4,12 @@ import cc.polyfrost.oneconfig.events.EventManager; import cc.polyfrost.oneconfig.events.event.InitializationEvent; import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; import com.mojang.realmsclient.gui.ChatFormatting; -import me.night0721.lilase.features.ah.AHConfig; import me.night0721.lilase.events.PacketReceivedEvent; -import me.night0721.lilase.features.ah.AuctionHouse; -import me.night0721.lilase.features.flip.Flipper; -import me.night0721.lilase.utils.KeyBindingManager; import me.night0721.lilase.events.SniperFlipperEvents; +import me.night0721.lilase.features.ah.AHConfig; +import me.night0721.lilase.features.ah.AuctionHouse; import me.night0721.lilase.utils.ConfigUtils; +import me.night0721.lilase.utils.KeyBindingManager; import me.night0721.lilase.utils.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiDisconnected; @@ -25,7 +24,6 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.opengl.Display; import java.io.IOException; @@ -45,14 +43,14 @@ public class Lilase { @Mod.EventHandler public void init(FMLInitializationEvent event) { + KeyBindingManager keyBindingManager = new KeyBindingManager(); MinecraftForge.EVENT_BUS.register(this); - MinecraftForge.EVENT_BUS.register(new KeyBindingManager()); + MinecraftForge.EVENT_BUS.register(keyBindingManager); MinecraftForge.EVENT_BUS.register(new SniperFlipperEvents()); EventManager.INSTANCE.register(this); ConfigUtils.register(); auctionHouse = new AuctionHouse(); - KeyBindingManager.registerKeyBindings(); - Display.setTitle("Lilase v" + VERSION + " | night0721"); + keyBindingManager.registerKeyBindings(); } @Subscribe diff --git a/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java b/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java index 9afb09c..3069930 100644 --- a/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java +++ b/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java @@ -193,7 +193,7 @@ public class SniperFlipperEvents { } @SubscribeEvent - public void onWindowClick(PacketReceivedEvent event) { + public void onPacketReceive(PacketReceivedEvent event) { if (event.packet instanceof S33PacketUpdateSign && Utils.checkInHub() && Flipper.state.equals(START)) { new Thread(() -> { try { diff --git a/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java b/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java index 9ea48a6..585b501 100644 --- a/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java +++ b/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java @@ -202,12 +202,12 @@ public class AuctionHouse { public void toggleAuction() { if (open) { - Utils.sendMessage("Stopped Auction House"); + Utils.sendMessage("Stopped AH Sniper"); open = false; UngrabUtils.regrabMouse(); } else { if (Utils.checkInHub()) { - Utils.sendMessage("Started Auction House"); + Utils.sendMessage("Started AH Sniper"); open = true; UngrabUtils.ungrabMouse(); } else Utils.sendMessage("Detected not in hub, please go to hub to start"); diff --git a/src/main/java/me/night0721/lilase/mixins/MixinMinecraft.java b/src/main/java/me/night0721/lilase/mixins/MixinMinecraft.java new file mode 100644 index 0000000..073f9e5 --- /dev/null +++ b/src/main/java/me/night0721/lilase/mixins/MixinMinecraft.java @@ -0,0 +1,18 @@ +package me.night0721.lilase.mixins; + +import net.minecraft.client.Minecraft; +import org.lwjgl.opengl.Display; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import static me.night0721.lilase.Lilase.VERSION; + +@Mixin({Minecraft.class}) +public class MixinMinecraft { + @Inject(method = {"startGame"}, at = {@At("RETURN")}) + private void startGame(CallbackInfo ci) { + Display.setTitle("Lilase v" + VERSION + " | night0721"); + } +} \ No newline at end of file diff --git a/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java b/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java index f2592a1..16a3505 100644 --- a/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java +++ b/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java @@ -8,10 +8,10 @@ import net.minecraftforge.fml.common.gameevent.InputEvent; import org.lwjgl.input.Keyboard; public class KeyBindingManager { - private static final KeyBinding[] keyBindings = new KeyBinding[4]; + private final KeyBinding[] keyBindings = new KeyBinding[2]; - public static void registerKeyBindings() { - keyBindings[0] = new KeyBinding("Auction House Toggle", Keyboard.KEY_END, Lilase.MOD_NAME); + public void registerKeyBindings() { + keyBindings[0] = new KeyBinding("Sniper Toggle", Keyboard.KEY_END, Lilase.MOD_NAME); keyBindings[1] = new KeyBinding("Config", Keyboard.KEY_MULTIPLY, Lilase.MOD_NAME); for (KeyBinding keyBinding : keyBindings) { ClientRegistry.registerKeyBinding(keyBinding); diff --git a/src/main/resources/mixins.night0721.json b/src/main/resources/mixins.night0721.json index e2b15b4..426a5d5 100644 --- a/src/main/resources/mixins.night0721.json +++ b/src/main/resources/mixins.night0721.json @@ -6,5 +6,8 @@ "minVersion": "0.8.2", "mixins": [ "MixinNetworkManager" + ], + "client": [ + "MixinMinecraft" ] } From dd2f59ec0941a2cfbf3d9d2431606180a679de45 Mon Sep 17 00:00:00 2001 From: NK Date: Sat, 25 Feb 2023 23:27:20 +0000 Subject: [PATCH 3/6] remove middle click as i dont use it --- .../java/me/night0721/lilase/utils/KeyBindingManager.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java b/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java index 16a3505..998550c 100644 --- a/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java +++ b/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java @@ -40,11 +40,6 @@ public class KeyBindingManager { } } - public static void middleClick() { - if (!ReflectionUtils.invoke(PlayerUtils.mc, "func_147112_ai")) { - ReflectionUtils.invoke(PlayerUtils.mc, "middleClickMouse"); - } - } public static void updateKeys(boolean forward, boolean back, boolean right, boolean left, boolean attack) { updateKeys(forward, back, right, left, attack, false, false); From 7f26cd36347c912386d85a44f915c35558a81ed9 Mon Sep 17 00:00:00 2001 From: NK Date: Sat, 25 Feb 2023 23:29:25 +0000 Subject: [PATCH 4/6] remove useless line --- src/main/java/me/night0721/lilase/Lilase.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/night0721/lilase/Lilase.java b/src/main/java/me/night0721/lilase/Lilase.java index 1e41d58..52a1586 100644 --- a/src/main/java/me/night0721/lilase/Lilase.java +++ b/src/main/java/me/night0721/lilase/Lilase.java @@ -62,17 +62,11 @@ public class Lilase { public void onTick(TickEvent.ClientTickEvent event) throws IOException { if (mc.thePlayer == null || event.phase != TickEvent.Phase.START) return; tickAmount++; - if (tickAmount % 20 == 0) { - Utils.checkForDungeon(); - } - if (tickAmount % (20 * AUCTION_HOUSE_DELAY) == 0) { - auctionHouse.getItem(); - } - if (tickAmount % 2400 == 0) { - ConfigUtils.checkWebhookAndAPI(); - } + if (tickAmount % 20 == 0) Utils.checkForDungeon(); + if (tickAmount % (20 * AUCTION_HOUSE_DELAY) == 0) auctionHouse.getItem(); + if (tickAmount % 2400 == 0) ConfigUtils.checkWebhookAndAPI(); AuctionHouse.flipper.switchStates(); - if ((mc.currentScreen instanceof GuiDisconnected)) { + if (mc.currentScreen instanceof GuiDisconnected) { if (waitTime >= (RECONNECT_DELAY * 20)) { waitTime = 0; FMLClientHandler.instance().connectToServer(new GuiMultiplayer(new GuiMainMenu()), new ServerData(" ", "mc.hypixel.net", false)); From 86ec615bd6746bf288f0ce75a3960f75f03f0031 Mon Sep 17 00:00:00 2001 From: NK Date: Sat, 25 Feb 2023 23:33:07 +0000 Subject: [PATCH 5/6] forget to add : in gui and bug fixing --- src/main/java/me/night0721/lilase/Lilase.java | 2 +- .../java/me/night0721/lilase/events/SniperFlipperEvents.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/night0721/lilase/Lilase.java b/src/main/java/me/night0721/lilase/Lilase.java index 52a1586..825d178 100644 --- a/src/main/java/me/night0721/lilase/Lilase.java +++ b/src/main/java/me/night0721/lilase/Lilase.java @@ -65,7 +65,7 @@ public class Lilase { if (tickAmount % 20 == 0) Utils.checkForDungeon(); if (tickAmount % (20 * AUCTION_HOUSE_DELAY) == 0) auctionHouse.getItem(); if (tickAmount % 2400 == 0) ConfigUtils.checkWebhookAndAPI(); - AuctionHouse.flipper.switchStates(); + if (AuctionHouse.flipper != null) AuctionHouse.flipper.switchStates(); if (mc.currentScreen instanceof GuiDisconnected) { if (waitTime >= (RECONNECT_DELAY * 20)) { waitTime = 0; diff --git a/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java b/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java index 3069930..9d061a9 100644 --- a/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java +++ b/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java @@ -164,7 +164,7 @@ public class SniperFlipperEvents { "Z: " + Math.round(PlayerUtils.mc.thePlayer.posZ) + "\n" + time + "\n" + "FPS: " + Minecraft.getDebugFPS() + "\n" + - "Auctions Sniped" + Lilase.auctionHouse.getAuctionsSniped(); + "Auctions Sniped: " + Lilase.auctionHouse.getAuctionsSniped(); TextRenderer.drawString(lines, 0, 0, 1.5, GUI_COLOR.getRGB()); } } From 9679d0caa07e90929526b4082f1da35e1256918d Mon Sep 17 00:00:00 2001 From: NK Date: Sun, 26 Feb 2023 00:20:51 +0000 Subject: [PATCH 6/6] v1.0.22 release --- build.gradle | 2 +- src/main/java/me/night0721/lilase/Lilase.java | 31 +++++---------- .../lilase/events/SniperFlipperEvents.java | 24 ++++++------ .../lilase/features/ah/AuctionHouse.java | 3 +- .../lilase/features/flip/Flipper.java | 24 ++++++------ .../me/night0721/lilase/gui/TextRenderer.java | 14 +++---- .../lilase/utils/KeyBindingManager.java | 38 +++++++++---------- .../night0721/lilase/utils/PlayerUtils.java | 7 +--- .../lilase/utils/ScoreboardUtils.java | 5 ++- .../java/me/night0721/lilase/utils/Utils.java | 25 +++--------- 10 files changed, 73 insertions(+), 100 deletions(-) diff --git a/build.gradle b/build.gradle index beedce2..2ae6d07 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ apply plugin: "net.minecraftforge.gradle.forge" apply plugin: "com.github.johnrengelman.shadow" apply plugin: "org.spongepowered.mixin" -version = "1.0.21" +version = "1.0.22" group = "me.night0721.lilase" archivesBaseName = "Lilase" sourceCompatibility = 1.8 diff --git a/src/main/java/me/night0721/lilase/Lilase.java b/src/main/java/me/night0721/lilase/Lilase.java index 825d178..4643d81 100644 --- a/src/main/java/me/night0721/lilase/Lilase.java +++ b/src/main/java/me/night0721/lilase/Lilase.java @@ -3,21 +3,17 @@ package me.night0721.lilase; import cc.polyfrost.oneconfig.events.EventManager; import cc.polyfrost.oneconfig.events.event.InitializationEvent; import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; -import com.mojang.realmsclient.gui.ChatFormatting; -import me.night0721.lilase.events.PacketReceivedEvent; import me.night0721.lilase.events.SniperFlipperEvents; import me.night0721.lilase.features.ah.AHConfig; import me.night0721.lilase.features.ah.AuctionHouse; +import me.night0721.lilase.utils.Clock; import me.night0721.lilase.utils.ConfigUtils; import me.night0721.lilase.utils.KeyBindingManager; -import me.night0721.lilase.utils.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiDisconnected; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.network.play.client.C0DPacketCloseWindow; -import net.minecraft.network.play.server.S2DPacketOpenWindow; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.Mod; @@ -34,12 +30,13 @@ import static me.night0721.lilase.features.ah.AHConfig.RECONNECT_DELAY; public class Lilase { public static final String MOD_NAME = "Lilase"; public static final String MODID = "Lilase"; - public static final String VERSION = "1.0.21"; - static int tickAmount; - int waitTime; + public static final String VERSION = "1.0.22"; + public static final Minecraft mc = Minecraft.getMinecraft(); public static AuctionHouse auctionHouse; public static AHConfig config; - static final Minecraft mc = Minecraft.getMinecraft(); + private int tickAmount; + private final Clock clock = new Clock(); + @Mod.EventHandler public void init(FMLInitializationEvent event) { @@ -62,25 +59,15 @@ public class Lilase { public void onTick(TickEvent.ClientTickEvent event) throws IOException { if (mc.thePlayer == null || event.phase != TickEvent.Phase.START) return; tickAmount++; - if (tickAmount % 20 == 0) Utils.checkForDungeon(); if (tickAmount % (20 * AUCTION_HOUSE_DELAY) == 0) auctionHouse.getItem(); if (tickAmount % 2400 == 0) ConfigUtils.checkWebhookAndAPI(); if (AuctionHouse.flipper != null) AuctionHouse.flipper.switchStates(); if (mc.currentScreen instanceof GuiDisconnected) { - if (waitTime >= (RECONNECT_DELAY * 20)) { - waitTime = 0; + if (clock.passed()) { + clock.schedule(RECONNECT_DELAY * 1000L); FMLClientHandler.instance().connectToServer(new GuiMultiplayer(new GuiMainMenu()), new ServerData(" ", "mc.hypixel.net", false)); - } else { - waitTime++; - } - } - } - @SubscribeEvent - public void onPacket(PacketReceivedEvent event) { - if (Utils.inDungeon && event.packet instanceof S2DPacketOpenWindow && ChatFormatting.stripFormatting(((S2DPacketOpenWindow) event.packet).getWindowTitle().getFormattedText()).equals("Chest")) { - event.setCanceled(true); - mc.getNetHandler().getNetworkManager().sendPacket(new C0DPacketCloseWindow(((S2DPacketOpenWindow) event.packet).getWindowId())); + } } } /* diff --git a/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java b/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java index 9d061a9..1d9959c 100644 --- a/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java +++ b/src/main/java/me/night0721/lilase/events/SniperFlipperEvents.java @@ -58,12 +58,12 @@ public class SniperFlipperEvents { flipper.sellItem(); } else if (message.equals("Your starting bid must be at least 10 coins!")) { InventoryUtils.clickOpenContainerSlot(13); - PlayerUtils.mc.thePlayer.closeScreen(); + Lilase.mc.thePlayer.closeScreen(); Utils.debugLog("[Flipper] Cannot post item as the cost is too low, stopping fliiper and starting sniper"); Lilase.auctionHouse.toggleAuction(); Flipper.state = FlipperState.NONE; } else if (message.contains("Can't create a BIN auction for this item for a PRICE this LOW!")) { - PlayerUtils.mc.thePlayer.closeScreen(); + Lilase.mc.thePlayer.closeScreen(); Utils.debugLog("[Flipper] Cannot post item as the cost is too low, stopping fliiper and starting sniper"); Lilase.auctionHouse.toggleAuction(); Flipper.state = FlipperState.NONE; @@ -110,12 +110,12 @@ public class SniperFlipperEvents { Thread.sleep(3000); InventoryUtils.clickOpenContainerSlot(10); Thread.sleep(3000); - PlayerUtils.mc.thePlayer.closeScreen(); + Lilase.mc.thePlayer.closeScreen(); } } else { Thread.sleep(1000 * 60 * 5); } - PlayerUtils.mc.thePlayer.sendChatMessage("/hub"); + Lilase.mc.thePlayer.sendChatMessage("/hub"); Thread.sleep(6000); Lilase.auctionHouse.toggleAuction(); } catch (Exception ignore) { @@ -138,7 +138,7 @@ public class SniperFlipperEvents { try { Utils.debugLog("[Flipper] Interrupting Flipper selling"); Thread.sleep(500); - PlayerUtils.mc.thePlayer.closeScreen(); + Lilase.mc.thePlayer.closeScreen(); Flipper.state = FlipperState.NONE; Lilase.auctionHouse.toggleAuction(); } catch (InterruptedException e) { @@ -159,9 +159,9 @@ public class SniperFlipperEvents { int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); String time = String.format("%02d:%02d", hour, minute); - String lines = "X: " + Math.round(PlayerUtils.mc.thePlayer.posX) + "\n" + - "Y: " + Math.round(PlayerUtils.mc.thePlayer.posY) + "\n" + - "Z: " + Math.round(PlayerUtils.mc.thePlayer.posZ) + "\n" + + String lines = "X: " + Math.round(Lilase.mc.thePlayer.posX) + "\n" + + "Y: " + Math.round(Lilase.mc.thePlayer.posY) + "\n" + + "Z: " + Math.round(Lilase.mc.thePlayer.posZ) + "\n" + time + "\n" + "FPS: " + Minecraft.getDebugFPS() + "\n" + "Auctions Sniped: " + Lilase.auctionHouse.getAuctionsSniped(); @@ -177,16 +177,16 @@ public class SniperFlipperEvents { ItemStack is = InventoryUtils.getStackInOpenContainerSlot(31); if (is != null && (is.getItem() == Items.gold_nugget || (AHConfig.BED_SPAM && is.getItem() == Items.bed))) { buying = true; - windowId = PlayerUtils.mc.thePlayer.openContainer.windowId; - PlayerUtils.mc.playerController.windowClick(windowId, 31, 0, 0, PlayerUtils.mc.thePlayer); + windowId = Lilase.mc.thePlayer.openContainer.windowId; + Lilase.mc.playerController.windowClick(windowId, 31, 0, 0, Lilase.mc.thePlayer); } else if (is != null && is.getItem() == Items.potato) { buying = false; - PlayerUtils.mc.thePlayer.closeScreen(); + Lilase.mc.thePlayer.closeScreen(); } } if (AHConfig.BED_SPAM) { if (buying && "Confirm Purchase".equals(windowName)) { - PlayerUtils.mc.playerController.windowClick(windowId + 1, 11, 0, 0, PlayerUtils.mc.thePlayer); + Lilase.mc.playerController.windowClick(windowId + 1, 11, 0, 0, Lilase.mc.thePlayer); buying = false; } } diff --git a/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java b/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java index 585b501..89a3c1c 100644 --- a/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java +++ b/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java @@ -1,5 +1,6 @@ package me.night0721.lilase.features.ah; +import me.night0721.lilase.Lilase; import me.night0721.lilase.features.flip.Flipper; import me.night0721.lilase.utils.*; import org.json.JSONArray; @@ -140,7 +141,7 @@ public class AuctionHouse { flipper = new Flipper(auction.getString("item_name"), auction.getString("item_bytes"), auction.getInt("starting_bid")); NumberFormat format = NumberFormat.getInstance(Locale.US); JSONObject profile = getHypixelData(auction.getString("auctioneer")); - if (profile.getJSONObject("player").getString("displayname").toLowerCase() == PlayerUtils.mc.thePlayer.getName().toLowerCase()) + if (profile.getJSONObject("player").getString("displayname").toLowerCase() == Lilase.mc.thePlayer.getName().toLowerCase()) break; Pattern pattern = Pattern.compile("§[0-9a-z]", Pattern.MULTILINE); Matcher matcher = pattern.matcher(auction.getString("item_lore")); diff --git a/src/main/java/me/night0721/lilase/features/flip/Flipper.java b/src/main/java/me/night0721/lilase/features/flip/Flipper.java index 2a992d2..fbd0f07 100644 --- a/src/main/java/me/night0721/lilase/features/flip/Flipper.java +++ b/src/main/java/me/night0721/lilase/features/flip/Flipper.java @@ -17,7 +17,7 @@ import java.nio.charset.StandardCharsets; public class Flipper { - private static String itemname = null; + private final String itemname; private final String bytedata; private final int itemprice; public static FlipperState state = FlipperState.NONE; @@ -51,8 +51,8 @@ public class Flipper { public void switchStates() { switch (state) { case WALKING_TO_FIRST_POINT: - if (PlayerUtils.mc.currentScreen != null) { - PlayerUtils.mc.thePlayer.closeScreen(); + if (Lilase.mc.currentScreen != null) { + Lilase.mc.thePlayer.closeScreen(); } else if (distanceToFirstPoint() < 0.7f) { Utils.debugLog("[Flipper] Moving to auction house"); KeyBindingManager.updateKeys(false, false, false, false, false); @@ -65,11 +65,11 @@ public class Flipper { } break; case WALKING_INTO_AUCTION_HOUSE: - if (PlayerUtils.mc.currentScreen != null) { - PlayerUtils.mc.thePlayer.closeScreen(); + if (Lilase.mc.currentScreen != null) { + Lilase.mc.thePlayer.closeScreen(); } else if (AngleUtils.smallestAngleDifference(AngleUtils.get360RotationYaw(), 88f) > 1.2) { Utils.debugLog("[Flipper] Rotating to Auction Master"); - rotation.easeTo(88f, PlayerUtils.mc.thePlayer.rotationPitch, 500); + rotation.easeTo(88f, Lilase.mc.thePlayer.rotationPitch, 500); } else if (distanceToAuctionMaster() < 0.7f) { Utils.debugLog("[Flipper] At Auction Master, opening shop"); KeyBindingManager.updateKeys(false, false, false, false, false); @@ -82,13 +82,13 @@ public class Flipper { } break; case BUYING: - if (PlayerUtils.mc.currentScreen == null && buyWait.passed()) { + if (Lilase.mc.currentScreen == null && buyWait.passed()) { final Entity auctionMaster = getAuctionMaster(); if (auctionMaster == null) { Utils.debugLog("[Flipper] Cannot find shop NPC, retrying"); buyWait.schedule(500); } else { - PlayerUtils.mc.playerController.interactWithEntitySendPacket(PlayerUtils.mc.thePlayer, auctionMaster); + Lilase.mc.playerController.interactWithEntitySendPacket(Lilase.mc.thePlayer, auctionMaster); buyWait.schedule(1500); } } else if (InventoryUtils.inventoryNameContains("Auction House") && buyWait.passed()) { @@ -127,7 +127,7 @@ public class Flipper { InventoryUtils.clickOpenContainerSlot(49); Lilase.auctionHouse.incrementAuctionsSniped(); buyWait.schedule(500); - PlayerUtils.mc.thePlayer.closeScreen(); + Lilase.mc.thePlayer.closeScreen(); buyWait.schedule(500); Utils.sendMessage("Posted item on Auction House, continue sniping now"); state = FlipperState.NONE; @@ -162,15 +162,15 @@ public class Flipper { } private float distanceToFirstPoint() { - return (float) Math.sqrt(Math.pow(PlayerUtils.mc.thePlayer.posX - (-2.5), 2) + Math.pow(PlayerUtils.mc.thePlayer.posZ - (-91.5), 2)); + return (float) Math.sqrt(Math.pow(Lilase.mc.thePlayer.posX - (-2.5), 2) + Math.pow(Lilase.mc.thePlayer.posZ - (-91.5), 2)); } private float distanceToAuctionMaster() { - return (float) Math.sqrt(Math.pow(PlayerUtils.mc.thePlayer.posX - (-45), 2) + Math.pow(PlayerUtils.mc.thePlayer.posZ - (-90), 2)); + return (float) Math.sqrt(Math.pow(Lilase.mc.thePlayer.posX - (-45), 2) + Math.pow(Lilase.mc.thePlayer.posZ - (-90), 2)); } private Entity getAuctionMaster() { - for (final Entity e : PlayerUtils.mc.theWorld.loadedEntityList) { + for (final Entity e : Lilase.mc.theWorld.loadedEntityList) { if (e instanceof EntityArmorStand) { final String name = StringUtils.stripControlCodes(e.getDisplayName().getUnformattedText()); if (name.startsWith("Auction Master")) { diff --git a/src/main/java/me/night0721/lilase/gui/TextRenderer.java b/src/main/java/me/night0721/lilase/gui/TextRenderer.java index acc7e4b..abd9844 100644 --- a/src/main/java/me/night0721/lilase/gui/TextRenderer.java +++ b/src/main/java/me/night0721/lilase/gui/TextRenderer.java @@ -1,6 +1,6 @@ package me.night0721.lilase.gui; -import me.night0721.lilase.utils.PlayerUtils; +import me.night0721.lilase.Lilase; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import org.lwjgl.opengl.GL11; @@ -9,10 +9,10 @@ public class TextRenderer { public static void drawString(String text, int x, int y, double scale) { double scaleReset = Math.pow(scale, -1); GL11.glScaled(scale, scale, scale); - y -= PlayerUtils.mc.fontRendererObj.FONT_HEIGHT * scale; + y -= Lilase.mc.fontRendererObj.FONT_HEIGHT * scale; for (String line : text.split("\n")) { - y += PlayerUtils.mc.fontRendererObj.FONT_HEIGHT * scale; - PlayerUtils.mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), 0xFFFFFF, true); + y += Lilase.mc.fontRendererObj.FONT_HEIGHT * scale; + Lilase.mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), 0xFFFFFF, true); } GL11.glScaled(scaleReset, scaleReset, scaleReset); GlStateManager.color(1, 1, 1, 1); @@ -22,10 +22,10 @@ public class TextRenderer { double scaleReset = Math.pow(scale, -1); GL11.glScaled(scale, scale, scale); - y -= PlayerUtils.mc.fontRendererObj.FONT_HEIGHT * scale; + y -= Lilase.mc.fontRendererObj.FONT_HEIGHT * scale; for (String line : text.split("\n")) { - y += PlayerUtils.mc.fontRendererObj.FONT_HEIGHT * scale; - PlayerUtils.mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), color, false); + y += Lilase.mc.fontRendererObj.FONT_HEIGHT * scale; + Lilase.mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), color, false); } GL11.glScaled(scaleReset, scaleReset, scaleReset); GlStateManager.color(1, 1, 1, 1); diff --git a/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java b/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java index 998550c..b2b80c8 100644 --- a/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java +++ b/src/main/java/me/night0721/lilase/utils/KeyBindingManager.java @@ -29,14 +29,14 @@ public class KeyBindingManager { } public static void rightClick() { - if (!ReflectionUtils.invoke(PlayerUtils.mc, "func_147121_ag")) { - ReflectionUtils.invoke(PlayerUtils.mc, "rightClickMouse"); + if (!ReflectionUtils.invoke(Lilase.mc, "func_147121_ag")) { + ReflectionUtils.invoke(Lilase.mc, "rightClickMouse"); } } public static void leftClick() { - if (!ReflectionUtils.invoke(PlayerUtils.mc, "func_147116_af")) { - ReflectionUtils.invoke(PlayerUtils.mc, "clickMouse"); + if (!ReflectionUtils.invoke(Lilase.mc, "func_147116_af")) { + ReflectionUtils.invoke(Lilase.mc, "clickMouse"); } } @@ -46,27 +46,27 @@ public class KeyBindingManager { } public static void updateKeys(boolean forward, boolean back, boolean right, boolean left, boolean attack, boolean crouch, boolean space) { - if (PlayerUtils.mc.currentScreen != null) { + if (Lilase.mc.currentScreen != null) { stopMovement(); return; } - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindForward.getKeyCode(), forward); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindBack.getKeyCode(), back); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindRight.getKeyCode(), right); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindLeft.getKeyCode(), left); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindAttack.getKeyCode(), attack); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindSneak.getKeyCode(), crouch); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindJump.getKeyCode(), space); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindForward.getKeyCode(), forward); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindBack.getKeyCode(), back); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindRight.getKeyCode(), right); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindLeft.getKeyCode(), left); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindAttack.getKeyCode(), attack); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindSneak.getKeyCode(), crouch); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindJump.getKeyCode(), space); } public static void stopMovement() { - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindForward.getKeyCode(), false); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindBack.getKeyCode(), false); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindRight.getKeyCode(), false); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindLeft.getKeyCode(), false); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindAttack.getKeyCode(), false); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindSneak.getKeyCode(), false); - KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindJump.getKeyCode(), false); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindForward.getKeyCode(), false); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindBack.getKeyCode(), false); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindRight.getKeyCode(), false); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindLeft.getKeyCode(), false); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindAttack.getKeyCode(), false); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindSneak.getKeyCode(), false); + KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindJump.getKeyCode(), false); } } diff --git a/src/main/java/me/night0721/lilase/utils/PlayerUtils.java b/src/main/java/me/night0721/lilase/utils/PlayerUtils.java index 348b483..cb38112 100644 --- a/src/main/java/me/night0721/lilase/utils/PlayerUtils.java +++ b/src/main/java/me/night0721/lilase/utils/PlayerUtils.java @@ -1,18 +1,15 @@ package me.night0721.lilase.utils; -import net.minecraft.client.Minecraft; +import me.night0721.lilase.Lilase; import net.minecraft.network.Packet; import java.util.ArrayList; public class PlayerUtils { - public static final Minecraft mc = Minecraft.getMinecraft(); - public static final ArrayList> packets = new ArrayList<>(); public static void sendPacketWithoutEvent(Packet packet) { packets.add(packet); - mc.getNetHandler().getNetworkManager().sendPacket(packet); - + Lilase.mc.getNetHandler().getNetworkManager().sendPacket(packet); } } diff --git a/src/main/java/me/night0721/lilase/utils/ScoreboardUtils.java b/src/main/java/me/night0721/lilase/utils/ScoreboardUtils.java index f280da3..86e6df1 100644 --- a/src/main/java/me/night0721/lilase/utils/ScoreboardUtils.java +++ b/src/main/java/me/night0721/lilase/utils/ScoreboardUtils.java @@ -2,6 +2,7 @@ package me.night0721.lilase.utils; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import me.night0721.lilase.Lilase; import net.minecraft.scoreboard.Score; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.ScorePlayerTeam; @@ -37,8 +38,8 @@ public class ScoreboardUtils { public static List getSidebarLines() { List lines = new ArrayList<>(); - if (PlayerUtils.mc.theWorld == null) return lines; - Scoreboard scoreboard = PlayerUtils.mc.theWorld.getScoreboard(); + if (Lilase.mc.theWorld == null) return lines; + Scoreboard scoreboard = Lilase.mc.theWorld.getScoreboard(); if (scoreboard == null) return lines; ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); diff --git a/src/main/java/me/night0721/lilase/utils/Utils.java b/src/main/java/me/night0721/lilase/utils/Utils.java index 00101d7..30e18fe 100644 --- a/src/main/java/me/night0721/lilase/utils/Utils.java +++ b/src/main/java/me/night0721/lilase/utils/Utils.java @@ -1,5 +1,6 @@ package me.night0721.lilase.utils; +import me.night0721.lilase.Lilase; import net.minecraft.network.play.server.S45PacketTitle; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -7,8 +8,6 @@ import net.minecraft.util.EnumChatFormatting; import java.util.List; public class Utils { - - public static boolean inDungeon; public static boolean inHub = false; public static String translateAlternateColorCodes(String text) { @@ -25,20 +24,8 @@ public class Utils { public static void addTitle(String title) { S45PacketTitle p1 = new S45PacketTitle(0, 20, 0); S45PacketTitle p2 = new S45PacketTitle(S45PacketTitle.Type.TITLE, new ChatComponentText(Utils.translateAlternateColorCodes(title))); - PlayerUtils.mc.thePlayer.sendQueue.handleTitle(p1); - PlayerUtils.mc.thePlayer.sendQueue.handleTitle(p2); - } - - public static void checkForDungeon() { - List scoreboard = ScoreboardUtils.getSidebarLines(); - for (String s : scoreboard) { - String sCleaned = ScoreboardUtils.cleanSB(s); - if (sCleaned.contains("The Catacombs") || (sCleaned.contains("Cleared:") && sCleaned.contains("% ("))) { - inDungeon = true; - return; - } - } - inDungeon = false; + Lilase.mc.thePlayer.sendQueue.handleTitle(p1); + Lilase.mc.thePlayer.sendQueue.handleTitle(p2); } public static boolean checkInHub() { @@ -52,14 +39,14 @@ public class Utils { } public static void sendMessage(String message) { - PlayerUtils.mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + EnumChatFormatting.BOLD + "Liliase" + EnumChatFormatting.RESET + EnumChatFormatting.DARK_GRAY + " » " + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + message)); + Lilase.mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + EnumChatFormatting.BOLD + "Liliase" + EnumChatFormatting.RESET + EnumChatFormatting.DARK_GRAY + " » " + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + message)); } public static void debugLog(String message) { - PlayerUtils.mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + "Liliase" + EnumChatFormatting.RESET + EnumChatFormatting.DARK_GRAY + " » " + EnumChatFormatting.RESET + EnumChatFormatting.WHITE + message)); + Lilase.mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + "Liliase" + EnumChatFormatting.RESET + EnumChatFormatting.DARK_GRAY + " » " + EnumChatFormatting.RESET + EnumChatFormatting.WHITE + message)); } public static void sendServerMessage(String message) { - PlayerUtils.mc.thePlayer.sendChatMessage(message); + Lilase.mc.thePlayer.sendChatMessage(message); } }