#Script API General

1 messages ¡ Page 86 of 1

dusky flicker
#

just hate it that it limits 20 executions per second.

fresh current
dusky flicker
#

well, yeah

#

whats the issue?

dull lodge
#

ive made a post in the thread thingy here, if someone could have a look and see if they can help me out that would be amazing :)

distant tulip
dusky flicker
distant tulip
sly valve
#

My dear chat, you got any Debuff Ideas?

warm mason
sly valve
#

Debuffs like Fire (Burns the enemy)

sly valve
random flint
sly valve
warm mason
sly valve
gilded shadow
#

does /summon triggers any event?

#

like entity load or spawn?

warm mason
sly valve
gilded shadow
#

also when is entity load even triggered?

random flint
#

chunk loaded with the entity inside it

sly valve
buoyant canopy
#

How can i do this without using try?
try { return dimension.getBlock(location).typeId == typeId } catch {fallback}

gilded shadow
warm mason
sly valve
sly valve
sly valve
random flint
buoyant canopy
#

I am trying if check the block type in a location that might not be loaded, and if not loaded it will use the last detected value

random flint
#

getting block on unloaded chunk simply just returned undefined.

buoyant canopy
random flint
#

Getting block beyond the build range (like void) throws error

buoyant canopy
gilded shadow
sly valve
random flint
#

Returns Block | undefined - Block at the specified location, or 'undefined' if asking for a block at an unloaded chunk.

buoyant canopy
random flint
#

lol, weird then xd

buoyant canopy
#

which makes that useless

random flint
#

Then kept the try catch then

buoyant canopy
random flint
#

stable?

buoyant canopy
#

the function returns undefined instead of the fallback value

buoyant canopy
warm mason
#
/**
 * @param {import("@minecraft/server").Dimension} dimension
 * @param {import("@minecraft/server").Vector3} location
 * @returns {String | undefined}
 */
function getBlockType(dimension, location) {
  const id = dimension.id.split(':')[1] + '*' + Math.floor(location.x) + ',' + Math.floor(location.y) + ',' + Math.floor(location.z);
  let block;

  try { block = dimension.getBlock(location) } catch {};
  if (block == undefined) return SavedBlockTypesMap.get(id);

  SavedBlockTypesMap.set(id, block.typeId)
  return block.typeId;
}
const SavedBlockTypesMap = new Map();
random flint
#

Oh, that make senses. On Beta getBlock just simply return undefined for unloaded chunk, thats why It feels weird xd

buoyant canopy
random flint
#

idk.

#

Have you tried using some kind of chunk loader?

warm mason
#

Okk........

random flint
warm mason
random flint
#

Use dynamic property, so it floods the storage instead of the memory 😎

sly valve
#

So it will flood the memory as well

#

or am i wrong

random flint
random flint
#

Across world loads yeah
-# (Not across different world)

sly valve
#

Alright

carmine quail
buoyant canopy
#

@random flint it turns out dimension.getBlock doesn't throw an error when the block is unloaded

random flint
#

IG is tied to how far from the nearest simulation distance chunk or smt... idk, I can't read

buoyant canopy
sly valve
sly valve
random flint
#

-# the anime

sly valve
prime zenith
#

Im so freaking tired

random flint
#

Take a rest 😎👍

sly valve
random flint
#

Virtual massage effectiveness is guaranteed 👍

sly valve
prime zenith
#

Lol

#

Ok ka nappy time

lyric kestrel
#

What parameters do yous think should be in a function that were to check if player placed blocks are aligned properly?

#

Like a multiblock structure function

#

I am unsure on how to proceed with making the function

#

The return of the function will just be if all blocks are in the correct position, return true

#

structureName

distant tulip
#

"aligned properly"?

lyric kestrel
#

Sorry, I'm not good with words

dusty temple
#

Is there an alternative to making runInterval async? I'm tried to yield a for loop and a runInterval and I'm not sure how to workaround it.

const music: Sound[] = [
  {
    id: 'lbs.music.take_me_out',
    volume: 1,
    duration: 222,
  },
];

world.afterEvents.playerSpawn.subscribe(({ player: plr }) => {
  system.runInterval(async () => {
    for (const { id, volume, duration } of music) {
      plr.playSound(id, {
        volume: volume,
      });
      console.log("Playing...",id)
      await system.waitTicks((duration ?? 20) * 20); // 20 ticks per second
    }
  });
});
#

k got it working, I just ditched runInterval

async function queueMusic(plr: Player) {
  for (const { id, volume, duration } of music) {
    plr.playSound(id, {
      volume: volume,
    });
    console.log('Playing...', id);
    await system.waitTicks((duration ?? 20) * 20); // 20 ticks per second
  }
}
world.afterEvents.playerSpawn.subscribe(async ({ player: plr }) => {
  while (true) {
    await queueMusic(plr);
  }
});
jolly citrus
#

What is the time complexity of Container.prototype.getItem, ItemEnchantableComponent.getEnchantment

dusty temple
#
console.time("time")
Container.prototype.getItem
console.timeEnd("time")
jolly citrus
#

I’m not on my PC i cantp

#

That doesn’t tell me the time complexity anyway really

sharp elbow
#

I imagine getItem and getEnchantment are constant time. It just might be a large constant time

sly valve
gaunt salmonBOT
# dusty temple ```ts console.time("time") Container.prototype.getItem console.timeEnd("time") `...

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 2 errors:

<REPL0>.ts:1:9 - error TS2339: Property 'time' does not exist on type 'Console'.

1 console.time("time")
          ~~~~

``````ansi
<REPL0>.ts:3:9 - error TS2339: Property 'timeEnd' does not exist on type 'Console'.

3 console.timeEnd("time")
          ~~~~~~~

Lint Result

ESLint results:

<REPL0>.ts

0:0 warning File ignored because no matching configuration was supplied

jolly citrus
#

I’m wondering what could possibly be the mslt efficient way to check for inventory updates on a player

#

I need to limit certain enchantments to lower levels than vanilla would allow you to enchant them to

granite badger
granite badger
#

(Preview only)

jolly citrus
#

SMH

lyric kestrel
#

Would that mean you only subscribe to those properties within the event? And any non-specified properties wouldn't work?

jolly citrus
#

You’re destructuring the event signal’s callback’s properties

open urchin
#

it's the equivalent of doing this, but you don't have access to event

subscribe(event => {
  let { playerId, playerName } = event;
})
lyric kestrel
#

I see

rigid torrent
#

How can I make an entity steal a random item from the player inventory, and store it on it's own inventory?

jolly citrus
rigid torrent
#

No

#

Well

#

Just must be empty

jolly citrus
#

Get the entity’s container
Get the player’s container

Then:

const targetSlot = 0; // for example but this can be any slot you’d like
playerContainer.swapItems(Math.floor(Math.random() * playerContainer.size), targetSlot, targetContainer)
jolly citrus
#

wait

solar dagger
#

wouldnt it be better to select items only from the hotbar? instead of the whole inventory, cause that would pull armor slots too right?

jolly citrus
#

So why assume

#

And no it doesn’t pull armor slots

#

Or offhand

solar dagger
#

im not assuming, im asking

jolly citrus
# solar dagger im not assuming, im asking

I wasn’t trying to say that you were assuming, I meant that if I’m going to help them then it’s better that I assist them with what they actually requested to get some help with, no?

#

They didn’t say they only want to steal from the player’s hotbar

solar dagger
#

and you're right about the container, i just checked the doc

jolly citrus
#

So I won’t help them with only making it steal from the hotbar

rigid torrent
#

Yea any slot works

jolly citrus
#

Get the entity’s container
Get the player’s container

Then:

const randomSlot = Math.floor(Math.random() * playerContainer.size)
let i = 0;
let playerItem;
while (!playerItem) {
if (i > playerContainer.size) break;
randomSlot = (randomSlot + 1) % playerContainer.size
playerItem = playerContainer.getItem(randomSlot)
i++;
}

if (playerItem) {
targetContainer.addItem(playerItem)
playerContainer.removeItem(randomSlot)
}
#

I recommend that you improve the logic of the playerItem loop

#

I’m on mobile so I just wrote something short to be used as reference

jolly citrus
#

also i forgot to regen randomSlot in it as well byt yea

rigid torrent
#

Thank you!!

jolly citrus
#

Actually now it should be fine

#

Basically it initializes randomSlot with a random number within the player’s inventory’s slot bounds (in vanilla this is 0-35 -> 36 slots), then checks if they have an item on that slot

If they don’t have one on that slot it will check the next slot and go on until it reaches the last slot and then proceeds to the first slot (slot 0) and begins to increment up from there again

#

But there’s better ways

#

I think there’s a method that lets you find the first item within a container

#

Maybe make use of that to reduce the number of recursive calls

#

For basic use this is fine

At a larger scale it’s worth improving though

sharp elbow
#

Out of curiosity, why start at a random slot? This is going to have the same average time complexity at its worst-case as starting from 0 would.

jolly citrus
sharp elbow
#

Ah, then I clearly did not read the requirements bao_ext_toldyouso

solar dagger
#

hey @rigid torrent any news on additional block templates? Your templates have helped me cut down production time xD

rigid torrent
solar dagger
full idol
#

I'm looking for a method to purge all diamonds, diamond blocks, and diamond ore from inventories, containers, and enderchests.

I was planning on going about it by clearing inventories of the items the first time they join after activation, every container gets cleared the next time it is opened. To deal with shulkers, maybe clear them and add a dynamic property?

sage portal
#

is there a link to a doc to get a rundown of how to use ActionFormData? I'm completely new to this

dusky flicker
#

is making a lib that makes communication between addons easier a good idea?

#

im making it, but by now is merely for fun

dusky flicker
#

so imma just adjust some stuff and put it in a particular github repo

#

i need people to test and check if there are some bugs or stuff related

#

its pretty based on client/server communication

#

i really dont know why in the hell i did choose to make it nestjs like

sly valve
dusky flicker
#

its pretty simple the way im doing it by the way

#

i was pretending to call it 'enchanted' but i've decided to call 'zetha' so whatever imma modify the names

#

and then i put on github

prime zenith
#

I really hate how discord does blocks i really dont want to see x blocked messages i just want them blocked fully

dusky flicker
prime zenith
#

Can a script trigger a component group

cinder shadow
#

You can run an event on the entity that triggers a component group

prime zenith
#

And that event can detect something the script did to trigger it?

dusky flicker
dusky flicker
#

when i send something i simply send it via scriptevents adding a header and the content

#

the header is 5 chars, 2 from the client id, 2 from the server id and 1 for the request index(get track of promises) and after it, its all thr content

#

i made it using lz/cbor+pako

#

to simply compress data and exceed the limit of 2043(2048 - 5 of the header) chars per scriptevent

prime zenith
#

If that person i blocked was answering me im not clicking the blocked messages to see it what you said was very rude

dusky flicker
#

im probably going to implement a method where i can simply dont compress data

#

it slows the code, but its better to send something huge.

prime zenith
#

@cinder shadow im unsure how these event triggers work

cinder shadow
prime zenith
#

Ohh so in the components event i just add the component group then i trigger that in script

cinder shadow
#

Yep, just use the add remove part of json events

prime zenith
#

Sweet ty so will a component group over ride the changed components from entity components

sly valve
#

Im doing a HTTP based system

dusky flicker
#

or just the system of client/server stuff?

sly valve
#

an REST-Api

dusky flicker
#

oh, thats the way ive implemented mine

sly valve
#

Host registers the routes, and client can send requests

sly valve
dusky flicker
#

im used to implement algorithms by hand but damn

#

im using memoirist to do so

#

ive benchmarked it and it seems to be 2x faster than findmyway(the one that fastify uses btw)

sly valve
#

:o I dont understand anything

#

sorry, im not a pro or something like that

dusky flicker
#

now i think about adding some kind of encrypting

sly valve
#

I just do it as a like hobby

dusky flicker
#

what handles it is called "radix tree"

sly valve
dusky flicker
#

yeah

sly valve
#

or players/:id/log

dusky flicker
#

memoirist is one implementation if it

#

findmyway as well

sly valve
#

so its a class/function?

#

or a whole npm

dusky flicker
#

both are whole npms

#

but memoirist is about 330 lines

#

you can check the code on the repoby the way

sly valve
#

so memoirist is a so called radix tree

dusky flicker
#

yeah

#

its a tree that each node is a radix of a string

#

thsts why

#

i really dont plan adding GET POST and these methods

sly valve
#

and its made to process this input? (example)

input = "players/player123/log?filterDate=282222822"
dusky flicker
sly valve
dusky flicker
#

i did not test with params like ?filterdata=...

#

but as its used in elysia

#

theres no reason to it not have this

sly valve
#

hmm, this whole topic is pretty interesting

dusky flicker
#

its defined on "routed" on the repo if you want to see it

#

had to use another lib other than reflect metadata for reflecting

#

20kb only for about 4 methods xd

sly valve
#

Ill do a simple one with "GET" | "POST" | "PUT" | "PATCH" | "DELETE" methods
and a radix tree so i can do routes like players/:id/log or players/

plucky light
#

I'm trying to hide HUD elements when a screen appears.

the one thing I can't figure out if we can hide the players hand or held item in first person view?

Is there a way to control that?

sly valve
dusky flicker
#

i switched to abraham/reflection

#

its about 3kb only

sly valve
#

what does it do

dusky flicker
#

well , reflection

#

decorators stuff

sly valve
#

sorry, i dont know what decorators are

shy leaf
dusky flicker
#

class Controller {
@Route("/example")
async f(){...}
}

#

when i call "/example" it executes this function

shy leaf
#

though you could do a workaround where you give the player an invisible item

sly valve
dusky flicker
#

by the way, if your going to implement it, i think you probably are going to implement streamming

dusky flicker
#

if using scriptevents

#

you send something that the size is >2048 chars

#

so to send it correctly, you break it into pieces

#

and send each piece

sly valve
#

like a TCP?

dusky flicker
#

i dont think tcp does so

#

it but probably

sly valve
#

so i chunk my too long string and send it in sequences?

dusky flicker
#

yeah

sly valve
#

ughhh

#

so many logic

#

ill die

dusky flicker
#

ive solved it by doing well a hashmap

#

with a circular index

#

just to do not use much memory

#

this index is passed on the request

#

so the server knows that promise to respond

#

it processes when the data is finalized and sends back to the client with thag index

#

so the index get that response and use it to resolve the promise

leaden elbow
#

chatSend event only for beta apis?

sly valve
leaden elbow
#

damn

sly valve
#

the Host notifies the client when all "packages" arrived?

dusky flicker
#

yeah

#

there are 5 ways of sending a "message" initialization, finalization, packet, batch, single

#

the single is when data is < 2048 chars so it sends in a single scriptevent

#

initialization just tells the client/server its going to receive a request/response

#

the packet is the data streammed

#

matching the initialization stuff

#

the finalization tells theres nothing more to receive

#

so the client/server can process the received data

sly valve
#

so much..

#

and I wanted todo everything by myself

dusky flicker
#

i did everything by my self, i think you could too

sly valve
#

You destroyed my ego

dusky flicker
#

the batch is simple, when requests are small and dont need to be resolved when sended, you can store them

#

when its close to 2048 chars, it sends them all at once

sly valve
#

whats the limit of request per tick in minecraft? 256?

dusky flicker
#

depends

#

if you block the thread on both sides

#

or simply dont use runJob

#

ive got about 3k requests per second

sly valve
#

YOU WONT EVER NEED THAT MUCH

prime zenith
#

Wait you can make a player balloonable

sly valve
#

probably

#

by editing the player.json

dusky flicker
#

but that's how much it did

sly valve
#

pretty cool

dusky flicker
#

well, it was a basic Hello World response

#

if you block the thread(or simply use runJob) on the server

shy leaf
#

hmm whats the topic?

dusky flicker
#

you limit the responses to the client by 20

sly valve
dusky flicker
#

if on both, by 10

sly valve
#

radix trees

shy leaf
#

well uh

#

scriptevent command doesnt have a character limit

#

just telling you

dusky flicker
#

really? ive seen on the docs about 2048

shy leaf
#

thats scriptevent method

#

the command one doesnt have limit for whatever reason

sly valve
#

btw

dusky flicker
#

hm, that can be usefull, thanks

sly valve
#

where do i normaly put my requestId, in the header?

dusky flicker
#

when sending a packet it gotta know from which request it's

#

to data dont get corrupted

#

the header is the same at every request

#

it's all(or almost) documented(please don't mind if you see some &, << and >> operations)

#

you can check it

shy leaf
#

but it doesnt have performance loss (or super small if any)

dusky flicker
sly valve
#

you all sound so exerienced

#

i hope i will be as good as you two someday

dusky flicker
#

i really dont think there are going to have some performance issue

thorn flicker
#

lol

shy leaf
#

my addon uses a system that makes use of the scriptevent command

dusky flicker
#

or at least not critical

shy leaf
dusky flicker
#

im not that experienced btw

#

i code with rust about less than 1 year

dusky flicker
shy leaf
shell sigil
#

(⁠•⁠‿⁠•⁠)

shy leaf
dusky flicker
#

i didn't even know there was some that implemented it before

shy leaf
#

but what that does is that it encodes data into base64 and send it using scriptevent command

#

and the other pack receives the scriptevent and decode it

dusky flicker
#

dwmn base64 adds 1 char each 3

#

it adds 33% overhead

#

i really do so

#

but depending on the size, it uses lz to compress

#

or cbor+pako

#

which reduce the size of data

#

instead of grow it

shy leaf
#

(well tbf i use that since i need new Function())

#

(it depends on use case)

dusky flicker
#

what is "tbf"? i dont speak english natively

shy leaf
#

its "to be fair"

dusky flicker
#

oh, thanks for clarifying

shy leaf
#

ja

dusky flicker
#

actually i thought in doing so because i wanted to make an addon that helps others

#

actually by saving data for them

#

and maybe some executables

shy leaf
#

well if your use case doesnt involve stuff like sending function data for new Function(), then IPC might be a bit too much for that

#

unless you need to encrypt the data to be unreadable for humans

dusky flicker
#

how does ipc work by the way?

shy leaf
#

@slow walrus can answer that for you

#

uhhh i dont know if he is online though

dusky flicker
#

probably not

shy leaf
#

yeah

#

(dont mind the mess, its under a huge code revamp)

#

i should get rid of the embeds, those are huge

floral vessel
#

Does onStepOn trigger for block with no collision?
If not, how can I trigger an event when a mob's hitbox is in my block?

wary edge
dusky flicker
#

im making it about 1 month

#

the way i implemented is godamn insecure

prime zenith
#

Why does the health component only change max health on the very first load if i change it but load the same world its not changed

dusky flicker
#

anything i modify can break if its changing the internals

#

and probably im going to modify compression

nova wraith
#

How can I detect if the player is on ground? "player.isOnGround"?

nova wraith
#

Are you sure?

shy leaf
nova wraith
#

I will ad it to the code anyways

shy leaf
nova wraith
dusky flicker
#

its on the docs

shy leaf
nova wraith
shy leaf
#

entities dont refresh themselves, the components will stay once its set

prime zenith
#

@shy leaf so how do i make there max health changeable with component groups if it wont change with the chsnge

shy leaf
#

uh

#

events

#

entity events

nova wraith
#

@shy leaf I'm trying to continue your dash code

prime zenith
#

So component groups do over ride its health

nova wraith
shy leaf
#

oh nice

prime zenith
#

Entity events just triger component groups for component stuff

nova wraith
shy leaf
#

was just answering your "Are you sure?" comment

nova wraith
vast grove
nova wraith
#

I'm too slow to understand some things, especially if it's not in my main language

shy leaf
#

just

#

dont mind that

nova wraith
#

Oh great, now I want to know

shy leaf
#
Object.defineProperty(Entity.prototype, "isRiding", {
  get: function() {
    return this.getComponent("riding")?.isValid ?? false;
  }
});

its just for checking if an entity is riding

vast grove
#

Riding state is when the player/entity is riding another entity or is in the seat of another entity

nova wraith
#

Yes but I was asking about isOnGround, not isRiding

shy leaf
#

yeah i was telling you to ignore it

nova wraith
#

Bruh

shy leaf
#

in case you wanted to ask

#

:sob;

nova wraith
#

Oh, Thank you

prime zenith
vast grove
#

Well then bad luck IG. You can't really change entity health at runtime without data defining components

shy leaf
#

what

vast grove
#

You can use effects

prime zenith
#

Thats not what i asked

wary edge
vast grove
#

If you wanna change player health without the risk of overriding you can use the effect that changes the player's max health but then it does become a bit annoying to manage the effect but it's less likely to get overriden

prime zenith
#

I have multiple packs so each pack can manage its own skills but that means player.json may be needing changes in multiple areas

#

I mean i could make a core pack dependency and use componenent groups thus only 1 player.json

vast grove
#

That can work. Only if the users don't use another add-on that overrides the player.json based on addon hierarchy

prime zenith
#

And no effects wont work as 1 adds 4 however theres an alternative way i can do health if i want and ill leave a note not compatible with other packs that change player.json

vast grove
# thorn flicker not true

In what way? The only way I know that it'll save the state is when you write a property that the molang detects at runtime.

wary edge
slow walrus
shy leaf
#

oh

#

wait it uses binary??

#

woah

vast grove
thorn flicker
prime zenith
#

@wary edge so if i add a component group that sets my max health to 21 when activated will it set health to 21

wary edge
#

Yes.

vast grove
slow walrus
slow walrus
shy leaf
#

wait wha

#

it didnt when i tried it before using IPC

slow walrus
#

more specific ones at least, that one is a prety broad question lol

prime zenith
#

If player.json is in pack a can a script in pack b still trigger event

vast grove
#

Yeah. It should be able to

dusky flicker
#

as the default way im transferring data is json if i remove the compression stuff

carmine quail
#

I'm having trouble with this why it won't execute

system.runTimeout(() => {
              dimension.runCommand(`playsound random.levelup "${player.name}" ~~~ 1 10`);},2);```
thorn flicker
#

and where's player

carmine quail
#

It was running whne i didn't add the pitch vol

thorn flicker
thorn flicker
prime zenith
#

Its to late for me save yourself

vast grove
#

What?

thorn flicker
prime zenith
#

Nothing im bored

thorn flicker
#

okay...

prime zenith
#

If (kirstin === "bored") { sendRandomMessages()}

thorn flicker
#

TypeError: "sendRandomMessages" is not a function

prime zenith
#

I had that defined elsewhere tho

thorn flicker
prime zenith
#

I need to do a million things and lost on what 1 to tackle while slso dealing with some of the most vile people 1 of which is sadly in this server my sanity is slipping

vast grove
#

Focus on what you need to do first for something else to work. I usually develop core base frameworks and dependencies first before moving on to other stuff.

carmine quail
#

player.playSound() is more accurate figured it out

thorn flicker
carmine quail
#

So thats for each individuals if via multiplayer just runCommand

thorn flicker
#

there's dimension.playSound

#

-# world.playSound is deprecated in newer versions

carmine quail
#

Ohh okay

prime zenith
#

How do i get the players health snd set it to a variable

prime zenith
#

Ok im trying my hardest to follow the example in that docs and i sm failing all i want is to create a var health that is the players health

thorn flicker
vast grove
prime zenith
#

That throws an error

thorn flicker
#

because thats typescript.

prime zenith
#

Oh the example was ts whats for hs

#

Js

thorn flicker
#

just remove the as part.

vast grove
#

Remove as EntityHealthComponent

prime zenith
#

Ahh

thorn flicker
prime zenith
#

system.runInterval(() => {
    const players = world.getAllPlayers();
    for (const player in players) {
        const health = player.getComponent(EntityComponentTypes.Health)
        console.warn(health)
    }
})``` is not a function
thorn flicker
#

and like I said, get the currentValue component for the health value

prime zenith
#

the const health = ect is where the errors thrown

#

i thought this was how you got the component

thorn flicker
#

you used in not of

#

player will return a string.

prime zenith
#

oh whoops typo but you said i still need to get the component

thorn flicker
prime zenith
#

hold on ill test it your going in circles

thorn flicker
#

Lol what

prime zenith
#

i need its value and max idk how thats done

thorn flicker
#

I told you.

#

get the currentValue property.

vast grove
#

What you did there in getting the component is correct except for how you're retrieving the player. You have to use for (const player of players) not for (const player in players)

prime zenith
#

no you said then just get its component

thorn flicker
#

yeah

#

and then get the currentValue property.

prime zenith
#

thats not how

thorn flicker
#

but how do you not know how

prime zenith
#

i possibly do not that i remember

thorn flicker
#

its just dot notation

prime zenith
#

so health. or player.

vast grove
#
import { world, system, EntityHealthComponent, EntityComponentTypes } from "@minecraft/server"

system.runInterval(() => {
    const players = world.getAllPlayers();
    for (const player of players) {
        const health = player.getComponent(EntityComponentTypes.Health);
        console.warn(health.currentValue);
    }
})
prime zenith
#

ok thats what i needed

thorn flicker
#

you need this too

prime zenith
#

Whats the script for a title

thorn flicker
#

then use the setTitle method

prime zenith
#

What is the alt code for the color change symbol

vast grove
#

§

prime zenith
#

The slt code but i found it 0167

vast grove
#

Yeah that's the correct code

carmine quail
#

Yo is there a code that I can get the world name

prime zenith
#

offtopic is dead 😦 all chats i have seem dead

meager cargo
#

You helped me and tell that to wrap it up. I made this:

world.beforeEvents.itemUse.subscribe(event => {
    const player = event.source
    const item = event.itemStack

    if (!item || item.typeId !== "minecraft:compass") return

    const riding = player.getComponent("riding")?.entityRidingOn
    if (!riding || riding.typeId !== "test:test") return

    const tags = riding.getTags()
    if (tags.includes("ride_1")) {
        player.runCommand("execute if entity @e[type=test:test,tag=ride_1] run event entity @e[type=test:test,tag=ride_1] ride_2");
    } else {
        player.runCommand("execute if entity @e[type=test:test,tag=ride_2] run event entity @e[type=test:test,tag=ride_2] ride_1");
    }
})

But it still says error with privileges
Can you or someone help me?

remote oyster
# meager cargo You helped me and tell that to wrap it up. I made this: ```js world.beforeEvents...

The runCommand function can't be executed directly during a beforeEvent because it runs at the start of the tick when the event is still in a read-only state. At this point, any method or property that modifies the world is restricted and will throw a "does not have required privileges" error.

To work around this, you need to delay the execution of those methods until the world is in a read/write state, typically at the end of the current tick or the beginning of the next one. One way you can do this is by wrapping the command calls in a function and passing it to system.run(). This effectively schedules it for execution later in the tick, when the required permissions are available.

meager cargo
#
    system.run(() => {
        if (tags.includes("ride_1")) {
            player.runCommand("execute if entity @e[type=test:test,tag=ride_1] run event entity @e[type=test:test,tag=ride_1] ride_2")
        } else {
            player.runCommand("execute if entity @e[type=test:test,tag=ride_2] run event entity @e[type=test:test,tag=ride_2] ride_1")
        }
    })

Like this

#

??

meager cargo
wise raft
sly valve
#

Probably

#

I think so

#

Perchance

warm mason
wise raft
warm mason
sly valve
little hull
#

where does the getview direction bases it values to the direction the pivot point of the head is facing in its model?

warm mason
#

Entities have a "rotation" property and getViewDirection() basically just turns a Vector2 into a Vector3

warm mason
sly valve
sly valve
remote oyster
wise raft
wise raft
remote oyster
#

If you click on the server tag next to the name it will pop up the server. Have to be on PC though. Won't work on mobile.

warm mason
sly valve
distant tulip
distant tulip
gaunt salmonBOT
warm mason
#

oh, yeah? well then he can wait

halcyon phoenix
#

hey how do I know if the function/event im using is beta?

halcyon phoenix
distant tulip
#

yes

wary edge
#

Idk.

halcyon phoenix
#

oh lol thanks a lot it's been at my face the whole time

leaden elbow
#

is there a way to check player is op on stable version

#

except for tags and isOp since its beta

random flint
#

No. You basically just exclude most of the practical ones with that question.

Scoreboard, dynamicProperty, is an option. But it's redundant and still requires manual handling.

dusky flicker
#

@sly valve can you give me some suggestion? its about the stuff of transfering data between addons

#

im thinking about changing the way i can transfer data, im sending at the beggining of the type of compression of the content, L for one, C for another(match the initials of the name of the algorithms used), but maybe i can use so to send more data in a single character.

sly valve
#

Uhhh idk

dusky flicker
#

in js each char is utf16, so i have 16 bits where i can use them to be bitflags. Instead of sending response/client responses and their respective types with an specific id on the scriptevent, such as
scriptevent zetha:client_packet ...
scriptevent zetha:client_batch ...
scriptevent zetha:server_packet

i could put them in a single char using it as a bitflag 'array'

#

like
XXXXXXXXXXXXXXX0
means its a request
XXXXXXXXXXXXXXX1
means its a response

XXXXXXXXXXXXXX0X
Means it uses lz for compression

XXXXXXXXXXXXXX1X
means it uses cbor + pako for compression
and so on

sly valve
#

:0

dusky flicker
#

so a response which uses lz could be a char whose bits are XXXXXXXXXXXXXX01

dusky flicker
sly valve
#

Ill read through it in one sec

#

I do

#

But whats the advantage of it

#

One char for the type of compression used for the content

dusky flicker
#

as i need passing between client and server the method used for compression

#

i thought it would really suck losing 16bits for only 1 task

sly valve
#

Well thats right

dusky flicker
#

and it would make things easier since i wouldnt need 9 types os messaging,
export enum ResponseType {
PacketData = "enchanted:response_data",
BatchResponse = "enchantend:batch_response",
SingleResponse = "enchanted:single_response",
Finalization = "enchanted:response_end"
}

export enum RequestType {
Initialization = "enchanted:request",
PacketData = "enchanted:request_data",
BatchRequest = "enchanted:batch_request",
SingleRequest = "enchanted:single_request",
Finalization = "enchanted:finalize_request"
}
as in here

#

i could only send 'zetha:message' and on the first char you get all the info you require to know how the data was sent

#

by now i dont think it's good because i dont have much ideas of what to put in there

sly valve
#

Each character is saved with UTF16? So that means they are 16bits long

dusky flicker
#

i've thought about
message type(client, batch, single)
response or request
compression method
if streammed, initialization or finalization

dusky flicker
#

i'd use String.fromCharCode() to get the number and transform to a char

#

nothing too complex

sly valve
#

And yiu want to use 2bit for the compression type?

dusky flicker
#

as i have only 2 options by now

sly valve
#

Ohh alr

sly valve
#

But isnt it impossible to have a single bit in a string

dusky flicker
#

only the message type would require 2 bits

dusky flicker
#

but i can cast it to number using content.charCodeAt(n)

sly valve
#

How many bit will the number have?

dusky flicker
#

the bounds of strings, so 16bits as well

#

imma make flags covering up to 1 << 15

#

32767 in decimal

sly valve
#

But why do even do that

#

Whats the advantage of it

dusky flicker
#

send more things, in a single scriptevent id

#

as i've said, it passes the method the data was compressed

sly valve
#

Does the id has a maximum amount of chars??

dusky flicker
#

so im losing 15bits only to check if it used one algorithm or another

dusky flicker
#

command has infinite as a bro said

sly valve
#

Hmm so id length and the message length in total must be below 2048

dusky flicker
#

the message length actually, about the id idk

#

but i dont think its >255

sly valve
#

I heard 32 somewhere

dusky flicker
#

i just need some ideas of what to transfer on those 16bits

#

depending of it i can implement

#

if not im not going to by now

sly valve
#

Maybe I got an idea

#

So each char has an unique bit pattern

dusky flicker
#

only the first char

sly valve
#

Nvm my idea just disappeared

dusky flicker
#

i really got no ideas of what to add

#

theres no reason to implement only by covering what i've thought

prisma shard
#

Ask ai

#

lol- i mean thats a good idea, AI can give nice ideas sometimes

wheat condor
#

nah

#

ai is good meccanically

#

ai doesnt have new ideas

warm mason
#

I look at his code and don't understand why there is so much stuff there?...

dusky flicker
acoustic basin
#

hey guys

#

so i'm moving to v2.0.0, and i'm getting this error

20:05:35[Scripting][error]-ReferenceError: Native function [World::getDimension] does not have required privileges. at <anonymous> (intervals.js:50)

what does this mean? what did they change to world.getDimension()?

#

what have i missed

acoustic basin
wary edge
# acoustic basin

Are you calling this at the top level? If so you cant do that. You must call it in worldLoad.

acoustic basin
#

worldLoad is something new?

#

how do i call it in worldLoad? i'm totally out of loop with the new stuff

open urchin
#

it's because in v2 scripts are ran before the world exists, so you can't get its dimensions

acoustic basin
somber cedar
# acoustic basin

https://jaylydev.github.io/scriptapi-docs/features/script-privileges.html#resolving-early-execution-issue
example

- for (const player of world.getAllPlayers()) {
-   player.sendMessage(`Hello ${player.name}!`);
- }
+ world.afterEvents.worldLoad.subscribe(() => {
+   // This procedure is moved inside the worldLoad callback,
+   // since world.getAllPlayers() can't be called in
+   // early-execution mode.
+   for (const player of world.getAllPlayers()) {
+     player.sendMessage(`Hello ${player.name}!`);
+   }
+ });
acoustic basin
#

ah yeah? i just did system.runTimeout(() => {}, 100) and it works, but this will be better, thank you

warm mason
acoustic basin
distant tulip
#

can confirm that it does somehow

warm mason
wary edge
#

Which is a tick.

warm mason
#

the first tick starts after the world loads so....

wary edge
#

20 ticks in a second so...

warm mason
prime zenith
#

Is it possible to increase fall damage by x5 i already have a trigger to remobe it in diamond gear whichbi need to stay also

warm mason
prime zenith
#

Is that type script i used the hurt without needing the entityDamagCause import on js

wintry bane
#

Is there a way to detect if the player is holding an entity with a leash?

wintry bane
#

thx

prime zenith
# warm mason ???????????

I never needed the entity damage cause component the event handler has a cause or is this specific for multiplying

warm mason
prime zenith
#

Ibknow im in school but the event handler slso has a cause built in

warm mason
# prime zenith Ibknow im in school but the event handler slso has a cause built in

cause, which comes from the event, is the cause why the entity received damage, EntityDamageCause is all possible causes why the entity can receive damage. In this case, we do it like this: if cause != EntityDamageCause.fall then the code execution ends by means of return, so the subsequent code will be executed only if cause == 'fall'

prime zenith
#

Actually i may need to multiply all damage by 5

#

Cause starting hp was multiplied by 5

warm mason
prime zenith
#

Could i just do a world afterhurt event take the damage amount multiply by 5 then apply damage

shy leaf
#

uh

#

wouldnt that cause a loop?

wheat condor
#

filter cause

#

or its better to set the health component

shy leaf
#

yeah that works

#

and in case of damage being high enough to kill the player, you could clamp the health component set value

warm mason
wheat condor
#

Ego maxxing

warm mason
wheat condor
#

idk

#

its up to her to decide if use your code or not

#

maybe its just a self testing thing

warm mason
#

Okay, never mind....

nova flame
#

@valid ice

#

Im having trouble with something and my friend told me you helpeed him before with the same problem but for some reason it doesnt work for me

#

could you help me please?

warm mason
sly valve
prime zenith
warm mason
sly valve
#

-# yep

nova flame
#

yap

valid ice
#

Why can’t you send it here

wheat condor
#

how do you guys do the small gray text?

prime zenith
warm mason
sly valve
wheat condor
#

-# did it work?

prime zenith
#

At the time then i said i need to multiply all damage byv5

sly valve
#

A space is missing my dear

somber cedar
#

-# a

prime zenith
#

Cause i multiplied start hp by 5

sly valve
#

-# b

wheat condor
#

it worked

valid ice
#

#off-topic

sly valve
#

Sorry 😔

warm mason
#

Or wait....

prime zenith
#

You said it only did fall damage were going in circles

wheat condor
#

bruh its not that hard to stop filtering from fall damage

warm mason
nova flame
#

its a script i got from someone

wheat condor
#

just dont ping if you dont even know what do you need

valid ice
nova flame
#

i have a chest ui

wheat condor
#

that makes sense

prime zenith
# warm mason Again, what do you need?

I needed to multiply all damage by x5 cause start health is multiplied by x5 i was asking if i could simply just multiply by 5 in the hurt event without needing the cause

wheat condor
warm mason
nova flame
#

and theres this typeId folder for like item textures that show up in it with numbers but all the numbers are wrong

wheat condor
nova flame
#

yes

valid ice
#

Make sure you have the latest version

wheat condor
#

that's the issue

nova flame
nova flame
valid ice
#

And also add your custom items to the file

#

There’s a place to put them

nova flame
#

how do i know what their numbers are?

valid ice
#

You don’t need to

#

forms.js file

wheat condor
nova flame
#

okay thanks ill try that

wheat condor
#

change the ids to your items

nova flame
#

what do u mean

wheat condor
nova flame
#

yes i did that

wheat condor
#

💯

nova flame
#

the custom items show up but the vanilla ones are still messed up

wheat condor
#

all items + blocks.....

nova flame
#

every item/block i added is there

#

idk what to do

wheat condor
#

look better you mightve doing something wrong with ids

nova flame
#

ive looked pretty hard

#

the typeids are just off

prime zenith
#

There are ppl in the us who think the us is a continent

Please can i leave this planet let me out

nova flame
#

@wheat condor what is wrong here why does it mess up the typeIds ```js
/**

  • Defines the custom block & item IDs for the form.
  • You can reference either a vanilla texture icon, which functions identically to other items...
  • ...or reference a texture path, which removes enchant glint and 3d block render capability.
    */
    const custom_content = {
    'sakura:common_key': {
    texture: "textures/items/common_key",
    type: 'item'
    },
    'sakura:rare_key': {
    texture: "textures/items/rare_key",
    type: 'item'
    },
    'sakura:server_menu': {
    texture: "textures/items/server_menu",
    type: 'item'
    },
    'sakura:epic_key': {
    texture: "textures/items/epic_key",
    type: 'item'
    },
    'sakura:legendary_key': {
    texture: "textures/items/legendary_key",
    type: 'item'
    },
    'sakura:power_up': {
    texture: "textures/items/power_up",
    type: 'item'
    },
    'sakura:sakura_key': {
    texture: "textures/items/sakura_key",
    type: 'item'
    },
    'sakura:mythic_key': {
    texture: "textures/items/mythic_key",
    type: 'item'
    },
    'sakura:drill': {
    texture: "textures/items/drill",
    type: 'item'
    },
    'sakura:hermes_boots': {
    texture: "textures/items/hermes_boots",
    type: 'item'
    },
    'sakura:battle_axe': {
    texture: "textures/items/battle_axe",
    type: 'item'
    },
    'sakura:life_battery': {
    texture: "textures/items/life_battery",
    type: 'item'
    }
    };

//Blocks are excluded from the count, as they do not shift vanilla IDs.
const number_of_custom_items = Object.values(custom_content).filter(v => v.type === 'item').length;
const custom_content_keys = new Set(Object.keys(custom_content));
//Add custom sizes defined in UI
]);```

wheat condor
#

are they ALL the typeids of your items

nova flame
#

EVERY item i added

#

is there

nova flame
wheat condor
#

then idk

nova flame
#

me neither

wheat condor
#

is it updated to latest version?

#

are you using preview or stable?

nova flame
#

stable

wheat condor
#

is it layest vertsion

nova flame
#

the type ids file is the same for my friend and works fine

#

same minecraft version

wheat condor
#

are you sure the game is reloading correctly, have you tried to close/reopen the game and the editor

nova flame
#

why the editor??

wheat condor
#

bridge sometimes does not save files and it breaks

nova flame
#

im using vs

#

soo

wheat condor
#

trying is free

#

it might work

nova flame
#

i just tried

#

not 1 change

wheat condor
#

are there more than 1 mod in your world?

nova flame
#

nope

wheat condor
#

idk then'

prime zenith
#

Someone find and delete this code from reality please ```class Society {
static influencers = ["CloutChaser99", "FakeNews4U", "GuruBro"];
static criticalThinkingEnabled = false;

static main() {
    for (let i = 0; i < 90; i++) {
        let person = new Human();
        person.brain.install(Society.createMindlessScrollApp());
        person.brain.disable("skepticism");
        person.opinion = Internet.TikTok.getRandomMisinformation();
        person.shareWithoutReading();
    }

    console.log("✅ Mission Accomplished: Intelligence Level → Critical Low.");
}

static createMindlessScrollApp() {
    return new App("ScrollHole", 267, "emotional_manipulation");
}

}

class Human {
constructor() {
this.brain = new Brain();
this.opinion = "";
}

shareWithoutReading() {
    console.log("🔥 SHARED: " + this.opinion);
}

}

class Brain {
constructor() {
this.modules = [];
}

install(app) {
    this.modules.push(app.name);
    console.log(`📲 Installed ${app.name}`);
}

disable(functionName) {
    console.log(`🔕 Disabled: ${functionName}`);
}

}

class App {
constructor(name, notificationsPerHour, contentType) {
this.name = name;
this.notificationsPerHour = notificationsPerHour;
this.contentType = contentType;
}
}

// Simulated API
const Internet = {
TikTok: {
getRandomMisinformation: function () {
const junk = [
"The Earth is flat!",
"Vaccines have microchips!",
"You can live off vibes!",
"5G causes telepathy!",
"Bananas cure anxiety!"
];
return junk[Math.floor(Math.random() * junk.length)];
}
}
};

// 💥 Run the simulation
Society.main();```

sly valve
#

Holy shiet

wheat condor
#

what's that 😭

prime zenith
#

The reality code that i assume is why so many stupid ppl exist

wheat condor
#

you spent time doing that?

prime zenith
#

Im bored deppressed and hurt ofc i spent time doing err i mean looking for that code

wheat condor
#

unemplaoyement final boss

#

(im the most unemployed)

prime zenith
#

Ill trade issues

nova flame
#

typing up a storm

prime zenith
wheat condor
#

just stop

prime zenith
#

Its not a story

#

Im so sick of toxic human beings right now

wheat condor
#

yeah but like you re a bit a cloutchaser too

prime zenith
#

Excuse ne

wheat condor
#

yk what cloutchaser means?

prime zenith
#

First off no and second off im just a girl who posts on here

#

Im just irritated right now cause of what happened

wheat condor
gilded shadow
#

whats the difference between property and dynamic property on entities?

wheat condor
#

dynamic properties are variables saved on the entity and properties idk

prime zenith
#

No its just posting cause i have nowhere else to post it

wheat condor
#

off topic?

nova flame
prime zenith
#

Properties are things alreeady stored on the entity

#

Yes it does

distant tulip
# gilded shadow whats the difference between property and dynamic property on entities?

properties are from the entity json file
you can't add properties or remove them and the data need to follow the range the property have
dynamic properties dose not have anything to do with the entity json
you can save dynamic properties to the world or entities or unstackable items
the data type is either number vector3 string or boolean, they are unlimited but each dynamic property can only store 32k bit

prime zenith
#

You cant just keep things to yourself thats how ppl end up dead or worst

prime zenith
wheat condor
prime zenith
#

No it means i want to vent

gilded shadow
prime zenith
distant tulip
prime zenith
#

Unless you set it to be removed on death

gilded shadow
#

i see, thanks

wheat condor
prime zenith
#

I post to vent stop policing every bit of content and this place has already given negative cause 1 of the ppl supporting this girls death was in this channel

distant tulip
#

Maybe use #off-topic ?

wheat condor
prime zenith
#

You mean dead chat topic

wheat condor
#

wtf are you talking about

distant tulip
#

It is more active than here

prime zenith
wheat condor
#

You want others to see

prime zenith
wheat condor
#

Ok

#

love yourself more

distant tulip
#

Anyway...

Was buttonPush event removed in v2? My editor saying it is deprecated

distant tulip
#

The types are wrong?

wary edge
distant tulip
#

I typed
world.afterevents.buttonPush.subscribe

And it is showing subscribe crossword over with a deprecation mark

wary edge
nova flame
open urchin
wary edge
#

It is exactly like PlayerSpawn.

#

Ok we not having any of that.

prime zenith
#

After what he said i just cant with it

nova flame
#

@wary edgeu ever do use numerical item ids?

#

im having a problem nobodys been able to help with so far

distant tulip
gilded shadow
#

they were removed right?

nova flame
nova flame
gilded shadow
#

what are you trying to do?

distant tulip
nova flame
distant tulip
#

do what

lyric kestrel
nova flame
#
const number_of_custom_items = Object.values(custom_content).filter(v => v.type === 'item').length;
const custom_content_keys = new Set(Object.keys(custom_content));```
#

idk if this works or what

#

the code was given to me btw

distant tulip
#

uh... what, what is that supposed to do

nova flame
#

the comment above says

#

Blocks are excluded from the count, as they do not shift vanilla IDs.

distant tulip
#

get all items in game and filter by namespace "minecraft:"

nova flame
#

my friend said the custom items get ignored?

gilded shadow
#

All new custom items (1.16.100, 1.20.80+ format) have increasingly positive IDs, starting from an ID of 261. These WILL SHIFT VANILLA IDs that are higher than 261. For example, 'minecraft:golden_apple' (ID of 263) will be moved up to an ID of 264 if you have one of these custom items.

distant tulip
gilded shadow
#

maybe count all your custom items and increase the aux id accordingly

gilded shadow
#

how many custom items are there?

nova flame
#

12

distant tulip
#

you can follow up this discussion

#

uh!.. sorry forget to remove the ping Leefy

nova flame
#

sorry im very new to bedrock api and coding in general

gilded shadow
distant tulip
#

ItemTypes.getAll().filter(i=>!i.includes("minecraft:")).length

gilded shadow
#

are there any other addons that are adding custom items?

#

also how are you getting aux id of the items in your custom ui

#

youre cooked

#

try looking into the json ui code or where the button is getting added to the form

#

go into auctionHouse.js

distant tulip
#

@nova flame
const ID = ( typeIdToDataId.get(targetTexture) ?? typeIdToID.get(targetTexture)) + items

gilded shadow
#

nvm

#

that is so cursed

#

like its shifting items upto 100 in between there

#

can you console.log(ID)

#

can you post the code here so i can take a look

#

yeah that whole function

#

if its short

nova flame
#
button(slot, itemName, itemDesc, texture, stackSize = 1, durability = 0, enchanted = false) {
        const items = ItemTypes.getAll().filter(i=>!i.id.includes("minecraft:")).length
        const targetTexture = custom_content_keys.has(texture) ? custom_content[texture]?.texture : texture;
        const ID = ( typeIdToDataId.get(targetTexture) ?? typeIdToID.get(targetTexture)) + items
        console.log(ID)
        let buttonRawtext = {
            rawtext: [
                {
                    text: `stack#${String(Math.min(Math.max(stackSize, 1), 99)).padStart(2, '0')}dur#${String(Math.min(Math.max(durability, 0), 99)).padStart(2, '0')}§r`
                }
            ]
        };
        if (typeof itemName === 'string') {
            buttonRawtext.rawtext.push({ text: itemName ? `${itemName}§r` : '§r' });
        }
        else if (typeof itemName === 'object' && itemName.rawtext) {
            buttonRawtext.rawtext.push(...itemName.rawtext, { text: '§r' });
        }
        else return;
        if (Array.isArray(itemDesc) && itemDesc.length > 0) {
            for (const obj of itemDesc) {
                if (typeof obj === 'string') {
                    buttonRawtext.rawtext.push({ text: `\n${obj}` });
                }
                else if (typeof obj === 'object' && obj.rawtext) {
                    buttonRawtext.rawtext.push({ text: `\n` }, ...obj.rawtext);
                }
            }
        }
        this.#buttonArray.splice(Math.max(0, Math.min(slot, this.slotCount - 1)), 1, [
            buttonRawtext,
            ID === undefined ? targetTexture : (ID * 65536) + (enchanted ? 32768 : 0)
        ]);
        return this;
    }```
distant tulip
#

open a post, brb

gilded shadow
#

can you post or tell what the typeIdToDataId function does?

#

are you sure your list typeIdToDataId is correct?

#

also show the typeIdToID

#
const baseID = typeIdToDataId.get(targetTexture) ?? typeIdToID.get(targetTexture);
const ID = baseID === undefined ? undefined : (baseID >= 261 ? baseID + items : baseID);
#

damn i was beat

distant tulip
amber granite
#

Is there a way to change item's texture

distant tulip
#

Nope

inland merlin
#

I was able to get auto selection of item aux id count, im not home to share the code, but might put something in shared scripts or something to show how I was able to get counts of item ids at world load

#

For the chestformdata

#

Get all items (count), remove what starts with minecraft: and then get all block ids, then remove those from the list as well, then get the end count, stick that in the count file dynamically

#

Issue i see is there is alot of ids haha, so might be a small bit of lagg unless done in some sorta spread out chunks/ticks

distant tulip
inland merlin
#

Actually might be better lmao, ill have to compare when I get a chance

#

Yours might be better*

distant tulip
#

alr, lol
let me know when you do so

dusty temple
#

Is there a way to place down a block in the world through a script?

wary edge
dusty temple
wary edge
dusty temple
#
world.beforeEvents.playerBreakBlock.subscribe((ev) => {
  const { block, player: plr } = ev;
  if (plr.getGameMode() === GameMode.creative) return;

  const oldBlockLoc = block.location;
  const oldBlockType = block.type;
  system.runTimeout(() => {
    plr.dimension.setBlockType(oldBlockLoc, oldBlockType);
  }, 2000);
});
#

but it works for everything else other than trees

wary edge
#

Ah I see. In that case what you want to do is getBlock and check if its undefined or try/catch the Exception.

nova flame
#

Anyone any idea why this is crashing FYI it didnt crash before i put the if statement there
also note
world without the behaviour dont crash me but world with it do(any help would be appreciated)

weary umbra
nova flame
#

thanks

#

exactly that lol

#

@weary umbraTY

fallow minnow
dusty temple
#

But I used dynamic properties to account for that so we chilling

#

ty

fast lark
#

Is there a spawner addon like the java one i can buy?

dusky flicker
#

just because of that imma start writing code with js and jsdocs

remote oyster
dusky flicker
fast lark
fervent topaz
#

anyone

#

anyone know how entity load works?

shy leaf
#

has anyone gotten block fluid container component for cauldron working? im testing smth with it and for whatever reason the component returns undefined

#

oh my god i think i know why...

#

nope nevermind

shy leaf
#

no it wasnt that

#

i just got it working as soon as you said it

#

apparently trying to get component via string doesnt work but enums work??

shy leaf
#

minecraft:fluid_container

#

or fluid_container

thorn flicker
#

thats correct

shy leaf
#
const fluidComp = block?.getComponent("minecraft:fluid_container");

this returns undefined

const fluidComp = block?.getComponent(BlockComponentTypes.FluidContainer);

and this doesnt

#

😭

#

like wtf

thorn flicker
#

weird

shy leaf
#

What

#

WHAT

#

oh

#

i was looking at beta version of the api the whole time...

thorn flicker
#

oh

#

me too.

shy leaf
#

well damn you mojang

#

you wasted 17 minutes of my life

thorn flicker
vast grove
#

Looks like they didn't follow the snake case naming convention for internal components or components we couldn't use. Or could we use it before?

dusky flicker
#

is there a way to check code performance? i mean, see which functions are slowing down the code and taking longer to complete

#

preferly inside minecraft, if not possible imma check with quickjs on my pc anyways

#

i really dont mean using console.time

vast grove
#

2 ways.
Use the script api debugger available for vscode ooorrrr
Use a datetime/stopwatch implementation that starts and ends on a function.

dusky flicker
#

and where are some docs for it?

vast grove
dusky flicker
#

no way im going to need to open this atomic bomb called vscode

#

that's life, sadly

halcyon phoenix
#

vscode is fine tho it's not that much bloated

sterile epoch
echo tinsel
#

how do i save properties with smaller names?

dusty temple
#

Is there any way to stringify and parse a function from JSON?

vast grove
#

Errr not really

dusty temple
#

I wanna be able to stringify this data and then run the function in it after parsing it

  plr.setAttributes({ sellMod: 0.5, duration: 15, onExit: (plr) => plr.sendMessage('§l§cSell values have been restored!') });
dusty temple
vast grove
#

You can't stringify logic unless you eval it or something which isn't exactly recommended

dusty temple
#

How come eval isn't recommended?

#

Is it not performant or is there some underlying reason I'm missing

vast grove
#

Usually security reasons I think. I don't think mc has an implementation of eval anyways.

dusty temple
#

Ah okay, thank you

warm mason
warm mason
#

For example

const functions = {
  "test": (player => {
    player.sendMessage('123')
  })
}
plr.setAttributes({ sellMod: 0.5, duration: 15, onExit: "test" });
#

And when you want to execute the function, you take it from the functions object by the saved key

dusty temple
#

Ohhh that is smart, I'll generate a uuid and connect it to a object and run it just like that after I parse it, thank you

dusty temple