use of net.silentchaos512.gems.api.tool.part.ArmorPartFrame in project SilentGems by SilentChaos512.
the class RecipeMixedMaterialItem method partTiersMatch.
protected boolean partTiersMatch(InventoryCrafting inv) {
EnumMaterialTier tier = null;
// Check mains
for (ItemStack stack : getMaterials(inv)) {
ToolPart part = ToolPartRegistry.fromStack(stack);
if (tier == null) {
tier = part.getTier();
} else if (tier != part.getTier()) {
return false;
}
}
// No mains found?
if (tier == null) {
return false;
}
// Tier restrictions?
if (tierRestriction != null && tier != tierRestriction) {
return false;
}
// Check rod
ItemStack rod = getRod(inv);
if (StackHelper.isValid(rod))
return ToolPartRegistry.fromStack(rod).validForToolOfTier(tier);
// Check frame
ItemStack frame = getFrame(inv);
if (StackHelper.isValid(frame)) {
ToolPart partFrame = ToolPartRegistry.fromStack(frame);
if (partFrame instanceof ArmorPartFrame) {
return partFrame.validForToolOfTier(tier) && doesFrameMatchItem((ArmorPartFrame) partFrame);
}
}
return true;
}
use of net.silentchaos512.gems.api.tool.part.ArmorPartFrame in project SilentGems by SilentChaos512.
the class ToolHelper method addExampleRecipe.
public static void addExampleRecipe(Item item, EnumMaterialTier[] tiers, String[] lines, Object... extraParams) {
// New ingredient-based recipes
ConfigOptionToolClass config = item instanceof ITool ? ((ITool) item).getConfig() : null;
for (EnumMaterialTier tier : tiers) {
// Only add recipes for valid tiers
if (config != null && !config.validTiers.contains(tier))
continue;
// Head parts for tier
List<ItemStack> heads = new ArrayList<>();
for (ToolPart part : ToolPartRegistry.getMains()) if (!part.isBlacklisted(part.getCraftingStack()) && part.getTier() == tier && StackHelper.isValid(part.getCraftingStack()))
heads.add(part.getCraftingStack());
IngredientSL headIngredient = IngredientSL.from(heads.toArray(new ItemStack[0]));
// Rods for tier
List<ItemStack> rods = new ArrayList<>();
for (ToolPart part : ToolPartRegistry.getRods()) if (!part.isBlacklisted(part.getCraftingStack()) && part.getCompatibleTiers().contains(tier))
rods.add(part.getCraftingStack());
IngredientSL rodIngredient = IngredientSL.from(rods.toArray(new ItemStack[0]));
// Armor frames
List<ItemStack> frames = new ArrayList<>();
if (item instanceof ItemGemArmor) {
EntityEquipmentSlot slot = ((ItemGemArmor) item).armorType;
for (ToolPart part : ToolPartRegistry.getValues()) if (part instanceof ArmorPartFrame && ((ArmorPartFrame) part).getSlot() == slot && part.getTier() == tier && !part.isBlacklisted(part.getCraftingStack()))
frames.add(part.getCraftingStack());
}
IngredientSL frameIngredient = IngredientSL.from(frames.toArray(new ItemStack[0]));
ResourceLocation recipeName = new ResourceLocation(item.getRegistryName().toString() + "_" + tier.name().toLowerCase() + "_example");
ItemStack result = new ItemStack(item);
NBTTagCompound tags = new NBTTagCompound();
tags.setInteger(NBT_EXAMPLE_TOOL_TIER, tier.ordinal());
result.setTagCompound(tags);
// Super ugly, but I've got never better at the moment.
List<Object> params = new ArrayList<>();
for (String line : lines) params.add(line);
if (recipeContainsKey(lines, "h")) {
params.add('h');
params.add(headIngredient);
}
if (recipeContainsKey(lines, "r")) {
params.add('r');
params.add(rodIngredient);
}
if (recipeContainsKey(lines, "a")) {
params.add('a');
params.add(frameIngredient);
}
for (Object obj : extraParams) params.add(obj);
EXAMPLE_RECIPES.add(SilentGems.registry.recipes.makeShaped(recipeName.getResourcePath(), result, params.toArray()));
}
}
use of net.silentchaos512.gems.api.tool.part.ArmorPartFrame 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