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
  • Mod Developer Central
  • Modder Support
  • CLOSED:How to get Private Value?
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 2
Crazy_sheep

CLOSED:How to get Private Value?

By Crazy_sheep, October 23, 2020 in Modder Support

  • Reply to this topic
  • Start new topic
  • Prev
  • 1
  • 2
  • 3
  • 4
  • Next
  • Page 1 of 4  

Recommended Posts

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020 (edited)

is there a command to get a private value?

because this does not work

CreeperEntity creeper = (CreeperEntity) event.getEntity();
Field f = creeper.getClass().getDeclaredField("POWERED"); //this errors and i dont know why
f.setAccessible(true);

so i hope you guys give me good answers

 

EDIT: this is closed(because i am gonne stop modding minecraft and i am garbage at java) and if you still wanna post something you can but this forum is closed

Edited October 29, 2020 by Crazy_sheep
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7589

diesieben07

diesieben07    7589

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7589
  • 54951 posts
Posted October 23, 2020

You need to use ObfuscationReflectionHelper with SRG names (obtainable from MCPBot).

Also: Only grab the Field instance once, store it in a static final field. Then just call get on it whenever you need to access the value.

  • Quote

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020 (edited)

@diesieben07 ok i will try

Edited October 23, 2020 by Crazy_sheep
  • Quote

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020

when i try to put the ObfuscationReflectionHelper with Field f = creeper.getclass.ObfuscationReflectionHelper or creeper.ObfuscationReflectionHelper its not a command

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7589

diesieben07

diesieben07    7589

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7589
  • 54951 posts
Posted October 23, 2020

Learn Basic Java.

  • Quote

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020

@diesieben07 oh come on why would i make a forum and on java there are no tutorials on how to get private value or a diffrent class when i try to put the ObfuscationReflectionHelper and this is not event a command in java i think that awsner does not help at all

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7589

diesieben07

diesieben07    7589

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7589
  • 54951 posts
Posted October 23, 2020

Java has no concept of "commands".

ObfuscationReflectionHelper is a class. If you do not know how to use classes and call method then you are not fit for writing a Minecraft mod.

I am sorry if this is not the answer you want, but this is like trying to drive a car without knowing what a road is.

  • Quote

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020 (edited)
Quote

this is like drive a car without knowing what a road is

that made me laugh just think about it someone just driving a car in the forest lol

but the ObfuscationReflectionHelper is without and attachments like this creeper.ObfuscationReflectionHelper because this does not work but just like this Field f = ObfuscationReflectionHelper is a command so i think all i need to know now is how to use the ObfuscationReflectionHelper command and there is a getPrivateValue command so can you just give me a basic example code on how to use ObfuscationReflectionHelper.getPrivateValue() and i am not asking for example code from that i could just copy and paste but i mean a tutorial example code

Edited October 23, 2020 by Crazy_sheep
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7589

diesieben07

diesieben07    7589

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7589
  • 54951 posts
Posted October 23, 2020

Again, it is not a command. ObfsucationReflectionHelper is a class. You call methods on it.

  • Quote

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020

i know but how do i use the privateValueCommand

  • Quote

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020

how do i use it?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7589

diesieben07

diesieben07    7589

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7589
  • 54951 posts
Posted October 23, 2020

It is not a command. It is a method.

And you use it by calling it. It has descriptive parameter names, javadoc and even documentation for each parameter that explains what you need to pass in.

  • Quote

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020

ok but how do i get the class instance and is the class name just the class name what its called(its probely the class name like this "class name here")

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2401

Draco18s

Draco18s    2401

  • Reality Controller
  • Draco18s
  • Members
  • 2401
  • 15920 posts
Posted October 23, 2020

You do it the same way you use the Math class to get the value of Pi.

  • Quote

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.

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020

@Draco18sbut i use 

ObfuscationReflectionHelper

so what do i need to do with ObfuscationReflectionHelper?

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2401

Draco18s

Draco18s    2401

  • Reality Controller
  • Draco18s
  • Members
  • 2401
  • 15920 posts
Posted October 23, 2020

Call its methods?

They're intelligently named.

  • Quote

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.

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020

@Draco18sum... ok..  but still:how do i get a private value and plz give me good answers that i understand because i dont want this to be the second topic that failed again like the first topic

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2401

Draco18s

Draco18s    2401

  • Reality Controller
  • Draco18s
  • Members
  • 2401
  • 15920 posts
Posted October 23, 2020 (edited)

GOSH MAYBE THERE'S A METHOD CALLED "getPrivateValue" IN THE CLASS.

HAVE YOU TRIED READING THE AVAILABLE METHODS?

Edited October 23, 2020 by Draco18s
  • Haha 2
  • Quote

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.

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020

@Draco18si did not mean to put that part as a mean part but so you know thats the main part(and for some reason i wanted to do that.... i hate my life) sorry. and i already know about the getPrivateValue but how do i use it

  • Quote

Share this post


Link to post
Share on other sites

loordgek    174

loordgek

loordgek    174

  • World Shaper
  • loordgek
  • Members
  • 174
  • 1797 posts
Posted October 23, 2020

 

  • Quote

Share this post


Link to post
Share on other sites

loordgek    174

loordgek

loordgek    174

  • World Shaper
  • loordgek
  • Members
  • 174
  • 1797 posts
Posted October 23, 2020

@Draco18s do you understand what i typed ?

 

@Crazy_sheep read this

https://github.com/MinecraftForge/MinecraftForge/blob/1.16.x/src/main/java/net/minecraftforge/fml/common/ObfuscationReflectionHelper.java#L67-L80

  • Quote

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020 (edited)

@loordgekah yeah oh you write another thing i needed to refresh idk not really i did not under stand where it needs to go

Edited October 23, 2020 by Crazy_sheep
  • Quote

Share this post


Link to post
Share on other sites

Crazy_sheep    1

Crazy_sheep

Crazy_sheep    1

  • Stone Miner
  • Crazy_sheep
  • Members
  • 1
  • 94 posts
Posted October 23, 2020

@loordgek idk where the most of the code needs to go so help

  • Quote

Share this post


Link to post
Share on other sites

loordgek    174

loordgek

loordgek    174

  • World Shaper
  • loordgek
  • Members
  • 174
  • 1797 posts
Posted October 23, 2020

the instance parameter is null because the field is static

the fieldName parameter is "field_184714_b" (can somebody explain why the name is so weird )

  • Quote

Share this post


Link to post
Share on other sites

loordgek    174

loordgek

loordgek    174

  • World Shaper
  • loordgek
  • Members
  • 174
  • 1797 posts
Posted October 23, 2020
3 minutes ago, Crazy_sheep said:

idk where the most of the code needs to go so help

this is BASIC java

  • Quote

Share this post


Link to post
Share on other sites
  • Prev
  • 1
  • 2
  • 3
  • 4
  • Next
  • Page 1 of 4  

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • ChampionAsh5357
      [1.16.4] Multiple worlds

      By ChampionAsh5357 · Posted 1 minute ago

      Well, yes. Now there's a bunch of new caveats. If you really want to attempt this, a similar mod named Hyperbox by Commoble accomplished this. That's probably the best I can do as the process of actually handling is quite complicated and problematic at times.
    • __SmolMight__
      Mods work in singleplayer but not in multiplayer

      By __SmolMight__ · Posted 4 minutes ago

      I am new to the world of modding Minecraft so when I say I am completely lost on what to do, I mean I am utterly lost. To set up my modded Minecraft server for 1.12.2 I followed a youtube tutorial by the Breakdown and It works amazingly! But when I went to install the mods on the server to the mod folder and installed them all nothing happened. I loaded up my game and server and when I got on in creative mode none of the mods were present. They all work in singleplayer just fine with no crashing so I know it's not mod conflicts. I am just so confused on where to go at this point. I've tried following several threads and other videos on how to troubleshoot the problem but all the computer jargon just goes over my head and I am left more turned around than ever. All I ask is your patience and I prematurely apologize if my sheer stupidity is aggravating. Thanks in advance.
    • uglyswed@gmail.com
      not all my mods are showing up in a 1.12.2 server

      By uglyswed@gmail.com · Posted 5 minutes ago

      when i play singleplayer all 19 of my mods are showing up but when i enter a server i made with my friend not all my mods are showing up. on my server list theres a green check mark and when i hover over it, it says "compatible FML modded server 4 mods present" how do I make all 19 mods show up in the server? We both have all 19 installed and both of us have singleplayer worlds with all 19 working fine.    
    • Teedledee
      1.16.4 Failed to synchronize registry data with server LAN

      By Teedledee · Posted 11 minutes ago

      Trying to play on a modded LAN server with my friend, when I try to join their LAN world I get the "Failed to synchronize registry data with server, closing connection" message, and they get the same message when trying to join my LAN world. We have the same forge version 35.1.12, all the same mods with the same versions of those mods as well as the same configs.   My forced crash report: https://pastebin.com/XMG5Z5Bi Friends forced crash report: https://pastebin.com/eXk8qQQT
    • Forix
      [1.16.4] Multiple worlds

      By Forix · Posted 12 minutes ago

      You know in 1.15 it was so much easier with the DimensionManager class
  • Topics

    • Forix
      8
      [1.16.4] Multiple worlds

      By Forix
      Started Saturday at 09:00 PM

    • __SmolMight__
      0
      Mods work in singleplayer but not in multiplayer

      By __SmolMight__
      Started 4 minutes ago

    • uglyswed@gmail.com
      0
      not all my mods are showing up in a 1.12.2 server

      By uglyswed@gmail.com
      Started 5 minutes ago

    • Teedledee
      0
      1.16.4 Failed to synchronize registry data with server LAN

      By Teedledee
      Started 11 minutes ago

    • cadbane86140
      0
      MInecraft: Parkour Paradise 3 Part 2!

      By cadbane86140
      Started 19 minutes ago

  • Who's Online (See full list)

    • DynamicSiren
    • Woodside
    • Squidsword
    • ChampionAsh5357
    • Teedledee
    • S-Spirit
    • Arthurmeade12
    • NorthWestWind
    • __SmolMight__
    • uglyswed@gmail.com
    • cadbane86140
    • Danebi
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • CLOSED:How to get Private Value?
  • Theme

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