#Script API General

1 messages · Page 114 of 1

shy leaf
#

and its not included in the game

#

tho theres a standalone file

#

theres a handful of stuff you can make use of for anything math

slim forum
#

Oh, then I'll keep using my little function

#

I have more control over it

shy leaf
#

ye

twilit tartan
#

Someoone know if is possible modify the Ui in forms, but for Add-Ons?

honest spear
#

wdym?

twilit tartan
# honest spear wdym?

Modify the UI of the forms, without using something that violates the addons rules

honest spear
#

no you can only modify the UI with JSON-UI resource pack

#

thats only way

twilit tartan
honest spear
#

Well you can use addon you don't have to change vanilla ones, but yea it does override some vanilla behavior, but if done correctly then its relatively safe

#

Well what all of you are working on?

#

i wonder what kind of addons are made nowdays

full idol
#

Finally got the debugger to connect to BDS, is there any way to see which add-on is writing to dynamic properties?

#

Mostly for this

distant tulip
#

Run a debug profiler for each one of them

unique apex
#

did mark variants use to be writeable? whyd they change it to read only? all my favorite things are going to read only 😭 ill miss you scale component

unique apex
#

nvm i figured it out bc im cool or smth like that

prisma shard
#

whats the point of using try catch if i just throw the error again 🤔

earnest meadow
#

its like "if this errors, do something"

grand heart
#

What folder to store server secrets and what format?

shy leaf
#

the rest of the code will run as normal

shy leaf
dusky flicker
#

i personally prefer errors as valuesso in general i dont use try catch nor throws

#

throws i use just for some violation

prisma shard
#

lmfao 😭

shy leaf
#

runCommand() doesnt throw iirc

#

so theyre doing that

dusky flicker
shy leaf
#

wait

#

does that even

#

make sense

prisma shard
#

absolutely not

#

thats why im laughing

shy leaf
#

hold on

#

try catch doesnt catch warns, right?

#

im so confused

dusky flicker
shy leaf
#

then

shy leaf
#

ok so

#

that just

#

lmao

dusky flicker
#

if nothing never throws, its never gonna be executed

prisma shard
#

yeah

shy leaf
#

i dont know if i should be laughing or be frightened

prisma shard
#

nope

#

we should crying

#

for EntityHurtBeforeEvent

distant tulip
#
Throws an exception if the command fails due to incorrect parameters or command syntax, or in erroneous cases for the command. Note that in many cases, if the command does not operate (e.g., a target selector found no matches), this method will not throw an exception.
meager cargo
#

What's wrong here?

world.afterEvents.playerInteractWithEntity.subscribe((event) => {
  const player = event.player;
  const entity = event.target;
  if (!player || !entity) return;
  const equip = player.getComponent("minecraft:equippable");
  if (!equip) return;
  const item = equip.getEquipment(EquipmentSlot.Mainhand);
  if (
    entity.hasTag("token_17") &&
    player.hasTag("tokens_place") &&
    item?.typeId === "test:item"
  ) {
    player.dimension.runCommand("clone 227 6 234 227 6 234 232 15 210");
  }
});
distant tulip
#

does that throw error or what

prisma shard
#

wha-wha what is this

#

you wrote some binary

meager cargo
meager cargo
distant tulip
#

put some console logs around and see where does it stop

prisma shard
prisma shard
shy leaf
prisma shard
#

Oh yes

shy leaf
#

try using that instead of equippable

meager cargo
#

Okay, imma try, thanks guys!

#
world.beforeEvents.playerInteractWithEntity.subscribe((event) => {
  const player = event.player;
  const entity = event.target;
  if (!player || !entity) return;
  const inv = player.getComponent("minecraft:inventory");
  if (!inv) return;
  const container = inv.container;
  if (!container) return;

  const item = container.getItem(player.selectedSlotIndex);

  if (!player.hasTag("tokens_place")) {
    return;
  }
  if (!entity.hasTag("token_17")) {
    return;
  }
  if (!item) {
    return;
  }
  if (item.typeId !== "test:item") {
    return;
  }

  player.runCommandAsync("clone 227 6 234 227 6 234 232 15 210");
});

That worked (without debug messages)

full idol
#

This crash is driving me insane. This weird __clone thing happens whenever a player punches a mob, but only sometimes when the server starts. It happens 3-5 times in a row then nothing for like a day. It's exactly like this https://github.com/itzg/docker-minecraft-bedrock-server/issues/508 but it happens on entity hit, which suggests scripting, but I've checked all addons removing one at a time, and nothing? Ideas?

GitHub

docker-compose.yml # version: "3.5" services: minecraft: container_name: minecraft image: itzg/minecraft-bedrock-server environment: EULA: "TRUE" GAMEMODE: creative SERVER_NAME:...

#

Looking through the .mcstats nothing stands out when it crashes, no addon handle spikes or JS memory issues

gaunt salmonBOT
elder spindle
#

I've got a custom slash command /mine a however it currently lets players do /mine aaaaaa which will become an issue later down the road (Prestige ranks like AA, BB, etc). Is there there any way it fails if the player does more than the 1 A?

wary edge
elder spindle
#

i have different Mines: Mine A, Mine B etc, and later on I plan on adding prestige ones, so Mine AA for example. If a player currently does /mine aaaaaaa it teleports them to Mine A regardless of how many letters they add to the end. It would become an issue if a player tries to access a prestige mine, like Mine AA because it will still teleport them to Mine A, and not Mine AA

wary edge
#

Then make it an enum?

elder spindle
#

That still doesnt fix the issue im having

wary edge
#

Players just select the mine they want, you check if they meet the requirement, if not dont do anything.

elder spindle
#

Im trying, however it keeps accepting "aa" as "a", it seems to only be checking the first letter, so if people start doing "/mine ab" it will allow them to warp to mine a

wary edge
#

How are you parsing it?

elder spindle
#
const player = origin.sourceEntity;
        const arg = args[0];
        if (!player) {
            return { status: CustomCommandStatus.Failure };
        }
        const requested = `rank_${arg.toLowerCase()}`;
        const playerRank = player.getDynamicProperty("rank");


        if (!/^[a-z]$/.test(arg)) {
            player.sendMessage("§cInvalid mine! Example: /mine a");
            return { status: CustomCommandStatus.Failure };
        }```
wary edge
#

You just need to use Enums and hardcode it is all I'll say. Dont do this regex whatever. Just do a switch case or map to teleport.

elder spindle
#

No matter what I do, it just seems to be an issue. If I add a debug like console.warn("player entered: " + arg) it would show "Player entered a" even if the player entered aa

wary edge
tender pier
#

Can i get some help with this?

#

I just changed the version to 2.2.0

#

I was using 1.9.0 iirc

distant tulip
#

DimensionType iirc

rigid torrent
#

How can I make something happen when an item is used on air?

#

itemUse does the trick

midnight ridge
#

how can i put an item in the scond hand of the player using script ?

tender pier
edgy elm
#

quick question. how do you make a custom command without namespace. I've been using chatsend all along and dont know that we can now use / command without namespace.

tidal wasp
distant tulip
#

lever_permutation have no getSelected function

tidal wasp
#

is that not valid getSelected function

distant tulip
#

that's calling it

#

not defining it

tidal wasp
#

But I define it before I call it in the big switch case

distant tulip
#

you did not

#

you assingned some stuff to it

tidal wasp
#

Ok so how would I define it because im confused

distant tulip
#

not sure what it is supposed to be tbh
you are doing
const leverSelected = lever_permutation.getSelected
lever_permutation is levers.propery
and propery is new SelectionBoxes()
SelectionBoxes is imported, so i am not sure what's there

tidal wasp
#

That error has been fixed when I checked

#

That's where I got the class from

inland merlin
#

why doesn't the iteminventorycomponent work for shulkers?

#

it works for bundles and custom possibly?

thorn flicker
#

yeah

inland merlin
#

dang thats annoying

#

how can i get the stuff inside then for now?

open urchin
thorn flicker
#

I dont think you can, it would need to be placed.

tidal wasp
#

Is item inventory component a recent addition

thorn flicker
#

but not that new

inland merlin
#

okay, thanks for letting me know, i am just trying to read the information inside a chest, so i can display the contents

#

of the shulker

#

inside a form

distant tulip
# tidal wasp https://wiki.bedrock.dev/blocks/precise-interaction

you are using SelectionBoxes, but calling getSelected() as if it were FaceSelectionPlains
according to the wiki
getSelected(faceLocation: Vector3, options?: { invertX?: boolean; invertY?: boolean; invertZ?: boolean }): number | string | undefined
but you are doing
const leverSelected = lever_permutation.getSelected({
face,
faceLocation: relativeFaceLocation
})

inland merlin
#

i supose i could use lore?

#

maybe?

thorn flicker
#

?

inland merlin
#

for the shulker inside the chest

thorn flicker
#

it wont detect it

inland merlin
#

awh dang

#

ok

thorn flicker
#

im pretty sure anyway.

inland merlin
#

ill test but even if it did, probably not the full list

thorn flicker
#

i doubt it would tho

tidal wasp
inland merlin
#

nah it doesn't work lol

tidal wasp
#

Because the other 2 addons I have the use face selection planes work perfectly fine

inland merlin
#

just isn't supported for their lore

tidal wasp
#

Or does it only effect the boxes

open urchin
tidal wasp
#

Dammit

inland merlin
#

lol

tidal wasp
inland merlin
#

yeah, ill just ask them to use bundles to show stuff inside them in the form

#

oh well

distant tulip
#

@inland merlin you can work around it by cloning the shulker and spawning it and destroying it

#

that should throw the items

tidal wasp
inland merlin
#

i forgot cani place the block

#

down?

distant tulip
distant tulip
inland merlin
#

ohhh hmm, so killing the shulker makes the items drop from inside it?

distant tulip
#

yes

inland merlin
#

i have never done that ever lol, so i guess i learn something new everyday

#

🙂

distant tulip
#

it is a survaivl thing

inland merlin
thorn flicker
#

killing the shulker box item will drop its inventory?

inland merlin
#

cheers mate

distant tulip
#

yes

inland merlin
#

ill give this a go

thorn flicker
distant tulip
#

not sure if it is kill or damage tho

#

there is a scripting resource for it

#

bundles too

inland merlin
#

i forget what the api uses to spawn the itemStack as an entity

#

please remind me, i tried looking it up, but forget where it is

#

something like createItemStack, or newItemStack

#

of the copied item

distant tulip
#

dim.spawnItem(itemStack)

inland merlin
#

oh... it must have changed because i swear it was something lese

#

else

#

for the copied itemStack shulker inside a chest

#

to have it spawn outside the chest

distant tulip
#

just get the item and use that

inland merlin
#

okay

distant tulip
#

get item already return a copy

tidal wasp
#

I have an absolutely diabolical work-around that involves a whole other script in a whole other addom

inland merlin
#

?

tidal wasp
#

Yes

#

My own stuff

inland merlin
#

for dropping the shulker contents

inland merlin
#

ill clean it up

#

but yeah, heck yeah ended up using the applyDamage

#

even better

thorn flicker
#

nice

inland merlin
#

the chestshop is insane lol im trying to make it part of a newer essentials im making

distant tulip
#

The down side is you lose the slot number

inland merlin
#

I mean its in order

#

From 0 + slot

distant tulip
#

That's good if it is 100% of the times

inland merlin
#

I get what u mean

#

Because im breaking the inventory out

#

So maybe I need to double check

distant tulip
#

Can you log date.now when you get the items and send it here?
Assuming you are using entity spawn

inland merlin
#

Yeah I stopped working it for the moment, but im curious as well

#

Ill send it to you to see if it comes out in order

#

Or random

distant tulip
#

Currently in my phone, will do when i can

inland merlin
#

Ok

hazy kraken
#

any way to cancel this form showing up? my message gets sent after the form is shown to the player

echo tinsel
#

I am using an armor stand runtime identifier and I'm wonder is it possible to destroy the armor stand item that spawns when it's broken and replace it with the entity placer item instead, without messing up the fact that it drops all the stuff it was wearing

tidal wasp
#

(Yes I've implemented every change suggested first)

tidal wasp
#

Let me try 1 last thing again

lethal bramble
#

i was wondering how many people use typescript or javascript?

cinder shadow
lethal bramble
tidal wasp
#

ok so aparently something is just wrong with the way im trying to grab the selection_box

#

I DO NOT KNOW WHAT

#

but something is wrong

#

Wait I think i might have it

#

It isnt the colons but they probably arent helping

hazy kraken
inland merlin
# hazy kraken Not yet

Check if the player has items to sell (e.g., via an if statement on itemAmounts[selectedIndex] > 0) before calling form.show(player), and only show the form if true—otherwise, just send the "no items" message immediately.

tidal wasp
#

Can someone tell why this is still returning undefined

#

Like I used the goddamn fix for face location and still NOTHING

#

And I can see the fix is pretty clearly working

dawn zealot
#
import { beforeEvents } from "@minecraft/server-admin";

system.run(() => {
    beforeEvents.asyncPlayerJoin.subscribe(async (data) => {
        world.setDynamicProperty('pending_pfids', undefined)
        console.warn("test", data.persistentId)
        const name = data.name
        const pfid = data.persistentId; // This is the PlayFab ID
        const map = JSON.parse(world.getDynamicProperty('pending_pfids') ?? '{}');
        map[name] = pfid;
        console.warn(JSON.stringify(map))
        world.setDynamicProperty('pending_pfids', JSON.stringify(map));

        return Promise.resolve();
    });
})
``` anyone know why this wont get the pfid?
#

it works in other packs i have but not this one, its so confusing

tidal wasp
#

it does work

#

but the hitboxes are borked to shit

#

and there is another block update bug

#

:)))))))))))))))))

crisp trellis
#

401k 🗣️

inland merlin
#

how do i lock chests from copper golems? for a chestshop, don't want them placing anything into them

grand heart
#

does worldLoad event triggers on /reload

dawn zealot
crisp trellis
inland merlin
crisp trellis
#

It's really good for initializing other scripts & such

dawn zealot
inland merlin
#

like a beforeEvent or something

crisp trellis
dawn zealot
#

oh wait maybe

#

is there a entityInteract with block event

crisp trellis
inland merlin
dawn zealot
#

then test for coppergolem

crisp trellis
#

you can cancel the event via using that too

dawn zealot
#

opening a chest

inland merlin
#

i guess i never really thought about it

dawn zealot
#

then test for the chest coords

inland merlin
#

for entities

#

ill check out the entityInteract as that would solve my problem

#

thx for letting me know

#

ill integrate into my existing stuff'

dawn zealot
#

i looked theres no entity interact with block event

crisp trellis
inland merlin
#

hmm

dawn zealot
crisp trellis
dawn zealot
#

custom form shop

#

or just use the normal copper chest and place a barrier above it

crisp trellis
#

btw custom containers are naturally interactive with hoppers, right?

dawn zealot
#

no clue

crisp trellis
#

or do I have to toggle something

crisp trellis
#

if hoppers work it'll be fine.

dawn zealot
#

could just script that

#

cuz iron golems have a inventory component im pretty sure

#

so just get Mainhand

crisp trellis
#

nahnah

#

I made a like magazine system

inland merlin
#

i already know about herobrines chestform, its not that for my chestshop

crisp trellis
#

artillery foundation
artillery storage
artillery gun (entity)

#

the entity basically tests for items in the artillery storage connected to an artillery foundation

#

then uses them

inland merlin
#

if we place a block on top of a chest, will it block them im assuming

crisp trellis
#

very useful for auto-cannons and flak

crisp trellis
#

had to make cooldowns for big stuff tho

inland merlin
#

ill just have to do that then lol recommend that

crisp trellis
#

brilliant

inland merlin
#

done, lol no coding needed

crisp trellis
#

not too sure if it will cancel your gui tho

#

cuz from what I've seen, some stuff like hoppers cancel the gui when being moved & stuff

#

so I'm not certain but chests might auto-close if you place a block over them.

inland merlin
#

yeah, it pretty much just cancels their using of the chest when placing a block on top if already open

#

the block method is the easiest method

crisp trellis
#

well it was a good idea

inland merlin
#

yeah lol

crisp trellis
#

I wonder what you're using...

#

gui right?

#

how do you make the gui open tho

inland merlin
#

actionform / modalforms for chestshop

crisp trellis
#

like how do you make the player open chests

#

via an item?

inland merlin
#

sign

#

interact

crisp trellis
#

ohh

#

so it is using actionforms

#

I am new to custom ui.json stuff

#

working on modular helmets rn

inland merlin
crisp trellis
#

figured out a way to put a custom button on screen that works

inland merlin
#

just sell for now, maybe adding a buy option from players down the road. but its gonna be part of my own essentials

crisp trellis
#

quite a unique UI btw

#

not all buttons which is hella inconvenient

#

mostly text is good

inland merlin
#

well, its mostly body and then the buttons down below

#

lies lol

crisp trellis
inland merlin
#

i forgot its a modalform

crisp trellis
#

I have a similar system

#

or well, W.I.P

inland merlin
crisp trellis
#

lots of bugs but it tests player inv for compatible stuff and displays it in the UI where you can select what to attach.

inland merlin
#

oh nice

crisp trellis
#

item tags are a lifesaver

#

love ts

crisp trellis
inland merlin
#

i made a system that basically copies donut smp generators/spawners system

#

but thats for another time lol uses herobrines stuff

crisp trellis
#

great idea implementing a number system for purchases

#

hella annoying in other servers where you gotta press the button 1k times for building blocks

inland merlin
#

yeah, thats why the chestshop is powerful, its also got a lock item inside the chest to protect it from players accessing

crisp trellis
#

interesting

inland merlin
#

just makes it easier, it auto places into the chest

#

and it doubles as a lock for other normal chests lol

#

not just chestshops hehe

#

yeah the method we figured out earlier in this chat about getting the data from the shulkers is insane lol

#

literally have to copy and damage the shulker as an entity, and then get each entity item information etc etc... and then populate that lol

#

things we do in bedrock

crisp trellis
#

I have

#

an 80% understanding

#

of what you just said

#

AHHH

crisp trellis
inland merlin
#

the shulker drops its stuff when damaged enough

#

applyDamage

crisp trellis
#

automate the shop system and abuse the copper clankers

inland merlin
#

its actually not a bad idea to use them

#

to auto fill

#

from behind or something

crisp trellis
#

I love Minecraft

inland merlin
#

as i have landclaims/skyblock claiim protections as well

crisp trellis
#

we finally have minimum-wage 1940s j*bs

inland merlin
#

skyblock i have made has a full protection (with limits on script api)

prisma shard
#

Will adding a tickingarea load the specefic coordinates or will load the entire chunk? In case of loading the chunk, Do i have to add tickingarea as a circle? What's difference between a circle ticking area and and position tickingarea? If i add the tickingarea, Then If i remove the tickingarea afterwards, Will the postion/chunk still be loaded?

inland merlin
crisp trellis
#

you have a limit tho

prisma shard
#

Are you sure

crisp trellis
#

I think it was 5

prisma shard
#

Ok ty

#

? If i add the tickingarea, Then If i remove the tickingarea afterwards, Will the postion/chunk still be loaded?

inland merlin
#

isn't the limit 10 for ticking areas or is it based on chunks

crisp trellis
#

I think both

#

depends how big the areas you load are

inland merlin
#

thats fair

crisp trellis
#

I used to do commands

#

not sure if it's a per-player limit or universal limit tho

inland merlin
#

native so much better,

if yall doing a server, endstone /c++ and python is way faster for plugins...

ninjallo has been converting all his script api to endstone python pluigins for his bedrock server and its actually much faster and better with the tps, as he has around 15-20 people on at all times

#

i wish we could do more with script api

crisp trellis
inland merlin
#

if i could just do plugins for endstone i would, script api just has more people using the addons lol

crisp trellis
crisp trellis
crisp trellis
#

basically keeps a console log of their clanker work

inland merlin
#

helpful

crisp trellis
#

you can divide them into groups and name the monitoring item too, I was gonna use it to determine which ones of my workers were building the shells and which ones loaded em'

#

gonna eventually make them operate the cannons too but maybe in the future, I'm feeling lazy.

crisp trellis
#

think about it, we got auto-crafters, clankers, and faster minecarts for item transport.

inland merlin
inland merlin
#

oh wait for java only?'

#

or does bedrock have that option

crisp trellis
#

nah, bugrock has it too I think

inland merlin
#

lol that would be insane tbh

inland merlin
#

imagine, infinite speed + the new spear coming out lol

#

its damage is based on speed

crisp trellis
#

now I'm curious wether the clankers can open minecart and boat chests

#

where are the limits

crisp trellis
inland merlin
#

lol

crisp trellis
#

bcuz you literally are not rendering the chunk anymore

#

without tickingarea I don't think anything works.

inland merlin
#

it would be a bad practice to keep it loaded

crisp trellis
#

ugh, why does bugrock have to have seperate simulation render distance and block render distance

crisp trellis
#

it would be insanely laggy tbh

#

because the server needs to run it basically 24/7

#

straining background RAM

#

and slowing down lots of other stuff

inland merlin
#

yup

wary edge
#

It also makes sense for performance.

gaunt salmonBOT
prisma shard
#

How can i get the center of a chunk

#

minecraft wiki says the chunk height is 384, so the Y would be middle of 384?

#

does the height start counting from 0 or all the way bottom...

#

if the X or Z of a chunk cordinates is js Math.floor(X / 16) * 16);
the center would be more 7.5 than that?

#

so

 { x: chunkX + 7.5, y: 64, z: chunkZ + 7.5 }
#

64 seemed as a placeholder i still dont know about Y

#

well uh is that Math.floor(X / 16)

#

or do i multiply again 16

devout sandal
spice finch
snow knoll
#

Now that applyImpulse is available for usage on players, what is the point in even using applyKnockback on players
Any advantages the latter has over the former?

jolly citrus
#

is there any native way to apply knockback with custom friction to mobs

magic peak
#

hi

#

i’m back

frosty sierra
#

is there any way that code only runs, when a special command is in the chat

inland merlin
snow knoll
#

Understood, wasnt even my question but I never really knew what applyImpulse does better besides format and that everyone says that it is better

jolly citrus
snow knoll
frosty sierra
distant tulip
#

The only place you can change drag, gravity and that kinda of stuff is with projectiles

inland merlin
#

As a 3d object

slow walrus
distant tulip
#

I did 😅

#

Sorry

distant tulip
jolly citrus
#

ehh well my workaround is good enough

#

so it's alright

#

only issue is it's a little twitchy on the hit player's end

#

in vanilla projectile hurt to player will not give them invulnerability ticks,
but my custom pvp script uses applyDamage to damage players and currently projectile hits also cause invulnerability for 10 ticks no matter what. is there a way around this

#

does healing the player a little bit afterwards still work was that ever even a thing because I remember creating a combo gamemode by giving players regeneration every tick

#

eh well i tried doing this

victim.getComponent("health")?.setCurrentValue((victim.getComponent("health")?.currentValue ?? 0) + 0.01);

but it doesn't seem to fix it

#

dont comment on the optional chaining pls im lazy 😢

spice finch
noble ibex
#

Is there a way to detect an interaction between a vanilla item on a vanilla block?

jolly citrus
#

playerinteractwithblock

#

and then get the item they used with selectedslotindex and compare its typeid

noble ibex
#

thank you

noble ibex
#

Nevermind I got it, thanks again

jolly citrus
inland merlin
jolly citrus
#

that will indeed work yes but i dont wanna do that because it doesnt look like normal dmg

#

there isnt even a red fade animation its just the hurt cam animation when u get hit + hurt color on skin

crisp trellis
#

man I wish I was good at texturing

jolly citrus
#

if its health doesnt lower as a result of damage apply it wont do any of the hurt events

inland merlin
#

Oh lol, well ignore my a**

jolly citrus
#

haha it’s ok I appreciate you taking the time to answer anyway

crisp trellis
#

if only I was good at texturing 🥀

inland merlin
#

👀

shy leaf
#

i remember why i dont open ts in vscode 😭

#

its a prototype wtf mate

round bone
shy leaf
#

yeah well i just decided to do that later

#

it compiles anyway

#

it might be annoying to catch errors though

round bone
#

Or you can simply add ts-ignore to it.

shy leaf
azure lichen
#

What causes this problem?

shy leaf
jolly citrus
# azure lichen What causes this problem?

What the guy above me said

You have function f that takes parameters x, y, z for example (f(x,y,z)). But when you call that function you call it with more arguments than what the function will actually make any use of e.g. f(1,2,3,4) would leave 4 unused because there’s no defined argument to catch the value of the 4th input which will result in this error

#

I still dont know what the difference between a parameter or argument is to this day so excuse my bad terminology 😢😢

mystic harness
#

do dynamic properties really reset after pack version update?

jolly citrus
#

Or at least when using a different manifest or when the pack is applied to another world

#

Note that pack version means the release version of the addon, not the version of the game it is meant for

fallen cape
mystic harness
#

i just changed version number and still keeps resetting my dynamic property idk why does this happen

slow walrus
grand heart
#

cannot kick player?

agile lance
vast grove
#

One such idea that brings to mind is to send a title message, store it and read off the binding in the inventory screen.

distant gulch
#

how do i get when the is when get the how is get the when?

#

and why does my script api keep saying "requested version: UI: 1.3.0" and not running the script api

.....
         {
            "type": "script",
            "language": "javascript",
            "uuid": "192d5bd8-9530-4db0-b4b8-78414820aa7f",
            "entry": "scripts/main.js",
            "version": [
                1,
                0,
                0
            ]
        }
    ],
    "dependencies": [
        {
            "uuid": "49a5e694-a0c9-4171-9047-7453a3d2d734",
            "version": [
                1,
                0,
                0
            ]
        },
        {
            "module_name": "@minecraft/server",
            "version": "2.1.0"
        },
        {
            "module_name": "@minecraft/server-ui",
            "version": "1.3.0"
        }
    ]
}
stoic coral
#

I hate this method of fighting.

jolly citrus
#

Wdym method of fighting

#

Obviously im not gonna leave the knockback values at that lmao it was just to exaggerate how it differs from vanilla

broken pawn
#

starting from @minecraft/server 2.1.0

#

cmiiw

distant gulch
vast grove
# agile lance Could you elaborate?

Nope because JSON UI is one of the things I haven't learned. But the idea is a persistent variable you set to a binding from the title binding and u read that persistent binding to change the UI. This question is more suited for #1067869374410657962 anyways.

#

Oh crap u already asked there

tidal wasp
jolly citrus
shy leaf
#

the devil even

#

is propertycomponent

jolly citrus
#

Right

#

I mean ots from

#

Setpropertyoverrideforentity

#

Someeyhing likecthat

warped kelp
#

Is there no documents or previously answered questions about shooting extra projectiles as an attack?

runic maple
jolly citrus
#

nvm it does

runic maple
jolly citrus
#

but i swear i get bowspammed on faster than 10 tick

runic maple
#

Lol

shy leaf
magic peak
#

Good morning everyone

frosty sierra
#

does anyone know why this is not in my behavior packs section at the preview version

mellow socket
#

Why does mc edu keep removing older script verions

lethal bramble
mellow socket
#

All of my old worlds keep breaking cuz mc keeps removing the older script version
And i have to use edu for work reasons

ocean escarp
#

Never done lists before in js, is this how I can format it?

woven loom
#

, not ;

ocean escarp
#

Thanks

ocean escarp
#

@woven loom
So something like this?

woven loom
#

uh in this u have to remove ,

ocean escarp
#

....

#

Where

#

Also can I even define a class inside a callback?

woven loom
#

ye

ocean escarp
#

Would you believe me if I told you I'm new to js??

woven loom
#

i have seen u here tho

ocean escarp
#

To look at maybe

#

Never actually wrote proper code

woven loom
#

hm

ocean escarp
#

Im just using GPT to research core concepts of the language and then trying to apply them to my own scripts (probably unsuccessfully)

woven loom
#

oh well u should remove those commas that u have used in ur class

ocean escarp
woven loom
#

ye

ocean escarp
#

Tbh this isn't even a project I'm likey going to continue with

#

I just want practice

#

I do want to make a classes system but my brain will never get used to mass coding mechanics and tag systems

#

It's funny.. I finally have enough knowledge to code stuff in but at the end of the day I still cant make anything

woven loom
#

its not that hard, ypu can do it

ocean escarp
#

Im just scared of having a 1000+ line source file

#

I hate being unorganized but I don't even know how I would organize

grand heart
#

fastest most efficient way to clear an area?

woven loom
woven loom
grand heart
woven loom
#

split into smaller chunks and use fill cmd

warped kelp
#

Helloo. I have a question, what JS test was about calling upon events within an entity? Or rather a custom event/component group?

#

I know it's either using scriptevent or custom commands but I forgor :(

#

Nevermind, it is scriptevent and I still gotta add the component groups affected by such.

grand heart
#

is it right player.isValid returns false if the player already quit?

floral copper
#

guys ive seen people use the Map() thingy many times in scripts and stuff but ionno how it works and it got many types like WeakMap() nad stuff so can someone explain what it is and how i can use it please?

valid ice
vast grove
mystic harness
#

are personal compass possible atp (like force point the compass to specific direction, for specific player)

kind zenith
#

how i do change vanilla block loot? if hardcoded say "y"

floral copper
#

thanks a lot brother

round bone
midnight ridge
#

can we check if the bundle has item or it is empty using script api?

empty yoke
#

Is it possible to recover the target via scripts?

midnight ridge
empty yoke
midnight ridge
jolly citrus
#

is there a way to ensure a player has fully loaded into the world before i try sending them a message

distant tulip
jolly citrus
#

is there any way to set blocks in unloaded chunks

#

or to like load them first i mean

#

i would use tickingareas but can those be created in unloaded areas?

wheat condor
#

fastest way to get if an entity is hostile or paceful without cheching typeIds?

wheat condor
jolly citrus
#

cant entities load chunks

#

custom entities

jolly citrus
wheat condor
jolly citrus
wheat condor
#

idk

jolly citrus
#

there's a component for entities that lets them load ticks

jolly citrus
#

yeah so why would that get patched

#

unless you mean removed

#

its not a bug or a glitch

wheat condor
#

its able to keep chunks loaded not to load new ones

#

but if you watied 2 ticks it could

#

What's the fastest way to get if a mob is hostile or not?

jade grail
#

Has player.isOp() been removed?

round bone
jade grail
#

Uh so now how can I check if the player has operator or is like the owner?

prisma shard
jade grail
#

That will return true or false right?

prisma shard
#

Yes

jade grail
#

Kk ty

rare plume
round bone
thorn flicker
distant tulip
#

beginners in typescript, yeah
i can say people who uses ts are beginners in js and that will have some trouth to it

thorn flicker
#

thats not what he said tho

distant tulip
#

i know

#

i am saying he is wrong

thorn flicker
distant tulip
#

the reality is that both experienced and beginner developers use both languages for different reasons

jolly citrus
#

can i somehow detect where performance spikes detected by watchdog come from

prisma shard
dusky flicker
#

i thought only Date was accessible and usable to track time

dusky flicker
#

seriously

mystic harness
#

how can i locate biome/structure and parse the coordinates of the result

mystic harness
#

and also can i give lodestone compass set to a specific coordinates to player thru scripts?

prisma shard
#

im not sure tho

neat hound
#

Hey... dipping my toes back into add-ons so had to update a few things... any idea why vscode giving me this? I did update the NPMs where they normally are.

#

Did something change?

jolly citrus
#

I don’t know what @param does but

#

If you’re trying to use Vector3 to declare the type of something as equal to the type of that

#

Then it might be the problem

#

Vector3 is only accessible as a type now not as a constructable class

open urchin
jolly citrus
jolly citrus
warped kelp
#

Is there a way to detect a player's EXP level?

snow knoll
warped kelp
#

Neat. I'll try play with that..

#

.. hmm. This might be out of my league

snow knoll
#

Well, what is it?

warped kelp
#

Detecting if player's EXP level is 100 and allowing entity that's detecting the level to be damaged from the level 100 player

#

Maybe scoreboards...

#

Player at lv100, give score of 1. If entity is hurt with the player with score of 1, deal damage to self .3.

snow knoll
#

Making an entity that can only be hurt by a player with level 100 <

warped kelp
#

The entity in question

snow knoll
#

I feel like scoreboards would overcomplicate things
Tags would work just as well, imo🤷‍♂️

warped kelp
#

Ah, true.

#

Honestly found out how good scoreboards are and I've just been spamming it everywhere I do

snow knoll
#

I actually noticed

warped kelp
#

Need a checker? Scoreboards.
Need a counter?
Scoreboards
In need of a "detector"?
Scoreboards

#

Made the phase 2 checker with script and scoreboard so much easier

snow knoll
#

Dynamic properties are better for scripting tho

warped kelp
#

Yeah I'm still at the surface of scripting

snow knoll
#

I can tell

#

Mainly since the answer to your question is right here in the documentation

warped kelp
#

Yeahh. Anywho, I'll do the entity first before I do any fancy magic...

snow knoll
#

If you ever have a question on scripting, I would strongly reccomend going to the entity and player documentation first

lethal bramble
warped kelp
dusky flicker
#

probably the import isnt getting the type but the class constructor instead, which doesn't exist anymore

jolly citrus
#

Yea my solution is redundant tho

jolly citrus
dusky flicker
#

aa you've mentioned

jolly citrus
#

Not vector3 not being accessible

dusky flicker
#

so the project doesnt figure it out

#

maybe its at a wrong directory

jolly citrus
#

Yea

dusky flicker
#

i'd try first restarting vscode

#

i had issues where it failed for some unknown reason

#

i restarted it and it worked

jolly citrus
#

If it for some reason only installs it in @minecraft/server-ui\@minecraft/server

#

Bc it did that for me

dusky flicker
#

weird as fuck

#

for me that doesnt happen

jolly citrus
#

Yeah it happens for me every time I install the modules

#

I just manually perma delete the other server module

dusky flicker
#

isnt that a problem with npm?

#

i only install with bun

jagged gazelle
#

I'm back??

mystic harness
#

is there some resources abt dynamic particles (or particles that can be seen by specific player/s)

woven loom
#

yes

gaunt salmonBOT
gaunt salmonBOT
shell sigil
#

.dropdown("§lButton 1", keys,1)

Why this doesn't work

broken pawn
shell sigil
valid ice
steady sluice
#

Does anyone know if playAnimation can be shown only to a specific player

distant tulip
frosty sierra
#

can anyone tell me what this says

distant tulip
fallow rivet
distant tulip
#

Heya!
Sadly we still cannot

fallow rivet
#

Whats this?

distant tulip
#

return the translation key for said item/block/some other stuff

open urchin
#

for data driven stuff it's the value of the display_name component

fallow rivet
open urchin
#

that would be item.apple.name i think

thorn flicker
distant tulip
#

I don't know the key from memory lol

fallow rivet
#

I haven't done anything script-related for about a year. What else has been added that is significant besides /commands?

frosty sierra
#

beacuse i dont understand what io need to change

distant tulip
#

I just said what

frosty sierra
#

yes but i dontr know if i did it right

distant tulip
#

Try and see

#

Or just send that part of the code

frosty sierra
#

im new at coding so dont expect much

distant tulip
#

Nothing wrong with that

frosty sierra
distant tulip
#

Send the code as text, i am at my phone

small river
#

can someone tell me why it's not working please ? (tryna title something on the shooter of a projectile) `import {
world,
system,
EntityDamageCause
} from "@minecraft/server";

const bullets = ["minecraft:arrow","sample:bullet"];

world.afterEvents.entityDie.subscribe((event) => {

const {
    damageSource,
    deadEntity
} = event;

const {
    cause,
    damagingEntity,
    damagingProjectile
} = damageSource;

if (cause === EntityDamageCause.projectile && bullets.includes(damagingProjectile?.typeId)) {

    damagingEntity?.runCommand("title @s title SampleTitle");

}

});

world.afterEvents.projectileHitEntity.subscribe((event) => {

const {
    dimension,
    hitVector,
    location,
    projectile,
    source
} = event;

const entityHit = event.getEntityHit()?.entity;

if (bullets.includes(projectile?.typeId)) {

    source?.runCommand("title @s title Hit");

}

});`

mystic harness
#

can i give lodestone compass set to a specific coordinates to player thru scripts?

wary edge
#

#1067876857103536159

digital field
neat hound
# jolly citrus I don’t know what @param does but

Not since May, but code had not changed and it was not doing it before. @param is used in jDoc which forces me to comply to definitions, its like having a typescript big brother but still using js. If I move a project to where it shared a closer top folder with the NPMs, then there is no error message. I just need to work out why all of a sudden (but not all of a sudden, a change may have happened a few months ago within VSCode), it is doing this. I do not want to have a nodes_module folder in every project. But if it is needed now, I need to make a deploy system for it.

neat hound
# open urchin sometimes i have to open the module's index.d.ts file in vscode before it realis...

I am using JS, not TS, so I do not have that. I will probably need to work with how far away in a folder structure works. I just know, that last May it was fine and now it is not, but I need to make sure I did not move the node_modules folder out of scope. I do recall building a deploy system for my lib files, so I can make changes in one place and have it copied to all folders using that file

neat hound
valid ice
#

There is a global node_modules folder for your PC there

neat hound
olive sphinx
valid ice
#

C:/users/you/node_modules

neat hound
# valid ice C:/users/you/node_modules

Nope, don't have one there. And all my stuff is c:\projects. I do not like putting this stuff behind the wall of my ID... in case there is problem one day...

neat hound
# jolly citrus You might wanna manually look into your node_modules folder as well I encounter...

I see that it, debug-utilities and admin do that. I do not need admin, so deleted it.. and just redid them all. So do you fix it everytime, move the index.d.ts and other files back out of the subfolders?

After studying it for a while, it may be valid per the wording of the package-lock info. Server has "peerDependencies" and this does not create subfolders, but server-ui has "dependencies" and it looks like it creates it do define it, in case you do not have them. For some reason, I think that has something to do with it.

neat hound
#

Success in case anyone else runs across the same issue (vscode not finding the installed NPMs for @minecraft/server).

  1. Recreated node_modules (server, common, vanilla-data, server-ui) at the script folder level, but fixed server-ui to not have it's own node_modules folder*(not sure this is a good thing yet, may affect dependencies - will test this again - may not have been an issue at all)*

  2. One by one, moved node_modules folder, package-lock.json and package.json to the outside parent folder , making sure to update the name: in package-lock and .package-lock.json to the parent folder name and verifying still working.

  3. Once I had it at the desired folder level, made sure code in both repo subfolders acknowledged it

olive sphinx
#

If you use Local NPM and not Global

neat hound
#

I do not know enough about how it all works and how to make anything see local or global. From observation, I think I figured a few things out.

dusky flicker
#

bun i -g package

frosty sierra
empty yoke
#

I'm using the shoot method to fire a projectile via scripts, but I've noticed that the projectile only rarely collides with entities. Do you know why?

olive sphinx
empty yoke
# olive sphinx Might be the entities Collision Box

The projectile has a collision of 0.35 but it seems to pass the entity many times over, only with the runtime_identifier on arrow the projectile behaves well as arrow, but I can't use it so I don't understand because with the scripts the projectile doesn't seem to work correctly

prisma shard
empty yoke
dawn zealot
prisma shard
# empty yoke

Myabe try using "minecraft:is_collidable": {} component

#

Since your problem is your projectile doesnt collide with entities, this might fix it

covert beacon
#

I use afterEvents.playerInventoryChange, but it always runs when the player joins the event. How do I make it run only when the player is already loaded in the world?

frigid rampart
#

How do I make it so that when the player interacts with a block, the item ID that was in their hand when they interacted appears in the chat?

tidal wasp
#

How would i tell how long a player has been sneaking?

#

Or at least store data on how long a player has been shifting

#

And save that data per player

#

The only idea I have rn are tags

distant tulip
#

Use that and calculate the difference

mint cairn
#

How can I send a scriptevent with the player as the source entity?

pale terrace
#

its possible to kill an active custom particle through scripting?

buoyant canopy
#

how to unsubscribe from an event?

#

it's not like system.clearRun

#

here it says that event.subscribe returns a callback

#

unsubscribe takes a callback

thorn flicker
buoyant canopy
thorn flicker
#

yeah

thorn flicker
buoyant canopy
tiny quest
#

o

buoyant canopy
#

hmmm, i think this one deserves a post

vast grove
verbal aurora
#

whoopsies

buoyant canopy
#

i have changed it to this, and i think it works?

vast grove
#

Actually nvm

buoyant canopy
#

how do you explain that?

buoyant canopy
thorn flicker
#

why did he leave lol

tidal wasp
#

Do runIntervals get canceled when the playerButtonInput detects the player inputs another button?

wary edge
#

You need to explicitly stop them.

tidal wasp
#

Dammit

wary edge
#

What are you trying to achieve?

tidal wasp
#

I'm trying to detect when the player is shifting for x consecutive seconds

#

While wearing a specific set of boots

jolly citrus
#

It really does speed up things so why wouldn’t one use it

thorn flicker
shy leaf
#

its more reliable and easier to debug that way

thorn flicker
shy leaf
#

yes i did

thorn flicker
tidal wasp
#

Ain't you used to be a duck

thorn flicker
thorn flicker
#

thats a duck right?

tidal wasp
#

Aye bro wtf they do to you

shy leaf
#

thats a goose

#

this is also a goose

thorn flicker
#

kinda hard to tell without seeing the full body

#

and size

shy leaf
#

thats true

thorn flicker
#

and the fact its a simplified drawing

tidal wasp
#

If I set a dynamic property to system.current tick it won't change every time I call it

#

Right

#

Well call to get the value of the dynamic property

thorn flicker
tidal wasp
#

Ok

thorn flicker
#

just because of the eyes

jolly citrus
#

But In my opinion there’s no point in avoiding ai ’just because’ since you won’t survive in the industry for very long by doing that at least not on a higher level assuming you have competitors

#

It’s a globally inevitable change we’ll have to adapt to over time no matter if we like it or not

thorn flicker
#

yes, that's the reality of it.

#

however I'm not going to sacrifice my enjoyment of creating things just for competition, it feels great knowing I don't use ai in my creations.

runic crypt
#

How to use /connect in scripts api ?

lethal bramble
#

but if ur asking how to run it, dimension.runCommand("connect")

distant tulip
#

I don't think that would work

#

It need higher permission level

inland merlin
#

how do i get glyphs to work on

player.onScreenDisplay.setTitle

it just doesn't show, but works on chat

#

for rawtext

#

using for sidebar

#

should it work the same?

warped blaze
#
- Released AABB from beta to v2.4.0
- Released Entity.getAABB from beta to v2.4.0```
what's AABB?
woven loom
#

bounding box

inland merlin
#

hmm thats strange lol, its custom ones.. so maybe?

subtle cove
#

its a glyph so it should work same way

inland merlin
#

ok, im probably just doing it wrong thanks for testing for me

turbid gulch
#

is it possible to prevent player from picking up an item?

frosty sierra
#

waht does this mean

#

i think my permission level cant be zero right?

#

but what is it then

dawn zealot
#

permissionLevel: CommandPermissionLevel.Any,

#

then import CommandPermissionLevel

shut vessel
#

hi, who know how to get a modified music on a disc ?

frosty sierra
gaunt salmonBOT
# frosty sierra is this what you mean?

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 1 errors:

index.js:12:48 - error TS2345: Argument of type '{ name: string; description: string; permissionLevel: CommandPermissionLevel; optionalParameters: { type: string; name: string; }[]; }' is not assignable to parameter of type 'CustomCommand'.
  Types of property 'optionalParameters' are incompatible.
    Type '{ type: string; name: string; }[]' is not assignable to type 'CustomCommandParameter[]'.
      Type '{ type: string; name: string; }' is not assignable to type 'CustomCommandParameter'.
        Types of property 'type' are incompatible.
          Type 'string' is not assignable to type 'CustomCommandParamType'.

12     init.customCommandRegistry.registerCommand(helloCommand, helloCustomCommand);
                                                  ~~~~~~~~~~~~

Lint Result

There are no errors from ESLint.

tidal wasp
hazy kraken
#

nvm

#

lololol

grand heart
#

does script api know URLSearchParams?

open urchin
#

No, that's a web api

grand heart
#

aww sad

grand heart
open urchin
#

That is a part of normal javascript so it will work

amber granite
#

hello

#

guys i forget how to script

#

I need smol reminder

hazy kraken
dusky flicker
#

in general if you know js, you might know how to code with the api

distant tulip
#

Kiro every month

distant gulch
#

its impossible for me to forget

hazy kraken
#

It takes like 10 plus years of not coding to start forgetting

#

🥀

distant gulch
#

but i started coding at 8

#

and never stopped

dusky flicker
distant gulch
#

my github was created in like 2023 or 2022

distant gulch
#

i have like 3 github accs

dusky flicker
distant gulch
distant gulch
#

this is my old github

#

which was created when i was 11

#

and you can see i joined discord in 2020

#

which was the same year i started making 3D Guns

dusky flicker
#

do you use something else?

#

i got interested to see what gitlab has

distant gulch
#

i dont use git in general

#

anymore

dusky flicker
#

so what do you use?

#

how do you version your code?

#

or do you use any concurrent?

distant gulch
#

huh?

#

what r u talking abt

midnight ridge
#

can i track the light of Chunks using script?

frosty sierra
#

Can anyone tell me how i casn save the posotion of a player

midnight ridge
# frosty sierra Can anyone tell me how i casn save the posotion of a player
import { world } from "@minecraft/server";

// save them :)
function savePlayerCoords(player) {
    const loc = player.location;
    
    const coordData = {
        name: player.name,
        x: Math.floor(loc.x),
        y: Math.floor(loc.y),
        z: Math.floor(loc.z),
        dimension: player.dimension.id
    };
    
    world.setDynamicProperty("playerCoords", JSON.stringify(coordData));
}

// get them :)
function getPlayerCoords() {
    const savedData = world.getDynamicProperty("playerCoords");
    
    if (savedData) {
        return JSON.parse(savedData);
    }
    return null;
}```
#

you can use those functions in your project

frosty sierra
#

thanks

lethal bramble
#

it depends whether you want to save them on the session or on disk

frosty sierra
lethal bramble
#

fill blocks from where

#

just that one block?

frosty sierra
#

yes its only one tiome for now

lethal bramble
frosty sierra
#

but its player.location

#

i think i need to change something there

lethal bramble
#

levo included that in their original example. you need to stringify the saved dynamic property

#

JSON.parse

#

i mean parse

frosty sierra
#

okay i think im not that far at making behavior packs

#

ithink icant do that now i will search and collect information

lethal bramble
#

be mindful that savedLoc also includes the player id and dimension

frosty sierra
#

so the fill blocks at the brackets from safedloc

lethal bramble
#

basically

frosty sierra
#

okay thank you

lethal bramble
#

just replace player.location with savedloc

frosty sierra
#

this is what i tried but i will give up and try tomorrow

hazy kraken
#

is there a way we can get shelf inventories? or anything?

midnight ridge
hazy kraken
full idol
#

Is there a way to easily desaturate a player's view? Like make it BW or just less... vibrant?

wary edge
full idol
#

AH yeah kinda needs to be dynamic. Thanks, I'll keep investigating!

hazy kraken
#

is there a way to stop a entity like a boat or armorstand from taking damage?

shy leaf
#

they have different hp mechanics

subtle cove
tender pier
#

Is MinecraftDimensionTypes useless now?

subtle cove
#

perhaps for quite a long time until custom dimensions would be even possible

tender pier
#

I mean if it was deprecated or something

#

I get a log using this

#

Not sure what was the replacement

subtle cove
#

i cant find it from typings as well, but the DimensionTypes.getAll() is still there

amber granite
gaunt salmonBOT
amber granite
#

Thx u

jolly citrus
#

is there any event that happens before /reload runs

#

that can be listened for

amber granite
#

What u mean ?

#

U need to detect when player used reload?

jolly citrus
#

whenever reloading of the scripts happens

#

right before it

#

because i wanna save data

#

maybe i could just wrap it around a custom call

#

and then use that instead of native /reload

#

idk if scripts have privilege to run /reload tho

amber granite
#

._.

#

Ma man

#

U can't predict something didn't happen yet

jolly citrus
#

thats not what i mean....

#

smh

#

there's a difference between an engine firing to event listeners AFTER the action has been done and right BEFORE it

amber granite
#

So u need data to be saved before reload get launched

#

That what u want

jolly citrus
amber granite
#

Yes u can't

jolly citrus
#

okay

amber granite
#

But possible

jolly citrus
#

??

#

you just said it's not

amber granite
#

Directly

#

There is no direct way i mean

#

Use ChatSend beforeEvent

jolly citrus
#

or not the call but the action of scripts being reloaded

amber granite
#

So /reload call is basically a chat message

jolly citrus
#

no it's not

amber granite
#

Make ur own reload then

jolly citrus
#

commands and chat messages use a completely separate handler in mcpe

jolly citrus
amber granite
#

Oh :-: then do it

#

Maybe there is event for commands

jolly citrus
#

there isn't

amber granite
#

Lemme check

#

Ok , ._. u don't have another option

#

@jolly citrus