v2.0.3 ready
Some checks failed
build-ci / build (push) Has been cancelled

This commit is contained in:
NK 2023-05-21 11:03:28 +01:00
parent 388a6e379a
commit 0eb36bd25c
21 changed files with 541 additions and 499 deletions

10
.github/CHANGELOG.md vendored
View file

@ -44,3 +44,13 @@
- Added many more stuff to debug
- v2.0.2
- Minor bug fixes
- v2.0.3
- Remove unecessary code
- Added debug option so you can choose to be spammed by debug message or not
- Uses altnative approach to snipe item so it is faster now
- Using lombok so less code is needed
- Added relist delay so you can set the delay between buying and relist
- Using OOP for selling item so less error
- Fixed pricing issue
- Item not found error should be fixed
- Added gui to tell you to update the mod

View file

@ -1,6 +1,6 @@
mod_name = Lilase
mod_id = lilase
mod_version = 2.0.2
mod_version = 2.0.3
essential.defaults.loom=0

View file

@ -7,7 +7,6 @@ import me.night0721.lilase.config.AHConfig;
import me.night0721.lilase.config.ConfigHandler;
import me.night0721.lilase.events.SniperFlipperEvents;
import me.night0721.lilase.features.cofl.Cofl;
import me.night0721.lilase.features.cofl.QueueItem;
import me.night0721.lilase.features.sniper.PageFlipper;
import me.night0721.lilase.features.sniper.Sniper;
import me.night0721.lilase.gui.ImageRenderer;
@ -32,7 +31,7 @@ import static me.night0721.lilase.config.AHConfig.RECONNECT_DELAY;
public class Lilase {
public static final String MOD_NAME = "Lilase";
public static final String MODID = "Lilase";
public static final String VERSION = "2.0.2";
public static final String VERSION = "2.0.3";
public static final Minecraft mc = Minecraft.getMinecraft();
public static Sniper sniper;
public static PageFlipper pageFlipper;
@ -69,7 +68,6 @@ public class Lilase {
tickAmount++;
if (tickAmount % 20 == 0) Utils.checkFooter();
if (pageFlipper != null) pageFlipper.switchStates();
if (QueueItem.flipper != null) QueueItem.flipper.switchStates();
if (mc.currentScreen instanceof GuiDisconnected && clock.passed()) {
clock.schedule(RECONNECT_DELAY * 1000L);
FMLClientHandler.instance().connectToServer(new GuiMultiplayer(new GuiMainMenu()), new ServerData(" ", "mc.hypixel.net", false));

View file

@ -20,6 +20,8 @@ public class AHConfig extends Config {
addListener("ONLY_SNIPER", () -> Lilase.configHandler.setBoolean("OnlySniper", ONLY_SNIPER));
addListener("GUI", () -> Lilase.configHandler.setBoolean("GUI", GUI));
addListener("GUI_COLOR", () -> Lilase.configHandler.setInt("GUI_COLOR", GUI_COLOR.getRGB()));
addListener("RELIST_TIMEOUT", () -> Lilase.configHandler.setInt("RELIST_TIMEOUT", Math.round(RELIST_TIMEOUT)));
addListener("DEBUG", () -> Lilase.configHandler.setBoolean("Debug", DEBUG));
addDependency("WEBHOOK", "SEND_MESSAGE");
addDependency("MINIMUM_PROFIT_PERCENTAGE", "CHECK_PERCENTAGE");
addDependency("MAXIMUM_PROFIT_PERCENTAGE", "CHECK_MAXIMUM_PROFIT");
@ -32,6 +34,12 @@ public class AHConfig extends Config {
@Slider(name = "Bed Spam Delay (ms)", min = 50, max = 500, step = 50, category = "Auction House", subcategory = "Sniper", description = "Delay between each bed spam")
public static int BED_SPAM_DELAY = 100;
@Number(name = "Relist timeout", min = 1500, max = 60000, step = 500, category = "Auction House", subcategory = "Sniper", description = "Delay between buying and relisting an item")
public static int RELIST_TIMEOUT = 1500;
@Switch(name = "Debug", category = "Auction House", subcategory = "Sniper", description = "Debug mode")
public static boolean DEBUG = false;
@Switch(name = "Only Sniper", category = "Auction House", subcategory = "Sniper", description = "Only snipe items, stop auto resell")
public static boolean ONLY_SNIPER = false;

View file

@ -28,6 +28,8 @@ public class ConfigHandler {
if (hasNoKey("OnlySniper")) setBoolean("OnlySniper", false);
if (hasNoKey("GUI")) setBoolean("GUI", true);
if (hasNoKey("GUI_COLOR")) setInt("GUI_COLOR", 0x003153);
if (hasNoKey("DEBUG")) setBoolean("DEBUG", false);
if (hasNoKey("RELIST_TIMEOUT")) setInt("RELIST_TIMEOUT", 1500);
}
public JsonObject readConfigFile() {

View file

@ -2,7 +2,6 @@ package me.night0721.lilase.events;
import me.night0721.lilase.Lilase;
import me.night0721.lilase.config.AHConfig;
import me.night0721.lilase.features.cofl.Cofl;
import me.night0721.lilase.features.cofl.QueueItem;
import me.night0721.lilase.features.flipper.Flipper;
import me.night0721.lilase.features.flipper.FlipperState;
@ -13,102 +12,77 @@ import me.night0721.lilase.utils.*;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.client.C12PacketUpdateSign;
import net.minecraft.network.play.server.S2DPacketOpenWindow;
import net.minecraft.network.play.server.S2FPacketSetSlot;
import net.minecraft.network.play.server.S33PacketUpdateSign;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.input.Keyboard;
import java.awt.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static me.night0721.lilase.config.AHConfig.GUI_COLOR;
import static me.night0721.lilase.config.AHConfig.SEND_MESSAGE;
import static me.night0721.lilase.config.AHConfig.*;
import static me.night0721.lilase.features.flipper.Flipper.*;
import static me.night0721.lilase.features.flipper.FlipperState.START;
import static me.night0721.lilase.utils.PlayerUtils.sendPacketWithoutEvent;
public class SniperFlipperEvents {
private int windowId = 1, price;
private boolean buying = false, bought = false;
private final Clock clock = new Clock();
private final Pattern AUCTION_SOLD_PATTERN = Pattern.compile("^(.*?) bought (.*?) for ([\\d,]+) coins CLICK$"),
pattern = Pattern.compile("You purchased (\\w+(?:\\s+\\w+)*) for ([\\d,]+)\\s*(\\w+)|You claimed (.+?) from (.+?)'s auction!|(You (purchased|claimed)( (\\\\d+x))? ([^\\\\s]+(\\\\s+[^\\\\d,]+)*)((,| for) (\\\\d+,?)+ coins?(!)?))?");
public static final List<String> postedNames = new ArrayList<>();
public static final ArrayList<Flipper> selling_queue = new ArrayList<>();
private final Pattern AUCTION_SOLD_PATTERN = Pattern.compile("^(.*?) bought (.*?) for ([\\d,]+) coins CLICK$");
@SubscribeEvent
public void onChat(ClientChatReceivedEvent event) throws InterruptedException {
String message = event.message.getUnformattedText();
if (!message.contains(":")) {
if (message.startsWith("§6[Auction]")) {
// §6[Auction] §aphiinix_ §ebought §fImplosion Belt §efor §6900,000 coins §lCLICK
Matcher matcher = AUCTION_SOLD_PATTERN.matcher(ScoreboardUtils.cleanSB(message));
if (matcher.matches()) {
String purchaser;
try {
purchaser = matcher.group(1).split("\\[Auction] ")[1];
} catch (Exception ignored) {
purchaser = message.split("\\[Auction] ")[1].split(" bought")[0];
}
if (SEND_MESSAGE) {
try {
webhook.setUsername("Lilase");
webhook.setAvatarUrl(icon);
webhook.addEmbed(new DiscordWebhook.EmbedObject()
.setTitle("Someone bought an item!")
.setFooter("Purse: " + format.format(Utils.getPurse()), icon)
.addField("Item:", matcher.group(2), true)
.addField("Price:", matcher.group(3), true)
.addField("Purchaser:", matcher.group(1), true)
.setColor(Color.decode("#003153")));
if (SEND_MESSAGE) webhook.execute();
webhook.addEmbed(new DiscordWebhook.EmbedObject().setTitle("Someone bought an item!").setFooter("Purse: " + format.format(Utils.getPurse()), icon).addField("Item:", matcher.group(2), true).addField("Price:", matcher.group(3), true).addField("Purchaser:", purchaser, true).setColor(Color.decode("#003153")));
webhook.execute();
Utils.debugLog("Notified Webhook");
} catch (Exception e) {
e.printStackTrace();
Utils.debugLog("Failed to send webhook");
}
}
Lilase.sniper.incrementAuctionsFlipped();
}
}
/*
§6[Auction] §aphiinix_ §ebought §fImplosion Belt §efor §6900,000 coins §lCLICK
*/
Matcher boughtMatcher = pattern.matcher(message);
if (!message.contains(":")) {
if (message.equals("You didn't participate in this auction!")) {
} else if (message.equals("You didn't participate in this auction!")) {
Utils.debugLog("Failed to buy item, not fast enough. Closing the menu");
InventoryUtils.clickOpenContainerSlot(49);
} else if (message.equals("You don't have enough coins to afford this bid!")) {
Utils.debugLog("Failed to buy item, not enough money. Closing the menu");
InventoryUtils.clickOpenContainerSlot(49);
} else if (boughtMatcher.matches() && bought) {
new Thread(() -> {
bought = false;
Utils.debugLog("Bought an item, starting to sell");
Utils.debugLog("Target price " + Cofl.target);
price = Cofl.target;
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (!AHConfig.ONLY_SNIPER) QueueItem.flipper.sellItem();
}).start();
} 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!") || message.contains("Can't create a BIN auction for this item for a PRICE this LOW!")) {
InventoryUtils.clickOpenContainerSlot(13);
Lilase.mc.thePlayer.closeScreen();
Utils.debugLog("Cannot post item as the cost is too low, stopping fliiper and starting sniper");
Lilase.cofl.toggleAuction();
Flipper.state = FlipperState.NONE;
} else if (message.contains("Can't create a BIN auction for this item for a PRICE this LOW!")) {
Lilase.mc.thePlayer.closeScreen();
Utils.debugLog("Cannot post item as the cost is too low, stopping fliiper and starting sniper");
Lilase.cofl.toggleAuction();
Flipper.state = FlipperState.NONE;
} else if (message.contains("You were spawned in Limbo")) {
Utils.debugLog("Detected in Limbo, stopping everything for 5 minutes");
Utils.addTitle("You got sent to Limbo!");
@ -124,6 +98,15 @@ public class SniperFlipperEvents {
}
}
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (Lilase.mc.thePlayer == null || event.phase != TickEvent.Phase.START) return;
try {
if (selling_queue.get(0) != null) selling_queue.forEach(Flipper::switchStates);
} catch (Exception ignored) {
}
}
private final Runnable bazaarChilling = () -> {
try {
rotation.reset();
@ -182,7 +165,8 @@ public class SniperFlipperEvents {
if (Flipper.state != FlipperState.NONE) {
new Thread(() -> {
Utils.debugLog("Interrupting Flipper selling");
Flipper.sendInterrupt();
selling_queue.get(0).sendInterrupt();
selling_queue.remove(0);
Lilase.mc.thePlayer.closeScreen();
Flipper.state = FlipperState.NONE;
Lilase.cofl.toggleAuction();
@ -219,56 +203,78 @@ public class SniperFlipperEvents {
}
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onInventoryRendering(GuiScreenEvent.BackgroundDrawnEvent event) {
String windowName = InventoryUtils.getInventoryName();
if (AHConfig.BED_SPAM && (Lilase.pageFlipper.getOpen() || Lilase.cofl.getOpen())) {
if ("BIN Auction View".equals(windowName)) {
ItemStack is = InventoryUtils.getStackInOpenContainerSlot(31);
if (is != null) {
System.out.println("Slot 31: " + is.getItem().getRegistryName());
buying = true;
windowId = Lilase.mc.thePlayer.openContainer.windowId;
if (is.getItem() == Items.bed && clock.passed()) {
Lilase.mc.playerController.windowClick(windowId, 31, 0, 0, Lilase.mc.thePlayer);
clock.schedule(AHConfig.BED_SPAM_DELAY);
} else if (is.getItem() == Items.gold_nugget)
Lilase.mc.playerController.windowClick(windowId, 31, 0, 0, Lilase.mc.thePlayer);
else if (is.getItem() == Items.potato) {
buying = false;
Lilase.mc.thePlayer.closeScreen();
} else if (is.getItem() == Items.feather) {
buying = false;
Lilase.mc.thePlayer.closeScreen();
} else {
System.out.println("Not potato, not bed, not nugget, not feather??");
buying = false;
Lilase.mc.thePlayer.closeScreen();
}
}
}
if (buying && "Confirm Purchase".equals(windowName)) {
System.out.println("Window ID: " + Lilase.mc.thePlayer.openContainer.windowId);
Lilase.mc.playerController.windowClick(windowId + 1, 11, 0, 0, Lilase.mc.thePlayer);
buying = false;
if (Lilase.cofl.getQueue().isRunning()) bought = true;
}
}
}
private int latestWindowId = -1;
@SubscribeEvent
public void onPacketReceive(PacketReceivedEvent event) {
if (event.packet instanceof S2FPacketSetSlot) {
S2FPacketSetSlot packetSetSlot = (S2FPacketSetSlot) event.packet;
ItemStack stack = packetSetSlot.func_149174_e();
if (stack != null && packetSetSlot.func_149175_c() == 0) {
try {
String uuid = stack.getTagCompound().getCompoundTag("ExtraAttributes").getString("uuid");
String uid = uuid.split("-")[4];
QueueItem item = Lilase.cofl.getQueue().getHistoryByUID(uid);
if (item != null) {
String unFormattedName = ScoreboardUtils.cleanSB(stack.getDisplayName());
int slot = packetSetSlot.func_149173_d();
NBTTagCompound tag = stack.getTagCompound();
System.out.println("Slot: " + slot + "\nStack Name: " + unFormattedName + " \nStack NBT: " + tag);
new Thread(() -> {
if (!ONLY_SNIPER) {
item.flipper = new Flipper(item.name, item.price, item.target, uuid);
item.flipper.sendBought();
Utils.debugLog("Bought an item, starting to sell");
System.out.println("Item Name: " + item.flipper.name);
System.out.println("Item Price: " + item.flipper.price);
System.out.println("Target Price: " + item.flipper.target);
selling_queue.add(item.flipper);
item.flipper.sellItem();
} else {
Utils.debugLog("Bought an item, not selling because only sniper is enabled");
}
}).start();
}
} catch (Exception ignored) {
}
}
}
if (AHConfig.BED_SPAM && (Lilase.pageFlipper.getOpen() || Lilase.cofl.getOpen())) {
if (event.packet instanceof S2DPacketOpenWindow && ((S2DPacketOpenWindow) event.packet).getGuiId().equals("minecraft:chest")) {
S2DPacketOpenWindow packetOpenWindow = (S2DPacketOpenWindow) event.packet;
if (packetOpenWindow.getWindowTitle().getUnformattedText().equals("BIN Auction View"))
latestWindowId = packetOpenWindow.getWindowId();
}
if (event.packet instanceof S2FPacketSetSlot) {
S2FPacketSetSlot packetSetSlot = (S2FPacketSetSlot) event.packet;
if (packetSetSlot.func_149173_d() == 31 && packetSetSlot.func_149174_e() != null && packetSetSlot.func_149175_c() == latestWindowId) {
ItemStack itemStack = packetSetSlot.func_149174_e();
Utils.debugLog("Slot 31: " + itemStack.getItem().getRegistryName());
if (itemStack.getItem() == Items.bed && clock.passed()) {
clickWindow(latestWindowId, 31);
clickWindow(latestWindowId + 1, 11);
clock.schedule(AHConfig.BED_SPAM_DELAY);
} else if (itemStack.getItem() == Items.gold_nugget || Item.getItemFromBlock(Blocks.gold_block) == itemStack.getItem()) {
clickWindow(latestWindowId, 31);
clickWindow(latestWindowId + 1, 11);
} else {
Utils.debugLog("Auction was bought by someone else, closing window");
Lilase.mc.thePlayer.closeScreen();
}
}
}
}
if (event.packet instanceof S33PacketUpdateSign && (Flipper.state.equals(START) || Lilase.cofl.getQueue().isRunning())) {
if (Utils.cookie == EffectState.ON || (Utils.cookie == EffectState.OFF && Utils.checkInHub()))
new Thread(() -> {
try {
S33PacketUpdateSign packetUpdateSign = (S33PacketUpdateSign) event.packet;
IChatComponent[] lines = packetUpdateSign.getLines();
Utils.debugLog("Item price should be " + price);
Utils.debugLog("Target Price: " + selling_queue.get(0).target);
Thread.sleep(300);
lines[0] = IChatComponent.Serializer.jsonToComponent("{\"text\":\"" + price + "\"}");
C12PacketUpdateSign packetUpdateSign1 = new C12PacketUpdateSign(packetUpdateSign.getPos(), lines);
sendPacketWithoutEvent(packetUpdateSign1);
lines[0] = IChatComponent.Serializer.jsonToComponent("{\"text\":\"" + selling_queue.get(0).target + "\"}");
sendPacketWithoutEvent(new C12PacketUpdateSign(packetUpdateSign.getPos(), lines));
} catch (RuntimeException | InterruptedException e) {
e.printStackTrace();
}
@ -276,8 +282,7 @@ public class SniperFlipperEvents {
}
}
@SubscribeEvent
public void onWorldChange(WorldEvent.Unload event) {
buying = false;
public void clickWindow(int window, int slot) {
Lilase.mc.playerController.windowClick(window, slot, 0, 0, Lilase.mc.thePlayer);
}
}

View file

@ -10,17 +10,14 @@ import me.night0721.lilase.utils.UngrabUtils;
import me.night0721.lilase.utils.Utils;
import java.io.PrintStream;
import java.util.concurrent.ThreadLocalRandom;
import java.util.Random;
import java.util.regex.Pattern;
import static me.night0721.lilase.config.AHConfig.SEND_MESSAGE;
public class Cofl {
private final Queue queue = new Queue();
public final Queue queue = new Queue();
private boolean open = false;
public static int price = 0;
public static int target = 0;
private final ThreadLocalRandom random = ThreadLocalRandom.current();
public final Thread thread = new Thread(() -> {
while (true) {
try {
@ -54,20 +51,20 @@ public class Cofl {
try {
if (!getOpen() || !str.startsWith("Received:")) return;
if (pattern.matcher(str).find()) {
// Utils.debugLog("Doing some motion as we don't want to be AFK");
Random random = new Random();
Lilase.mc.thePlayer.inventory.currentItem = random.nextInt(9);
String[] split = str.split("Received: ");
JsonObject auction = new JsonParser().parse(new JsonParser().parse(split[1]).getAsJsonObject().get("data").getAsString()).getAsJsonObject();
JsonObject received = new JsonParser().parse(split[1]).getAsJsonObject();
if (!received.get("type").getAsString().equals("flip")) return;
JsonObject auction = new JsonParser().parse(received.get("data").getAsString()).getAsJsonObject();
String itemName = auction.get("auction").getAsJsonObject().get("itemName").getAsString();
String id = auction.get("auction").getAsJsonObject().get("uuid").getAsString();
price = auction.get("auction").getAsJsonObject().get("startingBid").getAsInt();
target = auction.get("target").getAsInt();
// Utils.debugLog("Item Name: " + itemName);
// Utils.debugLog("ID: " + id);
// Utils.debugLog("Price: " + price);
if (itemName != null && id != null && price != 0 && target != 0) {
Utils.debugLog("Adding auction to queue: " + id, "Price: " + price, "Target Price: " + target, "Name: " + itemName);
getQueue().add(new QueueItem(id, itemName, price, target));
int price = auction.get("auction").getAsJsonObject().get("startingBid").getAsInt();
String uid = auction.get("auction").getAsJsonObject().get("flatNbt").getAsJsonObject().get("uid").getAsString();
int target = auction.get("target").getAsInt();
if (itemName != null && id != null && price != 0 && target != 0 && uid != null) {
Utils.debugLog("Adding auction to queue: " + id, "Price: " + price, "Target Price: " + target, "Name: " + itemName, "UID: " + uid);
getQueue().add(new QueueItem(id, itemName, price, target, uid));
getQueue().scheduleClear();
}
}

View file

@ -1,15 +1,26 @@
package me.night0721.lilase.features.cofl;
import lombok.Getter;
import me.night0721.lilase.utils.Utils;
import java.util.ArrayList;
import java.util.List;
public class Queue {
private final List<QueueItem> queue = new ArrayList<>();
public final List<QueueItem> queue = new ArrayList<>();
private final @Getter List<QueueItem> history = new ArrayList<>();
private boolean running = false, clearTaskRunning = false;
public void add(QueueItem item) {
this.queue.add(item);
this.history.add(item);
}
public QueueItem getHistoryByUID(String uid) {
for (QueueItem item : this.history) {
if (uid.contains(item.uid)) return item;
}
return null;
}
public QueueItem get() {
@ -29,6 +40,7 @@ public class Queue {
public boolean isRunning() {
return this.running;
}
public void clear() {
this.queue.clear();
}

View file

@ -1,25 +1,30 @@
package me.night0721.lilase.features.cofl;
import lombok.Getter;
import me.night0721.lilase.features.flipper.Flipper;
import me.night0721.lilase.utils.Utils;
// TODO: Implement Lombok Library for clean code
public class QueueItem {
private final String command, name;
private final int price;
private final int target;
public static Flipper flipper = null;
public @Getter
final String command, name;
public @Getter
final int price;
public @Getter
final int target;
public @Getter String uid;
public Flipper flipper;
public QueueItem(String command, String name, int price, int target) {
public QueueItem(String command, String name, int price, int target, String uid) {
this.command = command;
this.name = name;
this.price = price;
this.target = target;
this.uid = uid;
}
public void openAuction() {
Utils.debugLog("Executing: " + command);
Utils.sendServerMessage("/viewauction " + command);
flipper = new Flipper(name, price, target);
}
}

View file

@ -1,7 +1,6 @@
package me.night0721.lilase.features.flipper;
import me.night0721.lilase.Lilase;
import me.night0721.lilase.events.SniperFlipperEvents;
import me.night0721.lilase.player.EffectState;
import me.night0721.lilase.player.Rotation;
import me.night0721.lilase.utils.*;
@ -16,13 +15,16 @@ import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
import static me.night0721.lilase.config.AHConfig.RELIST_TIMEOUT;
import static me.night0721.lilase.config.AHConfig.SEND_MESSAGE;
import static me.night0721.lilase.events.SniperFlipperEvents.selling_queue;
// TODO: Fix repeating code (I will do it soon)
public class Flipper {
private static String itemname = "";
private static int itemprice = 0;
private static int target = 0;
public String name;
public int price;
public int target;
public String uuid;
public static FlipperState state = FlipperState.NONE;
public static final Rotation rotation = new Rotation();
private final Clock buyWait = new Clock();
@ -32,10 +34,11 @@ public class Flipper {
public static final String icon = "https://camo.githubusercontent.com/57a8295f890970d2173b895c7a0f6c60527fb3bec4489b233b221ab45cb9fa42/68747470733a2f2f63646e2e646973636f72646170702e636f6d2f6174746163686d656e74732f3834323031343930393236343935333335342f313038323337333237353033383030333231302f6c696c6173652e706e67";
public Flipper(String name, int price, int targetprice) {
itemname = name;
itemprice = price;
target = targetprice;
public Flipper(String name, int price, int target, String uuid) {
this.name = name;
this.price = price;
this.target = target;
this.uuid = uuid;
webhook.setUsername("Lilase");
webhook.setAvatarUrl(icon);
}
@ -48,22 +51,10 @@ public class Flipper {
if (Lilase.cofl.getOpen()) Lilase.cofl.toggleAuction();
UngrabUtils.ungrabMouse();
Utils.debugLog("Cookie: " + (Utils.cookie == EffectState.ON ? "ON" : "OFF"));
Utils.debugLog("Have screen: " + (Lilase.mc.currentScreen != null ? "Yes" : "No"));
Utils.debugLog("Profit Percentage: " + target / itemprice);
System.out.println("Slot in inventory: " + InventoryUtils.getSlotForItemm(this.uuid));
try {
webhook.addEmbed(new DiscordWebhook.EmbedObject()
.setTitle("Just purchased an item!")
.setFooter("Purse: " + format.format(Utils.getPurse()), icon)
.addField("Item:", itemname, true)
.addField("Price:", format.format(itemprice), true)
.addField("Target Price:", format.format(target), true)
.addField("Profit Percentage:", df.format(target / itemprice * 100L) + "%", true)
.setColor(Color.decode("#003153")));
if (SEND_MESSAGE) webhook.execute();
Utils.debugLog("Notified Webhook");
} catch (Exception e) {
e.printStackTrace();
Utils.debugLog("Failed to send webhook");
Thread.sleep(RELIST_TIMEOUT);
} catch (InterruptedException ignored) {
}
if (Utils.cookie != EffectState.ON) {
Utils.sendServerMessage("/hub");
@ -80,11 +71,11 @@ public class Flipper {
if (Lilase.mc.currentScreen != null) {
Lilase.mc.thePlayer.closeScreen();
} else if (distanceToFirstPoint() < 0.7f) {
System.out.println("Moving to auction house");
// System.out.println("Moving to auction house");
KeyBindingManager.updateKeys(false, false, false, false, false);
state = FlipperState.WALKING_INTO_AUCTION_HOUSE;
} else if (distanceToFirstPoint() < 5f) {
System.out.println("Crouching to point 1");
// System.out.println("Crouching to point 1");
KeyBindingManager.updateKeys(true, false, false, false, false, true, false);
} else {
KeyBindingManager.updateKeys(true, false, false, false, false);
@ -94,14 +85,14 @@ public class Flipper {
if (Lilase.mc.currentScreen != null) {
Lilase.mc.thePlayer.closeScreen();
} else if (AngleUtils.smallestAngleDifference(AngleUtils.get360RotationYaw(), 88f) > 1.2) {
System.out.println("Rotating to Auction Master");
// System.out.println("Rotating to Auction Master");
rotation.easeTo(88f, Lilase.mc.thePlayer.rotationPitch, 500);
} else if (distanceToAuctionMaster() < 0.7f) {
Utils.debugLog("At Auction Master, opening shop");
KeyBindingManager.updateKeys(false, false, false, false, false);
state = FlipperState.BUYING;
} else if (distanceToAuctionMaster() < 5f) {
System.out.println("Crouching to Auction Master");
// System.out.println("Crouching to Auction Master");
KeyBindingManager.updateKeys(true, false, false, false, false, true, false);
} else {
KeyBindingManager.updateKeys(true, false, false, false, false);
@ -122,83 +113,84 @@ public class Flipper {
buyWait.schedule(1500);
} else if (InventoryUtils.inventoryNameContains("Create BIN Auction")) {
if (InventoryUtils.isStoneButton() && buyWait.passed()) {
if (InventoryUtils.getSlotForItem(itemname) == -1) {
if (InventoryUtils.getSlotForItemm(this.uuid) == -1) {
Utils.debugLog("Cannot find item in inventory, stopping flipper");
selling_queue.remove(0);
if (SEND_MESSAGE) {
try {
webhook.addEmbed(new DiscordWebhook.EmbedObject()
.setTitle("Failed to post an item!")
.setDescription("Could not find item in inventory, sending so you can post it manually")
.setFooter("Purse: " + format.format(Utils.getPurse()), icon)
.addField("Item:", itemname, true)
.addField("Price:", format.format(itemprice), true)
.addField("Target Price:", format.format(target), true)
.addField("Profit Percentage:", Float.parseFloat(df.format(target / itemprice * 100L)) + "%", true)
.setColor(Color.decode("#ff0000")));
if (SEND_MESSAGE) webhook.execute();
webhook.addEmbed(embed("Failed to post an item!", "Could not find item in inventory, sending so you can post it manually", "#ff0000"));
webhook.execute();
Utils.debugLog("Notified Webhook");
} catch (Exception e) {
e.printStackTrace();
Utils.debugLog("Failed to send webhook");
}
}
Lilase.mc.thePlayer.closeScreen();
state = FlipperState.NONE;
Lilase.cofl.setOpen(true);
Lilase.cofl.toggleAuction();
return;
}
InventoryUtils.clickOpenContainerSlot(InventoryUtils.getSlotForItem(itemname));
InventoryUtils.clickOpenContainerSlot(InventoryUtils.getSlotForItemm(this.uuid) + 81);
buyWait.schedule(1000);
} else if (!InventoryUtils.isStoneButton() && InventoryUtils.isToAuctionItem(itemname) && buyWait.passed()) {
} else if (!InventoryUtils.isStoneButton() && InventoryUtils.isToAuctionItem(this.uuid) && buyWait.passed()) {
InventoryUtils.clickOpenContainerSlot(31);
buyWait.schedule(1000);
state = FlipperState.START;
} else if (!InventoryUtils.isStoneButton() && !InventoryUtils.isToAuctionItem(itemname) && buyWait.passed()) {
buyWait.schedule(1000);
} else if (!InventoryUtils.isStoneButton() && !InventoryUtils.isToAuctionItem(this.uuid) && buyWait.passed()) {
InventoryUtils.clickOpenContainerSlot(13);
buyWait.schedule(1000);
} // TODO: Ternary Expression
} else if (InventoryUtils.inventoryNameContains("Manage Auction") && buyWait.passed()) {
} else if (InventoryUtils.inventoryNameContains("Manage Auctions") && buyWait.passed()) {
ItemStack slot24 = InventoryUtils.getStackInOpenContainerSlot(24);
ItemStack slot33 = InventoryUtils.getStackInOpenContainerSlot(33);
ItemStack slot42 = InventoryUtils.getStackInOpenContainerSlot(42);
ItemStack slot51 = InventoryUtils.getStackInOpenContainerSlot(51);
if (slot24 != null && slot24.getItem() == Items.golden_horse_armor) {
InventoryUtils.clickOpenContainerSlot(24);
buyWait.schedule(1000);
} else if (slot33 != null && slot33.getItem() == Items.golden_horse_armor) {
InventoryUtils.clickOpenContainerSlot(33);
buyWait.schedule(1000);
} else if (slot42 != null && slot42.getItem() == Items.golden_horse_armor) {
InventoryUtils.clickOpenContainerSlot(42);
buyWait.schedule(1000);
} else if (slot51 != null && slot51.getItem() == Items.golden_horse_armor) {
InventoryUtils.clickOpenContainerSlot(51);
buyWait.schedule(1000);
} else {
Utils.debugLog("Can't find create auction button, stopping flipper");
} else if (slot33 != null) {
if (slot33.getSubCompound("display", false).getString("Name").startsWith("§c")) {
Utils.debugLog("Auction slots full, stopping sniper for a while");
selling_queue.remove(0);
if (SEND_MESSAGE) {
try {
webhook.addEmbed(new DiscordWebhook.EmbedObject()
.setTitle("Failed to post an item!")
.setDescription("Could not find create auction button, sending so you can post it manually")
.setFooter("Purse: " + format.format(Utils.getPurse()), icon)
.addField("Item:", itemname, true)
.addField("Price:", format.format(itemprice), true)
.addField("Target Price:", format.format(target), true)
.addField("Profit Percentage:", Float.parseFloat(df.format(target / itemprice * 100L)) + "%", true)
.setColor(Color.decode("#ff0000")));
if (SEND_MESSAGE) webhook.execute();
webhook.addEmbed(embed("Auction slots are full!", "Could not create more auctions as slots are full already, sending you here so you could create it manually", "#ff0000"));
webhook.execute();
Utils.debugLog("Notified Webhook");
} catch (Exception e) {
e.printStackTrace();
Utils.debugLog("Failed to send webhook");
}
}
Lilase.mc.thePlayer.closeScreen();
state = FlipperState.NONE;
Lilase.cofl.setOpen(true);
// Lilase.cofl.toggleAuction();
return;
} else if (slot33.getItem() == Items.golden_horse_armor) {
InventoryUtils.clickOpenContainerSlot(33);
buyWait.schedule(1000);
}
} else {
Utils.debugLog("Can't find create auction button, stopping flipper");
selling_queue.remove(0);
if (SEND_MESSAGE) {
try {
webhook.addEmbed(embed("Failed to post an item!", "Could not find create auction button, sending so you can post it manually", "#ff0000"));
webhook.execute();
Utils.debugLog("Notified Webhook");
} catch (Exception e) {
e.printStackTrace();
Utils.debugLog("Failed to send webhook");
}
}
Lilase.mc.thePlayer.closeScreen();
state = FlipperState.NONE;
Lilase.cofl.toggleAuction();
return;
}
}
case START:
if (!InventoryUtils.isStoneButton() && InventoryUtils.isToAuctionItem(itemname) && InventoryUtils.inventoryNameStartsWith("Create BIN Auction") && buyWait.passed()) {
if (!InventoryUtils.isStoneButton() && InventoryUtils.isToAuctionItem(this.uuid) && InventoryUtils.inventoryNameStartsWith("Create BIN Auction") && buyWait.passed()) {
InventoryUtils.clickOpenContainerSlot(29);
buyWait.schedule(1000);
} else if (InventoryUtils.inventoryNameContains("Confirm BIN Auction") && buyWait.passed()) {
@ -207,36 +199,45 @@ public class Flipper {
} else if (InventoryUtils.inventoryNameContains("BIN Auction View") && buyWait.passed()) {
InventoryUtils.clickOpenContainerSlot(49);
Lilase.sniper.incrementAuctionsPosted();
SniperFlipperEvents.postedNames.add(itemname);
buyWait.schedule(500);
Lilase.mc.thePlayer.closeScreen();
buyWait.schedule(500);
Utils.sendMessage("Posted item on Auction House, continue sniping now");
state = FlipperState.NONE;
Lilase.cofl.toggleAuction();
selling_queue.remove(0);
}
case NONE:
break;
}
}
public static void sendInterrupt() {
public void sendInterrupt() {
if (SEND_MESSAGE) {
try {
webhook.addEmbed(new DiscordWebhook.EmbedObject()
.setTitle("Failed to post an item!")
.setDescription("Could not find create as interruption, sending so you can post it manually")
.setFooter("Purse: " + format.format(Utils.getPurse()), icon)
.addField("Item:", itemname, true)
.addField("Price:", format.format(itemprice), true)
.addField("Target Price:", format.format(target), true)
.addField("Profit Percentage:", Float.parseFloat(df.format(target / itemprice * 100L)) + "%", true)
.setColor(Color.decode("#ff0000")));
if (SEND_MESSAGE) webhook.execute();
webhook.addEmbed(embed("Could not find create as interruption", "Could not find create as interruption, sending so you can post it manually", "#ff0000"));
webhook.execute();
Utils.debugLog("Notified Webhook");
} catch (Exception e) {
e.printStackTrace();
Utils.debugLog("Failed to send webhook");
}
}
}
public void sendBought() {
if (SEND_MESSAGE) {
try {
webhook.addEmbed(embed("Just purchased an item!", "", "#003153"));
webhook.execute();
Utils.debugLog("Notified Webhook");
} catch (Exception e) {
e.printStackTrace();
Utils.debugLog("Failed to send webhook");
}
}
}
public static float distanceToFirstPoint() {
return (float) Math.sqrt(Math.pow(Lilase.mc.thePlayer.posX - (-2.5), 2) + Math.pow(Lilase.mc.thePlayer.posZ - (-91.5), 2));
}
@ -248,5 +249,17 @@ public class Flipper {
public static Entity getAuctionMaster() {
return Lilase.mc.theWorld.loadedEntityList.stream().filter(e -> e instanceof EntityArmorStand && StringUtils.stripControlCodes(e.getDisplayName().getUnformattedText()).startsWith("Auction Master")).findFirst().orElse(null);
}
public DiscordWebhook.EmbedObject embed(String title, String description, String color) {
return new DiscordWebhook.EmbedObject()
.setTitle(title)
.setDescription(description)
.setFooter("Purse: " + format.format(Utils.getPurse()), icon)
.addField("Item:", name, true)
.addField("Price:", format.format(price), true)
.addField("Target Price:", format.format(target), true)
.addField("Profit Percentage:", df.format((double) (target - price) / price * 100f) + "%", true)
.setColor(Color.decode(color));
}
}

View file

@ -0,0 +1,134 @@
package me.night0721.lilase.gui;
import com.google.gson.JsonParser;
import me.night0721.lilase.Lilase;
import me.night0721.lilase.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiScreen;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
/*
Credits: FarmHelper
*/
public class UpdateGUI extends GuiScreen {
private static final Minecraft mc = Minecraft.getMinecraft();
private static boolean shownGui = false;
public static boolean outdated = false;
private static String[] message;
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawBackground(0);
float scale = 3;
GL11.glScalef(scale, scale, 0.0F);
this.drawCenteredString(mc.fontRendererObj, "Outdated version of Lilase", (int) (this.width / 2f / scale), (int) (this.height / 6f / scale), Color.RED.darker().getRGB());
GL11.glScalef(1.0F / scale, 1.0F / scale, 0.0F);
scale = 1.5f;
GL11.glScalef(scale, scale, 0.0F);
this.drawString(mc.fontRendererObj, "What's new? ➤", (int) (this.width / 2f / scale - 180), (int) (this.height / 6 / scale + 25), Color.GREEN.getRGB());
GL11.glScalef(1.0F / scale, 1.0F / scale, 0.0F);
if (message != null) {
int y = 40;
for (String s : message) {
this.drawString(mc.fontRendererObj, s, this.width / 2 - 160, this.height / 6 + y, Color.WHITE.getRGB());
y += 15;
}
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
public void initGui() {
super.initGui();
registerButtons();
}
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
if (keyCode == Keyboard.KEY_ESCAPE) {
mc.displayGuiScreen(new GuiMainMenu());
}
}
@Override
protected void actionPerformed(GuiButton button) {
switch (button.id) {
case 1: // closebtn
mc.displayGuiScreen(new GuiMainMenu());
break;
case 2: // downloadbtn
Utils.openURL("https://github.com/night0721/Lilase/releases/latest");
mc.displayGuiScreen(new GuiMainMenu());
break;
}
}
private void registerButtons() {
GuiButton closeBtn = new GuiButton(1, this.width / 2, this.height / 2 + 100, 150, 20, "Close");
this.buttonList.add(closeBtn);
GuiButton downloadBtn = new GuiButton(2, this.width / 2 - 150, this.height / 2 + 100, 150, 20, "Download new version");
this.buttonList.add(downloadBtn);
}
public static void showGUI() {
if (!shownGui && isOutdated()) {
mc.displayGuiScreen(new UpdateGUI());
shownGui = true;
outdated = isOutdated();
message = getReleaseMessage().replaceAll("\r", "").replace("+ ", "§a+ ").replace("= ", "§f= ").replace("- ", "§c- ").split("\n");
}
}
private static boolean isOutdated() {
try {
StringBuilder result = new StringBuilder();
URL url = new URL("https://api.github.com/repos/night0721/Lilase/releases/latest");
HttpURLConnection conn = ((HttpURLConnection)url.openConnection());
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
conn.setRequestMethod("GET");
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(conn.getInputStream()))) {
for (String line; (line = reader.readLine()) != null; ) {
result.append(line);
}
}
String latestversion = new JsonParser().parse(result.toString()).getAsJsonObject().get("tag_name").getAsString().replace("v", "");
return !Lilase.VERSION.contains(latestversion);
} catch (Exception e) {
return false;
}
}
private static String getReleaseMessage() {
try {
StringBuilder result = new StringBuilder();
URL url = new URL("https://api.github.com/repos/night0721/Lilase/releases/latest");
HttpURLConnection conn = ((HttpURLConnection)url.openConnection());
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
conn.setRequestMethod("GET");
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(conn.getInputStream()))) {
for (String line; (line = reader.readLine()) != null; ) {
result.append(line);
}
}
return new JsonParser().parse(result.toString()).getAsJsonObject().get("body").getAsString();
} catch (Exception e) {
return "No release message was found.";
}
}
}

View file

@ -0,0 +1,29 @@
package me.night0721.lilase.mixins;
import me.night0721.lilase.gui.UpdateGUI;
import net.minecraft.client.gui.GuiMainMenu;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GuiMainMenu.class)
public class MixinGuiMainMenu {
@Shadow
private String splashText;
private static boolean done = false;
@Final
@Inject(method = "updateScreen", at = @At("RETURN"))
private void initGui(CallbackInfo ci) {
if (!done) {
UpdateGUI.showGUI();
done = true;
}
if (UpdateGUI.outdated) {
this.splashText = "Update Lilase <3";
}
}
}

View file

@ -13,6 +13,6 @@ import static me.night0721.lilase.Lilase.VERSION;
public class MixinMinecraft {
@Inject(method = {"startGame"}, at = {@At("RETURN")})
private void startGame(CallbackInfo ci) {
Display.setTitle("Lilase v" + VERSION + " | night0721");
Display.setTitle("Lilase v" + VERSION);
}
}

View file

@ -1,11 +1,10 @@
package me.night0721.lilase.player;
import me.night0721.lilase.Lilase;
import me.night0721.lilase.utils.AngleUtils;
import net.minecraft.client.Minecraft;
import org.apache.commons.lang3.tuple.MutablePair;
public class Rotation {
private final static Minecraft mc = Minecraft.getMinecraft();
public boolean rotating;
public boolean completed;
@ -21,36 +20,36 @@ public class Rotation {
rotating = true;
startTime = System.currentTimeMillis();
endTime = System.currentTimeMillis() + time;
start.setLeft(mc.thePlayer.rotationYaw);
start.setRight(mc.thePlayer.rotationPitch);
start.setLeft(Lilase.mc.thePlayer.rotationYaw);
start.setRight(Lilase.mc.thePlayer.rotationPitch);
target.setLeft(AngleUtils.get360RotationYaw(yaw));
target.setRight(pitch);
getDifference();
}
public void lockAngle(float yaw, float pitch) {
if (mc.thePlayer.rotationYaw != yaw || mc.thePlayer.rotationPitch != pitch && !rotating)
if (Lilase.mc.thePlayer.rotationYaw != yaw || Lilase.mc.thePlayer.rotationPitch != pitch && !rotating)
easeTo(yaw, pitch, 1000);
}
public void update() {
if (System.currentTimeMillis() <= endTime) {
if (shouldRotateClockwise()) {
mc.thePlayer.rotationYaw = start.left + interpolate(difference.left);
Lilase.mc.thePlayer.rotationYaw = start.left + interpolate(difference.left);
} else {
mc.thePlayer.rotationYaw = start.left - interpolate(difference.left);
Lilase.mc.thePlayer.rotationYaw = start.left - interpolate(difference.left);
}
mc.thePlayer.rotationPitch = start.right + interpolate(difference.right);
Lilase.mc.thePlayer.rotationPitch = start.right + interpolate(difference.right);
} else if (!completed) {
if (shouldRotateClockwise()) {
System.out.println("Rotation final st - " + start.left + ", " + mc.thePlayer.rotationYaw);
mc.thePlayer.rotationYaw = target.left;
System.out.println("Rotation final st - " + start.left + ", " + Lilase.mc.thePlayer.rotationYaw);
Lilase.mc.thePlayer.rotationYaw = target.left;
System.out.println("Rotation final - " + start.left + difference.left);
} else {
mc.thePlayer.rotationYaw = target.left;
Lilase.mc.thePlayer.rotationYaw = target.left;
System.out.println("Rotation final - " + (start.left - difference.left));
}
mc.thePlayer.rotationPitch = start.right + difference.right;
Lilase.mc.thePlayer.rotationPitch = start.right + difference.right;
completed = true;
rotating = false;
}

View file

@ -1,16 +1,15 @@
package me.night0721.lilase.utils;
import net.minecraft.client.Minecraft;
import me.night0721.lilase.Lilase;
public class AngleUtils {
private static final Minecraft mc = Minecraft.getMinecraft();
public static float get360RotationYaw(float yaw) {
return (yaw % 360 + 360) % 360;
}
public static float get360RotationYaw() {
return get360RotationYaw(mc.thePlayer.rotationYaw);
return get360RotationYaw(Lilase.mc.thePlayer.rotationYaw);
}
public static float clockwiseDifference(float initialYaw360, float targetYaw360) {

View file

@ -1,19 +1,11 @@
package me.night0721.lilase.utils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCarpet;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3i;
import java.util.Arrays;
public class BlockUtils {
private static final Minecraft mc = Minecraft.getMinecraft();
private static final Block[] walkables = { Blocks.air, Blocks.water, Blocks.flowing_water, Blocks.dark_oak_fence_gate, Blocks.acacia_fence_gate, Blocks.birch_fence_gate, Blocks.oak_fence_gate, Blocks.jungle_fence_gate, Blocks.spruce_fence_gate, Blocks.wall_sign, Blocks.reeds };
public static int getUnitX() {
double modYaw = (mc.thePlayer.rotationYaw % 360 + 360) % 360;
@ -42,67 +34,6 @@ public class BlockUtils {
}
public static Block getRelativeBlock(float x, float y, float z) {
return (mc.theWorld.getBlockState(
new BlockPos(
mc.thePlayer.posX + (getUnitX() * z) + (getUnitZ() * -1 * x),
mc.thePlayer.posY + y,
mc.thePlayer.posZ + (getUnitZ() * z) + (getUnitX() * x)
)).getBlock());
}
public static BlockPos getRelativeBlockPos(float x, float y, float z) {
return new BlockPos(
mc.thePlayer.posX + (getUnitX() * z) + (getUnitZ() * -1 * x),
mc.thePlayer.posY + y,
mc.thePlayer.posZ + (getUnitZ() * z) + (getUnitX() * x)
);
}
public static int countCarpet() {
int r = 2;
int count = 0;
BlockPos playerPos = mc.thePlayer.getPosition();
playerPos.add(0, 1, 0);
Vec3i vec3i = new Vec3i(r, r, r);
Vec3i vec3i2 = new Vec3i(r, r, r);
for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i2))) {
IBlockState blockState = mc.theWorld.getBlockState(blockPos);
if (blockState.getBlock() == Blocks.carpet && blockState.getValue(BlockCarpet.COLOR) == EnumDyeColor.BROWN) {
System.out.println("Carpet color: " + blockState.getValue(BlockCarpet.COLOR));
count++;
}
}
return count;
}
public static int bedrockCount() {
int r = 4;
int count = 0;
BlockPos playerPos = Minecraft.getMinecraft().thePlayer.getPosition();
playerPos.add(0, 1, 0);
Vec3i vec3i = new Vec3i(r, r, r);
Vec3i vec3i2 = new Vec3i(r, r, r);
for (BlockPos blockPos : BlockPos.getAllInBox(playerPos.add(vec3i), playerPos.subtract(vec3i2))) {
IBlockState blockState = Minecraft.getMinecraft().theWorld.getBlockState(blockPos);
if (blockState.getBlock() == Blocks.bedrock) {
count++;
}
}
return count;
}
public static Block getLeftBlock(){
return getRelativeBlock(-1, 0, 0);
}
public static Block getRightBlock(){
return getRelativeBlock(1, 0, 0);
}
public static Block getBackBlock(){
return getRelativeBlock(0, 0, -1);
}
public static Block getFrontBlock(){
return getRelativeBlock(0, 0, 1);
}
public static boolean isWalkable(Block block) {
return Arrays.asList(walkables).contains(block);
return (mc.theWorld.getBlockState(new BlockPos(mc.thePlayer.posX + (getUnitX() * z) + (getUnitZ() * -1 * x), mc.thePlayer.posY + y, mc.thePlayer.posZ + (getUnitZ() * z) + (getUnitX() * x))).getBlock());
}
}

View file

@ -1,5 +1,8 @@
package me.night0721.lilase.utils;
import lombok.Getter;
import lombok.Setter;
import javax.net.ssl.HttpsURLConnection;
import java.awt.*;
import java.io.IOException;
@ -16,10 +19,10 @@ import java.util.*;
public class DiscordWebhook {
private final String url;
private String content;
private String username;
private String avatarUrl;
private boolean tts;
private @Setter String content;
private @Setter String username;
private @Setter String avatarUrl;
private @Setter boolean tts;
private final List<EmbedObject> embeds = new ArrayList<>();
/**
@ -31,22 +34,6 @@ public class DiscordWebhook {
this.url = url;
}
public void setContent(String content) {
this.content = content;
}
public void setUsername(String username) {
this.username = username;
}
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}
public void setTts(boolean tts) {
this.tts = tts;
}
public void addEmbed(EmbedObject embed) {
this.embeds.add(embed);
}
@ -143,52 +130,15 @@ public class DiscordWebhook {
// TODO: Lombok! I'm gonna add it soon. The code looks bad right now :/
public static class EmbedObject {
private String title;
private String description;
private String url;
private Color color;
private Footer footer;
private Thumbnail thumbnail;
private Image image;
private Author author;
private final List<Field> fields = new ArrayList<>();
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public String getUrl() {
return url;
}
public Color getColor() {
return color;
}
public Footer getFooter() {
return footer;
}
public Thumbnail getThumbnail() {
return thumbnail;
}
public Image getImage() {
return image;
}
public Author getAuthor() {
return author;
}
public List<Field> getFields() {
return fields;
}
private @Getter String title;
private @Getter String description;
private @Getter String url;
private @Getter Color color;
private @Getter Footer footer;
private @Getter Thumbnail thumbnail;
private @Getter Image image;
private @Getter Author author;
private final @Getter List<Field> fields = new ArrayList<>();
public EmbedObject setTitle(String title) {
this.title = title;
@ -236,93 +186,53 @@ public class DiscordWebhook {
}
private static class Footer {
private final String text;
private final String iconUrl;
private @Getter final String text;
private @Getter final String iconUrl;
private Footer(String text, String iconUrl) {
this.text = text;
this.iconUrl = iconUrl;
}
private String getText() {
return text;
}
private String getIconUrl() {
return iconUrl;
}
}
private static class Thumbnail {
private final String url;
private @Getter final String url;
private Thumbnail(String url) {
this.url = url;
}
private String getUrl() {
return url;
}
}
private static class Image {
private final String url;
private @Getter final String url;
private Image(String url) {
this.url = url;
}
private String getUrl() {
return url;
}
}
private static class Author {
private final String name;
private final String url;
private final String iconUrl;
private @Getter final String name;
private @Getter final String url;
private @Getter final String iconUrl;
private Author(String name, String url, String iconUrl) {
this.name = name;
this.url = url;
this.iconUrl = iconUrl;
}
private String getName() {
return name;
}
private String getUrl() {
return url;
}
private String getIconUrl() {
return iconUrl;
}
}
private static class Field {
private final String name;
private final String value;
private final boolean inline;
private @Getter final String name;
private @Getter final String value;
private @Getter final boolean inline;
private Field(String name, String value, boolean inline) {
this.name = name;
this.value = value;
this.inline = inline;
}
private String getName() {
return name;
}
private String getValue() {
return value;
}
private boolean isInline() {
return inline;
}
}
}

View file

@ -1,6 +1,6 @@
package me.night0721.lilase.utils;
import net.minecraft.client.Minecraft;
import me.night0721.lilase.Lilase;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.inventory.ContainerChest;
@ -17,27 +17,16 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class InventoryUtils {
private static final Minecraft mc = Minecraft.getMinecraft();
public static boolean isToAuctionItem(String name) {
final ItemStack stack = mc.thePlayer.openContainer.getSlot(13).getStack();
public class InventoryUtils { public static boolean isToAuctionItem(String uuid) {
ItemStack stack = Lilase.mc.thePlayer.openContainer.getSlot(13).getStack();
if (stack != null && stack.hasTagCompound()) {
final NBTTagCompound tag = stack.getTagCompound();
final Pattern pattern = Pattern.compile(name, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(tag.toString());
while (matcher.find()) {
if (matcher.group(0) != null) {
return true;
}
}
return stack.getTagCompound().getCompoundTag("ExtraAttributes").getString("uuid").equals(uuid);
}
return false;
}
public static boolean isStoneButton() {
final ItemStack stack = mc.thePlayer.openContainer.getSlot(13).getStack();
final ItemStack stack = Lilase.mc.thePlayer.openContainer.getSlot(13).getStack();
if (stack != null && stack.hasTagCompound()) {
final NBTTagCompound tag = stack.getTagCompound();
final Pattern pattern = Pattern.compile("Click an item in your inventory!", Pattern.MULTILINE);
@ -52,8 +41,8 @@ public class InventoryUtils {
}
public static String getInventoryName() {
if (InventoryUtils.mc.currentScreen instanceof GuiChest) {
final ContainerChest chest = (ContainerChest) InventoryUtils.mc.thePlayer.openContainer;
if (Lilase.mc.currentScreen instanceof GuiChest) {
final ContainerChest chest = (ContainerChest) Lilase.mc.thePlayer.openContainer;
final IInventory inv = chest.getLowerChestInventory();
return inv.hasCustomName() ? inv.getName() : null;
}
@ -61,46 +50,39 @@ public class InventoryUtils {
}
public static boolean inventoryNameStartsWith(String startsWithString) {
return InventoryUtils.getInventoryName() != null && InventoryUtils.getInventoryName().startsWith(startsWithString);
return getInventoryName() != null && getInventoryName().startsWith(startsWithString);
}
public static boolean inventoryNameContains(String startsWithString) {
return InventoryUtils.getInventoryName() != null && InventoryUtils.getInventoryName().contains(startsWithString);
return getInventoryName() != null && getInventoryName().contains(startsWithString);
}
public static void openInventory() {
mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
Lilase.mc.displayGuiScreen(new GuiInventory(Lilase.mc.thePlayer));
}
public static ItemStack getStackInSlot(final int slot) {
return InventoryUtils.mc.thePlayer.inventory.getStackInSlot(slot);
return Lilase.mc.thePlayer.inventory.getStackInSlot(slot);
}
public static ItemStack getStackInOpenContainerSlot(final int slot) {
if (InventoryUtils.mc.thePlayer.openContainer.inventorySlots.get(slot).getHasStack()) {
return InventoryUtils.mc.thePlayer.openContainer.inventorySlots.get(slot).getStack();
}
if (Lilase.mc.thePlayer.openContainer.inventorySlots.get(slot).getHasStack())
return Lilase.mc.thePlayer.openContainer.inventorySlots.get(slot).getStack();
return null;
}
public static int getSlotForItem(final String itemName) {
for (final Slot slot : mc.thePlayer.openContainer.inventorySlots) {
public static int getSlotForItemm(String id) {
for (final Slot slot : Lilase.mc.thePlayer.inventoryContainer.inventorySlots) {
if (slot.getHasStack()) {
final ItemStack is = slot.getStack();
if (is.getDisplayName().contains(itemName)) {
return slot.slotNumber;
}
if (is.getTagCompound().getCompoundTag("ExtraAttributes").getString("uuid").equals(id)) return slot.getSlotIndex();
}
}
return -1;
}
public static void clickOpenContainerSlot(final int slot, final int button, final int clickType) {
mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, slot, button, clickType, mc.thePlayer);
}
public static void clickOpenContainerSlot(final int slot, final int button) {
clickOpenContainerSlot(slot, button, 0);
Lilase.mc.playerController.windowClick(Lilase.mc.thePlayer.openContainer.windowId, slot, button, clickType, Lilase.mc.thePlayer);
}
public static void clickOpenContainerSlot(final int slot) {
@ -110,7 +92,7 @@ public class InventoryUtils {
public static int getAvailableHotbarSlot(final String name) {
for (int i = 0; i < 8; ++i) {
final ItemStack is = mc.thePlayer.inventory.getStackInSlot(i);
final ItemStack is = Lilase.mc.thePlayer.inventory.getStackInSlot(i);
if (is == null || is.getDisplayName().contains(name)) {
return i;
}
@ -121,7 +103,7 @@ public class InventoryUtils {
public static List<Integer> getAllSlots(final String name) {
final List<Integer> ret = new ArrayList<>();
for (int i = 9; i < 44; ++i) {
final ItemStack is = mc.thePlayer.inventoryContainer.inventorySlots.get(i).getStack();
final ItemStack is = Lilase.mc.thePlayer.inventoryContainer.inventorySlots.get(i).getStack();
if (is != null && is.getDisplayName().contains(name)) {
ret.add(i);
}
@ -131,7 +113,7 @@ public class InventoryUtils {
public static int getAmountInHotbar(final String item) {
for (int i = 0; i < 8; ++i) {
final ItemStack is = InventoryUtils.mc.thePlayer.inventory.getStackInSlot(i);
final ItemStack is = Lilase.mc.thePlayer.inventory.getStackInSlot(i);
if (is != null && StringUtils.stripControlCodes(is.getDisplayName()).equals(item)) {
return is.stackSize;
}
@ -141,7 +123,7 @@ public class InventoryUtils {
public static int getItemInHotbar(final String itemName) {
for (int i = 0; i < 8; ++i) {
final ItemStack is = InventoryUtils.mc.thePlayer.inventory.getStackInSlot(i);
final ItemStack is = Lilase.mc.thePlayer.inventory.getStackInSlot(i);
if (is != null && StringUtils.stripControlCodes(is.getDisplayName()).contains(itemName)) {
return i;
}
@ -152,7 +134,7 @@ public class InventoryUtils {
public static List<ItemStack> getInventoryStacks() {
final List<ItemStack> ret = new ArrayList<>();
for (int i = 9; i < 44; ++i) {
final Slot slot = InventoryUtils.mc.thePlayer.inventoryContainer.getSlot(i);
final Slot slot = Lilase.mc.thePlayer.inventoryContainer.getSlot(i);
if (slot != null) {
final ItemStack stack = slot.getStack();
if (stack != null) {
@ -166,7 +148,7 @@ public class InventoryUtils {
public static List<Slot> getInventorySlots() {
final List<Slot> ret = new ArrayList<>();
for (int i = 9; i < 44; ++i) {
final Slot slot = InventoryUtils.mc.thePlayer.inventoryContainer.getSlot(i);
final Slot slot = Lilase.mc.thePlayer.inventoryContainer.getSlot(i);
if (slot != null) {
final ItemStack stack = slot.getStack();
if (stack != null) {
@ -178,17 +160,6 @@ public class InventoryUtils {
}
public static NBTTagCompound getExtraAttributes(ItemStack item) {
if (item == null) {
throw new NullPointerException("The item cannot be null!");
}
if (!item.hasTagCompound()) {
return null;
}
return item.getSubCompound("ExtraAttributes", false);
}
public static NBTTagList getLore(ItemStack item) {
if (item == null) {
throw new NullPointerException("The item cannot be null!");

View file

@ -7,12 +7,15 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import java.awt.*;
import java.net.URI;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static me.night0721.lilase.Lilase.mc;
import static me.night0721.lilase.config.AHConfig.DEBUG;
public class Utils {
public static IChatComponent header = null, footer = null;
@ -42,9 +45,10 @@ public class Utils {
public static void checkFooter() {
if (footer != null) {
for (String line : footer.getFormattedText().split("\n")) {
for (String line : footer.getUnformattedText().split("\n")) {
if (line.contains("Not active! Obtain")) {
cookie = EffectState.OFF;
return;
} else {
cookie = EffectState.ON;
}
@ -54,16 +58,10 @@ public class Utils {
public static int getPurse() {
String purse = "";
List<String> matches = ScoreboardUtils.getSidebarLines().stream()
.map(ScoreboardUtils::cleanSB)
.map(PATTERN_PURSE::matcher)
.filter(Matcher::find)
.map(Matcher::group)
.collect(Collectors.toList());
List<String> matches = ScoreboardUtils.getSidebarLines().stream().map(ScoreboardUtils::cleanSB).map(PATTERN_PURSE::matcher).filter(Matcher::find).map(Matcher::group).collect(Collectors.toList());
String purseline = matches.get(0);
Matcher matcher = PATTERN_PURSE.matcher(purseline);
if (matcher.find()) {
System.out.println("Group: " + matcher.group());
purse = matcher.group(2);
purse = purse.replace(",", "");
purse = purse.replaceAll("\\..*", "");
@ -74,13 +72,33 @@ public class Utils {
}
public static void openURL(String url) {
String os = System.getProperty("os.name").toLowerCase();
try {
if (Desktop.isDesktopSupported()) { // Probably Windows
Desktop desktop = Desktop.getDesktop();
desktop.browse(new URI(url));
} else { // Definitely Non-windows
Runtime runtime = Runtime.getRuntime();
if (os.contains("mac")) { // Apple
runtime.exec("open " + url);
} else if (os.contains("nix") || os.contains("nux")) { // Linux
runtime.exec("xdg-open " + url);
}
}
} catch (Exception ignored) {
}
}
public static void sendMessage(String message) {
mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + String.valueOf(EnumChatFormatting.BOLD) + "[Lilase] " + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + message));
}
public static void debugLog(String message) {
if (DEBUG)
mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "[Lilase] " + EnumChatFormatting.RESET + EnumChatFormatting.WHITE + message));
else System.out.println("[Lilase] " + message);
}
public static void debugLog(String... messages) {

View file

@ -9,6 +9,7 @@
],
"client": [
"MixinGuiIngame",
"MixinGuiMainMenu",
"MixinMinecraft",
"MixinNetHandlerPlayClient"
]