#Script API General
1 messages · Page 90 of 1
because you said the end goal is just making code that works.
Then you misunderstood what I was speaking about.
Then I guess I did.
I am JS/TS guy and I care about it
Most people just code with the goal of the script working even if it's incredibly slow
Not essentially. I would say a big amount of people who's "interested" on learning this just wants to know the basics to do a basic addon for them or to share it to the public
anyways using Object.values or a const array wont change thst much the speed, its just 5 items
right
you're calling it every loop creation, so it does change a bit
yeah, that's not a big deal.
that really aint be that slow
an api call can be heavier than it
using a constant array will be faster than call of Object.values for every time
instead of going back and forth, test it.
When I say "code that works", I don’t just mean code that runs or gets the job done in a basic sense. I mean code that performs well within the specific constraints of the environment, especially on mobile devices, where performance, and hardware limitations really matter.
That’s exactly why I sometimes choose unconventional solutions (unpopular methods): not to ignore constraints, but to better address them. If a standard approach doesn’t meet those performance goals, I’m willing to step outside the norm to make sure the final result is both functional and efficient.
Thanks for explaining
why calling a function every time should be faster?
im not going to argue
honestly idc that much
if i wanted to make a custom trident, do i copy everything from the vanilla trident and just retexture it?
you have to create your own stuff to mimic it aswell.
like what
i dont want enchants on it, so its fine
wdym the item
?
is it because its a 3d model when held
the item for it.
oh ok yea i understand what you mean
ofc i need to make my own item texture
not the texture.
?
to make it shoot?
ah ok
well, throw.
is there like a premade thingy that someone has made
that i can use
or do i need to make it from scratch
const value = [
"Head",
"Chestplate",
"Leggings",
"Boot",
"Mainhand"
]
const obj = value.reduce((acc,next)=>{
acc[next]=next;
return acc;
},{});
let i = 0;
let j = 0;
{
const now = Date.now();
while(Date.now() - now < 1000)
for(const _ of value) i++;
console.log(i);
}
{
const now = Date.now();
while(Date.now() - now < 1000)
for(const _ of Object.values(obj)) j++;
console.log(j);
}
console.log(i/j);```
usually dont get 2x faster using a constant array, yeah it does get faster.
When we talk about node it seems to be constant time. but yet your "solution" is faster
i downloaded everything, now i have to rename everything
yay
fun
thats easy.
yea but tedious
not if you use the replace function.
ctrl+h?
whatever it is for your software.
ok
@remote oyster can you help me? im thinking in a way of implementing the db using btree on memory(files), im thinking about each key of a node to be a pointer to another node, the thing is that the data would get fragmented, but for this i solve when i have something basic working. i'd like to know if you got some idea i could use to implementing the search on the db other than mine with b+tree and pointers. i wanna find some better ideas than this.
i thought in this because with it i could implement(with files), a way to point at some offset on the file and so just load that part and append it on the btree, which later i'd implement some kind of WAL
the implementation itself i can handle it by myself, the problem is thinking on what to implement
Use event .isFirstEvent to check if it's the first one and report on the bug tracker because there's no good reason that event should fire multiple time
That sounds like you’re aiming to implement delta updates, which is a solid direction. I have recently considered this same concept but haven't touched on it just yet. It’s definitely a powerful idea, especially for managing large datasets efficiently by reducing memory pressure and minimizing I/O operations. I’m not entirely sure how to implement it myself yet, but the approach seems feasible. It will likely involve some complex logic, particularly around tracking changes and managing file offsets, but overall, it’s a smart way to handle partial loading and updates.
why is player interact with entity not detecting for all entities
use before event
Use before event.
thanks
One message removed from a suspended account.
No.
hello, does anyone knows if it's possible to add a tag to a block the same as setblockpermutation works?
oh, wait nmv
system.runInterval(() => {
updatePrestigeLeaderboard()
updateRebirthLeaderboard()
updateBlocksMinedLeaderboard()
}, 100)
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
updateInvestments(player)
}
}, 6000)
``` is it bad to have multiple stuff like this? if so how do i optimize it
The difference is approximately zero.
2 sec
there we go
forgot to update it
#1067535608660107284 message
?
spread the functions to different runIntervals, 100 105 110
You can't optimize, max 0.000001 ms
no so, one of them runs every 100 ticks, one runs every 6k ticks, is having multiple of them bad ?
It depends on what the function does.
i changed this
Almost nothing depends on the number of runInterval
well, it is an improvement at least, the devs them self recommend it
i have 4 of em
Might as well make the loop through players asynchronous
i think you should implement neutron splitting and certain mathematical algorithms to test each run interval accordingly
Could do some sorta event instead they could hit or interact to update leaderboards? Just depends on how you want it to function
i have multiple for like timed particles etc, im just wondering if having alot will cause issues
what
yo, you are a json ui guy right
leave particles client side if possible
yes
so instead of world.spawnParticle i do player.spawnParticle?
Less intervals the better, could make a single interval and based on time past run stuff. This way only one runs.
how is this not json ui
https://discord.com/channels/523663022053392405/1379161004558127215
no.
when does the particle spawn?
prob particles or something
something weird
thats some fancy ass particles if so
yeah uh
#1379161004558127215 message
i would attatch those to entities
you dont believe in variables I see
as locators
why would i use entities to spawn particles what
why are you responding to me with this
well i guess it doesnt matter but atleast make them client sided
which i do that how
Well, you asked "how is this not JsonUI"
I read his message dude.
Okk
its an entity
Yeah i used ticking also it lagged so bad I had to rewrite it
Oh lord...
depending on the way im implement, if the same way for minecraft, i will be able to do not so much api calls, but memory would have to be stored in variables
probably i load lazily like that and only when required i write on the game, but damn thats too far ahead
i just dont think that it would be something good for every addon have its own code of it running
5 reactions and not one of u have told me how to optimize it
just dont be noob
Well if you're using that many particles I would probably make a spawnParticles function that takes in an array of objects, each with the name of the particle and the location, you can also have a namespace argument to remove the redundancy of putting it in front of each particle.
interface Particle {
particle: string;
location: Vector3;
}
export function spawnParticles(namespace: string, particles: Particle[]) {
const dimension = world.getDimension('overworld');
for (const { particle, location } of particles) {
dimension.spawnParticle(`${namespace}:${particle}`, location);
}
}
const y = -57.5;
spawnParticles('osuea', [
{ particle: 'common_glass', location: { x: 27.5, y, z: -20.5 } },
{ particle: 'rare_glass', location: { x: 27.5, y, z: -12.5 } },
{ particle: 'epic_glass', location: { x: 28.5, y, z: -18.5 } },
{ particle: 'legendary_glass', location: { x: 28.5, y, z: -14.5 } },
{ particle: 'mythical_glass', location: { x: 30.5, y, z: -16.5 } },
{ particle: 'money', location: { x: 27.5, y: -58.5, z: -29.5 } },
{ particle: 'money', location: { x: 27.5, y: -58.5, z: -32.5 } },
{ particle: 'money', location: { x: 27.5, y: -58.5, z: -35.5 } },
]);
Something like this ig, reduces some of that redundancy at least.
If you are able to cache the dimension at a higher level then you could eliminate having to make that API call with each interval.
Yeah that's true
// COSTANTS
export const OVERWORLD = world.getDimension("overworld");
export function spawnParticles(namespace: string, particles: Particle[]) {
for (const { particle, location } of particles) {
OVERWORLD.spawnParticle(`${namespace}:${particle}`, location);
}
}
You can cache the dimension
I'd actually recommend having a constants file for storing all the dimensions in it
*if you're using module version 2.x.x, you'll need to make sure your file doesn't load during early execution
assuming you have no need for molang variable map, this syntax could work too:
spawnParticles('osuea', {
'common_glass': { x: 27.5, y, z: -20.5 },
'rare_glass': { x: 27.5, y, z: -12.5 },
'epic_glass': { x: 28.5, y, z: -18.5 },
'legendary_glass': { x: 28.5, y, z: -14.5 },
'mythical_glass': { x: 30.5, y, z: -16.5 },
'money': { x: 27.5, y: -58.5, z: -29.5 },
'money': { x: 27.5, y: -58.5, z: -32.5 },
'money': { x: 27.5, y: -58.5, z: -35.5 },
});
Batch processing. Even better.
True, batching it together would be way better actually.
personally, I also prefer keeping the namespace with the particle name, so I wouldn't pass in the namespace separately from the ids, but do whatever you like best
Impossible
as a general rule, if you have something like world.getDimension('overworld') multiple times, it will always be better to store it to a variable instead of calling the API every time. It's both easier to read and has less performance overhead when you store it to a variable
gotcha
ty
export function spawnParticles(particles: Record<string, Vector3>, namespace?: string) {
for (const particle in particles) {
const loc = particles[particle];
OVERWORLD.spawnParticle(`${namespace ? namespace + ":" : ""}${particle}`, loc);
}
}
Here is the function that supports namespace or neither
this implementation has an issue, : will always be prefixed even if there's no namespace
type name is triggering me, but I'm just nitpicking now 
spawnParticles([
{ particle: "osuea:common_glass", location: { x: 27.5, y: -57.5, z: -20.5 } },
{ particle: "osuea:rare_glass", location: { x: 27.5, y: -57.5, z: -12.5 } },
{ particle: "osuea:epic_glass", location: { x: 28.5, y: -57.5, z: -18.5 } },
{ particle: "osuea:legendary_glass", location: { x: 28.5, y: -57.5, z: -14.5 } },
{ particle: "osuea:mythical_glass", location: { x: 30.5, y: -57.5, z: -16.5 } },
{ particle: "osuea:money", location: { x: -17.5, y: -58.5, z: -29.5 } },
{ particle: "osuea:money", location: { x: -17.5, y: -58.5, z: -32.5 } },
{ particle: "osuea:money", location: { x: -17.5, y: -58.5, z: -35.5 } }
]);
export function spawnParticles(particles) {
const dimension = world.getDimension("overworld");
for (const { particle, location } of particles) {
dimension.spawnParticle(particle, location);
}
}
```so something like this then
yeah, that looks fine, though I'd probably allow passing in a dimension as a parameter to spawnParticles
this server is only 1 dimension only
all good then, I always do that anyway since I just like having options
prisons server but ty for helping instead of just putting a skull emoji and not 💀
A small issue with this is it can't have duplicate identifiers
Unless there is something that can support it 🤔
who needs multiple identifiers anyway
if you want a likely very minor performance improvement, you'd move getDimension out of the function and into top level, but honestly probably doesn't matter
if you're using 1.x.x APIs, might as well do it, if you're using 2.x.x, probably not worth it
im using 2.0.0-beta yeah
yeah, dealing with early execution there makes it painful
could always do the hacky thing and delay your root import until after early execution 
see idek what that means im just making a server 😭 i just know what shit does etc i dont know the bts of how calling the api to do things etc
early execution is just a state the API is in when it first loads, basically means you can't do things like call getDimension at the top-level
In 2.0.0, I'd recommend initializing constants during worldLoad and exporting them. For data such as dimensions that won't change, it's better to keep it in memory to minimize I/O operations and improve performance. Its like comparing tomatoes to oranges.
But it's also personal preference.
this is another language to me ngl
wait nvm think i get it
im just trying to make everything easy to read and optimized for myself cuz i get lost in my own files.
system.runInterval(() => {
const chance = randomNum(1, 100)
const percent = randomNum(1, 15)
let decision = ""
let currency = ""
let currency_chance = randomNum(1, 3)
switch (currency_chance) {
case 1:
currency = "money"
break;
case 2:
currency = "gems"
break;
case 3:
currency = "mine_dust"
break;
}
if (chance >= 1 && chance <= 50) decision = "increase"
if (chance >= 51 && chance <= 100) decision = "decrease"
if (decision == "increase") {
for (const player of world.getAllPlayers()) {
if (getScore(player, `${currency}_invest`) > 0) {
let amount = (getScore(player, `${currency}_invest`) / 100 * percent).toFixed(0)
player.runCommand(`scoreboard players add @s ${currency}_invest ${amount}`)
}
}
world.sendMessage(`§6Stock Update §8> §f${formatString(currency)} §ehas §aincreased by §f${percent}§a%%`)
}
if (decision == "decrease") {
for (const player of world.getAllPlayers()) {
if (getScore(player, `${currency}_invest`) > 0) {
let amount = (getScore(player, `${currency}_invest`) / 100 * percent).toFixed(0)
player.runCommand(`scoreboard players remove @s ${currency}_invest ${amount}`)
}
}
world.sendMessage(`§6Stock Update §8> §f${formatString(currency)} §ehas §cdecreased by §f${percent}§c%%`)
}
}, 3600)
``` like this for example
honestly not horrible, I've seen way worse
let OVERWORLD;
let NETHER;
let THE_END;
// Handle world load and cache dimension references
world.afterEvents.worldLoad.subscribe(() => {
OVERWORLD = world.getDimension("overworld");
NETHER = world.getDimension("nether");
THE_END = world.getDimension("the_end");
});
// Export constants
export { OVERWORLD, NETHER, THE_END };
Yes, you could use my syntax previously, or if you wanna remove the need to have to type "particle" and "location" everytime, use this function
export function spawnParticles(particles, namespace?) {
const dimension = world.getDimension("overworld")
for (const particle in particles) {
const loc = particles[particle];
dimension.spawnParticle(`${namespace ?? ''}:${particle}`, loc);
}
}
const y = -57.5;
spawnParticles(
{
common_glass: { x: 27.5, y, z: -20.5 },
rare_glass: { x: 27.5, y, z: -12.5 },
epic_glass: { x: 27.5, y, z: -18.5 },
legendary_glass: { x: 28.5, y, z: -14.5 },
mythical_glass: { x: 28.5, y, z: -16.5 },
},
'osuea'
);
for (let i = 0; i < 3; i++) {
const dimension = world.getDimension('overworld');
dimension.spawnParticle('osuea:money', { x: 27.5, y: -58.5 + 3 * i, z: -29.5 + i });
}
Use the for loop since objects can't have multiple properties with the same name 😞
@dawn zealot
i think someone loves capitals
there's something so cursed about seeing SCREAMING_CASE on a non-constant variable
it's a naming convention usually used to say that "this variable is constant and can't change"
oh right
Its technically a constant by right, but initialized as let to allow declaring it's constant value afterwards.
Yeah but it still looks cursed as it's using let lol
Sorry, was tryping a reply but something came up
To add up to what the others said, i see that you are spawning all the particle at the same time but different offset, a better option would be to make a main particle that you spawn using the script and then inside it in the resource pack side spawn the others using different offsets
javascript in general is just mental
True, but when you understand what it's doing it makes sense haha.
so like this, then whenever im using the overworld dimension, just import it from index.js?
ideally, you'd have a separate file for it
like a constants.js, or dimensions.js, depending on how you wanna organize
ah okay
Organizing makes writing your code way more manageable.
my shi is organnized, but the stuff that requires runinvertal or i just slam it into index/main js file
I also think in this case you would've ran into circular dependency issues since you'd be importing index from the files you're already importing in index
Var would solve that problem
-# but it is even more cursed
if I ever see var in a codebase I'm a part of, I'm running away
like this right
yep
bet
u shoulda seen me about 5 months ago
plz no 😨
couldn't have been as bad as @dusty temple
I mean, think about it
||gotta throw strays||
okay buddy
...
😡
old file btw
Yikes
yeah nvm, u win this one red
omg bruh what was i doing 😭
fire
The first line is not needed, var will work outside it scope
also is there a native method for titleraw, my typings arent working for some reason
Some things are better left unseen by the world
Actually nvm
But hey if it works, it works
player.onScreenDisplay.
wada faq
player.onScreenDisplay.setTitle() player.onScreenDisplay.setActionbar()
if you need to set the subtitle, that's part of .setTitle
me putting disclaimer in my old code before publishing it to the public
I still have early script api code from when I was first learning programming on my github
{rawtext: [{text:"test"}]}
I think the rawtext part is optional unless you need an array of things
{text:"test"} should work
aight
even just "test" would work, unless you need translation
try restarting the TS server?
player.onScreenDisplay.setTitle({ text: `§•§l§aNebula §7Prisons§r\n §7• §aName: §f${player.name}\n §7• §7Time-played §7- §f${getScore(player, "minutes")}M\n\n §l§7Your Profile§r\n §7> §bBalance §7- §a$§f${metricNumbers(getScore(player, "money"))}\n §7• §3Multiplier §7- §f${(getScore(player, "multiplier") / 100).toFixed(2)}§7x\n §7• §dGems §7- §f${getScore(player, "gems")}\n §7• §aMine Dust §7- §f${getScore(player, "mine_dust")}\n §7• §2Prestiges §7- §f${getScore(player, "prestiges")}\n §7• §bRebirths §7- §f${getScore(player, "rebirths")}\n §7• §eBlocks Mined §7- §f${metricNumbers(getScore(player, "blocks_mined"))}\n\n §7.gg/Vxby2XprUk\n§f` })
``` it works 😭
ive always done it like that, even before scripts were a thing
const lines = [
"first line",
"second line"
];
const finalMessage = lines.join('\n');
pre-scripting commands were pain
I'm so glad I've stopped doing primarily commands
back in my day 👴 i used to have thousands of function command for realms
what in the js-fuck is this 😭
lol, idk
back in my day, I wrote 300 commands into one long chain of command blocks on a controller
bro that was the shit
id always get my friend with his keyboard to pick block them for me
so it would save 😭
I did the same thing, made one of the only plot-systems for a realm at the time
until the realm eventually started to die of performance loss because we had so many plots
cuz it's not popular anymore
there was a couple good ones that were killed because they weren't popular enough
it is in the realm com
I must be too out of the loop now then
pretty sure i had the most popular prison realm for a year or 2
aquiver and project
but that was 3 years ago this month
im just replicating java like UI to get that java feel too
rookie numbers
also quick question, do tags have a string char limit
I think so?
well shit
what were you going to use it for?
if it's data-storage, use dynamic properties plz
😭
i hate using dynamic properties
shits so annoying when moving packs
Tags are so 2020 🥱
just resets
if ur changing ur uuids then yeah
I thought they fixed it??
?
every way ive tried never works, changing version in manifest doesnt work literally nothing
huh, strange
I mean even MP packs have issues updating on realms
realms are just cooked
was about to say that
im switching to servers anyway
after a month of realm tests
const floatingTexts = [...dimension.getEntities({
type: "osuea:floating_text",
tags: ["lb_blocksMined"]
})];
wha
why
?
why are you spreading into a new array?
oh yeah did i mention i had AI do that for me cuz i was sick and cba
hasn't returned an iterator for... a long time
💀
what was that AI on 😭
like 2 years minimum
it's very good at gaslighting you into thinking it knows math
it's tricked me up several times with its confidence
export function fillAreaWithBlocks(corner1, corner2, blockDistribution, blocksPerTick = 100) {
const dimension = world.getDimension("overworld");
const minX = Math.min(corner1.x, corner2.x);
const maxX = Math.max(corner1.x, corner2.x);
const minY = Math.min(corner1.y, corner2.y);
const maxY = Math.max(corner1.y, corner2.y);
const minZ = Math.min(corner1.z, corner2.z);
const maxZ = Math.max(corner1.z, corner2.z);
const sizeX = maxX - minX + 1;
const sizeY = maxY - minY + 1;
const sizeZ = maxZ - minZ + 1;
const totalBlocks = sizeX * sizeY * sizeZ;
let index = 0;
function getRandomBlockId() {
const rand = Math.random();
let cumulative = 0;
for (const entry of blockDistribution) {
cumulative += entry.chance;
if (rand < cumulative) return entry.id;
}
return blockDistribution[blockDistribution.length - 1].id;
}
function tick() {
let count = 0;
while (index < totalBlocks && count < blocksPerTick) {
const i = index++;
const x = minX + Math.floor(i / (sizeY * sizeZ));
const y = minY + Math.floor((i % (sizeY * sizeZ)) / sizeZ);
const z = minZ + (i % sizeZ);
try {
const block = dimension.getBlock({ x, y, z });
if (block) {
const blockId = getRandomBlockId();
block.setType(blockId); // Pass string directly
}
} catch (e) {
console.warn(`Failed to set block at ${x}, ${y}, ${z}: ${e}`);
}
count++;
}
if (index < totalBlocks) {
system.run(tick);
} else {
console.warn("Finished filling area.");
}
}
system.run(tick);
}
``` its really good at this stuff
I think my code has reached peak refactored-ness
const lavaCores: PrimitiveItemStack = {
typeId: 'minecraft:shroomlight',
amount: 64,
nameTag: '§vLava Core',
};
const bigBeth: PrimitiveItemStack = { typeId: 'minecraft:diamond_axe', nameTag: '§bBig Beth' };
world.afterEvents.chatSend.subscribe(({ message, sender: plr }) => {
if (message.toLowerCase() !== 'awaken') return;
const hasRequiredItems = plr.hasItems([lavaCores, bigBeth]);
const isOnMountain = plr.dimension.getEntities({
location: { x: -2955.6, y: 249.77, z: -1398.24 },
maxDistance: 50,
name: `${plr.name}`,
});
if (hasRequiredItems && isOnMountain.length > 0) {
plr.giveItem({
typeId: 'minecraft:netherite_axe',
amount: 1,
nameTag: '§dKrakatoa',
lore: '§5An axe only spoken in several myths and legends\nSightings of it are said to be bad omens\nfor Lumberjacks',
});
plr.removeItems([lavaCores, bigBeth]);
plr.playSounds({
'mob.ghast.scream': { pitch: 0.25 },
'mob.mooshroom.convert': { pitch: 0.25 },
'mob.ghast.charge': { pitch: 0.25 },
'mob.evocation_illager.prepare_attack': {},
});
world.sendMessage(`§5The Earth trembles as the mythical axe is released.`);
plr.camera.fade({
fadeColor: { red: 1, green: 0, blue: 1 },
fadeTime: { fadeInTime: 0, holdTime: 0, fadeOutTime: 10 },
});
plr.dimension.spawnEntity('minecraft:lightning_bolt', plr.location);
}
});
not having my vscode theme in discord makes reading these so hard
playSounds is a thing?
theres themes?
yeah
No I made it myself
you don't use one?
import { Player } from "@minecraft/server";
declare module '@minecraft/server' {
interface Player {
playSounds(sounds: Record<string, PlayerSoundOptions>): void;
}
}
Player.prototype.playSounds = function (sounds) {
for (const sound in sounds) {
const opts = sounds[sound];
this.playSound(sound, opts);
}
}
where i see this

i meant playSound
alr
my extension recommendations
questioned playSounds but not removeItems or giveItem 😔
Batch rename in vscode is an interesting choice.
just looked at the screen and that the first thing i saw
I use powertoys power rename.
I have not bothered to get or look into powertoys, just figured it wouldn't have anything I'd need
I use this one with a custom binding, since vscode lets you do that
hey me too
how do I save a dynamic property that contains an object?
JSON.stringify()
Keep in mind it doesn't work with functions and some other types
ty
just a general database question dynamic properties vs scoreboard database..
scoreboard database saves on the world and doesn't care about uuids..
now if i use dynamic properties... its still per world, but now they have to keep the same uuid to keep data right?
i haven't really done much testing on data being saved, and i just need to know as server/realm owners might run into trouble
with dynamic properties and issues having to update uuid's
but keeping old data
That is correct
dynamic properties are saved under the pack UUID in world storage, so changing the UUID changes what location the game looks for the data.
It doesn't technically delete the original data, as it's still saved under the old UUID, but it cannot be read unless you make a BP with that UUID.
can we close gui's yet?
like a crafting table?
i've seen unreliable damage... but not sure if thats been done yet
properly in api
thanks for clearing up the data question
as well
woah this might work
uhhhh don't think that's possible
teleporting them away and replacing the table
and teleporting back
funky but might work lol
In terms of hacky workarounds, it could be worse 😛
truth lol
is there a way to detect if they have closed the ui themselves?
wish there was some sorta event for that onCloseGui
hacky way again
is what i need lol
Not sure about that one
all i could think of was some raycast checks after interaction with block... but its not accurate because of mobile
so idk
nvm, im just gonna have them claim a quest by checking their inventory and checking if they have the items.
try to open a dummy form and check for userBusy and use closeAllForms
That wouldn't work for vanilla forms right like crafting table or chest?
Or will this trick it to close vanilla forms
Ill give this a go!
that just to check if the user is in a gui
hmm
should i save pfids externally?
or just on a dynamic property
its solely for getting player data
so it saves their pfid with their name
if their pfid is the same but name is different it updates their name
dont really know how to test if it actually works so
nvm it works
Ohhhh ok ty
That is genius
What database are you using as an external service?
supabase
oh, nice
Hello again.
👋
Sup coddy
Any good Vector libraries for v2?
The ones in #1067535712372654091 should still work.
ty
i kinda forgot if entityHitEntity fires after the attack damage
Is there anyway to add an item to the players inventory without needing to spawn it?
I want to be able to get an item directly to my inventory when interaction with a block
i saw that
wrong topic lol
yes
any suggestions to make this quicker or just better overall
its not slow but
what can i change
how
const inventory = player.getComponent("inventory")
const container = inventory.container;
container.addItem("minecraft:egg");
you can also use setItem to set an item on specific slots
Thanks! it worked as expected 
no probs and goodluck
you can save every few seconds much bigger loads of data
function targetedBlock(player) {
const block = player.getBlockFromViewDirection()?.block;
const e = player.getEntitiesFromViewDirection( { ignoreBlockCollision: true })
const entity = e.at(-1)?.entity;
if (!block || e.length === 0) { return "Not looking at any Block or Entity" };
if (block) {
return `typeId: ${block.typeId} \nXYZ: ${block.location.x}, ${block.location.y}, ${block.location.z}`
};
if (e.length !== 0 && entity.isValid) {
return `typeId: ${entity.typeId} \nXYZ: ${entity.location.x}, ${entity.location.y}, ${entity.location.z}`
}
};```
someone helpppppppppppp
this is the most confusing function i ever made
it always shows the blocks
but never returns the entity
issue is it mixes up entity with block detection
but when i remove block code, entity works fine
It returns block before entity, is that what you're experiencing?
So if both are valid, it will only return block
so whats the fix
Has anyone gotten the custom commands to open up a form without giving this error? I'd be okay if it was at least just a console log but this is getting spit out into chat.
no idea how to work around this, because you have to use system.run to use await.
"because you have to use system.run to use await." ??
With custom commands, yes
switch the order, idk
could be ""because you have to use system.run **or ** use await."
dunno what you're really after in the end'
What are you saying
ModalForm requires await, custom commands run in before and cannot run await
Huh? Can't you just make the callback async? Or run an asynchronous function inside the synchronous callback?
i meant
either await system.waitTicks(1)
or system.run()
idk why you meant run() with await
The screenshot I posted gets spit into chat with async as the callback
Hmm well IG that's expected.
Yeah, it's just really crumby and I'm hoping there's a workaround
I don't think you can hang a command over several ticks
Why does it have to be output into chat and not console log 😔
It still runs
It's basically a warning
It probably executes it but the result is unexpected.
Couldn't you just use form.show(player).then()
Also probably because it expects CustomCommandResult not Promise<CustomCommandResult>
I'll try it when I wake up. Completely forgot about that format, I always use await.

can you store dynamic properties on blocks?
No
What kind of data?
RF
I have a block that store power
should I just add Id to it's location and just set world dynamic property?
If BDS, yes, but if Realms, then no (use Dynamic Properties in this situation).
is realm same to single player world?
sorry but I didn't get that, can you explain more?
Are custom commands in-game yet?
its available in beta api
what can you do with custom commands?
you can add custom commands to the game, can you imagine?!
Adding Custom Commands
WHAT
Lol
also is there any way to get the id of every block in the game?
const blockIds = BlockTypes.getAll().map(b=>b.id)
Thanks 🙏
apparently form.show(player).then() doesn't functionally work different from using await form.show(player). I get the same error.
well actually, it's worse, because the form doesn't even open
Is it possible to detect when the player eats something without custom components? Like when someone finishes eating an apple or a sweet berry.
Can you tell me what the problem is?
Suggestion for @cinder shadow
Description
Force the game to show a UI form to player.
Credits
These scripts were written by Jayly#1397 on Jayly Discord, Worldwidebrine#9037 on Bedrock Add-Ons
I'm trying to open a form via custom commands. Unfortunately they run in a before state so they don't have the required privileges to use await. However, when using system.run(), it will always output a warning into chat.
show code
export async function resetStatsPage(source) {
const player = source.sourceEntity;
const resetCode = Math.round(Math.random() * 1e6);
const form = new ModalFormData()
form.title(`%settings.reset_skills.title`)
form.textField(`%settings.reset_skills.question\n\n${resetCode}\n\n§c%settings.reset_skills.warning`, 'Enter Code Here');
form.show(player).then(response => {
if (!response.canceled) {
if (response.formValues == resetCode) {
player.sendMessage(`§7§o%settings.reset_skills.confirm`);
resetDynamicProperties(player);
resetScoreboards(player);
player.triggerEvent('runecraft:constitution_0')
}
else {
player.sendMessage(`§7§o%settings.reset_skills.failed`);
}
}
})
}```
switched it off of await atm to test .then
Thanks
Show how you register the comamnd
Oh wait
the function is async so it doesn't work
asynchronous functions return Promise
and it expects a specific object or undefined
The only thing left to do is not to use asynchronous functions
or like this:
export function resetStatsPage(source) {
system.run(async () => {
const player = source.sourceEntity;
const resetCode = Math.round(Math.random() * 1e6);
const form = new ModalFormData()
form.title(`%settings.reset_skills.title`)
form.textField(`%settings.reset_skills.question\n\n${resetCode}\n\n§c%settings.reset_skills.warning`, 'Enter Code Here');
const response = await form.show(player)
if (!response.canceled) {
if (response.formValues == resetCode) {
player.sendMessage(`§7§o%settings.reset_skills.confirm`);
resetDynamicProperties(player);
resetScoreboards(player);
player.triggerEvent('runecraft:constitution_0')
}
else {
player.sendMessage(`§7§o%settings.reset_skills.failed`);
}
}
})
}
that won't work
it actually is working
what...
I swear I tried this last night
why?
I tried it last night and it still sent out the warning message in chat... but that was before I removed the async from the function
await work only in async
system.run is the async

TypeScript would have told you that
I don't care what TypeScript would have said to me
maybe skill issue, but typeScript slow me done a lot, and it is not like i don't know what to type and waste time searching stuff up
Don't worry, typescript also did not say anything that the in game warning messages did not already say
In conclusion, typescript is useless
case closed
The first one????
It's honestly worse, because the first "error" isn't an error
i wouldn't say that, but it is not as big of a deal to me, maybe to people who got used to it, but meh.
i don't see myself changing that any time soon, unless people who i work with use it
"let's throw an error so the user fix it and we remove his fix when he compile it"
Just another typescript L stay losing 
VSCode and bridge uses typescript, without it you probably coding this in notepad
what
it depends on file extension
.js -> JS
.ts -> TS
not depend on coding software
VScode both supports TS and JS including all languages
bruh what
I mean the code editor's source code is TypeScript
one thing for sure, it is not running using it
is this good structure
Join:
If player is in external db cache to dynamic property
If not, set external db and cache
Leave
Update external db and delete from cache
I hope there will be a special place for users that are hating TS and loving pure JS
warning: rant
Props to those who can do scripting. And major props for those who manage to do incredible things with scripts in Minecraft.
Long story short, I learned how to make addons from looking at how addons work. But with scripts, I opted out of because I did not see a need to learn a whole coding language for this pet project/hobby.
I have this addon that has an error message like this:
[Scripting][error]-TypeError: cannot read property 'typeId' of undefined at onTick (__bundle.js:1)
And it is spammed like crazy.
When I checked the offending code... Well. I am not going to unravel this ball of spaghetti code to find whatever error it has.
Here is the snippet for reference.
I don't expect anyone to bother with it, nor care to share what addon it is. Though wanted to share my frustration at this.
All of that code just to have a block generate crystals like a geode is insane.
Now I have to make a copycat for my friends because the want this to work.
But I cannot be bothered to fix this mess, nor pester the creator to do so either.
I'll make my own addon that lets the player craft their pretty crystals in as many colours as the pride flag has.
But it s encoded._.
encoded, encrypted, or given funny names for its components.
It has an error that the game supposedly does not like.
Yeah I don't see the point of this, did you want help or not?
Part of finding the error is reading the error
the TypeId is undefined, you are looking at inventory slots that are empty
the whole script is one line and obfuscated, so there is no point
oh, wait true
I figured the error they were showing was from the unobfuscated version
but that makes a lot more sense given it's on line 1
huh lmao what
Conclusion: Don't obfuscate scripts
Is this ragebait
It's good on the long run, if ur struggling writing types then thats on u not the language
I m writing code because it s fun :-:
you're associated with TypeScript!
am i tripping or did a bunch of messages just disappear?
mods hi
Load more
Hey where did my 15 messages of Typescript glaze go
I knew they would come 
1984
When's entity.target getting out of beta again?
never ;)
did someone just removed a glaze of the best language ever?
It's literally what carries my addon
Uh
cooked it with a furnace
According to chat gpt best language ever is python then c++
export type ts = Omit<APIGeneral, "Typescript">
Then js
You use Microsoft Windows 10 to make scripts in Microsoft VSCode for Microsoft Minecraft Bedrock using Microsoft TypeScript
python?!?!?!?!?
Yes
BRUHHHHHHHHH
Chat Gee bee dee can PYTH me ON that
python === garbage 🗑️
the slowest
C++ is better :-:
Performance-wise
literally coughing baby vs hydrogen bomb
Until you discover something called pointers and memory leaks
Ima just shit my pants when pointers are talked about
about time
And the rest is not so important
rust after c++?
beforeChat why did it never leave beta???????
due to slash commands probably
Just discovering that u need 5 lines of code to make it print hello world in cout , you will get sick ☠️
?
No , js
2
5
#include <iostream>
int main() { std::cout << "hello, world" << std::endl; return 0; };
just kidding
But that is indeed two lines
one line of code like some genius who obfuscated it 
#include iostream>
int main() {
std::cout << "hello, world" << std::endl;
}
Return 0;
you don't have to add return 0 in newer compilers
Oh
C++ for script API when
esolang for script API when
Bro u think js learning is something ☠️
LUA for script api when 💀
learn TypeScript at first
GODOT
I need this because C++ is faster
fuck it C# it is
Won't matter in the end because it will inevitably have to be compiled to javascript to run in Minecraft 😞
jk
restrict scripting API to TypeScript only!
I heard someone said lua ☠️
That's me
this is text 😭
____ is undefined ass code
then you fix it and everything is jolly again
not me typing as Array, as String blah blah if i even get forced to use ts
typesdcript so much better than js
That depends on how long youve been gone.
9 months
custom / commands now!
https://stirante.com/script/diff.html
Use this to compare the versions.
currently they require namespaces but soon they wont
They still require namespace.
well yes but they wont be required to be shown when using them
FINALLY!
let's glaze TypeScript together
people that dont like it just dont know how to use it
No
uh, i do
just too slow with it
BACK ME UP THEY ARE COMING @round bone
lol
diff ppl has diff choices
👆
they can't hold the power of TypeScript
😎
i guess when u just learn the types its really not that hard
some stuff gets confusing though tbf
yeah, sometimes
Do realms have ips?
yes
So technically i can transfer players realm to realm?
Could you tell me how to get the ip?
So i can test my theory

uhh just use a certain client
and do .ip
or i wonder if u could get it with wireshark
Its possible to add cooldown to system.run? I'm using it to run something when the player is sneaking, but it is playing every tick if I keep pressing shift, I want it to play when I click shift, and have a 5 seconds cooldown for me to use it again
Youll need to create your own timer.
Idk how to
.
Stop spamming that sh i t
im not

I personally hate when people obfuscates addons... I think that's so dumb and more when it's a small script that does something very simple like bro no one is gon steal ur sh.
So, just to piss them off I made a private AI deobfuscation tool, there you go.
You can try to fix the error now 👍🏼
everything related to programming is open source, and there are still people on this community that might think: 'i dont care, i was built different'
Anyone know the filepath and name for BDS server secrets and BDS server variables?
/config/default/variables.json
and then secrets.json
ty ty
but i couldnt get secrets to work so
oh
secrets are cool tho
I rember last I said "ai hope nobody does name their variables hex code" but WTF IS THIS
this just beyond gatekeeping
Hello, does anyone know of any script or code that would allow an entity such as the sniffer to hatch from an egg block after a period of time?
:-:
You can make a block :-: save it s location
After some amount of time
Replace it with air
Spawn an entity
Exactly, but how can I write that? Is there some kind of template?
Sorry, I just joined the server and I barely know how to navigate the server and for the moment I don't know how to make scripts. I want to learn.
But I would be very grateful if you helped me.
Read the wiki first and then ask
you've been asking that since yesterday
you should've used that time to learn the basics
use custom components and random tick the block, add some logic for the time and remove the block then spawn the entity
Anyone 😔
just decrease your interval..?
either decrease your interval, or store the time (system.currentTick is recommended for gameplay) in dynamic properties or memory and compare check
I dont know how to :/
if (player.isSneaking && (player.isOnGround && (!player.hasTag("dashs")))) {
player.runCommand('function dash2')
player.applyKnockback(getPl('dc_velocity').x, getPl('dc_velocity').z, 3, 0.3)
system.runTimeout(() => {
player.runCommand('function dash');
}, 2)
}
My 100% original code
It uses timeout
Idk about systenRun yet
Oh wait I messed it up
const tick = system.currentTick;
if (player.__cooldown > tick) return;
player.__cooldown = tick + 20;
this is just a simple code of cooldown
for anything cooldown related, i recommend using stuff like that
instead of runTimeout or interval
I really need to focus on learning before asking questions
I recommend that
It's always good to learn the language your using before using api's involved with it
Yeah, for now I'm gonna try to make a cooldown system using other methods
what does .__ do?
No I highly recommend doing what they sent
Don't use system.runTimeout
I could, but currently I don't have enough knowledge on how to do it, so for now I will try to use simple methods, like animation controllers and stuff
Dw it's very simple, when you create a new world and there are players actively in it, a timer is constantly incrementing by 1 per tick. That is what
system.currentTick
is.
When you do
if (cooldown > tick) return
It's checking if the current timer is less than the cooldown YOU created.
player.__cooldown = tick + 20;
All this is saying is the cooldown is exactly 1 second.
The reason why you don't do system.runTimeout is because if you /reload or restart the world, the cooldown will break
Relying on the world's currentTick will ensure that no matter what happens, it will run after the time you specified
Actually, I want the cooldown to reset when i leave the world
That's fine but currentTick will ensure no other potential issues happen with it other than breaking the cooldown. You can set all the cooldowns to be 0 when the world is loaded in that case
But if you want to use other methods that's fine, it is a learning experience after all
I think I got it, I will give it a try
const tick = system.currentTick;
if (player.__cooldown > tick && (player.isSneaking && (player.isOnGround))) {
player.runCommand('function dash2')
player.applyKnockback(getPl('dc_velocity').x, getPl('dc_velocity').z, 3, 0.3)
system.runTimeout(() => {
player.runCommand('function dash');
}, 2)
};
player.__cooldown = tick + 100;
Could you analyze it?
temporary property
(i think) __ part is for making sure that you dont confuse it as a property from API
thanks I just reasearched it and it's somehow called name mangling what a weird way to call it
i think temporary property is a better way to call it lol
you prolly should do
player.__cooldown <= tick
also put player.__cooldown = tick + 100 in the if check, since you want to refresh cooldown only when you sneak
Where it should be Inside the .js file? Because most of the scripts are Inside something, like a function or something else
inside the if check, the one you posted there
first time making an auction house works for all that offline stuff too:)
what did I do wrong?
oh wait I forgot to import files
no errors now I just forgot to import the files
setlore was triggered but it doesn't show on the item
do you need some components?
iirc you need to set the item back?
i forgot
Yes. You need to set the item once you set the lore
oh yeah
yep thanks
is it possible to setitem without needing the slot?
welp looks like that's impossible
what's one way to update the item?
setting the item requires a slot and I have no idea how to get current slot
forgor you could do these
setEquipment('Mainhand', weapon)
thanks god I have my past stuff
cool thank yall
does anyone know reasons why the hasTag function would ever occasionally fail to run in a situation like this? I've been running tests while trying to clear up error logs and idk what causes this to happen sometimes.
const entities = [...overworld.getEntities(), ...nether.getEntities(), ...the_end.getEntities()].filter(entity => entity?.isValid())
entities.forEach((entity) => {
if (entity?.hasTag("test")) {}
})
data for players are saved in worlddynamicproperties?
.
import { system, world, EntityComponentTypes, ItemStack } from "@minecraft/server";
const tick = system.currentTick;
if (player.__cooldown <= tick && (player.isSneaking && (player.isOnGround))) {
player.runCommand('function dash2')
player.__cooldown = tick + 100;
player.applyKnockback(getPl('dc_velocity').x, getPl('dc_velocity').z, 3, 0.3)
system.runTimeout(() => {
player.runCommand('function dash');
}, 2)
};
Something isn't right...
Invalid entities is my guess. Try entity?.isValid && entity.hasTag("test")
mc.world.beforeEvents.playerInteractWithBlock.subscribe(async (e) =>{
mc.system.run(() =>{
e.cancel = true;
const {itemStack, player} = e;
if (itemStack.typeId == "tm:transmutator") {
console.warn("TRANSMUTATE");
let currentEnergy = itemStack.getDynamicProperty("currentEnergy") - 1;
let maxEnergy = itemStack.getDynamicProperty("maxEnergy");
itemStack.setDynamicProperty("currentEnergy", currentEnergy);
itemStack.setLore([`Life Energy:`,`${JSON.stringify(currentEnergy)} / ${JSON.stringify(maxEnergy)}`]);
player.getComponent('equippable')?.setEquipment('Mainhand', itemStack);
};
})
});
why does sonsole.warn() triggers 7 times?
it's upsetting how this works because I've already filtered out invalid entities from the array lol.
Ah, I didn't even see that. Then realistically the condition shouldn't make a difference
it's my if (true) {} problem all over again
check if the isFirstEvent property is true.
nice they have that I thought I was gonna mkae my own one
I just discovered that it runs every interact/ holding interaction
thanks voidcell
Not to my knowledge. Do you need more than millisecond precision?
np
What's wrong with this code?
Didn't worked at all
When I loaded the world the main script was malfunctioning
This is a .js file btw
Because....
If statement will work once
put it inside a loop
it will not run at all because it is not being called
I noticed that, but I can't figure out how to make it run
I don't know...
for ( const player of world.getAllPlayers()) {
//Put code here
}
import { system, world, EntityComponentTypes, ItemStack } from "@minecraft/server";
import { HCFComponentManager } from "./CustomComponents/manager";
for ( const player of world.getAllPlayers()) {
const tick = system.currentTick;
if (player.__cooldown <= tick && (player.isSneaking && (player.isOnGround))) {
player.runCommand('function dash2')
player.__cooldown = tick + 100;
player.applyKnockback(getPl('dc_velocity').x, getPl('dc_velocity').z, 3, 0.3)
system.runTimeout(() => {
player.runCommand('function dash');
}, 2)
};
}
Like this?
Yes
Then add a loop
While loop
import { system, world, EntityComponentTypes, ItemStack } from "@minecraft/server";
import { HCFComponentManager } from "./CustomComponents/manager";
while ( true ) {
for ( const player of world.getAllPlayers()) {
const tick = system.currentTick;
if (player.__cooldown <= tick && (player.isSneaking && (player.isOnGround))) {
player.runCommand('function dash2')
player.__cooldown = tick + 100;
player.applyKnockback(getPl('dc_velocity').x, getPl('dc_velocity').z, 3, 0.3)
system.runTimeout(() => {
player.runCommand('function dash');
}, 2)
};
}}
It most work
I'm gonna test it
Didn't worked
It's part of the dash system
why while(true) loop, you could use system.runInterval()
im trying to use the debugDrawer to add a line from pos1 to pos2 but its not showing up in my world, am i doing something wrong here?
let line = new DebugLine(this.pos1, this.pos2);
line.color = {
blue: 0,
green: 1,
red: 0
};
line.scale = 1;
line.timeLeft = 4; //secs
debugDrawer.addShape(line);
pos1 and pos2 are Vector3 object.
yuh
Aha, thanks
is there a way to have dynamic properties on blocks? not states
i need to store a player name as an owner, but block states are static and have a maximum of 16 permutes per state
No. Best you can do is store it on a world or entity.
damn
world.setDynamicProperty(JSON.stringify(block.location), player.name)
i had a system like that before but it was horrible so ill redo it and maybe share it
👆
and then to get that block again:
dimension.getBlock(world.getDynamicProperty(player.name))```
how tf do i statically rotate an entity to adjust for facing direction ???
nope
like up/down/north/south/east/west
const owner = world.getDynamicProperty(JSON.stringify(block.location))
why do you want the block
pretty sure theres a set rotation thingy
becuase he trying to save block in dynamic prop?!?!?
your just saving player.name
if you checking who is linked to this block you need to get the owner not the block
okay but how
and its also wrong couse never set a dynamic property as player.name
u just did
hmmm i must have messsed up the parameter argument order
lol srry
identifier: blocck.location
value: player.name
world.getDynamicProperty(location) not getDynamicProperty(player.name)
if you want to get the blocks from the owner: world.getAllDynamicProperties().filter(([k,v]) => v == player.name)
ahhhhh i see
Is it possible to send data to another add-on? Like getting an array from another add-on.
how do i use it??? idk what that Vector2 is (but thanks)
vector2 = 2 dimensional vector """"coordinates"""" {x,y}
thanks
idk why ppl do new Vector(x,y,z) using external class
{x, y, z } is the same
since mojang made it as interface
yup
but in js it at least indicates a type
not like that's a problem in ts (:
how do i "tie" entity to block
ohh via properties
nop i meant tie so block tied to entity knows which entity is his etc
That is a planned feature Mojang wants to add.
Like bees/beehive and creaking/creaking heart
Okay
its possible to detect and replace items in a crafting table?
no
like i wanna rotate an entity beside the normal left/right
Yes cheese
Cheeese gromit cheeese
what
Cheese
Entity.setRotation?
it doesnt rotate the entity over specific axis
hmm
are you sure that you're providing correct params to a method?
anyone?
Hey, when i use entity.setRotation() it doesn't instantly set the rotation to the value but i can see the entity like taking a turn, is there any way to remove that "animation" or whatever that is
do i need to set location and endLocation after creating the object?
maybe teleport?
I'm trying to set the rotation not it's location
no you can rotate the entity while teleporting it to the same location
no need to change its location
i wanted to use this in-game
https://github.com/BluSpring/java-util-random/
What happens when multiple scripts from different add-ons ran the same scriptevent command at the same time asynchronously?
the game don't run them at the same time
Which one runs first, the add-on on top?
no idea
try and see
oh you talking about facingLocation
do dynamic props have a char limit
how can I detect a block? like knowing if there's lava 2 blocks under my custom block
take your custom block.location and -2 the y then
dimension.getBlock()
I don't know if block custom component is stable but you can use and loop this onTick
here @tender pier
thanks, i'll se if i can make it work
btw do you know if there's a way of replacing items when interacting with something?, i remember something like that but i can't find it anywhere
.
mangling is the name of the process to simply "obfuscate" names, generslly functions. in compilers, when you compile a function, the normal is to not be able to see the name of the function in the binary output, but with "no mangle" you disable it and make it possible
guys??
i cant debug my code cuz this is just not working
No errors or anything.
is there a toggle or something ?
how can I use setequipment thing?
EntityEquippableComponent.setEquipment(slot: EquipmentSlot, itemStack: ItemStack)
import { world, Player } from "@minecraft/server";
world.afterEvents.entityHealthChanged.subscribe((event) => {
if (event.entity instanceof Player) {
event.entity.onScreenDisplay.setTitle(`hp:${event.newValue}`);
}
});```
why doesnt my ui system work?
isn't this #1067870274894172260 related?
Your script is fine but regarding your file that is related to #1067869374410657962 not here.
im gonna cry
is there any orher way to make lines?
Debug drawing is still beta... Also what does this.pos1 contain? Did you test the variable?
mojangggg please release debugDrawer
i am hell waiting for it
i cant use it, i use only stable minecraft version
its only available on preview 😭
how do I
unintalicized and unpink lores and remove th Has Custom Priperties text?
/gamerule showtags false
is that for the Hs custom properties text?
what does it do?
yeah
thanks
👍
can someone help me? #1380166157981585418
Can someone help me with this pack idk what to do I get this error [Scripting][error]-Plugin [health score Pack - 1.0.0] - entry [] not supported for runtime [JavaScript].
please send your JS file, there is no reason for us to download that .ZIP, and check the scripts inside, why not just send the script?
world.afterEvents.entityHealthChanged.subscribe(ev => {
if(ev.entity.typeId !== "minecraft:player") return;
const obj = world.scoreboard.getObjective("Health");
if(!obj) return;
obj.setScore(ev.entity.scoreboardIdentity, ev.newValue);
});```
This is the manifest { "format_version": 2, "header": { "name": "Heart score v1.0.1", "description": "Shows hearts on a scoreboard using Script API", "uuid": "c359c02e-35bc-48ff-a3ee-0a8ee601b686", "version": [1, 0, 1], "min_engine_version":[1,19,0] }, "modules": [ { "type": "script", "uuid": "c22236ca-839f-4a9c-9d98-0ef6bde07109", "version": [1, 0, 0] } ], "dependencies": [ { "module_name": "@minecraft/server", "version": "1.8.0" } ] }
onRedstonePowered block custom component when?
never
you need to specify the main file. like this:
im on preview but it doesnt work for me
yes, its a Vector3 object (Player.location)
it should.
const box = new DebugBox({ x: 0, y: 173 + 0, z: 0 });
box.bound = { x: 2, y: 173 + 2, z: 2 }; // required for debugbox
box.color = { red: 1, green: 0, blue: 0 };
box.location = { x: 0, y: 173 + 0, z: 0 }; // can be updated later
box.rotation = { x: 0, y: 173 + 45, z: 0 }; // euler angles
box.scale = 1.5;
box.timeLeft = 60; // will disappear after 60 seconds
// box.hasduration (readonly)
// box.totaltimeleft (readonly)
// create a blue circle with all properties
const circle = new DebugCircle({ x: 5, y: 173 + 0, z: 0 });
circle.color = { red: 0, green: 0, blue: 1 };
circle.location = { x: 5, y: 173 + 0, z: 0 };
circle.rotation = { x: 90, y: 173 + 0, z: 0 }; // rotate to xz plane
circle.scale = 1.0;
circle.timeLeft = 60;
// create a green line with all properties
const tline = new DebugLine(
{ x: 0, y: 173 + 3, z: 0 },
{ x: 5, y: 173 + 3, z: 0 }
);
tline.color = { red: 0, green: 1, blue: 0 };
tline.location = { x: 0, y: 173 + 3, z: 0 }; // start point
tline.endLocation = { x: 5, y: 173 + 3, z: 0 }; // end point (debugline specific)
tline.rotation = { x: 0, y: 173 + 0, z: 0 }; // rotation affects the line
// line.scale doesn't apply to debugline
tline.timeLeft = 60;
// create a yellow sphere with all properties
const sphere = new DebugSphere({ x: -5, y: 173 + 0, z: 0 });
sphere.color = { red: 1, green: 1, blue: 0 };
sphere.location = { x: -5, y: 173 + 0, z: 0 };
sphere.rotation = { x: 0, y: 173 + 0, z: 0 };
sphere.scale = 1.0;
sphere.timeLeft = 60;
// create purple arrow with all properties
const arrow = new DebugArrow(
{ x: 0, y: 173 + 0, z: 5 }, // start
{ x: 0, y: 173 + 3, z: 5 } // end
);
arrow.color = { red: 1, green: 0, blue: 1 };
arrow.location = { x: 0, y: 173 + 0, z: 5 };
arrow.endLocation = { x: 0, y: 173 + 3, z: 5 };
arrow.rotation = { x: 0, y: 173 + 0, z: 0 };
// arrow.scale doesn't apply to debugarrow
arrow.timeLeft = 60;
arrow.headLength = 1.5; // debugarrow specific
arrow.headRadius = 0.7;
arrow.headSegme
nts = 8; // debugarrow specific (default: 4)
// create white text label with all properties
const text = new DebugText(
{ x: 0, y: 173 + 10, z: 0 },
"debug shapes"
);
text.color = { red: 1, green: 1, blue: 1 };
text.location = { x: 0, y: 173 + 10, z: 0 };
text.rotation = { x: 0, y: 173 + 0, z: 0 }; // doesn't affect text (always faces camera)
text.scale = 0.8;
text.timeLeft = 60;
text.text = "debug shapes"; // can be updated
// add all shapes to the debug drawer
debugDrawer.addShape(box);
debugDrawer.addShape(circle);
debugDrawer.addShape(tline);
debugDrawer.addShape(sphere);
debugDrawer.addShape(arrow);
debugDrawer.addShape(text);
// example of removing shapes
mc.system.runTimeout(()=>{
// remove individual shape
box.remove(); // same as debugdrawer.removeshape(box)
// remove all shapes
debugDrawer.removeAll();
}, 200)
this was the code that i tested
import { debugDrawer, DebugBox, DebugCircle, DebugLine, DebugSphere, DebugText, DebugArrow } from '@minecraft/debug-utilities';
import { system } from '@minecraft/server';
// create a red box with all properties
const box = new DebugBox({ x: 0, y: 0, z: 0 });
box.bound = { x: 2, y: 2, z: 2 }; // required for debugbox
box.color = { red: 1, green: 0, blue: 0 };
box.location = { x: 0, y: 0, z: 0 }; // can be updated later
box.rotation = { x: 0, y: 45, z: 0 }; // euler angles
box.scale = 1.5;
box.timeLeft = 60; // will disappear after 60 seconds
debugDrawer.addShape(box);```
try this
i had this
but this doesnt add the shape to the debugDrawer ?
debugDrawer.addShape(box);```
ah, forgor this one
did that work for you?
as i said, I didnt had a chance to try it since i only use stable minecraft
i am just begging mojang at this point to release it
ive already tried that code
none of the shapes appeared
wait
your one is same as mine uhhhhh
i got that from minato
did u get from him aswell
i searched debugDrawer and got that file
xd
I think I did something wrong I’m not sure { "format_version": 2, "header": { "name": "Heart score v1.0.1", "description": "Shows hearts on a scoreboard using Script API", "uuid": "787c31b3-d09b-45fc-8507-6b963b6e793f", "version": [1, 0, 1], "min_engine_version":[1,19,0] }, "modules": [ { "type": "script", "uuid": "899fce17-d325-4d45-a46e-e958ceb72950", "version": [1, 0, 0] }, "entry": "scripts/heartsScore.js" ], "dependencies": [ { "module_name": "@minecraft/server", "version": "1.8.0" } ] }
1.8.0 is real?
are you sure youre not trying to to use 1.18.0?
This error pops up when trying to load the pack ```Unable to parse pack manifest with stack: * Line 16, Column 12
Missing ',' or ']' in array declaration
- Line 10, Column 3
Missing '}' or object member name```
nvm i dont need it anymore
Under what title?
How would I get two vectors that are directly perpendicular from the midpoint between two vector3's
(Figured it out, I just need to get the cross vector of the midpoint's direction vector)
Is there a reason that the sizeWidth & sizeHeight aren't working here? The lifetime var works.
My particle:
{
"..."
"minecraft:particle_lifetime_expression": {
"max_lifetime": "variable.lifetime"
},
"minecraft:particle_appearance_billboard": {
"size": ["variable.sizeWidth", "variable.sizeHeight"],
"facing_camera_mode": "emitter_transform_xy"
},
"..."
}
In script:
molang.setFloat("lifetime", this.lifetimeSeconds);
molang.setFloat("sizeHeight", 0.5);
molang.setFloat("sizeWidth", 0.5);
this.dimension.spawnParticle(particleLocation.particleType, particleLocation.location, molang);
That is not how you set variables afaik, check the docs
Youre missing the v.
I think the error mustve been the captials or something, because this works
"minecraft:particle_lifetime_expression": {
"max_lifetime": "variable.lifetime"
},
"minecraft:particle_appearance_billboard": {
"size": ["variable.width", "variable.height"],
"facing_camera_mode": "emitter_transform_xy"
},
color.setFloat("lifetime", this.lifetimeSeconds);
color.setFloat("width", 0.5);
color.setFloat("height", 0.5);
I'm making a ban system, would it be better to store each ban in the same dynamic property object or use a database
how do you get an item icon path from an item type?
can't
So i have to setup a file to get the icon for all item types
Do people even do that?
or do they have other methods
yeah they do that
Bruh
whats the best way to do that? a bunch of if statements?
Is this the correct formula for random ticks?Math.random() < world.gameRules.randomTickSpeed/4096
Depending on where this is called.
Nearly all video games (including Minecraft) are driven by one big program loop. Just as every gear in a clock is synchronized with the pendulum, every task involved in advancing a game simulation is synchronized with the game loop. Appropriately, one cycle of the game loop is called a tick.
Holy hell this took too long 😩
Player process id 🦅
that is supabase, right?
yeah
#1380481355330355312 can someone help me pls
Is it possible to find the nearest village with a script?
no
Does the custom command must have two parts with : in the middle?
the name o the custom command
yes
bruh that sucks


