Class ChemicalContainingItem

java.lang.Object
net.minecraft.world.item.Item
ml.pluto7073.chemicals.item.ChemicalContainingItem
All Implemented Interfaces:
net.fabricmc.fabric.api.item.v1.FabricItem, net.minecraft.world.flag.FeatureElement, net.minecraft.world.level.ItemLike

public abstract class ChemicalContainingItem extends net.minecraft.world.item.Item
An abstract class for items that can contain a variable amount of any chemical in a stack. When an item that inherits ChemicalContainingItem is finished using by a player and the UseAnim of the item is UseAnim.DRINK or UseAnim.EAT, any chemicals in the item will be added to the player

Note: This class is intended for items that have a variable amount of chemicals. For Items that will always have the same amount of chemicals, use ChemicalHolderBuilder.addChemical(ResourceLocation, float)

  • Nested Class Summary

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

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

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

    BASE_ATTACK_DAMAGE_UUID, BASE_ATTACK_SPEED_UUID, BY_BLOCK, 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
    ChemicalContainingItem(net.minecraft.world.item.Item.Properties settings)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    appendHoverText(net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.world.level.Level world, List<net.minecraft.network.chat.Component> tooltip, net.minecraft.world.item.TooltipFlag context)
     
    abstract float
    getChemicalContent(net.minecraft.resources.ResourceLocation id, net.minecraft.world.item.ItemStack stack)
    Obtains the amount of a specific chemical stored in a stack

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

    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, getTooltipImage, getUseAnimation, getUseDuration, hasCraftingRemainingItem, hurtEnemy, interactLivingEntity, inventoryTick, isBarVisible, isComplex, isCorrectToolForDrops, isEdible, isEnchantable, isFireResistant, isFoil, isValidRepairItem, mineBlock, onCraftedBy, onDestroyed, onUseTick, overrideOtherStackedOnMe, overrideStackedOnOther, releaseUsing, requiredFeatures, shouldOverrideMultiplayerNbt, toString, use, 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.fabricmc.fabric.api.item.v1.FabricItem

    allowContinuingBlockBreaking, allowNbtUpdateAnimation, getAttributeModifiers, getRecipeRemainder, isSuitableFor

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

    isEnabled
  • Constructor Details

    • ChemicalContainingItem

      protected ChemicalContainingItem(net.minecraft.world.item.Item.Properties settings)
  • Method Details

    • getChemicalContent

      public abstract float getChemicalContent(net.minecraft.resources.ResourceLocation id, net.minecraft.world.item.ItemStack stack)
      Obtains the amount of a specific chemical stored in a stack
      Parameters:
      id - The ID representing the chemical
      stack - The itemStack
      Returns:
      Amount of the desired chemical stored in the stack
    • appendHoverText

      public void appendHoverText(net.minecraft.world.item.ItemStack stack, @Nullable @Nullable net.minecraft.world.level.Level world, List<net.minecraft.network.chat.Component> tooltip, net.minecraft.world.item.TooltipFlag context)
      Overrides:
      appendHoverText in class net.minecraft.world.item.Item