Class LivingGetProjectileEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.LivingEvent
net.neoforged.neoforge.event.entity.living.LivingGetProjectileEvent
This event is fired when a living entity attempts to get a projectile with the
LivingEntity.getProjectile(ItemStack)
method. The item stack given is usually the item stack of a
ProjectileWeaponItem
and the item stack returned is usually the item stack of a
Projectile
.
This event is not ICancellableEvent
.
This event does not have a result.
invalid reference
net.neoforged.bus.api.Event.HasResult
This event is fired on the NeoForge.EVENT_BUS
.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEvent
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
Field Summary
-
Constructor Summary
ConstructorDescriptionLivingGetProjectileEvent
(LivingEntity livingEntity, ItemStack projectileWeaponItemStack, ItemStack ammo) -
Method Summary
Modifier and TypeMethodDescriptionvoid
setProjectileItemStack
(ItemStack projectileItemStack) Sets the projectile itemstack to be used.Methods inherited from class net.neoforged.neoforge.event.entity.living.LivingEvent
getEntity
-
Field Details
-
projectileWeaponItemStack
-
projectileItemStack
-
-
Constructor Details
-
LivingGetProjectileEvent
public LivingGetProjectileEvent(LivingEntity livingEntity, ItemStack projectileWeaponItemStack, ItemStack ammo)
-
-
Method Details
-
getProjectileWeaponItemStack
- Returns:
- The itemstack of the itrm that is looking for a projectile. With vanilla behavior, this usually returns
an itemstack of a
ProjectileWeaponItem
, but it's possible for that to not be the case if modder uses a different implementation ofLivingEntity.getProjectile(ItemStack)
.
-
getProjectileItemStack
- Returns:
- The itemstack of the projectile found. Initially this is set to the projectile found by vanilla
behaviour, but it's possible for thatnot to be the case if a modder uses a different implementation of
LivingEntity.getProjectile(ItemStack)
.
-
setProjectileItemStack
Sets the projectile itemstack to be used.If the entity is a player: whenever the projectile is fired/consumed the stack will be shrunk by one. To disable this behaviour you can copy the stack before giving it to the event. For bows, you can use
ArrowLooseEvent
to remove the arrow yourself.Be aware that since this event fires every time a living entity gets a projectile, whether or not its
Entity.level
is client-side, you will want to make a conditional to always set the item stack to what you'd want it to be to avoid client-server desyncs.
-