Jump to content

How stop my PlayerEventHandler from crashing everytime I go into water


Ants1207

Recommended Posts

Hey all, I am very new to modding (started a week ago lol) and I have an ap computer science course level of java info. With some help of chatGPT and looking through forge api (trying to fix the things that arent in 1.21 since i can't find the api for that and I am using forge 1.21) I am trying to make a devil fruit mod. For all you non one piece fans, basically when you eat it it gives you a power (I will implement that later), It makes it so that you can't eat another without dying (Already implemented), and it makes it so that you can't swim. For now, I am trying to make the player really slowed down while going into the water. This is my code (except for my imported classes and package (YES I HAVE IMPORTED EVERYTHING :))):

 

@Mod.EventBusSubscriber(modid = DevilFruitMod.MOD_ID)
public class PlayerEventHandler {

    @SubscribeEvent
    public static void onLivingUpdate(LivingEvent event) {
        if (event.getEntity() instanceof Player player) {
            if (player.isInWater()) {
                applySlownessEffect(player, 60, 2);
            }

        }
    }

   /* @SubscribeEvent
    public static void onLivingJump(LivingEvent.LivingJumpEvent event) {
        if (event.getEntity() instanceof Player player) {

            // Check if you want to prevent jumping under certain conditions
            if (player.isInWater()) {
                event.setCanceled(true); // Cancel the jump event
            }
        }
    }*/

    public static void applySlownessEffect(Player player, int durationInTicks, int amplifier) {
        MobEffectInstance slownessEffect = new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, durationInTicks, amplifier);
        player.addEffect(slownessEffect);
    }
}

However, whenever I go into water (im testing it without the devil fruit part rn), the game crashes and I get this error in my run client:

Caused by: java.lang.LinkageError: loader constraint violation: loader 'SECURE-BOOTSTRAP' @add0edd wants to load interface org.apache.logging.log4j.util.MessageSupplier. (org.apache.logging.log4j.util.MessageSupplier is in module [email protected] of loader 'SECURE-BOOTSTRAP' @add0edd, parent loader 'app')

I would also like to be able to make them unable to jump, or if someone had a suggestion to make them completely unable to swim instead of slow and jump please tell me. Or if there was a way I could make it so that right after they eat the fruit they cant swim for the rest of the game in my fdevilfruit class after they use the item. Sorry if it is hard to help me since I havent shown the rest of my classes.

Can anyone please help, and aa good explantion would be nice since I am relatively new to modding but I love programming and want to understand what is happening. 

Thanks :)!

Edited by Ants1207
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.