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.level.ItemLike, net.neoforged.neoforge.common.extensions.IItemExtension
Direct Known Subclasses:
MusketItem, SimplePistolItem, SimpleShotgunItem

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

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
     

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

    net.minecraft.world.item.Item.Properties, net.minecraft.world.item.Item.TooltipContext
  • 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>
     
    protected static final Predicate<net.minecraft.world.item.ItemStack>
     
    static final net.neoforged.neoforge.registries.datamaps.DataMapType<net.minecraft.world.item.Item,FlammablePowder>
     

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

    ABSOLUTE_MAX_STACK_SIZE, APPROXIMATELY_INFINITE_USE_DURATION, BASE_ATTACK_DAMAGE_ID, BASE_ATTACK_SPEED_ID, BY_BLOCK, canCombineRepair, CODEC, DEFAULT_MAX_STACK_SIZE, descriptionId, MAX_BAR_WIDTH, STREAM_CODEC

    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)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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)
     
    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
     
    net.minecraft.sounds.SoundEvent
    Get the fire sound.
    float
    getFireVelocity(net.minecraft.world.item.ItemStack gun, float powderModifier, net.minecraft.world.entity.LivingEntity shooter)
     
    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
     
    int
    getUseDuration(net.minecraft.world.item.ItemStack pStack, net.minecraft.world.entity.LivingEntity livingEntity)
     
    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(@Nullable AbstractGunItem.PowderType powderType, net.minecraft.world.entity.player.Player player)
     
    void
    prepareBulletForFire(net.minecraft.world.item.ItemStack gun, BulletEntity bulletEntity, net.minecraft.world.entity.LivingEntity shooter, float powderModifier)
     
    boolean
    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.InteractionResult
    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, canDestroyBlock, canFitInsideContainerItems, components, finishUsingItem, getAttackDamageBonus, getBarColor, getBarWidth, getCraftingRemainder, getDamageSource, getDefaultInstance, getDefaultMaxStackSize, getDescriptionId, getDestroySpeed, getId, getName, getName, getPlayerPOVHitResult, getTooltipImage, getUseAnimation, hurtEnemy, interactLivingEntity, inventoryTick, isBarVisible, isCombineRepairable, isCorrectToolForDrops, isFoil, mineBlock, modifyDefaultComponentsFrom, onCraftedBy, onCraftedPostProcess, onDestroyed, onUseTick, overrideOtherStackedOnMe, overrideStackedOnOther, postHurtEnemy, requiredFeatures, shouldPrintOpWarning, toString, useOn, useOnRelease, 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, 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

    • POWDER_TYPE

      public static final net.neoforged.neoforge.registries.datamaps.DataMapType<net.minecraft.world.item.Item,FlammablePowder> POWDER_TYPE
    • 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
    • DRAGON_FIREBALLS

      protected static final Predicate<net.minecraft.world.item.ItemStack> DRAGON_FIREBALLS
    • 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)
  • Method Details

    • releaseUsing

      public boolean 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

      @Nullable public @Nullable AbstractGunItem.PowderType findPowder(net.minecraft.world.item.ItemStack gun, net.minecraft.world.entity.LivingEntity livingEntity)
    • 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.InteractionResult 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
    • 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
    • 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 pStack, net.minecraft.world.entity.LivingEntity livingEntity)
      Overrides:
      getUseDuration in class net.minecraft.world.item.Item
    • 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()
    • getFireVelocity

      public float getFireVelocity(net.minecraft.world.item.ItemStack gun, float powderModifier, net.minecraft.world.entity.LivingEntity shooter)
    • 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 shooter, 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(@Nullable @Nullable AbstractGunItem.PowderType powderType, net.minecraft.world.entity.player.Player player)