Search in sources :

Example 6 with IMaterialInstance

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

the class CraftedMaterial method getStatModifiers.

@Override
public Collection<StatInstance> getStatModifiers(IMaterialInstance material, PartType partType, StatGearKey key, ItemStack gear) {
    Collection<StatInstance> ret = super.getStatModifiers(material, partType, key, gear);
    IMaterialInstance base = getBaseMaterial(material);
    ret.addAll(base.getStatModifiers(partType, key, gear));
    return ret;
}
Also used : IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance) StatInstance(net.silentchaos512.gear.api.stats.StatInstance)

Example 7 with IMaterialInstance

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

the class CompoundMaterialDisplay method getLayerColor.

@Override
public int getLayerColor(GearType gearType, IPartData part, IMaterialInstance materialIn, int layer) {
    List<MaterialLayer> layers = getLayerList(gearType, part, materialIn).getLayers();
    if (layer < layers.size()) {
        ItemStack stack = materialIn.getItem();
        if (stack.getItem() instanceof CompoundMaterialItem) {
            List<IMaterialInstance> subMaterials = CompoundMaterialItem.getSubMaterials(stack);
            int color = ColorUtils.getBlendedColor((CompoundMaterialItem) stack.getItem(), subMaterials, layer);
            // return layers.get(layer).getColor();
            return color;
        }
    }
    return Color.VALUE_WHITE;
}
Also used : ItemStack(net.minecraft.world.item.ItemStack) CompoundMaterialItem(net.silentchaos512.gear.item.CompoundMaterialItem)

Example 8 with IMaterialInstance

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

the class GraderTileEntity method tryGradeItem.

private void tryGradeItem(ItemStack input, int catalystTier, IMaterialInstance material) {
    MaterialGrade targetGrade = MaterialGrade.selectWithCatalyst(SilentGear.RANDOM, catalystTier);
    this.lastGradeAttempt = targetGrade;
    if (targetGrade.ordinal() > material.getGrade().ordinal()) {
        // Assign grade, move to output slot
        ItemStack stack = input.split(1);
        targetGrade.setGradeOnStack(stack);
        InventoryUtils.mergeItem(this, 2, 2 + SLOTS_OUTPUT.length, stack);
    }
}
Also used : ItemStack(net.minecraft.world.item.ItemStack) MaterialGrade(net.silentchaos512.gear.api.part.MaterialGrade)

Example 9 with IMaterialInstance

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

the class CompoundMaterialItem method getPrimaryMaterial.

@Nullable
private static IMaterialInstance getPrimaryMaterial(ItemStack stack) {
    IMaterialInstance first = MaterialList.deserializeFirst(stack.getOrCreateTag().getList(NBT_MATERIALS, Tag.TAG_COMPOUND));
    if (first != null) {
        return first;
    }
    // Read old style
    ListTag listNbt = stack.getOrCreateTag().getList(NBT_MATERIALS, Tag.TAG_STRING);
    if (!listNbt.isEmpty()) {
        Tag nbt = listNbt.get(0);
        ResourceLocation id = ResourceLocation.tryParse(nbt.getAsString());
        if (id != null) {
            IMaterial material = MaterialManager.get(id);
            if (material != null) {
                return MaterialInstance.of(material);
            }
        }
    }
    return null;
}
Also used : IMaterial(net.silentchaos512.gear.api.material.IMaterial) IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance) ResourceLocation(net.minecraft.resources.ResourceLocation) Tag(net.minecraft.nbt.Tag) ListTag(net.minecraft.nbt.ListTag) ListTag(net.minecraft.nbt.ListTag) Nullable(javax.annotation.Nullable)

Example 10 with IMaterialInstance

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

the class CompoundMaterialItem method getName.

@Override
public Component getName(ItemStack stack) {
    IMaterialInstance material = getPrimaryMaterial(stack);
    Component text = material != null ? material.getDisplayName(PartType.MAIN) : TextUtil.misc("unknown");
    return new TranslatableComponent(this.getDescriptionId(), text);
}
Also used : TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Component(net.minecraft.network.chat.Component)

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