use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class ModKitItem method appendHoverText.
@Override
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
PartType selected = getSelectedType(stack);
tooltip.add(TextUtil.withColor(TextUtil.translate("item", "mod_kit.selected"), Color.SKYBLUE).append(selected.getDisplayName(0).withStyle(ChatFormatting.GRAY)));
tooltip.add(TextUtil.translate("item", "mod_kit.keyHint", TextUtil.withColor(TextUtil.keyBinding(KeyTracker.CYCLE_BACK), Color.AQUAMARINE), TextUtil.withColor(TextUtil.keyBinding(KeyTracker.CYCLE_NEXT), Color.AQUAMARINE)));
if (flagIn.isAdvanced()) {
TextComponent text = new TextComponent("Removable types: " + getRemovableTypes().size());
tooltip.add(TextUtil.withColor(text, ChatFormatting.DARK_GRAY));
}
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class GearBlueprintItem method appendSupportedTypesText.
private void appendSupportedTypesText(Collection<Component> list) {
if (KeyTracker.isDisplayStatsDown()) {
Optional<ICoreItem> itemOptional = this.gearType.getItem();
if (itemOptional.isPresent()) {
TextListBuilder builder = new TextListBuilder();
ICoreItem item = itemOptional.get();
ItemStack gear = new ItemStack(item);
for (PartType type : PartType.getValues()) {
if (type != PartType.MAIN) {
List<IGearPart> partsOfType = PartManager.getPartsOfType(type);
if (!partsOfType.isEmpty() && item.supportsPart(gear, PartData.of(partsOfType.get(0)))) {
builder.add(type.getDisplayName(0));
}
}
}
List<Component> lines = builder.build();
if (!lines.isEmpty()) {
list.add(TextUtil.withColor(TextUtil.misc("supportedPartTypes"), Color.GOLD));
list.addAll(lines);
}
}
} else {
list.add(TextUtil.withColor(TextUtil.misc("supportedPartTypes"), Color.GOLD).append(" ").append(TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_STATS), ChatFormatting.GRAY)));
}
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class SynergyUtils method getSynergy.
public static float getSynergy(PartType partType, List<? extends IMaterialInstance> materials, Collection<TraitInstance> traits) {
if (materials.isEmpty()) {
return 1;
}
// First, we add a bonus for the number of unique materials
double synergy = getBaseSynergy(materials);
// Second, reduce synergy for differences in certain properties
IMaterialInstance primary = materials.get(0);
final double primaryRarity = primary.getStat(partType, ItemStats.RARITY);
final double maxRarity = materials.stream().mapToDouble(m -> m.getStat(partType, ItemStats.RARITY)).max().orElse(0);
final int maxTier = materials.stream().mapToInt(m -> m.getTier(partType)).max().orElse(0);
for (IMaterialInstance material : getUniques(materials)) {
if (maxRarity > 0) {
float rarity = material.getStat(partType, ItemStats.RARITY);
synergy -= 0.005 * Math.abs(primaryRarity - rarity);
}
if (maxTier > 0) {
int tier = material.getTier(partType);
synergy -= 0.08 * Math.abs(maxTier - tier);
}
}
// Synergy traits
for (TraitInstance trait : traits) {
if (trait.getTrait() instanceof SynergyTrait) {
synergy = ((SynergyTrait) trait.getTrait()).apply(synergy, trait.getLevel());
}
}
return (float) Mth.clamp(synergy, MIN_VALUE, MAX_VALUE);
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class ConversionRecipe method getParts.
private Collection<? extends IPartData> getParts() {
PartDataList ret = PartDataList.of();
// noinspection OverlyLongLambda
this.resultMaterials.forEach((partType, list) -> {
partType.getCompoundPartItem(item.getGearType()).ifPresent(partItem -> {
PartData part = PartData.from(partItem.create(list));
if (part != null) {
ret.add(part);
}
});
});
return ret;
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class ConversionRecipe method deserializeMaterials.
private static void deserializeMaterials(JsonObject json, ConversionRecipe recipe) {
JsonObject resultJson = json.getAsJsonObject("result");
for (Map.Entry<String, JsonElement> entry : resultJson.getAsJsonObject("materials").entrySet()) {
PartType partType = PartType.get(Objects.requireNonNull(SilentGear.getIdWithDefaultNamespace(entry.getKey())));
JsonElement element = entry.getValue();
if (element.isJsonArray()) {
List<IMaterialInstance> list = new ArrayList<>();
for (JsonElement e : element.getAsJsonArray()) {
list.add(LazyMaterialInstance.deserialize(e.getAsJsonObject()));
}
recipe.resultMaterials.put(partType, list);
} else {
recipe.resultMaterials.put(partType, Collections.singletonList(LazyMaterialInstance.deserialize(element.getAsJsonObject())));
}
}
}
Aggregations