Search in sources :

Example 1 with ModKitItem

use of net.silentchaos512.gear.item.ModKitItem 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)

Aggregations

ItemStack (net.minecraft.world.item.ItemStack)1 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)1 PartType (net.silentchaos512.gear.api.part.PartType)1 ModKitItem (net.silentchaos512.gear.item.ModKitItem)1