#get a players active potion effects
26 messages · Page 1 of 1 (latest)
event.player.activeEffects.forEach(effect => {
//effect.duration
//effect.amplifier
//effect.getDescriptionId()
});
const amp = event.entity.getEffect('bad_omen').amplifier
event.entity.potionEffects.add('minecraft:bad_omen', 100000, amp + 1)
of course it's not defined
it needs an event
in what situation you want to increase the ampifier of bad omen
eating food?
drinking potion?
the id of food?
it's registered as a food, or potion?
send code
the code of kubejs:ominous_potion
Paste version of ominousPotionBackport.js from @steep seal
cool, then there's only one thing to do:
global.funcOminousPotionEffects = ctx => {
const amp = ctx.player.getEffect('bad_omen').amplifier
ctx.player.potionEffects.add('minecraft:bad_omen', 100000, amp + 1)
}
global.funcOminousPotionEffects = ctx => {
const player = ctx.player;
if(!player.hasEffect('minecraft:bad_omen')) {
player.potionEffects.add('minecraft:bad_omen', 100000, 0);
return;
}
const amp = player.getEffect('minecraft:bad_omen').amplifier
player.potionEffects.add('minecraft:bad_omen', 100000, amp + 1)
}
it's null probably because the player don't have bad omen yet
if(something) {
//then do something
}
if(!something) return //if not something, return
doesn't .useAnimation("drink") make the eating sound like potion?
a potion needs to register a new mob effect, or use extra listener
then it replaces all burp sound
nvm, let me register a mob effect
StartupEvents.registry('mob_effect', e => {
e.create('badomen_upgrade')
.harmful()
.color(0x192E22)
.effectTick((entity, level) =>{
if(!entity || entity.level.isClientSide()) return;
if(!entity.hasEffect('minecraft:bad_omen')) {
entity.potionEffects.add('minecraft:bad_omen', 10000, 0);
}
else{
const amp = entity.getEffect('minecraft:bad_omen').amplifier;
entity.potionEffects.add('minecraft:bad_omen', 100000, amp + 1);
}
entity.removeEffect('kubejs:badomen_upgrade')
})
})
let $PotionBuilder = Java.loadClass("dev.latvian.mods.kubejs.misc.PotionBuilder")
function potionRegist(e, id, durationInSeconds){
e.createCustom(id, () => {
return new $PotionBuilder(id)
.effect(`kubejs:${id}`, durationInSeconds * 20, 0)
.createObject()
})
}
StartupEvents.registry("potion", e => {
potionRegist(e, 'badomen_upgrade', 5);
})
restart the game, there should be a new potion with no translation key
and you need to add a en_us.json in kubejs/assets/lang
"effect.kubejs.badomen_upgrade":"Bad Omen Upgrade",
"item.minecraft.potion.effect.badomen_upgrade":"Ominous Bottle",
idk