#How do I hide unbreakable text (or any other flags)? [SOLVED]

45 messages · Page 1 of 1 (latest)

strange sparrow
#

I have an item with setting.component(DataComponentTypes.UNBREAKABLE, Unit.INSTANCE)
How do I hide the "Unbreakable" text on item tooltip, similar to [minecraft:unbreakable={show_in_tooltip:false}]?

hushed mauve
#

you need to also pass a TooltipDisplayComponent

#

in command form that is [minecraft:unbreakable={}, minecraft:tooltip_display={hidden_components:["minecraft:unbreakable"]}]*

strange sparrow
#

how you do it in the mod tho?

hushed mauve
#

create (or get) the component and set it

strange sparrow
#

like

#

whats the code for it?

#

im new sorry

hushed mauve
#
SequencedSet<ComponentType<?>> hidden_components = new LinkedHashSet<>();
hidden_components.add(DataComponentTypes.UNBREAKABLE);
TooltipDisplayComponent comp = new TooltipDisplayComponent(false, hidden_components)
itemStack.set(DataComponentTypes.TOOLTIP_DISPLAY, comp);
#

or smth like that

strange sparrow
#

uhmm

#

wait hold on

#

idk where to put it in

#

can you put it in for me instead?

hushed mauve
#

you need to add it just like how you are currently adding the unbreakable comp

strange sparrow
#

uhh sorry i dont get it

hushed mauve
#

the first three lines I sent are statements and cannot be used as expressions

#

the final line that calls set should be replaced with the component method

strange sparrow
#

alr the final line is in the correct place now

#

but where should the first three lines be?

hushed mauve
#

create a static block to put them in

strange sparrow
#

what should it be called?

hushed mauve
#

you cannot name static blocks

strange sparrow
#

sorry im pretty new to java in general

#

idk wheres the problem

hushed mauve
#

the public and void is the problem

strange sparrow
#

so it is private?

hushed mauve
#

no, its only static

strange sparrow
#

umm

#

im a noob please forgive me

hushed mauve
#

You'll* need to move your definition for your item into the block

#

so

static {
  ITEM = ...;
}

public static final Item ITEM;
strange sparrow
#

like this?

        SWORD_OF_THE_UNIVERSE = registerItem("sword_of_the_universe", setting -> new Item(setting
        .sword(ToolMaterial.GOLD, 3.0F, -2.4F)
        .fireproof()
        .rarity(Rarity.EPIC)
        .component(DataComponentTypes.UNBREAKABLE, Unit.INSTANCE)
        .component(DataComponentTypes.TOOLTIP_DISPLAY, comp)
    ) {
        @Override
        public void appendTooltip(ItemStack stack, Item.TooltipContext context, TooltipDisplayComponent displayComponent, Consumer<Text> textConsumer, TooltipType type) {
...
    });
        SequencedSet<ComponentType<?>> hidden_components = new LinkedHashSet<>();
        hidden_components.add(DataComponentTypes.UNBREAKABLE);
        TooltipDisplayComponent comp = new TooltipDisplayComponent(false, hidden_components);
    }

    public static final Item SWORD_OF_THE_UNIVERSE;```
#

it still has a red line under static

#

can you just write the code for me please?

hushed mauve
strange sparrow
#

oh nvm vscode just has some weird bugs

#

I restarted and it worked

#

ty for your help

#

How do I hide unbreakable text (or any other flags)? [SOLVED]

#

and it works for every other components than unbreakable right?