aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-09-15 22:49:58 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-09-15 22:49:58 +0200
commit01d4aef89b7fdad58a320cf1eb4e478ac12aaba4 (patch)
tree3b933dd02f0f976760c0adba9342ea727bcda61a /src/main/java/at/hannibal2
parentf02297bfffcdaaef5da4e04725b0658c00889cb7 (diff)
downloadskyhanni-01d4aef89b7fdad58a320cf1eb4e478ac12aaba4.tar.gz
skyhanni-01d4aef89b7fdad58a320cf1eb4e478ac12aaba4.tar.bz2
skyhanni-01d4aef89b7fdad58a320cf1eb4e478ac12aaba4.zip
added and used events for particle and sound
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt51
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/PlayParticleEvent.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt30
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt7
10 files changed, 108 insertions, 58 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 4c5bfa561..a5fda4100 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -10,7 +10,10 @@ import at.hannibal2.skyhanni.features.anvil.AnvilCombineHelper;
import at.hannibal2.skyhanni.features.bazaar.BazaarApi;
import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod;
import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper;
-import at.hannibal2.skyhanni.features.chat.*;
+import at.hannibal2.skyhanni.features.chat.ChatFilter;
+import at.hannibal2.skyhanni.features.chat.HideFarDeathMessages;
+import at.hannibal2.skyhanni.features.chat.PlayerChatFilter;
+import at.hannibal2.skyhanni.features.chat.SkyBlockLevelChatMessage;
import at.hannibal2.skyhanni.features.commands.WikiCommand;
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager;
import at.hannibal2.skyhanni.features.dungeon.*;
@@ -73,6 +76,7 @@ public class SkyHanniMod {
registerEvent(new EntityData());
registerEvent(new EntityMovementData());
registerEvent(new ItemClickData());
+ registerEvent(new MinecraftData());
registerEvent(new BazaarOrderHelper());
registerEvent(new ChatFilter());
diff --git a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt
new file mode 100644
index 000000000..e9ef04947
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt
@@ -0,0 +1,51 @@
+package at.hannibal2.skyhanni.data
+
+import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.events.PlayParticleEvent
+import at.hannibal2.skyhanni.events.PlaySoundEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzVec
+import net.minecraft.network.play.server.S29PacketSoundEffect
+import net.minecraft.network.play.server.S2APacketParticles
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class MinecraftData {
+
+ @SubscribeEvent(receiveCanceled = true)
+ fun onSoundPacket(event: PacketEvent.ReceiveEvent) {
+ if (!LorenzUtils.inSkyblock) return
+
+ val packet = event.packet
+ if (packet !is S29PacketSoundEffect) return
+
+ if (PlaySoundEvent(
+ packet.soundName,
+ LorenzVec(packet.x, packet.y, packet.z),
+ packet.pitch,
+ packet.volume
+ ).postAndCatch()
+ ) {
+ event.isCanceled = true
+ }
+ }
+
+ @SubscribeEvent(receiveCanceled = true)
+ fun onParticleEvent(event: PacketEvent.ReceiveEvent) {
+ if (!LorenzUtils.inSkyblock) return
+
+ val packet = event.packet
+ if (packet !is S2APacketParticles) return
+
+ if (PlayParticleEvent(
+ packet.particleType!!,
+ LorenzVec(packet.xCoordinate, packet.yCoordinate, packet.zCoordinate),
+ packet.particleCount,
+ packet.particleSpeed,
+ LorenzVec(packet.xOffset, packet.yOffset, packet.zOffset),
+ packet.particleArgs
+ ).postAndCatch()
+ ) {
+ event.isCanceled = true
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/PlayParticleEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PlayParticleEvent.kt
new file mode 100644
index 000000000..08548f1f4
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/PlayParticleEvent.kt
@@ -0,0 +1,15 @@
+package at.hannibal2.skyhanni.events
+
+import at.hannibal2.skyhanni.utils.LorenzVec
+import net.minecraft.util.EnumParticleTypes
+import net.minecraftforge.fml.common.eventhandler.Cancelable
+
+@Cancelable
+class PlayParticleEvent(
+ val type: EnumParticleTypes,
+ val location: LorenzVec,
+ val count: Int,
+ val speed: Float,
+ val offset: LorenzVec,
+ val particleArgs: IntArray
+) : LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt
new file mode 100644
index 000000000..cdf2f29a5
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt
@@ -0,0 +1,8 @@
+package at.hannibal2.skyhanni.events
+
+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
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt
index 7222d080d..a78f4a64c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt
@@ -8,7 +8,6 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.EntityGuardian
-import net.minecraft.network.play.server.S2APacketParticles
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -106,10 +105,8 @@ class DungeonCleanEnd {
}
@SubscribeEvent
- fun onReceivePacket(event: PacketEvent.ReceiveEvent) {
- if (!shouldBlock()) return
-
- if (event.packet is S2APacketParticles) {
+ fun onReceivePacket(event: PlayParticleEvent) {
+ if (shouldBlock()) {
event.isCanceled = true
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt
index acc0de8a0..2f36f01e5 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt
@@ -8,10 +8,8 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.getLorenzVec
-import at.hannibal2.skyhanni.utils.toLorenzVec
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.item.EntityItem
-import net.minecraft.network.play.server.S2APacketParticles
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -133,22 +131,19 @@ class DungeonHideItems {
}
@SubscribeEvent
- fun onReceivePacket(event: PacketEvent.ReceiveEvent) {
+ fun onReceivePacket(event: PlayParticleEvent) {
if (!LorenzUtils.inDungeons) return
if (!SkyHanniMod.feature.dungeon.hideSuperboomTNT && !SkyHanniMod.feature.dungeon.hideReviveStone) return
- val packet = event.packet
- if (packet is S2APacketParticles) {
- val packetLocation = packet.toLorenzVec()
+ val packetLocation = event.location
for (armorStand in hideParticles.filter { it.value + 100 > System.currentTimeMillis() }.map { it.key }) {
val distance = packetLocation.distance(armorStand.getLorenzVec())
if (distance < 2) {
//only hiding white "sparkling" particles
- if (packet.particleType.particleID == 3) {
+ if (event.type.particleID == 3) {
event.isCanceled = true
}
}
- }
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt
index c2b9ced29..28d605946 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt
@@ -2,13 +2,12 @@ package at.hannibal2.skyhanni.features.itemabilities
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.ItemClickInHandEvent
-import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.events.PlayParticleEvent
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils
import at.hannibal2.skyhanni.utils.SpecialColour
import net.minecraft.client.Minecraft
-import net.minecraft.network.play.server.S2APacketParticles
import net.minecraft.util.EnumParticleTypes
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -19,20 +18,12 @@ class FireVeilWandParticles {
var lastClick = 0L
@SubscribeEvent
- fun onChatPacket(event: PacketEvent.ReceiveEvent) {
+ fun onChatPacket(event: PlayParticleEvent) {
if (!LorenzUtils.inSkyblock) return
if (SkyHanniMod.feature.itemAbilities.fireVeilWandDisplay == 0) return
if (System.currentTimeMillis() > lastClick + 5_500) return
- val packet = event.packet
- if (packet !is S2APacketParticles) return
-
-
- if (packet.particleType == EnumParticleTypes.FLAME && packet.particleCount == 1 && packet.particleSpeed == 0f &&
- packet.xOffset == 0f &&
- packet.yOffset == 0f &&
- packet.zOffset == 0f
- ) {
+ if (event.type == EnumParticleTypes.FLAME && event.count == 1 && event.speed == 0f && event.offset.isZero()) {
event.isCanceled = true
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
index cb82e1a90..92aad363f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.background
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.events.LorenzActionBarEvent
import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.events.PlaySoundEvent
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
@@ -16,8 +17,6 @@ import net.minecraft.client.renderer.GlStateManager
import net.minecraft.item.ItemStack
import net.minecraft.network.play.client.C07PacketPlayerDigging
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement
-import net.minecraft.network.play.server.S29PacketSoundEffect
-import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -27,36 +26,33 @@ class ItemAbilityCooldown {
var tick = 0
val items = mutableMapOf<ItemStack, ItemText>()
- @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
- fun onChatPacket(event: PacketEvent.ReceiveEvent) {
- val packet = event.packet
- if (packet is S29PacketSoundEffect) {
- if (packet.soundName == "mob.zombie.remedy") {
- if (packet.pitch == 0.6984127f && packet.volume == 1f) {
+ @SubscribeEvent
+ fun onSoundEvent(event: PlaySoundEvent) {
+ if (event.soundName == "mob.zombie.remedy") {
+ if (event.pitch == 0.6984127f && event.volume == 1f) {
ItemAbility.HYPERION.sound()
}
}
- if (packet.soundName == "mob.enderdragon.growl") {
- if (packet.pitch == 1f && packet.volume == 1f) {
+ if (event.soundName == "mob.enderdragon.growl") {
+ if (event.pitch == 1f && event.volume == 1f) {
ItemAbility.ICE_SPRAY_WAND.sound()
}
}
- if (packet.soundName == "mob.endermen.portal") {
- if (packet.pitch == 0.61904764f && packet.volume == 1f) {
+ if (event.soundName == "mob.endermen.portal") {
+ if (event.pitch == 0.61904764f && event.volume == 1f) {
ItemAbility.GYROKINETIC_WAND.sound()
}
}
- if (packet.soundName == "random.anvil_land") {
- if (packet.pitch == 0.4920635f && packet.volume == 1f) {
+ if (event.soundName == "random.anvil_land") {
+ if (event.pitch == 0.4920635f && event.volume == 1f) {
ItemAbility.GIANTS_SWORD.sound()
}
}
- if (packet.soundName == "mob.ghast.affectionate_scream") {
- if (packet.pitch == 0.4920635f && packet.volume == 0.15f) {
+ if (event.soundName == "mob.ghast.affectionate_scream") {
+ if (event.pitch == 0.4920635f && event.volume == 0.15f) {
ItemAbility.ATOMSPLIT_KATANA.sound()
}
}
- }
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt
index 07dc6d305..419f82486 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt
@@ -1,26 +1,20 @@
package at.hannibal2.skyhanni.features.nether.ashfang
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.events.PlayParticleEvent
import at.hannibal2.skyhanni.features.damageindicator.BossType
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
import at.hannibal2.skyhanni.utils.LorenzUtils
-import net.minecraft.network.play.server.S2APacketParticles
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class AshfangHideParticles {
@SubscribeEvent
- fun onReceivePacket(event: PacketEvent.ReceiveEvent) {
- if (event.packet !is S2APacketParticles) return
-
- if (isEnabled()) {
+ fun onReceivePacket(event: PlayParticleEvent) {
+ if (LorenzUtils.inSkyblock && SkyHanniMod.feature.ashfang.hideParticles &&
+ DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG)
+ ) {
event.isCanceled = true
}
}
-
- private fun isEnabled(): Boolean {
- return LorenzUtils.inSkyblock && SkyHanniMod.feature.ashfang.hideParticles &&
- DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG)
- }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
index 117a35f77..0d70b5e5a 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
@@ -1,7 +1,6 @@
package at.hannibal2.skyhanni.utils
import net.minecraft.entity.Entity
-import net.minecraft.network.play.server.S2APacketParticles
import net.minecraft.util.BlockPos
import net.minecraft.util.Rotations
import net.minecraft.util.Vec3
@@ -75,6 +74,8 @@ data class LorenzVec(
return "$x:$y:$z"
}
+ fun isZero(): Boolean = x == 0.0 && y == 0.0 && z == 0.0
+
companion object {
fun getFromYawPitch(yaw: Double, pitch: Double): LorenzVec {
val yaw: Double = (yaw + 90) * Math.PI / 180
@@ -108,6 +109,4 @@ fun Entity.getLorenzVec(): LorenzVec = LorenzVec(posX, posY, posZ)
fun Vec3.toLorenzVec(): LorenzVec = LorenzVec(xCoord, yCoord, zCoord)
-fun Rotations.toLorenzVec(): LorenzVec = LorenzVec(x, y, z)
-
-fun S2APacketParticles.toLorenzVec(): LorenzVec = LorenzVec(xCoordinate, yCoordinate, zCoordinate) \ No newline at end of file
+fun Rotations.toLorenzVec(): LorenzVec = LorenzVec(x, y, z) \ No newline at end of file