Jump to content

Small issue with onArmorTick [1.16.5]


Feroov

Recommended Posts

Hello everyone, so currently my onArmorTick as of now works but not the way I want, basically it is on a constant, for example if I have absorption, lets say it is on always 0:10 seconds and when I do take damage, instantly the absorption regens (basically invincible). Here is my code:
 

      @Override
      public void onArmorTick(ItemStack stack, World world, PlayerEntity player)
      {
          if(!world.isClientSide)
          {
              boolean hasPlayerAbsorptionEffect = !Objects.equals(player.getEffect(Effects.ABSORPTION), null);
                  if(player.getItemBySlot(EquipmentSlotType.HEAD).getItem() == ModItems.OCLUTRIUM_HELMET.get()
                                         && player.getItemBySlot(EquipmentSlotType.CHEST).getItem() == ModItems.OCLUTRIUM_CHESTPLATE.get() &&
                          player.getItemBySlot(EquipmentSlotType.LEGS).getItem() == ModItems.OCLUTRIUM_LEGGINGS.get() &&
                          player.getItemBySlot(EquipmentSlotType.FEET).getItem() == ModItems.OCLUTRIUM_BOOTS.get()
                                 )
                      player.addEffect(new EffectInstance(Effects.ABSORPTION, 200, 2));
                  super.onArmorTick(stack, world, player);
          }
      }

Cheers!

Edited by Feroov
Link to comment
Share on other sites

7 minutes ago, Luis_ST said:

your code works how it should, since ArmorItem#onArmorTick is called every tick (20 times in a second)
what did you try to achieve?

Yes everything works it's just that if i have absorption, it will insta heal the player back, which is game breaking you become lets say invincible, I wanted to make it in a way when you take damage, you still have the absorption effect but empty hearts if that makes sense, lets say you ate a golden apple and took damage, you know how the hearts still stay but blacked out, same logic here how I want hope that makes sense

Link to comment
Share on other sites

23 hours ago, Feroov said:
Objects.equals(

The fuck? Why not just compare the return value to something useful? Like, I don't know, getEffect() == null?

23 hours ago, Feroov said:
boolean hasPlayerAbsorptionEffect

Cool you stored whether or not the player has the absorption effect in a local variable.

Which you then never use.

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Yeah idk how to shut this down but it had something to do with parchment. It works now, I think I may have had the wrong version or something?
    • Recently while playing offline due to internet outages Malwarebytes identified Javaw.exe as malware, not thinking too much of it i deleted the file causing this error.  Unable to start Java. Error details: The requested operation requires elevation. Filename on disk: javaw.exe Path: C:\Users\---\curseforge\minecraft\Install\runtime\java-runtime-gamma\windows-x64\java-runtime-gamma\bin\javaw.exe Exists: File I reinstalled the file, same error occurred. I deleted CurseForge, over wolf and Minecraft and reinstalled them. Same error occurring. I have read starting Minecraft in administrator mode will help. I attempted to launch Minecraft through CurseForge in administrative mode this did not help.  I updated and downloaded the newest version of java, again receiving the same error. I updated Malwarebytes authorizing settings to allow for Javaw.exe through the pathway C:\Users\jacob\curseforge\minecraft\Install\runtime\java-runtime-gamma\windows-x64\java-runtime-gamma\bin\javaw.exe this did not assist either.  I am unsure of what to try next or what i am missing, i am not an expert with the complexities of these systems but any help to teach me or assist in problem solving would help. I also cannot find any debug logs or crash logs based on this specific circumstance.  The only thing that pops up when I search debug through the files is https://pastebin.com/WqMEvEn6.    
    • I have been trying my hardest to find the method to detect if the player is on the ground. I looked it up and people just say it like onGround always works, or isOnGround always works. Nothing shows up for me and the wording is red. I tried looking up an import but it doesn't seem to exist. I had to same issue with hasGlint, which turned out to be in the Item class and was isFoil instead. I even found the checkfalldamage method in the Living Entity class (I found this through looking at isFallFlying method and looking at usages) but it  uses its own variable to see if the player is on the ground, and I have NO idea where it gets that from! (It is called pOnGround) I am using Intellij, SDk 21, Language level 17, and the Forge version is 1.20.1-47.1.0. I Don't know where to look anymore and I feel like im going crazy.
    • I have been trying my hardest to find the method to detect if the player is on the ground. I looked it up and people just say it like onGround always works, or isOnGround always works. Nothing shows up for me and the wording is red. I tried looking up an import but it doesn't seem to exist. I had to same issue with hasGlint, which turned out to be in the Item class and was isFoil instead. I even found the checkfalldamage method in the Living Entity class (I found this through looking at isFallFlying method and looking at usages) but it  uses its own variable to see if the player is on the ground, and I have NO idea where it gets that from! (It is called pOnGround) I am using Intellij, SDk 21, Language level 17, and the Forge version is 1.20.1-47.1.0. I Don't know where to look anymore and I feel like im going crazy.
  • Topics

×
×
  • Create New...

Important Information

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