Interface Mob
- All Superinterfaces:
CommandSource, Entity, HoverEventSource<HoverEvent.ShowEntity>, LivingEntity, SchedulerSource, Sound.Emitter, Sound.Source.Provider
A living entity that moves and thinks, whether it is a built-in mob or one a plugin defined.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionfloat<T extends MobBehaviour>
Optional<T> doubledistanceSqTo(Entity other) doublegoals()booleanhasLineOfSightTo(Entity other) doubleheight()voidlookAt(double x, double y, double z) Turns the head and body towards a point.default voiddoubledefault voidnavigateTo(Location destination, double speed) Walks towards a location for this tick.nearestPlayer(double maxDistance) booleanonGround()voidplaySound(Sound.Type sound, float volume, float pitch) Plays a sound at this mob, heard by the players tracking it.voidsetFollowRange(double range) voidsetMoveSpeed(double speed) Sets the speed the mob walks at this tick.voidSets the player this mob is after.voidsetVelocity(double x, double y, double z) Overwrites the velocity, in blocks per tick.target()doubledoubledoubledoublewidth()Methods inherited from interface CommandSource
executor, sender, serverMethods inherited from interface Entity
chunk, displayName, entityId, isRemoved, location, remove, teleport, teleport, teleport, teleport, type, uuid, worldMethods inherited from interface HoverEventSource
asHoverEvent, asHoverEventMethods inherited from interface LivingEntity
absorptionAmount, armor, armorToughness, damage, fireTicks, heal, health, isAlive, isDead, kill, knockbackResistance, maxHealth, setAbsorptionAmount, setFireTicks, setHealthMethods inherited from interface SchedulerSource
execute, executeDelayed, isOwnedByCurrentThreadMethods inherited from interface Sound.Source.Provider
soundSource
-
Method Details
-
definition
Optional<MobDefinition> definition()- Returns:
- the definition this mob was built from, empty for a built-in mob
- Since:
- 0.1.0
-
goals
Goals goals()- Returns:
- the goals driving this mob, mutable
- Since:
- 0.1.0
-
target
-
setTarget
Sets the player this mob is after.A mob re-picks its own target every few ticks among the players within
followRange(), so a target set from outside that range is dropped shortly after. WidensetFollowRange(double)first to make it stick.- Parameters:
target- the player to chase, ornullto clear- Since:
- 0.1.0
-
nearestPlayer
-
followRange
double followRange()- Returns:
- the radius in blocks this mob picks targets within
- Since:
- 0.1.0
-
setFollowRange
void setFollowRange(double range) - Parameters:
range- the radius in blocks to pick targets within, negative to restore the default- Since:
- 0.1.0
-
movementSpeed
double movementSpeed()- Returns:
- the walking speed this mob uses when no goal overrides it
- Since:
- 0.1.0
-
setMoveSpeed
void setMoveSpeed(double speed) Sets the speed the mob walks at this tick.The value is cleared at the start of every tick, so a goal moving a mob sets it on each one of its own ticks.
- Parameters:
speed- the speed in blocks per tick- Since:
- 0.1.0
-
width
double width()- Returns:
- the hitbox width in blocks
- Since:
- 0.1.0
-
height
double height()- Returns:
- the hitbox height in blocks
- Since:
- 0.1.0
-
attackDamage
float attackDamage()- Returns:
- the damage a hit from this mob deals,
0when it does not attack - Since:
- 0.1.0
-
onGround
boolean onGround()- Returns:
truewhen the mob is standing on a block- Since:
- 0.1.0
-
velocityX
double velocityX() -
velocityY
double velocityY() -
velocityZ
double velocityZ() -
setVelocity
void setVelocity(double x, double y, double z) Overwrites the velocity, in blocks per tick.- Parameters:
x- the velocity along xy- the velocity along y, positive upwardsz- the velocity along z- Since:
- 0.1.0
-
lookAt
void lookAt(double x, double y, double z) Turns the head and body towards a point.- Parameters:
x- the x coordinate to look aty- the y coordinate to look atz- the z coordinate to look at- Since:
- 0.1.0
-
lookAt
- Parameters:
entity- the entity to look at- Since:
- 0.1.0
-
distanceSqTo
- Parameters:
other- the entity to measure to- Returns:
- the squared distance between the two entities
- Since:
- 0.1.0
-
hasLineOfSightTo
- Parameters:
other- the entity to look for- Returns:
truewhen no full block stands between the two- Since:
- 0.1.0
-
playSound
Plays a sound at this mob, heard by the players tracking it.- Parameters:
sound- the sound to playvolume- the volume,1for the usual mob loudnesspitch- the pitch, between0.5and2- Since:
- 0.1.0
-
behaviours
List<MobBehaviour> behaviours()- Returns:
- the behaviours attached to this mob, in the order they were added
- Since:
- 0.1.0
-
behaviour
- Type Parameters:
T- the behaviour type- Parameters:
type- the behaviour implementation to look for- Returns:
- the first behaviour of that type, empty when none is attached
- Since:
- 0.1.0
-