public class CrossbowItem extends RangedWeaponItem implements Vanishable
Item.Settings
Modifier and Type | Field and Description |
---|---|
private boolean |
charged |
private boolean |
loaded |
BOW_PROJECTILES, CROSSBOW_HELD_PROJECTILES
ATTACK_DAMAGE_MODIFIER_ID, ATTACK_SPEED_MODIFIER_ID, BLOCK_ITEMS, group, RANDOM
Constructor and Description |
---|
CrossbowItem(Item.Settings settings) |
Modifier and Type | Method and Description |
---|---|
void |
appendTooltip(ItemStack stack,
World world,
List<Text> tooltip,
TooltipContext context) |
private static void |
clearProjectiles(ItemStack crossbow) |
private static PersistentProjectileEntity |
createArrow(World world,
LivingEntity entity,
ItemStack crossbow,
ItemStack arrow) |
Predicate<ItemStack> |
getHeldProjectiles() |
int |
getMaxUseTime(ItemStack stack) |
Predicate<ItemStack> |
getProjectiles() |
private static List<ItemStack> |
getProjectiles(ItemStack crossbow) |
private static float |
getPullProgress(int useTicks,
ItemStack stack) |
static int |
getPullTime(ItemStack stack) |
private SoundEvent |
getQuickChargeSound(int stage) |
int |
getRange() |
private static float |
getSoundPitch(boolean flag) |
private static float[] |
getSoundPitches(Random random) |
private static float |
getSpeed(ItemStack stack) |
UseAction |
getUseAction(ItemStack stack) |
static boolean |
hasProjectile(ItemStack crossbow,
Item projectile) |
static boolean |
isCharged(ItemStack stack) |
private static boolean |
loadProjectile(LivingEntity shooter,
ItemStack crossbow,
ItemStack projectile,
boolean simulated,
boolean creative) |
private static boolean |
loadProjectiles(LivingEntity shooter,
ItemStack projectile) |
void |
onStoppedUsing(ItemStack stack,
World world,
LivingEntity user,
int remainingUseTicks) |
private static void |
postShoot(World world,
LivingEntity entity,
ItemStack stack) |
private static void |
putProjectile(ItemStack crossbow,
ItemStack projectile) |
static void |
setCharged(ItemStack stack,
boolean charged) |
private static void |
shoot(World world,
LivingEntity shooter,
Hand hand,
ItemStack crossbow,
ItemStack projectile,
float soundPitch,
boolean creative,
float speed,
float divergence,
float simulated) |
static void |
shootAll(World world,
LivingEntity entity,
Hand hand,
ItemStack stack,
float speed,
float divergence) |
void |
usageTick(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.
|
getEnchantability, getHeldProjectile
appendStacks, asItem, byRawId, canMine, canRepair, damage, finishUsing, fromBlock, getAttributeModifiers, getDefaultStack, getDrinkSound, getEatSound, getFoodComponent, getGroup, getMaxCount, getMaxDamage, getMiningSpeedMultiplier, getName, getName, getOrCreateTranslationKey, getRarity, getRawId, getRecipeRemainder, getTranslationKey, getTranslationKey, hasGlint, hasRecipeRemainder, inventoryTick, isDamageable, isEffectiveOn, isEnchantable, isFireproof, isFood, isIn, isIn, isNetworkSynced, isUsedOnRelease, onCraft, postHit, postMine, postProcessTag, raycast, shouldSyncTagToClient, toString, useOnBlock, useOnEntity
public CrossbowItem(Item.Settings settings)
public Predicate<ItemStack> getHeldProjectiles()
getHeldProjectiles
in class RangedWeaponItem
public Predicate<ItemStack> getProjectiles()
getProjectiles
in class RangedWeaponItem
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand)
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()
.
use
in class Item
world
- the world the item was used inuser
- the player who used the itemhand
- the hand usedpublic void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks)
onStoppedUsing
in class Item
private static boolean loadProjectiles(LivingEntity shooter, ItemStack projectile)
private static boolean loadProjectile(LivingEntity shooter, ItemStack crossbow, ItemStack projectile, boolean simulated, boolean creative)
public static boolean isCharged(ItemStack stack)
public static void setCharged(ItemStack stack, boolean charged)
private static void clearProjectiles(ItemStack crossbow)
private static void shoot(World world, LivingEntity shooter, Hand hand, ItemStack crossbow, ItemStack projectile, float soundPitch, boolean creative, float speed, float divergence, float simulated)
private static PersistentProjectileEntity createArrow(World world, LivingEntity entity, ItemStack crossbow, ItemStack arrow)
public static void shootAll(World world, LivingEntity entity, Hand hand, ItemStack stack, float speed, float divergence)
private static float[] getSoundPitches(Random random)
private static float getSoundPitch(boolean flag)
private static void postShoot(World world, LivingEntity entity, ItemStack stack)
public void usageTick(World world, LivingEntity user, ItemStack stack, int remainingUseTicks)
public int getMaxUseTime(ItemStack stack)
getMaxUseTime
in class Item
public static int getPullTime(ItemStack stack)
public UseAction getUseAction(ItemStack stack)
getUseAction
in class Item
private SoundEvent getQuickChargeSound(int stage)
private static float getPullProgress(int useTicks, ItemStack stack)
@Environment(value=CLIENT) public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context)
appendTooltip
in class Item
private static float getSpeed(ItemStack stack)
public int getRange()
getRange
in class RangedWeaponItem