コード例 #1
0
ファイル: Upgrade.java プロジェクト: kenlefeb/Mekanism
  public static NBTTagCompound getTagFor(Upgrade upgrade, int amount) {
    NBTTagCompound compound = new NBTTagCompound();

    compound.setInteger("type", upgrade.ordinal());
    compound.setInteger("amount", amount);

    return compound;
  }
コード例 #2
0
ファイル: Upgrade.java プロジェクト: kenlefeb/Mekanism
  public static Map<Upgrade, Integer> buildMap(NBTTagCompound nbtTags) {
    Map<Upgrade, Integer> upgrades = new HashMap<Upgrade, Integer>();

    if (nbtTags != null) {
      if (nbtTags.hasKey("upgrades")) {
        NBTTagList list = nbtTags.getTagList("upgrades", NBT.TAG_COMPOUND);

        for (int tagCount = 0; tagCount < list.tagCount(); tagCount++) {
          NBTTagCompound compound = list.getCompoundTagAt(tagCount);

          Upgrade upgrade = Upgrade.values()[compound.getInteger("type")];
          upgrades.put(upgrade, compound.getInteger("amount"));
        }
      } else if (nbtTags.hasKey("energyMultiplier")
          && nbtTags.hasKey("speedMultiplier")) // TODO remove soon
      {
        upgrades.put(Upgrade.ENERGY, nbtTags.getInteger("energyMultiplier"));
        upgrades.put(Upgrade.SPEED, nbtTags.getInteger("speedMultiplier"));
      }
    }

    return upgrades;
  }