use of net.silentchaos512.gems.item.tool.ItemGemShield in project SilentGems by SilentChaos512.
the class ToolRenderHelper method addInformation.
@Override
public void addInformation(ItemStack tool, EntityPlayer player, List list, boolean advanced) {
LocalizationHelper loc = SilentGems.instance.localizationHelper;
boolean controlDown = KeyTracker.isControlDown();
boolean altDown = KeyTracker.isAltDown();
boolean shiftDown = KeyTracker.isShiftDown();
String line;
// Tipped upgrade
ToolPartTip partTip = (ToolPartTip) ToolHelper.getConstructionTip(tool);
if (partTip != null) {
String tipName = partTip.getUnlocalizedName().replaceFirst("[^:]+:", "");
tipName = loc.getMiscText("Tooltip." + tipName);
line = loc.getMiscText("Tooltip.Tipped", tipName);
list.add(line);
}
// Show original owner?
if (controlDown) {
String owner = ToolHelper.getOriginalOwner(tool);
if (owner.equals(SilentGems.localizationHelper.getMiscText("Tooltip.OriginalOwner.Creative")))
owner = TextFormatting.LIGHT_PURPLE + owner;
if (!owner.isEmpty())
list.add(loc.getMiscText("Tooltip.OriginalOwner", owner));
else
list.add(loc.getMiscText("Tooltip.OriginalOwner.Unknown"));
}
// Missing data?
if (ToolHelper.hasNoConstruction(tool)) {
list.add(loc.getMiscText("Tooltip.NoData1"));
list.add(loc.getMiscText("Tooltip.NoData2"));
} else // Broken?
if (ToolHelper.isBroken(tool)) {
line = loc.getMiscText("Tooltip.Broken");
list.add(line);
}
final Item item = tool.getItem();
final boolean isSword = item instanceof ItemGemSword;
final boolean isAxe = item instanceof ItemGemAxe;
final boolean isWeapon = isSword || isAxe;
final boolean isCaster = isSword && ToolHelper.getToolTier(tool).ordinal() >= EnumMaterialTier.SUPER.ordinal();
final boolean isBow = item instanceof ItemGemBow;
final boolean isDigger = item instanceof ItemTool;
final boolean isShield = item instanceof ItemGemShield;
final String sep = loc.getMiscText("Tooltip.Separator");
if (controlDown) {
// Properties Header
line = loc.getMiscText("Tooltip.Properties");
list.add(line);
TextFormatting color = TextFormatting.YELLOW;
// Tier
EnumMaterialTier tier = ToolHelper.getToolTier(tool);
line = TextFormatting.RESET + loc.getMiscText("ToolTier." + tier);
list.add(" " + color + loc.getMiscText("ToolTier", line));
int durabilityMax = ToolHelper.getMaxDamage(tool);
int durability = durabilityMax - tool.getItemDamage();
String s1 = String.format(durability > 9999 ? "%,d" : "%d", durability);
String s2 = String.format(durabilityMax > 9999 ? "%,d" : "%d", durabilityMax);
line = loc.getMiscText("Tooltip.Durability", s1 + " / " + s2);
list.add(color + " " + line);
if (isShield)
list.add(color + getTooltipLine("BlockingPower", ToolHelper.getBlockingPower(tool)));
if (isDigger) {
// @formatter:off
int harvestLevel = ToolHelper.getHarvestLevel(tool);
String str = color + getTooltipLine("HarvestLevel", harvestLevel);
String key = "Tooltip.level" + harvestLevel;
String val = SilentGems.localizationHelper.getMiscText(key);
if (!val.equals("misc.silentgems:" + key))
str += " (" + val + ")";
list.add(str);
list.add(color + getTooltipLine("HarvestSpeed", ToolHelper.getDigSpeedOnProperMaterial(tool)));
}
if (isWeapon) {
list.add(color + getTooltipLine("MeleeSpeed", ToolHelper.getMeleeSpeedModifier(tool) + 4).replaceFirst("%", ""));
list.add(color + getTooltipLine("MeleeDamage", ToolHelper.getMeleeDamageModifier(tool)));
if (isCaster)
list.add(color + getTooltipLine("MagicDamage", ToolHelper.getMagicDamageModifier(tool)));
}
if (isBow) {
list.add(color + getTooltipLine("DrawDelay", ModItems.bow.getDrawDelay(tool)));
list.add(color + getTooltipLine("ArrowDamage", 2f + ModItems.bow.getArrowDamage(tool)));
}
list.add(color + getTooltipLine("ChargeSpeed", ToolHelper.getChargeSpeed(tool)));
} else {
list.add(TextFormatting.GOLD + loc.getMiscText("Tooltip.CtrlForProp"));
}
if (altDown) {
// Statistics Header
list.add(sep);
line = loc.getMiscText("Tooltip.Statistics");
list.add(line);
list.add(getTooltipLine("BlocksMined", ToolHelper.getStatBlocksMined(tool)));
if (isDigger) {
list.add(getTooltipLine("BlocksPlaced", ToolHelper.getStatBlocksPlaced(tool)));
}
if (item instanceof ItemGemShovel) {
list.add(getTooltipLine("PathsMade", ToolHelper.getStatPathsMade(tool)));
}
if (item instanceof ItemGemHoe) {
list.add(getTooltipLine("BlocksTilled", ToolHelper.getStatBlocksTilled(tool)));
}
list.add(getTooltipLine("HitsLanded", ToolHelper.getStatHitsLanded(tool)));
if (isCaster || isBow)
list.add(getTooltipLine("ShotsFired", ToolHelper.getStatShotsFired(tool)));
if (item instanceof ItemGemTomahawk)
list.add(getTooltipLine("ThrownCount", ToolHelper.getStatThrownCount(tool)));
if (isWeapon)
list.add(getTooltipLine("KillCount", ToolHelper.getStatKillCount(tool)));
list.add(getTooltipLine("Redecorated", ToolHelper.getStatRedecorated(tool)));
list.add(sep);
line = loc.getMiscText("Tooltip.Construction");
list.add(line);
ToolPart[] parts = ToolHelper.getConstructionParts(tool);
EnumMaterialGrade[] grades = ToolHelper.getConstructionGrades(tool);
for (int i = 0; i < parts.length; ++i) {
ToolPart part = parts[i];
EnumMaterialGrade grade = grades[i];
line = " " + TextFormatting.YELLOW + part.getKey() + TextFormatting.GOLD + " (" + grade + ")";
list.add(line);
}
list.add(sep);
} else {
list.add(TextFormatting.GOLD + loc.getMiscText("Tooltip.AltForStat"));
}
// Debug render layers
if (controlDown && shiftDown && tool.hasTagCompound()) {
if (!altDown)
list.add(sep);
for (EnumPartPosition pos : EnumPartPosition.values()) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(NBT_MODEL_INDEX);
if (tags != null) {
String key = "Layer" + pos.ordinal();
String str = "%s: %d, %X";
str = String.format(str, key, tags.getInteger(key), tags.getInteger(key + "Color"));
list.add(str);
}
}
}
}
use of net.silentchaos512.gems.item.tool.ItemGemShield in project SilentGems by SilentChaos512.
the class ToolHelper method getSubItems.
public static List<ItemStack> getSubItems(Item item, int materialLength) {
List<ItemStack> list = Lists.newArrayList();
// final boolean isSuperTool = item instanceof ITool && ((ITool) item).isSuperTool();
final ItemStack rodWood = new ItemStack(Items.STICK);
final ItemStack rodIron = ModItems.craftingMaterial.toolRodIron;
final ItemStack rodGold = ModItems.craftingMaterial.toolRodGold;
for (ToolPartMain part : ToolPartRegistry.getMains()) {
// Check for parts with empty crafting stacks and scream at the user if any are found.
if (StackHelper.isEmpty(part.getCraftingStack())) {
if (!emptyPartSet.contains(part)) {
emptyPartSet.add(part);
SilentGems.logHelper.severe("Part with empty crafting stack: " + part);
if (!foundEmptyPart) {
Greetings.addExtraMessage(TextFormatting.RED + "Errored tool part found! Please report this issue on the GitHub issue tracker.");
foundEmptyPart = true;
}
Greetings.addExtraMessage(TextFormatting.ITALIC + part.toString());
}
} else {
if (!part.isBlacklisted(part.getCraftingStack())) {
if (item instanceof ITool && !((ITool) item).getValidTiers().contains(part.getTier())) {
continue;
}
list.add(constructTool(item, part.getTier() == EnumMaterialTier.SUPER ? rodGold : item instanceof ItemGemShield && part.getTier() == EnumMaterialTier.REGULAR ? rodIron : rodWood, part.getCraftingStack()));
}
}
}
// Set maker name.
String makerName = SilentGems.localizationHelper.getMiscText("Tooltip.OriginalOwner.Creative");
for (ItemStack stack : list) ToolHelper.setOriginalOwner(stack, makerName);
return list;
}
use of net.silentchaos512.gems.item.tool.ItemGemShield in project SilentGems by SilentChaos512.
the class ToolHelper method decorate.
private static ItemStack decorate(ItemStack tool, ItemStack material, EnumDecoPos pos) {
if (// Something went wrong
StackHelper.isEmpty(tool))
return StackHelper.empty();
if (// No material in the slot is OK.
StackHelper.isEmpty(material))
return tool;
// South - 'Bottom' (head right or 2)
if (tool.getItem() instanceof ItemGemShield) {
// @formatter:off
if (pos == EnumDecoPos.NORTH)
pos = EnumDecoPos.SOUTH;
else if (pos == EnumDecoPos.EAST)
pos = EnumDecoPos.NORTH;
else if (pos == EnumDecoPos.SOUTH)
pos = EnumDecoPos.EAST;
}
// No deco bit on certain (mostly non-super) rods.
if (pos == EnumDecoPos.SOUTH && !(tool.getItem() instanceof ItemGemShield)) {
ToolPartRod partRod = (ToolPartRod) getConstructionRod(tool);
if (partRod == null || !partRod.supportsDecoration())
return tool;
}
// Get the tool part, making sure it exists.
ToolPart part = ToolPartRegistry.fromStack(material);
if (part == null)
return null;
// Only main parts (like gems) work
if (!(part instanceof ToolPartMain))
return tool;
ItemStack result = StackHelper.safeCopy(tool);
switch(pos) {
case WEST:
setTagPart(result, NBT_DECO_HEAD_L, part, EnumMaterialGrade.fromStack(material));
break;
case NORTH:
setTagPart(result, NBT_DECO_HEAD_M, part, EnumMaterialGrade.fromStack(material));
break;
case EAST:
setTagPart(result, NBT_DECO_HEAD_R, part, EnumMaterialGrade.fromStack(material));
break;
case SOUTH:
setTagPart(result, NBT_PART_ROD_DECO, part, EnumMaterialGrade.fromStack(material));
break;
default:
SilentGems.instance.logHelper.warning("ToolHelper.decorate: invalid deco pos " + pos);
break;
}
return result;
}
Aggregations