#Script API General

1 messages · Page 70 of 1

untold magnet
#

ya

shy leaf
#

its the classic velocity fuckery

sterile epoch
#

ah

#

gotcha

shy leaf
#

you can try wrapping it with runTimeout or run

#

and hope that it gives you a good result

sterile epoch
#

alr

untold magnet
#

wait, will it be changed? like updated or something?

shy leaf
untold magnet
#

so they have removed the horizontal strength thing from it, kinda

shy leaf
#

for example, this will change to

entity.applyKnockback({ x:0 * 0.16, z: -0.03 * 0.16 }, 0);
untold magnet
#

rn it's just (Vector2, verticalStrength, diagonalStrengthSomething)

shy leaf
#

stable applyKnockback takes first two as direction and third one as strength

untold magnet
shy leaf
#

yeah its better to use too

untold magnet
#

btw,

untold magnet
#

or it would be a bit too OP

shy leaf
#

whats the death certificate item

untold magnet
shy leaf
#

hmm

#

whats the item for, anyway?

untold magnet
shy leaf
#

just that?

untold magnet
#

kinda

shy leaf
#

then yeah, dont add the location

untold magnet
#

it returns [object] [OBJECT] thing

#

or it shows the atoms of the location, ( x: 402.17362815286481618, y: 63, z: 1174.15181653718175168 )

#

it might be bugged when u die on the void, so I'll just dont add it.

shy leaf
untold magnet
slim spear
#

would return something like 402.1

shy leaf
#

or .toFixed(0) works too

#

it shits itself sometimes though but its an issue with programming in general

untold magnet
#

mhm

untold magnet
rapid nimbus
#

Hey guys, I have this script:

#
import { BiomeTypes, system, world } from "@minecraft/server";
import { Vector3Utils } from "@minecraft/math";
import { biomeTranslations } from "./biome_translations.js";

/**
 * Lấy tiêu đề của biome theo ngôn ngữ
 */
function getBiomeTitle(biome, lang) {
    return biomeTranslations[lang]?.[biome] || biomeTranslations["en_US"]?.[biome] || biome;
}

/**
 * Lấy tiêu đề của chiều không gian
 */
function getDimensionTitle(dimension) {
    const dimensionTitles = {
        "minecraft:overworld": "Overworld",
        "minecraft:nether": "§4The Nether",
        "minecraft:the_end": "§9The End"
    };
    return dimensionTitles[dimension] || dimension;
}

/**
 * Lấy biome tại vị trí cụ thể trong chiều không gian
 */
function getBiome(location, dimension) {
    const biomeTypes = BiomeTypes.getAll();
    const searchOptions = { boundingSize: { x: 64, y: 64, z: 64 } };
    let closestBiome;

    for (const biome of biomeTypes) {
        const biomeLocation = dimension.findClosestBiome(location, biome, searchOptions);
        if (biomeLocation) {
            const distance = Vector3Utils.distance(biomeLocation, location);
            if (!closestBiome || distance < closestBiome.distance) {
                closestBiome = { biome, distance };
            }
        }
    }

    if (!closestBiome) {
        throw new Error(`Could not find any biome within given location`);
    }

    return closestBiome.biome;
}

// Cập nhật tiêu đề biome và chiều không gian cho người chơi
system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        let location = player.location;
        let dimension = player.dimension;
        let biome = getBiome(location, dimension);
        let lang = player.getDynamicProperty("language") || "en_US";

        let biomeTitle = getBiomeTitle(biome.id, lang);
        let dimensionTitle = getDimensionTitle(dimension.id);
        let finalTitle = `${dimensionTitle} - ${biomeTitle}`;

        player.onScreenDisplay.setTitle(finalTitle);
    }
}, 60);
#

Along with the text in the logs:

#
14:37:12[Scripting][verbose]-Plugin Discovered [Traveler's Titles Bedrock] PackId [b1c22a08-3e7d-4a6e-b52b-123456789abc_1.0.0] ModuleId [d2a33b14-6c8f-4d93-8a47-987654321def]

14:37:12[Scripting][error]-Plugin [Traveler's Titles Bedrock - 1.0.0] - failed to create context.

14:37:12[Scripting][error]-Plugin [Traveler's Titles Bedrock] - module [Traveler's Titles Bedrock - 1.0.0] depends on unknown module [@minecraft/math - 1.0.0].

14:37:12[Scripting][error]-Plugin [Traveler's Titles Bedrock] - version conflict for module [@minecraft/server].
 [1.18.0] requested by [Traveler's Titles Bedrock - 1.0.0],
 [2.0.0-beta] requested by [Traveler's Titles Bedrock - 1.0.0]


14:37:12[Scripting][error]-Plugin [Traveler's Titles Bedrock - 1.0.0] - run failed, no runtime or context available.

shy leaf
rapid nimbus
shy leaf
shy leaf
#

you can import that file instead of module

rapid nimbus
shy leaf
#

just make sure its inside scripts folder

prisma shard
shy leaf
dim tusk
#

Uhh what?

stark kestrel
#

unbreakable vanilla items?

untold magnet
#

uh,
let deathCounter = entity?.getDynamicProperty('deathCounter');
entity?.setDynamicProperty('deathCounter', deathCounter+1);
isn't working

unique acorn
untold magnet
unique acorn
#

try doing console.log(ntity?.getDynamicProperty('deathCounter')) to check

unique acorn
#

u can do that

untold magnet
prisma shard
#

idk why people use Math.floor() for turning float into integer
but Math.round() is better to me

prisma shard
#

lmao

wary edge
shy leaf
#

yeah it depends on use case

#

sometimes youd need round, sometimes floor, sometimes ceil

untold magnet
gaunt flare
#

Like 10:59 is still 10 not 11

prisma shard
#
let counter;
world.afterEvents.entityDie((e) => {
    if (e.deadEntity instanceof Player) {
        counter++
    }
})```
#

@untold magnet

#

ig

shy leaf
untold magnet
untold magnet
shy leaf
#

also that too

prisma shard
prisma shard
untold magnet
untold magnet
prisma shard
#

kk

untold magnet
# prisma shard kk

like so:

world.afterEvents.entityDie.subscribe(({deadEntity: entity, damageSource: source}) => {
  if (entity?.typeId !== 'minecraft:player') return;// Detects only players after they die.
  let deathCounter = entity?.getDynamicProperty('deathCounter') ?? 0;// Used to increase the death counter values.
  entity?.setDynamicProperty('deathTrigger', true);// Needed to spawn the Death-Certificate item.
  entity?.setDynamicProperty('entityName', entity?.nameTag);// Getting the dead player name.
  entity?.setDynamicProperty('sourceId', source?.damagingEntity?.typeId);// Getting the killer ID.
  entity?.setDynamicProperty('cause', source?.cause);// Getting the damage type.
  entity?.setDynamicProperty('dim', entity?.dimension?.id);// Getting the dimension id.
  entity?.setDynamicProperty('deathCounter', deathCounter+1);// Will increase the death counter by 1.
  entity?.setDynamicProperty('rDate', date.toLocaleString());// Getting the Death Date.
});;```
prisma shard
#

alright alright

unique acorn
untold magnet
unique acorn
untold magnet
sharp elbow
#

That's actually an interesting question. If an entity is invalid, does Entity.getDynamicProperty throw?

#

If so, then there's no advantage (or disadvantage) to using a property, other than the space as Cennac says

#

I would be tempted to use a world dynamic property for that instead. Store it in a Map that's saved to disk on world close, based on the player's ID (which is always valid until they disconnect)

unique acorn
#

I think

#

but since the dynamic property in his code is set to a player, that shouldn't be an issue?

sharp elbow
#

Not undefined—just in the case of isValid == false

shut citrus
sharp elbow
#

That's neat ... but also in Java Edition?

shut citrus
#

it's java

wary edge
oak lynx
#

update on saving areas of blocks

#

I got an idea to get an express.js app running pulling mcstructure files that are saved by the api but turns out you can't save to .mcstructure with scripts

#

useless

prisma shard
# shut citrus
  • This is a "bedrock addons" server
  • maybe #off-topic would suit you
  • This is the Script API discussion channel
oak lynx
#

so like uhh anyone has any ideas on how to save a region of blocks

past blaze
oak lynx
#

do you have it somewhere

#

cuz I spent the past 2 weeks trying to figure something out

#

🤯🤯

past blaze
#

I do, but I'm not sure if it will be useful to you. It's in the form of a Godot project, and also, It's been so long since I worked on it, I can't even build it properly again.

oak lynx
#

Godot project what

past blaze
#

Yep. I made an app with a game engine

oak lynx
#

uhh is there any info anywhere on how to read the world database file(s)?

past blaze
#

It's kinda tricky. The only way to read it is with a C++ leveldb library. Any libraries you see in other languages use this library internally

oak lynx
#

Google leveldb?

past blaze
#

Yeah. Although I think Mojang has their own fork of it as well

oak lynx
#

hmm so I could try using something like this

oak lynx
past blaze
oak lynx
#

I will try doing something

#

but why can't we have a normal way to get blocks 😭😭

past blaze
#

Good morning @quaint birch (or good afternoon). I was wondering if there's a target date for when scripting v2 will release. I'm asking because I'm thinking of releasing WorldEdit 1.0 at the same as that becomes stable.

wary edge
digital trout
#

Is there a way to run scripts client side?

sharp elbow
# wary edge

This was really upsetting. It's inconsistent with entityHurt—and the JSDoc comments don't signify this

#

Certainly not a derp on the OP's end

somber onyx
#

is there a version of this script that works in 2.0.0-beta, I can not fix it

unique dragon
#

how custom componentes changed in 2.0.0-beta

wary edge
unique dragon
wary edge
unique dragon
#

oh ok

#

ty

devout dune
#

Hey! I am not understanding what is up with this single_block_feature.
The block that is placed has a custom_component.

I am trying to simply spawn a structure onTick. But when I place the block via feature_rules, the onTick is not seeming to work!
But the onPlayerInteract works??

#

Here is my component logic

#

onPlayerInteract, logs

#

but onTick does not

#

If anyone has any idea id appreciate it!

#

The block is connected to the custom_component properly. Just curious why the onPlayerInteract is working, but onTick is not. I figured it may be a feature restriction. But i thought i remembered it working before

glacial widget
#

does anyone know the name for redstone ore glow id, need this for minecraft:can_destroy

wary edge
devout dune
#

some of the single_block_features seem to work... but not all of them.
im using try/catch
and not seeing any error logs either

wary edge
#

Unfortunate, it very might well be the feature.

devout dune
# wary edge Unfortunate, it very might well be the feature.

Interesting.... It's weird that im seeing it work on some blocks though. So i figured i could catch the error, and just try the tick again. But i dont even get the initial tick. Hmm any idea? If i am trying to place a structure via custom_components.
(I am doing this to avoid the cutoff of some structs. without using jigsaw)

dim tusk
unique acorn
#

I'm so bored, what should I make

dim tusk
#
world.afterEvents.entityDie.subscribe(({ deadEntity, damageSource: { damagingEntity, cause } }) => {
  if (deadEntity.typeId !== 'minecraft:player') return;

  Object.entries({
    deathTrigger: true,
    entityName: deadEntity.nameTag, 
    sourceId: damagingEntity?.typeId,
    cause,
    dim: deadEntity.dimension.id, 
    deathCounter: (deadEntity.getDynamicProperty('deathCounter') ?? 0) + 1,
    rDate: new Date().toLocaleString()
  }).forEach(([k, v]) => deadEntity.setDynamicProperty(k, v));
});```
untold magnet
dim tusk
#

I guess, you never saw how I code before that's why.

untold magnet
dim tusk
# untold magnet yup, exactly.

So anyways. Just like array instead of just one string, you can get the name and get the values, that's what I did above instead of calling multiples dynamic propertyjs for (const [k, v] of Object.entries({ '<name>': '<value>' })) { console.error(k, v); }
It's in the variable, k = key and v = value.

Object.entries({ '<name>': '<value>' }).forEach(([k, v]) => {
  console.error(k, v);
});```
#

the variable can be any name btw.

#
const obj = { name: 'Coddy', age: 30 };

for (const [k, v] of Object.entries(obj)) {
  console.error(k, v); // "Coddy", "30"
}

Object.entries(obj).forEach(([k, v]) => {
  console.error(k, v); // output is the same.
});```
#

ohh yeah, expect me doing some destructing in some codes lol

untold magnet
untold magnet
#

adjusted

dim tusk
#

you can set multiple dynamic property without calling individual for then.

dim tusk
untold magnet
untold magnet
dim tusk
#

What'd you mean 2ft?

untold magnet
dim tusk
#

use double quotes since you used the single quotes. "5'59.3"

dim tusk
dim tusk
sharp elbow
#

Isn't there a method called setDynamicProperties?

#
entity.setDynamicProperties({
  deathTrigger: true,
  entityName: entity?.nameTag,
  sourceId: source?.damagingEntity?.typeId,
  cause: source?.cause,
  dim: entity?.dimension?.id,
  deathCounter: deathCounter+1,
  rDate: date.toLocaleString()
});
untold magnet
sharp elbow
#

That approach is also more overhead. What you had originally was just fine too, if a bit repetitive

#

"Easier to extend" would probably be a better reason to use either an iteration or setDynamicProperties. You could merge a bunch of properties into a single object, then set that object

#

Useful for when you don't know ahead of time which properties you are updating, or if you only want to update some properties when they change and not others

#
const propObj = {};
if (...) propObj.foo = ...;
// ... more statements
entity.setDynamicProperties(propObj);
dim tusk
#

Yeah... Lol

distant tulip
unique acorn
#

Good idea

#

I'll show results in 2026

distant tulip
#

lol, one of my to do ideas that i will probably never do

unique acorn
#

Maybe I don't have the mathematical knowledge for that

north frigate
#

guys why playerInteractWithBlock event doesn't work anymore

humble lintel
#

anyone tryna make an addon w me

#

im boreed

warped kelp
#

What server should I use script module api?

distant tulip
north frigate
warped kelp
#

Oh darn. It says 1.14.0 on mine

#

Is 1.17.0 stable?

unique acorn
distant tulip
#

yes but use 18

warped kelp
distant tulip
warped kelp
#

Oh right. I could edit it with bridge. Thanks ya'll

#

Change this?

unique acorn
unique acorn
humble lintel
#

recreation of a java mod?

#

those are usually fun to do

unique acorn
#

oo good idea

#

which mod tho

humble lintel
#

uhh let me see

unique acorn
#

and don't choose create mod pls

humble lintel
#

darn

#

tecxh mod?

unique acorn
#

huh

humble lintel
#

a tech mod?

unique acorn
#

sure

humble lintel
#

any suggestions

#

applied energistics

#

no way lmaoooo

unique acorn
#

Looks scary

humble lintel
#

m aybe its possible\

#

but maybe not too much bedrock limitatioins

#

are there power mods already?

unique acorn
#

I don't play java mods so irdk

humble lintel
#

sorry i meant addon

#

not mod

unique acorn
#

I don't play with bedrock addons much too lol

humble lintel
#

lmfaooo

unique acorn
#

last time I played with an actual addon for more than 2min and for fun was 2 years ago

humble lintel
#

oh? waht the lol

unique acorn
#

well whatever idea you have in mind I'll do it

warped kelp
#

Chat, why did Bridge lower the mb count of my addon? I have an exact copy and all I did was change the server from 1.14 to 1.18 😭

humble lintel
warped kelp
#

Power mod like those superhero armor/morphs?

humble lintel
#

noo like energy

#

tech mod

unique acorn
humble lintel
#

uh that somewhat

#

search upo mekanism

#

mod

warped kelp
unique acorn
# humble lintel search upo mekanism

"Mekanism’s team of experienced chemical and mechanical engineers have developed advanced ore processing machinery to extract resources from ores with utmost efficiency."
🙂

humble lintel
#

yes

unique acorn
#

lowkey when you said does anyone wanna do an addon I thought you were just aiming for a small idea to pass the time

humble lintel
#

yes not a project

#

I'm not trying to recreate mekanism i would die

#

any suggestions'

#

I mean i'm working on a tree harvester mod rn but everyone already has one

#

though mine is optimized

unique acorn
#

hmm

#

why not add more stuff to redstone

humble lintel
#

sure what kind

warped kelp
#

Copper wires

#

Copper infused redstone = more range, customizable output

#

Or they can crawl the walls and ceilings

humble lintel
#

aye that mightb e a good idea

unique acorn
#

I'm so terrible with ideas.

humble lintel
#

wireless redstone

unique acorn
#

70% of the time would be getting the idea

warped kelp
#

Sculk

unique acorn
#

oh why not a remote that can toggle redstone power from far away

#

redtooth type thing

humble lintel
#

lmaoo yeah that works

#

do u knwo how to make dust like blocks?

unique acorn
#

huh?

humble lintel
#

like yk a redstone

#

its model is a dust

unique acorn
#

use a custom model ig?

warped kelp
#

Seems like it works like grass or those item frames

humble lintel
#

hmm

#

@unique acorn

unique acorn
#

Hi

humble lintel
#

i can share u my codespace if u want

dim tusk
#

Go in #off-topic or #add-ons

warped kelp
#

Okiee

unique acorn
humble lintel
#

do u have github

unique acorn
#

yes

humble lintel
#

user?

unique acorn
#

CennacEh

humble lintel
#

addedd

unique acorn
#

so umm.

humble lintel
#

yeah...?

dim tusk
#

He don't do typescript

humble lintel
#

Ohhhhhhhh

#

you can still use js

#

doesnt matter

unique acorn
#

oh okay

#

nice

humble lintel
#

can we be in the same codespace at the same time

#

like remote or nah

unique acorn
#

idk, this is the first time I ever heard of codespace

humble lintel
#

ohh olkay

unique acorn
#

I just googled it when you mentioned it and read 3 articles about it and still have 0 info about it

humble lintel
#

lmao here

#

go on code and open the main codespace in either ur browser or ur vs

unique acorn
#

that took a while.

humble lintel
#

yeah my bad 😅

#

can u see the stuff

unique acorn
#

yep

humble lintel
#

i wanna see if whatever u do goes to me aswell

#

can u try writing in the script

unique acorn
#

okay

humble lintel
#

ohh wait

#

it might be an extension hold up

#

liveshare it's called

prime zenith
#

Hey anyone able to help with a complex optimisation

humble lintel
#

what is it

prime zenith
#

I made a post about it titled battle optimisation

humble lintel
unique acorn
#

I made a tiny tiny change, check if it's showing for u

prime zenith
#

This isnt typical coding as the code works but stats and order needs to be optimised

humble lintel
#

no it didnt work cennac

#

might have to join the liveshare

#

can i dm u cennac

unique acorn
#

sure

prime zenith
#

Atm its a simulation but ill plug it into the actual world when optimised

#

@humble lintel so you wanna help or no

gritty walrus
#

whats the new way to do const overworld = world.getDimension("overworld");

    {
      "module_name": "@minecraft/server",
      "version": "1.17.0-beta"
    },
    {
      "module_name": "@minecraft/server-ui",
      "version": "1.4.0-beta"
    }```
gritty walrus
shy leaf
gritty walrus
shy leaf
#

...i dont know where the pointer is pointing at

shy leaf
prime zenith
#

Lovely new bugs who would have guessed

shy leaf
#

no its not really a bug

#

its just that scripting load order has been changed in 2.0.0

thorn flicker
shy leaf
#

the scripts can start way before the world load

gritty walrus
shy leaf
#

what

gritty walrus
#

😭

#

time to do it 400 more times woohoo

shy leaf
#

yeah uh

#

lets not do that 400 times

prime zenith
#

Some things prob didnt change as nuch as you thought

gritty walrus
#

i remember i had to do that for everything a while back too

prime zenith
#

If the error was caused due to doing the same tick as a verification check thats why system.run can still work

gritty walrus
#

another question fixed one issue open alot more

RefernceError banUtils is not initialized

    static ban(player, reason, duration, admin) {
        bans.push({
            n: player,
            d: duration,
            tob: Date.now(),
            r: reason,
            a: admin
        });
    }
    static isBanned(player) {
        return bans.some(x => x.n === player);
    }
    ```
sick robin
#

anyone know if its possible to make chat ranks without using beta apis? which would ofc require not using chatsend.

warped blaze
#

ig it's simpler

gritty walrus
#

huh

sick robin
# shy leaf no

really not even using json some way that sucks extreemly bad if not

shy leaf
#

json is not related here

#

other than using plugins for BDS or something, its just not possible

sick robin
shy leaf
#

uhhh im not sure about that one

#

never used BDS

sick robin
warped blaze
# gritty walrus huh
const banUtils = {
  ban(player, reason, duration, admin) {
    bans.push({
      n: player,
      d: duration,
      tob: Date.now(),
      r: reason,
      a: admin
    })
  },
  isBanned(player) {
    return bans.some(x => x.n === player);
  }
};```
#

the way to use it remains the same:

using class: banUtils.ban()
using object: banUtils.ban()

gritty walrus
#

ah i see

#

sorry im fixing the errors as they come and they js keep comin

#
    at <anonymous> (moderation.js:100)


[Scripting][error]-Plugin [Zeno Prisons v2.0 - 1.0.1] - [index.js] ran with error: [ReferenceError: Native property getter [World::scoreboard] does not have required privileges.    at Database (moderation.js:21)
    at <anonymous> (moderation.js:100)
] ```

```21  this.objective = world.scoreboard.getObjective(databaseName) ?? world.scoreboard.addObjective(databaseName, databaseName);

100 const unbans_database = new Database("UnbanDatabase");

shy leaf
gritty walrus
#

world.afterEvents.worldLoad.subscribe(() => {
  import("./scripts/levelsystem.js")
  import("./scripts/mobstacker.js")
  import("./scripts/stack_remover.js")
  import("./scripts/placelimit")
  import("./scripts/loot_table.js")

})``` this?
#

worked didnt even see his message

patent bane
#

How do I teleport a player to the world spawn?

warped blaze
patent bane
warped blaze
#

The default Overworld spawn location. By default, the Y coordinate is 32767, indicating a player's spawn height is not fixed and will be determined by surrounding blocks.

dim tusk
#

Get the top most block.

#

then tp there.

warped blaze
#

Coddy saves the day again yippee

patent bane
dim tusk
# patent bane How do I teleport a player to the world spawn?
world.beforeEvents.itemUse.subscribe(({ itemStack, source }) => {
  if (source.typeId !== 'minecraft:player') return;

  if (itemStack.typeId === 'minecraft:stick') {
    const defaultSpawn = world.getDefaultSpawnLocation();
    const topMostBlock = source.dimension.getTopMostBlock({
      x: defaultSpawn.x,
      z: defaultSpawn.z
    });

    source.teleport(topMostBlock?.above(), {
      dimension: source.dimension
    });
  }
});```
dim tusk
patent bane
patent bane
#

you should try it sometime

rapid nimbus
#

Hey everyone, how to fixed "run failed, no runtime or context available." error when use Script API on Minecraft Bedrock Edition?

patent bane
# dim tusk why do you eat tables weekly?

yo, it works but it teleports the player to y256 instead of the top most block, is there any way to fix this?

import { world } from '@minecraft/server';

world.afterEvents.playerDimensionChange.subscribe((eventData) => {
    const { player, toDimension } = eventData;
    
    if (toDimension.id !== 'minecraft:overworld') {
        const overworld = world.getDimension('minecraft:overworld');
        const spawnVec = world.getDefaultSpawnLocation();
        
        const topMostBlock = player.dimension.getTopmostBlock({
            x: spawnVec.x,
            z: spawnVec.z
          });

        const safeSpawn = {
            x: spawnVec.x,
            y: topMostBlock?.location.y +1 ?? 70,
            z: spawnVec.z
        };

        player.teleport(safeSpawn, {
            dimension: overworld,
            keepVelocity: false
        });

        player.sendMessage('§cReturned to world spawn!');
    }
});
patent bane
#

oh mb

patent bane
leaden elbow
#

is this server hacked?

#

it jumbled all channel names lol

patent bane
patent bane
leaden elbow
#

oh yeah lol i forgot abt that

valid ice
prime zenith
#

Anyone able to help with optimisation and feedback for my battle system

prisma shard
#

olleh syug yppah lirpa sloof !

prisma shard
prime zenith
# leaden elbow mhm

The files are in battle optimisation also am i the princess varient of you lol im princessTG your just TG so bland 😛 im joking

#

@prisma shard whos the fool yous the fool happy april fools fool

prisma shard
#

no my

prime zenith
#

@leaden elbow so are you able to help optimise?

honest spear
#

Hello i want to ask, Can i use python code for addons for my world? My brother know code with python so i am asking bao_comm_hatchi_what

#

@prime zenith Can you help me?

prisma shard
#

you can use python to auto generate your addons tho

#

but not directly use it

honest spear
#

Like i want python to make player double jump

#

Is it possible

#

?

prisma shard
honest spear
#

AI tells to me that coding needs python or something so i don't understand now, python is like language or something

#

So how do you do that?

prisma shard
#

bruh.............

#

bro doesnt even know python is even a language

honest spear
#

I saw ppl use code in addon many times already

prisma shard
#

but.. this channel is about javasscript

#

so no point of talking about python here

prisma shard
honest spear
#

yes

#

so how can i do that

#

codes needs python or smth

#

or language

#

not sure what that means

#

i know JSON tho

prisma shard
honest spear
#

i need to double jump to work in my addons and they said only script api can do that

prisma shard
#

But can use python to write JSON/JS or auto generate addons

honest spear
#

so its not possible to code in addons?

prisma shard
#

Minecraft only supports Javascript and JSON

prisma shard
honest spear
#

So Code is also python is like javascript?

prisma shard
#

JSON is a code... Javascript is a code..

honest spear
#

ahh

#

so its the same thing

#

i see

#

interesting

prisma shard
#

they all are coding languages

#

but

#

the way of coding each of them is different

prisma shard
# honest spear i see

If you want to make a Double Jump as you said, you can use Javascript and read the article "Intro to scripting"
And detect, if player has jumped, then for the second jump. you can use applyKnockback()

honest spear
#

I want to use this but i don't know how to add this code to addon

# Abstract Minecraft API Example
# Assume the Minecraft API provides these methods: `get_player_position`, `set_player_velocity`,
# `on_player_jump`, and `is_player_on_ground`.

# Initialize variables for double jump
max_jumps = 2
jumps_left = max_jumps
jump_strength = 10  # Customize based on the Minecraft API's velocity units

# Event listener for player's jump action
def on_player_jump():
    global jumps_left

    # Get player's current position and velocity
    player_position = minecraft_api.get_player_position()  # Placeholder API method
    player_velocity = minecraft_api.get_player_velocity()  # Placeholder API method

    # Double jump logic
    if minecraft_api.is_player_on_ground(player_position):  # Check if player is on the ground
        jumps_left = max_jumps  # Reset jumps when on the ground
    elif jumps_left > 0:
        minecraft_api.set_player_velocity(player_position, (0, jump_strength, 0))  # Apply upward velocity
        jumps_left -= 1

# Main game loop (abstract representation)
def game_loop():
    while True:
        # Listen for jump events
        minecraft_api.on_player_jump(on_player_jump)  # Bind the jump event to the handler

        # Apply gravity (Minecraft should handle this as part of its physics engine)
        pass  # Gravity logic here if necessary

# Start the game loop
game_loop()

honest spear
#

No

#

its AI

#

chat ai

prisma shard
honest spear
#

yes chatgpt

#

but also not

#

i am using Copilot AI

prisma shard
#

please

#

for god sake

#

Don't use AI in minecraft scripting

#

But use if you want to make something Javascript-itself related.

honest spear
#

but i don't know how to us python, and AI knows the best

prisma shard
#

😭

honest spear
#

yea its the same thing as JavaScript its code you said so

prisma shard
#

i am so done with you

honest spear
#

bruh, i think i am cooked

#

why is script api so hard to learn

#

i already tried like month ago

prisma shard
#

atleast Learn abbout javascript before scripting

honest spear
#

yes

#

ok

prisma shard
#

bro doesn't even know that it is a coding language

honest spear
#

there are many languages

#

also molang

#

but molang is really hard

prisma shard
#

Minecraft doesn't support python

prisma shard
honest spear
#

Python is code

prisma shard
honest spear
prisma shard
#

oh...

#

Education Edition....

#

You didn't tell me this before!

honest spear
#

OK

prisma shard
#

then yes

#

i think python inside minecraft will work

honest spear
#

good

#

i think i am getting somewhere

prisma shard
#

I didn't knew you can run other languages in Education Edition 👀

honest spear
#

Hmmm, and how can i do double jump

#

in code?

prisma shard
#

idk python

#

and idk education edition

honest spear
#

ok

prisma shard
#

This is about Script API (javascript)

oak lynx
honest spear
#

Yes i need code in world with code Script api

#

for addon

prisma shard
honest spear
#

@oak lynx Can you help me, @prisma shard Doesn't knows python code in MC

oak lynx
#

I haven't touched python in years

honest spear
#

OK

oak lynx
#

from all the languages I had to use in my life python is in the top 3... worst languages

honest spear
#

I also don't like code

#

its hard

dim tusk
#

convert python into js 🤷

honest spear
#

but i need it for my world with my friends

honest spear
prisma shard
honest spear
#
# Abstract Minecraft API Example
# Assume the Minecraft API provides these methods: `get_player_position`, `set_player_velocity`,
# `on_player_jump`, and `is_player_on_ground`.

# Initialize variables for double jump
max_jumps = 2
jumps_left = max_jumps
jump_strength = 10  # Customize based on the Minecraft API's velocity units

# Event listener for player's jump action
def on_player_jump():
    global jumps_left

    # Get player's current position and velocity
    player_position = minecraft_api.get_player_position()  # Placeholder API method
    player_velocity = minecraft_api.get_player_velocity()  # Placeholder API method

    # Double jump logic
    if minecraft_api.is_player_on_ground(player_position):  # Check if player is on the ground
        jumps_left = max_jumps  # Reset jumps when on the ground
    elif jumps_left > 0:
        minecraft_api.set_player_velocity(player_position, (0, jump_strength, 0))  # Apply upward velocity
        jumps_left -= 1

# Main game loop (abstract representation)
def game_loop():
    while True:
        # Listen for jump events
        minecraft_api.on_player_jump(on_player_jump)  # Bind the jump event to the handler

        # Apply gravity (Minecraft should handle this as part of its physics engine)
        pass  # Gravity logic here if necessary

# Start the game loop
game_loop()

dim tusk
#

uhhh, this is AI?

honest spear
#

Yes

prisma shard
#

ofc

#

I cant fuking make him understand

#

DONT USE AI

dim tusk
#

Don't expect me helping you

honest spear
#

its python code

honest spear
#

its language for code

prisma shard
prisma shard
#

THIS IS JAVASCRIPT

dim tusk
#

that's not the reason I don't want to help you.

honest spear
#

OK

dim tusk
#

I know how to code python, it's literally in my bio.

honest spear
oak lynx
#

praying that the beta tomorrow makes getBlock() not useless

oak lynx
honest spear
#

but i don't know how to code

prisma shard
prisma shard
prisma shard
oak lynx
dim tusk
honest spear
#

i tried but it doesn't work

oak lynx
prisma shard
honest spear
#

Can you give me a way to learn code in addons?

dim tusk
honest spear
#

I tried 2 months ago and not working

dim tusk
#

learn basic JavaScript -> read Minecraft script API docs -> make scripts

oak lynx
#

wait is it possible to get like all the typeIds/permutations that are in a specific region?

prisma shard
#

........................

oak lynx
prisma shard
#

Guys

dim tusk
#

You're a confusing guy, you don't know js, but will help someone?

prisma shard
#

he is really ocnfusing

#

GUYS

#

GUYS

#

GUYSvv

#

GUYS

#

GUYS

dim tusk
#

Stfu

#

Don't spam.

honest spear
prisma shard
# dim tusk Stfu

i think....... that guy is making us April Fools???? Check his username!!! i think it is conmaster second alt account!!!!

dim tusk
honest spear
#

I know JSON and JS is part of the JSON

dim tusk
#

he can kiss me if he wanted 😘

prisma shard
#

;-;

dim tusk
#

you think I don't notice lol?

oak lynx
#

anyone knows the performance impact of this?

honest spear
#

damn

dim tusk
#

I'm just playing along, in the first place who tf has a joined date of 2021 who doesn't know addons?

prisma shard
#

fr

dim tusk
prisma shard
#

wait how u see join date

honest spear
dim tusk
prisma shard
oak lynx
honest spear
prisma shard
dim tusk
#

The area is actually large.

dim tusk
honest spear
prisma shard
dim tusk
honest spear
dim tusk
prisma shard
#

how 😭

oak lynx
dim tusk
prisma shard
#

i am april fooled 😭

honest spear
oak lynx
#

okay so right now the plan is simple

  1. I filter out what typeIds are in an area using containsBlock()
  2. I iterate over filtered typeIds with getBlocks() to get an area of typeIds and positions
#

then I run some compression stuff and send it to my DB

#

i hate April fools

prisma shard
oak lynx
#

NO WAY THEY ADDED COMMANDS WITHOUT NAMESPACES OMG

prisma shard
dim tusk
dim tusk
honest spear
oak lynx
prisma shard
dim tusk
oak lynx
prisma shard
oak lynx
#

nah this is actually a real question

honest spear
prisma shard
#

i am still shocked how conmaster fooled me

#

bro is a magician

#

who is your brother

#

that knows python

#

lol

oak lynx
#

someone threaten mojang to add these things:

  1. no namespace commands
  2. XUID
  3. working getBlocks()
    Like I want to make a server network using just bds cuz I am mentally insane
dim tusk
#

Stop already, the joke already dried out.

oak lynx
prisma shard
#

i have getBlock() better version

oak lynx
dim tusk
#

you can still talk.

honest spear
#

#1067535608660107284 message

honest spear
oak lynx
honest spear
oak lynx
honest spear
prisma shard
#

peanut bar

#

yum

oak lynx
honest spear
#

Chunk the structures

#

use multiple structures for single skyblock island

oak lynx
#

okay but what do I do with the structures? I already tried getPermutation or whatever the method was

#

I can't just send a structure through rest api

honest spear
oak lynx
#

yeah I will probably use mongodb

honest spear
#

well then getBlock is only way and still incomplete

#

if i could suggest then try using custom client to join and extract structures via it

#

its the fastest way

#

getBlock is not even providing all NBT information

#

only few components

oak lynx
#

okay but wouldn't first filtering what block types are in an area then using getBlocks to get all positions of specific typeIds

honest spear
oak lynx
#

like I filter out what typeIds aren't in the area

prisma shard
#

/**
 * @param {Vector3} location 
 * @param {Dimension} dim
 * @returns {Promise<Block>}
 * await getBlock(loc, world.getDimension('nether'))
 * getBlock(loc, world.getDimension('nether')).then(block => {})
 * Gets a block from any dimension & location in the MCworld asynchronously
 */
export async function getBlock(location, dim = world.getDimension("overworld")) {
    let block, { x, y, z } = location;
    const getBlock = dim.getBlock.bind(dim, location);
    try { if (!(block = getBlock())) throw null; else return block }
    catch {
        dim.runCommand(`tickingarea add circle ${~~x} ${~~y} ${~~z} 0 "${x},${y},${z}"`);
        let remove = () => dim.runCommand(`tickingarea remove "${x},${y},${z}"`);
        return new Promise(async resolve => {
            system.runJob(function* () {

                let trials = 1e3;
                do {
                    block = getBlock();
                    if (!--trials) yield void remove();
                } while (!block);
                remove();
                return resolve(block);
            }())
        })
    }
};

SIgma Ultra Pro Max++ getBlock()

oak lynx
#

wait I had a prototype somewhere

honest spear
#

If there are only some of them then yea, filtering helps

oak lynx
#
export function blockVolumeToBlockTypeIdArray(blockVolume: BlockVolume) {
    const blockArray: { blockId: string, position: Vector3 }[] = []
    const span = blockVolume.getSpan()
    const totalSize = span.x*span.y*span.z
    for (const id of blockTypeIds) {
        for (const location of dimension.getBlocks(blockVolume, { includeTypes: [id] }).getBlockLocationIterator()) {
            blockArray.push({ blockId: id, position: location })
        }
        if(totalSize==blockArray.length) break;
    }
    return blockArray
}
honest spear
honest spear
dim tusk
#

so true.

honest spear
#

not recommended for marketplace addons but for local usage is alot faster

oak lynx
honest spear
oak lynx
#

I mean my performance tests made getBlock look really bad

honest spear
#

yea, i think so

oak lynx
#

so I'm willing to try a lot of stuff

honest spear
#

Yea we need improvement for getBlocks() so we know what blocks are where

oak lynx
#

like bds performance is great actually

#

I just need a few little things and it will be enough to run actual servers on it

prisma shard
honest spear
#

like user name?

prisma shard
#

yes

honest spear
#

👍

prisma shard
honest spear
#

First thing i did, was creating existing works like, "Dexter Everyday" then just replace some letters and add weird Capital letters in the middle, thats whole story

prisma shard
#

why

distant tulip
prisma shard
#

alright sorry

chilly moth
#

how do I get all death cause in entity die

honest spear
#

wdym? entityDie event fires for all causes except forced removal

chilly moth
#

can you show a sample

#

how to use few causes instead of all

thorn flicker
#

get the cause property from the event

chilly moth
#

ok let me check

distant tulip
#

Was it event.damageSource.cause?

prime zenith
#

@honest spear with?

honest spear
unique acorn
#

you don't

honest spear
#

OK

chilly moth
boreal siren
#

How can I give a block a unique identifier and then use it like an entity with a dynamic property?

patent bane
distant tulip
shy leaf
#

i should optimize this shit.

honest spear
shy leaf
#

yeah i should

honest spear
#

nice!!!

#

art piece of work

shy leaf
#

though i actually didnt cache the value

#

since the property can be updated by players mid game

#

(this is just an excuse, i was just lazy)

#

((im not used to caching))

honest spear
#

OK

#

👍

honest spear
shy leaf
#

rip

honest spear
#

How can i use python in script api?

shy leaf
#

im feeling a deja vu

#

here

honest spear
#

OK

distant tulip
#

doesn't minecraft china have a python api or something like that

slow walrus
distant tulip
#

they have script api too?

cold grove
distant tulip
#

that is cool

slow walrus
#

pretty sure they don't

cold grove
#

Before

summer path
#

#1356632769035243550 Can anyone help?

cold grove
#

Its not called "Script" due to "javascript" btw

summer path
#

can anyone help me? #1356632769035243550

slim forum
#

Helloo

summer path
#

anyone wanna hel pme

slim forum
#

Can I detect an enderman teleporting before and after?

distant tulip
cold grove
#

No

slow walrus
#

that doesn't mean they have mainstream bedrock's scripting api

#

they have their own thing that only uses python iirc

#

no JS

prime zenith
#

@honest spear do not use python ever it is a bad code to use outside of learning it is absolutly terrible to use and is a leading cause to high electricity prices avoid python

summer path
#

cuz like i'm not learning JS for this

remote oyster
# prime zenith <@805533255121109022> do not use python ever it is a bad code to use outside of ...

Ah yes, Python—the true villain behind global energy crises. Forget inefficient data centers or industrial power consumption; it's those pesky print("Hello, World!") scripts driving up electricity bills worldwide. Next thing you’ll tell me is that JavaScript is responsible for climate change. Truly, we must return to writing everything in hand-optimized assembly to save the planet.

|| ~ By Someone, Somewhere ||

honest spear
# prime zenith <@805533255121109022> do not use python ever it is a bad code to use outside of ...

Why this code doesn't work?

import time

# Define parameters for double jump
MAX_JUMPS = 2
JUMP_STRENGTH = 10
jumps_left = MAX_JUMPS

# Event handler for jump action
def handle_jump_event():
    global jumps_left

    # Check if player is on the ground
    if minecraft_api.is_player_on_ground():
        jumps_left = MAX_JUMPS  # Reset double jump when touching the ground
    elif jumps_left > 0:
        # Apply upward velocity for the jump
        minecraft_api.set_player_velocity(0, JUMP_STRENGTH, 0)
        jumps_left -= 1

# Game loop
def game_loop():
    # Bind the jump event to the handler
    minecraft_api.on_player_jump_event(handle_jump_event)

    while True:
        # Simulate a game loop with minimal functionality
        time.sleep(0.05)  # Tick rate (replace with Minecraft's game tick logic if necessary)

# Start the game loop
game_loop()
valid ice
#

where script API

honest spear
#

it throws syntax error

prime zenith
#

Under no circumstance for any reason should anyone ever use python python is a bad language and its power consumption is extremely high and because of ppl who used it for servers the power req to keep them is extremely high

valid ice
#

I see no scripts and no snakes, so that is invalid python and not a script

honest spear
#

OK

#

How can i fix it

valid ice
#

Find a python

honest spear
#

i want doublt jump in my world to work

remote oyster
honest spear
#

but it doesn't

prime zenith
#

@honest spear im sorry ill help you with javascript but im not helping you write python python is to dangerouse of a language to use

remote oyster
#

All hello world applications will take over the world.

honest spear
remote oyster
#

Skynet told me

honest spear
#

I don't know how to fix it

honest spear
prime zenith
#

@honest spear tonight we can talk add me

remote oyster
summer path
#

#someonehelpme

honest spear
summer path
deep arrow
deep quiver
honest spear
#

i was waiting for this answer!!!

#

haha

deep quiver
#

I got you

honest spear
#

OK

deep quiver
#

Just wait a few years

#

Im gonna make a c++ interpreter in js

#

People will think its fast but its gonna be extremely slow

#

Its gonna compile to Mcssembly (pronounced Macsembly or just mc sembly)

#

Which then is gonna be interpreted

#

I think im onto something here

cold grove
prime zenith
#

@honest spear if you need help i cant help til tonight

honest spear
#

OK

#

i think its working now

deep quiver
deep quiver
honest spear
deep quiver
#

Damn

#

L python

honest spear
#

I won

quaint birch
wary edge
summer path
#

smokeystack can u help me

wary edge
#

PE_PandaDevil As long as Navi suffers...fine by me.

quaint birch
wary edge
#

Totally understand that!

#

Especially with something this huge!

past blaze
summer path
distant gulch
#

How to register custom components with @minecraft/server release?

#

I can't find startup event in system

distant gulch
wary edge
#

Continue using worldInitialize before event.

distant gulch
#

deprecated

wary edge
distant gulch
#

I can't compile with worldInitialize

distant gulch
wary edge
#

Then like I said, continue using worldInitialize before event.

distant gulch
wary edge
distant gulch
#

I can't compile JS file from source with this error

#

How to ignore errors?

wary edge
#

@distant gulch Please open a post with your code and the compile error.

granite badger
distant gulch
#

Nvm

#

All works

#

Thanks

patent bane
woven loom
#

profiler

patent bane
honest spear
#

yea profiler really helps

#

i would also suggest using MC debugger extension so you can see the statistics at the runtime

sharp elbow
#

I would determine the offset of the ray's intersection with the player's position. If, say, the player's "head" starts at ~1.4 blocks up when standing straight, then you can determine a headshot by seeing if the y-offset is greater than 1.4 blocks from the player's y-coordinate

prisma shard
#

oooo

#

headshot

#

you remind me of freefire

woven loom
#

Mame sure to check sneaking

crude bridge
#

.

woven loom
#

My approach would be to get the player head to entity head vector, and compare it with the player's direction vector using the dot product.

distant tulip
#

get entity from ray can give you exact location, so get head location and do a distance calculation

woven loom
#

something like this maybe

isHeadShot = V0 dot V1 < .75 + .15(distance/100)
hollow sail
#

Are there changelogs for the scripting api?

hollow sail
#

Where?

wary edge
hollow sail
#

I was kinda hoping for something more condensed but alright

#

It’s been awhile since I’ve touched addons and wanted to know if the stuff I’ve been missing have been adding

dim tusk
#

not the movement itself but the momentum?

north rapids
#

how do I get the entity family?

#

nvmd I found it

gray tinsel
#

if a particle is spawned on a player can it access player related queries?

#

like player.spawnParticle

gray tinsel
pale terrace
#

hey guys, do you think using js const startTime = Date.now(); const time = Date.now() - startTime is more efficient than using system.runTimeout? in the case that I need too many of them

neat cypress
#

When is scripting v2 expected to come out? Soon or later?

slim spear
shy leaf
#

i could run it for a few minutes but i was just super lazy

slim spear
#

oh

viscid horizon
#

how do i correctly subtract the value from a dynamic property (it’s int)

warped blaze
#

uhm, .getDynamicProperty()?

dim tusk
#
const value = World.getDynamicProperty('value') ?? 50;

World.setDynamicProperty('value', value - 10); // return 40;```
warped blaze
#

mb

runic crypt
#

Hey, is it possible to change the name of a spawned npc using scripts ?
If yes can anyone tell me how or link documentation ??

#

Please ping me if you do

dim tusk
#

get npc component

runic crypt
#

What I am aiming for is to show specific text above the npc's head
Kind of like a chat thingy

dim tusk
#

Also, there's a limit of amount you can display in npc's head/name tag.

#

Only 32 chars

runic crypt
dim tusk
runic crypt
rapid nimbus
#

My Script API is okay but the way it displays the title is not very good so I have to fix my script to make it work more stable.

prime zenith
leaden elbow
#

% sign in my form crashes the game lmao

#

even tho with backslash

prisma shard
#

hi steve

rapid nimbus
#

Fixed biome title, Now only fixed dimension title left

sage sparrow
granite badger
#

Mojang claims it can connect to remote servers provided you know how to setup a tcp server. You can connect the debugger to a BDS

sage sparrow
#

but how do I define the server IP?
"localRoot": "${workspaceFolder}/behavior_packs/Inner_BP/",
"port": 19144

oak lynx
#

today's beta predictions go 🗣️🗣️

#

they will add jack black 👍👍

shy leaf
#

please beforeEvents entityHitEntity

dim tusk
#

I doubt.

#

If they do I'll jump off a highway

shy leaf
#

yeah theres

#

like

#

near zero chance but still

wary edge
oak lynx
#

previews are the only thing that give me motivation on Wednesdays

#

I should try finishing my block saving function 🗣️

prisma shard
leaden elbow
#

urh

#

chicken jockey

wary edge
oak lynx
oak lynx
#

makes sense

shy leaf
#

the docs says

#

"that should heal and not damage"

#

news fuckin' flash, it doesnt!

prisma shard
shy leaf
#

uh

#

should be

dim tusk
#

learning javascript is fast, people are either lazy, or just slow learner which I respect, and people who are doing for the sake of friends

oak lynx
#

anyone here actually codes in js/ts outside of script api?

shy leaf
#

not me

dim tusk
#

Me, I do HTML

oak lynx
#

idk what i should use for my db connection prisma is cool but mongoose also looks like a decent option

shy leaf
#

that is practically a bug

#

it affects all the damages, even enchantments and mace damage

dim tusk
#

Don't inform Mojang.

shy leaf
#

lmfao

dim tusk
#

Just shhh

prisma shard
shy leaf
#

-# if they actually fix that i will go insane

#

-# please dont do it mojang, its my last hope

dim tusk
prisma shard
#

how

dim tusk
shy leaf
oak lynx
#

uhh anyone knows something really technical about dimension.getBlocks()?
does adding the exclude types filter make it faster or slower if i can add all the types i dont want there and include all the types i want?

oak lynx
#

everything makes a difference when talking about millions of blocks 🗣️

shy leaf
#

i dunno how the API works but

#

im p sure excludeTypes filter is just

#

equivalent to javascript native filters

#

(hopefully)

oak lynx
#

something is wrong

#

my pack loaded without a spike

shy leaf
oak lynx
#

it usually gets a huge spike when i open it cuz it does a lot of calculations on startup to avoid doing them later

shy leaf
#

should be considered as a bug

oak lynx
#

bruh

honest spear
#

bruh

oak lynx
#
    public* blockVolumeToBlockTypeIdArrayWithSaveBlocks(blockVolume: BlockVolume) {
        console.log(`Starting to save blocks`)
        const filteredBlockIds: string[] = []
        const time = system.currentTick
        const span = blockVolume.getSpan()
        const totalSize = span.x*span.y*span.z
        let i = 0;

        for(const id of blockById) {
            if(dimension.containsBlock(blockVolume, {includeTypes: [id]})){
                filteredBlockIds.push(id)
                yield;
            }
        }

        for (const id of filteredBlockIds) {
            i++
            for (const location of dimension.getBlocks(blockVolume, { includeTypes: [id]}).getBlockLocationIterator()) {
                this.vectorTypeIdArray.push({ blockId: id, position: location })
                yield;
            }
            if(totalSize==this.vectorTypeIdArray.length) break;
        }
        console.log(`Found ${this.vectorTypeIdArray.length} blocks out of ${totalSize} in ${i} iterations, Time: ${system.currentTick - time}`)
        const uniqueIds = [...new Set(this.vectorTypeIdArray.map(item => item.blockId))];
        console.log(`Unique block IDs: ${uniqueIds.join(", ")}`);
    }
shy leaf
#

oh bruj

oak lynx
#

this is just not possible

honest spear
#

yea, i already said you better use custom client

#

Script API is not build for these kind of stuff

oak lynx
#

nah the bootup spike is just a second of like 30ms when nobody is on the server

#

hmm

#

900 ticks to save 64x384x64 is really bad

oak lynx
honest spear
#

yea

honest spear
oak lynx
#

and it somehow found more blocks than there are in the area 💀

#

turns out dimension.containsBlock is really slow

#

i expected it to be at least a little bit better than getBlocks

honest spear
#

well you are calling it for every type id, its slow when you call it that many times, but it loops the same blocks many times

#

it has to visit each block x times

#

i wonder if there could be done some optimalizations

oak lynx
#

probably yeah

#

but i doubt they will change much

#

easiest would be restricting the list of checked ids to obtainable blocks (but thats use case specific)

honest spear
#

Well i could optimize it for you but create post and explain me your goal more for what you do in Script API side

oak lynx
#

i dont think its possible to make it fast enough i will check endstone docs to see if it can save block areas

honest spear
#

Well i could try at least, but if you don't want then all right

oak lynx
#

like what i am trying to do is to save an area of blocks to a format i can store in a database

honest spear
#

I need more of context code, please create a post so we don't spam here

#

but i already have some optimalization in mind

cyan basin
#

continued...

#

You can use:

import { world } from "@minecraft/server";
world.afterEvents.worldLoad.subscribe(() => {});```
or
```js
import { system } from "@minecraft/server";
system.beforeEvents.startup.subscribe((init) => {});```