Search in sources :

Example 21 with IMaterialInstance

use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.

the class CompoundMaterial method getPartTypes.

@Override
public Set<PartType> getPartTypes(IMaterialInstance material) {
    List<IMaterialInstance> subMaterials = getMaterials(material);
    if (subMaterials.isEmpty()) {
        return Collections.emptySet();
    } else if (subMaterials.size() == 1) {
        return subMaterials.get(0).getPartTypes();
    }
    Set<PartType> set = new LinkedHashSet<>(subMaterials.get(0).getPartTypes());
    for (int i = 1; i < subMaterials.size(); ++i) {
        Set<PartType> set1 = subMaterials.get(i).getPartTypes();
        Set<PartType> toRemove = new HashSet<>();
        for (PartType type : set) {
            if (!set1.contains(type)) {
                toRemove.add(type);
            }
        }
        set.removeAll(toRemove);
    }
    return set;
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType)

Example 22 with IMaterialInstance

use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.

the class CompoundMaterial method getTraits.

@Override
public Collection<TraitInstance> getTraits(IMaterialInstance material, PartGearKey partKey, ItemStack gear) {
    List<IMaterialInstance> materials = new ArrayList<>(getMaterials(material));
    List<TraitInstance> traits = TraitHelper.getTraits(materials, partKey, ItemStack.EMPTY);
    Collection<TraitInstance> ret = new ArrayList<>();
    for (TraitInstance inst : traits) {
        if (inst.conditionsMatch(partKey, ItemStack.EMPTY, materials)) {
            ret.add(inst);
        }
    }
    return ret;
}
Also used : TraitInstance(net.silentchaos512.gear.api.traits.TraitInstance)

Example 23 with IMaterialInstance

use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.

the class CraftedMaterial method getTraits.

@Override
public Collection<TraitInstance> getTraits(IMaterialInstance material, PartGearKey partKey, ItemStack gear) {
    Collection<TraitInstance> ret = super.getTraits(material, partKey, gear);
    IMaterialInstance base = getBaseMaterial(material);
    ret.addAll(base.getTraits(partKey, gear));
    return ret;
}
Also used : IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance) TraitInstance(net.silentchaos512.gear.api.traits.TraitInstance)

Example 24 with IMaterialInstance

use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.

the class CraftedMaterial method getStatKeys.

@Override
public Collection<StatGearKey> getStatKeys(IMaterialInstance material, PartType type) {
    Collection<StatGearKey> ret = new LinkedHashSet<>(super.getStatKeys(material, type));
    IMaterialInstance base = getBaseMaterial(material);
    ret.addAll(base.getStatKeys(type));
    return ret;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance) StatGearKey(net.silentchaos512.gear.api.util.StatGearKey)

Example 25 with IMaterialInstance

use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.

the class CompoundMaterialItem method appendHoverText.

@Override
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
    if (Config.Client.showMaterialTooltips.get()) {
        Collection<IMaterialInstance> materials = getSubMaterials(stack);
        TextListBuilder statsBuilder = new TextListBuilder();
        for (IMaterialInstance material : materials) {
            int nameColor = material.getNameColor(PartType.MAIN, GearType.ALL);
            statsBuilder.add(TextUtil.withColor(material.getDisplayName(PartType.MAIN).copy(), nameColor));
        }
        tooltip.addAll(statsBuilder.build());
    }
}
Also used : TextListBuilder(net.silentchaos512.gear.client.util.TextListBuilder) IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance)

Aggregations

IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)24 ItemStack (net.minecraft.world.item.ItemStack)10 PartType (net.silentchaos512.gear.api.part.PartType)6 TraitInstance (net.silentchaos512.gear.api.traits.TraitInstance)6 ResourceLocation (net.minecraft.resources.ResourceLocation)5 IMaterial (net.silentchaos512.gear.api.material.IMaterial)5 IMaterialDisplay (net.silentchaos512.gear.api.material.IMaterialDisplay)5 Nullable (javax.annotation.Nullable)4 StatGearKey (net.silentchaos512.gear.api.util.StatGearKey)4 ArrayList (java.util.ArrayList)3 Collectors (java.util.stream.Collectors)3 Component (net.minecraft.network.chat.Component)3 SilentGear (net.silentchaos512.gear.SilentGear)3 StatInstance (net.silentchaos512.gear.api.stats.StatInstance)3 JsonObject (com.google.gson.JsonObject)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 List (java.util.List)2 FriendlyByteBuf (net.minecraft.network.FriendlyByteBuf)2 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)2