diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-12 06:39:15 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-12 06:39:15 +0200 |
commit | c2a4208969d8f2ac18e8dcec1fb92fee08d2096f (patch) | |
tree | 5afb35358eda84f084d672c1f6f7a64a763d2afb /src/main/java/at | |
parent | 8e41ca93ab22eb4807beaa7447e19455f992ab76 (diff) | |
download | skyhanni-c2a4208969d8f2ac18e8dcec1fb92fee08d2096f.tar.gz skyhanni-c2a4208969d8f2ac18e8dcec1fb92fee08d2096f.tar.bz2 skyhanni-c2a4208969d8f2ac18e8dcec1fb92fee08d2096f.zip |
Created Block Data class
Diffstat (limited to 'src/main/java/at')
3 files changed, 25 insertions, 18 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 1511f8db6..524616a5e 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -154,6 +154,7 @@ class SkyHanniMod { loadModule(GardenCropSpeed) loadModule(ProfileStorageData) loadModule(TitleData()) + loadModule(BlockData()) // APIs loadModule(BazaarApi()) diff --git a/src/main/java/at/hannibal2/skyhanni/data/BlockData.kt b/src/main/java/at/hannibal2/skyhanni/data/BlockData.kt new file mode 100644 index 000000000..0c45a7bb1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/BlockData.kt @@ -0,0 +1,24 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.ServerBlockChangeEvent +import net.minecraft.network.play.server.S22PacketMultiBlockChange +import net.minecraft.network.play.server.S23PacketBlockChange +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class BlockData { + + @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) + fun onChatPacket(event: PacketEvent.ReceiveEvent) { + val packet = event.packet + + if (packet is S23PacketBlockChange) { + ServerBlockChangeEvent(packet.blockPosition, packet.blockState).postAndCatch() + } else if (packet is S22PacketMultiBlockChange) { + for (block in packet.changedBlocks) { + ServerBlockChangeEvent(block.pos, block.blockState).postAndCatch() + } + } + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt index a450280f9..0077fc870 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt @@ -1,6 +1,5 @@ package at.hannibal2.skyhanni.features.rift.area.livingcave -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.ServerBlockChangeEvent import at.hannibal2.skyhanni.events.withAlpha @@ -18,11 +17,8 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP -import net.minecraft.network.play.server.S22PacketMultiBlockChange -import net.minecraft.network.play.server.S23PacketBlockChange import net.minecraft.util.EnumParticleTypes import net.minecraftforge.client.event.RenderWorldLastEvent -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class LivingCaveDefenseBlocks { @@ -87,20 +83,6 @@ class LivingCaveDefenseBlocks { } } - // TODO move to somewhere else - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onChatPacket(event: PacketEvent.ReceiveEvent) { - val packet = event.packet - - if (packet is S23PacketBlockChange) { - ServerBlockChangeEvent(packet.blockPosition, packet.blockState).postAndCatch() - } else if (packet is S22PacketMultiBlockChange) { - for (block in packet.changedBlocks) { - ServerBlockChangeEvent(block.pos, block.blockState).postAndCatch() - } - } - } - @SubscribeEvent fun onBlockChange(event: ServerBlockChangeEvent) { if (!isEnabled()) return |