aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-08-06 11:46:08 +0200
committerLorenz <lo.scherf@gmail.com>2022-08-06 11:46:08 +0200
commitbfa53ca5b4cb9a0ef31256746612cb6289b06a49 (patch)
tree949cf71ede55fbb7ee33bfec0fcf9ec32873b8d5 /src/main/java/at
parent283a986d3d0f84afc5c38fb4c8465abc5de0d2b2 (diff)
downloadskyhanni-bfa53ca5b4cb9a0ef31256746612cb6289b06a49.tar.gz
skyhanni-bfa53ca5b4cb9a0ef31256746612cb6289b06a49.tar.bz2
skyhanni-bfa53ca5b4cb9a0ef31256746612cb6289b06a49.zip
Merge branch 'master' of C:\Users\Lorenz\IdeaProjects\SkyHanni with conflicts.
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java55
-rw-r--r--src/main/java/at/hannibal2/skyhanni/chat/ChatFilter.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/chat/NewChatFilter.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/diana/GriffinBurrowFinder.kt159
-rw-r--r--src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/DungeonBossFinder.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/misc/CurrentPetDisplay.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/GriffinJavaUtils.java353
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/GriffinUtils.kt116
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt81
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt24
12 files changed, 782 insertions, 59 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 179f24faa..a1cc397f5 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -5,9 +5,11 @@ import at.hannibal2.skyhanni.bazaar.BazaarBestSellMethod;
import at.hannibal2.skyhanni.bazaar.BazaarOrderHelper;
import at.hannibal2.skyhanni.chat.ChatFilter;
import at.hannibal2.skyhanni.chat.ChatManager;
+import at.hannibal2.skyhanni.chat.NewChatFilter;
import at.hannibal2.skyhanni.chat.PlayerChatFilter;
import at.hannibal2.skyhanni.config.Features;
import at.hannibal2.skyhanni.config.gui.commands.Commands;
+import at.hannibal2.skyhanni.diana.GriffinBurrowFinder;
import at.hannibal2.skyhanni.dungeon.*;
import at.hannibal2.skyhanni.dungeon.damageindicator.DungeonBossDamageIndicator;
import at.hannibal2.skyhanni.fishing.SeaCreatureManager;
@@ -16,13 +18,14 @@ import at.hannibal2.skyhanni.fishing.TrophyFishMessages;
import at.hannibal2.skyhanni.inventory.anvil.AnvilCombineHelper;
import at.hannibal2.skyhanni.items.HideNotClickableItems;
import at.hannibal2.skyhanni.items.ItemDisplayOverlayFeatures;
-import at.hannibal2.skyhanni.items.VanillaItemManager;
import at.hannibal2.skyhanni.items.abilitycooldown.ItemAbilityCooldown;
import at.hannibal2.skyhanni.misc.*;
import at.hannibal2.skyhanni.repo.RepoManager;
import at.hannibal2.skyhanni.test.LorenzTest;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.MinecraftForge;
@@ -32,9 +35,6 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
-import java.io.*;
-import java.nio.charset.StandardCharsets;
-
@Mod(modid = SkyHanniMod.MODID, version = SkyHanniMod.VERSION)
public class SkyHanniMod {
@@ -51,11 +51,7 @@ public class SkyHanniMod {
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
- loading("BazaarApi");
new BazaarApi();
- doneLoading();
-
- loading("MinecraftForge.EVENT_BUS");
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new ChatManager());
MinecraftForge.EVENT_BUS.register(new HypixelData());
@@ -63,10 +59,10 @@ public class SkyHanniMod {
MinecraftForge.EVENT_BUS.register(new ScoreboardData());
MinecraftForge.EVENT_BUS.register(new ApiData());
MinecraftForge.EVENT_BUS.register(new SeaCreatureManager());
- MinecraftForge.EVENT_BUS.register(new VanillaItemManager());
MinecraftForge.EVENT_BUS.register(new BazaarOrderHelper());
MinecraftForge.EVENT_BUS.register(new ChatFilter());
+ MinecraftForge.EVENT_BUS.register(new NewChatFilter());
MinecraftForge.EVENT_BUS.register(new PlayerChatFilter());
MinecraftForge.EVENT_BUS.register(new DungeonChatFilter());
MinecraftForge.EVENT_BUS.register(new HideNotClickableItems());
@@ -84,67 +80,35 @@ public class SkyHanniMod {
MinecraftForge.EVENT_BUS.register(new BazaarBestSellMethod());
MinecraftForge.EVENT_BUS.register(new AnvilCombineHelper());
MinecraftForge.EVENT_BUS.register(new SeaCreatureMessageShortener());
- doneLoading();
+ MinecraftForge.EVENT_BUS.register(new GriffinBurrowFinder());
- loading("Commands.init");
Commands.init();
- doneLoading();
- loading("more MinecraftForge.EVENT_BUS");
MinecraftForge.EVENT_BUS.register(new LorenzTest());
MinecraftForge.EVENT_BUS.register(new ButtonOnPause());
- doneLoading();
- loading("config");
configDirectory = new File("config/skyhanni");
try {
//noinspection ResultOfMethodCallIgnored
configDirectory.mkdir();
- } catch (Exception ignored) {
- }
+ } catch (Exception ignored) {}
configFile = new File(configDirectory, "config.json");
if (configFile.exists()) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) {
feature = gson.fromJson(reader, Features.class);
- } catch (Exception ignored) {
- }
+ } catch (Exception ignored) {}
}
- doneLoading();
- loading("features");
if (feature == null) {
feature = new Features();
saveConfig();
}
- doneLoading();
-
- loading("addShutdownHook");
Runtime.getRuntime().addShutdownHook(new Thread(this::saveConfig));
- doneLoading();
- loading("Repo");
repo = new RepoManager(configDirectory);
repo.loadRepoInformation();
- doneLoading();
- }
-
- private long startLoadTime = 0;
-
- private String lastLoad = "";
-
- private void loading(String text) {
- lastLoad = text;
- System.out.println(" ");
- System.out.println("SkyHanni starts loading '" + lastLoad + "'");
- startLoadTime = System.currentTimeMillis();
- }
-
- private void doneLoading() {
- long duration = System.currentTimeMillis() - startLoadTime;
- System.out.println("Done (took " + duration + " ms)");
- System.out.println(" ");
}
public void saveConfig() {
@@ -155,8 +119,7 @@ public class SkyHanniMod {
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) {
writer.write(gson.toJson(feature));
}
- } catch (IOException ignored) {
- }
+ } catch (IOException ignored) {}
}
public static GuiScreen screenToOpen = null;
diff --git a/src/main/java/at/hannibal2/skyhanni/chat/ChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/chat/ChatFilter.kt
index fc245405c..7efbf2ff6 100644
--- a/src/main/java/at/hannibal2/skyhanni/chat/ChatFilter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/chat/ChatFilter.kt
@@ -37,11 +37,28 @@ class ChatFilter {
winterIsland(message) && SkyHanniMod.feature.chat.others -> "winter_island"
uselessWarning(message) && SkyHanniMod.feature.chat.others -> "useless_warning"
friendJoin(message) && SkyHanniMod.feature.chat.others -> "friend_join"
+ annoyingSpam(message) && SkyHanniMod.feature.chat.others -> "annoying_spam"
+ else -> ""
+ }
+ //TODO split into others
+ private fun annoyingSpam(message: String): Boolean {
+ if (message.matchRegex("§7Your Implosion hit (.*) for §r§c(.*) §r§7damage.")) return true
+ if (message.matchRegex("§7Your Molten Wave hit (.*) for §r§c(.*) §r§7damage.")) return true
+ if (message == "§cThere are blocks in the way!") return true
+ if (message == "§aYour Blessing enchant got you double drops!") return true
+ if (message == "§cYou can't use the wardrobe in combat!") return true
+ if (message == "§6§lGOOD CATCH! §r§bYou found a §r§fFish Bait§r§b.") return true
+ if (message == "§6§lGOOD CATCH! §r§bYou found a §r§aGrand Experience Bottle§r§b.") return true
+ if (message == "§6§lGOOD CATCH! §r§bYou found a §r§aBlessed Bait§r§b.") return true
+ if (message == "§6§lGOOD CATCH! §r§bYou found a §r§fDark Bait§r§b.") return true
+ if (message == "§6§lGOOD CATCH! §r§bYou found a §r§fLight Bait§r§b.") return true
+ if (message == "§6§lGOOD CATCH! §r§bYou found a §r§aHot Bait§r§b.") return true
+ if (message == "§6§lGOOD CATCH! §r§bYou found a §r§fSpooky Bait§r§b.") return true
- else -> ""
+ return false
}
private fun friendJoin(message: String): Boolean {
diff --git a/src/main/java/at/hannibal2/skyhanni/chat/NewChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/chat/NewChatFilter.kt
new file mode 100644
index 000000000..b72f4fd4b
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/chat/NewChatFilter.kt
@@ -0,0 +1,18 @@
+package at.hannibal2.skyhanni.chat
+
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class NewChatFilter {
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (!LorenzUtils.isOnHypixel) return
+
+// val blockReason = block(event.message)
+// if (blockReason != "") {
+// event.blockedReason = blockReason
+// }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java b/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java
index b9260b71a..72e6c0ea1 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java
@@ -56,5 +56,15 @@ public class Commands {
}
)
);
+ ClientCommandHandler.instance.registerCommand(
+ new SimpleCommand(
+ "testhanni",
+ new SimpleCommand.ProcessCommandRunnable() {
+ public void processCommand(ICommandSender sender, String[] args) {
+ LorenzTest.Companion.testCommand();
+ }
+ }
+ )
+ );
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/diana/GriffinBurrowFinder.kt b/src/main/java/at/hannibal2/skyhanni/diana/GriffinBurrowFinder.kt
new file mode 100644
index 000000000..9cbabfa2f
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/diana/GriffinBurrowFinder.kt
@@ -0,0 +1,159 @@
+package at.hannibal2.skyhanni.diana
+
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.test.GriffinUtils.draw3DLine
+import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypoint
+import at.hannibal2.skyhanni.utils.*
+import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
+import net.minecraft.client.Minecraft
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.network.play.server.S29PacketSoundEffect
+import net.minecraft.network.play.server.S2APacketParticles
+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.TickEvent.ClientTickEvent
+import java.util.*
+
+class GriffinBurrowFinder {
+
+ private var ticks = 0
+ val list = mutableListOf<UUID>()
+ var lastArrowLine: Line? = null
+
+ @SubscribeEvent
+ fun onClientTick(event: ClientTickEvent?) {
+ if (!LorenzUtils.inSkyblock) return
+ ticks++
+ if (ticks % 5 == 0) {
+ checkEntities()
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ lastArrowLine = null
+ }
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ val message = event.message
+ if (message.startsWith("§eYou dug out a Griffin Burrow!") ||
+ message == "§eYou finished the Griffin burrow chain! §r§7(4/4)"
+ ) {
+ lastArrowLine = null
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldRender(event: RenderWorldLastEvent) {
+ if (lastArrowLine != null) {
+ var start = lastArrowLine!!.start
+ val y = (Minecraft.getMinecraft().thePlayer.position.y - 1).toDouble()
+ start = LorenzVec(start.x, y, start.z)
+ val direction = lastArrowLine!!.direction
+
+ event.drawWaypoint(start, LorenzColor.WHITE)
+ val nextPoint = start.add(direction.multiply(10))
+// event.drawWaypoint(nextPoint, LorenzColor.YELLOW)
+
+ event.draw3DLine(start, start.add(direction.multiply(400)), LorenzColor.YELLOW, 3, true)
+ }
+ }
+
+ var lastHarpTime = 0L
+ var lastHarpPitch = 0f
+ var lastHarpDistance = 0.0
+
+ @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
+ fun onChatPacket(event: PacketEvent.ReceiveEvent) {
+ val packet = event.packet
+ if (packet is S2APacketParticles) {
+ val x = packet.xCoordinate
+ val y = packet.yCoordinate
+ val z = packet.zCoordinate
+ val distance = LorenzVec(x, y, z).distance(Minecraft.getMinecraft().thePlayer.getLorenzVec())
+ if (distance < 20) {
+// LorenzDebug.log("")
+// LorenzDebug.log("S2APacketParticles close")
+// var particleType = packet.particleType
+// var particleID = particleType.particleID
+// LorenzDebug.log("particleType: $particleType")
+// LorenzDebug.log("particleID: $particleID")
+// LorenzDebug.log("distance: $distance")
+// LorenzDebug.log("")
+
+ } else {
+// LorenzDebug.log("S2APacketParticles far")
+ }
+ }
+ if (packet is S29PacketSoundEffect) {
+ val x = packet.x
+ val y = packet.y
+ val z = packet.z
+ val distance = LorenzVec(x, y, z).distance(Minecraft.getMinecraft().thePlayer.getLorenzVec())
+ if (distance < 20) {
+ val soundName = packet.soundName
+ val pitch = packet.pitch
+ val volume = packet.volume
+ if (soundName == "game.player.hurt" && volume == 0f) return
+
+ if (soundName == "note.harp") {
+
+ LorenzDebug.log("harp pitch: $pitch")
+ LorenzDebug.log("distance: $distance")
+ val now = System.currentTimeMillis()
+ if (lastHarpTime != 0L) {
+ LorenzDebug.log("")
+ val diffTime = now - lastHarpTime
+ LorenzDebug.log("diffTime: $diffTime")
+ val diffPitch = pitch - lastHarpPitch
+ LorenzDebug.log("diffPitch: $diffPitch")
+ val diffDistance = distance - lastHarpDistance
+ LorenzDebug.log("diffDistance: $diffDistance")
+ }
+ lastHarpTime = now
+ lastHarpPitch = pitch
+ lastHarpDistance = distance
+ LorenzDebug.log("")
+ return
+ }
+
+ LorenzDebug.log("")
+ LorenzDebug.log("S29PacketSoundEffect close")
+
+ LorenzDebug.log("soundName: $soundName")
+ LorenzDebug.log("pitch: $pitch")
+ LorenzDebug.log("volume: $volume")
+ LorenzDebug.log("")
+ } else {
+// LorenzDebug.log("S29PacketSoundEffect far")
+ }
+ }
+ }
+
+ private fun checkEntities() {
+ val playerLocation = Minecraft.getMinecraft().thePlayer.position.toLorenzVec()
+ for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList) {
+ if (list.contains(entity.uniqueID)) continue
+ if (entity !is EntityArmorStand) continue
+ val distance = entity.getLorenzVec().distance(playerLocation)
+ if (distance > 10) continue
+
+
+ val itemStack = entity.inventory[0] ?: continue
+ if (itemStack.cleanName() != "Arrow") continue
+
+ val rotationYaw = entity.rotationYaw
+ val direction = LorenzVec.getFromYawPitch(rotationYaw.toDouble(), 0.0)
+
+ lastArrowLine = Line(entity.getLorenzVec(), direction)
+ list.add(entity.uniqueID)
+ LorenzDebug.log("distance: $distance")
+ }
+ }
+
+ class Line(val start: LorenzVec, val direction: LorenzVec)
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/DungeonBossFinder.kt b/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/DungeonBossFinder.kt
index 1d30a9d24..02538673f 100644
--- a/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/DungeonBossFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/DungeonBossFinder.kt
@@ -152,8 +152,6 @@ class DungeonBossFinder {
if (DungeonData.isOneOf("F4", "M4")) {
if (entity is EntityGhast) {
val health = LorenzUtils.formatDouble(entity.health.toDouble())
- LorenzTest.enabled = true
- LorenzTest.text = "thorn has $health hp!"
return EntityResult(ignoreBlocks = true, finalBoss = true)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt
index 726c3172f..90ef95d4d 100644
--- a/src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt
@@ -167,7 +167,8 @@ class ItemAbilityCooldown {
ENDSTONE_SWORD("Extreme Focus", 5, "End Stone Sword"),
PIGMAN_SWORD("Burning Souls", 5, "Pigman Sword"),
- SOULWARD("Soulward", 20, "Soul Esoward");
+ SOULWARD("Soulward", 20, "Soul Esoward"),
+ ECHO("Echo", 3, "Ancestral Spade");
fun click() {
lastClick = System.currentTimeMillis()
diff --git a/src/main/java/at/hannibal2/skyhanni/misc/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/misc/CurrentPetDisplay.kt
index 06284c7c9..9266dd4f5 100644
--- a/src/main/java/at/hannibal2/skyhanni/misc/CurrentPetDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/misc/CurrentPetDisplay.kt
@@ -36,7 +36,6 @@ class CurrentPetDisplay {
}
}
-
@SubscribeEvent
fun renderOverlay(event: RenderGameOverlayEvent.Post) {
if (!LorenzUtils.inSkyblock) return
diff --git a/src/main/java/at/hannibal2/skyhanni/test/GriffinJavaUtils.java b/src/main/java/at/hannibal2/skyhanni/test/GriffinJavaUtils.java
new file mode 100644
index 000000000..431cfbe6f
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/test/GriffinJavaUtils.java
@@ -0,0 +1,353 @@
+package at.hannibal2.skyhanni.test;
+
+import at.hannibal2.skyhanni.utils.LorenzVec;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.WorldRenderer;
+import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.AxisAlignedBB;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+import java.text.DecimalFormat;
+import java.util.*;
+import java.util.List;
+import java.util.function.Function;
+
+public class GriffinJavaUtils {
+ public static <T> void permute(ArrayList<ArrayList<T>> result, T[] a, int k) {
+ if (k == a.length) {
+ ArrayList<T> subResult = new ArrayList<>();
+ result.add(subResult);
+ Collections.addAll(subResult, a);
+ } else {
+ for (int i = k; i < a.length; i++) {
+ T temp = a[k];
+ a[k] = a[i];
+ a[i] = temp;
+
+ permute(result, a, k + 1);
+
+ temp = a[k];
+ a[k] = a[i];
+ a[i] = temp;
+ }
+ }
+ }
+
+// public static <T> ArrayList<T> sortLocationListC(LorenzVec start, Map<T, LorenzVec> map, boolean brokenMath) {
+// Map<T, Double> fastestWithout = new HashMap<>();
+// for (T without : map.keySet()) {
+//
+// ArrayList<ArrayList<T>> variants = new ArrayList<>();
+// ArrayList<T> values = new ArrayList<>(map.keySet());
+//
+// values.remove(without);
+// T[] array = (T[]) values.toArray();
+//
+// permute(variants, array, 0);
+//
+// LinkedHashMap<ArrayList<T>, Double> distances = new LinkedHashMap<>();
+//
+// for (ArrayList<T> list : variants) {
+//
+// double distance = 0;
+// LorenzVec last = start;
+//
+// for (T t : list) {
+// LorenzVec location = map.get(t);
+// distance += last.distanceSq(location);
+// last = location;
+// }
+//
+// distances.put(list, distance);
+// }
+//
+// Map<ArrayList<T>, Double> sort;
+// if (brokenMath) {
+// sort = sortByValue(distances);
+// } else {
+// sort = sortByValueAsc(distances);
+// }
+//
+// double fastestDistance = sort.values().iterator().next();
+// fastestWithout.put(without, fastestDistance);
+// }
+//
+// T skip = sortByValueAsc(fastestWithout).keySet().iterator().next();
+//
+//
+// map.remove(skip);
+// ArrayList<T> result = sortLocationListB(start, map, brokenMath, false, T -> false, 0);
+// result.add(skip);
+//
+// return result;
+// }
+
+ public static <T> ArrayList<LorenzVec> sortLocationListB(LorenzVec start, Map<T, LorenzVec> map, boolean brokenMath,
+ boolean skipWorst, Function<T, Boolean> shouldAddToHostile, int addToHostileLastValue) {
+
+// if (skipWorst) {
+// return sortLocationListC(start, map, brokenMath);
+// }
+ ArrayList<ArrayList<T>> variants = new ArrayList<>();
+ Set<T> values = map.keySet();
+ T[] array = (T[]) values.toArray();
+
+ permute(variants, array, 0);
+
+ LinkedHashMap<ArrayList<T>, Double> distances = new LinkedHashMap<>();
+
+ int with = 0;
+ int without = 0;
+
+ for (ArrayList<T> list : variants) {
+
+ double distance = 0;
+ LorenzVec last = start;
+ T lastT = null;
+
+ for (T t : list) {
+ LorenzVec location = map.get(t);
+ distance += last.distanceSq(location);
+ last = location;
+ lastT = t;
+ }
+ if (shouldAddToHostile.apply(lastT)) {
+ distance += addToHostileLastValue;
+ with++;
+ } else {
+ without++;
+ }
+
+ distances.put(list, distance);
+ }
+// LorenzUtils.Companion.chat("with: " + with);
+// LorenzUtils.Companion.chat("without: " + without);
+
+ Map<ArrayList<T>, Double> sort;
+ if (brokenMath) {
+ sort = sortByValue(distances);
+ } else {
+ sort = sortByValueAsc(distances);
+ }
+ ArrayList<T> result = sort.keySet().iterator().next();
+ ArrayList<LorenzVec> resultList = new ArrayList<>();
+ for (T t : result) {
+ resultList.add(map.get(t));
+ }
+
+ return resultList;
+ }
+
+ //descending
+ public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
+ List<Map.Entry<K, V>> list = new ArrayList<>(map.entrySet());
+ list.sort(Map.Entry.comparingByValue());
+ Collections.reverse(list);
+
+ Map<K, V> result = new LinkedHashMap<>();
+ for (Map.Entry<K, V> entry : list) {
+ result.put(entry.getKey(), entry.getValue());
+ }
+
+ return result;
+ }
+
+ //ascending
+ public static <K, V extends Comparable<? super V>> Map<K, V> sortByValueAsc(Map<K, V> map) {
+ List<Map.Entry<K, V>> list = new ArrayList<>(map.entrySet());
+ list.sort(Map.Entry.comparingByValue());
+
+ Map<K, V> result = new LinkedHashMap<>();
+ for (Map.Entry<K, V> entry : list) {
+ result.put(entry.getKey(), entry.getValue());
+ }
+
+ return result;
+ }
+
+ public static String formatInteger(int i) {
+ return new DecimalFormat("#,##0").format(i).replace(',', '.');
+ }
+
+ public static List<ItemStack> getItemsInInventory() {
+ return getItemsInInventory(false);
+ }
+
+ public static List<ItemStack> getItemsInInventory(boolean withCursorItem) {
+ List<ItemStack> list = new ArrayList<>();
+
+// EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ if (player == null) {
+ System.err.println("loadCurrentInventory: player is null!");
+ return list;
+ }
+
+ InventoryPlayer inventory = player.inventory;
+ ItemStack[] mainInventory = inventory.mainInventory;
+
+ ArrayList<ItemStack> helpList = new ArrayList<>();
+ helpList.addAll(Arrays.asList(mainInventory));
+
+ if (withCursorItem) {
+ helpList.add(inventory.getItemStack());
+ }
+
+ for (ItemStack item : helpList) {
+ if (item == null) continue;
+ String name = item.getDisplayName();
+ if (name.equalsIgnoreCase("air")) continue;
+ if (name.equalsIgnoreCase("luft")) continue;
+ list.add(item);
+ }
+
+ return list;
+ }
+
+ public static void drawWaypoint(LorenzVec pos, float partialTicks, Color color, boolean beacon) {
+ drawWaypoint(pos, partialTicks, color, beacon, false);
+ }
+
+ public static void drawWaypoint(LorenzVec pos, float partialTicks, Color color, boolean beacon, boolean forceBeacon) {
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
+ double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
+ double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
+
+ double x = pos.getX() - viewerX;
+ double y = pos.getY() - viewerY;
+ double z = pos.getZ() - viewerZ;
+
+
+ GlStateManager.disableDepth();
+ GlStateManager.disableCull();
+ GlStateManager.disableTexture2D();
+ if (beacon) {
+ double distSq = x * x + y * y + z * z;
+ if (distSq > 5 * 5 || forceBeacon) {
+ //TODO add beacon
+// GriffinUtils.renderBeaconBeam(x, y, z, color.getRGB(), 1.0f, partialTicks);
+ }
+ }
+// BlockPos a = pos.toBlocPos();
+// BlockPos b = pos.add(1, 1, 1).toBlocPos();
+// draw3DBox(new AxisAlignedBB(a, b), color, partialTicks);
+
+ AxisAlignedBB aabb = new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
+
+ draw3DBox(aabb, color, partialTicks);
+ GlStateManager.disableLighting();
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableDepth();
+
+ }
+
+ public static void draw3DLine(LorenzVec p1, LorenzVec p2, Color color, int lineWidth, boolean depth, float partialTicks) {
+ GlStateManager.disableDepth();
+ GlStateManager.disableCull();
+
+// Vec3 pos1 = new Vec3(p1.getX(), p1.getY(), p1.getZ());
+// Vec3 pos2 = new Vec3(p2.getX(), p2.getY(), p2.getZ());
+
+ Entity render = Minecraft.getMinecraft().getRenderViewEntity();
+ WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
+
+ double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks;
+ double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks;
+ double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks;
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(-realX, -realY, -realZ);
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GL11.glLineWidth(lineWidth);
+
+
+ if (!depth) {
+ GL11.glDisable(GL11.GL_DEPTH_TEST);
+ GlStateManager.depthMask(false);
+ }
+ GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f);
+ worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
+
+ worldRenderer.pos(p1.getX(), p1.getY(), p1.getZ()).endVertex();
+ worldRenderer.pos(p2.getX(), p2.getY(), p2.getZ()).endVertex();
+ Tessellator.getInstance().draw();
+
+ GlStateManager.translate(realX, realY, realZ);
+ if (!depth) {
+ GL11.glEnable(GL11.GL_DEPTH_TEST);
+ GlStateManager.depthMask(true);
+ }
+
+
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.popMatrix();
+
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableDepth();
+ }
+
+ public static void draw3DBox(AxisAlignedBB aabb, Color colour, float partialTicks) {
+ Entity render = Minecraft.getMinecraft().getRenderViewEntity();
+ WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
+
+ double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks;
+ double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks;
+ double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks;
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(-realX, -realY, -realZ);
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GL11.glLineWidth(2);
+ GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue() / 255f, colour.getAlpha() / 255f);
+ worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
+
+ worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
+ worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();
+ worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
+ worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
+ worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
+ Tessellator.getInstance().draw();
+ worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
+ worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
+ worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
+ worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
+ worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();
+ worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
+ Tessellator.getInstance().draw();
+ worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
+ worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
+ worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
+ worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();
+ worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
+ worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
+ worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
+ worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
+ worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();
+ Tessellator.getInstance().draw();
+
+ GlStateManager.translate(realX, realY, realZ);
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.popMatrix();
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/test/GriffinUtils.kt b/src/main/java/at/hannibal2/skyhanni/test/GriffinUtils.kt
new file mode 100644
index 000000000..8b77dc6e3
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/test/GriffinUtils.kt
@@ -0,0 +1,116 @@
+package at.hannibal2.skyhanni.test
+
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzVec
+import net.minecraftforge.client.event.RenderWorldLastEvent
+
+object GriffinUtils {
+
+
+ fun RenderWorldLastEvent.drawWaypoint(location: LorenzVec, color: LorenzColor, beacon: Boolean = false) {
+ GriffinJavaUtils.drawWaypoint(location, partialTicks, color.toColor(), beacon)
+ }
+
+ fun RenderWorldLastEvent.draw3DLine(
+ p1: LorenzVec,
+ p2: LorenzVec,
+ color: LorenzColor,
+ lineWidth: Int,
+ depth: Boolean
+ ) {
+
+ GriffinJavaUtils.draw3DLine(p1, p2, color.toColor(), lineWidth, depth, partialTicks)
+ }
+
+// fun renderBeaconBeam(x: Double, y: Double, z: Double, rgb: Int, alphaMultiplier: Float, partialTicks: Float) {
+// val height = 300
+// val bottomOffset = 0
+// val topOffset = bottomOffset + height
+// val tessellator = Tessellator.getInstance()
+// val worldrenderer = tessellator.worldRenderer
+//
+//// Skytils.mc.textureManager.bindTexture(RenderUtil.beaconBeam)
+// GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0f)
+// GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0f)
+// GlStateManager.disableLighting()
+// GlStateManager.enableCull()
+// GlStateManager.enableTexture2D()
+// GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0)
+// GlStateManager.enableBlend()
+// GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
+// val time = Skytils.mc.theWorld.totalWorldTime + partialTicks.toDouble()
+// val d1 = MathHelper.func_181162_h(
+// -time * 0.2 - MathHelper.floor_double(-time * 0.1)
+// .toDouble()
+// )
+// val r = (rgb shr 16 and 0xFF) / 255f
+// val g = (rgb shr 8 and 0xFF) / 255f
+// val b = (rgb and 0xFF) / 255f
+// val d2 = time * 0.025 * -1.5
+// val d4 = 0.5 + cos(d2 + 2.356194490192345) * 0.2
+// val d5 = 0.5 + sin(d2 + 2.356194490192345) * 0.2
+// val d6 = 0.5 + cos(d2 + Math.PI / 4.0) * 0.2
+// val d7 = 0.5 + sin(d2 + Math.PI / 4.0) * 0.2
+// val d8 = 0.5 + cos(d2 + 3.9269908169872414) * 0.2
+// val d9 = 0.5 + sin(d2 + 3.9269908169872414) * 0.2
+// val d10 = 0.5 + cos(d2 + 5.497787143782138) * 0.2
+// val d11 = 0.5 + sin(d2 + 5.497787143782138) * 0.2
+// val d14 = -1.0 + d1
+// val d15 = height.toDouble() * 2.5 + d14
+// worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR)
+// worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0, d14).color(r, g, b, 1.0f).endVertex()
+// worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0, d14).color(r, g, b, 1.0f).endVertex()
+// worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0, d14).color(r, g, b, 1.0f).endVertex()
+// worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0, d14).color(r, g, b, 1.0f).endVertex()
+// worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0, d14).color(r, g, b, 1.0f).endVertex()
+// worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0, d14).color(r, g, b, 1.0f).endVertex()
+// worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0, d14).color(r, g, b, 1.0f).endVertex()
+// worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0, d14).color(r, g, b, 1.0f).endVertex()
+// worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+// .endVertex()
+// tessellator.draw()
+// GlStateManager.disableCull()
+// val d12 = -1.0 + d1
+// val d13 = height + d12
+// worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR)
+// worldrenderer.pos(x + 0.2, y + topOffset, z + 0.2).tex(1.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.2).tex(1.0, d12).color(r, g, b, 0.25f).endVertex()
+// worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.2).tex(0.0, d12).color(r, g, b, 0.25f).endVertex()
+// worldrenderer.pos(x + 0.8, y + topOffset, z + 0.2).tex(0.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + 0.8, y + topOffset, z + 0.8).tex(1.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.8).tex(1.0, d12).color(r, g, b, 0.25f).endVertex()
+// worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.8).tex(0.0, d12).color(r, g, b, 0.25f).endVertex()
+// worldrenderer.pos(x + 0.2, y + topOffset, z + 0.8).tex(0.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + 0.8, y + topOffset, z + 0.2).tex(1.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.2).tex(1.0, d12).color(r, g, b, 0.25f).endVertex()
+// worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.8).tex(0.0, d12).color(r, g, b, 0.25f).endVertex()
+// worldrenderer.pos(x + 0.8, y + topOffset, z + 0.8).tex(0.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + 0.2, y + topOffset, z + 0.8).tex(1.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+// .endVertex()
+// worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.8).tex(1.0, d12).color(r, g, b, 0.25f).endVertex()
+// worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.2).tex(0.0, d12).color(r, g, b, 0.25f).endVertex()
+// worldrenderer.pos(x + 0.2, y + topOffset, z + 0.2).tex(0.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+// .endVertex()
+// tessellator.draw()
+// }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
index 3d2611517..df176a02e 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
@@ -1,20 +1,22 @@
package at.hannibal2.skyhanni.test
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.GuiRender.renderString
+import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
-import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
-import at.hannibal2.skyhanni.utils.LorenzDebug
-import at.hannibal2.skyhanni.utils.LorenzLogger
-import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getSBItemID
import net.minecraft.client.Minecraft
+import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.client.event.RenderGameOverlayEvent
+import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class LorenzTest {
- var log = LorenzLogger("debug/packets")
+ var packetLog = LorenzLogger("debug/packets")
companion object {
var enabled = false
@@ -28,7 +30,7 @@ class LorenzTest {
print("===")
print("ITEM LORE")
print("display name: '" + itemStack.displayName.toString() + "'")
- val itemID = itemStack.getInternalName()
+ val itemID = itemStack.getSBItemID()
print("itemID: '$itemID'")
// val rarity: ItemRarityOld = ItemUtils.getRarity(itemStack)
// print("rarity: '$rarity'")
@@ -91,6 +93,68 @@ class LorenzTest {
private fun print(text: String) {
LorenzDebug.log(text)
}
+
+ fun testCommand() {
+ val minecraft = Minecraft.getMinecraft()
+ val start = minecraft.thePlayer.position.toLorenzVec()
+ val world = minecraft.theWorld
+ for (entity in world.loadedEntityList) {
+ val position = entity.position
+ val vec = position.toLorenzVec()
+ val distance = start.distance(vec)
+ if (distance < 10) {
+ LorenzDebug.log("found entity: " + entity.name)
+ val displayName = entity.displayName
+ LorenzDebug.log("displayName: $displayName")
+ val simpleName = entity.javaClass.simpleName
+ LorenzDebug.log("simpleName: $simpleName")
+ LorenzDebug.log("vec: $vec")
+ LorenzDebug.log("distance: $distance")
+
+ val rotationYaw = entity.rotationYaw
+ val rotationPitch = entity.rotationPitch
+ LorenzDebug.log("rotationYaw: $rotationYaw")
+ LorenzDebug.log("rotationPitch: $rotationPitch")
+
+ if (entity is EntityArmorStand) {
+ LorenzDebug.log("armor stand data:")
+ val headRotation = entity.headRotation.toLorenzVec()
+ val bodyRotation = entity.bodyRotation.toLorenzVec()
+ LorenzDebug.log("headRotation: $headRotation")
+ LorenzDebug.log("bodyRotation: $bodyRotation")
+
+ /**
+ * xzLen = cos(pitch)
+ x = xzLen * cos(yaw)
+ y = sin(pitch)
+ z = xzLen * sin(-yaw)
+ */
+
+// val xzLen = cos(0.0)
+// val x = xzLen * cos(rotationYaw)
+// val y = sin(0.0)
+// val z = xzLen * sin(-rotationYaw)
+
+ val dir = LorenzVec.getFromYawPitch(rotationYaw.toDouble(), 0.0)
+
+// val direction = Vec3(1.0, 1.0, 1.0).rotateYaw(rotationYaw).toLorenzVec()
+// val direction = LorenzVec(x, y, z)
+
+ for ((id, stack) in entity.inventory.withIndex()) {
+ LorenzDebug.log("id $id = $stack")
+ if (stack != null) {
+ val cleanName = stack.cleanName()
+ val type = stack.javaClass.name
+ LorenzDebug.log("cleanName: $cleanName")
+ LorenzDebug.log("type: $type")
+
+ }
+ }
+ }
+ LorenzDebug.log("")
+ }
+ }
+ }
}
@SubscribeEvent
@@ -102,6 +166,11 @@ class LorenzTest {
}
}
+ @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
+ fun onChatPacket(event: PacketEvent.ReceiveEvent) {
+ packetLog.log(event.packet.toString())
+ }
+
// @SubscribeEvent
// fun onGetBlockModel(event: RenderBlockInWorldEvent) {
// if (!LorenzUtils.inSkyblock || !SkyHanniMod.feature.debug.enabled) return
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
index bfc5f7228..510b04fb8 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
@@ -2,16 +2,22 @@ package at.hannibal2.skyhanni.utils
import net.minecraft.entity.Entity
import net.minecraft.util.BlockPos
+import net.minecraft.util.Rotations
import net.minecraft.util.Vec3
+import kotlin.math.cos
import kotlin.math.pow
+import kotlin.math.sin
data class LorenzVec(
val x: Double,
val y: Double,
- val z: Double
+ val z: Double,
) {
+
constructor(x: Int, y: Int, z: Int) : this(x.toDouble(), y.toDouble(), z.toDouble())
+ constructor(x: Float, y: Float, z: Float) : this(x.toDouble(), y.toDouble(), z.toDouble())
+
fun toBlocPos(): BlockPos = BlockPos(x, y, z)
fun toVec3(): Vec3 = Vec3(x, y, z)
@@ -47,6 +53,18 @@ data class LorenzVec(
LorenzVec(x multiplyZeroSave d.toDouble(), y multiplyZeroSave d.toDouble(), z multiplyZeroSave d.toDouble())
fun add(other: LorenzVec) = LorenzVec(x + other.x, y + other.y, z + other.z)
+
+ companion object {
+ fun getFromYawPitch(yaw: Double, pitch: Double): LorenzVec {
+ val yaw: Double = (yaw + 90) * Math.PI / 180
+ val pitch: Double = (pitch + 90) * Math.PI / 180
+
+ val x = sin(pitch) * cos(yaw)
+ val y = sin(pitch) * sin(yaw)
+ val z = cos(pitch)
+ return LorenzVec(x, z, y)
+ }
+ }
}
private infix fun Double.multiplyZeroSave(other: Double): Double {
@@ -58,4 +76,6 @@ fun BlockPos.toLorenzVec(): LorenzVec = LorenzVec(x, y, z)
fun Entity.getLorenzVec(): LorenzVec = LorenzVec(posX, posY, posZ)
-fun Vec3.toLorenzVec(): LorenzVec = LorenzVec(xCoord, yCoord, zCoord) \ No newline at end of file
+fun Vec3.toLorenzVec(): LorenzVec = LorenzVec(xCoord, yCoord, zCoord)
+
+fun Rotations.toLorenzVec(): LorenzVec = LorenzVec(x, y, z) \ No newline at end of file