mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-24 22:04:49 +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,11 +1,12 @@
|
||||
package mekanism.common.recipe.inputs;
|
||||
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.util.StackUtils;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AdvancedMachineInput extends MachineInput
|
||||
public class AdvancedMachineInput extends MachineInput<AdvancedMachineInput>
|
||||
{
|
||||
public ItemStack itemStack;
|
||||
|
||||
@@ -17,11 +18,41 @@ public class AdvancedMachineInput extends MachineInput
|
||||
gasType = gas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancedMachineInput copy()
|
||||
{
|
||||
return new AdvancedMachineInput(itemStack.copy(), gasType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return itemStack != null && gasType != null;
|
||||
}
|
||||
|
||||
public boolean useItem(ItemStack[] inventory, int index, boolean deplete)
|
||||
{
|
||||
if(StackUtils.contains(inventory[index], itemStack))
|
||||
{
|
||||
if(deplete)
|
||||
{
|
||||
inventory[index] = StackUtils.subtract(inventory[index], itemStack);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean useSecondary(GasTank gasTank, int amountToUse, boolean deplete)
|
||||
{
|
||||
if(gasTank.getGasType() == gasType && gasTank.getStored() >= amountToUse)
|
||||
{
|
||||
gasTank.draw(amountToUse, deplete);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean matches(AdvancedMachineInput input)
|
||||
{
|
||||
return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.stackSize >= itemStack.stackSize;
|
||||
@@ -30,12 +61,19 @@ public class AdvancedMachineInput extends MachineInput
|
||||
@Override
|
||||
public int hashIngredients()
|
||||
{
|
||||
return StackUtils.hashItemStack(itemStack) << 8 | gasType.getID();
|
||||
int hash = StackUtils.hashItemStack(itemStack) << 8 | gasType.getID();
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testEquality(MachineInput other)
|
||||
public boolean testEquality(AdvancedMachineInput other)
|
||||
{
|
||||
return other instanceof AdvancedMachineInput && StackUtils.equalsWildcardWithNBT(itemStack, ((AdvancedMachineInput)other).itemStack) && gasType.getID() == ((AdvancedMachineInput)other).gasType.getID();
|
||||
return StackUtils.equalsWildcardWithNBT(itemStack, other.itemStack) && gasType.getID() == other.gasType.getID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(Object other)
|
||||
{
|
||||
return other instanceof AdvancedMachineInput;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user