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

Can't get enchantment to work (1.12.2)


Danieldrd
 Share

Recommended Posts

Hi everyone, I'm really new to forge and everything  and am trying to make a new enchantment that can be applied to boots called "Jump".

 

As the name may imply, I want it to make a player jump higher. For testing purposes at least, this is twice as high as normal. The enchantment book appears in game and applies to boots just fine, but nothing happens.

 

This is the EnchantmentJump class (everything is imported above this):

public class EnchantmentJump extends Enchantment {
    public EnchantmentJump() {
        super(Enchantment.Rarity.RARE, EnumEnchantmentType.ARMOR_FEET, new EntityEquipmentSlot[] {EntityEquipmentSlot.FEET});
        this.setRegistryName("Jump");
        this.setName("Jump");
    }

    @Override
    public int getMaxLevel() {
        return 1;
    }

    @SubscribeEvent
    public void jumpBoost(LivingEvent.LivingJumpEvent event){
        int level = EnchantmentHelper.getMaxEnchantmentLevel(ModEnchantments.JUMP, event.getEntityLiving());

        if (level > 0) {
            EntityLivingBase player = event.getEntityLiving();
            player.motionY *= 2;
        }
    }

}

 

Here is my ModEnchantments class (again, everything is imported above this):

@Mod.EventBusSubscriber(modid=DanielsMinecraftMod.MODID)
public class ModEnchantments {

    public static final Enchantment JUMP = new EnchantmentJump();

    @SubscribeEvent
    public static void registerEnchantments(RegistryEvent.Register<Enchantment> event) {
        event.getRegistry().registerAll(JUMP);
    }
}

 

I realise that the reason this isn't working is likely a misunderstanding of how Forge works or something incredibly obvious, but I have been having trouble nonetheless.

 

Thanks!

Edited by Danieldrd
Link to comment
Share on other sites

5 minutes ago, Danieldrd said:

player.motionY *= 2;

this here seems kinda weird. i think this would probably make gravity 2 times as big. you might not be seeing the higher jump because the gravity is stronger and pulling the player to the ground faster. this is just speculation. i think giving the player a jump boost effect (like, the potion one) may be a better idea. Also im pretty sure you can check if the player is jumping using the LivingJumpEvent if that's useful. I hope this helps at least a little

Link to comment
Share on other sites

1.12 is no longer supported.

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



×
×
  • Create New...

Important Information

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