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

Hello again!

 

I hope this isn't too difficult to conquer, but I'm trying to make a potion effect that is similar to strength. Specifically trying to take the current damage being done by the player and multiply it by 1.75 while under the effect.

The potion effect is being applied to the player, but the effect of it is not working as intended.

This is my not quite exciting attempt: 

@SubscribeEvent
	public void newPotionHandling(AttackEntityEvent e){
	if(e.getEntityPlayer().isPotionActive(MyMod.Strengthlikepotion)){
		if(e.getEntityPlayer().getActivePotionEffect(MyMod.Strengthlikepotion).getDuration()==0){
			e.getEntityPlayer().removePotionEffect(MyMod.Strengthlikepotion);
			return;
		}
		else{
			EntityPlayer inquesiton = e.getEntityPlayer();
			ItemStack primary = inquesiton.getHeldItemMainhand();
			ItemStack seconary = inquesiton.getHeldItemOffhand();
			if(primary.isItemStackDamageable())
			primary.damageItem(1, inquesiton);
			if(seconary.isItemStackDamageable())
			seconary.damageItem(1, inquesiton);
			//System.out.println(e.getEntityPlayer().getHeldItemOffhand().toString());
			e.getTarget().attackEntityFrom(DamageSource.GENERIC,(float) (e.getEntityPlayer().getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue()*1.75));
		}
	}
	}

The attackEntityFrom() call is entirely preventing the damage type from the weapon/empty hand/tool from taking effect at all and is only doing the damage done with the method. Sort of like assigning damage to the target on attack.

I feel as though this approach is not the right way of doing it, any experience or even better the reference to how the vanilla strength potion works would be greatly appreciated because I can't seem to get to it with my IDE.

 

Thanks!

  • Author
2 hours ago, diesieben07 said:

Why are you damaging the player's current items?

I'm not doing all the specific handling of which items are getting damaged (like checking to see if they are the ones applicable), but at the moment the only thing applying the potion effect is when the player has set items equipped in the mainhand + offhand. Like dual wielding weapons. Will report back when I change the event parameters.

 

EDIT: Works perfectly now! Thanks diesieben07!

Edited by Heen

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.