Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Minecraft Forge
  • General Discussion
  • Gradle decompiled vanilla source instead of classes
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Alesimula

Gradle decompiled vanilla source instead of classes

By Alesimula, February 19, 2014 in General Discussion

  • Start new topic
  • Prev
  • 1
  • 2
  • Next
  • Page 1 of 2  

Recommended Posts

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

I know i can do it by myself (and I already did) but it would be better if gradle creates an eclipse workspace with the decopiled vanilla source code instead of the classes, just to easilly edit the: "private" to "public" and access some codes

 

may i be wrong, but aren't some (if not all) private changed to public in the game client?


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 19, 2014

I know i can do it by myself (and I already did) but it would be better if gradle creates an eclipse workspace with the decopiled vanilla source code instead of the classes, just to easilly edit the: "private" to "public" and access some codes

use setupDecompWorkspace to get access to the source code. You will still not be able to edit it, but why would you need to? Don't edit base classes.
may i be wrong, but aren't some (if not all) private changed to public in the game client?

No. They used to, because of ModLoader derpyness but that's removed now.

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

that means i can't anymore access to GuiAchievements.currentPage ?

 

so how am i supposed to add a custom GUI for achievements?

I used this code

 

Minecraft minecraft = Minecraft.getMinecraft();

 

GuiScreen var15 = minecraft.currentScreen;

 

int var14;

 

if (var15 != null)

{

if (var15 instanceof GuiAchievements)

{

var14 = ((GuiAchievements)var15).currentPage;

 

if (AchievementPage.getTitle(var14).equals("Glacia"))

{

minecraft.thePlayer.openGui(mod_Glacia.instance, GlaciaCommonProxy.GUI_ID_ACHIEVEMENTS, minecraft.theWorld, var14, 0, 0);

}

}

 

if (var15 instanceof GuiAchievementsGlacia)

{

var14 = ((GuiAchievementsGlacia)var15).currentPage;

 

if (!AchievementPage.getTitle(var14).equals("Glacia"))

{

GuiAchievements var16 = new GuiAchievements(var15, minecraft.thePlayer.getStatFileWriter());

var16.currentPage = var14;

FMLClientHandler.instance().displayGuiScreen(minecraft.thePlayer, var16);

}

}

}


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 19, 2014

Use Reflection or AccessTransformers.

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

how to? never used'em


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 19, 2014

http://lmgtfy.com/?q=java+reflection

http://lmgtfy.com/?q=forge+access+transformer

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

is this gonna work?

 

 

GuiScreen var15 = minecraft.currentScreen;

 

GuiAchievements GuiAchievements = new GuiAchievements(var15, minecraft.thePlayer.getStatFileWriter());

Field achPageCurrent = GuiAchievements.class.getDeclaredField("currentPage");

achPageCurrent.setAccessible(true);

int achCurrentPage = Integer.parseInt((String) achPageCurrent.get(GuiAchievements));


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 19, 2014

You mean casting an Integer to a String? No, that does not work.

And don't get the Field instance every time. It's sufficient if you get it once and then store it.

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

wait the problem is i have also to modify the int, i don't just have to get it, so this won't work anyway


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

also as i am reading, access transformer modifies access to public only on forge, but in the game client accesses are still private or am i wrong?


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 19, 2014

You can set values with reflection just fine. There is also Field#set but you should use Field#setInt / Field#getInt because that avoids the boxing overhead.

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

i am getting confused so can you please help me just with this?

 

the value i want to get, and then set is currentPage in GuiAchievements.class, what are the codes to get and then set it

 

PLEEEASE (SAD FACE)

 

 

PS: forum buttons aren't working


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 19, 2014

This is not a java forum.

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

I understand but... Oh wait like this?

 

 

GuiScreen var15 = minecraft.currentScreen;

 

GuiAchievements GuiAchievements = new GuiAchievements(var15, minecraft.thePlayer.getStatFileWriter());

Field achPageCurrent = GuiAchievements.class.getDeclaredField("currentPage");

achPageCurrent.setAccessible(true);

int achCurrentPage = achPageCurrent.getInt(GuiAchievements);

 

and then

 

achPageCurrent.setInt(GuiAchievements, 0);


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 19, 2014

Yes. But please:

a) Name your variables properly (var15 is horrible. GuiAchievements is bad, too, because it can be confused with a class. Variables start with lowercase).

 

b) Cache the field (= only call getDeclaredField once).

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

okay but will setInt really set the protected int currentpage in GuiAchievement to another value?


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 19, 2014

Yes.

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

nope mo probs:

 

i'm setting the int on the new GuiAchievements i created, while i need to set the int on the already existent GuiAchievements, and so var15 casted to GuiAchievements, so (GuiAchievements)var15

 

 

.....


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 19, 2014

Yeah, then do that?!?

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

Yeah i was getting confused, anyway for anyone looking for the final code to add your custom GUI to your achievement pages (In your TickEvent Event), here it is:

 

 

 

 

    public static class TickHandlerClient

    {

//private GuiScreen lastGuiOpen;

 

@SubscribeEvent

public void onTick(TickEvent.ClientTickEvent event)

{

//CLIENT TICK END

if (event.phase == TickEvent.Phase.END)

{

Minecraft minecraft = Minecraft.getMinecraft();

 

GuiScreen CurrentGUI = minecraft.currentScreen;

 

int PageToDisplay;

 

if (CurrentGUI != null)

{

//GETTING THE PRIVATE CURRENTPAGE INT

GuiAchievements AchievementGui = new GuiAchievements(CurrentGUI, minecraft.thePlayer.getStatFileWriter());

Field achPageCurrent = GuiAchievements.class.getDeclaredField("currentPage");

achPageCurrent.setAccessible(true);

 

if (CurrentGUI instanceof GuiAchievements)

{

//PageToDisplay = ((GuiAchievements)CurrentGUI).currentPage;

PageToDisplay = achPageCurrent.getInt((GuiAchievements)CurrentGUI);

 

if (AchievementPage.getTitle(PageToDisplay).equals("Glacia"))

{

minecraft.thePlayer.openGui(mod_Glacia.instance, GlaciaCommonProxy.GUI_ID_ACHIEVEMENTS, minecraft.theWorld, PageToDisplay, 0, 0);

}

}

 

if (CurrentGUI instanceof GuiAchievementsGlacia)

{

PageToDisplay = ((GuiAchievementsGlacia)CurrentGUI).currentPage;

 

if (!AchievementPage.getTitle(PageToDisplay).equals("Glacia"))

{

GuiAchievements OldPageGUI = new GuiAchievements(CurrentGUI, minecraft.thePlayer.getStatFileWriter());

 

//var16.currentPage = PageToDisplay;

achPageCurrent.setInt(OldPageGUI, PageToDisplay);

 

FMLClientHandler.instance().displayGuiScreen(minecraft.thePlayer, OldPageGUI);

}

}

}

}

}

    }


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 19, 2014

Again (last time I will say this): DO NOT ask for the field again every tick. Only do getDeclaredField ONCE, or you'll be killing performance in no time. getDeclaredField is SLOW.

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

and so where do i have to put getdeclaredfield? and also will this work if getdeclaredfield is called once and currentPage int changes?


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 19, 2014

a) Probably in static initializer.

b) Yes. The Field instance you get from getDeclaredField is always the same (every field in the code only ever gets one Field instance) so you can cache it. The get() method retrieves the actual value.

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

so you mean before calling tickevent, so

 

 

 

 

    public static class TickHandlerClient

    {

 

Field achPageCurrent = GuiAchievements.class.getDeclaredField("currentPage");

                achPageCurrent.setAccessible(true);

 

@SubscribeEvent

public void onTick(TickEvent.ClientTickEvent event)

{

                ................


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites

Alesimula    3

Alesimula

Alesimula    3

  • Creeper Killer
  • Alesimula
  • Members
  • 3
  • 117 posts
Posted February 19, 2014

oopps i also dragged setaccessible


Actually i don't know what to write in this signature soooo.... anyway

Share this post


Link to post
Share on other sites
  • Prev
  • 1
  • 2
  • Next
  • Page 1 of 2  
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • ChocoCookies33
      Description: Exception in server tick loop

      By ChocoCookies33 · Posted 9 minutes ago

      local server set up not working, help is appreciated.  crash-2021-03-07_00.55.37-server.txt
    • LessyDoggy
      Forge 1.12.2 Installing Bug

      By LessyDoggy · Posted 1 hour ago

      So I used forge 1.16.5 but now I cant change it too 1.12.2 no mather what. I have tried Installing client, Installing server and extract but nothing works. I even removed forge 1.16.5 from my computer but I still have that verison on and idk how to change it.
    • Yourskillx2
      !!Keeps crashing during launch!!

      By Yourskillx2 · Posted 1 hour ago

      I have a decent sized mod pack with around 90 mods and every time I go to launch the game, it loads some stuff then crashes with exit code 0, I cannot figure out if its a mod in the pack doing it, like maybe not a release version or if it just doesn't work with Mc like its supposed to.
    • IMaironI
      server error

      By IMaironI · Posted 8 hours ago

      2021-03-06-8.log
    • diesieben07
      server error

      By diesieben07 · Posted 8 hours ago

      Like I already said: The logs folder.
  • Topics

    • ChocoCookies33
      0
      Description: Exception in server tick loop

      By ChocoCookies33
      Started 9 minutes ago

    • LessyDoggy
      0
      Forge 1.12.2 Installing Bug

      By LessyDoggy
      Started 1 hour ago

    • Yourskillx2
      0
      !!Keeps crashing during launch!!

      By Yourskillx2
      Started 1 hour ago

    • IMaironI
      13
      server error

      By IMaironI
      Started 12 hours ago

    • prototype204
      0
      Attacking/Hitting issue

      By prototype204
      Started 8 hours ago

  • Who's Online (See full list)

    • Nyko
    • Kreepydude
    • Helios885
    • ChocoCookies33
    • vemerion
    • zlappedx3
    • VecsonON
  • All Activity
  • Home
  • Minecraft Forge
  • General Discussion
  • Gradle decompiled vanilla source instead of classes
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community