Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey,

 

I started picking up minecraft modding recently and I wanted to get a weapon to apply a potion effect when it hits an entity, I looked around in ItemSword and found "hitEntity" So I tried the following (here is the whole class)

 

public class ItemStoneSpear extends ItemSword{

public ItemStoneSpear(ToolMaterial p_i45356_1_) {
	super(p_i45356_1_);
	// TODO Auto-generated constructor stub
}

@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase){
	par1ItemStack.damageItem(1, par3EntityLivingBase);
	par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.poison.getId(),100 , 1));
	return true;
}



}

 

But it doesn't work no matter what I try. So if someone could help me out i'd love it a ton :D

Please help him! I need this too.  ;)

Hey,

 

I started picking up minecraft modding recently and I wanted to get a weapon to apply a potion effect when it hits an entity, I looked around in ItemSword and found "hitEntity" So I tried the following (here is the whole class)

 

public class ItemStoneSpear extends ItemSword{

public ItemStoneSpear(ToolMaterial p_i45356_1_) {
	super(p_i45356_1_);
	// TODO Auto-generated constructor stub
}

@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase){
	par1ItemStack.damageItem(1, par3EntityLivingBase);
	par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.poison.getId(),100 , 1));
	return true;
}



}

 

But it doesn't work no matter what I try. So if someone could help me out i'd love it a ton :D

 

Didn't know that there is an hitEntity function(would have used an onLivingUpdateEvent).

Please put some test output into the hit function and test if it is called when you hit something.

Here could be your advertisement!

  • Author

Didn't know that there is an hitEntity function(would have used an onLivingUpdateEvent).

Please put some test output into the hit function and test if it is called when you hit something.

 

Yeah, the hitEntity function doesn't seem to be getting called;

how would I go about using onLivingUpdateEvent?

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.