#Script API General

1 messages · Page 90 of 1

remote oyster
#

Why would I not be taking into account for the constraints and hardware limitations?

thorn flicker
remote oyster
#

Then you misunderstood what I was speaking about.

thorn flicker
#

Then I guess I did.

round bone
#

I am JS/TS guy and I care about it

steady canopy
#

Most people just code with the goal of the script working even if it's incredibly slow

thorn flicker
#

yeah because they are new

#

they'll learn

steady canopy
#

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

dusky flicker
round bone
dusky flicker
#

an api call can be heavier than it

thorn flicker
#

how about you test it

#

lets settle this

#

lol

round bone
#

using a constant array will be faster than call of Object.values for every time

thorn flicker
#

instead of going back and forth, test it.

remote oyster
# thorn flicker Then I guess I did.

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.

round bone
thorn flicker
#

honestly idc that much

finite totem
#

if i wanted to make a custom trident, do i copy everything from the vanilla trident and just retexture it?

thorn flicker
thorn flicker
#

dont forget about the enchantments.

finite totem
finite totem
thorn flicker
#

?

finite totem
#

is it because its a 3d model when held

thorn flicker
#

the item for it.

finite totem
#

ofc i need to make my own item texture

thorn flicker
#

not the texture.

finite totem
#

?

thorn flicker
#

to make it shoot?

finite totem
#

ah ok

thorn flicker
#

well, throw.

finite totem
#

is there like a premade thingy that someone has made

#

that i can use

#

or do i need to make it from scratch

thorn flicker
#

there's probably a template for a trident yeah.

#

its not that hard though

dusky flicker
#
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
finite totem
#

yay

#

fun

thorn flicker
#

thats easy.

finite totem
thorn flicker
finite totem
#

ctrl+h?

thorn flicker
#

whatever it is for your software.

finite totem
dusky flicker
#

@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

loud frigate
#

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

remote oyster
# dusky flicker <@825930528586727445> can you help me? im thinking in a way of implementing the ...

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.

mighty igloo
#

why is player interact with entity not detecting for all entities

mighty igloo
#

thanks

astral hull
#

One message removed from a suspended account.

tender pier
#

hello, does anyone knows if it's possible to add a tag to a block the same as setblockpermutation works?

open urchin
#

block tags are determined by block permutation

#

you can't control them separately

tender pier
#

oh, wait nmv

dawn zealot
#
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
warm mason
dawn zealot
#

there we go

#

forgot to update it

warm mason
distant tulip
warm mason
#

You can't optimize, max 0.000001 ms

dawn zealot
#

no so, one of them runs every 100 ticks, one runs every 6k ticks, is having multiple of them bad ?

warm mason
warm mason
distant tulip
dawn zealot
warm mason
fallow minnow
#

i think you should implement neutron splitting and certain mathematical algorithms to test each run interval accordingly

distant tulip
#

eh, that depend too
async is not a magic lag fixer

#

runJob might be better

inland merlin
dawn zealot
fallow minnow
#

well for particles

#

i would attatch them to whatever ur doing

#

and then yeah

dawn zealot
#

what

thorn flicker
distant tulip
#

leave particles client side if possible

fallow minnow
dawn zealot
inland merlin
#

Less intervals the better, could make a single interval and based on time past run stuff. This way only one runs.

thorn flicker
distant tulip
fallow minnow
#

something weird

thorn flicker
dawn zealot
#

they need different spawn times 😭

fallow minnow
#

yeah uh

fallow minnow
#

i would attatch those to entities

thorn flicker
fallow minnow
#

as locators

dawn zealot
thorn flicker
fallow minnow
dawn zealot
warm mason
thorn flicker
warm mason
thorn flicker
true isle
#

Yeah i used ticking also it lagged so bad I had to rewrite it

dusty temple
dusky flicker
#

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

dawn zealot
fallow minnow
#

just dont be noob

dusty temple
dusty temple
# dawn zealot 5 reactions and not one of u have told me how to optimize it
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.

remote oyster
#

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.

dusty temple
#

You can cache the dimension

#

I'd actually recommend having a constants file for storing all the dimensions in it

rugged tinsel
rugged tinsel
# dusty temple ```ts interface Particle { particle: string; location: Vector3; } export fu...

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 },
});
remote oyster
#

Batch processing. Even better.

dusty temple
rugged tinsel
#

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

remote oyster
rugged tinsel
dusty temple
rugged tinsel
dusty temple
#

There

#

Wait

rugged tinsel
#

type name is triggering me, but I'm just nitpicking now sunglas

dusty temple
#

Should be good, just looks ugly

#

I'll remove the type since it's unneeded

dawn zealot
#
    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
rugged tinsel
#

yeah, that looks fine, though I'd probably allow passing in a dimension as a parameter to spawnParticles

dawn zealot
rugged tinsel
#

all good then, I always do that anyway since I just like having options

dawn zealot
#

prisons server but ty for helping instead of just putting a skull emoji and not 💀

dusty temple
#

Unless there is something that can support it 🤔

dawn zealot
#

who needs multiple identifiers anyway

rugged tinsel
#

if you're using 1.x.x APIs, might as well do it, if you're using 2.x.x, probably not worth it

dawn zealot
#

im using 2.0.0-beta yeah

rugged tinsel
#

yeah, dealing with early execution there makes it painful

#

could always do the hacky thing and delay your root import until after early execution sunglas

dawn zealot
#

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

rugged tinsel
#

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

remote oyster
#

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.

dawn zealot
#

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
rugged tinsel
#

honestly not horrible, I've seen way worse

remote oyster
# dawn zealot this is another language to me ngl
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 };
dusty temple
#

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

rugged tinsel
rugged tinsel
remote oyster
wary edge
dusty temple
distant tulip
# dawn zealot 5 reactions and not one of u have told me how to optimize it

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

rugged tinsel
remote oyster
dawn zealot
rugged tinsel
#

like a constants.js, or dimensions.js, depending on how you wanna organize

dawn zealot
#

ah okay

remote oyster
#

Organizing makes writing your code way more manageable.

dawn zealot
#

my shi is organnized, but the stuff that requires runinvertal or i just slam it into index/main js file

rugged tinsel
distant tulip
rugged tinsel
#

if I ever see var in a codebase I'm a part of, I'm running away

rugged tinsel
#

yep

dawn zealot
#

bet

dawn zealot
rugged tinsel
#

plz no 😨

dawn zealot
#

😭

#

i could prob find some old files

rugged tinsel
#

couldn't have been as bad as @dusty temple

distant tulip
#

I mean, think about it

rugged tinsel
#

||gotta throw strays||

dusty temple
dusty temple
#

😡

dawn zealot
#

old file btw

distant tulip
#

Yikes

rugged tinsel
dawn zealot
#

omg bruh what was i doing 😭

rugged tinsel
#

fire

distant tulip
#

The first line is not needed, var will work outside it scope

dawn zealot
#

also is there a native method for titleraw, my typings arent working for some reason

dusty temple
distant tulip
#

Actually nvm

dusty temple
#

But hey if it works, it works

dawn zealot
rugged tinsel
#

player.onScreenDisplay.setTitle() player.onScreenDisplay.setActionbar()

#

if you need to set the subtitle, that's part of .setTitle

distant tulip
#

me putting disclaimer in my old code before publishing it to the public

dawn zealot
#

like that right

#

my typings arent showing idk why

rugged tinsel
rugged tinsel
#

I think the rawtext part is optional unless you need an array of things

#

{text:"test"} should work

dawn zealot
#

aight

rugged tinsel
#

even just "test" would work, unless you need translation

rugged tinsel
dawn zealot
#
        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 😭
rugged tinsel
#

holy

#

personally, I'd make each line a new string in an array and then .join them

dawn zealot
#

ive always done it like that, even before scripts were a thing

rugged tinsel
#
const lines = [
  "first line",
  "second line"
];

const finalMessage = lines.join('\n');
dawn zealot
#

👍

rugged tinsel
rugged tinsel
#

I'm so glad I've stopped doing primarily commands

dawn zealot
rugged tinsel
distant tulip
#

lol, idk

dawn zealot
#

😭

rugged tinsel
distant tulip
dawn zealot
#

id always get my friend with his keyboard to pick block them for me

#

so it would save 😭

rugged tinsel
#

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

dawn zealot
#

F

#

im jus making a prisons rn cuz theres not a single good one on bedrock

rugged tinsel
#

cuz it's not popular anymore

#

there was a couple good ones that were killed because they weren't popular enough

dawn zealot
#

it is in the realm com

rugged tinsel
#

I must be too out of the loop now then

dawn zealot
#

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

dawn zealot
#

also quick question, do tags have a string char limit

rugged tinsel
#

I've never seen you on an xbox grrr

rugged tinsel
dawn zealot
rugged tinsel
#

what were you going to use it for?

dawn zealot
#

uhh..

#

prepare ur eyes

rugged tinsel
#

if it's data-storage, use dynamic properties plz

dawn zealot
#

i hate using dynamic properties

rugged tinsel
#

why 😭

#

they're so good

dawn zealot
#

shits so annoying when moving packs

valid ice
#

Tags are so 2020 🥱

dawn zealot
#

just resets

rugged tinsel
dawn zealot
#

especially for realms, for realms u need to change ur uuids

#

to update the pack

rugged tinsel
#

I thought they fixed it??

dawn zealot
#

?

#

every way ive tried never works, changing version in manifest doesnt work literally nothing

rugged tinsel
#

huh, strange

#

I mean even MP packs have issues updating on realms

#

realms are just cooked

dawn zealot
#

thats my curent lb system

valid ice
#

bds goaded

#

fr

#

"but what about console?"

transferPlayers server-admin func echsplode

rugged tinsel
#

was about to say that

dawn zealot
#

after a month of realm tests

rugged tinsel
# dawn zealot
const floatingTexts = [...dimension.getEntities({
        type: "osuea:floating_text",
        tags: ["lb_blocksMined"]
    })];

wha

#

why

dawn zealot
#

?

rugged tinsel
#

why are you spreading into a new array?

dawn zealot
#

oh yeah did i mention i had AI do that for me cuz i was sick and cba

valid ice
#

hasn't returned an iterator for... a long time

dawn zealot
#

💀

rugged tinsel
#

what was that AI on 😭

rugged tinsel
dawn zealot
#

chat gpt is good but only for like repeating or doing math

#

like what was it 2sc

rugged tinsel
#

it's tricked me up several times with its confidence

dawn zealot
#
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
dusty temple
#

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);
  }
});
rugged tinsel
#

not having my vscode theme in discord makes reading these so hard

distant tulip
#

playSounds is a thing?

dawn zealot
#

theres themes?

dawn zealot
dusty temple
rugged tinsel
dusty temple
#
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);
    }
}
dawn zealot
rugged tinsel
#

extensions

distant tulip
dawn zealot
distant tulip
#

alr

rugged tinsel
#

my extension recommendations

rugged tinsel
wary edge
rugged tinsel
#

it comes in handy sometimes

#

I have no other way to do it

distant tulip
wary edge
rugged tinsel
#

I have not bothered to get or look into powertoys, just figured it wouldn't have anything I'd need

dawn zealot
rugged tinsel
#

I use this one with a custom binding, since vscode lets you do that

scarlet sable
#

how do I save a dynamic property that contains an object?

dusty temple
#

Keep in mind it doesn't work with functions and some other types

scarlet sable
#

ty

inland merlin
#

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

valid ice
#

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.

inland merlin
# valid ice That is correct

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

valid ice
#

uhhhh don't think that's possible

inland merlin
#

teleporting them away and replacing the table

#

and teleporting back

#

funky but might work lol

valid ice
#

In terms of hacky workarounds, it could be worse 😛

inland merlin
#

truth lol

inland merlin
#

hacky way again

#

is what i need lol

valid ice
#

Not sure about that one

inland merlin
#

so idk

#

nvm, im just gonna have them claim a quest by checking their inventory and checking if they have the items.

distant tulip
inland merlin
#

Or will this trick it to close vanilla forms

distant tulip
#

that just to check if the user is in a gui

fallow minnow
#

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

inland merlin
#

That is genius

fallow minnow
#

i have this so far

#

so now i guess i should cache the data?

round bone
fallow minnow
round bone
#

oh, nice

dim tusk
#

Hello again.

round bone
distant tulip
dusty temple
#

Any good Vector libraries for v2?

wary edge
dusty temple
#

ty

shy leaf
#

i kinda forgot if entityHitEntity fires after the attack damage

tender pier
#

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

fallow minnow
#

i saw that

halcyon phoenix
#

wrong topic lol

fallow minnow
#

😈

#

#REPORTED

fallow minnow
#

any suggestions to make this quicker or just better overall

#

its not slow but

#

what can i change

halcyon phoenix
tender pier
halcyon phoenix
#
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

halcyon phoenix
round bone
prisma shard
#
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

valid ice
#

It returns block before entity, is that what you're experiencing?

#

So if both are valid, it will only return block

prisma shard
#

I think so

#

i am so confused

prisma shard
cinder shadow
#

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.

prisma shard
#

"because you have to use system.run to use await." ??

cinder shadow
#

With custom commands, yes

valid ice
prisma shard
#

could be ""because you have to use system.run **or ** use await."

valid ice
#

dunno what you're really after in the end'

prisma shard
#

guys i made this
am i pro

cinder shadow
#

ModalForm requires await, custom commands run in before and cannot run await

vast grove
prisma shard
cinder shadow
vast grove
#

Hmm well IG that's expected.

cinder shadow
#

Yeah, it's just really crumby and I'm hoping there's a workaround

vast grove
#

I don't think you can hang a command over several ticks

cinder shadow
#

Why does it have to be output into chat and not console log 😔

#

It still runs

#

It's basically a warning

vast grove
#

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>

cinder shadow
valid ice
halcyon phoenix
#

can you store dynamic properties on blocks?

vast grove
#

No

halcyon phoenix
#

im trying to store data on blocks

#

what's one way to do it?

vast grove
#

What kind of data?

halcyon phoenix
#

I have a block that store power

#

should I just add Id to it's location and just set world dynamic property?

vast grove
#

Add it as a property on the block

#

Then set it via setPermutation()

bold stratus
#

I want ask.. can .js export .txt file for database?

#

or any file

remote oyster
#

If BDS, yes, but if Realms, then no (use Dynamic Properties in this situation).

bold stratus
halcyon phoenix
scarlet sable
#

Are custom commands in-game yet?

shy leaf
halcyon phoenix
#

what can you do with custom commands?

distant tulip
#

you can add custom commands to the game, can you imagine?!

sly valve
halcyon phoenix
#

Lol

#

also is there any way to get the id of every block in the game?

distant tulip
halcyon phoenix
cinder shadow
#

well actually, it's worse, because the form doesn't even open

wintry bane
#

Is it possible to detect when the player eats something without custom components? Like when someone finishes eating an apple or a sweet berry.

warm mason
gaunt salmonBOT
#

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

cinder shadow
# warm mason Can you tell me what the problem is?

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.

cinder shadow
#
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

somber cedar
#

Show how you register the comamnd

#

Oh wait

#

the function is async so it doesn't work

warm mason
#

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`);
            }
        }
    })
}
cinder shadow
distant tulip
#

what...

cinder shadow
#

I swear I tried this last night

warm mason
cinder shadow
#

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

distant tulip
#

await work only in async

cinder shadow
#

system.run is the async

warm mason
distant tulip
#

ah

#

yeah

#

mb

warm mason
cinder shadow
#

Damn, so I still had the error because the function itself was an async

#

thanks

somber cedar
#

TypeScript would have told you that

cinder shadow
#

I don't care what TypeScript would have said to me

somber cedar
distant tulip
#

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

cinder shadow
#

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

somber cedar
#

The first one????

cinder shadow
#

It's honestly worse, because the first "error" isn't an error

distant tulip
#

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

distant tulip
cinder shadow
#

Just another typescript L stay losing bao_ext_toldyouso

somber cedar
#

VSCode and bridge uses typescript, without it you probably coding this in notepad

prisma shard
#

what

#

it depends on file extension

#

.js -> JS

#

.ts -> TS

#

not depend on coding software

#

VScode both supports TS and JS including all languages

somber cedar
#

I mean the code editor's source code is TypeScript

distant tulip
#

one thing for sure, it is not running using it

fallow minnow
#

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

round bone
pallid portal
#

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.

amber granite
#

But it s encoded._.

pallid portal
#

encoded, encrypted, or given funny names for its components.
It has an error that the game supposedly does not like.

amber granite
#

And ... How supposed we work on it ?

#

U need to remake it i guess

cinder shadow
#

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

distant tulip
#

the whole script is one line and obfuscated, so there is no point

cinder shadow
#

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

prisma shard
#

huh lmao what

warm mason
dusty temple
amber granite
#

I m writing code because it s fun :-:

round bone
#

you're associated with TypeScript!

leaden glade
#

am i tripping or did a bunch of messages just disappear?

wintry bane
#

mods hi

amber granite
#

Load more

dusty temple
#

Hey where did my 15 messages of Typescript glaze go

warm mason
leaden glade
#

1984

wintry bane
#

When's entity.target getting out of beta again?

round bone
#

did someone just removed a glaze of the best language ever?

wintry bane
#

It's literally what carries my addon

prisma shard
#

Uh

wintry bane
amber granite
#

According to chat gpt best language ever is python then c++

dusty temple
#
export type ts = Omit<APIGeneral, "Typescript">
amber granite
#

Then js

prisma shard
#

You use Microsoft Windows 10 to make scripts in Microsoft VSCode for Microsoft Minecraft Bedrock using Microsoft TypeScript

amber granite
#

Yes

warm mason
#

BRUHHHHHHHHH

wintry bane
prisma shard
#

python === garbage 🗑️

warm mason
#

the slowest

amber granite
#

C++ is better :-:

dusty temple
#

Performance-wise

wintry bane
#

literally coughing baby vs hydrogen bomb

amber granite
#

Until you discover something called pointers and memory leaks

wintry bane
#

Ima just shit my pants when pointers are talked about

warm mason
prisma shard
#

rust after c++?

round bone
#

bring the glaze back!!

wintry bane
#

beforeChat why did it never leave beta???????

round bone
amber granite
#

Just discovering that u need 5 lines of code to make it print hello world in cout , you will get sick ☠️

prisma shard
amber granite
amber granite
round bone
#
#include <iostream>
int main() { std::cout << "hello, world" << std::endl; return 0; };
#

just kidding

wintry bane
#

one line of code like some genius who obfuscated it bao_ext_toldyouso

round bone
#
#include iostream>
int main() { 
    std::cout << "hello, world" << std::endl;
}
amber granite
#

Return 0;

round bone
#

you don't have to add return 0 in newer compilers

amber granite
#

Oh

wintry bane
#

C++ for script API when

prisma shard
#

noooooo

#

not me having to use that after learning js

wintry bane
#

esolang for script API when

amber granite
#

Bro u think js learning is something ☠️

prisma shard
#

LUA for script api when 💀

round bone
#

learn TypeScript at first

wintry bane
warm mason
wintry bane
#

fuck it C# it is

dusty temple
prisma shard
round bone
#

restrict scripting API to TypeScript only!

wintry bane
#

not my type

shoo shoo

amber granite
#

I heard someone said lua ☠️

prisma shard
#

That's me

wintry bane
prisma shard
#

Ts users be like

wintry bane
#

____ is undefined ass code

dusty temple
#

then you fix it and everything is jolly again

prisma shard
#

not me typing as Array, as String blah blah if i even get forced to use ts

amber granite
#

So

#

What s new in the api ?

fallow minnow
#

typesdcript so much better than js

wary edge
amber granite
#

9 months

fallow minnow
wary edge
fallow minnow
#

currently they require namespaces but soon they wont

wary edge
fallow minnow
#

well yes but they wont be required to be shown when using them

round bone
#

let's glaze TypeScript together

fallow minnow
#

people that dont like it just dont know how to use it

distant tulip
#

uh, i do
just too slow with it

fallow minnow
#

BACK ME UP THEY ARE COMING @round bone

distant tulip
#

lol

prisma shard
#

diff ppl has diff choices

fallow minnow
prisma shard
round bone
#

😎

fallow minnow
#

i guess when u just learn the types its really not that hard

#

some stuff gets confusing though tbf

prisma shard
#

Yeaghh

#

spam JS spread love

#

shit I gotta charge my phone uh oh 1%

round bone
fast lark
#

Do realms have ips?

fallow minnow
#

yes

fast lark
fallow minnow
#

idk if they allow direct connection to iips

#

i highly doubt it

fast lark
#

So i can test my theory

fallow minnow
#

uhh just use a certain client

#

and do .ip

#

or i wonder if u could get it with wireshark

fast lark
#

Thx

#

Ill try later

nova wraith
#

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

wary edge
nova wraith
#

Idk how to

nova wraith
amber granite
fallow minnow
#

im not

solar dagger
steady canopy
#

You can try to fix the error now 👍🏼

dusky flicker
valid ice
#

Anyone know the filepath and name for BDS server secrets and BDS server variables?

fallow minnow
#

and then secrets.json

valid ice
#

ty ty

fallow minnow
#

but i couldnt get secrets to work so

valid ice
#

oh

fallow minnow
#

variables are fine though

#

no one can get them

valid ice
#

secrets are cool tho

halcyon phoenix
#

this just beyond gatekeeping

stark sun
#

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?

amber granite
#

:-:

#

You can make a block :-: save it s location

#

After some amount of time

#

Replace it with air

#

Spawn an entity

stark sun
#

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.

deep quiver
halcyon phoenix
#

you should've used that time to learn the basics

distant tulip
distant tulip
#

just decrease your interval..?

shy leaf
nova wraith
#

I dont know how to :/

nova wraith
#

It uses timeout

#

Idk about systenRun yet

#

Oh wait I messed it up

shy leaf
#
const tick = system.currentTick;
if (player.__cooldown > tick) return;
player.__cooldown = tick + 20;

this is just a simple code of cooldown

nova wraith
#

This is inside system.runTimeout

#

💀

shy leaf
#

for anything cooldown related, i recommend using stuff like that

#

instead of runTimeout or interval

nova wraith
dusty temple
#

It's always good to learn the language your using before using api's involved with it

nova wraith
dusty temple
#

Don't use system.runTimeout

nova wraith
#

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

dusty temple
#

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

nova wraith
#

Actually, I want the cooldown to reset when i leave the world

dusty temple
#

But if you want to use other methods that's fine, it is a learning experience after all

nova wraith
nova wraith
#

Could you analyze it?

shy leaf
#

(i think) __ part is for making sure that you dont confuse it as a property from API

halcyon phoenix
#

thanks I just reasearched it and it's somehow called name mangling what a weird way to call it

shy leaf
#

i think temporary property is a better way to call it lol

shy leaf
#

also put player.__cooldown = tick + 100 in the if check, since you want to refresh cooldown only when you sneak

nova wraith
shy leaf
dawn zealot
#

first time making an auction house works for all that offline stuff too:)

halcyon phoenix
#

what did I do wrong?

dusty temple
#

and code its referenced in

halcyon phoenix
#

oh wait I forgot to import files

#

no errors now I just forgot to import the files

halcyon phoenix
#

setlore was triggered but it doesn't show on the item

#

do you need some components?

shy leaf
#

i forgot

vast grove
#

Yes. You need to set the item once you set the lore

halcyon phoenix
#

oh yeah

halcyon phoenix
#

is it possible to setitem without needing the slot?

#

welp looks like that's impossible

halcyon phoenix
#

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

sage portal
#

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")) {}
})
stark kestrel
warm drum
#

.

nova wraith
# shy leaf inside the `if` check, the one you posted there


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...

sharp elbow
halcyon phoenix
#
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?

sage portal
sharp elbow
#

Ah, I didn't even see that. Then realistically the condition shouldn't make a difference

sage portal
#

it's my if (true) {} problem all over again

thorn flicker
halcyon phoenix
#

I just discovered that it runs every interact/ holding interaction

#

thanks voidcell

leaden glade
#

is Date the only way to get a timestamp?

#

there isnt anything more precise right?

sharp elbow
#

Not to my knowledge. Do you need more than millisecond precision?

thorn flicker
nova wraith
amber granite
#

@nova wraith

#

Does it work one time ?

nova wraith
#

Didn't worked at all

amber granite
#

:-:

#

Add while loop

#

While ( true ) {};

shy leaf
#

what

#

WHY.

#

why would you add while loop

nova wraith
amber granite
halcyon phoenix
#

it will not run at all because it is not being called

nova wraith
amber granite
#

Wait a minute

#

It s full of errors

#

Where did u find fhe player object

#

Do that

nova wraith
amber granite
#

for ( const player of world.getAllPlayers()) {
//Put code here
}

nova wraith
#

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?

amber granite
#

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

nova wraith
#

I'm gonna test it

amber granite
#

Wait

#

@nova wraith

#

getPl ?

nova wraith
prisma shard
gilded shadow
#

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.

stark kestrel
night acorn
#

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

wary edge
night acorn
#

damn

wheat condor
night acorn
prisma shard
uncut lynx
uncut lynx
#

like up/down/north/south/east/west

prisma shard
#

idk

wheat condor
#
const owner = world.getDynamicProperty(JSON.stringify(block.location))
prisma shard
#

why you want owner

#

you want the block itself

wheat condor
#

why do you want the block

night acorn
prisma shard
wheat condor
#

if you checking who is linked to this block you need to get the owner not the block

uncut lynx
wheat condor
#

and its also wrong couse never set a dynamic property as player.name

prisma shard
#

hmmm i must have messsed up the parameter argument order

#

lol srry

wheat condor
prisma shard
#

hmmm k

#

idk why u saving the owner

wheat condor
#

if you want to get the blocks from the owner: world.getAllDynamicProperties().filter(([k,v]) => v == player.name)

wintry bane
#

Is it possible to send data to another add-on? Like getting an array from another add-on.

uncut lynx
wheat condor
uncut lynx
#

thanks

prisma shard
#

idk why ppl do new Vector(x,y,z) using external class

#

{x, y, z } is the same

#

since mojang made it as interface

uncut lynx
#

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

prisma shard
#

wdym tie entity to block

#

leash? it has methods for that

uncut lynx
#

nop i meant tie so block tied to entity knows which entity is his etc

wary edge
#

Like bees/beehive and creaking/creaking heart

pale terrace
#

its possible to detect and replace items in a crafting table?

distant tulip
#

no

uncut lynx
#

like i wanna rotate an entity beside the normal left/right

amber granite
#

Yes cheese

amber granite
#

Cheeese gromit cheeese

prisma shard
#

what

amber granite
#

Cheese

round bone
uncut lynx
round bone
#

are you sure that you're providing correct params to a method?

steady canopy
#

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

gilded shadow
#

do i need to set location and endLocation after creating the object?

steady canopy
gilded shadow
#

no need to change its location

leaden glade
wintry bane
#

What happens when multiple scripts from different add-ons ran the same scriptevent command at the same time asynchronously?

distant tulip
wintry bane
#

Which one runs first, the add-on on top?

distant tulip
#

no idea
try and see

steady canopy
dawn zealot
#

do dynamic props have a char limit

fallow minnow
#
  • the name
tender pier
#

how can I detect a block? like knowing if there's lava 2 blocks under my custom block

halcyon phoenix
halcyon phoenix
#

here @tender pier

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

dusky flicker
gilded shadow
#

i cant debug my code cuz this is just not working

#

No errors or anything.

#

is there a toggle or something ?

tender pier
#

how can I use setequipment thing?

round bone
little hull
#
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?

gilded shadow
remote oyster
gilded shadow
#

is there any orher way to make lines?

vast grove
#

Debug drawing is still beta... Also what does this.pos1 contain? Did you test the variable?

prisma shard
#

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 😭

halcyon phoenix
#

how do I
unintalicized and unpink lores and remove th Has Custom Priperties text?

round bone
#

/gamerule showtags false

halcyon phoenix
halcyon phoenix
halcyon phoenix
#

thanks

round bone
wheat condor
#

can someone help me? #1380166157981585418

proper perch
#

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].

prisma shard
proper perch
#
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" } ] }

wintry bane
#

onRedstonePowered block custom component when?

warm mason
gilded shadow
gilded shadow
prisma shard
gilded shadow
#
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

prisma shard
#
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

gilded shadow
prisma shard
#

ah, forgor this one

gilded shadow
#

did that work for you?

prisma shard
#

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

gilded shadow
#

none of the shapes appeared

prisma shard
#

wait

#

your one is same as mine uhhhhh

#

i got that from minato

#

did u get from him aswell

gilded shadow
prisma shard
#

xd

distant tulip
proper perch
# warm mason you need to specify the main file. like this:

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" } ] }

gilded shadow
#

are you sure youre not trying to to use 1.18.0?

proper perch
#

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```
leaden glade
scarlet sable
dusty temple
#

How would I get two vectors that are directly perpendicular from the midpoint between two vector3's

dusty temple
dense skiff
#

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);
distant tulip
dense skiff
#

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);
sterile epoch
#

I'm making a ban system, would it be better to store each ban in the same dynamic property object or use a database

mighty igloo
#

how do you get an item icon path from an item type?

mighty igloo
#

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

steady canopy
mighty igloo
#

Bruh

mighty igloo
#

whats the best way to do that? a bunch of if statements?

floral vessel
#

Is this the correct formula for random ticks?Math.random() < world.gameRules.randomTickSpeed/4096

wary edge
#
Minecraft Wiki

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.

valid ice
#

Holy hell this took too long 😩

deep quiver
distant tulip
round bone
uncut topaz
#

#1380481355330355312 can someone help me pls

plucky light
#

Is it possible to find the nearest village with a script?

distant tulip
#

no

scarlet sable
#

Does the custom command must have two parts with : in the middle?

scarlet sable
#

the name o the custom command

woven loom
#

yes

scarlet sable
#

bruh that sucks

woven loom
#

However, they allowed us to use it directly with the second part in-game.

#

And if that key is already in use by any means, you must use the full namepace.