#Script API General

1 messages ยท Page 137 of 1

honest spear
#

and requests would be just global constant or something

#

really depends on how you implement it ofc

rich jacinth
#

Ah

#

Got it

#

Massive thank you

#

Oh gosh

remote oyster
#

I used to have a script for batch processing large amounts of blocks when filling in. For stuff like spheres, cubes, pyramids, etc, etc. Using runJob allowed for efficient management to eliminate blocking of other functionality and greatly improving performance. I could probably write it up again honestly but I'm not familiar with the tick manager. So I would have to experiment with that to see what kind of delays it presents, etc. I definitely can't do anything now, as I have an appointment coming up, but I would definitely consider taking advantage of runJob() to handle your tasks if it's large and many, then properly yielding to allow other micro operations between ticks.

rich jacinth
#

Yeah

#

I already use runJob() alot in my current system, but yeh

#

useful ty

remote oyster
#

runJob is great. I love it lol.

honest spear
#

Where are the old good await null days lol

#

but i love it as well

rich jacinth
#

lol

honest spear
#

but it takes only generators right?

#

its not generic for iterators right?

remote oyster
#

runJob is a generator.

honest spear
#

yea i would guess so

honest spear
remote oyster
remote oyster
#

I'm saving that lol

honest spear
honest spear
honest spear
remote oyster
#

Oh I'm certain of that lol

honest spear
#

Somehow its harder to find than i thought

#

I find one!!!

turbid delta
#

What does function* do?

honest spear
#

give me sec

honest spear
honest spear
warm mason
honest spear
#

It does, it did

#

some apis changes since then

warm mason
#

why would yield work like await, but not await

honest spear
#

with yield you have more control, await is handled by engine it self

#

so i had to use yield for lot of stuff before

#

now it would likely work with await as well but only some stuff of it

warm mason
honest spear
honest spear
#

i run the generator and handle the return values and yield parames back to the function based on its value so when it returns number i just wait x ticks and then i ask for next value and so on

#

but its not typescript friendly

#

i would have to rewrite typescript compiler to support that or idk

warm mason
honest spear
# warm mason I get it, but what about events?

when you yield event, then it basicaly checks if it has subscribe and subscribes to it, once callback is fired i pass the value and call next iteration from the event callback + unsubscribe

#

its simplier than it looks like

#

its really basic stuff actually

#

i made that like 3 years ago

honest spear
#

i don't have src sadly

honest spear
#

i love generators in this since

#

the reason i used generators was that i could even handle events that were running multiple times per tick

#

i consider my self as educated in ECMAScript so ask anything, but ofc noone knows everything

lyric kestrel
#

BRO

#

I DIDN'T REALISE TYPESCRIPT HAD INTELLISENSE FOR STUFF LIKE THAT

#

๐Ÿ˜ญ

#

Now I wish I used Typsescript so much sooner

wary edge
#

Bro...

sharp elbow
#

Pretty fantastic, eh?

lyric kestrel
#

Very

sharp elbow
#

How coding will feel to you now

lyric kestrel
#

๐Ÿ˜‚

lyric kestrel
#

Bro

#

It's beautiful bro

distant tulip
#

it isn't ts exclusive
but there is other stuff that is

lyric kestrel
#

Damn

shut citrus
#

What happens if I assign entity hurt before event.cancel = false in the first addon and entity hurt before event.cancel = true in the second one?

earnest meadow
subtle cove
crude glacier
#

Oh. .. you mean showing intellisense inside functions for parameters yeah, for that people use TS in the first place

remote oyster
crude glacier
#

Because the editor knows what type your parameters are

distant tulip
#

it doesn't in some places

#

you need the type or jsdoc

crude glacier
distant tulip
#

you just said js

crude glacier
honest spear
simple zodiac
#

Just wait until you guys find out that the ts and js language server are the same thing

crude glacier
#

No wayyyyyy

#

When i started scripting for the first time i thought I was learning java tbh โ˜ ๏ธ because i thought JavaScript = Java

simple zodiac
#

Car vs Carpet

crude glacier
#

| true |

#

If you ask someone who doesn't know programming what the difference between java and JavaScript he will tell you they are the same programming language ngl

rough elm
#

@simple zodiac

honest spear
#

Do you have anything to say?

crude glacier
#

Nk

warped blaze
#

ohmygod ohmygod ohmygod

Added method registerCustomDimension to allow registrations of new custom dimensions in beta```
lavish surge
#

Pls tell me it's not

warm mason
warped blaze
lavish surge
#

๐Ÿ˜ญ ๐Ÿ™

#

I lived to see this in bedrock.

warped blaze
#

they released entityHurtBeforeEvent and then this, so nice

zinc breach
#

is there a way to use dimension.setBlockType in an unloaded chunk without using a ticking area

zinc breach
# warm mason no

do ticking areas you make with the api show up when you list them in game then

#

and if the max amount is set would it just not work if I try to make one

cyan basin
#

For people who have started messing around with the custom dimensions, does anyone know what's wrong with my command? If I do an itemUse event and teleport the player to the dimension it works just fine but using a command it says that my custom dimension is invalid.

Error: Dimension 'custom:test' is invalid. at <anonymous> (index.js:48)

#

It reaches the success message for teleporting the player, it just fails to transfer now. Originally I was registering the dimension after the command and thought that might have been it but I've since moved the dimension above the command and still the same error applies.

tidal wasp
#

Im trying to store a block permutation within a dynamic property but whenever I parse then unparse it says that its not a Block Permutation

#

When I go to use setPermuatation

tidal wasp
#

Kay

untold magnet
#

what should i use to detect the type of potions inside the cauldron?

warm mason
# tidal wasp

well, BlockPermutation doesn't have toJSON method, so u should do something like permutation.type.id + '|' JSON.stringify(permutation.getAllStates()) and then BlockPermutation.resolve(string.split('|')[0], JSON.parse(string.split('|')[1])) to parse

honest spear
#

Wait isn't path finding just BFS?

warm mason
honest spear
#

Breadth-First Search

warm mason
honest spear
#

doesn't sounds efficient for long distances but might actually work for small ratios

tidal wasp
#

Ok now I need a more efficient way of doing this

wary edge
#

Why use runCommand for actionbar?

#

And what are you trying to do that you're getting SO?

tidal wasp
#

Im trying to floodfill

#

Up to 11x11

#

And im getting stuck at 3x3

wary edge
#

Use runJob.

tidal wasp
#

Put the function inside of runjob whenever I call it?

wary edge
#

Yeah. Or take a look at the editor mode flood function.

tidal wasp
#

Unless I have to call a job within a job

lyric kestrel
#

Using player.onScreenDisplay.setActionBar(Foundry Invalid...\nMissing brick at ${block?.location.x}, ${block?.location.y}, ${block?.location.z}. Found: ${block?.typeId}).
How would I centre the "Foundry Invalid" part?

lyric kestrel
wary edge
lyric kestrel
#

Oh well

tidal wasp
#
function* fillArea(blockFace, radius, replace, x, z, permutation){
                    console.error(x, z)
                    if(border_blocks.includes(e.block.offset({x: x, y: blockFace == Direction.Up ? 1 : -1, z: z}).typeId) || Math.abs(x + (x > 0 ? 1 : -1)) > radius || Math.abs(z + (z > 0 ? 1 : -1)) > radius || e.block.offset({x: x, y: 0, z: z}).typeId == permutation.type.id){
                        console.error('failed')
                        return;
                    }
                    else {
                        //console.error('suceeded')
                        e.block.offset({x: x, y: replace ? 0 : 1, z: z}).setPermutation(permutation)
                        fillArea(blockFace, radius, replace, x + 1, z, permutation)
                        //yield;
                        fillArea(blockFace, radius, replace, x - 1, z, permutation)
                        //yield;
                        fillArea(blockFace, radius, replace, x, z + 1, permutation)
                        //yield;
                        fillArea(blockFace, radius, replace, x, z - 1, permutation)
                        //yield;
                    }
                }
#

why you no work

lyric kestrel
tidal wasp
#

Apparently needed for it to be run jobbable

tidal wasp
#

Now why didnt it stop

#

Why isnt it stopping

lyric kestrel
#

lol

distant tulip
lyric kestrel
#

I see

tidal wasp
#

How do you use clearJob()

lyric kestrel
tidal wasp
wary edge
#

const id = system.runJob

#

system.clearJob(id)

marble spruce
#

(epotrictically) is there a way to "manipulate" the vanilla effects without using the actual effects?

shut citrus
#

is it possible to change features in custom dimensions like gravity, atmosphere, friction?

wary edge
#

No.

shut citrus
#

why?

tidal wasp
#

mf they just released it ๐Ÿ˜ญ

shy leaf
#

we only have access to registering a dimension for now and thats all

naive frost
#

Any docs for the custom dimensions??

crude glacier
#

I never understood generator functions tbh

devout hazel
#

anyone know if you can show only the alias of the custom command in the command prompt in game?

#

at the moment both the alias and the namespaced version show

cold grove
devout hazel
#

wdym you create 2 commands?

cold grove
devout hazel
#

ah were you considering the actual registering

#

i was only hoping to just hide the namespaced version, still regestering it i suppose

#

just to clean it up for my freinds who will use the command

cold grove
devout hazel
#

do you know if theres a way to do that

#

so instead of both /raycast:wand and /wand showing, its just /wand

devout hazel
#

ok dw

#

thanks tho

woven loom
#

Is there a limit to how many ticking areas we can create with api?

crude glacier
#

10 as usual

open urchin
#

if two different ticking areas are ticking the same chunk, that chunk will count as two towards the limit

crude glacier
open urchin
#

These ticking areas are limited by a fixed amount of ticking chunks per pack independent of the command limits.

warm mason
crude glacier
#

Sure ?

subtle cove
#

While entity work_tick isn't limited by quantity, is it?

crude glacier
#

Yep

zinc breach
#

dimension.setBlockType() should work if I do it at a location inside a ticking area right?

#

how come it is still giving me the unloaded chunk error when I put it in one

wary edge
zinc breach
wary edge
#

Use proper methods.

#

Use await or .then

subtle cove
#

system.waitTicks(10)

zinc breach
#

the ticking area does get made before that though

subtle cove
#

Sample code...

wary edge
wary edge
#

Theres a reason its an async function.

subtle cove
#

I meant for when waiting for sth else

#

I usually do

await createTickingArea(id, {dimension,from,to})
wary edge
#

Im so curious why they changed from Promise<TickingArea> to Promise<void>

subtle cove
#

Is it like 99% it resolves that it created it...

cold grove
wary edge
cold grove
#

Is not necesary to return the same object you passed as argument

round bone
round bone
#

The same way REST APIs do return data after POST endpoint

wary edge
#

You're telling me.

await createArea(id);
const area = getArea(id);

Is better than

const area = await createArea(id)
cold grove
#

Well.. i guess it was useful to write all in one line

round bone
round bone
# wary edge Wdym?

The only new thing that you get from obtaining this object from create method is an unique identifier of this ticking area. Rest of it you can calculate basing of the params that you used before to create the same ticking area

wary edge
round bone
#

And BlockBoundingBox you can also resolve with the data that you used lmao

wary edge
#

Also, how are ypu going to get isFullyLoaded without the tickingarea? Exactly.

honest spear
#

i don't know technical details of createTickingArea but it would be easier for everyone if we could just get the ticking are from the promise

wary edge
round bone
round bone
round bone
wary edge
round bone
wary edge
#

Why do you like calculations instead of...letting the game give it to you?

round bone
wary edge
#

The point of the convo was to make things easier.

#

You're the type of person to say, "We can already do world gen in custom dimensions using noisejs, so who cares if Mojang adds or doesnt add feature rules to work"

round bone
#

I don't care about the things that don't extend functionality or make smth faster. It's just about the speed of development. Also, it'd be few lines of code more anyways so who cares atp?

wary edge
#

Person who gets charged by lines of code written.

round bone
wary edge
#

Congrats, you figured out my joke.

#

Doing manual calculations is like the anti thesis of fast development speed.

round bone
wary edge
#

It does yes, why write more lines of code when the previous implementation did not require you to do so.

#

Unless Mojang gives a reason why, it is a decision that makes 0 sense to me.

round bone
wary edge
#

I never said I couldnt. Im inquiring why the decision was made.

#

That was the whole point.

round bone
#

Look to the first message that I've sent. I claim that it's weird, but it does not change that much as you can still achive every single information about new ticking area except it's identifier

wary edge
#

And to which I reply why make us do more work when previous impl did it for us.

round bone
#

๐Ÿคท

wary edge
#

I never said there wasnt an alternative.

lyric kestrel
#

๐Ÿ˜ญ

#

Dw guys. It's not the most useless argument I've seen today ๐Ÿซถ

cold grove
stray spoke
#

custom dimensions with loading screen is so fire. I can't wait for it's future updates

#

its like a multiworld plugin, but it resets every reload I guess

stray spoke
#

So it only needs to register once?

warm mason
stray spoke
#

Like all builds are saved with the dim id, and we just need to define it by registry?

warm mason
#

yeah

#

this is what happened when I removed the registration

#

and if u register it again, all builds in the dimension will stay

stray spoke
#

Thanks for testing it out, that's a good news for me

#

i thought - on the sample code, we need to build platform everytime

lyric kestrel
#

We were testing it a lot yesterday

devout hazel
#

tru

frozen vine
#

Label and divider misalign the toggle in server-ui?

subtle cove
#

they contribute null into the formValues

#

i mean, they contribute 'nothing' type...

round bone
subtle cove
#

v != null to be short

round bone
frozen vine
#

If I remove the label, it starts working as it should again.

round bone
#

I think that you simply have to slice the beginning of an array (result.formValues in this case) and you'll be fine. If you send the code, I can fix it for you ๐Ÿ™‚

frozen vine
frozen vine
frozen vine
subtle cove
#

u might wana try ```js
form.title("%ui.biomes_beyond.mspawn.title.name")

round bone
sharp elbow
#

Put another way: null and undefined may be falsy, but null and undefined are not equivalent with false

frozen vine
subtle cove
frozen vine
subtle cove
#
form.label()
form.toggle()
form.label()
form.dropdown()
form.divider()
form.label()
form.textField()
``````js
const formValues = [
    ,
    boolean,
    ,
    number,
    ,
    ,
    string
]```
subtle cove
#

u can put this fix```js
const formValues = r.formValues.filter(v=> v != null);
playPageTurnSound(player);
// formValues[0] is the Global
const globalValue = formValues[0];

// formValues.slice(1) are the mobs
const individualValues = formValues.slice(1);

frozen vine
subtle cove
#

as for ur current form setup, it only has one null type in formValues

frozen vine
#

I hope the server-ui with ddui comes soon; I'd love to see a mix of buttons with toggle switches, since the current setup requires you to choose between them.

frozen vine
subtle cove
#

thats unfortunate then

devout hazel
#

u

devout hazel
#

M

lyric kestrel
#

TS
Argument of type '"foundries:valid_foundry"' is not assignable to parameter of type 'keyof BlockStateSuperset'
const controllerValidationState = controllerBlock.permutation.getState("foundries:valid_foundry") as boolean;
I'm a bit confused how to make it valid?

#

Do I just do as any?
(which defeats the purpose of types, but idk what else to do ๐Ÿ˜…

devout hazel
#

trururr

#

sry ive got some dumb shortcut that keeps thorwing me into discord chat in gamebar

open urchin
# lyric kestrel TS `Argument of type '"foundries:valid_foundry"' is not assignable to parameter ...

I hate how vanilla data is set up, for some reason BlockStateSuperset isn't an interface which makes it impossible to add custom states to it
ig you could do something like this (can go in any ts file in your project, should update the types across all of them)

import { BlockStateSuperset } from "@minecraft/vanilla-data";

type CustomStateSuperset = BlockStateSuperset & {
  "example:state": string;
};

declare module "@minecraft/server" {
  interface BlockPermutation {
    getState<T extends keyof CustomStateSuperset>(stateName: T): CustomStateSuperset[T] | undefined;
    withState<T extends keyof CustomStateSuperset>(name: T, value: CustomStateSuperset[T]): BlockPermutation;
  }
}

then you can do this

block.permutation.getState("example:state") // string
lyric kestrel
#

Oh, I didn't have vanilla-data installed ๐Ÿ˜…

#

I can do this now
block.permutation.getState("foundries:valid_foundry" as keyof BlockStateSuperset)

#

Lmao

harsh robin
#

is it true that we're getting custom dimensions ๐Ÿค”

naive frost
#

latest preview

harsh robin
# naive frost we got it!

Is it possible to make it when it turns night iron doors cant be powered. and if they were already powered to make them not.

crude glacier
#

what

harsh robin
#

that sucks

covert goblet
#

Evening all, does anybody know if it's would be possible to move somebody from one discord voice channel to another using a script?? I see there are bridge bots but they only seem to relay chat

ocean escarp
#

Do we have a dimension change callback? Specifically before Events?

ocean escarp
#

Well that sucks

#

I guess I can't prevent nether access without a laggy script

stray spoke
#

do we can use playerDimensionChange event on v26.13 Minecraft, or is it only for preview

fickle rapids
#

oh it's system.currentTick ๐Ÿ˜ญ

#

why is day time called absolute time then

unique acorn
simple zodiac
#

"minecraft:dimension_bound"

ocean escarp
simple zodiac
ocean escarp
#

Lock nether and end behind certain events occuring

simple zodiac
#

yeh you can do that with events that add a component group containing that component

#

Although I belive the component locks travel for both dimensions at once

#

with a bit of scripting logic you should still be able get your desired result

ocean escarp
#

I hope so

crude glacier
simple zodiac
#

That doesn't prevent the player from going through the portals

#

yes you can tp them out but that just feels bad

crude glacier
#

Oh hmmm

#

Hmmm

#

Them feel whatever they are getting closer to the portal blocks

#

Detect that

#

And don't let em go in

honest spear
#

sounds easier than it actually is also no one wants to spend all its performance on checking surrounding blocks every tick

stray spoke
#

firgured out 26.13 is just a hotfix, and I need to join beta on playstore

#

to use the minecraft beta or preview, I guess

crude glacier
#

Hmmmm

remote oyster
#

I eventually threw it out ๐Ÿ˜…

#

But that was a few years ago so performance may be better now since we have runJob() but I still wouldn't recommend it.

simple zodiac
#

We also have block volumes. In combination with dimesnion.getBlocks with filters its really efficient

remote oyster
#

Yea, a few options have become available since then. Unfortunately there are a lot of little variables that trip you up which can be difficult to catch and sometimes they still manage to pass through. Which is when that dimension change event would come in handy but you still deal with the loading screen which isn't ideal. So it's personal preference at this point until something more ideal becomes available. Which would be a before event.
-# Soonโ„ข๏ธ

karmic crystal
#

This is probably a simplle fix and im over looking it

what's happenin here?

2026-04-10 15:11:22:237 INFO] Pack Stack - [00] ยงbFeather FPS Boost V3 ยง7[BP] (id: a3c7e8f1-5b24-4d9a-bc61-8f3e7a2d1c04, version: 3.0.0) @ worlds/MCPE - KOB MMORPG/behavior_packs/bFeatherFPSBoostV37BP
[2026-04-10 15:11:22:237 INFO] Pack Stack - [01] MMORPG MCPE CLASSES [BP] (id: eceb0d2f-8743-4867-8b84-bc95fed292c5, version: 11.0.0) @ worlds/MCPE - KOB MMORPG/behavior_packs/MMORPGMCPECLASSESBP/bp
[2026-04-10 15:11:22:311 ERROR] [Blocks] block_definitions | worlds/MCPE - KOB MMORPG/behavior_packs/MMORPGMCPECLASSESBP/bp | blocks/frozen_s.json | Unexpected version for the loaded data

[2026-04-10 15:11:22:311 ERROR] [Blocks] block_definitions | worlds/MCPE - KOB MMORPG/behavior_packs/MMORPGMCPECLASSESBP/bp | blocks/fadingsnow.json | Unexpected version for the loaded data

[2026-04-10 15:11:22:312 ERROR] [Blocks] block_definitions | worlds/MCPE - KOB MMORPG/behavior_packs/MMORPGMCPECLASSESBP/bp | blocks/frozen.json | Unexpected version for the loaded data

warm mason
#

it's a fake error

#

that's not actually an error

karmic crystal
#

TYTY WHAT you think of the werewolf nightverision and blood hour

#

@warm mason

nova flame
#

am i able to check the playercount of a different server using api modules like admin or gametest?

karmic crystal
#

Website or Bedrock?

#

With this code you will need something like this https://realmbot.dev

Realm Bot

Realm Bot is a cutting-edge Minecraft Bedrock Realm management bot designed to revolutionize the way communities operate their servers. Our platform offers a comprehensive suite of features that enable realm owners to streamline operations, enhance moderation, and drive player engagement. With Realm Bot, you can easily manage your players, contr...

#

If your trying to do get Bedrock Edition player count of other servers you will access to a bot of theirs or a addon you made

#

and have them install the addon

#

@nova flame

nova flame
#

i own both servers

karmic crystal
#

@nova flame Let me create you better design for the website and two server status with playercount anything else if your using realm bot?

Player Management

Action Logging

Timed Bans

Realm Management

Member Management

Discord Verification

Vanity URLs

Chat Relay

Member Gate

Bot Detection

Execute Commands

Player Lookup

Leveling System

Tebex Integration

Skin Filtering

Live Playerlist

#

I would do it for commision the website and help you set it up for something

#

@nova flame

#

if your using dev bot

#

Let me show you a better looking website first

nova flame
#

no bro i dont need a website or anything

#

i have 2 bds running on 1 machine

#

one is a queue server

#

and ones the actual server

#

and the queu transfers you when theres free slots

karmic crystal
#

oh this is what I quickly put together for a website anyway

nova flame
#

cool man

karmic crystal
#

@Razz with realmbot do this To run two Bedrock Dedicated Servers (BDS) on one machine with a queue system, you will use different ports and the /transfer command.

#

@nova flame

nova flame
#

i know

karmic crystal
#

I think you might to get two realm bots

nova flame
#

im asking about getting the playercount on the other one

#

bro im not using realms

karmic crystal
#

the things is their no way to do it other wise

nova flame
#

there definatley is

karmic crystal
#

you active player like a bot

#

nope you need a active player on the server typeing the command /transfer with each login

#

that's what realmbot does

nova flame
#

bro omds

#

dont even talk to me

karmic crystal
#

honestly

#

They use real bedrock edition accounts @nova flame

nova flame
#

i know

#

i made a realm bot before

#

but i dont use realms anymore

#

im using bds

karmic crystal
#

i think you still might need it for bedrock edition

#

@nova flame i happen to have a propsal

#

no homo

#

no ring

#

lol

nova flame
#

what bro

karmic crystal
#

@nova flame dming you

cold grove
karmic crystal
#

Is this a actual error?

[2026-04-10 21:00:19:539 ERROR] [Scripting] Unhandled promise rejection: TypeError: cannot read property 'id' of undefined at <anonymous> (zabilities.js)
at map (native)
at <anonymous> (zabilities.js:936)

#

That's just the ability not selecting a target right

#

like it works but misses

round bone
karmic crystal
#

yeh because i have not added the hidden abilitiy

#

im getting the hang of this gui and scripting

#

it's not the best but it something i also got night vision and blood hour done for the werewolf class

#

Oh i know why that line does not work it's got to be in the void to work

#

Yess i am super getting the hang this

#

@round bone if their a lot of that class and they was all doing it around the same time would that spike the ram or cpu from console input for it logging it?

round bone
karmic crystal
#

how would i go about that @round bone

turbid delta
#

Anyone know if invalid permissions for selector expansion has been fixed?

turbid delta
#

Dumb gane

rich jacinth
#

How would I go about spliting up a large area between an x and z cords into chunks (the minecraft kind), pretty mch just how do I split one large area into each of it's chunks inside of it

rich jacinth
# wary edge What are you trying to achieve?

Trying to fill a large area by going chunk by chunk instead of all at once, both so I can split up the ticking area's I need to use more effectively, but also because I think it would run better then just getting large areas and filling them mostly all at once (I am using a runjob but still, probably faster?)

wary edge
rich jacinth
wary edge
#

Yeah, Math.

#

There's like various ways, divide by 16, take the starting coords +=16 in the loop

#

Etc etc

rich jacinth
#

got it

#

Oh also last question, how would you go about checking for when the chunk is done, my first thought was a let but that wouldn't be able to let the code know which chunk actually got loaded, and I think that would be a problem?

#

oop typo

#

Cause I know I'd just unload the ticking area after doing the fill, but would it end up not knowing I filled the area in the first place

wary edge
#
  const dimension = world.getDimension('overworld');
  for (let x = registry_area.start.x; x < registry_area.end.x; x += 16) {
    for (let z = registry_area.start.z; z < registry_area.end.z; z += 16) {
      if (
        !dimension.isChunkLoaded({
          x,
          y: 64,
          z,
        })
      ) {
        log.unloaded_chunks++;
        await loadChunk(new Vector3({ x, y: 64, z }));
      }

      const block_volume = new BlockVolume(
        {
          x: x,
          y: registry_area.start.y,
          z: z,
        },
        {
          x: x + 15,
          y: registry_area.end.y,
          z: z + 15,
        },
      );
      const blocks = dimension.getBlocks(
        block_volume,
        {
          includeTags: ['namespace:feature_flag'],
        },
        true,
      );
      for (const location of blocks.getBlockLocationIterator()) {
        const block = dimension.getBlock(location)!;
        const perm = block.permutation;
        block.setType('minecraft:air');
        // deno-lint-ignore no-await-in-loop
        await system.waitTicks(1);
        block.setPermutation(perm);
      }

      log.chunks++;
    }
  }
import { Vector3, world } from '@minecraft/server';

export async function loadChunk(location: Vector3): Promise<void> {
  const dimension = world.getDimension('overworld');
  if (world.tickingAreaManager.hasTickingArea('namespace:temp')) {
    world.tickingAreaManager.removeTickingArea('namespace:temp');
  }

  await world.tickingAreaManager.createTickingArea('namespace:temp', {
    dimension,
    from: location,
    to: location,
  });
}

This was an OLD code that I wrote to grab certain blocks in a chunk.

#

You can slightly modify it to fulfill your needs.

#

Ideally the area you're filling is chunk aligned.

rich jacinth
#

Tyyy

crude glacier
#

Brochachos can i ask ?

#

Is it possible to do the next things :
Slow time in mcbe,
Do more than one entity interacting button in Minecraft bedrock
Making Red Fog

crude glacier
#

Sad

#

Hmmm , i mean adding new buttons using json UI , and then using scripts to detect whenever they get clicked or something like that ?

warm mason
crude glacier
#

: (

crude glacier
warm mason
crude glacier
#

Oh

#

You mean like they trigger the same script

#

You mean you can't make the script make a difference between each one of them right ?

crude glacier
#

I didn't get it fr

crude glacier
dapper copper
#

how would i damage the enderdragon through scripts?

#

im currently using applyDamage, but the enderdragon takes damage differently and this cancels out the damage

#

i also tried the damage command, as well as instant_damage with effects

round bone
dapper copper
median geyser
#

is there any way to know if an item has just been created? like crafted or grabbed from inventory? I was wondering if I could put some kind of data on all items and if a specific item doesn't have it then I'll assume that it's new.

warm mason
#

but works only if the item max_stack_size is 1

median geyser
#

yeah I'm trying to do this for all items, even vanilla ones

lyric kestrel
#

Yayyy I made my Foundry modular in height

#

So it registers only if it's a height of 1, 2, etc all the way to 10 (the limit)

crude glacier
#

Hmm

weary umbra
#

does someone know what code it was that returned how much ticks does the event take to run?

#

someone send it here before I forgot how

turbid delta
#

You should probably modulo by 16 so you could get the starting cords that are Minecraft's 16x16 chunks, then += 16

turbid delta
remote oyster
weary umbra
#

I'm lazy xD

stray spoke
#

20 ticks is equivalent to 1 second right

subtle cove
#

depends on the world settings

#

but commonly, yes

stray spoke
#

Alright thanks, sometimes ticks changes in random delay when I tested it

subtle cove
#

there's also this

wary edge
#

The TicksPerSecond is always 20, it doesn't change based on the game setting.

subtle cove
#

sike

#

to be accurate, i'd rather use custom tick calculations using Date

drowsy scaffold
#
world.afterEvents.entityItemPickup.subscribe(({entity, items})=>{
    console.log(items instanceof Array)
    for (const item of items){
        console.log(item?.typeId)
    }
})

why is this throwing me an error? types show that items are returned as an array, instanceof check returns true, yet it always throws a value is not iteratable error

honest spear
#

some native arrays might give this error its a bit weird, I agree

#

thats for the snippet I might take a look in to it

lyric kestrel
#

So how would they all get into a single array?

honest spear
#

every instance is unique btw

#

every returned itemstack by engine is new instance in script api

lyric kestrel
#

Yeah, that's why I'm confused why items would be an array

#

Or why it's items and not item

honest spear
#

bc they could pick up more items at the same time

#

??

lyric kestrel
honest spear
#

?

#

idk what you mean

lyric kestrel
#

If I picked up an Apple, that would trigger the entityItemPickUp event.
If I picked up an iron ingot and an apple, that would trigger the event twice, no?

crude glacier
#

Guys is it possible to make a camera focus on an entity nearby

untold garnet
#

im writing a script to prevent friendly mobs to be damaged, is there a simple way to check for friendly mobs?

sage portal
#

Can we control the maximum height of the getTopMostBlock or whatever the method name is? I've been considering using it for spawning entities, but I don't want to try to spawn an entity underground if it's just gonna end up at the top of the mountain it's under.

crude glacier
sage portal
#

what

sage portal
crude glacier
#

Oh right

#

@untold garnet

crude glacier
#

Then you need to use a loop

#

Or check if entity is underground or not

sage portal
#

I'm just looking to spawn an entity on the ground, a loop is excessive

crude glacier
#

What ground you mean

#

You mean cave's ground

#

Underground?

#

I guess you better use json's spawn rules

sage portal
#

the ground relative to the player.
If I were to spawn something while in a house for example, I'd expect it to spawn on the floor and not on the roof.

#

Not talking about natural spawning

crude glacier
#

Oh

#

So what you mean is , if you want to spawn it on the ground it spawns on the top of the house instead of the actual ground

sage portal
#

the way I'm currently doing is using getViewDirection() to grab the location in front of the player, then using a getBlockBelow raycast to get the first solid block from that location to summon an entity.

But the problem is that this method only works with flat environments. Against something like a hill, this results in the entity being summoned in the ground.

crude glacier
#

Hmm understood

#

Then you can do something like if you want the entity to be near the player, then use if statement to check if entity Y is in safe range

#

Because getTopmostBlock() won't help in this situation

#

Ane i guess the only way you have is looping

#

@sage portal

#

But if i understood well what you are trying to achieve, yeah you have no other way

sage portal
#

I'm not really sure where you're going with the looping thing tbh because it's a case of activating the summon once, not a constant interval of it.

I guess the closest example I can use is the evoker. The evoker is capable of summoning evoker fangs even from behind a wall, and if you were to fight an evoker on a hill, the fangs would spawn on the surface of the hill properly rather than having some spawn in midair or some spawn inside the hill.

crude glacier
#

Oh your problem is , the entity doesn't spawn on the surface

#

Correctly

sage portal
#

basically, yeah.
And I considered the getTopMostBlock thing, but I didn't know if that would just make things not work if something was above the player, like if they're in a house or in a cave, or in the nether with the nether roof.

crude glacier
#

Hmm yeah if the place was hollow

#

It will spawn it on the exterior surface

#

Not inside it

sage portal
#

well that's unfortunate

crude glacier
#

But can you tell me what the entity is supposed to do or to be

#

Maybe there is a better way to achieve the same behaviour

sage portal
#

it's not like a living entity or anything, it's simply akin to like placing down a sentry.

#

just look in the general direction, right click, and the entity is summoned on the surface, relative to the player's position

crude glacier
#

Hmmm ok

#

So i recommend using mix of getBlockAbove() and getBlockBelow()

#

Best idea is this @sage portal

#

Use max dimension Y location if you are on the ground

#

And use getBlockBelow()

#

It is suitable to use with hills

#

Get Xand Z where the player is looking at and use it with Y = 320 , and getBlockBelow({ x : yourX , y : 320 , z : yourZ})

#

What do think ?

#

@sage portal did you understand the method?

#

And if player is underground use getBlockAbove()

#

Or mix of both above below for better accuracy

sage portal
#

It sounds like the third option of mixing both is the closest I'll get to accurate spawning.
Man I wish there was a way to look at how Mojang did it for evokers.

crude glacier
#

You can find it in java edition

#

Lol

sage portal
#

I sadly don't mess around with java edition enough to know where to even begin with that.
Or Java itself really.
I need to branch out my coding language skills

crude glacier
#

Hmmm

untold garnet
#

lol

#

oh well it works, for now

summer path
#

can i hav :)

dark urchin
#

what is the thing when the play full loads in to the world cuz im doing title thing

crude glacier
sudden nest
#

Lesgoo custom dimensions!!

i just got back

sly valve
sly valve
subtle cove
sharp elbow
#

I wonder, if it is determining the object to not be iterable, could one check if it is iterable with Symbol.iterator in items?

shut citrus
#

how to make custom npm module and import it to minecraft scripts?

left dragon
#

So, while working on my project, a bot supposedly joined and began spamming crap in the chat. It was something related to "Lumine Proxy". I had to leave immediately as I noticed my frames began to drop, possibly crashing my game.
My question is, is there any way to prevent something like this from happening again? I've looked up the phrase "lumine proxy" in the server and only got two results. One was a scam, the other was the same question as mine.

fair quarry
remote oyster
safe stream
#

is there a way to access the value simulationDistance on Stable?

remote oyster
distant tulip
#

there is no api with that name

torn trail
#

s

sage portal
#

can we detect player directional movement?

meager zenith
#

Is there anyway to take string with white spaces as an argument to custom commands, without using quotes

zinc breach
#

can you use emitters to make custom events or does that not work with addons

remote oyster
meager zenith
remote oyster
round bone
meager zenith
# remote oyster Give a sample code based on your situation.
system.beforeEvents.startup.subscribe(a =>{
    const Sentence = [{ name: "message", type: "String"}];
    const LocalChat = {
        name: "mw:localchat",
        description: "Use this to talk in normal chat when in a group.",
        cheatsRequired: false,
        permissionLevel: 0,
        mandatoryParameters: [...Sentence]
    }
    a.customCommandRegistry.registerCommand(LocalChat,
        (source, ...message) =>{
            console.warn(message.length)
            world.sendMessage(fabricateMessage(message.join(" "),source.sourceEntity,1))
        }
    )
});

fabricateMessage() only performs string manipulation so that shouldn't be a problem

round bone
#

Like if you place ! as a first character in your message, it'll behave the same as with your command

meager zenith
round bone
remote oyster
meager zenith
meager zenith
remote oyster
#

Make sure your function that is manipulating the string isn't returning more than one arg. If it is then you need to adjust how it's manipulating it based on your desire, or handle how you grab the arg in the array more efficiently. Albeit arg[0] or arg[1].

#

An array will contain indexes. Starting from 0.

meager zenith
remote oyster
#

Does it return as string or string[] because that is still important. Makes a difference when calling either arg or arg[0].

meager zenith
# remote oyster Does it return as `string` or `string[]` because that is still important. Makes ...

string
code for reference :

function fabricateMessage(msg,player,local=0)
{ 
    const alias = player.getDynamicProperty("mw:alias");
    const chatCode = player.getDynamicProperty("mw:formatCode");
    const chat_code = (chatCode == undefined)?"":chatCode;
    const alias_name = (alias == undefined)?player.name:((alias == "mw:is_hidden")?"???":alias);
    const group = player.getDynamicProperty("mw:group")
    return `${(group == undefined || local==1)?"":`${chat_code}[ยงr${group}${chat_code}]ยงr`}${chat_code}<ยงr${alias_name}ยงr${chat_code}> ${msg}`; 
}
remote oyster
#

Hmmm... Ok, so your code initially starts with string[]. Like this: message = ["hello", "world", "test"].

Then you message.join(" ") and it becomes a string like this "hello world test"

Your function function fabricateMessage(msg, player, local = 0) returns a string. So everything appears normal. I would inspect and debug that function and be sure everything, line for line, is handled correctly. Have it print everything as it executes synchronously for quality insurance.

meager zenith
# meager zenith ```js system.beforeEvents.startup.subscribe(a =>{ const Sentence = [{ name: ...

I found smth interesting so changing ...message to just message in the customCommandRegistry , allows the command to split string into array of chars

system.beforeEvents.startup.subscribe(a =>{
    const Sentence = [{ name: "message", type: "String"}];
    const LocalChat = {
        name: "mw:localchat",
        description: "Use this to talk in normal chat when in a group.",
        cheatsRequired: false,
        permissionLevel: 0,
        mandatoryParameters: [...Sentence]
    }
    a.customCommandRegistry.registerCommand(LocalChat,
        (source, message) =>{
            console.warn(message.length)
            console.warn(message[0])
            console.warn(message[1])
            world.sendMessage(fabricateMessage(message.join(" "),source.sourceEntity,1))
        }
    )
});

so /localchat hi hi will still throw an error,
BUT
/localchat hi will hi -> [ 'h' , 'i' ]

#

I think the issue is that I cannot use an array of string as a manadoryParameter

#

/localchat hi hi

remote oyster
#

That's plausible. I don't use custom commands personally. I still stick with the old school way of handling command lines.

meager zenith
#

fair

meager zenith
remote oyster
#

You are learning and I'm sure that will be enlightening as you study it further.

meager zenith
#

not the message.join(" ") actually, that throws an error\

subtle cove
#

It's indexable as well message[3]

meager zenith
#

yes

supple perch
#

custom dimensions!!!

#

yo

#

that's so peak

#

i'm so late too ๐Ÿ˜ญ

honest spear
#

zig 0.16 just released!!!!

#

ohh wrong thread sry

left dragon
# remote oyster https://discord.com/channels/523663022053392405/1481643759409168457/148164452381...

See I donโ€™t really wanna disable slash commands, and making custom commands is fine but making one for almost every command? Iโ€™m not doing that.

Iโ€™ve decided Iโ€™ll use the code provided, but expand it for my liking. Itโ€™ll work like this:

  • 3-5 different scoreboards, each with their own randomly generated name.
  • Each scoreboard has an either big or small number attached to that scoreboard.
  • The player must have all of those scoreboards with their number to be able to use slash commands, and they also need operator.
  • If a player lacks at least ONE of these, they canโ€™t use slash commands and have to default to custom commands.
steep hamlet
#

did anyone make a sneak subscriber?

gaunt salmonBOT
cold grove
#

Heeey! Someone know how to check the available API versions for a specific minecraft version?

lean torrent
#

hey i'm getting this error, [Scripting][error]-TypeError: cannot read property 'applyDamage' of undefined at handleEntityHurt (enchant/enchantmentEffects.js:83)
at <anonymous> (enchant/enchantmentEffects.js) from this code, function handleEntityHurt(event) {
const attacker = event.damageSource.damagingEntity;
const victim = event.entity;

if (!attacker || attacker.typeId !== "minecraft:player") return;

const player = attacker;
const inventory = player.getComponent("inventory").container;
const weapon = inventory.getItem(player.selectedSlotIndex);
if (!weapon) return;

const enchantments = readEnchantmentsFromLore(weapon);
if (!enchantments) return;

let bonusDamage = 0;

// --- SHARPNESS ---
if (enchantments.sharpness) {
    bonusDamage += enchantments.sharpness * SHARPNESS_DAMAGE;
}

// --- POWER (projectile only) ---
if (enchantments.power && event.damageSource.cause === "projectile") {
    bonusDamage += enchantments.power * POWER_DAMAGE;
}

if (bonusDamage <= 0) return;

// Apply ONLY the extra damage; vanilla damage still happens
victim.applyDamage(bonusDamage, {
    cause: event.damageSource.cause,
    damagingEntity: attacker
});

} does someone know how to fix this

rich jacinth
wary edge
rich jacinth
wary edge
#

Oh, don't use it. Just replace that with your coords.

rich jacinth
#

Ahhhhh, got it

#

okay thank you :D

#

was already going to, but wanted to make sure it wasn't important

round bone
honest spear
#

yea being victim of PHP is crazy

slim spear
#

has anyone thought of a full proof way to detect if a block doesn't have a block placer item?

#

i tried making an item stack from the block with its id and detecting if the localization keys are the same.. but with custom blocks it seems like they are always different and for vanilla things they are the same ๐Ÿ—ฟ

wary edge
slim spear
#

a use case that i thought of is having different animations on an entity based on if they are holding a block or a block placer item

#

since block placer items are normally a 2d icon and not a full block

late ore
#

ยฟthere's any script that makes that an entity move towards the current front direction like this thunder?

rain phoenix
#

can anyone help me?? I have a problem where when using beforeEvents.itemUse it actually works with my function, but other items like bundle cause errors.

#

like this that i can use bundle in vanilla

#

import * as mc from "@minecraft/server";

mc.world.beforeEvents.itemUse.subscribe((eventData) => {
const { itemStack , source: player} = eventData;
const isBlocked = (itemStack.typeId === "test:magic_bundle")
if (isBlocked){
eventData.cancel = true;
mc.system.run(() => {
let score = itemStack.getComponent("test:abc").customComponentParameters.params.value
player.sendMessage(score)
})
}
});

late ore
cold grove
#

I was looking at the examples of the documentation and theyre outdated ๐Ÿค” were we have to report it?

cold grove
sage portal
#

I'm gonna mess with the hunger component sometime in the near future, but I'm curious to know now; is the hunger value a float number like health value, or is it just an integer number?

sage portal
#

That's perfect, thanks

crude glacier
#

._.

crude glacier
crude glacier
#

Damn

sudden nest
weary umbra
#

is there a camerashake method?

wary edge
tidal wasp
#

This thing tends to just shit itself after a couple tries for some reason, saying it failed to place with permutation laser

#

that and the function not resetting at all unless I do clearjob

cinder shadow
#

uhhhhh waddafak

tidal wasp
#

okay so apparently its not returning the actual values its supposed to return

#

its just returning int

#

idfk how

cinder shadow
#

I don't understand this at all

tidal wasp
#

ok so basically what I am trying to do is find out when i place a the block and look for how many other of the same block is behind it and wheather it is a multiple of 256, 128, 64, 32, 16, 8, 4, or 2

#

and setting its state to that

#

the part after the permutationToPlace bit is fine

#

probably should've omitted that

cinder shadow
#

where is it getting stuck?

tidal wasp
#

When I try to set the permutation being placed

#

The function isn't returning any of the values it's supposed to return

#

Instead it's just incrementing by one every time I place the block

cinder shadow
#

Well I'm not sure what exactly this is trying to do

tidal wasp
#

And then failing unless I've placed 1, 2, 4, 8, 16, 32, 64, 128, 256 of the blocks

tidal wasp
cinder shadow
#

You're trying to use these as thresholds?

sharp elbow
#

What is the block state "cmd:laser" defined as? You are setting it to the value of the handler for a job; this is a rather opaque value that should not be interpreted in any meaningful way like this, and I highly doubt you've intended to use it for a block state value

cinder shadow
#

aren't block states also still very limited? you can only have 16 different states

tidal wasp
#

The block states are 1, 2, 4, 8, 16, 32, 64, 128, and 256

cinder shadow
tidal wasp
#

So really there's only 9 states

cinder shadow
#

should probably just give it a "default" and just do an else return 1 instead

#

then see where where the logic is breaking

#

anything % 1 is 0

tidal wasp
tidal wasp
tidal wasp
#

I might just try to put it into a for loop

cinder shadow
#

It just visually looks very weird to me, I don't think I would ever handle counting the length of blocks in a row like this

#

I'm probably missing something

tidal wasp
sharp elbow
#

I'm trying to think of ways to fix this without entirely rewriting it

tidal wasp
#

I do have a version of script that does work

#

But it takes increasingly long the farther out you go

#

And uses setPermutation instead of setting the permutation to be placed

wary edge
#

Whats the issue?

cinder shadow
#

I can't read

sharp elbow
#

So this laser block has a block state, 'cmd:laser', which should be equal to whatever multiple of a power of 2 you defined. Is it looking for another block of its ID that is facing the same way? And should this be assigned the instant you place this laser block?

tidal wasp
#

I think I'm going to try if I can use a for loop in a generator function

sharp elbow
#

Let's talk code; does this look like something you were trying to implement?

  • Given its "minecraft:block_face", pick the opposite direction.
  • Look for blocks at powers of 2 in this opposite direction for another laser block facing the same way, acquiring its distance if it matches, defaulting to 1
  • Assign this distance to the state "cmd:laser"
  • Set the block behind this block's state "cmd:capped" to false
sharp elbow
#

Plus generator + job semantics are unwieldy

#

I hope you don't mind me using bit shifting, it made writing a while-loop for this rather straightforward

tidal wasp
#

I do not understand bit shifting in the slightest ๐Ÿ˜ญ

cinder shadow
#

what the helly do you guys do

#

Here is what I did ๐Ÿ˜ญ

const permutationToPlace = e.permutationToPlace;
            const block = e.block;
            const blockId = permutationToPlace.type.id;
            const face = permutationToPlace.getState('minecraft:block_face');
            let checkDirection;
            switch(face){
                case 'west':
                checkDirection = {x: 1, y: 0, z: 0}
                break;
                case 'east':
                checkDirection = {x: -1, y: 0, z: 0}
                break;
                case 'north':
                checkDirection = {x: 0, y: 0, z: 1}
                break;
                case 'south':
                checkDirection = {x: 0, y: 0, z: -1}
                break;
                case 'down':
                checkDirection = {x: 0, y: 1, z: 0}
                break;
                case 'up':
                checkDirection = {x: 0, y: -1, z: 0}
                break;
                default:
                checkDirection = {x: 0, y: 0, z: 0}
                break;        
            }
            let count = 0;
            for(let i = 1; i <= 256; i++) {
                const nextBlock = block.offset({
                    x: checkDirection.x * i,
                    y: checkDirection.y * i,
                    z: checkDirection.z * i
                });
                
                if(nextBlock.typeId !== blockId || nextBlock.permutation.getState("minecraft:block_face") !== face) {
                    break;
                }
                count++; 
            }

            if(count % 256 == 0) count = 256
            else if(count % 128 == 0) count = 128
            else if(count % 64 == 0)  count = 64
            else if(count % 32 == 0) count = 32
            else if(count % 16 == 0) count = 16
            else if(count % 8 == 0) count = 8
            else if(count % 4 == 0) count = 4
            else if(count % 2 == 0) count = 2
            else if(count % 1 == 0) count = 1```
sharp elbow
#

Bit shifting (left and right) is a convenient way to represent powers of 2 when writing out code. It takes a numerical value in binary, then "shifts" its values either left or right.

// 2^1
> (1 << 1)
2
> (1 << 1).toString(2)
'10'

// 2^2
> (1 << 2)
4
> (1 << 2).toString(2)
'100'

// 2^3
> (1 << 3)
8
> (1 << 3).toString(2)
'1000'

// 2^4
> (1 << 4)
16
> (1 << 4).toString(2)
'10000'
#

So in the while-loop I wrote, we're starting at 256 (1 << 8), then we're shifting the bit down by one on each iteration, going to 128, 64, 32, 16, 8, 4, 2, and ending at 1

tidal wasp
#

I see

sharp elbow
tidal wasp
#

I'm looking for that

#

Like as you place the blocks down they should start to look like a rule

#

Well at least an imperial ruler

remote oyster
#
const permutationToPlace = e.permutationToPlace;
const block = e.block;

const blockId = permutationToPlace.type.id;
const face = permutationToPlace.getState('minecraft:block_face');

// O(1) lookup instead of switch statement
const directions = {
    west:  { x: 1,  y: 0,  z: 0 },
    east:  { x: -1, y: 0,  z: 0 },
    north: { x: 0,  y: 0,  z: 1 },
    south: { x: 0,  y: 0,  z: -1 },
    down:  { x: 0,  y: 1,  z: 0 },
    up:    { x: 0,  y: -1, z: 0 }
};

const dir = directions[face];
if (!dir) return;

// Start from current position (avoids object creation in loop)
let x = block.x;
let y = block.y;
let z = block.z;

let count = 0;

// Linear scan up to a hard cap (256 โ†’ effectively constant time O(1))
for (let i = 1; i <= 256; i++) {
    x += dir.x;
    y += dir.y;
    z += dir.z;

    const nextBlock = block.dimension.getBlock({ x, y, z });

    // Stop when block type or orientation changes
    if (
        nextBlock.typeId !== blockId ||
        nextBlock.permutation.getState("minecraft:block_face") !== face
    ) break;

    count++;
}

// Convert count to nearest lower power of 2 (O(1) math instead of branching chain)
count = Math.max(1, 1 << Math.floor(Math.log2(count)));
cinder shadow
tidal wasp
#

What if there is a gap

cinder shadow
#

not a very good laser then

sharp elbow
#

Think VisualImpact struck the nail here

cinder shadow
#

wtf! he STOLE both of our versions and combined them!

remote oyster
sharp elbow
#

Although should the loop stop when it doesn't find another laser block immediately? Or should it continue searching until it reaches one?

#

I assumed this was traversing something like air until it found another laser facing the same way

cinder shadow
#

Based on what Rem said, it should just keep going?

#

I thought it was all just supposed to be one connected line then stop as soon as it didn't find anything

sharp elbow
#

Easy enough to account for, simply reverse the logic of the if condition within the loop.
if (nextBlock.typeId === blockId && nextBlock.permutation.getState('minecraft:block_face') === face) break;

#

Great usage of floor(log2(count)) by the way, I was about to propose that

tidal wasp
#

Also is there any way to figure out the world simulation distance other than trial and error

sharp elbow
#

๐Ÿคท I was not able to work out a better solution than that

tidal wasp
#

bao_ext_toldyouso try catch it is

sharp elbow
#

You have some other options; check if the chunk is loaded, or use API calls that don't error when accessing unloaded chunks first and check if they returned anything meaningful

cinder shadow
#

create ticking areas along the entire predicted length of the laser

#

you no longer care ๐Ÿ—ฟ

#

Nothing bad will happen trust me

tidal wasp
#

๐Ÿ˜ญ

tidal wasp
#

so it doesnt work

#

but it doesnt work in a way I can work with

cold grove
#

Meow

night oracle
#

The if/else statements with 256 is using binary.

#

Binary 11111111 is = to 256

warm mason
night oracle
#

11111111 is actually 255, my bad

#

@cinder shadow

#

My attitude towards you = love @warm mason

warm mason
#

๐Ÿฟ ๐Ÿ‘€

night oracle
#

Crazy that you know binary @warm mason

#

Or how to utilize it in js

#

Who can answer what the binary for 2

warm mason
rich jacinth
#

Hey sorry for the days later re-ask but what is "ChunksToFillRequest[]" meant to be? Is it meant to be an array? I've got my code working thanks to this but this part has bothered me as I never ended up using this exact system, just something like it, so never figured it out

night oracle
#

I see [] so Iโ€™d say yes

#

Chunks is also plural

rich jacinth
#

yeah

#

you're probably right

night oracle
#

It could be an array of objects

#

[{x1: 35, x2: 55}, โ€ฆ]

#

An example of an object in an array

rich jacinth
#

Ohhhhh

#

yeah

warm mason
rich jacinth
#

Devils nightmare and you are for sure right, no clue why I didn't click that before hand ๐Ÿ˜ญ

#

oh?

night oracle
#

I edited it

#

Im not saying the methods inside the object are right but [{}, {}] is an array of 2 empty objects

rich jacinth
#

yeah

#

Thank you :D

cinder shadow
night oracle
#

@tidal wasp for you lol

tidal wasp
night oracle
tidal wasp
#

Also why doesn't x^y work

#

Shits a scam

night oracle
#

Just put num.toString(2) to get the value i think you wanted to return.@tidal wasp credit:@serty.name

#

1 will return 00000001
3 will return 00000011
7 will return 00000111

#

A bit holds a value 0-255

#

@tidal wasp

tidal wasp
#

Sir I have found my solution ๐Ÿ˜ญ

#

Also is that because there are 8 1,0 pairs

night oracle
#

Yes

tidal wasp
#

And 0 counts as a number

night oracle
#

0 = 0000000 and 255 = 11111111

#

@tidal wasp

#

Each number counts exponentially

tidal wasp
#

Could you not please

#

Im trying to edit something rn

night oracle
#

Yea

late ore
#

ยฟand thereยดs a script component for entities with properties?

random flint
random flint
late ore
#

i recently downloaded Bedrock Debugger. and i don't know how to make it work into the minecraft Bedrock files

#

The files folders are made here

cold grove
late ore
#

It seems I'll never be able to script

#

for everyone is easy

cold grove
cold grove
late ore
knotty plaza
#

Is it possible to place a chest with a custom name?

#

Like, I can rename a chest in an anvil and it will have that name in the container

#

Is that possible with scripting?

random flint
knotty plaza
random flint
#

Powder Snow, Water/Lava bucket, Shulkerboxes, and various things... can be dispensed by dispenser

shy leaf
#

i have discovered a horror

#

canceling damage doesnt cancel mob aggression

#

mob effects inflicted by attacking also dont cancel

nova flame
#

well ofc

#

its only cancelling damage

#

doesnt cancel kb either

#

damage sensors are just the way to go

#

unless ur damage logic is complex

shy leaf
#

oh my damage logic is beyond terror, trust me

shy leaf
nova flame
#

doesnt

shy leaf
#

what

#

entityHurt

nova flame
#

yes

#

cancelling enitytHurt

shy leaf
#

does cancel knockback

nova flame
#

doesnt stop knockbaxk

shy leaf
#

it was fixed a few versions ago

nova flame
#

rlly

#

dang

shy leaf
nova flame
#

@shy leafu adding to sweep n slash

shy leaf
#

just exploring stuff

nova flame
stray spoke
#

/lc hi hi makes it two parameters string and string even tho the required params is only one string, but /lc "hi hi" acts only as one string

meager zenith
stray spoke
#

Spread operator is good choice too

#

(source, ...messages)

meager zenith
stray spoke
#

You can't fix that actually, because the amount of parameters is fixed based on your command options

#

If your mandatoryParameters + optionalParameters only have 2 parameters for example, it only accepts 2

meager zenith
#

I am mostly gonna use chatSend with smth like !lc as command prefix, since I am already using chatSend for other things in the addons

stray spoke
#

That's still beta tho

meager zenith
#

I know but you can set the version as "beta" Instead of specifying the number as in "v2.7.0-beta" and it'll default to whatever the beta version is

#

So no need to update it for every Minecraft upsa

#

Update*

#

Granted you do have to turn on beta apis

stray spoke
#

Yeah, in my experience, most addon users don't follow a note to turn on beta-api option first and complain the addon doesn't work

#

It's kinda hassle too

remote oyster
stray spoke
#

Yeah even when I put it in there

#

Lol

zinc breach
#

so you do /localchat hi_hi

meager zenith
zinc breach
#

only real solution honestly

meager zenith
#

I meann I can do it the old way too with chatSend and !lc prefix

zinc breach
#

sure but you wanted custom commands and no beta api no?

meager zenith
zinc breach
#

yea thats alright then

meager zenith
remote oyster
meager zenith
#

yep totally agree

zinc breach
remote oyster
# zinc breach I don't understand tho why is chatSend in the beta api and not stable? I thought...

Don't know if it's still the case now, but a long while back, couple of years at least, maybe longer, I used it to implement end-to-end encryption. In doing so people were having their accounts suspended or soft banned from Microsoft. Turned out Mojang was monitoring every message being sent, which I didn't personally know at the time. This led to some serious issues which I reported to the devs. Next thing I know, they stuck to it being beta, and a lot of the functions and properties were made to be read only. Been that way since. But like I said, I don't know if that is still the main reason as of today or not.

#

If you look, you can find where I reported it. I believe it was in the Bedrock OSS server though. Been a while lol.

stray spoke
#

How did it even be sent to mojang

#

That's a crazy secret

remote oyster
#

They listen to the traffic by default. It was new to me when I learned about it lol.

cold grove
drifting ravenBOT
#
"Unknown" in inventories

You can make an entity with named inventory this way:
Summon entity via command: /summon furniture:fridge_upper_container tile.furniture:fridge_upper.name ~~~ then put tile.furniture:fridge_upper.name=Freezer in the lang file

crude glacier
#

Is there another way to put rotation too

round bone
crude glacier
#

@distant tulip is it possible to change entities inventory from unknown to something else using script api ?

crude glacier
#

Only ?

#

Hmmm what if i don't want the name tag to get shown

distant tulip
#

lang files+ nametag

weary umbra
#

why tf does the explosion beforeEvent not returning getImpactedBlocks It only give dim, cancel, source, and setImpactedBlocks which it doesnt make any sense

wary edge
weary umbra
#

[Scripting][error]-ReferenceError: Native function [ExplosionAfterEvent::getImpactedBlocks] object bound to prototype does not exist. at <anonymous> (events.js:75)

#

BRUHHHHHHH

#

let { source, getImpactedBlocks } = data

#

thats why lol

wary edge
#

Thats why destructuring is bad.

open urchin
#

You can't destructure methods

nova flame
#

hi guys

#

my pvp server

#

has a problem

#

where players fps drop over time

#

leaving and rejoining fixes it?

#

possible causes?

night oracle
#

It seems to be a problem with a for loop on the player. @nova flame

#

Maybe a function on the player isnโ€™t being canceled before rerunning the function, causing another loop and lag.

#


Anyone want to co-op gamble on baccarat with me in my world? Microsoft:

#

Bob8492710

tidal wasp
#

Has anyone made a keypad device or lock and key that uses dynamic properties to lock something

#

Because that just feels underexplored imo

wary edge
#

A lock and key is quite simple.

warm mason
tidal wasp
#

Man dynamic properties would so cool if you could attach them to blocks

warm mason
#

well, I don't see any problems with it

warm mason
tidal wasp
#

The bullshit id be pulling dould be unheard of

warm mason
tidal wasp
distant tulip
tidal wasp
warm mason
distant tulip
#

-# me rushing to add dimension id to a submitted project that used only block location as key after reading the chat

buoyant canopy
#

always add the dimension id you your location hashes it it's not exclusive to i single dimension

#

or a an integer representing it if you need to store a lot of hashes in a dynamic property and you are worried about hitting the size limit

distant tulip
#

I had the system built from the start for testing and totally forgot about the id afterword

buoyant canopy
#

which system?

rich jacinth
#

Is getentities laggy at all when done multiple times one after the other? I'm making a shockwave effect and I need to getentities when my particle reaches them, which leads me to my second question, is there any good way to line those up, the particle and script as in, in terms of timing

shy leaf
#

also for particle, i doubt it since those are client sided

#

your best bet is to use entities with particles

rich jacinth
rich jacinth
#

what would be a case where it would lag if you can think of any examples?

shy leaf
#

functions that are generally heavyweight in client/server, imagine every entities in your simulation distance making particles

#

on every tick

rich jacinth
#

I see

#

Well I'm fine there then, all I need to do is shake any players arounds screens and knockback the entities

rich jacinth
#

Because I'm mostly a scripting person, I am very bad at the more json side of things ;w;

shy leaf
rich jacinth
zinc breach
#

is there a way to track the output item of a specific block in a playerInteractWithBlock event

#

so the item someone crafts in a crafting table for example

#

or the armor someone adds a trim to

stray spoke
#

Can we detect if the player clicked jump button

#

To make double jump

zinc breach
#

I think that is the only way to do it

#

not sure though

stray spoke
#

Alright thanks

stray spoke
#

Right timing, im also on that page

#

Thanks

#

Nvm it's different

#

I thought its getButtonState

shy leaf
#

you must be in Player.inputInfo

#

that one is for getting which button the player is pressing

shy leaf
stray spoke
#

Okay I get it now

#

Thank you

#

newButtonState is just to detect if its pressed or released

shy leaf
#

you can change buttonstate with whatever you want

#

omitting it will fire on both press and release

stray spoke
#

I think you got syntax error

shy leaf
#

maybe

#

im on phone so i cant really see lol

stray spoke
#

subscribe({player})=>{})

#

But I understand

#

Thanks again

shy leaf
#

whoops

#

yeah i fixed it

stray spoke
#

Nice

#

Thanks

misty dagger
#

When you use block.setType() or block.setPermutation(), how would one make this trigger a block update?

#

Looks like just setting it to air first and then the target permutation works fine.

stray spoke
#

Is there also detection for movements

#

I mean the direction of movement we used

#

Up, down, left, right

remote oyster
# stray spoke Is there also detection for movements
import { system, world } from "@minecraft/server";

system.runInterval(() => {
  for (const player of world.getAllPlayers()) {
    const vel = player.getVelocity();

    if (Math.abs(vel.x) > Math.abs(vel.z)) {
      if (vel.x > 0) {
        console.warn("Moving East");
      } else {
        console.warn("Moving West");
      }
    } else {
      if (vel.z > 0) {
        console.warn("Moving South");
      } else {
        console.warn("Moving North");
      }
    }
  }
}, 1);
stray spoke
#

So there's no other way? Like an event or input

remote oyster
#

Nope

#

Can also use player.location as well to determine directions.

stray spoke
#

Damn, but this workaround helpful a lot

#

Thanks

remote oyster
#

Another one you can try:

function getRelativeDirection(player) {
  const vel = player.getVelocity();
  const rot = player.getRotation(); // yaw

  // Convert yaw to forward vector
  const yawRad = (rot.y * Math.PI) / 180;

  const forward = {
    x: -Math.sin(yawRad),
    z: Math.cos(yawRad),
  };

  // Dot product (forward/backward)
  const dot =
    vel.x * forward.x +
    vel.z * forward.z;

  // Perpendicular (left/right)
  const right = {
    x: forward.z,
    z: -forward.x,
  };

  const side =
    vel.x * right.x +
    vel.z * right.z;

  if (Math.abs(dot) > Math.abs(side)) {
    return dot > 0 ? "forward" : "backward";
  } else {
    return side > 0 ? "right" : "left";
  }
}
stray spoke