Fix recipe book auto-fill not working for OreDictionary ingredients.
This commit is contained in:
parent
0e789f3543
commit
7930adec70
1 changed files with 6 additions and 5 deletions
|
@ -29,14 +29,13 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class OreIngredient extends Ingredient
|
||||
{
|
||||
private NonNullList<ItemStack> ores;
|
||||
private IntList itemIds = null;
|
||||
private ItemStack[] array = null;
|
||||
private int lastSizeA = -1, lastSizeL = -1;
|
||||
|
||||
public OreIngredient(String ore)
|
||||
{
|
||||
|
@ -48,7 +47,7 @@ public class OreIngredient extends Ingredient
|
|||
@Nonnull
|
||||
public ItemStack[] getMatchingStacks()
|
||||
{
|
||||
if (array == null || this.array.length != ores.size())
|
||||
if (array == null || this.lastSizeA != ores.size())
|
||||
{
|
||||
NonNullList<ItemStack> lst = NonNullList.create();
|
||||
for (ItemStack itemstack : this.ores)
|
||||
|
@ -59,6 +58,7 @@ public class OreIngredient extends Ingredient
|
|||
lst.add(itemstack);
|
||||
}
|
||||
this.array = lst.toArray(new ItemStack[lst.size()]);
|
||||
this.lastSizeA = ores.size();
|
||||
}
|
||||
return this.array;
|
||||
}
|
||||
|
@ -66,10 +66,9 @@ public class OreIngredient extends Ingredient
|
|||
|
||||
@Override
|
||||
@Nonnull
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IntList getValidItemStacksPacked()
|
||||
{
|
||||
if (this.itemIds == null || this.itemIds.size() != ores.size())
|
||||
if (this.itemIds == null || this.lastSizeL != ores.size())
|
||||
{
|
||||
this.itemIds = new IntArrayList(this.ores.size());
|
||||
|
||||
|
@ -89,6 +88,7 @@ public class OreIngredient extends Ingredient
|
|||
}
|
||||
|
||||
this.itemIds.sort(IntComparators.NATURAL_COMPARATOR);
|
||||
this.lastSizeL = ores.size();
|
||||
}
|
||||
|
||||
return this.itemIds;
|
||||
|
@ -112,5 +112,6 @@ public class OreIngredient extends Ingredient
|
|||
protected void invalidate()
|
||||
{
|
||||
this.itemIds = null;
|
||||
this.array = null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue