Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/03/22 in all areas

  1. That way of doing it is very inefficient. The PlayerTick event is called on the client and server at both the start and end of each tick. You should be checking event.side and event.phase to limit when you do things. The onUpdateAbilities() sends a network packet to the other side. So, your code would be sending 4 network packets per player per tick. Here's a more efficient way: @Mod.EventBusSubscriber(modid = MODID) public class Events { @SubscribeEvent public static void equipmentChange(LivingEquipmentChangeEvent event) { if (event.getEntity() instanceof Player player && event.getSlot() == EquipmentSlot.OFFHAND) { // WARNING: Proof of concept code not the correct logic player.getAbilities().mayfly = event.getTo().is(Items.DIAMOND); player.onUpdateAbilities(); } } } That event only happens on the server and only when the equipment actually changes. The above works for me, using diamonds in the shield slot as my trigger. WARNING. The above logic is not complete. One example is, it would remove flight from creative mode players when they remove the diamond. Another is it doesn't set flying=false when the diamonds are removed.
    1 point
  2. You're right. That is a bug. You should report it as an issue on github MinecraftForge project. EDIT: I've gone ahead and logged the issue: #4617
    1 point
  3. Figured it out; for some reason SpawnAlwaysVisibleParticle() is defaulting ignoreRange to false... but the SpawnParticle with a boolean condition works just fine. Thanks for your help!
    1 point
×
×
  • Create New...

Important Information

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