Jump to content

Spawn a splash potion with an effect


Steverixxi

Recommended Posts

Hi, I am trying to spawn a splash potion with a specified potion effect (e.g. Slowness) with PotionEntity. I also already have an Potion Object but how do I get the PotionEntity to "have" my Potion or EffectInstance?

Thanks in advance

PotionEntity potion = new PotionEntity(world, player);
potion.setPos(playerPos.getX(), playerPos.getY() + 20, playerPos.getZ());
ItemStack splashPotion = new ItemStack(Items.SPLASH_POTION, 1);
EffectInstance potionEffect = new EffectInstance(Effects.BLINDNESS, 500, 100);
Potion potionToSet = new Potion(potionEffect);
PotionUtils.setPotion(splashPotion, potionToSet);
potion.setItem(splashPotion);

This is the code I am trying to use, but it only spawns a splash potion without any effects.

Edited by Steverixxi
Link to comment
Share on other sites

  • Steverixxi changed the title to Spawn a splash potion with an effect
1 hour ago, Steverixxi said:

Hi, I am trying to spawn a splash potion with a specified potion effect (e.g. Slowness) with PotionEntity. I also already have an Potion Object but how do I get the PotionEntity to "have" my Potion or EffectInstance?

you can't use an effect that has no item

if you want to use an effect that doesn't have a potion registered by vanilla, you have to register it yourself
you can find all registered potions in the Potions class

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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