#Brewin n Chewin Tipsy stacking and tooltips

71 messages · Page 1 of 1 (latest)

peak plover
#

Hiya! I've been trying to bridge together Let's Do Vinery and Brewin n Chewin. I've gotten to a point where I've successfully made fluid with fluid registry and added all the recipes for the various wines, but I'm at the point where I'm trying to get them all to apply Brewin n Chewin's "Tipsy" potion effect.
Currently, using basically the food modifier script from the wiki to add the effect, which kinda of works, but there's a whole lot of jank too. I have tested this on two different instances as well, with different results coming from each:

I've used a few script iterations using .effect in the food builder. these are posing multiple problems

One of the main problems is that tooltips are incorrect, and the parameters set in the script are ignored. Tipsy appears as blue text instead of red, and the time of the effect matches other effects on wines (1:30 jump boost = 1:30 tipsy, even though it is set to 3:00). Applying the effect to items that give no effects still displays incorrectly in the tooltip, as in does not display at all, but does actually apply correctly.

Another problem is that tipsy does not stack the way it does with BnC's in house drinks. @plush spear made and posted a script that kind of does this in 2023, with a couple issues to it as well. Firstly the script increases the amplitude of all potion effects on the player when a custom item is used, which...
a) requires the custom item created in the script to be used to increase the effect, rather than an item that already exists like a Vinery Wine, and
b) causes unexpected problems with effects that don't have higher amplitudes or otherwise have issue with that. ex: i was finding that spawning into a world and testing this while still having Cold Sweat's Grace Protection effect would just hard crash the game lol

I'm pretty new to using KubeJS and do not have the know-how to deconstruct Liopyus old script into something easier for a dumby like me to read and perhaps is more widely applicable, but do feel there must be a way to streamline it, maybe with the foodEaten event or something? And idk bout the tooltips and effect not applying properly with food.effect() but that might sort itself out along the way.

pastel glacierBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

peak plover
#

heres the script and screencaps using it

high geyser
#

oh nevermind

#

you already mentioned that

peak plover
#

i havent tested other items with pre-existing effects, but the vanilla apple acts weird

high geyser
#

what I usually do to add new effects to foods are use ItemEvents.foodEaten() for adding effects and ItemEvents.tooltip() for adding tooltips

#

more configurable that way

#

regardless, no clue what's going on here BigEyes

peak plover
#

what would a foodEaten script look like? i have a hard time building stuff from scratch since i dont know all the methods :\

high geyser
#

luckily for you I happen to have a script!

peak plover
#

i use vs code, have had a hell of time trying to get probejs up and running. ive heard 1.20.1 support is janky as hell

high geyser
#

it's... interesting

#

sometimes getting it set up on a heavy modded instance just doesn't work

#

here are a few examples I have:

#
ItemEvents.foodEaten([
    'collectorsreap:lime_cake_slice',
    'collectorsreap:pomegranate_cake_slice',
    'farmersrespite:coffee_cake_slice'
], event => {
    const { player } = event
    
    player.potionEffects.add('minecraft:speed', 400)
})

ItemEvents.foodEaten('create:chocolate_glazed_berries', event => {
    const { player } = event
    
    player.potionEffects.add('neapolitan:sugar_rush', 200, 1)
})

BlockEvents.rightClicked('enigmaticlegacy:cosmic_cake', event => {
    const { block, player } = event
    const { properties } = block

    if (properties.get('bites') == 6) return
    if (player.foodData.getFoodLevel() >= 20 && player.isCreative() == false) return
    const effects = [
        ['collectorsreap:corrosion', '300'],
        ['collectorsreap:volatility', '300'],
        ['farmersrespite:caffeinated', '600'],
        ['neapolitan:sugar_rush', '200'],
        ['neapolitan:agility', '200'],
        ['neapolitan:berserking', '300'],
        ['neapolitan:harmony', '200'],
        ['neapolitan:vanilla_scent', '100'] // Set last to allow other effects to be applied first
    ]

    effects.forEach(effect => {
        player.potionEffects.add(effect[0], effect[1])
    })

    player.heal(1)
})
#

you can also detect effects, detect their duration & amplification, and remove effects

#

so if you want to stack the tipsy effect, you can detect whether the player already has it

#

if that's how it works

#

as for a client tooltip script uhhh

#

let me get an example

#
ItemEvents.tooltip(event => {
    let individualEffectPairsBeneficial = [
        ['atmospheric:roasted_yucca_fruit', 'Persistence (00:28)'],
        ['atmospheric:yucca_gateau', 'Persistence (00:15)'],
        ['atmospheric:passion_fruit', 'Spitting (00:07)'],
        ['atmospheric:shimmering_passion_fruit', 'Spitting II (00:07)'],
        ['atmospheric:golden_dragon_fruit', 'Fire Resistance (03:00)'],

        ['autumnity:foul_berries', 'Foul Taste (00:16)'],
        ['autumnity:foul_soup', 'Foul Taste (01:00)'],

        ['caverns_and_chasms:bejeweled_apple', 'Gives 2 Random Effects']
    ]

    individualEffectPairsBeneficial.forEach(pair => {
        event.addAdvanced(pair[0], (item, advanced, text) => {
            text.add(1, [Text.of(pair[1]).blue()])
        })
    })

    event.addAdvanced('minecraft:golden_apple', (item, advanced, text) => {
        text.add(1, [Text.of('Regeneration II (00:05)').blue()])
        text.add(2, [Text.of('Absorption (02:00)').blue()])
        text.add(3, [Text.of('Minor Instant Health').blue()])
    })
})
#

if the item already has a tooltip, you'll have to change the specified order

#

err, index

#

which is the first integer argument

high geyser
#

or a lightly modded instance

#

then add the other necessary mods to the instance

#

sure you might not have all the registries from other mods, but at least ya got the KJS methods!

peak plover
#

hmm. this particular instance im taking screencaps from is light. 17 mods or smthn, but the packs i make and these scripts go into are kitchen-sinks with 370 mods listed on main menu, so that def doesnt help lol. but ive had issues getting either set up. wouldnt be surprised if running everything out of modrinths launcher could add complications

#

but these scripts look informative!! ill prod and tinker around and see what i can work out.

inland mortar
#

you can also see a little further down in that class that they actually just change the tooltip color for tipsy to red themselves

peak plover
#

interesting that the red effect text has to be done manually

peak plover
# high geyser ```js ItemEvents.foodEaten([ 'collectorsreap:lime_cake_slice', 'collecto...

well... no dice so far for the wines. they dont apply the effect using foodEaten... BUT, it works on a vanilla apple just fine, as well as applies the effect properly with farmers delight's beef broth, which provides the Comfort effect, and both appear with proper amplitude and duration.
got me wondering if the wines are treated as potions, rather than foods, and that effecting things somehow. i wonder if some sort of item modification like .finishedUsing would play nicer than a foodEaten if thats the case.

#

this is all with

#

gah. good findings, but calling it for the night. will continue in the morn

high geyser
#

the lets do mods are a bit clunky

#

not surprised that the wines aren't compatible with the event

inland mortar
#

Looks like Vinery modifies all the wines food effects based on it's age when it applies them, and overrides finishUsingItem which means the foodEaten event never gets fired

#

There is a forge event you can listen to though

ForgeEvents.onEvent('net.minecraftforge.event.entity.living.LivingEntityUseItemEvent$Finish', event => {
    const { entity, item } = event
    
})
peak plover
#

k stumbled my way into gettin ForgeEvents to work

#

this applies correctly as well. banger

#

time for tooltip. then ill look at stacking the effect

clever glacierBOT
#

Paste version of example.js from @peak plover

peak plover
# peak plover k stumbled my way into gettin ForgeEvents to work

i imagine getting the stacking to work will be something along the lines of adding like an "if entity has tipsy, get current tipsy and held items tipsy, add those two values together, and apply tipsy = to those two values sum. else apply the drinks tipsy by itself."

peak plover
#

current state of things- figured out how to get the effect info of the player, but how do i use the individual elements to make them into something useful? alternatively, is there a way i can literally just add the all old values to the new values at once, since the effect literally on top of itself?

clever glacierBOT
#

Paste version of example.js from @peak plover

peak plover
#

like... i guess what im describing is essentially

entity.potionEffects.add('brewinandchewin:tipsy', 3600, 1) + currenttipsy

i highly doubt something like that would work

high geyser
#

You could detect whether the player currently has the effect, and if so, get the duration of it, and add it to the drink’s tipsy’s duration

#

essentially overwriting the existing tipsy effect

peak plover
#

yeah thats pretty much what im attempting atm

high geyser
#

can also do the same for amplification probably

peak plover
#

im trying to get the actual output it gives but everythings half broken from what i was working on before lunch 🫠

inland mortar
#

This would basically mimic how brewin and chewin handles it

    let duration = 360
    let potency = 3

    if (entity.hasEffect('brewinandchewin:tipsy')) {
        let effect = entity.getEffect('brewinandchewin:tipsy')
        entity.potionEffects.add('brewinandchewin:tipsy', effect.duration == -1 ? -1 : effect.duration + duration, Math.min(effect.amplifier + potency + 1, 9), effect.ambient, effect.visible)
    } else {
        entity.potionEffects.add('brewinandchewin:tipsy', duration, potency)
    }
peak plover
#

will give it a shot shortly

peak plover
#

ya this gets it done. the 'if (item.id ==)' doesn't play nice with regex, but works fine with individual items

ForgeEvents.onEvent('net.minecraftforge.event.entity.living.LivingEntityUseItemEvent$Finish', event => {
    const {entity, item} = event

    if (item.id == /vinery:.*wine/) {
        let duration = 3600
        let potency = 2

        if (entity.hasEffect('brewinandchewin:tipsy')) {
            let effect = entity.getEffect('brewinandchewin:tipsy')
            entity.potionEffects.add('brewinandchewin:tipsy', effect.duration == -1 ? -1 : effect.duration + duration, Math.min(effect.amplifier + potency + 1, 9), effect.ambient, effect.visible)
        } else {
            entity.potionEffects.add('brewinandchewin:tipsy', duration, potency)
        }
    }
})
#

which is fine since i should build a function for it anyways.

#

would functions work here, since its in startup? or is that only for recipes on server scripts...

clever glacierBOT
#

Paste version of example.js from @peak plover

peak plover
#

ladies and gentlemen we gettin wine drunk with this one

peak plover
clever glacierBOT
#

Paste version of lets_do_wine_drunkeness.js from @peak plover