#Script API General
1 messages Ā· Page 12 of 1
Hey folk! Did minecraft worlds are the variables we set with the js kept in the world files or are all variables reset at each world entry?
Those variables you want to keep, you need to store them in world dynamic properties
Ohhh, thank you...
anyone got a data structure with everything at O(1)
in my own experience, variables that are kept in the world is saved temporarily just like RAM, but when you reload it, it is deleted. So, for a functionality like ROM, you need to use Dynamic Properties.
if you look at the qjs api, it tells us to create a qjs context which runs our code, so what reload in game should be doing is that to create new context means everything ROM is cleared
thanks folk
not relating for what you wanted but i have this, like a priority queue or min heap but for vectors so it returns the nearest vector.

it's O(log n) for getting the nearest vector on the container based on the passed vector
interesting
btw I had an idea of building global que which works across packs
using dps
still cant figure out how to make it work
need ideas
yeah i'm still alive, i had to take a little break from life, because my grandfather died....
so i was inactive for a month
what's the purpose for this? i'm intrigue
so diff packs can use this lib to push task which will be executed one by one and reduce load
tasks, as in "scripts"?
how would that even be possible
I mean funcs
Can we see total ram usage per world for scripting in bedrock?
hmm
you can make it depend on a scoreboard
before the function run it check a score if the queue is empty
script debugger kinda shows that but not really
yea my current idea is that to create a stack for every pack which holds the funcs with an id, where id is unique across packs the only think I am not sure about is that how to execute those tasks across pack in seq and remove them... /scriptevent can help to que them ig
can someone give me js files of mojang modules
no the other ones
can anyone gimme some iddeas
i am making a script for custom food
it gives you effect after eating
the script will be helpful for making custom food item
like
const customFood = {
typeId: "minecraft:steak",
applyEffect: "resistance",
runCommandOnConsume: "/give @s dirt",
// Give me more ideas i can add
}
@valid ice

- A food that, when eaten, stops the player from pinging me for random stuff
:(((
ok sorry for ping
ohh teleportOnConsume
but surely there might be more ideas
discord.beforeEvents.userMention.subscribe(e=>{
if(target.id == "330740982117302283" && source.id == "1107163750781440021") e.cancel = true
})
Lol
wait did you hack me
how you get my user ID
wtf
š¤Ø
sigh
1107163750781440021
oh noes I got revenge on you! >:(
282965566858461185
how can i detect if some code throws error

try catch
and if there is error, on that, i want to run another code
what do i do in catch
try {} catch (err) {}
@valid ice helo I ned your help
try {
//code
} catch(err) {
//if error
}
everyone keeps pining him for real lol
try {
//code
} catch(err) {
if (err) {
//run
}
}
I don't mind pings
But at the same time keep them slightly relevant
like that?
you don't need the if statement
oh wait
alr
but err do have some infos on the error if you want to use it
I add prototype to function as I hate so many tries
i just avoid them if i can
how to detect if something is number?
if (!duration typeof number) return```
like that
?
if ( ! isNaN( val ) )
cant i do it in this way
if (!duration typeof number) return```
I use if (+val)
is the number a string? "1"
no
if(typeof duration !== 'number')
Consider the following:
if (duration != 0 && duration != 0.1 && duration !== 0.021 && ...)
Yes, my addon is 54 gigabytes, why do you ask?
you can shorten that
const numbers = []
for(let i = 0 ; i <100000000000000; i++) numbers.push(i)
if(numbers.includes(duration)){
//code
}
hero have you ever created a keyframe system? i am trying to find to structure numbers in way where with any x i can find the nearest one
Ah but what about decimals
š¤
I have not
binary search would be first choice for this but I feel if we structure them differently to even improve the speed
in order?
ye
sorry something came out
brb ...
np
you can start from the middle
check the left and right
and go to the closest side
start from the middle of it and redo the steps
re do that until you reach a side with length of 1
let me see if i can code that
is it possible to change the selected slot?
no
alright thanks
@misty pivot try
i was thinking selectedSlotIndex is read only
but it is not marked as one
so maybe
(sorry for the hasty response)
ah, right, lemme test it right now
@woven loom
//keyframes array structure
const keyFrames = [
[10, "value"],
[12, "value"],
[14, "value"],
[19, "value"],
[22, "value"],
[25, "value"],
[37, "value"],
[39, "value"],
[49, "value"],
[50, "value"],
];
function findNearestKeyframe(keyFrames, x) {
let left=0;
let right=keyFrames.length-1;
while (left <= right) {
const mid=Math.floor((left+right)/2);
const midX=keyFrames[mid][0];
if(midX===x) return keyFrames[mid];
else if(midX<x) left=mid+1;
else right=mid-1;
}
const leftFrame=keyFrames[Math.max(0,left-1)];
const rightFrame=keyFrames[Math.min(keyFrames.length-1,left)];
return x-leftFrame[0]<=rightFrame[0]-x?leftFrame:rightFrame;
}
//usage:
console.log(findNearestKeyframe(keyFrames, 15));
yea that's binary
One message removed from a suspended account.
1.12.0-beta.1.21.3-stable
One message removed from a suspended account.
How do I spawn the particle that appears when removing wax and oxidation from the copper block?
What is the function and ID of the particle?
probably less efficient
but you can push the test value with a fake frame to the array
sort it find it index and get the closest neighbor
const keyFrames = [
[10, "value"],
[12, "value"],
[14, "value"],
[19, "value"],
[22, "value"],
[25, "value"],
[37, "value"],
[39, "value"],
[49, "value"],
[50, "value"],
];
const testArray = [...keyFrames,[15, undefined]].sort((a, b) => a[0] - b[0]);
const frame = testArray.find((frame) => frame[0] == 15 && frame[1] == undefined);
const index = testArray.indexOf(frame);
const closest = frame[0] - testArray[index - 1][0] > testArray[index + 1][0] - frame[0] ? testArray[index + 1] : testArray[index - 1];
console.log(closest);
yeah it is less efficient
complexity of O(n log n)
binary search only have complexity of O(log n)
Binary Search seem the best option
test of 1000 run
nope
Equipment is fine but +6 attack damage is annoying
i guess i can just copy all vanilla pickaxes and make my own items
Many have asked, nobody has succeeded :(
just a matter of finding the mining stats
@valid ice hi
allo
anyone knows where i can find that
Could look at the list of destroy times for blocks on the Minecraft wiki entry for Pickaxes and calculate their rough speed increase.
Although it's going to wildly differ depending on the block and whether that tool is eligible for harvesting the block or not.
It seems that on average, the following tools reduce destroy time by the following:
- Wooden pickaxes by x2;
- Stone pickaxes by x4;
- Iron pickaxes by x6;
- Diamond pickaxes by x8;
- Netherite pickaxes by x9;
- Gold pickaxes by x12.
And mining speed is increased by an additional x3.33 if the tool can harvest the block.
So for example, Chain: With a destroy time of 25 seconds, a wooden pickaxe can harvest it in 3.75 seconds: 25 / (2 * 10/3)
And for another, Raw Iron: Also with a destroy time of 25 seconds, a wooden pickaxe can break it in 12.5 seconds: 25 / (2 * 1)
Is this useful @oak lynx
Ah, and there may be more to it than that. See Breaking (Speed)
yeah but getting the values right will still be annoying
thanks for helping
json ui?
Does anyone wish there was a scriptEvent that happens when the player crafts something?
same problem here, did you fix it?
it'll get fixed in the upcoming update
im using randomTick instead for now
ohhh, alright thank you
i mean the one that includes items
if it is not this.... don't know what else it can be. https://learn.microsoft.com/en-us/minecraft/creator/reference/content/blockreference/examples/auxvaluetoblockstatemap?view=minecraft-bedrock-stable
nah its not that, but thank you for helping
you can give lores to every item afaik
why would it get removed when unequipping
Nevermind yeah, I forgot something
ć ¤

is this typo error or are these really the same ID values?
Both are incorrect lol
sorry for the late reply, i slept, but it does work although visually buggy like it could look like it's selected a different slot but you're actually selecting slot selected in the script
stained clay is 159, armadillo spawn is 720
lol damn these docs
how do get your IDs btw, do you test it one by one?
I do
I use https://www.mediafire.com/file/53wlw5djaf3hd7m/ID_Testing.zip/file to map IDs to textures
Names are ultimately a guess in the end. I try to map the ones I can based on /give or /setblock stuff, but some are unknown, so
You are not looking for this, are you? Cause you said Aux Values... https://github.com/Mojang/bedrock-samples/blob/preview/metadata/vanilladata_modules/mojang-items.json
does someone have the order of clicks in script
beforeItemUse -> afterItemUse ->
like that
found this
Events.* execution order
Hitting an entity
1 entityHit
Breaking a block
1 blockBreak
2 entityHit
Placing / pushing a block
1 itemStartUseOn
2 beforeItemUseOn
3 itemUseOn
4 blockPlace / buttonPush
5 itemStopUseOn
Hitting a block
1 beforeItemUseOn
2 itemUseOn
Using an item
1 beforeItemUse
2 itemUse
Using an item projectile
1 beforeItemUse
2 itemUse
3 entityCreate
Using an item charge start
1 beforeItemUse
2 itemUse
3 itemStartCharge
Using an item charge release
1 itemReleaseCharge
2 entityCreate
3 itemStopCharge
Using an item charged
1 itemCompleteCharge
2 itemStopCharge
speaking of which, does entityHitEntity fire after the entity receives damage (if the entity can)?
im kinda wondering if i can heal a mob before the mob dies to a hit
No
Legit the only thing that fires before damage is a damage sensor lol

beforeEvents for entityHurt and entityHitEntity when
Big Damage propaganda
Just asking, is there a way to whitelist a player using discord or a script?
using discord, very no
using script, sorta
Complicated?
no
How?
Yes kinda, i just learned few weeks ago
then try this
upon player join, check if the joining player's id (not name) matches with the whitelisted ids you set in script
if not, kick
keypoint here is 'id'
is there a way to stop the player from moving?
without constantly tping
like as a before or after event
Disable their inputperms
what would be the world event
No its a gamerule
OOps, my bad
nah ur good
world.beforeEvents.playerPlaceBlock.subscribe(evd => {
const block = evd.block
const player = evd.player
const dimension = world.getDimension('overworld')
const blockLocation = { x: block.x, y: block.y, z: block.z }
const b = dimension.getBlock(blockLocation);
const data = JSON.stringify(b)
world.sendMessage(`${data} ${b.nameTag}`)
})
Anyone know why this just gets the block location? How can I get other things like the blocks name and stuff
Wha...why do you need to use getBlock?
Because evd.block is just the location
But...the event data already gives you the block broken
Iām trying to get the blocks name but all I get is the coordinates of it
And Iām trying to get the type id
... you sure you checked the docs?
ill just make you one
world.afterEvents.playerPlaceBlock.subscribe(({player, block}) => {
const loc = block.location;
player.sendMessage(`${block.typeId} / ${loc.x}, ${loc.y}, ${loc.z}`);
});```
@viral plaza
ofc
Yes I got it, but what about getting the block name?
I tried to do block.getItemStack().nameTag
You cant get the name, only the id
cant
you can make an array of block identifiers & block names (item names)
That sucks
and make the script to check if both matches
I mean itās not a downside itās just I canāt use the same block with different levels
I mean I can set lore right?
yes
itemStack.setLore()
oh block?
get the block as a itemStack somehow
What are you trying to achieve?
cant yet
only option
i was asking cuz i kinda feel like saturation effect doesnt really fill saturation
only hunger
but does saturation effect do fill saturation
thats what i need
meh only one way to find out
found where, can you site the source?
I donāt see anything listed about block data on the docs with before event playerBreakBlock
Can you not get the block?
destroyedPermutation or whatver its called
What made you look up something from roughly 4 months ago?
#old-script-api
I searched "Replace custom block," and found that message.
Ah, well, that will do it lol š
you might not know, but there is a fact.
in india, most of the people who make"addons" or mods are kids. mostly under 11-13 yr olds, they don't actually make it, but steal them and claim it as your own, which, makes me to be so furious at them. they beg/ask that how to make smth, or they just make hillariously bad addons in addon maker. i know the accent of them , i did expect to beg him ,and you see in that conversation, i litterly said that "are you from india" at the start of the conversattion , bcoz i know the behvaiour of them. they even DM me and disturb me for no reason and spam,
@valid ice how to send a error ?
console.error()
like
if (typeof duration !== "number") {
// what sould i use
console.error('duration must be a number');
//which one i should use
throw new Error("duration must be a nuumber")
}```
idk
just uhhhhhhhhhhhhhhhhhhhhh don't make problems in the first place and you don't need errors 
throw stops the code
throw, since that interfaces with the try..catch syntax and can be caught
Erroring is not entirely a bad thing. But you do want robust errors
bruh
@woven loom see this screenshot
just do throw e
^
try {} catch (e) { throw new Error(e)} š¤
Is your sample here only for demonstration? Or is customFood going to be something else
@prisma shard do this.
Dont actually do that pls
You could design it so that customFood's effectDuration can only be a number when setting it. Then there would never be any need for error checking/throwing
he was joking.....
LOL
How easy would stamina meter be to create with scripts?
console.error works.
i'm making a template so that making custom food effects would be easy, but people could put a string instead of number parameter in the object like "1" instead of 1, andn they wold have to figure out why is this not working, so just i am trowing a error to show it must be a number
Send an action bar and youre ready
Ah, so these implementation details will be exposed. It is not abstracted away in any form
um, i am poor at english, what did you mean?
I meant the logic
In other wordsāpeople will be setting values for customFood directly, and you are not providing other means to set values for it
Actions that would consume hunger also consume stamina, and stamina only restores if not sprinting or attacking/mining etc.
I'll present an example of what I mean by "abstracting" details
I think the most complicated will be remove temporally the sprint from the player
But it can be just an slowness effect or edit player.json
I have a strange implementation I wanna try
All actions are fine until you completely run out of stamina at which point you become āfatiguedā until stamina is full again
I want the player to pace themselves
Not a hard implemented combat cooldown like Java but some mild guidelines
Something like this, where only you control how the property is set. People cannot use myFood.effectDuration = 5 because effectDuration is private.
class CustomFood {
#effectDuration
constructor(duration) {
this.setDuration(duration);
}
/** Sets the food duration.
* @param {number} duration Duration in seconds
*/
setDuration(duration) {
if(typeof duration !== "number") {
throw Error("Type was not number");
}
this.#effectDuration = duration;
}
}
const myFood = new CustomFood(3); // Internally, #effectDuration = 3
myFood.setDuration("3"); // "Error: Type was not number"
You could probably make something with get and set but I find that syntax kinda ugly
lalalalalal
im making things harder
i should take it easy
why people would be that dumb to put "3" instead of 3
It could happen on accident. For example: Reading input from chat messages, /scriptevent myevent:hi 3 the "3" is a string. It would need explicitly converted to a number, either by +"3" or Number("3")
I'd at least make those JSDoc comments, so Intellisense will suggest those comments when looked at
const customFood = {
/** Must be a string, or it will throw error */
typeId: "",
/** Must be a number, or it will throw error */
effectDuration: "",
// etc.
}
WAit wht
typeof "33" // returns string
typeof 33 // returns number
///dont work
if (typeof 33 === number) {
console.warn('its number')
}
//work but why
if (typeof 33 === "number") {
console.warn('its number')
}
number is a variable name. "number" is a string
For context: "number" in that line can be anything and it'd have the same effect: typeof 33 === foobar
Unnecessary how?
Good question. I don't know
Use typescript, setting tsconfig
You dont need to
like nothing abt ti\
Does VSCode work with a TSconfig out of the box?
then what do i need to wirte in tsconfig?
Yeh
Cant tell you rn going on a plane. Just look it up
tsconfig is like a JSON file. Not too much to it, there should be a template somewhere
I donāt remember if the guide here filters DOM elements but try https://wiki.bedrock.dev/scripting/typescript.html#top
can we use server 2.0.0 alpha
wat is even this
sth we should not know abt
That is a discord question, not a scripting question. Prob has to do with him already having the prefix of @ and their UI dealing with it.
game has 2.0.0-alpha
bcoz he has a @ before his name
and another @ shows bcoz your pinging him
This is a discussion channel-
With a specific topic and that question was not relevant nor was it important.
which is about the script api.
i am rewritting a Vector class utility wrapper i found in the script resources ā ļø
Idk but is this inefficient?
Snippet
class SomeVector3Utility {
add(other: SomeVector3Utility | Vector3): Vec3 {
return new SomeVector3Utility(this.x + other.x, this.y + other.y, this.z + other.z);
}
}
using this:
new SomeVector3Utility(player.location).add({x: 0, y: -10, z: 0})\
this creates two vector object instead of 1
imagine using this with 1000 loops or idk big loops
1000 * 2 = objects
and imagine the other methods from this which creates other new Vector instances which is unnecessary
oh, that's why xp
i wanna pass away ā ļø, creating static methods and class methods
class Vec3 {
constructor (x, y, z) {
this.x = x;
this.y = y;
this.z = z;
};
static add(vecA, vecB) {
return Vec3(vecA.x + vecB.x, vecA.y + vecB.y, vecA.z + vecB.z);
}
};
const vectorA = player.location;
const vectorB = new Vec3(0, -10, 0);
Vec3.add(vectorA, vectorB)
@sudden nest
dont complicate things
yeah, it should be like that, but this one is 1000+ lines of code
turn interface into that class, like don't do {x: 0, y: -10, z: 0} , instead do new Vec3(0, -10, 0);
then it willl wokr
as i did
i meant this Vector class: #1235161895879839785 message
i saw it, and it was great and all, until i saw the add method
it great
the other unique methods are cool
what happen after you saw add method
like CatmullRom and stuffs
the add method is okay in that
my gutt was telling me it's inefficient since it was creating new Vector instances
š
what?
where
Inefficient hmm š¤
i mean like this vector calculations and stuffs
or are you high
yes
oh

try ```js
- @param { import("@minecraft/server").Vector3 } other``` to enforce proper usage
I transferred it into one typescript file instead of two javascript (vec3.js) with types (vec3.d.ts)
@valid ice how to remove a item in 1.4.0-beta api ?
here is what happen when you ask a question that everyone can answer but you ping someone with it:
- the mentioned user get annoyed and ignore your question (especially if you are repeatedly pinging hem)
- other people ignore your message sense the question is directed to some one
also if you want to ask someone, make sure you're using the proper language and manners, you can't just say "Hey user, how do this" unless they're okay with that
Also, if youre gonna use an old version its best to read the docs
1.4 beta ?
yes
remove as in clear it from the inventory?
set the item to undefined
yeah, like the /clear command, but not clear all items.
Removing the specefic item from slot
why there is not a removeItem method
container.setItem(player.selectedSlotIndex, undefined)```
would that work?
yeah
.....
In playerBreakBlock
there is itemStackAfterBreak
container.setItem(itemStackAfterBreak, undefined)```
would that work
but that slot want number
player.selectedSlotIndex is a number
i feels like im using "as type" too much on my script especially at the formValues, is that normal?
let commandAmount = res.formValues[1] as number //formValues[1] is slider
that pointless, no?
how would i get all objects that start with "skill" inside an array?
Sometimes I use that "as type" when I am messing Component stuffs like ItemComponents or Entity or whatnot, since it doesn't autocomplete in my end unless I do that.
But when it autocompletes i just ignore it
const newArray = array.filter(e=> e.startsWith("skill"))
i forgor filter exist
could someone give me a function that moves the armour from the player who activates the function to the nearest entity?
Scripting][error]-Unhandled promise rejection: TypeError: Incorrect number of arguments to function. Expected 0-1, received 3 what is this error?
That's normal for forms unfortunately because of the way that Mojang made the API. š«
You can also cast from values to a typed array though.
const [sliderValue, textboxValue]:[number,string] = formValues;
show code
oh yeh mbmb
try #add-ons
I thought I was already in that channel from when I last left off lmao
i dont have the javascript OR operator, in my keyboard :(((
Your keyboard is missing |
Now you can copy and paste it lol.
your keyboard doesnt have backward slash??
Find the alt-code for it, so you can do it that way when needed
Pipe symbol
Download SwiftKey mobile keyboard its the best so far
function giveItem(player) {
const {
container
} = player.getComponent("inventory");
if (player.hasTag('PlayNodebuff')) {
for(let i = 9; i < 36; i++) {
container.getSlot(i).setItem('minecraft:splash_pointion', 64, 22)
}
for(let i = 3; i < 7; i++) {
container.getSlot(i).setItem('minecraft:splash_pointion', 64, 22)
}
for(let i = 6; i < 9; i++) {
container.getSlot(i).setItem('minecraft:splash_pointion', 64, 22)
}
container.getSlot(0).setItem('minercaft:diamond_sword')
container.getSlot(1).setItem('minercaft:bow')
container.getSlot(0).setItem('minercaft:fishing_rod')
container.getSlot(9).setItem('minercaft:cooked_beef', 64)
container.getSlot(8).setItem('minercaft:arrow', 64)
}
if (player.hasTag('PlayCombo')) {}
}```

Ya, no arrows and no keyboard previews so you don't know where you have special symbols
you should upgrade to SwiftKey
up and down?
š
its crazy how this is basically a built in feature
the devs went crazy with it
well not really built in but its semi official atp
oh i can just sweep my keyboard for that
the down 'arrow' doesnt work though for some reason
Lol
real ik
it the same sound too
but there was a bunch of random shit in with it for like 2 diffrent addons
Has the 1.14 version of the server API came out of betas?
How do I install modules other than "@minecraft/..."?
And if I want to install an NPM module, what do I do?
Bundling (works on modules that doesn't require nodejs or dom apis only)
system.runInterval(() => {
world.getPlayers().forEach(player => {
const playerInventory = player.getComponent("minecraft:inventory").container;
for (let i = 0; i < playerInventory.size; i++) {
const itemStack = playerInventory.getItem(i);
if (itemStack && genMap[itemStack.typeId]) {
const genMapData = genMap[itemStack.typeId]
itemStack.nameTag = `§e§l${genMapData.clean}`
world.sendMessage(`${genMapData.clean}`)
}
}
});
}, 200);
How can i change the names of the items in peoples inventoryās? It works just the item doesnāt get renamed.
Set the item back into the slot
Ok thank you
why is it every time i come back to use my old code that none of it works and loads has changed
How old is said code, exactly
like arround 3 months old
but even so i come back to work on some world every like few months and its all broken
The perils of using beta APIs 
A comment?
Can you share a more specific example?
think i fixed it
Comments should never break, ever
How do I test that itās the players first time joining the game, and if they leave and join itāll run again, cause mine runs when someone dies
playerJoin / playerLeave
instead of playerSpawn
Alr thanks
playerJoin only has player ID & name, not the actual player object
use playerSpawn but filter for event.initialSpawn- which is true when the player joins the world, and false when the player respawns after dying.
Thatās what I was looking for
I have initial spawn but I didnāt know how to use it
I just have if (!data.initialSpawn) return; at the top of my playerSpawn event
no?
whar
Thatās what I did
yeah its weird
yeah thats what i did
u can also use dynamicProperty
If youāre talking to me I just need it for my combat log
world.afterEvents.worldInitialize.subscribe((event) => {
const property = new DynamicPropertiesDefinition();
property.defineNumber("test", 1);
event.propertyRegistry.registerWorldDynamicProperties(property);
});
Not work, why?
You don't need to define it anymore. You can directly use it in World, Entity, or ItemStack.
I didn't understand, can you explain it in more detail?
Literally, just use it.
world.setDynamicProperty("name", 700)
world.getDynamicProperty("name") //return 700
Wow
skip the "defining" part
function giveItem(player) {
const {
container
} = player.getComponent("inventory");
if (player.hasTag('PlayNodebuff')) {
for(let i = 9; i < 36; i++) {
container.getSlot(i).setItem('minecraft:splash_pointion', 64, 22)
}
for(let i = 3; i < 7; i++) {
container.getSlot(i).setItem('minecraft:splash_pointion', 64, 22)
}
for(let i = 6; i < 9; i++) {
container.getSlot(i).setItem('minecraft:splash_pointion', 64, 22)
}
container.getSlot(0).setItem('minercaft:diamond_sword')
container.getSlot(1).setItem('minercaft:bow')
container.getSlot(0).setItem('minercaft:fishing_rod')
container.getSlot(9).setItem('minercaft:cooked_beef', 64)
container.getSlot(8).setItem('minercaft:arrow', 64)
}
if (player.hasTag('PlayCombo')) {}
}``` what wrong?
you can use it straight away now
You need to create an ItemStack before being able to set the item.
Incorrect: js container.setItem(i,"minecraft:diamond");
Correct:js container.setItem(i,new ItemStack("minecraft:diamond",1));
( import { ItemStack } from "@minecraft/server" )
If set item with amount 64 and data 2 then ItemStack("minecraft:diamond", 64, 2) right?
No
Data isn't supposed to be supported anymore in the future.
If you're looking for Durability, there's a Durability Component to manipulate it.
Else, if you're looking for more range of items, use the flattened identifiers.
Is it possible to get an array with all item ids in the game + addons?
So is there no way to set an item with quantity 64 and data 2?
Quantity of 64:
new ItemStack("diamond",64)
for data, no
Well, you can still use commands
But it's advisable not to depend on commands. It's slow af
I still haven't figured out how to use this 
What r u trying to do
I'm trying to fix this
You remove that ( aka: defining the property )
You "skip" that process
you can use dynamicProperty straight away
Ty 
The ItemTypes are mixed with blocks (in item form) too, so beware of that.
Ok
When I replace a door with other using block.setPermutation() the door breaks. How can I avoid this?
how would I find the closest entity to a player?
try the other half of the door
world.afterEvents.worldInitialize.subscribe((event) => {
const property = new DynamicPropertiesDefinition();
const auction_Items = new Array();
const data = JSON.stringify(auction_Items);
property.defineString("listed_Items", 99999, data);
event.propertyRegistry.registerWorldDynamicProperties(property);
});
I need to do the same thing for this code
My monkey brain is unable to comprehend new Array()
The code is something like this:
block.setPermutation(BlockPermutation.resolve("minecraft:waxed_copper_door",block.permutation.getAllStates()));
Same as before, you can remove it, but since it's defined with a set value for the default, you can do this:
world.setDynamicProperty("listed_Items","[]");
new Array() is simplified to [] and skip stringifying it into "[]"
setItem method has 2 parameter and you didnt return in the function
.getSlot() returns ContainerSlot where it has slightly modified .setItem(). It automatically referencing into that particular slot, so the slot number is not needed.
is there any way to detect the up and down buttons moving back and forth?
WASD keys
No easy way. You can utilize the player's past position and current position (or just use velocity), then recalculate based on the player's head rotation if they move forward or somewhere else.
hmmm..
I understand a little, thank you..
Is there any information about this on the Microsoft website?
DynamicProperty didn't get centralized into a single documentation page.
For the summary, you can use setDynamicProperty & getDynamicProperty inside Entity, ItemStack, and World Class.
The values you can set are: Vector3, Boolean, Number, and String ( use undefined to clear a property )
World Class possesses utility method for dynamicProperty:
- getDynamicPropertyIds
- getDynamicPropertyTotalByteCount
- clearDynamicProperties
It used to be required to define all possible Dynamic Properties on world initialization. But this has changed some time in the last year. Now you can use any value at any time. It was only ever in the release notes of some random Bedrock version.
#1271915600855171112
Ok but what should you do when you json.parse?
Whatever you want to do?
JSON.stringify turns a JavaScript object into a string. You save that string to a dynamic property and then use JSON.parse on it to get the original object back.
how would I find the closest entity to a player?
I don't know how to do this
getEntities(options?): Entity[]
And then maybe use maxDistance in EntityQueryOptions
tyty
ye
Not all the closest entities?
then do .getEntities()[0]
so doing [0] , it will return the first entitiy
maybe the most closest
wouldn't that be based off of existence time?
so longest entity is first?
Example:
script1.js
import { system } from "@minecraft/server";
// Example player statistics object
const playerStats = {
miniGame1Score: 1500,
miniGame2Score: 3200,
lastLoginTick: system.currentTick // Store the current tick
};
// Convert the object to a JSON string
const playerStatsJson = JSON.stringify(playerStats);
player.setDynamicProperty("playerStats", playerStatsJson);
script2.js
import { system } from "@minecraft/server";
const playerStatsJson = player.getDynamicProperty("playerStats");
// Check if the property exists and is valid
if (playerStatsJson) {
try {
// Convert the JSON string back to an object
const playerStats = JSON.parse(playerStatsJson);
// Access player statistics
console.log(`Mini-Game 1 Score: ${playerStats.miniGame1Score}`);
console.log(`Mini-Game 2 Score: ${playerStats.miniGame2Score}`);
// Calculate the time since the last login
const ticksSinceLastLogin = system.currentTick - playerStats.lastLoginTick;
console.log(`Ticks since last login: ${ticksSinceLastLogin}`);
} catch (error) {
console.error("Error parsing player stats:", error);
}
} else {
console.log("No player stats found.");
}
I dont know ĀÆ_(ć)_/ĀÆ
alrighty npnp, thanks anyways!
Hmm
got me in the right direction
Question: I don't suppose there is a way to get an entity's target block, like a bee, from the move_to_block component?
nah iirc
Yes, this kind of movement targets are not known to script
Does the delay from ServerForm depend on the player's connection/pings or World tick?
Woulda been nice... Making a tree spider and would like him to either replace a block with a web or put one in the air block he is in depending on the block... so guess I gotta just test. Using bee JSON as base with scripevent
You are godly
Yes he is
import { world, system } from "@minecraft/server";
import { ActionFormData, ModalFormData } from "@minecraft/server-ui";
world.afterEvents.itemUse.subscribe(data => {
const player = data.source;
const { x, y, z } = player.getViewDirection();
if (data.itemStack.typeId !== 'minecraft:diamond') return;
if (player.isSneaking == false ) {
menu(player);
}
if (player.isSneaking == true ) {
testmenu(player);
}
});
function menu(player) {
const stJson = player.getDynamicProperty("st");
const st = JSON.parse(stJson);
const form = new ActionFormData()
form.title(`§eMenü`)
form.body("")
form.button(st.text);
form.button('§eOK\n§r§rTıkla')
form.show(player).then(result => {
if (result.selection === 0) {
player.runCommandAsync(`playsound note.hat @s`)
}
}
)}
function testmenu(player) {
const modal = new ModalFormData();
modal.title("");
modal.textField("text", "...");
modal.show(player).then(result => {
const st = {
text: result.formValues[0]
};
const stJson = JSON.stringify(st);
player.setDynamicProperty("st", stJson);
})
}
Working but
I want this button to be added to every article I write here, the previous button should not be deleted.
You should have an array with all your "articles"
How can I do this?
async function giveArmour(player) {
const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
const boots = equipmentCompPlayer.getEquipment(EquipmentSlot.Feet);
const leggings = equipmentCompPlayer.getEquipment(EquipmentSlot.Legs);
const chestplate = equipmentCompPlayer.getEquipment(EquipmentSlot.Chest);
const helmet = equipmentCompPlayer.getEquipment(EquipmentSlot.Head);
const dimension = player.dimension;
const entity = dimension.getEntities({
closest: 1
});
const equipmentCompPlayer2 = entity.getComponent(EntityComponentTypes.Equippable);
equipmentCompPlayer2.setEquipment(EquipmentSlot.Feet, boots);
equipmentCompPlayer2.setEquipment(EquipmentSlot.Legs, leggings);
equipmentCompPlayer2.setEquipment(EquipmentSlot.Chest, chestplate);
equipmentCompPlayer2.setEquipment(EquipmentSlot.Head, helmet);
}
I've got this error and not sure why
You dont know what an array is??
const all = [];
// in some part of the code...
// all.push(new article)
// etc
const form =.....
all.forEach((e) => form.button(e.name))```
1 sec
const data = world.getDynamicProperty("listed_Items");
const auction = JSON.parse(data);
auction.push({ player: player.name, item: item, price: price, amount: amount ,itemname: itemn, id: auctionid, texture: texture});
world.setDynamicProperty("listed_Items", JSON.stringify(auction));
Is it like this?
Yes
What changes have happened to action forms recently as mine arent working?
What version were you using and what version did you upgrade to when you realized something broke?
it was probably about 1.20.6 I last updated it. (if its easier i can give an example of what its likee)
Beta API or no?
i have no clue if im honest
Look at your manifest
Assuming it's Beta then look at this to see what changed in "minecraft/server" and "minecraft/server-ui"
Latest NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Beta APIs NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Preview Latest NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Preview Beta APIs NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
world.afterEvents.playerInteractWithEntity.subscribe((e) =>{
const {player, target, itemStack} = e
if(target.hasTag("n1")){
pvp.show(player).then(e =>{
if(e.selection === 0){
player.sendMessage(`HCV kitpvp >> you have teleported to pvp`)
player.addEffect("slow_falling", 100, {amplifier: 1, showParticles: false})
player.teleport({x:20.16, y:129.56, z:42.11})
}
if(e.selection === 1){
player.sendMessage(`HCV kitpvp >> you have teleported to cpvp`)
player.addTag("pvp")
player.addEffect("slow_falling", 100, {amplifier: 1, showParticles: false})
player.teleport({x:37.98, y:154.69, z:1519.42})
}
})
}
})
how do i stop the npc menu from showing for the ActionFormData to be only showing
is there a way to get the player's biome without beta API
Player.json
Well...i was referring to the regular API
not using the player file
but if theres no other way it's fine, ill just wait
Yeah wait then
Can I recreate totems with this?
For checking a block neighbor do I just do block.north (+1)?
Used to be able to with an armor stand idk if that's usefull or not. I know foxynotale had an armostand that had cardinals coords and biome location not sure if it still works or not
i appreciate your input on this, but im like not in a big rush.
No, but you can create totems with programming There may be enough classes with properties and methods along with manipulation for the damage sensor of the player.json for you to be able to mimic it.
Hey guys i have a question, i made two seperate scripts for two addons, how can i combine them both ?
these are the scripts
how do i make them into a single script ?
if anyone knows then please tag me :)
Yeah u can
by just putting the code in the other script...
Yeah but ā ļø
yea but how ?
Copy past
i tried it didnt work
Remove the duplicated importa
Remove everything duplicated
If youāre using VSCode, shift+alt+o to sort imports 
so i tried
it didnt work
i put the rename one on top so it worked
the other one didnt
can anyone fix this ?
Remove Minecraft.
what ?? š
no i want it to be a single one :(
yea the player rename part is, the creator obscured it
We can't do anything about that
I'd explain why, but I don't think you know JS
i have permission to use it tho :)
wait i know a little bit ok š
Oh ā ļø know i understand why u told him to remove mc
a little help guys ? š
the other import did an alias
can u fix it if possible ? š
Others here will help you. This is against my personal policy. Either you want to know why and learn so you do not have to ask or get others to do it for you, if you can. If I just do it, I become your personal programmer... and that ain't happening... I teach to fish, not fish for you.
oki š«”
oki
I found a work-around for this but it's for my use-case only. But i think it can also suit to your use-case. Mine was creating an invisible entity that has a timer to despawn and it has this event filter for biomes they're spawned, and just assign a set_property to it, and then you fetch that property in the script api.
It's stable, and on my case since i didn't use it in loops, it pretty efficient
world.afterEvents.itemUse.subscribe(({ source, itemStack }) => {
const item = itemStack;
if (!item) return;
if (item.typeId === "minecraft:diamond_sword") {
item?.getComponent('enchantable')?.addEnchantment({type: new EnchantmentType('fire_aspect'), level: 2});
item.setLore(["Firebrand"]);
source.getComponent('equippable').setEquipment('Mainhand', itemStack);
}
});
Does anyone know how to prevent the enchantmentleveloutofbounds error? So this works but I don't know how to get it only to apply the enchantment once. So the error doesn't occur from trying to go past the max level
Here's a small function that caps a level to its maximum bounds. Use it by passing the EnchantmentType as its first argument, then the level you want to set as its second.
function safeLevel(enchantment, level) {
return level > 0 ? (level <= enchantment.maxLevel ? level : enchantment.maxLevel) : 0;
}
Oh cool! Thank you Sprunkles, I appreciate that a lot
Lol, not sure why autocorrect kicked in there with your name, sorry about that
yeah i was thinking of using a dummy entity too, but if the beta apis come out soon ill have to dismantle that system
Ye, sadge. Wait, they're going to remove entity.json stuffs soon?
anyone know a good GitHub client for Android with all the features, official one is useless
Web ??
I just use the official one. š¤·āāļø
If I actually need to work on someting, I'll just use my PC.
oky thxx
ye but I need an app
function menu(player) {
const form = new ActionFormData()
form.title(`§eMenü`)
form.body("")
form.button('§eOK\n§r§rTıkla')
form.show(player).then(result => {
if (result.selection === 0) {
player.runCommandAsync(`playsound note.hat @s`)
}
}
)}
I want to add 1 button for all items in the player's inventory. Is this possible?
1 btn ?
Get the inventory of player using player.getComponent("inventory") then iterate over all of the slots adding a button
use github in web
What's the problem in making your own?
If you need only vanilla you will just need to try them all or just play while you notice one with that time
i dont really understand why this isn't working, it's supposed to decrease timers 1 to 6 and when they reach 0 they get removed
const skillTimers = [
0, 1, 2, 3, 4, 5, 6
]
for (let skillTimer of skillTimers) {
const getTimer = player.getDynamicProperty(`timer${skillTimer}`);
if (getTimer !== undefined) {
if (getTimer > 0) {
world.setDynamicProperty(`timer${skillTimer}`, getTimer-1)
}else world.setDynamicProperty(`timer${skillTimer}`, undefined);
}
}```
ah, it's world not player
mb mb
Termux lol.
I don't know how to do this
Is there a place I can learn?
You use a for loop.
Can you give me a sample code?
import { ActionFormData, ModalFormData, world } from "@minecraft/server";
// Function to create and show the player selection form
function showPlayerSelectionForm(player) {
const form = new ActionFormData()
.title("Select a Player")
.body("Choose a player to view their inventory");
// Add each player's name as a button
world.getPlayers().forEach((p) => {
form.button(p.name);
});
form.show(player).then((response) => {
if (response.selection !== undefined) {
const selectedPlayerName = world.getPlayers()[response.selection].name;
const selectedPlayer = world.getPlayers().find(p => p.name === selectedPlayerName);
if (selectedPlayer) {
showInventoryForm(player, selectedPlayer);
}
}
});
}
// Function to create and show the inventory form
function showInventoryForm(player, targetPlayer) {
const form = new ModalFormData()
.title(`${targetPlayer.name}'s Inventory`)
.body(getInventoryString(targetPlayer));
form.show(player).then(() => {
// Handle any further interaction if necessary
});
}
// Function to retrieve the player's inventory as a string
function getInventoryString(targetPlayer) {
let inventoryString = "";
const inventory = targetPlayer.getComponent("minecraft:inventory").container;
for (let i = 0; i < inventory.size; i++) {
const item = inventory.getItem(i);
if (item) {
inventoryString += `${i + 1}: ${item.id} x${item.amount}\n`;
}
}
return inventoryString || "Inventory is empty";
}
// Example of triggering the form (e.g., when a player uses a custom command)
world.beforeEvents.chatSend.subscribe(event => {
const player = event.sender;
if (event.message === "!invsee") {
showPlayerSelectionForm(player);
event.cancel = true; // Prevent the message from appearing in chat
}
});
Something like this.
The code wasn't complete. I only gave an example. The rest is up to you.
Ok
Congratulations š
@fast lark
You can do this using
guys, ive got my scriptevent running, but is there a way i can hide this message? i mean, so it didnt appear when the event runs
/gamerule sendcommandfeedback false
why doesn't it do the documentation?
learn
@fast lark
world.afterEvents.itemUse.subscribe(event => {
const { source: player, itemStack } = event;
if (itemStack.nameTag !== "inventory") return;
const players = ['none', ...world.getPlayers().map(p => p.name)];
new ModalFormData()
.title('select player')
.dropdown('player', players, 0)
.show(player).then((r) => {
if (r.canceled) return;
const [playerName] = r.formValues;
const inspectedPlayer = world.getPlayers().find(p => p.name === players[playerName]);
if (!inspectedPlayer) {
player.sendMessage("§cPlayer not found");
player.playSound('note.bass');
return;
}
const items = []
const inv = inspectedPlayer.getComponent("inventory").container
for(let i = 0; i < inv.size; i++) {
const item = inv.getItem(i)
if(!item) continue
items.push({slot:i, id:item.typeId, amount:item.amount})
}
const invScreen = new ActionFormData()
.title(inspectedPlayer.name + ' Inventory');
for(const item of items) {
invScreen.button(`Item: ${item.id} |Amount: ${item.amount} |Slot: ${item.slot}`);
}
const item = items[r.formValues[0]]
invScreen.show(inspectedPlayer).then((r) => {
if (r.canceled) return;
const areYouSure = new MessageFormData()
.title("Are you sure you want to remove this item?")
.button1("cancel")
.button2("remove")
.show(inspectedPlayer).then((r) => {
if (r.canceled) return;
if (r.selection === 1) {
inv.setItem(item.slot, null)
}
})
})
});
});
not tested
Thx
Does anyone know how to display slabs or doors in an NPC as a texture?
I need the pop animation
yeah mb, i always mix those two terms
hey @valid ice can you see dms? i want to ask some things, thank you
Does player have a type of 'any'?
How to detect "IF" player is looking at any entity?
i tried to figure it out myself for hours, but i gave up
i tried doing this:
const getEntity = player.getEntitiesFromViewDirection()[0].entity;
if (getEntity) {
// doesn't work
console.warn("looking at a entity");
}
i tried doing this, but it doesnt seem to work
@distant tulip srry for ping
He needs help that bad š
print getEntitiesFromViewDirection directly to the console
pinging someone just make the others ignore your problem even if they can help
This works. Make sure you're running this code, and also use an optional accessor on getEntity: player.getEntitiesFromViewDirection()[0]?.entity
anybody know why this doesnt work for me but works for someone else?
import { world, Player, system, } from "@minecraft/server";
import { ActionFormData, ModalFormData } from "@minecraft/server-ui"
export function getScore(target, obj) {
obj = world.scoreboard.getObjective(obj)?? world.scoreboard.addObjective(obj, obj)
return obj.hasParticipant(target)
? obj.getScore(target)
: obj.addScore(target, 0)
}
world.beforeEvents.playerInteractWithEntity.subscribe((data) => {
let { target, player } = data
if (target.typeId === "minecraft:npc") { //endr:farmernpc
data.cancel = true
system.run(() => {
let farmshop = new ActionFormData()
.title(`§aFarm Shop!`)
.body(`Welcome to the farm shop, We've got plenty of fresh produce and seeds for you!`)
.button("§bSeeds\n§8[Click to interact]", "textures/ui/icon_new")
.button("§bSell Crops\n§8[Click to interact]", "textures/ui/icon_carrot")
.button("§bAnimal Produce\n§8[Click to interact]", "textures/ui/promo_chicken")
farmshop.show(player).then(response => {
if (response.selection === 0) {
seedsPage(player)
}
if (response.selection === 1) {
cropsPage(player)
}
if (response.selection === 2) {
animalProduce(player)
}
})
})
}
})
Doesn't work in what way?
the menu doesnt open.
wait
this time it worked
lool what
i don't think its my manifest or anything, its definitley running but i dont get any errors for it
You know how to protect an area so that it doesn't break or block
sprunkles playing minecraft for once
did you add the lib to the manifest?
uh i think? i made this ages ago and it worked so i think it should
please help me as to what im looking for
the only errors are with the .lang file
let me boot my game and see if it work in my end
alr ty
š¤·āāļø
i have no blimmin clue
what is your version
1.21.2
I think its because of your custom npc
nah tried it with normal npc
put
console.warn("this is the right pack")
in your script root and reload
are you using the developer behavior pack folder
yes, but im also updating the uuid so it resets aswell
remove the old one if you still have it
You shouldn't update the uuid. If you do you have to remove the old pack and add it to the world again
alright. ty
yo can someone dm me a basic manifest, i think its my manifest thats wrong but i dont think my main.js file is running
Check the wiki
Because just like any other project, it grows and changes under development. This is a natural cause and effect in any form of development. We simply adapt.
Cursed Event Ideas:
- cancelable beforeEvent playerLeave
- cancelable beforeEvent worldInitialize
i found my issue, i left one word in there thats outdated and it broke everything š
Canceling playerLeave will probably never happen, as I think it would be a security concern to prevent someone from being able to log out. That, and it would force the player to have to close the application if they were to succumb to that logic.
exactly. xd
thank you mr. obvious
Your comment was not necessary. I was replying to another individual. Please move along.
Oof, welcome to programming
Please refrain from sarcastic comments, it is the breeding ground for toxicity, which is the last thing we need in this category. #off-topic is fine for that.
His information was valid and useful for new programmers.
While I understood Gega's comment to be in jest, some people may not have or may be using a translator that does not convey it as that.
alr
What word in a manifest is outdated?
function showInventoryForm(player, targetPlayer) {
const form = new ActionFormData()
form.title(`${targetPlayer.name}'s Inventory`)
form.body("inventory");
form.button(getInventoryString(targetPlayer))
form.button("ok")
form.show(player).then(() => {
// Handle any further interaction if necessary
});
}
How can I make it so that there is 1 button for all items?
do loop
list all the item ids in an array then do forEach, with form.button() inside
Is there a way to obtain the items data value through script? Im trying to see if the player is wearing the ender dragon head item.
system.runInterval(() => {
world.getPlayers().forEach((player) => {
const equipComp = player.getComponent('minecraft:equippable');
if (equipComp) {
const headGear = equipComp.getEquipment(EquipmentSlot.Head);
console.error(`${headGear.typeId}`);
}
});
}, 20);
No, you'll have to wait for the flatenning
bruh
Is there any kind of VS-Code shortcuts for inserting JDoc?
never mind... dang.. it did it for me... I just typed /** and it made this```js
/**
*
- @param {*} array
- @returns
*/``` I love you VS-Code
Codeium extension (like copilot)
is this default behavior?
it might be one of your extensions
ai probably
not sure. I use //@ts-check and a bunch of extensions, so not sure what helps it.
just tried it with a blank profile
it is default
LOL.. I looked at that extension... not sure I am ready to have AI writing snippits for me... I am still learning fluency, so gotta do my own work...
But that is one NICE extension
i mostly use it for repetitive codes and jsDoc
Or ust typescript lol
no š
I can't.. I'll go crazy...... I love JS.... and I am learning C#.... typescript will mess me up write now.... and deploying from regolith... too much work... what filter do you use?
𤷠I literally use TS + regolith
i hate compiling
What filter for the convert?
ctrl + shift + b to access that
is that a ts thing or am i being dumb
yes it is
xd
trust me it is worth it
Minato, do you use regolith?
being able to define types easily is a god send
what's regolith
It's org heaven
nope
i came from notepad++ btw
ah
it's a linux distro?
Created by some guys in the OSS discord.... https://bedrock-oss.github.io/regolith/guide/what-is-regolith/
A flexible and language-agnostic addon-compiler for the Bedrock Edition of Minecraft.
It's fine
I was bullied from con master for that and switched to vs code using his profile
LOL
yeah
now i do the same lol
good lmao
it is a good change
yes
it's for their own sakes
really good change
notepad is best though

Yes
now switch to vim or emacs
can someone help me? it says " TypeError: not an object at line 2350"
hey @valid ice is there wrong in my item id list?
yeah uhhh idk it looks fine to me
Does someone know about a item database where I can save items with nbt data
yeah it keeps saying TypeError: not an object at Map (native) at <anonymous> line 2350
How're you using it?
Dont crosspost please
Yo I just did a post and asked a question
I don't think that's called cross post
That is crossposting yes
Lol

i use vex vaults, but its your chest form pack
theres no error on this file btw, its just on the typeId file
W coding
do I need to install anything alongside the regolith c# extension
How can I store data in a block? since there are no dynamic properties for blocks and states need predefined values
Huh ā ļø
U are on js channel
You cant
Youll need to store data via other dynamic properties. Have a key/val relationship that stores the coords then the id then the data
You can save block "dynamic properties" as world dynamic properties. Just make the key unique to the block's location
blocks/${block.dimension}-${block.x}-${block.y}-${block.z} for example
And? People most likely have more experience here compared to the others.
Maybe ask in the proper channels š
Then save it in world dynamic proprety, +
Use
world.setDynamicProprety(`${BlockTypeId}-${Loc.x},${Loc.y}.${Loc.z}` , UrDataAsStingAndParseItLater)```
@fiery solar
U can ask chat gpt if u want, it can give u with good infos
alright, thark you
thx
U can add dimension
To make it more precise
If u want to safe an object:
Stingify it using
JSON.stingify(urObj)
probably not for smaller extensions, even in trying I was not able to get anything usefyl
Yeah , i suggest using visual studio
Because they use it for c++ , and make ur work easier
And vscode isn't equipped enough to handle c languages
If u pc is high-end pc ofc
U can stick with vscode , it s good too
@gray tinsel
how could i run a command like as the server with BDS? for something like /transfer
have a parent process write into the servers stdin
Thank you
join the OSS discord and get started with any questions there... would you like me to send you an invite? That is what you where referring too, correct, our earlier convo?
Yeah that would be appreciated
I cannot invite, cause we are not connected, but here is the link... https://discord.gg/6PjqEtzn
I would highly suggest exploring filters and learning to make your own for any useful task.
I need to make the mob teleport to either side of the terrain I'm on as long as it doesn't go down the terrain I'm standing on.
for example if I am on the 3rd floor of a building and the mob instead of teleporting
to random locations on floor 3 teleports to floor 2.
How do I solve this?
Sorry about the comments you got from others after.. I was not here to nip that in the bud. He had no idea of the scope of the subject and it's relation to anything. Some people are just like that.
is the same location on the Y blocked?
For a test, tp a mob, commands into a block in the air... and see if it goes to top of block or below the block... I think this may be what is happening., try y+1 to ensure
No worries
i don't understand
world.beforeEvents.chatSend.subscribe((e) => {
const { sender, message } = e;
const inventory = sender.getComponent("inventory").container
const sword = new ItemStack ("minecraft:wooden_sword", 1)
const ench = sword.getComponent("enchantable")
if (message === "loadkit") {
e.cancel = true;
system.run(() => {
inventory.addItem(sword)
ench.addEnchantment({ type: new EnchantmentType("unbreaking"), level: 3 });
sender.sendMessage("sword loaded");
});
}
});
why does addEnchantment not work?
You need to set the items back into the inventory
back into?
Into the inventory
you added the item before you even added the enchantment
just switch those two lines
yeah it works, thank you
i didnt understand my bad
That s impossible to do with ur current script, but i think the mob itself falls of the floor then when the mob is in the middle of air it got teleported into that new floor and so on
Can i use it on my server, I will give you credit wherever I can
sure
Thank you so much
ur wlc
I need help making a reliable island generator. Dm me if you can help me 
whats island gen
function getInventoryString(targetPlayer) {
let items = "";
let inventoryString = "";
const inventory = targetPlayer.getComponent("minecraft:inventory").container;
for (let i = 0; i < inventory.size; i++) {
const item = inventory.getItem(i);
if (item) {
items = item.type.id;
inventoryString += `${i + 1}: ${item.type.id} x${item.amount}\n`;
}
}
return inventoryString || "Inventory is empty";
}
function showInventoryFormi(player, targetPlayer) {
const form = new ActionFormData()
form.title(`${targetPlayer.name}'s Inventory`)
form.body(getInventoryString(targetPlayer));
form.button("ok")
form.show(player).then(() => {
// Handle any further interaction if necessary
});
}
How can I see the enchantments of items here?
Someone have a script for player rank?
#1046947779118895114
You can look here, some people are sharing the mods
can someone help me
bro just say what is wrong with that, we can't really help you without it
Okay, sorry, can you help me fix it I donāt why but it doesnāt get the right button select and I was going to ask how would you change the percentages of winning if you hit a certain button like. If you select heads you have a 30% chance of it being heads and 70% chance for it to be tails. If you select tails it has a 30% of being tails and 70% chance being heads
- Form results are never null
world.beforeEvents.playerInteractWithBlock.subscribe((e) =>{
const {player, itemStack, block} = e
const inventory = player.getComponent("inventory").container
const sword = new ItemStack ("minecraft:stone_sword", 1)
const helmet = new ItemStack ("minecraft:chainmail_helmet", 1)
const chest = new ItemStack ("minecraft:chainmail_chestplate", 1)
const legs = new ItemStack ("minecraft:chainmail_leggings", 1)
const boots = new ItemStack ("minecraft:chainmail_boots", 1)
const ench = sword.getComponent("enchantable")
if(block.typeId == "minecraft:chest" && block.x == -353 && block.y == 82 && block.z == 17){
e.cancel = true
system.run(()=>{
ench.addEnchantment({ type: new EnchantmentType("vanishing"), level: 1 })
helmet.getComponent("enchantable").addEnchantment({ type: new EnchantmentType("vanishing"), level: 1 })
chest.getComponent("enchantable").addEnchantment({ type: new EnchantmentType("vanishing"), level: 1 })
legs.getComponent("enchantable").addEnchantment({ type: new EnchantmentType("vanishing"), level: 1 })
boots.getComponent("enchantable").addEnchantment({ type: new EnchantmentType("vanishing"), level: 1 })
sword.nameTag = "§d§lStarter"
helmet.nameTag = "§d§lStarter"
chest.nameTag = "§d§lStarter"
legs.nameTag = "§d§lStarter"
boots.nameTag = "§d§lStarter"
inventory.addItem(sword)
inventory.addItem(helmet)
inventory.addItem(chest)
inventory.addItem(legs)
inventory.addItem(boots)
is there a better way of doing this
use loops
const items = [
"minecraft:stone_sword",
"minecraft:chainmail_helmet",
"minecraft:chainmail_chestplate",
"minecraft:chainmail_leggings",
"minecraft:chainmail_boots"
]
world.beforeEvents.playerInteractWithBlock.subscribe((e) =>{
const {player, itemStack, block} = e
const inventory = player.getComponent("inventory").container;
if(block.typeId == "minecraft:chest" && block.x == -353 && block.y == 82 && block.z == 17){
e.cancel = true
system.run(()=>{
for(const itemId = items) {
const item = new ItemStack(itemId, 1);
item.getComponent("enchantable").addEnchantment({ type: new EnchantmentType("vanishing"), level: 1 });
item.nameTag = "§d§lStarter";
inventory.addItem(item);
}
@glacial widget
This is called loops
i mean, i want for chat feedback to show up, but only so scriptevent messages were disabled, and this disables all of the messages
oh
is there a way to get the ingame day?
i didnt know u could use loops for it
.
Is there anyway to get a players head, or set a Steve head in a chest ui? Or does anyone have a Steve head resource icon
Thanks, but do you by chance have one facing the player?
How do I get the items attack damage?
Where is supposed to be the player in a png
Nope
I've been getting random errors like that also but mine looks and works fine. Mine is an error of a line of code which I literally have 20 of just different tags lol
what does /scriptevent do and how do I use it?
triggers script event
its like functions but for scripts
#1070606638525980753 message
just sample
I see, thank you for the answers Seawhite and Remember M9!
I guess this means I can summon an explosion using scriptevents
/scriptevent is basically a command event
so yes everythings possible (that scripts can do)
I am connected to "script debbuger" successfully so I am be able to use "breakpoints etc." but there is no data in "diagnostic window", does it works for clientside worlds?
Here is my launch.json
"version": "0.3.0",
"configurations": [
{
"type": "minecraft-js",
"request": "attach",
"name": "Debug with Minecraft",
"mode": "listen",
"targetModuleUuid": "UUID HERE",
"localRoot": "${workspaceFolder}/scripts/",
"port": 19144,
}
]
}```
What Minecraft version are you using?
1.21.2
I can't recall if performance debugging is supported on that version. The client stats are certainly not
And is that the literal value you set for targetModuleUuid? Or is that redacted just for being sent here
no, i changed it
diagnostic panel is only for v1.21.20+ , stable cannot use it for now
ty!
How do I add custom components to an item and what format version do I need
The Holiday Creator Features experimental toggle has been removed. Along with it includes JSON block and item events. This functionality has been replaced with custom components.
Please take a look at the following links to learn more about custom components:
@wintry bane
