use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.
the class ArmorHelper method decorate.
private static ItemStack decorate(ItemStack armor, ItemStack material, ArmorPartPosition pos) {
if (StackHelper.isEmpty(armor))
return StackHelper.empty();
if (StackHelper.isEmpty(material))
return armor;
ToolPart part = ToolPartRegistry.fromDecoStack(material);
if (part == null)
return null;
// Only main parts (like gems) work
if (!(part instanceof ToolPartMain))
return armor;
ItemStack result = StackHelper.safeCopy(armor);
setTagPart(result, pos.getDecoKey(), part, EnumMaterialGrade.fromStack(material));
return result;
}
use of net.silentchaos512.gems.api.tool.part.ToolPartMain 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.fromDecoStack(material);
if (part == null)
return null;
// Only main parts (like gems) work
if (!(part instanceof ToolPartMain))
return tool;
ItemStack result = StackHelper.safeCopy(tool);
setTagPart(result, pos.nbtKey, part, EnumMaterialGrade.fromStack(material));
return result;
}
use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.
the class ToolHelper method getSubItems.
public static List<ItemStack> getSubItems(Item item, int materialLength) {
if (toolSubItems.containsKey(item)) {
// Return cached list.
return toolSubItems.get(item);
}
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;
}
ItemStack rod = part.getTier() == EnumMaterialTier.SUPER ? rodGold : item instanceof ItemGemShield && part.getTier() == EnumMaterialTier.REGULAR ? rodIron : rodWood;
ItemStack tool = constructTool(item, rod, part.getCraftingStack());
tool.getTagCompound().setBoolean(NBT_EXAMPLE_TOOL, true);
list.add(tool);
}
}
}
// Set maker name.
String makerName = SilentGems.localizationHelper.getMiscText("Tooltip.OriginalOwner.Creative");
for (ItemStack stack : list) ToolHelper.setOriginalOwner(stack, makerName);
// Save for later to prevent duplicates with different UUIDs.
toolSubItems.put(item, list);
return list;
}
use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.
the class GemsClientEvents method onTooltip.
@SubscribeEvent
public void onTooltip(ItemTooltipEvent event) {
boolean ctrlDown = KeyTracker.isControlDown();
boolean shiftDown = KeyTracker.isShiftDown();
ItemStack stack = event.getItemStack();
ToolPart part = StackHelper.isValid(stack) ? ToolPartRegistry.fromStack(stack) : null;
if (part != null && !part.isBlacklisted(stack)) {
if (part instanceof ToolPartRod) {
onTooltipForToolRod(event, stack, part, ctrlDown, shiftDown);
} else if (part instanceof ToolPartMain) {
onTooltipForToolMaterial(event, stack, part, ctrlDown, shiftDown);
} else if (part instanceof ArmorPartFrame) {
// TODO: Localization
event.getToolTip().add(TextFormatting.GOLD + "Armor Frame");
}
}
}
Aggregations