#Script API General

1 messages · Page 126 of 1

fresh comet
#

That's read only

thorn flicker
fresh comet
#

Oh right

thorn flicker
#

i dont think you can directly modify the potion's level but you can replace it with a new one with this.

devout sandal
#

Okay, what about tipped arrows..? do those use the potion component?

thorn flicker
#

you can use the replaceItem command instead

noble ridge
#

Thank you!

devout sandal
#

im getting potion component undefined..? im remaking the loot vaults to be reusable so its in the onPlayerInteract hook of the blocks custom component registry.

thorn flicker
devout sandal
thorn flicker
devout sandal
#

it doesnt...

thorn flicker
#

🤷‍♂️

#

my bad

#

I guess you would need to use commands

devout sandal
#

Can i not use the LootItem function? Im relatively new to scripting so idk how to do some suff

devout sandal
thorn flicker
#

good idea

#

create a loot table, then use loot table manager to get the itemstack from it

devout sandal
thorn flicker
thorn flicker
devout sandal
devout sandal
thorn flicker
devout sandal
devout sandal
devout sandal
# thorn flicker sure, share it

Ok, hold up.. I think I might have figured it out… I’ll try it when I get home in a few hrs and update youXD thanks again for your help

#

I’m iterating through the itemstack array, and creating a NEW itemstack with that itemstack iterations typeid and amount, and then dispensing THAT. I should just be dispensing the original iteration itemstack.. right..?

thorn flicker
#

the itemstack is already provided

#

plus the new itemstack you are creating wont magically get its data

#

i see why its not working now

devout sandal
#

So that’s gotta be the problemXD I FEEL SO STUPID!! Hahaha, ok well.. tysm for the help.

thorn flicker
granite cape
#

well well well

stray spoke
#

How do I place block in specific coords, tried getBlock to setType but errors if undefined

icy eagle
#

idk

stray spoke
#

Tf you mean idk

prisma shard
#

There's also setBlockType() too.

stray spoke
#

Did something like that but on entity.dimension, sometimes the getBlock returns undefined if block in that position didn't exist

stray spoke
prisma shard
stray spoke
#

maybe I can't use getBlock if its air

prisma shard
prisma shard
stray spoke
#

Oh alright, thanks again

devout sandal
midnight ridge
#

can we get the type id of the entity inside the monster spawner block?

weary merlin
#

It uses meta data which we can’t access you with scripting

thorn ocean
#

Alright, I need some clarification: I'm trying to optimize my script so the game can run better. When would be a good time to use runJob?

open urchin
# thorn ocean Alright, I need some clarification: I'm trying to optimize my script so the game...

Whenever you're doing a large amount of things at once that don't have to be done in a single tick such as filling in a large area

I have a script that resolves every block permutation in the game at once which causes the world to freeze for a few seconds as it's not going onto the next tick until the script is finished, if I used runJob I would be able to split the permutations being resolved between multiple ticks

thorn ocean
open urchin
#

for runJob you yield every time you want to give minecraft the opportunity to move to the next tick

system.runJob(myJob);

function* myJob() {
  doSomethingThatMightTakeAges();

  yield; // If the previous thing took a long time, the game will move to the next tick here. If there is still time left in the tick, the job will continue running in the same tick

  doSomethingElseThatMightTakeAges();

  yield;
 
  console.log("job finished");
}
#

most of the optimisation in scripting comes from reducing the number of API calls so that things take less time rather than using jobs to split something that takes a long time into smaller portions

thorn ocean
open urchin
#

yes, with intervals I often see people getting all players in the world every tick which is unnecessarily slowing things down
in that case you should have a players variable outside of the interval and update it whenever a player joins or leaves the world

thorn ocean
open urchin
#

If you have variables in the root of the file the value will last until you leave or reload the world

thorn ocean
open urchin
#

If it's a case where you need the players every tick then you'll have the same amount of data except the game won't have to create a new array of Player instances every tick

#

but if the interval stops at some point and the array of players is no longer needed, it would definitely be a good idea to remove the value e.g. set it to undefined

chrome gyro
#

Anyone got any theories as to why my projectile has an undefined owner??

       const projs = world.getDimension(dimension).getEntities({ location: loc, maxDistance: 64, families: ["projectile"] })
        if (!projs) return;
            projs.forEach(proj => {
                if (proj.typeId == "pro") {
                    const owner = (proj.getComponent("projectile")).owner
                    console.error(owner)```
#

Projectile is a custom one that doesn't have a runtime identifier in it, but I dont' think that would affect it.

snow knoll
chrome gyro
#

Forgot to add that, sorry. It's spawned through behavior.ranged_attack

#

Maybe there's a subvalue for keep owner? I'll check, I doubt it tho.

#

Yeah, nothing.

snow knoll
#

Are ranged attack behaviour entities usually unaffected by their weapons?

chrome gyro
#

Hmmm I think it depends on the projectile. You can define that the player not be affected or is affected in the components iirc.

#

So by definition it should store the owner... I have no idea what I'm missing tho.

#

Ugh, maybe I'll just reluctantly tag the owner as it leaves the "barrel". I feel like I'm going to lose a tick somewhere for some reason with that method though.

jade grail
#

i made a workaround tho

chrome gyro
#

Same, super clunky though. Having timing issues with it. handed off my entity spawn tag with a timer inside to a runinterval 😭

What was your work around?

jade grail
#

mine only works if its spawned with script api im prety sure

#

when i shoot projectile i set a owner dynamicproperty with the id of the owner

#

and then when i want to retrieve the owner it repeats through all entities in the world for that id

chrome gyro
#

I think that would work with projectiles from ranged attacks too.

I basically did the same, but with tags... I forgot why I did tags tbh.

chrome gyro
jade grail
#

Well i was also confused with the projectile owner

chrome gyro
#

Yeah, it should be working fine.

chrome gyro
jade grail
#

but u can check them before entity remove

chrome gyro
#

Oh wait there's why I used tags, I didn't want one more action that had to grab the closest entity so I did it with commands.

jade grail
#

which i use for kill detectioon

chrome gyro
jade grail
#

my addon isnt very optimised

#

but i think i should optimise it after it atually works...

chrome gyro
#

I've gotten stuck so many times doing that, I usually forget what my code means after I'm finished with a section so for me I have to do it up front 😢

uneven maple
#

Does anyone know how to change the value of a variable in the player's file using playanimation or any other method that isn't a property via the script?

chrome gyro
chrome gyro
uneven maple
#

I do this through playanimation and it works perfectly, but only for attachables, not for the player.

#

ops

chrome gyro
#

Some variables can't be changed that way.

#

I'm not sure then, maybe a better question for: #1070606638525980753 or #1067869288859447416

jade grail
#

turn the sync on so it also goes to the resource side

#

the property should be carry over and this can be changed using commands

#

event entity

uneven maple
jade grail
#

like if u made all the properties just numbers

#

theres a tons of combinations

uneven maple
# jade grail theres a tons of combinations

What I'm doing is complicated to explain via chat, but I need individual values ​​for each property, and there are more than 20 properties, so I have to do it this way.

jade grail
uneven maple
jade grail
#

nice

chrome gyro
jade grail
#

Dimension spawn entity

#

Then entity.getComponent('projectile').shoot(the settings here)

subtle cove
#

perhaps ```js
entity.getComponent("projectile").owner = player

jade grail
subtle cove
#

try it

jade grail
#

i have..

subtle cove
#

and...

jade grail
#

it dont work

#

when it should

#

we've solved the issues with around about method

subtle cove
#

bugged it is then

#

i just tested, it works... in beta

#
import { world, system } from "@minecraft/server";

system.runInterval(() => {
    const ovw = world.getDimension("overworld");
    const player = world.getPlayers()[0];
    if (!player) return;
    const arrow = ovw.spawnEntity("minecraft:arrow", {
        ...player.location,
        y: player.location.y + 5,
    });
    arrow.getComponent("projectile").owner = player;// may damage the player when not assigned
}, 40);

world.afterEvents.projectileHitBlock.subscribe((ev) => {
    const proj = ev.projectile.getComponent("projectile");
    world.sendMessage(proj.owner.name + ` owns the projectile`);
});
snow knoll
#

Im pretty sure it works in stable

thorn flicker
#

it does

silver agate
#

@clever smelt

clever smelt
#

on sum script api generak typeshi

silver agate
# clever smelt on sum script api generak typeshi

First add this field at BP manifest:


"dependencies": [
        {
            "uuid": "7641223a-0846-4c3a-97e3-9fb0a295269d",
            "version": [
                1,
                0,
                219
            ]
        },
        {
            "module_name": "@minecraft/server",
            "version": "2.3.0"
        },
        {
            "module_name": "@minecraft/server-ui",
            "version": "2.0.0"
        }
    ]
silver agate
# silver agate First add this field at BP manifest: ```json "dependencies": [ { ...

Like that:


{
    "format_version": 2,
    "metadata": {
        "product_type": "addon",
        "authors": [
            "VictãoSigma"
        ],
        "generated_with": {
            "bridge": [
                "2.7.52"
            ],
            "dash": [
                "0.11.7"
            ]
        }
    },
    "header": {
        "name": "Aurorian Progression",
        "description": "A pack that improves the craftings of the items in a realistic way. Progression was also reimagined to involve real life steps that ressemble the evolution of the humanity. Think you can beat this challenge?",
        "min_engine_version": [
            1,
            21,
            120
        ],
        "uuid": "c70b54ae-3208-4b49-9458-d881cfa0c69b",
        "version": [
            1,
            0,
            219
        ]
    },
    "modules": [
        {
            "type": "data",
            "uuid": "72cacb77-4e55-4276-9d2e-09ab743f20ed",
            "version": [
                1,
                0,
                0
            ]
        },
        {
            "type": "script",
            "language": "javascript",
            "uuid": "3aff7ca8-a207-45db-9625-63e7eb840569",
            "version": [
                2,
                0,
                0
            ],
            "entry": "scripts/aca_main.js"
        }
    ],
    "dependencies": [
        {
            "uuid": "7641223a-0846-4c3a-97e3-9fb0a295269d",
            "version": [
                1,
                0,
                219
            ]
        },
        {
            "module_name": "@minecraft/server",
            "version": "2.3.0"
        },
        {
            "module_name": "@minecraft/server-ui",
            "version": "2.0.0"
        }
    ]
}
silver agate
silver agate
clever smelt
#

okeh after doin the manifest stuff whaddo i do next

silver agate
clever smelt
#

oh so basically add scripting capabilties

#

ok

#

nexr

silver agate
#

Yes, now you create a folder called “scripts”

clever smelt
#

yes yes, ive made it in bridge

silver agate
#

After that you create a file called “main.js”

clever smelt
silver agate
# silver agate After that you create a file called “main.js”

And paste that on it:

import { world, server } from “@minecraft/server”;

system.runInterval(() => {
   for ( const player of world.getAllPlayers() ) {
   if ( player.isSneaking && !player.hasTag(“sneaking”) ) player.addTag(“sneaking”)
  else if ( !player.isSneaking && player.hasTag(“sneaking”) ) player.removeTag(“sneaking”);
  else continue;
  }
}, 1);
silver agate
silver agate
#

Also, it’s based on tags, so if player is sneaking, it adds the tag “sneaking”. If not, it removes the tag. So you won’t need further scripts

#

And can do the logic via commands

clever smelt
silver agate
clever smelt
#

so i can now run functions w that tag yes?

silver agate
#

Not the files & folders

silver agate
clever smelt
#

YOU

silver agate
#

No problem

clever smelt
#

i shall remember this act of kindness

silver agate
#

Appreciate

chrome gyro
chrome gyro
jade grail
#

how can i fix the issue of main hand being empty?

#

im using script api to detect the main items lore

wary edge
jade grail
#

i tried that it still throws an error

wary edge
jade grail
#

nvm getequipment slots never return undefined as even air isnt undefined

#

ive been using getequpmentslot instead of get equipment

distant tulip
#

Does lore return undefined or empty array?

thorn flicker
broken pawn
# jade grail

i'll go with

import{EntityEquippableComponent as eec,  EquipmentSlot as es}from"@minecraft/server"

let V1 = player.getComponent(eec.componentId).getEquipment(es.Mainhand)

if(V1)return

jade grail
#

mb forgot to mention i solved the issue

broken pawn
#

🗣️ 🔥 🔥

jade grail
#

sorry not mking it clear

broken pawn
#

i don't like using

import * as mc

tbh

jade grail
#

i use it so i dont need to import anything in the future

#

but its prob not the best idea

broken pawn
#

understandable, but if you create a big project, it could affect your file size

#

🗣️ 🔥 🔥

jade grail
#

is apply knockback better than impulse

broken pawn
#

what's the purpose you wanted?

#

smooth movement better with impulsr

#

like how transition sine in and out

#

set it to verbose may be easier for diagnose

#

but somehow you'll see some vanilla mob has error due ro their attack inverval never declared

subtle cove
fallow minnow
#

how can i use before player place and before interact with block to place a block?

#

currently im canceling block interactions

#

but that cancels block places

#

i need to cancel block interactions but let them place still

chrome gyro
#

(From a behavior ranged attack)

subtle cove
#

who's firing, player or entity?

#

i havent tested the projectile owned by a non-player tho

chrome gyro
#

entity

nova flame
#
"minecraft:cooldown": {
                "category": "cosmos:asteroid_annihilator",
                "duration": 0.5
            }```
 how do i like activate the cooldown using scripts
stray spoke
snow knoll
#

Its so helpful too, since you can give the item cooldown any length of time you want, independent of how long it would be with the item json

nova flame
#

thanis

snow knoll
#

No problem

stray spoke
#

Much useful than making manual cooldown that's buggy

snow knoll
#

Honestly, too true

#

And paired with itemStartUse and itemStopUse you can then set a cooldown after you release the interact button and even make the cooldown a dynamic length of time based off how long you held on the item

jagged gazelle
#

Even if it doesn't exist on any item...

stray spoke
stray spoke
snow knoll
jagged gazelle
dusky flicker
#

where is minecraft path located at windows?

#

its been a while i use windows for coding addons

#

so i forgot

#

i remember it used to be on app data

stray spoke
dusky flicker
stray spoke
# dusky flicker ?

Try localappdata%\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang

dusky flicker
#

hell yeah

#

i think i found it

stray spoke
#

Nicee

#

Yeah in modern windows it has id

dusky flicker
broken pawn
#

what's the difference between

function Test(){}
and
function* Test2(){}
dusky flicker
#

Test2 is returns a generator

stray spoke
#

What

dusky flicker
#

you can use it to yield values

stray spoke
#

Oh

dusky flicker
#

and then use them in a loop

broken pawn
#

i mean do it makes difference for low-end performance?

dusky flicker
#

function* EvenNumbers(){
let i = 0;
while(true) if(i % 2) yield i;
}

for(const n of EvenNumbers()) console.log(n); //1,3,5,7,9,11, etc

dusky flicker
stray spoke
#

@wild hazel your enemy @broken pawn ||(sorry for ping)||

dusky flicker
#

even though more flexible

#

because its a state machine

#

internally this kind of thing is implemented with an state machine

broken pawn
dusky flicker
#

so it executes a function, returns the actual state, you use it

broken pawn
#

then i'll stick with the first one

dusky flicker
#

internally isnt much different than simply

const obj = { generate(){return {completed: false, value: 5}}}

while(!obj.generate().completed) {
dothing();
}

#

but with more logic inside the obj

broken pawn
#

👍 🗣️ 🔥

dusky flicker
#

such as array

#

if it was already implemented on quickjs for sure

broken pawn
#

all i can say is:

there's 12 function running at runInterval (10 Tick)
and all of them uses "for(Let A of world.getAllPlayers())"

dusky flicker
#

but there are methods like filter, every, take, map, etc, theyre(i expect) lazy

#

so you can do something like

const generator = generator_func().map(f1).map(f2).filter(f3).map(f4).take(12);

#

and when looping it will execute a single loop

#

internally arrays can do the same but for each map, filter, and etc, its a loop by itself

#

with tends to be O(M*N)

stray spoke
#
function* Test2() {
  yield 1;
  yield 2;
  yield 3;
}

const gen = Test2();

console.log(gen.next()); // { value: 1, done: false }
console.log(gen.next()); // { value: 2, done: false }
console.log(gen.next()); // { value: 3, done: false }
console.log(gen.next()); // { value: undefined, done: true }
dusky flicker
#

with these generators its just O(N)

broken pawn
#

sounds like compressing everything into a single pack

dusky flicker
#

and when iterating use it

dusky flicker
dusky flicker
stray spoke
#

It's like a lazy function

broken pawn
#

imma about to take a nap sorry, here's 00.24

#

anyway, thank you for the explanation 🗣️ 🔥 🔥

stray spoke
dusky flicker
#

async functions are state machines as well

#

so its comprehensible it to be implemented like it internally

stray spoke
#

Yes you're right

snow knoll
woven loom
#

How do I see dps in a world? suggest me a software.

round bone
woven loom
#

Link

round bone
stray spoke
#

What's the problem in this:

player.onScreenDisplay.setTitle("§lUNVANISHED", {subtitle: msg}) //msg is already defined here

The log:

[Scripting][error]-TypeError: Native setter cannot be assigned null or undefined. Interface property ['stayDuration'] expected type: number (failed parsing interface to Function argument [1]).    at unvanish (main.js:39)
    at VanishFunc (main.js:60)
    at <anonymous> (vanishitem.js:9)
fallow minnow
#

Can having multiple of the same event cause any performance issues

wary edge
stray spoke
#

Is there an event about tick changes

wary edge
stray spoke
#

Like an event that activates repeatedly

#

Because system.runInterval crashes on mine when it's running too long

#

Or if there are workarounds

wary edge
stray spoke
#

Global system.runInterval every 5 ticks

#

Just updates the nametags

stray spoke
#

Oh wait I think its because of my creator setting's watchdog

runic crypt
#

How do I force a player's rotation?

thorn flicker
#

setRotation wont work

fallow minnow
#

do i HAVE to have a discord bot to link mc account to discord

round bone
#

Applications connections, your own system that pairs account?

#

It really depends on what you need

fallow minnow
#

just link discord account to mc xuid

#

i was thinking

round bone
#

For my server network, I am using an external backend to pair both services

fallow minnow
#

yeah

#

like

round bone
#

Are you using NoSQL or SQL database?

fallow minnow
#

well idk

#

im currently using supabase

#

will most likely switch to sql in the future

round bone
#
CREATE TABLE IF NOT EXISTS discord_connections (
    userId VARCHAR(20) NOT NULL UNIQUE,
    xuid   VARCHAR(20) NOT NULL UNIQUE
)
#

And then just check if any entry (XUID/Discord's user ID) already exists in a database

fallow minnow
#

ahh yeah

#

so wait

#

i would need to verify on discord though

#

i dont want people linking other players discord accounts

round bone
#

You also probably have to implement some code system, like you'll generate a code for 5-10 mins and user in Minecraft will have to type it in

round bone
fallow minnow
#

yeah i was thinking about that tbh

#

so in minecraft they do /link

round bone
fallow minnow
#

generates a code for their xuid in supabase

#

but then i do need a bot

#

to detect stuff in discord

round bone
fallow minnow
#

yeah true

#

itll be for 1 singular slash command

#

and other stuff

round bone
#

Install discord.js to simplify your process and it shouldn't take longer than 30-60 minutes tbh

fallow minnow
#

i just dont wanna host it on the same vps

#

so i might just buy anothe rone

#

unless u can host them for free somewhere

round bone
#

I host sometimes 2-3 containers on a single VPS and it runs smoothly

fallow minnow
#

im looking at Railway

#

its free supposedly

#

and looks super simple

round bone
#

I use OVHcloud most of the time, I don't really care about noisy neighbour problem tbh

fallow minnow
#

its crazy how cheap it is

round bone
fallow minnow
#

are u using vps 2026?

round bone
#

Regular customers are very few percent of their yearly revenue

round bone
#

😅

fallow minnow
#

yeah that one

#

vps-1

#

$4.90 a month

#

im surprised by it

round bone
#

You can't even buy a burger in McDonalds for that

#

😂

fallow minnow
#

vps-2 can handle 25 players with 19-20 tps dips

#

on a factions

#

7000 chunks loaded

#

and its freaking $7 a month

#

a realm would explode

#

they would go offline again if i tried that

round bone
#

Are you sure that you've configured your server correctly?

fallow minnow
#

well its not mine tbf

round bone
#

Oh, lol

fallow minnow
#

but they havent tested more than 25 so

#

but damn thats crazy

#

i have noticed though

#

around 300-350 entities starts to dip the tps

round bone
#

Entities are the worst thing to server's TPS

fallow minnow
#

yeah 😭

round bone
#

You can get up to 50-60 players easily if you simply cut entities down as much as you can

fallow minnow
#

thats actually insane

#

on vps 2 correct?

round bone
#

If you also configure your server correctly to prevent from loading plenty of chunks, change compression method etc.

fallow minnow
#

do you have any tutorials for that

#

and which compression method is best?

round bone
#

And only compress larger than 512/1024 bytes

fallow minnow
#

what do you mean

#

i can choose what sizes to compress?

round bone
fallow minnow
#

ohhhh

#

is it uhh

#

compression threshold

#

i just set that to 512

round bone
#

Yup

fallow minnow
#

it was on zlib and 1 💀

round bone
#

10240 is a good value

round bone
fallow minnow
#

ill try out snappy

#

and i cant get pm2 to work for the life of me

round bone
#

The only con of Snappy is that few percent of players will be unable to join your server, but I don't really know anyone that couldn't join my server because of that, so you shouldn't worry about it anyways

fallow minnow
#

its the easiest thing to set up but i cant get it to work with debian

round bone
#

Do you use PM2 for BDS or what?

fallow minnow
#

i think its because of my VENV

#

for endstone

#

so yes bds

round bone
#

I prefer to wrap everything around Docker Containers, it makes my workflow much easier tbh

fallow minnow
#

never have i ever used docker

#

know nothing about it

round bone
#

Docker is the biggest game-changer. It's high in demand, also makes any deployment much easier

#

You will never encounter error "It works on my machine" if you start using Docker

fallow minnow
#

so what even is docker

round bone
stray spoke
#

How do I get the "growth" permutation of the wheat block

#

Like if it is 7

warm mason
stray spoke
#

Thanks, I also figured it out

ocean stream
#

Is there any way to hide effect particles when using .addEffect in my script? I'm new to this so sorry if that sounds dumb.

naive tinsel
#

is it possible to dynamically change the generic speed of a pickaxe in script api without applying efficiency or haste

naive tinsel
snow knoll
midnight ridge
#

how to make addons achievement friendly?

thorn flicker
midnight ridge
thorn flicker
dapper copper
#

i never knew

thorn flicker
#

yeah ive found out like almost a year ago I think

tardy bane
#

Is there any EntityHurtBeforeEvent alternative that works on normal versions of mc and not just preview ones or nah

tardy bane
#

that sucks

#

thx

stray spoke
#

Is it okay to make multiple intervals, like per player

#

Dk if it will crash or not

distant tulip
#

as long as the code inside nothing crazy

snow knoll
stray spoke
#

Alr thanks yall

fallow minnow
#

whats the lore limit per line

cyan basin
devout sandal
#

anyone know a good way to get the nearest structure? im trying to determine (roughly) where the nearest ancient city is so that as chunks load I can determine if I want my code to run or not.

broken pawn
#

how to check if the block hasTag via script api on beforeEvents.playerBreakBlock ?

#

i mean, is it possible?

grim pasture
#

is it possible to make a scoreboard number go up to 9 quintillion

inland merlin
#

Quick question, did dynamicProperties change at all in how they are linked per uuid vs world?

last latch
inland merlin
#

Ok

#

Well I thought it was uuid, up until I changed version and uuid for someone that has a realm, the pack updated good, but data was still there lol. So maybe a fluke

remote oyster
remote oyster
#

Also, the data won't be deleted when you change the UUID. Just to be sure for clarity lol. It just won't be accessible.

inland merlin
#

Hmm weird lol

#

They confirmed the update took and data stayed idek, update changed some big ui things

remote oyster
inland merlin
#

Okay, it could be a simple misunderstanding on my end. Thanks guys!

remote oyster
inland merlin
#

Hate realms

remote oyster
#

Indeed lol

last latch
inland merlin
last latch
#

Yeah I use it kinda

#

The ScriptSDK is nice

inland merlin
#

Cool alright

stray spoke
#

Was there a shortcut to summon entity with pre inserted event

#

I remember to some source codes it was like entity<event> but I'm not sure

warm mason
stray spoke
#

Yo thank you

#

Coz I can't view spawn entity options

fallow minnow
#

does anyone know how to disable commands on endstone

round bone
#

config/commands.json

#
{
    "permission_levels": {
        "me": "owner"
    }
}
fallow minnow
#
{
    "permission_levels": {
        "me": "internal"
    }
}```
#

supposedly i have to use plugins but i do not wanna do that

round bone
#

Did you restart your server?

fallow minnow
#

i finally got this down

#

now time to make /link

stray spoke
#

Also can I know your font rp, just the png file if possible

last latch
fallow minnow
round bone
#

Even darknavi has mentioned it 🙂

jade grail
#

im trying to use player.getComponent('inventory').container to see if player has the items it needs for a craft and if it does it removes it and adds the crafted item

#

anyone know how i could do that?

thorn flicker
#

...

jade grail
#

i think i need a loop but idk what functions detects items

#

nor how to remove a specific number

thorn flicker
#

getItem()

#

on the container class.

#
const container = player.getComponent('inventory').container
for (let i = 0; i < container.size; i++) {
    const item = container.getItem(i)
    //...
}
jade grail
#

nvm

thorn flicker
#

nvm what

jade grail
#

theres a contains function

thorn flicker
#

that wont work well.

jade grail
thorn flicker
#

that checks for an exact copy of the itemstack.

jade grail
#

so i think for my purpose it will work

jade grail
#

well im prety sure

#

imagine i got 2 stacks 1 has 9 planks the other has 6 planks

thorn flicker
#

thats why you put break at the end so it breaks the loop.

jade grail
#

.

thorn flicker
#

i didnt give a complete script, it was just a snippet.

jade grail
#

@thorn flicker how would i remove items if its in a seperate slot

#

so it would remove 6 from the first slot the the rest of the 4 from the other

thorn flicker
#

sorry

jade grail
#

all good

#

👍🏻 manage to figure it out by making a for loop for how many i want to remove and 1 by 1 removing it from each stack

last latch
woven loom
#

anyone got entity cloner

round bone
#

Literally Mojang employee even said how to do it

honest spear
#

Or script api immitation?

#

bc you are not possible to do it only with script as all components are not accesible or modificable

fallow minnow
#

supposedly itll be fixed next update

#

yes its possible with vanilla bds but i run endstone so it doesnt work

round bone
#

They're not that reliable in my opinion

fallow minnow
#

yeah i really dont wanna touch plugins but look

round bone
#

Larger server networks use BDS with a proxy rather than a mod-loader like Endstone

fallow minnow
round bone
fallow minnow
#

well i need access to xuid

round bone
fallow minnow
#

yeah i have a friend who does that

#

but i also need boss bar and stuff for my json ui

#

its smart but ehh

#

i like the better control

#

ip bans

#

in the future i may use plugins purely for alt detection and vpn stuff

round bone
#

I've stopped using Endstone when I started using a proxy, it's easier to maintain and I am not depending on someone that might just stop working on a software anyways

fallow minnow
#

well i heard that they are backed by someone and are paid loadsss to keep it updated

#

tbf it does update every release

#

but not with loads of features just the newest version

round bone
#

Endstone is only good for server that do not bypass more than 30-40 players online tbh

stray spoke
#

Is there an event to detect if a block is being generated, such as cobblestone generator, cabalt generator and other causes

#

Damn

#

Thanks

fallow minnow
#

well actually i get what you mean kinda

round bone
# fallow minnow how so??

If you have more than 40 players, you'll start thinking about moving to your own infra etc.; most of bigger networks do not want to rely on OSS projects that they can't even maintain. Look at The Hive - they have their own software, Zeqa is using PMMP but owner of a server also maintains PMMP

fallow minnow
#

yeah

round bone
#

PokeBedrock also uses BDS with a proxy that is maintained by the owner

fallow minnow
#

but isnt pmmp php?

#

i guess like

#

building your own endstone like software would be cool

round bone
granite cape
#

1

fallow minnow
#

2

#

does anyone know the max length of an aux id

round bone
fallow minnow
#

perfect

round bone
#
const isLengthValid = (auxId) => {
    const numerical = Number(auxId)
    if (Number.isNaN(numerical) || !Number.isInteger(numerical)) return false
    return auxId.length <= (7 + Number(auxId < 0))
}
fallow minnow
#

its 3:56

stray spoke
fallow minnow
#

now its 3:57

round bone
#

It's 9:57

fallow minnow
#

No

round bone
#

Yes

fallow minnow
#

No

round bone
fallow minnow
fallow minnow
#

i love json ui

woven loom
warped kelp
#

Anyone happen to know why these don't work anymore? MC Chat says it is applied or asked, but it does not work. There are no errors, either.

{
system.afterEvents.scriptEventReceive.subscribe((event) => {
    const { id, sourceEntity } = event;

    if (id === "og:retshort" && sourceEntity) {
        
        const direction = sourceEntity.getViewDirection();
        

        const horizontalStrength = -3.0;
        const verticalStrength = 0.5;

       
        sourceEntity.applyKnockback(
            direction.x,
            direction.z,
            horizontalStrength,
            verticalStrength
        );
    }
});
}
round bone
#

Also, applyKnockback is a bit different

#

Do not use examples, beacuse they're outdated sometimes (and this example is a pure evidence)

stray spoke
#

npm install brain

warped kelp
fallow minnow
#

my math is correct for aux ids correct??

const itemId = typeIdToID.get("minecraft:stick");
const enchanted = false;
const encoded = (itemId ?? 0) * 65536 + (enchanted ? 32768 : 0);

it only seems to work for blocks

fallow minnow
#

it doesnt display items properly

jagged gazelle
#

Maybe there's custom items?

fallow minnow
#

nope

#

i have 0 custom items

#

22773760 is the aux id for diamond_sword

#

displays nothing

round bone
#

Maybe you have an outdated hashmap

fallow minnow
#

i doubt it because all the other stuff works

#

and it would just shift the ids

#

blocks work and shields work

#

like stone works

round bone
#

Hmm, I haven't encountered an issue like this before yet

fallow minnow
#

paper doesnt work

round bone
#

Is paper in your hashmap?

fallow minnow
#

yes

#

['minecraft:paper', 418],

#

418 * 65536

#

27426816

jagged gazelle
#

If you manually put the aux it still doesn't show up?

#

like directly put it

#

i know there's no difference but trying ain't bad

fallow minnow
#

yeah i tried that 😭

#

what the heck is this ???

#

nvm that doesnt matter

#

yeah its still all broken

#

im directly displaying the aux id and it only works for blocks

#

emerald: 36175872
enchanting_table: 7602176

emerald doesnt work but enchanting table does

#

what did minecraft do

subtle cove
sudden nest
#

There's this weird thing happening when you get the block container of a single chest that was just spawned via structure load (the chest has loot table in it) , then get the emptySlots it returns 27, even though, when you open it, there's loot inside it or if you destroy the chest block.

Not sure if this is intensional, i know it could probably be an optimized way to only get items when breaking it or opening it, i was trying to get like the explorer_map using loot_tables via script or command, but keep getting empty container instead.

P.S When you break the chest block it drops the items, although the explorer map is still not functioning, the only way to make it function properly is when you open the chest, which sucks.

stray spoke
#

Do I can directly transport the same item to another player like

anotherPlayer.getComponent("minecraft:inventory").container. addItem(data.itemStack) //or data.itemStack.clone()
subtle cove
#

btw,
where's data coming from?

stray spoke
#

Thanks

subtle cove
#

u could directly tranfer via, .container.transferItem instead of addItem

#

if possible

stray spoke
#

But it's buggy

#

It's delayed response

subtle cove
#

alr then

subtle cove
stray spoke
#

I already know what to do, but why you gotta spawn an item also

subtle cove
#

when the inv is full

stray spoke
#

Oh

#

Thanks again

subtle cove
#

np

jagged gazelle
#

I forgot itemstack returns that when it fails to fill up the container

stray spoke
stray spoke
subtle cove
#

can't remember other's code much, unfortunately

steep hamlet
#

is there any afterEvent that gets triggered when the player is fully loaded? basically when you can actually start playing

steep hamlet
#

that one seems to be triggered before you can play

#

im trying to get the simulation distance

#
function getSimDist(player) {
    const pos = player.location;
    for (let i = 16; i <= 196; i += 16) {
        const loc = { x: pos.x + i, y: pos.y, z: pos.z };
        try {
            const block = player.dimension.getBlock(loc);
            console.warn(block.x, block.y, block.z);
        } catch {
            return i - 16;
        }
    }
    return 196;
}

this returns 0 with playerSpawn or playerJoin or even worldLoad

round bone
steep hamlet
#

ooh the loop sounds good that'll work

wary edge
last latch
steep hamlet
distant tulip
woven loom
distant tulip
woven loom
#

Ye

distant tulip
#

Just used structure manager and saved a structure at the entity location, excluding blocks
There might be more than one entity in that location, so i did some other stuff to make sure i don't duplicate them

woven loom
#

Like?

distant tulip
#

Can't really remember every detail, sense that was in a lost version (i only shared videos)
What i do remember is keeping track of the entity id when saving it, so i don't save it multiple times when looping through nearby entities.
You can also tp the entity before saving it to avoid that? Not sure if this will work tho

last latch
distant tulip
woven loom
#

Whoa, that's really awesome.l

gaunt salmonBOT
hoary sun
#

i always wondered

#

Which is better, scoreboards or system.runs if used correctly?

valid ice
#

Scoreboards are better for keeping scores, system runs are better for running systems

hoary sun
#

which one is better for that case?

valid ice
#

Like for cooldowns between attacks and whatnot?

valid ice
#

I’d say out of the two, scoreboards would be better, but I would say to use date timestamps or dynamic properties if you are using scripts

#

Date method lets you set the cooldown based on current time and not have to decrement or increment any values
Dynamic properties are built for scripts, and a lot easier to use

wheat condor
#

Date method isnt always reliable, if someone stops the game or the game is lagging it causes cooldowns to be faster couse they re not game dependent

thorn flicker
#

just use the cooldown component?

valid ice
thorn flicker
#

...

distant tulip
#

depend on the use case

thorn flicker
distant tulip
#

yeah, if it is item related

dusky flicker
#

rather than normal arithmetic ones

dusky flicker
#

which does almost the same

#

but the sum generaly isnt literally a sum

fallow minnow
#

well tbf its not happening for me

dusky flicker
#

i forgot the source of this but, sums are OR operations and multiplications are AND operations

#

i think i learned from boolean algebra

woven loom
distant tulip
last latch
naive tinsel
#

is there a component for modifying how high a player can jump

round bone
fallow minnow
#

does anyone know why its not letting me import beforeEvents from server-admin?

#

its just not showing up, only variables, secrets and whatever else

sudden nest
#

Is it possible to get like the maindhand or offhand or armor of any mobs (not player) using script, like return the itemStack?

wary edge
#

No.

sudden nest
#

Ah okay

golden condor
#

Is there any known workaround for these vanilla mobs to differentiate which ones are tamed to specific players?

golden condor
round bone
#

Did you check what is this property even for?

golden condor
round bone
golden condor
round bone
fresh comet
#

How do I stop the player from breaking a specific block

#

I want it to block the player from breaking it when they don't have permission

#

Like if they don't have the specific tag

thorn flicker
#

set the cancel property to true

fresh comet
#

Thank you♥️

honest spear
#

np

fallow minnow
#

when are we getting player.kick or player.disconnect

stray spoke
fallow minnow
#

how can i runCommand on a player thats in the player selector for a custom command

#

they just dont work

#

im trying to foundPlayer.runCommand("kick @s")

honest spear
#

as it was resolved

#

so there is no problem anymore

honest spear
fallow minnow
#

why doesnt it exist 💀

honest spear
#

who knows

fallow minnow
#

what is up with this ```ts
commands.register({
name: "online-ban",
description: "Ban an online player from the server. Eg: /online-ban G07HN 'Cheating' '7d'",
parameters: [
{
mandatory: true,
name: "username",
type: CustomCommandParamType.PlayerSelector,
},
{
mandatory: true,
name: "reason",
type: CustomCommandParamType.String,
},
{
mandatory: true,
name: "duration",
type: CustomCommandParamType.String
},
],
permissionLevel: CommandPermissionLevel.GameDirectors,
callback: async (origin, player: any, reason: string, duration: string) => {
//const self = world.getPlayers().find(p => p.name === origin.sourceEntity?.nameTag)
const foundPlayer = player[0] as Player;
//if (foundPlayer.hasTag("owner")) return false
//if (foundPlayer.name === self.name) return false
if (!foundPlayer) {
return false;
}
if (duration.toLowerCase() === "forever") {
await bans.upsert({
xuid: foundPlayer.xuid,
username: foundPlayer.name,
reason: reason,
duration: formatDuration("1000w")
})
return true;
}
const durationSeconds = formatDuration(duration);
if (durationSeconds === null) {
return false;
}

    await bans.upsert({
        xuid: foundPlayer.xuid,
        username: foundPlayer.name,
        reason: reason,
        duration: formatDuration(duration)
    })

    const reasonArray = [
        "§cYou are banned from this server!",
        `§r§7Reason: §b${reason}`,
        `§r§7Duration: §b${reverseFormatDuration(Number(durationSeconds)) ?? "§bForever"}`
    ]
    foundPlayer.runCommand(`kick @s "${reasonArray.join(" ")}"`);

    return true;
}

});``` its not letting my run commands on the player

#

its adding to the database and stuff

fallow minnow
round bone
fallow minnow
#

ya ik it doesnt work

#

i might know a way to crash them actually 💀

#

oh wait

#

okay so

#

its not finding the player properly???

#

bruh what idk

#

i cant run anything on the found player

#

not sendMessage

#

nothing

#

but i can get the name and everything else..??

round bone
fallow minnow
#

but how if i can get the name??

round bone
#

Can't you use player's name directly instrad of a nametag?

fallow minnow
#

and the tags it has

fallow minnow
#

yes ik

#

but if the player is undefined how come i can get the name and their tags

round bone
#

Use a string instead of PlayerSelector in username param

fallow minnow
#

i just cant run stuff on them

fallow minnow
#

i get command failed

#

it wont run any commands on the player 💀

#

wtffff

#

first one fails, second one works..????

const foundPlayer = world.getPlayers({ name: player })[0];
console.warn(foundPlayer.name)

const worldPlayer = world.getPlayers({ name: foundPlayer.name })[0];
console.warn(JSON.stringify(worldPlayer.getTags()))
worldPlayer.sendMessage("test")```
#

might have found why

stray spoke
fallow minnow
#

okay yeah i got it

#

my if logic was messedup

unreal saddle
#

Is there a way to detect when an entity has been dyed?

distant tulip
#

interaction?

unreal saddle
#

But is there a way to do it in a script?

distant tulip
#

or just detect component group changes

unreal saddle
#

I saw something like
DyeColor,But I don't know how to use it

subtle cove
distant tulip
#

use DataDrivenEntityTriggerAfterEvent

#

also, this is a wired name tbh

unreal saddle
#

😔

subtle cove
distant tulip
#

keep in mind the evoker can chnage there color, so DataDrivenEntityTriggerAfterEvent might work best

subtle cove
#

when they spawn

e.setDynamicProperty('color', e.getComponent('color').value)

zinc breach
frosty yoke
honest spear
#

yea thats why its longest awaiting feature

dapper copper
fallow minnow
#

they added it back

dapper copper
#

when

fallow minnow
# dapper copper when

no idea but it works

kick: {
    value(reason: string) {
        system.run(() => {
            this.runCommand(`kick @s "${reason}"`);
        })
    }
}```
untold magnet
#

well, im trying to make a massive shockwave that happens after an event, it will release something like a circle that expands and knock back entities as it goes through them, so whats the most efficient way to do it?

jade grail
#

getentities has max distance and min distance

#

so i assume just loop it the min and max distance going up by 1

untold magnet
untold magnet
jade grail
#

that looks good

untold magnet
#

what i will do:
spawning like 20 projectiles that can go through multiple entities, it moves slowly and u can jump above it to avoid it

#

spawning 20 projectile entities once every a while is so much better than using getEntities multiple times

#

for now, ill add the other projectiles first, then ill deal with that shockwave one

#

i mean, i can make it alot simpler, like one large projectile that explodes into 4-9 other smaller ones that explodes upon impact, each one will have a small shockwave and it covers a large random area,

open urchin
#

Just checking that I haven't overcomplicated things for no reason, there's no easier way to check that an entity was killed by a charged creeper is there?

devout sandal
#

how tf do you export a typedef, i have tried making a module, i have tried importing the file, i have tried making an unused export, i keep getting the typedef not found in module error.

dusky flicker
#

by the way, is there a method to get the uuid of the addon?

#

or must it be hardcoded?

native osprey
#

can someone help me with this?

#

this is the manifest and main.js files

unique dragon
native osprey
#

The ",," format?

native osprey
#

okay i changed the dependency format to string, but now it says "at least one of your resource or behavior packs failed to load"

round bone
#

As far as any feature from your BP/RP works, omit this message

round bone
native osprey
round bone
#

Could you show me structure of your behavior pack?

#

Like some tree from VS Code

native osprey
round bone
#

Can you show me your current manifest?

native osprey
round bone
#

Use dots as a version

#

"2.4.0"

#

Also, fix caps on 7th line of main.js:

world.beforeEvents.chatSend.subscribe((event) => {

-# Just copy this to 7th line

native osprey
#

alright gonna try now

round bone
#

Should work fine, LMK if it still fails

native osprey
#

well it didnt failed but nothing happened

#

so im not sure if maybe the main is the one that needs something changed?

round bone
#

Hmm, very weird

#

Wait

round bone
# native osprey
world.beforeEvents.chatSend.subscribe((event) => {
    system.run(() => {
        world.sendMessage(`[LOG] Player sent message: ${event.message}`)
    })
})
native osprey
#

subcribe?

unreal saddle
#

Can absorption hearts be detected?

round bone
round bone
native osprey
#

jesus js is so weird sometimes

#

tho it says something about cannot read property subscribe of undefined, thats normal?

open urchin
#

That means the thing you're getting the subscribe property from doesn't exist
chatSend only exists in beta versions of @minecraft/server

native osprey
#

oh, so should i remove/change it?

round bone
native osprey
#

including "-beta"?

#

or there is any equivalent of chatSend in stable version?

native osprey
#

do you know where i can find these java scripts? so i know which ones are available in stable verions

native osprey
#

thanks

granite badger
#

Does anyone know how to get gametime?

wary edge
distant tulip
#

no

wary edge
distant tulip
#

i thought he meant the in game time

dull shell
#

is it possible to make my entity follow a certain path till it finds a player? im trying to make a horror game and my entity j moves wherever he wants and the maps too big for that.

#

i was thinking where it follows certain blocks in the floor or something? then one player isnt a target it goes back to following them

summer cloud
#

Is it possible to use ItemStack to give potions?

steep hamlet
#

how do you get equipment proprieties from zombies or non-player mobs?

const equipment = ent.getComponent("minecraft:equippable");
console.warn(ent.typeId); // returns minecraft:zombie
console.warn(equipment.totalArmor); // doesn't work
open urchin
#

You can't
They disabled the component on non-player entities years ago and haven't ever mentioned adding support back

steep hamlet
#

i saw theres a runCommand alternative with testfor but can it test for enchantments?

open urchin
#

no

steep hamlet
dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

snow knoll
dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

snow knoll
snow knoll
dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

snow knoll
#

Strange
And it didn't work either
Maybe try this

snow knoll
#

The game might not be getting the enemy in the first place
This helps us make sure

dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

snow knoll
#

I can't find where the docs include scoreboards
This one might not exist in the way you used it

#

Wait nvm, I cant read 😭

dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

dense wraith
#

One message removed from a suspended account.

snow knoll
#

Oh, it does now?
What changed?
No problem ofc

dense wraith
honest spear
#

These old days we had to use commands to set and get the scores 😭

snow knoll
frosty yoke
honest spear
#

Real do you guys remember Commands.run?

frosty yoke
#

I didn't remember how it was written tho

honest spear
#

crazy times ngl

#

import * as mc from "Minecraft";

stray spoke
#

How do we set equipment a custom dyed leather armor

#

Nvm found it

fallow minnow
#

is appwrite or supabase better?? supabase is cleaner to use but appwrite has 4x more free storage shrug

#

the better option would be to host your own sql database on a vps but idk how to do all that

#

Appwrite: free, 2gb, sql style
Supabase: free, 500mb, sql style
Self-hoster: $4.90, 75gb, sql

shut citrus
#

how to import this module?

round bone
#

Also, to import a package in Java, you just have to import a class/interface etc.:

import net.minecraft.client.model.animal.chicken.ChickenModel;
fallow minnow
honest spear
#

we got too much Java on JavaScript based channel lol

fallow minnow
round bone
fallow minnow
#

yeah i guess

#

i really like the layout of supabase since i can have json b columns and stuff

round bone
fallow minnow
#

so for self hosting do i just read and write data through vps hosted local hosts??

#

since i can only do http requests with script api

round bone
round bone
fallow minnow
#

can i FULLY customize it?

#

like identify certain columns as indexes to performantly sort them

chrome coyote
#

What are the dynamic properties limits?
can i save a 672 byte number on them?

round bone
wary edge
#

There's only a char limit(or was it a size limit) per DP. 😓 I've reached that limit so many times.

chrome coyote
#

i ve alredy reached an RGBH format in strings but i wanted to go further since a char heavier than a number

round bone
#

Do you need to save this single number with a very high precision?

#

If not so, I'd save it in a scientific notation

fallow minnow
#

omg

#

website where i can view all entries

round bone
#

What engine are you using?

fallow minnow
#

5liter

naive tinsel
#

these rookies man

fallow minnow
chrome coyote
#

This is what i reached with 4 characters per block 3015 chunks in 3.47MB

native osprey
#

Hey, weird question, ik they disabled the run command option we were used to and replaced it with onuse custom, anyone has a good guiode how to make a tool that when right clicked executes a function?

#

What im trying to do is

  • create object
    -create function
    -object executes function when right clicked
    -cooldown
#

But all guides are outdated and i cant find any good guide that explains correctly

shell sigil
fallow minnow
#

cool but only for mobile players

shell sigil
#

Who diceded that

fallow minnow
#

Me

#

Ik how it works

shell sigil
#

I mean it work 100% both PC and mobile because you just need click the button

#

I don't know about console though

#

I didn't test it on console because I have only have phone and keyboard/w mouse that I buy online

#

All backpack add-ons should have this feature and this not finish yet

fallow minnow
#

Ohhh wait I thought it was just the fake button method for mobile players

#

But it’s just an inventory slot

#

That you put items into

#

Very cool

knotty plaza
#

Is there a way to detect the player holding the interact button on items that are not chargeable?

devout sandal
#

how can i spawn a baby black cat with scripting..? i know there is a "isBabyComponent" but idk how i can set it, and how i can spawn a specific variant.

devout sandal
#

nvm, got it.

covert goblet
#

General question, but does anybody do before and after metrics when refining their scripts?? If so, how?

worldly heath
#

anyone know which exact version was custom commands added?

fickle dagger
#

are classes good to use for multiblocks?

distant tulip
worldly heath
distant tulip
#

they got moved to stable in minecraft-1-21-100-Bedrock

#

were beta in .80 up to .9x

worldly heath
distant tulip
chrome coyote
distant tulip
stray spoke
#

Why does player.startItemCooldown doesn't work

#

Not that it didn't work, I just don't know how to make it work

#

Even if my custom item has minecraft:cooldown component, I can't start the item cooldown

stray spoke
#

player.startItemCooldown("cd:leap", 20)

#

Because my item has component like:

   "minecraft:cooldown": {
                "category": "cd:leap",
                "duration": 20
            }
warm mason
#

idk then 🤷‍♂️

fallow minnow
#

their player data is bound to the island data

#

so an ID has to exist in players to exist in islands

round bone
fallow minnow
#

yes

#

postgreSQL

#

i have to set up more security though

#

i want to host it on an actual website maybe

#

or just be able to read AND write from a different ip

#

i already have anon roles and a JWT key set up so i can just use that

round bone
fallow minnow
#

is there any apis i can use to grab the usage and performance?

#

how long reading and writing takes

round bone
fallow minnow
#

backend

covert goblet
#

Does anybody know if there is a way to trigger a screen shot on a server from a script?? I want to make a photo booth for my SMP that uploads to a discord server

warm mason
#

But you can send the block data to the server so that the server can render it and take a "screenshot"

covert goblet
#

It was primarily to capture player skins for their bio, apparently taking a screenshot means to some people take a photo of the screen with your phone!!