Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

how to make creepers charged on spawn


Crazy_sheep
 Share

Recommended Posts

18 minutes ago, Crazy_sheep said:

@loordgekif I learn java I then still don't know how to do stuff in forge

and its a lot more fun to learn java with forge

Trying to explore and understand forge/minecraft concepts and code without knowing java is pure madness...trying to learn java by doing stuff that, at the beginning, makes almost no sense even to experienced Java programmers is even more madness

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

You already have the answer here:

23 hours ago, Draco18s said:

Well, the POWERED value and the dataManager are both private, so....

21 hours ago, Draco18s said:

ReflectionObfuscationHelper if I remember the class's name correctly.

You call getPrivateValue and pass in the SRG name of the field you want.

 

Edited by Danebi
Link to comment
Share on other sites

1 make a static DataParameter<Boolean> field in your Events class

2use ObfuscationReflectionHelper.getPrivateValue inside a static block https://www.geeksforgeeks.org/g-fact-79/  to init the field

the fieldname is "field_184714_b"

3 in your event handler method check if the entity is a creeper

4 get the EntityDataManager and set the value with the DataParameter field in the class

Edited by loordgek
Link to comment
Share on other sites

@loordgekok i will try to do it if it works i will but solved behind the topic

and when i try to add public or private static DataParameter<Boolean> it gives a error

package ultrahardcore.ultrahardcore.events;


import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.CreeperEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.datasync.DataParameter;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(value = Dist.CLIENT)

public class Events {

    public static DataParameter<Boolean>// when i add this it errors

    @SubscribeEvent
    public void autoChargeCreeper(EntityJoinWorldEvent event)
    {
        CreeperEntity creeper = (CreeperEntity) event.getEntity();
        if (event.getEntity() instanceof CreeperEntity) {

        }
    }
}

and where do i put field_184714_b

and where is my event handler???

Edited by Crazy_sheep
Link to comment
Share on other sites

        CreeperEntity creeper = (CreeperEntity) event.getEntity();
        if (event.getEntity() instanceof CreeperEntity)

Why would you cast it before checking it? This makes the checking pointless.

 

@Mod.EventBusSubscriber(value = Dist.CLIENT)

You should not be modifying entity data on client.

16 hours ago, loordgek said:

use ObfuscationReflectionHelper.getPrivateValue inside a static block https://www.geeksforgeeks.org/g-fact-79/  to init the field

the fieldname is "field_184714_b"

 

Link to comment
Share on other sites

https://stackoverflow.com/a/4186354

https://mcforge.readthedocs.io/en/latest/concepts/sides/#fmlenvironmentdist-and-onlyin

I'm not sure which one is better (getPrivateValue/findField), but you will need to save the returned value into a static final field, and use them when needed. I hope you've done your own research and stuff instead of sitting here waiting for someone to give you copy paste code, good luck : )

Link to comment
Share on other sites

i am sorry but i still dont get how to do this because public static final DataParameter<Boolean> gives errors

and i dont know how the getPrivateValue works

and i really wanna end this topic because i want to get this too work in my land its been 3 days and its still not working

Edited by Crazy_sheep
Link to comment
Share on other sites

1 hour ago, Crazy_sheep said:

i am sorry but i still dont get how to do this because public static final DataParameter<Boolean> gives errors

It gives errors because what you are writing isn't valid Java. If you want to mod Minecraft you're supposed to know Java.

1 hour ago, Crazy_sheep said:

and i dont know how the getPrivateValue works

It has a javadoc but even if it didn't, you can still figure it by yourself.

1 hour ago, Crazy_sheep said:

and i really wanna end this topic because i want to get this too work

Then learn Java.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.