Merge remote-tracking branch 'origin/master'

# Conflicts:
#	build.gradle
This commit is contained in:
Dawson 2023-02-26 00:11:39 -05:00
commit 53535e4f93
12 changed files with 157 additions and 155 deletions

View file

@ -3,56 +3,51 @@ package me.night0721.lilase;
import cc.polyfrost.oneconfig.events.EventManager; import cc.polyfrost.oneconfig.events.EventManager;
import cc.polyfrost.oneconfig.events.event.InitializationEvent; import cc.polyfrost.oneconfig.events.event.InitializationEvent;
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
import com.mojang.realmsclient.gui.ChatFormatting;
import me.night0721.lilase.config.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.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.ConfigUtils;
import me.night0721.lilase.utils.Utils; import me.night0721.lilase.utils.KeyBindingManager;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiDisconnected; import net.minecraft.client.gui.GuiDisconnected;
import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiMultiplayer;
import net.minecraft.client.multiplayer.ServerData; 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.common.MinecraftForge;
import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.opengl.Display;
import java.io.IOException; import java.io.IOException;
import static me.night0721.lilase.config.AHConfig.AUCTION_HOUSE_DELAY; import static me.night0721.lilase.features.ah.AHConfig.AUCTION_HOUSE_DELAY;
import static me.night0721.lilase.config.AHConfig.RECONNECT_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]") @Mod(modid = Lilase.MODID, name = Lilase.MOD_NAME, version = Lilase.VERSION, acceptedMinecraftVersions = "[1.8.9]")
public class Lilase { public class Lilase {
public static final String MOD_NAME = "Lilase"; public static final String MOD_NAME = "Lilase";
public static final String MODID = "Lilase"; public static final String MODID = "Lilase";
public static final String VERSION = "1.0.21"; public static final String VERSION = "1.0.22";
static int tickAmount; public static final Minecraft mc = Minecraft.getMinecraft();
int waitTime;
public static AuctionHouse auctionHouse; public static AuctionHouse auctionHouse;
public static AHConfig config; public static AHConfig config;
static final Minecraft mc = Minecraft.getMinecraft(); private int tickAmount;
private final Clock clock = new Clock();
@Mod.EventHandler @Mod.EventHandler
public void init(FMLInitializationEvent event) { public void init(FMLInitializationEvent event) {
KeyBindingManager keyBindingManager = new KeyBindingManager();
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new KeyBindingManager()); MinecraftForge.EVENT_BUS.register(keyBindingManager);
MinecraftForge.EVENT_BUS.register(new SniperFlipperEvents()); MinecraftForge.EVENT_BUS.register(new SniperFlipperEvents());
EventManager.INSTANCE.register(this); EventManager.INSTANCE.register(this);
ConfigUtils.register(); ConfigUtils.register();
auctionHouse = new AuctionHouse(); auctionHouse = new AuctionHouse();
KeyBindingManager.registerKeyBindings(); keyBindingManager.registerKeyBindings();
Display.setTitle("Lilase v" + VERSION + " | night0721");
} }
@Subscribe @Subscribe
@ -64,31 +59,15 @@ public class Lilase {
public void onTick(TickEvent.ClientTickEvent event) throws IOException { public void onTick(TickEvent.ClientTickEvent event) throws IOException {
if (mc.thePlayer == null || event.phase != TickEvent.Phase.START) return; if (mc.thePlayer == null || event.phase != TickEvent.Phase.START) return;
tickAmount++; tickAmount++;
if (tickAmount % 20 == 0) { if (tickAmount % (20 * AUCTION_HOUSE_DELAY) == 0) auctionHouse.getItem();
Utils.checkForDungeon(); if (tickAmount % 2400 == 0) ConfigUtils.checkWebhookAndAPI();
} if (AuctionHouse.flipper != null) AuctionHouse.flipper.switchStates();
if (tickAmount % (20 * AUCTION_HOUSE_DELAY) == 0) { if (mc.currentScreen instanceof GuiDisconnected) {
auctionHouse.getItem(); if (clock.passed()) {
} clock.schedule(RECONNECT_DELAY * 1000L);
if (tickAmount % 2400 == 0) {
ConfigUtils.checkWebhookAndAPI();
}
Flipper.switchStates();
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)); 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()));
} }
} }
/* /*

View file

@ -1,7 +1,7 @@
package me.night0721.lilase.events; package me.night0721.lilase.events;
import me.night0721.lilase.Lilase; 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.Flipper;
import me.night0721.lilase.features.flip.FlipperState; import me.night0721.lilase.features.flip.FlipperState;
import me.night0721.lilase.gui.TextRenderer; import me.night0721.lilase.gui.TextRenderer;
@ -27,17 +27,15 @@ import java.io.IOException;
import java.util.Calendar; import java.util.Calendar;
import java.util.TimeZone; 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.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.Flipper.rotation;
import static me.night0721.lilase.features.flip.FlipperState.START; import static me.night0721.lilase.features.flip.FlipperState.START;
import static me.night0721.lilase.utils.PlayerUtils.sendPacketWithoutEvent; import static me.night0721.lilase.utils.PlayerUtils.sendPacketWithoutEvent;
public class SniperFlipperEvents { public class SniperFlipperEvents {
Thread bzchillingthread; private int windowId = 1;
private static int windowId = 1; private boolean buying = false;
private static boolean buying = false;
@SubscribeEvent @SubscribeEvent
public void onChat(ClientChatReceivedEvent event) throws InterruptedException, IOException { public void onChat(ClientChatReceivedEvent event) throws InterruptedException, IOException {
@ -56,26 +54,26 @@ public class SniperFlipperEvents {
ConfigUtils.writeStringConfig("main", "APIKey", apiKey); ConfigUtils.writeStringConfig("main", "APIKey", apiKey);
} else if (message.equals("Claiming BIN auction...") && buying) { } else if (message.equals("Claiming BIN auction...") && buying) {
Utils.debugLog("[Sniper] Bought an item, starting to sell"); Utils.debugLog("[Sniper] Bought an item, starting to sell");
webhook.execute(); Lilase.auctionHouse.webhook.execute();
flipper.sellItem(); flipper.sellItem();
} else if (message.equals("Your starting bid must be at least 10 coins!")) { } else if (message.equals("Your starting bid must be at least 10 coins!")) {
InventoryUtils.clickOpenContainerSlot(13); 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"); Utils.debugLog("[Flipper] Cannot post item as the cost is too low, stopping fliiper and starting sniper");
Lilase.auctionHouse.toggleAuction(); Lilase.auctionHouse.toggleAuction();
Flipper.state = FlipperState.NONE; Flipper.state = FlipperState.NONE;
} else if (message.contains("Can't create a BIN auction for this item for a PRICE this LOW!")) { } 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"); Utils.debugLog("[Flipper] Cannot post item as the cost is too low, stopping fliiper and starting sniper");
Lilase.auctionHouse.toggleAuction(); Lilase.auctionHouse.toggleAuction();
Flipper.state = FlipperState.NONE; Flipper.state = FlipperState.NONE;
} else if (message.contains("You were spawned in Limbo")) { } else if (message.contains("You were spawned in Limbo")) {
Utils.sendMessage("Detected in Limbo, stopping everything for 5 minutes"); Utils.sendMessage("Detected in Limbo, stopping everything for 5 minutes");
Flipper.state = FlipperState.NONE; Flipper.state = FlipperState.NONE;
if (Lilase.auctionHouse.open) Lilase.auctionHouse.toggleAuction(); if (Lilase.auctionHouse.getOpen()) Lilase.auctionHouse.toggleAuction();
Thread.sleep(5000); Thread.sleep(5000);
Utils.sendServerMessage("/hub"); Utils.sendServerMessage("/hub");
bzchillingthread = new Thread(bazaarChilling); Thread bzchillingthread = new Thread(bazaarChilling);
bzchillingthread.start(); bzchillingthread.start();
} }
} }
@ -112,12 +110,12 @@ public class SniperFlipperEvents {
Thread.sleep(3000); Thread.sleep(3000);
InventoryUtils.clickOpenContainerSlot(10); InventoryUtils.clickOpenContainerSlot(10);
Thread.sleep(3000); Thread.sleep(3000);
PlayerUtils.mc.thePlayer.closeScreen(); Lilase.mc.thePlayer.closeScreen();
} }
} else { } else {
Thread.sleep(1000 * 60 * 5); Thread.sleep(1000 * 60 * 5);
} }
PlayerUtils.mc.thePlayer.sendChatMessage("/hub"); Lilase.mc.thePlayer.sendChatMessage("/hub");
Thread.sleep(6000); Thread.sleep(6000);
Lilase.auctionHouse.toggleAuction(); Lilase.auctionHouse.toggleAuction();
} catch (Exception ignore) { } catch (Exception ignore) {
@ -140,7 +138,7 @@ public class SniperFlipperEvents {
try { try {
Utils.debugLog("[Flipper] Interrupting Flipper selling"); Utils.debugLog("[Flipper] Interrupting Flipper selling");
Thread.sleep(500); Thread.sleep(500);
PlayerUtils.mc.thePlayer.closeScreen(); Lilase.mc.thePlayer.closeScreen();
Flipper.state = FlipperState.NONE; Flipper.state = FlipperState.NONE;
Lilase.auctionHouse.toggleAuction(); Lilase.auctionHouse.toggleAuction();
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -161,7 +159,12 @@ public class SniperFlipperEvents {
int hour = cal.get(Calendar.HOUR_OF_DAY); int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE); int minute = cal.get(Calendar.MINUTE);
String time = String.format("%02d:%02d", hour, 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(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();
TextRenderer.drawString(lines, 0, 0, 1.5, GUI_COLOR.getRGB()); TextRenderer.drawString(lines, 0, 0, 1.5, GUI_COLOR.getRGB());
} }
} }
@ -174,23 +177,23 @@ public class SniperFlipperEvents {
ItemStack is = InventoryUtils.getStackInOpenContainerSlot(31); ItemStack is = InventoryUtils.getStackInOpenContainerSlot(31);
if (is != null && (is.getItem() == Items.gold_nugget || (AHConfig.BED_SPAM && is.getItem() == Items.bed))) { if (is != null && (is.getItem() == Items.gold_nugget || (AHConfig.BED_SPAM && is.getItem() == Items.bed))) {
buying = true; buying = true;
windowId = PlayerUtils.mc.thePlayer.openContainer.windowId; windowId = Lilase.mc.thePlayer.openContainer.windowId;
PlayerUtils.mc.playerController.windowClick(windowId, 31, 0, 0, PlayerUtils.mc.thePlayer); Lilase.mc.playerController.windowClick(windowId, 31, 0, 0, Lilase.mc.thePlayer);
} else if (is != null && is.getItem() == Items.potato) { } else if (is != null && is.getItem() == Items.potato) {
buying = false; buying = false;
PlayerUtils.mc.thePlayer.closeScreen(); Lilase.mc.thePlayer.closeScreen();
} }
} }
if (AHConfig.BED_SPAM) { if (AHConfig.BED_SPAM) {
if (buying && "Confirm Purchase".equals(windowName)) { 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; buying = false;
} }
} }
} }
@SubscribeEvent @SubscribeEvent
public void onWindowClick(PacketReceivedEvent event) { public void onPacketReceive(PacketReceivedEvent event) {
if (event.packet instanceof S33PacketUpdateSign && Utils.checkInHub() && Flipper.state.equals(START)) { if (event.packet instanceof S33PacketUpdateSign && Utils.checkInHub() && Flipper.state.equals(START)) {
new Thread(() -> { new Thread(() -> {
try { try {

View file

@ -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.Config;
import cc.polyfrost.oneconfig.config.annotations.Number; import cc.polyfrost.oneconfig.config.annotations.Number;

View file

@ -1,5 +1,6 @@
package me.night0721.lilase.features.ah; package me.night0721.lilase.features.ah;
import me.night0721.lilase.Lilase;
import me.night0721.lilase.features.flip.Flipper; import me.night0721.lilase.features.flip.Flipper;
import me.night0721.lilase.utils.*; import me.night0721.lilase.utils.*;
import org.json.JSONArray; import org.json.JSONArray;
@ -23,14 +24,14 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class AuctionHouse { public class AuctionHouse {
private static String uuid; private String uuid;
private static String message_toSend; private String message_toSend;
public static Flipper flipper; private Boolean open = false;
public static final DiscordWebhook webhook = new DiscordWebhook(ConfigUtils.getString("main", "Webhook")); private int auctionsSniped = 0;
public DiscordWebhook webhook = new DiscordWebhook(ConfigUtils.getString("main", "Webhook"));
public Boolean open = false;
private final List<Item> items = new ArrayList<>(); private final List<Item> items = new ArrayList<>();
private final List<String> posted = new ArrayList<>(); private final List<String> posted = new ArrayList<>();
public static Flipper flipper;
public AuctionHouse() { public AuctionHouse() {
if (!ConfigUtils.getString("item1", "Name").equals("") && !ConfigUtils.getString("item1", "Type").equals("") && !ConfigUtils.getString("item1", "Tier").equals("") && ConfigUtils.getInt("item1", "Price") != 0) if (!ConfigUtils.getString("item1", "Name").equals("") && !ConfigUtils.getString("item1", "Type").equals("") && !ConfigUtils.getString("item1", "Tier").equals("") && ConfigUtils.getInt("item1", "Price") != 0)
@ -141,7 +142,7 @@ public class AuctionHouse {
flipper = new Flipper(auction.getString("item_name"), auction.getString("item_bytes"), auction.getInt("starting_bid")); flipper = new Flipper(auction.getString("item_name"), auction.getString("item_bytes"), auction.getInt("starting_bid"));
NumberFormat format = NumberFormat.getInstance(Locale.US); NumberFormat format = NumberFormat.getInstance(Locale.US);
JSONObject profile = getHypixelData(auction.getString("auctioneer")); 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; break;
Pattern pattern = Pattern.compile("§[0-9a-z]", Pattern.MULTILINE); Pattern pattern = Pattern.compile("§[0-9a-z]", Pattern.MULTILINE);
Matcher matcher = pattern.matcher(auction.getString("item_lore")); Matcher matcher = pattern.matcher(auction.getString("item_lore"));
@ -167,7 +168,7 @@ public class AuctionHouse {
} }
} }
public static void sendAuction() { private void sendAuction() {
Utils.sendServerMessage("/viewauction " + uuid); Utils.sendServerMessage("/viewauction " + uuid);
Utils.sendMessage(message_toSend); Utils.sendMessage(message_toSend);
} }
@ -176,7 +177,6 @@ public class AuctionHouse {
private final List<String> timesString = Arrays.asList("year", "month", "day", "hour", "minute", "second"); private final List<String> timesString = Arrays.asList("year", "month", "day", "hour", "minute", "second");
public String toDuration(long duration) { public String toDuration(long duration) {
StringBuilder res = new StringBuilder(); StringBuilder res = new StringBuilder();
for (int i = 0; i < times.size(); i++) { for (int i = 0; i < times.size(); i++) {
Long current = times.get(i); Long current = times.get(i);
@ -190,12 +190,11 @@ public class AuctionHouse {
else return res.toString(); else return res.toString();
} }
private static String getTimeSinceDate(long timeSinceDate) { private String getTimeSinceDate(long timeSinceDate) {
long seconds = TimeUnit.MILLISECONDS.toSeconds(timeSinceDate); long seconds = TimeUnit.MILLISECONDS.toSeconds(timeSinceDate);
long minutes = TimeUnit.MILLISECONDS.toMinutes(timeSinceDate); long minutes = TimeUnit.MILLISECONDS.toMinutes(timeSinceDate);
long hours = TimeUnit.MILLISECONDS.toHours(timeSinceDate); long hours = TimeUnit.MILLISECONDS.toHours(timeSinceDate);
long days = TimeUnit.MILLISECONDS.toDays(timeSinceDate); long days = TimeUnit.MILLISECONDS.toDays(timeSinceDate);
if (seconds < 60) return "in " + seconds + " seconds"; if (seconds < 60) return "in " + seconds + " seconds";
else if (minutes < 60) return "in " + minutes + " minutes"; else if (minutes < 60) return "in " + minutes + " minutes";
else if (hours < 24) return "in " + hours + " hours"; else if (hours < 24) return "in " + hours + " hours";
@ -205,17 +204,33 @@ public class AuctionHouse {
public void toggleAuction() { public void toggleAuction() {
if (open) { if (open) {
Utils.sendMessage("Stopped Auction House"); Utils.sendMessage("Stopped AH Sniper");
open = false; open = false;
UngrabUtils.regrabMouse(); UngrabUtils.regrabMouse();
} else { } else {
if (Utils.checkInHub()) { if (Utils.checkInHub()) {
Utils.sendMessage("Started Auction House"); Utils.sendMessage("Started AH Sniper");
open = true; open = true;
UngrabUtils.ungrabMouse(); UngrabUtils.ungrabMouse();
} else Utils.sendMessage("Detected not in hub, please go to hub to start"); } 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;
}
} }

View file

@ -17,12 +17,12 @@ import java.nio.charset.StandardCharsets;
public class Flipper { public class Flipper {
private static String itemname = null; private final String itemname;
private final String bytedata; private final String bytedata;
private final int itemprice; private final int itemprice;
public static FlipperState state = FlipperState.NONE; public static FlipperState state = FlipperState.NONE;
public static final Rotation rotation = new Rotation(); 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) { public Flipper(String name, String data, int price) {
itemname = name; itemname = name;
@ -42,17 +42,17 @@ public class Flipper {
public void sellItem() { public void sellItem() {
Utils.sendMessage("Flipper is running, stopping, will resume when flipper is done"); 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(); UngrabUtils.ungrabMouse();
Utils.sendServerMessage("/hub"); Utils.sendServerMessage("/hub");
state = FlipperState.WALKING_TO_FIRST_POINT; state = FlipperState.WALKING_TO_FIRST_POINT;
} }
public static void switchStates() { public void switchStates() {
switch (state) { switch (state) {
case WALKING_TO_FIRST_POINT: case WALKING_TO_FIRST_POINT:
if (PlayerUtils.mc.currentScreen != null) { if (Lilase.mc.currentScreen != null) {
PlayerUtils.mc.thePlayer.closeScreen(); Lilase.mc.thePlayer.closeScreen();
} else if (distanceToFirstPoint() < 0.7f) { } else if (distanceToFirstPoint() < 0.7f) {
Utils.debugLog("[Flipper] Moving to auction house"); Utils.debugLog("[Flipper] Moving to auction house");
KeyBindingManager.updateKeys(false, false, false, false, false); KeyBindingManager.updateKeys(false, false, false, false, false);
@ -65,11 +65,11 @@ public class Flipper {
} }
break; break;
case WALKING_INTO_AUCTION_HOUSE: case WALKING_INTO_AUCTION_HOUSE:
if (PlayerUtils.mc.currentScreen != null) { if (Lilase.mc.currentScreen != null) {
PlayerUtils.mc.thePlayer.closeScreen(); Lilase.mc.thePlayer.closeScreen();
} else if (AngleUtils.smallestAngleDifference(AngleUtils.get360RotationYaw(), 88f) > 1.2) { } else if (AngleUtils.smallestAngleDifference(AngleUtils.get360RotationYaw(), 88f) > 1.2) {
Utils.debugLog("[Flipper] Rotating to Auction Master"); 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) { } else if (distanceToAuctionMaster() < 0.7f) {
Utils.debugLog("[Flipper] At Auction Master, opening shop"); Utils.debugLog("[Flipper] At Auction Master, opening shop");
KeyBindingManager.updateKeys(false, false, false, false, false); KeyBindingManager.updateKeys(false, false, false, false, false);
@ -82,13 +82,13 @@ public class Flipper {
} }
break; break;
case BUYING: case BUYING:
if (PlayerUtils.mc.currentScreen == null && buyWait.passed()) { if (Lilase.mc.currentScreen == null && buyWait.passed()) {
final Entity auctionMaster = getAuctionMaster(); final Entity auctionMaster = getAuctionMaster();
if (auctionMaster == null) { if (auctionMaster == null) {
Utils.debugLog("[Flipper] Cannot find shop NPC, retrying"); Utils.debugLog("[Flipper] Cannot find shop NPC, retrying");
buyWait.schedule(500); buyWait.schedule(500);
} else { } else {
PlayerUtils.mc.playerController.interactWithEntitySendPacket(PlayerUtils.mc.thePlayer, auctionMaster); Lilase.mc.playerController.interactWithEntitySendPacket(Lilase.mc.thePlayer, auctionMaster);
buyWait.schedule(1500); buyWait.schedule(1500);
} }
} else if (InventoryUtils.inventoryNameContains("Auction House") && buyWait.passed()) { } else if (InventoryUtils.inventoryNameContains("Auction House") && buyWait.passed()) {
@ -99,7 +99,7 @@ public class Flipper {
if (InventoryUtils.getSlotForItem(itemname) == -1) { if (InventoryUtils.getSlotForItem(itemname) == -1) {
Utils.sendMessage("Cannot find item in inventory, stopping flipper"); Utils.sendMessage("Cannot find item in inventory, stopping flipper");
state = FlipperState.NONE; state = FlipperState.NONE;
Lilase.auctionHouse.open = true; Lilase.auctionHouse.setOpen(true);
return; return;
} }
InventoryUtils.clickOpenContainerSlot(InventoryUtils.getSlotForItem(itemname)); InventoryUtils.clickOpenContainerSlot(InventoryUtils.getSlotForItem(itemname));
@ -125,7 +125,10 @@ public class Flipper {
buyWait.schedule(1000); buyWait.schedule(1000);
} else if (InventoryUtils.inventoryNameContains("BIN Auction View") && buyWait.passed()) { } else if (InventoryUtils.inventoryNameContains("BIN Auction View") && buyWait.passed()) {
InventoryUtils.clickOpenContainerSlot(49); InventoryUtils.clickOpenContainerSlot(49);
PlayerUtils.mc.thePlayer.closeScreen(); Lilase.auctionHouse.incrementAuctionsSniped();
buyWait.schedule(500);
Lilase.mc.thePlayer.closeScreen();
buyWait.schedule(500);
Utils.sendMessage("Posted item on Auction House, continue sniping now"); Utils.sendMessage("Posted item on Auction House, continue sniping now");
state = FlipperState.NONE; state = FlipperState.NONE;
Lilase.auctionHouse.toggleAuction(); Lilase.auctionHouse.toggleAuction();
@ -158,16 +161,16 @@ public class Flipper {
return new JSONObject(content.toString()); 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)); return (float) Math.sqrt(Math.pow(Lilase.mc.thePlayer.posX - (-2.5), 2) + Math.pow(Lilase.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)); return (float) Math.sqrt(Math.pow(Lilase.mc.thePlayer.posX - (-45), 2) + Math.pow(Lilase.mc.thePlayer.posZ - (-90), 2));
} }
private static Entity getAuctionMaster() { private Entity getAuctionMaster() {
for (final Entity e : PlayerUtils.mc.theWorld.loadedEntityList) { for (final Entity e : Lilase.mc.theWorld.loadedEntityList) {
if (e instanceof EntityArmorStand) { if (e instanceof EntityArmorStand) {
final String name = StringUtils.stripControlCodes(e.getDisplayName().getUnformattedText()); final String name = StringUtils.stripControlCodes(e.getDisplayName().getUnformattedText());
if (name.startsWith("Auction Master")) { if (name.startsWith("Auction Master")) {

View file

@ -1,6 +1,6 @@
package me.night0721.lilase.gui; 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.Minecraft;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -9,10 +9,10 @@ public class TextRenderer {
public static void drawString(String text, int x, int y, double scale) { public static void drawString(String text, int x, int y, double scale) {
double scaleReset = Math.pow(scale, -1); double scaleReset = Math.pow(scale, -1);
GL11.glScaled(scale, scale, scale); 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")) { for (String line : text.split("\n")) {
y += PlayerUtils.mc.fontRendererObj.FONT_HEIGHT * scale; y += Lilase.mc.fontRendererObj.FONT_HEIGHT * scale;
PlayerUtils.mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), 0xFFFFFF, true); Lilase.mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), 0xFFFFFF, true);
} }
GL11.glScaled(scaleReset, scaleReset, scaleReset); GL11.glScaled(scaleReset, scaleReset, scaleReset);
GlStateManager.color(1, 1, 1, 1); GlStateManager.color(1, 1, 1, 1);
@ -22,10 +22,10 @@ public class TextRenderer {
double scaleReset = Math.pow(scale, -1); double scaleReset = Math.pow(scale, -1);
GL11.glScaled(scale, scale, scale); 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")) { for (String line : text.split("\n")) {
y += PlayerUtils.mc.fontRendererObj.FONT_HEIGHT * scale; y += Lilase.mc.fontRendererObj.FONT_HEIGHT * scale;
PlayerUtils.mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), color, false); Lilase.mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), color, false);
} }
GL11.glScaled(scaleReset, scaleReset, scaleReset); GL11.glScaled(scaleReset, scaleReset, scaleReset);
GlStateManager.color(1, 1, 1, 1); GlStateManager.color(1, 1, 1, 1);

View file

@ -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");
}
}

View file

@ -8,10 +8,10 @@ import net.minecraftforge.fml.common.gameevent.InputEvent;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
public class KeyBindingManager { public class KeyBindingManager {
private static final KeyBinding[] keyBindings = new KeyBinding[4]; private final KeyBinding[] keyBindings = new KeyBinding[2];
public static void registerKeyBindings() { public void registerKeyBindings() {
keyBindings[0] = new KeyBinding("Auction House Toggle", Keyboard.KEY_END, Lilase.MOD_NAME); keyBindings[0] = new KeyBinding("Sniper Toggle", Keyboard.KEY_END, Lilase.MOD_NAME);
keyBindings[1] = new KeyBinding("Config", Keyboard.KEY_MULTIPLY, Lilase.MOD_NAME); keyBindings[1] = new KeyBinding("Config", Keyboard.KEY_MULTIPLY, Lilase.MOD_NAME);
for (KeyBinding keyBinding : keyBindings) { for (KeyBinding keyBinding : keyBindings) {
ClientRegistry.registerKeyBinding(keyBinding); ClientRegistry.registerKeyBinding(keyBinding);
@ -29,49 +29,44 @@ public class KeyBindingManager {
} }
public static void rightClick() { public static void rightClick() {
if (!ReflectionUtils.invoke(PlayerUtils.mc, "func_147121_ag")) { if (!ReflectionUtils.invoke(Lilase.mc, "func_147121_ag")) {
ReflectionUtils.invoke(PlayerUtils.mc, "rightClickMouse"); ReflectionUtils.invoke(Lilase.mc, "rightClickMouse");
} }
} }
public static void leftClick() { public static void leftClick() {
if (!ReflectionUtils.invoke(PlayerUtils.mc, "func_147116_af")) { if (!ReflectionUtils.invoke(Lilase.mc, "func_147116_af")) {
ReflectionUtils.invoke(PlayerUtils.mc, "clickMouse"); ReflectionUtils.invoke(Lilase.mc, "clickMouse");
} }
} }
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) { public static void updateKeys(boolean forward, boolean back, boolean right, boolean left, boolean attack) {
updateKeys(forward, back, right, left, attack, false, false); updateKeys(forward, back, right, left, attack, false, false);
} }
public static void updateKeys(boolean forward, boolean back, boolean right, boolean left, boolean attack, boolean crouch, boolean space) { 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(); stopMovement();
return; return;
} }
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindForward.getKeyCode(), forward); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindForward.getKeyCode(), forward);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindBack.getKeyCode(), back); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindBack.getKeyCode(), back);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindRight.getKeyCode(), right); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindRight.getKeyCode(), right);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindLeft.getKeyCode(), left); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindLeft.getKeyCode(), left);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindAttack.getKeyCode(), attack); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindAttack.getKeyCode(), attack);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindSneak.getKeyCode(), crouch); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindSneak.getKeyCode(), crouch);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindJump.getKeyCode(), space); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindJump.getKeyCode(), space);
} }
public static void stopMovement() { public static void stopMovement() {
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindForward.getKeyCode(), false); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindForward.getKeyCode(), false);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindBack.getKeyCode(), false); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindBack.getKeyCode(), false);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindRight.getKeyCode(), false); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindRight.getKeyCode(), false);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindLeft.getKeyCode(), false); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindLeft.getKeyCode(), false);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindAttack.getKeyCode(), false); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindAttack.getKeyCode(), false);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindSneak.getKeyCode(), false); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindSneak.getKeyCode(), false);
KeyBinding.setKeyBindState(PlayerUtils.mc.gameSettings.keyBindJump.getKeyCode(), false); KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindJump.getKeyCode(), false);
} }
} }

View file

@ -1,18 +1,15 @@
package me.night0721.lilase.utils; package me.night0721.lilase.utils;
import net.minecraft.client.Minecraft; import me.night0721.lilase.Lilase;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import java.util.ArrayList; import java.util.ArrayList;
public class PlayerUtils { public class PlayerUtils {
public static final Minecraft mc = Minecraft.getMinecraft();
public static final ArrayList<Packet<?>> packets = new ArrayList<>(); public static final ArrayList<Packet<?>> packets = new ArrayList<>();
public static void sendPacketWithoutEvent(Packet<?> packet) { public static void sendPacketWithoutEvent(Packet<?> packet) {
packets.add(packet); packets.add(packet);
mc.getNetHandler().getNetworkManager().sendPacket(packet); Lilase.mc.getNetHandler().getNetworkManager().sendPacket(packet);
} }
} }

View file

@ -2,6 +2,7 @@ package me.night0721.lilase.utils;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import me.night0721.lilase.Lilase;
import net.minecraft.scoreboard.Score; import net.minecraft.scoreboard.Score;
import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.ScorePlayerTeam;
@ -37,8 +38,8 @@ public class ScoreboardUtils {
public static List<String> getSidebarLines() { public static List<String> getSidebarLines() {
List<String> lines = new ArrayList<>(); List<String> lines = new ArrayList<>();
if (PlayerUtils.mc.theWorld == null) return lines; if (Lilase.mc.theWorld == null) return lines;
Scoreboard scoreboard = PlayerUtils.mc.theWorld.getScoreboard(); Scoreboard scoreboard = Lilase.mc.theWorld.getScoreboard();
if (scoreboard == null) return lines; if (scoreboard == null) return lines;
ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1);

View file

@ -1,5 +1,6 @@
package me.night0721.lilase.utils; package me.night0721.lilase.utils;
import me.night0721.lilase.Lilase;
import net.minecraft.network.play.server.S45PacketTitle; import net.minecraft.network.play.server.S45PacketTitle;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
@ -7,8 +8,6 @@ import net.minecraft.util.EnumChatFormatting;
import java.util.List; import java.util.List;
public class Utils { public class Utils {
public static boolean inDungeon;
public static boolean inHub = false; public static boolean inHub = false;
public static String translateAlternateColorCodes(String text) { public static String translateAlternateColorCodes(String text) {
@ -25,20 +24,8 @@ public class Utils {
public static void addTitle(String title) { public static void addTitle(String title) {
S45PacketTitle p1 = new S45PacketTitle(0, 20, 0); S45PacketTitle p1 = new S45PacketTitle(0, 20, 0);
S45PacketTitle p2 = new S45PacketTitle(S45PacketTitle.Type.TITLE, new ChatComponentText(Utils.translateAlternateColorCodes(title))); S45PacketTitle p2 = new S45PacketTitle(S45PacketTitle.Type.TITLE, new ChatComponentText(Utils.translateAlternateColorCodes(title)));
PlayerUtils.mc.thePlayer.sendQueue.handleTitle(p1); Lilase.mc.thePlayer.sendQueue.handleTitle(p1);
PlayerUtils.mc.thePlayer.sendQueue.handleTitle(p2); Lilase.mc.thePlayer.sendQueue.handleTitle(p2);
}
public static void checkForDungeon() {
List<String> 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;
} }
public static boolean checkInHub() { public static boolean checkInHub() {
@ -52,14 +39,14 @@ public class Utils {
} }
public static void sendMessage(String message) { 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) { 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) { public static void sendServerMessage(String message) {
PlayerUtils.mc.thePlayer.sendChatMessage(message); Lilase.mc.thePlayer.sendChatMessage(message);
} }
} }

View file

@ -3,7 +3,11 @@
"package": "me.night0721.lilase.mixins", "package": "me.night0721.lilase.mixins",
"refmap": "mixins.night0721.refmap.json", "refmap": "mixins.night0721.refmap.json",
"compatibilityLevel": "JAVA_8", "compatibilityLevel": "JAVA_8",
"minVersion": "0.8.2",
"mixins": [ "mixins": [
"MixinNetworkManager" "MixinNetworkManager"
],
"client": [
"MixinMinecraft"
] ]
} }