#Script API General

1 messages ยท Page 93 of 1

vast grove
#

.... Do you have node installed?

abstract cave
#

no

#

how do i install it

vast grove
#

Look it up

shut citrus
#

When does vibrant visual come to java edition?

vast grove
#

This is a bedrock server. You're better off asking in a java server

abstract cave
#

i installed it

vast grove
#

Now just npm i the packages as per the guides on the official docs

#

VS will pick up on the auto completions iirc. Although idk since I never really used VSC for mc scripting

abstract cave
#

i dont think there is a guide for installing it

#

๐Ÿ˜ญ

vast grove
#

Did ya restart the terminal?

cinder shadow
#

0.8 * 3 ๐Ÿ˜”

#

weird that I haven't run into this issue before

#

Now that I think about it, I don't use decimal calculations for anything, maybe this is why

granite cape
#

cool, customCommand has alias without namespace now

shy leaf
#

not really an issue but its doesnt look clean hmmm

granite cape
#

yea

glacial widget
#

Is anyone else getting the problem of where you cant jump and you float while walking. this new update?

prisma shard
granite cape
prisma shard
#

Wohooo

#

Yay

#

also I didn't even notice 2.1.0-beta released ๐Ÿ˜ญ

#

Just saw it

#

A lot of changes

#

...

#

Eh what?

#

shouldn't that be 2.1.0-beta

#

Or 2.2.0-beta already released bruh

granite cape
#

2.1.0-beta

granite cape
glacial widget
abstract cave
#

How do i use world initalize in 2.0.0
Ik it got replaced with world load, but idk how to register my custom components with it

prisma shard
#

well Mojang added lookAt function in the new API update ๐Ÿ‘€

gaunt salmonBOT
wheat condor
#

So 2.1.0 related yesterday?

#

I need to update all my addons

gaunt salmonBOT
sly valve
#

I do, just dm me

shy leaf
#

this update is fire

#

especially hunger component

#

its a blessing ๐Ÿ˜ญ

halcyon phoenix
#
const point1 = {x:-0.5, z:1.5}
const point2 {x:-1.5, z:0.5}

const dx = point2.x - point1.x
const dz = point2.z - point1.z
const angle = Math.atan2(dz, dx)
console.warn(angle)

can somebody run this in their scipt real quick?

mine gets a result of 2.819842099193151 which is not the correct answer I do not know why is gives that and I need verification, Thanksin advance.

#

Math.atan2() is acting weird

woven loom
#

-2.356194490192345

halcyon phoenix
#

now my entire math is broken

#

watdahek

#

WHAT

#

WAT IS HAPPENING TO MY MATH

#

THIS WAS THE ISSUE ALL ALONG

#

WHY IS THIS ALLOWED

#

WHAT THE HECK

woven loom
#

uff

inland merlin
#

Got a feeling we gonna have a good amount of bug fixes for the next 6 months

abstract cave
#

Is there a way to detect if the player has operator permissions

sharp elbow
dawn zealot
#

does transferPlayer still work on realms?

halcyon phoenix
sharp elbow
#

The same kinds of things it is used for in math. e.g. a simple negation function could be (x) => -x

halcyon phoenix
#

oh I see, I know a lot of maths but I never heard about this

granite cape
#

bruh, why i use type playerSelector but have options @e?

distant tulip
wheat condor
lyric kestrel
#

At what point should I use TS?

drifting ravenBOT
#
Please, no screenshots or photos!

Screenshots are hard to read, and photos even more so. This is especially true if you are using bridge or another tree editor, as this format obscures the JSON format.

We can help you best if you copy and paste your code here, or send it directly as a file.

granite cape
#

The point is, why does CustomCommandParamType.playerSelector produce selectors like @a @e @r?, this shouldn't exist.

remote oyster
#

Only here, it may be handled internally and based on the selector type you choose for the parameter in question.

#

I'm guessing to be honest.

#

๐Ÿ˜…

cyan basin
#

I doubt that they'd modify it just to remove the entities from it

charred pawn
#

What would be the new method for making custom components in 2.0.0?

fast wind
#

How can I get the Vector3 of the center of the face of a block I'm looking at?

#

Or actually just the point I'm looking at

thorn ocean
#

Can someone take a look at my block file for a sec. Just used custom components V2, but now it displays as an missing block in the world, while the other blocks that use custom components V2 do work. ``````

round bone
#

it's automatic

fast wind
#

Thanks

full idol
#

Thank you!

untold magnet
gaunt salmonBOT
untold magnet
untold magnet
#

hold on
Player.applyImpulse is now working?!

grand needle
#

How to put equipment on armor stand with script?

untold magnet
thorn flicker
untold magnet
#

holy

shy leaf
#

or are you just doing the ui part

halcyon phoenix
halcyon phoenix
tardy pivot
#

beforeEvents.playerPlaceBlock is still in beta right?

vast rune
#

I need to rotate multiple entities if they are above something, how can I store multiple entities in an array so that they all can have this rotation behavior

#

also, if there are multiple of those entities that are in the array, only rotate the ones on that block

#

do i just use getEntities() with my array of entities typeIds?

ivory bough
#

Did isOp get removed?

vast grove
#

Yes

#

Use permission level

halcyon phoenix
vast rune
#

just create a for loop and loop through each entity and check?

#

loop for all entities in the world or array?

vast grove
#
const entities = dimension.getEntities();
entities.forEach(...
halcyon phoenix
#

yep, can't be more optimized than that

vast grove
#

Should use a normal for loop but I can't be bothered remembering what keyword is needed

halcyon phoenix
#

today I learned that you can assign a forEach in a variable

#

Oh wait

#

lol

#

I mislooked it

shy leaf
halcyon phoenix
#

hi Seawhite

shy leaf
#

hello

vast grove
#

Yeah that. Having a C# brain makes me think of in not of

vast rune
#

wait, can you use getEntities on an array?

#

last i checked it didnt seem possible

vast grove
#

What?

#

getEntities() returns an array

#

The hell do you think it returns

vast rune
#

oh wait wtf was i saying sry

halcyon phoenix
ivory bough
vast grove
#

Buddy. Look at the changelog

untold magnet
shy leaf
#

are you porting the UI part only

untold magnet
vast grove
untold magnet
untold magnet
#

everything possible*

shy leaf
#

applyImpulse directly sets velocity, and client doesnt like a sudden change in velocity

#

which results in rubberbanding

untold magnet
#

anyways,

halcyon phoenix
shy leaf
#

knockbacks are handled clientside so the client expects it and doesnt cause rubberbands

#

for now its better to stick to applyKnockback

untold magnet
#

sure ig

shy leaf
#

did you mean everything from appleskin mod or

halcyon phoenix
untold magnet
shy leaf
#

oh

untold magnet
#

the only issue is, im not sure how am i going to make it fully functional and compatible with my other addons at the same time

shy leaf
#

yeah appleskin is on 'Unlicense' license

#

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

untold magnet
#

btw,

shy leaf
untold magnet
#

is it possible to calculate how much health u will heal by getting the players saturation?

shy leaf
#

appleskin did that

#

you should check its source code ig

untold magnet
shy leaf
#

line 303 looks like the one youd be interested in

marsh pebble
#
  if (data.id === "plot:buy") {
        if (isProcessingPlotBuy) {
            player.sendMessage("Please wait, another plot purchase is being processed.");
            data.cancel();
            return;
        }
           if (player.hasTag('plot_owner')) {
            player.sendMessage("You already own a plot.");
            data.cancel();
            return;
        }

        isProcessingPlotBuy = true;

        try {
            let plotCount = world.getDynamicProperty("plotCount");
            if (plotCount === undefined || typeof plotCount !== "number") {
                plotCount = 0;
            }

            plotCount++;
            world.setDynamicProperty("plotCount", plotCount);

            player.setDynamicProperty("plotNumber", plotCount);

            // Register ownership
            const ownerRegistry = getOwnerRegistry();
            ownerRegistry[player.name] = plotCount;
            setOwnerRegistry(ownerRegistry);

            const row = Math.floor((plotCount - 1) / 100);
            const column = (plotCount - 1) % 100;
            const x = 1000 + column * 64;
            const z = row * -64;
            const y = 1;

            world.getDimension("overworld").runCommandAsync(
                `structure load plot ${x} ${y} ${z}`
            ).catch(error => {
                player.sendMessage(`Error loading structure: ${error.message}`);
            });

            player.sendMessage(`You have purchased plot ${plotCount}`);
            player.runCommand(`tag @s add plot_owner`);
        } catch (error) {
            player.sendMessage("An error occurred while processing your plot purchase.");
            console.error("Plot purchase error:", error);
        } finally {
            isProcessingPlotBuy = false;
        }
    }

How do i limit how many plots a person can buy

        if (player.hasTag('plot_owner')) {
            player.sendMessage("You already own a plot.");
            data.cancel();
            return;
        }
untold magnet
#

and i dont think it is possible to make the health part if u have more than 10 hearts

ivory bough
shy leaf
untold magnet
marsh pebble
#

HELP

#

SOMEBODY GEOL) NE

#

HELP

untold magnet
#

I'll just stick with the saturation parts, which is the most interesting part of the entire addon

shy leaf
untold magnet
shy leaf
#

dude

#

can you like

marsh pebble
#

?

shy leaf
#

not

marsh pebble
#

HELP

shy leaf
#

repost the whole code

#

3 times

marsh pebble
#

ill just make a post and wait 9 hours

untold magnet
#

and im not sure how am i going to render that food saturation thing

shy leaf
#

ig thats better

untold magnet
#

like should i use titles for it or chatmessages idk

shy leaf
#

definitely not chat messages

#

cuz yk

marsh pebble
#

HELPPP

untold magnet
marsh pebble
#

wait

halcyon phoenix
#

did you just yoink that code from someone else?

marsh pebble
#

payed someone 50$ for it

shy leaf
#

The fuck

#

$50???

#

WHAT?

marsh pebble
#

that's not the full code

#

just the buy part

shy leaf
#

oh my god

#

dude

marsh pebble
#

what?

shy leaf
#

wh

#

you paid $50 for that...

untold magnet
marsh pebble
halcyon phoenix
#

that's a scam

marsh pebble
#

@sullen ocean Already told me it was a scam

#

im informed

shy leaf
#

im starting to question if the majority of people here can make good financial decisions atp

marsh pebble
#

but i dont got anymore $ rn so i cant pay someone else to make a new one

halcyon phoenix
#

I can make that for $10 in 3 days

shy leaf
#

why the

#

dude why would you pay for THAT

halcyon phoenix
#

dang....

marsh pebble
untold magnet
halcyon phoenix
marsh pebble
#

?

shy leaf
halcyon phoenix
#

a little bit of ai and a little bit of concept

#

that's just free

marsh pebble
#

oh

#

anyone here willing to fix the addon for 3$?

halcyon phoenix
#

you got hard scammed

#

Lol

shy leaf
halcyon phoenix
#

Wth

#

WTH

#

youre creating an amalgamation of code and a waste of money

#

man, save your self some money

untold magnet
#

or just learn how to code for free

shy leaf
#

50 bucks is like a month worth of revenue i get from curseforge

#

someone got that in 3 hours

#

this is so wrong wtf ๐Ÿ˜ญ

marsh pebble
halcyon phoenix
#

force it yourself

#

no pain no gain

marsh pebble
#

it was already hard enough to learn css and html even tho they arent coding languages

shy leaf
#

8 months is how much it took for me to make my second addon

#

actually

#

its LESS

#

it took 8 months to learn

marsh pebble
#

anyone willing to teach a dumbo like me?

shy leaf
#

less than a month to make

#

The fuck

#

JESUS

halcyon phoenix
#

yeah made my almgamation of mc function and script api in 3 months then stopped and came back for more

halcyon phoenix
shy leaf
#

yeah like

halcyon phoenix
#

people can't just give you a lesson

marsh pebble
shy leaf
#

google for javascript tutorials

#

thats your bet.

untold magnet
halcyon phoenix
#

you gotta have something to build

marsh pebble
halcyon phoenix
#

having something you want gives you some motivation

#

so that you can get that sense of achievement

shy leaf
#

accomplishment and passion is how you get better in minecraft scripting

#

imo

halcyon phoenix
#

it's fine to have mistakes, it's what teaches you to learn man so go start something and fail then solve it and fail again and solve it again

#

cause that's how you learn

untold magnet
# shy leaf imo

btw, connecting a new image to the hunger bar can be done by adding controls inside the bar, right?

shy leaf
#

hold on

untold magnet
#

but wait, that will make the images render above the bar not under it

#

and the exhaustion bar needs to be rendered under the hunger bar

#

so i need to render them separately from the hunger bar

shy leaf
#

you can adjust layer on childrens

untold magnet
shy leaf
#
{
  "bar_bg": {
    "type": "image",
    "texture": "textures/cooldown_crosshair_empty",
    "alpha": 0.5,
    "layer": -1
  }
}
#

smth like that but this is json ui talk now and we are in #1067535608660107284 so

marsh pebble
shy leaf
#

not that kind of children

#

๐Ÿ˜ญ

marsh pebble
#

oh.

untold magnet
halcyon phoenix
marsh pebble
halcyon phoenix
shy leaf
untold magnet
#

ya i see,

shy leaf
untold magnet
#

i think

shy leaf
#

(and no sane person likes json ui)

halcyon phoenix
#

when will we have script based UI

untold magnet
#

on the first addon release, i won't add the food saturation stuff to it

vast grove
untold magnet
#

its just too complicated to code tbh

shy leaf
#

idk if it had any effect

vast grove
#

Docs are weird...

untold magnet
#

like i can just make it another progress bar, but making it animated in the good way is quite hard

shy leaf
#

well minecraft is weird tbh

ivory bough
vast grove
#

Anyways. You can just use commands

shy leaf
untold magnet
ivory bough
shy leaf
untold magnet
#

if i send those titles like in different ticks, it will not have any issues

ivory bough
untold magnet
shy leaf
#

i guess?

untold magnet
#

so the second title will sent after the first one is sent

vast grove
#

Well then. Don't change permission levels. As seawhite said, any add-on that sets a player's permission level isn't exactly safe.

untold magnet
#

not at the same exact tick

marsh pebble
#

seriously

#

can one of u command people intergrate is 3 line piece of code into my plot addon

#

i cant launch my server without this

untold magnet
untold magnet
ivory bough
marsh pebble
#

I NEED THIS SERVER RELEASED BY THIS HOUR OR IM PROB GONNA GET DEMOTED

#

PLEASE

vast grove
#

....

untold magnet
#

well, in that case, pay @shy leaf to fix the code or the entire addon for u
-# he will definitely do that if u pay him enough lol

vast grove
#

Gimme 10k coronalol

marsh pebble
#

bro

marsh pebble
#

i've seen u before

#

arent u godsunit friend

vast grove
#

Maybe. Used to. Never spoke to each other in years

halcyon phoenix
#

pick one @marsh pebble bao_mob_t_fox

marsh pebble
#

um

#

wait

untold magnet
marsh pebble
#

ik something

shy leaf
#

-# no

marsh pebble
#

I can give him a hug

halcyon phoenix
untold magnet
vast grove
#

A billion

untold magnet
shy leaf
#

a billion, thats something i can consider

#

great financial choices

marsh pebble
#

hm

#

How about

#

1$?

vast grove
#

$int.MaxValue

marsh pebble
#

my_heart @shy leaf can u fix

shy leaf
#

dawg

marsh pebble
vast grove
#

I looked at your code. Your problem is using tags

#

That's it

halcyon phoenix
#
const payAmount = `$` + Math.pow(pay.maxValue, 2)
shy leaf
#

on a serious note if the server youre working on has only you as a programmer/tech engineer but not anyone else

marsh pebble
shy leaf
#

while having the tightest deadline you can ever have from society

marsh pebble
#

it's a solo project -_-

vast grove
shy leaf
#

thats like the 2nd lie from you

marsh pebble
# vast grove For?

if i change it to not use tags it will break myserver and i'll have to redo everything involved with plots

marsh pebble
shy leaf
#

yeah no wonder why itll break

shy leaf
marsh pebble
#

i hate people like you (Not racial)

shy leaf
#

dude at least i dont pay $50 for that code

halcyon phoenix
vast grove
marsh pebble
#

i'll pass

wintry bane
#

...

vast grove
#

For simple shit. AI is fine, for undocumented projects, it's terrible

halcyon phoenix
marsh pebble
halcyon phoenix
vast grove
#

Yah bud. The problem is HTML

shy leaf
#

for javascript in general, its fine to use AI

wintry bane
marsh pebble
halcyon phoenix
marsh pebble
#

particles are easy

vast grove
#

I thought particles were documented...

#

Like well

shy leaf
#

i dont think AIs can see how particles look like

wintry bane
#

no /s what is ts

halcyon phoenix
shy leaf
#

well molangvariablemap doesnt have much stuff so

vast grove
marsh pebble
#
const MAX_PLOTS_PER_PLAYER = 3;
let isProcessingPlotBuy = false;

// Assuming this is inside a world.afterEvents.itemUse.subscribe or similar event
if (data.id === "plot:buy") {
    if (isProcessingPlotBuy) {
        player.sendMessage("Please wait, another plot purchase is being processed.");
        data.cancel();
        return;
    }

    let plotsOwned = player.getDynamicProperty("plotsOwned");
    if (plotsOwned === undefined) {
        plotsOwned = 0;
    }

    if (plotsOwned >= MAX_PLOTS_PER_PLAYER) {
        player.sendMessage(`You have reached the maximum plot limit of ${MAX_PLOTS_PER_PLAYER}.`);
        data.cancel();
        return;
    }

    isProcessingPlotBuy = true;

    try {
        let plotCount = world.getDynamicProperty("plotCount");
        if (plotCount === undefined || typeof plotCount !== "number") {
            plotCount = 0;
        }

        plotCount++;
        world.setDynamicProperty("plotCount", plotCount);

        player.setDynamicProperty("plotNumber", plotCount);

        const ownerRegistry = getOwnerRegistry();
        ownerRegistry[player.name] = plotCount;
        setOwnerRegistry(ownerRegistry);

        const row = Math.floor((plotCount - 1) / 100);
        const column = (plotCount - 1) % 100;
        const x = 1000 + column * 64;
        const z = row * -64;
        const y = 1;

        world.getDimension("overworld").runCommandAsync(
            `structure load plot ${x} ${y} ${z}`
        ).catch(error => {
            player.sendMessage(`Error loading structure: ${error.message}`);
        });

        player.sendMessage(`You have purchased plot ${plotCount}`);
        
        player.setDynamicProperty("plotsOwned", plotsOwned + 1);
        player.addTag('plot_owner');

    } catch (error) {
        player.sendMessage("An error occurred while processing your plot purchase.");
        console.error("Plot purchase error:", error);
    } finally {
        isProcessingPlotBuy = false;
    }
}```
this is what the ai gave me.. WIl it work?
halcyon phoenix
marsh pebble
vast grove
halcyon phoenix
#

do you have a mock server?

marsh pebble
halcyon phoenix
marsh pebble
vast grove
#

Dynamic property

marsh pebble
#

omg

halcyon phoenix
marsh pebble
#

it added 5 more bugs

#

i can create 3 plots instead of 1

#

what will i ever do

halcyon phoenix
#

Exactly, that's the consequences of now knowing what you're doing

marsh pebble
#

const MAX_PLOTS_PER_PLAYER = 3;

wintry bane
#

vibe code more

shy leaf
vast grove
#

Welcome to programming

marsh pebble
#

kidding

halcyon phoenix
shy leaf
#

hallucinations

marsh pebble
#

so will the code work?

#

WHAT THE FUCK

shy leaf
#

No

#

no.

marsh pebble
shy leaf
#

it will not

#

i literally pointed out why it wouldnt work, dont "bro" me

wintry bane
#

were you kidding with the "it works omg" part too

marsh pebble
#

why is there even a help channel if you guys tell me to do it myself? I wish cody was active he actually helped people

shy leaf
#

we dont build codes from scratch for people

vast grove
#

You're in regular chat

shy leaf
#

i mean if we were generous, we could

marsh pebble
#

wait

halcyon phoenix
marsh pebble
#

did cody get banned

#

what happened

halcyon phoenix
marsh pebble
#

gimme his user id rq

halcyon phoenix
#

and don't ping him

shy leaf
#

i dont think its the best to bother him rn

#

he seems busy

halcyon phoenix
#

you literally gonna disturb someone at this point

halcyon phoenix
marsh pebble
#

what's this

#

nice addon insockus

shy leaf
#

whats that

marsh pebble
#

it's insockus addon

shy leaf
#

i see

halcyon phoenix
#

Lol what I added that?

vast grove
#

si:test mmm

shy leaf
#

i dont see

marsh pebble
halcyon phoenix
#

oh lol

#

that's my very first addon

#

only me and my friends has

marsh pebble
#

it's tuff ๐Ÿ”ฅ

wintry bane
#

how tf is it not possible to use setEquipment for non-players when commands do it fine

wintry bane
#

undefined

halcyon phoenix
vast grove
#

EntityEquipmentComponent

#

Or something

marsh pebble
vast grove
#

Equippable?

shy leaf
wintry bane
#

undefined ๐Ÿ—ฃ๏ธ๐Ÿ—ฃ๏ธ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ

shy leaf
#

what about slot

#

commands use slots

halcyon phoenix
#

yeah I also dealt with that once with my custom mob, I cant put the equipment compinent

wintry bane
#

it uses equipment slots string not slots int

halcyon phoenix
#

and I can't set equipment

wintry bane
#

s2pid ik

shy leaf
#

๐Ÿ˜ญ

vast grove
#

Weird

#

Hey navi! Why

halcyon phoenix
#

you can't add equipment component on custom entities right?

wintry bane
#

I wanna set an enchanted armor on a baby zombie using scripts but nOooOOo

halcyon phoenix
shy leaf
#

the remark is bloody lying

halcyon phoenix
#

oh wait armor slot

vast grove
#

Inventory doesn't work I don't think

wintry bane
#

without modifying vanilla files

halcyon phoenix
#

there was a note there that only works for players before

shy leaf
#

This component exists for all mob entities.

#

This component only exists for all players. It does not exist on all entities.

#

oh fuck you

halcyon phoenix
#

That's why commands

wintry bane
#

oho middle finger right there

vast grove
#

Wtf do commands use

halcyon phoenix
#

I thought I was schizo for a sec there

vast grove
#

Bruuuhhh

marsh pebble
wintry bane
#

replaceitem

vast grove
halcyon phoenix
shy leaf
#

i kinda feel like they somehow added a case for entities on commands

#

but not for api?

vast grove
#

Could ask navi?

shy leaf
#

replaceitem

#

iirc

#

wait

#

nvm i misread that

marsh pebble
#

isnt this script api lets stop getting off topic

halcyon phoenix
shy leaf
#

nevermind the nvm i did read that correctly

wintry bane
#

๐Ÿซฅ

halcyon phoenix
#

addItem on the inventoryComponent of that entity so that you can save the itemStack somehow

then replaceitem command to make that item showup

wintry bane
#

show dyed leather boots

halcyon phoenix
#

lol

#

welp that visual part is the only hard part

shy leaf
#

wait a damn minute

#

if equippable returns undefined for mobs

vast grove
shy leaf
#

then how are we supposed to use the new armor properties

#

๐Ÿ˜ญ

wintry bane
#

exactly

glacial widget
wintry bane
#

one of these are enchanted

halcyon phoenix
halcyon phoenix
halcyon phoenix
wintry bane
#

I literally used your method before you did

vast grove
marsh pebble
wintry bane
halcyon phoenix
wintry bane
#

those dummies on a string actually wear the armor because of replaceitem, now they can't be enchanted

wintry bane
#

kill the entities, and you'll see which one's enchanted

halcyon phoenix
#

we are limited by the methods of our time

wintry bane
#

use a runtime identifier?

#

scripting is still pretty limited compared to commands so lets get back to topic before mods thanos snap us

halcyon phoenix
#

we're on topic though

vast grove
#

Commands and scripting

halcyon phoenix
#

welp just like what he said "we are limited by the technology of our time"

halcyon phoenix
wintry bane
#

segwayed to commands for a lil while, anyway scoreboards vs dynamic properties

vast grove
#

At least it's better than old script api. Before gametest

shy leaf
halcyon phoenix
#

ohh I see you can get them now

shy leaf
#

read only, yeah

marsh pebble
#

guys guess what

vast grove
#

No

glacial widget
halcyon phoenix
#

cause it's an inventory component

marsh pebble
halcyon phoenix
vast grove
#

No

shy leaf
#

im just gonna go play games

#

enough bao today

vast grove
#

I just spent all day fixing race conditions for VC

wintry bane
#

HOLY

                "interactions": [
                    {
                        "on_interact": {
                            "filters": {
                                "all_of": [
                                    {
                                        "test": "is_family",
                                        "subject": "other",
                                        "value": "player"
                                    }
                                ]
                            }
                        },
                        "give_item": true,
                        "take_item": true,
                        "interact_text": "action.interact.allay"
                    }
                ]
            }```
#

i thought allays were hardcoded damn

glacial widget
marsh pebble
#

HOLY

                "interactions": [
                    {
                        "on_interact": {
                            "filters": {
                                "all_of": [
                                    {
                                        "test": "is_family",
                                        "subject": "other",
                                        "value": "player"
                                    }
                                ]
                            }
                        },
                        "give_item": false,
                        "take_item": true,
                        "interact_text": "action.interact.allay"
                    }
                ]
            }```
distant tulip
ripe dune
#
player.teleport({ x: 0, y: 2147483500, z: 0 })
#

easy way to crash player game lol

vast rune
#
        if (entity === "minecraft:armor_stand" || "minecraft:sheep") {
            entity.applyImpulse({ x: 1, y: 0, z: 0 })
            const track_piece = getBlockBelow(entity);
        }

    }```

i am doing a test of looping through all of the entities and checking for specific ones, then doing scripted behaviors on only those specific entities. having one entity to filter works, but when I add || every entity has those behaviors. ๐Ÿ˜’
vast grove
#

Create a static array then do array.contains(entity);

vast rune
#

i got it, ty tho

halcyon phoenix
#

the || / OR operator does not or the String/the "minecraft:armor_stand"

basically

bool1 || bool2

vast rune
#

also thanks to all yall that helped, im coming from other languages so this helps a ton

misty dagger
#

Guys, do my eyes deceive me? Is API 2.0.0 out on stable?? ๐Ÿ‘€

vast grove
#

yes

woven loom
#

Did anyone attempt to shoot a trident?

untold magnet
distant gulch
#

hi

#

modifying the json file of pause screen how can i make a button open a modal form data

#

like zeqa or tropical

prisma shard
#

Tried using .shoot method

#

Tho you need to set the rotation to the players front
otherwise the arrow faces wierdly when getting shooted

vast rune
woven loom
prisma shard
#

got exams

woven loom
#

oh

thorn flicker
woven loom
#

sure

thorn flicker
#

alr, give me sec.

thorn flicker
#

on bedrock anyway

woven loom
#

with scripts u can but the shoot thing doesnt work

prisma shard
#
function shootProjectile(projectile, power, source) {
        const headLoc = source.getHeadLocation();
        const viewVector = source.getViewDirection();
        const direction = {
            x: headLoc.x + viewVector.x,
            y: headLoc.y + viewVector.y + viewVector.y * 0.4,
            z: headLoc.z + viewVector.z,
        };
        const vel = { x: viewVector.x * power, y: viewVector.y * power, z: viewVector.z * power };
        const entity = source.dimension.spawnEntity(projectile, direction);
        entity.getComponent("projectile").shoot(vel);

        return entity;
    }```
#

I have this function for shooting projectile

#

from the players head location

thorn flicker
#

I know how to

prisma shard
#

ok

thorn flicker
prisma shard
#

so tridents can't be spawned?

#

That's so bad

thorn flicker
#

summoned

#

no

prisma shard
#

mh

woven loom
#

also u cant break blocks with trident right? how do they do that

thorn flicker
#

...

prisma shard
#

tridents break blocks?....

open urchin
#

you can't in creative mode

woven loom
#

i was not able to

thorn flicker
woven loom
#

yea how is that done

prisma shard
#

so when trident hits a block the block breaks? Never heard that trident breaks block....

thorn flicker
#

they mean projectile hitting blocks

open urchin
#

oh

thorn flicker
#

lol

prisma shard
#

wadda hel xd

thorn flicker
#

just incase

open urchin
#

throw one at a decorated pot

thorn flicker
#

but no, they dont.

prisma shard
open urchin
thorn flicker
#

that doesnt count

prisma shard
#

lol

thorn flicker
#

-# it does

#

thats cool though, nice to know

thorn flicker
#

you cant summon a trident, maybe you can use a structure

wary edge
#

Its thrown_trident

#

Have you tried summoning that?

thorn flicker
woven loom
#

i wanted to shoot trident :/

thorn flicker
#

you could try to edit the entity file to make it summonable.

woven loom
#

does that require rp editing ?

thorn flicker
#

thats not a client side thing.

woven loom
#

gonna try that

thorn flicker
woven loom
#

thx, was about to ask for that xd

thorn flicker
#

np, make the process quicker

#

lol

thorn flicker
woven loom
#

u tried shoot ur just spawn

shell sigil
#

Guys Is there way to detect a block especially a chest that are Spawn in structure because I want every structure in Minecraft that have chest put a property

thorn flicker
#

why wouldnt I test it for you afterwards, I literally offered

#

give me a sec lol

woven loom
#

well its still not spawning idk what im doing

thorn flicker
#

did you import the file correctly

#

show me your folder

thorn flicker
woven loom
#

my just floats in the air

thorn flicker
#

lol what

#

not for me

woven loom
#

send vid?

thorn flicker
#
world.afterEvents.itemUse.subscribe(({ itemStack: item, source: player }) => {


    if (item.typeId === 'minecraft:stick') {
        const trident = player.dimension.spawnEntity('minecraft:thrown_trident', player.getHeadLocation())
        const proj = trident.getComponent('projectile')
        proj.owner = player
        proj.airInertia = 1.2
        
        proj.shoot(player.getViewDirection())

    }

})
woven loom
thorn flicker
#

you had to do something to it in the file

#

you copied my file right

wheat condor
# woven loom

why do you need the XYZ coordinates colored lines for an hitbox that its just static?

#

and also what are those buttons in the hotbar < >

woven loom
woven loom
wheat condor
#

that looks useful

#

does it exist for pc/controller?

woven loom
#

pc has mouse

wheat condor
woven loom
#

ye thats a good idea

untold magnet
#

@wary edge hey, sorry for the ping, d u have any link for docs of the new entity hunger/saturation/exhaustion component? cuz i cant find any

#

sorry for the ping once again

wary edge
#

Check stirante.

untold magnet
#

apparently it is available on 2.0.0 abi

#

but im not sure how it works

#

like how am i going to detect them

untold magnet
wary edge
untold magnet
#

ty.

untold magnet
# wary edge https://stirante.com/script/
        const saturation = player?.getComponent('minecraft:player.saturation');
        const exhaustion = player?.getComponent('minecraft:player.exhaustion');
```they returns undefined
#

like currentValue is not a thing

wheat condor
#

nope its right in bedrock samples

sharp elbow
#

You might be using the wrong API version?

untold magnet
#

on 1.21.90 stable

sharp elbow
#

Hm, I wonder if they forgot to move it from beta to 2.0.0

untold magnet
#

to the 2.0.0

#

i believe

wary edge
#

It's not in 2.0.0, it's still beta.

untold magnet
#

huh?

sharp elbow
#

If so, that changelog is outright misleading

untold magnet
#

in that case, i will make the addon and wait till 2.1.0

grand needle
#
const slots = [];
        for(let i = 0; i <= 7; i++){
            slots.push(inventory.getItem(i));
        }
if (slots[2]) {
          const isWearable = slots[2].getComponent("minecraft:wearable");
          if(isWearable) {
              ItemsClear("head", "armor");
          } else {
              ChestItems("head", slots[2], "armor");}
          } else {
              ItemsClear("head", "armor");
      }```
Does anyone know why it doesn't clean the item even though it has the wearable component?
untold magnet
#

it should make the number bigger not smaller, right?

sharp elbow
#

Depends. That implies currentValue is a number less than 0.

distant tulip
untold magnet
#

it starts from 0 allway to 4

#

i need to make it starts from 0 allway to 20 instead

#

how am i going to do that?

sharp elbow
#

I have yet to use this component, so I am not sure.

untold magnet
#

well

#

what about changing the value from - to + ?

#

somehow

sharp elbow
#

Could use Math.abs()

#

I would sooner try to understand why I am receiving a negative value. Would negative exhaustion happen after I eat food?

untold magnet
#

no, exhaustion is a different thing

untold magnet
#

hmmm

sharp elbow
#

You're a detective now

untold magnet
#

if (exhaustion > 0) console.warn(exhaustion * 5) this

#

should detect it only when the value is above 0

#

ig

untold magnet
#

my bad

sharp elbow
#

Haha, was it [Scripting][warn]-20

untold magnet
#

exactly

sharp elbow
#

Happens to the best of us. I've been caught by that too

untold magnet
#

console.warn always gets me lmao

charred pawn
#

In 2.0.0, a watchdog is occurring in my scripts, probably due to the new way of loading the world. Does anyone know how to solve this?

wheat condor
#

it isnt a problem

charred pawn
valid ice
weary umbra
# valid ice Money

Wow, that's pretty good and smart at the same time. But you're selling it right?

valid ice
#

Uh no

snow jungle
#

Is there a workaround for this?
[2025-06-19 23:25:16:299 WARN] [Scripting] Failed to apply enchantment protection: EnchantmentLevelOutOfBoundsError: When trying to create enchantment instance - Tyring to set enchantment level to 7, range for type protection is [0 - 4].

sharp elbow
#

Doesn't appear to be. I would use NBT editing next.

midnight crane
#

How do I make a realistic flying I want to make it look like you are flying with an elytra but you aren't

marsh pebble
#

is anyone able to fix this

halcyon phoenix
#

can you access minecraft:item like an itemStack?

halcyon phoenix
#

applyknockback with math

halcyon phoenix
valid ice
halcyon phoenix
#

how would you do it?

valid ice
#

Entity.getComponent('item').itemStack;

marsh pebble
halcyon phoenix
halcyon phoenix
marsh pebble
#

Nope.

#

As it is embed it doesnt take up most of the chat, it'll only get big if you expand it.

vast grove
#

Just make a post buddy before it gets drowned out

marsh pebble
vast grove
#

Not rude. Just telling you what happens here

marsh pebble
#

"make a post buddy"

halcyon phoenix
#

yeah

vast grove
#

If it isn't a quick fix, move it to a post or no-one is gonna put in the effort to help you

halcyon phoenix
marsh pebble
vast grove
#

Or better. Since this discord is a treasure trove of solutions, just research even if the discord search feature is pretty shit.

marsh pebble
halcyon phoenix
#

then learn how it works

marsh pebble
#

did minecraft make a command called /knockback?

marsh pebble
# vast grove Ok???

Like ive told you, I've already scrapped thru the messages. Not saying it js to say it. (Literally all of last week)

vast grove
#

Seems pretty common to me

#

764 messages isn't the whole story, you gotta preview the convo too

#

Videos and shit on mcpedl, google. Ok this is enough.

marsh pebble
#

Why don't you understand?

#

I've been researching plot system for months
-# (Not just in here)

halcyon phoenix
#

he's just lazy at this point

marsh pebble
#

I've already seen that yes. But it's not the type of plot im looking for. i already use a mod with land claims in it, But again not what im looking for.

#

also me and jmafk are literally friends

marsh pebble
vast grove
#

not looking for. Then modify it!

#

Or take inspiration

halcyon phoenix
#

welcome to cinema

#

he's at it again

vast grove
#

I'm not saying copy it. I'm saying look at how they did things.

marsh pebble
halcyon phoenix
shy leaf
#

hi

vast grove
#

Then learn JS!!!

marsh pebble
vast grove
#

Fucking hell now I've been reminded why I left this server

halcyon phoenix
shy leaf
#

you know

#

i think

#

at least trying a bit is better than pulling the hair off in this place

marsh pebble
#

Im out .

halcyon phoenix
vast grove
#

8 months? coronalol that's nothing compared to a few years

#

I give up, then come back, realise what I did wrong, fix it, another problem, give up, then come back. Never ending cycle

shy leaf
#

if i have to be honest

#

if you 'tried' for 8 whopping months

#

you gotta question yourself if you really tried it...

marsh pebble
halcyon phoenix
vast grove
#

Programming takes so many years to master.

#

I'm still shit at it.

#

But I know enough to try things

marsh pebble
halcyon phoenix
marsh pebble
#

@delicate palm

halcyon phoenix
#

... it's not our job to fix that this place is for learning script-api

sharp elbow
# marsh pebble

At first, this script could only register one plot per person. (the property that stored the player's plots is a number). I then made some edits to more heavily leverage the ownershipRegistry in storing those plots instead.
More work is needed to read from the registry when looking up the guest list, in general management, and when teleporting to owned plots

#

(If anyone would like to contribute to the theoretical solution, instead of bickering about attitudes)

#

I ran out of time to look at it tonight

delicate palm
#

@marsh pebble forced me to come here

marsh pebble
#

yes hi

marsh pebble
#

come here

#

i need to tell you something

#

||you stink||

delicate palm
#

๐Ÿ‘

marsh pebble
delicate palm
halcyon phoenix
#

so cooldown component gets ignored on a beforeEvent?

shy leaf
#

but you cant read cooldown ticks in read-only anyway

halcyon phoenix
#

also e.cancel = true doesn't work under system.run

glacial widget
marsh pebble
halcyon phoenix
halcyon phoenix
#

is there anyway/method to smelt an itemStack? can't find anything on the dev resources and script

wheat condor
prisma shard
#

He probably meant "smelt"

halcyon phoenix
#

my bad

#

imagine if I meant smell

wheat condor
halcyon phoenix
#

thanks Carchi

wheat condor
halcyon phoenix
wheat condor
#

you can do that aslo for raw => cooked food

#

and catch the exceptions in a map

halcyon phoenix
#

yeah but I have to input manually

#

that's the only downside

#

somebody we will be able to acces the recipes

lyric kestrel
#

Just realised I had 7 nested if statements in a piece of my code and another redundent if statement in a part of another code

#

Just removed 4 if statements

vast grove
#

if(poor) getRich(this);

lyric kestrel
#

Goddamn, I really need to clean to code up ๐Ÿ˜ญ

#
world.beforeEvents.playerBreakBlock.subscribe(e =>{

    const { block } = e;
    //let blockName = block.typeId.replace(/\d+$/, "");
    
    if (block.hasTag("framed_block")) 
    {
        let i = block.typeId.match(/\d+$/);
        //console.log(i);
        const blockKey = `block${i}`;
        const blockStates = blockStateMapping[blockKey];
        // Iterate through each state in the block and find if it matches the blockKey
        for (let j = 0; j < blockStates.length; j++) {
            const stateNumber = block.permutation.getState(`frame:${blockKey}`);
            if (stateNumber === j+1) {
                const state = blockStates[j];
                const blockToGive = new ItemStack(state, 1);
                console.log(state);
                
                // check if itemInHand is true
                //console.log("State: ",block.permutation.getState(`frame:block${i}`));
                if (!block.hasTag("state0")) {
                    
                    system.run(()=> {
                        // Spawn state block and give back framed block on break
                        block.dimension.spawnItem(blockToGive, block.center());
                    });
                };
            };
        };
    };
});```
#

Like look at that bs

#

That's just 1 beforeEvent

#

if (!block.hasTag("state0")) is competely redundent

vast grove
#

I think you need less nesting

lyric kestrel
#

Ye

#

Just a little bit xD

#
if (stateNumber === j+1) {
                const state = blockStates[j];
                const blockToGive = new ItemStack(state, 1);
                console.log(state);
                
                // check if itemInHand is true
                //console.log("State: ",block.permutation.getState(`frame:block${i}`));
                    system.run(()=> {
                        // Spawn state block and give back framed block on break
                        block.dimension.spawnItem(blockToGive, block.center());
                    });
                };
            };```
#

Changed the bottom bit to that instead

vast grove
#

You should do if(notThis) return

#

De nests a lot and is more performant

lyric kestrel
#

Ye

#

I watched a video yesterday on clearing up code, so I'm starting to look through my code to see what I can de-nest and de-clutter

#

@vast grove

world.beforeEvents.playerBreakBlock.subscribe(e =>{

    const { block } = e;
    //let blockName = block.typeId.replace(/\d+$/, "");
    
    if (!block.hasTag("framed_block")){
        return
    }
    let i = block.typeId.match(/\d+$/);
    //console.log(i);
    const blockKey = `block${i}`;
    const blockStates = blockStateMapping[blockKey];
    // Iterate through each state in the block and find if it matches the blockKey
    for (let j = 0; j < blockStates.length; j++) {
        const stateNumber = block.permutation.getState(`frame:${blockKey}`);
        if (stateNumber !== j+1)
        {
            continue
        }
        const state = blockStates[j];
        const blockToGive = new ItemStack(state, 1);
        console.log(state);
        
        // check if itemInHand is true
        //console.log("State: ",block.permutation.getState(`frame:block${i}`));

        system.run(()=> {
            // Spawn state block and give back framed block on break
            block.dimension.spawnItem(blockToGive, block.center());
        });
    };
});```
#

That looks so much better

coral ermine
#

how to see whatโ€™s new in 1.21.90?

lyric kestrel
#

#1384561782617669844

vast grove
#

Ye. Das is good

lyric kestrel
#

Now time to do that for the rest of the file ehappy

#

I have a 6 nest there now ๐Ÿคฃ

vast grove
#

Eh. The more you do it, it'll become easier. I do it subconsciously all the time

lyric kestrel
#

nice

#

I think I tested my add-on spikes 20ms when I had my scripts so badly written, I want to test how better they are after I make everything better

vast grove
#

I still don't know shit to denest try catch blocks but it's ffiiiinnneee... Also this is C#.

    private async Task ReaderLogic()
    {
        var startTick = Environment.TickCount64;
        var readBuffer = new short[Constants.BytesPerFrame / sizeof(short)];
        while (!Destroyed)
        {
            try
            {
                var tick = Environment.TickCount;
                var dist = startTick - tick;
                if (dist > 0)
                {
                    await Task.Delay((int)dist).ConfigureAwait(false); //Delay by required amount.
                    continue;
                }

                startTick += Constants.FrameSizeMs; //Step Forwards.
                Array.Clear(readBuffer); //Clear Read Buffer.
                var read = GetNextPacket(readBuffer);
                if (read <= 0) continue;

                WriteToOutputBuffer(readBuffer, Constants.BitDepth / 16 * Constants.Channels * read);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
    }
lyric kestrel
#

damn

#

I know nothing of C# xD

#

I just know some syntax is like JS

vast grove
#

Oh yeah some things are similar. Though the types at runtime is very much not.

lyric kestrel
#

ah

vast grove
#

Like you cannot cast an interface on a object if it does not inherit it

#

It will crash

#

Oh wait. Why the fuck am I Console.WriteLine(ex); the error... It's a GUI app...

#

Oh yeah. I gotta write the exception logger

lyric kestrel
#

oop

vast grove
#

Eh. For later. Going through 13k lines of code and finding local exception handlers to reroute is gonna be fun smilee

lyric kestrel
#

I just realised I have some code commented out, and I don't need it anymore. Probably should get rid of that ๐Ÿ˜…

vast grove
#

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

lyric kestrel
vast grove
#

I would imagine over 15 or 20k...

lyric kestrel
#

๐Ÿ˜‚

#

Hah, I had tile drops off on the world

#

I thought I broke something when the block wasn't dropping itself ๐Ÿคฃ

lyric kestrel
#

My script now runs 15-20ms

#

A very small, if not really any improvement

#

hmm, if it fails to put a texture on the block, it seems to spike to 20ms, but initially doing it seems to be below 10ms

#

I need to fix that

#

That is a 10ms improvement, I'm happy I even got that low (even with the 20ms spikes)

#

Ok, spikes are now only 14ms after de-nesting 1 more if statement

zenith cedar
#

Yo guys, I wanna ask something "@minecraft/vanilla-data" is only for TS right???

lyric kestrel
#

Man, I'm so fucking happy with myself now

#

I got my script down from 20ms to now be at a stable 9-12ms when in use

neat hazel
#

Why is this error happening?
In this line of code:

player.applyKnockback(0, 0, 2, 1);```
lyric kestrel
#

It's saying you have too many argumeents in applyKnockback()

#

You have 0,0,2,1 in there, which is 4 arguments

#

It can only have 2. No more or no less

zenith cedar
sterile epoch
#

question

zenith cedar
sterile epoch
#

I saw that

#

you rat

#

anyway

lyric kestrel
sterile epoch
zenith cedar
#

Lmao

sterile epoch
#

when using dividers in modal forms, is it a bug that they add null to the f.formValues array?

neat hazel
neat hazel
neat hazel
fickle dagger
#

Custom Commands are stable now, right?

sterile epoch
fickle dagger
#

aw damn

gaunt salmonBOT
serene lava
#

I'm looking to make the entity this script is applied to boost directly to the player or entity it's currently attacking. How do I do that?

weary umbra
#

Why does removeShap not working?

world.beforeEvents.itemUse.subscribe((event) => {
    let line = new DebugLine(
        { x: 0, y: 0, z: 0 },
        { x: 20, y: 10, z: 10 }
    )
    if (event.itemStack.typeId === "minecraft:stick") {

        line.color.red = 1
        line.color.green = 0
        line.color.blue = 0

        debugDrawer.addShape(line)
    } else if (event.itemStack.typeId === "minecraft:diamond") {
        debugDrawer.removeShape(line)
    }
})


gilded shadow
weary umbra
#

but when I use removeAll it doesn't works

gilded shadow
#

try caching the line object after addShape and remove that object.

gilded shadow
#

for me the debug shapes appear for like 10ms before disappearing

#

i think the debug shapes are bugged or something

snow jungle
#

Anyone know how to get armor trims with js?

wheat condor
snow jungle
#

How can I get the trims a armor piece has with js?

wheat condor
#

oh you cant

abstract cave
#

was the way applyKnockback works changed?

#

how do i push a player in the view direction?

wary edge
abstract cave
wary edge
abstract cave
halcyon phoenix
deep quiver
#

That their made by different people

halcyon phoenix
#

...

cinder shadow
#

oh wait

#

Microsoft docs never had the example updated lol

cinder shadow
#

you just have to bundle them

halcyon phoenix
sharp elbow
#

viewDirection returns a normalized vector. The length of that vector is 1; that is, the sum of the squares of the X, Y, and Z components equal 1

#

So I suppose yes, the components must be in the range [-1, 1]

chrome gyro
#

How do we filter to make sure a string only has numbers and letters? Not using "match" from beta.

Do we just have to do a complicated replace?

vast grove
#

Number(string);

#

It's js. You can do js shit

ripe dune
#

also if you want spaces, just add a space after 9

#
message.replace(/[^a-zA-z0-9 /g, ''))
chrome gyro
#

Ah ok, thanks. Seems to be something along the lines of:

(str.match(/^-?\d*\.\d+$/))
/^-?[0-9]+(?:\.[0-9]+)?$/.test(num+'')
ripe dune
#

yup

chrome gyro
#

Oh ok, thanks

ripe dune
#

wait its wrong

#

forgor a ]

#
message.replace(/[^a-zA-z0-9 ]/g, ''))
#

like tthat

chrome gyro
#

That would clear all letters or numbers though right?

ripe dune
#

you want to remove all letters or numbers?

#

or filter all letters or numbers

chrome gyro
#

Sorry, no just testing if the string has letters and numbers only.

#

I phrased it wrong, sorry.

ripe dune
#

so you want something like abdc123 -> true, abc$#123 -> false

chrome gyro
#

exactly.

ripe dune
#

hmmm

chrome gyro
#
string.match(/^-?\d*\.\d+$/)

I think it's this one, but I dont know how to get it to test correctly... I think \d is the test part so maybe like:

name.match(/[^A-Za-z0-9?.&\d]/g)
ripe dune
#
message.match(/[^a-zA-Z0-9]/g) === null
#

that should work