Class AbstractGunItem
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 ClassesNested classes/interfaces inherited from class net.minecraft.world.item.Item
net.minecraft.world.item.Item.Properties, net.minecraft.world.item.Item.TooltipContext -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected 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, BASE_ATTACK_DAMAGE_ID, BASE_ATTACK_SPEED_ID, BY_BLOCK, canRepair, DEFAULT_MAX_STACK_SIZE, MAX_BAR_WIDTHFields inherited from interface net.minecraft.world.flag.FeatureElement
FILTERED_REGISTRIES -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractGunItem(net.minecraft.world.item.Item.Properties properties) Constructor for AbstractGunItem. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanScope()net.minecraft.world.item.ItemGet the default ammunition.net.minecraft.world.item.ItemGet the default powder.net.minecraft.world.item.ItemStackfindAmmo(net.minecraft.world.item.ItemStack gun, net.minecraft.world.entity.LivingEntity livingEntity) @Nullable AbstractGunItem.PowderTypefindPowder(net.minecraft.world.item.ItemStack gun, net.minecraft.world.entity.LivingEntity livingEntity) floatintgetBulletsToFire(net.minecraft.world.item.ItemStack itemStack) Get the number of bullets to fire.intintgetEnchantmentValue(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.SoundEventGet the fire sound.floatgetFireVelocity(net.minecraft.world.item.ItemStack gun, float powderModifier, net.minecraft.world.entity.LivingEntity shooter) protected static net.minecraft.world.item.ItemStackgetHeldPredicate(net.minecraft.world.entity.LivingEntity livingEntity, Predicate<net.minecraft.world.item.ItemStack> predicate) floatPredicate<net.minecraft.world.item.ItemStack> Get the predicate to match ammunition when searching the player's inventory, not their main/offhandintintGet the maximum number of bullets that can be fired at once.floatfloatprotected net.minecraft.world.item.crafting.IngredientGet the repair material.net.minecraft.world.item.UseAnimgetUseAnimation(net.minecraft.world.item.ItemStack pStack) intgetUseDuration(net.minecraft.world.item.ItemStack pStack, net.minecraft.world.entity.LivingEntity livingEntity) protected voidhandleAmmoStack(net.minecraft.world.item.ItemStack gun, net.minecraft.world.item.ItemStack ammo, int bulletsToFire, net.minecraft.world.entity.player.Player player) protected voidhandleMuzzleFlash(net.minecraft.world.level.Level level, net.minecraft.world.entity.LivingEntity shooter, AbstractGunItem.PowderType powderType) protected voidhandlePowderStack(@Nullable AbstractGunItem.PowderType powderType, net.minecraft.world.entity.player.Player player) voidinventoryTick(net.minecraft.world.item.ItemStack pStack, net.minecraft.world.level.Level pLevel, net.minecraft.world.entity.Entity pEntity, int pSlotId, boolean pIsSelected) booleanisValidRepairItem(net.minecraft.world.item.ItemStack toRepair, net.minecraft.world.item.ItemStack repair) booleanonDroppedByPlayer(net.minecraft.world.item.ItemStack item, net.minecraft.world.entity.player.Player player) voidonUseTick(net.minecraft.world.level.Level level, net.minecraft.world.entity.LivingEntity livingEntity, net.minecraft.world.item.ItemStack stack, int remainingUseDuration) voidprepareBulletForFire(net.minecraft.world.item.ItemStack gun, BulletEntity bulletEntity, net.minecraft.world.entity.LivingEntity shooter, float powderModifier) voidreleaseUsing(net.minecraft.world.item.ItemStack gun, net.minecraft.world.level.Level level, net.minecraft.world.entity.LivingEntity livingEntity, int timeLeft) voidsetupFire(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, canFitInsideContainerItems, components, finishUsingItem, getAttackDamageBonus, getBarColor, getBarWidth, getBreakingSound, getCraftingRemainingItem, getDefaultAttributeModifiers, getDefaultInstance, getDefaultMaxStackSize, getDescription, getDescriptionId, getDescriptionId, getDestroySpeed, getDrinkingSound, getEatingSound, getEnchantmentValue, getId, getName, getOrCreateDescriptionId, getPlayerPOVHitResult, getTooltipImage, hasCraftingRemainingItem, hurtEnemy, initializeClient, interactLivingEntity, isBarVisible, isComplex, isCorrectToolForDrops, isEnchantable, isFoil, isRepairable, mineBlock, modifyDefaultComponentsFrom, onCraftedBy, onCraftedPostProcess, onDestroyed, overrideOtherStackedOnMe, overrideStackedOnOther, postHurtEnemy, requiredFeatures, toString, useOn, useOnRelease, verifyComponentsAfterLoadMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.world.flag.FeatureElement
isEnabledMethods inherited from interface net.neoforged.neoforge.common.extensions.IItemExtension
applyEnchantments, canBeHurtBy, canContinueUsing, canDisableShield, canElytraFly, canEquip, canGrindstoneRepair, canPerformAction, canWalkOnPowderedSnow, createEntity, damageItem, doesSneakBypassUse, elytraFlightTick, getAllEnchantments, getArmorTexture, getBurnTime, getCraftingRemainingItem, getCreatorModId, getDamage, getDefaultAttributeModifiers, getEnchantmentLevel, getEntityLifespan, getEquipmentSlot, getFoodProperties, getHighlightTip, getMaxDamage, getMaxStackSize, getSweepHitBox, getXpRepairRatio, hasCraftingRemainingItem, hasCustomEntity, isBookEnchantable, isDamageable, isDamaged, isEnderMask, isNotReplaceableByPickAction, isPiglinCurrency, isPrimaryItemFor, makesPiglinsNeutral, onAnimalArmorTick, onDestroyed, onEntityItemUpdate, onEntitySwing, 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
-
FLARES
-
CANNONBALLS
-
DRAGON_FIREBALLS
-
FLAMMABLE_POWDERS
-
-
Constructor Details
-
AbstractGunItem
protected AbstractGunItem(net.minecraft.world.item.Item.Properties properties) Constructor for AbstractGunItem.- Parameters:
properties- thePropertiesfor 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:
releaseUsingin classnet.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) -
isValidRepairItem
public boolean isValidRepairItem(net.minecraft.world.item.ItemStack toRepair, net.minecraft.world.item.ItemStack repair) - Overrides:
isValidRepairItemin classnet.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:
usein classnet.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:
onUseTickin classnet.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:
inventoryTickin classnet.minecraft.world.item.Item
-
onDroppedByPlayer
public boolean onDroppedByPlayer(net.minecraft.world.item.ItemStack item, net.minecraft.world.entity.player.Player player) -
getUseAnimation
public net.minecraft.world.item.UseAnim getUseAnimation(net.minecraft.world.item.ItemStack pStack) - Overrides:
getUseAnimationin classnet.minecraft.world.item.Item
-
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.- 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 pStack, net.minecraft.world.entity.LivingEntity livingEntity) - Overrides:
getUseDurationin classnet.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 ammunitionItemStack- 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, 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)
-