mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-24 22:04:49 +00:00
62 lines
1.4 KiB
Java
62 lines
1.4 KiB
Java
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>>
|
|
{
|
|
public abstract boolean isValid();
|
|
|
|
public abstract INPUT copy();
|
|
|
|
public abstract int hashIngredients();
|
|
|
|
public abstract void load(NBTTagCompound nbtTags);
|
|
|
|
/**
|
|
* Test equality to another input.
|
|
* This should return true if the input matches this one,
|
|
* IGNORING AMOUNTS.
|
|
* Allows usage of HashMap optimisation to get recipes.
|
|
* @param other
|
|
* @return
|
|
*/
|
|
public abstract boolean testEquality(INPUT other);
|
|
|
|
public static boolean inputContains(ItemStack container, ItemStack contained)
|
|
{
|
|
if(container != null && 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()
|
|
{
|
|
return hashIngredients();
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object other)
|
|
{
|
|
if(isInstance(other))
|
|
{
|
|
return testEquality((INPUT)other);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public abstract boolean isInstance(Object other);
|
|
}
|