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

Access Transformer not working - I would like to use some protected methods


Leronus
 Share

Recommended Posts

public net.minecraft.entity.LivingEntity func_184583_d(Lnet/minecraft/util/DamageSource;)Z # isDamageSourceBlocked
public net.minecraft.entity.LivingEntity func_184590_k(F)V # hurtCurrentlyUsedShield
public net.minecraft.entity.LivingEntity func_190629_c(Lnet/minecraft/entity/LivingEntity;)V # blockUsingShield

I'm trying to use these methods in LivingEntity.java, but I'm getting the following error: 

"attempting to assign weaker access privileges; was public"

 

I would like to use these methods in my Hooks.java class (location: /src/main/java/mod/mores/util/Hooks.java),

so that I can change how much incoming damage my custom shields can block.

 

My question is, why am I getting this error?

And also, what would be the correct way of achieving what I want?

 

GitRepository: https://github.com/Leronus/mOres

 

Edited by Leronus
Forgot gitRepo
Link to comment
Share on other sites

Protected methods cannot easily be made public, you have to list all methods that override them. Only the actual method you list will be transformed, so the overriding methods now produce errors (you cannot override a public method with a protected one).

Firstly, isDamageSourceBlocked is already public.

Why do you want to call these methods?

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

Protected methods cannot easily be made public, you have to list all methods that override them. Only the actual method you list will be transformed, so the overriding methods now produce errors (you cannot override a public method with a protected one).

Firstly, isDamageSourceBlocked is already public.

Why do you want to call these methods?

 

I'm trying to modify the amount of damage blocked. For example, the vanilla shield currently blocks 100% of incoming damage, I would like to change that to 60%.

For my other custom shields I want to increase this numbers, which depends on the material the shield is made out of.

To do so, I require access to

1. LivingEntity.isDamageSourceBlocked(DamageSource p_184583_1_)

2. LivingEntity.blockUsingShield(LivingEntity p_190629_1_) 

3. LivingEntity.hurtCurrentlyUsedShield(float p_184590_1_)

When I look at LivingEntity.isDamageSourceBlocked(DamageSource p_184583_1_) it is most definitely private.

The other two methods are indeed protected.

I am currently using Forge 36.2.6

 

Any way to accomplish this or should I just accept the vanilla shield functionality?

 

 

Edited by Leronus
Further explanation
Link to comment
Share on other sites

56 minutes ago, Leronus said:

I am currently using Forge 36.2.6

I was looking at the latest version, because you did not specify. In 1.17 this method is public.

58 minutes ago, Leronus said:

Any way to accomplish this or should I just accept the vanilla shield functionality?

You can call the methods using reflection.

  • Thanks 1
Link to comment
Share on other sites

10 minutes ago, diesieben07 said:

I was looking at the latest version, because you did not specify. In 1.17 this method is public.

You can call the methods using reflection.

My bad sorry. I solved it by using the accesstransformers for PlayerEntity as well. Thanks though!

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.

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.