Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.1] onArmorTick method not working
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 2
mirakapz97

[1.16.1] onArmorTick method not working

By mirakapz97, October 15, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

mirakapz97    0

mirakapz97

mirakapz97    0

  • Tree Puncher
  • mirakapz97
  • Members
  • 0
  • 6 posts
Posted October 15, 2020

Hello, so I wanted to add permanent potion effect to the Armor I created when fully equipped.

I meddled around in the internet to find some solutions but couldnt figure out anything since the weirdest part in my code is that it dosent show any problems in the log at the bottom.

 

Here's my Classes for RegistryHandler, OmArmorMaterial and ArmorEffects

 

>RegistryHandler: https://pastebin.com/WGPnjHCh

>OmArmorMaterial: https://pastebin.com/Msgx8Avc

>ArmorEffects: https://pastebin.com/rcSsjv8c

 

I am generally confused as to why its not working and yet not giving me any issues in the problems logger, any help is greatly appriciated.

Big tanks in advance!

 

Here's also a screenshot of ArmorEffects if thats in any help:

32IXhl4.png

  • Quote

Share this post


Link to post
Share on other sites

ChampionAsh5357    160

ChampionAsh5357

ChampionAsh5357    160

  • World Shaper
  • ChampionAsh5357
  • Members
  • 160
  • 1017 posts
Posted October 15, 2020

Instead of applying every tick, I would rather subscribe to LivingEquipmentChangeEvent or whatever its called and check there and apply infinitely. Less data calculated per tick. However, you will need to check if the effect gets removed due to milk or something and reapply when that happens. However, that's my opinion.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

mirakapz97    0

mirakapz97

mirakapz97    0

  • Tree Puncher
  • mirakapz97
  • Members
  • 0
  • 6 posts
Posted October 15, 2020

Much thanks ! 👍

  • Quote

Share this post


Link to post
Share on other sites

mirakapz97    0

mirakapz97

mirakapz97    0

  • Tree Puncher
  • mirakapz97
  • Members
  • 0
  • 6 posts
Posted October 16, 2020

@ChampionAsh5357It works now but i have a issue where, when i recieve the fire resistance on armor equp, i tried doing a onTickEvent to try and make so the effect refreshes and dosen't run out, but for some reason it dosent work and it has the same issue as onArmorTick. Is there any way i could make the effect infinite and to remove the fire resistance effect once i unequip armor?

 

Pic:

Y7E5boc.png

  • Quote

Share this post


Link to post
Share on other sites

vemerion    56

vemerion

vemerion    56

  • Creeper Killer
  • vemerion
  • Members
  • 56
  • 220 posts
Posted October 16, 2020
1 hour ago, mirakapz97 said:

Is there any way i could make the effect infinite and to remove the fire resistance effect once i unequip armor?

Just set the duration to something high (like Integer.MAX_VALUE) to approximate an infinite duration. To solve your other problem, just add an else to the if statement you already have, and use player.removePotionEffect().

 

You would still have to reapply the effect if it gets removed due to for example milk, as ChampionAsh pointed out.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

mirakapz97    0

mirakapz97

mirakapz97    0

  • Tree Puncher
  • mirakapz97
  • Members
  • 0
  • 6 posts
Posted October 16, 2020

Everything working as intended now! Appriciate it very much! @ChampionAsh5357 and @vemerion

  • Quote

Share this post


Link to post
Share on other sites

poopoodice    109

poopoodice

poopoodice    109

  • Dragon Slayer
  • poopoodice
  • Members
  • 109
  • 886 posts
Posted October 16, 2020 (edited)

I don't think applying potion effects on client will work as you expected.

Edited October 16, 2020 by poopoodice
  • Quote

Share this post


Link to post
Share on other sites

mirakapz97    0

mirakapz97

mirakapz97    0

  • Tree Puncher
  • mirakapz97
  • Members
  • 0
  • 6 posts
Posted October 16, 2020

@poopoodice Yeeah, i realised until late cuz i left it off and on the other day, I tried equipping the obsidian armor i get the effect, when i remove the armor the effect dissapears as intended. But the current issue is when for example i use a regular fire resistance potion and equip any other type for armor the effect gets removed. So im trying to figure that out.  i tried adding a else if with IsPotionActive and the regular potion effect stays when i equip any other type of armor. But when i equip the full obsidian set i get the infinite effect again but when i remove the set the infinite effect still stays there.

  • Quote

Share this post


Link to post
Share on other sites

vemerion    56

vemerion

vemerion    56

  • Creeper Killer
  • vemerion
  • Members
  • 56
  • 220 posts
Posted October 16, 2020
29 minutes ago, mirakapz97 said:

But the current issue is when for example i use a regular fire resistance potion and equip any other type for armor the effect gets removed

Whoops, I did not think about that when I wrote my response :P. If I remember correctly, you can get the equipment that was previously equipped from the event as well. Try checking that the previously equipped item was your custom armor, and the newly equipped armor is not, and only then remove the effect.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

poopoodice    109

poopoodice

poopoodice    109

  • Dragon Slayer
  • poopoodice
  • Members
  • 109
  • 886 posts
Posted October 16, 2020

Maybe it is not the best idea but what I do is apply 1 tick duration effect to the wearer if the wearer does not have the effect(isPotionActive) and has full equipped your armour set. By this you don't have to worry about the effect gets removed externally(milk, commands...), and the effect will disappear right after you take of your armour set. It also avoids you to remove the effect if the effect is applied externally via commands, potions...etc.

Just my thoughts, may not be the best.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

mirakapz97    0

mirakapz97

mirakapz97    0

  • Tree Puncher
  • mirakapz97
  • Members
  • 0
  • 6 posts
Posted October 21, 2020

I aplologise for the late response, i made it so it checks out the gear im wearing and now everything is working like a charm. Thank you all!

@ChampionAsh5357 , @vemerion , @poopoodice . 👍

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • poopoodice
      Adding jar files to existing environment

      By poopoodice · Posted 9 minutes ago

      It's been discussed for a long time, but none of the solutions worked for me (maybe I did not did them right). So I have created another mod (basically a tool) and I want to use it in another environment, this is what I've tried:   1. run normal build ./gradlew.bat build, and then put built jar from lib into the mods folder. 2. run jar build ./gradlew.bat jar, and then put built jar from reobfJar into the mods folder. 3. build jar using existing ide options, and then put built jar from lib into the mods folder.   1 & 2 causes crashes, and 3 does not work at all (not detected).   What is the correct way of doing it in 1.16.4? Thanks.
    • Draco18s
      GUI Documentation

      By Draco18s · Posted 35 minutes ago

      GUIs aren't that difficult. There's dozens of tutorials for them and they haven't really changed all that much in ten years.
    • Xenfo
      Mod Blocker

      By Xenfo · Posted 51 minutes ago

      Any mod blockers that actually work? Please link them if yes.
    • diesieben07
      Tessellator ignores lighting?

      By diesieben07 · Posted 1 hour ago

      Neither 1.10 now 1.14 are supported here. Please refer to the supported versions page: https://forums.minecraftforge.net/topic/91712-supported-version-directory/
    • CookieLukas
      Tessellator ignores lighting?

      By CookieLukas · Posted 1 hour ago

      Oh,  sorry, the code was 1.10.2, but as its not allowed here, I updated it to 1.14.4.
  • Topics

    • poopoodice
      0
      Adding jar files to existing environment

      By poopoodice
      Started 9 minutes ago

    • T1ps
      3
      GUI Documentation

      By T1ps
      Started Tuesday at 10:14 PM

    • Xenfo
      0
      Mod Blocker

      By Xenfo
      Started 51 minutes ago

    • CookieLukas
      3
      Tessellator ignores lighting?

      By CookieLukas
      Started 2 hours ago

    • Extrodonary
      1
      Forge isn't working on Minecraft Realms

      By Extrodonary
      Started 1 hour ago

  • Who's Online (See full list)

    • Pinary
    • StealthyNoodle
    • bananapizzuh
    • Xenfo
    • Warsade
    • monkeysHK
    • Microcellule
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.1] onArmorTick method not working
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community