use of crazypants.enderio.base.recipe.IMachineRecipe in project EnderIO by SleepyTrousers.
the class TileAlloySmelter method isMachineItemValidForSlot.
@Override
public boolean isMachineItemValidForSlot(int slot, @Nonnull ItemStack itemstack) {
if (!slotDefinition.isInputSlot(slot)) {
return false;
}
// We will assume anything that is in a slot is valid, so just return whether the new input can be stacked with the current one
ItemStack currentStackInSlot = NullHelper.first(inventory[slot], Prep.getEmpty());
if (Prep.isValid(currentStackInSlot)) {
return currentStackInSlot.isItemEqual(itemstack);
}
int numSlotsFilled = 0;
for (int i = slotDefinition.getMinInputSlot(); i <= slotDefinition.getMaxInputSlot(); i++) {
if (i >= 0 && i < inventory.length) {
if (inventory[i] != null && inventory[i].getCount() > 0) {
numSlotsFilled++;
}
}
}
NNList<IMachineRecipe> recipes = MachineRecipeRegistry.instance.getRecipesForInput(getMachineName(), MachineRecipeInput.create(slot, itemstack));
if (getMode() == Mode.FURNACE) {
return isValidInputForFurnaceRecipe(itemstack, numSlotsFilled, recipes);
} else if (getMode() == Mode.ALLOY) {
return isValidInputForAlloyRecipe(slot, itemstack, numSlotsFilled, recipes);
}
return isValidInputForFurnaceRecipe(itemstack, numSlotsFilled, recipes) || isValidInputForAlloyRecipe(slot, itemstack, numSlotsFilled, recipes);
}
use of crazypants.enderio.base.recipe.IMachineRecipe in project EnderIO by SleepyTrousers.
the class TileSoulBinder method canStartNextTask.
@Override
protected IMachineRecipe canStartNextTask(long nextSeed) {
IMachineRecipe recipe = super.canStartNextTask(nextSeed);
if (recipe == null) {
return null;
}
int xpRequired = ((ISoulBinderRecipe) recipe).getExperienceRequired();
if (xpCont.getExperienceTotal() >= xpRequired) {
return recipe;
}
return null;
}
use of crazypants.enderio.base.recipe.IMachineRecipe in project EnderIO by SleepyTrousers.
the class TileEntityPainter method isMachineItemValidForSlot.
@Override
public boolean isMachineItemValidForSlot(int i, @Nonnull ItemStack itemStack) {
if (i > 1) {
return false;
}
ItemStack paint = i == 0 ? getStackInSlot(1) : itemStack;
ItemStack targt = i == 0 ? itemStack : getStackInSlot(0);
Map<String, IMachineRecipe> recipes = MachineRecipeRegistry.instance.getRecipesForMachine(getMachineName());
for (IMachineRecipe rec : recipes.values()) {
if (rec instanceof AbstractPainterTemplate<?>) {
AbstractPainterTemplate<?> temp = (AbstractPainterTemplate<?>) rec;
if (temp.isPartialRecipe(paint, targt)) {
return true;
}
}
}
return false;
}
use of crazypants.enderio.base.recipe.IMachineRecipe in project EnderIO by SleepyTrousers.
the class TileAlloySmelter method canStartNextTask.
@Override
protected IMachineRecipe canStartNextTask(long nextSeed) {
if (getMode() == Mode.FURNACE) {
VanillaSmeltingRecipe vr = AlloyRecipeManager.getInstance().getVanillaRecipe();
if (vr.isRecipe(getRecipeInputs())) {
final IPoweredTask task = createTask(vr, nextSeed);
if (task == null) {
return null;
}
IMachineRecipe.ResultStack[] res = task.getCompletedResult();
if (res.length == 0) {
return null;
}
return canInsertResult(nextSeed, vr) ? vr : null;
}
return null;
}
IMachineRecipe nextRecipe = getNextRecipe();
if (getMode() == Mode.ALLOY && nextRecipe instanceof VanillaSmeltingRecipe) {
nextRecipe = null;
}
if (nextRecipe == null) {
// no template
return null;
}
// make sure we have room for the next output
return canInsertResult(nextSeed, nextRecipe) ? nextRecipe : null;
}
Aggregations