#Give the player an attribute if they've eaten the Forbidden Fruit.

3 messages · Page 1 of 1 (latest)

late flicker
#

The forbidden fruit is an item from Enigmatic Legacy that gives the player infinite hunger at the cost of reducing health regeneration by 80%. However, if you're playing with a mod that reworks or even outright gets rid of the hunger system such as Spice of Life: Valheim addition. This effect is unable to do anything.

The following script is able to check if the player has eaten it or not and apply a new attribute to the player. Health boost is used, but it can very easily be changed to whatever you prefer. You could even change it entirely to do something more complex.

It will also remove the attribute if they've consumed the potion of redemption, so you can't exploit it in that way.

//SERVER SCRIPTS
PlayerEvents.tick(event => {
    //probably a better way to trigger this, but this is reliable, so who cares?


    let data = event.player.nbt.ForgeData.PlayerPersisted.ConsumedForbiddenFruit;
    //console.log(data)
    //Read wether or not the player has eaten the Forbidden Fruit

    if (data == 1) {
       // console.log('fruit is eaten')
        event.player.modifyAttribute("generic.max_health", 'eb5a4c7e-d27d-450d-b452-6850c80f30ad', .5, 'multiply_total')
    }
//If the player's eaten the Forbidden Fruit, increase their max HP by 50%. You can replace this with any other attribute.

    else if (data == 0){
       // console.log('Fruit is not eaten')
        event.player.modifyAttribute("generic.max_health", 'eb5a4c7e-d27d-450d-b452-6850c80f30ad', 0, "multiply_total")}
         //Checks if the player has attoned by drinking the Redemption Potion. Once again, you can change the attribute being added. 
         //The player has no data about the fruit if they've not eaten it.
})```
#

Thanks. I still have no idea how to give text in code boxes coloring.

upbeat geyser
#

add js at the end of the first 3 `