Fix forestry sapling integration
This commit is contained in:
parent
d72f4b6181
commit
c9f0ed0941
5 changed files with 24 additions and 8 deletions
|
@ -236,11 +236,6 @@ public final class StackUtils
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean contains(ItemStack container, ItemStack contained)
|
||||
{
|
||||
return equalsWildcardWithNBT(contained, container) && container.stackSize >= contained.stackSize;
|
||||
}
|
||||
|
||||
public static int hashItemStack(ItemStack stack)
|
||||
{
|
||||
if(stack == null || stack.getItem() == null)
|
||||
|
|
|
@ -41,7 +41,7 @@ public class AdvancedMachineInput extends MachineInput<AdvancedMachineInput>
|
|||
|
||||
public boolean useItem(ItemStack[] inventory, int index, boolean deplete)
|
||||
{
|
||||
if(StackUtils.contains(inventory[index], itemStack))
|
||||
if(inputContains(inventory[index], itemStack))
|
||||
{
|
||||
if(deplete)
|
||||
{
|
||||
|
|
|
@ -56,15 +56,17 @@ public class InfusionInput extends MachineInput<InfusionInput>
|
|||
|
||||
public boolean use(ItemStack[] inventory, int index, InfuseStorage infuseStorage, boolean deplete)
|
||||
{
|
||||
if(StackUtils.contains(inventory[index], inputStack) && infuseStorage.contains(infuse))
|
||||
if(inputContains(inventory[index], inputStack) && infuseStorage.contains(infuse))
|
||||
{
|
||||
if(deplete)
|
||||
{
|
||||
inventory[index] = StackUtils.subtract(inventory[index], inputStack);
|
||||
infuseStorage.subtract(infuse);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -81,6 +83,7 @@ public class InfusionInput extends MachineInput<InfusionInput>
|
|||
{
|
||||
return !other.isValid();
|
||||
}
|
||||
|
||||
return infuse.type == other.infuse.type && StackUtils.equalsWildcardWithNBT(inputStack, other.inputStack);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ItemStackInput extends MachineInput<ItemStackInput>
|
|||
|
||||
public boolean useItemStackFromInventory(ItemStack[] inventory, int index, boolean deplete)
|
||||
{
|
||||
if(StackUtils.contains(inventory[index], ingredient))
|
||||
if(inputContains(inventory[index], ingredient))
|
||||
{
|
||||
if(deplete)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package mekanism.common.recipe.inputs;
|
||||
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class MachineInput<INPUT extends MachineInput<INPUT>>
|
||||
|
@ -21,6 +24,21 @@ public abstract class MachineInput<INPUT extends MachineInput<INPUT>>
|
|||
* @return
|
||||
*/
|
||||
public abstract boolean testEquality(INPUT other);
|
||||
|
||||
public static boolean inputContains(ItemStack container, ItemStack contained)
|
||||
{
|
||||
if(container.stackSize >= contained.stackSize)
|
||||
{
|
||||
if(MekanismUtils.getOreDictName(container).contains("treeSapling"))
|
||||
{
|
||||
return StackUtils.equalsWildcard(contained, container);
|
||||
}
|
||||
|
||||
return StackUtils.equalsWildcardWithNBT(contained, container) && container.stackSize >= contained.stackSize;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
|
|
Loading…
Reference in a new issue