From b5cd8f42e063cea235bd2971412c3b48e2f3afeb Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sat, 5 Nov 2022 21:25:38 +0000 Subject: [PATCH] Fixed illusioner goals --- .../IllusionerBlindnessSpellGoalFactory.kt | 14 ++-- .../IllusionerMirrorSpellGoalFactory.kt | 14 ++-- .../opengoals/IllusionerBlindnessSpellGoal.kt | 50 ------------ .../ai/opengoals/IllusionerMirrorSpellGoal.kt | 29 ------- .../proxy/common/ai/opengoals/Spellcaster.kt | 79 ------------------- 5 files changed, 16 insertions(+), 170 deletions(-) delete mode 100644 eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/opengoals/IllusionerBlindnessSpellGoal.kt delete mode 100644 eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/opengoals/IllusionerMirrorSpellGoal.kt delete mode 100644 eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/opengoals/Spellcaster.kt diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/IllusionerBlindnessSpellGoalFactory.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/IllusionerBlindnessSpellGoalFactory.kt index 3bc7557e..fb04ddb5 100644 --- a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/IllusionerBlindnessSpellGoalFactory.kt +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/ai/entity/IllusionerBlindnessSpellGoalFactory.kt @@ -2,7 +2,6 @@ package com.willfp.eco.internal.spigot.proxy.common.ai.entity import com.willfp.eco.core.entities.ai.entity.EntityGoalIllusionerBlindnessSpell import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory -import com.willfp.eco.internal.spigot.proxy.common.ai.opengoals.IllusionerBlindnessSpellGoal import net.minecraft.world.entity.PathfinderMob import net.minecraft.world.entity.ai.goal.Goal import net.minecraft.world.entity.monster.Illusioner @@ -11,11 +10,14 @@ object IllusionerBlindnessSpellGoalFactory : EntityGoalFactory, - handle.level -) { - var openSpellCastingTickCount - get() = this.spellCastingTickCount - set(value) { - this.spellCastingTickCount = value - } - - val openCastingSoundEvent = this.castingSoundEvent - - override fun applyRaidBuffs(wave: Int, unused: Boolean) { - handle.applyRaidBuffs(wave, unused) - } - - override fun getCelebrateSound(): SoundEvent { - return handle.celebrateSound - } - - override fun getCastingSoundEvent(): SoundEvent { - return this.openCastingSoundEvent - } -} - -@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") -abstract class OpenUseSpellGoal( - private val handle: SpellcasterIllager -) : Goal() { - private var attackWarmupDelay = 0 - private var nextAttackTickCount = 0 - - private val openHandle = DelegatedSpellcaster(handle) - - override fun canUse(): Boolean { - val entityliving: LivingEntity = handle.target ?: return false - return if (entityliving.isAlive) if (handle.isCastingSpell) false else handle.tickCount >= nextAttackTickCount else false - } - - override fun canContinueToUse(): Boolean { - val entityliving: LivingEntity = handle.target ?: return false - return entityliving.isAlive && attackWarmupDelay > 0 - } - - override fun start() { - attackWarmupDelay = castWarmupTime - openHandle.openSpellCastingTickCount = castingTime - nextAttackTickCount = handle.tickCount + castingInterval - val soundeffect = spellPrepareSound - if (soundeffect != null) { - handle.playSound(soundeffect, 1.0f, 1.0f) - } - handle.setIsCastingSpell(spell) - } - - override fun tick() { - --attackWarmupDelay - if (attackWarmupDelay == 0) { - performSpellCasting() - handle.playSound(openHandle.openCastingSoundEvent, 1.0f, 1.0f) - } - } - - protected abstract fun performSpellCasting() - protected abstract val castingTime: Int - protected abstract val castingInterval: Int - protected abstract val spellPrepareSound: SoundEvent? - protected abstract val spell: SpellcasterIllager.IllagerSpell? - protected open val castWarmupTime: Int = 60 -}