Jump to content

Recommended Posts

Posted

Hey so I'm having a little trouble with GUI buttons. I new to GUI and I can't seem to get this to work. I have the button set so that if the player has a poison effect and the button is pressed then it will remove the poison effect. I pressed the button and my players hearts turn from that green color back to a red but the poison effect doesn't actually get removed. This also happens if I try to apply invisibility, it shows the effect in the players inventory but the player isn't actually invisible. Any help would be greatly appreciated.

 

Here is the code in my GUI class that involves removing the potion effect:

 
        public void initGui()
{
this.buttonList.clear();

int posX = ((this.width - xSOT) / 2);
int posY = ((this.height - ySOT) / 2);

this.buttonList.add(new GuiButton(0, posX + 40, posY + 40, 100, 20, "Remove Posion" ));
}


public void actionPerformed(GuiButton button)
{

switch(button.id)
{
case 0: this.mc.thePlayer.removePotionEffect(Potion.poison.id);
}
}
[/Code]

Posted

I dont know if this would be different for buttons but I have an item that when right clicked removes all potion effects. Here is the code.

 

for(int i = 0; i <20; i++)
{
player.removePotionEffect(i);
}

 

This takes away the actual effect and the display on the side of the inventory GUI.

You can get rid of the for statement and just put in the number of the potion effect you want to remove. (Don't know what poison is off the top of my head)

 

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.