use of com.infinityraider.infinitylib.network.serialization.IMessageReader in project AgriCraft by AgriCraft.
the class MessageTileEntitySeedStorage method getNecessarySerializers.
@Override
protected List<IMessageSerializer> getNecessarySerializers() {
return ImmutableList.of(new IMessageSerializer<IAgriStat>() {
@Override
public boolean accepts(Class<IAgriStat> clazz) {
return IAgriStat.class.isAssignableFrom(clazz);
}
@Override
public IMessageWriter<IAgriStat> getWriter(Class<IAgriStat> clazz) {
return (buf, data) -> {
NBTTagCompound tag = new NBTTagCompound();
data.writeToNBT(tag);
ByteBufUtil.writeNBT(buf, tag);
};
}
@Override
public IMessageReader<IAgriStat> getReader(Class<IAgriStat> clazz) {
return buf -> AgriApi.getStatRegistry().valueOf(ByteBufUtil.readNBT(buf)).get();
}
});
}
Aggregations