#Script API General

1 messages · Page 106 of 1

prisma shard
#

ok

#

1 sec

honest spear
#

ping me then

prisma shard
honest spear
#

-# 😔

#

thanks

#

i expected this, but i also hoped it could work

midnight crane
#

Can somebody send me the docs for applying knockback

subtle cove
#

I would search here 'applyKnockback' for more samples

floral timber
# midnight crane Can somebody send me the docs for applying knockback
import { EntityQueryOptions, DimensionLocation } from "@minecraft/server";

function bounceSkeletons(targetLocation: DimensionLocation) {
  const mobs = ["creeper", "skeleton", "sheep"];
  const horizontalForce = { x: 5, z: 4 }; // horizontal knockback strength - xz vector
  const verticalStrength = 0.3;           // upward knockback strength

  // Spawn 10 mobs in a pattern
  for (let i = 0; i < 10; i++) {
    targetLocation.dimension.spawnEntity(
      mobs[i % mobs.length],
      targetLocation
    );
  }

  const eqo: EntityQueryOptions = { type: "skeleton" };

  // Apply knockback to all skeletons in the area
  for (const entity of targetLocation.dimension.getEntities(eqo)) {
    entity.applyKnockback(horizontalForce, verticalStrength);
  }
}

the fact that @granite badger aint even updating the example even after PR sucks, kinda.

prisma shard
#

he told u to make a pr ;/

floral timber
#

and so i did

prisma shard
#

hmm okay nice

#

he;s just not on that repo working, there are alot things old

floral timber
#

yeah, sry, (jayly) I didnt mean anything personal.

midnight crane
#

Sorry if that comes off rude btw

floral timber
#

ohk

floral timber
#

the example's kinda outdated ig...

halcyon phoenix
#

yeah most of the examples are way too outdated

narrow lintel
#

Hello everyone, can you help me? I need to summon lightning at custom projectile when it hits entities or hits any blocks, anybody can make a script?

nimble schooner
#

(I'm on 21.100) how do I make it test for block ticks? That's the way it's described in the wiki. And what's a startUp listener? Ty for the runcommand thing btw

distant tulip
nimble schooner
#

Tysm

round bone
#

Check out this article, if you'll be lacking in smth, just ask there

#

🙂

prisma shard
halcyon phoenix
#

👃

granite badger
floral timber
granite badger
#

What did they add in v2 APIs btw, haven’t been catching up

echo tinsel
#

where can i find on_interact documentation?

inland merlin
#

i went from script api only, to endstone c++ plugin development can can't go back to script api anymore its crazy how much more we can do with server software

valid ice
inland merlin
valid ice
#

Hmm

#

Does it support RP & BP alongside plugins?

#

Mainly asking for RP

inland merlin
#

yes, it supports all RP and BP normally

valid ice
#

Zamn

#

I’ll have to look into that

inland merlin
#

yeah, its built on top of bds

#

yeah its amazing

granite badger
slow loom
#

Yeah ig I don't understand that part, been trying to have AI help me build this

round bone
#

I am not using Endstone, beacuse I prefer to have a stable server software rather than lots of functions and plugins, that I won't even use, but it's really good for simple servers

#

If you server will be a bigger network, consider using proxies with it and then you'll see, if Endstone is must-have for you

#

Unless, just use Endstone

wise raft
#

is it possible to know if a player uses vv?
player0.graphicsMode says Fancy, but Fancy is also Fancy

wise raft
wary edge
wise raft
#

1.21.100

wary edge
#

You might need to relaunch Minecraft properly then? Did you toggle the graphics mode ingame?

wise raft
#

with rejoining it works, thanks

wary edge
# wise raft yes

That's your issue. The game doesn't recognize if you change it ingame.

wise raft
wary edge
sullen grotto
#

Is there a way to get entity's passengers via script api?

warped blaze
warped blaze
#

yw

livid elk
#

is it possible to change entity inventory "restrict_to_owner" value using script?

deep arrow
#

Is it possible to get the entity that is being rode on, from the riding entity

halcyon phoenix
thorn flicker
#

so yes

livid elk
#

ahh i see, btw how i can set the owner for entity inventory?

livid elk
#

thanks!

subtle cove
#

Should it be not...

thorn flicker
winter plaza
#

How do I make my projectile born leashed?

warped blaze
#

then spawn it, get the component and leash it

winter plaza
#
function spawnProjectile(entityId, player, name = false, leash = false) {
  try {
    const dir = player.getViewDirection();
    const origin = player.getHeadLocation();

    const pos = {
      x: origin.x + dir.x,
      y: origin.y + dir.y,
      z: origin.z + dir.z
    };

    const projectile = player.dimension.spawnEntity(entityId, pos);
    const comp = projectile.getComponent("projectile");
    const comp2 = projectile.getComponent("leashable");
    if (name) {
      projectile.nameTag = player.nameTag
    }
    if (leash) {
      comp2.leash(player);
    }
    if (comp) {
      comp.owner = player;
      comp.shoot({
        x: dir.x * 1.5,
        y: dir.y * 1.5,
        z: dir.z * 1.5
      });
    } else {
      console.warn(`[PROJETIL] A entidade '${entityId}' não tem o componente 'projectile'`);
    }
  } catch (e) {
    console.warn(`[Erro em spawnProjectile]: ${e}`);
  }
}
#

when I leave leash true, it gives the error "not a function"

warped blaze
winter plaza
#

Ok

subtle cove
vast grove
#

Modify each chat message through the chat event and iterate through this for each letter.

distant gulch
#

Someone deleted my message

final ocean
#

How to fix
No errors
I typed !ah and then nothing happened.

lethal bramble
lapis heart
#

How can I get the first empty slot?

I tried this and it didn't work.:


player.runCommand(`testfor @s[hasitem={item=air,location=slot.enderchest,slot=${i}}]`);

sudden verge
#

for enderchest idk

prisma shard
#

mm

#

if you tried to get a item's localizationKey, would that return like item.apple? and how can i get the actual name.. Oh maybe by using string methods to remove the item. and capitalize the name after it?

#

cant i get nameTag of item,,, isnt the nameTag is the item's name? like wouldnt it return Apple if i used get the item's nameTag

#

ok gotta test mayb in game

sudden verge
#

i might be wrong tho

floral timber
#

u r correct

prisma shard
#

ah

sudden verge
# lapis heart How can I get the first empty slot? I tried this and it didn't work.: ```js pl...

with script APIs you cant access the enderchest inventory (from what I can tell from the docs). But you can use commands & the hasitem selector to do that.

I would write a .mcfunction that checks every enderchest slot & when it finds an empty slot store the slot id in a scoreboard. Then in a new function pass over every slot again but include a condition to check for the slot, then do whatever you need to do with it.
(Can all be done with execute command)

floral timber
# prisma shard ah

for most of the things this should do,

const text = itemStack.localizationKey
world.sendMessage({translate: text})
prisma shard
#

does that translate work outside of sendMessage..

floral timber
#

i dont think so, have to check. its mainly on native methods iirc.

#

forms and all.

prisma shard
#

alr

sudden verge
#

should work

prisma shard
#

oki

distant tulip
woven loom
#

nice

halcyon phoenix
#

lemme yoink this code

wise raft
#

How can I apply knock so that the player lands on a specific location?

woven loom
#

not possible

halcyon phoenix
#

MATH

#

PHYSICS

#

CALCULUS

wise raft
#

alright

woven loom
#

Dealing with all the friction values is hard

halcyon phoenix
#

it's janky tho

distant tulip
#

Madlad have something for it but it is not accurate

woven loom
#

imo what u can do is summon a fake player and make it walk to a location and tp ur entity to that player

#

iic we dont need structures to spawn fake players now

final ocean
halcyon phoenix
round bone
final ocean
round bone
final ocean
round bone
final ocean
round bone
final ocean
# round bone migrate to the latest version or use slash commands?
mc.system.beforeEvents.startup.subscribe(init => {
  init.customCommandRegistry.registerEnum('a:a', ["sell", "admin"]);
  init.customCommandRegistry.registerEnum('a:b', ["money", "coin"]);

  init.customCommandRegistry.registerCommand({
    name: 'a:ah',
    description: 'Auction House',
    permissionLevel: mc.CommandPermissionLevel.Any,
    optionalParameters: [
      { name: 'a:a', type: mc.CustomCommandParamType.Enum },
      { name: 'a:b', type: mc.CustomCommandParamType.Enum },
      { name: 'price', type: mc.CustomCommandParamType.Float }
    ]
  }, (ctx, action, currency, price) => {
    const player = ctx.sourceEntity;

    if (!action) {
      mc.system.run(() => {
        giaoDienChon(player, "Auction House", 1, "Giảm");
      });
      return;
    }

Like this right?

round bone
#

yes, just check before calling a function if player actually a Player instance

#
if (!(player instanceof Player)) return
buoyant canopy
#

Is there a way to check if a translation key exists or not?

round bone
buoyant canopy
#

i have a behavior pack, and i have a resource pack, the behavior pack tries to send a rawMessage, if it gets translated, show it, if it doesn't send a default message.

subtle cove
#

translate doesnt throw errors tho

#

U gotta make another lang lib for js reference

amber nest
#

Why is remember m9 a member now

round bone
#
class LanguageTranslations {
    private constructor() {}
    private static readonly TRANSLATION_KEYS: Readonly<Set<string>> = new Set<string>([
        // keys go here
    ])

    public static isValid(key: string): boolean {
        return this.TRANSLATION_KEYS.has(key)
    }
}
prisma shard
floral timber
warm mason
#

I have an idea how this can be done via JsonUI, but it seems to me that it doesn't work that way.

#

It also depends on the type of this text, because if it is the name of an entity or block or item, then it can be checked, but if not, then it cannot.

#

Although the easiest way is to just do a translation for all keys

round bone
#

you can create a script to automaticly generate a JSON file will all of vanilla keys

#

or just one of them

warm mason
round bone
#

it's much simpler to-do than using JSON-UI with it

warm mason
round bone
floral timber
#

i was saying, can u not just put it somewhere and get its display value? signs or something for checking? if the value is same as key, it aint translating. just asking. would it work?

warm mason
round bone
round bone
#

just gets a value out of prebuilt variable

round bone
loud brook
#

why is this happening 😭

round bone
#

if not, then he has to get it work with JSON-UI stuff

round bone
warm mason
loud brook
round bone
round bone
loud brook
#

here it is

round bone
# loud brook

isn't it dangerous because of amount of listeners that you're creating?

warm mason
round bone
#

🙂

#

I think you're missing something in my implementation

loud brook
#

what are listeners anyway? the subscribe method thing?

warm mason
round bone
loud brook
# round bone yes

I had multiple files with the same form two listeners but different function (for example wide block)

warm mason
loud brook
#

Detected: Trojan:Script/Wacatac.B!ml
Status: Active
The active threats have not been fixed and are running on the device.

Date: 15/08/2025 16:06
Details: This program is dangerous and executes commands from an attacker.

Affected items:

containerfile: C:\Users\Drixs\Downloads\BendyReani.mcpack

file: C:\Users\Drixs\Downloads\BendyReani.mcpack->BendyReani/scripts/2tallblock.js

webfile: C:\Users\Drixs\Downloads\BendyReani.mcpack|https://cdn.discordapp.com/attachments/.../BendyReani.mcpack?...
here is the translation btw

round bone
loud brook
round bone
loud brook
#

The thing is, I also have this file which it doesn't get detected as a harmful file

warm mason
#

Try creating a new file and copy the code there.

loud brook
warm mason
#

hm

loud brook
warm mason
warm mason
#

In general, the code itself still needs some work...

warm mason
warm mason
loud brook
loud brook
floral timber
#

he meant itemUseOn aint on latest version

#

ur code needs work if its for latest api

loud brook
#

oh then I should use playerPlaceBlock am I right?

floral timber
#

ye

loud brook
#

but will that fix the malware detection problem anyway?

floral timber
#

no, it has nothing to do with that.

loud brook
#

How do I fix it?

#

im generally tweaking rn

floral timber
#

hmm, can u not just copy paste the code in a new file?

loud brook
floral timber
#

idk man

floral timber
loud brook
dusky flicker
#

hell the code is worse than i thought

loud brook
loud brook
woven loom
#

what's the issue

loud brook
#

it detectts it as a trojan

#

this is the file

dusky flicker
#

wait ,what is the actual file to look at? you sent a bunch

prisma shard
#

Bunch?

#

I only see 1

prisma shard
#

He just forwared it

loud brook
# loud brook

This is the original one I had problem with, I tried solving it by telling chatgpt to optimize it (just a desperate attempt)

woven loom
#

first time seeing an error like that

#

do u have any option to pass

loud brook
#

I don't think i have an option

dusky flicker
#

the application that is blocking might be bugged

loud brook
#

the thing is in the pinned messages, I found one that is talking about this issue

#

the solution was to change its encoding

#

however that didn't work

dusky flicker
#

the encoding doesnt affect, i think what blocks generally would try to find some suspicious syscalls

loud brook
dusky flicker
#

js has nothing to do with syscall

#

syscall i mean is about OS

loud brook
dusky flicker
#

js should not trigger anything

loud brook
#

#add-ons message

#

check this message

#

the same problem

dusky flicker
loud brook
dusky flicker
#

i use linux for about 2 years, so i forgot

dusky flicker
#

i found so

loud brook
dusky flicker
#

i found some about babylonjs, but same thing, no solution on the post

loud brook
loud brook
#

WAIT, I THINK I HAVE FINALLY FIXED IT!

#

Can someone with windows please test it for me?

livid elk
#

how to get the dropped item count?

warm mason
#
item.amount
warm mason
warm mason
livid elk
warm mason
livid elk
#

i see, thanks! ill try that

round bone
#

🙂

cinder shadow
#

why do slimes default to a health value of 20 🗿

#

even when they split apart they only have 1 health it reads 20 for some reason

round bone
cinder shadow
#

I'm referring to currentValue

buoyant canopy
# warm mason I know. Let's just end this topic already.

you had this whole conversation about my question and didn't ping me once?
Yeah I Know about the Array.includes() method and yes, i definitely don't want to provide the API with a pre built array of strings, it was clear from the start that the answer he provides was generated by a drunk AI.

cinder shadow
#

Are slimes just completely broken when trying to grab values wth

#

It even throws errors trying to grab their variants when they split apart

distant tulip
#

huh, i had that working before

cinder shadow
#

those 20s are also apparently the current health values of the slimes

#

yeah it's straight up removed

#

I guess I have to determine which slime it is based on it's movement value which is pretty absurd EDIT: I can't do this either, the value gets thrown all over the place when they split and they are instantly killed by an attack.

buoyant canopy
lethal bramble
#

Do itemstacks with different dynamic properties stack and if so is there a way to prevent it?

subtle cove
#

DynamicProperty only works on most unstackable items

lethal bramble
#

Do dynamic properties not work on stackable items?

round bone
slender bolt
#

Will changing durability cancel item charging?

round bone
thorn flicker
#

probably, yeah.

slender bolt
round bone
#

Log smth into console every time item will start charging

slender bolt
round bone
slender bolt
#

Yeah, I'm gonna try charging instead of using

warped blaze
#

does the onTick custom component for blocks means that the script is triggered every tick? kinda obvious but i may be wrong

warped blaze
#

k thx

round bone
round bone
warped blaze
# round bone https://wiki.bedrock.dev/blocks/block-events#tick

uhm


"minecraft:tick": {
    "interval_range": [10, 20],
    "looping": true
}```

so does this mean that the component runs on the ten ticks between the 10th and 20th tick of a second or it means that it runs around 10 to 20 times on random ticks of a second?
#

i don't know if you understand what i mean

warm mason
#

if you specify [1,1] it will run every tick. if you specify [2,3] it will run every 2 or 3 ticks.

warped blaze
#

that's a clearer explanation than the one on the wiki imo, ty

prisma shard
#

give me a perfect value for applyImpulse 😭

#

someone

#

im wanna make my entity swim on water
its not psosible with entity.json so

warped blaze
prisma shard
#

;-;

prisma shard
warped blaze
warped blaze
#

-999 social credit

prisma shard
warm mason
prisma shard
#

doesnt matter cuz i already have -664613684616321 credits

#

its decreasing day by day

warped blaze
#

or navigate through water

prisma shard
warped blaze
#

add a sail to your entity's model

round bone
prisma shard
rustic ermine
#

Trying to migrate my project out of Bridge into Webstorm but running into some issues if anyone has done similar.. notably setting up a watcher so that I can add my resource pack as a Root Directory, but have it automatically mirror into the minecraft/development[rp/bp] folders. I have the TS watcher already set up, but can't see a way to make that specifically do what I want from docs/MS pages. Alternatively, was trying to put the BP/RP directly in the dev folders and just modify them there, with the root Webstorm project being elsewhere and just adding those two folders as root dirs, but then run into the issue of not having them all be under one github repo

#

~1800 lines of code across 12 TS files. time for a full IDE lol. getting to the point where changing just one class/function/interface signature leads to an entire night of refactoring, which I completely understand is my fault for not doing proper project / domain planning from the start, just wasn't sure if I would actually get anywhere with bedrock when I started.

round bone
#

you have to write your own script that will copy these files, or open directly BP/RP directories

rustic ermine
round bone
rustic ermine
#

ah I guess I mean .. for example with Java/gradle, you can add pretty much anything you want to the build process. so when you hit "run this Task" or similar, you can have it do something like...

  1. clean the server's plugin folder
  2. recompile all of your plugins to .jar
  3. move them to the server plugin folder
  4. start the server
    not seeing anything similar for node/ts/webstorm
round bone
rustic ermine
#

thanks. I did see a way to add a script or executable to a custom Watcher, maybe that is the route

#

will mess with it after I move my postgres database to my mac mini lol. been meaning to do that for a while because I dont like background processes running on my main computer

round bone
#

This is my monorepo structure, not finished due to my other project, but I recommend smth like this

src/ directory contains building script (watching is not finished)

rustic ermine
#

and you just have a script to sync the bp/rp to the minecraft folder I take it?

round bone
#

yes, but I haven't finished my work on this script

#

I only wrote a script to compress BP/RP directories into smallest zip archives

rustic ermine
#

is what I have been doing but feels kinda bad for quick iterative devlopment to have to restart it every time

round bone
#

-# I can't send a message 😭

rustic ermine
#

hmm not a bad idea to do it in TS. sometimes I forget you don't need to use batch/powershell for this kind of thing lmao

distant tulip
#

Uh, where is script api channel

round bone
rustic ermine
round bone
#

Just wondering how he can copy his BP/RP files using a script

distant tulip
#

That look like node js to me

#

I don't really care tho
You guys feel free to continue

round bone
round bone
#

😱

rustic ermine
#

might as well just write in brainf*ck

#

I do actually use deno lol

distant tulip
round bone
rustic ermine
#

yeah bun and deno are hit or miss. use node always when you need something stable/reliable

round bone
#

Bun is new and they're implementing every module from scratch

rustic ermine
#

mainly was using Deno until I decided to try out webstorm, and now seeing that it can auto-configure a TS project with node sort of defeats the purpose of deno to me

round bone
#

I like it's performance, but I am still missing port of some of modules like bedrock-protocol, which are essential for my work

distant tulip
round bone
rustic ermine
#

yeah it's pretty fast if it works for what you need

#

but to be fair, if I need something fast, any JS runtime is not what I would reach for

#

java + spring/hibernate 🙂

round bone
#

I got pretty deeper with JS, and it's not that bad in-topic of perfomance

rustic ermine
#

nope it absolutely is fast enough.

round bone
rustic ermine
distant tulip
rustic ermine
#

its pretty hard to get meaningfully faster on a complete project stack than node with rust/c++. by that I mean, its very easy to whip up a benchmark that "proves" rocket or something is fast AF, but once you start getting into a full web stack with IO bottlenecks etc, they end up basically the same, but you'd spent a lot of time reinventing the wheel with rust/c++

distant tulip
#

I honestly use js for most of my automated tasks, i just find it way easier to write and debug

rustic ermine
#

same lately. I only started TS about a month ago, but have been programming for about 20 years. I've very quickly learned why it is so popular

#

the "idea in your head" to "I have this working" time is insane

distant tulip
#

I don't think i ever used ts in a real project

#

I feel like it slow me done more than it worth

#

I am slow at typing as it is, i don't need to define every type to make my compiler happy

rustic ermine
#

you can turn off strict mode. it'll let you be selective where you add types. I mainly just add them to enforce function param safety. but a good example of why that can be helpful.. I rewrote herobrine's chestUI code in TS, and it is about 60-200x faster depending on what you are doing because I could remove all type checking since I know for a fact that the types are sound. filling a 99 button UI with mine takes "0ms" with BS dateTime test, takes 60-200ms with default depending on if you use durability/enchant data

halcyon phoenix
#

the only thing I find a lot helpful with ts is the suggestions when creating classes and functions because pure js will require you to either guess/check the docs/memorize what you are tring to do

prisma shard
#

UHH

#

Entity.setVelocity not exists?

#

Well if it does not, Is there a workaround of doing it?

rustic ermine
#

applyImpulse

prisma shard
#

uh

#

Im confused lol

#

Is velocity and impulse same though

unique acorn
#

velocity is how fast they are moving and applyImpulse pushes the entity which increases their velocity

prisma shard
#

yes i'd want to adjust the velocity

#

how about that then

#

:>

unique acorn
#

you do that by pushing the entity using applyImpulse?

prisma shard
#

mh

unique acorn
#

Entity.clearVelocity() exists if you need that

prisma shard
#

ok let me do some tinkering

#

my code is already getting like spaghetti

sly valve
#

How.. nothing against your Script but its basically a Set and a Wrapper class

#

I want rhis Attention as well

sly valve
warm mason
distant tulip
#

how much of your code is actually code

sly valve
#

Rest are types and Interfaces

round bone
#

Working with larger codebases is really hard if you're not using at least FOOP, which is also messy

round bone
distant tulip
#

sound like js to me

round bone
#

JS is missing a lot of features that TypeScript offers

distant tulip
#

everyone and his need, if you feel like ts help you, that up to you
i see a lot of positives, but they are not worth the hassle

round bone
#

while you have to execute JavaScript code directly to check for even small crack-ups

distant tulip
#

you learn to catch small stuff quickly, it is not that big of a deal

round bone
prisma shard
#

GUYS

#

I wrote a whole frikin PATHFINDING AI for my duck entity

#

It's not possible to make them swim using entity.json, So just made it using scripts

#

It ignores obstacles, Sets rotation randomly and smoothly, Goes into bigger areas of pond/river so they dont keep idling into a corner, The ducklings follow a duck , etc

remote oyster
#

When you say AI, are you using that loosely?

subtle cove
#

Imagine a big centipede tracking a player across a mountain

prisma shard
#

tf

#

😭 so out of topic lmfao

warm mason
round bone
#

😭

subtle cove
#

It's easier to track errors in ts especially with OOP

round bone
#

even the app they're using to write their JavaScript code is written in TypeScript

warm mason
subtle cove
#

Then there's also diff ways of code styles

wise raft
#

Can I let player place blocks on my custom block without sneaking when the block uses a custom component with onPlayerInteract?

warm mason
wise raft
round bone
round bone
wise raft
warm mason
round bone
halcyon phoenix
round bone
round bone
halcyon phoenix
wise raft
warm mason
round bone
subtle cove
#

Also when renaming a property, it's faster when it's OOP, especially when its all nested

prisma shard
prisma shard
#

🙄

round bone
#

did he just try to access a property from an array?

subtle cove
#

Those comment types starting to annoy me when I'm coding too fast ngl

round bone
#

it takes even longer to add these comments than a single type

distant tulip
#

/**+enter

round bone
#
import { Player, type Vector3 } from "@minecraft/server"

class VeryUsefulPlayerUtilities {
    static getPlayersLocationUsingPlayer(player: Player): Vector3 {
        return player.location
    }
}
flat barn
#

Why wrap an already abstracted class

warm mason
prisma shard
#

Also ive figured a thing

normally, this should work

for (const type of entityTypes) {
        for (const e of overworld.getEntities({ type: type })) {

but this also works...

for (const type of entityTypes) {
        for (const e of overworld.getEntities({ type })) {
prisma shard
round bone
flat barn
round bone
flat barn
#

just lyk

round bone
#

do you think that I would create a wrapper for a single property?

warm mason
flat barn
#

No I'd assumed it would be scaled, but there is no reason for you to create a wrapper class over the already existing Array class

warm mason
round bone
#

you don't have interfaces in JavaScript, that's why you don't know these things

flat barn
warm mason
#

ok then

round bone
flat barn
#

then no wonder he thinks OOP is less useful

#

lmao

round bone
#

Yeah

warm mason
round bone
#

to make the code scalable

flat barn
#

For simple things like what you showed, its completely unnecessary

#

however if you have a system that in the future, you want to update/scale

#

then OOP is good for that

warm mason
#

#1067535608660107284 message

flat barn
#

functional programming can be scalable if done correctly

#

same with OOP

#

they are both good

prisma shard
#

guys stop ill break your code

class VeryUsefulPlayerUtilities {
    static getPlayersLocationUsingPlayer(player) {
        await null;
        await null;      
        await null;
        await null;
        return player.location
    }
}
wise raft
flat barn
#

or itemUse

wise raft
prisma shard
warm mason
round bone
flat barn
#

Damn I've not been here for a while

#

xd

round bone
#

it encapsulates translations keys out of a variable to a private static property

round bone
flat barn
#

It's been like

wise raft
flat barn
#

almost 2 years

round bone
warm mason
prisma shard
warm mason
flat barn
#

fair enough then

round bone
flat barn
#

Very disgusting

prisma shard
#

asking for entityHurtBeforeEvent day 6422445801

round bone
# flat barn Very disgusting

I stopped using VS Code for development about 2 months ago for WebStorm and I feel that writing scripts in it is much better

flat barn
#

I used to use webstorm

#

but I like vscode

round bone
#

I have professional version beacuse of GitHub Student Pack

flat barn
#

webstorm has a really good debugger

round bone
#

Probably the best one out of other IDEs

flat barn
#

Yeah for sure

#

Its extremely powerful

#

You can output a large object and you can search the object using the debugger

#

I used to use it to analyse mc packets

#

with bedrock protocol

round bone
flat barn
#

how so

round bone
#

not much documentation, code is written in JavaScript, I tried to add Snappy support, but the code is so messy I just dropped it

flat barn
#
function Vector(x, y)
{
    this.x = x;
    this.y = y;

    this.add = function(v)
    {
        this.x += v.x;
        this.y += v.y;

        return `(${this.x}, ${this.y})`;
    }
}

const vector = new Vector(1, 2);

console.log(vector.add(vector));``` Would this be functional or OOP
#

xd

flat barn
#

me when js

round bone
#

That's how I had to do OOP in school

flat barn
#

in js???

round bone
#

Yes

flat barn
#

no way

round bone
#

Yeah, I got some tasks on my private repo still

flat barn
#

I was just messing around with things ages ago

#

and found I could do that

#

and I was like

#

💀

#

skull emoji'd in real life

round bone
#

This type of classes is the only thing that I learned from programming school

#

I still make fun of this to today

halcyon phoenix
#

this is interesting but I have no idea how to implement it inside functions

#

can you give me some examples mk?

flat barn
#

/**
* @param {string} parameter
*/
function example(parameter){}
halcyon phoenix
#

pretty handy

#

thanks a lot guys

round bone
#

👍

flat barn
round bone
flat barn
#

I use TS for everything instead of js

#

I only use js if Im too lazy to setup ts

#

lol

warm mason
#

🍿 👀

round bone
round bone
warm mason
flat barn
#

Like doing this shit in js is stupid asf

#

but TS it looks clean asf

round bone
#

Interfaces are a bit faster for TSC

flat barn
#

You can yeah

#

but I plan to use them as types

round bone
#

Oh, okay

#

Makes sense then

flat barn
#

Yessir

round bone
#

I started using back-end services as a database/caching stuff

flat barn
#

Yeah I use an expressjs local server

#

which sends data to my db

#

then I just communicate between that and server-net

round bone
#

I was using Express.js, until I discovered Fastify

flat barn
#

I love having custom events though

#

It's so clean

round bone
round bone
# flat barn I love having custom events though
import { Vector3 } from "@minecraft/server"
import { AfterEventListener } from "leafpe/utils/events/AfterEventListener"
import { Dimensions } from "leafpe/utils/globals/Dimensions"
import { ServerData } from "leafpe/utils/globals/ServerData"

class WorldLoadAfterEventListener extends AfterEventListener<"worldLoad"> {
    public readonly eventName: "worldLoad" = "worldLoad" as const

    public onEventActivate(): void {
        Dimensions.init()

        const { x, y, z }: Vector3 = ServerData.ITEM_DATABASE_POSITION
        Dimensions.overworld.runCommand(`tickingarea add ${x} ${y} ${y} ${x} ${y} ${z} item_database true`)
    }
}

export { WorldLoadAfterEventListener }
#

Doing the same thing as you xD

flat barn
#

firee

#

Mine could use some cleaning up

#

xd

#

but its whatever

round bone
#

My base event handler is not also that clean

flat barn
#

sheesh

#

Basically same thing actually

#

just shuffled around

round bone
#

Yeah

flat barn
#

I have mine in my server initialisation method

#

I assume urs is also something like that

#

to call this

#

class

#

that initialises the events

round bone
#

This is called in the first place

#

It's my main file of an add-on

flat barn
honest spear
#

lmao

round bone
#

What are you using packet event for? Blocking crashing?

flat barn
#

currently

#

might see what else I can do

honest spear
flat barn
#

Most of the anticheat for crashes etc is gonna be via a relay

#

Probably gonna make my reach ac with the relay aswell since

#

script API abit too slow

round bone
flat barn
#

child_process?

round bone
#

Yeah

flat barn
#

I did that aswell xd

round bone
#

I also had to Dockerize it, beacuse I am on macOS

#

😭

flat barn
#

Only for server usage tho

#

back when the memory leak crash was a thing

round bone
#

That's why I need it

flat barn
#

really?

#

why not use entity Id

round bone
#

I might have more BDS shards in future

#

I want to make it scalable from the beginning

flat barn
#

If I'm not lazy, I could make my own server software usable and be able to grab all that data easily

#

I'd just need to create all the packet implementations

#

which I dreaded

#

alot

round bone
#

I like BDS-ecosystem and I am staying with it

#

I am probably the biggest hater of PMMP and PHP

flat barn
#

Oh yeah

#

that's why I made my server software in ts

#

Mainly cos its my strongest langugae

#

and 2. because if I use it

#

I can just

#

recreate the script API

#

and add extra stuff

#

to it

round bone
#

Reasonable

#

Scripting API lacks a lot of things, even a basic ender chest is not implemented

flat barn
#

Yeah exactly

#

and alot of networking data

#

is lacking

#

I can't even clearVelocity on the player well

#

It hardly even works

#

as far as I'm aware

round bone
#

We are forced to use run-arounds

flat barn
#

If I could get ping

#

it'd be so useful

#

for anticheats

#

like movement cheats, and reach

round bone
#

Yeah

flat barn
#

I have to get their last 20-40 movements

#

and try to analyse it

#

to see if theres any inconsistencies

#

to determine whether they were lagging

round bone
#

Technically you can use Endstone to get these metrics, but you're getting a lot of bloat with it

flat barn
#

during the "reach"

#

The timer anticheat I made I was actually quite proud of

#

I made it a 3 stage system

#

to prevent false flags

#

and it worked perfectly

#

detected 1.01x >=

#

with no false flags

#

Then I changed some values and now it false flags

#

😭

round bone
#

I'll have to implement my own anti-cheat soon aswell

flat barn
#

I'm glad I learned abit of statistics

#

because it helped alot

#

with the timer ac

honest spear
flat barn
#

but it's really intuitive statistics

round bone
#

I'm going to 11th class after vacation

flat barn
#

when I was using timer

#

but u can still use like

#

1.05x <

round bone
#

I barely have learned any advanced math

honest spear
#

thats pretty much free time killer

flat barn
#

1th

honest spear
#

sorry lol

#

i know its ST but i typed that too fast

flat barn
#

its all good

round bone
flat barn
#

I said it jokingly

#

Idk when I'll be in university

round bone
#

I hope that PHP will be boycotted by this time

flat barn
#

I dropped out of school

#

and now I'm too old to go back

#

xd

honest spear
#

PHP is so over-used, idk why even PMMP is done in PHP lol

flat barn
#

I hate php

honest spear
#

i mean the performance is worse than most of the JS engines

flat barn
#

like lua

#

why do they have

#

indexes start at 1

flat barn
#

They are like

#

ahhh yes

#

let us just DESTROY the WHOLE PROGRAMMING RULES

honest spear
flat barn
#

Then also

#

the fucking

#

$ before EVERYTHINGGGG

honest spear
#

also officially its called element offset indexing

round bone
#

$ is a macro in PHP afaik

flat barn
#

I hated having to reach over with my hand

#

to press $

honest spear
#

ahh thats why JQuery is the way it is

round bone
honest spear
flat barn
#

At my work experience, they told me to use php

#

and I said no

#

Only because they dont hold the cards

#

if it were an actual workplace

round bone
#

I'll be learning PHP in school this year

#

Pure PHP

flat barn
#

I'd have to say sure

round bone
#

💀

prisma shard
#

🍿 👀

honest spear
#

imma learn Zig with free time i have, its really nice language

#

its basicly new era C/C++

prisma shard
#

i know nothing

honest spear
#

thats good

round bone
#

I probably need to switch to software development/data science, beacuse I am colorblind and I have to drop front-end related stuff beacuse of it

#

🙁

prisma shard
#

i wish i could learn C , C++ , java, and rust

#

i will learn them whjen i get bigger in age

#

programming is love

honest spear
round bone
honest spear
#

unless you do some security shit

round bone
#

Rust is okay, but it's not that important language

#

BUT STILL BETTER THAN PHP!

prisma shard
flat barn
#

I hate front end development

honest spear
honest spear
#

its really similar

round bone
flat barn
prisma shard
#

I started with programming from 13 actually

honest spear
prisma shard
round bone
#

Few days after my 14th birthday, I got diagnosed with colorblind and by this time I just learned Tailwind CSS and Next.js/Vite, and I dropped more front-end learning

flat barn
honest spear
#

also compilation time of rust is crazy

prisma shard
honest spear
#

thats good

flat barn
#

xd

round bone
#

😭

honest spear
#

i started batch programming at 11 bc if my dad 🫡 🇨🇿 , he just said "Hey son, look i can do this cool shit" and i was like, ohh damn i want to do that too

flat barn
#

It's almost my 3 year anniversary

honest spear
#

og

flat barn
#

of programming

honest spear
round bone
#

In 2021 I started playing Mimo with my friend, a simple game that's learning you full-stack development, Python and SQL, and I had really fun time while playing it

#

So I started coding even more

#

And that's how I am here

flat barn
#

🔥

#

I learnt to code with script API

#

lol

#

in september 2022

round bone
#

I already knew basics of JS before I started learning scripting API

subtle cove
#

me from redstone, cmd blocks, functions, bp/entity files, to scripting

prisma shard
# prisma shard 16

Here's my history

My dad used to do his office work on a Shit 2010 pc, And i used to watch him , So he teached me about computers (mostly just refreshing 100x times lmfao), then i knew about minecraft from youtube, tried downloading Java Edition, but understood i can NEVER. (how could i expect to run java edition on a 2010 pc???), then knew about bedrock edition, Saw that it can run smoothly on my shit pc. Then played all time, Then at a time, I saw about addons, It was frinkin cool, thought about making them (but couldn't actually, i just used to download addons and look at them, combine those addons), i eventually then watched addon tutorials, those old ones really didn't help, then ever since Script API dropped, i saw its MUCH easier. Then i got into it and i'm here

round bone
flat barn
#

d

#

xd

subtle cove
#

what sparked me was the cheaters/hackers in our survival server

round bone
flat barn
#

?

subtle cove
#

ye

prisma shard
flat barn
round bone
#

I have been playing my entire life on Bedrock, and I am staying loyal with it

#

🙂

honest spear
#

everyone started with MC i feel i am really Alien

subtle cove
#

i touched mc java, but my laptop was dying, so nahhh

flat barn
#

I find it funny how I found my passion for programming because I wanted to make a kitpvp realm 💀

honest spear
#

i started mc on family smart tablet

round bone
#

I started MC on Xbox One console

#

The same console I am selling soon

subtle cove
#

pe

round bone
#

The same console that has been raising me up for the last 12 years

halcyon phoenix
#

I am already compiling my addon and now I have to compile my script

flat barn
#

u can use npx tsc --watch

halcyon phoenix
#

it's too tedious to compile ts -> compile addon -> reload

round bone
halcyon phoenix
#

I'll do it in the future i'm too lazy as of now

flat barn
#

its like js

#

u can just write the code

#

it compiles for u before u even get to mc

#

then u can reload

halcyon phoenix
#

I see, thanks a lot for the recommendation I'll definitely take note of it

stuck ibex
#

Guys, I am wondering if there is a way now to detect if a player has fully loaded a world? Without timing the execution of a code?

round bone
stuck ibex
floral timber
prisma shard
#

im going 10th class after this year

floral timber
#

hmm. u r 3 months late, yeah.

round bone
#

😭

floral timber
#

countries ig...

#

@warm mason whats that supposed to mean?

round bone
floral timber
#

ye

warm mason
round bone
#

And I am facing some issues with polish because of it

slender bolt
#

How to manipulate int properties using script?

round bone
slender bolt
#
  "example:example": {
                    "type": "int",
                    "range": [
                        0,
                        20
                    ],
                    "default": 0,
                    "client_sync": true
                },
}```
slender bolt
warm mason
round bone
slender bolt
#

THANKS

round bone
#

And Entity.getProperty

sullen grotto
#

Is it possible to replace one script by another via subpacks?

#

I have a ts file that can only return true or false and I want to change it depending on a subpack player has chosen

wary edge
sullen grotto
wary edge
#

It's currently in Preview only.

sullen grotto
#

Haven't heard of it before

sullen grotto
wary edge
#

Yes.

warped blaze
wary edge
#

What?

warped blaze
warped blaze
#

or something else

rapid sail
#

is it possible to inform the player you need another addon using script?

wary edge
rapid sail
#

i see i dont understand that xd

#

i do and dont

#

so i add a item from the addon thats needed?

rapid sail
#

okay? how do i detect it if its not installed?

rapid sail
#

ty i have to keep telling people my dlc addon isnt to be used a standalone they need the main addon to work

round bone
#

Or it's working with RPs only?

rapid sail
#

RPS only

round bone
#

Oh, kinda sad

rapid sail
#

its reduce space and file size

wary edge
wary edge
rapid sail
warped blaze
rapid sail
#

alr

warped blaze
#

you can also search the id in the itemTypes and throw if the script couldn't find it

granite cape
#

well well well

prisma shard
sudden verge
#

How do you check if a chunk is unloaded?

#

i know you can try to get a block at a location & it will return undefined if chunk is unloaded, but iterating on a bunch of blocks is awful for performance.
I need to check if any of the blocks in a volume are in unloaded chunks

harsh robin
#
world.beforeEvents.playerInteractWithEntity.subscribe(({ player, target }) => {
  if (target.typeId !== 'minecraft:player') return;

  system.run(() => player.runCommand('scriptevent leaf:open stats_viewer'));```
halcyon phoenix
unique acorn
sudden verge
unique acorn
#

oh you want to test an entire chunk, I thought just 1 block is enough, I mean you can check the 4 blocks on the side of the chunk, won't that work?

sudden verge
#

im working with an arbitrary volume of any size that can cover one or more chunks, I thought that i would have to iterate on every block in the volume. But I realize now I can iterate on a wildly smaller array of chunk positions instead of individual block positions
mmm so simple yet i somehow didnt consider 🧠🔨

narrow lintel
#

Hello, how to block /kill for a specific entity?

#

I won't eliminate entity by /kill @e or /kill Custom:entity

#

Please help 🙏

unreal cove
narrow lintel
#

Half health?

unreal cove
#

just know that the only way to get rid of your entity after that would be despawning it (or using .remove() in script api)

unreal cove
narrow lintel
#

it wouldn't kill by /kill ?

unreal cove
#

yes

halcyon phoenix
distant tulip
alpine wigeon
#

how do i use player.playerPermissionLevel

#

it seems to not be working

#

i tried

if (player.playerPermissionLevel == "operator")
#

oh wait nvm it's an int not a string

halcyon phoenix
distant tulip
halcyon phoenix
#

I see, thanks

stuck ibex
#

dang, I thought Custom Slash Commands are stable

nimble schooner
#

Is there a way to make ui intern stuff translatable in the en_GB.lang or de_DE.lang file?

#

in lang files in general I mean of course

warped blaze
nimble schooner
nimble schooner
#

How does it need to be formatted?

subtle cove
#
form.title({translate:"aaaa.ksk.ls"})
#

asuming that key exists in ur lang files

nimble schooner
nimble schooner
#

Why does it throw that error at the THOMAS line?
js form.textField("Na", "Aa Be Cc", "THOMAS");

round bone
#
form.textField("Na", "Aa Be Cc", {
    defaultValue: "THOMAS"
})
nimble schooner
round bone
#

No problem.

wise raft
#

Why is this not possible?
{rawtext: [{ translate: "ui.button.idk" }, { with: { rawtext: [{ translate: ["ui.button.idk.amogus"] }] } }]}

subtle cove
granite cape
#

hey💢

stark kestrel
#

Does someone have vanilla PvP knockback replica

#

Like real vanilla PvP one, very similar

#

Or one similar to hive or cubecraft

wise raft
narrow lintel
distant tulip
#

no

#

i mean, you can't remove them with commands

narrow lintel
#

By /kill command, it will killed?

distant tulip
#

no

narrow lintel
#

?

distant tulip
#

no...

narrow lintel
#

By command will it kill?

distant tulip
#

wtf man

narrow lintel
#

Just kidding 😂

distant tulip
narrow lintel
#

Btw thank you for clarify

distant tulip
#

np

nimble schooner
#

Why does it say /content/0/default and /content/1/default, expected 'string' received 'object'? The translated text should be a string (it is a string) and at other places in the code translating in buttons or titles (forms) works flawless.

sudden verge
#

default value cannot be a raw message. Like it says, it needs to be a string.

nimble schooner
nimble schooner
#

Why does this in MessageFormData show [object Object] instead of the translation file text?

form.body({
        translate: "ui.waystone.teleport.confirm"
    } + " " + requiredPoints + " " +  {
        translate: "ui.waystone.teleport.confirm_1"
    });```
#

Or can you like insert variables from the script into the translation?

sudden verge
#

you cant add strings and raw messages like that

#

define an array of rawmessages insetad

nimble schooner
#

Oh sorry for the ping

#

Thought I'd turned it off

round bone
#
console.warn(itemStack.getTags()) // "ore_detector"
if (!itemStack.hasTag("ore_detector")) return
#

How am I getting false from if case, when the item has a tag

wary edge
#

Why are you not using a namespace for your tags?

round bone
#

Didn't know, I'll add them then, thanks

wary edge
#

Yes. You SHOULD be using namespaces.

round bone
#

I thought that I can use tags without namespaces

#

I added a namespace in every single place of my pack, except item namespaces

nimble schooner
#
player.stopSound("ambient.nether_wastes.mood");```

Why does it say invalid function (I'm using 2.2.0-beta
#

Or is it removed already?

remote oyster
nimble schooner
remote oyster
#

Hmm, then I got nothing. Best I can say is share your code in #1067535382285135923 by opening a forum and get some more in-depth help there.

nimble schooner
#

Ty