Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

+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.

Posted

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;
    }

Posted

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!)

Posted

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.

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • on my last computer, i had a similar problem with forge/ neoforge mods but instead them launcher screen was black
    • I am trying to make a mod, all it is, a config folder that tells another mod to not require a dependency, pretty simple right.. well, I dont want whoever downloads my mod to have to download 4 other mods and then decide if they want 2 more that they kinda really need.. i want to make my mod basically implement all of these mods, i really dont care how it does it, ive tried putting them in every file location you can think of, ive downloaded intellij, mcreator, and tried vmware but thats eh (had it from school). I downloaded them in hopes theyd create the correct file i needed but honestly im only more lost now. I have gotten my config file to work, if i put all these mods into my own mods folder and the config file into the config and it works (unvbelievably) but i want to share this to everyone else, lets just say this mod will legitimately get 7M downloads.  I tried putting them in a run folder then having it create all the contents in that for a game (mods,config..etc) then i drop the mods in and all the sudden i cant even open the game, like it literally works with my own world i play on, but i cant get it to work on any coding platform, they all have like built in java versions you cant switch, its a nightmare. I am on 1.20.1 I need Java 17 (i dont think the specific versions of 17 matter) I have even tried recreating the mods i want to implement and deleting import things like net.adamsandler.themodsname and replacing it with what mine is. that only creates other problems, where im at right now is i got the thing to start opening then it crashes, closest ive gotten it, then it just says this  exception in thread "main" cpw.mods.niofs.union.unionfilesystem$uncheckedioexception: java.util.zip.zipexception: zip end header not found caused by: java.util.zip.zipexception: zip end header not found basically saying theres something wrong with my java.exe file, so i tried downloading so many different versions of java and putting them all in so many different spots, nothing, someone online says its just a mod that isnt built right so i put the mod into an editor and bunch of errors came up, id post it but i deleted it on accident, i just need help integrating mods
    • Vanilla 1.16.5 Crash Report [#L2KYKaK] - mclo.gs  
    • Hello, probably the last update, if anyone has the same problem or this can be of any help, the answer was pretty simple, textures started rendering just using a Tesselator instead of a VertexConsumer given by a MultibufferSource and a RenderType, pretty simple
    • Finally circling back to this, and I think all of us were half right.  getChunk() does appear to immediately load the chunk, but what changed between 1.16 and 1.18 is that the list of entities is now stored in the server, not per chunk.  So while it was possible to load a chunk in 1.16 and immediately grab an entity out of it, 1.18 loads the chunk and submits a request to load its entities on the next tick (if I understand correctly).  All this to say, you can immediately access the chunk itself, however you have to wait an additional tick for its entities to load in. In my case what this means is that I do have to set up an interface to wait an additional tick before submitting the request to retrieve the entity.  However, other functions do appear to be available immediately.  Just depends on what you're trying to do. Thank you all for the help! 
  • Topics

×
×
  • Create New...

Important Information

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