#Cancelling mods persistent data

258 messages · Page 1 of 1 (latest)

craggy swallow
#

So theres this mod called MutationCraft and it sets stages to the player and says it in chat as well with no config to disable it. I was looking at the code and it says it's using persistent data for this but when i go to check the players persistent data (or the servers persistent data) its not there

    public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
        StagesLulProcedure.execute(null, world, x, y, z, entity);
    }

    private static void execute(@Nullable Event event, LevelAccessor world, double x, double y, double z, Entity entity) {
        if (entity == null) {
            return;
        }
        if (entity instanceof Player) {
            MutationcraftMod.queueServerWork((int)40, () -> {
                Level _level;
                Player _player;
                entity.getPersistentData().m_128347_("Stage0", entity.getPersistentData().m_128459_("Stage0") + 1.0);
                entity.getPersistentData().m_128347_("Stage1", entity.getPersistentData().m_128459_("Stage1") + 1.0);
                entity.getPersistentData().m_128347_("Stage2", entity.getPersistentData().m_128459_("Stage2") + 1.0);
                entity.getPersistentData().m_128347_("Stage3", entity.getPersistentData().m_128459_("Stage3") + 1.0);
                if (entity.getPersistentData().m_128459_("Stage0") == 1.0) {
                    if (entity instanceof Player) {
                        _player = (Player)entity;
                        if (!_player.f_19853_.m_5776_()) {
                            _player.m_5661_((Component)Component.m_237113_((String)"Stage 0"), false);
                        }``` this is the class file and ive attatched my script attempt lol
woeful pythonBOT
#

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

karmic tuskBOT
#

Paste version of temp.js from @craggy swallow

craggy swallow
#

now im trying this js NetworkEvents.dataReceived('channel', event =>{ console.log(event.data.allKeys) }) idk how to work network events though

craggy swallow
#

@grave zephyr really the main goal here is to stop that "stage0" "stage1" message from popping up every time i die and respawn

grave zephyr
#

we on ATM just listened to the chat event and cancelled the messages from an annoying mod

#

you may try that

craggy swallow
#

oh?

grave zephyr
#

let me se

craggy swallow
#

kk

#

thx

grave zephyr
craggy swallow
#

oh?

#

oo lemme try it sec

grave zephyr
#

this was 1.18 btw, just adapt

craggy swallow
#

ye

#

also dang you work on atm?

#

im not suprised considering how adept you are at kubejs

grave zephyr
#

I'm just a tester there, not a team member, more like a contributor

craggy swallow
#

ah i see

#

still cool

#

crashed

#

sec lemme link the report

#

crashed on world load though not startup

karmic tuskBOT
#

Paste version of crash-2023-10-02_12.49.28-client.txt, startup.log from @craggy swallow

grave zephyr
#

maybe it is contains now, don't know lol on 1.20

#

you will have to test

craggy swallow
#

im on 1.19

grave zephyr
#

this contains/includes is a PAIN

#

yeah

craggy swallow
#

lmao kk

#

lemme try it

grave zephyr
#

you can try to print all functions available or just try contains

#

do you remember? the Object.keys

craggy swallow
#

oh i should also remove the print world features

#

ooh true

#

wait how would i do that again?

grave zephyr
#

console.log(Object.keys(e.getMessage().getContents()))

craggy swallow
#

aight thanks lmao

grave zephyr
#

i don't like all this get I did before, just use beans if you can

#

this is not Java

craggy swallow
#

XD

grave zephyr
#

you know that feel when you see your old codes

craggy swallow
#

lmao fr tho

grave zephyr
#

are you taking that long to kys?

craggy swallow
#

lmaooo

grave zephyr
craggy swallow
#

my pack takes forever to load

grave zephyr
#

wth are you loading again, you are using the global trick

craggy swallow
#

if it crashes again im gonna go on my test pack, not sure why i chose to do it on the main pack with 250 mods

grave zephyr
#

oh

#

it crashed

#

LOL

craggy swallow
#

it crashed even with the global

grave zephyr
#

global wont save

craggy swallow
#

thats what im using haha

#

ye

#

crashed with .contains

#

sec lemme post the stuff

grave zephyr
#

did you do the Object.keys before the .contains so we can have a clue

craggy swallow
#
ForgeEvents.onEvent('net.minecraftforge.client.event.ClientChatReceivedEvent', e => {
    global.cancelmessage(e)
  })

  global.cancelmessage = e => {
    if (e.getMessage().getContents().contains("Stage 0")) {
        console.log(Object.keys(e.getMessage().getContents()))
        e.setCanceled(true)
        
      }
  }```im gonna try doing it this time without the global script having anything to make sure its the script
karmic tuskBOT
#

Paste version of startup.log, crash-2023-10-02_12.59.47-client.txt from @craggy swallow

vital vigil
craggy swallow
#

lemme post logs

#

hi don

vital vigil
#
// Hey, that tickles! Hehehe!
#

anyways

craggy swallow
karmic tuskBOT
#

Paste version of latest.log from @craggy swallow

grave zephyr
#

do the objectkeys before the if check

#

and disables it for now so you don't crash, or make a trycatch

vital vigil
#

well

craggy swallow
#

kk

grave zephyr
#

when are you going to use ProbeJS @craggy swallow :p

vital vigil
#

e.getMessage().getContents() gives you ComponentContests, which only has two methods - resolve and visit

craggy swallow
#

probejs doesnt work in global events does it?

#

i have probe

vital vigil
karmic tuskBOT
grave zephyr
#

it does work

craggy swallow
#

ah

grave zephyr
#

just dump again

#

after you first listen to it

craggy swallow
#

i guess i just dont have vsc open with the folder then

#

kk

vital vigil
#

anyways

#

@craggy swallow try e.message.string hmmm

#

beans moment heh

craggy swallow
#

WAIT

grave zephyr
#

this one looks like it would work

craggy swallow
#

i tested it on my test pack and its working now?

#

lemme make sure though

grave zephyr
vital vigil
craggy swallow
#

hm

#

its not showing anything in the console tho

grave zephyr
#

@vital vigil do you know if all/most of the .string are also beans of toString()?

craggy swallow
#

kk lemme try

vital vigil
#

for some reason, Component doesn't have a .toString() method

#

however, it has .getString() smugphalia

grave zephyr
#

lazy devs

craggy swallow
#

lemme try it in the main pack

grave zephyr
#

or maybe they use toString() for other stuff

vital vigil
#

maybe

grave zephyr
craggy swallow
#

hmm

#

not really

#

and i have it open in the folder too

#

wait

vital vigil
#

...

grave zephyr
#

you have to /probejs dump

craggy swallow
#

ive probejs dumped like 20 times before

#

Xd

#

still doesnt work in the global event block

#

well it works but it only goes as far as e

#

like e, eval ect

#

im loading into the world where ill probjes dump again

#

if it doesnt crash againdespair

craggy swallow
#

hmm same crash

vital vigil
#

e

craggy swallow
#

im gonna see if its something else

vital vigil
#

send skript

craggy swallow
#

gonna remove the script and restart i guess

#

kk

vital vigil
#

where skript ahujel

#

??code

karmic tuskBOT
# vital vigil ??code

🗒️**Send the code!**🗒️
You may have an issue with a KubeJS script and you explain it to the best of your ability yet without the actual code in question we have very little to go off of in trying to assist you.

vital vigil
#

get code'd pepepointandlaugh

craggy swallow
#
ForgeEvents.onEvent('net.minecraftforge.client.event.ClientChatReceivedEvent', e => {
  global.cancelmessage(e)
  
})

global.cancelmessage = e => {
  if (e.message.string("Stage 0")) {
      console.log(Object.keys(e.getMessage().getContents()))
      console.log('test')
      e.setCanceled(true)
      
    }
}```
#

lmao

grave zephyr
#

when using global you need to type your e with JSDoc

craggy swallow
#

ah

vital vigil
#

e.message.string("Stage 0")?

grave zephyr
#

LMAO

#

what

#

am I

#

reading

vital vigil
#

what are you even trying to achieve despair

#

??helpyou

karmic tuskBOT
# vital vigil ??helpyou

╰( ͡° ͜ʖ ͡° )つ──☆:・゚˜”°•.˜”°• Many Help •°”˜.•°”˜*
Please provide a description of your issue with as much detail as possible. If you have an issue with a script provide the script. Explain what you can see happening and what you expect to happen. Be specific!

Tell us what is happening, we already know it "doesn't work".
Avoid using words like "it", tell us exactly what "it" is.
Don't assume anyone knows what you are talking about, be specific.

Provide screenshots or video of the issue, not the code or chat, if possible.

Provide the log.

craggy swallow
#

kk

grave zephyr
#

contains/includes

#

what ever

vital vigil
#

👌

grave zephyr
#

Rhino likes

vital vigil
craggy swallow
karmic tuskBOT
#

Paste version of startup.log, crash-2023-10-02_13.14.01-client.txt from @craggy swallow

vital vigil
#

huh

#

anyways

#

string doesn't take any arguments ahujel

#

nor - in this case - is it a function

craggy swallow
#

.>

grave zephyr
#

do the objectkeys broooooooooo

vital vigil
#

you'd do something like theMessage.includes(e.message.string)

#

lexxie.site exists for a reason ahujel

craggy swallow
#

i can post logs again tho sec

grave zephyr
#

you didnt mention lol

vital vigil
#

...

grave zephyr
#

where?

craggy swallow
vital vigil
#

hate it when people just ignore my messages ahujel

vital vigil
craggy swallow
#

ah ok lmao

vital vigil
#

??tryitandse

#

💀

craggy swallow
#

sec lemme try

vital vigil
#

??tryitandsee

karmic tuskBOT
vital vigil
craggy swallow
#

??okk

#

like this? ```js
ForgeEvents.onEvent('net.minecraftforge.client.event.ClientChatReceivedEvent', e => {
global.cancelmessage(e)

})

global.cancelmessage = e => {
console.log(Object.keys(e.getMessage().getContents()))
if (e.theMessage.includes('Stage 0')) {

  console.log('test')
  e.setCanceled(true)
  
}

}```

#

just making sure i got this right

vital vigil
#

the other way around heh

craggy swallow
#

oh lmao

grave zephyr
#

lol theMessage? is it defined?

craggy swallow
#
global.cancelmessage = e => {
  console.log(Object.keys(e.theMessage.includes(e.message.string)))
  if (e.message.string("Stage 0")) {
      
      console.log('test')
      e.setCanceled(true)
      
    }
}```
grave zephyr
craggy swallow
#

probe doesnt work for me here so idk😂

#

is that wrong lmao

vital vigil
#
ForgeEvents.onEvent('net.minecraftforge.client.event.ClientChatReceivedEvent', e => global.cancelMessage(e))

global.cancelMessage = e => {
    console.log(Object.keys(e.message.contents))
    if (e.message.string.includes('Stage 0')) {
        console.log('your message contained "Stage 0" for some weird reason')
        e.setCanceled(true)
    }
}
grave zephyr
#

hover the e of the first e, it will say the event

vital vigil
craggy swallow
#

lmaoo

#

kk

vital vigil
#

jsdoc exists for a reason ahujel

craggy swallow
#

wait how do i do jsdoc?

#

what is jsdoc in the first place

grave zephyr
#

it is JavaScript Doctor, it aids you with types

vital vigil
#
ForgeEvents.onEvent('net.minecraftforge.client.event.ClientChatReceivedEvent', e => global.cancelMessage(e))

/**
 * jsdoc for typings to work correctly
 * credit to donald :)
 * @param {Internal.ClientChatReceivedEvent} e
 * @returns {any}
 */
global.cancelMessage = e => {
    console.log(Object.keys(e.message.contents))
    if (e.message.string.includes('Stage 0')) {
        console.log('your message contained "Stage 0" for some weird reason')
        e.setCanceled(true)
    }
}
craggy swallow
#

ah

#

oo

vital vigil
#

tl;dr ✨ magic ✨

grave zephyr
vital vigil
#

wdym

craggy swallow
#

pleasedontcrashpleasedontcrashpleasedontcrashpleasedontcrash

vital vigil
grave zephyr
#

(/** @type {Internal.ClientChatReceivedEvent} */ e)

vital vigil
#

idk

#

if it works, don't to fix it

craggy swallow
#

oo didnt crash

vital vigil
craggy swallow
#

oooo it worked i dont see stage 0 anymore when i respawn

#

its saying wierd stuff in the logs tho

vital vigil
vital vigil
craggy swallow
#
13:28:02.495
Scaling Health
Server thread
Player lost 0.00 heart crystal(s)
13:28:02.496
Scaling Health
Server thread
Player lost 0.00 difficulty
13:28:02.510
dev.gigaherz.toolbelt.slot.BeltExtensionSlot
Server thread
New entity has data, contents assigned.
13:28:02.528
DynamicSurroundings
Render thread
EntityJoinLevelEvent fired (playerJoined: true, reloadFired: true, customTagsEventFired: false, vanillaTagsEventFired: true)
13:28:02.551
DynamicSurroundings
Server thread
EntityJoinLevelEvent fired (playerJoined: true, reloadFired: true, customTagsEventFired: false, vanillaTagsEventFired: true)
13:28:04.707
SoundControl
Render thread
Unable to locate sound 'mobeffects:empty'
13:28:05.403
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:4: getClass
13:28:05.403
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:4: wait
13:28:05.403
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:4: resolve
13:28:05.403
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:4: hashCode
13:28:05.403
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:4: equals
13:28:05.403
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:4: notifyAll
13:28:05.403
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:4: toString
13:28:05.403
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:4: visit
13:28:05.404
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:4: text
13:28:05.404
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:4: class
13:28:05.404
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:4: notify
13:28:05.404
KubeJS Startup
Render thread
startup_scripts:disablemessages.js:6: your message contained "Stage 0" for some weird reason```
#

is that normal?

vital vigil
#

that's the Object.keys from earlier

#

yeet that out heh

craggy swallow
#

oh thats right cause i put it outside the if statement

#

yeee

#

ty guys now i can finally not see these messages anymore rofl

#

❤️

vital vigil
woeful pythonBOT
#

Ticket closed!

grave zephyr
#

@craggy swallow post your final script, @subtle rivet may need it

subtle rivet
karmic tuskBOT
#

[Quote ➤](#1158087494361952276 message) ```js
ForgeEvents.onEvent('net.minecraftforge.client.event.ClientChatReceivedEvent', e => global.cancelMessage(e))

/**

  • jsdoc for typings to work correctly
  • credit to donald :)
  • @param {Internal.ClientChatReceivedEvent} e
  • @returns {any}
    */
    global.cancelMessage = e => {
    console.log(Object.keys(e.message.contents))
    if (e.message.string.includes('Stage 0')) {
    console.log('your message contained "Stage 0" for some weird reason')
    e.setCanceled(true)
    }
    }
vital vigil
#

don't know why you need it hmmm

subtle rivet
#

ah ok thanks

grave zephyr
vital vigil
grave zephyr
vital vigil
#

👌

craggy swallow
#

oh did i not post it?

#

sec i got you

vital vigil
#

I already sent it despair

craggy swallow
#

oh haha fair enough

vital vigil
#

just remove the first console.log heh

craggy swallow
#

ye

subtle rivet
#

Ye thanks