Java Code Examples for net.minecraftforge.oredict.OreDictionary#getOreIDs()

The following examples show how to use net.minecraftforge.oredict.OreDictionary#getOreIDs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InventoryUtils.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static boolean doesStackMatchOreDictName(ItemStack stack, String name)
{
    int[] ids = OreDictionary.getOreIDs(stack);

    for (int id : ids)
    {
        String oreName = OreDictionary.getOreName(id);

        if (oreName.startsWith(name))
        {
            return true;
        }
    }

    return false;
}
 
Example 2
Source File: ContainerOreMappingSatallite.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public ItemStack slotClick(int slot, int dragType, ClickType clickTypeIn,
		EntityPlayer player) {
	//Check if slot exists
			ItemStack stack;
			if(slot != -999)
				stack =  player.inventory.getStackInSlot(slot);
			else stack = null;

			if(inv != null && dragType == 0)
				//Check if anything is in the slot and set the slot value if it is
				if(stack == null) {
					inv.setSelectedSlot(-1);
				}
				else
					for(int id : OreDictionary.getOreIDs(stack)) {
						if(OreDictionary.getOreName(id).startsWith("ore") || OreDictionary.getOreName(id).startsWith("gem") || OreDictionary.getOreName(id).startsWith("dust")) {
							inv.setSelectedSlot(slot);
						}

					}

			return stack;

}
 
Example 3
Source File: TileEntityEngineeringTable.java    From Cyberware with MIT License 6 votes vote down vote up
public boolean isItemValidForSlot(int slot, ItemStack stack)
{
	switch (slot)
	{
		case 0:
			return CyberwareAPI.canDeconstruct(stack);
		case 1:
			int[] ids = OreDictionary.getOreIDs(stack);
			int paperId = OreDictionary.getOreID("paper");
			for (int id : ids)
			{
				if (id == paperId)
				{
					return true;
				}
			}
			return false;
		case 8:
			return stack != null && stack.getItem() instanceof IBlueprint;
		case 9:
			return false;
		default:
			return overrideExtract || !CyberwareAPI.canDeconstruct(stack);
	}
}
 
Example 4
Source File: RecipeBuilder.java    From EmergingTechnology with MIT License 6 votes vote down vote up
public static IMachineRecipe getMatchingRecipe(ItemStack itemStack, List<IMachineRecipe> recipes) {

        if (itemStack == null || itemStack.isEmpty())
            return null;

        int[] oreIds = OreDictionary.getOreIDs(itemStack);

        for (IMachineRecipe recipe : recipes) {

            if (!recipe.hasOreDictInput()) {
                if (recipe.getInput().isItemEqual(itemStack)) {
                    return recipe;
                }
            } else {

                int oreId = OreDictionary.getOreID(recipe.getInputOreName());

                for (int id : oreIds) {
                    if (id == oreId) {
                        return recipe;
                    }
                }
            }
        }
        return null;
    }
 
Example 5
Source File: TileEntityPlasticMixer.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static int getDyeIndex(ItemStack stack){
    int[] ids = OreDictionary.getOreIDs(stack);
    for(int id : ids) {
        String name = OreDictionary.getOreName(id);
        for(int i = 0; i < DYES.length; i++) {
            if(DYES[i].equals(name)) return i;
        }
    }
    return -1;
}
 
Example 6
Source File: Carving.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ICarvingGroup getGroup(Block block, int metadata) {
	int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, metadata));
	if (ids.length > 0) {
		for (int id : ids) {
			ICarvingGroup oreGroup = groups.getGroupByOre(OreDictionary.getOreName(id));
			if (oreGroup != null) {
				return oreGroup;
			}
		}
	}

	return groups.getGroup(block, metadata);
}
 
Example 7
Source File: ItemToolTipHandler.java    From AgriCraft with MIT License 5 votes vote down vote up
@SubscribeEvent
public void addOreDictInfo(ItemTooltipEvent event) {
    if (AgriCraftConfig.enableOreDictTooltips && !event.getItemStack().isEmpty()) {
        addCategory(event, "OreDict");
        final int[] ids = OreDictionary.getOreIDs(event.getItemStack());
        for (int id : ids) {
            addFormatted(event, " - {1} ({0})", id, OreDictionary.getOreName(id));
        }
        if (ids.length == 0) {
            addFormatted(event, " - No OreDict Entries");
        }
    }
}
 
Example 8
Source File: RecipeHandlerOreDictionary.java    From NEI-Integration with MIT License 5 votes vote down vote up
@Override
public void loadUsageRecipes(ItemStack ingred) {
    if (Config.handlerOreDictionary) {
        for (int id : OreDictionary.getOreIDs(ingred)) {
            for (String oreName : this.getOreNames()) {
                if (OreDictionary.getOreName(id).equals(oreName)) {
                    CachedOreDictionaryRecipe crecipe = new CachedOreDictionaryRecipe(oreName, new ItemStack(ingred.getItem(), 1, ingred.getItemDamage()), OreDictionary.getOres(oreName));
                    crecipe.setIngredientPermutation(Collections.singletonList(crecipe.input), ingred);
                    this.arecipes.add(crecipe);
                }
            }
        }
    }
}
 
Example 9
Source File: PneumaticCraftUtils.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isSameOreDictStack(ItemStack stack1, ItemStack stack2){
    int[] oredictIds = OreDictionary.getOreIDs(stack1);
    for(int oredictId : oredictIds) {
        List<ItemStack> oreDictStacks = OreDictionary.getOres(OreDictionary.getOreName(oredictId));
        for(ItemStack oreDictStack : oreDictStacks) {
            if(OreDictionary.itemMatches(oreDictStack, stack2, false)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 10
Source File: FMEventHandler.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
private boolean isGarbage(ItemStack drop) {
    for(int id : OreDictionary.getOreIDs(drop)) {
        for(String ore : Config.trash) {
            if(OreDictionary.getOreName(id).equals(ore))
                return true;
        }
    }
    return false;
}
 
Example 11
Source File: OreDictionaryInterface.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<OreDictionaryEntry> getOreEntries(ItemStack itemStack) {
    int[] ids = OreDictionary.getOreIDs(CraftItemStack.asNMSCopy(itemStack));

    ImmutableList.Builder<OreDictionaryEntry> builder = ImmutableList.builder();
    for (int id : ids) {
        builder.add(OreDictionaryEntry.valueOf(id));
    }

    return builder.build();
}
 
Example 12
Source File: DestinationProviderItems.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isSameOreDictStack(ItemStack stack1, ItemStack stack2){
    int[] oredictIds = OreDictionary.getOreIDs(stack1);
    for(int oredictId : oredictIds) {
        List<ItemStack> oreDictStacks = OreDictionary.getOres(OreDictionary.getOreName(oredictId));
        for(ItemStack oreDictStack : oreDictStacks) {
            if(OreDictionary.itemMatches(oreDictStack, stack2, false)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 13
Source File: SlotItemSpecific.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check if the stack is a valid item for this slot. Always true beside for
 * the armor slots.
 */
@Override
public boolean isItemValid(ItemStack par1ItemStack){
    if(itemAllowed != null) {
        Item item = par1ItemStack == null ? null : par1ItemStack.getItem();
        return item == itemAllowed;
    } else {
        int[] ids = OreDictionary.getOreIDs(par1ItemStack);
        for(int id : ids) {
            if(id == oreDictEntry) return true;
            if(dye && TileEntityPlasticMixer.getDyeIndex(par1ItemStack) >= 0) return true;
        }
        return false;
    }
}
 
Example 14
Source File: Utils.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static boolean hasOreDictPrefix(ItemStack stack, String dict) {
	int[] ids = OreDictionary.getOreIDs(stack);
	for (int id : ids) {
		if (OreDictionary.getOreName(id).length() >= dict.length()) {
			if (OreDictionary.getOreName(id).substring(0, dict.length()).compareTo(dict) == 0) {
				return true;
			}
		}
	}
	return false;
}
 
Example 15
Source File: GTHelperStack.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Checks if an itemstack has an oredict entry **/
public static boolean oreDictStartsWith(ItemStack stack, String entry) {
	if (!stack.isEmpty() && (OreDictionary.getOreIDs(stack).length > 0)) {
		for (int i = 0; i < OreDictionary.getOreIDs(stack).length; i++) {
			if (OreDictionary.getOreName(OreDictionary.getOreIDs(stack)[i]).startsWith(entry)) {
				return true;
			}
		}
	}
	return false;
}
 
Example 16
Source File: GTHelperStack.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Checks if an itemstack has an oredict entry **/
public static boolean matchOreDict(ItemStack stack, String entry) {
	if (!stack.isEmpty() && (OreDictionary.getOreIDs(stack).length > 0)) {
		for (int i = 0; i < OreDictionary.getOreIDs(stack).length; i++) {
			if (OreDictionary.getOreName(OreDictionary.getOreIDs(stack)[i]).contains(entry)) {
				return true;
			}
		}
	}
	return false;
}
 
Example 17
Source File: GTHelperStack.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Checks if two items share ore dict entries **/
public static boolean sharesOreDict(ItemStack stack, ItemStack toCompare) {
	if (!stack.isEmpty() && (OreDictionary.getOreIDs(stack).length > 0)) {
		for (int i = 0; i < OreDictionary.getOreIDs(stack).length; i++) {
			if (matchOreDict(toCompare, OreDictionary.getOreName(OreDictionary.getOreIDs(stack)[i]))) {
				return true;
			}
		}
	}
	return false;
}
 
Example 18
Source File: CircuitImprintLoader.java    From bartworks with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static GT_Recipe makeMoreExpensive(GT_Recipe original) {
    GT_Recipe newRecipe = original.copy();
    for (ItemStack is : newRecipe.mInputs){
        int[] oreIDs = OreDictionary.getOreIDs(is);
        if(oreIDs == null || oreIDs.length < 1 || !OreDictionary.getOreName(oreIDs[0]).contains("circuit")) {
            is.stackSize = Math.min(is.stackSize * 6, 64);
            if (is.stackSize > is.getItem().getItemStackLimit() || is.stackSize > is.getMaxStackSize())
                is.stackSize = is.getMaxStackSize();
        }
    }
    newRecipe.mFluidInputs[0].amount *= 4;
    newRecipe.mDuration *= 4;
    return newRecipe;
}
 
Example 19
Source File: CircuitImprintLoader.java    From bartworks with MIT License 5 votes vote down vote up
private static String getTypeFromOreDict(ItemStack[] outputs) {
    int[] oreIDS = OreDictionary.getOreIDs(outputs[0]);

    if (oreIDS.length < 1)
        return "";

    return OreDictionary.getOreName(oreIDS[0]);
}
 
Example 20
Source File: CircuitPartLoader.java    From bartworks with MIT License 4 votes vote down vote up
public static void makeCircuitParts() {
    ItemList[] itemLists = values();
    for (ItemList single : itemLists) {
        if (!single.hasBeenSet())
            continue;
        if (
                single.toString().contains("Wafer") ||
                        single.toString().contains("Circuit_Silicon_Ingot") ||
                        single.toString().contains("Raw") ||
                        single.toString().contains("raw") ||
                        single.toString().contains("Glass_Tube") ||
                        single == Circuit_Parts_GlassFiber ||
                        single == Circuit_Parts_Advanced ||
                        single == Circuit_Parts_Wiring_Advanced ||
                        single == Circuit_Parts_Wiring_Elite ||
                        single == Circuit_Parts_Wiring_Basic ||
                        single == Circuit_Integrated ||
                        single == Circuit_Parts_PetriDish ||
                        single == Circuit_Parts_Vacuum_Tube ||
                        single == Circuit_Integrated_Good ||
                        single == Circuit_Parts_Capacitor ||
                        single == Circuit_Parts_Diode ||
                        single == Circuit_Parts_Resistor ||
                        single == Circuit_Parts_Transistor

        ){
            CircuitImprintLoader.blacklistSet.add(single.get(1));
            continue;
        }
        ItemStack itemStack = single.get(1);
        if (!GT_Utility.isStackValid(itemStack))
            continue;
        int[] oreIDS = OreDictionary.getOreIDs(itemStack);
        if (oreIDS.length > 1)
            continue;
        String name = null;
        if (oreIDS.length == 1)
            name = OreDictionary.getOreName(oreIDS[0]);
        if ((name == null || name.isEmpty()) && (single.toString().contains("Circuit") || single.toString().contains("circuit") || single.toString().contains("board")) && single.getBlock() == Blocks.air) {
            ArrayList<String> toolTip = new ArrayList<>();
            if (FMLCommonHandler.instance().getEffectiveSide().isClient())
                single.getItem().addInformation(single.get(1).copy(), null, toolTip, true);
            String tt = (toolTip.size() > 0 ? toolTip.get(0) : "");
            //  tt += "Internal Name = "+single;
            String localised = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(itemStack));
            BW_Meta_Items.getNEWCIRCUITS().addItem(CircuitImprintLoader.reverseIDs, "Wrap of " + localised+"s", tt);
            GT_Values.RA.addAssemblerRecipe(new ItemStack[]{single.get(16).copy(), GT_Utility.getIntegratedCircuit(16)}, Materials.Plastic.getMolten(72),BW_Meta_Items.getNEWCIRCUITS().getStack(CircuitImprintLoader.reverseIDs),600,30);
            CircuitImprintLoader.circuitIIconRefs.put(CircuitImprintLoader.reverseIDs,single);
            CircuitImprintLoader.reverseIDs--;
        }
    }
}