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 ClassesNested 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, 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 TypeMethodDescriptionvoid
appendHoverText
(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) protected Projectile
createProjectile
(Level level, LivingEntity shooter, ItemStack weapon, ItemStack ammo, boolean isCrit) static int
getChargeDuration
(ItemStack stack, LivingEntity shooter) (package private) CrossbowItem.ChargingSounds
getChargingSounds
(ItemStack stack) int
protected int
getDurabilityUse
(ItemStack stack) private static float
getPowerForTime
(int timeLeft, ItemStack stack, LivingEntity shooter) private static org.joml.Vector3f
getProjectileShotVector
(LivingEntity shooter, Vec3 distance, float angle) private static float
getRandomShotPitch
(boolean isHighPitched, RandomSource random) private static float
getShootingPower
(ChargedProjectiles projectile) private static float
getShotPitch
(RandomSource random, int index) getUseAnimation
(ItemStack stack) Returns the action that specifies what animation to play when the item is being used.int
getUseDuration
(ItemStack stack, LivingEntity entity) static boolean
void
onUseTick
(Level level, LivingEntity livingEntity, ItemStack stack, int count) Called as the item is being used by an entity.void
performShooting
(Level level, LivingEntity shooter, InteractionHand hand, ItemStack weapon, float velocity, float inaccuracy, LivingEntity target) void
releaseUsing
(ItemStack stack, Level level, LivingEntity entityLiving, int timeLeft) Called when the player stops using an Item (stops holding the right mouse button).protected void
shootProjectile
(LivingEntity shooter, Projectile projectile, int index, float velocity, float inaccuracy, float angle, LivingEntity target) private static boolean
tryLoadProjectiles
(LivingEntity shooter, ItemStack crossbowStack) use
(Level level, Player player, InteractionHand hand) Called to trigger the item's "innate" right click behavior.boolean
useOnRelease
(ItemStack stack) If this stack's item is a crossbowMethods inherited from class net.minecraft.world.item.ProjectileWeaponItem
customArrow, draw, getAllSupportedProjectiles, getDefaultCreativeAmmo, getEnchantmentValue, getHeldProjectile, getSupportedHeldProjectiles, shoot, useAmmo
Methods inherited from class net.minecraft.world.item.Item
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, hasCraftingRemainingItem, hurtEnemy, initializeClient, interactLivingEntity, inventoryTick, isBarVisible, isComplex, isCorrectToolForDrops, isEnchantable, isFoil, isRepairable, isValidRepairItem, mineBlock, modifyDefaultComponentsFrom, onCraftedBy, onCraftedPostProcess, onDestroyed, overrideOtherStackedOnMe, overrideStackedOnOther, postHurtEnemy, requiredFeatures, 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, 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
-
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
Called to trigger the item's "innate" right click behavior. To handle when this item is used on a Block, seeinvalid reference
#onItemUse
-
getShootingPower
-
releaseUsing
Called when the player stops using an Item (stops holding the right mouse button).- Overrides:
releaseUsing
in classItem
-
tryLoadProjectiles
-
isCharged
-
shootProjectile
protected void shootProjectile(LivingEntity shooter, Projectile projectile, int index, float velocity, float inaccuracy, float angle, @Nullable LivingEntity target) - Specified by:
shootProjectile
in classProjectileWeaponItem
-
getProjectileShotVector
private static org.joml.Vector3f getProjectileShotVector(LivingEntity shooter, Vec3 distance, float angle) -
createProjectile
protected Projectile createProjectile(Level level, LivingEntity shooter, ItemStack weapon, ItemStack ammo, boolean isCrit) - Overrides:
createProjectile
in classProjectileWeaponItem
-
getDurabilityUse
- Overrides:
getDurabilityUse
in classProjectileWeaponItem
-
performShooting
public void performShooting(Level level, LivingEntity shooter, InteractionHand hand, ItemStack weapon, float velocity, float inaccuracy, @Nullable LivingEntity target) -
getShotPitch
-
getRandomShotPitch
-
onUseTick
Called as the item is being used by an entity. -
getUseDuration
- Overrides:
getUseDuration
in classItem
-
getChargeDuration
-
getUseAnimation
Returns the action that specifies what animation to play when the item is being used.- Overrides:
getUseAnimation
in classItem
-
getChargingSounds
-
getPowerForTime
-
appendHoverText
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) - Overrides:
appendHoverText
in classItem
-
useOnRelease
If this stack's item is a crossbow- Overrides:
useOnRelease
in classItem
-
getDefaultProjectileRange
public int getDefaultProjectileRange()- Specified by:
getDefaultProjectileRange
in classProjectileWeaponItem
-