Class EnchantedTomeItem

java.lang.Object
net.minecraft.world.item.Item
johnsmith.enchantingoverhauled.item.EnchantedTomeItem
All Implemented Interfaces:
net.fabricmc.fabric.api.item.v1.FabricItem, net.minecraft.world.flag.FeatureElement, net.minecraft.world.level.ItemLike

public class EnchantedTomeItem extends net.minecraft.world.item.Item
A custom item representing an Enchanted Tome.

The Enchanted Tome is a special variant of an enchanted book used to activate DeactivatedEnchantingTableBlocks. Supports dynamic "<Theme> <Item Name> of <School>" attribution and naming.

  • 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

    Nested classes/interfaces inherited from interface net.fabricmc.fabric.api.item.v1.FabricItem

    net.fabricmc.fabric.api.item.v1.FabricItem.Settings
  • Field Summary

    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, 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
    EnchantedTomeItem(net.minecraft.world.item.Item.Properties properties)
    Constructs a new EnchantedTomeItem.
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.world.item.ItemStack
    applyTomeEnchantments(net.minecraft.world.item.ItemStack itemStack, List<net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment>> candidates, net.minecraft.util.RandomSource random)
    Applies the "Tome Logic" to a specific list of candidates.
    static net.minecraft.world.item.ItemStack
    enchantRandomly(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.Level world, net.minecraft.util.RandomSource random)
    Enchants a given Enchanted Tome ItemStack with random, high-level enchantments.
    static net.minecraft.world.item.ItemStack
    enchantRandomly(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.Level world, net.minecraft.util.RandomSource random, net.minecraft.tags.TagKey<net.minecraft.world.item.enchantment.Enchantment> specialTag, net.minecraft.tags.TagKey<net.minecraft.world.item.enchantment.Enchantment> commonTag)
    Enchants a given Enchanted Tome ItemStack using biome-specific trades.
    static net.minecraft.world.item.ItemStack
    enchantWithThemeAndSchool(net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.RegistryAccess registryAccess, net.minecraft.util.RandomSource random, @Nullable net.minecraft.resources.ResourceKey<EnchantmentTheme> themeKey, @Nullable net.minecraft.resources.ResourceKey<MagicSchool> schoolKey)
    Enchants a given Enchanted Tome ItemStack prioritizing enchantments that match the specified EnchantmentTheme and/or MagicSchool.
    @NotNull net.minecraft.network.chat.Component
    getName(@NotNull net.minecraft.world.item.ItemStack stack)
     
    static Optional<net.minecraft.resources.ResourceKey<MagicSchool>>
    getSchool(net.minecraft.world.item.ItemStack stack)
     
    static Optional<net.minecraft.resources.ResourceKey<MagicSchool>>
    getSchool(net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.core.RegistryAccess registryAccess)
    Resolves the dominant MagicSchool of the given Enchanted Tome stack.
    static Optional<net.minecraft.resources.ResourceKey<EnchantmentTheme>>
    getTheme(net.minecraft.world.item.ItemStack stack)
     
    static Optional<net.minecraft.resources.ResourceKey<EnchantmentTheme>>
    getTheme(net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.core.RegistryAccess registryAccess)
    Resolves the dominant EnchantmentTheme of the given Enchanted Tome stack.
    boolean
    isFoil(@NotNull net.minecraft.world.item.ItemStack stack)
     
    static net.minecraft.world.item.ItemStack
    withDefaultEnchantment(net.minecraft.core.RegistryAccess registryAccess)
    A static helper to get a new Enchanted Tome with the default enchantment.

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

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

    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

    allowComponentsUpdateAnimation, allowContinuingBlockBreaking, canBeEnchantedWith, getCreatorNamespace, getRecipeRemainder

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

    isEnabled
  • Constructor Details

    • EnchantedTomeItem

      public EnchantedTomeItem(net.minecraft.world.item.Item.Properties properties)
      Constructs a new EnchantedTomeItem.
      Parameters:
      properties - The item properties (stack size, rarity, etc.).
  • Method Details

    • isFoil

      public boolean isFoil(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Overrides:
      isFoil in class net.minecraft.world.item.Item
    • getName

      @NotNull public @NotNull net.minecraft.network.chat.Component getName(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Overrides:
      getName in class net.minecraft.world.item.Item
    • getTheme

      public static Optional<net.minecraft.resources.ResourceKey<EnchantmentTheme>> getTheme(net.minecraft.world.item.ItemStack stack, @Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess)
      Resolves the dominant EnchantmentTheme of the given Enchanted Tome stack.
    • getTheme

      public static Optional<net.minecraft.resources.ResourceKey<EnchantmentTheme>> getTheme(net.minecraft.world.item.ItemStack stack)
    • getSchool

      public static Optional<net.minecraft.resources.ResourceKey<MagicSchool>> getSchool(net.minecraft.world.item.ItemStack stack, @Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess)
      Resolves the dominant MagicSchool of the given Enchanted Tome stack.
    • getSchool

      public static Optional<net.minecraft.resources.ResourceKey<MagicSchool>> getSchool(net.minecraft.world.item.ItemStack stack)
    • enchantWithThemeAndSchool

      public static net.minecraft.world.item.ItemStack enchantWithThemeAndSchool(net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.RegistryAccess registryAccess, net.minecraft.util.RandomSource random, @Nullable @Nullable net.minecraft.resources.ResourceKey<EnchantmentTheme> themeKey, @Nullable @Nullable net.minecraft.resources.ResourceKey<MagicSchool> schoolKey)
      Enchants a given Enchanted Tome ItemStack prioritizing enchantments that match the specified EnchantmentTheme and/or MagicSchool.

      Follows the Wildcard Rule: if themeKey is common or schoolKey is Aberration, it rolls across all eligible enchantments and adopts the dominant Theme and School of the generated Tome.

    • enchantRandomly

      public static net.minecraft.world.item.ItemStack enchantRandomly(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.Level world, net.minecraft.util.RandomSource random, net.minecraft.tags.TagKey<net.minecraft.world.item.enchantment.Enchantment> specialTag, net.minecraft.tags.TagKey<net.minecraft.world.item.enchantment.Enchantment> commonTag)
      Enchants a given Enchanted Tome ItemStack using biome-specific trades. Prefers enchantments from the SPECIAL tag before falling back to the COMMON tag.
    • enchantRandomly

      public static net.minecraft.world.item.ItemStack enchantRandomly(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.Level world, net.minecraft.util.RandomSource random)
      Enchants a given Enchanted Tome ItemStack with random, high-level enchantments.
    • applyTomeEnchantments

      public static net.minecraft.world.item.ItemStack applyTomeEnchantments(net.minecraft.world.item.ItemStack itemStack, List<net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment>> candidates, net.minecraft.util.RandomSource random)
      Applies the "Tome Logic" to a specific list of candidates.
      Parameters:
      candidates - The list of possible enchantments (as Holders).
    • withDefaultEnchantment

      public static net.minecraft.world.item.ItemStack withDefaultEnchantment(net.minecraft.core.RegistryAccess registryAccess)
      A static helper to get a new Enchanted Tome with the default enchantment.