Fix NPE making gold casts while they are disabled (#132)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Wilhelm Schusterandgithub-actions[bot] authored and GitHub committed 2024-11-10 20:10:52 +01:00
1 parent 4604856878
commit a7e02d584a
1 file changed
+7 -4
@@ -1,5 +1,7 @@
package tconstruct.library.crafting;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
@@ -32,14 +34,15 @@ public class CastingRecipe {
this(replacement, metal, cast, consume, delay, props, false);
}
public boolean matches(FluidStack metal, ItemStack inputCast) {
if (castingMetal.isFluidEqual(metal)) {
if (cast != null && cast.getItemDamage() == OreDictionary.WILDCARD_VALUE
public boolean matches(@Nullable FluidStack metal, @Nullable ItemStack inputCast) {
if (metal != null && castingMetal.isFluidEqual(metal)) {
if (inputCast != null && cast != null
&& cast.getItemDamage() == OreDictionary.WILDCARD_VALUE
&& inputCast.getItem() == cast.getItem()) {
return true;
} else if (!ignoreNBT && ItemStack.areItemStacksEqual(cast, inputCast)) {
return true;
} else return ignoreNBT && cast != null && inputCast != null && cast.isItemEqual(inputCast);
} else return ignoreNBT && inputCast != null && cast != null && cast.isItemEqual(inputCast);
}
return false;
}