Package net.minecraft.world.item
Class CrossbowItem
java.lang.Object
net.minecraft.world.item.Item
net.minecraft.world.item.ProjectileWeaponItem
net.minecraft.world.item.CrossbowItem
- All Implemented Interfaces:
FeatureElement
,ItemLike
,IItemExtension
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static final record
Nested classes/interfaces inherited from class net.minecraft.world.item.Item
Item.Properties, Item.TooltipContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final float
static final int
private static final CrossbowItem.ChargingSounds
private static final float
private static final float
private static final float
private boolean
Set totrue
when the crossbow is 50% charged.static final float
private static final float
private boolean
Set totrue
when the crossbow is 20% charged.Fields inherited from class net.minecraft.world.item.ProjectileWeaponItem
ARROW_ONLY, ARROW_OR_FIREWORK
Fields inherited from class net.minecraft.world.item.Item
ABSOLUTE_MAX_STACK_SIZE, APPROXIMATELY_INFINITE_USE_DURATION, BASE_ATTACK_DAMAGE_ID, BASE_ATTACK_SPEED_ID, BY_BLOCK, canCombineRepair, CODEC, DEFAULT_MAX_STACK_SIZE, descriptionId, MAX_BAR_WIDTH, STREAM_CODEC
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) static int
getChargeDuration
(ItemStack pStack, LivingEntity pShooter) (package private) CrossbowItem.ChargingSounds
getChargingSounds
(ItemStack pStack) int
protected int
getDurabilityUse
(ItemStack pStack) private static float
getPowerForTime
(int pTimeLeft, ItemStack pStack, LivingEntity pShooter) private static org.joml.Vector3f
getProjectileShotVector
(LivingEntity p_331584_, Vec3 p_331590_, float p_331104_) private static float
getRandomShotPitch
(boolean pIsHighPitched, RandomSource pRandom) private static float
getShootingPower
(ChargedProjectiles pProjectile) private static float
getShotPitch
(RandomSource pRandom, int pIndex) getUseAnimation
(ItemStack pStack) int
getUseDuration
(ItemStack pStack, LivingEntity pEntity) static boolean
void
onUseTick
(Level pLevel, LivingEntity pLivingEntity, ItemStack pStack, int pCount) Called as the item is being used by an entity.void
performShooting
(Level pLevel, LivingEntity pShooter, InteractionHand pHand, ItemStack pWeapon, float pVelocity, float pInaccuracy, LivingEntity pTarget) boolean
releaseUsing
(ItemStack pStack, Level pLevel, LivingEntity pEntity, int pTimeLeft) protected void
shootProjectile
(LivingEntity pShooter, Projectile pProjectile, int pIndex, float pVelocity, float pInaccuracy, float pAngle, LivingEntity pTarget) private static boolean
tryLoadProjectiles
(LivingEntity pShooter, ItemStack pCrossbowStack) use
(Level pLevel, Player pPlayer, InteractionHand pHand) boolean
useOnRelease
(ItemStack pStack) If this stack's item is a crossbowMethods inherited from class net.minecraft.world.item.ProjectileWeaponItem
customArrow, draw, getAllSupportedProjectiles, getDefaultCreativeAmmo, getHeldProjectile, getSupportedHeldProjectiles, shoot, useAmmo
Methods inherited from class net.minecraft.world.item.Item
appendHoverText, asItem, builtInRegistryHolder, byBlock, byId, canDestroyBlock, canFitInsideContainerItems, components, finishUsingItem, getAttackDamageBonus, getBarColor, getBarWidth, getCraftingRemainder, getDamageSource, getDefaultInstance, getDefaultMaxStackSize, getDescriptionId, getDestroySpeed, getId, getName, getName, getPlayerPOVHitResult, getTooltipImage, hurtEnemy, interactLivingEntity, inventoryTick, isBarVisible, isCombineRepairable, isCorrectToolForDrops, isFoil, mineBlock, modifyDefaultComponentsFrom, onCraftedBy, onCraftedPostProcess, onDestroyed, overrideOtherStackedOnMe, overrideStackedOnOther, postHurtEnemy, requiredFeatures, shouldPrintOpWarning, toString, useOn, 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, canEquip, canGrindstoneRepair, canPerformAction, canWalkOnPowderedSnow, createEntity, damageItem, doesSneakBypassUse, getAllEnchantments, getBurnTime, getCraftingRemainder, getCreatorModId, getDamage, getDefaultAttributeModifiers, getEnchantmentLevel, getEntityLifespan, getEquipmentSlot, getHighlightTip, getMaxDamage, getMaxStackSize, getSweepHitBox, getXpRepairRatio, hasCustomEntity, isDamageable, isDamaged, isGazeDisguise, isNotReplaceableByPickAction, isPiglinCurrency, isPrimaryItemFor, makesPiglinsNeutral, onAnimalArmorTick, onDestroyed, onDroppedByPlayer, onEntityItemUpdate, onEntitySwing, onItemUseFirst, onLeftClickEntity, onStopUsing, setDamage, shouldCauseBlockBreakReset, shouldCauseReequipAnimation, supportsEnchantment
-
Field Details
-
MAX_CHARGE_DURATION
private static final float MAX_CHARGE_DURATION- See Also:
-
DEFAULT_RANGE
public static final int DEFAULT_RANGE- See Also:
-
startSoundPlayed
private boolean startSoundPlayedSet totrue
when the crossbow is 20% charged. -
midLoadSoundPlayed
private boolean midLoadSoundPlayedSet totrue
when the crossbow is 50% charged. -
START_SOUND_PERCENT
private static final float START_SOUND_PERCENT- See Also:
-
MID_SOUND_PERCENT
private static final float MID_SOUND_PERCENT- See Also:
-
ARROW_POWER
private static final float ARROW_POWER- See Also:
-
FIREWORK_POWER
private static final float FIREWORK_POWER- See Also:
-
MOB_ARROW_POWER
public static final float MOB_ARROW_POWER- See Also:
-
DEFAULT_SOUNDS
-
-
Constructor Details
-
CrossbowItem
-
-
Method Details
-
getSupportedHeldProjectiles
- Overrides:
getSupportedHeldProjectiles
in classProjectileWeaponItem
-
getAllSupportedProjectiles
- Specified by:
getAllSupportedProjectiles
in classProjectileWeaponItem
-
use
-
getShootingPower
-
releaseUsing
- Overrides:
releaseUsing
in classItem
-
tryLoadProjectiles
-
isCharged
-
shootProjectile
protected void shootProjectile(LivingEntity pShooter, Projectile pProjectile, int pIndex, float pVelocity, float pInaccuracy, float pAngle, @Nullable LivingEntity pTarget) - Specified by:
shootProjectile
in classProjectileWeaponItem
-
getProjectileShotVector
private static org.joml.Vector3f getProjectileShotVector(LivingEntity p_331584_, Vec3 p_331590_, float p_331104_) -
createProjectile
protected Projectile createProjectile(Level pLevel, LivingEntity pShooter, ItemStack pWeapon, ItemStack pAmmo, boolean pIsCrit) - Overrides:
createProjectile
in classProjectileWeaponItem
-
getDurabilityUse
- Overrides:
getDurabilityUse
in classProjectileWeaponItem
-
performShooting
public void performShooting(Level pLevel, LivingEntity pShooter, InteractionHand pHand, ItemStack pWeapon, float pVelocity, float pInaccuracy, @Nullable LivingEntity pTarget) -
getShotPitch
-
getRandomShotPitch
-
onUseTick
Called as the item is being used by an entity. -
getUseDuration
- Overrides:
getUseDuration
in classItem
-
getChargeDuration
-
getUseAnimation
- Overrides:
getUseAnimation
in classItem
-
getChargingSounds
-
getPowerForTime
-
useOnRelease
If this stack's item is a crossbow- Overrides:
useOnRelease
in classItem
-
getDefaultProjectileRange
public int getDefaultProjectileRange()- Specified by:
getDefaultProjectileRange
in classProjectileWeaponItem
-