#Script API General

1 messages · Page 67 of 1

boreal siren
#

What will it give me? Can you give me more details?

dim tusk
#

With speed 100 in y-axis

boreal siren
#

Why do I need this? I need the item to be impossible to pick up by the player.

#

Like a component that doesn't allow you to pick it up

dim tusk
dim tusk
boreal siren
#

Oh, sorry for not expressing myself correctly, I need the item to have a property, or a system that does not allow the player to pick up the item

dim tusk
#

Make a fake item drop.

boreal siren
solar dagger
#

Honestly I don't think you can stop specific items from being picked up

boreal siren
#

Okay, I was just thinking, can you make a custom entity that will hold the item?

fast lark
#

Best Pokemon addon?

ivory bough
#

Is there any way to take a photo from an entity's pov and then display it on the player's screen?

thorn flicker
night acorn
#

i mean you could use the /camera command or teleport the player to the entities head location with entity.getHeadLocation()

ivory bough
#

How do the bedrock replay mods do it?

twilit tartan
#

Someone can help me with my question pls!?chill_guy

night acorn
#

anyway, my turn for a question, is there a max size for dynamic properties?

#

specifically world properties

gaunt flare
#

Minato is typing...

random flint
#

Minato is typing...

distant tulip
#

canceled

random flint
#

bummer

distant tulip
valid ice
#

Number limit is 64-bit float

#

(Very large)

distant tulip
twilit tartan
distant tulip
#

do what

random flint
# ivory bough Yeah how to do that?

It records actions by utilizing world events and entity properties. Compiling each change into linear recording/data that can be interpolated and reenacted using Gametest and Native methods.

The camera's stuff is there for an optional cinematic mobility tool. Probably doesn't take much play in inner-working.

#

It doesn't take photos or actually 'recording' it as a video. It's like a 3D scanner checking what happened where and when then reenacting it back as best as it could.

Such system can't be done with only the vanilla's client. It's relying on the server-side features. This means you can't use it on random servers without permission and be able to record everything.

shut vessel
#

you know how to duplicate a message from a command of the same style as a msg but by a command with a "!"

sharp elbow
#

Can you give an example?

past coyote
# shut vessel you know how to duplicate a message from a command of the same style as a msg bu...
import { world } from "@minecraft/server";

world.beforeEvents.chatSend.subscribe((eventData) => {
    const player = eventData.sender; // The player who sent the message
    const message = eventData.message; // The full message typed in chat


    if (message.startsWith("!msg ")) {
        eventData.cancel = true; // Prevent the original message from appearing in chat

        // Split the message into parts: "!msg <target> <message>"
        const args = message.split(" ").slice(1); // Remove "!msg" and get the rest
        if (args.length < 2) {
            player.sendMessage("Usage: !msg <player> <message>");
            return;
        }

        const targetName = args[0]; // The target player's name
        const privateMessage = args.slice(1).join(" "); // The message to send

        // Find the target player
        const targetPlayer = world.getAllPlayers().find(p => p.name === targetName);

        if (!targetPlayer) {
            player.sendMessage(`Player "${targetName}" not found.`);
            return;
        }

        // Send the private message to the target player
        targetPlayer.sendMessage(`[Private from ${player.name}]: ${privateMessage}`);
        player.sendMessage(`[To ${targetName}]: ${privateMessage}`);
    }
});```
dawn zealot
past coyote
#

Thanks 😅

#

I gotta cancel the command sending without anything in it

#

I think its my own chat script conflicting

valid scaffold
#

does anyone know why this isn't working? It seems to not be able to grab an entity with the property value of 0?

const worm1 = entity.dimension.getEntities({families:["blood_worm"],location:entity.location,maxDistance:50,propertyOptions: [{ propertyId: 'os_br:segment',value:Boolean(0) }]})
dim tusk
#

If you want to check numbers, why do Boolean(0)??

#

it returns true or false since it's a Boolean.

valid scaffold
valid scaffold
#
"properties": {
    "os_br:segment": {
        "type": "int",
        "range": [
            0,
            12
        ],
        "default": 0
    }
}
dim tusk
#

obviously it wouldn't work since in your entity you used numbers not true or false

past coyote
#

😭

valid scaffold
past coyote
#

Boolean means true or false

valid scaffold
#

Had a brain fart

#
            const worm1 = entity.dimension.getEntities({families:["blood_worm"],location:entity.location,maxDistance:50,propertyOptions: [{ propertyId: 'os_br:segment',value: { lessThanOrEquals: 0 }}]})

will this work?

past coyote
#

Yeah

valid scaffold
#

Thanks and sorry for taking up your time lol. I can't believe I was sitting here for a good minute like bruh.

cinder shadow
past coyote
#

We couldn't understand what he wanted and I like little coding exercises

shy leaf
#
const viewDir = player.getViewDirection();
viewDir.y = 0
console.log(viewDir.y) // 0?

i wonder if this works?

shy leaf
#

so im just not sure

#

feels like the game could yell at me anytime

dim tusk
dim tusk
#

but tbh, I don't like doing that.

shy leaf
shy leaf
#

oh

rose light
#

Could I use the script to make one entity attack another? I interact with one, and then with another, and they start attacking each other.

#

??

dim tusk
rose light
dim tusk
#

no.

rose light
#

😭

past coyote
# shy leaf ```js const viewDir = player.getViewDirection(); viewDir.y = 0 console.log(viewD...

const viewDir = (function fetchTheVector() {
    return player.getViewDirection() || { x: 0, y: 0, z: 0 };
})();

// SUPER PERCISE!!
viewDir.y = (function resetTheYComponent() {
    const zero = Math.min(Math.max(Math.sin(Math.PI / 2) - Math.cos(Math.PI / 2), -0), 0); // math for no reason
    return zero * Math.pow(Math.E, Math.log(1)) * Math.round(Math.random() * 0); // Zero, but make it fancy
})();


console.log(
    (function checkTheResult() {
        const yValue = viewDir.y;
        const isZero = yValue === 0 ? "Y is zero" : "Y is " + yValue;
        return `${isZero} (Verified: ${
            Array(5).fill().reduce((acc) => acc + yValue, 0) === 0 
                ? "Confirmed by five checks" 
                : "Something’s off"
        })`;
    })()
);```
rose light
#

not even in the experimental? or in the preview experimental

past coyote
dim tusk
# past coyote I try
system.runInterval(() => {
  for (const player of world.getPlayers()) {
    const { getComponent, inputInfo: { getMovementVector } } = player;
    const movementVector = getMovementVector.call(player.inputInfo);
    const health = getComponent.call(player, 'health');
    console.error(JSON.stringify(movementVector), health.currentValue);
  }
});```
past coyote
#

Oh thats really terrible

shy leaf
#

i didnt expect a simple question to turn into a nausea-inducing code competition

dim tusk
#
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {
  if (message.includes('test')) {
    ev.cancel = true;
  }
});```
shy leaf
#

why

past coyote
#

thats nothing...

dim tusk
#
const { dimension: { id, heightRage: { min, max } } } = player;

console.error(id, min, max);
past coyote
shut citrus
#

How to detect the game is lagging?

past coyote
#

Coddy, imagine us being absolute menaces and 'helping' people with the most over-engineered shit like bloated code with layers of unnecessary abstractions, redundant loops, and pointless async. Like, it’d technically work, so most of the script kiddies wouldn't know anything lol

dim tusk
#

As much as possible I lessen it.

ivory bough
ivory bough
#

I basically wanna get an entity's pov and play it on the player's screen

drifting ravenBOT
#
Info

This bot was created by SmokeyStack for the purpose of making a FAQ bot for the Bedrock Add-Ons Discord Server.

Managing Entries

To manage entries, please make a pull request on GitHub.

Source Code
amber granite
#

Guys

#

Need help fr

woven loom
#

hm

amber granite
#

Wait me to send video

#

Why the components dosen't get showed up

#

After clicking "ctrl + space"

#

@woven loom

woven loom
#

do other suggestions show up

amber granite
#

No

#

I mean only some random words

#

In the script

#

But not the suggestion

#

What i did wrong?

woven loom
#

LSP is not working then

#

look to fix that

amber granite
#

How i make it work : |

woven loom
#

Where the types were installed

amber granite
#

In user/node_packages

woven loom
#

Try installing in the addon folder.

amber granite
#

Ok

#

I mean there is intellisense

#

But components intellisense doesn't work

acoustic basin
#

guys, is there a way to get player/entities fall distance? i know there's fallDistance property, but it's for fall on custom component for block...

amber granite
#

What i did wrong ?

#

In my new pc

#

In my old pc

unique acorn
cold grove
#

Bot is down soooo

#

Im the bot

amber granite
#

I did install server 1.17.0

unique acorn
#

you need beta

amber granite
#

Why ?

unique acorn
#

idk, those only show on beta

amber granite
#

Sure ?

cold grove
#

Its ok, blockExplode is stable

amber granite
#

I didn't know that

cold grove
amber granite
#

That only

#

Everything else works fine

cold grove
#

Like, other autocompletions work normally

amber granite
#

Yes

cold grove
#

Aahh, just use enums

amber granite
#

But components string suggestions dosen't work

amber granite
cold grove
#

Import BlockComponentTypes

cold grove
amber granite
#

Yes

#

I mean propreties

#

Of that component

cold grove
#

do you mean getComponent() method

amber granite
#

Yes

cold grove
ivory bough
#

how to set the player's pov the pov of an entity? Without teleporing there

amber granite
#

Does anyone knows how to setup it ?

ivory bough
# wary edge Camera API.

Also how to replay addons kinda record the frames of the past? I basically wanna capture some frames from an entity's pov and then play it later.

somber cedar
#

How do I add text like the one in the screenshot

wary edge
somber cedar
somber cedar
#

It's in preview...

#

thx

boreal siren
#

Guys, how can I make it so that the form opens only after the chat is closed?

#

I just wanted to make it so that the form would open when entering a command.

shy leaf
gaunt salmonBOT
#

Description
Force the game to show a UI form to player.

Credits
These scripts were written by Jayly#1397 on Jayly Discord, Worldwidebrine#9037 on Bedrock Add-Ons

boreal siren
#

How to use it? Can you show an example?

shy leaf
#
function configForm(player) {
    let form = new ModalFormData()
    form.show(player).then((response) => {
            const { canceled, formValues, cancelationReason } = response;
     
            if (response && canceled && cancelationReason === "UserBusy") {
                configForm(player);
                return;
            }
    })
}```

smth like this
#

jayly's method should work too, though i find this easier

boreal siren
#

Ahh, it creates a cyclic launch of the form using a special event?

shy leaf
#

and since youre only making the form to show up when the player is not busy, itll work

boreal siren
#

I didn't know

shy leaf
#

never experienced any lags with it btw

prisma shard
prisma shard
#

anyways

boreal siren
#

Can I use another method? For example, instead of a function, just try to call "show" on a loop?

warped kelp
#

Is there a way to detect if a player is wearing a mob head like a skeleton/wither skeleton for example, so that a specific mob won't attack the player?

boreal siren
#

It can be determined, but I don't know that the entity would ignore the player.

warped kelp
shy leaf
warped kelp
#

True

boreal siren
#

As I understand it, with the help of scripts, you can only get information about components, but not interact (except for inventory)

warped kelp
#

Could it have something to do with if a player is within a certain radius of the entity, if the player does not have the mob head, it takes damage from the player (once) to target the player?

#

Could be like check every 10 ticks, but for some reason my execute commands used by functions do not work

boreal siren
boreal siren
cinder shadow
#

anyone know if there's a way to stop items from duping with itemUseOn events?

ivory bough
#

Also how do replay addons kinda record the frames of the past? I basically wanna capture some frames from an entity's pov and then play it later.

cinder shadow
#

yeah, you always have to set the item though, don't you?

shy leaf
#

i think i have a solution for this, hold on

warped kelp
shy leaf
#

aaand is it afterEvents or beforeEvents?

cinder shadow
#

nope, it's just for clicking something on any block

shy leaf
#

beforeEvents then

cinder shadow
#

it's using the onUseOn itemRegistry component

shy leaf
#

oh

#

hmmm custom components, rarely touched those

#

how are you setting the item rn?

cinder shadow
#

lazy way, I just realized I can fix this

#

I always just use player.selectedSlotIndex

#

I'm just going ot need to grab the slot the item is in first

#

then use that

shy leaf
#

oh yeah i think that might be the reason

#

try using equippable component from Entity instead

#

theres setEquipment function for it

shy leaf
#

-# dont tell me youre using that code as whole

boreal siren
#

No, I rewrote it for myself.

shy leaf
#

odd

#

no content logs?

boreal siren
#
import { world, system } from "@minecraft/server";
import { ModalFormData } from "@minecraft/server-ui";

console.warn("Script runed...");

world.beforeEvents.chatSend.subscribe((event) => {
    const player = event.sender;
    const message = event.message;
    if (message == "!open") {
        event.cancel = true;
        formUse(player);    
    }
})

function formUse(player) {
    const form = new ModalFormData()
        .title("MEnu")
        .textField("Write what you want", "§7write here...")
        .show(player)
        .then((r) => {
            const { canceled, formValue, cancelationReason } = r;
            if (r && canceled && cancelationReason === "UserBusy") {
                formUse(player);
                return;
            }
            player.sendMessage(`Your message: ${formValue}`);
        })
}
#

What did I do wrong?

shy leaf
#

oh uh i think you wanna do form.show(player).then() instead of doing it like that

#

i dunno why but

#

sometimes javascript just goes coco crazy and make the work-able to not work

cold grove
#

show() can't be called in read-only mode

shy leaf
#

is that

#

oh thats beforeEvents...

#

yeah, wrap it in system.run()

boreal siren
#

a okey

#

Yeah, It's working

#

thanks

cinder shadow
#

even if I grab it at the very beginning of the event, the slot is wrong

ivory bough
#

How to run some code in the location of a block every 200 ticks?

inland flax
#

Does anyone know how to make duels bots eg, easy, medium and hard?

cinder shadow
#

but it's ridiculously easy

cinder shadow
#

I think the only solution for this would be if I loop through the hotbar slots for any stack with the item first

#

but that will have it's own problems

cinder shadow
#

itemRegistry onUseOn

#

all you have to do is try and use the stackable item and then use your scroll wheel at the same time

covert grove
granite badger
distant tulip
covert grove
distant tulip
#

read that again

#

"renamed"

covert grove
#

im using BeforeEvent not AfterEvent, i read it right

distant tulip
#

you are using 2.0.0-beta?

covert grove
#

or am i actually missing something

#

yes

distant tulip
#

yeah, stable still have it

covert grove
#

wait fr so do i just change the manifest to something else?

cinder shadow
#

Only thing I can think of here is to then run through the hotbar and search for the item

#

then decrement it

cinder shadow
#

but that can still result in some issues

distant tulip
#

wdym it won't decrement the stack, you are using the same itemstack?

cinder shadow
#

Because it dupes the items to that new slot

#

then runs everything on the item stack in that new slot

covert grove
#

tried that already and it didnt work

round bone
#

did you change your version to 2.0.0-beta and updated Minecraft already?

covert grove
#

yep

round bone
#

what's the error right now?

cinder shadow
#

for registering custom components

round bone
#

ohh he's registering custom components

#

my bad xD

#

system.beforeEvents.startUp

covert grove
#

is there meant to be a .subscribe after that or just that

round bone
#

yes

covert grove
#

didnt work

round bone
#

send me full coed

covert grove
#

hold on it could be because of my other scripts (that are also bugged) arent loading

cinder shadow
#

system.beforeEvents.startup.subscribe((eventData) => {}

cinder shadow
# distant tulip wdym it won't decrement the stack, you are using the same itemstack?

ehh, mb. I was looking for a way to still run the event on the item that was used, which would mean searching through the inventory slots 0-9 for the item then running it on the first instance. But that would create issues if there were multiple instances of that item and it decrements a different stack then the one you were running it off of.

#

I'm just going to go the route of cancelling whatever I was doing if the item isn't in that slot

#

so only an arm swing will occur

#

what's interesting is that it automatically moves the cursor back to that original slot

scenic bolt
cinder shadow
#

no

scenic bolt
#

Thanks

covert grove
#

nvm chat all i needed was to change my manifest to 1.18.0 and everything works now 😭

tight basalt
#

im getting this error now with 2.0.0-beta

[Scripting][error]-ReferenceError: Native function [World::getDimension] does not have required privileges. at <anonymous> (TheItems/Weapons/Admin_Stun.js:3)

```js

const overworld = world.getDimension("overworld")

scenic bolt
#

Would you guys happen to know why block.isValid() is showing up as not a function now

iron apex
#

Hello everyone. What command can I use to open the interfaces of the game or other addons? I need it for a script

wary edge
twilit crag
#

what is that website that shows differences between script versions again

fallow minnow
#

does anyone know the new npm packages for stable

#

beta apis

sage sparrow
#

yeps... the update broke the ConDB, anyone using it know how to fix?

gaunt salmonBOT
gaunt salmonBOT
fallow minnow
#

tjamls

#

thanks

sage sparrow
#

I was using: { "module_name": "@minecraft/server", "version": "1.18.0-beta" }, { "module_name": "@minecraft/server-ui", "version": "1.4.0-beta" },
should I change it to 2.0.0-beta or 1.18.0?

wary edge
sage sparrow
#

I mean, what I have done using the 1.18.0-beta will work with 1.18.0? I dont want to go on 2.0.0 now

distant tulip
wary edge
iron apex
distant tulip
#

not possible

iron apex
#

I got it

sage sparrow
#

I massively used the ConDB so I cannot even start my codes because it get errors at startup, due to this early execution that I m struggling to understand, look: [2025-03-25 19:19:13:307 ERROR] [Scripting] ReferenceError: Native function [World::getDynamicPropertyIds] does not have required privileges. at call (native) at getIds (world/system/database.js) at DynamicDatabase (world/system/database.js:75) at JsonDatabase (world/system/database.js:198) at <anonymous> (world/system_events/death_system.js:7)

any idea how to fix that?

granite badger
#

@honest spear

honest spear
loud zenith
#

anyone know how can we make our script to worl in 2.0.0 ?

distant tulip
#

try to update it first, and let us know if you had any problems

#

-# this channel will full of updating questions the next coming days

deep arrow
#

Lol

#

All because the beta is now only 2.0.0

loud zenith
#

For exemple this doesn't work anymore

system.runInterval(() => {
var player = world.getAllPlayers().filter(p => p.hasTag("player"))[0]
})```
umbral dune
#

what happened?

deep arrow
deep arrow
#

Wait for the worldLoad event

loud zenith
fallow minnow
#

What exactly does this new update do for scripting

#

Is it just more performant?

#

Or is just mc being dumb again

deep arrow
fallow minnow
#

For why

deep arrow
#

More freedom ¯_(ツ)_/¯

fallow minnow
#

So like

#

What

sage sparrow
fallow minnow
#

I’m not big into this script api stuff but is it quite literally just faster execution or something?

deep arrow
honest spear
deep arrow
# fallow minnow So like

also with the update to the 2.0 beta they redid the order of how scripts are ran, for example the left is the old order and right in the new order

fallow minnow
#

Ohhhhh wow

honest spear
#

await null;
const deathlistDB = new JsonDatabase('db:deathlist');
const charTraitsDB = new JsonDatabase('db:chartraits');
fallow minnow
#

So yeah just earlier execution

#

That’s actually quite good

deep arrow
#

indeed

fallow minnow
#

Ish

honest spear
#

@sage sparrow

await null;
const deathlistDB = new JsonDatabase('db:deathlist');
const charTraitsDB = new JsonDatabase('db:chartraits');
fallow minnow
#

If it can catch players before they actually load in and send packets yes

#

If not then it’s useless kinda

#

I feel like that will mainly be used for anti crushers

#

Crashers

deep arrow
#

thats when loading the scripts initally

sage sparrow
deep arrow
#

minato you've been talking for a hot minute

distant tulip
#

just double checking the docs as i am typing lol

distant tulip
tight basalt
#

Dynamic properties do not get cleared when changing the packs UUID, right?

wary edge
deep arrow
#

since dynamic properties are tied to that packs uuid

fallow minnow
#

You can just change the pack version to bypass that

#

Or use scoreboard database

deep arrow
#

or packs in general, just the version number

dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

deep arrow
dense wraith
#

One message removed from a suspended account.

somber cedar
deep arrow
dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

fervent topaz
#

why doesnt world.getDimension("overworld") not have the req privileges?

deep arrow
fervent topaz
#

where is this worldLoad event

#

so how the frick does this work

world.afterEvents.worldLoad.subscribe(() => {
    const overworld = world.getDimension("overworld")
})```
tight basalt
#

ok, i change just the version in the pack.

bcuz my issue was when i update the pack and add it back to the realm, there was no difference for the players, so uuid worked but then all the players daily rewards streak and lodestone location and other lil things are lost and the players get a lil frustrated.

deep arrow
fervent topaz
amber granite
foggy fog
#

Hi, I have a doubt, why world::scoreboard now needs permissions, it became beforeEvent? or why this change in version 2.0 of the module?

deep arrow
dense wraith
#

One message removed from a suspended account.

fervent topaz
deep arrow
dense wraith
#

One message removed from a suspended account.

deep arrow
#

its now worldLoad, and its only an afterEvent

dense wraith
#

One message removed from a suspended account.

glacial widget
deep arrow
dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

deep arrow
dense wraith
#

One message removed from a suspended account.

glacial widget
unique acorn
glacial widget
deep arrow
#

the full version name for the new beta would be 2.0.0-beta

somber cedar
#

guys check the docs

sage sparrow
# deep arrow for the block component registry you'd use this ```js system.beforeEvents.startu...

hi, I tried it but still got warning like this [2025-03-25 20:10:44:278 WARN] [Scripting] Component 'awp:on_tick' was not registered in script but used on a block [2025-03-25 20:10:44:278 WARN] [Scripting] Component 'awp:on_destroy' was not registered in script but used on a block [2025-03-25 20:10:44:278 WARN] [Scripting] Component 'awp:before_place_block' was not registered in script but used on a block [2025-03-25 20:10:44:278 WARN] [Scripting] Component 'awp:on_step_on' was not registered in script but used on a block [2025-03-25 20:10:44:278 WARN] [Scripting] Component 'awp:on_step_off' was not registered in script but used on a block [2025-03-25 20:10:44:278 WARN] [Scripting] Component 'awp:on_place' was not registered in script but used on a block [2025-03-25 20:10:44:278 WARN] [Scripting] Component 'awp:on_interact' was not registered in script but used on a block

but if I do a reload then the warning changes to this:reload [2025-03-25 20:15:02:027 WARN] [Scripting] Script reload did not re-register 'awp:on_tick' custom block component [2025-03-25 20:15:02:027 WARN] [Scripting] Script reload did not re-register 'awp:on_destroy' custom block component [2025-03-25 20:15:02:027 WARN] [Scripting] Script reload did not re-register 'awp:before_place_block' custom block component [2025-03-25 20:15:02:027 WARN] [Scripting] Script reload did not re-register 'awp:on_step_on' custom block component [2025-03-25 20:15:02:027 WARN] [Scripting] Script reload did not re-register 'awp:on_step_off' custom block component [2025-03-25 20:15:02:027 WARN] [Scripting] Script reload did not re-register 'awp:on_place' custom block component [2025-03-25 20:15:02:027 WARN] [Scripting] Script reload did not re-register 'awp:on_interact' custom block component [2025-03-25 20:15:02:125 INFO] Function and script files have been reloaded.

fervent topaz
#

guide how to update ^

past blaze
#

Is anybody else getting this error? error TS2304: Cannot find name 'NoInfer'.

past blaze
wary edge
past blaze
#

I'm not sure exactly what I'm supposed to be doing

#

So far I tried this

#

But still nothing

woven canopy
#

question, does world.afterEvents.chatsend exist in stable, becouse i keep getting undifined

past blaze
wary edge
woven canopy
wary edge
#

I'm not getting this when updating to 1.18.0. Unless you're using 2.0.0.

past blaze
patent tapir
#

Does my distance function look right?

/**
 * Calculate the distance between two points, given the type of calculation and two vectors.
 * @param {string} type The type of distance you want. Must be "euclidean", "taxicab", or "chebyshev", case insensitive.
 * @param {Vector3} vec1 The starting point.
 * @param {Vector3} vec2 The ending point.
 * @param {boolean} horizontal (optional) Whether the distance should be calculated only on the X and Z axes.
 */
function dist(type, vec1, vec2, horizontal) {
    const typeA = type.toString().toLowerCase().trim()
    const x1 = Number(vec1.x)
    const x2 = Number(vec2.x)
    const y1 = horizontal === true ? 0 : Number(vec1.y)
    const y2 = horizontal === true ? 0 : Number(vec2.y)
    const z1 = Number(vec1.z)
    const z2 = Number(vec2.z)
    if (isNaN(x1) || isNaN(x2) || isNaN(y1) || isNaN(y2) || isNaN(z1) || isNaN(z2)) {
        return NaN
    } else {
        if (typeA === "euclidean") {
            return (Math.sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2) + Math.pow((z1 - z2), 2)))
        } else if (typeA === "taxicab") {
            return (Math.abs((x1 - x2)) + Math.abs((y1 - y2)) + Math.abs((z1 - z2)))
        } else if (typeA === "chebyshev") {
            return (Math.max(Math.abs((x1 - x2)), Math.abs((y1 - y2)), Math.abs((z1 - z2))))
        } else {
            return null
        }
    }
}```
thorn ocean
#

Anyone know how to deal with itemComponentRegistry now?

wary edge
thorn ocean
# wary edge Move it to startUp

I tried that but I kept getting the error not a function.system.beforeEvents.startup(initEvent => { initEvent.itemComponentRegistry.registerCustomComponent('plantalia:bucketed', { onUseOn: e => {

warm mason
#

Script-API V2 is terrible. Why did they remove Entity.isValid()?...

thorn ocean
warm mason
#

Even if I write code like this ```js
if (entity.isValid) location = entity.location

wary edge
warm mason
thorn ocean
warm mason
#

Even this code can throw an error. ```js
try { entity.location } catch { return }
location = entity.location

fervent topaz
#

bro how do u even get overworld and export it

warm mason
glacial widget
#

how did you fix that?

#

where?

cerulean cliff
#

what version are you using?

sage sparrow
glacial widget
glacial widget
cerulean cliff
glacial widget
thorn ocean
# thorn ocean Make sure to import system.

When I changed it to the new format, some files didn't work as I didn't use system previously, so make sure to import "system", along with the rest of the any needed classes from "@minecraft/server" package.

sage sparrow
#

yes I already have it

night acorn
#

can someone please explain to me how to use Block.setPermutation() because i just cant understand it

patent tapir
#

Is there some way to get a player's experience level/experience points using scripting

thorn ocean
patent tapir
night acorn
patent tapir
#

Unless bridge doesn't have completions for it and it does exist

night acorn
#

player.getTotalXp()

sage sparrow
patent tapir
#

Oh

#

Alright thank you

drowsy scaffold
#

just out of my curiousity, how many people here have had to make changes beyond just manifest updates to their packs?

wary edge
thorn ocean
thorn ocean
fallen hearth
drowsy scaffold
#

might be that server-ui requires 2.0.0 beta now as well

fallen hearth
#

[Scripting][error]-Unhandled promise rejection: TypeError: not a function at <anonymous>

world.afterEvents.playerSpawn.subscribe(async ( { player, initialSpawn } ) => {
  if(!initialSpawn) return
    await wait(100)
    if(player.isValid()){
      JoinForm(player)
    }
})
#
Erro:
if(player.isValid()){}
unique acorn
#

so do player.isValid

past coyote
#

thank you mojang

unique acorn
#

major change tbh

fallen hearth
#

I hate Mojang, why is that?

unique acorn
#

idk

wary edge
#

I will never understand this change. isValid implies invoking a method. Not a proeprty!

somber cedar
#

Is there an article about early execution

drowsy scaffold
#

is valid is now a property???

#

what

#

that literally makes no sense

fallen hearth
#

[Scripting][error]-TypeError: not a function at <anonymous>

player.runCommandAsync(`say conf`)
past coyote
#

love my life

drowsy scaffold
#

I guess maybe to make it more in line with isSprinting or isJumping?

unique acorn
#

THEY REMOVED RUNCOMMANDASYNC??

#

wait lemme double check

drowsy scaffold
unique acorn
#

eh not like I used it anyway

past coyote
drowsy scaffold
shut vessel
#
   case '!unfreeze':
                        if(!eventData.sender.hasTag("host")) return;
    var arg = msg.message.slice(11).toLowerCase();
    if (arg.startsWith("@")) {
        arg = arg.slice(1);
    }
    
    for (let i = 0; i < players.length; i++) {
            const player = players[i];
        eventData.sender.runCommandAsync('inputpermission set ${arg} movement enabled');
    }
    break;
        
            
                       case '!kit':
            if(!eventData.sender.hasTag("host")) return;
            var arg = msg.message.slice(4).toLowerCase();
        if (arg.startsWith("@")) {
            arg = arg.slice(1);
        }
        for (let i = 0; i < players.length; i++) {
            const player = players[i];

            eventData.sender.runCommandAsync('execute at ${arg} run structure load base ~~~');
        break;      


            
         case '!freeze':
            if(!eventData.sender.hasTag("host")) return;
                        var arg = msg.message.slice(7).toLowerCase();
        if (arg.startsWith("@")) {
            arg = arg.slice(1);
        }
        for (let i = 0; i < players.length; i++) {
            const player = players[i];
            eventData.sender.runCommandAsync('inputpermission set ${arg} movement disabled');

        break;

Do you know what doesn't work? Basically, what I want is that when the command with the "!" is typed followed by a nickname with an @, it executes the command on the chosen player.

past coyote
fallen hearth
patent tapir
#

Hey, with system.runInterval, would a tick interval of 1 or 2 act like a repeating command block with 1 tick delay?

past coyote
#

thanks big dog

drowsy scaffold
dim tusk
unique acorn
#

wait did they completly get rid of runCommandAsync in 1.21.70 instead of only in 2.0.0?

fallen hearth
drowsy scaffold
#

like tag @s add example

dim tusk
#

Just wrap it in the system.run() 🤷

fallen hearth
shut vessel
drowsy scaffold
somber cedar
unique acorn
#

how did I even do that

somber cedar
#

Enable deprecated on visibility

dim tusk
patent tapir
dim tusk
fallen hearth
#

[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous>

player.applyKnockback(player.getViewDirection().x, player.getViewDirection().z, 7, 0)
unique acorn
dim tusk
patent tapir
drowsy scaffold
# dim tusk nah, you got a choice? Nahh

this is really unfortunate for a lot of people who weren't as good with scripts, it's not a problem for me specifically since I know what I'm doing but I wouldn't be suprised if we see a massive influx of how do I convert this to scripts or why isn't runCommandAsync working

wary edge
shut vessel
fallen hearth
somber cedar
#

Use jayly docs

dim tusk
drowsy scaffold
dim tusk
#

the 1 is the vertical

dim tusk
fallen hearth
sage sparrow
# thorn ocean Huh, what error are u getting specifically?

it says it was not registered: [2025-03-25 21:41:16:316 WARN] [Scripting] Component 'awp:on_tick' was not registered in script but used on a block [2025-03-25 21:41:16:316 WARN] [Scripting] Component 'awp:on_destroy' was not registered in script but used on a block [2025-03-25 21:41:16:316 WARN] [Scripting] Component 'awp:before_place_block' was not registered in script but used on a block [2025-03-25 21:41:16:316 WARN] [Scripting] Component 'awp:on_step_on' was not registered in script but used on a block [2025-03-25 21:41:16:316 WARN] [Scripting] Component 'awp:on_step_off' was not registered in script but used on a block [2025-03-25 21:41:16:316 WARN] [Scripting] Component 'awp:on_place' was not registered in script but used on a block [2025-03-25 21:41:16:316 WARN] [Scripting] Component 'awp:on_interact' was not registered in script but used on a block

thorn ocean
dim tusk
#

player.applyKnocback({ x: 0, z: 0 }, <vertical>)

shut vessel
dim tusk
#

It's only 2 parameters, vectorXZ and vertical

shut vessel
#

like that

dim tusk
thorn ocean
shut vessel
# dim tusk and after that, what does it do?

it executes the command like the structure load for the !kit, !freeze prevents the player from moving then !unfreeze allows the player to move via this execution: eventData.sender.runCommandAsync

fallen hearth
#

not is function

dim tusk
thorn ocean
dim tusk
dim tusk
# shut vessel it executes the command like the structure load for the !kit, !freeze prevents t...
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {  
  if (message.startsWith('!@')) {
    ev.cancel = true;
    
    const parts = message.split(' ');
    if (parts.length < 3) return sender.sendMessage('§cUsage: !@<player name> <freeze|unfreeze|kit>');
    
    const playerName = parts[0].substring(2);
    const command = parts[1].toLowerCase();
    const args = parts.slice(2);

    const target = world.getAllPlayers().find(p => p.name === playerName);
    
    if (!target) return sender.sendMessage(`§cPlayer "${playerName}" not found!`);
    
    switch (command) {
      case 'freeze':
        sender.sendMessage(`§aFroze ${target.name}`);
        target.sendMessage(`§aYou got Froze!`);
        break;
        
      case 'unfreeze':
        sender.sendMessage(`§aUnfroze ${target.name}`);
        target.sendMessage(`§aYou got Unfroze!`);
        break;
        
      case 'kit':
        sender.sendMessage(`§aGave kit to ${target.name}`);
        target.sendMessage(`§aYou got Kit!`);
        break;
        
      default:
        sender.sendMessage(`§cUnknown command: ${command}`);
        break;
    }
  } else if (message.startsWith('!')) {}
});```
fallen hearth
dim tusk
# fallen hearth 2.0.0-beta

It works perfectly fine with me.```js
world.beforeEvents.itemUse.subscribe(({ itemStack, source }) => {
if (source.typeId !== 'minecraft:player') return;

const view = source.getViewDirection();

if (itemStack.typeId === 'minecraft:stick') {
system.run(() => source.applyKnockback({ x: view.x * 2, z: view.z * 2 }, view.y) );
}
});```

dawn zealot
#

so is it 1.18.0 now

shut vessel
dim tusk
shut vessel
#

its normal ?

dim tusk
shut vessel
#

it didn't detect it

#

Is there something missing from my manifest?

fallen hearth
dim tusk
# shut vessel Why does he tell me the usage if it works?
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {
  if (message.startsWith("!@")) {
    const args = message.slice(2).split(' ');
    if (args.length < 2) return;

    const targetName = args[0];
    const action = args[1].toLowerCase();

    const target = world.getAllPlayers().find(player => player.name.toLowerCase() === targetName.toLowerCase());

    if (!target) {
      sender.sendMessage(`Player "${targetName}" not found.`);
      ev.cancel = true;
      return;
    }
    
    switch (action) {
      case 'freeze':
        sender.sendMessage(`Froze ${target.name}`);
        target.sendMessage('You got froze!');
        break;
        
      case 'unfreeze':
        sender.sendMessage(`Unfroze ${target.name}`);
        target.sendMessage('You got unfroze!');
        break;
        
      case 'kit':
        sender.sendMessage(`Gave kit to ${target.name}`);
        target.sendMessage('You got kit!');
        break;
        
      default:
        sender.sendMessage(`Unknown action: ${action}. Use freeze, unfreeze, or kit.`);
    }

    ev.cancel = true;
  }
});```
dawn zealot
#

can someone give me something to make im bored that doesnt require databases

unique acorn
dawn zealot
#

erm nty

unique acorn
#

dang no one wants to do it

dawn zealot
#

i just wanna make systems

dim tusk
shut citrus
#

2.0.0 beta

dawn zealot
#

ask chatgpt

wary edge
#

isValid not isValid() anymore.

unique acorn
dawn zealot
unique acorn
#

I'm still realizing that I need to update my addons 😞

#

im so lazy to do that tho

#

later

dawn zealot
#

i just done that but MCPEDL wont accept them ive waited 3 days bro

unique acorn
#

I heard MCPEDL will use curseforge to upload addons or stuff now, mcpedl will just have those addons so you can no longer use mcpedl to upload

#

hey at least curseforge pays you if people download your stuff

dawn zealot
#

bruh too much effort

foggy fog
dim tusk
oak lynx
#

so like this will be fun

#

i actually need to use my brain for updating applyKnockback 😭

distant tulip
#

Didn't get to updating mine, i can already see th console errors on the screen

oak lynx
#

this is just tsc

#

i am too scared to turn on the server

distant tulip
#

Yeah ik, lol

oak lynx
#

i need to write a function for knockback that will still use old params

#

cuz the new version is just worse ngl

distant tulip
#

Yeah, the args are not self explanatory at all

dim tusk
#

I like it 😺

oak lynx
#
player.inputPermissions.setPermissionCategory(InputPermissionCategory.Movement, true)
player.inputPermissions.movementEnabled = true
#

damn more symbols

#

they are all applyKnockbacks now

distant tulip
dim tusk
#

i mean, I live alone now lmao

#

for 6 years now soo

distant tulip
#

I guess that is not a problem lol

oak lynx
#

like all my knockback usage was for dashes

#

the new version makes it worse

distant tulip
#

In term of what? Isn't it the same appart from the syntax

oak lynx
#
applyKnockback(horizontalForce: VectorXZ, verticalStrength: number): void
#

unless i am stupid providing horizontal force is different to providing the direction and force

drowsy scaffold
#

it is, but you can normalize it by multiplying your x and z values passed by the old horiziontal force

#

I asked the same thing, look for my post in script-api to see it visualised better if you need

dim tusk
#

They world exactly the same tho.

#

it's just VectorXZ

oak lynx
#
import { Entity } from "@minecraft/server";
export function applyKnockback(entity: Entity, directionX: number, directionZ: number, horizontalStrength: number, verticalStrength: number): void {
    entity.applyKnockback({x: directionX*horizontalStrength, z: directionZ*horizontalStrength}, verticalStrength)
}
#

🙏

dim tusk
#
world.beforeEvents.itemUse.subscribe(({ itemStack, source }) => {
  if (source.typeId !== 'minecraft:player') return;

  const view = source.getViewDirection();

  if (itemStack.typeId === 'minecraft:stick') {
    system.run(() => source.applyKnockback({ x: view.x * 2, z: view.z * 2 }, view.y) );
  }
});```
karmic pond
#

@dim tusk I had runCommandAsync() run kick commands for the last 3 versions at least, it doesn't have different permissions from runCommand() does it?

oak lynx
#

pretty sure it got removed

karmic pond
#

it did

oak lynx
glacial widget
#

for am getting the same error awell

karmic pond
#

don't call it in before event

gray tinsel
#

is the experimental spawnParticle on the player class coming to stable next update?

gray tinsel
#

yeah just double checked and saw that

#

great stuff

distant tulip
#

True

gray tinsel
#

just need client side texture rendering now

karmic pond
#

was playerSpawn after event deprecated, it says it is, but works fine

gray tinsel
#

beleive it's somethign like afterPlayerFirstSpawn?

#

not 100% sure though

karmic pond
gray tinsel
#

that's join event then

karmic pond
#

Dam I'm blind

#

Ur right

shy leaf
#

how does the new applyKnockback work now?

#

i just woke up so my brain aint braining

unique acorn
karmic pond
glacial widget
#

Werid error for new verison

[2025-03-25 22:36:36.276 ERROR] [Scripting] [Scripting] Plugin [HCV KitPvP S3 10.2v - 1.0.0] - [main.js] ran with error: [ReferenceError: Native function [World::getDimension] does not have required privileges.    at <anonymous> (guis/admin_gui.js:599)

This is the code that causes the error?

const console = world.getDimension("overworld")
gray tinsel
#

oooh

gray tinsel
warped blaze
shy leaf
#

ill just do trial and error

karmic pond
gray tinsel
#

not 100% clear

karmic pond
#

Amazing ❤️

gray tinsel
#

yeah the event still exists in 2.0.0, must be something upcoming

oak lynx
#

its dumb we cant use this

unique acorn
#

make your own UUID generator

gray tinsel
#

external packages would be great in minecraft

#

and hitbeforeevent :(

oak lynx
#

its a built in js feature

gray tinsel
#

I know

karmic pond
#

part of crypto package

shy leaf
unique acorn
#

mojang should also make it so we can read what's inside a packet

karmic pond
#
function generateUUID() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        const r = Math.random() * 16 | 0;
        const v = c === 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
}
unique acorn
#

very useful

oak lynx
#

the main thing i need is the ability to get an array of blocks

#

like please i just want to save player plots to json and store them in a db

#

(iterating with dimension.getBlock() doesnt work well)

valid ice
#

Custom commands (confirmed in roadmap!), before hurt event, and packet reading 🔥

oak lynx
#

roadmap where?

karmic pond
#

custom commands as in / ?

shy leaf
#

uh

unique acorn
shy leaf
#

is World.playSound gone now?

unique acorn
#

smokeyStack said it could be out tomorrow

karmic pond
#

yayy (?)

unique acorn
karmic pond
#

can we get the ability to read what commands are ran

#

🙏

unique acorn
#

idk

valid ice
oak lynx
valid ice
#

Huh?

oak lynx
#

we cant get an array of blocks with it

#

we get a BlockVolumeList if i remember correctly

valid ice
#

Which you can iterate over

#

There’s a thing to do that

oak lynx
#

i can but 3.2m iterations per player island is bad

valid ice
#

._.

#

But why do you need that in the first place

oak lynx
#

i could store player islands in ram and dynamically change them but ram consumption would be high

#

i need to store player islands in a db

#

cuz i want to have regions like zeqa with pure bds cuz i am a masochist

gray tinsel
#

Btw how do you iterate over a block volume

dawn zealot
gray tinsel
#

Was never really clear to me

#

A proper database would be nice

gray tinsel
#

Current best way is to use dynamic properties or convert an object into json to store for later

oak lynx
#
for(const block of blockVolume.getBlockLocationIterator()){

}```
dim tusk
gray tinsel
#

Wait that's peak

gray tinsel
#

Also Ty to the 2 of you

shy leaf
#

i see

valid ice
oak lynx
gray tinsel
#

Ah ok

oak lynx
#

with every passing day i realize that maybe bds and script api werent made for stuff i am doing

gray tinsel
#

Lmao

oak lynx
#

this post is not getting a response

dim tusk
#

Oh yeah, Herobrine when do you think they'll add custom commands?

oak lynx
#

custom commands will mean more rewriting but also more functionality i guess

valid ice
dim tusk
wary edge
dim tusk
#

not I guess, it's literally fire

drowsy scaffold
#

custom slash commands would be SO peak

past coyote
#

I think they will do it tomarrow too, especially with the new elevated permission

dim tusk
#

After commands they should start doing before events hurt and hit.

valid ice
wary edge
past coyote
#

from my work on custom server software I have noticed that commands are added to the world before load

#

its really really low level

valid ice
dim tusk
# valid ice

It literally said that it's like custom components

#

Make sense I guess?

wary edge
shy leaf
#

lovely

oak lynx
#

now i wanna know what oss is

oak lynx
wary edge
past coyote
#

Open Source Software basically, its a hub for talking about OSS projects in the bedrock community

past coyote
#

its for more high level discussions rather than addon creation or help topics

dim tusk
dim tusk
#

Ohh nvm

#

-# I didn't see someone asked it lmao

oak lynx
#

i have 11.5k typescript lines in my project
someone bet how many errors i will get after opening the project tomorrow

past coyote
#

bro was so mad that I provided context

dim tusk
#

Me?

past coyote
#

im joking too

wary edge
dim tusk
#

The fact I don't use Twitter is even more funny.

past coyote
#

Coddy is gonna sue twitter

valid ice
#

Why would you sue them

deep yew
#

or use

unique acorn
deep yew
#

((What's X?))

valid ice
#

Nobody knows, math teachers still need to find it

oak lynx
#

i will never call it X

dim tusk
unique acorn
#

I thought you said you don't use it

shy leaf
#

why do dead entities despawn that fast

dim tusk
dim tusk
past coyote
shy leaf
dim tusk
past coyote
#

how do people code on mobile 😭

#

Do they have typings and stuff too?

shy leaf
#

with enough dedication

shy leaf
#

i mean

#

for me at least

valid ice
#

Raw is war backwards

past coyote
#

I could never

shy leaf
#

how

dim tusk
#

That's why I easily remember stuff since I manually type it

#

I mean not saying typings is bad, it's just we're limited lol

oak lynx
#

i cant code without 2 screens and vsc with build scripts 😭

past coyote
#

I dont use typescript

oak lynx
oak lynx
past coyote
#

i just dont like it idk its yet another step

oak lynx
#

i hate dynamic i hate dynamic types i hate dynamic types i hate dynamic types

unique acorn
valid ice
#

If you start from scratch it’s excellent

#

Trying to transition from js to ts is pain

oak lynx
#

in the past year i only made one js project

#

rest were ts

#

the js project was just a transferPlayer bds instance lol

dim tusk
lyric kestrel
#

I really need to do a whole refresher on js

#

Literally my whole js knowledge is part python, and just learn as you go, with scripting API

humble lintel
#

anyone know how to register custom componenrts in the new script api beta

unique acorn
#

the rest should be the same

#

they only changed the event

humble lintel
#

ohh shi okay than ks

shy leaf
#

worldLoad too

unique acorn
humble lintel
#

fireee

#

any cool new features with scriopt api

unique acorn
#

nothing much rlly but custom commands using slash are going to be added soon!

dim tusk
#

lezz go

#

🥺🙏🏽

foggy fog
#

Hii, is there any news about the registration of custom components? the Startup event is still not working 🕊️

unique acorn
foggy fog
shut citrus
unique acorn
unique acorn
#

I'll update my game rn ig

foggy fog
shy leaf
#

should i just wrap the whole code in worldLoad afterEvents?

unique acorn
#

not the whole code

#

events can be ran in early execution mode so you don't need those in worldLoad

shy leaf
#

what about chatSend beforeEvents?

unique acorn
#

you don't need to put that in worldLoad

shy leaf
unique acorn
#

my wifi is so slow 😞 (it's been 30minutes)

unique acorn
#

aw man I had to restart the download

dim tusk
unique acorn
#

i ran out of storage, that's why.

#

0 bytes free, awesome

#

android could never

dim tusk
#

how tf you only have that amount of storage?

unique acorn
#

idk

#

I'm planning to get more soon

#

118gb is NOT enough for me

dim tusk
#

my phone really beat you?

unique acorn
dim tusk
#

wadahell

unique acorn
#

it's a 9 years old phone tho

#

3gb ram on it

fallen hearth
#

[Scripting][error]-ReferenceError: Native function [Entity::runCommand] does not have required privileges. at <anonymous>

world.beforeEvents.chatSend.subscribe((ev) => {
  const { sender, message } = ev;
    if (ev.message.toLowerCase() == "declare") {
      sender.runCommand(`say aaa`)
      return
    }
}
wanton ocean
#

are you able to check the attack damage of a weapon?
ex: item.damage or something like that??

wanton ocean
unique acorn
#

wrap it in system.run

fallen hearth
unique acorn
#

oh then you can wrap everything in system.run

#

except for when you cancel it

fallen hearth
#

What is this for?

#

system.run

#

I didn't have this before

unique acorn
gaunt salmonBOT
shy leaf
fallen hearth
# shy leaf

I don't know English, could you explain it to me?

shy leaf
shy leaf
#

so codes wrapped with system.run() in beforeEvents will run after the beforeEvents does its job

#

the wrapped codes will practically work the same as afterEvents

fallen hearth
shy leaf
#

javascript native functions will work fine

fallen hearth
#

For me this update was made just to break the codes and force us to update our addons

#

why mess with what is quiet?

wary edge
#

If you really hate breaking changes...stop using beta.

fallen hearth
#

just like what they did with run_command

unique acorn
#

I just tried startup before event and dangg it runs so early

#

I just clicked the join button and it alread started

shy leaf
unique acorn
#

yet I still don't know what this will be used for.

shy leaf
#

me neither

wary edge
shy leaf
#

oh right, commands

#

wait

#

spawn rules?

wary edge
#

Allegedly.

shy leaf
#

would be cool though

wary edge
#

Again, all allegedly based on the files.

valid ice
#

Time to play 1.21.70! I hope none of my scripts broke Clueless

unique acorn
valid ice
#

It uses stable scripts for a reason- I am suprised if none of the type IDs broke

unique acorn
#

it didn't break in 2.0.0-beta too, didnt try the type IDs tho

marsh pebble
#

this game is slowly becoming java

wary edge
#

devious We love parity.

humble lintel
shut citrus
#

How to pause the game like this but except players using scripts

deep yew
#

everything seems to "have no privileges"

stark kestrel
stark kestrel
wary edge
deep yew
distant gulch
#
player.applyKnockback(direction.x, direction.z, 100.2, 5);```

I badly need help why isnt this line working 😭
#

it was previously working

deep yew
#

It helps to know what "isn't working" and if there's syntax errors or anything

shy leaf
#

applyKnockback has changed to use Vector2

distant gulch
#

im confused... How would I insert the numbers do I just replace X and Z with them?

shy leaf
distant gulch
shy leaf
#

that

distant gulch
#

🙏🏻

shy leaf
#

...is the example?

distant gulch
#

with like numbers in it

shy leaf
#

fine

#

@distant gulch

player.applyKnockback({x: direction.x * 100.2, z: direction.z * 100.2}, 5);
distant gulch
# shy leaf <@456226577798135808> ```js player.applyKnockback({x: direction.x * 100.2, z: d...
system.runInterval(() => {
    const players = world.getAllPlayers();
    
    for (let player of players) {
      const blockBelow = player.dimension.getBlock(player.location);
      
      if (blockBelow?.typeId === "minecraft:yellow_carpet") {
        const direction = player.getViewDirection();
        player.runCommand(`scoreboard players set @s pvp 1`);
        player.runCommand(`/function misc/enterpvp`);
        player.applyKnockback(direction.x, direction.z, 100.2, 5);
        player.applyKnockback({x: direction.x * 100.2, z: direction.z * 100.2}, 5);
      }
    }
}, 1);

This is what I got does it look good? I'm still learning...

#

Oh wait 💀

#

forgot to remove previous

#

yeah should work

shy leaf
#

yeah

#

also i recommend to not use runCommand and use native functions instead

distant gulch
shy leaf
#

uh

warped blaze
#

I dont understand the part about replacing Vector3 with... Vector3?

shy leaf
#

its just how you call the script functions

distant gulch
shy leaf
#

like Entity.applyKnockback()

#

if theres /damage command, theres Entity.applyDamage() function for scripts

burnt remnant
#

can someone show me an example of a for loop

stark kestrel
ivory bough
#

how to run code at a block's location every 200 ticks?

valid ice
#

Man... 😭

#

Wtf is wrong

deep arrow
deep arrow
stark kestrel
deep arrow
#

Is the event not firing? Or the registry not working

valid ice
#

I can check

deep arrow
#

Its unstable for a reason

valid ice
stark kestrel
valid ice
stark kestrel
#

cant get over world.getDimension("overworld");

valid ice
deep arrow
#

The biggest problem with the update imo is how peoples like view on coding is gonna change on having to have run everything on the worldload event instead of the global scope

deep arrow
valid ice
#

yea

stark kestrel
valid ice
deep arrow
valid ice
#

always

#

@wary edge is this a legit bug or a skill issue on my part

dim tusk
#

I know the beta version and the stable version of 1.21.70 is different but it's odd why it wouldn't work.

#

I tried it in the beta version of it and it works

valid ice
shy leaf
# burnt remnant can someone show me an example of a for loop
for (let i = 0; i < 5; i++) {
    console.log("Iteration:", i);
}
let fruits = ["Apple", "Banana", "Orange"];
for (let i = 0; i < fruits.length; i++) {
    console.log(fruits[i]);
}
let colors = ["Red", "Green", "Blue"];
for (const color of colors) {
    console.log(color);
}
inland merlin
#

I've just started getting onto the new update... and holy...

dense skiff
#

Suggestions for how this type of export should work in v2.0.0-beta?
CounterChannels.js

let counterChannels;
world.afterEvents.worldLoad.subscribe(() => {
    counterChannels = new CounterChannels();
});
export { counterChannels };

hopperCounters.js

import { counterChannels } from "../classes/CounterChannels";
new Rule({
    category: 'Rules',
    identifier: 'hopperCounters',
    description: { translate: 'rules.hopperCounters' },
    onEnableCallback: () => counterChannels.enable(),
    onDisableCallback: () => counterChannels.disable()
});

counterChannels is undefined when the new Rule() is executed, since it's not wrapped in the worldLoad event so it throws an error. I do not want to wrap the rule instantiation in the worldLoad event if possible -- plus wouldn't that create a race condition anyway?

dim tusk
valid ice
#

zamn

#

Love that retail is so goofy rn

hybrid island
#

I update to @minecraft/server - v2.0.0-beta and same for ui and it keeps giving error even on the stuff that pervisously worked?

[Scripting][error]-TypeError: not a function at updateMobName (testers.js:132)
at <anonymous> (testers.js:209)

Line 132 if (!entity.isValid()) return;

dense skiff
#

That's because many things changed in v2

past coyote
#

entity.isValid 😭

hybrid island
#

idk i tried chatgpt

dense skiff
#

Go read the changelogs and watch thishttps://youtu.be/owfBDnOHI_o?si=NgsPO5Rg205XtErI

A detailed video about the infrastructural changes in how Script API v2.0.0 beta works -- it's not that different from v1.0.0, but we'll cover the subtleties in this video. Warning: there isn't really any discussion about newer APIs in this video, so not a lot of new fireworks on display :)

Scripting API 2.0.0 Documentation: (docs coming soon,...

▶ Play video
hybrid island
#

run command async removed?

past coyote
#

yep

hybrid island
#

gonna rewrite 500 files

dense skiff
#

Yep same

valid ice
#

Update TLDR:
world.afterEvents.worldInitialize -> world.afterEvents.worldLoad
world.beforeEvents.worldInitialize -> system.beforeEvents.startup
isValid() -> isValid
runCommandAsync() -> Good luck 🫡