From 354805d19626e375c2adc79e34cac7ca78ecc7ee Mon Sep 17 00:00:00 2001 From: Will FP Date: Thu, 23 Nov 2023 12:57:03 +0000 Subject: [PATCH] Improved aoe --- .../willfp/libreforge/effects/impl/EffectAOE.kt | 15 +++++++++++++-- .../libreforge/effects/impl/EffectAOEBlocks.kt | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt index 365c2ad46..2adb40b59 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt @@ -26,10 +26,21 @@ object EffectAOE : Effect("aoe") { } override fun onTrigger(config: Config, data: TriggerData, compileData: AOECompileData): Boolean { - val location = data.dispatcher.get()?.eyeLocation - ?: data.dispatcher.location + val location = data.location?.clone() + ?: data.dispatcher.location?.clone() ?: return false + val dispatcherLocation = data.dispatcher.location + + if (dispatcherLocation != null) { + if (location.world == dispatcherLocation.world + && location.distanceSquared(dispatcherLocation) <= 1.0 + ) { + location.add(0.0, data.dispatcher.get()?.eyeHeight ?: 0.0, 0.0) + location.direction = dispatcherLocation.direction + } + } + val shape = compileData.shape ?: return false for (entity in shape.getEntities( diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt index aa5342bcd..4b0fb44f7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt @@ -24,10 +24,21 @@ object EffectAOEBlocks : Effect("aoe_blocks") { } override fun onTrigger(config: Config, data: TriggerData, compileData: AOECompileData): Boolean { - val location = data.dispatcher.get()?.eyeLocation - ?: data.dispatcher.location + val location = data.location?.clone() + ?: data.dispatcher.location?.clone() ?: return false + val dispatcherLocation = data.dispatcher.location + + if (dispatcherLocation != null) { + if (location.world == dispatcherLocation.world + && location.distanceSquared(dispatcherLocation) <= 1.0 + ) { + location.add(0.0, data.dispatcher.get()?.eyeHeight ?: 0.0, 0.0) + location.direction = dispatcherLocation.direction + } + } + val shape = compileData.shape ?: return false for (block in shape.getBlocks(