Package net.minecraft.item
Class CrossbowItem
java.lang.Object
net.minecraft.item.Item
net.minecraft.item.RangedWeaponItem
net.minecraft.item.CrossbowItem
- All Implemented Interfaces:
ItemConvertible,Vanishable
public class CrossbowItem extends RangedWeaponItem implements Vanishable
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.item.Item
Item.Settings -
Field Summary
Fields inherited from class net.minecraft.item.RangedWeaponItem
BOW_PROJECTILES, CROSSBOW_HELD_PROJECTILESFields inherited from class net.minecraft.item.Item
ATTACK_DAMAGE_MODIFIER_ID, ATTACK_SPEED_MODIFIER_ID, BLOCK_ITEMS, group -
Constructor Summary
Constructors Constructor Description CrossbowItem(Item.Settings settings) -
Method Summary
Modifier and Type Method Description voidappendTooltip(ItemStack stack, World world, List<Text> tooltip, TooltipContext context)private static voidclearProjectiles(ItemStack crossbow)private static PersistentProjectileEntitycreateArrow(World world, LivingEntity entity, ItemStack crossbow, ItemStack arrow)Predicate<ItemStack>getHeldProjectiles()intgetMaxUseTime(ItemStack stack)Predicate<ItemStack>getProjectiles()private static List<ItemStack>getProjectiles(ItemStack crossbow)private static floatgetPullProgress(int useTicks, ItemStack stack)static intgetPullTime(ItemStack stack)private SoundEventgetQuickChargeSound(int stage)intgetRange()private static floatgetSoundPitch(boolean flag, Random random)private static float[]getSoundPitches(Random random)private static floatgetSpeed(ItemStack stack)UseActiongetUseAction(ItemStack stack)static booleanhasProjectile(ItemStack crossbow, Item projectile)static booleanisCharged(ItemStack stack)booleanisUsedOnRelease(ItemStack stack)private static booleanloadProjectile(LivingEntity shooter, ItemStack crossbow, ItemStack projectile, boolean simulated, boolean creative)private static booleanloadProjectiles(LivingEntity shooter, ItemStack projectile)voidonStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks)private static voidpostShoot(World world, LivingEntity entity, ItemStack stack)private static voidputProjectile(ItemStack crossbow, ItemStack projectile)static voidsetCharged(ItemStack stack, boolean charged)private static voidshoot(World world, LivingEntity shooter, Hand hand, ItemStack crossbow, ItemStack projectile, float soundPitch, boolean creative, float speed, float divergence, float simulated)static voidshootAll(World world, LivingEntity entity, Hand hand, ItemStack stack, float speed, float divergence)voidusageTick(World world, LivingEntity user, ItemStack stack, int remainingUseTicks)TypedActionResult<ItemStack>use(World world, PlayerEntity user, Hand hand)Called when an item is used by a player.Methods inherited from class net.minecraft.item.RangedWeaponItem
getEnchantability, getHeldProjectileMethods inherited from class net.minecraft.item.Item
appendStacks, asItem, byRawId, canMine, canRepair, damage, finishUsing, fromBlock, getAttributeModifiers, getDefaultStack, getDrinkSound, getEatSound, getEquipSound, getFoodComponent, getGroup, getItemBarColor, getItemBarStep, getMaxCount, getMaxDamage, getMiningSpeedMultiplier, getName, getName, getOrCreateTranslationKey, getRarity, getRawId, getRecipeRemainder, getTooltipData, getTranslationKey, getTranslationKey, hasGlint, hasRecipeRemainder, hasStoredInventory, inventoryTick, isDamageable, isEnchantable, isFireproof, isFood, isIn, isItemBarVisible, isNetworkSynced, isSuitableFor, method_33261, onClicked, onCraft, onStackClicked, postHit, postMine, postProcessTag, raycast, shouldSyncTagToClient, toString, useOnBlock, useOnEntity
-
Field Details
-
charged
private boolean charged -
loaded
private boolean loaded
-
-
Constructor Details
-
CrossbowItem
-
-
Method Details
-
getHeldProjectiles
- Overrides:
getHeldProjectilesin classRangedWeaponItem
-
getProjectiles
- Specified by:
getProjectilesin classRangedWeaponItem
-
use
Called when an item is used by a player. The use action, by default, is bound to the right mouse button.This method is called on both the logical client and logical server, so take caution when overriding this method. The logical side can be checked using
world.isClient().- Overrides:
usein classItem- Parameters:
world- the world the item was used inuser- the player who used the itemhand- the hand used- Returns:
- a typed action result that specifies whether using the item was successful. The action result contains the new item stack that the player's hand will be set to.
-
getSpeed
-
onStoppedUsing
- Overrides:
onStoppedUsingin classItem
-
loadProjectiles
-
loadProjectile
private static boolean loadProjectile(LivingEntity shooter, ItemStack crossbow, ItemStack projectile, boolean simulated, boolean creative) -
isCharged
-
setCharged
-
putProjectile
-
getProjectiles
-
clearProjectiles
-
hasProjectile
-
shoot
private static void shoot(World world, LivingEntity shooter, Hand hand, ItemStack crossbow, ItemStack projectile, float soundPitch, boolean creative, float speed, float divergence, float simulated) -
createArrow
private static PersistentProjectileEntity createArrow(World world, LivingEntity entity, ItemStack crossbow, ItemStack arrow) -
shootAll
public static void shootAll(World world, LivingEntity entity, Hand hand, ItemStack stack, float speed, float divergence) -
getSoundPitches
-
getSoundPitch
-
postShoot
-
usageTick
-
getMaxUseTime
- Overrides:
getMaxUseTimein classItem
-
getPullTime
-
getUseAction
- Overrides:
getUseActionin classItem
-
getQuickChargeSound
-
getPullProgress
-
appendTooltip
@Environment(CLIENT) public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context)- Overrides:
appendTooltipin classItem
-
isUsedOnRelease
- Overrides:
isUsedOnReleasein classItem
-
getRange
public int getRange()- Specified by:
getRangein classRangedWeaponItem
-