Posted August 23, 20205 yr Hi everyone, I'm very new in coding and i thought it's a good idea to start with Minecraft modding. A lot of my things work but one thing doesnt work: I tried to give me Godmode with Regeneration but i dont get the Potion. So can anyone help me with my code?(Please an example code) And sorry for my bad english ._. Here is the code: import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.potion.Effect; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; public class Godmode { public static PlayerEntity Player = Minecraft.getInstance().player; public static boolean Toggle = false; public static void Regeneration() { if(Toggle){ PlayerEntity Player = Minecraft.getInstance().player; EffectInstance EffectInstance = new EffectInstance(Effects.REGENERATION); Player.getActivePotionEffect(Effect.get(20)); Toggle = false; }else{ Player.removeActivePotionEffect(Effects.REGENERATION); Toggle = true; } } } Edited August 23, 20205 yr by vJesus
August 23, 20205 yr Ugh, let's break this down... First, this will never load since it's mod not a mod. Second, you are reaching across logical sides making it crash on the server. Third, there will be no actual result on the client because that's where you call it from. Fourth, you have static variables meaning that you can only have one instance of it for all players. Fifth, why in the world do you have a static and nonstatic variable doing the same wrong thing? Sixth, you have unused variables that actually makes the code work. Seventh, what in the world are you using integer ids for? Eighth, you're not even giving the player regeneration. Ninth, this is all declared in a static method for some strange reason. Tenth, you're not even calling the method. And finally, the only thing you did right was removing the potion effect even though it will never work. Please take time to learn some java and read the docs. Don't go asking for example code if you're not understanding what you are doing, it just makes the learning curve that much harder.
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.