diff options
author | Roman / Linnea Gräf <nea@nea.moe> | 2023-04-20 21:59:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-20 21:59:19 +0200 |
commit | f3b199cf8abd93e6b8b761af8e7b28bed5fe7592 (patch) | |
tree | 28924c0b9d4b0fa006906f989f4dc545b11a7606 /src/main/java/at/hannibal2/skyhanni/events | |
parent | 9699af8fb7e394b124a282ded8a7cf185d592e8e (diff) | |
download | skyhanni-f3b199cf8abd93e6b8b761af8e7b28bed5fe7592.tar.gz skyhanni-f3b199cf8abd93e6b8b761af8e7b28bed5fe7592.tar.bz2 skyhanni-f3b199cf8abd93e6b8b761af8e7b28bed5fe7592.zip |
Mark packet event as async and fix threading issue in garden visitor … (#51)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/events')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/events/OwnInventorItemUpdateEvent.kt | 5 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt | 26 |
2 files changed, 20 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/OwnInventorItemUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/OwnInventorItemUpdateEvent.kt index d9b641cee..892651a3d 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/OwnInventorItemUpdateEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/OwnInventorItemUpdateEvent.kt @@ -2,4 +2,7 @@ package at.hannibal2.skyhanni.events import net.minecraft.item.ItemStack -class OwnInventorItemUpdateEvent(val itemStack: ItemStack): LorenzEvent()
\ No newline at end of file +/** + * Note: This event is async and may not be executed on the main minecraft thread. + */ +data class OwnInventorItemUpdateEvent(val itemStack: ItemStack): LorenzEvent()
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt index abdb79b39..71c1cfa73 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt @@ -4,19 +4,25 @@ import net.minecraft.network.Packet import net.minecraftforge.fml.common.eventhandler.Cancelable @Cancelable -open class PacketEvent(val packet: Packet<*>) : LorenzEvent() { - var direction: Direction? = null +/** + * Note: This event is async and may not be executed on the main minecraft thread. + */ +abstract class PacketEvent : LorenzEvent() { + abstract val direction: Direction + abstract val packet: Packet<*> - class ReceiveEvent(packet: Packet<*>) : PacketEvent(packet) { - init { - direction = Direction.INBOUND - } + /** + * Note: This event is async and may not be executed on the main minecraft thread. + */ + data class ReceiveEvent(override val packet: Packet<*>) : PacketEvent() { + override val direction = Direction.INBOUND } - class SendEvent(packet: Packet<*>) : PacketEvent(packet) { - init { - direction = Direction.OUTBOUND - } + /** + * Note: This event is async and may not be executed on the main minecraft thread. + */ + data class SendEvent(override val packet: Packet<*>) : PacketEvent() { + override val direction = Direction.OUTBOUND } enum class Direction { |