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.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 ClassesNested classes/interfaces inherited from class net.minecraft.world.item.Item
net.minecraft.world.item.Item.Properties -
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>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_SIZEFields 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) net.minecraft.world.item.ItemStackfindPowder(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) protected static net.minecraft.world.item.ItemStackgetHeldPredicate(net.minecraft.world.entity.LivingEntity livingEntity, Predicate<net.minecraft.world.item.ItemStack> predicate) Predicate<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.floatfloatstatic AbstractGunItem.PowderTypegetPowderFromItem(net.minecraft.world.item.Item item) protected 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 stack) Get the use duration.protected voidhandleAmmoStack(net.minecraft.world.item.ItemStack gun, net.minecraft.world.item.ItemStack ammo, int bulletsToFire, net.minecraft.world.entity.player.Player player) protected voidhandlePowderStack(net.minecraft.world.item.ItemStack powder, net.minecraft.world.entity.player.Player player) voidinitializeClient(Consumer<net.neoforged.neoforge.client.extensions.common.IClientItemExtensions> consumer) voidinventoryTick(net.minecraft.world.item.ItemStack pStack, net.minecraft.world.level.Level pLevel, net.minecraft.world.entity.Entity pEntity, int pSlotId, boolean pIsSelected) static booleanisPowder(net.minecraft.world.item.Item item) 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) voidreleaseUsing(net.minecraft.world.item.ItemStack gun, net.minecraft.world.level.Level level, net.minecraft.world.entity.LivingEntity livingEntity, int timeLeft) protected voidsetupFire(net.minecraft.world.item.ItemStack gun, BulletEntity bulletEntity, net.minecraft.world.entity.player.Player player, float powderModifier) 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, verifyTagAfterLoadMethods 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
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
-
FLARES
-
CANNONBALLS
-
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
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:
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) - Specified by:
onDroppedByPlayerin interfacenet.neoforged.neoforge.common.extensions.IItemExtension
-
getUseAnimation
public net.minecraft.world.item.UseAnim getUseAnimation(net.minecraft.world.item.ItemStack pStack) - Overrides:
getUseAnimationin classnet.minecraft.world.item.Item
-
initializeClient
public void initializeClient(Consumer<net.neoforged.neoforge.client.extensions.common.IClientItemExtensions> consumer) - Overrides:
initializeClientin 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.- Specified by:
getEnchantmentValuein interfacenet.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:
getUseDurationin classnet.minecraft.world.item.Item- Parameters:
stack- theItemStackto 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 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) -
getBaseFireVelocity
public float getBaseFireVelocity() -
getKnockbackLevel
public int getKnockbackLevel() -
setupFire
protected void setupFire(net.minecraft.world.item.ItemStack gun, BulletEntity bulletEntity, net.minecraft.world.entity.player.Player player, float powderModifier) -
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
-