use of minechem.item.augment.augments.IAugment in project Minechem by iopleke.
the class AugmentedItem method getAugments.
@Override
public Map<IAugment, Integer> getAugments(ItemStack stack) {
Map<IAugment, Integer> result = new HashMap<IAugment, Integer>();
if (stack.hasTagCompound() && stack.getTagCompound().hasKey(augmentList, Compendium.NBTTags.tagList)) {
NBTTagList augments = stack.getTagCompound().getTagList(augmentList, Compendium.NBTTags.tagString);
for (int i = 0; i < augments.tagCount(); i++) {
String key = augments.getStringTagAt(i);
result.put(AugmentRegistry.getAugment(key), (int) stack.getTagCompound().getCompoundTag(key).getByte(level));
}
}
return result;
}
use of minechem.item.augment.augments.IAugment in project Minechem by iopleke.
the class AugmentedItem method setAugment.
/**
* Set {@link minechem.item.augment.augments.IAugment} on Item
*
* @param item ItemStack to add augment to
* @param augmentItem Augment to add
*/
@Override
public boolean setAugment(ItemStack item, ItemStack augmentItem) {
IAugment augment = AugmentRegistry.getAugment(augmentItem);
if (augment == null) {
return false;
}
if (!item.hasTagCompound()) {
item.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tagCompound = item.getTagCompound();
String augmentKey = augment.getKey();
if (!tagCompound.hasKey(augmentKey, Compendium.NBTTags.tagCompound)) {
NBTTagList augments = tagCompound.getTagList(augmentList, Compendium.NBTTags.tagString);
augments.appendTag(new NBTTagString(augmentKey));
tagCompound.setTag(augmentList, augments);
NBTTagCompound augmentTag = new NBTTagCompound();
augmentTag.setTag(Compendium.NBTTags.item, augmentItem.writeToNBT(new NBTTagCompound()));
augmentTag.setByte(this.level, (byte) 0);
tagCompound.setTag(augmentKey, augmentTag);
return true;
}
return false;
}
Aggregations