Search in sources :

Example 1 with RecipeTartaricForge

use of WayofTime.bloodmagic.api.impl.recipe.RecipeTartaricForge in project BloodMagic by WayofTime.

the class BloodMagicRecipeRegistrar method addTartaricForge.

@Override
public void addTartaricForge(@Nonnull ItemStack output, @Nonnegative double minimumSouls, @Nonnegative double soulDrain, @Nonnull Ingredient... input) {
    Preconditions.checkNotNull(output, "output cannot be null.");
    Preconditions.checkArgument(minimumSouls >= 0, "minimumSouls cannot be negative.");
    Preconditions.checkArgument(soulDrain >= 0, "soulDrain cannot be negative.");
    Preconditions.checkNotNull(input, "input cannot be null.");
    NonNullList<Ingredient> inputs = NonNullList.from(Ingredient.EMPTY, input);
    tartaricForgeRecipes.add(new RecipeTartaricForge(inputs, output, minimumSouls, soulDrain));
}
Also used : Ingredient(net.minecraft.item.crafting.Ingredient) RecipeTartaricForge(WayofTime.bloodmagic.api.impl.recipe.RecipeTartaricForge)

Example 2 with RecipeTartaricForge

use of WayofTime.bloodmagic.api.impl.recipe.RecipeTartaricForge in project BloodMagic by WayofTime.

the class TileSoulForge method update.

@Override
public void update() {
    if (!getWorld().isRemote) {
        for (EnumDemonWillType type : EnumDemonWillType.values()) {
            double willInWorld = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type);
            double filled = Math.min(willInWorld, worldWillTransferRate);
            if (filled > 0) {
                filled = this.fillDemonWill(type, filled, false);
                filled = WorldDemonWillHandler.drainWill(getWorld(), pos, type, filled, false);
                if (filled > 0) {
                    this.fillDemonWill(type, filled, true);
                    WorldDemonWillHandler.drainWill(getWorld(), pos, type, filled, true);
                }
            }
        }
    }
    if (!hasSoulGemOrSoul()) {
        burnTime = 0;
        return;
    }
    double soulsInGem = getWill(EnumDemonWillType.DEFAULT);
    List<ItemStack> inputList = new ArrayList<>();
    for (int i = 0; i < 4; i++) if (!getStackInSlot(i).isEmpty())
        inputList.add(getStackInSlot(i));
    RecipeTartaricForge recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getTartaricForge(inputList);
    if (recipe != null && (soulsInGem >= recipe.getMinimumSouls() || burnTime > 0)) {
        if (canCraft(recipe)) {
            burnTime++;
            if (burnTime == ticksRequired) {
                if (!getWorld().isRemote) {
                    double requiredSouls = recipe.getSoulDrain();
                    if (requiredSouls > 0) {
                        if (!getWorld().isRemote && soulsInGem >= recipe.getMinimumSouls()) {
                            consumeSouls(EnumDemonWillType.DEFAULT, requiredSouls);
                        }
                    }
                    if (!getWorld().isRemote && soulsInGem >= recipe.getMinimumSouls())
                        craftItem(recipe);
                }
                burnTime = 0;
            } else if (burnTime > ticksRequired + 10) {
                burnTime = 0;
            }
        } else {
            burnTime = 0;
        }
    } else {
        burnTime = 0;
    }
}
Also used : ArrayList(java.util.ArrayList) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType) ItemStack(net.minecraft.item.ItemStack) RecipeTartaricForge(WayofTime.bloodmagic.api.impl.recipe.RecipeTartaricForge)

Aggregations

RecipeTartaricForge (WayofTime.bloodmagic.api.impl.recipe.RecipeTartaricForge)2 EnumDemonWillType (WayofTime.bloodmagic.soul.EnumDemonWillType)1 ArrayList (java.util.ArrayList)1 ItemStack (net.minecraft.item.ItemStack)1 Ingredient (net.minecraft.item.crafting.Ingredient)1