#Script API General
1 messages · Page 87 of 1
Nevermind it does, I just realized it has to be set in place, can't add it dynamically
This is why ur bad at json ui
I’m amazing at it
U barely know JavaScript so
🍿 
Im javascript king
You "rose" quickly, don't you think? #1067535608660107284 message
Serty dont get involved before i beat u up boy
What does this do?
error
bruh
Minato just forgot that ItemTypes.getAll() returns ItemType[] and not String[]
joined a voice with the guy and corrected it there
.
custom item count
is it possible to do ui with just script and no json ui?
Yes, with the UI server module
im making a mana bar of some sort is that possible purely with just scripts?
Im not well known in this topic.
But for that you'd probably need Resource package related stuff
awright thanks for the help neko
do you know any resources that I can start learning with?
Not really, maybe try reading the docs
yes.
you can use titles to display mana, and use dynamics properties for the mana values.
if you want to make the titles look a different way, you will need learn a little bit of #1067869374410657962
server-ui is for forms, you will not be able to create bar with what N3K0 is talking about.
does Player.id changes when the playereave and rejoins the game?
I'm currently using it to store data about the player on world dynamic properties.
so i wanna be sure if its safe
it is server side only, so yeah it is save
I was thinking of making different states/png of a mana bar and then manipulating it through script
should use glyphs
are u doing it on the action bar or as part of the ui
also is there a way to check dynamic properties saved in a world outside of minecraft?
im making a new ui if possible
I dont it once but it's a hell of a hole
I didn't udnerstand a single part
https://discord.com/channels/523663022053392405/1343590380217569363
i had similar issue , someone helped me here
made a custom cooldown bar
glyphs? can you enlightem me more about it?
custom emojis you can create and use in a title
I thought at this point, he meant forms
I was just letting him know
Oh alright
you can hash data
im used to write with neovim, cant use vscode anymore
i simply think coding with it is too slow
maybe if you parse the function
but you would need to parse a lot of things
and then based on the ast rewrite the function
ast is just a recursive tree, so as long as it's defined using objects, you can use JSON with them
I've heard vim is shit
its cuz the one couldnt get used to the keybinds
how do this suck bro? im running neovim in terminal and i've got a terminal inside it
i dont even need to use the mouse
but yeah its confused as hell on the first time
i remember when i was switching from vscode, i got confused to exit it
if you love keybinds use vim it's a lot useful
and once you get used to it you don't even have to move your hands away from the keyboard
can you lead me to the docs for forms?
Sure
by the way, thanks, its working
i thought i'd have troubles to debug within linux and running with an unnoficial launcher
I think I've asked this a few days ago but got busy with rl family. My question is does anyone know how to detect when a player gets the "unlock" for recipes. Like when you mine a diamond for the first time it shows you what you can craft now? I'm looking at running some events on it if possible.
DUDE WHY WAS NO ONE SUGGESTING ME MCTOOLS BEFORE
Dang all my past problems could have been solved by this
it has a builtin VSCode editor
anybody know what's wrong here? modules version error?
but why tho
why would anyone care abt not having to use a mouse
just seems extra for no reason
its simply faster
and more customizable
and uses less ram
It's a powerful tool, that only a few master.
The ones that talk bad about it are the majority who couldn't master it lol.
Which is why other alternatives exist, such as Nano, to name one.
some stuff like this can't be answered by questions, you gotta feel it
master what it's an ide why would you need to master it ☠️
you legit js write code
and save it, and boom you're done
poor guy, so innocent

yeah he needs some hands-on field exp
Yo guys i might have just cooked
so i used firstly claude ai to clean up that shi and use graph system
and after that i implemented a lot of stuff
[Scripting][error]-Unhandled promise rejection: TypeError: not a function at <anonymous> (index.js:56)
Code:
const form = new ActionFormData()
.title("§aWarp Menu")
.body("§fSelect warp")
.button("Mine §aA")
.button("Mine §aB")
.button("Mine §aC")
.button("Mine §aD")
.button("Mine §aE")
.button("Mine §aF")
.button("Mine §aG")
.button("Mine §aH")
.button("Mine §aI")
.button("Mine §aJ");
form.show(player).then(response => {
if (response.canceled) {
showMainMenu(player);
return;
}
const destinations = [
{ rank: 0, coords: "7 67 20" },
{ rank: 1, coords: "49 67 20" },
{ rank: 2, coords: "91 67 20" },
{ rank: 3, coords: "133 67 20" },
{ rank: 4, coords: "175 67 20" },
{ rank: 5, coords: "217 67 20" },
{ rank: 6, coords: "259 67 20" },
{ rank: 7, coords: "301 67 20" },
{ rank: 8, coords: "343 67 20" },
{ rank: 9, coords: "379 67 20" },
];
const selected = destinations[response.selection];
if (!selected) {
showMainMenu(player);
return;
}
const rankObjective = world.scoreboard.getObjective("rank");
const playerRank = rankObjective?.getScore(player) ?? 0;
if (playerRank < selected.rank) {
player.sendMessage(`§cYou need rank §e${selected.rank}§c or more to enter this area!`);
showMainMenu(player);
return;
}
const overworld = world.getDimension("overworld");
overworld.runCommandAsync(`tp "${player.name}" ${selected.coords}`);
player.sendMessage(`§aYou Tp To §bMine ${String.fromCharCode(65 + response.selection)}`);
showMainMenu(player);
});
}```
This is the error code extracted from a complete file.
Help Me
bruh
BRUH
😢
a function for generating sphere with blocks would be block-utils? dimension-utils? math-utils?
pls someone help me categorize
math
thank u ig
you've made this already in the past
No
Thats different qeustion
i said how can i create the function itself in the post
i am just asking for a idea where would i put it
ohh
i think structure utils
mmmmm
yeah
i dont know why it would be dimension, block or math(please just dont put it here)
I would do it like that.
The spheric calculator: bodies/spheric.js
another question
Go ahead
dimension.runCommand(`setblock ${location.x} ${location.y} ${location.z} air destroy`);```
this drops the loot of the block too. How can i make it not drop the loot of the block?
dont use destroy
Dont use destroy
Dont even use runCommand
soda
yoda
and The reason i am using commands is you can't make it show destroy particles of the block, if using setType("air")
that would'nt make it show destroy particles
im aware.
you have no other option then.
aw
well
Somehow
kill those items right
let me guess, remove the item
that could go wrong
the hell
i rememebr somth
Holy shit never seen that
preview
wait
is there a method to play the particle
same question
Probably not((
The result is a useless component.
yeah same question
yeah theres no method
I just remembered
bruh
There always is one
so does the downvote mean that thing does't even exist?
make your own particle
No, it means its a bad idea
no, it means it's not recommended
There will be too much to do.
almost another soda
ye
not really, i done it before
hm
Particle for each block, are you sure it's not much?
one particle
is it worth it
And how are you going to change the texture?
there is a query for the texture corrds
tell me those issues??
think
i'd just set it to true again after breaking
You can't pass texture to particle
use atlas and change the uv
How do you know the UV coordinates?
i canot
if molangvariablemap had a string variable option, and we could use molang for the texture in the particle...
wouldnt that be awesome?
a query
ok guys thank you for the help i am just gonna kill those items
that has issues aswell
And how will it know what texture to look for?
uh doesnt the items drop in a x-0.5 y-0.5 z-0.5 from the block
it take the block it is on top of
delay the breaking and spawn the particle
you might kill items you dont want to kill.
what if you drop your diamonds on accident
+500% slowdown
well then again you'll check for the item type
this uses it
https://youtu.be/F2T98e4tFHA
الفيديو عبارة عن استعراض لتقدمي فتطوير الربلاي مود لماينكرافت الجوال
but still, what if you drop your cobblestone you mined into the cobblestone being destroyed
and poof
there goes your cobblestone
with the gamerule method, what if someone is mining?
ok oko k ok
wrong video, nvm
can someone refer to json-ui channel i need sum help there
I dont know json ui
Dimension.fillBlocks would be a better option
why
Well, because these particles are not needed at all.
dimension.setBlockType
I don't think he only needs 1 block
he used the setblock command.
unless its being iterated
oh
It is quite possible that the shape is not square.
can u pls refer to json-ui? i need sum help there
where's your post
+2000% slowdown from entities
bruh? He is making his replay addon, he just sent his method for the break particles, does he have another way to display those particles? thats the only option for him, even if being aware of slowdown
can't, i am working in something
well, it is an option at least
i am actually removing that method
Ok, ok, sorry
thats cool. But the animations are not smooth
Bru thats one geometry per rotation degree
already i do every 15 degrees
Sorry also me if that hurt you
i.e. 6 geos per block
I dont know but i've seen create addons have shafts smoother than that
Ya
because they probably used entities dude
lol
Also i am planning on doin 1:1 port not some create-likey thingy so i dont really look at other "create" addons
I see
huh
it is
how is it changing geometry then
one way or the other
which is ticking
yeah
im no longer interested
so, a runinterval, that don't change anything
I was having the same issue, and I went to look for the relevant support thread since somebody was sure to have the same question.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
But nobody answered it. 😩
did you make a post
bruh i am making this functions:
breakBlocksWithDropLoot()
breakBlocksWithoutDropLoot()
that name is too descriptive 😭 and seems AI how else do i name it, i am making a utils file, otherwise if i name it breakBlocks(), the users wouldnt get the difference, how do i name the both? lol
No, I went to look for someone else's existing post, and saw that it had no answers.
So now I am sad.
make a post
lol
i used ai since i am currently busy.
That post already exists, and it is asking functionally the same question. It would just be a duplicate.
so depres 💔 🥀
mew mew bump
any ai usage is lame
but hey, do what you want
ok say whatever u want
yup, just did
and i did too ^^
yes
-# In anticipation of a question like "why doesn't this fictitious AI function work?"
-# "guys, fix this code it aint working, btw I used chatGPT"
It is highly recommended that you don't use AI-generated answers for help chats, especially for something as niche as Bedrock add-on development. Most of the code that the LLMs ate up is outdated and probably doesn't even work. 😂
facts though, i mainly used claude ai to refactor my code.
-# Too difficult
idk
yeah
finna dont you use ai
undefined
can we cancel the gui opening interaction of a chest?
lol
yes
good
playerInteractWithBlock beforeEvent
world.beforeEvents.playerInteractWithBlock
beat you to it
You type fast, damn.
im literally the slowest typer
what do you mean
Documentation for @minecraft/server
Well, actually I wanted to write the code at first, but then I got lazy
fair
Thank you, i know this method, i was just wondering whether event.cancel = true will cancel the opening or not
Similar question: #1363633290426191942 message
It has no satisfactory answers, but it at least has activity.
lol
I can't type
just joking
Lets be honest
some people dont want to understand this
When developing with script api, People just ask AI , and he can give always wrong answers on that, since AI doesn't know about the documentation, even so, feeding the documentation is very hard. But the thing AI is too useful for is basic JS stuff, such as JavaScript logics that doesnt relate with the API, and also either useful if you tell AI to help with bigger things to help with automation that would take so much time such as, "Hey AI, can you please optimize and format the code, and make functions for some part of code, to make the code readable? and please dont add any new methods, just help to refactor the code"
its not the fact I dont understand it.
I was not talking about you either
@thorn flicker if you want to criticize me for using ai, then help me with my project duh
nah
See?
well, its not the fact people dont understand it
see what
This does not cancel out the disadvantages of AI
mm
I think yeah
True
I don't use ai for api-specifics
I rarely have issues with just JS logic when I run into issues with add-on development. It is almost always an issue of the API having some silly limitation.
hahah
Like right now, for instance.
see what lol
Are you guys talking about how AI isn't accurate and shouldn't be used to write all your code or something?
The onPlayerInteract custom component event seems to absorb all block events, and cancels ordinary events. It's has no filter options (e.g. filter by item used), and it has no cancel option. So applying it to simple blocks that otherwise have no special interaction functionality beyond the one thing I need it to do is really annoying.
In this case, making a custom log that you can strip with an axe.
just discussioning our opinions
yes
(in case there is some officially-supported method for that and I am XY probleming here)
||I use ai so i dont feel lonely||
poor guy.
I can make the log stripable just fine. But then you can't place anything on said log without sneaking. :P
Ah fair enough.. I actually asked it about JSON UI once and it got everything correct except it wanted to add a file for passing through textures. For how little knowledge there is on JSON UI, I'm surprised it got it correct except for the one file. I also wont lie, I do rely on ChatGPT a lot but most of it is used purely for formatting my code or helping me move existing code into classes, functions and such..
So much sarcasm in the people i fkg swear
sad times
I also kinda just use AI for being a solo developer too. I'm not even gonna lie about that. It helps for usre
I need to stop using it though, I'm not able to learn further since I use it so much
tbh me too
The most I can justify using AI for is as a glorified search engine. It's useful for connecting dots and getting some useful terms into my consciousness. But I refuse to use it for writing code as a matter of principle.
AI is too helpful when learning about JS.
i learned a lot about Obejct methods and Array methods, AI explained it easily
did you really learn though
lets see, why not have a test lol
idk really if i did learn
AI used to help cheat on exams moment.
Just shooting yourself in the foot.
You won, but at what cost?
I don't really tend to learn unless I'm writing the code which also kinda sucks. I managed to get a grasp on it for the Script API but if I tried typing out C# or python or whatever other language, I'm not going to be able to understand it so it's kind of a mess for how I learn. I don't have a sufficient way of learning
I get spotify ads about chatGBT being in college or whatever
like how is that good
at all
what does Object.entries() method do?
you need to feel JS code to understand, I really cant explain it how it works, BUT lets say it iterates though all value and keys
send a code you used ai on and let us question you
yes, promote more ai usage
It returns an array of the keys/values within the object called
pro ai minato
Use an IDE that has the method documentation at the ready from hovering the mouse over it.
cant believe this
Also use TS.
lets see my deepseek history
Oh boy, Deepseek
did i say that
im fucking around
LMFAO LMAO most of my chat history is just combining database scritpts
-# am i getting leaked
Wft did i start...
well, i didn't say i don't
huh
i do use it when my brain is not braining
omg

it*
my bad machine
I used to use AI a lot, but I've been trying to use it a lot less now. MistralAI was amazing at it. But it has gotten terrible now
practice skills
fr
can't rally use it when my project is 200+ file
Well
AI it's pretty simple Ask it "what's the date of your last knowledge training" or similar. You'll find out most are about 6 months ago. So it does not know that things like .chatSend before after events don't exist in the current stable like 1.19.0
was not supposed to share that screenshot
what was it
Mistral has a library system where you can add all your files for it to look through and help you with. I have like 30 scripting files in one library in case I'm stuck. And its knowledge is fully up-to-date with 2.0.0-beta
cant tell, lol
it is under NDA
i thought it is another workspace
woop
The police are on their way.
And you can get ones to query the current version (if has web access) the current versions, and convert the version to actual links to some like unpkg.com for the module and use current data. But that shit eats up tokens
i saved the screenshot
prank
lol
damn
um, this is a civil matter
im a lawyer, you see
Impersonating a lawyer could get you into prison and a hefty fine 
i hope you dont take bribe (your jooking youre not a actual lawyer right)
now its not civil matter
not moving to offtopic to continue this joke further lol
This just means you are inexperienced in that area. So you shouldn't be so quick to jump on someone about it when you lack very little knowledge to grasp it.
Prime example of why one should humble themselves. If you know then you know, but when you don't, just say you don't, and either learn more of it, or move on.
It's not a competition 🫡
it's not that deep
holy moly
I sensed some passive aggressiveness
i don't know how to use it, and i don't want to use it
but man they have some powerful shortcuts
Best I can come up with is to juse use the itemUse world after event and check if the block is there via the raycast method. The only downside is that it doesn't trigger the swing animation. But better no swing animation than the block not letting other blocks be placed on it.
the time you spend learning them will amount to the time saved
On the topic of VIM, it's super useful if you're SSH'ing into a Linux server backend that has no GUI to speak of. But as an editor, it is frankly painful to use. lol
guys I'm a nerd 🤓☝️☝️
nerds are cool
when using them you save time, so...
vscode has shortcuts also
not as useful
Okay and?
what a nerd
i call that 'skill issue'
theyre limited to what vscode permits
legit nobody except 3 people here give af about vim
i dont think thats relevant
n neither is vim
so why you losing so much time talking about it?
Why are we still talking about this? Move on.
bcuz someone replied to me from a while ago 
Move on
i just saw 'vim' in a message and it got my attention
Lol
I did stop bootlickin
It is, yes. Although, at the moment, I don't see the perks of VIM beyond the ability to use it in the shell worth it to get super good at it.
It would never be my regular IDE, for instance.
actually i tried switching from vscode to nvim about 3 times
i got so confused that i simply thought about going back to vscode
Why would I need to do that? Who am I trying to impress here? Definitely ain't you lol.
Just move on. It ain't worth arguing over.
bruh I'm muting this fkn chat stop pinging me holy

why do i always come back to this?
ok I'm sorry this was mean
That's just #1067535608660107284, no worries

damn bro, tsc rewrite using go is so damn fast
seriously, it compiles everything in less than a second
An argument? At this time of day, in this discord server, localized entirely within the script general chat?
Yep. As spontaneous as a fire
May I see it?
Best one is naturally shitty code 
This made me chuckle lol
just bundle the code
normally bundlers in js minify the code
trust me, that won't stop people from yoinking your code
Wtf has happened here
Can we use beta APIs in realms?
Yes
How?
What do you mean
I believe you just enable the beta apis on the world and then apply the pack
U sure about that
Yes, that's how it works.
Hmm
upload a world with beta api on
don't think so
How can i summon an entity that already have a nametag?
I'm using a form with a list of mobs the player can spawn but I want one of then to spawn with a nametag applied to it
create enity and change name tag
@thorn flicker thanks, i realized thanks to you that i've been using ai lately way too much and not doing stuff myself.
L m f a o
the api is still very limited tho
i think i'mma do it by myself from now on
If you do both within the same tick, there's absolutely zero difference
spawnEntity() returns the Entity it spawned into the world, so you can do:
const entity = Dimension.spawnEntity(...):
entity.nameTag = ...;
@nova wraith
for entity.playAnimation, is the "controller" required? And is the list of players an Player ID or NameTag
Is there anyway I can get an item stack and supply a conditions argument that contains all of the properties of the class Container (In Typescript)
Player.prototype.hasItem = function (item: ItemStack, conditions: <Container properties>) {
let hasItem = false;
//Dunno what to do here
return hasItem;
};
plr.hasItem(item, {amount: 64, nameTag: "dirt"})
// If player has 64 dirt return true, otherwise false
Might have to do some very complex typescript typing to get this desirable result 😨
No
Nametags, this is going to change in the future
That sounds like a filter. And I believe in Beta Container has a findFirst itemStack.
And how do I apply this to this code? ```
if (r.selection == 11) {
player.runCommandAsync("summon goat:steve")
}
don't use runCommand 
That is how it is right now
ty
I want to make it spawn with the nametag
const entity = player.dimension.spawnEntity("goat:steve", player.location):
entity.nameTag = "something";
requires a location too
edited
Also, async runCommand is deprecated in v2, so avoid it
I'm new to scripts so I don't know nothing about the scripts versions
Thank you
Don't know nothing = do know something 
Maybe
They are referring to v2.0.0-beta.
Im learning
Oh, that makes sense
I have another question, how can I detect when the player hit a custom entity with a custom item?
Is there not a way to access specific slots from hotbar? I'm doing this but EquipmentSlot doesn't seem to have Hotbar or Inventory:
player.getComponent("minecraft:equippable")?.getEquipment(EquipmentSlot.Hotbar, 1)```
How do I get an entity's item when they're dead?
like the deadEntity
from entityDie
There is two main versions of the api, v1 (1.0.0 to 1.19.0) and v2 (starting from 2.0.0).
we moved from v1 to v2 sense the api had some changes that break backward compatibility, there slight changes in how some stuff work, also some api functions got removed.
When I kill a zombie holding a sword, I want to use scripts to drop that sword.
So, when the 2.0 comes to an oficial version, all addons will have to update it?
No, v1 stable version will still work fine
Anything that uses beta version will have to migrate
Thank you, I was starting to get worried
Can anyone reply to this?
Open a post
I'm getting undefined from both equippable and inventory
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.11.0"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.1.0"
}
]
That's what I'm using
There is really nothing to worry about really, it is a smooth migration
That is a bit old, use 1.19.0 to be able to use the latest functions and APIs
and 1.3.0 for the ui one
I will change it, if nothing breaks I will keep it
it will not
I can't help you with that
I hope so
player or none player?
non-player
i don't think that possible

try getting the inv component from event.deadEntity and see
just undefined
welp, there is your answer
try from entityhurt event
undefined
What if
let test = entity.dimension.runCommand(`testfor @s[hasitem=[{item=${i.typeId}, quantity=${amount}..}]]`); if(test.successCount == 1){}
Managed to get it working
declare module '@minecraft/server' {
interface Player {
hasItem(conditions: {[K in keyof ItemStack]?: ItemStack[K]}): boolean;
}
}
Player.prototype.hasItem = function (conditions) {
let hasItem = false;
for (let i = 0; i < this.inventory.size; i++) {
const item = this.inventory.getItem(i);
if (!item) continue;
for (const key in conditions) {
if (item[key] !== conditions[key]) continue;
hasItem = true;
break;
}
}
return hasItem;
};
console.log(plr.hasItem({typeId: 'minecraft:shroomlight', amount: 64, nameTag: '§vLava Core'})) // True or False
Typescript is a hate and love relationship
I really dislike extending prototypes but yeah, glad to see.
https://stirante.com/script/server/2.1.0-beta.1.21.90-preview.27/classes/Container.html#contains Beta has this btw in case you missed it.
Documentation for @minecraft/server

Yeah ew go away.
Could you tell me more. Or tell me where to look to learn that?
I really should learn TS
Anybody know any good videos for setting up TS properly in VSC?
there are algorithms that transform data and use its hashed version, its used internally by hashmap and hashset(Map and Set in js), theres no where exactly to see, it depends on your purpose, you can try using murmurhash v3
it hashes a string into a 32bit number
it can have collision, but well, it depends on what are your needs
nah but if you just want something quick, you can use my tool by running npx create-mca in your terminal.
But in general, you have a tool like esbuild, swc or even tsc go over the ts files and transpile them into js files. Just search the tools names up on the internet and you should find guides very quickly
system.runInterval(() => {
const random = Math.floor(Math.random() * 3) + 1;
if (airdrop_config[random]) {
const location = airdrop_config[random].location as Vector3;
const overworld = world.getDimension("overworld");
// Adiciona o ticking area para carregar o chunk
overworld.runCommand(`tickingarea add circle ${location.x} ${location.y} ${location.z} 1 a`);
// Aguarda alguns ticks para garantir que o chunk seja carregado
system.runTimeout(() => {
// Agora tenta spawnar a entidade
overworld.spawnEntity("dz:airdrop", location);
// Remove o ticking area após spawnar – pode ser ajustado conforme necessário
system.runTimeout(() => {
overworld.runCommand(`tickingarea remove_all`);
}, 20);
}, 10); // Ajuste esse valor se necessário (pode ser 10, 15 ou 20 ticks)
}
}, 20);
I am creating an automatic airdrop spawn system, but I am encountering unloaded chunk errors. How can I resolve this? I have already added tick_world to the entity, but it doesn't allow spawning in unloaded areas.
Spam the spawnEntity thing until it doesn't error or find a different way to see if the chunk has been loaded
Isn't there a way to load the area through the API?
One way is to calculate when the chunk is loaded. You spawn the airdrop as like an object in memory. You then iterate through all players and check if the player is within a certain range to an airdrop. You then calculate it's start position to the top most block and figure out how high you need to spawn it in order to represent a feeling of the airdrop actually being simulated.
No ticking chunks. Just a bit of smart logic and math.
one question, if i'd do something like nosql inside minecraft(not just a class that calls world.setDynamicProperty), would you guys focus performance or memory usage? in case, would it be ok to get a little longer to read/write on it to save memory?
It'll be more performance than memory. Memory isn't much of an issue unless you're writing literal GB's in which case yeah that might be a problem
performance is always an issue when it comes to script API, so definitely prioritize that
i think its better making a poll for it
did the transfer command get removed?
No
wdym by not showing up
You can create a balance, but memory in the Minecraft scripting API has its limits, if you exceed them, Watchdog can shut down your world or server (although I haven't experienced this in a long while so I am personally curious if this limitation has been modified). I’d say memory is best used for caching or temporarily loading data blobs, but even then, the size and structure of that data can still be a concern.
Unfortunately, there’s no one size fits all solution in this environment. It really depends on the structure and purpose of your data. A database design that works well for one user may not be ideal for another. What matters most is whether the approach meets the specific needs of the use case. Even if a method seems unconventional, as long as its logic is sound and fits the requirement, it’s valid.
Why is subscribe and unsubscribe depreciated in playerJoin event
It's not 🫡
https://stirante.com/script/server/2.0.0-beta.1.21.83-stable/classes/PlayerJoinAfterEventSignal.html
Documentation for @minecraft/server
i gotta find where its telling sbout this limit. not only probably but id do implement stuff to be saved on ram and so flush them
i really think having to read about 4kb everytime i want to read data would be bad for performance
i cannot do some hackings such understanding the data such as a in memory file and use pointer arithmetic for accessing data faster
No, it is. Reading and writing large blobs of data is definitely not ideal. One thing I enjoy about the environment for the API's is that it will teach you to learn how to write very efficient and optimized code, or suffer wondering why.
so when requested something, it gets it oncr and keeps on ram, but all that is theory, im still thinking about how to make the 'byte array' to store it
im really having fun with this actually
i like thinking about performance, so it will probably help me to learn about algorithms and problems i can face when dealing with performance in other scenarios
im primarly focusing on backend, but i think working with minecraft in an environment that isnt thst good, and trying to get the best of it can help me on the backend stuff
I know i didnt fix the copy paste
But subscribe being crossed out means depreciated
i mean, the 'byte array'itself i already know, the problem is how would i structure the pages so i can read/write efficiently using btrees
I don't have an answer for this issue other than to be sure you have the right NPM package? Also, it doesn't return a player object. Only the players string name and string id. You will need to use world.getEntity() to get the object using their id string.
Oh like inside the player.join?
I'm storing stats on a bunch of different hats. And its about 200-300 characters per the way it is right now fully writing out names and stats and it's storing numbers as like 0.10482859
BTrees will be extremely difficult to simulate in a JavaScript environment, especially when constrained to the API's ecosystem without external dependencies.
Trying to make the hat names shorter, make the numbers whole only, and shorten the stat names without effecting the way they are displayed
Yea, so world.getEntity(event.playerId).
I can't even unlock a quarter of the hats without hitting the 32k limot
Refactor the code to chunk the data.
Wait does get all players not work for it
Well you just want to get the specific player object of the player joining so using getEntity() is logically sound.
yeah, alot of stuff to think
Im sorry my heads screaming why at mojang right now
Im actually trying to set an id for each player on load
Instead of playerJoin, you could use playerSpawn. That will give you the player object without having to make an additional API call.
Aside from checking if it's their first initial spawn.
I don't quite understand sorry. Can you laymens it? Lol
I dont need to worry about if its first it will run only if that property doesnt exist
i think that, by now, imma do a basic implementation in rust, so i can understand better how databases work, doing so directly, with the lack of knowledge i have, it would be a total mess and i'd lose my time
i still cant get over why its depreciated what are they doing
It's not.
It says it is also whys it not working
It says it because the signal is being replaced from IPlayerSpawn to PlayerSpawn.
So its temp crossed out ?
Check if the blob of data is exceeding the limitation for its size and if true, split the data into smaller chunks then store it. You will need to add logic to look for a key-value pair with chunks and join them back together of course. Or find some other means to handle the data, such as flattening the objects.
Yeah.
Player.sendMessage is not sending player there message
Console warn below it works fine
Might not be spawning in fast enough. The spawn event can trigger before you actually load on screen.
Do i need to do a timeout console.warn got my name
You could try delaying it, yes.
Also check your chat messages. It's plausible it's working but because you aren't loaded on screen it doesn't show up but will be there when you open your chat window.
Its not in chat window
Then you are definitely not loading in fast enough.
20 ticks is 1 second.
I know
1 second isn't that long.
My loading in only apears to take half a sexond ill try 10
Hmm well 10 secs worked i was waiting so ima try 5
It is definitely exceeding the size. im trying to make it save everything in like short names. Instead of storing it as "Equipped time: long ass number" it's stores as "E:1.25.32" or something along those lines. I don't know if I need to store them separately if I can change stuff like that. But I'm still new to this so how to do that is beyond me
Sounds good. Keep in mind that everyone's load time will vary depending on their hardware, and most importantly, their ping. One person could take 1 second to load, another could take up to 60 seconds. Mileage varies.
Console warn got it right away so internalized data wont need to rime out right
And idk any better way to fix it i wish player.sendMessage was save til there loaded grr
Is there a check for if they are loaded in
I could do a recursion function that tries until they are loaded in
If theres a check
isValid maybe? Haven't messed with that property that much. Try it out and see if it returns false any time during the event. Could probably use that to loop back until it's true. Then show the message. ##theory##
Other option is to listen for their input and see if they move. Once they do, you know they are in and you can show the message.
Nope both were true
Only downside to that option is whether they are afk when they load in lol. So maybe consider a delay timer to fall back on? Lol
Its not really critical since i do get the players properties right away
I can't really think of anything else.
I may load them in with a custum bametag the purpose us so they can see there id number
const namePart = player.name;
const timePart = Date.now(); // e.g., 1717035512000
const randomMs = Math.floor(Math.random() * 1000); // 0–999
const randomNumber = Math.floor(Math.random() * 100000); // 0–99999
return `id_${namePart}_${timePart}_${randomMs}_${randomNumber}`;
}
world.afterEvents.playerSpawn.subscribe((event) => {
const { player } = event;
if (!player.getDynamicProperty("id")) {
let id = generateUniquePlayerId(player)
player.setDynamicProperty("id", id)
}
console.warn(`welcome ${player.name} `)
system.runTimeout(() => {
player.sendMessage(`welcome ${player.name} `)
}, 100)
});``` this should work right
i love the effectiveness but hate testing dynamic properties
You don't have to generate a unique id. They already have one when they join the world. player.id. It's persistent in the world they join in, but never the same in other worlds.
For what im doing i do
That id is a key that i need for accessing the grand exchange it will be set to the world dynamic property as a key to your grand exchange
It has to be uncopyable unguessable and unfindable
By uncopyable i dont mean copy and paste i mean 2 ppl getting the same it has a use like a ssn basicually all world data is tied to it
The player id is persistent enough though... And the player name can be changed quite easily either by offline profile or spoofing.
Also very hard to change without world editing I think
There are ways to get the built in id mine adds fluxuation to how my world works
what does sampleManager do?
What?
Minecraft Creator Tools
Why would mojang devs ever deprecate subscribe anyway lol
it would make more sense to deprecate the event itself, not the subscribe method
here
💔 Not loading.
Idk im guessing just while they make changes it says depreciated
also is this the only UI t he forms only capable? they cannot arrange where it is or change the texture?
I sent the sampleManager.js as a message check it out
and then they do this
import SampleManager from "./SampleManager";
import { scriptBox } from "./ScriptBox";
const sm = new SampleManager();
sm.registerSamples({
scriptBox: [scriptBox],
});
Can't change texture through scripting, you'll have to edit the json files behind the button textures
Thats just the class name they gave. It runs a sample code from a quick glance.
ohh I see
dang.. Back to the hellhole I guess
You're importing a class that isn't apart of Minecraft's default scripting api, I'd assume whoever made it would have documentation behind it
Or you can Ctrl + Click Sample Manager to see the code behind it
assuming ur in vscode
I made this script that was supposed to change block states after interacting with certain items. For some idk, it isnt working. Content log says there is an error on line 53, but i wonder what
Are you on the latest version? world.beforeEvents.worldInitialize doesn't exist
Use system.beforeEvents.startup
Im on 1.14.0
Gotta be a bit more specific what latest version means.
Also, it seems to not be a problem, as i got another codes with this that work perfectly
Latest "@minecraft/server" version and minecraft version
What is the best way for me to set up block interaction with armor items. Since use on doesn't seem to work for armor since it equips it
Then that doesnt exist as its 2.0.0-beta.
my first time making a custom component can anybody explain why this isn't running 😔
`import { world } from "@minecraft/server";
const ItemIceComponent = {
onHitEntity(event) {
const hitEntity = event.hitEntity;
const attacker = event.attackingEntity;
if (hitEntity && attacker?.runCommand) {
hitEntity.runCommand('effect @s slowness 1 3 true');
hitEntity.runCommand('playsound random.glass @a[r=12]')
}
},
};
world.beforeEvents.worldInitialize.subscribe(({ itemComponentRegistry }) => {
itemComponentRegistry.registerCustomComponent("swordssorcery:ice", ItemIceComponent);
});`
I got way too used to beta my bad 😞
isnt there a better way to modify the ui? writing json for it is really painful
or at least something being implemented
Rewriting a 600 line file is going to drive me nuts
😁
only 600 lines
I tried suicide but it wasnt hardcore so i only lost my stuff guess i need to write this
My grand exchange hurts my brain
Is there a way to change the player knockback resistance while in the world?
Since yesterday I was able to make the player change from 0 to 2 using events, but today I was editing some scripts and suddenly the knockback event isn't working anymore
And none of the scripts had something related to knockback
I just don't understand why it stopped working
???
@valid ice help
when i try to use the scoreboard database in custom commands it errors
or any functions i call in it
DMs
how does the source get passed into custom commands? I don't see it present in the object parameters. I can see that I can import CustomCommandSource from server, but the only info I'm really getting from the command is the sourceType
You mean the executor of the command?
Be it block or entity?
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/customcommandorigin?view=minecraft-bedrock-experimental
Because you can get the source entity, block or initiator
is playerJoin triggered before playerSpawn?
but where do I add that capability? The only info I'm getting from the command is sourceType
ahh nvm
It's there.. the stringify output just doesn't say it for whatever reason
Yes.
consider using VS Code with TS instead bridge.
1st argument is a origin
if you want to achieve a player, use:
import { CustomCommandOrigin, CustomCommandResult, Entity, Player } from "@minecraft/server";
const sampleCommandHandle = (origin: CustomCommandOrigin): CustomCommandResult => {
const player: Entity | undefined = origin.sourceEntity
if (!(player instanceof Player)) {
return {
status: CustomCommandStatus.Failure,
}
}
// player variable has `Player` type here.
return {
status: CustomCommandStatus.Succes,
}
}
I know, displaying the 1st argument into chat is only showing entityType
i already had to do so with 3k, now i dont make code bigger than 500 lines if possible
hey btw is it possible to (without manually storing it via onPlace), check the number of ticks that've passed after the block'd been placed?
Also why is this chat dead
this is script chat go to #add-ons if you wanna talk that place is much more generalized
or at least absolute value of system.currentTick for when the block was placed.
what do you mean not storing it via onPlace? you mean not triggering it via onPlace Afterevent??
basically currently i do this
onPlace(event) {
placeTick = system.currentTick;
...
}
in reality my code is more modular than that but thats basically what i do
can't you just currentTick - placeTick?
i can but i wonder if i can omit using placeTick at all
that would get the difference between the ticks / duration
I don't know if this works haven't tried it but run a timer that add +1 everytick?
that'd be even worse
brb
hey guys, so i'm trying to figure out the custom components v2.0, i'm making progress, made some components for the block, but now i'm trying to make an array component with objects, so when item was consumed, player would get each effect, but i'm getting error that native conversion failed for first argument of addEffect. what am i doing wrong, and how do i access the parameters of this custom component?
"v360:food_effects": [
{
"effect": "absorption",
"duration": 120,
"amplifier": 0,
"particles": true
},
{
"effect": "regeneration",
"duration": 5,
"amplifier": 2,
"particles": true
},
{
"effect": "night_vision",
"duration": 120,
"amplifier": 0,
"particles": true
}
]```
```js
onConsume({ source }, { params }) {
source.addEffect(params.effect, params.duration, { amplifier: params.amplifier, showParticles: params.particles });
}```
i'm sure that the way i'm trying to get parameters right now is wrong, but i don't know how to do it correctly in this case
that's an array I believe to access it you gotta params[0].effect that would be absorption and params[1].effect would be regeneration.
the way this works is that array -> object
🗿
Anyone?
Hey
Also i think we should stop using the ai altogether
those 2000 lines of code from ai are my 600
I don't think you should ever exceed past 1k lines unless there's a very good reason like source generation...
yes
use AI for techincal stuff and use your self for the logic
I don't think you can manipulate knockback in script
how did you do it before?
what? where did this topic come from + why did you reply me + why do you care about if I use AI
its just upto yourself whether to use it or not
i mean that ai's 2000 line code fits within my 600 lines
Okay
But i meant that ""we should stop using the ai altogether"" which you said, doesn't make sense.
alright i didnt mean it in such way
that was the most random comment lmao
I was baffled
lets never use ai
......what? AI is not for replacing us...... i dont think you get it., AI is for helping with hard work, It can help us really, Why not use it?
2 component_groups, one with 0 resistance and other with 2, I used events to change the component_groups, but for some reason it stopped working, the player can't receive knockback even if I manually run the events with command
Btw bridge auto compiles ts into js ^^
again, just because I dont have the same opinion as you, does not mean I dont understand.
mh Okay
AI can help if you use it correctly. Most of the time it's BS
AI at most is really helpful for explaining something (but not doing it itself !!!!)

my point is not about it being helpful or not
i just might be bad at english xd i see
also ts is SOOOO good
so ive heard.
C# is my main
probably go to #1070606638525980753 something might be wrong with the json rather than the script
AI is just another tool and like any other tool it has its pros and cons. It can also be used improperly just like any other tool.
it's better sometimes to search smth by yourself
Been doing benchmarks with different packages and so far JSON.stringify() and JSON.parse() have had the fastest read/write cycles when handling data structures. So I'm just gonna stick to using that and not worry about anything else right now. Thought I would share my experience.
-# An explicitly custom serializer and de-serializer would clearly have much faster results but not recommended for open source projects projecting to share resources with strict limitations.
no more googlin
Btw when u initialize some global object in main.js it keeps it in there like
class ClassifiedClassifyingClass {
constructor() {
this.classer = 1;
}
}
classifiedClassifyClass = ClassifiedClassifyingClass();
// ^^^ this object instance will exist for the lifetime of minecraft world.
AI is still using in most cases outdated data
use static properties?
not for when u have dynamic stuff
you can change static properties
they're not readonly
yeah but that is uglier?
make them private and use getters/setters
Slower duh
wdym
... if you can have full-ass class, then why bother with some singular-value properties?
Yea that's expected because the variable is referencing it at the top level and so as long as its reachable it will remain.
??????
Yeah u can deserialize & serialize
Huh
static properties are better for your case
U haven't even seen my code bro
??????
I don't even know what this conversation is about anymore.
I don't think that he is familiar with OOP xd
xd
it does not mean that you know OOP that much
I know oop bruh i've made in C++ countless 2000+ line classes
I just made a comment regarding my experience with benchmarking data and this took a different turn haha.
Because it is nicer ?
???
I don't make global namespace full of trash that way
it's slower
a tiny bit
still slower
correct
and more memory usage
still a bad practise
True, i'd love to have
namespace shit {};```
in js
?????
Also if there exists such then please tell me
[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'addEnchantment' of undefined at buyPickaxe (ui/pickaxe_shop.js:79)
at <anonymous> (ui/pickaxe_shop.js:145)
const item = new ItemStack(itemId, 1);
// Add enchantments to the item
if (enchants.length > 0) {
const enchantsComp = item.getComponent("minecraft:enchantments");
for (const enchant of enchants) {
enchantsComp.addEnchantment({ type: enchant.type, level: enchant.level });
}
}
anyone know why my enchants arent adding to the item?
Thats C++
why would you have to use a namespace
I wouldn't have to use it
?.
but i'd prefer to
wym? i asked why its not working
it's in .d.ts files
?.addEnch...
that dont work
I think this thread should be named "Conflicted People General"
IMO
its enchantable component
not enchantments
o
also iirc if the item is not enchanted, it can return undefined? im not too sure
oh yeah
false
just getEnchantments method is returning an empty array
[Scripting][error]-Unhandled promise rejection: TypeError: Native type conversion failed. Interface property ['type'] expected type: EnchantmentType (failed parsing interface to Function argument [0]) at buyPickaxe (ui/pickaxe_shop.js:79)
at <anonymous> (ui/pickaxe_shop.js:145)
now im getting this error
uh
what's enchants in your code?
yeah was about to ask that
huh
alr
just copy current string ID and use this sample
2 polish teens arguing over some random thing
🤷
Does perhaps the api allow levels to exceed normal limits? That'd be cool.
Yeah
yeah
player.json
But look at the chat history
Ik how to do it manually
you can use component groups technically
apparently EnchantmentType doesnt have required privileges
system.run(() => { shitHere() });```
gotcha
use worldLoad and loaders
idk what that is
also why arent ppl using newest 2.0.0-beta
Not everyone can or wants to use beta.
marketplace/must be stable
Because beta can break easily.
as a person who (has to) use beta api, youre not wrong
but
theres also a downside where
works 👍
you have to look through the whole code for at least once if theres a breaking change
every update
most of the times its just as simple as changing version in manifest.json
literally bro
but if this happens...
nothing would feel worse than that
ive spent more time updating my code than making it
No. You wait for it to be stable.
i'm porting create mod duh i want the most i can get from the api.
There is no cutting edge in Marketplace.
yeah im not stopping you
im just telling you the reason why ppl dont use it
(and they also explained why marketplace doesnt use it)
Ohh okay
But i wonder, if i wanted to not only host it on some online website, but on marketplace, then do i have to lose features?
Or can i technically put there unstable-api-d mod
marketplace doesnt allow any experimental features
... so i wait till it's stable... yay
mhm
also is it a bug that theres like a 10% chance my game crashes when i do /relaod or /reload all
it should be fixed
cool
its not
past 2 times ive done /reload all my game crashes
Maybe fixed with 2.1.0-beta

Hello! Is it possible to spawn an enchanted book with any random enchantments?
Thanks!
for spawning items, you'd have to use structure blocks
then i guess make each per enchantment
but that is a lot of work
O, does <Dimension>.spawnItem not do that? Or have I interpreted it wrong
The implications of AI-powered development
You can make this much easier, give me a minute
no that is the way i did that when i worked with command blocks only
idk much bout the api so i am not an expert
I see! Thank you very much!
as u can see i am not super crazy or whatever
https://wiki.bedrock.dev/items/spawning-items#structure-method
anyways the goal is to have enchantment(s) on it
I dropped using ai
or maybe spawn some random madeup entity, do /enchant on it's item and kill it
I see, I would like to use APIs in this case so I'll try a different approach
Thank you though!
I'll also see if I can make a way for it
So @warm mason what bout this method?
If i were you i'd use that
But serty prolly knows better method
import { ItemStack, EnchantmentTypes } from "@minecraft/server"
/**
* @param {import("@minecraft/server").Dimension} dimension
* @param {import("@minecraft/server").Vector3} location
* @param {String} itemId
* @param {Number} enchantmentsAmount
*/
function spawnItemWithRandomEnchantments(dimension, location, itemId, enchantmentsAmount = 10) {
const item = new ItemStack(itemId, 1);
const enchantable = item.getComponent('enchantable');
if (enchantable == undefined) return false;
let types = EnchantmentTypes.getAll()
types.sort(() => Math.random() - Math.random())
for (let type of types) {
if (enchantmentsAmount <= 0) break;
if (!enchantable.canAddEnchantment({ level: type.maxLevel, type: type })) continue;
enchantable.addEnchantment({ type: type, level: Math.floor(Math.random() * type.maxLevel) + 1 });
enchantmentsAmount--
}
dimension.spawnItem(item, location);
return true
}
@ancient sierra
Awesome! Thank you so much!
is there any way to enchant above normal limits via script? (i know how to do it via nbt editor.)
no
So i guess my method of structure blocks is the only real way for that lol
Set it to undefined
Instead of null>
I remove the player.jskn from the addon and for some reason the player still unable to receive knockback
And my character have 100hp (on the json file I had the hp set to 100)
Apparently the player informations are stored in the world files
Yeah, properties must be set to undefined to be cleared
If I use components to change hp then it will remain like that
Just setting to null will give it that value
I think the same applies to knockback_resistance
But what I can't understand is why it was working and now it's not working
Yeah, it worked with null. It was I just wasn't recalling my propertys. Also wsp man
Just added AoE, and AoE + Poison abilities.
Got anyone more ideas for cool abilities?
structure, you dont need structure BLOCKS
okay
freezing, fire (spread)
I am just gonna use gameule 👎 👎 👎 👎 bye
