#Tick intervals

184 messages · Page 1 of 1 (latest)

quartz sleet
#

Is it possible to change the tick intervals of event.effectTick under registry events?
If so would love to know how

vale plankBOT
#

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

dull ermine
#

no that would break the game lol

#

youre probably overcomplicating whatever youre trying to do

quartz sleet
dull ermine
#

you can add something like this in the body

if (Utils.server.tickCount % 5) return

and that will run everything after once every 5 ticks, as an example

quartz sleet
#

everything as in EVERY thing?

dull ermine
#

well yeah, its a guard clause

quartz sleet
#

it doesn't recognize "server" as a method or anything

dull ermine
#

hm maybe it changed in 1.21

quartz sleet
#

i mean i believe you meant to put it in a different script?

dull ermine
#

whats your script?

quartz sleet
#

Or did you mean in the effect

dull ermine
#

you put that in the effect tick

quartz sleet
#

_> i put it inside the effect but not the tick

#

I thought u meant the body as in the registry event

dull ermine
#

no---

quartz sleet
#

well according to probeJS it still doesn't recognize it

dull ermine
#

silly duck_smh_lex

#

i dunno probejs

quartz sleet
#

but i will try >_>

#

Wait so you just wing it?

#

You dont use probe at all?

#

dam

#

built different

dull ermine
#

no ive never used probe hmmm

quartz sleet
#
``` ye thats not it
#

Perhaps it changed let me see if probe has something

dull ermine
#

let me check, a lot of things changed in 1.21

#

huh... getServer was removed from utils

#

i wonder why

#

show me your code

quartz sleet
#

well i manged to do it >_>

#

I knew it was a thing i just didn't know how to apply it

dull ermine
#

what thing thinking_lex

quartz sleet
#

You show me something and i kinda got it

#

Imma show u how it's done in 1.21

dull ermine
#

i think your effect tick callback has the entity

quartz sleet
#
      if (entity.hasEffect("betterasfour:nature_gigante")) return;
      if (entity.tickCount % 20) return
        entity.attack("minecraft:arrow", 0.001)
      }
    )```
#

O i see

dull ermine
#

thats exactly what i wanted

quartz sleet
#

What u mean

dull ermine
#

xD

quartz sleet
#

Probably

#

But this works

dull ermine
quartz sleet
#

Ye finally ;-;

dull ermine
quartz sleet
#

Ty ;D

#

I should probably keep it open for those to come

#

the ticket i mean

dull ermine
#

close it, people can use the search to find it :P

quartz sleet
#

How do you personally go around checking for that stuff?

#

If u dont have files compiled specifically for that info by probe?

dull ermine
#

uh

#

i either know how most of them work, or use the source code and my website

#

which is also good for when you want something but dont know how to get there, you search what you want and work your way backwards

#

which is what i did in this case when i saw Utils didnt get the server anymore

quartz sleet
#

oh thats your website >_>

#

well ty for doing that either

#

Btw if i already have your attention do you know how to get rid of these log messages ```! cantinscript.js#140: Error in 'EntityEvents.beforeHurt': dev.latvian.mods.rhino.EcmaError: TypeError: Cannot read property "stages" from null
[17:14:45] [ERROR] ! cantinscript.js#181: Error in 'EntityEvents.beforeHurt': dev.latvian.mods.rhino.EcmaError: TypeError: Cannot read property "stages" from null

#

The value is supposed to return null because it doesn't exist but why does it have to spam my logs >_>

dull ermine
quartz sleet
#
const { source : { player } } = event;
if ((player.stages.has("gauntlets1")) && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets"))
  {
  player.runCommandSilent("/puffish_skills category unlock @s puffish_skills:gauntlets")
  player.stages.add("gauntlets")
} else return```
#

this is a snippet of the script

dull ermine
#

you should add a js after the 3 ` to get syntax highlighting

#

makes it easier to read the code

quartz sleet
#

o

#

lemme do it

#
[17:14:45] [ERROR] ! cantinscript.js#181: Error in 'EntityEvents.beforeHurt': dev.latvian.mods.rhino.EcmaError: TypeError: Cannot read property "stages" from null```js
#

i did it wrong

shadow mountainBOT
#

You can write your code in a codeblock by typing it between the codeblock delimiters:
Note that these are backticks, not apostrophes

```js :arrow_left:

ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})

``` :arrow_left:

This example will look like this:

ServerEvents.recipes(event => {
  event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
quartz sleet
#
[17:14:45] [ERROR] ! cantinscript.js#181: Error in 'EntityEvents.beforeHurt': dev.latvian.mods.rhino.EcmaError: TypeError: Cannot read property "stages" from null```
#

huh

#
const { source : { player } } = event;
if ((player.stages.has("gauntlets1")) && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets"))
  {
  player.runCommandSilent("/puffish_skills category unlock @s puffish_skills:gauntlets")
  player.stages.add("gauntlets")
} else return```
dull ermine
#
EntityEvents.beforeHurt(event => {
  const { source : { player } } = event
  if (player.stages?.has("gauntlets1") && event.source.weaponItem.hasTag("c:tools/gauntlets")) {
    player.runCommandSilent("/puffish_skills category unlock @s puffish_skills:gauntlets")
    player.stages?.add("gauntlets")
  } else return
  // is there more here?

try this

quartz sleet
#

there is a lot more xD

dull ermine
#

o.o

quartz sleet
#

o u added the ? if

#

since im new to this i made this code in such a whacky way xD

#

if i were to show you the code you'd be stunned

dull ermine
#

oh god

#

one tip i can give you for much better code is learn to use guard clauses everywhere

quartz sleet
#

how so?

dull ermine
#

reduces the complexity and indentation of your code by exiting early

quartz sleet
#

well it didn't work with the "?"

#

Good god if i were to show you this monstrousity after you tell me that

dull ermine
#

or you could even add a guard clause to check the stages

#
EntityEvents.beforeHurt(event => {
  const { source : { player } } = event
  if (!player.stages) return
  if (!player.stages.has("gauntlets1")) return
  if (!event.source.weaponItem.hasTag("c:tools/gauntlets") return

  player.runCommandSilent("/puffish_skills category unlock @s puffish_skills:gauntlets")
  player.stages.add("gauntlets")
quartz sleet
#

where is it in the last example?

dull ermine
#

at the top

quartz sleet
#

Im sorry i just dont notice what you mean this seems like a regular script i would make >_>?

dull ermine
#
EntityEvents.beforeHurt(event => {
  const { source : { player } } = event
  if (!player.stages) return
quartz sleet
#

o u meant

#

i see

#

My bad xD

#

Ye i used to do that like that

#

but then idk wtf was going through my head

#

Well if u were to see the code you will know or maybe not know what went through my head >_<

#

Lemme change it around according to that

#

but it gave me null log messages anyways when i did have the guard clauses early

#

What i sent you previously was after trial and error with various ways

dull ermine
#

then maybe its somewhere else hmmm

quartz sleet
#

But wait it's important to point out that for some reason it returns null when i get attacked

dull ermine
#

oh wait

quartz sleet
#

And thats weird

dull ermine
#

stages from null

quartz sleet
#

Ye stages

dull ermine
#

no

#

not stages

#

thats the thing

quartz sleet
#

_<?

dull ermine
#

whatever is before stages is null

quartz sleet
#

O

dull ermine
#

so in your example, player is null

#
EntityEvents.beforeHurt(event => {
  const { source : { player } } = event
  if (!player) return
quartz sleet
#

Ok but it tell me specifically in the logs that the stages returns null is that now how it works?

dull ermine
#

so the damage source doesnt have a player source

quartz sleet
#

Ok so i need to make an exit for non players?

dull ermine
#

the log says Cannot read property "stages" from null

#

you have player.stages

quartz sleet
#

O FROM NULL

#

I SEE

dull ermine
#

yeyeye

quartz sleet
#

So when i take damage from an effect?

#

It just gets confused

dull ermine
#

source.player only exists when the player deals damage

#

most damage sources arent from the player

quartz sleet
#

How do i counter that?

#

Do i need to return both conditions?

#

Would that even do anything

#

I mean it's already like that

quartz sleet
#

well i put it in

#

it still does it >_<

dull ermine
#

which line is the exact line doing it

#

from the log

quartz sleet
#

Ok i feel like i should reveal the monstrousity so you can help me better

#

HOW do i make it into a js ;-;

#
const { source : { player } } = event;
if (!player) return;
if ((player.stages?.has("gauntlets1")) && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets"))
  {
  player.runCommandSilent("/puffish_skills category unlock @s puffish_skills:gauntlets")
  player.stages.add("gauntlets")
}
if (player.stages.has("spears") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
  player.stages.remove("spears")
  player.runCommandSilent("/puffish_skills category lock @s puffish_skills:spears")
} 
if (player.stages.has("swords") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
  player.stages.remove("swords")
  player.runCommandSilent("/puffish_skills category lock @s puffish_skills:swords")
} 
if (player.stages.has("hammers") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
  player.stages.remove("hammers")
  player.runCommandSilent("/puffish_skills category lock @s puffish_skills:hammers")
} 
if (player.stages.has("chakrams") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
  player.stages.remove("chakrams")
  player.runCommandSilent("/puffish_skills category lock @s puffish_skills:chakrams")
} 
if (player.stages.has("dual_blades") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
  player.stages.remove("dual_blades")
  player.runCommandSilent("/puffish_skills category lock @s puffish_skills:dual_blades")
} 
if (player.stages.has("scythes") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
  player.stages.remove("scythes")
  player.runCommandSilent("/puffish_skills category lock @s puffish_skills:scythes")
} 
}
)js```
dull ermine
#

look at the example in the codeblock command, you need to write exactly that nothing more nothing less

#

but i still dont know the exact like

#

i just need the one line

quartz sleet
#

o ye my bad lemme show u

#

wait nevermind

#

it works maybe?

#

gimme like 2 mins

#

Ok so i had my conditions all messed up

#

On basically all my scripts

#

Almost all

#

Apparently i cant do

#

if (!event.source.player && ...) return;
it has to be alone without any additional conditions

dull ermine
#

no it can work but you need to be careful what you write

quartz sleet
#

Well specifically for this event probably cant

dull ermine
#

when you invert the if statement, you need to invert the && into ||

quartz sleet
#

Ye >_>

#

I see

#

also i just crashed my world by dying with my effect

#

to my effect*

#

i hope that's a fluke

dull ermine
#

lol

quartz sleet
#

oh no

#

what you just helped me with

#

fixed the initial problem

#

but CREATED ANOTHER ;-;

dull ermine
quartz sleet
shadow mountainBOT
#

Paste version of message.txt from @quartz sleet

quartz sleet
#

this might be worse than before

#

idk what i did

#

o it's the "?"

#

Ok IM good now phw

#

phew

dull ermine
#

what an emotional rollercoaster lol

quartz sleet
#

It really was

#

i was simply ignoring it before but it became overwhelming

#

So i tried for way longer than i should have to fix it

#

Ty once again

#

I will now close this ticket