#Script API General
1 messages · Page 113 of 1
Nah, but the settings label works on 2
i see
random question someone ping me if they know, but is there a place to check what is in which version of API dependencies?
or more specifically, does anyone know if simulated player is in the stable version of server-gametest? (0.1.0)
i went to the documentation on microsoft learn but its a bit outdated
you can either check metadata in bedrock-samples repo, or use what sean sent, or use jayly docs
also for the gametest part, no, theyre only in 1.0.0-beta still
thanks guys! super helpful
https://jaylydev.github.io/scriptapi-docs/latest/modules/_minecraft_server-gametest.html
There is nothing there tho
Does /damage suicide command like when using the projectile method, does it also remove the stun delay
if using anything else besides projectiles
i tried it with an autoclicker for an item but it still had the stun
hello everyone @magic peak here
hello kanin @dusky flicker here
js
thanks
sadly, js 😢
im really thinking on usint haxe to transpile to js instead of ts
it seems to be more interesting
not sadly python is slow as a shit
i didnt benchmark it compared to js, but it could be damn better
quickjs is at least 20 times slower than bun and node for some tasks
this is onlt showing (undefined) when i look at any entity, what am i doing wrong?
system.runInterval(()=>{
world.getAllPlayers().forEach((player)=>{
const lookAtEntity = player.getEntitiesFromViewDirection({maxDistance:100})[0]
if(lookAtEntity){
console.warn(lookAtEntity.id)
}
})
})```
how do I get the item in a glow item frame? I would've assumed that they have an inventory component but they don't
nevermind, found it
You cant
for whatever reason Block.getItemStack returns the item inside the frame which is the exact opposite of what I would think that call would do but okay
Thats...new.
right?
1-. Save the item frame on a structure
2-.Load it somwhere else and break it
3-. Read the item from the entity that drops
best solution i can think of
Block.getItemStack() works
When there is nothing in the item frame, getItemStack returns "minecraft:frame" btw.
interesting, appreciate that
whats the required format version for item custom components in v2 scripting?
just need to note it somewhere
1.21.90
danke sean
Now go fix your addon.
looks like AI code
you can make custom error handler
could make use of that
what is this for though
is it meant to be something Promise-like?
Does anyone know why you can’t run and execute command in scripts
It always throws and on the @ symbol
Yes
use "runCommand" instead
Both still work either way it throws an error
The problem is something with the script not liking the exits command
Kinda yea
Haha, yeah used AI for help
yeah the comments are what gives it away
It already does handle errors though, Or you meant a different thing? Cuz if i implement more error logging that would just turn into a Logger
I don't know but thought could be useful, Such as doing clearRun stops interval but its harder, so this class what it does is helps to resume/pause a interval. Then when you need to abort the task, it does clearRun. I kinda wanted to make it Promise-like.
So yeah basically you can do:
const id = TaskScheduler.runInterval(() => {
})
id.stop() // this will stop the interval
id.start() // this will resume the interval again
So basically it makes managing tasks easier by allowing interval to stop or start which mojang doesnt allow this feature cuz clearRun just aborts the interval.
@rare plume do u think its useful in cases?
this could actually be really using if your handling a lot of system run intervals for like a timer or something
i might honestly use this
Yup thats why
haha ty
you should put this in #1067535712372654091
i meant different thing, yeah
there can be some unexpected cases that isnt handled from scripting api
Such as?
It currently handles normal errors like if the task is already running, and if you try to run it again, it wil throw err
yeah idk, i was just thinking if it could have one
i dont see why exactly it's harder. Anyways, you could add some functions to handle failures
and make onComplete generate other TaskScheduler in chain
even maybe make usage of promises to make it able to use await syntax
@tranquil junco by the way, that idea of storing data in binary, im implementing it slowly
im making some tests yet
it seems to be working
i just must implement arrays
thats some peculiar looking ide
i see
Ask a bit, if i increase the interval timer, does it reduce any lag?
import {EntityEquippableComponent,EquipmentSlot,system}from"@minecraft/server";
let S = system;
S.runInterval(()=>{for(let A of world.getPlayers()){try{
let B=A.getComponent(EntityEquippableComponent.componentId);
let C1=B.getEquipment(EquipmentSlot.Head);
let C2=B.getEquipment(EquipmentSlot.Chest);
let C3=B.getEquipment(EquipmentSlot.Legs);
let C4=B.getEquipment(EquipmentSlot.Feet);
if(C1.typeId.includes(":")&&C2.typeId.includes(":")&&C3.typeId.includes(":")&&C4.typeId.includes(":")){A.addEffect("resistance",300,{showParticles:false})};
}catch(e){}}},150);
Can you read player entity properties using scripts?
Im using getProperty but my script wont read it somehow
i think you can make things simpler
put a tag on the player when it wears something
and put the effect with time infinite
it would be better, i'm still trying to learn how to script rn
import { world, system, Entity, ItemStack } from "@minecraft/server"
const TARGET_ITEM = "vdg:coltwalker" // target item ID
const DAMAGE_PER_USE = 1 // durability consumed per use
let useitem
world.afterEvents.worldLoad.subscribe(() => {
useitem = world.getDynamicProperty('vd:shooting')
})
world.afterEvents.itemUse.subscribe(ev => {
const { source: player, itemStack } = ev
if (!player || !itemStack) return
if (itemStack.typeId !== TARGET_ITEM) return
const dur = itemStack.getComponent("minecraft:durability")
if (!dur) return
if (useitem === false) return;
if (dur.damage == 12) system.run(() => player.runCommand('function coltwalker/empty'))
dur.damage += DAMAGE_PER_USE
const container = player.getComponent("minecraft:inventory")?.container
if (!container) return
container.setItem(player.selectedSlotIndex, itemStack)
});
console.warn
when it removes, you remove the tag as well as the effect
the tag is mainly to check if it's got the effect
Why wont my script return if my property is false?
sounds good, gonna try that then
using world.afterEvents.itemUse.subscribe??
Ye
Should i put my useitem part on the itemuse.subscribe?
Idk
well, idk tho
my quickjs version doesnt have float16 support '-'
test
bruh what the heck is this
it's typescript bro.
but im working with binary serialization
i know that, but for what:v
just because im studying about network and the guy i've mentioned gave me idea to do something like it
for storing binary instead of json yknow
oowh, thats nice
at least on that tiny example i was testing, the binary got at least 6 times smaller
but compacting 2bytes to 1 char it may get something around 11 chars
async function forceOpen(player, form) {
let res = await form.show(player)
while (res.cancelationReason === "UserBusy") res = await form.show(player)
return res
}
how do you think about this compact "forceOpen"?
it's doing its job, so it's good
lol literally the same respond from my friends
arrays implemented 👍
whats command for downloading all latest scritpapi packages and versions?
I remember there was some command here
nvm got it:
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/server
npm i @minecraft/server-ui
you can run that in one command
npm i @minecraft/[email protected] @minecraft/[email protected] @minecraft/[email protected] @minecraft/[email protected] @minecraft/[email protected] @minecraft/[email protected] @minecraft/server @minecraft/server-ui
works the same
man i cannot take a break from this, i leave the space for like 3 months and have to relearn half of it
we went from worldload to worldinitialize back to worldload 😭
i also cant get my block component registry to work anymore so ill have to look into that one
interesting
looks like it's the reason registryBlockComponent somehow didn't work as intented
what's the current beta api in 1.21.111?
2.3.0-beta
ty
What's the name of that method which sets a entity property on a specific client?
setPropertyOverrideForEntity
Documentation for @minecraft/server
A gift that keeps on giving.
How does one make a custom UI element show on the HUD? And how do you feed it values for things like meters and such.
The JSON UI tutorials don't really explain how to do that from the scripting API
I don't actively code bedrock addons like I used to
I had the idea of coding a spelling bee detecting keyboard inputs to play with my friends
is that even possible?
I don't think you can detect keystrokes like that
Bedrock Dedicated server keeps crashing with this when a mob gets punched. Sometimes when it restarts the issue is gone, but then eventually it comes back. No idea how or why, but could this be an addon thing?
not possible
the best you can do is change your key binding to some letters and only use those
we can detect the keys for moving, jumping, sneaking, interacting, and maybe hitting
anyone can help me with my question pls
#1423380725373341856
I worked on a system for right click detection however the most I got was detecting right click if you're inside a room encased in structure voids so it just would always act like your inside a block in practice
but yeah I guess I can build a website 😔
would've been fun to build a map and stuff
well... if you really want that you can build a website and link it to a map
hello everyone
hello
wassup bro
i am kanin
just here to ruin everyones day, the D in down for dropdown doesnt work if uppercase, however textField does and textfield doesnt, thank me later:)
genuine question, is there a way that achievement is enabled with script api running?
Add-ons don't disable achievements anymore no.
it still prompts me this as you said addons dont disable achievements anymore
got it thanks
dropdown is 1 word textField is 2
its just camel case
How do you iterate an entity list in an order. I've tried using:
entitys.forEach(entity => {
for (let e = 0; e < 64; e++) {
const entity = entitys[e]
if ( entity == undefined ) { break };
but these both execute all the entities at the same time, or atleast too fast between each iteration for it to matter. I'm trying to kill an entity if it detects a duplicate entity, but keep running into entities killing eachother.
What do you mean by duplicate?
The same typeId? (zombie & zombie)
or the exact same entity you want to filter out?
You can use the Set() object to record unique elements
I'm using a property to detect same type. But doesn't matter much to me. Ok I'll look into using Set() thank you!
how would i modify the contents of an itemstack, for example a chest that the player is holding?
ive tried using ItemInventoryComponent, but it just returns undefined
this component is so stupid. LITERALLY EVERY ITEM DOES NOT HAVE IT. that includes:
- chest
- barrel
- shulker box
- bundle
WHY???
bundle should have it
you are in beta?
ye
send code
system.run(() => {
const shulkerBox = new ItemStack("minecraft:bundle", 1);
console.log(`bundle has component: ${shulkerBox.hasComponent("minecraft:inventory")}`);
const container = shulkerBox.getComponent("minecraft:inventory").container;
for (let i = itemsRequired; i > 64; i -= 64) {
container.addItem(new ItemStack("minecraft:redstone", 64));
}
if (itemsRequired % 64 > 0) container.addItem(new ItemStack("minecraft:redstone", itemsRequired % 64));
shulkerBox.nameTag = signalStrength.toString();
origin.sourceEntity.getComponent("minecraft:inventory").container.addItem(shulkerBox);
return {
status: CustomCommandStatus.Success,
message: `Gave ${origin.sourceEntity.nameTag} shulker box`
}
})```
you could use runJob instead
sets arent gonna help you if what you have are objects
if you store the entities in the set
I am creating a prison map should I use chest ui or actionformdata
Is there a way to cancel event on interaction with dispenser block, but then opening ActionForm and set up some commands on the buttons?
I made script for canceling events with beforeEvents.playerInteractWithBlock ev.cancel = true;
But then I can't open ActionForm. I figured it out that I can open form by using script events, but now I'm struggling with seting up working commands on the buttons in this form...
show your code
I made workaround - I canceled event on dispenser but added interact with button on it. So it solved my issue. I'm sorry I deleted wrong code
Both.
Which one do you use more?
Mostly OOP and sometimee Functional
is it bad idk what any of these are
i use classes because thats the only way to make objects have methods, but im really interested in using f# to compile down to js
but i really hate the fact of not having a bunch of functional features
im used to rust, and in general thing.method() is just a sintax sugar to TypeOfThing::method(&thing)
so im used to think of things like this
Rust looks interesting
yes
What type of stuff do you typically use OOP for and what stuff do you use functional?
anyone can help me with my question pls
#1423380725373341856
OOP for games mostly or big system, functional when im too lazy to do a good structure
I typically use OOP for database related stuff and functional for everything else
I use it for everything nearly
I love a good structure
And yeah I also use Functional for little scripts, like my Tag game, or a simple Rank system
even for stuff that would just be static?
I tried to use oop but a lot of my code would just be a collection of function
For static stuff thats yes. If its critical i may use functions or literal objects instead
How much of your stuff is only static?
and how much are you uses instances
Services or helpers are static
And I use instances for like Enemies or Towers in a tower defense
Hoe much in total idk
Hey, do you have more context here? What base game version are you in? Do you mean that the hasComponent call returns false, but then you can still get the component and use the container within it? Thanks!
i tend to use oop for things that follow some pattern
i mean, a bunch of things that follow the same pattern
not a single one
but in general a simple struct and it's functions should be enough
the getEntitiesFromRay api is cooked 💔
So I am the codev of a hitbox/collision box pack and suddenly this update certain entities just dont get picked up by the ray system
like items, arrows, tridents, potions, xp orbs, and more.
standard mobs are detected just fine though :/
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]
I will investgate, thanks!
erm
npm i @minecraft/[email protected]
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: @minecraft/[email protected]
npm error node_modules/@minecraft/server
npm error @minecraft/server@"^2.3.0-beta.1.21.111-stable" from the root project
npm error
npm error Could not resolve dependency:
npm error peer @minecraft/server@"^2.0.0" from @minecraft/[email protected]
npm error node_modules/@minecraft/server-ui
npm error @minecraft/server-ui@"2.1.0-beta.1.21.111-stable" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
Use —force
They messed up the dependencies somehow
world.afterEvents.worldLoad.subscribe(() =>{})
Using this event,
Now how do I make a function like waitForWorldLoad(), so whatever code after this function, will wrap inside the event
function waitForWorldLoad(){
return new Promise(res => {
world.afterEvents.worldLoad.subscribe(res);
})
}
``````js
await waitForWorldLoad();
console.warn("Test worldLoad awaited");
waitForWorldLoad().then(() => {
console.warn("Test worldLoad awaited");
})
?
heroes on mobile
Nice
is it possible to make it so regular players with member permissions not be able to use target selectors like /w @a[tag=hasTagThisOne]
or just make them not be able to use /w
and stuff like that
BDS?
import { world, system, Entity, ItemStack } from "@minecraft/server"
const TARGET_ITEM = "vdg:coltwalker" // target item ID
const DAMAGE_PER_USE = 1 // durability consumed per use
world.afterEvents.itemUse.subscribe(ev => {
const { source: player, itemStack } = ev
if (!player || !itemStack) return
if (itemStack.typeId !== TARGET_ITEM) return
let useitem = world.getProperty('vd:shooting') == false
const dur = itemStack.getComponent("minecraft:durability")
if (!dur) return
if (useitem) return
if (dur.damage == 12) system.run(() => player.runCommand('function coltwalker/empty'))
dur.damage += DAMAGE_PER_USE
const container = player.getComponent("minecraft:inventory")?.container
if (!container) return
container.setItem(player.selectedSlotIndex, itemStack)
});
console.warn
Uhh why?
Help😭
let useitem = world.getProperty('vd:shooting') == false
this is not a thing, please don't use ai if you don't know what are you doing
It even looks over complicated
What are you actually attempting to do?
I'm sure that a simpler solution can be made to help you if you ask
Thank u very much
realms
Am not using ai
Im just trying to eyeball things and hope they work😭
Bedrock Wikis and script documentation the only good source i got
Basically
If i use the revolver item while having the property vd:shooting set to true it deducts durability on the item
After 6th use of the item it triggers a replace item function
Bro getProperty is not a thing
In which script documentation did you even saw
this is a thing
Not possible then.
variable == variable returns true/false
but Only for entities
let variable = variable1 == variable2
// variable = true/false
Yes im trying to get that property from player.json
Do u see Entity.getProperty in screenshot? @cursive fog
U used world.getProperty
Not entity
It wouldnt work😭
It says not documented or smth
Idk
A property can only be retrieved from an entity with a property defined in their entity file
Was it defined?
Well for getting the property you need to define it in Entiy json
exactly what i was gonna say
Tuff
My sentiments exactly
Wym defined
I made a property on player.json vd:shooting
Unless it doesnt count custom made properties
Defined/declared
Basically made and given (or not) a value
Guh
Essentially the game knows it exists
define entity means
const entity = Entity
Oh
There are no default player properties anyways so it being custom is no issue
Hmmm
So should i seperate the get property part on a diffrent worldload thingy or keep it there
get property can be called only on a specific entity
you need an event or some function to get the entity first
This?
"properties":{"mba:light":{"type": "int","range":[0, 15],"default":0}}
Here
Like this u define property inside entity json
for example
const entities = dimension.getEntities()
const entity = entities[0]
Alr have that on my player.json(pardon me for the tree editor)
{
"filters": {
"test": "light_level",
"value": 0
},
"add": {
"component_groups": ["light_level:0"]
}
U can then change the property using event trigger
Okay nice
But, everyone, the most important thing is probably that he doesn't even need the entity property
He isn't interacting with anything outside of scripts, so he could just use a dynamic property instead of editing the player file and wasting one of only 32 properties
If possible can i use scoreboard on this?
Been thinking of that for a while but yeah
Besides that the vd:shooting property is alr reused twice
So then because your setting property on player,
U should get player:
const player = world.getPlayers()[0].getProperty("b")
uh? no?
getProperty is not a function, that throw an error before comparing the values
Why do we not get the Player object in params
I also have a trigger to change the entity property inside ac
getProperty does not exist on world, It does exist on entity,
the join event is triggered before the player entity is spawned
Player represents an entity
Use playerSpawn
Wait guys
does getDynamicProperty work on world?
Yes
becouse join is when the player is connecting to the server but its not an entity yet
my point still stand
Alr ill try that
i see thanks guys
Have you seen the documentation?
Its all there
Wdym? You do remember you did that in ur Light level detection and it's done by defining the properties on the entity json
Oh if u mean world.getProperty is not a thing, Oh yes yeah
yes
the day we get dynamic properties on blocks
im so tired of setting world dynamic properties with xyz as an alternative
lol for real
Im confused rn there are 2 Property things
One on entity and one on world class
Idk which one to follow lol
properties are controlled by behaviour (you need to define them) and they can only have the same type of data
whereas dynamic properties can be defined via script directly without touching json files
Hmmm
Please don't get confused of getProperty with getDyanmicProperty, they are different.
getProperty only exist for Entity class, And on the other hand, getDynamicProperty exists both on entity and world.
"one on world class"?
where?
getDynamicProperty i guess
.
Alr my bad for bothering yall guys😭
Just one last which one works better?
There's also maps
Dynamic property
Yeah
Depends on what you need it for tho
usually dynamic properties are used for long term data storing
or at least multi session
Yea
Or just an alternative to using properties cause many dont like to tamper with the player.json
what
Guys, One question,
I've rarely seen people using the .unsubscribe in events. What use case it could be used for?
i actually dont know what is that for (or at least its practical purpose)
Yep me too
Stops listening to an event.
same as world shutdown
they are different thing
getProperty
accessing static properties provided from the entity file itself in the entity definition in its behavior pack
getDynamicProperty
accessing script defined properties stored in the entity, world, or item, those properties are unique and linked to each add-on uuid and can't be accessed by other add-ons
so it depend on your use case
Oh, But I've seen using unsubsribe after a subscribe, But it does run everytime.
const callback = world.afterEvents.projectileHitEntity.subscribe((arg) => {
const { source, projectile } = arg;
const hitInfo = arg.getEntityHit();
if (hitInfo?.entity && source instanceof Player && projectile === entity) {
const shooter = source;
const target = hitInfo.entity;
const projectileType = projectile.typeId;
world.afterEvents.projectileHitEntity.unsubscribe(callback);
}
});
Such as I have this code, this does run everytime player hits a entity, and the projectilesHitEntity event does run, but it's unsubscribing in this code..?
Yep, it just stops listening to this event. I do not recommend relaying on dynamic event listeners, unless you know how to deal with them.
there is not a lot of good use cases really
does it just kill that firing?
maybe let say a welcome message to the world host?
you can sub to player spawn and unsub in the first event
or a debug thing that only need to run once you actually need it
yes
it is just like when you unsub from a YouTube channel to stop getting notifications
Subsingle is a good example, but except of this I can't think of any others.
I think discord.js uses unsubscribe for once listeners.
Yup, it's also probably an event that's immediately unsubscribed inside a C++ code.
yeah
I think it's a very little important detail that can make a difference, but in very rare cases.
I used unsubscribe in @minecraft/server only once in my entire life, but it actually can lead to optimization at few percents, so I still like it.
i mean yeah, but there is probably no performance impact if the event stop in the game code itself.
i mean for worldLoad
getAttachedBlocks() does not return the block that was pushed?
Oh, I talk about the performance that multiple listeners may have impact on.
yeah when you have subscribe in a loop or a scope that execute more than once, unsubscribe is very necessary
Yup.
Im gonna loose my sanity
How do you make a script single use only
Like
When i use item
It triggers only once
Then after i use the item again it triggers once too
There should be a property isFirstUse iirc.
Just do
(event) => {
if (!event.isFirstUse) return;
}
you are thinking of IsFirstEvent and i dont think that's what they are talking about, they said use not interact..
Ill try
that wont work.
Yep doesnt work
Got any idea
I am loosing my sanity man💔
almost like I said that
I think you are misunderstanding something, can you share the code that you are working with
Alr w8
import { world, system, Entity, ItemStack } from "@minecraft/server"
const TARGET_ITEM = "vdg:coltwalker" // target item ID
const DAMAGE_PER_USE = 1 // durability consumed per use
world.afterEvents.itemUse.subscribe(ev => {
const { source: player, itemStack } = ev
if (!player || !itemStack) return
if (itemStack.typeId !== TARGET_ITEM) return
let useitem = world.getDynamicProperty('vd:shooting') == false
const dur = itemStack.getComponent("minecraft:durability")
if (!dur) return
if (useitem) return
if (dur.damage == 12) system.run(() => player.runCommand('function coltwalker/empty'))
dur.damage += DAMAGE_PER_USE
const container = player.getComponent("minecraft:inventory")?.container
if (!container) return
container.setItem(player.selectedSlotIndex, itemStack)
});
console.warn
its because of system.run
@thorn flicker i just need it to run once
The runcommand?
yes.
Basically it deals damage to durability of an item
The run command is for replace item
@thorn flicker yo sorry for ping
I removed the system part but uhh it started screaming at me
W8 hold on
yeah because you didnt remove the arrow function.
and nvm about the system.run thing I was wrong.
I only need it to deal damage on a item once
yeah you dont need to ping me, im right here with you lol
could you elaborate on what do you expect and what is happening?
let useitem = world.getDynamicProperty('vd:shooting') == false
If i kept using the item the durability still goes down
Thats why im using entity properties so that when the AC triggers the false part
It returns and stop the damage on the item
Ohhh
No worries
you need to set dp if it doesnt exist... and if it does return early.
sorry wrong reply
Ye basically ive been trying to deal damage on a item durability
But i only need it to trigger ONCE when i use the item
you mean, you want to just make the item one time use?
Im using AC and property to make sure it returns but doesnt seem to work
what does the function do?
No i mean
The item can be used multiple times
But the durability only deals 1 damage when i kept using the script
Replace item
yeah
hmm gotcha, why not use itemStartUse
and decrease durability on stopUse?
Or directly on StartUse
oh is this a chargeable item?
Seems to work
Kinda
either it is or not lol
Isnt there a component to make it chargeable?
shooter component
My bad @distant tulip 😭😭 i kept going around the entity property part
I dont use minecraft shooter
why would it trigger multiple times then
there's eat or edible component ig? use modifier things..
no worry
oh, you are using the food component?
"Hell yeah, Im about to eat this revoler"
sure, sounds good
in that case I can see how its being used multiple times
I tried it once it wont go down
Anyways how do i implement this?
runInterval inside start use, set interval 20 ticks, stop it on stopUse
it should work
or change ticks according to what fits
I think this works? Idk
NOO!
or just do this
if (player.start === undefined) {
player.start = true
// damage stuff...
system.runTimeout(() => { player.start = undefined }, 20)
}
just by creating a temporary property on the player
Naww😭
I would help but I cant code on phone
Open wide, here comes the plane~
Good thing yeah
oh you dont know what ive gone through
ive coded on this text field right here on discord
Coding on phone is hell
Hell, I hope you get well soon
im, been a while
this is why I would wait until I could get a computer if I were in your shoes
Quick Reminder, people use Text Editors in Light mode to code whole Applications
@floral timber where can i find the itemStartUse on the documentations?
on world and afterEvents
On the official docs, or any else
id like to meet 'em someday
Better if you dont
These i guess
I remember when I was new to JS and had lots of issues with brackets
(I made my command handler with 30 statements and no if else)
lmao
If you go down to the bottomy you can see the world constant
hey does anyone wanna help me out
Btw what the °=° is LinearSpine
explain what you need help with
Depends
i'm trying to make a script that tellraws everyone when someone dies
like player1 has died
Use world.sendMessage
And theres an event if a entity dies
and use EntityDie
Just filter either if its typeId, instance (or my thr filter object) if its an player
Documentation for @minecraft/server
no i want it to show entities to
world.afterEvents.entityDie.subscribe(data => {
}, {entityTypes: 'minecraft:player'})
If you want to also Trigger if a entities dies, remove the filter
no like player1 was slain by zombie etc.
Okay then it may be a little more work
i dont have anyone to test with thats why
its just getting the entity that killed them...
You need definitions of death messages with placeholders like
{
"entityAttack": "%player% got killer by %attacker%"
}
A parser to insert the names
import { world } from "@minecraft/server";
world.afterEvents.entityDie.subscribe(event => {
const victim = event.deadEntity;
const attacker = event.damageSource?.damagingEntity;
world.sendMessage(`§c${victimName} §7was killed by §a${attackerName}`);
});
would this work
And a manager/handler to show the correct message
It would, but only for entity attacks
If you also want like falldamage, fire damage or explosion, you need a lottle bit more
would my code3 work rn?
If you only want to make it being used on entity attacks, yeah
okay
i want to know if it lodas correctly too but idk how to do that
i do /reload all and reload but it does nothing
Yup this should work
Do /reload all, check your manifest or your file if it even gets executen
{
"format_version": 2,
"header": {
"name": "Test",
"description": "Test",
"uuid": "20c744da-6f9f-8f0d-f212-a96ed88a5eb8",
"version": [
1,
0,
0
],
"min_engine_version": [
1,
17,
0
]
},
"modules": [
{
"type": "data",
"uuid": "cb6f1da2-40be-9411-bd3c-08c1395ba634",
"version": [
1,
0,
0
]
}
]
}
Also check for the log, maybe errors appear
thats my manifest
our manifest is wrong
@thorn flicker Can you help him? Kinda hard on phone
Same as my life, no worries, the great VOIDCELL will help you
Pack Manifest generator for Minecraft Bedrock Edition, with this generator you can easily generate manifest for your Skin, Resource, or Behavior pack.
Void took too long, here
Already used that
Its missing the script module and more
I'm like really sorry for being dumb as fuck
{
"format_version": 2,
"header": {
"name": "Bedrock Add-ons",
"description": "Script API Template",
"uuid": "<UUID>",
"version": "1.0.0",
"min_engine_version": [1, 21, 90]
},
"modules": [
{
"uuid": "<UUID>",
"version": "1.0.0",
"type": "script",
"language": "javascript",
// Your entry file; where Minecraft will read your code from.
"entry": "scripts/main.js",
}
],
// Uncomment to use eval() and Function() inside your code (unrecommended), remove if not neccessary
// "capabilities": ["script_eval"],
"dependencies": [
{
// Enables the use of @minecraft/server module, with a version of 2.0.0 (the latest stable version available).
"module_name": "@minecraft/server",
"version": "2.0.0"
}
]
}
Use this
my bad
latest stable is 2.1.0
ok
For anything else please ask Void, I gotta go
Cya

{
"format_version": 2,
"header": {
"name": "Bedrock Add-ons",
"description": "Script API Template",
"uuid": "20c744da-6f9f-8f0d-f212-a96ed88a5eb8",
"version": [1, 0, 0],
"min_engine_version": [1, 21, 90]
},
"modules": [
{
"uuid": "cb6f1da2-40be-9411-bd3c-08c1395ba634",
"version": [1, 0, 0],
"type": "script",
"language": "javascript",
"entry": "scripts/main.js"
}
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "2.1.0"
}
]
}
this?
lol
yes.
you'll have to wait until you can test because im busy, it seems good though.
-# you need to re-add the addon, because we changed the UUID of it
not sure if version is required
idm
Never share your UUID, those are used to estimate your location
oh
Xd just joking
💀
what the hell
I was going to say
but like idc
its not like that they gonna swat me
import { world } from "@minecraft/server";
world.sendMessage('hi')
world.afterEvents.entityDie.subscribe(event => {
const victim = event.deadEntity;
const attacker = event.damageSource?.damagingEntity;
world.sendMessage(`§c${victimName} §7was killed by §a${attackerName}`);
});
Things we dont understand does not make sense
They wont, but I do
things that dont make sense, dont make sense
Use the even if a Player joins
playerJoin or playerSpawn
Flat earth-
after events or
Finally someone who is awake too
yes
Yes
world.afterEvents.playerSpawn
there's a property to check if the player has spawned by joining
initialSpawn ig
Documentation for @minecraft/server
yes
import { world } from "@minecraft/server";
world.afterEvents.playerSpawn.subscribe(event => {
world.sendMessage('test')
})
world.afterEvents.entityDie.subscribe(event => {
const victim = event.deadEntity;
const attacker = event.damageSource?.damagingEntity;
world.sendMessage(`§c${victimName} §7was killed by §a${attackerName}`);
});
Yes
check for the initialspawn property
That will now tell the whole world "test"
if (event.initialSpawn) { world.sendMessage('test') }
You wont see the message because microsft is weird
If someone differently joins, youll see it
You could make it delayed
well actually you wont see the message sent because you wont be loaded in time.
is there a chat event to test it?
you have to find a way to check if the player is loaded in or not
or delay the message
Kinda, #debug-playground
i DONT know js
Learn it
system.runTimeout
Best thing that happend to me right after my depressions
how long
10 i g
heres the thing everyone has different loading times.
is this ticks
So...
Lets make it more advanced
After the join wait untill the player pressed any button
And then send the message
tbh i think this is all because the addon isnt loaded or some silly thing
Nope
No...
iie void-san... iie
Hmm
let me copy some old code
const { message, sender } = ev;
const [cmd, ...args] = message.split(' ');
if (sender.hasTag('muted')) {
ev.cancel = true;
return sender.sendMessage('§cYou are muted and cannot chat!');
}
if (cmd.startsWith('!')) {
ev.cancel = true;
const findPlayer = name => world.getAllPlayers().find(p => p.name.toLowerCase() === name?.toLowerCase());
if (!sender.hasTag('admin')) return sender.sendMessage('§cError: You don\'t have permission!');
const target = args[0] ? findPlayer(args[0]) : sender;
if (!target && args[0]) return sender.sendMessage('§cPlayer not found!');
const reason = args.slice(1).join(' ') || 'No reason specified';
switch (cmd) {
case '!warn':
target.sendMessage(`§cYou've been warned. Reason: ${reason}`);
break;
case '!mute':
target.addTag('muted');
target.sendMessage(`§cYou've been muted. Reason: ${reason}`);
break;
case '!unmute':
target.removeTag('muted');
target.sendMessage('§aYou\'ve been unmuted.');
break;
}
}
});```
found ts
Ok it's 100% nto loaded
onthing works
@thorn flicker YAY
dont cry now, here.
import { world, system } from "@minecraft/server"
const TARGET_ITEM = "vdg:coltwalker" // target item ID
const DAMAGE_PER_USE = 1 // durability consumed per use
const TIME_DELAY = 1
const store = new Map()
world.afterEvents.itemStartUse.subscribe(ev => {
const { source: player, itemStack } = ev
if (itemStack.typeId !== TARGET_ITEM) return
if (store.get(player.id)) return
const id = system.runInterval(() => {
player.runCommand('function coltwalker/empty')
}, TIME_DELAY * 20)
store.set(player.id, id)
});
world.afterEvents.itemStopUse.subscribe(({ source: player, itemStack: item }) => {
const id = store.get(player.id)
if (!id) return
const dur = item.getComponent("minecraft:durability")
dur.damage += DAMAGE_PER_USE
player.getComponent("minecraft:inventory").container.setItem(player.selectedSlotIndex, item)
system.clearRun(id)
store.delete(player.id)
})
🥣
Madlad did it😱
I cant get used to this💔
Minato's the example, all hail him.
But alr ill take it❤️
lol
@thorn flicker Is there an autocomplete
are you using Vscode?
you can install npms to get autocompletions
Yes
world.beforeEvents.chatSend.subscribe(ev => {
const { message, sender } = ev;
if (message === '!spawn') {
ev.cancel = true;
sender.runCommandAsync('tp @s 0 100 0');
sender.sendMessage('§aTeleported to spawn.');
}
});
help someone fr
dont use AI if you dont know what you are doing
-# dont use ai period
for starters, change runCommandAsync to runCommand
it got depreciated a long while ago
Install the npm packages
it should work, are you using beta module?
{
"format_version": 2,
"header": {
"name": "Bedrock Add-ons",
"description": "Script API Template",
"uuid": "6c2285a9-e037-476d-935e-59bfa8f264df",
"version": [1, 0, 0],
"min_engine_version": [1, 21, 90]
},
"modules": [
{
"uuid": "ddee3837-c6f7-4fb7-98be-0895b1dadb05",
"version": [1, 0, 0],
"type": "script",
"language": "javascript",
"entry": "scripts/main.js"
}
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "2.1.0"
}
]
}
thats my json
chat event's only in beta
how do i get beta then?
that's not even a full spoon
fr?
2.2.0-beta
"version": "2.3.0-beta"
2.3.0*
oops
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "2.3.0-beta"
}
]
}
import { world } from "@minecraft/server";
world.beforeEvents.chatSend.subscribe(ev => {
const { message, sender } = ev;
if (message === '!spawn') {
ev.cancel = true;
sender.runCommand('tp @s 0 100 0');
sender.sendMessage('§aTeleported to spawn.');
}
});
[Scripting][verbose]-Plugin [Bedrock Add-ons] - promoted [@minecraft/server] from [2.1.0] to [2.2.0] requested by [Bedrock Add-ons - 1.0.0].
[Scripting][error]-TypeError: cannot read property 'subscribe' of undefined at <anonymous> (main.js:3)
[Scripting][error]-Plugin [Bedrock Add-ons - 1.0.0] - [main.js] ran with error: [TypeError: cannot read property 'subscribe' of undefined at <anonymous> (main.js:3)
]
system.run(() => {
beforeEvents.asyncPlayerJoin.subscribe(async (data) => {
console.warn("test", data.persistentId)
const name = data.name
const pfid = data.persistentId; // This is the PlayFab ID
const map = JSON.parse(world.getDynamicProperty('pending_pfids') ?? '{}');
map[name] = pfid;
world.setDynamicProperty('pending_pfids', JSON.stringify(map));
return Promise.resolve();
});
})
```Anyone know why this isnt working? it wont even log the data.persistentId, however its working in other packs im lost rn
what the hell
?
where is beforeEvents defined?
import { beforeEvents } from "@minecraft/server-admin";
ohhh
guys help me
why dont you just use / commands
awhile ago
import { system, CommandPermissionLevel } from "@minecraft/server";
system.beforeEvents.startup.subscribe(({ customCommandRegistry }) => {
// Register the custom command
customCommandRegistry.registerCommand(
{
name: "lab:home",
description: "Create a home.",
permissionLevel: CommandPermissionLevel.Any,
mandatoryParameters: [
],
},
(origin) => {
system.runTimeout(() => {
create_waypoint(origin.sourceEntity)
})
});
});
bru..
yk instead of sending us the error you could read it and fix it 😭
just the registration stuff.
now i have to figure out how to give someone a random kit when they die..
w/ random enchants
i'm SO cooked
idek how to get death
not if you learn javascript and then the api
is there some simple kit system i can copy from
learning is an option too
lol
cant
like too lazy
maybe /replace item but how would i enchant it
idk
ofc, how could I beat nanny Minato? (lol)
Use sender.teleport instead kf runCommandAsnyc ir any of that.
Also why making jt that complex?
Minecraft added custom commands, use them
he knows now
Read the docs
He will forget soon
is there a way to feed animals without interacting with them just by using script api?
for taming or breeding?
you can get the tameable component on entities
breeding
you cant get the breedable component though
i tried using /event but theres nothing called breeding
because there's no event for it
sooo how does cow starts breeding when with interact with them using some food?
minecraft:behavior.breed
soo if i want to make my breeding event i need to modifie the cow behavoir?
there's no way you can modify it so you can trigger it when you want to.
breeding mobs using script sames imposible for now?
yes.
ty
how would i take 1 item from the player's mainhand and replace it with another item?
What type of programming do you use for scripting?
7
13
2
OOP
It is good to know and be able to apply both patterns.
detecting the potion type is still beta right?
Have you looked into the OLOO pattern?
interface MyObject {
a: number;
b: number;
}
const myObjectProto = {
sum(this: MyObject) {
return this.a + this.b;
}
}
const myObject: MyObject & typeof myObjectProto = Object.create(myObjectProto, {
a: 1,
b: 2
});
myObject.sum() // returns 3
not a bad option
hadnt see it yet
by the way @slow walrus what chars exactly the id of a scriptevent doesnt handle?
im testing with some arbitrary numbers and it's working
seems to be sending and receiving the bytes correctly
on the id
import { system, System, world } from "@minecraft/server";
world.afterEvents.playerButtonInput.subscribe(ev => {
const buffer = new ArrayBuffer(128);
const view = new DataView(buffer);
for (let i = 0; i < 64; i++) view.setUint16(i * 2, Math.random() * 0xffff, true);
for (let i = 0; i < 128; i++) if (view.getUint8(i) == 0) view.setUint8(i, 1);
const arr = new Uint16Array(buffer);
const id = String.fromCharCode(...arr);
console.warn("Sending this shit\n", arr);
system.sendScriptEvent("test:" + id, '');
})```
the sender one
```ts
import {system} from "@minecraft/server";
system.afterEvents.scriptEventReceive.subscribe(e => {
const splitted = e.id.split(':')[1];
const arr = new Uint16Array(splitted.length);
for(let i = 0, j = splitted.length; i < j; i++) {
arr[i] = splitted.charCodeAt(i);
}
console.warn('Received\n', arr);
});```
the receiver one
just made to console the id instead
it seems that as long as the chars are not control ones, its safe
well, actually only bytes 10 and 13 are causing troubles
only, 0, 10 and 13
i aint got idea of why the fuck 10 and 13 cannot be sent on the ID
anyways, anything that isnt these 3 work. Using something like base32767 would be enough probably
10 is line feed and 13 is cariage return
i thing that might be the problem
yeah, \n and \r are the only problems
what the helly
i tested with base32768, no problems at all to send bytes
just by avoiding 0xA and 0xD and obviously 0x0 can be enough
OLOO seems interesting
Is it good?
It's all right. I have yet to build anything big using that pattern, mostly because TypeScript is really pissy about typings and prototype chains.
TS would much rather you use classes.
im almost switching to f# due to the lunatic type system ts has
and because f# is purely functional and transpiles to js
so it would be pretty fun to learn more abort really FP languages
Dang 99999 msgs
I mean, js based their whole inheritance system on prototypes. The pattern is sort of built into the language already.
hey i left scripting api for a while
does someone know if typescript is supported natively now?
or still have to compile
Still have to compile
Getting MC to natively support TS won't happen.
Since TS is it's own thing...
?
ts is literally just a superset of javascript
ts is javascript but with better typings
it shouldn't be that hard to implement
idk why they haven't done it yet
well, its
its hard as fuck
and that isnt Mojang job to create a language for us
anyways, one of the reasons why its hard is because js works focusing on the duck typing and being fully dynamic
if making it run ts natively, it woukd have to be another runtime than js
actually ts hasn't a real runtime anywhere you find
node, bun and deno internally build the ts code to js and then run it
ts is just a language that transpiles, it doesn't have its own runtime
so reimplement alot of shit, work in other optimizations, since js tries to optimize as hell to handle any types, write new errors, etc etc
i think the harder would be to implement new optimizations and male the runtime
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]
I got myself a new lil sla-, uh, I mean friend. yay!!
Because TypeScript isn’t something you run directly, it’s a language that gets transpiled (converted) to JavaScript before execution. The Minecraft Bedrock engine only runs JavaScript at runtime, so there’s no real benefit in adding native TypeScript support. Running TypeScript directly would require embedding a compiler or interpreter in the engine, which would be less efficient and add unnecessary complexity. That’s why it’s not implemented, and likely never will be.
Such a good time reading it
Also i want to say the TS is not just superset as it contains things like Enums that are not JS feature at all so it requires transformation steps and thats already part of the compiler, its not just that you can drop types 
Pretty useless feature, when you can just compile it to JavaScript.
is it possible to change the filepath of a particle texture using js?
No, It's not possible to change path of any stuff inside a addon using JS, but you can setFloat of the particle's MolangVariableMap and change it's color
aw damn, guess that leaves me with the other method of using offset on texture uv
atleast that's possible, right?
gotta find out myself
or maybe docs has anything about it
actually yeah it's possible
how
that could be texture editor
and just moving the uv possible
using variables on the particles, even if we can't set the offset directly, it should be possible to offset by multiplying the values of it
example :
x = 16
y = 16 * v.uvOffset```
yeah yeah something like this
What would be a good offset value for setting camera to third person over shoulder of player?
Like a bit up and right over shoulder
Depends on what do you mean by JS.
Do I have to pre-register a dynamic property or can I just set a value to one and it will automatically register?
How do i get variable list for vanilla particles?
world.getDimension("overworld").spawnParticle("minecraft:note_particle", loc, new MolangVariableMap().setColorRGB("variable.note_color", { red: Math.random(), green: Math.random(), blue: Math.random() }));```
For example this code, How does one get that "variable.note_color" exists?
look at the particle definition https://github.com/Mojang/bedrock-samples/tree/main/resource_pack/particles
Thank you
Why does the particle look black when I set RGB values?
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
world.getDimension("overworld")
.spawnParticle(
"minecraft:note_particle",
{ x: player.location.x, y: player.location.y + 2, z: player.location.z },
new MolangVariableMap().
setColorRGB("variable.note_color",
{
red: 1,
green: 0,
blue: 0
}));
}
})```
my code
The particles look black instead of red :/
does bds script api have the ability to intercept entity name tag related packets yet
last time i checked was like a year ago and based on what packet events it could listen to back then there wasn’t an ability to do so
you're setting the third argument of spawnParticle to the result of setColorRGB which is undefined
you should be setting it to the MolangVariableMap
const variables = new MolangVariableMap();
variables.setColorRGB("variable.note_color", {
red: 1,
green: 0,
blue: 0
});
spawnParticle(
"minecraft:note_particle",
{ x: player.location.x, y: player.location.y + 2, z: player.location.z },
variables
);
btw getting all players and the overworld dimension every time the interval runs is unnecessary and could cause lag
i’d hope the list’s been updated since
"format_version" tells the Minecraft API which version of the add-on system to use for a specific file. It's sadly not as simple as matching the game version however, since some systems are not updated very frequently. You may have to use an old format version with them!
You can read more about format versions here: https://wiki.bedrock.dev/guide/format-version.html
I have a custom command, however its showing two versions of the same command. Is there anyway to hide the one with a prefix?
import { world, system, CommandPermissionLevel, CustomCommandStatus} from "@minecraft/server";
system.beforeEvents.startup.subscribe(init => {
const rankUpCommand = {
name: "up:rankup",
description: "Rank Up",
permissionLevel: CommandPermissionLevel.Any
};
init.customCommandRegistry.registerCommand(rankUpCommand, rankUp);
});
function rankUp(origin, entities) {
world.sendMessage("Rank Up!");
return {
status: CustomCommandStatus.Success
};
}
Thank you very much
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
const dim = player.dimension;
const variables = new MolangVariableMap();
variables.setColorRGB("variable.note_color", {
red: Math.random(),
green: Math.random(),
blue: Math.random()
});
dim.spawnParticle(
"minecraft:note_particle",
{ x: player.location.x, y: player.location.y + 2, z: player.location.z },
variables
);
}
})
And yeah i knew about calling the overworld dimension everytime
What does setVector3 do? does that set the particle's location? but don't we determine particle's location already when we spawn it?
Read the comment provided to it. It says it stores the components of the vector to a struct of the given name
Something like this IIRC:
variables.setVector3("variable.foo", {x:1, y: 2, z: 3});
// variable.foo.x = 1
// variable.foo.y = 2
// variable.foo.z = 3
it is possible to get light level by entity with api?
If you meant get light level "emmited" by the entity:
Dimension.getLightLevel(entity.location)
The method is available in latest Beta API module.
Also uh can anyone send me a full Form template? I have never touched UI stuff, So i want to do tinkering with it.
You can't hide it.
same thing happens here, I thought it's a bug
Eeek, okay. I guess I just gotta hope and prey that they allow us to do it in the future
They might allow it in a future, but if you really want to get rid of this - use Endstone (if it's a server network) or stick with ! prefixed commands.
thx
It's for the case when 2 add-ons have the same command name, then /thiscommand is hidden and you only see options with /prefix:thiscommand.
Potions.resolve(new PotionEffectType(`instant_healing`), new PotionDeliveryType())
How do use this to make potions? can I even get documentation for these?
Wdym?
they changed the signature for making potions and it's weird because you would think both of those would be enums but they're classes
Not sure if thats fixed but type instance should be unique there should be no way to create custom instances as the venilla should define them
Try looking for something like EffectTypes.get()
or something like that
Bump
is there a way to synchronously run jobs? for example
system.runJob(job1)
system.runJob(job2)
I want to run job2 after job1 has finished. is there a way to achieve this?
call system.runJob(job2) at the end of job1 function?
in this scenario i cant really do that
i think theres a way to see if a job is still running or not
i dont entirely remember tho
it only returns a number for clearing the job
but if you can do that, then in job2 check if the job1 has finished or not each tick then only really start once it has
Use my code
Using this class, you can manage runJobs easily
I made a class to detect runJob progress and detect when it finishes
thanks
is there a typescript version? it doesnt really matter, but im just asking
because this seems useful
What different between runjob, async/await and promise?
system.runJob is specific to the Minecraft Scripting API, and queues a generator to be run whenever free time is available each tick.
However, a Promise is a ECMAScript feature that returns a value, but not always instantly. it is basically what an asynchronous function returns.
can't even believe ai
Sadly no I don't have a typescript version, haha
But you can use a online compiler for JavaScript to TypeScript
uh, that's not how that work
Is it normal that when using spawnEntity the entity despawns instantly when I move away only 16 blocks?
cudtom entity?
nvm it works now
By the way, do you know how to make entities despawn based on distance? I used minecraft:despawn, with min max, but they never despawn, no matter how far away I get or what value I give it, It wont despawn
nope, sorry
alr ty
i have the same problem 
how do one use setCameraWithEase if it doesn't have rotation and location properties?
nvm
does anyone knows how to fix this error? I am using the QIDB https://discord.com/channels/523663022053392405/1252014916496527380 but this gives me error
[Scripting][inform]-§aQIDB > Set key PlayerShop:Plund_mgeyo28y succesfully. 2ms §r10/06/2025, 10:01:23.556 AM
[Scripting][inform]-§eQIDB > Saving, Dont close the world.
§r[Stats]-§eRemaining: 1 keys | speed: NaN keys/s §r10/06/2025, 10:01:23.726 AM
[Scripting][inform]-1
[Scripting][error]-Unhandled promise rejection: InvalidArgumentError: Invalid value passed to argument [0]. 'qidb:storage' is not a valid entity type. at #load (db/QIDB.js:167)
at #romSave (db/QIDB.js:204)
at <anonymous> (db/QIDB.js:110)
[Scripting][inform]-§aQIDB >Saved, You can now close the world safely. §r10/06/2025, 10:01:23.745 AM
what?
current commpilers use AI to compile js to ts
that's not compiling
converting?
yes
Transpiling
not ai 🤦♂️
Does anyone know how to use custom parameters in custom components
yes
system.beforeEvents.startup.subscribe(({ itemComponentRegistry: icr }) => {
icr.registerCustomComponent('custom:component', {
onUse(data, { params }) {
world.sendMessage(`${params.test}`)
}
})
})
{
"format_version": "1.21.100",
"minecraft:item": {
"description": {
"identifier": "minecraft:item"
},
"components": {
"custom:component": {
"test": 0
}
}
}
}
I assume its similar enough for block components?
Can forms show after the result of a command?
for sure they dont
i've already built compilers and transpilers, they dont and wont use ai
In @minecraft/server API 2.2.3-beta, worldLoad doesn’t give access to blockComponentRegistry. What event should I use to register custom block components?
Yeah its set to increase speed even if the speed isnt qhats defined lol youll havw to have something to trigfer the speed decreing
system.beforeEvents.startup
btw, typescript is a superset of javascript, so most javascript code should work in typescript
hello @magic peak here
sorry i haven’t been active recently i’ve been moderating my own discord server
but it was nuked by some bad people
Why is installing npm package so bitchy now?
Always had been.
It lets me install server but then bitches at me with errors for server ui
Only time I've ever not had this issue is with using bun
Had to use --force to get around it
Can you show me the command that are you using to install a package?
errors are common
npm audit
npm force
probably the issue with malicious code
or something like it
i use bun so in generap i dont see these problems
Can someone please help me make a simple script that detects if a Minecart “dies” and if so say a message in chat. For the life of me I can’t get it to work….
I’ve tried almost everything I can think of including just detecting when the item spawns… but no matter what I can’t make it work
show script
import { world, system } from "@minecraft/server";
const triggeredItems = new Set();
world.afterEvents.entitySpawn.subscribe(ev => {
const entity = ev.entity;
if (!entity) return;
if (entity.typeId !== "minecraft:item") return;
const itemComp = entity.getComponent("minecraft:item");
if (!itemComp || !itemComp.itemStack) return;
if (itemComp.itemStack.typeId !== "minecraft:minecart") return;
if (triggeredItems.has(entity.id)) return;
triggeredItems.add(entity.id);
const loc = entity.location ?? { x: 0, y: 0, z: 0 };
const dim = entity.dimension;
if (!dim) return;
dim.runCommandAsync(`say Minecart item spawned at ${loc.x.toFixed(1)} ${loc.y.toFixed(1)} ${loc.z.toFixed(1)}`);
system.runTimeout(() => triggeredItems.delete(entity.id), 20 * 10);
});```
That’s the item based one..
use entityDie event?
also runCommandAsync dont exist
use runCommand
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]
Lol i didnt have typings installed for UI module and i was like why isnt typings showing
I tried that and nothing happened. My only guess would be Minecarts don’t really “die”? Idk I also considered just tracking if the UUID exists and when it doesn’t it died but that seemed cringe
Hm makes sense why would minecart die
why dont you check if it is alive/valid
and when it is not valid anymore, You can detect that it was removed
entity.isValid
Literally just using npm i and then the packages
Sorry not at pc rn so couldn’t send anything
What was the error
anyone know how to use that: https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entityqueryoptions?view=minecraft-bedrock-stable#volume
I dont know, but the converters say it is powered by AI
a
How to create a backpack (no ui and use dynamic property), if you mine a block it will automatically put items in the backpack.
Good evening, I'm using a command to detect entities several blocks higher than the player/entity but it seems to be a bit inefficient. Is there anyway I could use scripts to make it easier?
Command in quesiton:
/execute if entity @e[type=!player] at @e[type=!player,dy=3] run tp @s ~~3~
It's very simple using dy to detect a different entity's Y level to run a command/function
probably uses "ai" for propaganda, or this one really does use ai because doesn't know how to write a transpiler
but the normal process is to write all the frontend by hand
frontend i mean text relates stuff, the syntax and grammar
A GitHub copilot in disguise
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
I couldn't stand my ADHD confusing me with Math.max and Math.min anymore, so I created this globally
(There is no Math.clamp in javascript for some reason)
it actually exists in math module
function clampNumber(val, min, max) {
return Math.min(Math.max(val, min), max);
}
tho its basically the same as what youre using
lol, i allways keep doing Math.clamp, Math.round
Oh
Uh...
I don't think it exists, it doesn't even appear in autocomplete
i meant minecraft math module
Yes, I use it in json
But in JavaScript apparently there is no such thing
Hmmmm
its only available in npm

