java.lang.Object
net.minecraft.world.item.Item
tech.anonymoushacker1279.immersiveweapons.item.gun.AbstractGunItem
All Implemented Interfaces:
net.minecraft.world.flag.FeatureElement, net.minecraft.world.item.Vanishable, net.minecraft.world.level.ItemLike, net.neoforged.neoforge.common.extensions.IItemExtension
Direct Known Subclasses:
MusketItem, SimplePistolItem, SimpleShotgunItem

public abstract class AbstractGunItem extends net.minecraft.world.item.Item implements net.minecraft.world.item.Vanishable
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     

    Nested classes/interfaces inherited from class net.minecraft.world.item.Item

    net.minecraft.world.item.Item.Properties
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final Predicate<net.minecraft.world.item.ItemStack>
     
    protected static final Predicate<net.minecraft.world.item.ItemStack>
     
    protected static final Predicate<net.minecraft.world.item.ItemStack>
     
    protected static final Predicate<net.minecraft.world.item.ItemStack>
     

    Fields inherited from class net.minecraft.world.item.Item

    BASE_ATTACK_DAMAGE_UUID, BASE_ATTACK_SPEED_UUID, BY_BLOCK, canRepair, EAT_DURATION, MAX_BAR_WIDTH, MAX_STACK_SIZE

    Fields inherited from interface net.minecraft.world.flag.FeatureElement

    FILTERED_REGISTRIES
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractGunItem(net.minecraft.world.item.Item.Properties properties)
    Constructor for AbstractGunItem.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    net.minecraft.world.item.Item
    Get the default ammunition.
    net.minecraft.world.item.Item
    Get the default powder.
    net.minecraft.world.item.ItemStack
    findAmmo(net.minecraft.world.item.ItemStack gun, net.minecraft.world.entity.LivingEntity livingEntity)
     
    net.minecraft.world.item.ItemStack
    findPowder(net.minecraft.world.item.ItemStack gun, net.minecraft.world.entity.LivingEntity livingEntity)
     
    float
     
    int
    getBulletsToFire(net.minecraft.world.item.ItemStack itemStack)
    Get the number of bullets to fire.
    int
     
    int
    getEnchantmentValue(net.minecraft.world.item.ItemStack stack)
    Return the enchantability factor of the item, most of the time it is based on material.
    net.minecraft.sounds.SoundEvent
    Get the fire sound.
    float
    getFireVelocity(net.minecraft.world.item.ItemStack gun, float powderModifier)
     
    protected static net.minecraft.world.item.ItemStack
    getHeldPredicate(net.minecraft.world.entity.LivingEntity livingEntity, Predicate<net.minecraft.world.item.ItemStack> predicate)
     
    float
     
    Predicate<net.minecraft.world.item.ItemStack>
    Get the predicate to match ammunition when searching the player's inventory, not their main/offhand
    int
     
    int
    Get the maximum number of bullets that can be fired at once.
    float
     
    float
     
    getPowderFromItem(net.minecraft.world.item.Item item)
     
    protected net.minecraft.world.item.crafting.Ingredient
    Get the repair material.
    net.minecraft.world.item.UseAnim
    getUseAnimation(net.minecraft.world.item.ItemStack pStack)
     
    int
    getUseDuration(net.minecraft.world.item.ItemStack stack)
    Get the use duration.
    protected void
    handleAmmoStack(net.minecraft.world.item.ItemStack gun, net.minecraft.world.item.ItemStack ammo, int bulletsToFire, net.minecraft.world.entity.player.Player player)
     
    protected void
    handleMuzzleFlash(net.minecraft.world.level.Level level, net.minecraft.world.entity.LivingEntity shooter, AbstractGunItem.PowderType powderType)
     
    protected void
    handlePowderStack(net.minecraft.world.item.ItemStack powder, net.minecraft.world.entity.player.Player player)
     
    void
    initializeClient(Consumer<net.neoforged.neoforge.client.extensions.common.IClientItemExtensions> consumer)
     
    void
    inventoryTick(net.minecraft.world.item.ItemStack pStack, net.minecraft.world.level.Level pLevel, net.minecraft.world.entity.Entity pEntity, int pSlotId, boolean pIsSelected)
     
    static boolean
    isPowder(net.minecraft.world.item.Item item)
     
    boolean
    isValidRepairItem(net.minecraft.world.item.ItemStack toRepair, net.minecraft.world.item.ItemStack repair)
     
    boolean
    onDroppedByPlayer(net.minecraft.world.item.ItemStack item, net.minecraft.world.entity.player.Player player)
     
    void
    onUseTick(net.minecraft.world.level.Level level, net.minecraft.world.entity.LivingEntity livingEntity, net.minecraft.world.item.ItemStack stack, int remainingUseDuration)
     
    void
    prepareBulletForFire(net.minecraft.world.item.ItemStack gun, BulletEntity bulletEntity, net.minecraft.world.entity.LivingEntity livingEntity, float powderModifier)
     
    void
    releaseUsing(net.minecraft.world.item.ItemStack gun, net.minecraft.world.level.Level level, net.minecraft.world.entity.LivingEntity livingEntity, int timeLeft)
     
    void
    setupFire(net.minecraft.world.entity.LivingEntity shooter, BulletEntity bullet, net.minecraft.world.item.ItemStack gun, @Nullable net.minecraft.world.item.ItemStack ammo, AbstractGunItem.PowderType powderType)
     
    net.minecraft.world.InteractionResultHolder<net.minecraft.world.item.ItemStack>
    use(net.minecraft.world.level.Level level, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand)
     

    Methods inherited from class net.minecraft.world.item.Item

    appendHoverText, asItem, builtInRegistryHolder, byBlock, byId, canAttackBlock, canBeDepleted, canBeHurtBy, canFitInsideContainerItems, finishUsingItem, getBarColor, getBarWidth, getCraftingRemainingItem, getDefaultAttributeModifiers, getDefaultInstance, getDescription, getDescriptionId, getDescriptionId, getDestroySpeed, getDrinkingSound, getEatingSound, getEnchantmentValue, getFoodProperties, getId, getMaxDamage, getMaxStackSize, getName, getOrCreateDescriptionId, getPlayerPOVHitResult, getRarity, getRenderPropertiesInternal, getTooltipImage, hasCraftingRemainingItem, hurtEnemy, interactLivingEntity, isBarVisible, isComplex, isCorrectToolForDrops, isEdible, isEnchantable, isFireResistant, isFoil, isRepairable, mineBlock, onCraftedBy, onCraftedPostProcess, onDestroyed, overrideOtherStackedOnMe, overrideStackedOnOther, requiredFeatures, shouldOverrideMultiplayerNbt, toString, useOn, useOnRelease, verifyTagAfterLoad

    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

    canApplyAtEnchantingTable, canContinueUsing, canDisableShield, canElytraFly, canEquip, canGrindstoneRepair, canPerformAction, canWalkOnPowderedSnow, createEntity, damageItem, doesSneakBypassUse, elytraFlightTick, getAllEnchantments, getArmorTexture, getAttributeModifiers, getBurnTime, getCraftingRemainingItem, getCreatorModId, getDamage, getDefaultTooltipHideFlags, getEnchantmentLevel, getEntityLifespan, getEquipmentSlot, getFoodProperties, getHighlightTip, getMaxDamage, getMaxStackSize, getSweepHitBox, getXpRepairRatio, hasCraftingRemainingItem, hasCustomEntity, isBookEnchantable, isCorrectToolForDrops, isDamageable, isDamaged, isEnderMask, isNotReplaceableByPickAction, isPiglinCurrency, makesPiglinsNeutral, onArmorTick, onBlockStartBreak, onDestroyed, onEntityItemUpdate, onEntitySwing, onHorseArmorTick, onItemUseFirst, onLeftClickEntity, onStopUsing, setDamage, shouldCauseBlockBreakReset, shouldCauseReequipAnimation
  • Field Details

    • MUSKET_BALLS

      protected static final Predicate<net.minecraft.world.item.ItemStack> MUSKET_BALLS
    • FLARES

      protected static final Predicate<net.minecraft.world.item.ItemStack> FLARES
    • CANNONBALLS

      protected static final Predicate<net.minecraft.world.item.ItemStack> CANNONBALLS
    • FLAMMABLE_POWDERS

      protected static final Predicate<net.minecraft.world.item.ItemStack> FLAMMABLE_POWDERS
  • Constructor Details

    • AbstractGunItem

      protected AbstractGunItem(net.minecraft.world.item.Item.Properties properties)
      Constructor for AbstractGunItem.
      Parameters:
      properties - the Properties for the item
  • Method Details

    • releaseUsing

      public void releaseUsing(net.minecraft.world.item.ItemStack gun, net.minecraft.world.level.Level level, net.minecraft.world.entity.LivingEntity livingEntity, int timeLeft)
      Overrides:
      releaseUsing in class net.minecraft.world.item.Item
    • findAmmo

      public net.minecraft.world.item.ItemStack findAmmo(net.minecraft.world.item.ItemStack gun, net.minecraft.world.entity.LivingEntity livingEntity)
    • findPowder

      public net.minecraft.world.item.ItemStack findPowder(net.minecraft.world.item.ItemStack gun, net.minecraft.world.entity.LivingEntity livingEntity)
    • isValidRepairItem

      public boolean isValidRepairItem(net.minecraft.world.item.ItemStack toRepair, net.minecraft.world.item.ItemStack repair)
      Overrides:
      isValidRepairItem in class net.minecraft.world.item.Item
    • getHeldPredicate

      protected static net.minecraft.world.item.ItemStack getHeldPredicate(net.minecraft.world.entity.LivingEntity livingEntity, Predicate<net.minecraft.world.item.ItemStack> predicate)
    • use

      public net.minecraft.world.InteractionResultHolder<net.minecraft.world.item.ItemStack> use(net.minecraft.world.level.Level level, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand)
      Overrides:
      use in class net.minecraft.world.item.Item
    • onUseTick

      public void onUseTick(net.minecraft.world.level.Level level, net.minecraft.world.entity.LivingEntity livingEntity, net.minecraft.world.item.ItemStack stack, int remainingUseDuration)
      Overrides:
      onUseTick in class net.minecraft.world.item.Item
    • inventoryTick

      public void inventoryTick(net.minecraft.world.item.ItemStack pStack, net.minecraft.world.level.Level pLevel, net.minecraft.world.entity.Entity pEntity, int pSlotId, boolean pIsSelected)
      Overrides:
      inventoryTick in class net.minecraft.world.item.Item
    • onDroppedByPlayer

      public boolean onDroppedByPlayer(net.minecraft.world.item.ItemStack item, net.minecraft.world.entity.player.Player player)
      Specified by:
      onDroppedByPlayer in interface net.neoforged.neoforge.common.extensions.IItemExtension
    • getUseAnimation

      public net.minecraft.world.item.UseAnim getUseAnimation(net.minecraft.world.item.ItemStack pStack)
      Overrides:
      getUseAnimation in class net.minecraft.world.item.Item
    • initializeClient

      public void initializeClient(Consumer<net.neoforged.neoforge.client.extensions.common.IClientItemExtensions> consumer)
      Overrides:
      initializeClient in class net.minecraft.world.item.Item
    • getInventoryAmmoPredicate

      public Predicate<net.minecraft.world.item.ItemStack> getInventoryAmmoPredicate()
      Get the predicate to match ammunition when searching the player's inventory, not their main/offhand
      Returns:
      Predicate extending ItemStack
    • getEnchantmentValue

      public int getEnchantmentValue(net.minecraft.world.item.ItemStack stack)
      Return the enchantability factor of the item, most of the time it is based on material.
      Specified by:
      getEnchantmentValue in interface net.neoforged.neoforge.common.extensions.IItemExtension
      Returns:
      int
    • getRepairMaterial

      protected net.minecraft.world.item.crafting.Ingredient getRepairMaterial()
      Get the repair material.
      Returns:
      Ingredient
    • defaultAmmo

      public net.minecraft.world.item.Item defaultAmmo()
      Get the default ammunition.
      Returns:
      Item
    • defaultPowder

      public net.minecraft.world.item.Item defaultPowder()
      Get the default powder.
      Returns:
      Item
    • getUseDuration

      public int getUseDuration(net.minecraft.world.item.ItemStack stack)
      Get the use duration.
      Overrides:
      getUseDuration in class net.minecraft.world.item.Item
      Parameters:
      stack - the ItemStack to check
      Returns:
      int
    • getFireSound

      public net.minecraft.sounds.SoundEvent getFireSound()
      Get the fire sound.
      Returns:
      SoundEvent
    • getMaxBulletsToFire

      public int getMaxBulletsToFire()
      Get the maximum number of bullets that can be fired at once.
      Returns:
      int
    • getBulletsToFire

      public int getBulletsToFire(net.minecraft.world.item.ItemStack itemStack)
      Get the number of bullets to fire.
      Parameters:
      itemStack - the ammunition ItemStack
      Returns:
      int
    • getCooldown

      public int getCooldown()
    • getMaxYRecoil

      public float getMaxYRecoil()
    • getMaxXRecoil

      public float getMaxXRecoil()
    • canScope

      public boolean canScope()
    • getFireVelocity

      public float getFireVelocity(net.minecraft.world.item.ItemStack gun, float powderModifier)
    • getBaseFireVelocity

      public float getBaseFireVelocity()
    • getInaccuracy

      public float getInaccuracy()
    • getKnockbackLevel

      public int getKnockbackLevel()
    • setupFire

      public void setupFire(net.minecraft.world.entity.LivingEntity shooter, BulletEntity bullet, net.minecraft.world.item.ItemStack gun, @Nullable @Nullable net.minecraft.world.item.ItemStack ammo, AbstractGunItem.PowderType powderType)
    • prepareBulletForFire

      public void prepareBulletForFire(net.minecraft.world.item.ItemStack gun, BulletEntity bulletEntity, net.minecraft.world.entity.LivingEntity livingEntity, float powderModifier)
    • handleMuzzleFlash

      protected void handleMuzzleFlash(net.minecraft.world.level.Level level, net.minecraft.world.entity.LivingEntity shooter, AbstractGunItem.PowderType powderType)
    • handleAmmoStack

      protected void handleAmmoStack(net.minecraft.world.item.ItemStack gun, net.minecraft.world.item.ItemStack ammo, int bulletsToFire, net.minecraft.world.entity.player.Player player)
    • handlePowderStack

      protected void handlePowderStack(net.minecraft.world.item.ItemStack powder, net.minecraft.world.entity.player.Player player)
    • isPowder

      public static boolean isPowder(net.minecraft.world.item.Item item)
    • getPowderFromItem

      public static AbstractGunItem.PowderType getPowderFromItem(net.minecraft.world.item.Item item)