aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-16 15:04:39 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-16 15:04:39 +0100
commitd887e8dd0e24c300722b859cab4222e29f32c83a (patch)
tree7a0bfd64517984c083d688a1b60231ca7a02cea1 /src/main/java/at
parentf39532f554eb1b0f7171ed90ef81ea28fccf75be (diff)
downloadskyhanni-d887e8dd0e24c300722b859cab4222e29f32c83a.tar.gz
skyhanni-d887e8dd0e24c300722b859cab4222e29f32c83a.tar.bz2
skyhanni-d887e8dd0e24c300722b859cab4222e29f32c83a.zip
Moved packet test into own class.
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayHelper.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt104
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt78
6 files changed, 94 insertions, 102 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 5395f1bea..e83191ceb 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -47,6 +47,7 @@ import at.hannibal2.skyhanni.features.summonings.SummoningMobManager;
import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName;
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper;
import at.hannibal2.skyhanni.test.LorenzTest;
+import at.hannibal2.skyhanni.test.PacketTest;
import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter;
import kotlin.coroutines.EmptyCoroutineContext;
import kotlinx.coroutines.*;
@@ -198,6 +199,7 @@ public class SkyHanniMod {
loadModule(new LorenzTest());
loadModule(new ButtonOnPause());
+ loadModule(new PacketTest());
configManager = new ConfigManager();
configManager.firstLoad();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
index 510f66f0d..f7c89dc4d 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper
import at.hannibal2.skyhanni.features.misc.CollectionCounter
import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
import at.hannibal2.skyhanni.test.LorenzTest
+import at.hannibal2.skyhanni.test.PacketTest
import at.hannibal2.skyhanni.test.command.CopyItemCommand
import at.hannibal2.skyhanni.test.command.CopyNearbyEntitiesCommand
import net.minecraft.command.ICommandSender
@@ -38,7 +39,7 @@ object Commands {
registerCommand("copyitem") { CopyItemCommand.command(it) }
registerCommand("shconfigsave") { SkyHanniMod.configManager.saveConfig() }
registerCommand("shmarkplayer") { MarkedPlayerManager.command(it) }
- registerCommand("togglepacketlog") { LorenzTest.togglePacketLog() }
+ registerCommand("shtestpacket") { PacketTest.toggle() }
registerCommand("shreloadlisteners") { LorenzTest.reloadListeners() }
registerCommand("shstoplisteners") { LorenzTest.stopListeners() }
registerCommand("shresetburrowwarps") { BurrowWarpHelper.resetDisabledWarps() }
diff --git a/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt
index cdf2f29a5..acedbc608 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt
@@ -1,8 +1,11 @@
package at.hannibal2.skyhanni.events
+import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzVec
import net.minecraftforge.fml.common.eventhandler.Cancelable
@Cancelable
class PlaySoundEvent(val soundName: String, val location: LorenzVec, val pitch: Float, val volume: Float) :
- LorenzEvent() \ No newline at end of file
+ LorenzEvent() {
+ val distanceToPlayer by lazy { location.distance(LocationUtils.playerLocation()) }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayHelper.kt
index a622fa02a..64b54d9e6 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayHelper.kt
@@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.events.PlaySoundEvent
import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
-import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.sorted
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -37,8 +36,7 @@ class TiaRelayHelper {
if (!SkyHanniMod.feature.misc.tiaRelayHelper) return
if (!inInventory) return
- val location = event.location
- val distance = location.distance(LocationUtils.playerLocation())
+ val distance = event.distanceToPlayer
if (distance >= 2) return
if (lastClickSlot == 0) return
diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
index 49c1b899b..fefa34668 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
@@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.test
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
-import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.events.PlaySoundEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
import at.hannibal2.skyhanni.utils.*
@@ -12,14 +11,12 @@ import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.event.entity.player.ItemTooltipEvent
-import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.io.File
class LorenzTest {
companion object {
- private var shouldLogPackets = false
var text = ""
var a = 1.0
@@ -68,11 +65,6 @@ class LorenzTest {
// }
}
- fun togglePacketLog() {
- shouldLogPackets = !shouldLogPackets
- println("shouldLogPackets: $shouldLogPackets")
- }
-
fun reloadListeners() {
val blockedFeatures = try {
File("config/skyhanni/blocked-features.txt").readLines().toList()
@@ -145,30 +137,12 @@ class LorenzTest {
}
@SubscribeEvent
- fun onSendPacket(event: PacketEvent.SendEvent) {
- if (!shouldLogPackets) return
-
- val packet = event.packet
- val name = packet.javaClass.simpleName
-
- if (name == "C0FPacketConfirmTransaction") return
- if (name == "C03PacketPlayer") return
- if (name == "C05PacketPlayerLook") return
- if (name == "C00PacketKeepAlive") return
-
-// println("SendEvent: $name")
- }
-
- @SubscribeEvent
fun onSoundPlay(event: PlaySoundEvent) {
- if (!shouldLogPackets) return
-
-
- val location = event.location
- val distance = location.distance(LocationUtils.playerLocation())
- val soundName = event.soundName
- val pitch = event.pitch
- val volume = event.volume
+// val location = event.location
+// val distance = location.distance(LocationUtils.playerLocation())
+// val soundName = event.soundName
+// val pitch = event.pitch
+// val volume = event.volume
//background music
// if (soundName == "note.harp") {
@@ -331,8 +305,8 @@ class LorenzTest {
// }
- if (soundName == "game.player.hurt") return
- if (soundName.startsWith("step.")) return
+// if (soundName == "game.player.hurt") return
+// if (soundName.startsWith("step.")) return
// if (soundName != "mob.chicken.plop") return
@@ -346,8 +320,6 @@ class LorenzTest {
@SubscribeEvent
fun onParticlePlay(event: ReceiveParticleEvent) {
- if (!shouldLogPackets) return
-
// val particleType = event.type
// val distance = LocationUtils.playerLocation().distance(event.location).round(2)
//
@@ -370,66 +342,4 @@ class LorenzTest {
// println("particleSpeed: $particleSpeed")
// println("offset: $offset")
}
-
- @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
- fun onChatPacket(event: PacketEvent.ReceiveEvent) {
- if (!shouldLogPackets) return
-
- val packet = event.packet
-
- val name = packet.javaClass.simpleName
-
- if (name == "S2APacketParticles") return
- if (name == "S3BPacketScoreboardObjective") return
- if (name == "S18PacketEntityTeleport") return
- if (name == "S38PacketPlayerListItem") return
- if (name == "S17PacketEntityLookMove") return
- if (name == "S00PacketKeepAlive") return
- if (name == "S23PacketBlockChange") return
- if (name == "S32PacketConfirmTransaction") return
- if (name == "S47PacketPlayerListHeaderFooter") return
- if (name == "S29PacketSoundEffect") return
- if (name == "S04PacketEntityEquipment") return
- if (name == "S16PacketEntityLook") return
-
- if (name == "S15PacketEntityRelMove") return
- if (name == "S12PacketEntityVelocity") return
- if (name == "S19PacketEntityHeadLook") return
- if (name == "S06PacketUpdateHealth") return
- if (name == "S1FPacketSetExperience") return
- if (name == "S02PacketChat") return
- if (name == "S03PacketTimeUpdate") return
- if (name == "S1DPacketEntityEffect") return
- if (name == "S1EPacketRemoveEntityEffect") return
- if (name == "S43PacketCamera") return
- if (name == "S07PacketRespawn") return
- if (name == "S01PacketJoinGame") return
- if (name == "S05PacketSpawnPosition") return
- if (name == "S08PacketPlayerPosLook") return
- if (name == "S09PacketHeldItemChange") return
- if (name == "S37PacketStatistics") return
- if (name == "S39PacketPlayerAbilities") return
-
- if (name == "S3EPacketTeams") return
- if (name == "S3CPacketUpdateScore") return
-
- //TODO find out what that is
- if (name == "S0BPacketAnimation") return
-
- //world
- if (name == "S34PacketMaps") return
- if (name == "S21PacketChunkData") return
- if (name == "S22PacketMultiBlockChange") return
-// if (name == "S0EPacketSpawnObject") return
- if (name == "S13PacketDestroyEntities") return
- if (name == "S33PacketUpdateSign") return
-// if (name == "S0FPacketSpawnMob") return
-
- //inventory
-// if (name == "S2FPacketSetSlot") return
- if (name == "S2DPacketOpenWindow") return
-// if (name == "S30PacketWindowItems") return
- if (name == "S2EPacketCloseWindow") return
-
- }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt
new file mode 100644
index 000000000..4817979e7
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt
@@ -0,0 +1,78 @@
+package at.hannibal2.skyhanni.test
+
+import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class PacketTest {
+ companion object {
+ private var enabled = false
+
+ fun toggle() {
+ enabled = !enabled
+ LorenzUtils.chat("Packet test: $enabled")
+ }
+ }
+
+ @SubscribeEvent
+ fun onSendPacket(event: PacketEvent.SendEvent) {
+ if (!enabled) return
+
+ val packet = event.packet
+ val name = packet.javaClass.simpleName
+
+ if (name == "C00PacketKeepAlive") return
+
+ if (name == "C0FPacketConfirmTransaction") return
+ if (name == "C03PacketPlayer") return
+ if (name == "C04PacketPlayerPosition") return
+
+ println("Send: $name")
+ }
+
+ @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
+ fun onChatPacket(event: PacketEvent.ReceiveEvent) {
+ if (!enabled) return
+
+ val packet = event.packet
+ val name = packet.javaClass.simpleName
+
+ if (name == "S00PacketKeepAlive") return
+ if (name == "C00PacketKeepAlive") return
+
+ if (name == "S32PacketConfirmTransaction") return
+ if (name == "S3BPacketScoreboardObjective") return
+ if (name == "S17PacketEntityLookMove") return
+ if (name == "S15PacketEntityRelMove") return
+ if (name == "S33PacketUpdateSign") return
+ if (name == "S18PacketEntityTeleport") return
+ if (name == "S16PacketEntityLook") return
+ if (name == "S0BPacketAnimation") return
+ if (name == "S1FPacketSetExperience") return
+ if (name == "S06PacketUpdateHealth") return
+ if (name == "S02PacketChat") return
+ if (name == "S03PacketTimeUpdate") return
+ if (name == "S3EPacketTeams") return
+ if (name == "S38PacketPlayerListItem") return
+ if (name == "S04PacketEntityEquipment") return
+ if (name == "S1DPacketEntityEffect") return
+
+ if (name == "S19PacketEntityHeadLook") return
+ if (name == "S12PacketEntityVelocity") return
+ if (name == "S29PacketSoundEffect") return
+ if (name == "S22PacketMultiBlockChange") return
+ if (name == "S19PacketEntityStatus") return
+ if (name == "S1CPacketEntityMetadata") return
+ if (name == "S3CPacketUpdateScore") return
+ if (name == "S20PacketEntityProperties") return
+
+ if (name == "S1BPacketEntityAttach") return
+ if (name == "S13PacketDestroyEntities") return
+ if (name == "S0EPacketSpawnObject") return
+
+ if (name == "S2APacketParticles") return
+
+ println("Receive: $name")
+ }
+} \ No newline at end of file