コード例 #1
0
  @Override
  public void increaseCharge(ItemStack stack) {

    if (NBTHelper.getShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY) < maxChargeLevel) {
      NBTHelper.setShort(
          stack,
          Strings.NBT_ITEM_CHARGE_LEVEL_KEY,
          (short) (NBTHelper.getShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY) + 1));
    }
  }
コード例 #2
0
  @Override
  public void decreaseCharge(ItemStack stack) {

    if (NBTHelper.getShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY) > 0) {
      NBTHelper.setShort(
          stack,
          Strings.NBT_ITEM_CHARGE_LEVEL_KEY,
          (short) (NBTHelper.getShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY) - 1));
    }
  }
コード例 #3
0
  @Override
  public short getCharge(ItemStack stack) {

    return NBTHelper.getShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY);
  }