This repository has been archived by the owner on May 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Move MythicMobs features to this repo
- Loading branch information
Showing
25 changed files
with
233 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion
1
...elengine/animation/AnimationController.kt → ...elengine/animation/AnimationController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
...plugin-integrations/src/main/kotlin/com/mineinabyss/mobzy/mythicmobs/MythicMobsSupport.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.mineinabyss.mobzy.mythicmobs | ||
|
||
import com.mineinabyss.geary.addons.dsl.GearyAddonWithDefault | ||
import com.mineinabyss.geary.modules.geary | ||
import com.mineinabyss.idofront.di.DI | ||
import com.mineinabyss.idofront.plugin.listeners | ||
import com.mineinabyss.mobzy.mobzy | ||
import com.mineinabyss.mobzy.mythicmobs.actions.runMMSkillAction | ||
import com.mineinabyss.mobzy.mythicmobs.items.MythicMobDropListener | ||
import com.mineinabyss.mobzy.mythicmobs.spawning.mythicMobSpawner | ||
import com.mineinabyss.mobzy.mythicmobs.spawning.setBoundingBoxFromMythicMob | ||
|
||
val mobzyMythicMobs: MythicMobsSupport? by DI.observe() | ||
|
||
interface MythicMobsSupport { | ||
|
||
companion object : GearyAddonWithDefault<MythicMobsSupport> { | ||
override fun default() = object : MythicMobsSupport { | ||
} | ||
|
||
override fun MythicMobsSupport.install(): Unit = geary.run { | ||
mobzy.plugin.listeners( | ||
// ConvertToMythicMobListener(), TODO fix and bring back | ||
MythicMobDropListener(), | ||
) | ||
setBoundingBoxFromMythicMob() | ||
runMMSkillAction() | ||
mythicMobSpawner() | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...egrations/src/main/kotlin/com/mineinabyss/mobzy/mythicmobs/actions/RunMythicMobsSkills.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.mineinabyss.mobzy.mythicmobs.actions | ||
|
||
import com.google.common.collect.Lists | ||
import com.mineinabyss.geary.modules.GearyModule | ||
import com.mineinabyss.geary.serialization.serializers.InnerSerializer | ||
import com.mineinabyss.geary.systems.builders.listener | ||
import com.mineinabyss.geary.systems.query.ListenerQuery | ||
import com.mineinabyss.idofront.typealiases.BukkitEntity | ||
import io.lumine.mythic.api.adapters.AbstractEntity | ||
import io.lumine.mythic.bukkit.BukkitAdapter | ||
import io.lumine.mythic.bukkit.MythicBukkit | ||
import io.lumine.mythic.core.skills.SkillMetadataImpl | ||
import io.lumine.mythic.core.skills.SkillTriggers | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.builtins.ListSerializer | ||
import kotlinx.serialization.builtins.serializer | ||
import kotlin.jvm.optionals.getOrNull | ||
|
||
@Serializable(with = RunMythicMobsSkills.Serializer::class) | ||
class RunMythicMobsSkills( | ||
val keys: List<String>, | ||
) { | ||
class Serializer : InnerSerializer<List<String>, RunMythicMobsSkills>( | ||
serialName = "geary:run_mythic_skills", | ||
inner = ListSerializer(String.serializer()), | ||
inverseTransform = { it.keys }, | ||
transform = ::RunMythicMobsSkills | ||
) | ||
} | ||
|
||
fun GearyModule.runMMSkillAction() = listener( | ||
object : ListenerQuery() { | ||
val bukkit by get<BukkitEntity>() | ||
val skill by source.get<RunMythicMobsSkills>() | ||
} | ||
).exec { | ||
skill.keys.forEach { | ||
val line = "[ - $it ]" | ||
val entity = BukkitAdapter.adapt(bukkit) | ||
val caster = MythicBukkit.inst().skillManager.getCaster(entity) | ||
val skill = MythicBukkit.inst().skillManager.getSkill(line).getOrNull() | ||
val meta = SkillMetadataImpl( | ||
SkillTriggers.API, | ||
caster, | ||
entity, | ||
entity.location, | ||
Lists.newArrayList(*arrayOf<AbstractEntity>(entity)), | ||
null, | ||
1.0f | ||
) | ||
skill?.execute(meta) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...egrations/src/main/kotlin/com/mineinabyss/mobzy/mythicmobs/items/MythicMobDropListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.mineinabyss.mobzy.mythicmobs.items | ||
|
||
import com.mineinabyss.geary.papermc.tracking.items.gearyItems | ||
import com.mineinabyss.geary.papermc.tracking.items.helpers.GearyItemPrefabQuery.Companion.getKeys | ||
import com.mineinabyss.geary.prefabs.PrefabKey | ||
import io.lumine.mythic.bukkit.adapters.BukkitItemStack | ||
import io.lumine.mythic.bukkit.events.MythicDropLoadEvent | ||
import io.lumine.mythic.core.drops.droppables.VanillaItemDrop | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.Listener | ||
|
||
|
||
class MythicMobDropListener : Listener { | ||
@EventHandler | ||
fun MythicDropLoadEvent.onMythicDropLoad() { | ||
if (dropName.lowercase() != "geary") return | ||
val prefabKey = PrefabKey.of(container.line.split(" ")[1]) | ||
if (prefabKey !in gearyItems.prefabs.getKeys()) return | ||
|
||
register(VanillaItemDrop(container.line, config, BukkitItemStack(gearyItems.createItem(prefabKey)))) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ations/src/main/kotlin/com/mineinabyss/mobzy/mythicmobs/spawning/AttemptSpawnMythicMob.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.mineinabyss.mobzy.mythicmobs.spawning | ||
|
||
import com.mineinabyss.geary.modules.GearyModule | ||
import com.mineinabyss.geary.papermc.tracking.entities.components.AttemptSpawn | ||
import com.mineinabyss.geary.systems.builders.listener | ||
import com.mineinabyss.geary.systems.query.ListenerQuery | ||
import com.mineinabyss.idofront.typealiases.BukkitEntity | ||
import io.lumine.mythic.api.mobs.entities.SpawnReason | ||
import io.lumine.mythic.bukkit.BukkitAdapter | ||
import io.lumine.mythic.bukkit.MythicBukkit | ||
import kotlin.jvm.optionals.getOrNull | ||
|
||
fun GearyModule.mythicMobSpawner() = listener( | ||
object : ListenerQuery() { | ||
val mobType by get<SetMythicMob>() | ||
val attemptSpawn by event.get<AttemptSpawn>() | ||
override fun ensure() = this { not { has<BukkitEntity>() } } | ||
} | ||
).exec { | ||
val mythicMob = MythicBukkit.inst().mobManager.getMythicMob(mobType.id).getOrNull() ?: return@exec | ||
mythicMob.spawn(BukkitAdapter.adapt(attemptSpawn.location), 1.0, SpawnReason.NATURAL) { mob -> | ||
entity.set(mob) | ||
entity.set(mythicMob) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...s/src/main/kotlin/com/mineinabyss/mobzy/mythicmobs/spawning/ConvertToMythicMobListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.mineinabyss.mobzy.mythicmobs.spawning | ||
|
||
import com.mineinabyss.geary.papermc.MobTypeConversion | ||
import com.mineinabyss.geary.papermc.gearyPaper | ||
import com.mineinabyss.geary.papermc.tracking.entities.events.GearyEntityAddToWorldEvent | ||
import com.mineinabyss.geary.papermc.tracking.entities.systems.updatemobtype.UpdateMob | ||
import io.lumine.mythic.api.mobs.MythicMob | ||
import io.lumine.mythic.bukkit.MythicBukkit | ||
import io.lumine.mythic.core.constants.MobKeys | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.Listener | ||
|
||
class ConvertToMythicMobListener : Listener { | ||
@EventHandler | ||
fun GearyEntityAddToWorldEvent.onAdd() { | ||
if (gearyPaper.config.mobTypeConversion == MobTypeConversion.IGNORE) return | ||
val mm = MythicBukkit.inst() | ||
if (mm.mobManager == null) return | ||
|
||
// If MM already encoded or loaded, we let it handle things itself | ||
if (entity.persistentDataContainer.has(MobKeys.TYPE)) return | ||
if (mm.mobManager.isActiveMob(entity.uniqueId)) return | ||
|
||
if (!gearyEntity.has<SetMythicMob>()) return | ||
if (gearyEntity.has<MythicMob>()) return | ||
|
||
when (gearyPaper.config.mobTypeConversion) { | ||
MobTypeConversion.MIGRATE -> { | ||
UpdateMob.scheduleRecreation(entity, gearyEntity) | ||
} | ||
|
||
MobTypeConversion.REMOVE -> { | ||
UpdateMob.scheduleRemove(entity) | ||
} | ||
|
||
MobTypeConversion.IGNORE -> Unit | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
.../src/main/kotlin/com/mineinabyss/mobzy/mythicmobs/spawning/SetBoundingBoxFromMythicMob.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.mineinabyss.mobzy.mythicmobs.spawning | ||
|
||
import com.mineinabyss.geary.components.relations.NoInherit | ||
import com.mineinabyss.geary.modules.GearyModule | ||
import com.mineinabyss.geary.systems.builders.listener | ||
import com.mineinabyss.geary.systems.query.ListenerQuery | ||
import com.mineinabyss.idofront.nms.aliases.NMSEntityType | ||
import io.lumine.mythic.bukkit.MythicBukkit | ||
import org.bukkit.NamespacedKey | ||
import org.bukkit.util.BoundingBox | ||
import kotlin.jvm.optionals.getOrNull | ||
|
||
fun GearyModule.setBoundingBoxFromMythicMob() = listener( | ||
object : ListenerQuery() { | ||
val mobType by get<com.mineinabyss.mobzy.mythicmobs.spawning.SetMythicMob>() | ||
override fun ensure() = event.anySet(::mobType) | ||
} | ||
).exec { | ||
val mythicMob = MythicBukkit.inst().mobManager.getMythicMob(mobType.id).getOrNull() ?: return@exec | ||
|
||
// val megModel = mythicMob.model.config.getString("Id") | ||
val vanillaType = NamespacedKey.minecraft(mythicMob.entityType.name.lowercase()) | ||
|
||
val nmsType = NMSEntityType.byString(vanillaType.toString()) | ||
.orElseGet { error("An entity type with key $vanillaType was not found.") } | ||
|
||
entity.addRelation<NoInherit, BoundingBox>() | ||
// entity.set(BoundingBoxHelpers.getForEntityType(nmsType)) | ||
} |
9 changes: 9 additions & 0 deletions
9
...in-integrations/src/main/kotlin/com/mineinabyss/mobzy/mythicmobs/spawning/SetMythicMob.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.mineinabyss.mobzy.mythicmobs.spawning | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@JvmInline | ||
@Serializable | ||
@SerialName("mobzy:set.mythic_mob") | ||
value class SetMythicMob(val id: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters