Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 22875

Mike C. Fletcher: Potions with Custom Effects

$
0
0

In Pycraft, I figured out the Potions-with-custom-effects, the problem being that Bukkit's PotionEffectType doesn't actually implement the keyed interface, but instead has its own .values() call, so needs a whole special handler. The code for creating potion with custom effects looks like:


await potion_of(
'night_vision',
"Gopher's Gruel",
{
'type': 'fast_digging',
'duration': 20 * 60 * 8, # in ticks, so 20 seconds...
'amplifier': 50, # likely excessive
},
{
'type': 'luck',
'duration': 20 * 60 * 8, # in ticks, so 20 seconds...
'amplifier': 1,
},
player=player,
world=world,
)

Custom effects are converted from the dictionaries to the PotionEffect type and the python code for potion_of just adds each of them in turn using addCustomEffect() for the PotionMeta.

Viewing all articles
Browse latest Browse all 22875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>