Potion effect on right click

3 posts / 0 new
Last post
stegy17's picture
Offline
Last seen: 1 year 1 month ago
Joined: 12/22/2014 - 19:07
Gems: 0
Potion effect on right click

I want to make an item that damages you then gives you a potion effect but since it's a tool adding a potion effect isn't in the premade settings, so can someone please tell me the custom code to put in the right click area to make it give you the strenght 2 potion effect for 1 minute? Thank you.



Offline
Last seen: 1 year 8 months ago
Joined: 05/19/2015 - 00:13
Gems: 0
public ItemStack
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entity){
float var4 = 1.0F;
int i = (int)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)var4);
int j = (int)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)var4 + 1.62D - (double)entity.yOffset);
int k = (int)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)var4);
 
 
if(true){
if(entity instanceof EntityLivingBase) ((EntityLivingBase)entity).addPotionEffect(new PotionEffect(1, 60, 1));
}
 
Help it worked ;D (PS: i don't made the damage effect jsut potion)
stegy17's picture
Offline
Last seen: 1 year 1 month ago
Joined: 12/22/2014 - 19:07
Gems: 0
RE:public ItemStack

But where exactly do i put that code in the coding for an item.