Skip to content

Commit

Permalink
Update invite item names
Browse files Browse the repository at this point in the history
  • Loading branch information
Gegy committed Oct 27, 2023
1 parent fd36374 commit ca364c9
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/main/java/com/lovetropics/extras/item/InviteItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Optional;

public class InviteItem extends Item {
public static final List<ImageData> PRESETS = List.of(
new ImageData(
Optional.of(Component.literal("1").withStyle(ChatFormatting.DARK_PURPLE)),
Optional.of(Component.literal("... ")
.append(Component.literal("1").withStyle(s -> s.withColor(ChatFormatting.DARK_PURPLE).withObfuscated(false)))
.append(" ...").withStyle(ChatFormatting.OBFUSCATED)
),
new ResourceLocation(LTExtras.MODID, "textures/images/ccfucc_invite_1.png"),
371,
292,
Expand All @@ -33,7 +33,10 @@ public class InviteItem extends Item {
)
),
new ImageData(
Optional.of(Component.literal("2").withStyle(ChatFormatting.DARK_PURPLE)),
Optional.of(Component.literal("... ")
.append(Component.literal("2").withStyle(s -> s.withColor(ChatFormatting.DARK_PURPLE).withObfuscated(false)))
.append(" ...").withStyle(ChatFormatting.OBFUSCATED)
),
new ResourceLocation(LTExtras.MODID, "textures/images/ccfucc_invite_2.png"),
371,
292,
Expand All @@ -56,12 +59,10 @@ public InviteItem(final Properties properties) {

@Override
public Component getName(final ItemStack stack) {
final Optional<Component> name = ImageData.get(stack).flatMap(ImageData::name);
if (name.isPresent()) {
return name.get();
}
return super.getName(stack).copy().withStyle(ChatFormatting.OBFUSCATED);
}

@Override
public void appendHoverText(final ItemStack stack, @Nullable final Level level, final List<Component> lines, final TooltipFlag flag) {
super.appendHoverText(stack, level, lines, flag);
ImageData.get(stack).flatMap(ImageData::name).ifPresent(lines::add);
}
}

0 comments on commit ca364c9

Please sign in to comment.