Class MirrorItem

java.lang.Object
net.minecraft.item.Item
dev.jaxydog.astral.content.item.AstralItem
dev.jaxydog.astral.content.item.custom.MirrorItem
All Implemented Interfaces:
Custom, LoreHolder, Registered, Registered.Client, Registered.Common, net.fabricmc.fabric.api.item.v1.FabricItem, net.minecraft.item.ItemConvertible, net.minecraft.resource.featuretoggle.ToggleableFeature

public class MirrorItem extends AstralItem implements Registered.Client
Implements a simple breakable mirror item.

By default, unless overridden, all stacks start out as being unbroken.

A mirror item's state can be controlled via the "Broken" boolean NBT key.

Since:
1.0.0
  • Nested Class Summary

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

    net.minecraft.item.Item.Settings

    Nested classes/interfaces inherited from interface dev.jaxydog.astral.register.Registered

    Registered.All, Registered.Client, Registered.Common, Registered.Generated, Registered.Server
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The NBT key that determines whether a mirror item is considered broken.
    static final net.minecraft.util.Identifier
    The identifier corresponding to the mirror item's broken model.

    Fields inherited from class net.minecraft.item.Item

    ATTACK_DAMAGE_MODIFIER_ID, ATTACK_SPEED_MODIFIER_ID, BLOCK_ITEMS, DEFAULT_MAX_COUNT, DEFAULT_MAX_USE_TIME, ITEM_BAR_STEPS

    Fields inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature

    FEATURE_ENABLED_REGISTRY_KEYS
  • Constructor Summary

    Constructors
    Constructor
    Description
    MirrorItem(String path, net.minecraft.item.Item.Settings settings)
    Creates a new mirror item using the given settings.
    MirrorItem(String path, net.minecraft.item.Item.Settings settings, @Nullable Supplier<net.minecraft.registry.RegistryKey<net.minecraft.item.ItemGroup>> preferredGroup)
    Creates a new item using the given settings.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected float
    getBrokenModelData(net.minecraft.item.ItemStack stack, net.minecraft.world.World world, net.minecraft.entity.LivingEntity entity, int seed)
    Returns the data used in the mirror's item model that determines the texture to use.
    net.minecraft.item.ItemStack
     
    boolean
    isBroken(net.minecraft.item.ItemStack stack)
    Returns whether the given item stack is considered broken.
    void
    Registers this value on the client environment.
    void
    setBroken(net.minecraft.item.ItemStack stack, boolean broken)
    Sets whether the given item stack is considered broken.

    Methods inherited from class dev.jaxydog.astral.content.item.AstralItem

    appendTooltip, getItemGroup, getRegistryPath

    Methods inherited from class net.minecraft.item.Item

    asItem, byRawId, canBeNested, canMine, canRepair, damage, finishUsing, fromBlock, getAttributeModifiers, getDrinkSound, getEatSound, getEnchantability, getFoodComponent, getItemBarColor, getItemBarStep, getMaxCount, getMaxDamage, getMaxUseTime, getMiningSpeedMultiplier, getName, getName, getOrCreateTranslationKey, getRarity, getRawId, getRecipeRemainder, getRegistryEntry, getRequiredFeatures, getTooltipData, getTranslationKey, getTranslationKey, getUseAction, hasGlint, hasRecipeRemainder, inventoryTick, isDamageable, isEnchantable, isFireproof, isFood, isItemBarVisible, isNbtSynced, isNetworkSynced, isSuitableFor, isUsedOnRelease, onClicked, onCraft, onItemEntityDestroyed, onStackClicked, onStoppedUsing, postHit, postMine, postProcessNbt, raycast, toString, usageTick, use, useOnBlock, useOnEntity

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface dev.jaxydog.astral.content.item.Custom

    registerCommon

    Methods inherited from interface net.fabricmc.fabric.api.item.v1.FabricItem

    allowContinuingBlockBreaking, allowNbtUpdateAnimation, getAttributeModifiers, getRecipeRemainder, isSuitableFor

    Methods inherited from interface net.minecraft.item.ItemConvertible

    asItem

    Methods inherited from interface dev.jaxydog.astral.content.item.LoreHolder

    formatLoreText, getLoreTooltips

    Methods inherited from interface dev.jaxydog.astral.register.Registered

    getRegistryId, getRegistryPath

    Methods inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature

    isEnabled
  • Field Details

    • BROKEN_KEY

      public static final String BROKEN_KEY
      The NBT key that determines whether a mirror item is considered broken.

      The value assigned to this is expected to be boolean-coercible.

      Since:
      1.0.0
      See Also:
    • BROKEN_MODEL_ID

      public static final net.minecraft.util.Identifier BROKEN_MODEL_ID
      The identifier corresponding to the mirror item's broken model.

      This is expected to be used solely within the ModelPredicateProviderRegistry.

      Since:
      2.0.0
  • Constructor Details

    • MirrorItem

      public MirrorItem(String path, net.minecraft.item.Item.Settings settings, @Nullable @Nullable Supplier<net.minecraft.registry.RegistryKey<net.minecraft.item.ItemGroup>> preferredGroup)
      Creates a new item using the given settings.

      If the preferredGroup supplier is null, this item will not be added to any item groups.

      Parameters:
      path - The item's identifier path.
      settings - The item's settings.
      preferredGroup - The item's preferred item group.
      Since:
      2.0.0
    • MirrorItem

      public MirrorItem(String path, net.minecraft.item.Item.Settings settings)
      Creates a new mirror item using the given settings.

      This item will be added to the default item group.

      Parameters:
      path - The item's identifier path.
      settings - The item's settings.
      Since:
      1.0.0
  • Method Details

    • isBroken

      public boolean isBroken(net.minecraft.item.ItemStack stack)
      Returns whether the given item stack is considered broken.

      If the NBT key is missing, or present but not boolean-coercible, false is always returned.

      Parameters:
      stack - The item stack.
      Returns:
      If the mirror is broken.
      Since:
      1.0.0
    • setBroken

      public void setBroken(net.minecraft.item.ItemStack stack, boolean broken)
      Sets whether the given item stack is considered broken.
      Parameters:
      stack - The item stack.
      broken - Whether the mirror is broken.
      Since:
      1.0.0
    • getBrokenModelData

      protected float getBrokenModelData(net.minecraft.item.ItemStack stack, net.minecraft.world.World world, net.minecraft.entity.LivingEntity entity, int seed)
      Returns the data used in the mirror's item model that determines the texture to use.

      If the stack represents a broken mirror, this method should return 1F. Otherwise, if the stack represents a non-broken mirror, this method should return 0F (or any other value expected by its model).

      The default behavior is to always return either 1F or 0F.

      Parameters:
      stack - The item stack.
      world - The world instance.
      entity - The entity holding the mirror.
      seed - The randomness seed.
      Returns:
      The data used to determine the mirror's texture.
      Since:
      2.0.0
    • getDefaultStack

      public net.minecraft.item.ItemStack getDefaultStack()
      Overrides:
      getDefaultStack in class net.minecraft.item.Item
    • registerClient

      public void registerClient()
      Description copied from interface: Registered.Client
      Registers this value on the client environment.

      The contained code will only ever run on the game client. If you only want the server or want both, see its sister interfaces.

      Specified by:
      registerClient in interface Registered.Client
      See Also: