Class 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
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.SettingsNested classes/interfaces inherited from interface dev.jaxydog.astral.register.Registered
Registered.All, Registered.Client, Registered.Common, Registered.Generated, Registered.Server -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe NBT key that determines whether a mirror item is considered broken.static final net.minecraft.util.IdentifierThe 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_STEPSFields inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
FEATURE_ENABLED_REGISTRY_KEYS -
Constructor Summary
ConstructorsConstructorDescriptionMirrorItem(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 TypeMethodDescriptionprotected floatgetBrokenModelData(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.ItemStackbooleanisBroken(net.minecraft.item.ItemStack stack) Returns whether the given item stack is considered broken.voidRegisters this value on the client environment.voidsetBroken(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, getRegistryPathMethods 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, useOnEntityMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.jaxydog.astral.content.item.Custom
registerCommonMethods inherited from interface net.fabricmc.fabric.api.item.v1.FabricItem
allowContinuingBlockBreaking, allowNbtUpdateAnimation, getAttributeModifiers, getRecipeRemainder, isSuitableForMethods inherited from interface net.minecraft.item.ItemConvertible
asItemMethods inherited from interface dev.jaxydog.astral.content.item.LoreHolder
formatLoreText, getLoreTooltipsMethods inherited from interface dev.jaxydog.astral.register.Registered
getRegistryId, getRegistryPathMethods inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
isEnabled
-
Field Details
-
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_IDThe 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
preferredGroupsupplier isnull, 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
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,
falseis 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 return0F(or any other value expected by its model).The default behavior is to always return either
1For0F.- 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:
getDefaultStackin classnet.minecraft.item.Item
-
registerClient
public void registerClient()Description copied from interface:Registered.ClientRegisters 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:
registerClientin interfaceRegistered.Client- See Also:
-