コード例 #1
0
  /** 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);
    }
  }
コード例 #2
0
    @Override
    public void deserializeNBT(NBTTagCompound nbt) {

      CUSTOM_DATA.getStorage().readNBT(CUSTOM_DATA, this.instance, null, nbt);
    }
コード例 #3
0
    @Override
    public NBTTagCompound serializeNBT() {

      return (NBTTagCompound) CUSTOM_DATA.getStorage().writeNBT(CUSTOM_DATA, this.instance, null);
    }
コード例 #4
0
    @Override
    public <T> T getCapability(Capability<T> capability, EnumFacing facing) {

      return this.hasCapability(capability, facing) ? CUSTOM_DATA.<T>cast(this.instance) : null;
    }