/** Handles all the checks and delegate methods for the capability. */ public static class Provider implements ICapabilitySerializable<NBTTagCompound> { ICustomData instance = CUSTOM_DATA.getDefaultInstance(); @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { return capability == CUSTOM_DATA; } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { return this.hasCapability(capability, facing) ? CUSTOM_DATA.<T>cast(this.instance) : null; } @Override public NBTTagCompound serializeNBT() { return (NBTTagCompound) CUSTOM_DATA.getStorage().writeNBT(CUSTOM_DATA, this.instance, null); } @Override public void deserializeNBT(NBTTagCompound nbt) { CUSTOM_DATA.getStorage().readNBT(CUSTOM_DATA, this.instance, null, nbt); } }
@Override public void deserializeNBT(NBTTagCompound nbt) { CUSTOM_DATA.getStorage().readNBT(CUSTOM_DATA, this.instance, null, nbt); }
@Override public NBTTagCompound serializeNBT() { return (NBTTagCompound) CUSTOM_DATA.getStorage().writeNBT(CUSTOM_DATA, this.instance, null); }
@Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { return this.hasCapability(capability, facing) ? CUSTOM_DATA.<T>cast(this.instance) : null; }