
walkmc.entity.IEntity.kt Maven / Gradle / Ivy
package walkmc.entity
import net.minecraft.server.*
import org.bukkit.*
import org.bukkit.block.Block
import org.bukkit.entity.*
import org.bukkit.entity.Entity
import walkmc.DamageSource
typealias Action = PacketPlayInUseEntity.EnumEntityUseAction
/**
* A handler for custom entities. This is a general interface for any entity.
*/
interface IEntity {
/**
* Gets the current location of this entity.
*/
val location: Location
/**
* Gets the bukkit entity related to this entity.
*/
val entity: Entity
/**
* When this entity spawn, this will be called.
*/
fun onSpawn()
/**
* When this entity dies, this will be called.
*/
fun onDie()
/**
* When this entity dies by a player, this will be called.
*/
fun onDie(player: Player)
/**
* When a player interacts with this entity, this will be called.
* If this function returns false, the interact action will not be performed.
*/
fun onInteract(player: Player, action: Action): Boolean
/**
* When this entity takes any damage, this will be called.
* If this function returns false, the damage will not be performed.
*/
fun onDamage(source: DamageSource, damage: Double): Boolean
/**
* When this entity takes any damage from another entity, this will be called.
* If this function returns false, the damage will not be performed.
*/
fun onDamage(entity: Entity, source: DamageSource, damage: Double): Boolean
/**
* When this entity jumps, this will be called.
* If this functions returns false, the entity will not jump.
*/
fun onJump(block: Block): Boolean
/**
* When this entity post jumps, this will be called.
* This is called after the entity jump, with this you can configure how high the entity will jump.
*/
fun onPostJump(block: Block)
/**
* When this entity falls on a block, this will be called.
*/
fun onFall(block: Block, height: Float)
/**
* When this entity ticks, this will be called.
*/
fun onTick()
/**
* When this entity collides with a another entity, this will be called.
*/
fun onCollide(entity: Entity)
/**
* Adds a new goal behavior for this entity.
*/
fun addBehavior(priority: Int, behavior: PathfinderGoal)
/**
* Adds a new target behavior for this entity.
*/
fun addTargetBehavior(priority: Int, behavior: PathfinderGoal)
/**
* Clears all goal behavior of this entity.
*/
fun clearBehaviors()
/**
* Clears all target behavior of this entity.
*/
fun clearTargetBehaviors()
/**
* Saves the data of this entity.
*/
fun save(tag: NBTTagCompound)
/**
* Loads the data of entity.
*/
fun load(tag: NBTTagCompound)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy