use of crazypants.enderio.base.recipe.MachineRecipeInput in project EnderIO by SleepyTrousers.
the class VatMachineRecipe method getQuantitiesConsumed.
@Override
@Nonnull
public NNList<MachineRecipeInput> getQuantitiesConsumed(@Nonnull NNList<MachineRecipeInput> inputs) {
NNList<MachineRecipeInput> result = new NNList<MachineRecipeInput>();
VatRecipe rec = (VatRecipe) getRecipeForInputs(inputs);
FluidStack inputFluidStack = rec.getRequiredFluidInput(inputs);
result.add(new MachineRecipeInput(0, inputFluidStack));
for (MachineRecipeInput ri : inputs) {
if (!ri.isFluid() && Prep.isValid(ri.item)) {
ItemStack st = ri.item.copy();
st.setCount(rec.getNumConsumed(ri.item));
result.add(new MachineRecipeInput(ri.slotNumber, st));
}
}
return result;
}
use of crazypants.enderio.base.recipe.MachineRecipeInput in project EnderIO by SleepyTrousers.
the class AbstractSoulBinderRecipe method getCompletedResult.
@Override
@Nonnull
public ResultStack[] getCompletedResult(long nextSeed, float chanceMultiplier, @Nonnull NNList<MachineRecipeInput> inputs) {
CapturedMob mobType = null;
ItemStack inputItem = null;
for (MachineRecipeInput input : inputs) {
if (input != null && input.slotNumber == 0 && CapturedMob.containsSoul(input.item)) {
mobType = CapturedMob.create(input.item);
} else if (input != null && input.slotNumber == 1 && isValidInputItem(input.item)) {
inputItem = input.item;
}
}
if (mobType == null || !isValidInputSoul(mobType) || inputItem == null) {
return new ResultStack[0];
}
ItemStack resultStack = getOutputStack(inputItem, mobType);
ItemStack soulVessel = new ItemStack(itemSoulVial.getItemNN());
return new ResultStack[] { new ResultStack(soulVessel), new ResultStack(resultStack) };
}
use of crazypants.enderio.base.recipe.MachineRecipeInput in project EnderIO by SleepyTrousers.
the class AbstractSoulBinderRecipe method getQuantitiesConsumed.
@Override
@Nonnull
public List<MachineRecipeInput> getQuantitiesConsumed(@Nonnull NNList<MachineRecipeInput> inputs) {
List<MachineRecipeInput> result = new ArrayList<MachineRecipeInput>(inputs.size());
for (MachineRecipeInput input : inputs) {
if (input != null && Prep.isValid(input.item)) {
ItemStack resStack = input.item.copy();
resStack.setCount(1);
MachineRecipeInput mri = new MachineRecipeInput(input.slotNumber, resStack);
result.add(mri);
}
}
return result;
}
use of crazypants.enderio.base.recipe.MachineRecipeInput in project EnderIO by SleepyTrousers.
the class TileSoulBinder method isMachineItemValidForSlot.
@Override
public boolean isMachineItemValidForSlot(int slot, @Nonnull ItemStack item) {
if (!slotDefinition.isInputSlot(slot)) {
return false;
}
MachineRecipeInput newInput = new MachineRecipeInput(slot, item);
int otherSlot = slot == 0 ? 1 : 0;
if (Prep.isInvalid(getStackInSlot(otherSlot))) {
List<IMachineRecipe> recipes = MachineRecipeRegistry.instance.getRecipesForInput(getMachineName(), newInput);
if (recipes.isEmpty()) {
return false;
}
for (IMachineRecipe rec : recipes) {
if (rec != null && rec.isValidInput(newInput)) {
return true;
}
}
} else {
NNList<MachineRecipeInput> inputs = new NNList<>(newInput, new MachineRecipeInput(otherSlot, getStackInSlot(otherSlot)));
return MachineRecipeRegistry.instance.getRecipeForInputs(getMachineName(), inputs) != null;
}
return false;
}
use of crazypants.enderio.base.recipe.MachineRecipeInput in project EnderIO by SleepyTrousers.
the class ContainerEnchanter method addSlots.
@Override
protected void addSlots(@Nonnull InventoryPlayer playerInv) {
final TileEnchanter te = getInv();
addSlotToContainer(new Slot(te, 0, 16, 35) {
@Override
public int getSlotStackLimit() {
return 1;
}
@Override
public boolean isItemValid(@Nonnull ItemStack itemStack) {
return te.isItemValidForSlot(0, itemStack);
}
@Override
public void onSlotChanged() {
updateOutput();
}
});
addSlotToContainer(new Slot(te, 1, 65, 35) {
@Override
public boolean isItemValid(@Nonnull ItemStack itemStack) {
return te.isItemValidForSlot(1, itemStack);
}
@Override
public void onSlotChanged() {
updateOutput();
}
});
addSlotToContainer(new Slot(te, 2, 85, 35) {
@Override
public boolean isItemValid(@Nonnull ItemStack itemStack) {
return te.isItemValidForSlot(2, itemStack);
}
@Override
public void onSlotChanged() {
updateOutput();
}
});
addSlotToContainer(new Slot(te, 3, 144, 35) {
@Override
public int getSlotStackLimit() {
return 1;
}
@Override
public boolean isItemValid(@Nullable ItemStack itemStack) {
return false;
}
@Override
@Nonnull
public ItemStack onTake(@Nonnull EntityPlayer player, @Nonnull ItemStack stack) {
EnchanterRecipe currentEnchantmentRecipe = getInv().getCurrentEnchantmentRecipe();
if (currentEnchantmentRecipe != null) {
final int xpCost = currentEnchantmentRecipe.getXPCost(getInv().getInvAsMachineRecipeInput());
List<MachineRecipeInput> quantitiesConsumed = currentEnchantmentRecipe.getQuantitiesConsumed(getInv().getInvAsMachineRecipeInput());
for (MachineRecipeInput machineRecipeInput : quantitiesConsumed) {
te.decrStackSize(machineRecipeInput.slotNumber, machineRecipeInput.item.getCount());
}
if (!player.capabilities.isCreativeMode) {
player.addExperienceLevel(-xpCost);
}
} else {
Log.error("Enchanting yielded result without resources");
}
if (!te.getWorld().isRemote) {
te.getWorld().playEvent(1030, te.getPos(), 0);
te.getWorld().playEvent(2005, te.getPos().up(), 0);
}
return stack;
}
@Override
public boolean canTakeStack(@Nonnull EntityPlayer player) {
return playerHasEnoughLevels(player);
}
});
}
Aggregations