use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class UpgradeSmithingRecipe method applyUpgrade.
@Override
protected ItemStack applyUpgrade(ItemStack gear, ItemStack upgradeItem) {
PartData part = PartData.from(upgradeItem);
if (part != null) {
GearType gearType = GearHelper.getType(gear);
if (gearType.isGear() && part.get().canAddToGear(gear, part) && !GearData.hasPart(gear, part.get())) {
ItemStack result = gear.copy();
GearData.addPart(result, part);
GearData.recalculateStats(result, ForgeHooks.getCraftingPlayer());
return result;
}
}
return ItemStack.EMPTY;
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class ShapelessGearRecipe method matches.
@Override
public boolean matches(CraftingContainer inv, Level worldIn) {
if (!this.getBaseRecipe().matches(inv, worldIn))
return false;
GearType gearType = item.getGearType();
Collection<PartData> parts = getParts(inv);
if (parts.isEmpty())
return false;
for (PartData part : parts) {
if (!part.isCraftingAllowed(gearType, inv)) {
return false;
}
}
return true;
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class GearClientHelper method addInformation.
public static void addInformation(ItemStack stack, Level world, List<Component> tooltip, GearTooltipFlag flag) {
if (!(stack.getItem() instanceof ICoreItem))
return;
ICoreItem item = (ICoreItem) stack.getItem();
if (GearHelper.isBroken(stack)) {
tooltip.add(Math.min(1, tooltip.size()), TextUtil.withColor(misc("broken"), Color.FIREBRICK));
}
if (GearData.isExampleGear(stack)) {
tooltip.add(Math.min(1, tooltip.size()), TextUtil.withColor(misc("exampleOutput1"), Color.YELLOW));
tooltip.add(Math.min(2, tooltip.size()), TextUtil.withColor(misc("exampleOutput2"), Color.YELLOW));
}
PartDataList constructionParts = GearData.getConstructionParts(stack);
if (constructionParts.getMains().isEmpty()) {
tooltip.add(TextUtil.withColor(misc("invalidParts"), Color.FIREBRICK));
tooltip.add(TextUtil.withColor(misc("lockedStats"), Color.FIREBRICK));
} else if (GearData.hasLockedStats(stack)) {
tooltip.add(TextUtil.withColor(misc("lockedStats"), Color.YELLOW));
}
if (!Config.Client.vanillaStyleTooltips.get()) {
// Let parts add information if they need to
Collections.reverse(constructionParts);
for (PartData data : constructionParts) {
data.get().addInformation(data, stack, tooltip, flag);
}
}
// Traits
addTraitsInfo(stack, tooltip, flag);
if (!Config.Client.vanillaStyleTooltips.get()) {
// Stats
addStatsInfo(stack, tooltip, flag, item);
}
// Tool construction
if (KeyTracker.isDisplayConstructionDown() && flag.showConstruction) {
tooltip.add(TextUtil.withColor(misc("tooltip.construction"), Color.GOLD));
Collections.reverse(constructionParts);
tooltipListParts(stack, tooltip, constructionParts, flag);
} else if (flag.showConstruction) {
tooltip.add(TextUtil.withColor(TextUtil.misc("tooltip.construction"), Color.GOLD).append(new TextComponent(" ").append(TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_CONSTRUCTION), ChatFormatting.GRAY))));
}
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class GearSalvagingRecipe method getPossibleResults.
@Override
public List<ItemStack> getPossibleResults(Container inv) {
ItemStack input = inv.getItem(0);
List<ItemStack> ret = new ArrayList<>();
PartDataList parts = GearData.getConstructionParts(input);
for (PartData part : parts) {
ret.addAll(salvage(part));
}
return ret;
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class CompoundPartItem method getName.
@Override
public Component getName(ItemStack stack) {
PartData part = PartData.from(stack);
MaterialInstance material = getPrimaryMaterial(stack);
if (part != null && material != null) {
TranslatableComponent nameText = new TranslatableComponent(this.getDescriptionId() + ".nameProper", material.getDisplayName(partType, ItemStack.EMPTY));
int nameColor = Color.blend(part.getColor(ItemStack.EMPTY), Color.VALUE_WHITE, 0.25f) & 0xFFFFFF;
return TextUtil.withColor(nameText, nameColor);
}
return super.getName(stack);
}
Aggregations