Jump to content

Recommended Posts

Posted

I'm trying to make a check to see if the player has my sword in his/her hands. It doesn't print anything in the console when I start the client.

 

mod_deathman12e3 (It's in the postInit)

 

  Reveal hidden contents

 

 

CommonProxy

 

  Reveal hidden contents

 

 

ServerTickHandler12e3

 

  Reveal hidden contents

 

Kain

Posted

Ok, I changed my method to this one.

 

 

  Reveal hidden contents

 

 

It still doesn't print anything :I

Kain

Posted

I tweaked my code to check for the item ID. But I don't really know anything about item meta data values. Sorry I'm a bit of a newb at Java. :|

 

 

  Reveal hidden contents

 

Kain

Posted

Figured it out. :D

 

I never called the onPlayer method. I'll put my ServerTickHandler right here for anyone having the same problem.

 

ServerTickHandler12e3

 

  Reveal hidden contents

 

Kain

Posted

par5 boolean is what you need to check if item is held

 

if(par5 && (entity instanceof EntityPlayer)) {

EntityPlayer player = (EntityPlayer)entity;

if (!world.isRemote && !player.capabilities.isCreativeMode) {

if (player.getFoodStats().getFoodLevel() >= 0) {

player.getFoodStats().setFoodLevel(player.getFoodStats().getFoodLevel()-1);

                        player.getFoodStats().setFoodSaturationLevel(0);

}

}

}

 

my hunger item code

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.