Splash potions

ArchivesFeature 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;
		}
	}
		
}
==+1== You soul saver

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.

http://m.youtube.com/watch?v=8NFwrgLLIpc

.HEAL instead of .HARM @Curs3d … also you could be more specific with eff.getAmplifier() or something like that.
True, you coukd just disable potions with amplifier of 253… let me test.
so @Curs3d it appears that nothing happened from this idea, so i’m gonna do it myself.

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.