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!