Search in sources :

Example 46 with PartType

use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.

the class PartMaterialIngredient method test.

@Override
public boolean test(@Nullable ItemStack stack) {
    if (stack == null || stack.isEmpty())
        return false;
    MaterialInstance material = MaterialInstance.from(stack);
    if (material == null)
        return false;
    int tier = material.getTier(this.partType);
    return material.get().isCraftingAllowed(material, partType, gearType) && (categories.isEmpty() || material.hasAnyCategory(categories)) && tierMatches(tier);
}
Also used : MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance)

Example 47 with PartType

use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.

the class ConversionRecipe method readMaterials.

private static void readMaterials(FriendlyByteBuf buffer, ConversionRecipe recipe) {
    int typeCount = buffer.readByte();
    for (int i = 0; i < typeCount; ++i) {
        PartType partType = PartType.get(buffer.readResourceLocation());
        int matCount = buffer.readByte();
        List<IMaterialInstance> list = new ArrayList<>(matCount);
        for (int j = 0; j < matCount; ++j) {
            list.add(LazyMaterialInstance.read(buffer));
        }
        recipe.resultMaterials.put(partType, list);
    }
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType) IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance)

Example 48 with PartType

use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.

the class ModKitRemovePartRecipe method getRemainingItems.

@Override
public NonNullList<ItemStack> getRemainingItems(CraftingContainer inv) {
    NonNullList<ItemStack> list = NonNullList.withSize(inv.getContainerSize(), ItemStack.EMPTY);
    ItemStack gear = StackList.from(inv).uniqueOfType(ICoreItem.class);
    ItemStack modKit = StackList.from(inv).uniqueOfType(ModKitItem.class);
    PartType type = ModKitItem.getSelectedType(modKit);
    PartData part = GearData.getPartOfType(gear, type);
    for (int i = 0; i < list.size(); ++i) {
        ItemStack stack = inv.getItem(i);
        if (stack.getItem() instanceof ICoreItem) {
            list.set(i, part != null ? part.getItem() : ItemStack.EMPTY);
        } else if (stack.hasContainerItem()) {
            list.set(i, stack.getContainerItem());
        }
    }
    return list;
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType) PartData(net.silentchaos512.gear.gear.part.PartData) ICoreItem(net.silentchaos512.gear.api.item.ICoreItem) ItemStack(net.minecraft.world.item.ItemStack)

Example 49 with PartType

use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.

the class ModKitRemovePartRecipe method matches.

@Override
public boolean matches(CraftingContainer inv, Level worldIn) {
    ItemStack gear = ItemStack.EMPTY;
    boolean foundModKit = false;
    PartType type = PartType.NONE;
    for (int i = 0; i < inv.getContainerSize(); ++i) {
        ItemStack stack = inv.getItem(i);
        if (!stack.isEmpty()) {
            // noinspection ChainOfInstanceofChecks
            if (gear.isEmpty() && stack.getItem() instanceof ICoreItem) {
                gear = stack;
            } else if (!foundModKit && stack.getItem() instanceof ModKitItem) {
                type = ModKitItem.getSelectedType(stack);
                if (type == PartType.NONE) {
                    return false;
                }
                foundModKit = true;
            } else {
                return false;
            }
        }
    }
    return !gear.isEmpty() && foundModKit && GearData.hasPartOfType(gear, type);
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType) ModKitItem(net.silentchaos512.gear.item.ModKitItem) ICoreItem(net.silentchaos512.gear.api.item.ICoreItem) ItemStack(net.minecraft.world.item.ItemStack)

Example 50 with PartType

use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.

the class GearArmorItem method getArmorTexture.

// endregion
// region Client-side methods and rendering horrors
@Override
public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {
    // Empty texture if broken
    if (GearHelper.isBroken(stack))
        return SilentGear.MOD_ID + ":textures/models/armor/empty.png";
    int layer = slot == EquipmentSlot.LEGS ? 2 : 1;
    // Overlay - default to a blank texture
    if ("overlay".equals(type))
        return SilentGear.MOD_ID + ":textures/models/armor/all_layer_" + layer + "_overlay.png";
    // New material-based armor
    MaterialInstance material = GearData.getPrimaryArmorMaterial(stack);
    if (material != null) {
        IMaterialDisplay materialModel = material.getDisplayProperties();
        PartType partType = GearData.hasPartOfType(stack, PartType.COATING) ? PartType.COATING : PartType.MAIN;
        MaterialLayer materialLayer = materialModel.getLayerList(this.getGearType(), partType, material).getFirstLayer();
        if (materialLayer != null) {
            ResourceLocation tex = materialLayer.getTextureId();
            return tex.getNamespace() + ":textures/models/armor/" + tex.getPath() + "_layer_" + layer + (type != null ? "_" + type : "") + ".png";
        }
    }
    return "silentgear:textures/models/armor/main_generic_hc_layer_" + layer + (type != null ? "_" + type : "") + ".png";
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType) IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) ResourceLocation(net.minecraft.resources.ResourceLocation) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance)

Aggregations

PartType (net.silentchaos512.gear.api.part.PartType)37 ItemStack (net.minecraft.world.item.ItemStack)14 PartData (net.silentchaos512.gear.gear.part.PartData)14 StatInstance (net.silentchaos512.gear.api.stats.StatInstance)13 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)10 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)10 TextComponent (net.minecraft.network.chat.TextComponent)9 ResourceLocation (net.minecraft.resources.ResourceLocation)9 GearType (net.silentchaos512.gear.api.item.GearType)9 PartDataList (net.silentchaos512.gear.api.part.PartDataList)9 ItemStat (net.silentchaos512.gear.api.stats.ItemStat)9 Component (net.minecraft.network.chat.Component)8 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)8 IPartData (net.silentchaos512.gear.api.part.IPartData)8 MaterialInstance (net.silentchaos512.gear.gear.material.MaterialInstance)8 TraitInstance (net.silentchaos512.gear.api.traits.TraitInstance)7 StatGearKey (net.silentchaos512.gear.api.util.StatGearKey)7 ArrayList (java.util.ArrayList)5 Collectors (java.util.stream.Collectors)5 MutableComponent (net.minecraft.network.chat.MutableComponent)5