#Script API General

1 messages · Page 68 of 1

hybrid island
#

😭

dense skiff
#

And also you can't have any world-based api calls at the base level anymore lol

hybrid island
#

they didnt even do anything with isvalid they just removed the braaces

#

system.run spam!!

valid ice
#

I am not immune 😛

dense skiff
#

oh man

hybrid island
#

i forgot that exists

valid ice
hybrid island
#

not gotta do everything

#

wait

#

they edited async stuff right

echo bramble
#

we meet again 😭

dense skiff
#

I think I might be making a separate class to deal with this kinda stuff...

echo bramble
#

aight guys need yalls help rq

valid ice
#

Honestly glad they axed it, I had gotten lazy lol

true isle
#

yeah all mine are broken too it keeps giving me errors saying unexpected format and missing namespace in identifier so idk what happend lol

hybrid island
#

gg
v

#

i dont use aync that much

#

i dont event use async?

dense skiff
#

having to update my dependancies myself so I can update quicker 😍

echo bramble
#

[Scripting][error]-ReferenceError: Native constructor for [MolangVariableMap] does not have required privileges. at MolangVariableMap (native)
at <anonymous> (avatar/utils.js:13)

how can i gain "privileges" ive looked over at the documentation but cant find anything relevant to that

hybrid island
#

system.run

dense skiff
#

System.run won't do it anymore

hybrid island
#

??!?!?

#

No it cant be

dense skiff
#

you need world.afterEvents.worldLoad

hybrid island
#

system.run still works right??

echo bramble
dense skiff
#

Everyone needs to watch this lmao

chilly moth
#
    //reload is needed to stop crashes
    reload = reload + 1;
    if (reload > 1) return;
    for (const comp of blockComponents){
        //register the component
blockComponentRegistry.registerCustomComponent(comp.id, comp.code);
    }
});

Error
blockComponentRegistry.registerCustomComponent(comp.id, comp.code);

is not a function

hybrid island
#

welp

echo bramble
#

waittt runcommandasync hooked 💀 ?

hybrid island
#

use runcommand it removed

chilly moth
#

can anyone help

echo bramble
hybrid island
#

what do i replace system.run with

dense skiff
#

It's not a direct replacement

chilly moth
hybrid island
#

what do i do then

past coyote
#

Maybe learn javascript first haha

dense skiff
#

System.run will be fine getting out of EarlyExecution on beforeEvents I think, but the big change is that all your setup code essentially doesn't have access to world data anymore unless you use the worldLoad event, which triggers after the very first tick once everything is loaded.

hybrid island
#

already having this open makes me wanna switch

#

oh then im ok

dense skiff
past coyote
#

Alrighty, time to move stuff over lol

dense skiff
hybrid island
#

wait i dont need to change my code

past coyote
#

You 10000% should

hybrid island
#

everything works i dont use worldLoad

#

i dont use runcommandasync

dense skiff
#

sounds nice - dying over here

past coyote
#

Yeah, I have a pretty big server codebase that I need to refactor now 😭

hybrid island
#

good that my every file looks like someone who doesnt know how to script made it

past coyote
#

such is life using beta script api

valid ice
#

real

hybrid island
#

wait why do i even use beta?

past coyote
#

I always tell myself "This beta version wont change its feature set much... I can use this." then its flips 180.

hybrid island
#

🤔

echo bramble
#

rah im just deeping how im gonna edit so many files 😭

dense skiff
#

I mean I started using beta in august -- it's been like uber stable from what i've used lol

hybrid island
#

i opened discord and saw everyone saying i will update my addon is 3 days💀

past coyote
#

I just started using beta last week and im pretty deep into reworking stuff with this new update

#

very small portion of what might have to be refactored

hybrid island
#

my code is just that bad that i dont even need to change it

past coyote
#

oh my

hybrid island
#

💀

past coyote
#

thats uhh a pretty interesting way to do it

hybrid island
#

yes ik i didn't use switch case somethin

echo bramble
dim tusk
#

this is the right format.

#
system.beforeEvents.startup.subscribe(({ blockComponentRegistry }) => {
  blockComponentRegistry.registerCustomComponent('<id>', {
    // ...
  });
});```
chilly moth
#

ook

dim tusk
valid ice
#

Is destructuring absolutely needed, or is mine just buggered for realsies

dim tusk
#

It's not necessary tho, I just did that since it makes the code long (not at all) lmao

#

-# I can just use ev lmaooo

echo bramble
#

world.afterEvents.worldLoad.subscribe how do i use this for a molang variable map?

dim tusk
echo bramble
#

k cos im getting privileges issues

dim tusk
echo bramble
#

[Scripting][error]-ReferenceError: Native constructor for [MolangVariableMap] does not have required privileges. at MolangVariableMap (native) at <anonymous> (avatar/utils.js:13)

dim tusk
echo bramble
#

import { system, world, Player, MolangVariableMap } from "@minecraft/server";
import { ActionFormData, ModalFormData } from "@minecraft/server-ui";
import { PLAYER_DATA_MAP, WORLD_SETTINGS } from "./index.js";

import { chooseBendingMenu } from "./core/scroll/chooseBending.js";
import { chooseSlotsMenu } from "./core/scroll/chooseSlots.js";
import { showSkillTreeMenu } from "./core/scroll/skillTree.js";
import { chooseSettingsMenu } from "./core/scroll/chooseSettings.js";
import { statsInfoMenu } from "./core/scroll/statsInfo.js";
import { teamsMenu } from "./core/scroll/teams.js";
import { clear } from "./core/player/hud.js";

const map = new MolangVariableMap();

export const autoSmeltItems = {
    "minecraft:cod": "minecraft:cooked_cod",
    "minecraft:beef": "minecraft:cooked_beef",`

dim tusk
echo bramble
#

yh cool

#

ty

dim tusk
#

Can't you put it in the event listener itself?

echo bramble
#

yh your right tbf

prisma shard
#

hmmm whats the reason behind runCommandAsync removing

echo bramble
#

they felt like it

dim tusk
prisma shard
#

alr

#

We got everything at once, lol
Custom slash commands!!
and New discord UI

echo bramble
#

been using the discord ui for a good 2 months now

#

its so ahhh

hybrid island
#

where is the changelog from

#

i saw the 1.21.70 logs i didnt see that one

dim tusk
prisma shard
#

ig some ppl will stop yapping about "i saw someone make custom slash commands, how are they making it?!?!"

hybrid island
#

oh

echo bramble
#

for scripting

dim tusk
prisma shard
#

fr

#

how much delay is there between the .startup and .worldLoad event?

#

I think not a big delay, if the v1.0.0 scripts running in the middle is not very heavy

#

oh wait

#

huh

#

i didn't know async runs before runJob

dense skiff
# prisma shard

Depends on your pc and the world you're trying to load and more

prisma shard
#
await system.waitTicks(0); // not possible in v1, but now possible in v2

wtf

#

there is no meaning to waiting 0 ticks

#

(still trying to understand docs ahh)

shy leaf
amber granite
#

Hello

#

Is it possible to add new propreties to player?

valid ice
#

Like, extending the player class? Totally possible

fallow minnow
#

thank the lord our stuff was only 2 errors 💔 🙏

valid ice
#

This is a mojang bug lol

fallow minnow
#

oh

valid ice
#

At least from what I’ve seen so far

fallow minnow
#

bro discord had a huge update along minecraft too

valid ice
#

Looks ass, but #off-topic

lethal flame
#

Itemuseon.subscribe

#

Is error, what other I can use for item usage?

prisma shard
prisma shard
lethal flame
prisma shard
#

huh?

#

what are you trying to say?

lethal flame
prisma shard
#

hmm

lethal flame
prisma shard
#

show manifest.. script version?

lethal flame
#

When player use an item, it will start the event to record starting position

prisma shard
lethal flame
#

Already update to 2.0.0

lethal flame
# prisma shard i know but

// Land Claim by Item
const CooldownSet = {}
world.events.itemUseOn.subscribe(data => {
if (data.cancel) return
const { source } = data
if (data.itemStack.typeId == Server.Setting.get("itemClaimLand")) {
const Cooldown = CooldownSet[source.name] ?? Date.now()
data.cancel = true
if (Cooldown > Date.now()) return
if (data.source.isSneaking) {
EndPos(data.source, data.block.location)
} else {
StartPos(data.source, data.block.location)
}
CooldownSet[source.name] = Date.now() + 500
}
})

#

This is the code

prisma shard
lethal flame
#

Worldevent to before/after event?

prisma shard
#

yes

lethal flame
#

Whats the difference between those? Before and after

prisma shard
lethal flame
#

Problem solved

#

But new error

#

Cannot read property subscribe

prisma shard
#

..

#

show

lethal flame
#

Same line

prisma shard
#

you have to use beforeEvents

lethal flame
#

Ahh

#

Same error hahaha damn this is so frustrating

#

Failed to import command | TypeError : cannot read property subscribe of undefined

thorn flicker
#

itemUseOn has been removed in 2.0.0

#

use playerInteractWithBlock instead

humble lintel
#

does isValid() work now

shy leaf
#

making it read-only

humble lintel
#

that makes sense

oak lynx
#

so for blockVolume.getBlockLocationIterator() what order are the blocks in?

loud zenith
#

is it possible to to do an import of a file such as
Import "file.js"
after a worldLoad event ?

thorn flicker
ivory bough
#

at my block's location

oak lynx
#

wow there are more docs websites

thorn flicker
#

(I use this one the most)

thorn flicker
chilly moth
#
                    // Execute the /structure command to load the chosen tree at the sapling's location plus the offset
                    block.dimension.runCommandAsync(`/structure load ${structure} ${x + offset.x} ${y + offset.y} ${z + offset.z}`);
                }```


Error not a function 

Changelog:
Removed Dimension.runCommandAsync as most commands did not actually run asynchronously. If you are looking to run a function asynchronously, please investigate using Jobs via System.runJob.
chilly moth
#

nvm

prisma shard
#

use runCommand()

#

as it says

chilly moth
#

Yeah i did it

#

it works now

prisma shard
#

you just wrote the changelog and sent the error along? does that mean your asking for solution? or gave solution?

chilly moth
#

I dk for
now when I sent the msg I didn't read the changelog 😅

prisma shard
chilly moth
#

it works even if it's their

prisma shard
#

🤷

distant tulip
#

I see a lot of panic here.

#

I guess it is my turn to try updating my code

pseudo timber
#

{
"format_version": 2,
"header": {
"name": "§bInsanity MC V1.1",
"description": "§sMade By Dynamic!",
"min_engine_version": [1, 20, 0],
"uuid": "c6bd08e4-9223-4b69-9f4a-0cfecfa321fd",
"version": [1, 0, 0]
},
"modules": [
{
"type": "data",
"uuid": "8942c0d5-efcf-42c0-a104-9e5c424f7f63",
"version": [1, 0, 0]
},
{
"type": "script",
"language": "javascript",
"uuid": "1a75456f-8a5a-4ce3-807e-2131f2cd0709",
"entry": "index.js",
"version": [1, 0, 0]
}
],
"capabilities": [
"world_builder",
"ui",
"scripting.privileged"
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.18.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "2.0.0-alpha"
}
],
"metadata": {
"generated_with": {
"blockbench_entity_wizard": ["1.6.0"]
}
}
}

#

What i do wrong

wary edge
pseudo timber
pseudo timber
# wary edge Server needs to be 2.0.0-beta

{
"format_version": 2,
"header": {
"name": "§bInsanity MC V1.2",
"description": "§sMade By Dynamic!",
"min_engine_version": [1, 20, 0],
"uuid": "446dec93-559a-430a-a1af-97d4be714f4b",
"version": [1, 0, 0]
},
"modules": [
{
"type": "data",
"uuid": "9d822fb9-a3b8-41af-8ff0-8ac332b3ec8a",
"version": [1, 0, 0]
},
{
"type": "script",
"language": "javascript",
"uuid": "3d290939-a59d-47a8-8dd9-3c692cf08f4c",
"entry": "index.js",
"version": [1, 0, 0]
}
],
"capabilities": [
"world_builder",
"ui",
"scripting.privileged"
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "2.0.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "3.0.0-alpha"
}
],
"metadata": {
"generated_with": {
"blockbench_entity_wizard": ["1.6.0"]
}
}
}

#

what i do now lol

slow walrus
#

use server-ui 2.0.0-beta

pseudo timber
#

Oh

dim tusk
prisma shard
lethal flame
# dim tusk don't use itemUseOn use playerinteractwithBlock and use beforeEvents too

So it will be like this?

// Land Claim by Item
const CooldownSet = {}
world.beforeEvents.playerinteractwithBlock.subscribe(data => {
if (data.cancel) return
const { source } = data
if (data.itemStack.typeId == Server.Setting.get("itemClaimLand")) {
const Cooldown = CooldownSet[source.name] ?? Date.now()
data.cancel = true
if (Cooldown > Date.now()) return
if (data.source.isSneaking) {
EndPos(data.source, data.block.location)
} else {
StartPos(data.source, data.block.location)
}
CooldownSet[source.name] = Date.now() + 500
}
})

prisma shard
#

hell naw

#

playerInteractWithBlock not playerinteractwithBlock

dim tusk
lethal flame
dim tusk
lethal flame
dim tusk
#

huh???

lethal flame
#

Right click golden shovel to start the event

dim tusk
#
world.beforeEvents.playerInteractWithBlock.subscribe((ev, { block, player, itemStack } = ev) => {
  if (block.typeId === 'minecraft:end_rod') {
    if (itemStack?.typeId === 'minecraft:golden_shovel') {
      // ...
    } else {
      // ...
    }
  }
});```
lethal flame
#

I have import another js to read the item by using Server.Setting.get(“itemClaimLand”)

#

Im not sure what could go wrong

#

But i can try use yours

dim tusk
#

As long as it returns the right id it would work

ivory bough
#

How to detect blocks at a block's location every 500 ticks?

prisma shard
dim tusk
prisma shard
#

i still havent ported all my scripts to 2.0.0-beta lol

dim tusk
# ivory bough Can you give an example?
const volume = new BlockVolume({ x: 0, y: 0, z: 0 }, { x: 10, y: 10, z: 10 });
const blocks = Dimension.getBlocks(volume, {}, true);

for (const coord of blocks.getBlockLocationIterator()) {
  const block = Dimension.getBlock(coord);
}```
thorn flicker
unique acorn
#

I'm still confused as to why startup event doesn't work for some people

#

I tried everything and it worked for me

dim tusk
#

i didn't add it yet lol since my discord keeps crashing

warped kelp
#

Why does this not work?

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

{
world.afterEvents.entitySpawn.subscribe(({ entity }) => {
  try {
    if (entity.typeId === 'luv:phase2_akuma') {
      const entities = entity.dimension.getEntities({ type: 'luv:phase2_akuma' });

      if (entities.length > 1) {
        entity.remove();
        console.warn("Only one 'luv:phase2_akuma' entity can exist at a time!");
      }
    }
  } catch (error) {
    console.error("Error in entitySpawn event for luv:phase2_akuma (duplicate check):", error);
  }
});
warped kelp
#

Oof right

dim tusk
#

huh?

#

Wrong reply?

thorn flicker
dim tusk
slow walrus
#

Quick suggestion for anyone wanting a quick dirty fix for their beta scripts.

  • Rename your main.js (or equivalent) to something like old_main.js
  • Create a new main.js, and the add this
import { world } from "@minecraft/server"

world.afterEvents.worldLoad.subscribe(() => {
  import("./old_main")
})

This should fix any required privilege errors

dim tusk
#

No comment.

#

-# (insert meme)

thorn flicker
dim tusk
thorn flicker
#

lol

wheat condor
#

so now you cant import scripts if the world isnt fully loaded?

dim tusk
#

I'm addicted to using lol and lmfao

thorn flicker
#

I need help.

dim tusk
#

It make the conversation not dry or make my response don't sound bad or angry.

thorn flicker
dim tusk
#

you see how me adding . sounds mad lol

thorn flicker
dim tusk
dim tusk
thorn flicker
#

nah but really, its not that deep.

thorn flicker
#

calm down.

dim tusk
thorn flicker
#

"..." how condescending...

wary edge
#

We're getting off topic.

sage sparrow
#

I still need a fix for the registering custom compoents, saddly I cannot run my server without it and I believe moving to 1.18.0 will also not work many of my functions =\

dim tusk
thorn flicker
dim tusk
#

Maybe you can help?

sage sparrow
# dim tusk <@1147510275063423080>

I asked him already, but nothing worked. I still cannot believe it is a bug otherwise many ppl would be asking here and the few that asked said it was fixed but dont say how it was, I tried many ways including your suggestions I saw in some conversations.

oak lynx
#

new errors with every reload

#

updating gonna take a few minutes

#

now i need to update my global dimension variable

valid ice
#

await null

oak lynx
#

i just have this line after my imports export const dimension = world.getDimension("overworld")

sage sparrow
#

it is not possible to register custom components on world.afterEvents.worldLoad?

distant tulip
#

Custom components neeed to register in world start up, no?

slow walrus
#

trying to find out rn

#

oh yeah, you do it in the startup event

sage sparrow
#

the problem is that the startup is not even executing and cannot register custom components

distant tulip
#

Yeah, i seen people having the same problem

#

What beta stuff are you using

oak lynx
slim forum
#

What is going?

sage sparrow
oak lynx
#

i forgor to turn off my embeds for my local server 🤯

oak lynx
slim forum
#

Ok

distant tulip
shy leaf
#

since world.playSound is gone... what did it really do? did it play the sound across all the dimensions?

#

i used it before

oak lynx
#

i moved my 11.5k lines project to 2.0.0 in under an hour well i havent bug tested it yet

distant tulip
shy leaf
#

ah

dim tusk
oak lynx
#

wait so they just broke it completely

dim tusk
#

In stable release I guess? I use the preview version of 1.21.70 as of now and never had that problem

#

I'll update to 1.21.80 or to any update tomorrow

oak lynx
#

i just use the beta version on stable cuz updating every week on preview versions is too tiring

wary edge
#

joe_shrug Or just dont use beta.

valid ice
#

This is a mojang bug Sean

granite badger
#

my addon uses custom component and it works

oak lynx
valid ice
#

2/3 of my packs work, 1 does not

slim forum
#

I will go back to 1.18.0

granite badger
oak lynx
#

using a version with no chatSend before event is impossible

sage sparrow
wary edge
oak lynx
#

today right?

lethal flame
wary edge
#

One day!

#

Navi could just be fucking with us and delay it till 1.21.90 or 1.22.

#

Whichever is next.

valid ice
#

😭 noooooo

oak lynx
distant tulip
#

You could use scriptevent

ivory bough
oak lynx
#

wait what will we get after 1.21.90
1.21.100?

#

assuming they wont move to 1.22

dim tusk
#

only in 1.16

wary edge
dim tusk
ivory bough
# dim tusk yes.

Then is there a way to get its location through custom components?

dim tusk
distant tulip
#

And items

ivory bough
slim forum
#

Whyyyy

sage sparrow
#

lol... moved back to 1.18.0 and also world.beforeEvents.worldInitialize.subscribe is not being executed

#

so that is it, sit and wait for the fix =\

valid ice
wary edge
#

🙏 Before Shutdown.

wary edge
valid ice
#

Very niche 😛

wary edge
valid ice
slim forum
oak lynx
#

i have an array and instead of getting players each tick i add them when they join or leave

wary edge
slim forum
#

Let me check

#

Yeah, my bad

#

Sorry

oak lynx
slim forum
oak lynx
#

I am literally using playerLeave and playerJoin/Spawn no issues

slim forum
#

I don't find anything about getAllPlayers

#

So, Im going to wait a fix too

#

Cause...

oak lynx
slim forum
#

Hmmm, I see

#

Thanks 💕

chilly moth
#

oh someone already told you😅

#

deepseek told Me the to do that

#

and it worked for me

slim forum
#

My luck is that I keep all my scripts organized so I can correct them more easily

chilly moth
#

nice.

wary edge
#

#1354481778278273246

dim tusk
#

FIREEE.

#

Updating to 1.21.80.22 now.

chilly moth
#

whoa flat world customization

inland merlin
#

anyone having issues with transferPlayer working in 2.0.0?

unique acorn
inland merlin
#

it just doesn't do anything

valid ice
#

Did you make server admin 2.0.0-beta?

inland merlin
#

let me check

#

oh i didn't realize that changed too

valid ice
#

If you did- don't

inland merlin
#

i didn't

#

oh

valid ice
#

It's still 1.0.0-beta ye

#

Lol

inland merlin
#

ok lol

#

yeah its just not working

#

so not sure why

valid ice
#

Hmm

inland merlin
#

not allowed in single player worlds anymore?

#

thats where i was testing

valid ice
#

I'll test it when I get home

inland merlin
#

wait ill do a few more tests

#

then ill let you know if its still broken or not

inland merlin
#

i was just stupid

valid ice
inland merlin
#

lmao

unique acorn
#

so we dont need to loop thru every inventory slot anymore

jade grail
#

anything special u can do with the @minecraft/server alpha?

#

which u cant do with beta

#

im do lazy to read

#

Did they change before Event world initiliaze?

unique acorn
#

Yes

jade grail
#

so is there a new way to call it?

#

or they js remove it

unique acorn
#
system.beforeEvents.startup.subscribe()
#

this is now what you use to register custom components

jade grail
#

ah i saw that

#

what is the shutdown?

#

what can u use it for

unique acorn
#

allows you to run code right before the world is closed

#

which is (of course) in read mode only

jade grail
#

They removed runCommandAsync?

valid ice
#

Ye

unique acorn
#

yep

jade grail
#

damm

#

the lag

long hedge
#

can anyone explain what's happening here?

valid ice
unique acorn
pseudo timber
#

how this make sense

{
"format_version": 2,
"header": {
"description": "§l§bCustom Commands By §l§3InsanityMC",
"name": "§l§bCustom Commands V1.1",
"uuid": "863a0f3c-c988-4aa2-ba5b-2333c9926b2e",
"version": [1, 0, 0],
"min_engine_version": [1, 21, 62]
},
"modules": [
{
"description": "Custom Commands",
"entry": "scripts/help.js",
"type": "script",
"uuid": "3819b6af-4bd1-4d59-8ef3-51b107c3b500",
"version": [1, 0, 0]
}
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "2.0.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "2.0.0-beta"
}
]
}

unique acorn
long hedge
valid ice
#

Your pack isn't updating properly, then

long hedge
#

it says the ui module is requesting some non existant version lmao

jade grail
pseudo timber
unique acorn
#

then restart your game completly

pseudo timber
long hedge
valid ice
#

Your game is saying the pack is using old versions
The pack's manifest is using the latest versions

So the game isn't reading your changes properly

valid ice
#

Are you using dev folders

long hedge
#

yes

pseudo timber
#

no

valid ice
drifting ravenBOT
#
Using the `development_*_packs` folders

The correct way to create addons is by using the development_behavior_packs and development_resource_packs folders. Storing your addons here will allow you to reload the world to see addon changes, and will prevent pack caching issues.

You can work directly in the world, or in behavior_packs/resource_packs, but you need an understanding of manifest-versions and caching to avoid issues.

We highly recommend using the development_*_packs folders.

valid ice
pseudo timber
#

i forgot to lol ik how to do it

long hedge
#

eh?

#

why?

valid ice
pseudo timber
#

lol

night acorn
#

does anyone know how to get the aux / numerical id of custom blocks

long hedge
#

I mean I was using the stable version of ui module just fine up until this .70 so what happened now?

pseudo timber
#

mc messes packs up

long hedge
#

ofcourse, I'm the idiot for thinking that stable versions are going to be stable

pseudo timber
valid ice
pseudo timber
valid ice
pseudo timber
#

my dev packs not loading the file for commands stupid mc

random flint
#

The lore limit got increased right?

valid ice
pseudo timber
#

whats the lore limit now?

timid zenith
#
const overworld = world.getDimension("overworld"),
  nether = world.getDimension("nether"),
  end = world.getDimension("the end");

Privilege error in world.getDimension

pseudo timber
#

overworld is broke for me lol

unique acorn
#

per line

pseudo timber
#

dam

valid ice
pseudo timber
#

well

pseudo timber
unique acorn
past coyote
#

that seems hacky but damn ill take it 😭

shy leaf
shy leaf
#

like an array

unique acorn
past coyote
#

I'm still a little confused as to where to put this, I have a pretty big coadbase, is there a spot where I can put this where it would work throughout?

unique acorn
#

didnt notice it

unique acorn
#

so you just do

await null
const dimension = world.getDimension(...)
#

that wouldn't work

random flint
#

really?

unique acorn
#

wait lemme try

ivory bough
#

How to change the name of an already spawned entity without name tags?

random flint
onyx lantern
#

is there anyway I could get an early view at how custom component parameters will work?

#

like is it on preview or something

unique acorn
past coyote
#

do I have to put that inside every async function that uses world.getDimension

random flint
random flint
past coyote
#

that easy?

unique acorn
#

yep

past coyote
#

😭

unique acorn
#

that easy

past coyote
#

that feels so cheap

random flint
#

If you don't want to deal with earlyPrivilage stuff, thats the simple solution

past coyote
#

I'm so tempted to fix it the right way but I have so much code to fix 😭

onyx lantern
past coyote
#

if I do it with await null; I know its gonna make it so I can't use the command system, because bedrock commands load very early into world load

random flint
ivory bough
#

Also did world.getDimension get broken in the latest update?

random flint
#

You can't use most methods from the world class, except certain ones like the system class. (Basically new timings!)

Only happens if you call it outside any event.subscribe() or function scope.

import { stuff } from "module";

//Early Execution scope
world.sendMessage("UwU") //Privilage Error here
world.getDimension("overworld") //Privilage Error here

world.afterEvents.itemUse.subscribe((e)=>{
    //code is fine here
})

system.runInterval(()=>{
    //safe here too
})
past coyote
#
function stopSound(player, sound) {
  if (player?.isValid()) {
    player.runCommand(`stopsound @s "${sound}"`).catch(error => {
      console.warn(`Failed to stop '${sound}' for ${player?.name || "unknown"}: ${error.message}`);
    });
  }
}```

in a function like this, how would we rework it so "isValid" works properly again?
#

its not a boolean value

#

or is it just isValid() -> isValid

random flint
past coyote
#

Thats def the most interesting change out of all of this

#

so if runCommandAsync wasn't even async... runCommand should be ok?

valid ice
#

Ye

past coyote
#

I know theres a method for sounds, but when I tried to use it it played in the left or right ear when I played them on the player

#

kinda bugged

valid ice
#

Yeah, sounds have always been janky

past coyote
#

thats the only reason im using runCommand guys 😭 don't kill me

valid ice
#

Never had a pleasant experience with sounds, unless they're omnidirectional

slim forum
#

What they change here?

past coyote
#

😭

valid ice
#

system.beforeEvents.startup.subscribe(....

slim forum
#

Thanks

oak lynx
#

so like one thing i dont understand with runJob is that it finishes but i still have slowdowns in job queue for like a few seconds after

past coyote
#

Could I not theoretically CTRL+F my codebase and replace the old before/after events with the new startup stuff or is the underlying format different?

valid ice
#

It's pretty much the same, just be careful

oak lynx
#

does anyone have a list of minecraft blocks by how often they appear in a world

deep quiver
deep quiver
#
  1. maybe some dirt
oak lynx
#

1 is air

#

2 is stone

deep quiver
#
  1. maybe some dirt
unique acorn
#
  1. water
#
  1. deepslate
#
  1. dirt
valid ice
#
  1. The Rot
oak lynx
#
  1. well maybe someone knows how to save a large area of blocks to an array
deep quiver
#
  1. blockVolume
valid ice
oak lynx
deep quiver
#

Yes now think

#

Maybe perhaps you could call getBlock for all of those locations and store them in an array

#

Just a theory

oak lynx
#

you know how demanding millions of getBlock calls is?

deep quiver
#

Yes but thats what you want lol, theres no other way except for external tools which probably is your way to go

oak lynx
#
    public* blockVolumeToBlockTypeIdArray(blockVolume: BlockVolume) {
        const span = blockVolume.getSpan()
        const totalSize = span.x*span.y*span.z
        let i = 0;
        for (const id of blockById) {
            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`)
        const uniqueIds = [...new Set(this.vectorTypeIdArray.map(item => item.blockId))];
        console.log(`Unique block IDs: ${uniqueIds.join(", ")}`);
    }

this is faster assuming i hit all the blocks early

ivory bough
#

How to get block location of my custom block through custom component? Do I do it through blockontick?

random flint
#

In a nutshell, ye

night acorn
#

why tf is the id for the stairs rotation state "weirdo_direction"

random flint
#

stairs are weirdo

wary edge
#

Weird am I right?

past coyote
#

custom commands requiring namespaces is odd

wary edge
#

It is needed to prevent a more likely collision.

#

There's a whole discussion in #1354481778278273246 if you wanna catch up.

past coyote
#

thanks

past coyote
#

Two questions.

Does the structure manager have access to structures in the BP, and do I need a ticking area to place structure with the structure manager.

Using Server 2.0.0-beta

past coyote
#

Is this new to 2.0.0? @wary edge

wary edge
inland merlin
#

I still have to get used to the script startup and timing stuff

random flint
inland merlin
#

Every update is just gonna confuse newbies even more

random flint
#

I'm newbies

sterile epoch
#

why am I getting this error:
Version conflict for module @minecraft/server.
2.0.0-beta requested by (pack name) - 1.0.0
1.3.0 requested by @minecraft/server-ui 1.3.0

slow walrus
unique acorn
sterile epoch
#

gotcha

#

thanks

past coyote
#

Yeah I thought before and after events was bad 😭

glacial widget
prisma shard
#

quick question what is a await null

#

everyone telling it

open urchin
#

doesn't sound like something you should rely on

elder heath
#

Please pass the new manifest

prisma shard
elder heath
#

Thanks

distant tulip
#

how i feel updating my 10 line script without any errors

unique acorn
#

I updated my 400 line script with no errors 🙂

distant tulip
#

i did re-write 600 line of code but the part related to the update is not much
was using an open source script that i finally decided to write my own

north rapids
#

"world.beforeEvents.itemUseOn.subscribe" what is the new sintax?

distant tulip
#

playerInteractWithBlock

north rapids
#

remains as a beforeEvent?

distant tulip
#

yes
there is an itemStack property there

indigo parcel
#

Beta & Preview - 1.21.80.22

Experimental Technical Updates

bao_cmd_impulse_unc Custom Commands

  • Added support for custom commands authored in script. The new CustomCommandRegistry is provided when listening to ModuleStartupEvent. More APIs in the area will come in the coming weeks.
north rapids
#

so i don't need to use the before chatSend 😄

unique acorn
#

It's still in preview

north rapids
#

let's update my 1000 lines script

#

💀

past coyote
#

so I can't summon a "ticking" entity to a chunk thats unloaded?

#

I made an entity that acts as a ticking area but I can't even place it in the location I need it 😭

distant tulip
#

try tp

past coyote
#

teleport the entity there?

distant tulip
#

yep

past coyote
#

😭

distant tulip
#

try summon with commands first

past coyote
#

I can't most of my code expects async

#

idk something is really bugged, I think it has to do with runCommand being wierd now

patent tapir
#

Is it just not possible with scripts to decrease a player's LEVEL?

#

I can decrease the total xp just fine

#

But it will not, no matter what I do, push it below the player's current level and level them down

umbral dune
#

yeah custom slash commands :D

patent tapir
#

Never mind it does work my logic was just wrong

north rapids
#

player.runCommandAsync('execute at @s anchored eyes positioned ^^0.8^ run particle minecraft:basic_flame_particle');

#

what is the new sintax?

#

runCommandAsync got removed?

past coyote
#

yeah

#

gotta use runCommand (non-async)

#

the original wasn't async to begin with anyways

#

it was broken

north rapids
#

ok ty

patent tapir
#

Okay can someone please re-write this script for me cuz I'm stupid and this js const expLoss = (body.getTotalXp() / 10) const expHad = body.xpEarnedAtCurrentLevel if (expHad < expLoss) { system.run(() => { body.addLevels(-1) system.run(() => { body.addExperience(body.xpEarnedAtCurrentLevel - (Math.abs(expHad - expLoss))) }) }) } else { body.addExperience(-expLoss) }
...doesn't work fully. "Body" here is the dead entity and I want players to lose 10% of their total xp when they die.

#

The issue is that scripts won't decrease the player's LEVEL when it reaches that threshold and the logic I have doesn't work to simulate it.

inland merlin
#

how do i fix this?

const overworld = world.getDimension('overworld');

seems to struggle

#

?

#

should this work if its in the worldLoad afterEvents?

inland merlin
#

ok haha thx

wary edge
#

There is no world since world isnt loaded.

inland merlin
#

aww i see

#

i have a not a function im tryn to track down

#

lmao

fallen hearth
#

I have an entity that does not have this component, even doing this gives an error in the log:

let markVariant = projectile?.getComponent("mark_variant").value ?? null
dim tusk
warped blaze
#

I didn't quite understand all that stuff

wary edge
#

Yeah.

fallen hearth
#

[Scripting][error]-Error: Failed to call function 'getComponent' due to the Entity being invalid (has the Entity been removed?). at <anonymous> (projectileHitEntity.js:10)

warped blaze
dim tusk
#

You use projectileHitEntity? Or Block?

warped blaze
fallen hearth
dim tusk
#

just remove the destroy on hit thing

#

And remove the projectile manually in the event listener using projectile.remove()

lyric kestrel
wary edge
#

Yeah the entity is gone.

dim tusk
#

I already told you the solution, remove the remove_on_hit thingy in your projectile and do projectile.remove() instead in the scripts

distant tulip
dim tusk
#

I'm having a Mandela effect or something?

thorn flicker
dim tusk
#

Everything is floaty rn

thorn flicker
#

im confused about what minato said too

#

im not questioning your logic or anything

fallen hearth
thorn flicker
#

wdym

#

also I think it would be better just to give the projectile the instant despawn component through component groups, triggered from on_hit

#

no scripts needed

distant tulip
# dim tusk what?

Just asking a question, What's confusing about it?
Does projectile api have a removeOnHit property or not

dim tusk
distant tulip
#

bao_icon_entities i just read something different seconds ago

dim tusk
#

Lol

thorn flicker
rose light
#

Did they remove CustomComponent from API 2.0? Is there no other alternative without me having to use an older version?

rose light
wary edge
#

No.

distant tulip
#

Smokey most used reply

deep yew
#

No.

valid ice
#

No

valid ice
rose light
valid ice
#

It’s an event

rose light
rose light
distant tulip
valid ice
rose light
#

never seen before

distant tulip
valid ice
#

eh..... no

dim tusk
#

Idk how it doesn't work.

valid ice
#

But Jayly said it's because of the overhead I have on initialization, so the event doesn't fire until after it's supposed to... somehow that makes logical sense

distant tulip
#

I should test that out too

valid ice
rose light
#

disguise, I forgot to put the beta in the manifest

valid ice
#

Waiter! Waiter! More v2 nonsense, please!

rose light
#

How do I solve this? @valid ice

#
    system.beforeEvents.startup.subscribe(ev => {
            ev.blockComponentRegistry.registerCustomComponent("dz:tick", {
                onTick: ((dz) => {
                    const { block, dimension } = dz;
                    if (block) {
                        callback(block, dimension);
                    }
                })
            });
        });```
valid ice
#

Make sure you're on 2.0.0-beta n' 1.21.70

rose light
#

v

valid ice
#

dev packs?

rose light
#

ahhh

lyric kestrel
valid ice
#

Yeah

#

The event... just never fires

lyric kestrel
#

Are you using the new event thingy when loading in?

#

The pre-loading thing

valid ice
#

That's the event that registers custom components, so yes

lyric kestrel
#

no clue then

valid ice
#

Jayly said what the problem was lol

lyric kestrel
#

Speaking of fixing stuff, I've fixed my code and refined it so much more now so it's easily expandable

#
try {
            for (let i = 1; i <= 20; i++) {
                let tall_wedge = `tall_wedge${i}`
                camoState = getCamoState(blockType, tall_wedge)
                if (camoState){
                    blockKey = tall_wedge
                    break;
                }
            }
        } catch (error) {
            console.log("An error has occurred:", error)
        }``` Instead of
```js
const tall_wedges = ["tall_wedge1", "tall_wedge2", "tall_wedge3", "tall_wedge4","tall_wedge5", "tall_wedge6", "tall_wedge7", "tall_wedge8", "tall_wedge9", "tall_wedge10", "tall_wedge11", "tall_wedge12", "tall_wedge13", "tall_wedge14", "tall_wedge15", "tall_wedge16", "tall_wedge17"]
        for (const tall_wedge of tall_wedges) {
            camoState = getCamoState(blockType, tall_wedge)
            if (camoState){
                blockKey = tall_wedge
                break;
            }
        };
        if (!camoState) return;```
#

It's so much better xD

valid ice
lyric kestrel
#

although, I might change the 20 in for (let i = 1; i <= 20; i++) to a const to make it easier to read

#

When I put it on mcpedl or wherever, I do want people to be able to add their own blocks to it, so I need to work a lot more on the easy editing

thorn flicker
valid ice
#

Constant file / config file is the way to go for users

#

Make it braindead 😛

lyric kestrel
lyric kestrel
#

I might xD

thorn flicker
lyric kestrel
#

oh no lol

thorn flicker
#

i didnt read correctly

#

mb

lyric kestrel
#

Just the ceiling

#

You're grand, man

#

No worries 👍

#

And when I'm done with the tall, medium and small wedges, Imma start working on a custom lantern frame block

#

They all use the same Map array for their textures and states across the different types

sterile epoch
#

what's the difference between world load and system startup

dim tusk
#

aww man, I was about to send it.

valid ice
lyric kestrel
midnight ridge
# valid ice

it thats why world dynamic and scorboard need to be add to worldLoad or system.run ?

distant tulip
#

Yes, if they are in a scope that excute before the world actually load

timid zenith
#

Someone to help me my database the new version of minecraft is damaged :/

pale grail
#

anyone able to help on this issue im having
do you know how to fix this

[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (Epics/Pokemon Battles/main.js:80)

below is the line it refers to with the error
hitter.applyKnockback(direction.x, direction.z, -2, 0.5);

valid ice
#

hitter.applyKnockback({x:direction.x*-2, z:direction.z*-2}, 0.5);

pale grail
#

thank you

valid ice
#

Note the changes :)

timid zenith
pale grail
gaunt salmonBOT
pale grail
#

so maybe there is a valid reason

#

idk

gaunt salmonBOT
elder heath
#

wy?

[Scripting][error]-Plugin [Test All Addons - 1.0.0] - failed to create context.

[Scripting][error]-Plugin [Test All Addons] - version conflict for module [@minecraft/server].
[2.0.0-beta] requested by [Test All Addons - 1.0.0],
[1.3.0] requested by [@minecraft/server-ui - 1.3.0]

[Scripting][error]-Plugin [Test All Addons - 1.0.0] - run failed, no runtime or context available.

#

{
"format_version": 2,
"metadata": {
"authors": [
"IIBl4z3MasterII"
],
"generated_with": {
"bridge": [
"2.7.44"
],
"dash": [
"0.11.7"
]
}
},
"header": {
"name": "Test All Addons",
"description": "Test All Addon By: IIBl4z3MasterII",
"min_engine_version": [
1,
21,
70
],
"uuid": "d9e585e4-5aa9-47f2-9b7d-1fdfe73d4a5e",
"version": [
1,
0,
0
]
},
"modules": [
{
"type": "data",
"uuid": "667c1f9e-adfa-400e-ad6b-29156aa577b5",
"version": [
1,
0,
0
]
},
{
"type": "script",
"language": "javascript",
"uuid": "01ea94d3-f0a6-46eb-9222-c939e95ca9f8",
"entry": "scripts/index.js",
"version": [
1,
0,
0
]
}
],
"dependencies": [
{
"uuid": "5fdaa6a1-ac4d-47e0-9335-b30dc92e6281",
"version": [
1,
0,
0
]
},
{
"module_name": "@minecraft/server",
"version": "2.0.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.3.0"
}
]
}

timid zenith
elder heath
#

thanks

dense skiff
#

Did the addon achievements change make it so all addons now allow achievements or how does that work?

wary edge
dense skiff
#

Wdym it's being patched lol

wary edge
dense skiff
#

So currently it's all, but in the future it will be marketplace only

wary edge
#

Ye.

unique acorn
fallen hearth
#

[Scripting] LocationInUnloadedChunkError: Trying to access location (-502.0, 11.0, 9.0) which is not in a chunk currently loaded and ticking. at <anonymous>

system.runInterval(() => {
  world.sendMessage({ translate: "server.texto_2" })
}, 5500)
sharp elbow
#

You sure that is the affected call? That has little to do with a location

pale terrace
#

its possible to get client camera movement?

woven canopy
#

NOOOOOOOOOOO

timid zenith
#

Someone to help me my database the new version of minecraft is damaged :/ Someone help me

inland merlin
#

Other code

#

Database will send errors but it's the new 2.0.0-beta change that's messing with it

lyric kestrel
lyric kestrel
#

And it's saying that the chunk you're trying to search at those coordinates, isn't loaded

fallen hearth
lyric kestrel
#

Or anything about locating

shy leaf
#

in server forms, does divider, label and header also count in formValues?

fallen hearth
lyric kestrel
#

Where does it indicate that?

fallen hearth
lyric kestrel
#

How do you know the<anonymous> refers to that?

#

Is there more to the error?

fallen hearth
#

[Scripting] LocationInUnloadedChunkError: Trying to access location (-502.0, 11.0, 9.0) which is not in a chunk currently loaded and ticking. at <anonymous> (principal.js:4)

#
import { world, system } from "@minecraft/server";

system.runInterval(() => {
  world.sendMessage({ translate: "server.texto_1" })
}, 6500)
lyric kestrel
#

Thank you

fallen hearth
#

just need to ask for the file name

prisma shard
lyric tiger
#

Yo

#

Wsg

#

100k

valid ice
#

we're way past 100k

lethal flame
#

Hi, how to make custom name for minecraft:paper ?

I want to make sure player got custom name that I set for that paper

My code is

{ item = "paper" , quantity= 3}

So it will

runCommand(`give @s ${item} ${quantity})

#

Nvm it's setLore

oak lynx
granite cape
wheat condor
#

so now world.getDimension() requires to be ran in system.run()

distant tulip
wheat condor
distant tulip
#

They can't delay a function execution just like that

shy leaf
#

tfw i have to change every Date.now() to system.currentTick because of game pause feature

stuck ibex
granite cape
#

name not optional

prisma shard
stuck ibex
prisma shard
granite cape
unique acorn
granite cape
#

different

stuck ibex
granite cape
unique acorn
#

no, namespace is required

granite cape
#

wait

flat barn
#

Bro wtf

#

why tf has mojang removed Proxies

granite cape
unique acorn
#

huh

granite cape
#

like we need add prefix for the namespace?
prefix:command

#

?

unique acorn
shy leaf
granite cape
#

weit what

#

um ok i understand

distant tulip
#

Navi said they might look into ways to allow the use of custom commands without namespace but still make it a requirement for marketplace content

deep quiver
#

Yep

#

#879773489601585244 message

past coyote
coral ermine
#
const healthComp = player.getComponent("health");
                if (healthComp) {
                    healthComp.currentValue = Math.min(healthComp.value, healthComp.currentValue + recovered);
                }

error: currentValue is read-only

#

or how to heal player?

#

without effects

fallen cape
coral ermine
fallen cape
#

healthComp.setCurrentValue(10)?

#

ig

prisma shard
coral ermine
inland merlin
prisma shard
turbid delta
#

This hurts for real

distant tulip
#

perhaps mention why and suggest a better way

prisma shard
glacial widget
prisma shard
#
world.afterEvents.worldLoad.subscribe(ev => {
  await null;
  world.getDimension("overworld").runCommand(`scoreboard players add @p playjoined 1`);
  world.getDimension("overworld").runCommand(`scoreboard players set @p kit 0`);
  world.getDimension("overworld").runCommand(`function firstjoin`);
}```
#

code look different but the result is same

unique acorn
#

you dont need await null there

prisma shard
#

await null is also a delay

prisma shard
#

(jk)

unique acorn
#

peak

prisma shard
coral ermine
#

How to remove durability from player armor?

cinder shadow
#

anyone ever get errors for things that just don't exist in their code?

#

oh, the content log error is just spitting out misinfo 😔 figured it out

rose light
#

[Scripting][error]-ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (modulo/all_class/database/ScoreboardAapi.js:2)

[Scripting][error]-Plugin [script expansion - 1.0.0] - [main.js] ran with error: [ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (modulo/all_class/database/ScoreboardAapi.js:2)

Does anyone know how to resolve this error in the new stable beta version?

unique acorn
rose light
#

what

#

do you have to do this now?

unique acorn
#

yep

#

or you can put the variable scoreboard inside the class

rose light
unique acorn
#

yeah

rose light
#

is my using TypeScript

unique acorn
# rose light is my using TypeScript
import { Entity, ScoreboardIdentity, ScoreboardObjective, world } from "@minecraft/server";

let scoreboard;

world.afterEvents.worldLoad.subscribe(() => {
  scoreboard = world.scoreboard;
})


class Scoreboard {
    objectiveId: string;
    objectiveDisplayName: string;
    objective: ScoreboardObjective | undefined;

    constructor(objectiveId: string, objectiveDisplayName: string = objectiveId) {
        this.objectiveId = objectiveId;
        this.objectiveDisplayName = objectiveDisplayName;

        if (!Scoreboard.hasObjective(objectiveId)) {
            Scoreboard.addObjective(objectiveId, objectiveDisplayName);
        }

        this.objective = Scoreboard.getObjective(this.objectiveId);
        this.objectiveDisplayName = this.objective?.displayName || objectiveDisplayName;
    }

    static getObjective(objectiveId: string): ScoreboardObjective | undefined {
        return scoreboard.getObjective(objectiveId);
    }

    static getParticipants(): ScoreboardIdentity[] {
        return scoreboard.getParticipants();
    }

    static getObjectives(): ScoreboardObjective[] {
        return scoreboard.getObjectives();
    }

    static addObjective(objectiveId: string, displayName: string = objectiveId): ScoreboardObjective {
        return scoreboard.addObjective(objectiveId, displayName);
    }

    static removeObjective(objectiveId: string): boolean {
        return scoreboard.removeObjective(objectiveId);
    }

    static hasObjective(objectiveId: string): boolean {
        return scoreboard.getObjective(objectiveId) !== undefined;
    }

    getObjectiveInfo(): object | undefined {
        const objective = this.objective;
        return objective ? { ...objective, size: this.size } : undefined;
    }

    getScore(participant: string | Entity | ScoreboardIdentity): number | undefined {
        return this.objective?.getScore(participant);
    }

    setScore(participant: string | Entity | ScoreboardIdentity, score: number): number | undefined {
        this.objective?.setScore(participant, score);
        return this.getScore(participant);
    }

    clearParticipants(): void {
        scoreboard.getParticipants().forEach(participant => {
            this.removeParticipant(participant.displayName);
        });
    }

    hasParticipant(participant: string | Entity | ScoreboardIdentity): boolean {
        return this.objective?.hasParticipant(participant) || false;
    }

    getParticipants(): ScoreboardIdentity[] | undefined {
        return scoreboard.getObjective(this.objectiveId)?.getParticipants();
    }

    removeParticipant(participant: string | Entity | ScoreboardIdentity): boolean {
        return this.objective?.removeParticipant(participant) || false;
    }

    get size(): number {
        return this.objective?.getParticipants().length || 0;
    }
}

export {
    Scoreboard
};
sterile epoch
#

is there a reliable way to detect the host of a realm?

rose light
#

man, I'm screwed, the amount of coding I did

elder heath
#

why?

"[Scripting][warning]-Error sending world message: ReferenceError: Native function [World::sendMessage] does not have required privileges."

function safeSendMessage(message) {
try {
world.sendMessage(message);
} catch (error) {
console.warn("Error sending world message:", error);
}
}

deep yew
#
  1. Send code in a code block using the back tick (`):
    ```
    code here...
    ```

  2. You need to put the world.sendMessage(...) into system.run(()=>{ here }) like

function safeSendMessage(message) {
    try {
        system.run(()=>{
            world.sendMessage(message);
        })
    } catch (error) {
        console.warn("Error sending world message:", error);
    }
}
#

@elder heath

patent tapir
#

Is anyone excited for custom commands??

#

I certainly am

#

Unfortunately I don't know how to use typescript lol

deep yew
#

Is there a way to get an item's number ID using scripts? I only know of using a utility mod to get the ID number, but not a "legit" way

narrow patio
#

how do you make a simple custom cmd without typescript?

patent tapir
#

Woah

deep yew
patent tapir
narrow patio
#

oh, ty

deep yew
unique acorn
patent tapir
#

I found out there was custom commands from the Minecraft Creator Channel

#

Which used typescript

#

And typescript feels "non-standard" to me so I just automatically assumed it was ts only

unique acorn
#

minecraft can't even read typescript in the first place

#

they just compile their code to js

patent tapir
#

Well now I need to figure out how to make them, whether or whether not there's autocompletions in Bridge

deep yew
patent tapir
#

Sounds good to me then

#

Although it's very new and unstable (probably) and I'll need to update the scripts when the next update drops :/

unique acorn
#

/cen:sayhello

patent tapir
#

Shouldn't be too hard though

deep yew
#

Note: The namespace (cen:sayhello) is required. It can be a: or reallylongnamespaceidkwhy: but it needs one

#

just use the docs

patent tapir
#

Yeah

deep yew
#

and remember it's only in preview right now

unique acorn
#

status: 1 is failure

patent tapir
#

chatSend seems pretty stable to me by now

patent tapir
deep yew
#

yes, I don't know what really is still "beta" about it

patent tapir
#

Gah, the docs have the tutorials in typescript

unique acorn
#

ignore the typescript stuff

#

should be the same

patent tapir
#

Why does typescript even exist as a scripting option if it's just an alternative JavaScript that Minecraft can't even read on its own?

unique acorn
#

minecraft isn't the only one using javascript or typescript

#

typescript has more features ig

#

even tho I don't use it

patent tapir
#

It still gets compiled into JavaScript

#

Which means it has to have the same features

wary edge
#

Typescript is amazing for larger projects and for types safety.

patent tapir
thorn flicker
deep yew
#

Typescript shows and uses types more than javascript, so you can specify, basically, what type you want variables and stuff to be, what type a function returns, etc.

patent tapir
#

Oh ok

deep yew
#

Just because it gets compiled in minecraft doesn't mean it's useless

#

It's basically like having a function. Why not just copy and paste all the function code into everywhere it's needed instead of just calling the function?

#

Because you don't want to, or it wouldn't be right

#

It's helpful and in some cases can solve issues that may not work in javascript alone, or help beginners so they don't have to remember complex tasks

#

Do what is best for you, and that for us is typescript

elder heath
fallen hearth
#
let objective = world.scoreboard.getObjective("teste") ?? world.scoreboard.addObjective("Teste", "");

does not have required privileges.

rose light
#

I haven't been able to use worldLoad so far

fallen hearth
dim tusk
dim tusk
#
let obj;
world.afterEvents.worldLoad.subscribe(() => {
  obj = world.scoreboard....
});```
deep yew
#

I defined the variable first, empty, then set the value of it in system run, then (if needed) export it after

#

like shown above

rose light
#

and how do you do this for a class that uses world?

deep yew
#

You should be able to do system.run in the class. Otherwise, provide context for better help please

#

Does anyone have a "legit" way to get block/item number IDs?

rose light
#

I'm using a class that creates a database using a scoreboard, but every time I call it, I get that privilege error.

deep yew
#

try surrounding code with system.run(()=>{...})

rose light
#

or numberId

deep yew
#

number ID:

rose light
deep yew
#

There probably is, but I need it for custom items as well

rose light
#

Well, I've never seen a code that takes the ID as a number

steady canopy
deep yew
rose light
#

How do I load the class so this shit stops returning an error?

timid zenith
#

Someone help me fix a problem

dim tusk
#

There's no direct way without you manually doing it.

#

either get Herobrine's chest ui

deep yew
timid zenith
dim tusk
#

Or check the Microsoft docs

rose light
#

you have to specify the id in the object and get it later

deep yew
thorn flicker
deep yew
dim tusk
#

an OA act, you don't need to "X" it just for that, just say give the code.

deep yew
#

I was not trying to show disrespect or rudeness

thorn flicker
#

there's more respectful ways

dim tusk
#

What you did is kinda rude ngl.

thorn flicker
#

on the other side, they couldive actually asked

timid zenith
deep yew
#

Okay I do apologize, it was not meant to say anything like you don't deserve or get help.

timid zenith
#

Nariz, casi inglés

rose light
#

you may have put the const name wrong

rose light
timid zenith
#

?

dim tusk
#

Are you sure the file you're editing is the right one?

deep yew
#

Is HomeSystem defined in your main file? Imported?

rose light
timid zenith
#

I've already checked several times aaaaa

dim tusk
#

As I can see the HomeSystem is in the same file, I don't think it should throw isn't defined error.

deep yew
#

HomeSystem is in sethome.js not main

dim tusk
#

Bruh.

#

export it.

#

export function ....