Skip to content

Commit

Permalink
Start Geary 0.26 update
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed Mar 13, 2024
1 parent bed6e37 commit ca2c516
Show file tree
Hide file tree
Showing 55 changed files with 656 additions and 660 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ import com.mineinabyss.geary.autoscan.autoscan
import com.mineinabyss.geary.helpers.component
import com.mineinabyss.geary.modules.geary
import com.mineinabyss.geary.papermc.GearyPaperConfigModule
import com.mineinabyss.geary.papermc.bridge.actions.DoDamageSystem
import com.mineinabyss.geary.papermc.bridge.actions.DoKnockbackSystem
import com.mineinabyss.geary.papermc.bridge.actions.DoSpawnSystem
import com.mineinabyss.geary.papermc.bridge.actions.ExplosionSystem
import com.mineinabyss.geary.papermc.bridge.actions.createDoDamageAction
import com.mineinabyss.geary.papermc.bridge.actions.createDoKnockbackAction
import com.mineinabyss.geary.papermc.bridge.actions.createDoSpawnAction
import com.mineinabyss.geary.papermc.bridge.actions.createExplosionAction
import com.mineinabyss.geary.papermc.bridge.conditions.*
import com.mineinabyss.geary.papermc.bridge.conditions.location.BlockConditionChecker
import com.mineinabyss.geary.papermc.bridge.conditions.location.HeightConditionChecker
import com.mineinabyss.geary.papermc.bridge.conditions.location.LightConditionChecker
import com.mineinabyss.geary.papermc.bridge.conditions.location.TimeConditionChecker
import com.mineinabyss.geary.papermc.bridge.conditions.location.createBlockConditionChecker
import com.mineinabyss.geary.papermc.bridge.conditions.location.createHeightConditionChecker
import com.mineinabyss.geary.papermc.bridge.conditions.location.createLightConditionChecker
import com.mineinabyss.geary.papermc.bridge.conditions.location.createTimeConditionChecker
import com.mineinabyss.geary.papermc.bridge.config.OnEvent
import com.mineinabyss.geary.papermc.bridge.config.parsers.CreateDefaultSkills
import com.mineinabyss.geary.papermc.bridge.config.parsers.ParseSkills
import com.mineinabyss.geary.papermc.bridge.config.parsers.createDefaultSkillsListener
import com.mineinabyss.geary.papermc.bridge.config.parsers.createParseSkillsListener
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.RunMMSkillSystem
import com.mineinabyss.geary.papermc.bridge.readers.ReadLocationSystem
import com.mineinabyss.geary.papermc.bridge.readers.ReadTargetBlockSystem
import com.mineinabyss.geary.papermc.bridge.targetselectors.NearbyEntitiesSelector
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.targetselectors.createNearbyEntitiesSelector
import com.mineinabyss.geary.papermc.gearyPaper
import com.mineinabyss.geary.papermc.tracking.items.components.SetItem
import com.mineinabyss.idofront.di.DI
import com.mineinabyss.idofront.plugin.listeners

class PaperBridge {
companion object : GearyAddonWithDefault<PaperBridge> {
override fun PaperBridge.install() {
override fun PaperBridge.install() = geary.run {
geary {
autoscan(this::class.java.classLoader, "com.mineinabyss.geary.papermc.bridge") {
systems()
Expand All @@ -43,29 +43,28 @@ class PaperBridge {
addRelation<OnEvent, OnSpawn>()
}
}
geary.pipeline.addSystems(
BlockConditionChecker(),
ChanceChecker(),
EntityConditionsChecker(),
HealthConditionChecker(),
HeightConditionChecker(),
LightConditionChecker(),
TimeConditionChecker(),
ExplosionSystem(),
ParseSkills(),
CreateDefaultSkills(),
DoSpawnSystem(),
ReadTargetBlockSystem(),
RunMMSkillSystem(),
DoDamageSystem(),
NearbyEntitiesSelector(),
ReadLocationSystem(),
DoKnockbackSystem(),
)
geary.pipeline.addSystems(
CooldownChecker(),
PlayerConditionsChecker(),
)
createBlockConditionChecker()
createChanceChecker()
createEntityConditionsChecker()
createHealthConditionChecker()
createHeightConditionChecker()
createLightConditionChecker()
createTimeConditionChecker()
createCooldownChecker()
createPlayerConditionsChecker()

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

createParseSkillsListener()
createDefaultSkillsListener()

createTargetBlockReader()
createLocationReader()
createNearbyEntitiesSelector()

geary.pipeline.runOnOrAfter(GearyPhase.ENABLE) {
DI.getOrNull<GearyPaperConfigModule>() ?: return@runOnOrAfter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mineinabyss.geary.papermc.bridge.actions

import com.mineinabyss.geary.systems.GearyListener
import com.mineinabyss.geary.systems.accessors.Pointers
import com.mineinabyss.geary.modules.GearyModule
import com.mineinabyss.geary.systems.builders.listener
import com.mineinabyss.geary.systems.query.ListenerQuery
import com.mineinabyss.idofront.serialization.DoubleRangeSerializer
import com.mineinabyss.idofront.typealiases.BukkitEntity
import com.mineinabyss.idofront.util.DoubleRange
Expand All @@ -23,19 +24,19 @@ data class DoDamage(
val ignoreArmor: Boolean = false,
)


class DoDamageSystem : GearyListener() {
val Pointers.bukkit by get<BukkitEntity>().on(target)
val Pointers.damage by get<DoDamage>().on(source)

override fun Pointers.handle() {
val living = bukkit as? LivingEntity ?: return
if (living.health > damage.minHealth) {
if (damage.ignoreArmor) {
living.health -= damage.damage.randomOrMin()
} else {
living.damage(damage.damage.randomOrMin())
}
fun GearyModule.createDoDamageAction() = listener(
object : ListenerQuery() {
val bukkit by get<BukkitEntity>()
val damage by source.get<DoDamage>()
}
).exec {
val living = bukkit as? LivingEntity ?: return@exec
if (living.health > damage.minHealth) {
if (damage.ignoreArmor) {
living.health -= damage.damage.randomOrMin()
} else {
living.damage(damage.damage.randomOrMin())
}
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.mineinabyss.geary.papermc.bridge.actions

import com.mineinabyss.geary.modules.GearyModule
import com.mineinabyss.geary.papermc.bridge.config.inputs.Input
import com.mineinabyss.geary.systems.GearyListener
import com.mineinabyss.geary.systems.accessors.Pointers
import com.mineinabyss.geary.systems.builders.listener
import com.mineinabyss.geary.systems.query.ListenerQuery
import com.mineinabyss.idofront.spawning.spawn
import kotlinx.serialization.Contextual
import kotlinx.serialization.SerialName
Expand All @@ -20,17 +21,18 @@ data class Explosion(
val at: Input<@Contextual Location>,
)

class ExplosionSystem : GearyListener() {
private val Pointers.explosion by get<Explosion>().on(source)

override fun Pointers.handle() {
val location = explosion.at.get(this)
if (explosion.fuseTicks <= 0) location.createExplosion(
explosion.power, explosion.setFire, explosion.breakBlocks
)
else //only spawn a tnt in if we have a fuse
location.spawn<TNTPrimed> {
fuseTicks = explosion.fuseTicks
}
fun GearyModule.createExplosionAction() = listener(
object : ListenerQuery() {
val explosion by source.get<Explosion>()
}
).exec {
val location = explosion.at.get(this)
if (explosion.fuseTicks <= 0) location.createExplosion(
explosion.power, explosion.setFire, explosion.breakBlocks
)
else //only spawn a tnt in if we have a fuse
location.spawn<TNTPrimed> {
fuseTicks = explosion.fuseTicks
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.mineinabyss.geary.papermc.bridge.actions

import com.mineinabyss.geary.modules.GearyModule
import com.mineinabyss.geary.papermc.bridge.config.inputs.Input
import com.mineinabyss.geary.systems.GearyListener
import com.mineinabyss.geary.systems.accessors.Pointers
import com.mineinabyss.geary.systems.builders.listener
import com.mineinabyss.geary.systems.query.ListenerQuery
import com.mineinabyss.idofront.operators.minus
import com.mineinabyss.idofront.operators.plus
import com.mineinabyss.idofront.operators.times
Expand Down Expand Up @@ -32,27 +33,28 @@ class DoKnockback(
val center: Input<@Contextual Location>
)

class DoKnockbackSystem : GearyListener() {
val Pointers.entity by get<BukkitEntity>().on(target)
val Pointers.doKnockback by get<DoKnockback>().on(source)
fun GearyModule.createDoKnockbackAction() = listener(
object : ListenerQuery() {
val bukkit by get<BukkitEntity>()
val doKnockback by source.get<DoKnockback>()
}
).exec {
val targetLoc = bukkit.location
val center = doKnockback.center.get(this)
if (targetLoc.world != center.world) return@exec

override fun Pointers.handle() {
val targetLoc = entity.location
val center = doKnockback.center.get(this)
if (targetLoc.world != center.world) return
val delta = center - bukkit.location
delta.y = 0.0

val delta = center - entity.location
delta.y = 0.0
val velocity = delta.toVector().multiply(-1).normalize().apply {
y = cos(Math.toRadians(doKnockback.yAngle))
} * doKnockback.power

val velocity = delta.toVector().multiply(-1).normalize().apply {
y = cos(Math.toRadians(doKnockback.yAngle))
} * doKnockback.power
// Not sure about this, should probably get all of the

// Not sure about this, should probably get all of the
if (doKnockback.cancelCurrentVelocity)
bukkit.velocity = velocity
else
bukkit.velocity += velocity

if (doKnockback.cancelCurrentVelocity)
entity.velocity = velocity
else
entity.velocity += velocity
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.mineinabyss.geary.papermc.bridge.actions

import com.mineinabyss.geary.modules.GearyModule
import com.mineinabyss.geary.papermc.bridge.config.inputs.Input
import com.mineinabyss.geary.papermc.tracking.entities.helpers.spawnFromPrefab
import com.mineinabyss.geary.serialization.serializers.SerializableGearyEntity
import com.mineinabyss.geary.systems.GearyListener
import com.mineinabyss.geary.systems.accessors.Pointers
import com.mineinabyss.geary.systems.builders.listener
import com.mineinabyss.geary.systems.query.ListenerQuery
import kotlinx.serialization.Contextual
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -17,10 +18,11 @@ class DoSpawnEntity(
val at: Input<@Contextual Location>
)

class DoSpawnSystem : GearyListener() {
private val Pointers.spawn by get<DoSpawnEntity>().on(source)

override fun Pointers.handle() {
spawn.at.get(this).spawnFromPrefab(spawn.entity.get(this))
fun GearyModule.createDoSpawnAction() = listener(
object : ListenerQuery() {
val spawn by source.get<DoSpawnEntity>()
}
).exec {
spawn.at.get(this).spawnFromPrefab(spawn.entity.get(this))
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.mineinabyss.geary.papermc.bridge.actions

import com.mineinabyss.geary.annotations.optin.UnsafeAccessors
import com.mineinabyss.geary.autoscan.AutoScan
import com.mineinabyss.geary.modules.GearyModule
import com.mineinabyss.geary.papermc.bridge.config.Skill
import com.mineinabyss.geary.papermc.bridge.events.EventHelpers
import com.mineinabyss.geary.prefabs.PrefabKey
import com.mineinabyss.geary.prefabs.prefabs
import com.mineinabyss.geary.prefabs.serializers.PrefabKeySerializer
import com.mineinabyss.geary.serialization.serializers.InnerSerializer
import com.mineinabyss.geary.systems.GearyListener
import com.mineinabyss.geary.systems.accessors.Pointers
import com.mineinabyss.geary.systems.builders.listener
import com.mineinabyss.geary.systems.query.ListenerQuery
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import kotlinx.serialization.builtins.ListSerializer
Expand All @@ -31,18 +30,16 @@ class RunSkills(
)
}

@AutoScan
class RunSkillSystem : GearyListener() {
private val Pointers.action by get<RunSkills>().on(source)

@OptIn(UnsafeAccessors::class)
override fun Pointers.handle() {
action.skills.forEach { skill ->
EventHelpers.runSkill(
target.entity,
event.entity,
skill,
)
}
fun GearyModule.createRunSkillAction() = listener(
object : ListenerQuery() {
val action by source.get<RunSkills>()
}
).exec {
action.skills.forEach { skill ->
EventHelpers.runSkill(
entity,
event.entity,
skill,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.mineinabyss.geary.papermc.bridge.actions.particles

import com.destroystokyo.paper.ParticleBuilder
import com.mineinabyss.geary.autoscan.AutoScan
import com.mineinabyss.geary.modules.GearyModule
import com.mineinabyss.geary.papermc.bridge.config.inputs.Input
import com.mineinabyss.geary.systems.GearyListener
import com.mineinabyss.geary.systems.accessors.Pointers
import com.mineinabyss.geary.systems.builders.listener
import com.mineinabyss.geary.systems.query.ListenerQuery
import com.mineinabyss.idofront.serialization.ColorSerializer
import com.mineinabyss.idofront.serialization.IntRangeSerializer
import com.mineinabyss.idofront.util.DoubleRange
Expand All @@ -30,21 +30,20 @@ class DoSpawnParticle(
val speed: DoubleRange = 0.0..0.0,
)

@AutoScan
class DoSpawnParticleSystem : GearyListener() {
private val Pointers.spawn by get<DoSpawnParticle>().on(source)

override fun Pointers.handle() {
val location = spawn.at.get(this)
with(spawn) {
ParticleBuilder(particle)
.location(location)
.offset(offsetX.randomOrMin(), offsetY.randomOrMin(), offsetZ.randomOrMin())
.color(color)
.count(count.randomOrMin())
.extra(speed.randomOrMin())
.receivers(radius)
.spawn()
}
fun GearyModule.createSpawnParticleAction() = listener(
object : ListenerQuery() {
val spawn by source.get<DoSpawnParticle>()
}
).exec {
val location = spawn.at.get(this)
with(spawn) {
ParticleBuilder(particle)
.location(location)
.offset(offsetX.randomOrMin(), offsetY.randomOrMin(), offsetZ.randomOrMin())
.color(color)
.count(count.randomOrMin())
.extra(speed.randomOrMin())
.receivers(radius)
.spawn()
}
}
Loading

0 comments on commit ca2c516

Please sign in to comment.