#Script API General
1 messages ยท Page 93 of 1
Look it up
When does vibrant visual come to java edition?
This is a bedrock server. You're better off asking in a java server
Now just npm i the packages as per the guides on the official docs
VS will pick up on the auto completions iirc. Although idk since I never really used VSC for mc scripting
Did ya restart the terminal?
0.8 * 3 ๐
weird that I haven't run into this issue before
Now that I think about it, I don't use decimal calculations for anything, maybe this is why
cool, customCommand has alias without namespace now
it shows both the one with namespace and without it
not really an issue but its doesnt look clean 
yea
How?
Is anyone else getting the problem of where you cant jump and you float while walking. this new update?
Wait what.. Really? How??
new update module 2.1.0-beta they add alias without namespace
Wohooo
Yay
also I didn't even notice 2.1.0-beta released ๐ญ
Just saw it
A lot of changes
...
Eh what?
shouldn't that be 2.1.0-beta
Or 2.2.0-beta already released bruh
2.1.0-beta
thats for preview
nvm this is happening to alot of entities
How do i use world initalize in 2.0.0
Ik it got replaced with world load, but idk how to register my custom components with it
you need to use before system startup https://wiki.bedrock.dev/blocks/block-events#registering-custom-components
oh I see
well Mojang added lookAt function in the new API update ๐
Installation for @minecraft/server-admin
Beta API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
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-admin
Beta API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
I do, just dm me
const point1 = {x:-0.5, z:1.5}
const point2 {x:-1.5, z:0.5}
const dx = point2.x - point1.x
const dz = point2.z - point1.z
const angle = Math.atan2(dz, dx)
console.warn(angle)
can somebody run this in their scipt real quick?
mine gets a result of 2.819842099193151 which is not the correct answer I do not know why is gives that and I need verification, Thanksin advance.
Math.atan2() is acting weird
-2.356194490192345
wtf
now my entire math is broken
watdahek
WHAT
WAT IS HAPPENING TO MY MATH
THIS WAS THE ISSUE ALL ALONG
WHY IS THIS ALLOWED
WHAT THE HECK
uff
Got a feeling we gonna have a good amount of bug fixes for the next 6 months
Is there a way to detect if the player has operator permissions
https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server.Player-1.html#commandpermissionlevel check if level > 0
Unary negation operator 
does transferPlayer still work on realms?
hotfixes incoming
what's it mostly used for?
The same kinds of things it is used for in math. e.g. a simple negation function could be (x) => -x
oh I see, I know a lot of maths but I never heard about this
bruh, why i use type playerSelector but have options @e?
that just like doing
const x = a;
-b
the -b doesn't do anything, the code computes the negation of b but does nothing with the result
it just garbage collects it and forgets it instantly
At what point should I use TS?
Screenshots are hard to read, and photos even more so. This is especially true if you are using bridge or another tree editor, as this format obscures the JSON format.
We can help you best if you copy and paste your code here, or send it directly as a file.
okok
The point is, why does CustomCommandParamType.playerSelector produce selectors like @a @e @r?, this shouldn't exist.
I don't use them yet, but I would like to safely assume it's because you can use target selectors to target a specific type. In this case it would be the same as using a function command to target a selector and specifying the target type.
Only here, it may be handled internally and based on the selector type you choose for the parameter in question.
I'm guessing to be honest.
๐
It's just like the /msg command though.. that most likely also would use the playerSelector too but also includes @e like what? You can't message entities so why is it a thing.. It's just how they have it coded 
I doubt that they'd modify it just to remove the entities from it
What would be the new method for making custom components in 2.0.0?
How can I get the Vector3 of the center of the face of a block I'm looking at?
Or actually just the point I'm looking at
Thanks
Can someone take a look at my block file for a sec. Just used custom components V2, but now it displays as an missing block in the world, while the other blocks that use custom components V2 do work. ``````
it's automatic
block.center()
Thanks
Thank you!
i will use it, for my upcoming AppleSkin bedrock port
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]
damn, the feature is now available, i will start making the addon by tomorrow.
hold on
Player.applyImpulse is now working?!
How to put equipment on armor stand with script?
afaik not possible yet, u have to do that using commands (runCommand / runCommandAsync)
Ok, thanks.
yes, support for players was added recently.
holy
do you want the code for saturation healing?
or are you just doing the ui part
why use applyImpulse when you can use applyKnockback?
what's the difference between the 2?
beforeEvents.playerPlaceBlock is still in beta right?
yes
I need to rotate multiple entities if they are above something, how can I store multiple entities in an array so that they all can have this rotation behavior
also, if there are multiple of those entities that are in the array, only rotate the ones on that block
do i just use getEntities() with my array of entities typeIds?
Did isOp get removed?
getEntities()
loop for each of the entities
check the y level if it's above the one you need then rotate it
just create a for loop and loop through each entity and check?
loop for all entities in the world or array?
const entities = dimension.getEntities();
entities.forEach(...
yep, can't be more optimized than that
Should use a normal for loop but I can't be bothered remembering what keyword is needed
today I learned that you can assign a forEach in a variable
Oh wait
lol
I mislooked it
for (const entity of entities) {
...
};
hi Seawhite
hello
Yeah that. Having a C# brain makes me think of in not of
oh wait wtf was i saying sry
entities
Bruh so I can't change their op permissions anymore?
Buddy. Look at the changelog
like detecting the saturation/exhaustion? i can do that very easily ig,
d u mean detecting how much health u will heal by eating that specific food?
are you porting the UI part only
why would i ever use applyknockback to move the player when i can use applyimpulse?
Removed Player.isOp()
Add read-only property playerPermissionLevel to Player
Use the property
everything it has i believe
applyImpulse is barely usable rn
everything possible*
fair enough
applyImpulse directly sets velocity, and client doesnt like a sudden change in velocity
which results in rubberbanding
anyways,
what about applyKnockback?
knockbacks are handled clientside so the client expects it and doesnt cause rubberbands
for now its better to stick to applyKnockback
sure ig
also what do you mean by everything possible
did you mean everything from appleskin mod or
I see, thanks for explaining
everything appleskin includes, such as saturation, exhaustion and how much saturation u will get by eating that specific food etc
oh
and yes before u ask, i have the permission here
the only issue is, im not sure how am i going to make it fully functional and compatible with my other addons at the same time
yeah appleskin is on 'Unlicense' license
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
btw,
you can get food component from itemstacks
is it possible to calculate how much health u will heal by getting the players saturation?
appleskin did that
you should check its source code ig
its kinda hard to deal with tbh
line 303 looks like the one youd be interested in
if (data.id === "plot:buy") {
if (isProcessingPlotBuy) {
player.sendMessage("Please wait, another plot purchase is being processed.");
data.cancel();
return;
}
if (player.hasTag('plot_owner')) {
player.sendMessage("You already own a plot.");
data.cancel();
return;
}
isProcessingPlotBuy = true;
try {
let plotCount = world.getDynamicProperty("plotCount");
if (plotCount === undefined || typeof plotCount !== "number") {
plotCount = 0;
}
plotCount++;
world.setDynamicProperty("plotCount", plotCount);
player.setDynamicProperty("plotNumber", plotCount);
// Register ownership
const ownerRegistry = getOwnerRegistry();
ownerRegistry[player.name] = plotCount;
setOwnerRegistry(ownerRegistry);
const row = Math.floor((plotCount - 1) / 100);
const column = (plotCount - 1) % 100;
const x = 1000 + column * 64;
const z = row * -64;
const y = 1;
world.getDimension("overworld").runCommandAsync(
`structure load plot ${x} ${y} ${z}`
).catch(error => {
player.sendMessage(`Error loading structure: ${error.message}`);
});
player.sendMessage(`You have purchased plot ${plotCount}`);
player.runCommand(`tag @s add plot_owner`);
} catch (error) {
player.sendMessage("An error occurred while processing your plot purchase.");
console.error("Plot purchase error:", error);
} finally {
isProcessingPlotBuy = false;
}
}
How do i limit how many plots a person can buy
if (player.hasTag('plot_owner')) {
player.sendMessage("You already own a plot.");
data.cancel();
return;
}
and i dont think it is possible to make the health part if u have more than 10 hearts
But I can't change their permissions cause it's read only whereas isOp was not
bread
yeah but making the healing part is not quite possible, since ur heart can go higher than 10 and i dont want to make 999 ui images just for the healing part
I'll just stick with the saturation parts, which is the most interesting part of the entire addon
in fact, heart renderer in json ui uses custom renderer so
call 911
?
not
HELP
screw the healing part, I'll just add two progress bars under and above the hunger bar to render both saturation and exhaustion,
and im not sure how am i going to render that food saturation thing
ig thats better
like should i use titles for it or chatmessages idk
HELPPP
call 911
did you just yoink that code from someone else?
Nope
payed someone 50$ for it
what?
yah, if i want to use chatmessages, i would have to make over 40 images just to render how much saturation u will get from 0 allway to 20 (0.5, 1, 1.5, 2...)
yes
im starting to question if the majority of people here can make good financial decisions atp
but i dont got anymore $ rn so i cant pay someone else to make a new one
I can make that for $10 in 3 days
dang....
he made it in 3 hours
-# someone got an instant 50 bucks
-# and someone got scammed
-# damn
exactly
?
3 hours make it even more obvious
?????????????????
Wth
WTH
youre creating an amalgamation of code and a waste of money
man, save your self some money
or just learn how to code for free
50 bucks is like a month worth of revenue i get from curseforge
someone got that in 3 hours
this is so wrong wtf ๐ญ
i've been trying for 8 months. Self motivation fucks with me
it was already hard enough to learn css and html even tho they arent coding languages
8 months is how much it took for me to make my second addon
actually
its LESS
it took 8 months to learn
anyone willing to teach a dumbo like me?
yeah made my almgamation of mc function and script api in 3 months then stopped and came back for more
you goota start your own
yeah like
people can't just give you a lesson
i already know all the sources
my first ever addon (EpicPaladins - Bedrock Port) took me around 6 months to finish back then, now it will take me around 2 weeks to finish
you gotta have something to build
yoo i've seen that addon befpre
-# im lying
unlike school where they just present you the stuff how to do it and crap even though you don't want it
having something you want gives you some motivation
so that you can get that sense of achievement
Yeah exactly
it's fine to have mistakes, it's what teaches you to learn man so go start something and fail then solve it and fail again and solve it again
cause that's how you learn
btw, connecting a new image to the hunger bar can be done by adding controls inside the bar, right?
i havent touched json ui for so long i forgot
hold on
but wait, that will make the images render above the bar not under it
and the exhaustion bar needs to be rendered under the hunger bar
so i need to render them separately from the hunger bar
you can adjust layer on childrens
"layer":-3 or something idk
{
"bar_bg": {
"type": "image",
"texture": "textures/cooldown_crosshair_empty",
"alpha": 0.5,
"layer": -1
}
}
smth like that but this is json ui talk now and we are in #1067535608660107284 so
let's not talk about kids like that in here
oh.
yah u know, im just making sure that i can use "layer":-999
can you manipulate those ui in scripts?
after my first addon never touched json-ui again, never again
if youre adding a control on hunger element (idk if youd do that or something) but just doing "layer": -1 or -2 should be fine
ya i see,
there are some methods but its super limited
i think
(and no sane person likes json ui)
when will we have script based UI
on the first addon release, i won't add the food saturation stuff to it
Wtf do you mean? It was a function that you could not set.
its just too complicated to code tbh
it was writable for whatever reason
idk if it had any effect
Docs are weird...
like i can just make it another progress bar, but making it animated in the good way is quite hard
well minecraft is weird tbh
I used it and I could actually change their op permissions
Anyways. You can just use commands
and thats a huge security concern imo
btw, sending two titles at the same tick to update two progress bars will make one be glitched, right?
But it can't be executed by addons
only the title thats executed the last will have effect
if i send those titles like in different ticks, it will not have any issues
I was just porting a java horror mod that disabled commands and setOp came out of nowhere and I used it
like
title1: every 2 ticks
title2: every 3 ticks
i guess?
so the second title will sent after the first one is sent
Well then. Don't change permission levels. As seawhite said, any add-on that sets a player's permission level isn't exactly safe.
not at the same exact tick
seriously
can one of u command people intergrate is 3 line piece of code into my plot addon
i cant launch my server without this
so instead of using titles and subtitles to render two progress bars, i can use only titles and ticks to redner the ui correctly
the best thing u can do is probably see other people work and learn from it,
I mean you are kinda right. Cause when I tried to isOp to true after setting it to false it didn't work
I DONT HAVE TIME RIGJT NOW
I NEED THIS SERVER RELEASED BY THIS HOUR OR IM PROB GONNA GET DEMOTED
PLEASE
....
well, in that case, pay @shy leaf to fix the code or the entire addon for u
-# he will definitely do that if u pay him enough lol
Gimme 10k 
bro
hey
i've seen u before
arent u godsunit friend
Maybe. Used to. Never spoke to each other in years
11K and I'll do it
pick one @marsh pebble 
No
-# $50?
ik something
-# no
I can give him a hug
12K
seawhite will Bid
-# $200?
A billion
deal
$int.MaxValue
@shy leaf can u fix
dawg

const payAmount = `$` + Math.pow(pay.maxValue, 2)
on a serious note if the server youre working on has only you as a programmer/tech engineer but not anyone else
i want it to use tags
while having the tightest deadline you can ever have from society
i lied
it's a solo project -_-
For?
thats like the 2nd lie from you
if i change it to not use tags it will break myserver and i'll have to redo everything involved with plots
whats the first lie?
yeah no wonder why itll break
ill just let you search instead
i hate people like you (Not racial)
dude at least i dont pay $50 for that code
.....have you ever considered AI instead of nagging us here?
Buddy. If there's no reason to use tags. Don't. Use DP's.
Oh god no
I tried using ai for html. just made my code 100 lines longer
i'll pass
...
For simple shit. AI is fine, for undocumented projects, it's terrible
i asked the ai to fix an error not add another 50 features
you're just using it wrong
Yah bud. The problem is HTML
for javascript in general, its fine to use AI
fr instant hex2rgba function at my disposal
im currently learning vite rn
yeah lol like json-ui and particles
particles are easy
i dont think AIs can see how particles look like
no /s what is ts
not that much, can't find documents on manipulating particles using scripts
well molangvariablemap doesnt have much stuff so
Oh yeah shit like that. Yeah no. That's a whole different level
const MAX_PLOTS_PER_PLAYER = 3;
let isProcessingPlotBuy = false;
// Assuming this is inside a world.afterEvents.itemUse.subscribe or similar event
if (data.id === "plot:buy") {
if (isProcessingPlotBuy) {
player.sendMessage("Please wait, another plot purchase is being processed.");
data.cancel();
return;
}
let plotsOwned = player.getDynamicProperty("plotsOwned");
if (plotsOwned === undefined) {
plotsOwned = 0;
}
if (plotsOwned >= MAX_PLOTS_PER_PLAYER) {
player.sendMessage(`You have reached the maximum plot limit of ${MAX_PLOTS_PER_PLAYER}.`);
data.cancel();
return;
}
isProcessingPlotBuy = true;
try {
let plotCount = world.getDynamicProperty("plotCount");
if (plotCount === undefined || typeof plotCount !== "number") {
plotCount = 0;
}
plotCount++;
world.setDynamicProperty("plotCount", plotCount);
player.setDynamicProperty("plotNumber", plotCount);
const ownerRegistry = getOwnerRegistry();
ownerRegistry[player.name] = plotCount;
setOwnerRegistry(ownerRegistry);
const row = Math.floor((plotCount - 1) / 100);
const column = (plotCount - 1) % 100;
const x = 1000 + column * 64;
const z = row * -64;
const y = 1;
world.getDimension("overworld").runCommandAsync(
`structure load plot ${x} ${y} ${z}`
).catch(error => {
player.sendMessage(`Error loading structure: ${error.message}`);
});
player.sendMessage(`You have purchased plot ${plotCount}`);
player.setDynamicProperty("plotsOwned", plotsOwned + 1);
player.addTag('plot_owner');
} catch (error) {
player.sendMessage("An error occurred while processing your plot purchase.");
console.error("Plot purchase error:", error);
} finally {
isProcessingPlotBuy = false;
}
}```
this is what the ai gave me.. WIl it work?
we don't know why don't you try it?
i already did
Oh good the ai is smarter. It's using DP's on the player
do you have a mock server?
what's dp ๐
then you have the result
for my commands
Dynamic property
then good
Exactly, that's the consequences of now knowing what you're doing
const MAX_PLOTS_PER_PLAYER = 3;
vibe code more
- you need to use
setDynamicProperty()for setting DP - what is
getOwnerRegistry()๐ญ
Welcome to programming
kidding
AI sometimes makes up crap
hallucinations
bro
were you kidding with the "it works omg" part too
why is there even a help channel if you guys tell me to do it myself? I wish cody was active he actually helped people
we dont build codes from scratch for people
You're in regular chat
i mean if we were generous, we could
wait
it's another lie
no
gimme his user id rq
and don't ping him
you literally gonna disturb someone at this point
ye...
whats that
it's insockus addon
i see
Lol what I added that?
si:test mmm
i dont see
it's tuff ๐ฅ
how tf is it not possible to use setEquipment for non-players when commands do it fine
Get the component
undefined
it's not released its only for my smp
Um okay? Im aware people make addons for themselves
Equippable?
maybe commands have stuff that can handle non-player mobs' equipments?
undefined ๐ฃ๏ธ๐ฃ๏ธ๐ฅ๐ฅ๐ฅ
yeah I also dealt with that once with my custom mob, I cant put the equipment compinent
it uses equipment slots string not slots int
so I can't get the equipment
and I can't set equipment
oh bruh
s2pid ik
๐ญ
you can't add equipment component on custom entities right?
I wanna set an enchanted armor on a baby zombie using scripts but nOooOOo
Get the inventory instead I guess?
the remark is bloody lying
oh wait armor slot
Inventory doesn't work I don't think
without modifying vanilla files
WAIT
there was a note there that only works for players before
This component exists for all mob entities.
This component only exists for all players. It does not exist on all entities.
oh fuck you
oho middle finger right there
Wtf do commands use
I thought I was schizo for a sec there
Bruuuhhh
commands
I meant internally, not logically.
what I do is I add that item In the entities inventory then I use commands to show it
Could ask navi?
what command does that?
isnt this script api lets stop getting off topic
nevermind the nvm i did read that correctly
๐ซฅ
addItem on the inventoryComponent of that entity so that you can save the itemStack somehow
then replaceitem command to make that item showup
show dyed leather boots
That doesn't account for full inventories 
exactly
is slotContainer the player inventory?
one of these are enchanted
yeah it's not applicable to all, but in my case yes
wait
slot.runCommandAsync(enchant @s unbreaking 1)
I literally used your method before you did
I believe you could save the item stack in the slot you are gonna replace, swap then put back. That could work.
is this fmbe?
that works for mainhand
nope it's the entity's
those dummies on a string actually wear the armor because of replaceitem, now they can't be enchanted
kill the entities, and you'll see which one's enchanted
we are limited by the methods of our time
use a runtime identifier?
scripting is still pretty limited compared to commands so lets get back to topic before mods thanos snap us
we're on topic though
Commands and scripting
welp just like what he said "we are limited by the technology of our time"
wait what are the new armor prop?
me when .runCommand()
segwayed to commands for a lil while, anyway scoreboards vs dynamic properties
At least it's better than old script api. Before gametest
totalArmor and totalToughness
ohh I see you can get them now
read only, yeah
guys guess what
No
Meaning it could be a player
yeah I guess
cause it's an inventory component
CHICKEN BUT\
const slotContainer = slot.getComponent("inventory").container;
No
I just spent all day fixing race conditions for VC
HOLY
"interactions": [
{
"on_interact": {
"filters": {
"all_of": [
{
"test": "is_family",
"subject": "other",
"value": "player"
}
]
}
},
"give_item": true,
"take_item": true,
"interact_text": "action.interact.allay"
}
]
}```
i thought allays were hardcoded damn
nice, so slot can be any entity makes sense
HOLY
"interactions": [
{
"on_interact": {
"filters": {
"all_of": [
{
"test": "is_family",
"subject": "other",
"value": "player"
}
]
}
},
"give_item": false,
"take_item": true,
"interact_text": "action.interact.allay"
}
]
}```
You can assign functions to variables, yes
if (entity === "minecraft:armor_stand" || "minecraft:sheep") {
entity.applyImpulse({ x: 1, y: 0, z: 0 })
const track_piece = getBlockBelow(entity);
}
}```
i am doing a test of looping through all of the entities and checking for specific ones, then doing scripted behaviors on only those specific entities. having one entity to filter works, but when I add || every entity has those behaviors. ๐
Create a static array then do array.contains(entity);
i got it, ty tho
the || / OR operator does not or the String/the "minecraft:armor_stand"
basically
bool1 || bool2
also thanks to all yall that helped, im coming from other languages so this helps a ton
Guys, do my eyes deceive me? Is API 2.0.0 out on stable?? ๐
yes
Did anyone attempt to shoot a trident?
-# hmm, thats actually a good idea, if i find an unfixable bug in my addons, i could warn the player one or two times before crashing their game
hi
modifying the json file of pause screen how can i make a button open a modal form data
like zeqa or tropical
A arrow should act same as trident
Tried using .shoot method
Tho you need to set the rotation to the players front
otherwise the arrow faces wierdly when getting shooted
not me using 3.0.0-alpha
try trident and lwt me know
oh
do you want me to test this for you?
sure
alr, give me sec.
with scripts u can but the shoot thing doesnt work
function shootProjectile(projectile, power, source) {
const headLoc = source.getHeadLocation();
const viewVector = source.getViewDirection();
const direction = {
x: headLoc.x + viewVector.x,
y: headLoc.y + viewVector.y + viewVector.y * 0.4,
z: headLoc.z + viewVector.z,
};
const vel = { x: viewVector.x * power, y: viewVector.y * power, z: viewVector.z * power };
const entity = source.dimension.spawnEntity(projectile, direction);
entity.getComponent("projectile").shoot(vel);
return entity;
}```
I have this function for shooting projectile
from the players head location
I know how to
ok
I cant summon it.
mh
also u cant break blocks with trident right? how do they do that
...
tridents break blocks?....
no
can you?
you can't in creative mode
i was not able to
huh
yea how is that done
so when trident hits a block the block breaks? Never heard that trident breaks block....
they mean projectile hitting blocks
oh
lol
wadda hel xd
I had to make sure when hitting glass
just incase
throw one at a decorated pot
but no, they dont.
Interesting
that doesnt count
lol
so uh
you cant summon a trident, maybe you can use a structure
yes.
i wanted to shoot trident :/
you could try to edit the entity file to make it summonable.
does that require rp editing ?
thats not a client side thing.
this works.
gonna try that
thx, was about to ask for that xd
mojang should just make it summonable.
u tried shoot ur just spawn
Guys Is there way to detect a block especially a chest that are Spawn in structure because I want every structure in Minecraft that have chest put a property
oh shit
why wouldnt I test it for you afterwards, I literally offered
give me a sec lol
well its still not spawning idk what im doing
yup, it shoots.
my just floats in the air
send vid?
world.afterEvents.itemUse.subscribe(({ itemStack: item, source: player }) => {
if (item.typeId === 'minecraft:stick') {
const trident = player.dimension.spawnEntity('minecraft:thrown_trident', player.getHeadLocation())
const proj = trident.getComponent('projectile')
proj.owner = player
proj.airInertia = 1.2
proj.shoot(player.getViewDirection())
}
})
why do you need the XYZ coordinates colored lines for an hitbox that its just static?
and also what are those buttons in the hotbar < >
k fixed it now thx ๐
hot bar slot cycler
pc has mouse
i thouight it was something to switch hotbars with the 3 lines you have in the inventory
ye thats a good idea
@wary edge hey, sorry for the ping, d u have any link for docs of the new entity hunger/saturation/exhaustion component? cuz i cant find any
sorry for the ping once again
Check stirante.
apparently it is available on 2.0.0 abi
but im not sure how it works
like how am i going to detect them
umm, what is that?
ty.
const saturation = player?.getComponent('minecraft:player.saturation');
const exhaustion = player?.getComponent('minecraft:player.exhaustion');
```they returns undefined
like currentValue is not a thing
nope its right in bedrock samples
You might be using the wrong API version?
"@minecraft/server","version":"2.0.0"
on 1.21.90 stable
Hm, I wonder if they forgot to move it from beta to 2.0.0
to the 2.0.0
i believe
It's not in 2.0.0, it's still beta.
huh?
If so, that changelog is outright misleading
Documentation for @minecraft/server
yah now its working
in that case, i will make the addon and wait till 2.1.0
const slots = [];
for(let i = 0; i <= 7; i++){
slots.push(inventory.getItem(i));
}
if (slots[2]) {
const isWearable = slots[2].getComponent("minecraft:wearable");
if(isWearable) {
ItemsClear("head", "armor");
} else {
ChestItems("head", slots[2], "armor");}
} else {
ItemsClear("head", "armor");
}```
Does anyone know why it doesn't clean the item even though it has the wearable component?
ummm, why am i getting negative values when i do this:
const exhaustion = player?.getComponent('minecraft:player.exhaustion')?.currentValue * 5;?
it should make the number bigger not smaller, right?
Depends. That implies currentValue is a number less than 0.
Dispenser ๐คก
it starts from 0 allway to 4
i need to make it starts from 0 allway to 20 instead
how am i going to do that?
I have yet to use this component, so I am not sure.
Could use Math.abs()
I would sooner try to understand why I am receiving a negative value. Would negative exhaustion happen after I eat food?
no, exhaustion is a different thing
You're a detective now
if (exhaustion > 0) console.warn(exhaustion * 5) this
should detect it only when the value is above 0
ig
wait nvm im soo stupid, the number isnt negative
my bad
Haha, was it [Scripting][warn]-20
exactly
Happens to the best of us. I've been caught by that too
console.warn always gets me lmao
In 2.0.0, a watchdog is occurring in my scripts, probably due to the new way of loading the world. Does anyone know how to solve this?
its just something that only mojang can fix thats the initial stutter
it isnt a problem
ok thanks, I was racking my brains to figure it out
Money
Wow, that's pretty good and smart at the same time. But you're selling it right?
Uh no
Is there a workaround for this?
[2025-06-19 23:25:16:299 WARN] [Scripting] Failed to apply enchantment protection: EnchantmentLevelOutOfBoundsError: When trying to create enchantment instance - Tyring to set enchantment level to 7, range for type protection is [0 - 4].
Doesn't appear to be. I would use NBT editing next.
How do I make a realistic flying I want to make it look like you are flying with an elytra but you aren't
can you access minecraft:item like an itemStack?
math
applyknockback with math
you're back at it again, make a post and be patient
On an entity? Yes
how would you do it?
Entity.getComponent('item').itemStack;
Let's not be rude?
make a post tho cause your code is bombing the chat
I see thanks
Nope.
As it is embed it doesnt take up most of the chat, it'll only get big if you expand it.
Just make a post buddy before it gets drowned out
Why are yall so rude for nun?
Not rude. Just telling you what happens here
"make a post buddy"
yeah
If it isn't a quick fix, move it to a post or no-one is gonna put in the effort to help you
the threads are made for those kind of questions, most questions in here are quick ones
I really just wanna know the error. Im not looking for anyone to do it right now.
Or better. Since this discord is a treasure trove of solutions, just research even if the discord search feature is pretty shit.
i've already scraped this server for plot systems. There isnt alot to look at.
then learn how it works
did minecraft make a command called /knockback?
Ok???
Like ive told you, I've already scrapped thru the messages. Not saying it js to say it. (Literally all of last week)
Seems pretty common to me
764 messages isn't the whole story, you gotta preview the convo too
Videos and shit on mcpedl, google. Ok this is enough.
Yes. Anything that looked intresting i clicked on it. again i already told you i looked through pretty much all of the messages with "vaults" or "plots".
Why don't you understand?
I've been researching plot system for months
-# (Not just in here)
https://mcpedl.com/improved-land-claim-plot-protection-add-on/
Wtf is this then
he's just lazy at this point
I've already seen that yes. But it's not the type of plot im looking for. i already use a mod with land claims in it, But again not what im looking for.
also me and jmafk are literally friends
Trying to prove a point is serverly not mature.
HI SEAWHITE
welcome to cinema
he's at it again
I'm not saying copy it. I'm saying look at how they did things.
it'd take me weeks if not months to understand javascript. I would know i've tried.
hi
Then learn JS!!!
Self motivation for me suck. It's not as easy as that.
Fucking hell now I've been reminded why I left this server
we've told him that yesterday and he's persistent he prefers that other works for him
you know
i think
at least trying a bit is better than pulling the hair off in this place
Not true? I literally said the same thing. Now why are we lying??
Im out .
Good
8 months?
that's nothing compared to a few years
I give up, then come back, realise what I did wrong, fix it, another problem, give up, then come back. Never ending cycle
if i have to be honest
if you 'tried' for 8 whopping months
you gotta question yourself if you really tried it...
I didnt really try. it was more of me learning for 3-4 hours trying to make something work and then just stop for a couple weeks / month and do that same thing. I'll just have to learn another time when i can. Tho right now i just don't have the time.
he told a lot of lies last time I wonder if that 8 months is also a lie at this point 
Programming takes so many years to master.
I'm still shit at it.
But I know enough to try things
Nope. Back when i was a staff member at leaf essentials my friend "Trashy" told me to learn Script api if i wanted to become a developer. If you dont belive me that's fine.
just motivate your self man, at this point you're just pitiful
You know how many times i've told myself that?
@delicate palm
... it's not our job to fix that this place is for learning script-api
At first, this script could only register one plot per person. (the property that stored the player's plots is a number). I then made some edits to more heavily leverage the ownershipRegistry in storing those plots instead.
More work is needed to read from the registry when looking up the guest list, in general management, and when teleporting to owned plots
(If anyone would like to contribute to the theoretical solution, instead of bickering about attitudes)
I ran out of time to look at it tonight
@marsh pebble forced me to come here
yes hi
@delicate palm
come here
i need to tell you something
||you stink||

so cooldown component gets ignored on a beforeEvent?
i dont think so
but you cant read cooldown ticks in read-only anyway
lol, this is why happends when your to lazy brodie
"you're too lazy brodie*"
just ignore it brodie let's not start another one here
is there anyway/method to smelt an itemStack? can't find anything on the dev resources and script
i started learning js 1 year ago, in just 1 month i was albe to create simple scripts for events, after 6 months i was albe to create basically everything
what does smel mean?
He probably meant "smelt"
you cant access recipes so, either you do with name or map the element to the smelt
dang it's gotta be manual, guess I can't do it dynamically
thanks Carchi
you can try to remove "minecraft:raw_iron" => .replace("raw_", "") =>"minecraft:iron" + "_ingot"
that only works for ores though I want to consider every single one
yeah but I have to input manually
that's the only downside
somebody we will be able to acces the recipes
Just realised I had 7 nested if statements in a piece of my code and another redundent if statement in a part of another code
Just removed 4 if statements

if(poor) getRich(this);
Goddamn, I really need to clean to code up ๐ญ
world.beforeEvents.playerBreakBlock.subscribe(e =>{
const { block } = e;
//let blockName = block.typeId.replace(/\d+$/, "");
if (block.hasTag("framed_block"))
{
let i = block.typeId.match(/\d+$/);
//console.log(i);
const blockKey = `block${i}`;
const blockStates = blockStateMapping[blockKey];
// Iterate through each state in the block and find if it matches the blockKey
for (let j = 0; j < blockStates.length; j++) {
const stateNumber = block.permutation.getState(`frame:${blockKey}`);
if (stateNumber === j+1) {
const state = blockStates[j];
const blockToGive = new ItemStack(state, 1);
console.log(state);
// check if itemInHand is true
//console.log("State: ",block.permutation.getState(`frame:block${i}`));
if (!block.hasTag("state0")) {
system.run(()=> {
// Spawn state block and give back framed block on break
block.dimension.spawnItem(blockToGive, block.center());
});
};
};
};
};
});```
Like look at that bs
That's just 1 beforeEvent
if (!block.hasTag("state0")) is competely redundent
I think you need less nesting
Ye
Just a little bit xD
if (stateNumber === j+1) {
const state = blockStates[j];
const blockToGive = new ItemStack(state, 1);
console.log(state);
// check if itemInHand is true
//console.log("State: ",block.permutation.getState(`frame:block${i}`));
system.run(()=> {
// Spawn state block and give back framed block on break
block.dimension.spawnItem(blockToGive, block.center());
});
};
};```
Changed the bottom bit to that instead
Ye
I watched a video yesterday on clearing up code, so I'm starting to look through my code to see what I can de-nest and de-clutter
@vast grove
world.beforeEvents.playerBreakBlock.subscribe(e =>{
const { block } = e;
//let blockName = block.typeId.replace(/\d+$/, "");
if (!block.hasTag("framed_block")){
return
}
let i = block.typeId.match(/\d+$/);
//console.log(i);
const blockKey = `block${i}`;
const blockStates = blockStateMapping[blockKey];
// Iterate through each state in the block and find if it matches the blockKey
for (let j = 0; j < blockStates.length; j++) {
const stateNumber = block.permutation.getState(`frame:${blockKey}`);
if (stateNumber !== j+1)
{
continue
}
const state = blockStates[j];
const blockToGive = new ItemStack(state, 1);
console.log(state);
// check if itemInHand is true
//console.log("State: ",block.permutation.getState(`frame:block${i}`));
system.run(()=> {
// Spawn state block and give back framed block on break
block.dimension.spawnItem(blockToGive, block.center());
});
};
});```
That looks so much better
how to see whatโs new in 1.21.90?
#1384561782617669844
Ye. Das is good
Eh. The more you do it, it'll become easier. I do it subconsciously all the time
nice
I think I tested my add-on spikes 20ms when I had my scripts so badly written, I want to test how better they are after I make everything better
I still don't know shit to denest try catch blocks but it's ffiiiinnneee... Also this is C#.
private async Task ReaderLogic()
{
var startTick = Environment.TickCount64;
var readBuffer = new short[Constants.BytesPerFrame / sizeof(short)];
while (!Destroyed)
{
try
{
var tick = Environment.TickCount;
var dist = startTick - tick;
if (dist > 0)
{
await Task.Delay((int)dist).ConfigureAwait(false); //Delay by required amount.
continue;
}
startTick += Constants.FrameSizeMs; //Step Forwards.
Array.Clear(readBuffer); //Clear Read Buffer.
var read = GetNextPacket(readBuffer);
if (read <= 0) continue;
WriteToOutputBuffer(readBuffer, Constants.BitDepth / 16 * Constants.Channels * read);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
Oh yeah some things are similar. Though the types at runtime is very much not.
ah
Like you cannot cast an interface on a object if it does not inherit it
It will crash
Oh wait. Why the fuck am I Console.WriteLine(ex); the error... It's a GUI app...
Oh yeah. I gotta write the exception logger
oop
Eh. For later. Going through 13k lines of code and finding local exception handlers to reroute is gonna be fun 
I just realised I have some code commented out, and I don't need it anymore. Probably should get rid of that ๐

I wonder how big it would get when I run the source generation...

I would imagine over 15 or 20k...
๐
Hah, I had tile drops off on the world
I thought I broke something when the block wasn't dropping itself ๐คฃ
My script now runs 15-20ms
A very small, if not really any improvement
hmm, if it fails to put a texture on the block, it seems to spike to 20ms, but initially doing it seems to be below 10ms
I need to fix that
That is a 10ms improvement, I'm happy I even got that low (even with the 20ms spikes)
Ok, spikes are now only 14ms after de-nesting 1 more if statement
Yo guys, I wanna ask something "@minecraft/vanilla-data" is only for TS right???
Man, I'm so fucking happy with myself now
I got my script down from 20ms to now be at a stable 9-12ms when in use
Why is this error happening?
In this line of code:
player.applyKnockback(0, 0, 2, 1);```
It's saying you have too many argumeents in applyKnockback()
You have 0,0,2,1 in there, which is 4 arguments
It can only have 2. No more or no less
You are using 2.0.0 ver or 2.1.0-beta?
question
Because it doesnt longer need 4 arguments, needs
XZ and Y vector ({x:0,z:0},0)


Lmao
when using dividers in modal forms, is it a bug that they add null to the f.formValues array?
"2.1.0-beta"
Oh, I get it
๐
Ok, thks
Custom Commands are stable now, right?
no
aw damn
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'm looking to make the entity this script is applied to boost directly to the player or entity it's currently attacking. How do I do that?
Why does removeShap not working?
world.beforeEvents.itemUse.subscribe((event) => {
let line = new DebugLine(
{ x: 0, y: 0, z: 0 },
{ x: 20, y: 10, z: 10 }
)
if (event.itemStack.typeId === "minecraft:stick") {
line.color.red = 1
line.color.green = 0
line.color.blue = 0
debugDrawer.addShape(line)
} else if (event.itemStack.typeId === "minecraft:diamond") {
debugDrawer.removeShape(line)
}
})
It seems that you are likely creating a new instance of DebugLine each time that event is triggered, and removing the newly created line instead of the previously added one.
but when I use removeAll it doesn't works
try caching the line object after addShape and remove that object.
thats weird.
for me the debug shapes appear for like 10ms before disappearing
i think the debug shapes are bugged or something
Anyone know how to get armor trims with js?
wdym?
Netherite armor you can puit a trim on it
How can I get the trims a armor piece has with js?
oh you cant
was the way applyKnockback works changed?
how do i push a player in the view direction?
Not as far as I know. Unless you mean the syntax then yes.
it doesnt allow direction, how do i add the direction then?
https://stirante.com/script/server/2.0.0/classes/Entity.html#applyknockback
It has been changed to use this function signature.
Documentation for @minecraft/server
the example uses the old syntax, im screwed ๐ญ
What is that domain?
what's the difference between that and jayly's?
That their made by different people
...
what happens when you make an api based on another api or docs based on other docs ๐
oh wait
Microsoft docs never had the example updated lol
export function leap(player) {
const viewDirection = player.getViewDirection();
const horizontalForce = {
x: viewDirection.x * 3,
z: viewDirection.z * 3
}
return player.applyKnockback(horizontalForce, viewDirection.y * 1.5);
}``` here's an example of how to use it
you just have to bundle them
thanks
biewdirection returns -1 to 1 right? depending on the quadrant?
viewDirection returns a normalized vector. The length of that vector is 1; that is, the sum of the squares of the X, Y, and Z components equal 1
So I suppose yes, the components must be in the range [-1, 1]
How do we filter to make sure a string only has numbers and letters? Not using "match" from beta.
Do we just have to do a complicated replace?
message.replace(/[^a-zA-z0-9/g, ''))
also if you want spaces, just add a space after 9
message.replace(/[^a-zA-z0-9 /g, ''))
Ah ok, thanks. Seems to be something along the lines of:
(str.match(/^-?\d*\.\d+$/))
/^-?[0-9]+(?:\.[0-9]+)?$/.test(num+'')
yup
Oh ok, thanks
That would clear all letters or numbers though right?
Sorry, no just testing if the string has letters and numbers only.
I phrased it wrong, sorry.
so you want something like abdc123 -> true, abc$#123 -> false
exactly.
hmmm
string.match(/^-?\d*\.\d+$/)
I think it's this one, but I dont know how to get it to test correctly... I think \d is the test part so maybe like:
name.match(/[^A-Za-z0-9?.&\d]/g)
