2024-04-02 09:30:42 +02:00
|
|
|
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;
|
2024-04-02 09:30:42 +02:00
|
|
|
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;
|
2024-04-02 09:30:42 +02:00
|
|
|
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,
|
2024-04-04 21:22:10 +02:00
|
|
|
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
|
|
|
|
);
|
2024-04-02 09:30:42 +02:00
|
|
|
|
2024-04-04 21:22:10 +02:00
|
|
|
@Override
|
|
|
|
public List<FoodGroupKey> tags() {
|
|
|
|
return attributes.tags();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Optional<FoodComponent> foodComponent() {
|
|
|
|
return attributes.foodComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Ailment ailment() {
|
|
|
|
return attributes.ailment();
|
|
|
|
}
|
2024-04-02 09:30:42 +02:00
|
|
|
@Override
|
2024-09-28 23:27:46 +02:00
|
|
|
public void appendTooltip(ItemStack stack, List<Text> tooltip, TooltipType context) {
|
2024-04-02 09:30:42 +02:00
|
|
|
tooltip.add(Text.literal(" ").append(Text.translatable(Util.createTranslationKey("food_group", id()))).formatted(Formatting.GRAY));
|
|
|
|
Effect.super.appendTooltip(stack, tooltip, context);
|
|
|
|
}
|
|
|
|
}
|