use of WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyTable in project BloodMagic by WayofTime.
the class BloodMagicRecipeRegistrar method addAlchemyTable.
@Override
public void addAlchemyTable(@Nonnull ItemStack output, @Nonnegative int syphon, @Nonnegative int ticks, @Nonnegative int minimumTier, @Nonnull Ingredient... input) {
Preconditions.checkNotNull(output, "output cannot be null.");
Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
Preconditions.checkArgument(ticks >= 0, "ticks cannot be negative.");
Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
Preconditions.checkNotNull(input, "input cannot be null.");
NonNullList<Ingredient> inputs = NonNullList.from(Ingredient.EMPTY, input);
alchemyRecipes.add(new RecipeAlchemyTable(inputs, output, syphon, ticks, minimumTier));
}
use of WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyTable in project BloodMagic by WayofTime.
the class TileAlchemyTable method update.
@Override
public void update() {
if (isSlave()) {
return;
}
List<ItemStack> inputList = new ArrayList<>();
for (int i = 0; i < 6; i++) {
if (!getStackInSlot(i).isEmpty()) {
inputList.add(getStackInSlot(i));
}
}
int tier = getTierOfOrb();
// special recipes like dying
AlchemyTableRecipe recipe = AlchemyTableRecipeRegistry.getMatchingRecipe(inputList, getWorld(), getPos());
if (recipe != null && (burnTime > 0 || (!getWorld().isRemote && tier >= recipe.getTierRequired() && this.getContainedLp() >= recipe.getLpDrained()))) {
if (burnTime == 1)
notifyUpdate();
if (canCraft(recipe.getRecipeOutput(inputList))) {
ticksRequired = recipe.getTicksRequired();
burnTime++;
if (burnTime == ticksRequired) {
if (!getWorld().isRemote) {
int requiredLp = recipe.getLpDrained();
if (requiredLp > 0) {
if (!getWorld().isRemote) {
consumeLp(requiredLp);
}
}
if (!getWorld().isRemote) {
craftItem(inputList, recipe);
}
}
burnTime = 0;
IBlockState state = getWorld().getBlockState(pos);
getWorld().notifyBlockUpdate(getPos(), state, state, 3);
} else if (burnTime > ticksRequired + 10) {
burnTime = 0;
}
} else {
burnTime = 0;
}
} else {
// Simple recipes
RecipeAlchemyTable recipeAlchemyTable = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyTable(inputList);
if (recipeAlchemyTable != null && (burnTime > 0 || (!getWorld().isRemote && tier >= recipeAlchemyTable.getMinimumTier() && getContainedLp() >= recipeAlchemyTable.getSyphon()))) {
if (burnTime == 1)
notifyUpdate();
if (canCraft(recipeAlchemyTable.getOutput())) {
ticksRequired = recipeAlchemyTable.getTicks();
burnTime++;
if (burnTime >= ticksRequired) {
if (!getWorld().isRemote) {
if (recipeAlchemyTable.getSyphon() > 0 && !getWorld().isRemote)
consumeLp(recipeAlchemyTable.getSyphon());
ItemStack outputSlotStack = getStackInSlot(outputSlot);
if (outputSlotStack.isEmpty())
setInventorySlotContents(outputSlot, recipeAlchemyTable.getOutput().copy());
else
outputSlotStack.grow(recipeAlchemyTable.getOutput().getCount());
for (int i = 0; i < 6; i++) {
ItemStack currentStack = getStackInSlot(i);
if (currentStack.getItem().hasContainerItem(currentStack))
setInventorySlotContents(i, currentStack.getItem().getContainerItem(currentStack));
else
currentStack.shrink(1);
}
burnTime = 0;
notifyUpdate();
}
}
}
} else {
burnTime = 0;
}
}
}
Aggregations