Jump to content

ShapedOreRecipe and ShapelessOreRecipe...


Player131

Recommended Posts

Hello,

 

I'm trying to reverse engineer crafting table items. I already arrive to retrieve and throw every items for many crafts, but some aren't usable. I found that it's linked to 2 new classes that are managing recipes : ShapedOreRecipe and ShapelessOreRecipe.

 

So, i extended my if block to use these new classes, but the getInput method on them don't give something usable for me. Indead, istead of an ItemStack/Block/Item array it returns UnmodifiableArrayList witch is completely blocked from access and can't be passed as ItemStack.

 

So i'm asking you if you do know a way for passing this Unmodifiable into an ItemStack/Block/Item so i can read the composition of the item i want to reverse engineer.

 

 

Thanks by advance

Link to comment
Share on other sites

That array list is likely the list of item stacks that are valid inputs for the given slot.  Remember that the ShapedOreRecipe and ShapelessOreRecipe are classes that use OreDict strings instead of item stacks, so that mods that add various new woods, ores, and so on are all intercompatible.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

+1.

 

I've been looking for this for 2 hours now, and was about the same question on this forum as well. What a coincidence. ;) Don't worry, I need it for other uses than you. ;)

 

I need to be able to get an ItemStack out of the IRecipe.getInput(). It returns an array of Objects.

 

If I try to cast the first element of the array to an ArrayList type, it says "net.minecraft.item.ItemStack cannot be cast to java.util.ArrayList".

 

if I try to cast it to an ItemStack, it says "net.minecraftforge.oredict.OreDictionary$UnmodifiableArrayList cannot be cast to net.minecraft.item.ItemStack"

 

I'm confused. How should I cast the Object to something that I can use? The class UnmodifiableArrayList cannot be found.

 

 

Thanks in advance,

Pancake.

Link to comment
Share on other sites

Exactly the same problem than me !

 

However i just made a method, but incomplete and not realy clean :

    private ItemStack pirateMinecraftForgeUnmodifiableArrayList(String s){
        String s1 = s.split("\\[")[1];
        String s2 = s1.split("\\]")[0];
        String s3 = s2.split("x")[1];
        String s4 = s3.split("@")[0];

        if (s4.startsWith("tile.")) {
            for (Object i : Block.blockRegistry){
                Block item = (Block) i;
                if (item.getUnlocalizedName().equalsIgnoreCase(s4)){
                    return new ItemStack(item);
                }
            }
        } else if (s4.startsWith("item.")) {
            for (Object i : Item.itemRegistry){
                Item item = (Item) i;
                if (item.getUnlocalizedName().equalsIgnoreCase(s4)){
                    return new ItemStack(item);
                }
            }
        }
        return null;
    }

Link to comment
Share on other sites

Exactly the same problem than me !

 

However i just made a method, but incomplete and not realy clean :

    private ItemStack pirateMinecraftForgeUnmodifiableArrayList(String s){
        String s1 = s.split("\\[")[1];
        String s2 = s1.split("\\]")[0];
        String s3 = s2.split("x")[1];
        String s4 = s3.split("@")[0];

        if (s4.startsWith("tile.")) {
            for (Object i : Block.blockRegistry){
                Block item = (Block) i;
                if (item.getUnlocalizedName().equalsIgnoreCase(s4)){
                    return new ItemStack(item);
                }
            }
        } else if (s4.startsWith("item.")) {
            for (Object i : Item.itemRegistry){
                Item item = (Item) i;
                if (item.getUnlocalizedName().equalsIgnoreCase(s4)){
                    return new ItemStack(item);
                }
            }
        }
        return null;
    }

 

I suppose you COULD get itemstacks that way... Just one remark. What if multiple ores use the same block ID but different metadata? Doesn't the constructor ItemStack(Item) auto-set the metadata to 0?

 

Just saying... ;) But as long as each modder defines different ores as different blocks, you'll be fine! (and me too, i'm stealing your code! muahaha!)

Link to comment
Share on other sites

Use other methods before resorting to try/catch.  Try/catch is pretty resource intensive compared to "if(str != null)"

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.