Package net.minestom.server.entity
Class EntityCreature
java.lang.Object
net.minestom.server.entity.Entity
net.minestom.server.entity.LivingEntity
net.minestom.server.entity.EntityCreature
- All Implemented Interfaces:
DataContainer
,EventHandler
,EquipmentHandler
,PermissionHandler
,Viewable
- Direct Known Subclasses:
EntityBat
,EntityBee
,EntityBlaze
,EntityCat
,EntityCaveSpider
,EntityChicken
,EntityCow
,EntityCreeper
,EntityDolphin
,EntityEndermite
,EntityFox
,EntityGhast
,EntityGiant
,EntityGuardian
,EntityIronGolem
,EntityMooshroom
,EntityOcelot
,EntityPanda
,EntityPhantom
,EntityPig
,EntityPolarBear
,EntityRabbit
,EntitySilverfish
,EntitySlime
,EntitySnowman
,EntitySpider
,EntityWitch
,EntityZombie
,EntityZombifiedPiglin
public abstract class EntityCreature extends LivingEntity
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<GoalSelector>
goalSelectors
protected java.util.List<TargetSelector>
targetSelectors
Fields inherited from class net.minestom.server.entity.LivingEntity
canPickupItem, expandedBoundingBox, invulnerable, isDead, itemPickupCooldown, lastDamageSource
Fields inherited from class net.minestom.server.entity.Entity
air, cachePitch, cacheX, cacheY, cacheYaw, cacheZ, crouched, customName, customNameVisible, eyeHeight, glowing, gravityDragPerTick, instance, invisible, lastPitch, lastVelocityUpdateTime, lastX, lastY, lastYaw, lastZ, METADATA_BOOLEAN, METADATA_BYTE, METADATA_CHAT, METADATA_FLOAT, METADATA_OPTCHAT, METADATA_PARTICLE, METADATA_POSE, METADATA_POSITION, METADATA_ROTATION, METADATA_SLOT, METADATA_STRING, METADATA_VARINT, nextTick, noGravity, onFire, onGround, pose, position, silent, sprinting, swimming, UNUSED_METADATA, usingElytra, uuid, vehicle, velocity, viewers
-
Constructor Summary
Constructors Constructor Description EntityCreature(EntityType entityType, Position spawnPosition)
EntityCreature(EntityType entityType, Position spawnPosition, Instance instance)
-
Method Summary
Modifier and Type Method Description boolean
addViewer(Player player)
Adds a viewer.void
attack(Entity target)
Calls aEntityAttackEvent
with this entity as the source andtarget
as the target.void
attack(Entity target, boolean swingHand)
Calls aEntityAttackEvent
with this entity as the source andtarget
as the target.ItemStack
getBoots()
Gets the boots.ItemStack
getChestplate()
Gets the chestplate.java.util.List<GoalSelector>
getGoalSelectors()
Gets the goal selectors of this entity.ItemStack
getHelmet()
Gets the helmet.ItemStack
getItemInMainHand()
Gets theItemStack
in main hand.ItemStack
getItemInOffHand()
Gets theItemStack
in off hand.ItemStack
getLeggings()
Gets the leggings.PFPathingEntity
getPathingEntity()
Gets the pathing entity.Position
getPathPosition()
Gets the target pathfinder position.Entity
getTarget()
Gets the entity target.java.util.List<TargetSelector>
getTargetSelectors()
Gets the target selectors of this entity.void
jump(float height)
void
kill()
Kills the entity, trigger theEntityDeathEvent
event.void
moveTowards(Position direction, float speed)
Used to move the entity towarddirection
in the X and Z axis Gravity is still applied but the entity will not attempt to jump Also update the yaw/pitch of the entity to look along 'direction'void
setBoots(ItemStack itemStack)
Changes the boots.void
setChestplate(ItemStack itemStack)
Changes the chestplate.void
setHelmet(ItemStack itemStack)
Changes the helmet.void
setInstance(Instance instance)
Changes the entity instance.void
setItemInMainHand(ItemStack itemStack)
Changes the main handItemStack
.void
setItemInOffHand(ItemStack itemStack)
Changes the off handItemStack
.void
setLeggings(ItemStack itemStack)
Changes the leggings.boolean
setPathTo(Position position)
Retrieves the path toposition
and ask the entity to follow the path.void
setTarget(Entity target)
Changes the entity target.void
spawn()
Called when a new instance is set.void
update(long time)
Called each tick.Methods inherited from class net.minestom.server.entity.LivingEntity
canPickupItem, damage, fillMetadataIndex, getArrowCount, getAttributeValue, getFireDamagePeriod, getHealth, getLastDamageSource, getMaxHealth, getMetadataConsumer, getPropertiesPacket, getTeam, handleVoid, heal, isDead, isImmune, isInvulnerable, refreshActiveHand, refreshIsDead, setArrowCount, setAttribute, setBoundingBox, setCanPickupItem, setFireDamagePeriod, setFireForDuration, setFireForDuration, setHealth, setInvulnerable, setTeam, swingMainHand, swingOffHand
Methods inherited from class net.minestom.server.entity.Entity
addPassenger, askSynchronization, callEvent, getAliveTicks, getAllPermissions, getBoundingBox, getChunk, getCustomName, getData, getDistance, getEntity, getEntityId, getEntityType, getEventCallbacksMap, getEyeHeight, getInstance, getMetadataPacket, getPassengers, getPassengersPacket, getPosition, getUuid, getVehicle, getVelocity, getVelocityPacket, getVelocityUpdatePeriod, getViewers, hasNoGravity, hasPassenger, hasVelocity, isActive, isAutoViewable, isCustomNameVisible, isGlowing, isInvisible, isOnFire, isOnGround, isRemoved, isRemoveScheduled, isSilent, refreshPosition, refreshPosition, refreshView, remove, removePassenger, removeViewer, sameChunk, sameChunk, scheduleNextTick, scheduleRemove, sendMetadataIndex, sendSynchronization, sendVelocityPacket, setAutoViewable, setCustomName, setCustomNameVisible, setData, setEyeHeight, setGlowing, setGravity, setInvisible, setNoGravity, setOnFire, setSilent, setSneaking, setSprinting, setUuid, setVelocity, setVelocityUpdatePeriod, setView, setView, shouldRemove, shouldSendVelocityUpdate, teleport, teleport, tick, triggerStatus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minestom.server.inventory.EquipmentHandler
getEquipment, getEquipmentsPacket, getItemInHand, setItemInHand, syncEquipment, syncEquipments, syncEquipments
Methods inherited from interface net.minestom.server.event.handler.EventHandler
addEventCallback, callCancellableEvent, getEventCallbacks, getEventCallbacks, removeEventCallback
Methods inherited from interface net.minestom.server.permission.PermissionHandler
addPermission, hasPermission, hasPermission, hasPermission, hasPermission, removePermission
Methods inherited from interface net.minestom.server.Viewable
isViewer, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Field Details
-
Constructor Details
-
EntityCreature
-
EntityCreature
public EntityCreature(@NotNull EntityType entityType, @NotNull Position spawnPosition, @Nullable Instance instance)
-
-
Method Details
-
update
public void update(long time)Description copied from class:Entity
Called each tick.- Overrides:
update
in classLivingEntity
- Parameters:
time
- time of the update in milliseconds
-
setInstance
Description copied from class:Entity
Changes the entity instance.- Overrides:
setInstance
in classEntity
- Parameters:
instance
- the new instance of the entity
-
spawn
public void spawn()Description copied from class:Entity
Called when a new instance is set. -
kill
public void kill()Description copied from class:LivingEntity
Kills the entity, trigger theEntityDeathEvent
event.- Overrides:
kill
in classLivingEntity
-
addViewer
Description copied from interface:Viewable
Adds a viewer. -
getGoalSelectors
Gets the goal selectors of this entity.- Returns:
- a modifiable list containing the entity goal selectors
-
getTargetSelectors
Gets the target selectors of this entity.- Returns:
- a modifiable list containing the entity target selectors
-
getTarget
Gets the entity target.- Returns:
- the entity target
-
setTarget
Changes the entity target.- Parameters:
target
- the new entity target
-
getItemInMainHand
Description copied from interface:EquipmentHandler
Gets theItemStack
in main hand.- Returns:
- the
ItemStack
in main hand
-
setItemInMainHand
Description copied from interface:EquipmentHandler
Changes the main handItemStack
.- Parameters:
itemStack
- the main handItemStack
-
getItemInOffHand
Description copied from interface:EquipmentHandler
Gets theItemStack
in off hand.- Returns:
- the item in off hand
-
setItemInOffHand
Description copied from interface:EquipmentHandler
Changes the off handItemStack
.- Parameters:
itemStack
- the off handItemStack
-
getHelmet
Description copied from interface:EquipmentHandler
Gets the helmet.- Returns:
- the helmet
-
setHelmet
Description copied from interface:EquipmentHandler
Changes the helmet.- Parameters:
itemStack
- the helmet
-
getChestplate
Description copied from interface:EquipmentHandler
Gets the chestplate.- Returns:
- the chestplate
-
setChestplate
Description copied from interface:EquipmentHandler
Changes the chestplate.- Parameters:
itemStack
- the chestplate
-
getLeggings
Description copied from interface:EquipmentHandler
Gets the leggings.- Returns:
- the leggings
-
setLeggings
Description copied from interface:EquipmentHandler
Changes the leggings.- Parameters:
itemStack
- the leggings
-
getBoots
Description copied from interface:EquipmentHandler
Gets the boots.- Returns:
- the boots
-
setBoots
Description copied from interface:EquipmentHandler
Changes the boots.- Parameters:
itemStack
- the boots
-
attack
Calls aEntityAttackEvent
with this entity as the source andtarget
as the target.- Parameters:
target
- the entity targetswingHand
- true to swing the entity main hand, false otherwise
-
attack
Calls aEntityAttackEvent
with this entity as the source andtarget
as the target.This does not trigger the hand animation.
- Parameters:
target
- the entity target
-
jump
public void jump(float height) -
setPathTo
Retrieves the path toposition
and ask the entity to follow the path.Can be set to null to reset the pathfinder.
The position is cloned, if you want the entity to continually follow this position object you need to call this when you want the path to update.
- Parameters:
position
- the position to find the path to, null to reset the pathfinder- Returns:
- true if a path has been found
-
getPathPosition
Gets the target pathfinder position.- Returns:
- the target pathfinder position, null if there is no one
-
moveTowards
Used to move the entity towarddirection
in the X and Z axis Gravity is still applied but the entity will not attempt to jump Also update the yaw/pitch of the entity to look along 'direction'- Parameters:
direction
- the targeted positionspeed
- define how far the entity will move
-
getPathingEntity
Gets the pathing entity.Used by the pathfinder.
- Returns:
- the pathing entity
-