mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Make getSubItems non-client only. Use it for Ingredient iteration.
This commit is contained in:
1 parent
478a84e748
commit
efd8b38be9
18 files changed
+190
-16
No files matched your search
@@ -527,7 +527,7 @@ public class CraftingHelper {
|
||||
|
||||
registerI("minecraft:item", (context, json) -> Ingredient.fromStacks(CraftingHelper.getItemStackBasic(json, context)));
|
||||
registerI("minecraft:empty", (context, json) -> Ingredient.EMPTY);
|
||||
registerI("minecraft:item_nbt", (context, json) -> Ingredient.fromStacks(CraftingHelper.getItemStack(json, context)));
|
||||
registerI("minecraft:item_nbt", (context, json) -> new IngredientNBT(CraftingHelper.getItemStack(json, context)));
|
||||
registerI("forge:ore_dict", (context, json) -> new OreIngredient(JsonUtils.getString(json, "ore")));
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,6 @@ public class UniversalBucket extends Item
|
||||
return super.getContainerItem(itemStack);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems)
|
||||
{
|
||||
|
||||
@@ -596,7 +596,7 @@ public class OreDictionary
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (target.getItem() == input.getItem() && ((target.getItemDamage() == WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage()));
|
||||
return (target.getItem() == input.getItem() && ((target.getMetadata() == WILDCARD_VALUE && !strict) || target.getMetadata() == input.getMetadata()));
|
||||
}
|
||||
|
||||
//Convenience functions that make for cleaner code mod side. They all drill down to registerOre(String, int, ItemStack)
|
||||
|
||||
@@ -25,6 +25,7 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntComparators;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import net.minecraft.client.util.RecipeItemHelper;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
@@ -35,6 +36,7 @@ public class OreIngredient extends Ingredient
|
||||
{
|
||||
private NonNullList<ItemStack> ores;
|
||||
private IntList itemIds = null;
|
||||
private ItemStack[] array = null;
|
||||
|
||||
public OreIngredient(String ore)
|
||||
{
|
||||
@@ -46,7 +48,19 @@ public class OreIngredient extends Ingredient
|
||||
@Nonnull
|
||||
public ItemStack[] getMatchingStacks()
|
||||
{
|
||||
return ores.toArray(new ItemStack[ores.size()]);
|
||||
if (array == null || this.array.length != ores.size())
|
||||
{
|
||||
NonNullList<ItemStack> lst = NonNullList.create();
|
||||
for (ItemStack itemstack : this.ores)
|
||||
{
|
||||
if (itemstack.getMetadata() == OreDictionary.WILDCARD_VALUE)
|
||||
itemstack.getItem().getSubItems(CreativeTabs.SEARCH, lst);
|
||||
else
|
||||
lst.add(itemstack);
|
||||
}
|
||||
this.array = lst.toArray(new ItemStack[lst.size()]);
|
||||
}
|
||||
return this.array;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +75,17 @@ public class OreIngredient extends Ingredient
|
||||
|
||||
for (ItemStack itemstack : this.ores)
|
||||
{
|
||||
this.itemIds.add(RecipeItemHelper.pack(itemstack));
|
||||
if (itemstack.getMetadata() == OreDictionary.WILDCARD_VALUE)
|
||||
{
|
||||
NonNullList<ItemStack> lst = NonNullList.create();
|
||||
itemstack.getItem().getSubItems(CreativeTabs.SEARCH, lst);
|
||||
for (ItemStack item : lst)
|
||||
this.itemIds.add(RecipeItemHelper.pack(item));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.itemIds.add(RecipeItemHelper.pack(itemstack));
|
||||
}
|
||||
}
|
||||
|
||||
this.itemIds.sort(IntComparators.NATURAL_COMPARATOR);
|
||||
|
||||
Reference in new issue
Block a user