#Script API General
1 messages Β· Page 78 of 1
.bat files is what started my hunt to learn more. My brother sent me an email that shut down my PC and I was so intrigued that I started soaking up the knowledge lol. Now I write code on the regular as a hobby and I tell people it all started from my brother crashing my computer when I was young haha
I don't remember
i was 9 years old π why tf was my dad doing to me
they're all trying to make us stare at the monitor and some characters for the most of our life
my dad just hoped for the billionare football player project. (i dont even like football)
i restarted PC in the school in the middle of the history class and teacher didn't even notice and it was all in background so every stodent saw that except the teacher
i was bad guy ngl
i am sorry for that teacher now
i was a kid
Β―_(γ)_/Β―
my classmates are stealing markers from classrooms
is stealing from school better than a single restart of a PC?
they stole like already 40-50 of them
π
sounds pretty normal activity to me
boys do that in school
I'm just a chill guy who is trying to learn something at school
2 years ago using only powershell and cmd i installed minecraft in the pc class, school pc assistants are absolutely a$$ at stopping you from doing something on the pc
ohh
i thought we are talking about times that were more than 5 years ago
i am old
sorry guys
I am almost in the middle of high school
i have to leave now
i might be older
damn, i always do the minimum to get it sufficient to pass the year i currently have 5.7 / 10
really?
I'm listening to teachers and that's the only effort that I am putting into school tbh
yeah, take a guess
minato older?! i thought you were like 18
i am too shy to guess about your age
my dude is 7 years off
you were born perfectly in 2000
what that means?
hes 25
late 99
neat
damn
you are giving me hope, i wasn't sure if i would be here in this community for another years
i like this community and i wish i will never forget about it
i dont even have full beard π
i have solid one
if i ever left i would come back from time to time
don't tell Smokey, bc this topic is getting too hot for script api channel
@wary edge
When I was in school, they used a proxy server to communicate between their systems in the network. It had a backdoor that was overlooked and it took me no time to find it. I targeted the printer in a teachers class and used Word to print off paper saying stuff like "Hi", "How are you", "I'm bored" lol. Never did anything malicious. Just playful.
we should end this talk
eh, i had one from 17 lol
we should delete this chat
dude 
nice thats good
im still 16 and a half
hew is new here
how got newbie protection
is smokey the owner of the server?
CICI is
Wait were you fr? I was joking
it is alt, lol
the topic kinda die if you tell someone to move to #off-topic
it was fun, i wish hight school was at least as fun as elementary school for me
nah i thought i am the youngest
dude, all we learn in high school is fucking word and exel
and a bit of algo
im the youngest
so true!
excel*
thats good you have a lot of stuff in front of you
in high school im just learning cmd stuff, excel, word, java (obviously using eclipse on eye frying mode)
and i choosed a scentific subjects school
we were doing only python π
it was absolute sh*t
hey java, but on version 1.8
i remembered using a software to turn algorithm to code, pascal? not sure about the name
but at least i know something about electronics
in 2 years of java we just learnt what arrays are π
real
flowgorithm?
btw i was learning a bit of Italy but nothing much
nah, it have pascal in the name iirc
bro
really? i didnt know italian was studied in the world
6 months of duolingo
we in russia studying only pascal
oh i thougth in school
nah
I really need to change my spacings in vscode. They're 8 spaces each I think π€£
π
i use 3 personally
same lol, and it is in freaking french
PROGRAM bonjour;
BEGIN
writeln ('bonjour');
END.
@pulsar sparrow was 2 and i was 4 so we decided to use 3
in school i used to study french (i hate it) and BRITISH english (i also hate it)
US en > GB en
us english has a latin pronunciation, gb english has a french like pronunciation
yea
any we are getting too much offtopic now
so lets stick to the JS and TS at least
like i dont understand why sometimes letters have a sound and sometimes they dont
to be fair that is in English too
yeah but less frequent
Are dynamic imports back? Or are they still gone?
Δ
dynamic imports has been back for a while
and in italian every letter has its own sound like it has sound rules, even if you dont know the word you can pronunce it correctly.. and for me its harder to read like the E sometimes as an I or an E
Ε better
Oh nice. I'm glad they are
there are so back
what are they?
dynamic imports?
ye
const module = await import("index.js");
Importing anywhere in a file that isn't at the statt
like import('')
You can do it without specifying the .js file extension iirc?
that's good
yea, but thats not in ES spcecification
so now we can use the function worldLoad to load the pack when the world is loaded
yea
Nah, I'd await null;
Lol
i used an horrible method to fix that in my database
i just wrapped the constructor of the class in a system.run() π π₯
π
2020 Reddit ahh meme
you did that?
Bruh haha
What does await null even do?
We are not having this conversation lol.
Like does it just fire instantly?
check the second meme
i meant did you recommended that
But we are
so why is await null not reccomended?
it defers the execution in bit but always depends how its manage by engine
Damn
it has unpredictable behavior based on the version of the engine
wdym?
but for before events it works pretty well
Bruh I did await system.waitTicks(1) inside a beforeEvents, thinking there would be no tick gap. Thank god they can now accept 0. ππΌ
i actually use it for before events
yea, i was the guy who invented await null like 1.5 years ago
from what i tested i found out that ALSO RunJobs run differently from each device to another
runJobs are different topic and also managed by engine
ohh
i got notification for preview hotfix
huh
1.21.90, im still processing what they added in 1.21.70
iirc. Trials chamber stuff?
Ah, the spooky wooden creature
the scp statue like entity
Huh
Ye, most likely 1.21.80 stable next week
im the only one that has noticed that the cave and cliffs update got nerfed a lot like at the start there were rivers and land was like everywhere at y 100 + and now it looks like it isnt?
Maybe you're getting unlucky with the world seed
I want to do something, but idk what..
does someone have something useful to work on?
guys, i'm trying to set a damagingEntity in my applyDamage options, but i can't understand how to do it... can someone please explaine me?
entity.applyDamage(3, { damagingEntity: { } });
i think you need to give it an Entity parameter
for test, i've set the entity parameter to attackingEntity (i'm using onHitEntity custom component)
didn't work
send code
I bet you simply put the itemStack inside a placed down shulkerbox and then use block.getItemStack()
Btw, if you tried Ctrl+Pickblock a filled regular chest, and then throw the chest into- like Lava, it actually drops its item content like a shulkerbox.
mh ill keep that in mind
Trying to export JSON through console logs, but there seems to be a logs max length?
Split them into chunks ig?
You can probably shrink it by using "Greedy Voxel Meshing" algorithm. This additionally would allow you to use Dimension.fillBlocks() to fill up blocks faster than individual Dimension.setBlockType()
Using the TXT logs I can get it uncapped, though I do need them to be in raw block by block format to save a painful decompression setup later
Holy fuck. What are you trying to export π
I want to make an overworld map in the nether, 250x250, so I need to scan a 2000x2000 area. I'm saving the height too so I can include it scaled down
Save them as separate maps in the scripts?
I might have a bad approach to the scan but I think it's cool. Use world ticking entities, with a 6 chunk radius, place them in a grid with 120 blocks between each, then I can just get the block at each point, taking the average of 9 blocks in an 8x8 area
nah the export is working fine now, I just copy from the TXT and it's all there in one big block
Ah ok
what data are you displaying lol
there is crazy stuff going on
Does console.log not work for people other than the host?
Yes
Anyone that has it on
Can the script check the graphics configuration?
player.graphicsMode?
which is in v2 beta
so 2.1.0-beta?
its in stable beta, you dont need to be in preview
Documentation for @minecraft/server
But do you know if it is stable in the preview or if it remains in beta in version 2.1.0?
just check the site I sent you.
you can see if its in versions or not
Thanks 
import { world, system } from "@minecraft/server";
world.beforeEvents.chatSend.subscribe((event) => {
const
message = event.message,
sender = event.sender;
if (message === 'test') {
event.cancel = true;
event.sender.runCommandAsync("say Oi2");
}
});
Help me, I don't know why I can't use runCommand
directional checks are getting to be a huge pain in the ass
one of them works so well that i need it to not work so well
Hey guys I have no idea about script api but I want my functions only work when a player break event happens, would you guys pls breakthrough this problem and give me the edit π
How I can to do when player click to villager with tag shop1 it opened form with name "showMainMenu" i don't know because my script for this is don't working right.
PlayerInteractWithEntity event
world.afterEvents.playerInteractWithEntity.subscribe(({ player, target }) => {
if (!player instanceof Player) return;
if (target?.typeId === "minecraft:villager" && player.hasTag("shop1")) {
showMainMenu()
}
})```
also send the code if you have some issues with it in the first place
world.afterEvents.playerInteractWithEntity.subscribe(({ player, target }) => {
if (!(player instanceof Player)) return;
if (target?.typeId === "minecraft:villager" && target.hasTag("shop1")) {
showMainMenu()
}
})
player->targetfor hasTag method- additional curly brackets for first
ifstatement
ooooooh
i see now, he wanted tag for villager
I didn't notice, I thought player needed to have shop1 tag
guguga
@analog salmon
[Scripting][error]-ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (main.js:9)
[Scripting][error]-Plugin [IntoCMD Skyblock Behavior - 1.0.0] - [main.js] ran with error: [ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (main.js:9)
]
Send code
pleas
//imports
import { world, system } from "@minecraft/server";
import { ActionFormData, ModalFormData, MessageFormData } from "@minecraft/server-ui"
//chat command prefix
const cmdPrefix = ".";
//initial SCB obj
world.scoreboard.addObjective("player_info", "Player Info");
//player chat event
world.beforeEvents.chatSend.subscribe((eventData) => {
var {message:message, sender:sender, targets:targets } = eventData;
if (!message.startsWith(cmdPrefix)) return;
eventData.cancel = true;
if (message.split(" ")[0] === cmdPrefix+"island" || message.split(" ")[0] === cmdPrefix+"is") {
world.sendMessage("island CMD")
}
})```
//imports
import { world, system } from "@minecraft/server";
import { ActionFormData, ModalFormData, MessageFormData } from "@minecraft/server-ui"
//chat command prefix
const cmdPrefix = ".";
//initial SCB obj
system.run(() => {
world.scoreboard.addObjective("player_info", "Player Info");
})
//player chat event
world.beforeEvents.chatSend.subscribe((eventData) => {
var {message:message, sender:sender, targets:targets } = eventData;
if (!message.startsWith(cmdPrefix)) return;
eventData.cancel = true;
if (message.split(" ")[0] === cmdPrefix+"island" || message.split(" ")[0] === cmdPrefix+"is") {
world.sendMessage("island CMD")
}
})
try this
@untold garnet
worked
thank you so much sir
is system.run required now in experimental?
usually i create a scb in global code it should work
always remember that whenever you see this in error :
does not have required privileges.
Always put the code in system.run(() => {})
import { world, system } from "@minecraft/server"
import { ActionFormData, ModalFormData, MessageFormData } from "@minecraft/server-ui"
const cmdPrefix = "."
world.afterEvents.worldLoad.subscribe(() => {
world.scoreboard.addObjective("player_info", "Player Info");
})
world.beforeEvents.chatSend.subscribe((eventData) => {
const { message, sender, targets } = eventData;
if (!message.startsWith(cmdPrefix)) return;
eventData.cancel = true;
const [commandName] = message.split(" ")
if (commandName === `${cmdPrefix}island` || commandName === `${cmdPrefix}is`) {
world.sendMessage("island CMD")
}
})
is there a getScore function that I can use to get both real and fake player score?
nvm got it haha
i mean
that also works
i do it
but this is don't working now also
can you send me an error?
can i DM you?
sure
my terminal crashes whilst i was installing npm package
i dont want to reinstall my vscode what do i do
i only get this fucking problem on my laptop
my pc vscode works fine
aaaaaa
Anyway of setting a block permutation without causing block updates?
-# (like door)
How to rotate the player's camera to different axis?
you cant directly edit the view direction, you have to use
player.teleport(player.location, {rotation: {x:10, y:20}})
is there a way to detect if plauer is about to drop a certain item from his inventory and cancel it
kill the dropped item
then add the item again to the inventory
so it acts like cancelling
I just found a new way to detect dropped items. However, it's only available in minecraft 1.21.90.20+
it's more reliable and accurate than using entitySpawn, but of course it's not currently available in the release version of minecraft
what's that?
Documentation for @minecraft/server
playerInventoryItemChange AfterEvent
^^
is there a way to add button to form using for loop?
const form = new ActionFormData();
for (...) {
form.button(...);
}
thank you brother
any know when is the bug?
Script
import { world, Vector, system } from "@minecraft/server";
import { ModalFormData, ActionFormData, MessageFormData } from "@minecraft/server-ui";
-# tomorrow
Vector isn't a thing on @minecraft/server
when?
...?
it's a thing on ui?
create a post and send the whole code there
Vector only exists in the server API as an interface. The actual code can be found in here:
Documentation for @minecraft/math
I try Vector3 later also
You need to import it from @minecraft/math. What you are importing from @minecraft/server is just an interface. An interface defines the structure of an object by specifying the properties and their types. It acts as a contract that classes or objects must follow. To get the actual object itself you need @minecraft/math.
You won't need the interface unless you are writing your code in TS. Possibly using JS Docs as well, but not sure why that may be necessary.
import { Vector3 } from "@minecraft/math";
js
Then you shouldn't be importing the interface. You need the object itself which is in @minecraft/math.
what is a version for Vector3 in math
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "2.0.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "2.0.0-beta"
}
]
}
@minecraft/math is not a module. It's merely a dependency. So you have to bundle it with your behavior pack in order to use it.
When I need active
βοΈ
Bundle the script or use this file
how
check the link
"@minecraft/math" is not a module (visual1mpact said) You gotta download the dumped JS file
@minecraft/mathis not a module. It's merely a dependency. So you have to bundle it with your behavior pack in order to use it.
import { Vector3Builder } from "./minecraft-math.js";
Then you shouldn't be importing the interface. You need the object itself which is the Vector3Builder in
@minecraft/math.
world.beforeEvents.worldInitialize.subscribe(e => {
e.propertyRegistry.registerEntityTypeDynamicProperties({ blocksBroken: "number" }, "minecraft:player");
});```
can you guys help me ?
propertyRegistry isnt a thing, you might be using a wrong version of script api or that property just doesnt exist
i think its only in beta versions
You don't need to register properties any more; you can just straight use them
since when its like 2 years now?
damn
i remember the truggle with dynamic properties back then
haha yeah
it was easier to use scoreboards
Was interesting
scoreboards DBs were fun
indeed
I've searched, even under the rock... I guess setting a block permutation without causing block updates around it is currently impossible.
And, no, Dimension.setBlockPermutation still causes block updates. The reason why a wither/golems doesn't spawn, is because they only detect player placement and dispensers...
Youβre updating the block
Thereβs gonna be block updates
I need that Java's strict block placement option ππΌπ
Even loading a structure has janky block update correction.
are you able to have image links with server-net on action forms?
like
form.button("text", http.get("https://www.youtube.com/imagetest.png"))```
I think they need to have it downloaded on their RP since its an iconPath, not image png
is there anyway to detect running?
movement component
detecting with getComponent the movement value?
Entity.isSprinting
HUH THIS EXISTS
I've been searching in docs for ages π
i always forget that exist
Movement input is still good tho
doesnt detect sprint
Probably. Not sure if you were swiming, crawling, sneaking, or gliding (elytra) tho
k gonna test it out myself ty
it does
yea just tried it
entity.applyKnockback(viewDirection.x, viewDirection.z, 3, viewDirection.y / 2);```
want to make this only does knockback in the x and z axis
system.afterEvents.scriptEventReceive.subscribe((event) => {
const id = event.id;
const entity = event.sourceEntity;
const viewDirection = entity.getViewDirection();
switch (id) {
case 'sp:dash':
entity.applyKnockback(viewDirection.x, viewDirection.z, 3, viewDirection.y / 2);
break;```
full code
make vertical 0
ty
also
is there a way to detect when sneaking it runs a code 1 time only until you unsneak and resneak
basically this but it runs 1 time until you resneak
if (player.isSneaking && (normalizedX === 1, -1 || normalizedY === 1, -1)) {
player.runCommand('scriptevent sp:dash')
}```
use the afterEvent.
k
but if you must use it system.runInterval for some reason, you can do that too.
is there another way to always detect movement without runinterval?
wait nvm u just told me lol
well, only for sneaking and jumping
oh so no sprinting
well I just need it for sneaking actually
they could add it later
sprinting I need it to be constant so I was gonna use runInterval anyway
also can you provide an exemple of using this if you have
ive posted an example in the preview post
let me link it
I still cant do code from scratch just modify it
when did you start scripting
like 2 month ago but last month I had a big break of it cuz of exams
so just 1 month actually
I lied
its for something else
π¬
well I wasnt really trying to learn
when I started I was the same for a short period of time
then I finally said to myself "I cant copy and paste forever"
well I will do that when summer vac starts
so eh, can you make a quick exemple or just how to use it
instead of making it for you
look at other code, and use that logic to create this
I searched for ages on this server in the search feature in dc
suprisingly nobody ever did that lol
you dont have any code that includes an event listener
np lol
in my script i need the block running it to access the adjacent block in a specific direction
how do i do that
@unique acorn can you help maybe?
block.above();
block.below();
block.north();
block.east();
block.west();
block.south();
use whichever one you want!
also you can put number inside parentheses to tell it how many blocks to go to
world.afterEvents.playerButtonInput.subscribe(data => {
const player = data.player
const button = data.button
const state = data.newButtonState
})
Is there no way to check if something is a typeof Array?
I am unsure if I should use string or not
ah wait, I can just do Array.isArray()
Also, what is the Enum to get the switch of panels a person is hovering over?
How to make it that a player canβt hit another player in the radius of 10 from an entity ( v:spawn )
give em weakness 255
ty
With neth sword sharpness 5 you can still hit and you can still mace
give other player instant health 255 for an infinite duration!
I give resistance but I want no knockback, no hitting ( hitting = the players getting red ( I think ) for a second and shaking ))))
instant health does that
it removes knockbac and getting red
idk about sharpness 5 netherite sword or mace tho
"infinite duration"
you can edit the player.json which indeed disables all damage
but if you're making a public addon, I don't suggest it as it can break compatibility with other addons
AH. Iβm using other Addons on my realm
If none of them change player.json also, then you should be fine
Is it not possible to edit dialogue's content (text) via scripts?
how do i check if a player has op
How do you remove a certain amount of letters from a name tag?
const lengthoname = (`${entitys.nameTag}`.length - 10)
const codedintstack = `${entitys.nameTag}`.replace(lengthoname.length, "")
Here's one of the 20 things I've tried... any ideas?
In what order or way are you trying to remove these characters. That is an important question to determine what logic is best suited.
Using a length of text number then removing that much from the beginning of the entities name.
If there's a '.remove' or '.delete' that's what I'm looking for, but using an integer to remove letters. Similar to how '.repeat' works.
You are wanting to remove Β§ as well?
That comes after, but basically right now I'm just trying to get the beginning part to be removed so I can get to the number at the end that's hidden with Β§.
const lengthofname = 10; // number of characters to remove from the start
const nameTag = `${entitys.nameTag}`;
const trimmedName = nameTag.slice(lengthofname); // removes the first 'lengthofname' characters
const cleanName = trimmedName.replace(/Β§/g, ""); // removes all Β§ symbols if needed
Oh! Slice, excellent, thank you so much for your help and time!
I forgot about the / and g for the Β§ too, thanks!
No problem
so i have an issue with typescript
when detecting a gamemode. typescript uses Creative with a capital C, but js uses creative with a lower case c
and when i try to put creative with lowercase c in the typescript file, it errors./
is there anyway to make exceptions for errors
Please share an example of your code to demonstrate what you are experiencing. Preferably in Typescript.
@mighty igloo, are you referring to the GameMode enum?
Because in the preview they use capital letters. JS simply can just get away from by doing this, but idk about TypeScript ππΌ
GameMode.Creative ?? GameMode.creative
Why am I getting equippable as undefined? 
Most mobs (like 90% of the game iirc) can't use equippable component
Player can always use it
also he's logging the object directly
you have to use JSON.stringify()
I assumed sourceEntity was the player instead of the actual entity lol
my bad, thanks for the help
is there a way of getting the player entity using 'event: ScriptEventCommandMessageAfterEvent'?
sourceEntity means the entity running the scriptEvent.
It could be a player, npc, command block minecart... or any execute as @e[...] run scriptevent ...
ooooh, I didn't know the 'execute as' tech, tyvm!!
do you think it is a good idea to protect a spawn by storing the position of its blocks in an array in a dymamic property and canceling the event in case its coordinate is in the array?
If you can define min & max coordinates for each (e.g. a cubical zone) it would be easier to handle overall
export function estrutura(block) {
const blocoPos = block.location;
const radius = 30;
const dimension = block.dimension;
const playersNearby = dimension.getEntities({ location: blocoPos, type: "minecraft:player", maxDistance: radius });
if (playersNearby.length === 0) return;
const jinwooNearby = dimension.getEntities({ type: "wesl3y:mob.jinwoo", location: blocoPos, maxDistance: radius });
if (jinwooNearby.length === 0) {
playersNearby.runCommandAsync(`tag @s add unlock.jinwoo`);
playersNearby.runCommandAsync(`tellraw @s{"rawtext":[{"selector":"@s"},{"text":" has made the advancement Β§a[Jinwoo]Β§r"}]}`);
}
}
There is no error in the code, but it says that this function does not exist
No, typescript cant, but there are workarounds. Like (GameMode as any).creative something like that
I just found that recently
When it compiles it shows as GameMode.creative in js
you mean cancel the event in case the position is X distance from the center?
So it works
if you're using beta, runCommandAsync got deprecated
I mean cancel event if position is between min & max for each coordinate
if above min and below max
beta no.
send the error log here
ok
good idea, thx
what's on line 16
uhm, idk wtf is happening there
@past coyote your logic looked sound, as far as I could see.. z
oh i see
Console warns to see data throughout the code would help you see where stuff is going wrong, if you arenβt already doing so
you're using runCommandAsync on the array
you must do a .forEach() loop
Can you show me where I should put it?
instead of
playersNearby.rumCommandAsync("blah");
do
playerNearby.forEach(player => {
player.runCommandAsync();
player.runCommandAsync();
});```
he said he's using stable
Ah ok gotcha
Oh ok ok
Nvm then
it was isValid() :(

im working on a minecraft beta 1.7.3 server
and I wanted to make scripts that feel non-invasive, especially for something like block/land protectionm
@winter plaza also next time send the code directly, not a screenshot
Ive noticed when doing things with blocks that are bigger than 1x1 (door, or double chest) that things can sometimes fail.
Is there a method or reliable way for handing double chests or doors with a script?
(ie I have a sign that players can place on a door or chest to lock it, however when doing the checks to see where the sign is, or what block its attached to it only sees the single chest block or the door block)
Can I check which way a chest is facing???
player.isOp
does anyone know how to make custom commands on version 1.21.51, I tried to use the code from bedrock wiki, but it doesn't work for this version?
that's the way you're supposed to do it
idk what could be wrong with the wiki example
it still works as far as i know
maybe your code is wrong
Here's my code, I don't think it has any errors
Player.isOp() method in latest beta
but it will be replaced with something else in future updates
yes π
is playerplaceblock before event functioning properly? im trying to log permutationToPlace.type.id type is undefined
can script set a block where chunk is not loaded?
i remember the OG gametest can do that
No.
Show your code. Or an example.
its just
world.beforeEvents.playerPlaceBlock.subscribe((data) => {
console.warn(data.permutationToPlace.type.id)
})
when i place blocks it logs but logging returns undefined
For sake of testing try data.block.permutation.type.id.
okay thanks
now it returns id of undefined
No worries. I just wanted to see. The original method you used returned undefined for any block or were you placing a custom block of some kind?
oak planks to be specific
Oh, well then that would be odd. I would need to get on my PC to investigate the situation but at face value this sounds like a bug with the API.
okok
permutationBeingPlaced
so the property in docs is for latest preview?
the property have different naming between custom components and events, so maybe they fixed that in the latest preview
seem so
beta stable
latest preview
oh okay that works thanks
leave a comment there so you remember updating it later
Oof, I just realized I was looking at the preview docs when talking to that person lol. That's why I couldn't give a proper answer. π
No, I was looking at the correct one. For 2.0.0-Beta.
Documentation for @minecraft/server
the docs are outdated?
this is what i used
that's not event relased
where can i get documentation for module v3.0.0-alpha?
my preview minecraft is at 1.21.80
@leaden elbow it would be permutationBeingPlaced. I'm just now realizing you had a typo in your example that used permutationToPlace.
most obvious rage bait
he seem to be doing the same thing over #1367797461795602432
yeah thanks i js got it on docs thats why lol
yeah i found out
No, but your example above called the wrong one in Beta-stable.
A simple overlook.
Oh wait. I'm an idiot.
You gave two examples showing the change.
I'm gonna go drink some coffee.
How can i detect how many blocks a player has traveled
lol, enjoy you coffee
it is not?
i have those auto fetched, so i am not sure
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]
that's impossible to get an accurate result without using a lot of resources,
but you can check like every 5 seconds the location of player an use the pythagorean theorem to approximate the distance and sum it to the total distance
make sure to look into all the edge cases
nether travel, teleport, and so on
Those edge cases is what will make that a challenge lol.
yeah, jayly had a statistic addon, maybe look into that
Too much work for a single quest..
like
const previousLocation = new Map()
system.runInterval(()=>{
world.getPlayers.forEach(player=>{
const loc = player.location
const befLoc = previousLocation.get(player)
const distance = Math.cbrt((befLoc.x- loc.z)^2 + (befLoc.y - loc.z)^2 + (befLoc.z - loc.z)^2)
//........
})
})
Mh
how to use item component consume event
Why my code not working in minecraft version 1.21.51?
Send direct code instead of sending a zip file
its doesnt use before and after right
import { world } from "@minecraft/server";
world.beforeEvents.chatSend.subscribe((eventData) => {
const player = eventData.sender;
if (!player.hasTag("Admin")) return;
switch (eventData.message) {
case "!gmc":
eventData.cancel = true;
player.runCommandAsync("gamemode c");
break;
case "!gms":
eventData.cancel = true;
player.runCommandAsync("gamemode s");
break;
default:
break;
}
});
What is your script version?
1.0.0-beta
I have nothing to say more but,
Use the latest version
Either use the stable, or 2.0.0-beta
It depends on the version of the Minecraft itself, doesn't it?
Yep
To use the latest version you need to have latest minecraft
Does anybody have documentation for literally any functions for scripting api?
Uh, isn't that the official Microsoft doc?
Wdym any functions?? The documentation does have all functions documented
oh okie
This also does not work, I tried both stable version (1.11.0) and 2.0.0.0-beta, I also remind you that I have a version of Minecraft 1.21.51.
does not exist anymore
Also, im trying to make a item when consumed, removes all effects (just like a milk bucket), problem is:
2.0.0-beta or 2.1.0-beta for preview
why do you have old version
just curious
use ItemCompleteUseAfterEffect
you have to get all effects and loop through them and remove each one
for (const effect of entity.getEffects())
entity.removeEffect(effect.typeId)
what if there's no effects
entity.getEffects() will be an empty array
thanks
World.prototype.structureManager
thanks
what is even a 2.0.0.0-beta, lmao
i think he meant 2.0.0-beta
I'm using bedrock lanucher - https://github.com/BedrockLauncher/BedrockLauncher
i mean i asked why, not how
lol
Just need
I think I got why, When generating addons in bridge, You get a auto-generated manifest with 1.0.0-beta. You have to just change it manually
Yooou use bridge right
Yes
Yeah change it either to latest stable or 2.0.0-beta
the actual minecraft command register is looking very exciting, any speculation on when will it make it to regular released version?
Apparently so, I thought it would adjust to the version I specify in the project.
1.21.80 will be releasing slash commands probably
this wednesday if I'm correct
I've been doing this - it doesn't work.
how hard do you think it will be converting the existing chat command to actual commands?
lastest stable isn't that 1.11.0?
depends on your codebase
just a chat command with 1 optional argument
shouldnt be too hard i guess
very looking forward for future releases
just back to the topic
1.18.0
2.0.0π€
True, it is only available in preview.
nah thats true
codebase
I mean, you're using some class to create a command?
you didnt get me
ππ ππππ
this also doesn't work for some reason, and with 2.0.0-beta.
what doesn't work
this code
chatsend is in beta
ofc it wont work in 1.18.0
but you said its also not working in beta?
it should.
- If using 2.0.0-beta, in 2.0.0-beta, runCommandAsync was removed
- why use commands for gamemode switching, There's native methods instead of
gamemode c - If in stable, chatSend is not available
...right, and do you have content logs on?
it would've told you something was up with runCommandAsync
runCommandAsync The Real Impostor
did
Make The All Creator Addon in My Region Make a bad Script Performance
the
about the second, you mean that you can change the game mode via api without using commands? And why exactly in the example in the bedrock wiki they did that.
Nope
then there we have it
we already had it though.
runCommandAsync was removed.
but yes, that would be another issue.
there
player.setGameMode(GameMode.creative)
theyre on 1.21.51
they should update their game
but yeah, 1.21.51 server beta version is 1.17.0-beta
right ^
what
lmao
ignore them
What happened to him
He looks very sussy today
import world as http
import system as www
lol
i saw that post
I changed to this version, but it still doesn't work
its strangely
have you enabled beta api
and please turn on content log as voidcell said
π@Don't tryβ΄Β²
Yeah, of course
then do us a favor and enable content logs
ATleast send the error, instead of saying " It doesn't work "

why u sad
how many potions did you take today
Only show:
[Scripting][warning]-Debugger auto-attach waiting for [0] seconds.
[Scripting][warning]-Debugger auto-attach did not connect.
are you even running the exact script file
do console.warn(`god help`)
to seee if the script running
I see warn in content log
goodbye runCommandAsync
lmao
I've finished all the try catches for my Custom Crafter function. I will now begin the actual functionality of the function 
what is this code
π
@round bone can you give me an example on how to fill 0 0 0 to 5 5 5 with dirt replacing air only
thank you
Dmension.fillBlocks
import { world, BlockVolume } from "@minecraft/server";
world.afterEvents.worldLoad.subscribe(() => {
world.getDimension("overworld").fillBlock(
new BlockVolume({
x: 0,
y: 0,
z: 0,
}, {
x: 5,
y: 5,
z: 5
}
), "minecraft:air", {
includeTypes: [
"minecraft:dirt"
]
})
})
smth like this
@thorn flicker Im really grateful of the code you gave me, you just tought me the js syntax just by a simple code π
idk what are those BlockVolume classes but shouldn't he also import BlockVolumeBase?
since you're using new to create an instance of that class
also you missed a comma
where?
-# actually two
{
x: 5,
y: 5 // <=
z: 5
}```
there is a comma
not at the y:5 part
you also typed an extra comma
is it here
doesn't matter
It already worked, thanks
Are custom commands dropping on 1.21.80 release?
Beta APIs.
so⦠is that a yes or a no
because it doesnβt look like I can use them with the beta api on 1.21.70
What version of scripting are you on?
If custom commands existed in the .80 preview cycle, they will be available in the .80 stable version via beta APIs
Thanks, that was my question
what code?
@fast lark
anyone know if there are plans in the future to update the packet stuff in server-net?
atm you can just acknowledge and cancel packets, canβt read them
Does anyone know, in general, how to use scripting to give a specific entity an item and make them hold it in their right hand, so that it actually displays as held?
For example, zombies are capable of picking up and holding swords. Is there a way to make a mob like that where it can hold any item, and then I can give it an item for it to hold?
You have to use runCommand and the replaceitem command, as scripts canβt access non-player entity equipment
That sounds workable. Do you know what specific components I need on my custom entity in order to make that possible?
Only thing you need, afaik, is a point named βrightItemβ in the entity model and "enable_attachables": true in the client entity
Where specifically do you mean to put "enable_attachables"?
RP/entity/your_file.json
Oh snap, that worked already (mostly). Just one problem. How do I specify a specific entity? I just ran it with @e and it worked just like I expected it to, but now EVERYONE has the item.
I summoned the entity in scripting. How do I target it now?
The spawnEntity function does return an Entity class, which you can use to run a command off of
const spawnedEntity = dimension.spawnEntity(β¦)
spawnedEntity.runCommand('replaceitem @s β¦')
Perfect. You're my hero.
Is it possible to get the offhand using the on place component?
want to publish this ai code
interesting
is there any way to check if a specific item can be worn on a specific slot using scriptapi?
Hi all, maybe someone knows why this code from the documentation doesn't work:
import { world } from "@minecraft/server";
console.warn(`god help`)
world.beforeEvents.chatSend.subscribe((eventData) => {
const player = eventData.sender;
if (!player.hasTag("Admin")) return;
switch (eventData.message) {
case "!gmc":
eventData.cancel = true;
player.runCommandAsync("gamemode c");
break;
case "!gms":
eventData.cancel = true;
player.runCommandAsync("gamemode s");
break;
default:
break;
}
});
Also to clarify that I have Minecraft version 1.21.51.1, and I say right away that I used the version of Scripting api and 2.0.0-beta and 1.17.0-beta, still does not work, which is quite strange. Thank you in advance for your help
Do you know what part of it doesnβt work? Because if youβre on 1.17.0-beta it looks fine..
Any console errors
only it, Also, that my addon is exactly what's running.
Do you have the tag
Sorry to bother you because of my stupidity, it's just that I was issuing the admin tag, not Admin.
Yeah, the hasTag is case sensitive
Yeah, just didn't notice
RunCommandAsync is removed in Minecraft/server 2.0.0-beta
hes not using current minecraft version.
I solved this problem already, it's just that I was issuing the admin tag instead of Admin.
Can anyone tell me how to make a scriptevent? I tried to ask chatgpt(I know bad idea, but still), but he gives out code that doesn't work.
Whats troubling you
well, like creating a script event that can be called via /scriptevent
import {
world
,system,
Player
} from "@minecraft/server"
system.afterEvents.scriptEventReceive.subscribe(e => {
const { id, message, sourceType, initiator, sourceBlock, sourceEntity } = e
if (sourceEntity instanceof Player) {
/**
* @type {Player
*/
let player = sourceEntity
player.sendMessage("id: " + id + " message: " + message)
}
})```
Does anyone know if I put a Player as a key in a WeakMap and then he re-enters the world, will it be a new Player or will the old one just become valid again?
guys why MinecraftBlockTypes does not work ?
thanks for the help, it worked!
My ESLint is punching you using:
import { world, system, Player } from "@minecraft/server";
system.afterEvents.scriptEventReceive.subscribe(({ id, message, sourceType: player, initiator, sourceBlock, sourceEntity }) => {
if (player instanceof Player) {
player.sendMessage(`id: ${id} message: ${message}`);
}
})
you must import it directly to your scripts or src directory
@minecraft/vanilla-data is not supported navitely by engine
i used an other methode
Installation for @minecraft/server-gametest
Beta API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
because patch is a http method?
ah sorry I misread that
they prolly forgot it
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]
yup
so id have to append files into the rp? or something
if thats even possible
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]
hi
Did you know how I can make a knockback edit menu?
use a ModalFormData class
okay
Is there a way to check if the player has just interacted with a specific inventory slot?
Like taken an item from the slot
check for selectedSlotIndex value
Thank you
Player.prototype.selectedSlotIndex of course
no problem
Isn't that only which hotbar slot they have selected? Would that not necessarily correlate with a given slot the player interacted with?
Any slot in a given container?
it's correct I thnk
if he's detecting interaction via PlayerInteractWithEntity or PlayerInteractWithBlock event, it's a good way
Yes. I'm trying to make a custom crafter recipe function for more than 3x3 recipes
ohh, container interaction?
So I need to check when the person takes the item, then the recipe slots are emptied stack
Ye
ohh
I'm running it through system.runinterval, no afterEvent or beforeEvent
are you using stable or beta API?
stable
I don't mind using either
Nothing in the function is beta, yet
If it's not possible for stable, I can use Beta
if PlayerInventoryItemChangeAfterEvent is not in stable Minecraft, then you probably are forced to wait for 3 days (to 1.21.80)
Ah, that's only for the player inventory
And it's preview 2.1.0-beta
ahh, sorry, but you're forced to use intervals and check both (block's and player's) containers every tick
hmm, I could use PlayerCursorInventoryComponent
It seems right for what I want to do
check every tick if it changed
You helped, not just tried
I was able to find PlayerCursorInventoryComponent which is exactly what I need
I think
xD
Installation for @minecraft/server-net
Beta API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
Server net, not working un 1.21.72?
"afk"
check if server-net is allowed by going to files then config/default/permissions.json
and server net is only usable in bds
are you able to change a cmd inside a cmd block using a script
nope
What is bds?
bedrock server
- only for BDS
- enable it in server permissiojs
- add dependency in a manifest
if you would like to test it, you can use my API for Discord webhooks just to check if it works
I have done it few times
π
Hmmm anyone know how we go about giving an item that has a specific dye already? Been trying solutions related to:
const texture = new item.getComponent("minecraft:dyeable");
item.set(texture, 4)
This is inside a basic giveItem function
I cant get it to work
For some reason
/server-net in general?
Yh
are you using BDS?
I tried to use ur api some time ago, and i ended up doing a normal message and not a beautiful embed
Yh
did you use an EmbedUtility class?
I used the basic message u made
Im not on pc rn
ohh nice
you can leave a star or smth if you like it xD
I would like to push it to 16 stars just for achievement xD
ahh no problem
if you're a programmer I would recommend to create an account
GitHub is pretty important
GitHub is great for managing projects. Git is a great tool to have and utilize.
Gerrit is phenomenal if working on large projects.
Hi, could someone show me how I can make a menu to change the kb?
Okay
β οΈ
has anyone here done some codicate, which simulates a spwan rules, by Js/Ts ??
praying mojang will make dimension.getBlocks() useful
can anyone help me?
guys i have a little problem tho, I need to check if entity has a specified effect. How do i do it?
entity.getEffect('swiftness')
thanks
so basically this:
no
just do if (getEffect())
it'll return true because the effect is on the player and valid.
okay
Anyone? π¦
it has the color property.
maybe you use it
And set the color using RGB interface
interface RGB {
blue: number;
green: number;
red: number;
}
so it's like:
const texture = new item.getComponent("minecraft:dyeable");
texture.color = {
blue: 0;
green: 1; ///example
red: 0;
}
item.set(texture, 4)
i don't think i am right....
Someone correct me
Hmm I made something similar, it's saying it's not a constructor... what exactly.. Idk XD
const texture = new item.getComponent("minecraft:dyeable");
const redscore = 0
const greenscore = 1
const bluescore = 0
texture.color = ({ red: redscore, green: greenscore, blue: bluescore })
item.set(texture)
"Typeerror" lol np. Thank you for trying... tbh I'm still learning how to unpack the documenation, was on that page earlier today... I'll keep trying.
if (block.permutation.getState('minecraft:cardinal_direction') === 'west') {
// Check for the south block
if (
adjacentBlocks.south?.permutation.getState('blushrooms:shape') === 'straight' &&
adjacentBlocks.south.permutation.getState('minecraft:cardinal_direction') === 'north'
) {
// Validate if the south block's neighbor to the west has the 'straight' shape and if it has a special shape
const hasWestNeighbor = (
adjacentBlocks.south.west()?.permutation.getState('minecraft:cardinal_direction') === 'north' &&
adjacentBlocks.south.east()?.permutation.getState('minecraft:cardinal_direction') === 'north'
);
const hasSpecialShape = ['outer_left', 'outer_right', 'inner_left', 'inner_right'].includes(
adjacentBlocks.south?.permutation.getState('blushrooms:shape')
);
if (!(hasWestNeighbor || hasSpecialShape)) {
adjacentBlocks.south.setPermutation(
adjacentBlocks.south.permutation
.withState('blushrooms:shape', 'outer_left')
.withState('minecraft:cardinal_direction', 'west')
);
}
}
whats the best way to do a check like this im stumped
one half of the whole check system but only half of it works while the other half overrides the other if that makes sence
Whatβs your code
https://discord.com/channels/523663022053392405/1368572115732664330 any help would be great. as i fixed all the actual bugs it broke this type of check
Is dynamic properties commonly used? Does it cause lag if you have to many? Does it use up a lot of storage? Is it efficient?
Can someone answer these questions?
yes
no, they are in storage and they only cause lag if you tried to get them by a large amount in the same time
it uses as many storage as you set with it
yes
anyone knows why I cant use script api 1.18.0-beta? it says the only beta version I can use is 2.0.0-beta
Anyone have a clue why and when does FormRejectError occurs?
on 1.21.70-73, 1.18.0-beta isn't a thing, for beta you're forced to use 2.0.0-beta
Not a thing
For the MalformedResponse, not familiar with it. Just curious
Just say what u need
blockComponentRegistry.registerCustomComponent('kevrox:pressure_plate', {
onStepOn: ({ block }) => {
console.warn('stepped on!')
if (block.hasTag('kevrox:pressure_plate') && !block.permutation.getState('kevrox:is_active')) {
const currentStates = block.permutation.getAllStates();
const newStates = { ...currentStates, 'kevrox:is_active': true };
block.setPermutation(BlockPermutation.resolve(block.typeId, newStates));
}
},
onStepOff: ({ block }) => {
console.warn('stepped off!')
if (block.hasTag('kevrox:pressure_plate') && block.permutation.getState('kevrox:is_active')) {
const currentStates = block.permutation.getAllStates();
const newStates = { ...currentStates, 'kevrox:is_active': false };
block.setPermutation(BlockPermutation.resolve(block.typeId, newStates));
}
},
beforeOnPlayerPlace: ({face, cancel}) => {
if(face != Direction.Down) { cancel = true }
}
})
why the onStepOn & onStepOff event not working
Dynamic properties are commonly used by developers to store custom data such as player stats, quest progress, and custom flags. By default, they donβt cause lag, but there are important caveats that determine when this holds true. Small to moderate use (a few dozen properties per entity or player) is usually fine. However, using hundreds or thousands, especially if they are frequently read or written to within a tick loop, can lead to lag due to memory and CPU strain. Performance also depends on how often the properties are updated; frequent changes every tick are more demanding than static or infrequently modified data. Additionally, how you read and write the data can impact performance if not handled efficiently.
Dynamic properties are much more efficient and scalable than workarounds like storing data in scoreboards or entities with custom tags. Storage requirements will vary depending on how much data you store, it could range from just a few bytes to several gigabytes, depending on your design, structure, and the relevance of the stored data.
At the end of the day, dynamic properties are highly recommended. However, how effectively you implement them will depend on your understanding and experience, which will ultimately shape your experience using them.
Basically they re the most used to store data in a way that can't be accesed with commands. they re very versatile you can set a property to particular entities or itemstacks but you can also use them generally by saving them in world.
In dynamic properties you can save strings numbers booleans and vector3s, but you can also save objects by stringifing the data.
They re the current fastest method to save data like strings numbers booleans and locations, and its the most efficient rn
there is a minimal height the collision box need to be
can't remember it
is there a way to mess with recipe unlocking using scripts?
like force the unlocking after some event or smt
/recipe command
ahh that's why!
Yh
U could add back the health
But idk
BlockVlome?
i just solved
new BlockVolume(from, to) iirc
i used a for x y z
huh
no it was BlockVolumeBase
for (let x = ....)
for (let y ...)
for (let z = ...)
i just needed to get all blocks
Use getBlocks...
im doing a block database but i feel that: getting the blocks, using that with the function, placing the blocks at a far away area and saving them its actually pretty inefficient
Yeah, that uses what i sent
VolumeBASE]
Something like this example:
import { ListBlockVolume, world } from "@minecraft/server";
import { Vector3Builder } from "@minecraft/minecraft-math";
const min = new Vector3Builder(0, 0, 0);
const max = new Vector3Builder(10, 10, 10);
const volume = new ListBlockVolume([min, max]);
world.getDimension("overworld").getBlocks(volume, {}, true);
Actually, that would be pointless.
ListBlockVolume?
never seen that
i am pretty sure i used BlockVolume alone before
getBlocks returns ListBlockVolume lol.
why vector3builder if you can just an object
world.getDimension("overworld").getBlocks(new BlockVolume({x,y,z}, {x,y,z}), {}, true);
I just did it for the example. Haven't touched on the blocks stuff much and when I saw the question above I decided to look at the Types on VSC. The docs on it is pretty ugly and not well organized. A bit scattered lol.
That, or just use ListBlockVolume. Both should be fine. Not sure which is more efficient.
like why cant they just do
{from:{x,y,z},to:{x,y,z}}
Does anyone know how to give the player a potion with a certain level or length? Alsk how do I read a potions length and level.
because
And for containers. How can I save the contents json string data to a dynamic property value?
potion item or effect
Item
you cant
const time = 20 // 20 ticks
const amplifier = 2 // lvl 3
player.addEffect('effectId',time, {amplifier:amplifier})
?


