#Script API General

1 messages · Page 37 of 1

distant tulip
#

you are right

warm mason
#

😎

distant tulip
jolly citrus
#

tried that does not work

warm mason
#

code

jolly citrus
#

i did like try catch do { getblock } while (getblock === undefined)

jolly citrus
#

nvm here

#
let claimWand;

do {
    claimWand = world.getDimension("overworld").getBlock({ x: 2919, y: 59, z: 0 });
} while (claimWand === undefined);

claimWand = claimWand.getComponent("inventory").container;
warm mason
#

You need to check this every tick via runInterval

jolly citrus
#

nevermind the error is different now

jolly citrus
#
let claimWand;

let _claimid = system.runInterval(()=>{
    if (claimWand === undefined) {
        claimWand = world.getDimension("overworld").getBlock({ x: 2919, y: 59, z: 0 });
    } else {
        system.clearRun(_claimid)
    }
})

claimWand = claimWand.getComponent("inventory").container;

like so?

#

how is this possible

#

oh wait

#
let _claimid = system.runInterval(()=>{
    if (claimWand === undefined) {
        claimWand = world.getDimension("overworld").getBlock({ x: 2919, y: 59, z: 0 });
    }
    if (claimWand !== undefined) {
        system.clearRun(_claimid)
    }
})
#

maybe this i'll try

#

cos i realized the task will immediately be cleared

#

still does not work tho

warm mason
#
function waitForBlockLoading(dimension, location, func) {
  let interval = system.runInterval(() => {
    if (dimension.getBlock(location) != undefined) {
      system.clearRun(interval)
      func(dimension.getBlock(location))
    }
  })
}

waitForBlockLoading(world.getDimension("overworld"), { x: 2919, y: 59, z: 0 }, (block => {
  block.setType("stone")
}))
jolly citrus
#

oh that's nicer

jolly citrus
# warm mason ```js function waitForBlockLoading(dimension, location, func) { let interval =...
function waitForBlockLoading(dimension, location, func) {
    let interval = system.runInterval(() => {
      if (dimension.getBlock(location) != undefined) {
        system.clearRun(interval)
        return func(dimension.getBlock(location))
      }
    })
  }
  
let claimWand = waitForBlockLoading(world.getDimension("overworld"), { x: 2919, y: 59, z: 0 }, (block => {
    block.getComponent("inventory").container;
  }))

why does it return void

warm mason
#

Because the function for manipulating the block should be here

jolly citrus
#

yeah and it is, i tried to add a return to the functio nitself

#

currently i have this

function waitForBlockLoading(dimension, location, func, callback) {
    let interval = system.runInterval(() => {
      const block = dimension.getBlock(location);
      if (block !== undefined) {
        system.clearRun(interval);
        const result = func(block);
        callback(result);
      }
    });
  }

let claimWand;

waitForBlockLoading(world.getDimension("overworld"), { x: 2919, y: 59, z: 0 }, (block) => {
    block.getComponent("inventory").container
    }, (result) => { claimWand = result; }
);

#

nvm that fixed it

warm mason
#

For what?!?

jolly citrus
#

the reason i need this is to preload an item stack i have saved in a chest so i can use it later

#

without having to get the block every time i want to do something with it

#

i've fixed it now, this works perfectly

#

thank you for the help!

warm mason
#

ok..

fiery solar
# jolly citrus ```js function waitForBlockLoading(dimension, location, func) { let interval...

You can't return a value directly from the code inside runInterval. Using function callbacks can get really hard to manage. You can create an async function that waits for the block if you want to return it directly. Something like:

export function waitForBlock(dimension, location) {
    const block = dimension.getBlock(location);
    if (block) return Promise.resolve(block);
    let ev = {
        promise: new Promise((resolve) => {
            const runId = system.runInterval(() => {
                const block = dimension.getBlock(location);
                if (block) {
                    system.clearRun(runId);
                    resolve(block);
                }
            }, 1);
        }),
    };
    return ev;
}

neat hazel
#

Where do I put this?

jolly citrus
#

how long does it take to load a string from a dynamic property that is 18k characters long

warm mason
wary edge
#

That's concerning.

jolly citrus
#

loading a string 18k chars in length or it taking 0.5ms

warm mason
#

It will take much longer to turn this string into an object if you use JSON to store data

jolly citrus
#

i'm implementing a rank system, and i need to reset the world's data and player data every time i wanna begin a new season

jolly citrus
#

every 9th character is a comma

jolly citrus
#

5 ranks, 400 codes each

#

the way you receive a rank ever is you're given a rank code

#

and the used codes would be stored in a dynamic property in the world

warm mason
#

In any case, the receiving time is not so long that this would be a problem.

jolly citrus
#

okay that's good to hear

#

i will have to prevent players from attempting to redeem in quick succession anyway

#

dont want people brute forcing the codes since the pattern is pretty simple

jolly citrus
#

nvm i forgot there's more than one they can match for

#

with 2000 it would be 5.5h

#

💀

fiery solar
jolly citrus
#

did you see my original idea that i am implementing this for

#

I need a list of codes which can be used to redeem a rank, because I can't save it as a property of a player or of a world

#

seasons reset

#

players would lose their ranks

#

it would become hard for staff to manage requests to get a rank back

#

my idea is, if you're granted a rank, you get a rank code you can redeem instead of just straightforwardly being given a tag or a property in-game for it

fiery solar
jolly citrus
#

this is why it's good, the dynamic property will be reset if a new season starts

#

making each code redemptible again

#

no need for staff to interfere for the process of re-claiming your ranks on new seasons

fiery solar
jolly citrus
#

well i mean there are a few ways indeed but

#

those will be more tedious to set up

#

what if you want to quit, and wanna share your rank with somebody else later

#

this also makes it more convenient

grim raft
#
world.afterEvents.playerSpawn.subscribe(() => {
    if (!player.hasTag("join")) {
        start(player)
        player.runCommand('function kingdom_choose')
        player.addTag("join")
    } else {
        return;
    }
})```
"player" is not defined (at line 2)
dim tusk
grim raft
#
world.afterEvents.playerSpawn.subscribe(({ player }) => {
    if (!player.hasTag("join")) {
        start(source)
        player.addTag("join")
    } else {
        return;
    }
})


function start(player) {
    const form = new ActionFormData();
    form.button("human");
    form.button("witch");
    form.button("elf");
    form.button("dwarf");

    form.show(player).then((response) => {
        if (response.selection === 0) {
            player.runCommand('tag @s add human')
        }
        if (response.selection === 1) {
            player.runCommand('tag @s add witch')
        }
        if (response.selection === 2) {
            player.runCommand('tag @s add elf')
        }
        if (response.selection === 2) {
            player.runCommand('tag @s add dwarf')
        }
    });
}```
full code
#

the menu isnt opening

warm mason
#

So I'll go write my "guide"

grim raft
dim tusk
# grim raft ```js world.afterEvents.playerSpawn.subscribe(({ player }) => { if (!player....
world.afterEvents.playerSpawn.subscribe(({ player }) => {
    if (!player.hasTag("join")) {
        start(player);
        player.addTag("join");
    }
});

async function start(player) {
    const form = new ActionFormData()
        .title("Choose Your Race")
        .button("Human")
        .button("Witch")
        .button("Elf")
        .button("Dwarf");

    try {
        const response = await forceShow(player, form);

        if (response.canceled) return;

        switch (response.selection) {
            case 0:
                player.addTag("human");
                break;
            case 1:
                player.addTag("witch");
                break;
            case 2:
                player.addTag("elf");
                break;
            case 3:
                player.addTag("dwarf");
                break;
            default:
                break;
        }
    } catch (error) {}
}

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;
        }
    }
    throw new Error(`Timed out after ${timeout} ticks`);
}
#

Sorry for late response, my internet sucks

grim raft
grim raft
dim tusk
# grim raft could you explain whats happening here?

So if player spawn and doesn't have the tag join it calls the functions, you said the form is not opening it is because when player is spawning it's not somewhat "ready" yet so the form didn't open, we make another function where if the form doesn't open because user is busy, it will try over and over again till it opens the form.

#

-# I hope my grammar isn't shit

grim raft
grim raft
dim tusk
#

It can be you want to open the form after 2 seconds syes it opens on local world but how about the server they can be slow and delay the readiness of the player

#

We made a function force show so that we could use it anytime we want

distant tulip
grim raft
warm mason
dim tusk
distant tulip
dim tusk
grim raft
dim tusk
#

And why the hell use this? It's not reliable

#

We already gave you a better solution and you want the hard way

grim raft
distant tulip
dim tusk
warm mason
grim raft
warm mason
distant tulip
warm mason
dim tusk
distant tulip
warm mason
dim tusk
warm mason
dim tusk
#

The way you said it's a mistake I feel like you're angry at me

distant tulip
#

lol

warm mason
dim tusk
#

Idk but I have this bad side that I always puts the await forceShow(player) inside of try and catch

distant tulip
#

huh
those are tow different things

dim tusk
distant tulip
#

ik
how dose try and catch relate to that

warm mason
dim tusk
#

I always put them there even tho they're kinda unnecessary

distant tulip
#

yeah i am lost lol

dim tusk
#

Let's change the topic..

#

What do you guys think is a better way to activate an airplane?

warm mason
dim tusk
#

Using WASD JUMP AND SNEAK button

gusty bramble
#

Is it possible for a script to select a specific function file that I type the name of in chat?

distant tulip
gusty bramble
#

Wait really?

#

How?

dim tusk
gusty bramble
#

Like a .mcfunction file

warm mason
#

The main question: WHY?!

distant tulip
#

that is kinda of a lot to ask for
do you have any script api knowledge?

drifting ravenBOT
#
Free Work

If you want an add-on made for you for free, you're most likely out of luck. The best thing you can do is watch tutorials and read guides so you can learn how to develop it yourself.

People won't work for free, but you can always offer to pay them to make something for you.

grim raft
dim tusk
#

Just put the code I made to that post

grim raft
#

when its undefined or cancelled it opens a new menu and doesnt leave the one before so they stack

dim tusk
distant tulip
distant tulip
grim raft
#

and u can actually

dim tusk
warm mason
grim raft
#

w json ui I opened 3 menus at once and every button worked

dim tusk
#

I mean if you want to stack it's not ideal

distant tulip
#

spamming show form dose stack them

dim tusk
dim tusk
#

Why stack it if you can open a form based on what you only need 😭

warm mason
# dim tusk What!

I remember wonderful (no) times when I struggled with 20 forms opening at the same time. So yes, this could happen

dim tusk
#

That happened to me, since I'm kinda lazy to find a way to trigger it so I trigger it when the player sneaks 🤣

distant tulip
warm mason
grim raft
gusty bramble
distant tulip
dim tusk
#

Wtf three mentioned in one chat

dim tusk
gusty bramble
distant tulip
dim tusk
grim raft
warm mason
dim tusk
#

Lmao I once tried doing this.

world.beforeEvents.chatSend.subscribe(ev => {
   const { message, sender, cancel } = ev;
   if (message === 'bruh') cancel = true;
});```
dim tusk
jade grail
#

im making a simple cooldown what should the catergory be?

distant tulip
distant tulip
jade grail
#

mb caps lock

#

the menu catergory?

distant tulip
#

cooldown catergory
you can add it to your item

neat hazel
round bone
#

if you need stackable, maybs use lore or smth like it

neat hazel
round bone
#

then you can use dynamic properties on this item

neat hazel
celest abyss
#

How can I make a custom command that only works with my nametag?

if (hasName:'name')
?????

ruby haven
#

Is it possible to set the entity like align it in the center of the block before spawning?

distant gulch
#

What's the latest beta @minecraft/server npm?

#

nvm I see, 1.18.0-beta

fiery solar
distant gulch
#

Can I use 1.18.0-beta in a regular server?

dim tusk
dim tusk
dim tusk
distant gulch
#

Ah

fiery solar
distant gulch
#

So can I use player.inputInfo.getMovementVector?

#

in 1.16.0-beta

distant gulch
#

Dang, that sucks

dim tusk
#

1.17.0-beta

distant gulch
#

I was really looking forward to it

dim tusk
#

You need to wait next update

distant gulch
#

I guess I'll track player movement the old fashioned way

dim tusk
distant gulch
dim tusk
#

I was kinda bored...

let jumpTime = {};

world.afterEvents.playerButtonInput.subscribe(({ button, newButtonState, player }) => {
    if (button === 'Jump') {
        if (newButtonState === 'Pressed') {
            jumpTime[player.id] = Date.now();
        } else if (newButtonState === 'Released') {
            if (jumpTime[player.id]) {
                const duration = Date.now() - jumpTime[player.id];
                delete jumpTime[player.id];

                const milliseconds = duration % 1000;
                const seconds = Math.floor((duration / 1000) % 60);
                const minutes = Math.floor((duration / (1000 * 60)) % 60);
                const hours = Math.floor(duration / (1000 * 60 * 60));

                player.sendMessage(`${player.name} held jump for ${hours}h:${minutes}m:${seconds}s:${milliseconds}ms`);
            }
        }
    }
});```
somber onyx
#

Hello,
It’s been an hour now I’m on a problem that I can’t solve, someone could help me I’m currently.

let targetPlayer = args[1]
let newTargetPlayer = targetPlayer.replace("@", "")
if (!world.getPlayers(newTargetPlayer).hasTag(opTag)) {
///code
}
distant gulch
#

Is there any way to detect isWalking?
The only thing I see is player.isSprinting, and I'd like to check for walking as well

#

If not, how can I check movement direction with getVelocity

#

can I just do .getVelocity().x

#

and if it's over 1, it's going forward in x direction

#

over 0*

#

and if its under 0, it's going backward in x direction'

dim tusk
distant gulch
somber onyx
distant gulch
#

and would this be a constant run?

dim tusk
# distant gulch Is there any way to detect isWalking? The only thing I see is player.isSprinting...
system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        let { forward, right, backward, left } = direction(player);
        let text = ''
        if (forward > 0) {
           text = 'forward';
        } else if (left > 0) {
           text = 'left';
        } else if (right > 0) {
           text = 'right';
        } else if (backward > 0) {
           text = 'backward';
        } else return;
        player.sendMessage(text);
    }
})

function direction(player) {
    let velocity = player.getVelocity();
    let viewDirection = player.getViewDirection();

    let viewDirMagnitude = Math.sqrt(viewDirection.x ** 2 + viewDirection.z ** 2);
    let normalizedViewDir = { x: viewDirection.x / viewDirMagnitude, z: viewDirection.z / viewDirMagnitude };

    let forwardVelocity = (velocity.x * normalizedViewDir.x + velocity.z * normalizedViewDir.z);
    let rightVelocity = (velocity.z * normalizedViewDir.x - velocity.x * normalizedViewDir.z);

    let backwardVelocity = -forwardVelocity; 
    let leftVelocity = -rightVelocity; 
    
    forwardVelocity = Math.round(forwardVelocity * 100) / 100;
    rightVelocity = Math.round(rightVelocity * 100) / 100;
    backwardVelocity = Math.round(backwardVelocity * 100) / 100;
    leftVelocity = Math.round(leftVelocity * 100) / 100;
    return {
        forward: forwardVelocity,
        right: rightVelocity,
        backward: backwardVelocity,
        left: leftVelocity
    };
}```
#

This is not accurate if the player is in the wall the velocity freaks out

dim tusk
distant gulch
#

Alright, thanks! That's all I need!

dim tusk
somber onyx
dim tusk
somber onyx
#

Je veux créer une commande personnalisée pour ajouter et supprimer cohost dans UHC, je fais cela avec opTag

somber onyx
# dim tusk Wait, explain it to me first what you are trying to do.

here is a more complete version of my code

if (args[1] != undefined) {
                            let targetPlayer = args[1]
                            if (args[2] != undefined) {targetPlayer += " " + args[2]}
                            let newTargetPlayer = targetPlayer.replace("@", "")
                            log(newTargetPlayer)
                                if (validPlayer(newTargetPlayer)) {
                                    if (!world.getPlayers(newTargetPlayer).hasTag(opTag)) {
                                        runCommandAsync(`tag ${newTargetPlayer} add ${opTag}`)
                                        world.sendMessage(`${glyph} ${sender.name} est maintenant co-Host de la partie !`)
                                        sender.runCommandAsync("playsound mob.chicken.plop @a")
                                    }else {
                                        runCommandAsync(`tag ${newTargetPlayer} remove ${opTag}`)
                                        sender.sendMessage(`${glyph} ${newTargetPlayer} n'est plus co-Host de la partie ! `)
                                        sender.runCommandAsync("playsound mob.chicken.plop @a")
                                    }
                            }else {
                                sender.sendMessage(`${glyph} !co-host @"Nom du joueur"`)
                                error(sender)
                            }
                    }
sly currentBOT
#
coddy2009

I want to create a custom command to add and remove cohost in UHC, I do this with opTag

somber onyx
dim tusk
#

Invalid:

if (world.getPlayers().hasTag('') {}```

Valid:
```js
for (const player of world.getPlayers()) {
   if (player.hasTag('')) {
   }
}```
somber onyx
dim tusk
somber onyx
#

yes

dim tusk
distant gulch
#

@dim tusk

#

That setup you gave me

#

I changed the

#

console.error

#

to world.sendMessage

dim tusk
distant gulch
#

and I'm not getting any info back

distant gulch
#

But yeah, I'm confused as to why I'm not getting a message in world

#
system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        let { forward, right, backward, left } = direction(player);
        let text = ''
        if (forward > 0) {
            text = 'forward';
        } else if (left > 0) {
            text = 'left';
        } else if (right > 0) {
            text = 'right';
        } else if (backward > 0) {
            text = 'backward';
        }
        world.sendMessage(text);
    }
})

function direction(player) {
    let velocity = player.getVelocity();
    let viewDirection = player.getViewDirection();

    let viewDirMagnitude = Math.sqrt(viewDirection.x ** 2 + viewDirection.z ** 2);
    let normalizedViewDir = { x: viewDirection.x / viewDirMagnitude, z: viewDirection.z / viewDirMagnitude };

    let forwardVelocity = (velocity.x * normalizedViewDir.x + velocity.z * normalizedViewDir.z);
    let rightVelocity = (velocity.z * normalizedViewDir.x - velocity.x * normalizedViewDir.z);

    let backwardVelocity = -forwardVelocity;
    let leftVelocity = -rightVelocity;

    forwardVelocity = Math.round(forwardVelocity * 100) / 100;
    rightVelocity = Math.round(rightVelocity * 100) / 100;
    backwardVelocity = Math.round(backwardVelocity * 100) / 100;
    leftVelocity = Math.round(leftVelocity * 100) / 100;
    return {
        forward: forwardVelocity,
        right: rightVelocity,
        backward: backwardVelocity,
        left: leftVelocity
    };
}
dim tusk
distant gulch
#

I did, the only thing I changed was

dim tusk
distant gulch
#

the console.error

#

to world.sendMessage

#

There are no shenanigans, I can't check console on my server

somber onyx
# dim tusk Send the whole *chatSend*

export const opTag = 'operator'
export const commandPrefix = "!"

world.beforeEvents.chatSend.subscribe((event) => {
    let sender = event.sender
    let message = event.message
    let args = message.slice(commandPrefix.length).split(/\s+/g);
        if (message.startsWith(commandPrefix)) {
        event.cancel = true
        system.run(() => {
            switch (args[0]) {
            case 'cohost':
                        if (args[1] != undefined) {
                            let targetPlayer = args[1]
                            if (args[2] != undefined) {targetPlayer += " " + args[2]}
                            let newTargetPlayer = targetPlayer.replace("@", "")
                            log(newTargetPlayer)
                                if (validPlayer(newTargetPlayer)) {
                                    if (!world.getPlayers(newTargetPlayer).hasTag(opTag)) {
                                        runCommandAsync(`tag ${newTargetPlayer} add ${opTag}`)
                                        world.sendMessage(`${glyph} ${sender.name} est maintenant co-Host de la partie !`)
                                        sender.runCommandAsync("playsound mob.chicken.plop @a")
                                    }else {
                                        runCommandAsync(`tag ${newTargetPlayer} remove ${opTag}`)
                                        sender.sendMessage(`${glyph} ${newTargetPlayer} n'est plus co-Host de la partie ! `)
                                        sender.runCommandAsync("playsound mob.chicken.plop @a")
                                    }
                            }else {
                                sender.sendMessage(`${glyph} !co-host @"Nom du joueur"`)
                                error(sender)
                            }
                    }
                    break;
                }
            }
        })
    }
dim tusk
distant gulch
#

The only thing I need to import

#

is world and system

#

from "@minecraft/server"

dim tusk
distant gulch
#

right?

somber onyx
dim tusk
# somber onyx like this `!cohost @LunaireI`
export const opTag = 'operator';
export const commandPrefix = "!";

world.beforeEvents.chatSend.subscribe((event) => {
    const sender = event.sender;
    const message = event.message;

    if (message.startsWith(commandPrefix)) {
        event.cancel = true;
        const args = message.slice(commandPrefix.length).split(/\s+/g);

        switch (args[0]) {
            case 'cohost':
                if (args[1]) {
                    let targetPlayer = args.slice(1).join(" ").replace("@", "");
                    const targetPlayerObject = Array.from(world.getPlayers()).find(player => player.name === targetPlayer);

                    if (targetPlayerObject) {
                        if (!targetPlayerObject.hasTag(opTag)) {
                            targetPlayerObject.addTag(opTag);
                            world.sendMessage(`${glyph} ${sender.name} est maintenant co-Host de la partie !`);
                            sender.runCommandAsync("playsound mob.chicken.plop @a");
                        } else {
                            targetPlayerObject.removeTag(opTag);
                            world.sendMessage(`${glyph} ${targetPlayer} n'est plus co-Host de la partie !`);
                            sender.runCommandAsync("playsound mob.chicken.plop @a");
                        }
                    } else {
                        sender.sendMessage(`${glyph} !cohost @"Nom du joueur"`);
                        error(sender);
                    }
                } else {
                    sender.sendMessage(`${glyph} Utilisation: !cohost @"Nom du joueur"`);
                    error(sender);
                }
                break;
        }
    }
});
somber onyx
#

thanks you guy's

dim tusk
wary edge
#

Since it's a string it should automatically convert.

dim tusk
dim tusk
distant gulch
#

but I tried thee other way too

#

Then I thought that maybe my script isn't working

#

so I did a simple itemUse

#

but my script isn't running at all

#

weirdly

dim tusk
#
system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        let { forward, right, backward, left } = direction(player);
        let text = ''
        if (forward > 0) {
           text = 'forward';
        } else if (left > 0) {
           text = 'left';
        } else if (right > 0) {
           text = 'right';
        } else if (backward > 0) {
           text = 'backward';
        } else return;
        player.sendMessage(text);
    }
})

function direction(player) {
    let velocity = player.getVelocity();
    let viewDirection = player.getViewDirection();

    let viewDirMagnitude = Math.sqrt(viewDirection.x ** 2 + viewDirection.z ** 2);
    let normalizedViewDir = { x: viewDirection.x / viewDirMagnitude, z: viewDirection.z / viewDirMagnitude };

    let forwardVelocity = (velocity.x * normalizedViewDir.x + velocity.z * normalizedViewDir.z);
    let rightVelocity = (velocity.z * normalizedViewDir.x - velocity.x * normalizedViewDir.z);

    let backwardVelocity = -forwardVelocity; 
    let leftVelocity = -rightVelocity; 
    
    forwardVelocity = Math.round(forwardVelocity * 100) / 100;
    rightVelocity = Math.round(rightVelocity * 100) / 100;
    backwardVelocity = Math.round(backwardVelocity * 100) / 100;
    leftVelocity = Math.round(leftVelocity * 100) / 100;
    return {
        forward: forwardVelocity,
        right: rightVelocity,
        backward: backwardVelocity,
        left: leftVelocity
    };
}```

This works very fine to me.
distant gulch
#

I added this to make sure

world.afterEvents.itemUse.subscribe((e) => {
    if (e.itemStack.typeId == "minecraft:stick") {
        world.sendMessage("Working");
    }
})
#

but that didn't do anything either

#

My script is bein all messed up

dim tusk
distant gulch
#

They may or may not, unfortunately, my script is broken so I can't find out lol

dim tusk
#

Probably you disabled it on settings or json ui

#

But as I said it works. That's why I'm confused

distant gulch
#

Nah, I'm using a server, and I keep my server running the same all the time

#

I'll try copy and pasting this into a new addon

#

and see if it works

dim tusk
distant gulch
#

Is there any way to make it test diagonals?

#

I'm terrible with javascipt Math

dim tusk
#

Like forward-left?

distant gulch
#

sure

#

Yeah

dim tusk
#

just add that in the iff statement

#

Ok I'll do it for you

distant gulch
#

Oh, makes sense

#

just a

#
else if (left > 0 && forward > 0)
#

But to make it detect backward easier, can I just up the value from > 0 to > 0.5 or something?

#

wait, that would make it less detecting

#

I'll make backwards above left and right

dim tusk
# distant gulch Oh, makes sense
system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        let { forward, right, backward, left } = direction(player);
        let text = '';

        if (forward > 0 && left > 0) {
            text = 'forward-left';
        } else if (forward > 0 && right > 0) {
            text = 'forward-right';
        } else if (backward > 0 && left > 0) {
            text = 'backward-left';
        } else if (backward > 0 && right > 0) {
            text = 'backward-right';
        } else if (forward > 0) {
            text = 'forward';
        } else if (left > 0) {
            text = 'left';
        } else if (right > 0) {
            text = 'right';
        } else if (backward > 0) {
            text = 'backward';
        } else return;
        
        player.sendMessage(text);
    }
});```
distant gulch
#

yeah, I already got that

#

thanks

dim tusk
distant gulch
#

Yeah, that's why I corrected myself

celest abyss
#

How can I make it so that it only interacts with the entity if it has a tag?

I'm using playerInteractWithEntity

dim tusk
celest abyss
dim tusk
celest relic
#

The /loot command always seems to spawn items on the edge of blocks. Is there a way to teleport each dropped item from the command to the center of a block?

dim tusk
celest relic
#

Yes, but regardless of the position input into the command, the loot will always spawn on the edge

slow walrus
#
  • 0.5 on x and z
celest relic
slow walrus
#

hmm probably

#

is it in the corner or like actually on only one edge?

celest relic
#

The corner

#

Like the very corner

slow walrus
#

yeah

#

north-west corner afaik

#

must be a bug

celest relic
#

Mmhm

slow walrus
#

you can run the command, then getEntites at the location, filter for items, and tp them to the center i guess

celest relic
#

Alright, thanks

slow walrus
#

chuck the tp stuff in a system.run though, cause the items might not spawn in the same tick

celest relic
#

Hmm. Explain more

#

Nevermind, got it, thanks Omniac!

distant gulch
#

Bonjour

celest relic
celest relic
dim tusk
#

That shouldn't happen in the first place.

celest relic
distant gulch
#

Divine General Maharago

celest relic
olive rapids
#

Hi, how are you? Can someone help me recreate some scripts with the same functions?

jolly citrus
distant gulch
#

AHH

proud saddle
#

playerSpawn after events triggers after player join the world?

warm mason
slow walrus
#

you can use event.initialSpawn to see if it's their first time spawning (aka. they joined)

ruby haven
#

On a function flie can I create variables there? Or create variables in script and import it to my function file

distant gulch
#

es, by using the import and export sytaxs

jolly citrus
#

initialSpawn is a bool determining whether or not it is the first time the player’s entity has spawned in since they have joined

distant gulch
#

@ruby haven

// scripts/config.js
export const myVariable = 12;
// scripts/function.js
import { myVariable } from "./config"
jolly citrus
ruby haven
#

Not a script file but a function file

distant gulch
#

ohhh, no you cant (i think)

jolly citrus
#

i doubt that it’d be possible

distant gulch
#

by using scoreboard

distant gulch
#

like

scoreboard players set "response:1" manager 1

// other .mcfunction

execute if score "response:1" matches 1 run ...

ruby haven
distant gulch
ruby haven
distant gulch
#

it does

ruby haven
ruby haven
distant gulch
#

well, initialSpawn is true when its your first time spawning

#

not if you really jiined for the first first time

ruby haven
ruby haven
distant gulch
#

No

#

initialSpawn is true, everytime you enter a world and the player spawns, if you die and the player spawns again, it will be false

ruby haven
distant gulch
#

Well now you know

#

Just do

if he joins add a tag if he doesnt already haves it.so you can check if its his first join

jolly citrus
distant gulch
#

so then there is no issue

ruby haven
jolly citrus
#

initial spawn, meaning the first time their ENTITY SPAWNS as they join

#

doesn't matter if they're a new, fresh player

#

what matters is if their entity has been spawned for the first time since they initialize their connection

distant gulch
#
if (player.hasTag("isRegistered") {
    // is already registered
else {
  player.addTag("isRegistered")
   // ..code
}
#

smth like that

jolly citrus
#

without initialSpawn it will run if you warp dimensions, die, respawn etc

ruby haven
# jolly citrus obviously?

I thought you're telling that if intialspawn works like I thought cause @distant gulch already cleared out the misunderstanding for me

jolly citrus
#
world.afterEvents.playerSpawn.subscribe(({initialSpawn, player})=>{
    if (initialSpawn && (!player.hasTag("isRegistered"))) {
      // Code to run when they join for the first time ever
      player.addTag("isregistered")
    }
  }
)
jolly citrus
ruby haven
jolly citrus
#

okay

#

thank you for letting me know

#

?

ruby haven
jolly citrus
#

i got that dw

quick shoal
#

Guys

#

Quick question

#

Is the formValues can be changed to other names?

#

    new ModalFormData()
        .title('§lTpa')
        .dropdown('select player!', playerNames, 0)
        .show(player).then((Tpa) => {
            if (!Tpa) return;
            const selected = playerNames[Tpa[0]];
#

Like this

chilly fractal
#

No

#

Use Tpa.formValues[0]

quick shoal
#

Ohh

ruby haven
#

What is the command that centers an entity in a block?

warm mason
ruby haven
#

Can I use this in before events or after events?

#

Cause I want the entity to be centered upon spawned without delay if possible?

quick shoal
#

Guys

#
function tpa(player) {
    const players = world.getAllPlayers().filter(p => p.name !== player.name);
    const playerNames = players.map(p => p.name);

    if (players.length === 0) {
        player.sendMessage('§cno others player online!');
        player.playSound('random.hurt');
        return;
    }

    new ModalFormData()
        .title('§ltpa')
        .dropdown('select player', playerNames, 0)
        .show(player).then((Tpa) => {
            if (!Tpa) return;
            const selected = playerNames[Tpa.formValues[0]];
            const targetPlayer = players.find(p => p.name === selected);

            if (!targetPlayer) {
                player.sendMessage('§cplayer is offline!');
                player.playSound('random.hurt');
            } else {
                requestTpa(player, targetPlayer)
                targetPlayer.playSound('random.toast');
                player.sendMessage(`§c§asent request to §b${targetPlayer.name}`);
                player.playSound('random.pop', {
                    volume: 5
                });
            }
        });
}
quick shoal
#

I really can't find the reason

#

Who can help me solve this?

chilly fractal
#

Try using world.getPlayers() instead of world.getAllPlayers and if it doesn't work just make it direct

chilly fractal
#

Like playerNames accesses the players directly and same with target player, they both have their own world.getPlayers() instead of relying on "players"

chilly fractal
acoustic basin
#

guys, how to make entity get a block in 10 block radius every 1 second?

#

ik that i gotta use system.runInterval, but im stuck at looking for a block in 10 block radius, i dont quite know how to do it

jolly citrus
#

is there a way to pre-calculate the path that an ender pearl would pass through if thrown

proud saddle
#

do we have a limit of world dynamic properties to world?

distant tulip
proud saddle
#

okay

warm mason
#

I heard that too, but it's a disinfo.

jolly citrus
#

just found out you can technically cancel ender pearls from tping when landing

#

not the dmg tho

#
world.beforeEvents.entityRemove.subscribe(({removedEntity})=>{
    if (removedEntity.typeId == "minecraft:ender_pearl") {
        let owner = removedEntity.getComponent("projectile").owner
        let ownerLoc = owner.location
        system.run(()=>{
            owner.teleport(ownerLoc)
        })
    }
})
distant tulip
# warm mason no

keys can only be 32k bit
so there is a limit, you probably will never reach it tho

jolly citrus
#

according to them

distant tulip
#

there is

jolly citrus
#

serty said no so i assumed

#

idk myself

proud saddle
jolly citrus
#

🤷

distant tulip
#

nothing is unlimited
the game is running in 32bit

distant tulip
distant tulip
jolly citrus
#

i feel like it might not have privileges

#

tho

distant tulip
#

oh yeah

#

runinterval?

proud saddle
distant tulip
#

as i said echa key can be 32k bit
if you used all string in that range you can't save anymore

proud saddle
distant tulip
#

yeah

#

i used to save more then 10 properties a tick for 20 min without a problem

warm mason
jolly citrus
#
let pearlMap = new Map();

system.runInterval(() => {
    world.getDimension("overworld").getEntities({type: "minecraft:ender_pearl"}).forEach(pearl => {
        /** @type {Array} */
        let path = pearlMap.get(pearl.id);
        if (path) {
            pearlMap.set(pearl.id, path + world.getDimension("overworld").getBlock(pearl.location).typeId);
        } else {
            pearlMap.set(pearl.id, world.getDimension("overworld").getBlock(pearl.location).typeId);
        }
    });
});


world.beforeEvents.entityRemove.subscribe(({removedEntity})=>{
    if (removedEntity.typeId == "minecraft:ender_pearl") {
        /** @type {Array} */
        let path = pearlMap.get(removedEntity.id);
        if (path) {
            Frozen.Info(path)
            if (!path.includes("minecraft:air")) {
                let owner = removedEntity.getComponent("projectile").owner
                let ownerLoc = owner.location
                system.run(()=>{
                    owner.teleport(ownerLoc)
                })
            }
        }
    }
})

why does the owner not get teleported back

merry crown
#

🤨

distant tulip
jolly citrus
#

it is my original loc

#

for whatever reason if (!path.includes("minecraft:air")) is returning false?

#
world.beforeEvents.entityRemove.subscribe(({removedEntity})=>{
    if (removedEntity.typeId == "minecraft:ender_pearl") {
        let owner = removedEntity.getComponent("projectile").owner
        let ownerLoc = owner.location
        Frozen.Info(JSON.stringify(ownerLoc))
        /** @type {Array} */
        let path = pearlMap.get(removedEntity.id);
        if (path) {
            Frozen.Info(path)
            if (!path.includes("minecraft:air")) {
                system.run(()=>{
                    owner.teleport(ownerLoc)
                })
            } else {
                Frozen.Info("was false")
            }
        }
    }
})
#

fixed it

#
world.beforeEvents.entityRemove.subscribe(({removedEntity})=>{
    if (removedEntity.typeId == "minecraft:ender_pearl") {
        let owner = removedEntity.getComponent("projectile").owner
        const ownerLoc = JSON.parse(JSON.stringify(owner.location))
        Frozen.Info(JSON.stringify(ownerLoc))
        /** @type {Array} */
        let path = pearlMap.get(removedEntity.id);
        if (path) {
            Frozen.Info(path)
            if (path.replace(/minecraft:air/g,'') !== "") {
                system.run(()=>{
                    owner.teleport(ownerLoc)
                })
            } else {
                Frozen.Info("was false")
            }
        }
    }
})
proud saddle
drifting ravenBOT
#
When Preview?

It is unlikely to be preview day my dudes

When do Previews usually happen?

Previews usually occur on a Wednesday or Thursday between <t:1703692800:t> and <t:1703700000:t>

warm mason
distant tulip
celest abyss
#

how does random math work?

dim tusk
#

If you don't add the + 1 it will generate numbers from 0 to 99

chilly fractal
#

Yo if I use yield; early on in the loop would it return immediately or complete loop unless told to return?

#

(For example)

system.runJob(function* someName(){
  for (let I = 0; I > 1000; I++) {
  yield;
  let someThing = false;
  if (someThing) return;
  console.warn('Bay Harbor Butcher? NAH more like Bay Harbor Baddie');
  }
});
sage portal
#

It's up to you to decide how to apply that math.

chilly fractal
jolly citrus
#

can i set the name tag of an entity to show up differently for a client receiving some form of packet using server-net

celest abyss
#

Is it possible to make the player's name not appear?

#

That is, the name does not appear above the character.

sharp elbow
neat hazel
dim tusk
sterile epoch
#

does anyone know why ```js
function getNearbyEntities(player, maxDistance) {
const nearbyEntities = player.dimension.nearbyEntities({
maxDistance: maxDistance,
families: ["mob", "player"],
location: player.location
});
return nearbyEntities;
}


isn't working?
uncut summit
#

its not working

thorn flicker
#

you guys should make posts

wary edge
#

@uncut summit Please don't make a post and then repost it here.

sterile epoch
#

i looked on the wiki, it says "mob" accounts for all mobs, including passive and hostile

#

so not sure what's causing it

thorn flicker
sterile epoch
#

my fault, meant to put getEntities

#

it wasn't a copy paste of my function, it was a retype, but original function is correct

thorn flicker
#

and dont make this a function, just put this in a variable

#

to get the entities within this array, just use a for loop.

sterile epoch
#

im using it for multiple weapons tho

#

rn I have the same getEntities in each so i thought making it a function would be cleaner

#

but do u know what's wrong with the families parameter?

thorn flicker
sterile epoch
#

hm

potent drift
#
const stone = Object.values(Protection_Stones).find(stone =>
    item.typeId === stone.id && item.name === stone.nombre
  );
simple arch
#

anyone willing to help me with setEquipment issue? I don't get the problem. (even though nobody responded) although the chat function works but the setEquipment is an issue I don't understand.

dim tusk
dim tusk
potent drift
simple arch
# dim tusk equippable component only works in player rn...

well it might be but I managed to do it on simulated players. You just have to go far away until the simulated player is a (classic not very classic but the one without the steve smile) and the equippable (e.g, offhand) will appear but with other ones it'll just put on automatically.

#

plus I get it. It doesn't work, but I also don't think mojang is going to work on simulated players anyway :/

dim tusk
dim tusk
distant gulch
#

I'm trying to grab a custom entity I made. I can even spawn it, but I can't get it from world.getEntity()

#
world.afterEvents.itemUse.subscribe((e) => {
    if (e.itemStack.typeId == "minecraft:gold_nugget") {
        e.source.sendMessage("Working");
        const playerLoc = e.source.location;
        const playerView = e.source.getViewDirection();
        const playerHyp = Math.sqrt(playerView.x * playerView.x + playerView.y * playerView.y);
        e.source.dimension.spawnEntity("mm:empty_entity", e.source.location);
        e.source.sendMessage("Working2");
        const fireballTp = system.runInterval(() => {
            world.getEntity("mm:empty_entity").applyKnockback(playerView.x, playerView.y, playerHyp, playerHyp);
        })
        system.runTimeout(() => {
            system.clearRun(fireballTp)
        }, 60);
    }
})
#

The only thing showing an error is the world.getEntity("mm:empty_entity")

#

ah nvm

#

maybe

#

idk

distant gulch
#

well bridge told me there is

#

but either way, I have a solution

#

maybe

#

If you have another way, I'd be glad to know

#

nvm, my solution is screwe

#

screwed

fiery solar
# distant gulch If you have another way, I'd be glad to know

spawnEntity returns the entity object.

...
const entity = e.source.dimension.spawnEntity("mm:empty_entity", e.source.location);
        e.source.sendMessage("Working2");
        const fireballTp = system.runInterval(() => {
            entity.applyKnockback(playerView.x, playerView.y, playerHyp, playerHyp);
        })
        system.runTimeout(() => {
            system.clearRun(fireballTp)
        }, 60);
    }
potent drift
distant gulch
#

Ah, the entity is from that command

distant gulch
#

script*

#

now I just need to fix some stuff up

#

Can anyone tell me the math needed to use applyKnockback in the exact direction I'm looking?

dim tusk
#

why'd you delete your message @ruby haven it's correct tho

ruby haven
celest abyss
#

entityComponentRegistry.registerCustomComponent('example:test')

Does this exist?

dim tusk
valid ice
#

Custom components do not exist for entities; there is no need for them

celest abyss
distant gulch
celest abyss
distant gulch
#

So you want it to increase your max hearts?

valid ice
#

Would that not be an item custom component?

distant gulch
#

That's possible

celest abyss
valid ice
#

Ah, or are you talking about specifically the health part

distant gulch
#

You can change your max hearts in player.json based on a tag

valid ice
#

For that, component groups are your friend

distant gulch
#

and you can change your tag with the item

#

Unfortunately, you'd reach a limit

#

but that limit is based on how many times you are willing to copy and paste

dim tusk
#

You got no choice 🤷

distant gulch
# celest abyss Yes
"minecraft:health": {
                    "value": 20,
                    "max": 20
                }
            },
            "custom:health1": {
                "minecraft:health": {
                    "value": 25,
                    "max": 25
                }
            },
            "custom:health2": {
                "minecraft:health": {
                    "value": 30,
                    "max": 30
                }
            }
bright dove
#

Anyone here have the time and passion to volunteer for an on-going Create port for completion ?

thorn flicker
dreamy elbow
#

Is there an easy way in scripts to change an entities targeted enemy. Like let's say I want a skeletons aggro to be changed from its current target to like a specific frog nearby for some reason

thorn flicker
dreamy elbow
#

Gotcha darn

acoustic basin
#

guys, how can i detect a block in a ten-block-radius for entity?

thorn flicker
acoustic basin
thorn flicker
acoustic basin
#

oki

bright dove
thorn flicker
#

whats up

warm mason
dim tusk
#

Is it possible to detect if an entity has a runtime identifier of a boat?

thorn flicker
dim tusk
#

Looks like I'll just make the player stop riding any entity

proud saddle
proud saddle
# distant tulip wdym

i mean
I heard that the byte size of all world dynamic properties cannot exceed one megabyte

distant tulip
#

that is not true

shy leaf
#

one megabyte sounds too small

distant tulip
#

i think there is a limit on how much you can save in a tick
i remember getting a warning related to this

neat hazel
jolly citrus
#

is it possible to accurately get a player's ping

ruby haven
#

Is it possible to detect if a players model is slim or not cause I made this custom animation and model for the characters player but when my character switches to slim the skin breaks

jolly citrus
#

in world/realm no server

sage portal
#

how do you check if a player has an item?

dim tusk
dim tusk
dim tusk
bronze helm
#

is there a way to disable players from stopping sprinting when attacking other players/entities?

sage portal
dim tusk
#

for inventory you use player.getComponent('inventory').container and player.getComponent('equippable') for armor and offhand

sage portal
#

well that sucks. I guess I'll have to make that into a function for convenience.

dim tusk
#
const inventory = players.getComponent('inventory').container;
for (let i = 0; i < inventory.size; i++) {
   const item = inventory.getItem(i);
}```
sage portal
#

I was looking to check if a player had an item in any possible slot: inventory, hotbar, hands, and armor

buoyant canopy
#

how do i check if a location is inside loaded chunks?

dim tusk
dim tusk
# bronze helm someone?

No I think? The closest thing you can do is make the entity keep moving using applyKnockback()

bronze helm
distant gulch
#

How to I applyKnockback in the exact direction I'm looking? I'm using a runInterval to apply knockback to an entity in a straight line, but I can't get the angle right

warm mason
dim tusk
#

Can I make the entity float? Like just float doesn't levitate or go down just float?

warm mason
#

Can I make the entity float? Like just float doesn't levitate or go down just float?

distant gulch
#

but it's unprecise

warm mason
#

applyKnockback is never accurate

distant gulch
warm mason
#

no

distant gulch
#

To make a bullet/fireball

#

or anythinfg that goes straight in the direction I'm looking

#

anything*

#

alr

#

that sucks

distant gulch
#

how can I set the rotation of a mob to face a player

#

or would I have to use commands?

dim tusk
random flint
distant gulch
distant gulch
#

I'm assuming you are referring to water, as that's where buoyancy takes place

dim tusk
dim tusk
dim tusk
random flint
#

why cannot you just use teleport()

dim tusk
random flint
#

Shouldn't the player also get teleported?

dim tusk
ripe swan
#

ok, I'm calling shenanigans... The Dimension class on MS's stable API's page clearly shows that it has a containsBlock method, yet visual studio has no reference to it for @minecraft/server v1.15.0

distant gulch
dim tusk
dim tusk
ripe swan
#

RC?

wary edge
#

Release candidate.

distant gulch
ripe swan
#

So they jumped the gun on updating the Stable API documentation?

dim tusk
wary edge
#

Idk. I dont use ms docs for scripting.

ripe swan
#

alright, fair enough

random flint
#

-# Doesn't dismount me ^

dim tusk
#

Ngl, I kinda forget that existed lmao

dim tusk
random flint
#

It looks like the teleportation doesn't reset the falling momentum, idk, maybe just weird unintended bug

dim tusk
random flint
#

Good job 👍

olive briar
#

how can i detect an entity in a range?

#

whit script

#

with

knotty plaza
dim tusk
#

Hmm, I stringified the location, and face location in getBlockFromViewDirection and the stringified values are flipped instead of { x: 0, y: 0, z: 0 } it's { z: 0, y: 0, x: 0 } I remembered someone pointed this out last year...

knotty plaza
dim tusk
knotty plaza
#

Just do it manually, its the only way

dim tusk
neat hazel
jolly citrus
dim tusk
autumn seal
#

how do arrows store their piercing level?

neat hazel
distant tulip
autumn seal
#

unfortunate

neat hazel
#

Thnk

distant tulip
#

np

ruby haven
dim tusk
ruby haven
thorn flicker
distant tulip
#

you can "disable" it other ways

thorn flicker
ruby haven
distant tulip
ruby haven
thorn flicker
#

I know there's the movement component

distant tulip
#

yeah that

thorn flicker
#

ive disabled sprinting with it before, but it was weird

distant tulip
#

how so?

thorn flicker
distant tulip
#

no need
i guess it well be
sense it take a moment to change

thorn flicker
#

that wasnt the problem I think

#

ill mess around with it again at some point and let you know.

distant tulip
#

alr

distant gulch
#

What does struct Scripting::FutureType entail in scriptstats?

#

Is that await/run jobs?

#

has there ever been a update from this?

shy leaf
#

whats the max size limit for script event messages?

distant gulch
#

2500 chars

shy leaf
sudden nest
slow walrus
shy leaf
#

another bao_comm_ty

slow walrus
#

what do you need it for?

shy leaf
slow walrus
#

communication?

shy leaf
#

yep

slow walrus
shy leaf
#

ooooo

#

ill take a look at it

ruby haven
#

Is it possible to create a boomerang type projectile using scripts there is an angle offset parameter in the projectile component but I think it only works vertically so I want to make a curving projectile horizontally

dim tusk
ruby haven
dim tusk
#

Iirc the shulker bullet has hardcoded speed, so the speed the shulker have will be same if you sue it on your own.

sterile epoch
#

how can I summon an entity in front of the player?

#

using spawnEntity

dim tusk
sterile epoch
#

Tysm

jolly citrus
#

can i kill a player with a specific death reason?

sterile epoch
jolly citrus
#

can the cause be any string

#

like "0"

#

or something

sterile epoch
#

has to be an acceptable damage cause

jolly citrus
#

ah

sterile epoch
#

like "freezing", etc

jolly citrus
sterile epoch
#

yes

jolly citrus
#

will .getEntities() with EntityQueryOptions also include entities in unloaded chunks?

sterile epoch
#

don't think so. doing /testfor @e[type=type] with that entity doesn't return it if it's in an unloaded chunk

jolly citrus
#

yeah i figured that out, sad

#

but makes sense tho

sterile epoch
#

fr

#

imo bedrock should still return entities in unloaded chunks. Think it does on Java

jolly citrus
#

how do i check what block a player would be interacting with if they clicked on the screen (like getting block from view direction, but w support for mobiles)

dim tusk
#

Is the breaking or interacting one

odd path
#

Coddy

#

Coddy

#

How the heck do I identify the interacting entity with InteractWithEntity?

#
world.beforeEvents.playerInteractWithEntity.subscribe(event => {
  const { player, entityTarget } = event

  if (entityTarget.typeId != "ssak:condition_changer") return

})
dim tusk
odd path
#

Is it not possible to transform target into a variable of type entityTarget?

dim tusk
#

That??

odd path
#

May God bless us

dim tusk
odd path
dim tusk
jolly citrus
#

i need like the view direction but based on the position they’d be clicking on if they touched the screen/left clicked

#

to make it movile compatible

#

cos viewdirection is not

warm mason
jolly citrus
#

need to check if they are trying to use it directly on a block

#

i dont want ppl to pearl glitch easily

ruby haven
#

Can I access an entities anchor through scripts?

wise raft
#

There is still no way to get the item translation code, right?

somber cedar
wise raft
jolly citrus
#

how do i check what block a player would be interacting with if they clicked on the screen (like getting block from view direction, but w support for mobiles)

random flint
#

playerInteractWithBlock or itemUseOn

jolly citrus
#

how do i create a new Block object

#

i need to return default values on .getBlock() but i cant figure out how

random flint
jolly citrus
random flint
#

No, that's itemUse

cold shoal
#

Is there a way to make the spawned arrow through scripting unclaimable?

cold shoal
#

Like it can't be picked up.

celest abyss
#

How can I change the player name?

#

Or how can I make the player's name not appear?

unique acorn
celest abyss
#

Ok

gusty bramble
#

Would it be possible to detect items despawning and have it say something like “[item] despawned” in chat

distant tulip
#

yeah that work

frozen vine
#

Can lore be translated?

distant gulch
dim tusk
#

Can you at least access the global variables before the world was /reload or closed? I know dp exists but I'm kinda curious if you could access it before the data is erased

distant tulip
distant tulip
dim tusk
#

You mean the worldInitialize?

distant tulip
#

in beforeEvents

dim tusk
dim tusk
# distant tulip

Minato idk if this is intended behavior because I'm using a local world but when you /reload it can access the variables but when leaving the world no. Lol

distant tulip
#

huh

#

that is weird

dim tusk
distant tulip
#

can't right now, sorry

dim tusk
# distant tulip

Nah it's okay.. just weird because it's the opposite of the descriptions

distant tulip
dim tusk
#

I did tested it.

distant tulip
#

the game clear the variables before shutdown event fire?

dim tusk
#

This is the script, sorry kinda messy. I was testing some things

#

Want to send me a vid?

distant tulip
distant tulip
dim tusk
dim tusk
distant tulip
dim tusk
distant tulip
#

🤷

dim tusk
#

Guys is there a way to add extra in unnamed item? Like it would be <name> - <other>

#

Since the nameTag returns undefined if the item is unnamed...

valid ice
#

Grab item typeId & format it, it's the best you'll get

dim tusk
dim tusk
#

Or what's is the limit
-# sorry for grammar

#

Nvm found it.

List of lore lines. Each element in the list represents a new line. The maximum lore line count is 20. The maximum lore line length is 50 characters.

distant tulip
dim tusk
#

Yeah I know but still doesn't fix that I can't access it's original name 😞

distant tulip
#

we well get client side scripting one day.... i hope

valid ice
#

Funny cuz you can access it with commands

dim tusk
#

You mean the /testfor

ruby haven
valid ice
ripe swan
#

anyone happen to know if there's a way to find an entity's component groups from script api? I'm trying to figure out if a bee has the "angry_bee" component group applied, but I haven't been able to find it as a component or property or tag. I'm not sure if there's any other way to interrogate an entity for the information

wary edge
ripe swan
#

well, that's unfortunate. I really didn't want to have to change the bee's entity code

random flint
olive briar
#

why this happen?

import * as jjba from "@minecraft/server";

jjba.system.runInterval(() => {
    for (const player of jjba.world.getPlayers()) {
        player.runCommandAsync(`execute at @s run say gay`)
    }
}, 1);
dim tusk
olive briar
#

1.13.0

#

no experimental

dim tusk
# olive briar 1.13.0

Try using a newer format version like 1.20 since the execute command you used is new format

olive briar
#

ty, i think i forgot this

dim tusk
#

And just do player.sendMessage("im gay")

olive briar
#

for the execute

dim tusk
ripe swan
#

I'm not entirely sure what to do with that.

dim tusk
main hill
#

Anyone know why the BlockPermutation.getState had a restrictive type constraint added to it? This breaks basically all custom block examples if you're using 1.18 beta

random flint
#

What's a type constraint?

slow walrus
#

iirc there's a workaround for it

#

somewhere

random flint
#

Oh, the typing.... make sense

slow walrus
#

Here:

main hill
#

Bit odd this change got put in when it breaks stuff

slow walrus
#

stuff slips past

#

it is also in beta

#

so there's some breakage expected

slow walrus
shy leaf
#

i dont wanna force other addons to use it

subtle cove
slow walrus
sterile epoch
#

is there an easy way to make a delay system? I want to make a countdown system with a bunch of camera commands, but having a bunch of system.runTimeout() inside of eachother is very unreadable

dim tusk
slow walrus
sterile epoch
#

thank you

dim tusk
#

I'm sooo stuuupid.

#

The .show().. I was so confused why its throwing error Cannot read canceled of undefined, I literally destructured it... Ughh

#
.show(player).then(({ selection }) => {
   if (selection.canceled) return;
});```
#

I literally did that

quick shoal
#

Selection alr is a property💀

dim tusk
gaunt flare
warm mason
gaunt flare
#

I see. Thanks!

distant gulch
#
world.beforeEvents.playerBreakBlock.subscribe((event) =>{
    const player = event.player;
    const block = event.block;
    if (block.type.id.includes("log")) {
        player.applyDamage(5);
    }
});
#

First time getting this error

unique acorn
distant gulch
#

Question, how can I apply damage to the player when he starts punchin a block

distant tulip
distant gulch
#

Oh k

ruby haven
#

Can I position a projectiles offset from an entity using scripts cause I tried it in json but I have no idea where my entities anchor is located at cause that is where the offset parameter bases it's values

gusty bramble
#

Is it possible to set it so a block can store data when a chat command is run?

Essentially I want to try make a block execute a function file (selected by trying a chat command with the file name) and say for example the block is powered it runs that function is something like this possible?

acoustic basin
#

guys, i need some help. i have a scriptevent for entity, the entity runs scriptevent command with timer, basically, i need to remove the item in entities hand. entity picks up the item, everything works just fine, but when i try to check if the entity has item in hand, i get this error

#

i dont understand y, since in jayly's script documentation it's stated the equippable component exists for every mob entities

acoustic basin
#
import { world, system, ItemStack, TicksPerSecond } from '@minecraft/server'

system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity: magmaGolem }) => {
    if (id === 'v360:magma_golem') {
        const mainhand = magmaGolem.getComponent('equippable').getEquipment('Mainhand')
        if (mainhand?.amount >= 1) {
            system.runTimeout(() => {
                magmaGolem.getComponent('minecraft:equippable').setEquipment('Mainhand', new ItemStack('air', 1))
            }, TicksPerSecond * 1)
        }
    }
})```
#

i tried and with minecraft namespace, and without, doesn't work...

warm mason
#

I don't really trust the information that equippable is now available for all mobs, although it seems to be written in the documentation (but I need to check). But here the error is different... how is the /scriptevent command called?

acoustic basin
warm mason
#

Try just using system.runInterval in the script

acoustic basin
#

still getting the error O_O

warm mason
acoustic basin
#
import { world, system, ItemStack, TicksPerSecond } from '@minecraft/server'

system.runInterval(() => {
    world.getDimension('overworld').getEntities({ type: 'v360:magma_golem' }).forEach((entity) => {
        const mainhand = entity.getComponent('equippable').getEquipment('Mainhand')
        if (mainhand?.amount >= 1) {
            system.runTimeout(() => {
                entity.getComponent('equippable').setEquipment('Mainhand', new ItemStack('air', 1))
            }, TicksPerSecond * 1)
        }
    })
}, 100)```
warm mason
acoustic basin
warm mason
#

By the way, you don't need to do that. You can write undefined or just don't write anything there

warm mason
#

But how can it be that getEntities returns an array that may contain undefined?...

#

Are you sure the code has been updated?

acoustic basin
open urchin
#

equippable only exists for players

warm mason
#

Ahhh, god..

#

I didn't read the error correctly

acoustic basin
warm mason
acoustic basin
#

i thought equippable works for non player entities...

warm mason
#

/replaceitem command

#

Apparently this is information from beta and it is possible that this will come into force in the future

acoustic basin
distant gulch
#

Guys

#

What do you (all) think about OOP

open urchin
acoustic basin
#

i'll try to achive my goal with /replaceitem, thank u Serty

open urchin
#

unless they plan to add a "mouth" slot, i think they should add equippable back because it makes a lot of thing impossible now

warm mason
distant gulch
#

hmm, maybe a new component would be better, like "minecraft:mouth_equipable"

#

is it possible to add owns? i dont think so but maybe it is

warm mason
distant gulch
#

Only tthe fox should be able to use it

#

because its more useful

#

Maybe make that the Fox is the only entity you can "interact" with!!

acoustic basin
#

i got it! and fully in json =D

open current
#

Hello, I’d like to ask a question. Is it possible to change player characteristics, such as speed or strength, without using /effect?

dim tusk
#
const move = player.getComponent('movement');
move.setCurrentValue(2);

world.afterEvents.entityHurt.subscribe(({ damageSource, hurtEntity, damage }) => {

});```
distant gulch
#

How can I see a list of events

dim tusk
distant gulch
dim tusk
distant gulch
dim tusk
olive briar
#

@dim tusk this still happens, whyyyyy? 😭

import * as jjba from "@minecraft/server";

jjba.system.runInterval(() => {
    for (const player of jjba.world.getPlayers()) {
        player.runCommandAsync(`execute at @s[tag=has_stand] run tp @e[type=dekuh:star_platinum,tag=stand_of_${player.nameTag}] ^-0.7^0.1^ facing ^^^4`);
    }
});
#

my manifest is right

warm mason
#
player.runCommandAsync(`execute at @s[tag=has_stand] run tp @e[type=dekuh:star_platinum,tag=stand_of_${player.name}] ^-0.7^0.1^ facing ^^^4`);```
olive briar
#

(i know i forgot the run)

#

Leave it, I'll solve it

dim tusk
#

btw guys is this valid on ActionFormData's body... Idk how to use rawtext in scripts lmao...
.body({ rawtext: [ { text: '' }, { translate: '' }, { text: '' } ] })
-# edit: yes it does infact work

#

Like <text> <translated> <text>

#

Valid?

deep yew
#

execute as?

fast wind
#

How do you hide the "Has custom components" on items?

dim tusk
fast wind
#

Thanks

main hill
#

Is there a place to submit feature requests for bedrock scripting APIs? It'd be awesome if there were a BlockCustomComponent callback for whenever redstone power level changes

granite badger
#

Use the onTick component to check if redstone power changes

main hill
#

Sure, that's a lot more heavyweight than it being something handled for you though

crude flame
#

how do you spawn a smal mob?

umbral scarab
#

I've installed NPM typings but my intellisense still isnt working. Any ideas?

deep yew
#

Intellisense is installed and updated correctly?

rigid torrent
#

Can an Add-On A read a dynamic property from Add-On B?

open urchin
#

no

quick shoal
#

Yea if U save in world

quick shoal
open urchin
#

they're saved and read per pack header uuid

quick shoal
#

Dynamic Property is a value(data to save in the world bro