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.7.2] If wore armor does certain abilities
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Heltrato

[1.7.2] If wore armor does certain abilities

By Heltrato, July 3, 2014 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted July 3, 2014

As the title says what is the best way ill do that in an event or in the ItemStack on itemUseClick? please reply because i wanna try this.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7587

diesieben07

diesieben07    7587

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7587
  • 54935 posts
Posted July 3, 2014

It depends on which abilities you want to add. But

onArmorTick

is usually useful for this, it is called every tick as long as your armor piece is equipped (keep in mind: If the player wears a full armor set, it is called for every Item in the set every tick).

  • Quote

Share this post


Link to post
Share on other sites

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted July 3, 2014

Nice nice :D onArmorTick exactly what i need really easy :)

about the full set ? on worries i know that

thanks for the help thou :)

  • Quote

Share this post


Link to post
Share on other sites

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted July 3, 2014

Last Question : How do player detects if its holding an ItemFood.class?

 

as of now i got this i havent test much but hopefully this might :)

 

 

@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemstack) {
	ItemStack boots = player.getCurrentArmor(0);
	ItemStack legs = player.getCurrentArmor(1);
	ItemStack chest = player.getCurrentArmor(2);
	ItemStack helmet = player.getCurrentArmor(3);

	int duration = 15;
	if(boots != null && legs != null && chest != null && helmet != null)
	{
	if(boots.getItem() == MHFCRegItem.mhfcitemtigrexboots && legs.getItem() == MHFCRegItem.mhfcitemtigrexlegs &&
	chest.getItem() == MHFCRegItem.mhfcitemtigrexchest && helmet.getItem() == MHFCRegItem.mhfcitemtigrexhelm)
	{
		if(player){

		}
	}
	}
}


  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7587

diesieben07

diesieben07    7587

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7587
  • 54935 posts
Posted July 3, 2014

player.getCurrentEquippedItem gives you the current Item. Then just check with instanceof if it's a food item.

Also: You have not listened to my advice about the full set :P Your code will run 4 times per tick instead of 1.

  • Quote

Share this post


Link to post
Share on other sites

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted July 3, 2014

instanceof yeah im trying that now , yeah sorry about that im trying to figure out myself but ill fix it myself :)

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7587

diesieben07

diesieben07    7587

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7587
  • 54935 posts
Posted July 3, 2014

It would be as simple as adding the additional check of if (this == MyMod.theHelmetItem) (or any other of your armor set it doesn't matter).

  • Quote

Share this post


Link to post
Share on other sites

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted July 3, 2014

Did i made right? i got an idea at your tip and this is what i made :)

 

 

@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemstack) {
	ItemStack food = player.getCurrentEquippedItem();
	if(this != null && this == MHFCRegItem.mhfcitemtigrexhelm && this == MHFCRegItem.mhfcitemtigrexboots && this == MHFCRegItem.mhfcitemtigrexchest && this == MHFCRegItem.mhfcitemtigrexlegs){
		if(food.getItem() instanceof ItemFood){

		}
	}
}

 

If it is one last Question how do i detect the itemfood maxduration because this armor makes u eat faster >.<

  • Quote

Share this post


Link to post
Share on other sites

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted July 3, 2014

No wait wait i made wrong let me fix this hmmm sorry bout that let me straightly fix this

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7587

diesieben07

diesieben07    7587

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7587
  • 54935 posts
Posted July 3, 2014

You're basically saying "Only do this if I am the boots, the legs, the chestpiece and the helmet all in one", which is never gonna happen :P

  • Quote

Share this post


Link to post
Share on other sites

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted July 3, 2014

OMG i always crash doing stuff this is pretty complicated

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7587

diesieben07

diesieben07    7587

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7587
  • 54935 posts
Posted July 3, 2014

This is not very complicated.

  • Quote

Share this post


Link to post
Share on other sites

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted July 3, 2014

Uhm , am i right

the one that runs 4 times is the cause of this variables ?

 

	ItemStack boots = player.getCurrentArmor(0);
	ItemStack legs = player.getCurrentArmor(1);
	ItemStack chest = player.getCurrentArmor(2);
	ItemStack helmet = player.getCurrentArmor(3);

 

Also how do player detect the item duration on itemuse ? im probably putting all things now and gonna test it if im not mistaking of the codes above

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7587

diesieben07

diesieben07    7587

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7587
  • 54935 posts
Posted July 3, 2014

It is running 4 times because it is run for every armor piece that the player is wearing. Only one of them (it doesn't matter which because you check for the full set anyways) should execute the code.

  • Quote

Share this post


Link to post
Share on other sites

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted July 3, 2014

So if hopefully if im not mistaken i should to this ?

 

ItemStack armor = player.getCurrentArmor(armorType // <---- to get all the sets);

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7587

diesieben07

diesieben07    7587

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7587
  • 54935 posts
Posted July 3, 2014

Ehm... no.

Pseudocode:

if (this == theHelmetItem && player.isWearingFullSet()) {
    // performAction
}

 

  • 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 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Rollng
      Game crashes while loading world

      By Rollng · Posted 7 minutes ago

      Whenever i try to enter my world game closes itself. Heres crash report and log : Log, Crash
    • Linky132
      [SOLVED] [1.16.5 ] Dust Block Texture Glitch

      By Linky132 · Posted 30 minutes ago

      I figured it out. I had the render type set to translucent, when what it should have been on was cutout. Thanks for the help.
    • Klarks
      [1.16.4] How i can open a container by clicking on my mob

      By Klarks · Posted 55 minutes ago

      So what needs to be implemented? My Entity?  
    • Linky132
      (1.16.2) Making a new capability (3)

      By Linky132 · Posted 1 hour ago

      I could be wrong, but I think you might need to add this code in the constructor: FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); And you may need to change the setup method to non-static.
    • Linky132
      [SOLVED] [1.16.5 ] Dust Block Texture Glitch

      By Linky132 · Posted 1 hour ago

      Also, the texture doesn't glitch when the dust is in a straight line, or when it's in its dot form (not the '+' shape).
  • Topics

    • Rollng
      0
      Game crashes while loading world

      By Rollng
      Started 8 minutes ago

    • Linky132
      4
      [SOLVED] [1.16.5 ] Dust Block Texture Glitch

      By Linky132
      Started 18 hours ago

    • Klarks
      12
      [1.16.4] How i can open a container by clicking on my mob

      By Klarks
      Started 18 hours ago

    • e2rifia
      13
      (1.16.2) Making a new capability (3)

      By e2rifia
      Started 6 hours ago

    • Somonestolemyusername
      18
      [1.15.2] How Would I make a custom bow?

      By Somonestolemyusername
      Started Tuesday at 09:30 PM

  • Who's Online (See full list)

    • Rollng
    • Somonestolemyusername
    • SixSix
    • Edrax
    • Klarks
    • Linky132
    • scorpin1
    • Sensenmann
    • JoB76205
    • StealthyNoodle
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.7.2] If wore armor does certain abilities
  • Theme

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