#Right click water with empty hand

20 messages · Page 1 of 1 (latest)

unreal loom
#

I want to do a drinking system and I need a procedure to drink water from world. There is my script:

ItemEvents.rightClicked(event => {
    const {player, level} = event;
   if(event.target.block?.id == 'minecraft:water') {
       level.playSound(null, event.player.x, event.player.y, event.player.z, 'entity.generic.drink', 'master', 1, 1)
       Utils.server.scheduleInTicks(1, () => {
    event.server.runCommandSilent(`execute as ${player.username} run thirst set @s 20 20`)
    if(Math.random > 0.80) { player.potionEffects.add('minecraft:hunger', 30, 0, false, false) }
       })
     } 
})
stone mauveBOT
#

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

trim ivy
unreal loom
unreal loom
trim ivy
#

How about using blockevents instead of itemevents

unreal loom
#

The script of this does not read the water

trim ivy
#

If it reads the block under the water, then you can use event.facing to get the face being clicked, and check whether there's water in that direction relative to the block

unreal loom
trim ivy
#

BlockEvents.rightClicked

unreal loom
#

Something like this?

BlockEvents.rightClicked(event => {
    const {player, level} = event;
   if(event.target.block?.id == 'minecraft:water') {
   if(event.facing('up') == true) {
       level.playSound(null, event.player.x, event.player.y, event.player.z, 'entity.generic.drink', 'master', 1, 1)
       Utils.server.scheduleInTicks(1, () => {
    event.server.runCommandSilent(`execute as ${player.username} run thirst set @s 20 20`)
       })
     } 
   }
})
trim ivy
#

Do you use probejs?

unreal loom
#

No

trim ivy
#

I recommend it. It will let you know each variable has what properties and how to use them

ivory tuskBOT
#

ProbeJS is an addon mod for KubeJS that generates typings files for VSCode, allowing VSCode to offer autocompletions for a ton of things!

Mod by @sour sigil

trim ivy