use of net.silentchaos512.gems.item.ItemToolSoul in project SilentGems by SilentChaos512.
the class RecipeApplyToolSoul method getCraftingResult.
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
ItemStack tool = StackHelper.empty();
ItemStack soul = StackHelper.empty();
for (int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack stack = inv.getStackInSlot(i);
// Found a tool or armor piece?
if (stack.getItem() instanceof ITool || stack.getItem() instanceof IArmor) {
if (StackHelper.isValid(tool)) {
return StackHelper.empty();
}
tool = stack;
} else // Found a soul?
if (stack.getItem() instanceof ItemToolSoul) {
if (StackHelper.isValid(soul)) {
return StackHelper.empty();
}
soul = stack;
}
}
if (StackHelper.isEmpty(tool) || StackHelper.isEmpty(soul)) {
return StackHelper.empty();
}
// Does tool already have a soul?
if (SoulManager.getSoul(tool) != null) {
return StackHelper.empty();
}
// Is the soul valid?
ToolSoul toolSoul = ModItems.toolSoul.getSoul(soul);
if (toolSoul == null) {
return StackHelper.empty();
}
ItemStack result = StackHelper.safeCopy(tool);
// Have to change UUID to prevent soul duping.
// result.getTagCompound().removeTag(ToolHelper.NBT_UUID);
SoulManager.setSoul(result, toolSoul, true);
// Apply name, if applicable.
if (soul.hasDisplayName()) {
String name = soul.getDisplayName();
toolSoul.setName(name);
result.setStackDisplayName(name);
}
// Recalculate stats and return.
ToolHelper.recalculateStats(result);
return result;
}
use of net.silentchaos512.gems.item.ItemToolSoul in project SilentGems by SilentChaos512.
the class ToolSoul method addInformation.
public void addInformation(ItemStack stack, World world, List<String> list, boolean advanced) {
LocalizationHelper loc = SilentGems.localizationHelper;
String color;
// Level, XP, AP
color = "" + TextFormatting.GREEN;
list.add(color + loc.getMiscText("ToolSoul.level", level, xp, getXpToNextLevel()));
list.add(color + loc.getMiscText("ToolSoul.actionPoints", actionPoints, getMaxActionPoints()));
boolean skillsKeyDown = Keyboard.isKeyDown(Keyboard.KEY_S);
if (skillsKeyDown || stack.getItem() instanceof ItemToolSoul) {
// Display elements.
String e1 = element1 == null ? "None" : element1.getDisplayName();
String e2 = element2 == null ? "None" : element2.getDisplayName();
String elements = e1 + (e2.equalsIgnoreCase("none") ? "" : ", " + e2);
list.add(loc.getMiscText("ToolSoul.elements", elements));
}
if (skillsKeyDown) {
// Display stat modifiers.
color = " " + TextFormatting.YELLOW;
float durability = getDurabilityModifierForDisplay(this);
float harvestSpeed = getHarvestSpeedModifierForDisplay(this);
float meleeDamage = getMeleeDamageModifierForDisplay(this);
float magicDamage = getMagicDamageModifierForDisplay(this);
float protection = getProtectionModifierForDisplay(this);
if (durability != 0f)
list.add(color + TooltipHelper.getAsColoredPercentage("Durability", durability, 0, true));
if (harvestSpeed != 0f)
list.add(color + TooltipHelper.getAsColoredPercentage("HarvestSpeed", harvestSpeed, 0, true));
if (meleeDamage != 0f)
list.add(color + TooltipHelper.getAsColoredPercentage("MeleeDamage", meleeDamage, 0, true));
if (magicDamage != 0f)
list.add(color + TooltipHelper.getAsColoredPercentage("MagicDamage", magicDamage, 0, true));
if (protection != 0f)
list.add(color + TooltipHelper.getAsColoredPercentage("Protection", protection, 0, true));
// Display skills.
for (Entry<SoulSkill, Integer> entry : skills.entrySet()) {
SoulSkill skill = entry.getKey();
int level = entry.getValue();
list.add(" " + skill.getLocalizedName(stack, level));
}
} else {
list.add(TextFormatting.GOLD + loc.getMiscText("Tooltip.keyForSkills"));
}
}
Aggregations