Like this?
public class NoseProvider implements ICapabilitySerializable<INBT> {
public static final ResourceLocation IDENTIFIER = new ResourceLocation(MODID, "capability_nose");
@CapabilityInject(INose.class)
public static Capability<INose> NOSE_CAP = null;
private INose instance = NOSE_CAP.getDefaultInstance();
private final LazyOptional<INose> holder = LazyOptional.of(() -> instance);
@Override
public INBT serializeNBT() {
VillagersNose.LOGGER.info("Serializing NBT...");
return NOSE_CAP.getStorage().writeNBT(NOSE_CAP, instance, null);
}
@Override
public void deserializeNBT(INBT nbt) {
VillagersNose.LOGGER.info("Deserializing NBT...");
NOSE_CAP.getStorage().readNBT(NOSE_CAP, instance, null, nbt);
}
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
return NOSE_CAP.orEmpty(cap, holder);
}
}