use of crazypants.enderio.base.recipe.MachineRecipeInput in project EnderIO by SleepyTrousers.
the class PoweredTask method readFromNBT.
@Nullable
public static IPoweredTask readFromNBT(@Nonnull NBTTagCompound nbtRoot) {
IMachineRecipe recipe;
float usedEnergy = nbtRoot.getFloat(KEY_USED_ENERGY);
long seed = nbtRoot.getLong(KEY_SEED);
float outputMultiplier = nbtRoot.getFloat(KEY_CHANCE_OUTPUT);
float chanceMultiplier = nbtRoot.getFloat(KEY_CHANCE_MULTI);
NBTTagList inputItems = (NBTTagList) nbtRoot.getTag(KEY_INPUT_STACKS);
NNList<MachineRecipeInput> ins = new NNList<MachineRecipeInput>();
for (int i = 0; i < inputItems.tagCount(); i++) {
NBTTagCompound stackTag = inputItems.getCompoundTagAt(i);
MachineRecipeInput mi = MachineRecipeInput.readFromNBT(stackTag);
ins.add(mi);
}
String uid = nbtRoot.getString(KEY_RECIPE);
recipe = MachineRecipeRegistry.instance.getRecipeForUid(uid);
if (recipe != null) {
return new PoweredTask(recipe, usedEnergy, seed, outputMultiplier, chanceMultiplier, ins);
}
return null;
}
use of crazypants.enderio.base.recipe.MachineRecipeInput in project EnderIO by SleepyTrousers.
the class PoweredTask method writeToNBT.
@Override
public void writeToNBT(@Nonnull NBTTagCompound nbtRoot) {
NBTTagList inputItems = new NBTTagList();
for (MachineRecipeInput ri : inputs) {
NBTTagCompound stackRoot = new NBTTagCompound();
ri.writeToNbt(stackRoot);
inputItems.appendTag(stackRoot);
}
nbtRoot.setTag(KEY_INPUT_STACKS, inputItems);
nbtRoot.setString(KEY_RECIPE, recipe.getUid());
nbtRoot.setFloat(KEY_USED_ENERGY, usedEnergy);
nbtRoot.setLong(KEY_SEED, nextSeed);
nbtRoot.setFloat(KEY_CHANCE_OUTPUT, outputMultiplier);
nbtRoot.setFloat(KEY_CHANCE_MULTI, chanceMultiplier);
}
use of crazypants.enderio.base.recipe.MachineRecipeInput in project EnderIO by SleepyTrousers.
the class AbstractPoweredTaskEntity method startNextTask.
protected boolean startNextTask(@Nonnull IMachineRecipe nextRecipe, long nextSeed) {
if (hasPower() && nextRecipe.isRecipe(getRecipeInputs())) {
// then get our recipe and take away the source items
currentTask = createTask(nextRecipe, nextSeed);
List<MachineRecipeInput> consumed = nextRecipe.getQuantitiesConsumed(getRecipeInputs());
for (MachineRecipeInput item : consumed) {
if (item != null) {
if (Prep.isValid(item.item)) {
decrStackSize(item.slotNumber, item.item.getCount());
} else if (item.fluid != null) {
drainInputFluid(item);
}
}
}
return true;
}
return false;
}
use of crazypants.enderio.base.recipe.MachineRecipeInput in project EnderIO by SleepyTrousers.
the class EnchanterRecipe method getVariants.
public NNList<NNList<MachineRecipeInput>> getVariants() {
NNList<NNList<MachineRecipeInput>> result = new NNList<>();
for (int level = 1; level <= enchantment.getMaxLevel(); level++) {
for (ItemStack item : input.getItemStacks()) {
item = item.copy();
for (ItemStack lapis : LAPIS.getItemStacks()) {
lapis = lapis.copy();
item.setCount(stackSizePerLevel * level);
lapis.setCount(getLapizForLevel(level));
if (item.getCount() <= item.getMaxStackSize() && lapis.getCount() <= lapis.getMaxStackSize()) {
result.add(getQuantitiesConsumed(new NNList<>(new MachineRecipeInput(0, BOOK.getItemStacks().get(0)), new MachineRecipeInput(1, item), new MachineRecipeInput(2, lapis))));
}
}
}
}
return result;
}
use of crazypants.enderio.base.recipe.MachineRecipeInput in project EnderIO by SleepyTrousers.
the class AbstractPainterTemplate method getQuantitiesConsumed.
@Override
@Nonnull
public List<MachineRecipeInput> getQuantitiesConsumed(@Nonnull NNList<MachineRecipeInput> inputs) {
MachineRecipeInput consume = null;
for (MachineRecipeInput input : inputs) {
if (input != null && input.slotNumber == 0 && Prep.isValid(input.item)) {
ItemStack consumed = input.item.copy();
consumed.setCount(1);
consume = new MachineRecipeInput(input.slotNumber, consumed);
}
}
if (consume != null) {
return Collections.singletonList(consume);
}
return Collections.emptyList();
}
Aggregations