mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 21:20:06 +00:00
Add a way to ignore NBT in casting recipes (#43)
* Add a way to ignore NBT in casting recipes * use WILDCARD_VALUE * fix NPE
This commit is contained in:
1 parent
fdf4e1f212
commit
3394029e1d
2 files changed
+20
-7
No files matched your search
@@ -2,6 +2,7 @@ package tconstruct.library.crafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import tconstruct.library.client.FluidRenderProperties;
|
||||
|
||||
public class CastingRecipe
|
||||
@@ -12,8 +13,9 @@ public class CastingRecipe
|
||||
public boolean consumeCast;
|
||||
public int coolTime;
|
||||
public FluidRenderProperties fluidRenderProperties;
|
||||
public boolean ignoreNBT;
|
||||
|
||||
public CastingRecipe(ItemStack replacement, FluidStack metal, ItemStack cast, boolean consume, int delay, FluidRenderProperties props)
|
||||
public CastingRecipe(ItemStack replacement, FluidStack metal, ItemStack cast, boolean consume, int delay, FluidRenderProperties props, boolean ignoreNBT)
|
||||
{
|
||||
castingMetal = metal;
|
||||
this.cast = cast;
|
||||
@@ -21,16 +23,26 @@ public class CastingRecipe
|
||||
consumeCast = consume;
|
||||
coolTime = delay;
|
||||
fluidRenderProperties = props;
|
||||
this.ignoreNBT = ignoreNBT;
|
||||
}
|
||||
|
||||
public CastingRecipe(ItemStack replacement, FluidStack metal, ItemStack cast, boolean consume, int delay, FluidRenderProperties props)
|
||||
{
|
||||
this(replacement, metal, cast, consume, delay, props, false);
|
||||
}
|
||||
|
||||
public boolean matches (FluidStack metal, ItemStack inputCast)
|
||||
{
|
||||
if (castingMetal.isFluidEqual(metal) && ((cast != null && cast.getItemDamage() == Short.MAX_VALUE && inputCast.getItem() == cast.getItem()) || ItemStack.areItemStacksEqual(this.cast, inputCast)))
|
||||
{
|
||||
return true;
|
||||
if (castingMetal.isFluidEqual(metal)) {
|
||||
if (cast != null && cast.getItemDamage() == OreDictionary.WILDCARD_VALUE && inputCast.getItem() == cast.getItem()) {
|
||||
return true;
|
||||
} else if (!ignoreNBT && ItemStack.areItemStacksEqual(cast, inputCast)) {
|
||||
return true;
|
||||
} else if (ignoreNBT && cast != null && inputCast != null && cast.isItemEqual(inputCast)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getResult ()
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import tconstruct.library.crafting.FluidType;
|
||||
import tconstruct.library.crafting.LiquidCasting;
|
||||
import tconstruct.library.crafting.Smeltery;
|
||||
@@ -684,7 +685,7 @@ public class TinkerSmeltery
|
||||
goldAmount = new FluidStack(TinkerSmeltery.moltenGoldFluid, TConstruct.ingotLiquidValue * 8);
|
||||
tableCasting.addCastingRecipe(new ItemStack(Items.golden_apple, 1), goldAmount, new ItemStack(Items.apple), true, 50);
|
||||
if (TinkerWorld.goldHead != null)
|
||||
tableCasting.addCastingRecipe(new ItemStack(TinkerWorld.goldHead), goldAmount, new ItemStack(Items.skull, 1, 3), true, 50);
|
||||
tableCasting.addCustomCastingRecipe(new CastingRecipe(new ItemStack(TinkerWorld.goldHead), goldAmount, new ItemStack(Items.skull, 1, 3), true, 50, null, true));
|
||||
|
||||
|
||||
// Ensure TConstruct ingots are always first. Otherwise you might get ingots from other mods from casting
|
||||
|
||||
Reference in new issue
Block a user