Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

feat: 1.20.4 #119

Merged
merged 5 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ allprojects {
maven("https://maven.enginehub.org/repo/") //WorldGuard/Edit
maven("https://mvn.lumine.io/repository/maven-public/")
maven("https://jitpack.io")
mavenLocal()
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=com.mineinabyss
version=0.23
idofrontVersion=0.20.14
version=0.24
idofrontVersion=0.21.5
2 changes: 1 addition & 1 deletion gradle/myLibs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
gearyPaper = "0.28.4"
gearyPaper = "0.29.0"

[libraries]
geary-papermc = { module = "com.mineinabyss:geary-papermc", version.ref = "gearyPaper" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.mineinabyss.mobzy.features.drops

import com.mineinabyss.geary.datatypes.ComponentDefinition
import com.mineinabyss.geary.papermc.bridge.events.EventHelpers
import com.mineinabyss.geary.papermc.bridge.events.entities.OnDeath
import com.mineinabyss.geary.serialization.serializers.InnerSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.ListSerializer


/**
* A component for loot that should drop on entity death.
*
* @param minExp The minimum amount of exp to drop.
* @param maxExp The maximum amount of exp to drop.
* @param deathCommands A list of commands to run.
* @param drops A list of [Drop]s to spawn.
*/
@Serializable(with = DoDrop.Serializer::class)
class DoDrop(
val drops: List<Drop> = listOf(),
) {
class Serializer : InnerSerializer<List<Drop>, DoDrop>(
"mobzy:drop",
ListSerializer(Drop.serializer()),
{ DoDrop(it) },
{ it.drops },
)

companion object : ComponentDefinition by EventHelpers.defaultTo<OnDeath>()
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.mineinabyss.mobzy.features.deathloot
package com.mineinabyss.mobzy.features.drops

import com.mineinabyss.idofront.serialization.IntRangeSerializer
import com.mineinabyss.idofront.serialization.SerializableItemStack
import kotlinx.serialization.Serializable
import org.bukkit.event.entity.EntityDamageEvent.DamageCause
import org.bukkit.inventory.ItemStack
import kotlin.math.roundToInt
import kotlin.random.Random
Expand All @@ -22,17 +23,26 @@ import kotlin.random.Random
*
*/
@Serializable
data class MobDrop(
val item: SerializableItemStack,
data class Drop(
val exp: @Serializable(with = IntRangeSerializer::class) IntRange? = null,
val item: SerializableItemStack? = null,
val cooked: SerializableItemStack? = null,
val cookExp: Float = 0f,
val cookTime: Int = 200,
val amount: @Serializable(with = IntRangeSerializer::class) IntRange = 1..1,
val dropChance: Double = 1.0
val dropChance: Double = 1.0,
val ignoredCauses: List<DamageCause> = listOf(
DamageCause.SUFFOCATION,
DamageCause.DROWNING,
DamageCause.DRYOUT,
DamageCause.CRAMMING,
DamageCause.FALL
),
) {
/** @return The amount of items to be dropped, or null if the drop does not succeed */
// TODO I'd like to use exactly what Minecraft's existing system is, but I can't seem to find a way to reuse that.
fun chooseDrop(lootingLevel: Int, fire: Boolean): ItemStack? {
if(item == null) return null
val lootingPercent = lootingLevel / 100.0

val lootingMaxAmount: Int =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.mineinabyss.mobzy.features.drops

import com.mineinabyss.geary.papermc.bridge.events.entities.Drops
import com.mineinabyss.geary.systems.GearyListener
import com.mineinabyss.geary.systems.accessors.Pointers
import com.mineinabyss.idofront.spawning.spawn
import com.mineinabyss.idofront.typealiases.BukkitEntity
import com.mineinabyss.idofront.util.randomOrMin
import org.bukkit.enchantments.Enchantment
import org.bukkit.entity.ExperienceOrb
import org.bukkit.entity.Item
import org.bukkit.entity.LivingEntity
import org.bukkit.event.entity.EntityDamageEvent.DamageCause

class DropsSystem : GearyListener() {
private val Pointers.drops by get<Drops>().orNull().on(event)
private val Pointers.bukkit by get<BukkitEntity>().on(target)
private val Pointers.deathLoot by get<DoDrop>().on(source)

override fun Pointers.handle() {
val bukkit = bukkit
val drops = drops

// Drop equipped items from rideable entity
// if(entity is Saddleable) drops.add(ItemStack(Material.SADDLE))
val ignoredCauses = mutableListOf<DamageCause>()
deathLoot.drops.forEach { mobDrop ->
ignoredCauses.addAll(mobDrop.ignoredCauses)
}
val exp = deathLoot.drops.mapNotNull { it.exp?.randomOrMin() }.sum()
if (bukkit.lastDamageCause?.cause !in ignoredCauses) {
drops?.items?.clear()
drops?.exp = 0
val looting = (bukkit as? LivingEntity)
?.killer?.inventory?.itemInMainHand
?.enchantments?.get(Enchantment.LOOT_BONUS_MOBS) ?: 0
val newDrops = deathLoot.drops.mapNotNull { it.chooseDrop(looting, bukkit.fireTicks > 0) }
newDrops.forEach {
bukkit.location.spawn<Item> { itemStack = it }
}
bukkit.location.spawn<ExperienceOrb>() {
experience = exp
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
package com.mineinabyss.mobzy.features.initializers.sheep

import com.mineinabyss.geary.annotations.optin.UnsafeAccessors
import com.mineinabyss.geary.autoscan.AutoScan
import com.mineinabyss.geary.datatypes.ComponentDefinition
import com.mineinabyss.geary.papermc.bridge.events.EventHelpers
import com.mineinabyss.geary.papermc.bridge.events.entities.OnSpawn
import com.mineinabyss.geary.systems.GearyListener
import com.mineinabyss.geary.systems.accessors.Pointers
import com.mineinabyss.idofront.typealiases.BukkitEntity
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import org.bukkit.DyeColor
import org.bukkit.entity.Sheep
import org.bukkit.material.Colorable

@JvmInline
@Serializable
@SerialName("mobzy:set.wool_color")
value class SetWoolColor(val value: DyeColor)
value class SetWoolColor(val value: DyeColor) {
companion object : ComponentDefinition by EventHelpers.defaultTo<OnSpawn>()
}

@AutoScan
class SetWoolColorSystem : GearyListener() {
private val Pointers.woolColor by get<SetWoolColor>().whenSetOnTarget()
private val Pointers.bukkit by get<BukkitEntity>().whenSetOnTarget()
private val Pointers.bukkit by get<BukkitEntity>().on(target)
private val Pointers.woolColor by get<SetWoolColor>().on(source)

@OptIn(UnsafeAccessors::class)
override fun Pointers.handle() {
when(val mob = bukkit) {
is Sheep -> mob.color = woolColor.value
target.entity.set(SetWoolColor(woolColor.value))
when (val mob = bukkit) {
is Colorable -> mob.color = woolColor.value
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.mineinabyss.mobzy.features.initializers.slime

import com.mineinabyss.geary.autoscan.AutoScan
import com.mineinabyss.geary.datatypes.ComponentDefinition
import com.mineinabyss.geary.papermc.bridge.events.EventHelpers
import com.mineinabyss.geary.papermc.bridge.events.entities.OnSpawn
import com.mineinabyss.geary.systems.GearyListener
import com.mineinabyss.geary.systems.accessors.Pointers
import com.mineinabyss.idofront.serialization.IntRangeSerializer
Expand All @@ -13,12 +16,14 @@ import org.bukkit.entity.Slime
@JvmInline
@Serializable
@SerialName("mobzy:set.slime_size")
value class SetSlimeSize(@Serializable(with = IntRangeSerializer::class) val size: IntRange)
value class SetSlimeSize(@Serializable(with = IntRangeSerializer::class) val size: IntRange) {
companion object : ComponentDefinition by EventHelpers.defaultTo<OnSpawn>()
}

@AutoScan
class SetSlimeSizeSystem : GearyListener() {
private val Pointers.slimeSize by get<SetSlimeSize>().whenSetOnTarget()
private val Pointers.bukkit by get<BukkitEntity>().whenSetOnTarget()
private val Pointers.bukkit by get<BukkitEntity>().on(target)
private val Pointers.slimeSize by get<SetSlimeSize>().on(source)

override fun Pointers.handle() {
val slime = (bukkit as? Slime) ?: return
Expand Down
1 change: 0 additions & 1 deletion mobzy-pathfinding/gradle.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlinx.serialization.Serializable
import net.minecraft.world.entity.PathfinderMob
import net.minecraft.world.entity.ai.goal.TemptGoal
import net.minecraft.world.item.crafting.Ingredient
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack
import org.bukkit.entity.Mob
import org.bukkit.inventory.ItemStack

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mineinabyss.mobzy.pathfinding.components

import com.mineinabyss.geary.prefabs.serializers.PolymorphicListAsMapSerializer
import com.mineinabyss.geary.serialization.serializers.PolymorphicListAsMapSerializer
import kotlinx.serialization.Polymorphic
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.mineinabyss.mobzy.pathfinding.custom.goals.hostile

import com.mineinabyss.geary.datatypes.GearyEntity
import com.mineinabyss.geary.papermc.configlang.helpers.parseEntity
import com.mineinabyss.geary.papermc.bridge.helpers.parseEntity
import com.mineinabyss.geary.papermc.tracking.entities.helpers.spawnFromPrefab
import com.mineinabyss.geary.papermc.tracking.entities.toGeary
import com.mineinabyss.idofront.destructure.component1
import com.mineinabyss.idofront.destructure.component2
import com.mineinabyss.idofront.destructure.component3
import com.mineinabyss.idofront.location.up
import com.mineinabyss.idofront.operators.plus
import com.mineinabyss.idofront.operators.times
import com.mineinabyss.idofront.serialization.DurationSerializer
import com.mineinabyss.mobzy.pathfinding.MobzyPathfinderGoal
import com.mineinabyss.mobzy.pathfinding.components.PathfinderComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SpawnRegistry {
fun reloadSpawns() {
unregisterSpawns()
spawnConfigsQuery.matchedEntities.forEach {
prefabLoader.reread(it)
prefabLoader.reload(it)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.mineinabyss.mobzy.spawning.vertical

import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull
import com.mineinabyss.geary.prefabs.PrefabKey
import com.mineinabyss.geary.prefabs.helpers.prefabs
import com.mineinabyss.idofront.location.down
import com.mineinabyss.idofront.location.up
import com.mineinabyss.mobzy.spawning.SpawnPosition
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pluginManagement {
gradlePluginPortal()
maven("https://repo.mineinabyss.com/releases")
google()
mavenLocal()
}

val idofrontVersion: String by settings
Expand All @@ -21,6 +22,7 @@ dependencyResolutionManagement {

repositories {
maven("https://repo.mineinabyss.com/releases")
mavenLocal()
}

versionCatalogs {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/mineinabyss/mobzy/MobzyPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import com.mineinabyss.idofront.plugin.Plugins
import com.mineinabyss.idofront.plugin.actions
import com.mineinabyss.idofront.plugin.listeners
import com.mineinabyss.mobzy.features.copynbt.CopyNBTSystem
import com.mineinabyss.mobzy.features.deathloot.DeathLootSystem
import com.mineinabyss.mobzy.features.despawning.RemoveOnChunkUnloadSystem
import com.mineinabyss.mobzy.features.displayname.ShowDisplayNameOnKillerSystem
import com.mineinabyss.mobzy.features.drops.DropsSystem
import com.mineinabyss.mobzy.features.prevent.breeding.PreventBreedingSystem
import com.mineinabyss.mobzy.features.prevent.interaction.PreventInteractionSystem
import com.mineinabyss.mobzy.features.prevent.regen.PreventRegenerationSystem
Expand Down Expand Up @@ -57,7 +57,6 @@ class MobzyPlugin : JavaPlugin() {

listeners(
PreventBreedingSystem(),
DeathLootSystem(),
RemoveOnChunkUnloadSystem(),
ShowDisplayNameOnKillerSystem(),
TamableListener(),
Expand All @@ -69,6 +68,7 @@ class MobzyPlugin : JavaPlugin() {

geary.pipeline.addSystems(
CopyNBTSystem(),
DropsSystem(),
)

geary {
Expand Down
Loading