Posted December 14, 20168 yr First time modder here, so please excuse me if I failed massively, but can anyone explain why this behaviour is happening? The flight becomes very stuttery for some odd reason which I cannot really figure out Extract from the code in question: @SubscribeEvent public void onLivingUpdateEvent(LivingEvent.LivingUpdateEvent event) { if (event.getEntityLiving() == null || !(event.getEntityLiving() instanceof EntityPlayer) || event.isCanceled()) { return; } EntityPlayer player = (EntityPlayer) event.getEntityLiving(); if (Registry.enableFlightEnchantment && !player.isCreative()) handleFlight(player); // ... more abilities player.sendPlayerAbilities(); } private void handleFlight(EntityPlayer player) { if (hasEnchantment(EnchantmentFlight.NAME, player) && !player.capabilities.allowFlying) { player.capabilities.allowFlying = true; } else if(!hasEnchantment(EnchantmentFlight.NAME, player) && player.capabilities.allowFlying) { player.capabilities.allowFlying = false; } } private boolean hasEnchantment(String key, EntityPlayer player) { return EnchantmentHelper.getMaxEnchantmentLevel(Registry.enchantments.get(key), player) > 0; }
December 15, 20168 yr Author What do you mean by flight? Did you add a new elytra? Or did you make a "jetpack"? Or what exactly are you trying to do? And stuttery... You mean laggy? "Teleporty"? What exactly? Have you read my post at all? It's an Enchantment, setting the allowFlying capability on the player if present on the Armor. Have you checked the link? It shows the stuttering pretty well.
December 15, 20168 yr Author Full repo here: https://github.com/mc-mazen/moreenchantments And no, you don't get fall damage if allowFlying is true, even if in survival mode.
December 15, 20168 yr this checks if the world is client side Not quite this checks if the world is server side. Full repo here: https://github.com/mc-mazen/moreenchantments And no, you don't get fall damage if allowFlying is true, even if in survival mode. A couple of things.You should be using EnchantmentHelper.getEnchantmentLevel(...) and not EnchantmentHelper.getMaxEnchantmentLevel(...) Next if you haven't already if(!world.isRemote) { //allow flying code here } Instead of getting your Enchantment from the registry you should have a static field for your enchantment you should be using instead. Also in survival mode you should still take fall damage even if allowFlying is true. This is why the PlayerFlyableFallEvent exists. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 15, 20168 yr Author You should be using EnchantmentHelper.getEnchantmentLevel(...) and not EnchantmentHelper.getMaxEnchantmentLevel(...) That's already done. I added an && event.side == Side.SERVER check, which should techically be the same if i'm not mistaken. Instead of getting your Enchantment from the registry you should have a static field for your enchantment you should be using instead. I'm a relative Java newb although i have a professioal programming background, but are HashMaps with 6 entries really that bad? (this is not the Forge registry we are talking about, here). Also in survival mode you should still take fall damage even if allowFlying is true. This is why the PlayerFlyableFallEvent exists. I don't get any damage though, which seems to be contradicting. Anyhow, still after using either event.SIDE or player.getEntityWorld().isRemote , i still experience the choppieness when double tapping the space bar. I can fly fine after spamming the spacebar enough however that is really an annoying behaviour
December 16, 20168 yr I'm a relative Java newb although i have a professioal programming background, but are HashMaps with 6 entries really that bad? (this is not the Forge registry we are talking about, here). Unless you specifically have to use a HashMap ie you need some way to save the Enchantment yourself to something there is no need to use one. And post your updated code. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 16, 20168 yr I added an && event.side == Side.SERVER check, which should techically be the same if i'm not mistaken. Nope. That checks physical side, not logical side. SSP will return true for both the client and server in that case. If you want logical side, you MUST check world.isRemote (read it as "world.isClient"). 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.
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.