#Script API General

1 messages · Page 52 of 1

inland merlin
#

@valid ice

honestly even tho it sorta works having custom items and having to register them with the vanilla item typeIds in the files and them id's annoying..

im gonna make a system that actually lets you target their icon directly outside of ids just for custom items...

we use the blocks folder instead as it doesn't conflict with the vanilla file ids

and then just place all the icons of the items there... under textures/blocks/icons/path.png..

honestly the best method and not having to deal with annoying compatibility.

so maybe thats something to look into i think for the future

#

*custom item icons only for the chestformdata

#

so thats my suggested work around (to make compatibiltiy for custom items easier)

valid ice
#

wdym by using the blocks folder

#

Like placing all textures (including items) under the blocks folder?

inland merlin
#

yes it seems to make it better for my custom items as it doesn't conflict with id's>>>

im using custom items from the blocks folders directly and it is so much better. hard to explain but it doesn't mess up crap for me

#

it still can register id's, so we still need to do the shift

#

like how many custom items we have,, we just take that count and shift it over...

#

for vanilla to work

#

but

#

for custom items its much easier to just dynamically grab their own icon from a custom folder

#

i guess it doesn't have to be blocks folder for texture side

celest abyss
#

How to detect when a player steps on a block

wary edge
celest abyss
#

Custom

valid ice
inland merlin
#

@valid ice

i just do the vanilla shift, and then just source my own icons for my custom items instead of trying to add the id's

#

the block icons are manually sourced

wary edge
inland merlin
#

the circled is vanilla

#

so its less work honestly and better for me

#

so idk if it makes sense at all for yah

#

the block icons are not registered at all

#

in the typeId

#

js file

#

so those still work even if the shift gets messed up for vanilla items

#

since its not part of the shift of ids

#

anyways,, ill get a better explaination later and post it to you

#

its hard to explain without confusing people... much easier then trying to do the id's for custom items

#

be back in a few days lmao with that basic info

coral trail
#

Thank you very much. I appreciate your help.

deep yew
#

Does anyone else have issues with certain areas loading in when teleporting using script api? My spawn has a ticking area, but takes ~15-30 seconds to load in being teleported from about 10k blocks away.

valid ice
#

@inland merlin I just pushed a commit to the git to make adding custom stuff easier. Please let me know if it's easy to use! 😛

inland merlin
#

So thanks for adding that in

#

I'll add another config to move/shift the items for vanilla textures as well

#

In game

untold magnet
#

i know it is possible but,
how can i get the mob variant? ( for vanilla mobs )

#

like:
Cold Frog
Temperature Frog
Warm Frog

#

each one of them will have different drops, so how can i detect the mob variants via scripts?

untold magnet
#

yes ig

untold magnet
#

detecting those things,

wary edge
#

Why are you looking at the render controller?

untold magnet
#

idk im just trying to get the mob variant via scripts,

wary edge
#

Look at the BP then.

distant tulip
#

entity.getComponent('variant')?.value

untold magnet
untold magnet
warm mason
#

variant.value is number

wary edge
warm mason
#

Look at the json code of the frog and find out which variation has which number

untold magnet
distant tulip
#

0 "temperate"
1 "cold"
2 "warm"

untold magnet
#

yah i saw it

fallow rivet
#

Can I test if there is a stone between the player's position ~1 ~1 ~1 ~-1 ~-1 ~-1

#

So 3x3

deep yew
#
function isStoneNearby(player) {
    const overworld = world.getDimension("overworld");
    const playerLocation = player.location;

    // Define the bounding box around the player
    const min = new Vector3(playerLocation.x - 1, playerLocation.y - 1, playerLocation.z - 1);
    const max = new Vector3(playerLocation.x + 1, playerLocation.y + 1, playerLocation.z + 1);

    // Iterate through the bounding box
    for (let x = min.x; x <= max.x; x++) {
        for (let y = min.y; y <= max.y; y++) {
            for (let z = min.z; z <= max.z; z++) {
                const block = overworld.getBlock(new Vector3(x, y, z));
                if (block && block.typeId === "minecraft:stone") {
                    return true; // Found a stone block
                }
            }
        }
    }
    return false; // No stone found
}

// Usage
system.run(() => {
    const player = Array.from(world.getPlayers())[0];
    const hasStone = isStoneNearby(player);
    if (hasStone) {
        player.sendMessage("§aStone block detected nearby!");
    } else {
        player.sendMessage("§cNo stone block detected nearby.");
    }
});

Something like this

distant tulip
#

ai

deep yew
#

intention of pointing into a direction, not necessarily for direct copy, paste, and use

distant tulip
#

@fallow rivet you are using beta api?

fallow rivet
#

1.15

distant tulip
#

give me a sec

distant tulip
# fallow rivet No
import { world, system, Dimension, BlockVolume, BlockVolumeBase } from "@minecraft/server";

/**
 * Returns true if the given block is contained in the given volume of the given dimension, false otherwise.
 * @param {BlockVolume} volume - The volume to check.
 * @param {string} id - The block ID to check.
 * @param {Dimension} dimension - The dimension to check.
 * @returns {boolean} True if the volume contains the block, false otherwise.
 * @throws {Error} If the area is not loaded.
 */
function volumeContainBlock(volume, id, dimension) {
    const locations = volume.getBlockLocationIterator()
    for (const location of locations) {
        if(dimension.getBlock(location).typeId === id) return true
    }
    return false
}

// example usage:

system.runInterval(() => {
    for(const player of world.getPlayers()) {
        const loc = player.location
        const volume = new BlockVolume(
            {x:loc.x+1, y:loc.y+1, z:loc.z+1},
            {x:loc.x-1, y:loc.y-1, z:loc.z-1}
        )
        if(volumeContainBlock(volume, "minecraft:stone", player.dimension)) {
            player.sendMessage("there is stone around you")
        } else {
            player.sendMessage("there is no stone around you")
        }
    }
},10)

not tested

fallow rivet
# distant tulip ```js import { world, system, Dimension, BlockVolume, BlockVolumeBase } from "@m...
const playerX = Math.floor(player.location.x);
const playerY = Math.floor(player.location.y);
const playerZ = Math.floor(player.location.z);
for (let x = -1; x <= 1; x++) {
for (let y = -1; y <= 1; y++) {
for (let z = -1; z <= 1; z++) {
const block = player.dimension.getBlock({ x: playerX + x, y: playerY + y, z: playerZ + z })?.typeId;
if (block == "minecraft:portal" || block == "minecraft:end_portal") {
if (player.hasTag("hasEntity")) {
entitydatastore(player, lastbackpackversion)
}
continue
}}}}
#

I found a solution like this

distant tulip
#

test it out

#

my code is for general use

valid ice
#

Would recommend checking the hasTag before the triple loop- will cut down on complexity a lot

#

Aka it won’t run the loop every single time

fallow rivet
distant tulip
#

all the useful stuff are beta, getBlocks and containBlock

distant tulip
chilly fractal
#

Yo bois

distant tulip
chilly fractal
#

Can i use external npm packages within behavior packs?

fast lark
chilly fractal
fast lark
#

Its possible to make an ip ban on servers

#

?

chilly fractal
#

Probably not

#

Unless you have access to the whole server

#

And it's underlying stuff

#

Like the whole processor

#

So you can intercept join events and get their ip.

fast lark
#

Mmh okay

chilly fractal
#

But the best option is per world id

#

Unique id

#

It doesn't change even if you change your gamertag

distant tulip
chilly fractal
#

I am working with server net

#

The thing is

#

I am already using my api end point too much

#

And i might run into rate limits very soon

#

So yeah idk

fast lark
chilly fractal
#

Ya well there is no way to do that

#

Idk read about packets tho

distant tulip
#

unless quick js support the package there is not other option

chilly fractal
#

Might have something useful

fast lark
fast lark
chilly fractal
chilly fractal
#

When a user connects to the server you check their ip from that

chilly fractal
#

Basically just some simple http stuff but you gotta have full backend access

chilly fractal
#

Oh boy i am tired, i need to sleep now

#

I have been working on alot

#

I have like 27 days to finish

#

Kinda not cool

#

From my end

#

I should've increased the deadline

#

But it is what it is, and i can't let time kill me. I must kill it first.

distant tulip
distant tulip
chilly fractal
#

And i will never ever break that legacy.

#

Family tradition

chilly fractal
#

It basically is completely useless on run

valid ice
#

Minecraft/data is just an external package that you add to your addon

#

It doesn’t contain much code, just types- strings, numbers, names, etc

chilly fractal
#

Anyway all i need is some alternative to the client side canvas

#

Or some way to edit an image

valid ice
#

Hah good luck 😢

distant tulip
# chilly fractal I don't promise stuff i don't deliver

nah it was more like:
here is 15 thing (mostly entities and items with complex stuff) we need you to add, we know that this is your first project with us and we know that you don't know how to do some stuff, here is the models and textures and animations, deal with all that in 15 day

distant tulip
chilly fractal
#

It is possible using a package

#

But

#

It's kinda, a "package".

#

And it's designed for server side

#

But it could work

#

If all hope is lost i could implement aggressive caching...

#

With server side

valid ice
#

Real question is why you need to edit images in real time inside mc anyways

distant tulip
#

i mean yeah, but what are you editing? we can't import the pic to mc

chilly fractal
#

For my discord relay

#

I have got the image url

#

But i just simply get a texture

#

Not a head

valid ice
#

You may be able to use some funky json ui like the pause screen does

#

You want a player head..?

chilly fractal
#

Nah

#

I wanna get the head of their avatar and embed it within discord

#

Kind with the message

#

I already got everything in place

#

I just can't edit the image

#

That's all that's holding me back

distant tulip
#

why do you need to edit it?

chilly fractal
#

But i might explore a little more and come up with a better solution

chilly fractal
#

I gtg sleep rn tho so ya cya soon... its kinda late... 2am typa late

distant tulip
#

alr, gn

coral trail
#

Quick qestion. If my add on no longer requires Beta APIs to be toggled on, will that mean I don't have to make an update to change the API version every time the game updates?

wary edge
#

That's the goal anyways.

#

There might be a few function renames every once in a while.

coral trail
#

That's fantastic. Thank you for letting me know.

chrome flint
#

what's with the encircled podzol?

inland merlin
#

The end of the vanilla

chrome flint
inland merlin
#

The id system is a pain

#

Im just gonna auto vanilla, and manually do the custom icons

chrome flint
pale terrace
#

How can I get all the possible values ​​of a block's state?

dim tusk
dim tusk
#

or you can just use .get('<state name>')

#
import { BlockStates } from '@minecraft/server';

const state = block.permutation.getAllStates();

const allValues = {};

Object.keys(state).forEach((stateName) => {
    const validValues = BlockStates.get(stateName).validValues;
    allValues[stateName] = validValues;
});```
#

@pale terrace

deep yew
cold grove
#

probably not bds

chilly fractal
# deep yew some people use dedicated servers or hosted servers with bots that intercept you...

Nah that stuff has nothing to do with ips, ip ban means you have access to the server itself. Like.. the actual server. Low level part of the server. Not the high level stuff like packet events, normal events, system events, other stuff. Minecraft doesn't provide access to ips nor any other sensitive data from high level apis Becuz you could then turn any world into an ip grabber.

#

Yeah ima try to use the image module and give it a try

wheat condor
#

How do I check if a score already exists?

#

Like .getScore() but that doesn’t throw errors like an hasScore()

dim tusk
#

then return otherwise do what you want.

slow walrus
#

oh

distant tulip
#

hasParticipant

subtle cove
#
objective.getScores().find(o => o.score === score)
chilly fractal
#

const score = obj.hasParticipant(ent) ? obj.getScore(ent) : 0;

warm mason
chilly fractal
warm mason
chilly fractal
#

There is an error my fam

#

I don't remember its message but it appears if you dont have any scores

#

Either way, why not be extra sure and safe

#

It's not like you are using a try catch block.

dim tusk
#

a lot of solutions lol,

noble bolt
dim tusk
#

-# mb ping

warm mason
#

It's a very idiotic decision to return an error in this case, especially when the documentation says "score || undefined"

lone thistle
#

It's actually annoying

#

Even if you return 0 or || 0 an error will still be thrown

static oyster
#

Anyone know how to change the player tag above the head? Like changing 'Yulu' to '[AFK] Yulu'?

lone thistle
unique acorn
#
player.nameTag = "[AFK] Yulu"
static oyster
static oyster
lone thistle
#

The code is supposed to add score to a player but they have no score at all and although I am returning 0 it's still throwing that error ¯_(ツ)_/¯

noble bolt
#

because you cant add score on 0

lone thistle
lone thistle
#

What were you getting?

chilly fractal
#

That's a you problem

#

A little score related error i just dont remember it

lone thistle
remote oyster
#

What does it do if you use ?? versus || because they behave differently.

#

The OR operator uses the right value if left is falsy, while the nullish coalescing operator uses the right value if left is null or undefined.

dim tusk
#

i was about to say that 😭

remote oyster
#

Yea, I'm just curious how it would handle the example Serty shared above.

lone thistle
chilly fractal
#

What's your code

#

Me personally, this my old scoreboard class, i switched to dynamic properties as scoreboard but here it is:

class Scoreboard {
  constructor(objectiveID) {
    this.objectiveID = objectiveID;
    return world.scoreboard.getObjective(this.objectiveID) ?? world.scoreboard.addObjective(this.objectiveID);
  }
  doOperation(operation) {
    const objective = world.scoreboard.getObjective(this.objectiveID) ?? world.scoreboard.addObjective(this.scoreboardID);
    return operation(objective);
  }
  
  getScore(ent) {
    return this.doOperation(obj => obj.hasParticipant(ent) ? obj.getScore(ent) : 0);
  }
  addScore(ent, score) {
    return this.doOperation(obj => obj.addScore(ent, score));
  }
  removeScore(ent, score) {
    return this.doOperation(obj => obj.addScore(ent, -score));
  }
  setScore(ent, score) {
    this.doOperation(obj => obj.setScore(ent, score));
    return score;
  }
}

(Feel free to use it)

dim tusk
#

since there's the swtscore add score BLA BLA

chilly fractal
#

Basically doOperation initializes the objective then runs the function

#

Basically you give it a function, it initializes the scoreboard if it doesn't exist, and runs the operation using the objective, and returns the value minecraft would return for you.

#

You doing "doOperation(obj => /*function*/)" basically is the function, and it takes the initialized objective as the param.

dim tusk
#

Ahhh, I get it lol. I didn't fully read the script oof

chilly fractal
#

No worries

dim tusk
#

That's why I got confused, since you're doing a constructor already

chilly fractal
#

Yeah lol, i got confused when i thought of this idea at first but then it became easier to understand and i just adopted it instead of Initializing it every single time manually

fast lark
#

#1330516225532366909

empty grail
#

is there a way to check if player is opening his inventory?

shut citrus
#

can i use gametest-sever module in stable addons?

shut citrus
warm mason
alpine ibex
#

Is there a way to do this on_use on the current version of Minecraft

#

or do I need to make a script?

wary edge
alpine ibex
#

Nevermind I've got zero knowledge

wary edge
#

No idea, I don't use bridge.

alpine ibex
alpine ibex
# lone thistle ``itemUse`` event
world.afterEvents.itemUse.subscribe(({ source, itemStack }) => {
  const item = itemStack;
  if (!item) return;
  if (item.typeId === "ds:nichirinblade") {
  }
  if (item.typeId === "ds:nichirinblade") {
    source.runCommand(`tag @p add color`);
  }
});

Like this?

lone thistle
warm mason
wheat condor
celest abyss
#

How can I detect when the player moves the camera?

wary edge
#

Get the view direction perhaps?

wicked girder
#

does anyone happen to know the uses of the ground_sign_direction and attached_bit hanging sign states

#

the ground_sign_direction is on normal signs but why hanging??

wary edge
distant tulip
dim tusk
distant tulip
#

spam?

dim tusk
#

What's the spam there?

distant tulip
#

repeated words i guess

wicked girder
# distant tulip hmm

but hanging signs arent diagonal, and they use the facing_direction state. And they also use the hanging state for if its on a wall or the ceiling.

wary edge
wicked girder
#

i couldnt get them to be?

#

nvm i didnt know that its different on fences

dim tusk
#

guys quick question since I'm not sure if I can lol
-# haven't tested on my phone yet.

world.afterEvents.playerSpawn.subscribe(async ({ player, initialSpawn }) => {
  const warning = await forceShow(player, new ActionFormData().title('warning').button(''));
});

async function forceShow(player, form, timeout = Infinity) {
    const startTick = system.currentTick;

    while ((system.currentTick - startTick) < timeout) {
        const response = await form.show(player);
        if (response.cancelationReason !== 'UserBusy') return response;
    }
}```
#

is there a way to check if the form is opened??

#

If ever you're gonna say use selection canceled no I don't think you can. Because iirc, selection only returns undefined or a value if you clicked a button in ActionFormData while the canceled will only be false when you clicked any buttons

distant tulip
#

"UserBusy" if it didn't open

dim tusk
#

it doesn't return anything when the form is opened, only when closed or busy.
-# I just tried it

remote oyster
dim tusk
#

Sorry for my dum dumbness

lone thistle
#

Yeah you can execute that using server-admin and server-ui

chilly fractal
#

Yo

#

Are dynamic imports allowed in minecraft?

#

Cuz if not then I'm cooked af..

#

Y'know what? I'll just test rq

distant tulip
chilly fractal
#

I am so happy that i dont need to go through 7 stages of hell now

remote oyster
chilly fractal
#

Yo is require available in minecraft?

#

nvm I'll just test

#

Nope not supported

#

I guess I'll make my own build script to edit out all things to use a custom require and copy the node_modules into scripts/node_modules and delete the outer one and yeah... it should work... hypothetically

round bone
celest abyss
#

EntityDie,is beta or stable?

inland merlin
#

question for those that use blocks in their scriptping alot..

any way to store dynamic properties on a block? im using coordinates in a database currently which makes it impossible nearly to keep the data with the block in a sturcture block moving stuff around unless i uses signs.... but i don't want signs

#

maybe if i had some sorta block inventory that is unaccessable with item in it with lore... but not sure

#

any ideas?

#

also don't want entities

#

but if i HAVE to

#

....

dim tusk
thorn flicker
inland merlin
#

can't save data onto a block if its pushed by a piston or structure block

inland merlin
#

i've encounterd this issue before but used a sign

thorn flicker
#

there's no dynamic properties for blocks

inland merlin
#

to store data, but thats ugly

#

i wish we had sign properties for custom blocks

dim tusk
#

r4isen once suggested that I use one dynamic property to store dynamic properties so that you will use all strings of that dynamic property without bloating a lot of dps

inland merlin
#

huh?

#

i know there is alot of plot systems that use structure blocks

thorn flicker
dim tusk
inland merlin
#

this is if someone saves a "plot" or area with structure block and loads it elsewhere with one of my custom blocks

inland merlin
#

the main issue is i can't trace that location to a new spot

#

unless i modify the plot system directly

#

but i can't do that for everyone

inland merlin
#

from a different addon

inland merlin
#

i used signs in the past to link the database to previous data but signs are ugly.

#

if they uses a plot system

#

they could just click on the sign/block and it updated the location

#

but i can't add data to that custom block

#

dynamically

#

all my levels are database side... not permutations...

#

but.... i guess..

#

idk

#

my only setback rn lamo

#

lmao

#

plot systems

distant tulip
#

you can make a system to save dynamic properties relative to the structure, and load them when you place it again

inland merlin
#

like all possible rotations?

#

4

#

and sizes

#

hmm

#

how would i grab the size of the sturcture block is that able to be grabbed

distant tulip
#

uhh, nvm lol
that a lot

inland merlin
#

or would i be customzing the plot system

#

yeah lmao, i hate this limitation

#

we need nbt or some sorta dynamic properties for blocks

#

the best i can think of is like signs, or inventory component

distant tulip
#

what is the data for

inland merlin
#

persistant data when spawner upgrades etc

#

dynamic

#

the block

dim tusk
#

I guess you can't really do anything about the structure block.

inland merlin
#

this one

#

ive been working on a while

dim tusk
#

even if you did, that's a lot of checks

inland merlin
#

yeah

#

well... signs the only way, or some sorta entity

distant tulip
inland merlin
#

its a block

dim tusk
#

ahh, it's chest form data

inland merlin
dim tusk
#

Lol, you modified it a bit.

inland merlin
#

some

#

yeah

#

lol

#

i also added a config shift in my database to make sure the ids match up depending on custom addons added to the same world lmao

#

that was interesting

distant tulip
#

spawner upgrades can just be a block state, no?

inland merlin
#

so if the items are off, its easy to fix

dim tusk
#

... Umm, since you're doing that, why not place an entity of with the block? And store the datats there? Tho it's still the lol, when they use structure block and include entitiesi false... Then nah

inland merlin
inland merlin
#

signs...

#

hmm

#

lol make a sign invisible

#

lmao

dim tusk
inland merlin
#

just using a scoreboard database for now... can always change it to the dynamic properties/database system

dim tusk
#

if it's not really custom strings or under a pattern only, just use states, just be careful when doing that since doing it setting states on a block sometimes causes TPS drop tho just rarely
-# still depends lol

inland merlin
#

the only thing that can be static/permanant is how many blocks are "stacked" according to the database...

so i could change a state of up to 64

#

that might work i suppose on custom block

#

but then getting more data from it

#

is the issue

#

i could get level but everything else is a bust

#

just some info passed

#

but there is alot of things like the storage, and xp etc..

#

so i guess my best bet is either my own custom structure plot system its compatible with, or use signs

#

to store some data

#

thanks for yall input!!!!

#

just gotta love the limitations

fallow rivet
#

Hello

dim tusk
fallow rivet
#
world.afterEvents.playerLeave.subscribe(({ playerId }) => {
const dimensions = ["overworld", "nether", "the_end"];
dimensions.forEach((dimensionName) => {
const dimension = world.getDimension(dimensionName);
const entities = dimension.getEntities({tags: [`owner:${playerId}`],})[0]
const version = entities.getDynamicProperty("version")
inventorys = entities.getComponent("inventory").container;
for (let i = 0; i < inventorys.size; i++) {
const item = inventorys.getItem(i);
if (item) {
datastoreentity.setItem((version*27)+i, item);
} else {
datastoreentity.setItem((version*27)+i, null);
}}
entities.forEach((entity) => entity.remove());
})});

This code is not working and I can't find the reason why it gives an error here

for (let i = 0; i < inventorys.size; i++) {
dim tusk
inland merlin
#

crap why do so many server/realm owners have plot systems fff's

#

lol

fallow rivet
#

But before beta

dim tusk
#

since the player already left the game especially if it's a single player, you can't check it anymore

distant tulip
#

unless you want to keep track of his inv all the time

inland merlin
#

signs are nbt data right

#

or some form of system they have for them

#

either i make my own plots system that makes them compatible... or im using stupid signs

thorn flicker
inland merlin
#

Yeah, Have to use signs (with id) to adjust the location. Oh well

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.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

thorn flicker
#

there's getVelocity()

dim tusk
#
world.afterEvents.playerSpawn.subscribe(async ({ player, initialSpawn }) => {
  const { selection, canceled, cancelationReason } = await forceShow(player, new ActionFormData().title('warning').button(''));
  if (cancelationReason !== 'UserBusy' && cancelationReason !== 'UserClosed') console.error('test');
});

async function forceShow(player, form, timeout = Infinity) {
    const startTick = system.currentTick;

    while ((system.currentTick - startTick) < timeout) {
        const response = await form.show(player);
        if (response.cancelationReason !== 'UserBusy') return response;
    }
}```

Guys helped how to detect opened form.
dim tusk
#

tho cancelationReason will only trigger if it's busy and closed when I do if statement and && them

#

It doesn't return true

#

-# sorry if the script is scuffed, I'm too lazy

dense wraith
thorn flicker
#

yup

remote oyster
# dim tusk I followed this lol

Yea, idk, I find it to be this simple:

import { ActionFormData } from "@minecraft/server-ui";
import { Player, system, world } from "@minecraft/server";

function showActionForm(player: Player): void {
    const form = new ActionFormData().title("Sample Form").body("Testing busy state").button("OK");

    form.show(player)
        .then((response) => {
            if (response.cancelationReason === "UserBusy") {
                // Retry after a short delay if the user is busy
                system.waitTicks(20);
                // Recall the action form to create a new instance.
                showActionForm(player);
            } else if (response.selection !== undefined) {
                // Confirm that the user successfully opened and interacted with the form
                console.log(`${player.name} opened the form and selected option ${response.selection}.`);
            } else if (response.canceled) {
                // Handle case where user closed the form
                console.log(`${player.name} closed the form without making a selection.`);
            }
        })
        .catch((error) => {
            // Handle errors such as the player disconnecting
            console.error(`An error occurred while showing the form: ${error}`);
        });
}

// Example call to the function for all players in the world
world.getPlayers().forEach((player) => {
    showActionForm(player);
});
dim tusk
inland merlin
# inland merlin

this is the idea i have to save data (using §k)

ugly but works for persistant data (wax it with scripts) and then block breaking it etc...

#

the §k is scrambling lol, not in photo obv

#

for database, then they just have to hit the block or sign to fix the location of the block... and then open the chestformdata again and then we are back in business. nothing changes other then relinking the spawner.

#

so i think this is the current solution

valid ice
#

Interesting

remote oyster
dim tusk
#

there's a built-in open and close ...

steady canopy
#

or idk if it still works i tried that when they just implemented the sign apis

#

if the rawtext is invalid you can get is as a JSON but it wont show in the sign

wary edge
#

@sick robin Please don't crosspost.

sick robin
#

@wary edge how do I get the most out of jayly debug

chilly fractal
chilly fractal
#

Also if commonjs require fails then i can't use import pkg from "discord.js";

#

It would fail also

#

(I tried it to make sure, and it fails)

#

Kinda my only request to the devs to allow us to import packages fr

#

I have been losing my mind

#

Using bundlers like webpack, esbuild... I'll keep trying more, i made my own require, and named it requireLimited and yeah it almost worked but kinda too many bugs for me to fix.. so now i am going after the tactic of replacing relative/absolute paths in require to the actual location and i have copied node_modules inside

#

The scripts folder

#

Not sure if i put the entry point to be the same level as manifest.json would i be able to access node_modules directly as is but that's kinda useless as i also moved my package.json & package-lock.json inside of the scripts folder

random flint
#

hello world

limber patrol
#

I don't know how to write scripts, but does anyone have a script for generating random caves at specific coordinates?

#

and how to do this at all?

distant tulip
distant tulip
limber patrol
#

😭😭😭

distant tulip
#

🤷‍♂️ or you know, commands can do that too

limber patrol
#

do you know how?

limber patrol
lone thistle
limber patrol
acoustic basin
#

hey guys! i have a tile entity, i wanted to ask if there's a way to open up entities ui when interacting with the block, not entity itself, so like, i interact with the block, and the block opens up the inventory of the entity inside of this block for the player

granite cape
#

how to get role the best scripter in this server (just kidding)

#

🌚

dim tusk
granite cape
flat dew
#

is there an easier way to detect if an item is moved around in an inventory other than just checking each slot each tick?

granite cape
chilly fractal
#

Yo bois if i make my own kinda bundler which bundles pretty much any package (to a certain point) should i publish it?

remote oyster
#

Not sure if you plan to bundle it in a way where it compiles it all into one single script or keeping them separate. I personally do not favor compiling it all into a single script when bundling. It just doesn't look natural to me. So I like to simply copy what external packages I need, over to my behavior pack after building it, and just ensuring the paths are correct. Very simple process honestly, and I don't have it all piled up in a single "main" script.

simple zodiac
#

I do not see any advantages of using something like that over an already exsisting bundler tbh

#

But If you plan on doing it anyways then yeh go for it. Because why not?

meager cargo
#

Can anyone help me?

const blockCenter = centerBlock.center();

This is not working and not detecting if player is in the center of the block - water. I would like to make that if player jump on or try swim he gets teleported. But if he goes on waterlogged stairs block it won't detect him.

I tried using below(1);, but it also detected water on surface, not under surface 1 block

wary edge
meager cargo
#

I can't show video right now, but when I'm using below(1); it detects water on surface, in pond. But when I use center(); nothing is happening

subtle cove
#

may u provide us the code used..

meager cargo
#

Sure,

system.runInterval(() => {
    const players = world.getPlayers();
    if (players) {
        for (const player of players) {
            const blockUnder = player.dimension.getBlock(player.location);
            if (!blockUnder) continue; 
            const blockBelow = blockUnder.below(1); // center();
            if (!blockBelow) continue; 

            if (
                blockBelow.typeId === "minecraft:water" &&
                player.hasTag("test1") &&
                player.hasTag("test2")
            ) {
                const teleportPointEntities = player.dimension.getEntities({
                    tags: ["teleport_point"],
                    location: player.location,
                    maxDistance: 150,
                });

                if (teleportPointEntities.length > 0) {
                    const teleportPoint = teleportPointEntities.reduce(
                        (farthest, current) => {
                            const currentDistance = Math.sqrt(
                                Math.pow(current.location.x - player.location.x, 2) +
                                Math.pow(current.location.y - player.location.y, 2) +
                                Math.pow(current.location.z - player.location.z, 2)
                            );
                            const farthestDistance = Math.sqrt(
                                Math.pow(current.location.x - player.location.x, 2) +
                                Math.pow(current.location.y - player.location.y, 2) +
                                Math.pow(current.location.z - player.location.z, 2)
                            );

                            return currentDistance > farthestDistance ? current : farthest;
                        }
                    );
                    const targetLocation = teleportPoint.location;
                    player.teleport(targetLocation, { facing: player.location });
                }
            }
        }
    }
}, 1);
subtle cove
# meager cargo Sure, ```js system.runInterval(() => { const players = world.getPlayers(); ...

try this one

system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        const playerLocation = player.location
        try {
            const location = {...playerLocation};
            location.y -= 1;
            const blockBelow = player.dimension.getBlock(location);
            if (!blockBelow?.isWaterlogged || !blockBelow.typeId.includes("water")) continue;
        } catch {
            // Check if player is above water or waterlogged block, it throws an error when out of bounds
            continue
        }
        if (
            player.hasTag("test1") &&
            player.hasTag("test2")
        ) {
            const teleportPointEntity = player.dimension.getEntities({
                tags: ["teleport_point"],
                location: playerLocation,
                maxDistance: 150,
            }).pop();

            if (!teleportPointEntity) {
                //perhaps remove the tags here to prevent spam tps
                const targetLocation = teleportPointEntity.location;
                player.teleport(targetLocation, { facingLocation: playerLocation });
            }
        }
    }
}, 1);
#

looks like the dim.getEntities({location}) sorts the entities by distance from that location, ||as long as the query has that location property,|| (near to far).
So the last entity in the array should be ur target

chilly fractal
#

So i guess I'll just discontinue working on it for now as i have a deadline for when i must finish

#

I just forgor to ask a very important question

#

Is the scripting api environment a more restricted version of nodejs? I don't think so because require and stuff don't work so i think it is a browser environment... i wonder would it let me import stuff from links?

subtle cove
#

server-net's HTTP methods only iirc

chilly fractal
chilly fractal
subtle cove
#

import('localFile.js') yes

chilly fractal
#

Nah i meant

subtle cove
#

then no...

chilly fractal
#

import('https://cdn.com/file');

chilly fractal
#

K

#

Welp

#

I guess back to my scratcher..

#

The web is a cool place when you utilize it

subtle cove
#

mhm, mojang's just reducing risks, i think

granite cape
subtle cove
meager cargo
granite cape
#

o

#

ok

granite cape
#

nvm im stupid

meager cargo
#

Don't say that!
It's not exactly like rtp, but it is using entities with tags as points to teleport. I have bunch of different entities with this tag regarding situation. And if player is in this case near water and he try run across water pond, it should teleport him to the entity or near this entity

chilly fractal
granite cape
# granite cape like this?
system.runInterval(()=>{
  for(const player of world.getPlayers()) {
    const block = player.dimension.getBlock(player.location)
    player.onScreenDisplay.setActionBar(`
    block: ${block.typeId}
    waterlogged: ${block.isWaterlogged}
    liquid: ${block.isLiquid}
    block-below: ${block.below(1).typeId}
    block-below-waterlogged: ${block.below(1).isWaterlogged}
    below-isliquid: ${block.below(1).isLiquid}
    `)
  }
})
meager cargo
#

Remember M9, already point me to the solution - player.isInWater which detects if player touch water and don't diretcly block below, but thank you for trying 😄

granite cape
#

ok

umbral scarab
#

im sure im being stupid but why is this not working?

switch (event.block.location){
    case {x: 10099, y: -59, z: 10001}:
        world.sendMessage("hi");
        break;
}
dim tusk
#
const location = block.location;

if (location.x === 10099 && location.y === -59 && location.z === 10001) {
    world.sendMessage("hi");
}```

do this.
#

Or you can just make it as a string.

const location = `${block.location.x},${block.location.y},${block.location.z}`;

switch (location) {
    case "10099,-59,10001":
        world.sendMessage('lol');
        break;
}```
umbral scarab
#

ok tyty

worn sphinx
#

How to Right Click Entity?

dim tusk
fickle dagger
fickle dagger
valid ice
#

Thanks discord, very helpful

remote oyster
valid ice
#

:discordthink:

empty yoke
#

is there any event that always works when you interact with an item? Why am I using itemUse on the item chest but it doesn't work if I interact with the blocks, even if I prevent the chest from being placed

granite cape
#

playerPlaceBlock,playerInteractWithBlock

empty yoke
#

ok, but I'm trying to open the menu via an item chest without the player placing the chest on the floor, I'm using the event to prevent the chest from being placed but then the itemUse event doesn't work

granite cape
#

Looks like it has to be manual for now

valid ice
#

If you’re using the event to to cancel block placement, why not also use it to open the menu?

empty yoke
#

It appears to me that I don't have privileges, how can I avoid this behavior?

granite cape
#

bruh why my english so badd

distant tulip
limber patrol
#

hi guys

#

my script isn't working

#

I need help

lone thistle
limber patrol
gaunt salmonBOT
# limber patrol
Debug Result

JavaScript/TypeScript code blocks not detected in [message](#1067535608660107284 message).
You can either send the script in code block highlighted in JS format:

​`​`​`js
world.sendMessage("Hello World");
​`​`​`

Or Send an attachment end in .js to debug the file.

limber patrol
vital halo
#

Is there any way to roll on a loot table from the scripting API?

#

I've just been using runCommand but that isn't that great for what I want

valid ice
#

There is not a native way, no. Gotta use the commands.

vital halo
#

How do I make an entity persist?

vital halo
#

The name tag fix works for now

chilly fractal
# chilly fractal Eh, well..

Again so uhh which environment does it support the most?...... that's a stupid question but like is it ok if i use node with some bundling and resolving dependencies to not use require?

#

Ig I'll try to read about how others made their relay

#

I am betting it is 100% with the wss or connect or whatever that command was

celest abyss
#

isSneaking, is beta?

distant tulip
pale terrace
#

is there a way to keep the inventory on death for one player?

unique dragon
chilly fractal
#

I think i went a little too far

#

For my restrictions

jolly veldt
#

Message test

loud brook
#

Hey guys, how do I detect if a player spawns an entity?

dim tusk
chrome flint
limber patrol
#

What to use to close the crafting table via script, or the chest if possible?
I tried to use a player.closeInventory() but it didn't work

distant tulip
#

damage the player

limber patrol
#

ohhhhh genius!

#

thank you

limber patrol
chilly fractal
#

It*

limber patrol
#

yeah

limber patrol
#

I still remain in the crafting table

#

ohhh

#

the player needs to attack!

distant tulip
#

if that didn't work tp the player away and back, or remove the crafting table and set it back

limber patrol
#

phenomenally brilliant

dim tusk
#

just a small head up, the way it closes the ui doesn't work always, when you get damaged and you open ui and you get damaged it won't close the ui. It has a cooldown we can say

#

tho, I have some stupid way I did before, change gamemode of player to creative then back to original gamemode

#

it works fine with me

limber patrol
dim tusk
limber patrol
#

how to save player position, teleport up 100 blocks, and then return to saved position exactly to .01?

thorn flicker
limber patrol
#

This may seem funny to you, but I can't think of anything else:

player.runCommandAsync("tp @s ~ ~+100 ~");
player.runCommandAsync("tp @s ~ ~-100 ~");
thorn flicker
#

player.teleport(player.getDynamicProperty('location'))

limber patrol
alpine ibex
#

Erm does anybody know how I can get animation controller query.is_item_equipped to work?

#

NVM thanks anyways if you we're going to tell me

warm mason
alpine ibex
quick shoal
#

Ai is lying forever

slow walrus
inland merlin
#

Truth

thorn flicker
limber patrol
#

hi guys

#

how r u guys?

valid ice
#

Update on server-admin on local worlds:

weary umbra
#

is there away to set a string in MolangVariableMap?
molang.setFloat("variable.texture", "");

bc every function can only read numbers

distant tulip
dense sun
#

simulated player has no properties?

grave nebula
#

does anyone have the npm install for server-admin?

#

i tried

npm i -g @minecraft/sever-admin@beta```
and nothing works
grave nebula
#

thx

#

yep works

odd path
#

Does anyone know if it is possible to identify that I am mining a block to execute a command?

odd path
odd path
#

It doesn't identify when I start mining or stop mining

wheat condor
#

you can use this to identify left clicks #1323024128877527211

odd path
#

It's an addon for the Marketplace 😔

wheat condor
odd path
wheat condor
#

maybe playerhitblock

odd path
#

There is a way to identify when I start to break and when I break, but there is no way to identify when I stop breaking

odd path
wheat condor
odd path
#

Only script

wheat condor
#

why

odd path
wheat condor
#

and marketplace doesnt allow editing vanilla aninatins?

odd path
#

No

#

It is forbidden

wheat condor
#

then just post on mcpedl

#

with patreon

odd path
#

The addon is not mine

wheat condor
#

then there is no way of doing this

valid ice
valid ice
#

dense sun
#

is this bad?

valid ice
#

21 seconds is a bit goofy

dense sun
#

is that the EntitygetProperty?

#

imma try in a new world lol

distant tulip
#

isn't that the total time it took across the running period

dense sun
#

I have 2 loops

#

1 loop that test for players

#

and another that test for entities

#
system.runInterval(() => {
const players = world.getAllPlayers();
const entities = world.getDimension("overworld").getEntities();
for (const player of players) {
...

for (const entity of entities)
..
}
#

i might get around 30 players in a server

#

do u guys have any optimization suggestions?

wary edge
dense sun
#

good idea

#

i wish there were filters for this inbuilt
const entities = world.getDimension("overworld").getEntities();

winter plaza
#

How do you use .teleport()?

thorn flicker
#
entity.teleport({x: 0, y: 0, z: 0})
alpine ibex
#

Does anybody know how I can add images to titleraw?

dim tusk
remote oyster
marsh pebble
#

@wary edge

#

So does this server have anything

#

about hiring ppl to make stuff (not for free ofc)

remote oyster
marsh pebble
#

@remote oyster

#

No

#

im not lookign to make stuff for ppl

#

im lookign for people to make stuff.

vital halo
#

What damage types bypass immunity?

valid ice
remote oyster
#

#welcome message

serene lava
#

this script has a error?

remote oyster
#

👍

marsh pebble
#

ik

#

but

#

i need anothe rone

remote oyster
#

Maybe try Minecraft Realm Hub or Build-A-Realm.

remote oyster
remote oyster
serene lava
remote oyster
#

Looks fine to me. I'm assuming line 1 you are importing what is needed.

#

Maybe check data.id to be sure it matches the string you have in the script.

#

You can print it using console.log().

grave nebula
#

whats the best way to see what item someone is holding

#

in their mainhand

warm mason
grave nebula
#

thx

serene lava
#

there's a script to make that a entity summon a row of a ground attack like the Evocation Fang?

lone ruin
#

what does getHeadLocation() method return? a local Vec3 value from the player's current location property or from the world origin (ie., the location is already added in)

lone ruin
#

ty

noble bolt
#

Is it possible to edit the owner of an entity in Scripts?

simple zodiac
#

yeh, get the tamable component. It should have a method to tame it to a player

distant tulip
#

tameable component get removed on tame...

drifting pollenBOT
dim tusk
distant tulip
#

Oh no indeed

#

actually, that might get removed on tame too

meager cargo
#

Maybe it's a stupid question, but I recently found out that if I exit game when script is performing runTimeout it won't perform again when I join to world again. Is there any solution, so even if player exit world when runTimeout is on, it will continue/restart after player join again?

#

Anyone pls?

subtle cove
#

save the method in dynmic property..

#

remove when executed

noble bolt
distant tulip
#

check the bug report

meager cargo
# subtle cove save the method in dynmic property..

It's not working somehow.

const cutsceneInProgress = new Map();

system.runInterval(async () => {
    for (const player of world.getAllPlayers()) {
        const playerPos = player.location;
        const playerId = player.nameTag;

        if (
            playerPos.x >= -45 && playerPos.x <= -41 &&
            playerPos.y >= -2 && playerPos.y <= 2 &&
            playerPos.z >= 116 && playerPos.z <= 120 &&
            player.hasTag('test')
        ) {
            if (cooldowns_betwen_levels.has(playerId) || cutsceneInProgress.has(playerId)) continue;

            cutsceneInProgress.set(playerId, true);

            player.runCommandAsync("scoreboard objectives add transition_1 dummy");
            player.runCommandAsync("scoreboard players set @s apple 0");
            runCutscene();
            system.runTimeout(() => {
                player.onScreenDisplay.setTitle({ rawtext: [{ translate: 'title', "with": ["\n"] }] }, {
                    stayDuration: 100,
                    fadeInDuration: 40,
                    fadeOutDuration: 20,
                });
            }, 80);

            system.runTimeout(() => {
                player.runCommandAsync("say hello1");
                player.runCommandAsync("say hello2");
                player.runCommandAsync("say hello3");
                cutsceneInProgress.delete(playerId);
            }, 100);

            await system.waitTicks(240);
            player.sendMessage({ "rawtext": [{ "translate": "info", "with": ["\n"] }] });

            cooldowns_betwen_levels.set(playerId, Date.now() + 2000);
        }
chilly fractal
#

Yo

#

Does minecraft support crypto apis?

dim tusk
chilly fractal
#

Like

#

window.crypto

#

(Reason is they have really good random generation and i wanna utilize that)

chilly fractal
dim tusk
chilly fractal
#

Ooooh

dim tusk
chilly fractal
#

Yeah i doubt it too

#

I can't use require or import crypto from "crypto"; so that means nodejs's built-in crypto module is not supported and since minecraft doesn't support window nor any web api then they dont support it at all

chilly fractal
#

I was just saying

dim tusk
#

ALL I FREAKING WANT IS BEFORE VENTS ENTITYHITENTITY

#

GOD DAMNIT

#

-# my bad I ranted a bit

chilly fractal
#

They aren't gonna do that soon (probably)

#

I just won't yap

chilly fractal
dim tusk
#

im talking about non server

chilly fractal
#

Ah

#

Well then ig good luck lol

#

All i want is a way to open a websocket

#

And then i am a happy and free man

#

WSConnectPacket
:(

#

Why do they only allow /wsserver & /connect

#

Cmon add a scripting api method moyang

chilly fractal
#

But why not try

#

Who am i not to try

dim tusk
#

I wished before that /reload can be used in commands

#

I'm too lazy to manually type if 🤣

#

guys, what'd you think the best way to check the location you are looking to an eitity

#

Imagine faceLocation on blocks

chilly fractal
#

Distance from you and entity

#

Or

#

Entity's location

#

Or
the location of the block the entity is in?

chilly fractal
#

That one has many reasons not to be allowed within scripting api

#

But what can a simple websocket do?

dim tusk
# chilly fractal Wdym?

no, like which position or collision player is looking. As I said imagine the faceLocation methods in blocks

remote oyster
winter plaza
#

How do you teleport 1 block forward according to the mob's vision?

dim tusk
#
const head = Entity.getHeadLocation();
const view = Entity.getViewDirection();

Entity.teleport({ x: head.x + view.x * 1, y: head.y * view.y + 1, z: head.z + view.z * 1 });```
winter plaza
dim tusk
#
const rotation = Entity.getRotation();
Entity.teleport(...., { rotation: rotation });```
#

tho it's better if you store it in a variable.

shut citrus
#

how can I give players have their own array/ class

cold grove
chilly fractal
chilly fractal
#

I am so fking behind schedule

#

Dang man

distant tulip
latent wing
#

Does anyone know how I can make a dynamic life bar? I've got everything, I just need some math to control the bar with simple numbers ;-;

warm mason
latent wing
# warm mason What exactly do you need to calculate?

I couldn't explain it well, but making the life bar change with a 10-point system, when the player loses a certain amount of life the script would take as a reference the maximum amount of life to be able to calculate how much life he lost and thus assign a number from 1 to 10 with 10 being the highest and 1 being the lowest

warm mason
#
let length = player.getComponent('health').currentValue/player.getComponent('health').effectiveMax*10```
latent wing
blazing hare
#

ideas

meager pulsar
#

Can you detect if the player is inside an specific biome using script?

sage portal
#

We should put stable entity.target and Silksong in a release race

misty pivot
#

is there a way to stop a for loop once a error is detected, specifically if a particle is outside boundaries?

misty pivot
#

yeah but how about detecting the error?

#

let me try using catch

noble bolt
meager cargo
#

I have question, Is there anything like checking what button player pressed on his keyboard? OR someone has idea how I can check that?

wary edge
meager cargo
#

ehh, thank for info!

woven loom
#

wasd shift space

meager cargo
#

I have set up things on player.isSneaking, isGliding, isInWater, etc. So I think I used all possibilities. I wanted to make a "help" server form, after clicking button, example "H"

grim raft
#

yo

#
world.afterEvents.entityHitEntity.subscribe((event) => {
    const { damagingEntity } = event

    damagingEntity.runCommand(`summon bleach:damage_indicator §c${event.damage}`);
})```
the damage undefined how to fix that?
subtle cove
grim raft
#

wait nvm

#

nvm again

#

damagingEntity is not defined

wary edge
grim raft
#

by hitting an entity

wary edge
#

Of course in game...are you hitting the entity or what scenario happens that logs the "damagingEntity is not defined".

grim raft
chilly fractal
#

Nah my Importer & Exporter classes are smoking crack

#

One minute they are working

#

And the other they aren't

#

(I didn't change anything)

#

Or minecraft is smoking crack

#

Or the await import(<file>); method is smoking crack

wary edge
#

It is likely the await portion.

chilly fractal
#

Cuz i am 100 and 10 percent sure that both the files i am importing have an export

#

And also the they are in the correct corresponding location

chilly fractal
wary edge
#

Are you sure?

chilly fractal
#

Minecraft is just smoking crack

chilly fractal
noble ibex
#

Does anybody know if there's a way to detect an entity's target using scripts?

chilly fractal
#

This time it wasn't a 6am coding session

wary edge
#

People always like to blame Minecraft first.

noble ibex
#

fr? I didnt see that in the docs

#

Ill look again

chilly fractal
#

And everything works fine

#

I even tested with the exact setup

#

On the web

#

Using html & js

noble ibex
chilly fractal
#

And it literally doesn't throw any error

chilly fractal
wary edge
grim raft
#

oh didnt see that

noble ibex
chilly fractal
grim raft
#

also this

world.afterEvents.entityHitEntity.subscribe((event) => {
    const { damagingEntity } = event
    const itemStack = damagingEntity.getComponent('equippable').getEquipment("Mainhand")
    const itemUsing = itemStack.typeId == 'bleach:zanpakuto_2'
    const score = world.scoreboard.getObjective('z2_charge')

    if (itemUsing)
        damagingEntity.runCommand('scoreboard players add @s z2_charge 1')```
#

when I hit an entity with no item an error appears

#

everything works but I want to remove that error

#

[Scripting][error]-TypeError: cannot read property 'typeId' of undefined at <anonymous> (main.js:73)

chilly fractal
#

Use itemStack?.typeId

grim raft
#

now how can I detect the damged entities?

grim raft
#

ty

grave nebula
#

so using @minecraft/server-admin you can transfer to another server, is it possible to transfer to another world in the same server?

#

i want to put 2 maps on seperate worlds and transfer between them

grim raft
#
world.afterEvents.entityHurt.subscribe((event) => {
    const { damageSource } = event
    const entity = event.hurtEntity.typeId == 'bleach:dummy'
    if (entity)
        entity.runCommandAsync(`summon bleach:damage_indicator §c${event.damage}`);
})```
can entities run commands?
#

I want to sumon at the entity no at the player

#

the error is not a function at the command line

fallow rivet
#
system.runInterval(() => {
const dimensions = [
world.getDimension("overworld"),
world.getDimension("nether"),
world.getDimension("the_end")
];
for (const dimension of dimensions) {
for (const entity of dimension.getEntities()) {
if (entity.id == "kaos:backpack") {
console.warn("test")
const entityid = entity.getDynamicProperty("playerid");
let testentity = true;
for (const player of world.getPlayers()) {
if (entityid == player.id) {
testentity = false;
}}
if (testentity == true) {
console.warn(entityid)
}
}}}});

Why dont work

#

Does not give any error

winter pumice
remote oyster
#

Have each server handle the different worlds, and transfer to each one as needed based on the port.

fallow rivet
#
system.runInterval(() => {
const dimensions = [
world.getDimension("overworld"),
world.getDimension("nether"),
world.getDimension("the_end")
];
for (const dimension of dimensions) {
for (const entity of dimension.getEntities()) {
if (entity.typeId == "kaos:backpacks") {
const entityid = entity.getDynamicProperty("playerid");
const verion = entity.getDynamicProperty("version");
let testentity = true;
for (const player of world.getPlayers()) {
if (entityid == player.id) {
testentity = false;
}}
if (testentity == true) {
const datastoreentity = world.getDimension("overworld").getEntities({tags: [`datastore`],})[0].getComponent("inventory").container;
inventorys = entity.getComponent("inventory").container;
for (let i = 0; i < inventorys.size; i++) {
const item = inventorys.getItem(i);
if (item) {
datastoreentity.setItem((version*27)+i, item);
} else {
datastoreentity.setItem((version*27)+i, null);
}}
entity.forEach((entities) => entities.remove());
}
}}}});
#

I don't know what to do

grim raft
fallow rivet
grim raft
#

I sometimes code in the wrong file then need to restart everything again lol

distant tulip
grave nebula
remote oyster
inland merlin
#

hear me out..... "block dynamic properties"

#

that would solve alot of issues in regards to structure blocks and scripting for block data

wary edge
inland merlin
wary edge
#

It's been highly requested ever since item dp.

inland merlin
#

awh yeah it would complete it

dim tusk
#
world.afterEvents.entityHurt.subscribe((event) => {
    const { damageSource, hurtEntity: entity, damage } = event;
    if (entity.typeId === 'bleach:dummy') {
        entity.runCommandAsync(`summon bleach:damage_indicator §c${damage}`);
    }
})```
#

or you can just...

world.afterEvents.entityHurt.subscribe(({ damageSource: damagingEntity, damagingProjectile, cause }, hurtEntity: entity, damage }) => {
    if (entity.typeId === 'bleach:dummy') {
         const damageInt = entity.dimension.spawnEntity('bleach:damage_indicator');
         damageInt.nameTag = `§c${damage}`;
     }
})```
deep arrow
#

are dynamic properties on players permanent?

#

like when they leave, join, kick, die, etc.

valid ice
#

yep

deep arrow
#

sick thanks

gaunt salmonBOT
grave nebula
#

theres plugins for it

#

ex: bungeecord

remote oyster
grave nebula
#

how exactly would i run 2 different worlds on the same software

#

how do you manage the different ports

remote oyster
#

BDS has a file called server.properties which allows you to specify the port of your choice. You can run more than one instance of BDS.

grave nebula
#

right, and you also have to specify the world name

#

you cannot transfer a player between 2 world files

#

you have to have different servers running

#

on 2 different ports

#

i was wondering if you can only run 1 server and transfer from one file to another

remote oyster
#

I know you can move files around as needed (BDS only) but I cannot think of how you would "reload" the world without disconnecting the player.

#

So running more than one instance on different ports may be your only option.

#

Then using the following:

remote oyster
grave nebula
#

so i cant use it

#

its fine tho

#

ill make my own system

remote oyster
grave nebula
#

Yh

simple zodiac
#

You guys are probably looking for proxies like waterdog that can transfer server by faking a dimesnion change which is faster then the transfer packet. To bad most proxies don't work with bds or only do so partially

chilly fractal
#

Nahhhhh

#

Minecraft is SMOKING crack

#

I literally tried my importer class with node & with browser codes

#

It works

#

It works

#

(WITH THE SAME FILES)

#

And it doesn't work on Minecraft

#

It says the module is not found

subtle cove
#

mhm...

chilly fractal
#

HOW IS IT NOT FOUND

subtle cove
#

its isolated

chilly fractal
#

IT IS EXACTLY THE CORRECT FILE

chilly fractal
subtle cove
#

what file?

chilly fractal
#

The importer class i made for managing imports and also correctly resolves the true path from the current script to the imported works but not on minecraft

subtle cove
#

without server-net?

chilly fractal
#

Yes

#

It just uses import and some string manipulation

subtle cove
#

where is this said files located relative to the BP

chilly fractal
#

They are in the scripts folder

#

I dont import outside

subtle cove
#

show sample...
i cant imagine

chilly fractal
#

Ima send the class

#

I need someone to test cuz i have lost my mind

#

Maybe my phone is modifying the game some how

chilly fractal
#

Anyway here it is

#

I tested and tested

#

Still the same error

#

Everything, Everything works except the part where it does its job

#

But they are unnecessary and wouldn't effect anything as i am using a type single import.

#

I hope some higher intelligence being tells me what happened here because i tested with so many devices

#

Maybe just maybe

#

It might be the folder case i didn't test?

#

One sec-

#

Oh yeah, the sendMsgWithSound has a little bit of an error so yeah ill fix it later

#

But still it isn't run even once currently

chilly fractal
#

It's for sure my class

#

Sorry for the hurdle

dim tusk
#

What's happening here.

chilly fractal
#

Me arguing my Importer class with myself in public

#

I'm still confused how it resolves the correct path yet doesn't import

#

Ima just remake it from scratch

#

NOT the getRelativePath tho

#

That is staying there

#

And will stay there

#

And in every version

#

I will not lose my sanity on it too

dim tusk
#

This is my exact feeling trying to make my chess work

#

PAIN IN MY FREAKING ASS

chilly fractal
subtle cove
#

uhh, wheres the error?

#

perhaps make a post for it if u still need help with it

chilly fractal