Package net.minecraft.world.item
Class ProjectileWeaponItem
java.lang.Object
net.minecraft.world.item.Item
net.minecraft.world.item.ProjectileWeaponItem
- All Implemented Interfaces:
FeatureElement
,ItemLike
,IItemExtension
- Direct Known Subclasses:
BowItem
,CrossbowItem
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.world.item.Item
Item.Properties, Item.TooltipContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class net.minecraft.world.item.Item
ABSOLUTE_MAX_STACK_SIZE, BASE_ATTACK_DAMAGE_ID, BASE_ATTACK_SPEED_ID, BY_BLOCK, canRepair, DEFAULT_MAX_STACK_SIZE, MAX_BAR_WIDTH
Fields inherited from interface net.minecraft.world.flag.FeatureElement
FILTERED_REGISTRIES
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Projectile
createProjectile
(Level pLevel, LivingEntity pShooter, ItemStack pWeapon, ItemStack pAmmo, boolean pIsCrit) customArrow
(AbstractArrow arrow, ItemStack projectileStack, ItemStack weaponStack) draw
(ItemStack pWeapon, ItemStack pAmmo, LivingEntity pShooter) Deprecated.Override this method if the allowed projectile is weapon stack dependent.getDefaultCreativeAmmo
(Player player, ItemStack projectileWeaponItem) Neo: Controls what ammo ItemStack that Creative Mode should return if the player has no valid ammo in inventory.abstract int
protected int
getDurabilityUse
(ItemStack pStack) int
static ItemStack
getHeldProjectile
(LivingEntity pShooter, Predicate<ItemStack> pIsAmmo) Deprecated.Use ItemStack sensitive versiongetSupportedHeldProjectiles(ItemStack)
Override this method if the weapon stack allows special projectile that would only be used if it's in hand.protected void
shoot
(ServerLevel pLevel, LivingEntity pShooter, InteractionHand pHand, ItemStack pWeapon, List<ItemStack> pProjectileItems, float pVelocity, float pInaccuracy, boolean pIsCrit, LivingEntity pTarget) protected abstract void
shootProjectile
(LivingEntity pShooter, Projectile pProjectile, int pIndex, float pVelocity, float pInaccuracy, float pAngle, LivingEntity pTarget) protected static ItemStack
useAmmo
(ItemStack pWeapon, ItemStack pAmmo, LivingEntity pShooter, boolean pIntangable) Methods inherited from class net.minecraft.world.item.Item
appendHoverText, asItem, builtInRegistryHolder, byBlock, byId, canAttackBlock, canFitInsideContainerItems, components, finishUsingItem, getAttackDamageBonus, getBarColor, getBarWidth, getBreakingSound, getCraftingRemainingItem, getDefaultAttributeModifiers, getDefaultInstance, getDefaultMaxStackSize, getDescription, getDescriptionId, getDescriptionId, getDestroySpeed, getDrinkingSound, getEatingSound, getId, getName, getOrCreateDescriptionId, getPlayerPOVHitResult, getTooltipImage, getUseAnimation, getUseDuration, hasCraftingRemainingItem, hurtEnemy, initializeClient, interactLivingEntity, inventoryTick, isBarVisible, isComplex, isCorrectToolForDrops, isEnchantable, isFoil, isRepairable, isValidRepairItem, mineBlock, modifyDefaultComponentsFrom, onCraftedBy, onCraftedPostProcess, onDestroyed, onUseTick, overrideOtherStackedOnMe, overrideStackedOnOther, postHurtEnemy, releaseUsing, requiredFeatures, toString, use, useOn, useOnRelease, verifyComponentsAfterLoad
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.minecraft.world.flag.FeatureElement
isEnabled
Methods inherited from interface net.neoforged.neoforge.common.extensions.IItemExtension
applyEnchantments, canBeHurtBy, canContinueUsing, canDisableShield, canElytraFly, canEquip, canGrindstoneRepair, canPerformAction, canWalkOnPowderedSnow, createEntity, damageItem, doesSneakBypassUse, elytraFlightTick, getAllEnchantments, getArmorTexture, getBurnTime, getCraftingRemainingItem, getCreatorModId, getDamage, getDefaultAttributeModifiers, getEnchantmentLevel, getEnchantmentValue, getEntityLifespan, getEquipmentSlot, getFoodProperties, getHighlightTip, getMaxDamage, getMaxStackSize, getSweepHitBox, getXpRepairRatio, hasCraftingRemainingItem, hasCustomEntity, isBookEnchantable, isDamageable, isDamaged, isEnderMask, isNotReplaceableByPickAction, isPiglinCurrency, isPrimaryItemFor, makesPiglinsNeutral, onAnimalArmorTick, onDestroyed, onDroppedByPlayer, onEntityItemUpdate, onEntitySwing, onEntitySwing, onItemUseFirst, onLeftClickEntity, onStopUsing, setDamage, shouldCauseBlockBreakReset, shouldCauseReequipAnimation, supportsEnchantment
-
Field Details
-
ARROW_ONLY
-
ARROW_OR_FIREWORK
-
-
Constructor Details
-
ProjectileWeaponItem
-
-
Method Details
-
getSupportedHeldProjectiles
Deprecated.Use ItemStack sensitive versiongetSupportedHeldProjectiles(ItemStack)
-
getAllSupportedProjectiles
Deprecated.Use ItemStack sensitive versiongetAllSupportedProjectiles(ItemStack)
-
getSupportedHeldProjectiles
Override this method if the weapon stack allows special projectile that would only be used if it's in hand. The default return value is a union-predicate ofgetAllSupportedProjectiles(ItemStack)
andgetSupportedHeldProjectiles()
- Parameters:
stack
- The ProjectileWeapon stack- Returns:
- A predicate that returns true for supported projectile stack in hand
-
getAllSupportedProjectiles
Override this method if the allowed projectile is weapon stack dependent.- Parameters:
stack
- The ProjectileWeapon stack- Returns:
- A predicate that returns true for all supported projectile stack
-
getHeldProjectile
-
getEnchantmentValue
public int getEnchantmentValue()- Overrides:
getEnchantmentValue
in classItem
-
getDefaultProjectileRange
public abstract int getDefaultProjectileRange() -
shoot
protected void shoot(ServerLevel pLevel, LivingEntity pShooter, InteractionHand pHand, ItemStack pWeapon, List<ItemStack> pProjectileItems, float pVelocity, float pInaccuracy, boolean pIsCrit, @Nullable LivingEntity pTarget) -
getDurabilityUse
-
shootProjectile
protected abstract void shootProjectile(LivingEntity pShooter, Projectile pProjectile, int pIndex, float pVelocity, float pInaccuracy, float pAngle, @Nullable LivingEntity pTarget) -
createProjectile
protected Projectile createProjectile(Level pLevel, LivingEntity pShooter, ItemStack pWeapon, ItemStack pAmmo, boolean pIsCrit) -
draw
-
useAmmo
protected static ItemStack useAmmo(ItemStack pWeapon, ItemStack pAmmo, LivingEntity pShooter, boolean pIntangable) -
customArrow
public AbstractArrow customArrow(AbstractArrow arrow, ItemStack projectileStack, ItemStack weaponStack) -
getDefaultCreativeAmmo
Neo: Controls what ammo ItemStack that Creative Mode should return if the player has no valid ammo in inventory. Modded weapons should override this to return their own ammo if they do not use vanilla arrows.- Parameters:
player
- The player (if in context) firing the weaponprojectileWeaponItem
- The weapon ItemStack the ammo is for- Returns:
- The default ammo ItemStack for this weapon
-
getAllSupportedProjectiles(ItemStack)