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    7590

diesieben07

diesieben07    7590

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7590
  • 54991 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    7590

diesieben07

diesieben07    7590

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7590
  • 54991 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    7590

diesieben07

diesieben07    7590

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7590
  • 54991 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    7590

diesieben07

diesieben07    7590

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7590
  • 54991 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    7590

diesieben07

diesieben07    7590

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7590
  • 54991 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    2402

Draco18s

Draco18s    2402

  • Reality Controller
  • Draco18s
  • Members
  • 2402
  • 15921 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    2402

Draco18s

Draco18s    2402

  • Reality Controller
  • Draco18s
  • Members
  • 2402
  • 15921 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    2402

Draco18s

Draco18s    2402

  • Reality Controller
  • Draco18s
  • Members
  • 2402
  • 15921 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

    • Draco18s
      GUI Documentation

      By Draco18s · Posted 10 minutes ago

      GUIs aren't that difficult. There's dozens of tutorials for them and they haven't really changed all that much in ten years.
    • Xenfo
      Mod Blocker

      By Xenfo · Posted 26 minutes ago

      Any mod blockers that actually work? Please link them if yes.
    • diesieben07
      Tessellator ignores lighting?

      By diesieben07 · Posted 47 minutes ago

      Neither 1.10 now 1.14 are supported here. Please refer to the supported versions page: https://forums.minecraftforge.net/topic/91712-supported-version-directory/
    • CookieLukas
      Tessellator ignores lighting?

      By CookieLukas · Posted 48 minutes ago

      Oh,  sorry, the code was 1.10.2, but as its not allowed here, I updated it to 1.14.4.
    • diesieben07
      Forge isn't working on Minecraft Realms

      By diesieben07 · Posted 49 minutes ago

      1.8 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  • Topics

    • T1ps
      3
      GUI Documentation

      By T1ps
      Started Tuesday at 10:14 PM

    • Xenfo
      0
      Mod Blocker

      By Xenfo
      Started 26 minutes ago

    • CookieLukas
      3
      Tessellator ignores lighting?

      By CookieLukas
      Started 1 hour ago

    • Extrodonary
      1
      Forge isn't working on Minecraft Realms

      By Extrodonary
      Started 1 hour ago

    • Liahim
      0
      [1.16.4-1.16.5] Seed for Biome Provider and Chunk Generator

      By Liahim
      Started 1 hour ago

  • Who's Online (See full list)

    • philip-elsner@gmx.net
    • Beethoven92
    • Mango106
    • Luis_ST
    • Liahim
    • diesieben07
    • Mounty
    • Tiro
    • jrein03
    • Draco18s
    • larsgerrits
    • RpxdYTX
    • Heinzchen
    • bananapizzuh
    • ozumman
    • Xenfo
    • EmilyW524
    • 1321313dfddksjdlsdw
  • 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