Skip to content

Commit

Permalink
chore: Move out MythicMobs features to Mobzy
Browse files Browse the repository at this point in the history
feat: Add CustomMob component to search for custom mobs in world queries
  • Loading branch information
0ffz committed Apr 7, 2024
1 parent 492998c commit 4ad211e
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 232 deletions.
4 changes: 0 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ allprojects {
mavenCentral()
maven("https://repo.mineinabyss.com/releases")
maven("https://repo.mineinabyss.com/snapshots")
maven("https://raw.githubusercontent.com/TheBlackEntity/PlugMan/repository/")
maven("https://jitpack.io")
maven("https://repo.codemc.io/repository/nms/")
maven("https://mvn.lumine.io/repository/maven-public/")
mavenLocal()
}

Expand Down
4 changes: 0 additions & 4 deletions geary-papermc-bridge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ dependencies {
implementation(gearyLibs.serialization)
implementation(gearyLibs.autoscan)

// Plugins
compileOnly(libs.plugman)
compileOnly(idofrontLibs.minecraft.plugin.mythic.dist)

// MineInAbyss platform
compileOnly(idofrontLibs.kotlin.stdlib)
compileOnly(idofrontLibs.kotlinx.serialization.json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import com.mineinabyss.geary.papermc.bridge.events.entities.*
import com.mineinabyss.geary.papermc.bridge.events.items.ItemBreakBridge
import com.mineinabyss.geary.papermc.bridge.events.items.ItemConsumeBridge
import com.mineinabyss.geary.papermc.bridge.events.items.ItemInteractBridge
import com.mineinabyss.geary.papermc.bridge.mythicmobs.createRunMMSkillAction
import com.mineinabyss.geary.papermc.bridge.readers.createLocationReader
import com.mineinabyss.geary.papermc.bridge.readers.createTargetBlockReader
import com.mineinabyss.geary.papermc.bridge.systems.createCooldownDisplaySystem
Expand Down Expand Up @@ -56,7 +55,6 @@ class PaperBridge {

createExplosionAction()
createDoSpawnAction()
createRunMMSkillAction()
createDoDamageAction()
createDoKnockbackAction()

Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions geary-papermc-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ configurations {
dependencies {
implementation(project(":"))

// Plugins
compileOnly(libs.plugman)

// MineInAbyss platform
compileOnly(idofrontLibs.kotlin.stdlib)
compileOnly(idofrontLibs.kotlinx.serialization.json)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.mineinabyss.geary.papermc.plugin.commands

import com.mineinabyss.geary.components.relations.InstanceOf
import com.mineinabyss.geary.datatypes.GearyEntity
import com.mineinabyss.geary.helpers.toGeary
import com.mineinabyss.geary.papermc.gearyPaper
import com.mineinabyss.geary.papermc.tracking.entities.helpers.GearyMobPrefabQuery
import com.mineinabyss.geary.papermc.tracking.entities.toGeary
Expand Down Expand Up @@ -62,7 +59,9 @@ fun Command.mobsQuery() {
)
if (isInfo) {
val categories = entities
.groupingBy { it.toGeary().prefabs.first().get<PrefabKey>() }
.asSequence()
.flatMap { it.toGeary().prefabs }
.groupingBy { it }
.eachCount()
.entries
.sortedByDescending { it.value }
Expand All @@ -82,8 +81,3 @@ fun Command.mobsQuery() {
}
}
}

fun GearyEntity.deepInstanceOf(entity: GearyEntity): Boolean =
instanceOf(entity) || getRelations<InstanceOf?, Any?>().any {
it.target.toGeary().deepInstanceOf(entity)
}
4 changes: 0 additions & 4 deletions geary-papermc-plugin/src/main/resources/paper-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ description: An Entity Component System written for Spigot

dependencies:
server:
MythicMobs:
required: false
load: BEFORE
join-classpath: true
Idofront:
required: true
load: BEFORE
Expand Down
1 change: 0 additions & 1 deletion geary-papermc-tracking/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ plugins {
}

dependencies {
compileOnly(idofrontLibs.minecraft.plugin.mythic.dist)
compileOnly(idofrontLibs.idofront.nms)
compileOnly(idofrontLibs.minecraft.mccoroutine)
implementation(gearyLibs.uuid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ import com.mineinabyss.geary.helpers.componentId
import com.mineinabyss.geary.modules.geary
import com.mineinabyss.geary.papermc.CatchType
import com.mineinabyss.geary.papermc.gearyPaper
import com.mineinabyss.geary.papermc.tracking.entities.components.markSetEntityTypeAsCustomMob
import com.mineinabyss.geary.papermc.tracking.entities.helpers.GearyMobPrefabQuery
import com.mineinabyss.geary.papermc.tracking.entities.systems.EntityWorldEventTracker
import com.mineinabyss.geary.papermc.tracking.entities.systems.attemptspawn.createAttemptSpawnListener
import com.mineinabyss.geary.papermc.tracking.entities.systems.attemptspawn.createAttemptSpawnMythicMobListener
import com.mineinabyss.geary.papermc.tracking.entities.systems.boundingbox.setBoundingBoxFromEntityType
import com.mineinabyss.geary.papermc.tracking.entities.systems.createBukkitEntityRemoveListener
import com.mineinabyss.geary.papermc.tracking.entities.systems.createBukkitEntitySetListener
import com.mineinabyss.geary.papermc.tracking.entities.systems.removevanillamobs.RemoveVanillaMobsListener
import com.mineinabyss.geary.papermc.tracking.entities.systems.updatemobtype.ConvertEntityTypesListener
import com.mineinabyss.geary.papermc.tracking.entities.systems.updatemobtype.ConvertToMythicMobListener
import com.mineinabyss.geary.systems.builders.cachedQuery
import com.mineinabyss.geary.systems.query.CachedQueryRunner
import com.mineinabyss.idofront.di.DI
import com.mineinabyss.idofront.plugin.listeners
import com.mineinabyss.idofront.typealiases.BukkitEntity
import org.bukkit.Bukkit

val gearyMobs by DI.observe<EntityTracking>()

Expand All @@ -34,7 +32,8 @@ interface EntityTracking {
companion object : GearyAddonWithDefault<EntityTracking> {
override fun default(): EntityTracking = object : EntityTracking {
override val bukkitEntityComponent = componentId<BukkitEntity>()
override val bukkit2Geary = BukkitEntity2Geary(gearyPaper.config.catch.asyncEntityConversion == CatchType.ERROR)
override val bukkit2Geary =
BukkitEntity2Geary(gearyPaper.config.catch.asyncEntityConversion == CatchType.ERROR)
override val prefabs = geary.cachedQuery(GearyMobPrefabQuery())
}

Expand All @@ -43,20 +42,14 @@ interface EntityTracking {
geary.createBukkitEntitySetListener()
geary.createAttemptSpawnListener()
geary.setBoundingBoxFromEntityType()
geary.markSetEntityTypeAsCustomMob()
geary.pipeline.runOnOrAfter(GearyPhase.ENABLE) {
gearyPaper.plugin.listeners(
EntityWorldEventTracker(),
ConvertEntityTypesListener(),
RemoveVanillaMobsListener(),
)

if (Bukkit.getPluginManager().plugins.any { it.name == "MythicMobs" }) {
geary.createAttemptSpawnMythicMobListener()

gearyPaper.plugin.listeners(
ConvertToMythicMobListener(),
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.mineinabyss.geary.papermc.tracking.entities.components

import kotlinx.serialization.Serializable

@Serializable
sealed class CustomMob
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.mineinabyss.geary.papermc.tracking.entities.components

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 kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -14,3 +17,10 @@ value class SetEntityType(val key: String) {
.byString(key)
.orElseGet { error("An entity type with key $key was not found.") }
}

fun GearyModule.markSetEntityTypeAsCustomMob() = listener(object : ListenerQuery() {
val entityType by get<SetEntityType>()
override fun ensure() = event.anySet(::entityType)
}).exec {
entity.add<CustomMob>()
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package com.mineinabyss.geary.papermc.tracking.entities.helpers
import com.mineinabyss.geary.datatypes.GearyEntity
import com.mineinabyss.geary.datatypes.family.family
import com.mineinabyss.geary.helpers.contains
import com.mineinabyss.geary.papermc.tracking.entities.components.SetEntityType
import com.mineinabyss.geary.papermc.tracking.entities.components.SetMythicMob
import com.mineinabyss.geary.papermc.tracking.entities.components.CustomMob
import com.mineinabyss.geary.prefabs.PrefabKey
import com.mineinabyss.geary.prefabs.configuration.components.Prefab
import com.mineinabyss.geary.systems.query.CachedQueryRunner
Expand All @@ -22,10 +21,7 @@ class GearyMobPrefabQuery : GearyQuery() {

private val mobQuery = family {
has<Prefab>()
or {
has<SetEntityType>()
has<SetMythicMob>()
}
has<CustomMob>()
}

fun isMob(entity: GearyEntity): Boolean {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import org.bukkit.util.BoundingBox
fun GearyModule.setBoundingBoxFromEntityType() = listener(
object : ListenerQuery() {
val mobType by get<SetEntityType>()
override fun ensure() = event.anySet(::mobType)
override fun ensure() {
event.anySet(::mobType)
this { not { has<BoundingBox>() } }
}
}
).exec {
entity.addRelation<NoInherit, BoundingBox>()
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.mineinabyss.geary.papermc.tracking.items.migration.SetItemIgnoredProp
import com.mineinabyss.geary.papermc.tracking.items.migration.createCustomModelDataToPrefabTracker
import com.mineinabyss.geary.papermc.tracking.items.migration.createItemMigrationListener
import com.mineinabyss.geary.papermc.tracking.items.systems.LoginListener
import com.mineinabyss.geary.papermc.tracking.items.systems.MythicMobDropSystem
import com.mineinabyss.geary.papermc.tracking.items.systems.createInventoryTrackerSystem
import com.mineinabyss.geary.prefabs.PrefabKey
import com.mineinabyss.geary.systems.query.CachedQueryRunner
Expand Down Expand Up @@ -46,7 +45,6 @@ interface ItemTracking {
gearyPaper.plugin.listeners(
loginListener,
SetItemIgnoredPropertyListener(),
MythicMobDropSystem()
)
}
}
Expand Down
Loading

0 comments on commit 4ad211e

Please sign in to comment.