Class AbstractHatItem

java.lang.Object
net.minecraft.world.item.Item
de.cech12.usefulhats.item.AbstractHatItem
All Implemented Interfaces:
net.minecraft.world.flag.FeatureElement, net.minecraft.world.level.ItemLike, net.minecraftforge.common.extensions.IForgeItem
Direct Known Subclasses:
AbstractMiningHatItem, AquanautHelmetItem, BunnyEarsItem, EnderHelmetItem, HaloItem, LuckyHatItem, MushroomHatItem, PostmanHatItem, ShulkerHelmetItem, StockingCapItem, WingHelmetItem

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

    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 final Supplier<Boolean>
     

    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, CODEC, CODEC_WITH_BOUND_COMPONENTS, DEFAULT_MAX_STACK_SIZE, descriptionId, MAX_BAR_WIDTH, STREAM_CODEC

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

    FILTERED_REGISTRIES
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractHatItem(String name, net.minecraft.world.item.equipment.ArmorMaterial material, Supplier<Integer> durabilityConfig, Supplier<Boolean> enabledDamageConfig)
     
    AbstractHatItem(String name, net.minecraft.world.item.Item.Properties properties, Supplier<Integer> durabilityConfig, Supplier<Boolean> enabledDamageConfig)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addEffect(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect, int duration, int amplifier)
     
    protected void
    addEffect(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect, int duration, int amplifier, boolean showParticles)
     
    void
    appendHoverText(@NotNull net.minecraft.world.item.ItemStack stack, @NotNull net.minecraft.world.item.Item.TooltipContext context, @NotNull net.minecraft.world.item.component.TooltipDisplay display, @NotNull Consumer<net.minecraft.network.chat.Component> tooltip, @NotNull net.minecraft.world.item.TooltipFlag flagIn)
    Adds "When on head" line to end of tooltip.
    protected static net.minecraft.world.item.component.TooltipDisplay
     
    protected void
    damageHatItemByOne(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity entity)
    Copy of ItemStack.hurtAndBreak(int, ServerLevel, ServerPlayer, Consumer) to enable own damaging of hat items.
    int
     
    int
    getMaxDamage(net.minecraft.world.item.ItemStack stack)
     
    protected boolean
    isEffectCausedByOtherSource(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect, int maxDuration, int amplifier)
     
    protected void
    removeEffect(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect, int maxDuration, int amplifier)
    This is a helper method to remove an effect of a living entity with a maximal duration and a specific amplifier.

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

    asItem, builtInRegistryHolder, byBlock, byId, canDestroyBlock, canFitInsideContainerItems, components, finishUsingItem, getAttackDamageBonus, getBarColor, getBarWidth, getCraftingRemainder, getDefaultInstance, getDefaultMaxStackSize, getDescriptionId, getDestroySpeed, getId, getItemDamageSource, getName, getPlayerPOVHitResult, getRenderPropertiesInternal, getTooltipImage, getUseAnimation, getUseDuration, hurtEnemy, initializeClient, interactLivingEntity, inventoryTick, isBarVisible, isCorrectToolForDrops, isFoil, mineBlock, onCraftedBy, onCraftedPostProcess, onDestroyed, onUseTick, overrideOtherStackedOnMe, overrideStackedOnOther, postHurtEnemy, releaseUsing, requiredFeatures, shouldPrintOpWarning, toString, use, useOn, useOnRelease

    Methods inherited from class 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.minecraftforge.common.extensions.IForgeItem

    canApplyAtEnchantingTable, canContinueUsing, canElytraFly, canEquip, canGrindstoneRepair, canPerformAction, canWalkOnPowderedSnow, createEntity, damageItem, doesSneakBypassUse, elytraFlightTick, getBurnTime, getCapabilityProvider, getCraftingRemainder, getCreatorModId, getDefaultTooltipHideFlags, getEntityLifespan, getEquipmentSlot, getHighlightTip, getSweepHitBox, hasCustomEntity, inventoryTick, isBookEnchantable, isMonsterDisguise, isNotReplaceableByPickAction, isPiglinCurrency, makesPiglinsNeutral, onBlockStartBreak, onDestroyed, onDroppedByPlayer, onEntityItemUpdate, onEntitySwing, onHorseArmorTick, onItemUseFirst, onLeftClickEntity, onStopUsing, shouldCauseBlockBreakReset, shouldCauseReequipAnimation
  • Field Details

    • enabledDamageConfig

      protected final Supplier<Boolean> enabledDamageConfig
  • Constructor Details

    • AbstractHatItem

      public AbstractHatItem(String name, net.minecraft.world.item.equipment.ArmorMaterial material, Supplier<Integer> durabilityConfig, Supplier<Boolean> enabledDamageConfig)
    • AbstractHatItem

      public AbstractHatItem(String name, net.minecraft.world.item.Item.Properties properties, Supplier<Integer> durabilityConfig, Supplier<Boolean> enabledDamageConfig)
  • Method Details

    • getDurabilityFromConfig

      public int getDurabilityFromConfig()
    • createTooltipDisplay

      protected static net.minecraft.world.item.component.TooltipDisplay createTooltipDisplay()
    • isEffectCausedByOtherSource

      protected boolean isEffectCausedByOtherSource(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect, int maxDuration, int amplifier)
    • addEffect

      protected void addEffect(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect, int duration, int amplifier)
    • addEffect

      protected void addEffect(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect, int duration, int amplifier, boolean showParticles)
    • removeEffect

      protected void removeEffect(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect, int maxDuration, int amplifier)
      This is a helper method to remove an effect of a living entity with a maximal duration and a specific amplifier.
      Parameters:
      entity - entity
      effect - effect object
      maxDuration - maximal effect duration
      amplifier - effect amplifier
    • damageHatItemByOne

      protected void damageHatItemByOne(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity entity)
      Copy of ItemStack.hurtAndBreak(int, ServerLevel, ServerPlayer, Consumer) to enable own damaging of hat items. Added config value to disable damage.
    • appendHoverText

      public void appendHoverText(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, @NotNull @NotNull net.minecraft.world.item.Item.TooltipContext context, @NotNull @NotNull net.minecraft.world.item.component.TooltipDisplay display, @NotNull @NotNull Consumer<net.minecraft.network.chat.Component> tooltip, @NotNull @NotNull net.minecraft.world.item.TooltipFlag flagIn)
      Adds "When on head" line to end of tooltip. When hat item has no effect, override this method with an empty method.
      Overrides:
      appendHoverText in class net.minecraft.world.item.Item
    • getMaxDamage

      public int getMaxDamage(net.minecraft.world.item.ItemStack stack)