Splash potions
Archives → Feature requests → Splash potions
SOLVED
I’ve posted this code already on the news post “Splash potions”, and its basically a way to fix splash potions without enabling kill potions again. So again: devs translate to python please and implement it if its good.
@EventHandler
public void onPotionSplash(PotionSplashEvent e) {
ItemStack potion = e.getPotion().getItem();
Collection<PotionEffect> potionEffects = Potion.fromItemStack(potion).getEffects();
for (PotionEffect eff : potionEffects) {
if (eff.getType() == PotionEffectType.HARM) {
e.setCancelled(true);
break;
}
}
}
But there is a problem: Kill potions can also be HEALING potions. I think they are with a data value of 253 or something, and kill players in creative mode.
der, dun it, just have to test it now…
def on_splash(event):
potion_effects = event.getPotion().getEffects()
for eff in potion_effects:
if eff.getType() == (PotionEffectType.HEAL || PotionEffectType.HARM):
if eff.getAmplifier() > 250:
event.setCancelled(True)
break
def on_splash(event):
potion_effects = event.getPotion().getEffects()
for eff in potion_effects:
if not (1 <= eff.getAmplifier() <= 2):
event.setCancelled(True)
break
^ I would do it that way.
Besides, I think disabling splash potions entirely, I don’t actually know if that’s currently the case, is the better option. Drinking normal potions could be allowed, though people could still suicide that way and cause problems.
I like the idea of having a command that just gives you infinite night vision because that seems to really be the only important one. What do you think?
@Command("nightvision", sender_type = Command.SENDER_PLAYER)
def nightvision_command(sender, scape, args):
sender.addPotionEffect(PotionEffect(PotionEffectType.NIGHT_VISION, MAX_INT_VALUE, 0))
Assuming -1 doesn’t work for infinite duration, which I believe to be the case, you need to just enter a high value really. The amplifier might have to be 1, I’m unsure. 0 -> 1 you know?
EDIT: The above code uses the command api which I wrote for the toolbox repository, AKA redstoner-utils 2.0. It’s missing description and stuff, but you get the idea.