#Script API General
1 messages · Page 67 of 1
It will make the entity go up in sky
With speed 100 in y-axis
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
Not possible.
You literally said "make an item fly up in the air" that's why I gave that.
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
Make a fake item drop.
Like custom?
Honestly I don't think you can stop specific items from being picked up
Okay, I was just thinking, can you make a custom entity that will hold the item?
Yeah you can
Best Pokemon addon?
Is there any way to take a photo from an entity's pov and then display it on the player's screen?
script api
no
i mean you could use the /camera command or teleport the player to the entities head location with entity.getHeadLocation()
ah. Then how do I make the player take a photo there without the player noticing?
How do the bedrock replay mods do it?
Someone can help me with my question pls!?
they usually capture entity location and states every tick
anyway, my turn for a question, is there a max size for dynamic properties?
specifically world properties
Minato is typing...
Minato is typing...
bummer
ask your question directly
32767 characters for string
Number limit is 64-bit float
(Very large)
wdym? my "mod" (if it is what you are referring to) don't take pictures, it uses the camera api
Rotation error
Yeah how to do that?
do what
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.
you know how to duplicate a message from a command of the same style as a msg but by a command with a "!"
Can you give an example?
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}`);
}
});```
reading this code is better than watching tiktok it was satisfying
Thanks 😅
I gotta cancel the command sending without anything in it
I think its my own chat script conflicting
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) }]})
I'm confused, in your properties does it accept Boolean or number?
If you want to check numbers, why do Boolean(0)??
it returns true or false since it's a Boolean.
Maybe that's the problem but the entity property I'm checking for is an integer so a Boolean.
Just send the entity properties
"properties": {
"os_br:segment": {
"type": "int",
"range": [
0,
12
],
"default": 0
}
}
then why did you do Boolean(0)??
obviously it wouldn't work since in your entity you used numbers not true or false
😭
I'm so sorry I understand what you mean lol
Boolean means true or false
yeah
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?
Yeah
Thanks and sorry for taking up your time lol. I can't believe I was sitting here for a good minute like bruh.
Why wouldn't you just use /tell?
They wanted a custom command
We couldn't understand what he wanted and I like little coding exercises
const viewDir = player.getViewDirection();
viewDir.y = 0
console.log(viewDir.y) // 0?
i wonder if this works?
Why would it not work?
ive never tried making stuff that way
so im just not sure
feels like the game could yell at me anytime
That's why you can see some people do this ```js
let location = player.location;
location.y -= 1;
const block = Dimension.getBlock(location)```
i see
but tbh, I don't like doing that.
why not? it seems better than this
let viewDir = player.getViewDirection();
viewDir = { x: viewDir.x, y: 0, z: viewDir.z };
That's not what I meant lol
oh
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.
??
no direct way but instead just use applyDamage()
Is it possible for me to set a rotation on the player without using teleport?
no.
😭
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"
})`;
})()
);```
not even in the experimental? or in the preview experimental
you made me throw up
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);
}
});```
Oh thats really terrible
i didnt expect a simple question to turn into a nausea-inducing code competition
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {
if (message.includes('test')) {
ev.cancel = true;
}
});```
why
thats nothing...
const { dimension: { id, heightRage: { min, max } } } = player;
console.error(id, min, max);
How to detect the game is lagging?
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
The thing is I don't do redundant, unnecessary or bloat shit.
As much as possible I lessen it.
Nah i am using this for singleplayer
I basically wanna get an entity's pov and play it on the player's screen
This bot was created by SmokeyStack for the purpose of making a FAQ bot for the Bedrock Add-Ons Discord Server.
To manage entries, please make a pull request on GitHub.
hm
Wait me to send video
Why the components dosen't get showed up
After clicking "ctrl + space"
@woven loom
Intro to ScriptAPI: https://aka.ms/startwithmcscript
Intro to Tests: https://docs.microsoft.com/en-us/minecraft/creator/documents/gametestgettingstarted
Official Docs: https://docs.microsoft.com/en-us/minecraft/creator/scriptapi
Community Docs: https://wiki.bedrock.dev/scripting/game-tests
Script API examples: https://github.com/JaylyDev/ScriptAPI
2021 Q&A: https://wiki.bedrock.dev/scripting/gametest-qna.html
2022 Q&A: https://wiki.bedrock.dev/scripting/scripting-editor-qna.html
do other suggestions show up
No
I mean only some random words
In the script
But not the suggestion
What i did wrong?
How i make it work : |
Where the types were installed
In user/node_packages
Try installing in the addon folder.
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...
did you install the beta @minecraft/server or stable
Install typedefs from npm
Bot is down soooo
Im the bot
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
I did install server 1.17.0
Stable
you need beta
Why ?
idk, those only show on beta
Sure ?
Its ok, blockExplode is stable
I didn't know that
Its just that? Orrr
Like, other autocompletions work normally
Yes
Aahh, just use enums
But components string suggestions dosen't work
Even tho , the component proprety dosen't get displayed
Import BlockComponentTypes
...
Component property?
do you mean getComponent() method
Yes
/** @type {BlockPistonComponent} */
const pistonComponent = block.getComponent(BlockComponentTypes.Piston);
how to set the player's pov the pov of an entity? Without teleporing there
Camera API.
I think there is something with vscode itself
Does anyone knows how to setup it ?
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.
How do I add text like the one in the screenshot
You're reading the docs...do as it says.
I mean the hello world text
Documentation for @minecraft/server-ui
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.
theres "UserBusy" for cancelationReason
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
How to use it? Can you show an example?
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
Ahh, it creates a cyclic launch of the form using a special event?
and since youre only making the form to show up when the player is not busy, itll work
I didn't know
yeah, i havent tested the performance though
never experienced any lags with it btw
hmmmmmm i've never used that exact function inside a function lol
it works wonderfully
anyways
Can I use another method? For example, instead of a function, just try to call "show" on a loop?
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?
never tested that
It can be determined, but I don't know that the entity would ignore the player.
Could it be similar to the endermen and sheared pumpkin?
making the mob to be passive is the hard part here
True
There are already components working there.
As I understand it, with the help of scripts, you can only get information about components, but not interact (except for inventory)
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
Like with the invisibility effect?
To be honest, I don't know how to implement what you said, but if your commands work but the functions don't, you can use scripts to automate all of this or you can look for possible implementations
anyone know if there's a way to stop items from duping with itemUseOn events?
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.
are you doing setItem?
yeah, you always have to set the item though, don't you?
i think i have a solution for this, hold on
Ya, might be too complicated. Thanks for the help, though!
youre doing it for durability, right?
aaand is it afterEvents or beforeEvents?
nope, it's just for clicking something on any block
beforeEvents then
it's using the onUseOn itemRegistry component
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
oh yeah i think that might be the reason
try using equippable component from Entity instead
theres setEquipment function for it
It's not working?
uhhh which part?
-# dont tell me youre using that code as whole
No, I rewrote it for myself.
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?
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
yes, I agree
show() can't be called in read-only mode
looks like this doesn't work
even if I grab it at the very beginning of the event, the slot is wrong
How to run some code in the location of a block every 200 ticks?
Does anyone know how to make duels bots eg, easy, medium and hard?
yeah damn this sucks, I figured it'd be an easy solution or at least hard to pull off
but it's ridiculously easy
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
what event are you using
itemRegistry onUseOn
all you have to do is try and use the stackable item and then use your scroll wheel at the same time
someone please help me find an alternative to world.beforeEvents.worldInitialize
hi guys. i updated my docs and jaylybot. unfortuantly jaylybot compiler faces errors again. Anyway I tried adding some stuff to my docs, feel free to provide feedback thanks (e.g. https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server-ui.ModalFormData-1.html).
woah they added new stuff??
try double checking if the item in the main hand is still the same item when you are setting the item
they removed it thats why im trying to find an alternative
im using BeforeEvent not AfterEvent, i read it right
you are using 2.0.0-beta?
yeah, stable still have it
wait fr so do i just change the manifest to something else?
yeah woops, accidentally was checking that spot AFTER I already set the item. It does work in not duplicating it, but now it won't decrement the stack. A little annoying considering even getting the slot from the event will still have this same issue.
Only thing I can think of here is to then run through the hotbar and search for the item
then decrement it
1.18.0
but that can still result in some issues
wdym it won't decrement the stack, you are using the same itemstack?
Because it dupes the items to that new slot
then runs everything on the item stack in that new slot
world.afterEvents.worldLoad
tried that already and it didnt work
did you change your version to 2.0.0-beta and updated Minecraft already?
yep
what's the error right now?
It's not worldLoad, it's startup
for registering custom components
is there meant to be a .subscribe after that or just that
yes
didnt work
send me full coed
hold on it could be because of my other scripts (that are also bugged) arent loading
system.beforeEvents.startup.subscribe((eventData) => {}
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
it’s not world anymore?
no
Thanks
nvm chat all i needed was to change my manifest to 1.18.0 and everything works now 😭
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")
Would you guys happen to know why block.isValid() is showing up as not a function now
Hello everyone. What command can I use to open the interfaces of the game or other addons? I need it for a script
They changed it to be a property now.
what is that website that shows differences between script versions again
yeps... the update broke the ConDB, anyone using it know how to fix?
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
here
Installation for @minecraft/server-ui
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
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?
If you still rely on beta, 2.0.0
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
So what?
depend, most likely not
what interfaces
It honestly depends on what you used.
Of the Crafting_table UI type
not possible
I got it
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?
@honest spear
Its new privilege in 2.x APIs, you better not initialíze things in global scope, but if you want to then use await null before you initialize the instance
anyone know how can we make our script to worl in 2.0.0 ?
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
For exemple this doesn't work anymore
system.runInterval(() => {
var player = world.getAllPlayers().filter(p => p.hasTag("player"))[0]
})```
what happened?
The interval does, its basically everything within the world class that isn't accessible in early execution
what should i do then ?
Wait for the worldLoad event
may you show me an exemple pls ;-;"
What exactly does this new update do for scripting
Is it just more performant?
Or is just mc being dumb again
Allows early execution
For why
More freedom ¯_(ツ)_/¯
like this?javascript let deathlistDB, charTraitsDB; (async () => { await null; deathlistDB = new JsonDatabase('db:deathlist'); charTraitsDB = new JsonDatabase('db:chartraits'); })();
I’m not big into this script api stuff but is it quite literally just faster execution or something?
i beleive you dont even need it in a function, just await null in the top level
you can use top level as well
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
Ohhhhh wow
await null;
const deathlistDB = new JsonDatabase('db:deathlist');
const charTraitsDB = new JsonDatabase('db:chartraits');
indeed
Ish
@sage sparrow
await null;
const deathlistDB = new JsonDatabase('db:deathlist');
const charTraitsDB = new JsonDatabase('db:chartraits');
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
the world isnt loaded, players wouldnt be able to join
thats when loading the scripts initally
thx much easier than I thought, I will try that now
minato you've been talking for a hot minute
just double checking the docs as i am typing lol
scripts now initialize earlier during the world startup allowing for configuration before additional content loads, this is general give the api more freedom on what it can do, custom component v2 and custom commands will for sure use that.
it also make some changes to the way Promises are handled, they can now be resolved in the end of tick, they were before delayed to the next tick (iirc)
Dynamic properties do not get cleared when changing the packs UUID, right?
They get cleared if you change uuid.
they are not "cleared" they are just no longer accessable to that pack
since dynamic properties are tied to that packs uuid
realistically tho, you shouldnt need to change a behavior packs uuid
or packs in general, just the version number
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
if your planning on sticking with the beta, you'll need to use the 2.0 version
One message removed from a suspended account.
It's v2.0.0 now. check the list here https://jaylydev.github.io/scriptapi-docs/latest/
no 1.18.0 -> 2.0.0
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
why doesnt world.getDimension("overworld") not have the req privileges?
because its running during the early execution, you'll have to wait for the worldLoad event
where is this worldLoad event
so how the frick does this work
world.afterEvents.worldLoad.subscribe(() => {
const overworld = world.getDimension("overworld")
})```
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.
changing the uuid would essentially wipe the stored data in your addon
and how would i even export this
@distant tulip do u know how to fix that ?
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?
you can do this
// Early Execution/Top Level Code
// Code here will run before the world is loaded
world.afterEvents.worldLoad.subscribe(() => {
// Code here will run after the world is loaded
})
or
// This will make the top level code wait
// and prevent early execution, allowing access to world api's
await null
const players = world.getPlayers()
One message removed from a suspended account.
to export the code inside tho????
the event worldInitialize no longer exists
One message removed from a suspended account.
its now worldLoad, and its only an afterEvent
One message removed from a suspended account.
its just "2-0-0?"
for the block component registry you'd use this
system.beforeEvents.startup.subscribe(event=>{
event.blockComponentRegistry
})
One message removed from a suspended account.
One message removed from a suspended account.
its . not -
One message removed from a suspended account.
alr so no -beta?
2.0.0-beta
i tried but doesnt work
the full version name for the new beta would be 2.0.0-beta
guys check the docs
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.
guide how to update ^
Is anybody else getting this error? error TS2304: Cannot find name 'NoInfer'.
Server module?
Yup
I'm not sure exactly what I'm supposed to be doing
So far I tried this
But still nothing
question, does world.afterEvents.chatsend exist in stable, becouse i keep getting undifined
nvm, I figured out the problem
It does not. It's still beta
Is there not a specific line Error?
that, makes a whole lot of sense now lmao
I'm not getting this when updating to 1.18.0. Unless you're using 2.0.0.
It was a package.json thing. I was unknowingly using wrong version
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
}
}
}```
Anyone know how to deal with itemComponentRegistry now?
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 => {
Script-API V2 is terrible. Why did they remove Entity.isValid()?...
You are using 2.0.0?
startup.subscribe(data =>
I think they changed it to a property instead of a function.
But they didnt?
Yes, but it works terribly. More precisely, it does not work.
Even if I write code like this ```js
if (entity.isValid) location = entity.location
Because it throws instead of retuening undefined.
But there is a condition there.
Oh yeah, when I put that for the first file, it moved to the next file error, let me quickly change every instance of that.
Even this code can throw an error. ```js
try { entity.location } catch { return }
location = entity.location
bro how do u even get overworld and export it
Perhaps the problem is in entity.location itself
I used an older library that didnt support 2.0.0
what version are you using?
was you able to fix yours? can you check what is wrong on mine? javascript system.beforeEvents.startup.subscribe(eventData => { // On Step On eventData.blockComponentRegistry.registerCustomComponent('awp:on_step_on', { onStepOn: (event) => { onStepOnBlock(event.entity, event.block, event.dimension) } }); })
am using the same version
meaning i would have to change the library?
what library are you using?
Make sure to import system.
how do i check the library first of all?
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.
yes I already have it
can someone please explain to me how to use Block.setPermutation() because i just cant understand it
Is there some way to get a player's experience level/experience points using scripting
player.getLevel()
Did you change the server version in the manifest file to 2.0.0?
Impossible
it is actually cos its wrong mb
Unless bridge doesn't have completions for it and it does exist
player.getTotalXp()
yes
{ "module_name": "@minecraft/server", "version": "2.0.0-beta" },
just out of my curiousity, how many people here have had to make changes beyond just manifest updates to their packs?
Entirely depends on if you're using beta or not.
I have, since some things haven't been released from beta yet. But everything is working now.
Huh, what error are u getting specifically?
For me, this is also a bet, have you decided how to agree?
might be that server-ui requires 2.0.0 beta now as well
Ehh, not really
[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()){}
if you're on 2.0.0-beta, isValid is no longer a method
so do player.isValid
😭
thank you mojang
major change tbh
I hate Mojang, why is that?
idk
I will never understand this change. isValid implies invoking a method. Not a proeprty!
same
Is there an article about early execution
[Scripting][error]-TypeError: not a function at <anonymous>
player.runCommandAsync(`say conf`)
love my life
I guess maybe to make it more in line with isSprinting or isJumping?
pretty sure runCommandAsync got killed with v2

good luck kicking players without server-admin
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.
link to this plss
How can I replace it?
Hey, with system.runInterval, would a tick interval of 1 or 2 act like a repeating command block with 1 tick delay?
thanks big dog
what are you calling within the ran command?
You ask this hundreds of times now, just open a post and wait. If you can't wait find a way
wait did they completly get rid of runCommandAsync in 1.21.70 instead of only in 2.0.0?
yes.
player
no no like the actual slash command
like tag @s add example
Just wrap it in the system.run() 🤷
I use several commands this is an example
ok but i feel like the post is way too far back if you know what i mean so i think no one will reply and i can't figure out why it's not working
it's still in v1 https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server.Player.html#runcommandasync
does this fix runCommandAsync?
runCommandAsync -> runCommand
ok maybe this is why it isnt showing
how did I even do that
Why mojang.
Enable deprecated on visibility
nah, you got a choice? Nahh
Yes?
Stop sending gifs pls.
[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)
erm actually that's a video 🤓☝️
Huh? I already answered it....
So both act the same way?
it uses vector2 now.
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
Not my fault, sooo
Then tell people to read changelogs.
Do you have any idea why this isn't working?
I don't understand vector
Use jayly docs
player.applyKnocback({ x: p, z: 0 }, 1)
basically a glorified object that contains x,y,z properties to represent world locations
the 1 is the vertical
how do you use the command? !@<name>??
[Scripting][error]-TypeError: not a function at <anonymous>
player.applyKnocback({ x: player.getViewDirection().x, z: player.getViewDirection().z }, 7, 0)
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
Isn't the reason why runCommandAsync is not working is because it is no longer needed due to how Scripting 2.0 works?
pretty sure, yes
uhh? I just showed the example
player.applyKnocback({ x: 0, z: 0 }, <vertical>)
yes
It's only 2 parameters, vectorXZ and vertical
like that
and after that, what does it do?
Just create a vector like { x: direc.x * horizontalStrength, z: direc.x * horizontalStrength}, verticalStrength
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
player.applyKnocback({ x: player.getViewDirection().x * 2, z: player.getViewDirection().z * 2}, 0)
not is function
so !@<player name> <freeze | kit | unfreeze>??
That's strange. That is how it's supposed to work. Not sure what's happening then.
😓
What version are you?
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('!')) {}
});```
2.0.0-beta
thx
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) );
}
});```
so is it 1.18.0 now
Does it have any required prerequisites for this to work? And in your command, I need to put the "!" for it to work. Because for me, the @ doesn't work, I have the impression.
!@<player name> <freeze | kit | unfreeze>
yeah.
Why does he tell me the usage if it works?
it didn't detect it
Is there something missing from my manifest?
Thank you very much friend, you saved my life
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;
}
});```
can someone give me something to make im bored that doesnt require databases
minecraft inside minecraft since baRD didn't want to do it
erm nty
dang no one wants to do it
i just wanna make systems
Y'know what's funny? If Minecraft java mod struggles to do it, how about bedrock with even more limitedm
2.0.0 beta
ask chatgpt
isValid not isValid() anymore.
booohooo, get out of here man
lmaooo iu was waiting for that
I'm still realizing that I need to update my addons 😞
im so lazy to do that tho
later
i just done that but MCPEDL wont accept them ive waited 3 days bro
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
bruh too much effort

better than you waiting for 3 days 🤷
so like this will be fun
i actually need to use my brain for updating applyKnockback 😭
Didn't get to updating mine, i can already see th console errors on the screen
Yeah ik, lol
i need to write a function for knockback that will still use old params
cuz the new version is just worse ngl
Yeah, the args are not self explanatory at all
I like it 😺
player.inputPermissions.setPermissionCategory(InputPermissionCategory.Movement, true)
player.inputPermissions.movementEnabled = true
damn more symbols
they are all applyKnockbacks now
That why you don't have friends
-# jk
And?
i mean, I live alone now lmao
for 6 years now soo
I guess that is not a problem lol
In term of what? Isn't it the same appart from the syntax
applyKnockback(horizontalForce: VectorXZ, verticalStrength: number): void
unless i am stupid providing horizontal force is different to providing the direction and force
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
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)
}
🙏
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) );
}
});```
@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?
pretty sure it got removed
it did
how would you fix that?
for am getting the same error awell
don't call it in before event
is the experimental spawnParticle on the player class coming to stable next update?
It is stable as of now
True
just need client side texture rendering now
was playerSpawn after event deprecated, it says it is, but works fine
don't think it is
that's join event then
player.applyKnockback(Vector2, VerticalStrength)
I just get this in my script
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")
oooh
that's in the current experiemental version
a lot simpler and easier to understand now

ill just do trial and error
So it's gonna be removed ?
not 100% clear
Amazing ❤️
yeah the event still exists in 2.0.0, must be something upcoming
its dumb we cant use this
make your own UUID generator
its a built in js feature
I know
part of crypto package
please mojang, please make us happy with entityHurtBeforeEvents
mojang should also make it so we can read what's inside a packet
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);
});
}
very useful
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)
Custom commands (confirmed in roadmap!), before hurt event, and packet reading 🔥
roadmap where?
custom commands as in / ?
uh
yeah
is World.playSound gone now?
smokeyStack said it could be out tomorrow
yayy (?)
idk
Huh?
we cant get an array of blocks with it
we get a BlockVolumeList if i remember correctly
i can but 3.2m iterations per player island is bad
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
Btw how do you iterate over a block volume
structure block
Current best way is to use dynamic properties or convert an object into json to store for later
for(const block of blockVolume.getBlockLocationIterator()){
}```
Wait that's peak
@shy leaf
Also Ty to the 2 of you
i see
Yeah a proper DB would be phenomenal
i have a mongodb running and an express js server and i just send http requests to it with server-net
Ah ok
with every passing day i realize that maybe bds and script api werent made for stuff i am doing
Lmao
Oh yeah, Herobrine when do you think they'll add custom commands?
custom commands will mean more rewriting but also more functionality i guess
Tomorrow.
Are you predicting or do you know something
serious?
#blamenavi
custom slash commands would be SO peak
I think they will do it tomarrow too, especially with the new elevated permission
After commands they should start doing before events hurt and hit.
Where
OSS.
from my work on custom server software I have noticed that commands are added to the world before load
its really really low level
Where in oss 😭
😭 Navi doesnt talk anywhere but one channel.
lovely
now i wanna know what oss is
best change ngl
Nunya.
Open Source Software basically, its a hub for talking about OSS projects in the bedrock community
its for more high level discussions rather than addon creation or help topics
I said this multiple times, Herobrine loves this
why send it?
Ohh nvm
-# I didn't see someone asked it lmao
i have 11.5k typescript lines in my project
someone bet how many errors i will get after opening the project tomorrow
bro was so mad that I provided context
Me?
im joking too
im pretty scared 😭
Twitter users:
The fact I don't use Twitter is even more funny.
Coddy is gonna sue twitter
Why would you sue them
or use
(it's called X now)
((What's X?))
Nobody knows, math teachers still need to find it
i will never call it X
i watch videos in X
I thought you said you don't use it
Inside joke.
bro said: I'm outta here.
bros ui
would you rather have a default layout or that
Bro is a coder not a player 🤷
with enough dedication
no its all raw
i mean
for me at least
Raw is war backwards
I could never
how
that's the fun part, no.
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
i cant code without 2 screens and vsc with build scripts 😭
I dont use typescript
war crime
i just dont like it idk its yet another step
i hate dynamic i hate dynamic types i hate dynamic types i hate dynamic types
I tried TS and it complained so much I switched back to Javascript
in the past year i only made one js project
rest were ts
the js project was just a transferPlayer bds instance lol
That's true but not for me. I enjoy it, but I rarely do it since I hate my dam phone lmao
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
anyone know how to register custom componenrts in the new script api beta
use this
system.beforeEvents.startup.subscribe()
the rest should be the same
they only changed the event
ohh shi okay than ks
i guess they realized it was too long
worldLoad too
this is a comparision between v1 script api and v2 script api, now scripts start earlier than before
nothing much rlly but custom commands using slash are going to be added soon!
Hii, is there any news about the registration of custom components? the Startup event is still not working 🕊️
Does it return an error?
Are you sure you're using 2.0.0?
Did you leave and rejoin the world?
Make sure you saved the file
Make sure you imported system
It doesn't return anything, in fact it doesn't even execute and I have tried everything, the only time where I did mark something was when I turned it into a variable and added it in a system.run, but it turned it into an afterEvent (https://discord.com/channels/523663022053392405/1354214428438171758)
So it still slow reading code?

idk then, this stuff is still new and I still didn't even update my game yet so I have no idea on any other stuff to check
I'll update my game rn ig
if you find a solution, please tell me, this is eating my head xD

should i just wrap the whole code in worldLoad afterEvents?
not the whole code
events can be ran in early execution mode so you don't need those in worldLoad
what about chatSend beforeEvents?
you don't need to put that in worldLoad
got it
my wifi is so slow 😞 (it's been 30minutes)
yoink
aw man I had to restart the download
cry.
wadahell
[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
}
}
are you able to check the attack damage of a weapon?
ex: item.damage or something like that??
wrap it in system.run
system.run(()=>{
})
world.beforeEvents.chatSend.subscribe((ev) => {
const { sender, message } = ev;
if (ev.message.toLowerCase() == "declare") {
system.run(() => {
sender.runCommand(`say aaa`)
})
return
}
}
wrap it in system.run
I have several if statements, why should I use this?
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
Installation for @minecraft/server-ui
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
system.run() runs the code at the end of the same tick where the event is triggered
#debug-playground
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
Didn't this happen before? There was no error before
well, some minecraft script functions cant be run without it
javascript native functions will work fine
For me this update was made just to break the codes and force us to update our addons
why mess with what is quiet?
it was always like this though
If you really hate breaking changes...stop using beta.
just like what they did with run_command
I just tried startup before event and dangg it runs so early
I just clicked the join button and it alread started
basically the scripts can quickdraw
yet I still don't know what this will be used for.
me neither
Registering commands, custom components, spawn rules, etc.
Allegedly.
Again, all allegedly based on the files.
Time to play 1.21.70! I hope none of my scripts broke 
I'm actually suprised your chest ui addon didn't break
It uses stable scripts for a reason- I am suprised if none of the type IDs broke
it didn't break in 2.0.0-beta too, didnt try the type IDs tho
We love parity.
Does anyone have any feature in their mind taht I should add to this system
How to pause the game like this but except players using scripts
everything is broken for me
everything seems to "have no privileges"
commands? what?
Custom commands coming soon™️
FINALLY!!!!
I wouldn't expect to have files starting with a system.run
player.applyKnockback(direction.x, direction.z, 100.2, 5);```
I badly need help why isnt this line working 😭
it was previously working
It helps to know what "isn't working" and if there's syntax errors or anything
from
player.applyKnockback(X, Z, HorizontalValue, VerticalValue)
to
player.applyKnockback({ x: X * HorizontalValue, z: Z * HorizontalValue}, VerticalValue)
applyKnockback has changed to use Vector2
im confused... How would I insert the numbers do I just replace X and Z with them?
you just change the format to that
Can I get an example
that
🙏🏻
...is the example?
with like numbers in it

fine
@distant gulch
player.applyKnockback({x: direction.x * 100.2, z: direction.z * 100.2}, 5);
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
native function? Never heard of it
uh
I dont understand the part about replacing Vector3 with... Vector3?
its just how you call the script functions
👍🏻👍🏻
like Entity.applyKnockback()
if theres /damage command, theres Entity.applyDamage() function for scripts
hmm
can someone show me an example of a for loop
wait they aren't available rn right?
how to run code at a block's location every 200 ticks?
Wym "at a blocks location?"
I saw someone also having a similar problem
im crying either way, my server is broken
Is the event not firing? Or the registry not working
I can check
What do you expect from using the beta
Its unstable for a reason
Are you experiencing this bug, or just normal update woes?
just normal

havent tested that yet, going to, soon enough
cant get over world.getDimension("overworld");
Seems the event isn't even ever fired
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
Really??
yea

Nothing in content log
And you have your console log level show warnings right?
did you also use the console.error?
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
Just tried, still nuttin
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);
}
I've just started getting onto the new update... and holy...
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?
It works with the preview version of MC
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;
That's because many things changed in v2
entity.isValid 😭
idk i tried chatgpt
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,...
run command async removed?
yep
gonna rewrite 500 files
Yep same
Any suggestions for this?
Update TLDR:
world.afterEvents.worldInitialize -> world.afterEvents.worldLoad
world.beforeEvents.worldInitialize -> system.beforeEvents.startup
isValid() -> isValid
runCommandAsync() -> Good luck 🫡


