Skip to content

Commit

Permalink
Apply toEntity before properly spawning the mob
Browse files Browse the repository at this point in the history
  • Loading branch information
EsotericEnderman committed Nov 2, 2024
1 parent 3fa42a3 commit ae1c99e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "foundation.esoteric"
version = "0.7.2-experimental.1"
version = "0.7.2"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.bukkit.Location
import org.bukkit.entity.Entity
import org.bukkit.entity.EntityType
import org.bukkit.event.Listener
import org.bukkit.event.entity.CreatureSpawnEvent
import org.bukkit.persistence.PersistentDataType

abstract class CustomEntity<E : Entity> protected constructor(protected val plugin: CustomEntityPlugin, private val entityId: String, private val entityType: EntityType) : Listener {
Expand All @@ -15,10 +16,12 @@ abstract class CustomEntity<E : Entity> protected constructor(protected val plug
plugin.customEntityManager.addEntity(entityId, this)
}

open fun createEntity(spawnLocation: Location): E {
val entity = spawnLocation.world.spawnEntity(spawnLocation, entityType) as E
toEntity(entity)
return entity
fun createEntity(spawnLocation: Location): E {
return spawnLocation.world.spawnEntity(spawnLocation, entityType, CreatureSpawnEvent.SpawnReason.DEFAULT) { entity ->
toEntity(
entity as E
)
} as E
}

open fun toEntity(vararg entities: E): Array<out E> {
Expand Down

0 comments on commit ae1c99e

Please sign in to comment.