#Is there a way to give a player an infinite effect

28 messages · Page 1 of 1 (latest)

atomic nexus
#

i whant to use a command but i cant figure what to place in the time so its infinite
currently i use

if (player.hasEffect("night_vision")) {
                console.log("got here3")
                // Remove night vision if already active
                player.removeEffect("night_vision");
                player.displayClientMessage(Component.gold('Night Vision: ').append(Component.red('disabled')), true)
            } else {
                console.log("got here4")
                // Apply night vision if not active/
                player.addEffect("night_vision" , "infinite", 0, true); // Infinite duration
                player.displayClientMessage(Component.gold('Night Vision: ').append(Component.green('enabled')), true)
            }

to mention that its a command and the player i defined my problem is in "infinite" i tried Java.loadClass.lang.MAX_VALUE , java.lang.Integer.MAX_VALUE and Integer.MAX_VALUE but all of them gave my errors i do not want to use 9999999 because ive heard that infinite now exists and i wanted to use it

sullen palmBOT
#

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

wanton pelican
#

its literally "infinite"

#

oh you said you want to use a command but youre using kubejs methods, hmmm

atomic nexus
#

the weird thing now this player.addEffect("night_vision" , 999999, 0, true) gives an error as whell
and its from the addEffect

wanton pelican
#

try setting it to -1

atomic nexus
#

ok

#

if it can help ```txt
[15:40:45] [Server thread/ERROR] [minecraft/Commands]: Command exception: /night_vision
dev.latvian.mods.rhino.EvaluatorException: Can't find method net.minecraft.world.entity.LivingEntity.m_7292_(string,number,number,boolean). (server_scripts:Commands.js#53)
at dev.latvian.mods.rhino.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:67) ~[rhino-forge-2001.2.2-build.18.jar%23198!/:2001.2.2-build.18] {re:classloading}
at dev.latvian.mods.rhino.Context.reportRuntimeError(Context.java:133) ~[rhino-forge-2001.2.2-build.18.jar%23198!/:2001.2.2-build.18] {re:classloading}
at dev.latvian.mods.rhino.Context.reportRuntimeError(Context.java:173) ~[rhino-forge-2001.2.2-build.18.jar%23198!/:2001.2.2-build.18] {re:classloading}
at dev.latvian.mods.rhino.Context.reportRuntimeError1(Context.java:145) ~[rhino-forge-2001.2.2-build.18.jar%23198!/:2001.2.2-build.18] {re:classloading}
at dev.latvian.mods.rhino.NativeJavaMethod.call(NativeJavaMethod.java:379) ~[rhino-forge-2001.2.2-build.18.jar%23198!/:2001.2.2-build.18] {re:classloading}
at dev.latvian.mods.rhino.Interpreter.interpretLoop(Interpreter.java:986) ~[rhino-forge-2001.2.2-build.18.jar%23198!/:2001.2.2-build.18] {re:classloading}

#

and the script ```js
ServerEvents.commandRegistry(event => {
const { commands: Commands, arguments: Arguments } = event

    event.register(Commands.literal("night_vision")
        .requires(s => s.hasPermission(1))
        .executes(context => vision(context.source.player))
        .then(Commands.argument("target", Arguments.PLAYER.create(event))
            .executes(context => vision(Arguments.PLAYER.getResult(context, "target")))
        )
    )

var vision = (player) => {

        if (!player) {
            player.sendMessage(Text.red("This command can only be run by a player!"));
            return;
        }


        if (player.hasEffect("night_vision")) {
            // Remove night vision if already active
            player.removeEffect("night_vision");
            player.displayClientMessage(Component.gold('Night Vision: ').append(Component.red('disabled')), true)
        } else {
            // Apply night vision if not active/
            player.addEffect("night_vision" , -1, 0, true); // Infinite duration
            player.displayClientMessage(Component.gold('Night Vision: ').append(Component.green('enabled')), true)
        }
        return 1
    }

})

wanton pelican
#

i just realized

#

sec

#

you want this method js player.potionEffects.add("night_vision", 10, 0, true,true)

atomic nexus
#

why does it have true ,true at the end like why are there 2

wanton pelican
#

i put those there for standin, change them to whatever you want

#

you're using the wrong method

#

player.addEffect() takes 1 arguement and that arguement is a mobeffect instance

atomic nexus
#

oh

wanton pelican
#
player.potionEffects.add```
#

try -1 again and see if that works

#

looks like it works on my instance pepepoggers

atomic nexus
#

to remove it what do i need player.potionEffects.remove("night_vision")

wanton pelican
#

what you've been doing works

#

player.removeEffect

atomic nexus
#

you need false ,false because you do not whant the effect to be beacon type and you do not whant particles

#

in game the /effect asks you if you whant to hide the particles not if you whant them

sullen palmBOT
#

Ticket re-opened!

atomic nexus
#

also thanks