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 enumstatic final recordNested classes/interfaces inherited from class Item
Item.Properties, Item.TooltipContext -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final floatstatic final intprivate static final CrossbowItem.ChargingSoundsprivate static final floatprivate static final floatprivate static final floatprivate booleanSet totruewhen the crossbow is 50% charged.static final floatprivate static final floatprivate booleanSet totruewhen the crossbow is 20% charged.Fields inherited from class ProjectileWeaponItem
ARROW_ONLY, ARROW_OR_FIREWORKFields inherited from class Item
ABSOLUTE_MAX_STACK_SIZE, APPROXIMATELY_INFINITE_USE_DURATION, BASE_ATTACK_DAMAGE_ID, BASE_ATTACK_SPEED_ID, BY_BLOCK, canCombineRepair, CODEC, CODEC_WITH_BOUND_COMPONENTS, DEFAULT_MAX_STACK_SIZE, descriptionId, MAX_BAR_WIDTH, STREAM_CODECFields inherited from interface FeatureElement
FILTERED_REGISTRIES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ProjectilecreateProjectile(Level level, LivingEntity shooter, ItemStack heldItem, ItemStack projectile, boolean isCrit) static intgetChargeDuration(ItemStack crossbow, LivingEntity user) (package private) CrossbowItem.ChargingSoundsgetChargingSounds(ItemStack itemStack) intprotected intgetDurabilityUse(ItemStack projectile) private static floatgetPowerForTime(int timeHeld, ItemStack itemStack, LivingEntity holder) private static Vector3fgetProjectileShotVector(LivingEntity body, Vec3 originalVector, float angle) private static floatgetRandomShotPitch(boolean highPitch, RandomSource random) private static floatgetShootingPower(ChargedProjectiles projectiles) private static floatgetShotPitch(RandomSource random, int index) getUseAnimation(ItemStack itemStack) intgetUseDuration(ItemStack itemStack, LivingEntity user) static booleanvoidonUseTick(Level level, LivingEntity entity, ItemStack itemStack, int ticksRemaining) Called as the item is being used by an entity.voidperformShooting(Level level, LivingEntity shooter, InteractionHand hand, ItemStack weapon, float power, float uncertainty, @Nullable LivingEntity targetOverride) booleanreleaseUsing(ItemStack itemStack, Level level, LivingEntity entity, int remainingTime) protected voidshootProjectile(LivingEntity livingEntity, Projectile projectileEntity, int index, float power, float uncertainty, float angle, @Nullable LivingEntity targetOverride) private static booleantryLoadProjectiles(LivingEntity shooter, ItemStack heldItem) use(Level level, Player player, InteractionHand hand) booleanuseOnRelease(ItemStack itemStack) If this stack's item is a crossbowMethods inherited from class ProjectileWeaponItem
customArrow, draw, getAllSupportedProjectiles, getDefaultCreativeAmmo, getHeldProjectile, getSupportedHeldProjectiles, shoot, useAmmoMethods inherited from class Item
appendHoverText, asItem, builtInRegistryHolder, byBlock, byId, canDestroyBlock, canFitInsideContainerItems, components, computeDefaultResource, finishUsingItem, getAttackDamageBonus, getBarColor, getBarWidth, getCraftingRemainder, getDefaultInstance, getDefaultMaxStackSize, getDescriptionId, getDestroySpeed, getId, getItemDamageSource, getName, getPlayerPOVHitResult, getTooltipImage, hurtEnemy, interactLivingEntity, inventoryTick, isBarVisible, isCombineRepairable, isCorrectToolForDrops, isFoil, mineBlock, onCraftedBy, onCraftedPostProcess, onDestroyed, overrideOtherStackedOnMe, overrideStackedOnOther, postHurtEnemy, requiredFeatures, resetDefaultResource, shouldPrintOpWarning, toString, useOnMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface FeatureElement
isEnabledMethods inherited from interface IItemExtension
applyEnchantments, canBeHurtBy, canContinueUsing, canEquip, canFitInsideContainerItems, 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 totruewhen the crossbow is 20% charged. -
midLoadSoundPlayed
private boolean midLoadSoundPlayedSet totruewhen 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:
getSupportedHeldProjectilesin classProjectileWeaponItem
-
getAllSupportedProjectiles
- Specified by:
getAllSupportedProjectilesin classProjectileWeaponItem
-
use
-
getShootingPower
-
releaseUsing
public boolean releaseUsing(ItemStack itemStack, Level level, LivingEntity entity, int remainingTime) - Overrides:
releaseUsingin classItem
-
tryLoadProjectiles
-
isCharged
-
shootProjectile
protected void shootProjectile(LivingEntity livingEntity, Projectile projectileEntity, int index, float power, float uncertainty, float angle, @Nullable LivingEntity targetOverride) - Specified by:
shootProjectilein classProjectileWeaponItem
-
getProjectileShotVector
private static Vector3f getProjectileShotVector(LivingEntity body, Vec3 originalVector, float angle) -
createProjectile
protected Projectile createProjectile(Level level, LivingEntity shooter, ItemStack heldItem, ItemStack projectile, boolean isCrit) - Overrides:
createProjectilein classProjectileWeaponItem
-
getDurabilityUse
- Overrides:
getDurabilityUsein classProjectileWeaponItem
-
performShooting
public void performShooting(Level level, LivingEntity shooter, InteractionHand hand, ItemStack weapon, float power, float uncertainty, @Nullable LivingEntity targetOverride) -
getShotPitch
-
getRandomShotPitch
-
onUseTick
Called as the item is being used by an entity. -
getUseDuration
- Overrides:
getUseDurationin classItem
-
getChargeDuration
-
getUseAnimation
- Overrides:
getUseAnimationin classItem
-
getChargingSounds
-
getPowerForTime
-
useOnRelease
Description copied from class:ItemIf this stack's item is a crossbow- Overrides:
useOnReleasein classItem
-
getDefaultProjectileRange
public int getDefaultProjectileRange()- Specified by:
getDefaultProjectileRangein classProjectileWeaponItem
-