Unicopia/src/main/java/com/minelittlepony/unicopia/diet/FoodGroup.java

47 lines
1.6 KiB
Java
Raw Normal View History

package com.minelittlepony.unicopia.diet;
import java.util.List;
import java.util.Optional;
import com.mojang.serialization.Codec;
2024-09-28 23:27:46 +02:00
import net.minecraft.component.type.FoodComponent;
import net.minecraft.item.ItemStack;
2024-09-28 23:27:46 +02:00
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
public record FoodGroup(
Identifier id,
FoodGroupEffects attributes) implements Effect {
2024-09-28 23:27:46 +02:00
public static final Codec<FoodGroupEffects> EFFECTS_CODEC = FoodGroupEffects.createCodec(FoodGroupKey.TAG_CODEC);
public static final PacketCodec<RegistryByteBuf, FoodGroup> PACKET_CODEC = PacketCodec.tuple(
Identifier.PACKET_CODEC, FoodGroup::id,
FoodGroupEffects.createPacketCodec(FoodGroupKey.TAG_PACKET_CODEC), FoodGroup::attributes,
FoodGroup::new
);
@Override
public List<FoodGroupKey> tags() {
return attributes.tags();
}
@Override
public Optional<FoodComponent> foodComponent() {
return attributes.foodComponent();
}
@Override
public Ailment ailment() {
return attributes.ailment();
}
@Override
2024-09-28 23:27:46 +02:00
public void appendTooltip(ItemStack stack, List<Text> tooltip, TooltipType context) {
tooltip.add(Text.literal(" ").append(Text.translatable(Util.createTranslationKey("food_group", id()))).formatted(Formatting.GRAY));
Effect.super.appendTooltip(stack, tooltip, context);
}
}