Leronus Posted October 14, 2021 Posted October 14, 2021 (edited) 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 October 14, 2021 by Leronus Forgot gitRepo Quote
Leronus Posted October 14, 2021 Author Posted October 14, 2021 (edited) On 10/14/2021 at 4:22 PM, 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? Expand 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 October 14, 2021 by Leronus Further explanation Quote
Leronus Posted October 14, 2021 Author Posted October 14, 2021 On 10/14/2021 at 6:28 PM, 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. Expand My bad sorry. I solved it by using the accesstransformers for PlayerEntity as well. Thanks though! Quote
Recommended Posts
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.