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

23 lines
770 B
Java
Raw Normal View History

2023-11-28 16:26:55 +01:00
package com.minelittlepony.unicopia.diet;
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;
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) {
this(Affliction.read(buffer));
2023-11-28 16:26:55 +01:00
}
public void toBuffer(PacketByteBuf buffer) {
Affliction.write(buffer, effects);
}
}