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    7607

diesieben07

diesieben07    7607

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7607
  • 55143 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    7607

diesieben07

diesieben07    7607

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7607
  • 55143 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    7607

diesieben07

diesieben07    7607

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7607
  • 55143 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    7607

diesieben07

diesieben07    7607

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7607
  • 55143 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    7607

diesieben07

diesieben07    7607

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7607
  • 55143 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    2406

Draco18s

Draco18s    2406

  • Reality Controller
  • Draco18s
  • Members
  • 2406
  • 15935 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    2406

Draco18s

Draco18s    2406

  • Reality Controller
  • Draco18s
  • Members
  • 2406
  • 15935 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    2406

Draco18s

Draco18s    2406

  • Reality Controller
  • Draco18s
  • Members
  • 2406
  • 15935 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
  • 1798 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
  • 1798 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
  • 1798 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
  • 1798 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

    • DeNub
      Cannot create a modded forge server for 1.16.4

      By DeNub · Posted 22 minutes ago

      oh ok ok Server : debug.loglatest.log Client: debug.loglatest.log
    • F0RZera
      have an error when trying to connect to LAN server with mods

      By F0RZera · Posted 25 minutes ago

      I made a LAN server with my friends with some mods on forge 1.16.3. We were playing for 3 weeks and it was ok, but after we tried to upgrade to a new version we got this problem. Even after opening the save before an upgrade we still had this error. mods list:  astikor carts, biomes o plenty, voxelmap, guard villagers, jei and simplefarming. We also tried to download the same mods and forge version but it still didn't work.
    • diesieben07
      Cannot create a modded forge server for 1.16.4

      By diesieben07 · Posted 28 minutes ago

      Yes, unless you changed the game directory in your launcher.
    • DeNub
      Cannot create a modded forge server for 1.16.4

      By DeNub · Posted 30 minutes ago

      Where is it located? I googled it but nothing really came up that matched Is it the AppData\Roaming\.minecraft\logs folder?
    • diesieben07
      Cannot create a modded forge server for 1.16.4

      By diesieben07 · Posted 32 minutes ago

      Now you posted latest.log and debug.log from the server. You need to post the debug.log from your client, showing the attempt to connect to the server.
  • Topics

    • DeNub
      23
      Cannot create a modded forge server for 1.16.4

      By DeNub
      Started 6 hours ago

    • F0RZera
      0
      have an error when trying to connect to LAN server with mods

      By F0RZera
      Started 25 minutes ago

    • Ogaro
      1
      1.8.9 version crashing

      By Ogaro
      Started 1 hour ago

    • BIGDog8808
      12
      HELP! WORLD WONT WORK

      By BIGDog8808
      Started 18 hours ago

    • squidlex
      1
      How to correctly setup a Cancelable event

      By squidlex
      Started 1 hour ago

  • Who's Online (See full list)

    • F0RZera
    • vemerion
    • Thomate_yt
    • Choonster
    • DeNub
    • ChampionAsh5357
  • 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