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 3 of 4  

Recommended Posts

diesieben07    7599

diesieben07

diesieben07    7599

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7599
  • 55135 posts
Posted October 27, 2020

I asked because loordgek asked you to show what you have tried and you have not done that.

  • 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 27, 2020 (edited)

Showing what you tried involves showing your code to us.

So we can read it. We're not telepathic.

Edited October 27, 2020 by Draco18s
  • 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 27, 2020
40 minutes ago, diesieben07 said:

I asked because loordgek asked you to show what you have tried and you have not done that.

i showed where the first error came from

@Draco18sok here is the code from the events class

package com.example.examplemod.event;

import com.example.examplemod.ExampleMod;
import net.minecraft.entity.monster.CreeperEntity;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public class Event {
    public static DataParameter<Boolean> e; //I FIXED IT YAY
    @SubscribeEvent
    public void onspawn(EntityJoinWorldEvent e, World world) {
    CreeperEntity creeper = (CreeperEntity) e.getEntity();
    if (creeper instanceof CreeperEntity) {
        
        }
    }
}
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7599

diesieben07

diesieben07    7599

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7599
  • 55135 posts
Posted October 27, 2020
Just now, Crazy_sheep said:

I FIXED IT YAY

No, you did not.

You ignored everything we told you to do and just clicked the Eclipse quickfixes until your errors went away.

You must learn Java before continuing here.

Do not pass go. Do not collect $200.

It does not matter that you don't want to. You will not get further without doing 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 27, 2020 (edited)
Quote

You ignored everything we told you to do and just clicked the Eclipse quickfixes until your errors went away.

bro... i dont use Eclipse i use intellij and i did not do quickfixes that e was just a fast test if that worked as a name(and i am trying to make a doom mod lol)

Edited October 27, 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 27, 2020
package com.example.examplemod.event;

import com.example.examplemod.ExampleMod;
import net.minecraft.entity.monster.CreeperEntity;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;

@Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
// filename: Main.java
class Test {
    static int i;
    int j;

    // start of static block
    static {
        i = 10;
        ObfuscationReflectionHelper.getPrivateValue(CreeperEntity.class, null,"field_184714_b");
    }
    // end of static block
}

public class Event {
    public static DataParameter<Boolean> test; //I FIXED IT YAY
    @SubscribeEvent
    public void onspawn(EntityJoinWorldEvent e, World world) {
    CreeperEntity creeper = (CreeperEntity) e.getEntity();
    if (creeper instanceof CreeperEntity) {
        EntityDataManager // i am stuck here now
        }
    }
}

is this good and i got lost by the EntityDataManager part

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7599

diesieben07

diesieben07    7599

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7599
  • 55135 posts
Posted October 27, 2020
1 minute ago, Crazy_sheep said:

ObfuscationReflectionHelper.getPrivateValue(CreeperEntity.class, null,"field_184714_b");

Great you have the value. How about you do something with it instead of just ... ignoring 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 27, 2020

@diesieben07hmmm.... how do i do that🤔

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7599

diesieben07

diesieben07    7599

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7599
  • 55135 posts
Posted October 27, 2020

Again, this is where basic Java knowledge comes in.

You need to learn what fields are and how to use them.

  • 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 27, 2020

@diesieben07ok i am quikly gonne learn what fields are and come back to the code

  • 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 27, 2020
14 minutes ago, Crazy_sheep said:

public static DataParameter<Boolean> e;

yes now initialize it using ObfuscationReflectionHelper.getPrivateValue

 

16 minutes ago, Crazy_sheep said:

public void onspawn(EntityJoinWorldEvent e, World world)

you dont need the world here

 

16 minutes ago, Crazy_sheep said:

CreeperEntity creeper = (CreeperEntity) e.getEntity();

if (creeper instanceof CreeperEntity)

first you do "you are a creeper"

then you ask "are you a creeper "

  • 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 27, 2020 (edited)

@diesieben07can you give me a fast example of a field and i am not asking for the real code

Edited October 27, 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 27, 2020

and can i do something with this 

creeper.getDataManager()
  • 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 27, 2020 (edited)

there is a command that is called this

creeper.getDataManager().getAll();

can i do someting with this

Edited October 27, 2020 by Crazy_sheep
  • 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 27, 2020
13 minutes ago, Crazy_sheep said:

can you give me a fast example of a field and i am not asking for the real code

Quote

please keep in mind that this is not a Java school. You are expected to have basic knowledge of Java before posting here.

 

  • 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 27, 2020 (edited)
13 minutes ago, Crazy_sheep said:

there is a command that is called this

can you stop calling it a command

 

the method you need is "get"

it has 2 parameters the first one is the DataParameter the second one is the value you want to set

Edited October 27, 2020 by loordgek
  • Quote

Share this post


Link to post
Share on other sites

Danebi    26

Danebi

Danebi    26

  • Diamond Finder
  • Danebi
  • Members
  • 26
  • 432 posts
Posted October 27, 2020 (edited)
3 minutes ago, loordgek said:

the method you need is "get"

Wouldn't it be "set"?

Edited October 27, 2020 by Danebi
  • 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 27, 2020

oops yes

  • Quote

Share this post


Link to post
Share on other sites

DavidM    179

DavidM

DavidM    179

  • World Shaper
  • DavidM
  • Members
  • 179
  • 1821 posts
Posted October 28, 2020
On 10/26/2020 at 4:27 AM, Draco18s said:

Cool.

I did this in a week.

https://draco18s.itch.io/time-slicing-sword

That's a really cool idea.

  • Quote

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

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 28, 2020

@loordgekbut i have the value how do i inalize it do

  • Quote

Share this post


Link to post
Share on other sites

Danebi    26

Danebi

Danebi    26

  • Diamond Finder
  • Danebi
  • Members
  • 26
  • 432 posts
Posted October 28, 2020
10 minutes ago, Crazy_sheep said:

@loordgekbut i have the value how do i inalize it do

18 hours ago, diesieben07 said:

Again, this is where basic Java knowledge comes in.

You need to learn what fields are and how to use them.

 

  • 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 28, 2020

but how do i inalize 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 28, 2020 (edited)

how long will this topic go on because i wanna close it but i am only gonne close it if i have a awnser

Edited October 28, 2020 by Crazy_sheep
  • 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 28, 2020

https://docs.oracle.com/javase/tutorial/java/javaOO/initial.html

  • 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 28, 2020

@loordgekbut what code do i need to put in it???

  • Quote

Share this post


Link to post
Share on other sites
  • Prev
  • 1
  • 2
  • 3
  • 4
  • Next
  • Page 3 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

    • squidlex
      How to correctly setup a Cancelable event

      By squidlex · Posted 9 minutes ago

      I have a custom event with the @Cancelable annotation, that I want to only do something if it isn't canceled. At the moment, I'm doing something like: if (!event.isCanceled()) { //Do Something } Which obviously doesn't work. How would I go about making an event that when fired, only runs code if it isn't cancelled? Thanks for your help!
    • DeNub
      Cannot create a modded forge server for 1.16.4

      By DeNub · Posted 9 minutes ago

      It wont let me join the server
    • LK1905
      [Solved][1.16.4] How do I correctly sync capability data between Client and server?

      By LK1905 · Posted 19 minutes ago

      I've changed the serializeNBT and deserialize methods so the value of i is in the key: @Override public CompoundNBT serializeNBT() { CompoundNBT data = new CompoundNBT(); for(int i = 0; i < 26; i++) { data.putInt("xp_" + i, (int) xp[i]); data.putInt("dynamic_" + i, dynamicLevels[i]); data.putInt("static_" + i, staticLevels[i]); } return data; } @Override public void deserializeNBT(CompoundNBT data) { for(int i = 0; i < 26; i++) { xp[i] = data.getInt("xp_" + i); dynamicLevels[i] = data.getInt("dynamic_" + i); staticLevels[i] = data.getInt("static_" + i); } }   And now it works, thank you! (I think thats what the first person to reply to this post was trying to tell me to do but I didn't understand at the time).
    • diesieben07
      Cannot create a modded forge server for 1.16.4

      By diesieben07 · Posted 26 minutes ago

      Try joining the server anyways and then post the debug.log from server and client.
    • DeNub
      Cannot create a modded forge server for 1.16.4

      By DeNub · Posted 32 minutes ago

      New Bitmap Image.bmp
  • Topics

    • squidlex
      0
      How to correctly setup a Cancelable event

      By squidlex
      Started 9 minutes ago

    • DeNub
      13
      Cannot create a modded forge server for 1.16.4

      By DeNub
      Started 4 hours ago

    • LK1905
      27
      [Solved][1.16.4] How do I correctly sync capability data between Client and server?

      By LK1905
      Started December 31, 2020

    • squidlex
      2
      How to cancel an event without subscribing to it

      By squidlex
      Started 46 minutes ago

    • Klarks
      2
      [1.16.4] My structure doesnt work

      By Klarks
      Started Tuesday at 03:55 PM

  • Who's Online (See full list)

    • Danebi
    • GrigLog
    • squidlex
    • topgun6854
    • Choonster
    • hrlil
    • LexManos
    • LK1905
    • CookieLukas
    • Pl00py_R
    • diesieben07
    • Error_Coding
    • DeNub
    • P0SCH1T0
  • 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