mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 23:03:01 +00:00
More work in the quest for greater recipe efficiency.
This commit is contained in:
1 parent
c6a77f9cfa
commit
c7a429177b
87 files changed
+1416
-1106
No files matched your search
@@ -1,52 +1,78 @@
|
||||
package mekanism.common.recipe.inputs;
|
||||
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.infuse.InfuseType;
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.InfuseStorage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
/**
|
||||
* An infusion input, containing the type of and amount of infuse the operation requires, as well as the input ItemStack.
|
||||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
public class InfusionInput extends MachineInput
|
||||
public class InfusionInput extends MachineInput<InfusionInput>
|
||||
{
|
||||
/** The type of this infusion */
|
||||
public InfuseType infusionType;
|
||||
|
||||
/** How much infuse it takes to perform this operation */
|
||||
public int infuseAmount;
|
||||
public InfuseStorage infuse;
|
||||
|
||||
/** The input ItemStack */
|
||||
public ItemStack inputStack;
|
||||
|
||||
public InfusionInput(InfuseType infusiontype, int required, ItemStack itemstack)
|
||||
public InfusionInput(InfuseStorage storage, ItemStack itemStack)
|
||||
{
|
||||
infusionType = infusiontype;
|
||||
infuseAmount = required;
|
||||
inputStack = itemstack;
|
||||
infuse = new InfuseStorage(storage.type, storage.amount);
|
||||
inputStack = itemStack;
|
||||
}
|
||||
|
||||
public static InfusionInput getInfusion(InfuseType type, int stored, ItemStack itemstack)
|
||||
public InfusionInput(InfuseType infusionType, int required, ItemStack itemStack)
|
||||
{
|
||||
return new InfusionInput(type, stored, itemstack);
|
||||
infuse = new InfuseStorage(infusionType, required);
|
||||
inputStack = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfusionInput copy()
|
||||
{
|
||||
return new InfusionInput(infuse.type, infuse.amount, inputStack.copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return infuse.type != null && inputStack != null;
|
||||
}
|
||||
|
||||
public boolean use(ItemStack[] inventory, int index, InfuseStorage infuseStorage, boolean deplete)
|
||||
{
|
||||
if(StackUtils.contains(inventory[index], inputStack) && infuseStorage.contains(infuse))
|
||||
{
|
||||
if(deplete)
|
||||
{
|
||||
inventory[index] = StackUtils.subtract(inventory[index], inputStack);
|
||||
infuseStorage.subtract(infuse);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashIngredients()
|
||||
{
|
||||
return infusionType.unlocalizedName.hashCode() << 8 | StackUtils.hashItemStack(inputStack);
|
||||
return infuse.type.unlocalizedName.hashCode() << 8 | StackUtils.hashItemStack(inputStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testEquality(MachineInput other)
|
||||
public boolean testEquality(InfusionInput other)
|
||||
{
|
||||
if(other instanceof InfusionInput)
|
||||
{
|
||||
InfusionInput ii = (InfusionInput)other;
|
||||
return infusionType == ii.infusionType && StackUtils.equalsWildcardWithNBT(inputStack, ii.inputStack);
|
||||
}
|
||||
return false;
|
||||
return infuse.type == other.infuse.type && StackUtils.equalsWildcardWithNBT(inputStack, other.inputStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(Object other)
|
||||
{
|
||||
return other instanceof InfusionInput;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user