2023-11-28 16:26:55 +01:00
|
|
|
package com.minelittlepony.unicopia.diet;
|
|
|
|
|
2023-12-03 03:39:55 +01:00
|
|
|
import com.minelittlepony.unicopia.diet.affliction.Affliction;
|
2023-11-28 16:26:55 +01:00
|
|
|
import com.mojang.serialization.Codec;
|
|
|
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
|
|
|
|
|
|
import net.minecraft.network.PacketByteBuf;
|
|
|
|
|
2023-12-03 03:39:55 +01:00
|
|
|
public record Ailment(Affliction effects) {
|
|
|
|
public static final Ailment EMPTY = new Ailment(Affliction.EMPTY);
|
2023-11-28 16:26:55 +01:00
|
|
|
public static final Codec<Ailment> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
|
|
|
Affliction.CODEC.fieldOf("effects").forGetter(Ailment::effects)
|
|
|
|
).apply(instance, Ailment::new));
|
|
|
|
|
|
|
|
public Ailment(PacketByteBuf buffer) {
|
2023-12-03 03:39:55 +01:00
|
|
|
this(Affliction.read(buffer));
|
2023-11-28 16:26:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void toBuffer(PacketByteBuf buffer) {
|
|
|
|
Affliction.write(buffer, effects);
|
|
|
|
}
|
|
|
|
}
|