Migrate most of the OreDictionary to tags.

This commit is contained in:
LexManos 2018-09-16 16:28:21 -07:00
parent 231dfeee31
commit afead63381
103 changed files with 733 additions and 511 deletions

View file

@ -1,27 +0,0 @@
--- a/net/minecraft/tags/ItemTags.java
+++ b/net/minecraft/tags/ItemTags.java
@@ -41,6 +41,24 @@
public static final Tag<Item> field_212187_B = func_199901_a("trapdoors");
public static final Tag<Item> field_202902_o = func_199901_a("boats");
public static final Tag<Item> field_206964_G = func_199901_a("fishes");
+ public static final Tag<Item> DYES = func_199901_a("dyes");
+ public static final Tag<Item> DYES_BLACK = func_199901_a("dyes_black");
+ public static final Tag<Item> DYES_RED = func_199901_a("dyes_red");
+ public static final Tag<Item> DYES_GREEN = func_199901_a("dyes_green");
+ public static final Tag<Item> DYES_BROWN = func_199901_a("dyes_brown");
+ public static final Tag<Item> DYES_BLUE = func_199901_a("dyes_blue");
+ public static final Tag<Item> DYES_PURPLE = func_199901_a("dyes_purple");
+ public static final Tag<Item> DYES_CYAN = func_199901_a("dyes_cyan");
+ public static final Tag<Item> DYES_LIGHT_GRAY = func_199901_a("dyes_light_gray");
+ public static final Tag<Item> DYES_GRAY = func_199901_a("dyes_gray");
+ public static final Tag<Item> DYES_PINK = func_199901_a("dyes_pink");
+ public static final Tag<Item> DYES_LIME = func_199901_a("dyes_lime");
+ public static final Tag<Item> DYES_YELLOW = func_199901_a("dyes_yellow");
+ public static final Tag<Item> DYES_LIGHT_BLUE = func_199901_a("dyes_light_blue");
+ public static final Tag<Item> DYES_MAGENTA = func_199901_a("dyes_magenta");
+ public static final Tag<Item> DYES_ORANGE = func_199901_a("dyes_orange");
+ public static final Tag<Item> DYES_WHITE = func_199901_a("dyes_white");
+ public static final Tag<Item> MUSIC_DISCS = func_199901_a("music_discs");
public static void func_199902_a(TagCollection<Item> p_199902_0_) {
field_199906_c = p_199902_0_;

View file

@ -0,0 +1,145 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.common;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.util.ResourceLocation;
public class Tags
{
public static class Blocks
{
public static final Tag<Block> CHESTS = tag("chests");
public static final Tag<Block> CHESTS_ENDER = tag("chests/ender");
public static final Tag<Block> CHESTS_TRAPPED = tag("chests/trapped");
public static final Tag<Block> CHESTS_WOODEN = tag("chests/wooden");
public static final Tag<Block> COBBLESTONE = tag("cobblestone");
public static final Tag<Block> FENCE_GATES = tag("fence_gates");
public static final Tag<Block> FENCE_GATES_WOODEN = tag("fence_gates/wooden");
public static final Tag<Block> FENCES = tag("fences");
public static final Tag<Block> FENCES_NETHER_BRRICK = tag("fences/nether_brick");
public static final Tag<Block> FENCES_WOODEN = tag("fences/wooden");
public static final Tag<Block> ORES = tag("ores");
public static final Tag<Block> ORES_COAL = tag("ores/coal");
public static final Tag<Block> ORES_DIAMOND = tag("ores/diamond");
public static final Tag<Block> ORES_EMERALD = tag("ores/emerald");
public static final Tag<Block> ORES_GOLD = tag("ores/gold");
public static final Tag<Block> ORES_IRON = tag("ores/iron");
public static final Tag<Block> ORES_LAPIS = tag("ores/lapis");
public static final Tag<Block> ORES_QUARTZ = tag("ores/quartz");
public static final Tag<Block> ORES_REDSTONE = tag("ores/redstone");
public static final Tag<Block> STONE = tag("stone");
public static final Tag<Block> STORAGE_BLOCKS = tag("storage_blocks");
public static final Tag<Block> STORAGE_BLOCKS_COAL = tag("storage_blocks/coal");
public static final Tag<Block> STORAGE_BLOCKS_DIAMOND = tag("storage_blocks/diamond");
public static final Tag<Block> STORAGE_BLOCKS_EMERALD = tag("storage_blocks/emerald");
public static final Tag<Block> STORAGE_BLOCKS_GOLD = tag("storage_blocks/gold");
public static final Tag<Block> STORAGE_BLOCKS_IRON = tag("storage_blocks/iron");
public static final Tag<Block> STORAGE_BLOCKS_LAPIS = tag("storage_blocks/lapis");
public static final Tag<Block> STORAGE_BLOCKS_QUARTZ = tag("storage_blocks/quartz");
public static final Tag<Block> STORAGE_BLOCKS_REDSTONE = tag("storage_blocks/redstone");
private static Tag<Block> tag(String name)
{
return new BlockTags.Wrapper(new ResourceLocation("forge", name));
}
}
public static class Items
{
public static final Tag<Item> CHESTS = tag("chests");
public static final Tag<Item> CHESTS_ENDER = tag("chests/ender");
public static final Tag<Item> CHESTS_TRAPPED = tag("chests/trapped");
public static final Tag<Item> CHESTS_WOODEN = tag("chests/wooden");
public static final Tag<Item> COBBLESTONE = tag("cobblestone");
public static final Tag<Item> DUSTS = tag("dusts");
public static final Tag<Item> DUSTS_PRISMARINE = tag("dusts/prismarine");
public static final Tag<Item> DUSTS_REDSTONE = tag("dusts/redstone");
public static final Tag<Item> DUSTS_GLOWSTONE = tag("dusts/glowstone");
public static final Tag<Item> DYES = tag("dyes");
public static final Tag<Item> DYES_BLACK = tag("dyes/black");
public static final Tag<Item> DYES_RED = tag("dyes/red");
public static final Tag<Item> DYES_GREEN = tag("dyes/green");
public static final Tag<Item> DYES_BROWN = tag("dyes/brown");
public static final Tag<Item> DYES_BLUE = tag("dyes/blue");
public static final Tag<Item> DYES_PURPLE = tag("dyes/purple");
public static final Tag<Item> DYES_CYAN = tag("dyes/cyan");
public static final Tag<Item> DYES_LIGHT_GRAY = tag("dyes/light_gray");
public static final Tag<Item> DYES_GRAY = tag("dyes/gray");
public static final Tag<Item> DYES_PINK = tag("dyes/pink");
public static final Tag<Item> DYES_LIME = tag("dyes/lime");
public static final Tag<Item> DYES_YELLOW = tag("dyes/yellow");
public static final Tag<Item> DYES_LIGHT_BLUE = tag("dyes/light_blue");
public static final Tag<Item> DYES_MAGENTA = tag("dyes/magenta");
public static final Tag<Item> DYES_ORANGE = tag("dyes/orange");
public static final Tag<Item> DYES_WHITE = tag("dyes/white");
public static final Tag<Item> FENCE_GATES = tag("fence_gates");
public static final Tag<Item> FENCE_GATES_WOODEN = tag("fence_gates/wooden");
public static final Tag<Item> FENCES = tag("fences");
public static final Tag<Item> FENCES_NETHER_BRRICK = tag("fences/nether_brick");
public static final Tag<Item> FENCES_WOODEN = tag("fences/wooden");
public static final Tag<Item> GEMS = tag("gems");
public static final Tag<Item> GEMS_DIAMOND = tag("gems/diamond");
public static final Tag<Item> GEMS_EMERALD = tag("gems/emerald");
public static final Tag<Item> GEMS_LAPIS = tag("gems/lapis");
public static final Tag<Item> GEMS_PRISMARINE = tag("gems/prismarine");
public static final Tag<Item> GEMS_QUARRTZ = tag("gems/quartz");
public static final Tag<Item> INGOTS = tag("ingots");
public static final Tag<Item> INGOTS_BRICK = tag("ingots/brrick");
public static final Tag<Item> INGOTS_GOLD = tag("ingots/gold");
public static final Tag<Item> INGOTS_IRON = tag("ingots/iron");
public static final Tag<Item> INGOTS_NETHER_BRICK = tag("ingots/nether_brick");
public static final Tag<Item> MUSIC_DISCS = tag("music_discs");
public static final Tag<Item> NUGGETS = tag("nuggets");
public static final Tag<Item> NUGGETS_GOLD = tag("nuggets/gold");
public static final Tag<Item> NUGGETS_IRRON = tag("nuggets/iron");
public static final Tag<Item> ORES = tag("ores");
public static final Tag<Item> ORES_COAL = tag("ores/coal");
public static final Tag<Item> ORES_DIAMOND = tag("ores/diamond");
public static final Tag<Item> ORES_EMERALD = tag("ores/emerald");
public static final Tag<Item> ORES_GOLD = tag("ores/gold");
public static final Tag<Item> ORES_IRON = tag("ores/iron");
public static final Tag<Item> ORES_LAPIS = tag("ores/lapis");
public static final Tag<Item> ORES_QUARTZ = tag("ores/quartz");
public static final Tag<Item> ORES_REDSTONE = tag("ores/redstone");
public static final Tag<Item> RODS = tag("rods");
public static final Tag<Item> RODS_BLAZE = tag("rods/blaze");
public static final Tag<Item> RODS_WOODEN = tag("rods/wooden");
public static final Tag<Item> STONE = tag("stone");
public static final Tag<Item> STORAGE_BLOCKS = tag("storage_blocks");
public static final Tag<Item> STORAGE_BLOCKS_COAL = tag("storage_blocks/coal");
public static final Tag<Item> STORAGE_BLOCKS_DIAMOND = tag("storage_blocks/diamond");
public static final Tag<Item> STORAGE_BLOCKS_EMERALD = tag("storage_blocks/emerald");
public static final Tag<Item> STORAGE_BLOCKS_GOLD = tag("storage_blocks/gold");
public static final Tag<Item> STORAGE_BLOCKS_IRON = tag("storage_blocks/iron");
public static final Tag<Item> STORAGE_BLOCKS_LAPIS = tag("storage_blocks/lapis");
public static final Tag<Item> STORAGE_BLOCKS_QUARTZ = tag("storage_blocks/quartz");
public static final Tag<Item> STORAGE_BLOCKS_REDSTONE = tag("storage_blocks/redstone");
private static Tag<Item> tag(String name)
{
return new ItemTags.Wrapper(new ResourceLocation("forge", name));
}
}
}

View file

@ -18,139 +18,20 @@
*/ */
package net.minecraftforge.oredict; package net.minecraftforge.oredict;
/*
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import net.minecraft.block.BlockPrismarine;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.ModContainer;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.common.MinecraftForge;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Loader;
import javax.annotation.Nonnull;
*/
public class OreDictionary public class OreDictionary
{ {
/* /*
private static final boolean DEBUG = false;
private static boolean hasInit = false;
private static List<String> idToName = new ArrayList<String>();
private static Map<String, Integer> nameToId = new HashMap<String, Integer>(128);
private static List<NonNullList<ItemStack>> idToStack = Lists.newArrayList();
private static List<NonNullList<ItemStack>> idToStackUn = Lists.newArrayList();
private static Map<Integer, List<Integer>> stackToId = Maps.newHashMapWithExpectedSize((int)(128 * 0.75));
public static final NonNullList<ItemStack> EMPTY_LIST = NonNullList.create();
/**
* Minecraft changed from -1 to Short.MAX_VALUE in 1.5 release for the "block wildcard". Use this in case it
* changes again.
* /
public static final int WILDCARD_VALUE = Short.MAX_VALUE;
static {
initVanillaEntries();
}
private static void initVanillaEntries() private static void initVanillaEntries()
{ {
if (!hasInit) if (!hasInit)
{ {
// tree- and wood-related things // tree- and wood-related things
registerOre("logWood", new ItemStack(Blocks.LOG, 1, WILDCARD_VALUE));
registerOre("logWood", new ItemStack(Blocks.LOG2, 1, WILDCARD_VALUE));
registerOre("plankWood", new ItemStack(Blocks.PLANKS, 1, WILDCARD_VALUE));
registerOre("slabWood", new ItemStack(Blocks.WOODEN_SLAB, 1, WILDCARD_VALUE));
registerOre("stairWood", Blocks.OAK_STAIRS);
registerOre("stairWood", Blocks.SPRUCE_STAIRS);
registerOre("stairWood", Blocks.BIRCH_STAIRS);
registerOre("stairWood", Blocks.JUNGLE_STAIRS);
registerOre("stairWood", Blocks.ACACIA_STAIRS);
registerOre("stairWood", Blocks.DARK_OAK_STAIRS);
registerOre("fenceWood", Blocks.OAK_FENCE);
registerOre("fenceWood", Blocks.SPRUCE_FENCE);
registerOre("fenceWood", Blocks.BIRCH_FENCE);
registerOre("fenceWood", Blocks.JUNGLE_FENCE);
registerOre("fenceWood", Blocks.DARK_OAK_FENCE);
registerOre("fenceWood", Blocks.ACACIA_FENCE);
registerOre("fenceGateWood", Blocks.OAK_FENCE_GATE);
registerOre("fenceGateWood", Blocks.SPRUCE_FENCE_GATE);
registerOre("fenceGateWood", Blocks.BIRCH_FENCE_GATE);
registerOre("fenceGateWood", Blocks.JUNGLE_FENCE_GATE);
registerOre("fenceGateWood", Blocks.DARK_OAK_FENCE_GATE);
registerOre("fenceGateWood", Blocks.ACACIA_FENCE_GATE);
registerOre("doorWood", Items.ACACIA_DOOR);
registerOre("doorWood", Items.BIRCH_DOOR);
registerOre("doorWood", Items.DARK_OAK_DOOR);
registerOre("doorWood", Items.OAK_DOOR);
registerOre("doorWood", Items.JUNGLE_DOOR);
registerOre("doorWood", Items.SPRUCE_DOOR);
registerOre("stickWood", Items.STICK);
registerOre("treeSapling", new ItemStack(Blocks.SAPLING, 1, WILDCARD_VALUE));
registerOre("treeLeaves", new ItemStack(Blocks.LEAVES, 1, WILDCARD_VALUE)); registerOre("treeLeaves", new ItemStack(Blocks.LEAVES, 1, WILDCARD_VALUE));
registerOre("treeLeaves", new ItemStack(Blocks.LEAVES2, 1, WILDCARD_VALUE)); registerOre("treeLeaves", new ItemStack(Blocks.LEAVES2, 1, WILDCARD_VALUE));
registerOre("vine", Blocks.VINE); registerOre("vine", Blocks.VINE);
// Ores
registerOre("oreGold", Blocks.GOLD_ORE);
registerOre("oreIron", Blocks.IRON_ORE);
registerOre("oreLapis", Blocks.LAPIS_ORE);
registerOre("oreDiamond", Blocks.DIAMOND_ORE);
registerOre("oreRedstone", Blocks.REDSTONE_ORE);
registerOre("oreEmerald", Blocks.EMERALD_ORE);
registerOre("oreQuartz", Blocks.QUARTZ_ORE);
registerOre("oreCoal", Blocks.COAL_ORE);
// ingots/nuggets
registerOre("ingotIron", Items.IRON_INGOT);
registerOre("ingotGold", Items.GOLD_INGOT);
registerOre("ingotBrick", Items.BRICK);
registerOre("ingotBrickNether", Items.NETHERBRICK);
registerOre("nuggetGold", Items.GOLD_NUGGET);
registerOre("nuggetIron", Items.IRON_NUGGET);
// gems and dusts
registerOre("gemDiamond", Items.DIAMOND);
registerOre("gemEmerald", Items.EMERALD);
registerOre("gemQuartz", Items.QUARTZ);
registerOre("gemPrismarine", Items.PRISMARINE_SHARD);
registerOre("dustPrismarine", Items.PRISMARINE_CRYSTALS);
registerOre("dustRedstone", Items.REDSTONE);
registerOre("dustGlowstone", Items.GLOWSTONE_DUST);
registerOre("gemLapis", new ItemStack(Items.DYE, 1, 4));
// storage blocks
registerOre("blockGold", Blocks.GOLD_BLOCK);
registerOre("blockIron", Blocks.IRON_BLOCK);
registerOre("blockLapis", Blocks.LAPIS_BLOCK);
registerOre("blockDiamond", Blocks.DIAMOND_BLOCK);
registerOre("blockRedstone", Blocks.REDSTONE_BLOCK);
registerOre("blockEmerald", Blocks.EMERALD_BLOCK);
registerOre("blockQuartz", Blocks.QUARTZ_BLOCK);
registerOre("blockCoal", Blocks.COAL_BLOCK);
// crops // crops
registerOre("cropWheat", Items.WHEAT); registerOre("cropWheat", Items.WHEAT);
registerOre("cropPotato", Items.POTATO); registerOre("cropPotato", Items.POTATO);
@ -160,7 +41,6 @@ public class OreDictionary
registerOre("blockCactus", Blocks.CACTUS); registerOre("blockCactus", Blocks.CACTUS);
// misc materials // misc materials
registerOre("dye", new ItemStack(Items.DYE, 1, WILDCARD_VALUE));
registerOre("paper", new ItemStack(Items.PAPER)); registerOre("paper", new ItemStack(Items.PAPER));
// mob drops // mob drops
@ -177,10 +57,7 @@ public class OreDictionary
// blocks // blocks
registerOre("dirt", Blocks.DIRT); registerOre("dirt", Blocks.DIRT);
registerOre("grass", Blocks.GRASS); registerOre("grass", Blocks.GRASS);
registerOre("stone", Blocks.STONE);
registerOre("cobblestone", Blocks.COBBLESTONE);
registerOre("gravel", Blocks.GRAVEL); registerOre("gravel", Blocks.GRAVEL);
registerOre("sand", new ItemStack(Blocks.SAND, 1, WILDCARD_VALUE));
registerOre("sandstone", new ItemStack(Blocks.SANDSTONE, 1, WILDCARD_VALUE)); registerOre("sandstone", new ItemStack(Blocks.SANDSTONE, 1, WILDCARD_VALUE));
registerOre("sandstone", new ItemStack(Blocks.RED_SANDSTONE, 1, WILDCARD_VALUE)); registerOre("sandstone", new ItemStack(Blocks.RED_SANDSTONE, 1, WILDCARD_VALUE));
registerOre("netherrack", Blocks.NETHERRACK); registerOre("netherrack", Blocks.NETHERRACK);
@ -193,12 +70,6 @@ public class OreDictionary
registerOre("blockPrismarine", new ItemStack(Blocks.PRISMARINE, 1, BlockPrismarine.EnumType.ROUGH.getMetadata())); registerOre("blockPrismarine", new ItemStack(Blocks.PRISMARINE, 1, BlockPrismarine.EnumType.ROUGH.getMetadata()));
registerOre("blockPrismarineBrick", new ItemStack(Blocks.PRISMARINE, 1, BlockPrismarine.EnumType.BRICKS.getMetadata())); registerOre("blockPrismarineBrick", new ItemStack(Blocks.PRISMARINE, 1, BlockPrismarine.EnumType.BRICKS.getMetadata()));
registerOre("blockPrismarineDark", new ItemStack(Blocks.PRISMARINE, 1, BlockPrismarine.EnumType.DARK.getMetadata())); registerOre("blockPrismarineDark", new ItemStack(Blocks.PRISMARINE, 1, BlockPrismarine.EnumType.DARK.getMetadata()));
registerOre("stoneGranite", new ItemStack(Blocks.STONE, 1, 1));
registerOre("stoneGranitePolished", new ItemStack(Blocks.STONE, 1, 2));
registerOre("stoneDiorite", new ItemStack(Blocks.STONE, 1, 3));
registerOre("stoneDioritePolished", new ItemStack(Blocks.STONE, 1, 4));
registerOre("stoneAndesite", new ItemStack(Blocks.STONE, 1, 5));
registerOre("stoneAndesitePolished", new ItemStack(Blocks.STONE, 1, 6));
registerOre("blockGlassColorless", Blocks.GLASS); registerOre("blockGlassColorless", Blocks.GLASS);
registerOre("blockGlass", Blocks.GLASS); registerOre("blockGlass", Blocks.GLASS);
registerOre("blockGlass", new ItemStack(Blocks.STAINED_GLASS, 1, WILDCARD_VALUE)); registerOre("blockGlass", new ItemStack(Blocks.STAINED_GLASS, 1, WILDCARD_VALUE));
@ -207,14 +78,6 @@ public class OreDictionary
registerOre("paneGlass", Blocks.GLASS_PANE); registerOre("paneGlass", Blocks.GLASS_PANE);
registerOre("paneGlass", new ItemStack(Blocks.STAINED_GLASS_PANE, 1, WILDCARD_VALUE)); registerOre("paneGlass", new ItemStack(Blocks.STAINED_GLASS_PANE, 1, WILDCARD_VALUE));
//paneGlass{Color} is added below with dyes //paneGlass{Color} is added below with dyes
// chests
registerOre("chest", Blocks.CHEST);
registerOre("chest", Blocks.ENDER_CHEST);
registerOre("chest", Blocks.TRAPPED_CHEST);
registerOre("chestWood", Blocks.CHEST);
registerOre("chestEnder", Blocks.ENDER_CHEST);
registerOre("chestTrapped", Blocks.TRAPPED_CHEST);
} }
// Build our list of items to replace with ore tags // Build our list of items to replace with ore tags
@ -303,12 +166,10 @@ public class OreDictionary
for(int i = 0; i < 16; i++) for(int i = 0; i < 16; i++)
{ {
ItemStack dye = new ItemStack(Items.DYE, 1, i);
ItemStack block = new ItemStack(Blocks.STAINED_GLASS, 1, 15 - i); ItemStack block = new ItemStack(Blocks.STAINED_GLASS, 1, 15 - i);
ItemStack pane = new ItemStack(Blocks.STAINED_GLASS_PANE, 1, 15 - i); ItemStack pane = new ItemStack(Blocks.STAINED_GLASS_PANE, 1, 15 - i);
if (!hasInit) if (!hasInit)
{ {
registerOre("dye" + dyes[i], dye);
registerOre("blockGlass" + dyes[i], block); registerOre("blockGlass" + dyes[i], block);
registerOre("paneGlass" + dyes[i], pane); registerOre("paneGlass" + dyes[i], pane);
} }
@ -434,308 +295,5 @@ public class OreDictionary
LOGGER.info("Replaced {} ore ingredients", replaced); LOGGER.info("Replaced {} ore ingredients", replaced);
} }
/**
* Gets the integer ID for the specified ore name.
* If the name does not have a ID it assigns it a new one.
*
* @param name The unique name for this ore 'oreIron', 'ingotIron', etc..
* @return A number representing the ID for this ore type
* /
public static int getOreID(String name)
{
Integer val = nameToId.get(name);
if (val == null)
{
idToName.add(name);
val = idToName.size() - 1; //0 indexed
nameToId.put(name, val);
NonNullList<ItemStack> back = NonNullList.create();
idToStack.add(back);
idToStackUn.add(back);
}
return val;
}
/**
* Reverse of getOreID, will not create new entries.
*
* @param id The ID to translate to a string
* @return The String name, or "Unknown" if not found.
* /
public static String getOreName(int id)
{
return (id >= 0 && id < idToName.size()) ? idToName.get(id) : "Unknown";
}
/**
* Gets all the integer ID for the ores that the specified item stack is registered to.
* If the item stack is not linked to any ore, this will return an empty array and no new entry will be created.
*
* @param stack The item stack of the ore.
* @return An array of ids that this ore is registered as.
* /
public static int[] getOreIDs(@Nonnull ItemStack stack)
{
if (stack.isEmpty()) throw new IllegalArgumentException("Stack can not be invalid!");
Set<Integer> set = new HashSet<Integer>();
// HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not aware of the item yet
// IT should be noted that -1 will fail the gate further down, if an entry already exists with value -1 for this name. This is what is broken and being warned about.
// APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes - you can't make them properly until you've registered with the game.
ResourceLocation registryName = stack.getItem().delegate.name();
int id;
if (registryName == null)
{
LOGGER.debug("Attempted to find the oreIDs for an unregistered object ({}). This won't work very well.", stack);
return new int[0];
}
else
{
id = Item.REGISTRY.getIDForObject(stack.getItem().delegate.get());
}
List<Integer> ids = stackToId.get(id);
if (ids != null) set.addAll(ids);
ids = stackToId.get(id | ((stack.getItemDamage() + 1) << 16));
if (ids != null) set.addAll(ids);
Integer[] tmp = set.toArray(new Integer[set.size()]);
int[] ret = new int[tmp.length];
for (int x = 0; x < tmp.length; x++)
ret[x] = tmp[x];
return ret;
}
/**
* Retrieves the ArrayList of items that are registered to this ore type.
* Creates the list as empty if it did not exist.
*
* The returned List is unmodifiable, but will be updated if a new ore
* is registered using registerOre
*
* @param name The ore name, directly calls getOreID
* @return An arrayList containing ItemStacks registered for this ore
* /
public static NonNullList<ItemStack> getOres(String name)
{
return getOres(getOreID(name));
}
/**
* Retrieves the List of items that are registered to this ore type at this instant.
* If the flag is TRUE, then it will create the list as empty if it did not exist.
*
* This option should be used by modders who are doing blanket scans in postInit.
* It greatly reduces clutter in the OreDictionary is the responsible and proper
* way to use the dictionary in a large number of cases.
*
* The other function above is utilized in OreRecipe and is required for the
* operation of that code.
*
* @param name The ore name, directly calls getOreID if the flag is TRUE
* @param alwaysCreateEntry Flag - should a new entry be created if empty
* @return An arraylist containing ItemStacks registered for this ore
* /
public static NonNullList<ItemStack> getOres(String name, boolean alwaysCreateEntry)
{
if (alwaysCreateEntry) {
return getOres(getOreID(name));
}
return nameToId.get(name) != null ? getOres(getOreID(name)) : EMPTY_LIST;
}
/**
* Returns whether or not an oreName exists in the dictionary.
* This function can be used to safely query the Ore Dictionary without
* adding needless clutter to the underlying map structure.
*
* Please use this when possible and appropriate.
*
* @param name The ore name
* @return Whether or not that name is in the Ore Dictionary.
* /
public static boolean doesOreNameExist(String name)
{
return nameToId.get(name) != null;
}
/**
* Retrieves a list of all unique ore names that are already registered.
*
* @return All unique ore names that are currently registered.
* /
public static String[] getOreNames()
{
return idToName.toArray(new String[idToName.size()]);
}
/**
* Retrieves the List of items that are registered to this ore type.
* Creates the list as empty if it did not exist.
*
* @param id The ore ID, see getOreID
* @return An List containing ItemStacks registered for this ore
* /
private static NonNullList<ItemStack> getOres(int id)
{
return idToStackUn.size() > id ? idToStackUn.get(id) : EMPTY_LIST;
}
private static boolean containsMatch(boolean strict, ItemStack[] inputs, @Nonnull ItemStack... targets)
{
for (ItemStack input : inputs)
{
for (ItemStack target : targets)
{
if (itemMatches(target, input, strict))
{
return true;
}
}
}
return false;
}
public static boolean containsMatch(boolean strict, NonNullList<ItemStack> inputs, @Nonnull ItemStack... targets)
{
for (ItemStack input : inputs)
{
for (ItemStack target : targets)
{
if (itemMatches(target, input, strict))
{
return true;
}
}
}
return false;
}
public static boolean itemMatches(@Nonnull ItemStack target, @Nonnull ItemStack input, boolean strict)
{
if (input.isEmpty() && !target.isEmpty() || !input.isEmpty() && target.isEmpty())
{
return false;
}
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)
public static void registerOre(String name, Item ore){ registerOre(name, new ItemStack(ore)); }
public static void registerOre(String name, Block ore){ registerOre(name, new ItemStack(ore)); }
public static void registerOre(String name, @Nonnull ItemStack ore){ registerOreImpl(name, ore); }
/**
* Registers a ore item into the dictionary.
* Raises the registerOre function in all registered handlers.
*
* @param name The name of the ore
* @param ore The ore's ItemStack
* /
private static void registerOreImpl(String name, @Nonnull ItemStack ore)
{
if ("Unknown".equals(name)) return; //prevent bad IDs.
if (ore.isEmpty())
{
FMLLog.bigWarning("Invalid registration attempt for an Ore Dictionary item with name {} has occurred. The registration has been denied to prevent crashes. The mod responsible for the registration needs to correct this.", name);
return; //prevent bad ItemStacks.
}
int oreID = getOreID(name);
// HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not aware of the item yet
// IT should be noted that -1 will fail the gate further down, if an entry already exists with value -1 for this name. This is what is broken and being warned about.
// APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes - you can't make them properly until you've registered with the game.
ResourceLocation registryName = ore.getItem().delegate.name();
int hash;
if (registryName == null)
{
ModContainer modContainer = Loader.instance().activeModContainer();
String modContainerName = modContainer == null ? null : modContainer.getName();
FMLLog.bigWarning("A broken ore dictionary registration with name {} has occurred. It adds an item (type: {}) which is currently unknown to the game registry. This dictionary item can only support a single value when"
+ " registered with ores like this, and NO I am not going to turn this spam off. Just register your ore dictionary entries after the GameRegistry.\n"
+ "TO USERS: YES this is a BUG in the mod " + modContainerName + " report it to them!", name, ore.getItem().getClass());
hash = -1;
}
else
{
hash = Item.REGISTRY.getIDForObject(ore.getItem().delegate.get());
}
if (ore.getItemDamage() != WILDCARD_VALUE)
{
hash |= ((ore.getItemDamage() + 1) << 16); // +1 so 0 is significant
}
//Add things to the baked version, and prevent duplicates
List<Integer> ids = stackToId.get(hash);
if (ids != null && ids.contains(oreID)) return;
if (ids == null)
{
ids = Lists.newArrayList();
stackToId.put(hash, ids);
}
ids.add(oreID);
//Add to the unbaked version
ore = ore.copy();
idToStack.get(oreID).add(ore);
MinecraftForge.EVENT_BUS.post(new OreRegisterEvent(name, ore));
}
public static class OreRegisterEvent extends net.minecraftforge.eventbus.api.Event
{
private final String Name;
private final ItemStack Ore;
public OreRegisterEvent(String name, @Nonnull ItemStack ore)
{
this.Name = name;
this.Ore = ore;
}
public String getName()
{
return Name;
}
@Nonnull
public ItemStack getOre()
{
return Ore;
}
}
public static void rebakeMap()
{
//System.out.println("Baking OreDictionary:");
stackToId.clear();
for (int id = 0; id < idToStack.size(); id++)
{
NonNullList<ItemStack> ores = idToStack.get(id);
if (ores == null) continue;
for (ItemStack ore : ores)
{
// HACK: use the registry name's ID. It is unique and it knows about substitutions
ResourceLocation name = ore.getItem().delegate.name();
int hash;
if (name == null)
{
LOGGER.debug("Defaulting unregistered ore dictionary entry for ore dictionary {}: type {} to -1", getOreName(id), ore.getItem().getClass());
hash = -1;
}
else
{
hash = Item.REGISTRY.getIDForObject(ore.getItem().delegate.get());
}
if (ore.getItemDamage() != WILDCARD_VALUE)
{
hash |= ((ore.getItemDamage() + 1) << 16); // +1 so meta 0 is significant
}
List<Integer> ids = stackToId.computeIfAbsent(hash, k -> Lists.newArrayList());
ids.add(id);
//System.out.println(id + " " + getOreName(id) + " " + Integer.toHexString(hash) + " " + ore);
}
}
}
*/ */
} }

View file

@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"#forge:chests/ender",
"#forge:chests/trapped",
"#forge:chests/wooden"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:ender_chest"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:trapped_chest"
]
}

View file

@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"minecraft:chest",
"minecraft:trapped_chest"
]
}

View file

@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"minecraft:cobblestone",
"minecraft:infested_cobblestone",
"minecraft:mossy_cobblestone"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"#forge:fence_gates/wooden"
]
}

View file

@ -0,0 +1,11 @@
{
"replace": false,
"values": [
"minecraft:oak_fence_gate",
"minecraft:spruce_fence_gate"
"minecraft:birch_fence_gate",
"minecraft:jungle_fence_gate",
"minecraft:acacia_fence_gate",
"minecraft:dark_oak_fence_gate"
]
}

View file

@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"#forge:fences/nether_brick",
"#forge:fences/wooden"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:nether_brick_fence"
]
}

View file

@ -0,0 +1,11 @@
{
"replace": false,
"values": [
"minecraft:oak_fence",
"minecraft:spruce_fence"
"minecraft:birch_fence",
"minecraft:jungle_fence",
"minecraft:acacia_fence",
"minecraft:dark_oak_fence"
]
}

View file

@ -0,0 +1,13 @@
{
"replace": false,
"values": [
"#forge:ores/iron",
"#forge:ores/gold",
"#forge:ores/coal",
"#forge:ores/lapis",
"#forge:ores/redstone",
"#forge:ores/emerald",
"#forge:ores/diamond",
"#forge:ores/quartz"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:coal_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:diamond_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:emerald_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:gold_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:iron_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:lapis_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:nether_quartz_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:redstone_ore"
]
}

View file

@ -0,0 +1,13 @@
{
"replace": false,
"values": [
"minecraft:andesite",
"minecraft:diorite",
"minecraft:granite",
"minecraft:infested_stone",
"minecraft:stone",
"minecraft:spolished_andesite",
"minecraft:polished_diorite",
"minecraft:polished_granite"
]
}

View file

@ -0,0 +1,13 @@
{
"replace": false,
"values": [
"#forge:storage_blocks/coal",
"#forge:storage_blocks/diamond",
"#forge:storage_blocks/emerald",
"#forge:storage_blocks/gold",
"#forge:storage_blocks/iron",
"#forge:storage_blocks/lapis",
"#forge:storage_blocks/quartz",
"#forge:storage_blocks/redstone"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:coal_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:diamond_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:emerald_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:gold_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:iron_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:lapis_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:quartz_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:redstone_block"
]
}

View file

@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"#forge:chests/ender",
"#forge:chests/trapped",
"#forge:chests/wooden"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:ender_chest"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:trapped_chest"
]
}

View file

@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"minecraft:chest",
"minecraft:trapped_chest"
]
}

View file

@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"minecraft:cobblestone",
"minecraft:infested_cobblestone",
"minecraft:mossy_cobblestone"
]
}

View file

@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"#forge:dusts/prismarine",
"#forge:dusts/redstone",
"#forge:dusts/glowstone"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:glowstone_dust"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:prismarine_shard"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:redstone"
]
}

View file

@ -0,0 +1,21 @@
{
"replace": false,
"values": [
"#forge:dyes/black",
"#forge:dyes/red",
"#forge:dyes/green",
"#forge:dyes/brown",
"#forge:dyes/blue",
"#forge:dyes/purple",
"#forge:dyes/cyan",
"#forge:dyes/light_gray",
"#forge:dyes/gray",
"#forge:dyes/pink",
"#forge:dyes/lime",
"#forge:dyes/yellow",
"#forge:dyes/light_blue",
"#forge:dyes/magenta",
"#forge:dyes/orange",
"#forge:dyes/white"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:bone_meal"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"#forge:fence_gates/wooden"
]
}

View file

@ -0,0 +1,11 @@
{
"replace": false,
"values": [
"minecraft:oak_fence_gate",
"minecraft:spruce_fence_gate"
"minecraft:birch_fence_gate",
"minecraft:jungle_fence_gate",
"minecraft:acacia_fence_gate",
"minecraft:dark_oak_fence_gate"
]
}

View file

@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"#forge:fences/nether_brick",
"#forge:fences/wooden"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:nether_brick_fence"
]
}

View file

@ -0,0 +1,11 @@
{
"replace": false,
"values": [
"minecraft:oak_fence",
"minecraft:spruce_fence"
"minecraft:birch_fence",
"minecraft:jungle_fence",
"minecraft:acacia_fence",
"minecraft:dark_oak_fence"
]
}

View file

@ -0,0 +1,10 @@
{
"replace": false,
"values": [
"#forge:gems/diamond",
"#forge:gems/emerald",
"#forge:gems/quartz",
"#forge:gems/lapis",
"#forge:gems/prismarine"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:diamond"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:emerald"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:lapis_lazuli"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:prismarine_crystal"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:quartz"
]
}

View file

@ -0,0 +1,9 @@
{
"replace": false,
"values": [
"#forge:ingots/iron",
"#forge:ingots/gold",
"#forge:ingots/brick",
"#forge:ingots/nether_brick"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:brick"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:gold_ingot"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:iron_ingot"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:nether_brick"
]
}

View file

@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"#forge:nuggets/iron",
"#forge:nuggests/gold"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:gold_nugget"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:iron_nugget"
]
}

View file

@ -0,0 +1,13 @@
{
"replace": false,
"values": [
"#forge:ores/iron",
"#forge:ores/gold",
"#forge:ores/coal",
"#forge:ores/lapis",
"#forge:ores/redstone",
"#forge:ores/emerald",
"#forge:ores/diamond",
"#forge:ores/quartz"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:coal_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:diamond_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:emerald_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:gold_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:iron_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:lapis_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:nether_quartz_ore"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:redstone_ore"
]
}

View file

@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"#forge:rods/blaze",
"#forge:rods/wooden"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:blaze_rod"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:stick"
]
}

View file

@ -0,0 +1,12 @@
{
"replace": false,
"values": [
"minecraft:andesite",
"minecraft:diorite",
"minecraft:granite",
"minecraft:stone",
"minecraft:spolished_andesite",
"minecraft:polished_diorite",
"minecraft:polished_granite"
]
}

View file

@ -0,0 +1,13 @@
{
"replace": false,
"values": [
"#forge:storage_blocks/coal",
"#forge:storage_blocks/diamond",
"#forge:storage_blocks/emerald",
"#forge:storage_blocks/gold",
"#forge:storage_blocks/iron",
"#forge:storage_blocks/lapis",
"#forge:storage_blocks/quartz",
"#forge:storage_blocks/redstone"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:coal_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:diamond_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:emerald_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:gold_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:iron_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:lapis_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:quartz_block"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:redstone_block"
]
}

Some files were not shown because too many files have changed in this diff Show more