page flipper and making other files compatible to page flipper

This commit is contained in:
NK 2023-03-13 12:46:39 +00:00
parent 7803215d4c
commit e0818a27c9
4 changed files with 161 additions and 23 deletions

View file

@ -21,19 +21,22 @@ import java.net.URL;
public class Flipper { public class Flipper {
private final String itemname; private final String itemname;
private final String bytedata; private static 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 final Clock buyWait = new Clock(); private final Clock buyWait = new Clock();
private JsonObject object; private static JsonObject object;
public Flipper(String name, String data, int price) { public Flipper(String name, String data, int price) {
itemname = name; itemname = name;
bytedata = data; bytedata = data;
itemprice = price; itemprice = price;
} }
public Flipper(String name, int price) {
itemname = name;
itemprice = price;
}
public int getItemPrice() { public int getItemPrice() {
if (object == null) { if (object == null) {
try { try {
@ -55,7 +58,6 @@ public class Flipper {
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.sniper.getOpen()) Lilase.sniper.toggleAuction(); if (Lilase.sniper.getOpen()) Lilase.sniper.toggleAuction();
UngrabUtils.ungrabMouse(); UngrabUtils.ungrabMouse();
Utils.checkFooter();
if (Utils.cookie != EffectState.ON) { if (Utils.cookie != EffectState.ON) {
Utils.sendServerMessage("/hub"); Utils.sendServerMessage("/hub");
state = FlipperState.WALKING_TO_FIRST_POINT; state = FlipperState.WALKING_TO_FIRST_POINT;
@ -68,11 +70,11 @@ public class Flipper {
if (Lilase.mc.currentScreen != null) { if (Lilase.mc.currentScreen != null) {
Lilase.mc.thePlayer.closeScreen(); Lilase.mc.thePlayer.closeScreen();
} else if (distanceToFirstPoint() < 0.7f) { } else if (distanceToFirstPoint() < 0.7f) {
System.out.println("[Flipper] Moving to auction house"); System.out.println("Moving to auction house");
KeyBindingManager.updateKeys(false, false, false, false, false); KeyBindingManager.updateKeys(false, false, false, false, false);
state = FlipperState.WALKING_INTO_AUCTION_HOUSE; state = FlipperState.WALKING_INTO_AUCTION_HOUSE;
} else if (distanceToFirstPoint() < 5f) { } else if (distanceToFirstPoint() < 5f) {
System.out.println("[Flipper] Crouching to point 1"); System.out.println("Crouching to point 1");
KeyBindingManager.updateKeys(true, false, false, false, false, true, false); KeyBindingManager.updateKeys(true, false, false, false, false, true, false);
} else { } else {
KeyBindingManager.updateKeys(true, false, false, false, false); KeyBindingManager.updateKeys(true, false, false, false, false);
@ -82,14 +84,14 @@ public class Flipper {
if (Lilase.mc.currentScreen != null) { if (Lilase.mc.currentScreen != null) {
Lilase.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) {
System.out.println("[Flipper] Rotating to Auction Master"); System.out.println("Rotating to Auction Master");
rotation.easeTo(88f, Lilase.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("At Auction Master, opening shop");
KeyBindingManager.updateKeys(false, false, false, false, false); KeyBindingManager.updateKeys(false, false, false, false, false);
state = FlipperState.BUYING; state = FlipperState.BUYING;
} else if (distanceToAuctionMaster() < 5f) { } else if (distanceToAuctionMaster() < 5f) {
System.out.println("[Flipper] Crouching to Auction Master"); System.out.println("Crouching to Auction Master");
KeyBindingManager.updateKeys(true, false, false, false, false, true, false); KeyBindingManager.updateKeys(true, false, false, false, false, true, false);
} else { } else {
KeyBindingManager.updateKeys(true, false, false, false, false); KeyBindingManager.updateKeys(true, false, false, false, false);
@ -99,7 +101,7 @@ public class Flipper {
if (Utils.cookie != EffectState.ON && Lilase.mc.currentScreen == null && buyWait.passed()) { if (Utils.cookie != EffectState.ON && 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("Cannot find shop NPC, retrying");
buyWait.schedule(500); buyWait.schedule(500);
} else { } else {
Lilase.mc.playerController.interactWithEntitySendPacket(Lilase.mc.thePlayer, auctionMaster); Lilase.mc.playerController.interactWithEntitySendPacket(Lilase.mc.thePlayer, auctionMaster);
@ -111,7 +113,7 @@ public class Flipper {
} else if (InventoryUtils.inventoryNameContains("Create BIN Auction")) { } else if (InventoryUtils.inventoryNameContains("Create BIN Auction")) {
if (InventoryUtils.isStoneButton() && buyWait.passed()) { if (InventoryUtils.isStoneButton() && buyWait.passed()) {
if (InventoryUtils.getSlotForItem(itemname) == -1) { if (InventoryUtils.getSlotForItem(itemname) == -1) {
Utils.debugLog("[Flipper] Cannot find item in inventory, stopping flipper"); Utils.debugLog("Cannot find item in inventory, stopping flipper");
state = FlipperState.NONE; state = FlipperState.NONE;
Lilase.sniper.setOpen(true); Lilase.sniper.setOpen(true);
return; return;
@ -151,10 +153,9 @@ public class Flipper {
case NONE: case NONE:
break; break;
} }
} }
public JsonObject getItemData() throws IOException { public static JsonObject getItemData() throws IOException {
URL url = new URL("https://www.night0721.me/api/skyblock"); URL url = new URL("https://www.night0721.me/api/skyblock");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.addRequestProperty("Content-Type", "text/plain"); connection.addRequestProperty("Content-Type", "text/plain");
@ -176,15 +177,15 @@ public class Flipper {
return (JsonObject) new JsonParser().parse(content.toString()); return (JsonObject) new JsonParser().parse(content.toString());
} }
private float distanceToFirstPoint() { 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)); return (float) Math.sqrt(Math.pow(Lilase.mc.thePlayer.posX - (-2.5), 2) + Math.pow(Lilase.mc.thePlayer.posZ - (-91.5), 2));
} }
private float distanceToAuctionMaster() { public static float distanceToAuctionMaster() {
return (float) Math.sqrt(Math.pow(Lilase.mc.thePlayer.posX - (-45), 2) + Math.pow(Lilase.mc.thePlayer.posZ - (-90), 2)); return (float) Math.sqrt(Math.pow(Lilase.mc.thePlayer.posX - (-45), 2) + Math.pow(Lilase.mc.thePlayer.posZ - (-90), 2));
} }
private Entity getAuctionMaster() { public static Entity getAuctionMaster() {
for (final Entity e : Lilase.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());

View file

@ -1,10 +1,131 @@
package me.night0721.lilase.features.sniper; package me.night0721.lilase.features.sniper;
import me.night0721.lilase.Lilase;
import me.night0721.lilase.player.EffectState;
import me.night0721.lilase.utils.*;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import java.util.Objects;
import static me.night0721.lilase.features.flipper.Flipper.*;
public class PageFlipper { public class PageFlipper {
public PageFlipperState state = PageFlipperState.NONE;
public Clock cooldown = new Clock();
public boolean open = false;
private Thread loop;
public void start() { public void start() {
// Utils.checkFooter(); Utils.checkFooter();
// if (Utils.cookie) { if (Utils.cookie == EffectState.ON) state = PageFlipperState.OPENING;
// Utils.sendServerMessage("/ah"); else {
// } Utils.sendServerMessage("/hub");
state = PageFlipperState.WALKING_TO_FIRST_POINT;
}
}
public void switchStates() {
switch (state) {
case WALKING_TO_FIRST_POINT:
if (Lilase.mc.currentScreen != null) {
Lilase.mc.thePlayer.closeScreen();
} else if (distanceToFirstPoint() < 0.7f) {
System.out.println("Moving to auction house");
KeyBindingManager.updateKeys(false, false, false, false, false);
state = PageFlipperState.WALKING_INTO_AUCTION_HOUSE;
} else if (distanceToFirstPoint() < 5f) {
System.out.println("Crouching to point 1");
KeyBindingManager.updateKeys(true, false, false, false, false, true, false);
} else {
KeyBindingManager.updateKeys(true, false, false, false, false);
}
break;
case WALKING_INTO_AUCTION_HOUSE:
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");
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 = PageFlipperState.OPENING;
} else if (distanceToAuctionMaster() < 5f) {
System.out.println("Crouching to Auction Master");
KeyBindingManager.updateKeys(true, false, false, false, false, true, false);
} else {
KeyBindingManager.updateKeys(true, false, false, false, false);
}
break;
case OPENING:
if (Utils.cookie != EffectState.ON && Lilase.mc.currentScreen == null && cooldown.passed()) {
final Entity auctionMaster = getAuctionMaster();
if (auctionMaster == null) {
Utils.debugLog("Cannot find shop NPC, retrying");
cooldown.schedule(500);
} else {
Lilase.mc.playerController.interactWithEntitySendPacket(Lilase.mc.thePlayer, auctionMaster);
cooldown.schedule(1500);
}
} else if (Utils.cookie == EffectState.ON) {
if (Lilase.mc.currentScreen != null) Lilase.mc.thePlayer.closeScreen();
else Utils.sendServerMessage("/ah");
} else if (InventoryUtils.inventoryNameContains("Auction House") && cooldown.passed()) {
InventoryUtils.clickOpenContainerSlot(11);
state = PageFlipperState.START;
}
case START:
if (InventoryUtils.inventoryNameContains("Auctions")) {
ItemStack is = InventoryUtils.getStackInOpenContainerSlot(49);
if (is != null && is.getItem() == Items.arrow) {
if (loop == null) {
loop = new Thread(() -> {
for (int i = 11; i <= 43; i++) {
if (!Objects.equals(Lilase.mc.thePlayer.openContainer.getSlot(i).getStack().getDisplayName(), " ")) {
byte[] b = Lilase.mc.thePlayer.openContainer.getSlot(i).getStack().getTagCompound().getCompoundTag("display").getByteArray("Lore");
// System.out.println(Arrays.toString(b).replaceAll("§[0-9a-z]", ""));
}
}
loop = null;
});
loop.start();
}
} else {
Utils.debugLog("Not in auction house GUI, stopping");
// toggleAuction();
}
} else {
Utils.debugLog("No GUI open, stopping");
}
case NONE:
break;
}
}
public void toggleAuction() {
if (getOpen()) {
Utils.sendMessage("Stopped Page Flipper");
Lilase.mc.thePlayer.closeScreen();
state = PageFlipperState.NONE;
setOpen(false);
UngrabUtils.regrabMouse();
} else {
if (Utils.checkInHub()) {
Utils.sendMessage("Started Page Flipper");
start();
setOpen(true);
UngrabUtils.ungrabMouse();
} 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;
} }
} }

View file

@ -0,0 +1,5 @@
package me.night0721.lilase.features.sniper;
public enum PageFlipperState {
NONE, WALKING_TO_FIRST_POINT, WALKING_INTO_AUCTION_HOUSE, OPENING, START
}

View file

@ -1,6 +1,7 @@
package me.night0721.lilase.utils; package me.night0721.lilase.utils;
import me.night0721.lilase.Lilase; import me.night0721.lilase.Lilase;
import me.night0721.lilase.config.AHConfig;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@ -21,7 +22,17 @@ public class KeyBindingManager {
@SubscribeEvent @SubscribeEvent
public void onKeyPress(InputEvent.KeyInputEvent event) { public void onKeyPress(InputEvent.KeyInputEvent event) {
if (keyBindings[0].isPressed()) { if (keyBindings[0].isPressed()) {
switch (AHConfig.SNIPER_MODE) {
case 0:
Lilase.sniper.toggleAuction(); Lilase.sniper.toggleAuction();
break;
case 1:
Lilase.pageFlipper.toggleAuction();
break;
case 2:
Lilase.cofl.toggleAuction();
break;
}
} }
if (keyBindings[1].isPressed()) { if (keyBindings[1].isPressed()) {
Lilase.config.openGui(); Lilase.config.openGui();