Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10] bytecode doesn't seem to match sourcecode


kauan99
 Share

Recommended Posts

I'm trying to experiement with ASM, but I'm facing a weird problem.

 

I'm looking into what was supposed to be the bytecode of EntityPlayer.setCurrentItemOrArmor(int, ItemStack). I'm really bad at reading bytecode, but this doesn't seem right even to me:

 

java source:

 

    public void setCurrentItemOrArmor(int p_70062_1_, ItemStack p_70062_2_)
    {
        if (p_70062_1_ == 0)
        {
            this.inventory.mainInventory[this.inventory.currentItem] = p_70062_2_;
        }
        else
        {
            this.inventory.armorInventory[p_70062_1_ - 1] = p_70062_2_;
        }
    }

 

bytecode:

aload_0
getfield yz/bm Lyx;
getfield yx/b [Ladd;
iload_1
aload_2
aastore
return

 

let me see if I inderstand this correctly:

 

  • aload_0

    puts a pointer to

    this

    on the stack

  • getfield yz/bm Lyx;

    gets the field from the pointer on top of the stack (

    this

    ) identified as

    bm

    in the constants pool (

    inventory

    ), which is of type

    Lyx

    (

    pointer to InventoryPlayer

    ), pops the pointer on top the stack and puts the pointer to the field we just got onto the stack

  • getfield yx/b [Ladd;

    same operation above, now resulting in we having a pointer to

    this.inventory.armorInventory

    (type:

    array of pointers to ItemStack

    ) on the stack

  • iload_1

    stacks the

    int

    value param 1 on top of the stack

  • aload_2

    stacks the

    ItemStack

    pointer param 2 on top of the stack

  • aastore probably reads the pointer on top of the stack to some register
    A

    and pops it from the stack, then reads an

    int

    from the stack to some register

    B

    and pops it too, then stores the pointer at register

    A

    at the address obtained by performing pointer arithmetic on the pointer now on top of the stack (to

    this.inventory.armorInventory

    ), and finally pops this last pointer out of the stack

  • return

    we all know that one

 

where is the code that checks if the index is 0? if this method was used it would put a sword at your helmet slot. where is the subtraction param1 - 1?

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

how do I get the bytecode for that method? I checked the joined.srg file to find the method and the class, and picked the class from my .minecraft\versions\1.7.10.jar file (yz.class, method c(ILadd;)V). am I supposed to get the class file from somewhere else?

 

also, if someone would be so kind to check my interpretation of the bytecode for correctness that would be really apreciated.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

There is a very handy plugin for IntelliJ IDEA called ASM Bytecode Outline which allows you to view the ASM and bytecode versions of classes inside IDEA.

 

yeah, thanks! I'm aware of that and I use eclipse and I can't install it for my life.... eclipse always displays and error.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

please I'd really like to know how to see the bytecode for minecraft classes. maybe the source displays the class after forge patches it. I want to see the source of the class after all patching has been done. could anybody help me with that? thanks.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

I used bytecode viewer, the problem is I don't know where to find the .class files. they're not inside .minecraft\versions\1.7.10.jar because that's where I got that .class file from. it seems only vanilla classes are in there? maybe forge uses ASM to transform the classes into what we see in the source code? All I want is access to the .class files the way they actually are when we play modded minecraft. I want to know where they are, that's all.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

See my post here. You should be able to follow the folder path and find the original jar files nearby.

 

http://www.minecraftforge.net/forum/index.php/topic,33642.0.html

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

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