Class: EntityProjectileComponent
entity componentBeta
投射物组件控制投射物实体的属性,并允许其向给定方向射出。当实体具有 minecraft:projectile 组件时,此组件存在。
The projectile component controls the properties of a projectile entity and allows it to be shot in a given direction. This component is present when the entity has the minecraft:projectile component.
Example
shootArrow.ts
Extends
Properties
airInertia
airInertia:
number
World Mutation Beta
Remarks
投射物在空气中飞行时每 tick 保持的速度比例。
The fraction of the projectile's speed maintained every tick while traveling through air.
catchFireOnHurt
catchFireOnHurt:
boolean
World Mutation Beta
Remarks
如果为 true,实体在受伤时会被点燃。默认燃烧时长为 5 秒。此持续时间可以通过 onFireTime 属性修改。如果实体免疫火焰或实体处于潮湿状态,则不会着火。
If true, the entity will be set on fire when hurt. The default burn duration is 5 seconds. This duration can be modified via the onFireTime property. The entity will not catch fire if immune or if the entity is wet.
critParticlesOnProjectileHurt
critParticlesOnProjectileHurt:
boolean
World Mutation Beta
Remarks
如果为 true,投射物在被玩家击中时会生成暴击粒子。例如,玩家攻击潜影贝子弹。
If true, the projectile will spawn crit particles when hit by a player. E.g. Player attacking a Shulker bullet.
destroyOnProjectileHurt
destroyOnProjectileHurt:
boolean
World Mutation Beta
Remarks
如果为 true,投射物在受到伤害时会被摧毁。例如,玩家攻击潜影贝子弹。
If true, the projectile will be destroyed when it takes damage. E.g. Player attacking a Shulker bullet.
entity
readonlyentity:Entity
Beta
Remarks
拥有此组件的实体。如果实体已被移除,则实体将为 undefined。
The entity that owns this component. The entity will be undefined if it has been removed.
Throws
This property can throw when used.
Inherited from
gravity
gravity:
number
World Mutation Beta
Remarks
应用于投射物的重力。当实体不在地面上时,每 tick 从投射物的垂直位置变化中减去此值。值越高,投射物下落越快。如果为负值,实体将上升而不是下落。
The gravity applied to the projectile. When the entity is not on the ground, subtracts this amount from the projectile's change in vertical position every tick. The higher the value, the faster the projectile falls. If negative, the entity will rise instead of fall.
hitEntitySound?
optionalhitEntitySound?:string
World Mutation Beta
Remarks
投射物击中实体时播放的声音。
The sound that plays when the projectile hits an entity.
hitGroundSound?
optionalhitGroundSound?:string
World Mutation Beta
Remarks
投射物击中方块时播放的声音。
The sound that plays when the projectile hits a block.
hitParticle?
optionalhitParticle?:string
World Mutation Beta
Remarks
投射物击中物体时生成的粒子。
The particle that spawns when the projectile hits something.
isValid
readonlyisValid:boolean
Beta
Remarks
返回该组件是否有效。如果组件的拥有者有效,并且满足组件所需的任何额外验证,则该组件被视为有效。
Returns whether the component is valid. A component is considered valid if its owner is valid, in addition to any addition to any additional validation required by the component.
Inherited from
lightningStrikeOnHit
lightningStrikeOnHit:
boolean
World Mutation Beta
Remarks
如果为 true,且天气为雷暴且实体与天空之间没有遮挡,则实体在被击中时会遭雷击。例如,带有引雷附魔的投掷三叉戟。
If true and the weather is thunder and the entity has line of sight to the sky, the entity will be struck by lightning when hit. E.g. A thrown Trident with the Channeling enchantment.
liquidInertia
liquidInertia:
number
World Mutation Beta
Remarks
投射物在液体中飞行时每 tick 保持的速度比例。
The fraction of the projectile's speed maintained every tick while traveling through a liquid.
onFireTime
onFireTime:
number
World Mutation Beta
Remarks
当 catchFireOnHurt 设置为 true 时,被击中实体着火的持续时间(以秒为单位)。
Duration in seconds that the entity hit will be on fire for when catchFireOnHurt is set to true.
owner?
optionalowner?:Entity
World Mutation Beta
Remarks
投射物的拥有者。用于确定投射物可以与什么碰撞并造成伤害。它还确定哪个实体被指定为攻击者。
The owner of the projectile. This is used to determine what the projectile can collide with and damage. It also determines which entity is assigned as the attacker.
shouldBounceOnHit
shouldBounceOnHit:
boolean
World Mutation Beta
Remarks
如果为 true,投射物在未造成伤害时会从生物身上弹开。例如,正在生成的凋灵。
If true, the projectile will bounce off mobs when no damage is taken. E.g. A spawning wither.
stopOnHit
stopOnHit:
boolean
World Mutation Beta
Remarks
如果为 true,投射物在击中实体时会停止移动,如同被格挡一样。例如,投掷三叉戟的击中行为。
If true, the projectile will stop moving when an entity is hit as thought it had been blocked. E.g. Thrown trident on hit behavior.
typeId
readonlytypeId:string
Beta
Remarks
组件的标识符。
Identifier of the component.
Inherited from
componentId
readonlystaticcomponentId:"minecraft:projectile"='minecraft:projectile'
Beta
Methods
shoot()
shoot(
velocity,options?):void
World Mutation Beta
Parameters
velocity
发射投射物的速度。这同时控制投射物射出的速度和方向。
The velocity to fire the projectile. This controls both the speed and direction which which the projectile will be shot.
options?
射出的可选配置。
Optional configuration for the shoot.
Returns
void
Remarks
以给定速度射出投射物。投射物将从其当前位置射出。
Shoots the projectile with a given velocity. The projectile will be shot from its current location.
Throws
如果组件或实体不再存在则抛出异常。
Throws if the component or entity no longer exist.
