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



×
×
  • Create New...

Important Information

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