Fix some potential NPE problems.

This commit is contained in:
Ben Spiers 2014-09-07 00:15:23 +01:00
parent bafdb18756
commit 32b3a5b0ac
5 changed files with 23 additions and 4 deletions

View file

@ -61,13 +61,16 @@ public class AdvancedMachineInput extends MachineInput<AdvancedMachineInput>
@Override
public int hashIngredients()
{
int hash = StackUtils.hashItemStack(itemStack) << 8 | gasType.getID();
return hash;
return StackUtils.hashItemStack(itemStack) << 8 | gasType.getID();
}
@Override
public boolean testEquality(AdvancedMachineInput other)
{
if(!isValid())
{
return !other.isValid();
}
return StackUtils.equalsWildcardWithNBT(itemStack, other.itemStack) && gasType.getID() == other.gasType.getID();
}

View file

@ -147,8 +147,12 @@ public class ChemicalPairInput extends MachineInput<ChemicalPairInput>
@Override
public boolean testEquality(ChemicalPairInput other)
{
return (other.leftGas.hashCode() == leftGas.hashCode() && other.rightGas.hashCode() == rightGas.hashCode())
|| (other.leftGas.hashCode() == rightGas.hashCode() && other.rightGas.hashCode() == leftGas.hashCode());
if(!isValid())
{
return !other.isValid();
}
return (other.leftGas.hashCode() == leftGas.hashCode() && other.rightGas.hashCode() == rightGas.hashCode())
|| (other.leftGas.hashCode() == rightGas.hashCode() && other.rightGas.hashCode() == leftGas.hashCode());
}
@Override

View file

@ -43,6 +43,10 @@ public class FluidInput extends MachineInput<FluidInput>
@Override
public boolean testEquality(FluidInput other)
{
if(!isValid())
{
return !other.isValid();
}
return ingredient.equals(other.ingredient);
}

View file

@ -43,6 +43,10 @@ public class GasInput extends MachineInput<GasInput>
@Override
public boolean testEquality(GasInput other)
{
if(!isValid())
{
return !other.isValid();
}
return other.ingredient.hashCode() == ingredient.hashCode();
}

View file

@ -65,6 +65,10 @@ public class InfusionInput extends MachineInput<InfusionInput>
@Override
public boolean testEquality(InfusionInput other)
{
if(!isValid())
{
return !other.isValid();
}
return infuse.type == other.infuse.type && StackUtils.equalsWildcardWithNBT(inputStack, other.inputStack);
}