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

Commit

Permalink
Fix default creature type being lowercase,
Browse files Browse the repository at this point in the history
Small geary syntax update
  • Loading branch information
0ffz committed Aug 8, 2022
1 parent e9f506c commit a69410b
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion gradle/mobzylibs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
geary = "0.17.102"
geary = "0.18.103"

[libraries]
protocolburrito = "com.mineinabyss:protocolburrito:0.4.33"
Expand Down
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-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 4 additions & 0 deletions mobzy-components/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ plugins {
kotlin("plugin.serialization")
}

repositories {
maven("https://mvn.lumine.io/repository/maven-public/") { metadataSources { artifact() } } // Model Engine
}

dependencies {
compileOnly(libs.kotlinx.serialization.json)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
class MobzyType(
val baseClass: PrefabKey,
@SerialName("creatureType")
private val _creatureType: String = "misc",
private val _creatureType: String = "MISC",
val mobCategory: MobCategory? = null,
) {
val creatureType get() = net.minecraft.world.entity.MobCategory.valueOf(_creatureType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ class CapFull : GearyListener() {

@Handler
fun TargetScope.check(event: EventScope): Boolean =
(event.spawnInfo.localTypes[spawnType.prefab.toEntity()?.get<PrefabKey>()?.toString()] ?: 0) < conf.max
(event.spawnInfo.localTypes[spawnType.prefab.toEntityOrNull()?.get<PrefabKey>()?.toString()] ?: 0) < conf.max
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SpawnCategoryCapCondition : GearyListener() {

@Handler
fun TargetScope.check(event: EventScope): Boolean {
val category = spawnType.prefab.toEntity()?.get<MobCategory>() ?: return false
val category = spawnType.prefab.toEntityOrNull()?.get<MobCategory>() ?: return false
return MobCountManager.isCategoryAllowed(category) &&
(event.spawnInfo.localCategories[category] ?: 0) <
(MobCountManager.categoryCounts[category]?.get() ?: 0)
Expand Down
1 change: 1 addition & 0 deletions mobzy-systems/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
repositories {
maven("https://repo.dmulloy2.net/nexus/repository/public/") //ProtocolLib
maven("https://jitpack.io")
maven("https://mvn.lumine.io/repository/maven-public/") { metadataSources { artifact() } } // Model Engine
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,10 @@ object MobzyPacketInterception {
val entityFlags = existingMeta.getObject(META_ENTITY_FLAGS) as? Byte ?: 0

// Ensure invisible but keep other parts (glowing) if active
setObject(
WrappedDataWatcherObject(META_ENTITY_FLAGS, byteSerializer),
entityFlags or 0x20
)
setObject(META_ENTITY_FLAGS, byteSerializer, entityFlags or 0x20)

//Maker, no base pate
setObject(
WrappedDataWatcherObject(META_ARMORSTAND, byteSerializer),
(0x08 or 0x10).toByte()
)
setObject(META_ARMORSTAND, byteSerializer, (0x08 or 0x10).toByte())

//Don't copy anything else to prevent crashes from bad packets
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.mineinabyss.mobzy.systems.systems

import com.mineinabyss.geary.annotations.AutoScan
import com.mineinabyss.geary.annotations.Handler
import com.mineinabyss.geary.papermc.store.decodeComponentsFrom
import com.mineinabyss.geary.papermc.store.loadComponentsFrom
import com.mineinabyss.geary.systems.GearyListener
import com.mineinabyss.geary.systems.accessors.TargetScope
import com.mineinabyss.idofront.nms.aliases.toNMS
Expand All @@ -24,7 +24,7 @@ class CopyNBTSystem : GearyListener() {
@Handler
fun TargetScope.copyNBT() {
bukkitEntity.toNMS().load(nbt.compound)
entity.decodeComponentsFrom(bukkitEntity.persistentDataContainer)
entity.loadComponentsFrom(bukkitEntity.persistentDataContainer)
entity.remove<CopyNBT>()
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/mineinabyss/mobzy/DebugCommands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal fun Command.createDebugCommands() {
z = z,
startY = loc.blockY
)
PrefabKey.of(spawnName).toEntity()?.callEvent(spawnInfo, DoSpawn(player.location))
PrefabKey.of(spawnName).toEntityOrNull()?.callEvent(spawnInfo, DoSpawn(player.location))
//TODO list all failed conditions
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/mineinabyss/mobzy/MobzyCommands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class MobzyCommands : IdofrontCommandExecutor(), TabCompleter, GearyContext by G
"flying" -> nmsEntity is FlyingMob && excludeDefault()
"fish" -> nmsEntity is AbstractFish && excludeDefault()
else -> {
val prefab = runCatching { PrefabKey.of(type).toEntity() }.getOrNull()
val prefab = runCatching { PrefabKey.of(type).toEntityOrNull() }.getOrNull()
?: this@commandGroup.stopCommand("No such prefab or selector $type")
geary.instanceOf(prefab)
}
Expand Down Expand Up @@ -151,14 +151,14 @@ class MobzyCommands : IdofrontCommandExecutor(), TabCompleter, GearyContext by G
val key = PrefabKey.of(mobKey)
if (radius <= 0) {
Bukkit.getWorlds().forEach { world ->
world.entities.filter { it.toGeary().instanceOf(key.toEntity()!!) }.forEach { entity ->
world.entities.filter { it.toGeary().instanceOf(key.toEntity()) }.forEach { entity ->
val loc = entity.location
player.info("Found ${key.key} at <click:run_command:/teleport ${loc.blockX} ${loc.blockY} ${loc.blockZ}>${entity.location}>${entity.location} in ${entity.world.name}")
}
}
} else {
player.location.getNearbyEntities(radius.toDouble(), radius.toDouble(), radius.toDouble())
.filter { it.toGeary().instanceOf(key.toEntity()!!) }.forEach { entity ->
.filter { it.toGeary().instanceOf(key.toEntity()) }.forEach { entity ->
val loc = entity.location
player.info("Found ${key.key} at <click:run_command:/teleport ${loc.blockX} ${loc.blockY} ${loc.blockZ}>${entity.location}")

Expand Down

0 comments on commit a69410b

Please sign in to comment.