Class LivingGetProjectileEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.entity.EntityEvent
net.minecraftforge.event.entity.living.LivingEvent
net.minecraftforge.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 Cancelable
.
This event does not have a result. Event.HasResult
This event is fired on the MinecraftForge.EVENT_BUS
.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingTickEvent, LivingEvent.LivingVisibilityEvent
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.EyeHeight, EntityEvent.Size
Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
-
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.minecraftforge.event.entity.living.LivingEvent
getEntity
Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult
-
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.
-