#How do I hide unbreakable text (or any other flags)? [SOLVED]
45 messages · Page 1 of 1 (latest)
you need to also pass a TooltipDisplayComponent
in command form that is [minecraft:unbreakable={}, minecraft:tooltip_display={hidden_components:["minecraft:unbreakable"]}]*
how you do it in the mod tho?
create (or get) the component and set it
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
uhmm
wait hold on
idk where to put it in
can you put it in for me instead?
you need to add it just like how you are currently adding the unbreakable comp
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
alr the final line is in the correct place now
but where should the first three lines be?
create a static block to put them in
what should it be called?
you cannot name static blocks
the public and void is the problem
so it is private?
no, its only static
You'll* need to move your definition for your item into the block
so
static {
ITEM = ...;
}
public static final Item ITEM;
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?
what is the error