Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

How do I give leather armor a special effect?


  • Please log in to reply
15 replies to this topic

#1

Liquid Metal Slime

Posted 31 March 2012 - 02:39 AM

I added this new food stat to FoodStats.java. It is called foodExhaustionLimit. I defined foodExhaustionLimit as 4F, and replaced 4F with foodExhaustionLimit in the code where food exhaustion reaches 4F in vanilla. I tested this out and it worked just like vanilla. When I edited the foodExhaustionLimit, raising it and lowering it worked as intended.

However, I am at a loss for making code that will do the thing that I was thinking of doing with the food exhaustion limit when I added it. That thing is making each piece of leather armor add 1F to the player's foodExhaustionLimit as long as it is equipped. This would mean that the more leather armor you have on, the longer it takes for you to get hungry.

public boolean OnTickInGame(Minecraft minecraft)
	{
		ItemStack boots = minecraft.thePlayer.inventory.armorInventory[0];
		ItemStack legs = minecraft.thePlayer.inventory.armorInventory[1];
		ItemStack chest = minecraft.thePlayer.inventory.armorInventory[2];
		ItemStack helm = minecraft.thePlayer.inventory.armorInventory[3];
		if(helm != null && helm.itemID == helmetLeather.shiftedIndex)
		{
			minecraft.thePlayer.isImmuneToFire = true;
		}
		if(chest != null && chest.itemID == plateLeather.shiftedIndex)
		{
			minecraft.thePlayer.isImmuneToFire = true;
		}
		if(legs != null && legs.itemID == legsLeather.shiftedIndex)
		{
			minecraft.thePlayer.isImmuneToFire = true;
		}
		if(boots != null && boots.itemID == bootsLeather.shiftedIndex)
		{
			minecraft.thePlayer.isImmuneToFire = true;
		}
		return true;
	}

Here is some code that I am starting out with and for a start I want to make sure that I am able to give leather armor an effect at all, specifically immunity to fire for purposes of testing. However, it won't recognize the leather armor, how do I get it to recognize the leather armor? It won't go into italics and it keeps saying "bootsLeather cannot be resolved to a variable" for each of the equipment respectively.

Register or log in to remove.

#2

PhantomJedi759
  • Minecraft: PhantomJedi759

Posted 13 April 2012 - 03:09 AM

Do not mod base classes!  Ask again later when you find a method that does not involve changing base classes!

#3

Joneal9174
  • Minecraft: Joneal

Posted 13 April 2012 - 04:36 AM

He isn't modding base classes.  And base class modding isn't a reason not to help someone.  Anyways, I think you probably need to add Item before all of the items.  Such as Item.bootsLeather.itemID
Did I help?  Hit the Posted Image at the lower right corner of my post!

#4

xTwilight3
  • Minecraft: xTwilight

Posted 13 April 2012 - 06:18 AM

View PostPhantomJedi759, on 13 April 2012 - 03:09 AM, said:

Do not mod base classes!  Ask again later when you find a method that does not involve changing base classes!

Well, only in some cases.

View PostJoneal9174, on 13 April 2012 - 04:36 AM, said:

He isn't modding base classes.  And base class modding isn't a reason not to help someone.  Anyways, I think you probably need to add Item before all of the items.  Such as Item.bootsLeather.itemID

Probably that, only thing I can see that could be in-correct, and YES there are cases where you just need to tell people to not edit baseclasses because it can be rather stupid, such as editing EnumToolMaterial, Block, Item and whatnot WITH NO special reason to do so.
Did my post help? Click the Posted Image on my post. It's 110% optional Popcorn smelting, old removed feature, new mod. :D

#5

RANKSHANK
  • Location: American lost in Aussyland
  • Minecraft: RANKSHANK

Posted 13 April 2012 - 07:19 AM

View PostLiquid Metal Slime, on 31 March 2012 - 02:39 AM, said:

However, it won't recognize the leather armor, how do I get it to recognize the leather armor? It won't go into italics and it keeps saying "bootsLeather cannot be resolved to a variable" for each of the equipment respectively.
Did you call bootsLeather from item.class?
shouldnt it be
Item.bootsLeather.shiftedIndex

Posted Image

#6

TechGuy543
  • Location: QLD, Australia

Posted 14 April 2012 - 03:25 AM

OnTickInGame
needs to be
onTickInGame

Also do what RANKSHAFT said.

“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant;
together they are powerful beyond imagination."


#7

Liquid Metal Slime

Posted 14 April 2012 - 03:31 AM

View PostRANKSHANK, on 13 April 2012 - 07:19 AM, said:

Did you call bootsLeather from item.class?
shouldnt it be
Item.bootsLeather.shiftedIndex

Thanks. Now I've done that.

View PostTechGuy543, on 14 April 2012 - 03:25 AM, said:

OnTickInGame
needs to be
onTickInGame

Also do what RANKSHAFT said.

And that.
But, now the problem is it won't work, I'm not immune to fire when I have leather pants on. Here's what I've got:

public boolean onTickInGame(Minecraft minecraft)
	{
			ItemStack boots = minecraft.thePlayer.inventory.armorInventory[0];
			ItemStack legs = minecraft.thePlayer.inventory.armorInventory[1];
			ItemStack chest = minecraft.thePlayer.inventory.armorInventory[2];
			ItemStack helm = minecraft.thePlayer.inventory.armorInventory[3];
			if(helm != null && helm.itemID == Item.helmetLeather.shiftedIndex)
			{
					minecraft.thePlayer.isImmuneToFire = true;
			}
			if(chest != null && chest.itemID == Item.plateLeather.shiftedIndex)
			{
					minecraft.thePlayer.isImmuneToFire = true;
			}
			if(legs != null && legs.itemID == Item.legsLeather.shiftedIndex)
			{
					minecraft.thePlayer.isImmuneToFire = true;
			}
			if(boots != null && boots.itemID == Item.bootsLeather.shiftedIndex)
			{
					minecraft.thePlayer.isImmuneToFire = true;
			}
			return true;
	}


#8

RANKSHANK
  • Location: American lost in Aussyland
  • Minecraft: RANKSHANK

Posted 14 April 2012 - 04:22 AM

View PostLiquid Metal Slime, on 14 April 2012 - 03:31 AM, said:

~snip~
Have you set in game gook for the ticking?
Posted Image

#9

meeees
    meeees

    Void Walker

  • Curse Premium
  • Curse Premium
  • 1560 posts
  • Minecraft: meeees

Posted 14 April 2012 - 05:42 AM

u have them flipped
boots is minecraft.thePlayer.inventory.armorInventory[3];
while you said minecraft.thePlayer.inventory.armorInventory[0];
u start with the helm and go down

Posted ImagePosted Image

Did I help you? press the green arrow!


#10

Liquid Metal Slime

Posted 14 April 2012 - 02:51 PM

View Postmeeees, on 14 April 2012 - 05:42 AM, said:

u have them flipped
boots is minecraft.thePlayer.inventory.armorInventory[3];
while you said minecraft.thePlayer.inventory.armorInventory[0];
u start with the helm and go down

Thanks.

View PostRANKSHANK, on 14 April 2012 - 04:22 AM, said:

Have you set in game gook for the ticking?

How do I do that?

#11

RANKSHANK
  • Location: American lost in Aussyland
  • Minecraft: RANKSHANK

Posted 14 April 2012 - 03:05 PM

View PostLiquid Metal Slime, on 14 April 2012 - 02:51 PM, said:

How do I do that?
add
ModLoader.setInGameHook(this, true, true);
to your constructor or load void
Posted Image

#12

Liquid Metal Slime

Posted 14 April 2012 - 07:35 PM

View PostRANKSHANK, on 14 April 2012 - 03:05 PM, said:

add
ModLoader.setInGameHook(this, true, true);
to your constructor or load void

OK, now I've done that, but the leather pants still won't protect me from fire. (I just want to say, thank you for all the help you've given me thus far.)

#13

TechGuy543
  • Location: QLD, Australia

Posted 15 April 2012 - 12:22 AM

Have you done what meeees said?

“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant;
together they are powerful beyond imagination."


#14

Liquid Metal Slime

Posted 15 April 2012 - 07:17 PM

View PostTechGuy543, on 15 April 2012 - 12:22 AM, said:

Have you done what meeees said?

Yes.

This is the code right now:

public boolean onTickInGame(EntityPlayer par1EntityPlayer)
	{
			ItemStack helm = par1EntityPlayer.inventory.armorInventory[0];
			ItemStack chest = par1EntityPlayer.inventory.armorInventory[1];
			ItemStack legs = par1EntityPlayer.inventory.armorInventory[2];
			ItemStack boots = par1EntityPlayer.inventory.armorInventory[3];
			if(helm != null && helm.itemID == Item.helmetLeather.shiftedIndex)
			{
					par1EntityPlayer.isImmuneToFire = true;
			}
			if(chest != null && chest.itemID == Item.plateLeather.shiftedIndex)
			{
					par1EntityPlayer.isImmuneToFire = true;
			}
			if(legs != null && legs.itemID == Item.legsLeather.shiftedIndex)
			{
					par1EntityPlayer.isImmuneToFire = true;
			}
			if(boots != null && boots.itemID == Item.bootsLeather.shiftedIndex)
			{
					par1EntityPlayer.isImmuneToFire = true;
			}
			return true;
	}


#15

Joneal9174
  • Minecraft: Joneal

Posted 15 April 2012 - 07:49 PM

onTickInGame(EntityPlayer) need to be onTickInGame(float f, Minecraft minecraft)
Did I help?  Hit the Posted Image at the lower right corner of my post!

#16

Liquid Metal Slime

Posted 15 April 2012 - 11:18 PM

View PostJoneal9174, on 15 April 2012 - 07:49 PM, said:

onTickInGame(EntityPlayer) need to be onTickInGame(float f, Minecraft minecraft)

OK, tested that. It didn't work.