#Script API General

1 messages · Page 69 of 1

dim tusk
#

then he can't edit the variable then? Or
He meant another thing

timid zenith
#

There is seve the function of the set home

deep yew
#

or

function homesystem (){}
export {homesystem}

main.js: import "homesystem"

rose light
#

Guys, how do I use the scoreboard class or anything else that uses the world

deep yew
rose light
#

is my using script v2

timid zenith
thorn flicker
#

he should use const anyway

deep yew
rose light
#

[Scripting][error]-ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (modulo/all_class/database/ScoreboardAapi.js:2)

[Scripting][error]-Plugin [script expansion - 1.0.0] - [main.js] ran with error: [ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (modulo/all_class/database/ScoreboardAapi.js:2

timid zenith
rose light
#

.

thorn flicker
deep yew
#

As I said, you can do system.run(()=>{world.scoreboard.otherstuff} for simply giving it permission, or use worldLoad with premade variables

rose light
timid zenith
#

Ummm

rose light
deep yew
thorn flicker
# rose light How would this work? Should I call all scripts through it?

just set up your main.js (or whatever the entry is called), to have worldLoad.
make seperate script files for your stuff, and import them.

// entry
import { world } from '@minecraft/server';

world.afterEvents.worldLoad.subscribe(() => {
  import("./scripts/example_1.js");
  import("./scripts/example_2.js");
  import("./scripts/example_3.js");
})
deep yew
rose light
#

would I have to do this for all my codes?

rose light
thorn flicker
rose light
#

Could I simply call a function there? But if I want to use an event, for example ItemUse, what happens?

#

@thorn flicker

chrome gyro
#

Random question... has anyone ever ran into lag from having too many scoreboards. I'm trying to figure out if I want to go full lore variables somehow or just keep using scoreboards.

rose light
#

[Scripting][error]-ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (world/modulo/all_class/database/ScoreboardAapi.js:2)

[Scripting][error]-Plugin [script expansion - 1.0.0] - [main.js] ran with error: [ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (world/modulo/all_class/database/ScoreboardAapi.js:2)
]

rose light
chrome gyro
dim tusk
warm drum
#

can anyone tell me what change in the 2.0.0 beta

chrome gyro
dim tusk
warm drum
#

but really

wary edge
warm drum
#

oh right

wary edge
#

No seriously, read the changelogs. It's a shit ton.

warm drum
#

someone should compile a list of change

wary edge
#

😭 That's what the changelogs are.

valid ice
#

Literally

#

Or… a community hosted docs site and you can compare changes between versions

warm drum
#

LIAR!!!

dim tusk
warm drum
#

😝

elder heath
#

Could you tell me why this is happening to me please :c?

[Scripting][warning]-Error getting dynamic property: ReferenceError: Native function [World::getDynamicProperty] does not have required privileges.

#
function safeGetDynamicProperty(propertyId) {
    try {
        return world.getDynamicProperty(propertyId);
    } catch (error) {
        console.warn("Error getting dynamic property:", error);
        return null;
    }
}

function safeSetDynamicProperty(propertyId, value) {
    try {
        world.setDynamicProperty(propertyId, value);
    } catch (error) {
        console.warn("Error setting dynamic property:", error);
    }
}

export function loadConfig() {
    try {
        const savedConfig = safeGetDynamicProperty(CONFIG_PROPERTY);
        if (!savedConfig) return;
        
        const parsedConfig = JSON.parse(savedConfig);
        if (!parsedConfig || typeof parsedConfig !== 'object') {
            console.warn("La configuración guardada no es válida");
            return;
        }
        
        config = {
            idleTime: 300,
            enableKick: true,
            kickDelay: 60,
            afkMessage: "§e{player} §6ahora está AFK",
            notAfkMessage: "§e{player} §6ha vuelto",
            warnMessage: "§cSerás expulsado en §e{kickDelay} §csegundos por inactividad",
            kickReason: "Has sido expulsado por inactividad",
            ignoreAdmins: true,
            notifyKick: true,
            notifyStatus: true,
            showActionBar: true,
            stillDetectionTime: 5,
            activeMessage: "§a§lBien, estás Activo",
            adminMessage: "§6§lEres Moderador, estate tranquilo",
            actionBarUpdateThreshold: 3,
            ...parsedConfig
        };
        
    } catch (error) {
        console.warn("Error al cargar la configuración AFK:", error);
    }
}

export function saveConfig() {
    try {
        safeSetDynamicProperty(CONFIG_PROPERTY, JSON.stringify(config));
    } catch (error) {
        console.warn("Error al guardar la configuración AFK:", error);
    }
}
elder heath
warm drum
#

Can be called or Must be called?

#

Why...

distant tulip
warm drum
#

world.afterEvents.worldLoad ?

distant tulip
#

startup event

#

it might not work 🤷‍♂️

valid ice
#

pain

warm drum
distant tulip
warm drum
#

knockback is also change....

distant tulip
# warm drum knockback is also change....

applyKnockback method now takes a VectorXZ parameter for the knockback horizontal force (which includes the strength/magnitude), as well as a vertical strength parameter. To convert from V1, you should normalize your previous direction vector and multiply it by the old horizontal strength value. Vertical strength is the same as before.

dim tusk
#

This is my first time dealing with custom commands so no hate lmao

#

~~js system.beforeEvents.startup.subscribe(({ customCommandRegistry }) => { customCommandRegistry.registerCommand({ name: 'creator:hellocustomcommand', description: 'Celebration size', permissionLevel: 'Any', optionalParameters: [{ type: 'Integer', name: 'celebrationSize' }] }, (celebrationSize) => { world.sendMessage('Lezz go!'); }); });

I'm kinda confused about what's wrong here.~~
-# fixed it.

dim tusk
granite cape
#

we need CustomCommandSender!!

slim spear
#

did they ever make equippable work for entities other than the player yet?

wary edge
#

No.

unique acorn
#

same thing for permission level

#

tbh this is so dumb, why couldn't it be string

iron apex
#

Guys, how do I make a cooldown?

dim tusk
#

Tho i won't really complain since it's newly released lol

shy leaf
iron apex
shy leaf
iron apex
#

I tried using JSON and it didn't work, so I thought maybe it's now being done through a Script

iron apex
shy leaf
#

and you use script API to start cooldowns, i think?

iron apex
#

I wanted to use a Script for this, but when you said about the JSON in which you need to make a Cooldown category, I broke down at that moment. Has this innovation been introduced long ago? I just remember that they used to do this in the item file.

shy leaf
#

this is vanilla example, ill grab some codes from addons, brb

iron apex
#

TY

shy leaf
#

and then you start cooldown using scripts

#

there are various ways of starting cooldowns, ill tell you if you need

iron apex
#

Can you tell me how to use it via Script? I'll need it for the future, in case I need it

shy leaf
iron apex
#

Yep

shy leaf
# iron apex Yep

so the first one is Player.startItemCooldown(), this allows you to start cooldown of specified category on player

iron apex
#

Thank you very much

shy leaf
#

the second one is ItemStack's cooldown component's startCooldown() function

#

it gets the category from the ItemStack itself, so you need to specify the player only

shy leaf
#
const item = player.getComponent("equippable")?.getEquipment("Mainhand");
item?.getComponent("cooldown")?.startCooldown(player);
player.startItemCooldown(cooldownCategory, tickDuration);
#

the former one starts the cooldown of duration set in JSON, while the latter can be anything, even beyond the max cooldown ticks

dim tusk
#

The same goes to setCurrentValue of health, tho the health icons don't increase :(

dim tusk
#

You can try it.

shy leaf
#

what the devil

thorn flicker
#

well that could be considered a problem in some cases

shy leaf
#

will it clamp the health back to 20?

dim tusk
shy leaf
prisma shard
#

is there a "workaround" to make a entity Invincible, just like when a player is in creative, and you hit him, he doesnt get hit. By workaround, I meant that something like if applying 255 amplifier resistance or instant health every tick, something like that

fallen cape
#

anyways, if the entity is yours, or you can edit its json, use damage sensors

prisma shard
prisma shard
#

its vanilla entity, thats why

fallen cape
prisma shard
#

thats some real goofy workaround

fallen cape
#

yeah

prisma shard
#

nah like i heard that 255 instant health every tick does that

#

so i am curious to know if its real

#

bcoz i dont have minecraft to test

fallen cape
#

the red overlay would still appear probably

prisma shard
#

can ya test

fallen cape
#

nah i'm busy rn

prisma shard
#

👍 np

lyric kestrel
#

Is it possible to initialise a block in JS yet, or no?

distant tulip
#

no

shy leaf
#

so yes that could work

dim tusk
#

guys, what Minecraft version is this script "1.0.0-beta.11940b24" and below.

#

Just curious

cold grove
#

Never heard about it

dim tusk
#

Then the npm is funny lol

fast wind
#

Does anyone know how to get the players current speed?

chilly moth
#

can anyone show example of
JSON.parse dynamic property and using it in json ui bindings/variables

prisma shard
#

i heard someone do it

#

so was asking abt that

lyric kestrel
#

Damnit, Nitro ran out

shy leaf
#

or if youre talking about velocity,
player.getVeloicty()

fast wind
shy leaf
#

oh

#

no, it gets the player's movement speed

#

not the player's speed

fast wind
fast wind
shy leaf
#

i think you can just do player.getVelocity()*20

#

for player's block per second

dim tusk
#

You just grab the value of dynamic property and thats it.

#

Use it to somewhere else, there no special thing tho.

#

also, you shouldn't problem in script side... Json ui is harder

chilly moth
#

yeah I guess I am confused in bindings and stuff

let slots = JSON.parse(world.getDynamicProperty(`slots_${player.id}`) || "[]");
#

I have made it using sidebar so just trying to remake it with json

dim tusk
#

you mean actionbar?

#

Then do setActionBar()

chilly moth
#

like that but actionbar disappears

dim tusk
#

Learn how to grbs the data in json ui

#

in short, learn json ui.

chilly moth
#

hm

dim tusk
#

bedrock wiki exists.

#

go in #1067869374410657962 and ask there

#

Open a post etc.

prisma shard
cold grove
#

Preview 1.19.60.22

dim tusk
#

.60 preview first then stable .50

prisma shard
distant tulip
#

add tame component and tame it to the player

prisma shard
solar dagger
#

If an entity is teleported to a location where a block is present. Does the game teleport the entity above that block or in the block?

distant tulip
distant tulip
solar dagger
prisma shard
distant tulip
distant tulip
prisma shard
distant tulip
#

what entity

solar dagger
prisma shard
distant tulip
#

huh, light block is not an entity

prisma shard
prisma shard
#

where is my mind at lol

prisma shard
#

thats why its an example

distant tulip
#

that is not a fix anyway

prisma shard
prisma shard
solar dagger
#

The dimension class has a native method getTopMostBlock

prisma shard
prisma shard
prisma shard
dim tusk
#

I mean I know, how about you?

prisma shard
#

?

dim tusk
dim tusk
prisma shard
#

good

prisma shard
#

can you tell me some uses of getBlockFromRay()

#

its like getBlockFromViewDirection() right?

dim tusk
#

since getBlockFromViewDirection() has ray limit

prisma shard
dim tusk
#

Try looking at the edge of a block it passes through it

#

Unlike getBlockFromRay() it doesn't.

dim tusk
prisma shard
#

Why does my VSCode auto-complete this?

instead of: js import { world } from "@minecraft/server"
Why is it doing this?

dim tusk
#

Because require is like import {} from? And vscode can read it but Minecraft can't?

prisma shard
#

but i have script API npm installed

#

is this any extensions doing that

dim tusk
#

and what's the connect?

prisma shard
#

connect?

dim tusk
#

what's the connect of Script APi npm istalled?

prisma shard
#

what is connect?

dim tusk
prisma shard
#

connecting is merging things... what would you mean by "connect of script API"

prisma shard
dim tusk
#

sigh

slow walrus
dim tusk
prisma shard
#

i see no type

slow walrus
#

then add it

#

how is there no type

slow walrus
#

did you do npm init?

prisma shard
slow walrus
#

then how tf are you even using typings

prisma shard
slow walrus
#

delete it and do npm init

#

the package.json

#

delete that file

#

and then in the same folder it was in, open terminal and run npm init, and then reinstall the dependency

prisma shard
#

okay..

prisma shard
prisma shard
#

what i put

gaunt salmonBOT
lyric kestrel
#

@prisma shard

prisma shard
#

hm

#

ok

#

oh

#

the module is it what ask for?

lyric kestrel
#

If you're doing the lastest then the top one

slow walrus
#

or nothing

untold magnet
#

uh, worldInitializes stable or beta?

inland plinth
#

stable

unique acorn
#

it's stable, but it got removed in 2.0.0-beta

#

and been replaced with worldLoad and startup

untold magnet
night acorn
#

anyone know how to get the itemstack currentlyin the players offhand slot?

#

im trying to use getSlot() but its index based

night acorn
#

ohhh

#

i was using the inventory one

unique acorn
untold magnet
#

good.

inland plinth
#

Can custom command get a command executor?

wary edge
#

Planned.

inland plinth
fast wind
#

After the new update worldInitialize stopped working and so my code for custom crops now is broken. What was it replaced with?

#

I've been using it to register a custom component

timid zenith
fast wind
wary edge
fast wind
#

Oh read that wrong

#

I actually don't know sorry

timid zenith
#

Well

timid zenith
prime zenith
#

Can you use script to make npc dialogues

unique acorn
prime zenith
#

How big can a title form body be

wheat condor
#

how do custom components work in the new 2.0.0-beta?

wary edge
wheat condor
#

i mean what's the event?

#

world.beforeEvents world initialize doesnt exists

unique acorn
#

the rest should be the same

wheat condor
#

ty

coral ermine
#

Why does js world.beforeEvents.playerInteractWithBlockExecute 4 times?

woven loom
#

use property

coral ermine
#

wym

woven loom
#

world.beforeEvents.playerInteractWithBlock.subscribe
if ( ! e.isFirstEvent) return

ur code
})

unique acorn
#

in the sendMessage part, you should do

world.sendMessage(celebrationSize.toString() + " " + string);
dim tusk
#

Motehr ufck I'm stupid

#

I didn't realized I'm using sendMessage

#

All this time I thought I'm using console

#

Mbmb

distant tulip
#

pfft

unique acorn
#

xd

#

hey you didn't have to delete that

#

now I look crazy

distant tulip
#

lol, he got ashamed of that

dim tusk
#

yes definitely

#

Like wtttf

distant tulip
leaden elbow
#

or refer to LeGend's samples

flat barn
#

Why does the Proxy native object no longer work?

untold magnet
#

uh, afaik there's a way to add emojis kind of things into the game, so try adding one somehow and apply it there.

#

-# idk how btw

#

well, try making the emoji longer

#

like increase the actual image size of that emoji, horizontally and diagonally and test if it works.

unique acorn
#

what's the event where when you press sneak it runs it

#

nvm found it

untold magnet
unique acorn
#

yep figured it out

untold magnet
midnight ridge
#

what is the best way to get the player inventory when he died?

drowsy scaffold
deep yew
#

You can save the players' inventories in a map that's being updated every few ticks and/or every time the inventory is updated. After the death, you can just get the inventory from the map

distant tulip
#

just use keep inv and get it on death

drowsy scaffold
slim spear
#

Is there a way to check if an item stack is a block without manually inputting every block id?

#

making a pickup notification thing and i need to differentiate between purely items and blocks

#

so i can put item. or tile.

wary edge
#

In 2.0.0 there is a get localization key.

slim spear
slim spear
wary edge
#

No.

slim spear
fallen cape
#

Scaling the whole glyph file makes the bounding box larger
If that's what you're talking about

#

Yeah just make a line on a bigger scale glyph file

prisma shard
prisma shard
prisma shard
slim spear
#

the system in that video was detecting item entities but the new system i made js compares old and new inv every 1/4 of a second

prisma shard
#

ugh

slim spear
# prisma shard ooo i see

here it is if you were curious

function updateInventory(player: Player) {
    const items: {[typeId: string]: {amount: number, item: ItemStack}} = {}
    function addItem(item: ItemStack) {
        const key = item.nameTag ? item.nameTag : item.typeId
        if (items[key]) {
            items[key].amount = items[key].amount + item.amount
        } else {
            items[key] = {amount: item.amount, item: item}
        }
    }
    const equippable = player.getComponent(EntityEquippableComponent.componentId) as EntityEquippableComponent | undefined
    if (equippable) for (const equipSlot in EquipmentSlot) {
        if (equipSlot === EquipmentSlot.Mainhand) continue
        const slot = equippable.getEquipmentSlot(equipSlot as EquipmentSlot)
        if (!slot) continue
        const item = slot.getItem()
        if (!item) continue
        addItem(item)
    }
    const inv = (player.getComponent(EntityInventoryComponent.componentId) as EntityInventoryComponent | undefined)?.container
    if (inv) {
        for (let i = 0; i < inv.size; i++) {
            const item = inv.getItem(i)
            if (item) addItem(item)
        }
    }
    const cursorComponent = player.getComponent(PlayerCursorInventoryComponent.componentId) as PlayerCursorInventoryComponent | undefined
    if (cursorComponent && cursorComponent.item) addItem(cursorComponent.item)
    inventories[player.id] = items
}

function*job(player: Player) {
    if (!player || !player.isValid()) return
    const lastItems = inventories[player.id]
    updateInventory(player)
    if (!lastItems) return
    const items = inventories[player.id]
    if (!items) return
    for (const id in items) if (!lastItems[id] || (lastItems[id].amount < items[id].amount)) {
        const item = items[id]
    }
}
round bone
#

Record<string, { amount: number, item: ItemStack }>

slim spear
#

what's the difference?

fallen cape
#

You want the package version to install?

Should be @minecraft/[email protected] or smth like that

prisma shard
stark kestrel
#

what was new applyKnockback ?

#

hurtEntity.applyKnockback(0, 1, 0.3, launchPower);

dim tusk
stark kestrel
dim tusk
prisma shard
#

uh

#

how would i set blockVolume and get it again as a global variable, to do setType() on it?

#

@dim tusk

dim tusk
prisma shard
#

i want to get the block interacted, but playerInteractWithBlock only works with interactable blocks

dim tusk
prisma shard
#

hmM ok

dim tusk
prisma shard
#

pretty genious workaorund lol

#

lemme see if i can do it before sending your snippet lol

#

do i have to get the first intersection using [0] in getblockfromray?

dim tusk
# prisma shard do i have to get the first intersection using [0] in getblockfromray?
world.beforeEvents.itemUse.subscribe(({ source, itemStack }) => {
  if (source.typeId !=== 'minecraft:player') return;

  const head = player.getHeadLocation();
  const view = player.getViewDirection();

  if (itemStack.typeId === 'minecraft:stick') {
    const blocks = player.dimension.getBlockFromRay({ x: head.x, y: head.y + 0.1, z: head.z }, view, { maxDistance: 10 });
    if (!blocks) return;

    const { block, face, faceLocation } = blocks;

    console.error(block.typeId);
  }
});```
prisma shard
#

thanks

dim tusk
shy leaf
#

yeah

prisma shard
#

declaring it like this only works in worldLoad

prisma shard
#

then set it inside the event

#

then did console.warn(volume)

#

then bruh returns undefined, meaning it wasnt set

dim tusk
#

I will try it, if it works means you did something wrong.

round bone
#

if you want to export a variable between files and change it, try using some singleton pattern

dim tusk
#

And yes, it works in my side....

round bone
#
const exportingObject = {
    "volume": "some value"
}

export { exportingObject }
prisma shard
#

um i think it works

#

it said its read-only

#

so i removed the export and works

prisma shard
#

@dim tusk

#

how can i get the messege that has been sent?

dim tusk
#

Wdym message that's been sent?

prisma shard
#

the mesege that has been just sent by player

dim tusk
#

chatSend...

prisma shard
#

if ( mesege === "helo")
this just check for if the messege matches

dim tusk
#

and yes it's beta, and no I don't know when it will become stable.

prisma shard
dim tusk
#
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {
  if (message === 'hello') {
    ev.cancel = true;
  }
});```
prisma shard
#

bruh

#

this just check for if the messege matches

#

suppose player sent a text in chat, i want the whole string in the script.

wary edge
prisma shard
#

..

#

how

#

anyways

#

i think i am just being stupid

dim tusk
#

uhh, where'd common sense go? Obviously get the message properties

prisma shard
prisma shard
#

damn, cant belive im THAT STUPID

dim tusk
#

BlockVolume, returns locations from point1 to point2, so it returns array of locations

prisma shard
#

messeeg just returns the string 😭 why im stupid

prisma shard
dim tusk
# prisma shard k thx

for getting individual locations just do js const volume = new BlockVolume(); for (const location of volume.getBlockLocationIterator()) { Dimension.setBlockType(location, 'minecraft:tnt'); }

prisma shard
#

alr thats genius

#

but fillBlocks is faster

#

uhm uhmmmm\

#

@dim tusk so i just updatedd tto 2.0.0-beta today, and.. i think i just saw that system.run() works to give privilage, why is everyone doing global variablle or await null?

dim tusk
#

why do that if you can just make that you store variable after world is loaded.

prisma shard
#

hmm

#

fair

prisma shard
# dim tusk Not 100% reliable

uhm

world.beforeEvents.chatSend.subscribe((ev) => {
    const { message, sender: player } = ev;
    if (player instanceof Player && message === `!set minecraft:stone`) {
        ev.cancel = true;
        player.dimension.fillBlocks(volume, "minecraft:stone")
    }
})

How would i make it for every block.typeId ?
like even if i type "!set minecraft:dirt", it will fillBlock dirt..

dim tusk
#

Can a zombie or mobs chat? No right?

prisma shard
prisma shard
#

animals cant chat 💀 ahh moment

prisma shard
dim tusk
#
world.beforeEvents.chatSend.subscribe((ev, { message, sender: player } = ev) => {
    if (message.startsWith('!set ')) {
        ev.cancel = true;
        const blockId = message.substring(5).trim();
        player.dimension.fillBlocks(volume, blockId);
    }
});```
#

As simple as that

prisma shard
#

"as simple as that". regex is not for everyone

dim tusk
#

Hmm, very obvious... You're doing a world edit.

dim tusk
#

Where'd you get that?

prisma shard
#

ok lol

dim tusk
#

message.substring(5).trim()
regex? Where?

prisma shard
#

i meant those string methods, i havent learn about them

#

so its hard for me

dim tusk
prisma shard
#

hmm okay

#

thanks then

#

damn

#

cool

#

works liken a charm

prisma shard
round bone
dim tusk
prisma shard
#

what?

dim tusk
#
let text = "Coddy";
let substring = text.substring(0, 2); // Extracts "Co"```
prisma shard
#

so, change .substring(5) to .substring(0, 2) ?

dim tusk
#

Nono, I didn't say that.

prisma shard
#

hm,mmmm. fillBlocks cannot perform single fill greater than 32768 blocks

#

how would i divide it so, it would perform 2 fillBlocks if it is greater than 32768 blocks?

#

@distant tulip

dim tusk
dim tusk
#

get if the blocks are more than that if yes dividie that.

stiff ginkgo
#

is it possible to add multiple thing in one line like this?

#
player.addTag('max').setproperty('max', 1).getComponent('projectile')
dim tusk
#

addTag().setProperty()

stiff ginkgo
#

i know but this there a way?

dim tusk
#

You're saying setProperty() is under addTag()??

dim tusk
stiff ginkgo
#

i want to summon entity with setproperty and getcomponent

#
player.dimension.spawnEntity(projectile, direction).getComponent("projectile");
dim tusk
dim tusk
prisma shard
stiff ginkgo
#

how to teleport entity like tp @s ^^^5

boreal siren
#

Guys, how can I use the beforeEvents.playerBreakBlock event to determine the color of a bed?

dim tusk
#

I'm not entirely sure but you can check if it has states that corresponds to color by doing.js world.beforeEvents.playerBreakBlock.subscribe(({ block, player }) => { if (block.typeId === 'minecraft:bed') { console.error(JSON.stringify(block.permutation.getAllStates())); } });

boreal siren
#

{"direction":2,"head_piece_bit":false,"occupied_bit":false}

#

There is no mention of color here.

dim tusk
# stiff ginkgo how to teleport entity like tp @s ^^^5
const entity = ...; // Your entity
const distance = 5; // How far to teleport forward

const view = entity.getViewDirection();
const head = entity.getHeadLocation();

entity.teleport({
    x: head.x + view.x * distance,
    y: (head.y + 0.1) + view.y * distance,
    z: head.z + view.z * distance
});```
dim tusk
boreal siren
#

0_0

distant tulip
prisma shard
#

omg hel naw

#

bro wrote a whole script for me

#

who told you to make a whole script

#

💀 .

prisma shard
dim tusk
prisma shard
#

what

distant tulip
#

sure

prisma shard
#

whats going on

dim tusk
#
function splitIntoChunks({ from, to }) {
  const max = 32768;

  const [xMin, xMax] = [Math.min(from.x, to.x), Math.max(from.x, to.x)];
  const [yMin, yMax] = [Math.min(from.y, to.y), Math.max(from.y, to.y)];
  const [zMin, zMax] = [Math.min(from.z, to.z), Math.max(from.z, to.z)];

  const totalBlocks = (xMax - xMin + 1) * (yMax - yMin + 1) * (zMax - zMin + 1);
  if (totalBlocks <= max) return [{ from, to }];

  const chunkSize = Math.floor(Math.cbrt(max));

  const chunks = [];
  for (let x = xMin; x <= xMax; x += chunkSize) for (let y = yMin; y <= yMax; y += chunkSize) for (let z = zMin; z <= zMax; z += chunkSize) {
    chunks.push({
      from: { x, y, z },
      to: {
        x: Math.min(x + chunkSize - 1, xMax),
        y: Math.min(y + chunkSize - 1, yMax),
        z: Math.min(z + chunkSize - 1, zMax),
      }
    });
  }

  return chunks;
}```
dim tusk
slim spear
#

wtf is a math.cbrt

dim tusk
slim spear
#

oh

remote oyster
#

Hi Google

prisma shard
dim tusk
prisma shard
#

i miss the days when "several peoples are typing" in this channel

distant tulip
#

would be cool if there is a general root function that you pass it n and it uses that for
root(number, n)

distant tulip
dim tusk
distant tulip
#

lol

dim tusk
#

fck u.

#

Never simplifying codes again.

distant tulip
#

lol, i mean you did a great job

dim tusk
#

Especially I love destructing so much.

prisma shard
#

i dont wanna make my sscript that complicated

lyric kestrel
distant tulip
distant tulip
untold magnet
#

uh, how am i going to decrease the itemStack amount? (const itemStack = player?.getComponent('equippable')?.getEquipment('Mainhand');)

honest spear
untold magnet
untold magnet
distant tulip
past coyote
past coyote
#

I’ll check when I can, replying so I remember

lyric kestrel
oak lynx
#

So like I am trying to do regions for my server and like I am storing player data in an external DB
any way to be sure that a player joining the server is the same player

#

I guess I can use a different server software that isn't pure bds for the routing server

lyric kestrel
remote oyster
remote oyster
fast wind
#

How does the new applyKnockback work?

#

Before I used this to make a character fly:
const { x, y, z } = player.getViewDirection();
player.applyKnockback(x, z, 4 - Math.abs(y) + player.getDynamicProperty('acceleration'), y)

#

How would it work now?

#

I get how it works just not how to add speed to x and z

unique acorn
fast wind
#

Oh I just needed to multiply my bad

#

That makes sense

unique acorn
#

you multiply the x and z value by the Horizontal strength

fast wind
fast wind
unique acorn
#

you can replace the js with anything

#

js is for javascript

#

and code is the code

sharp elbow
#

If doing that does anything, it makes it more readable

unique acorn
#

that's how I code lol

sharp elbow
#

It's interesting seeing people's approach to variables. Some people minimize their use as much as possible. Others use them quite liberally

oak lynx
distant tulip
wary edge
oak lynx
past coyote
#

It’s generally tedious

#

I ended up deciding to map items in a giant file that’s exported

oak lynx
#

for custom items I just made it so that the texture matches their ID

wary edge
#

Oh that's an excellent suggestion.

oak lynx
#

but for vanilla you kinda just need to have a big map

wary edge
#

I havne't messed with Server-UI that much and I glanced over that you can define an icon path!

oak lynx
#

My wishlist for script api:

  • a method that can get an area of blocks because getBlock() is slow
  • commands without namespaces (in case of no conflict)
  • ability to get player XUID
  • ability to use node js workers 🗣️
  • other stuff I forgot about
wary edge
supple reef
#

minecraft updates is shit

oak lynx
stuck ibex
#

u mean like putting icon on buttons?

slow walrus
oak lynx
untold magnet
#

uh, why is my itemStack not decreasing?
i tried all of those:
itemStack.amount--;
itemStack.amount -= 1;
itemStack.amount = itemStack.amount - 1
and i tried having all of them inside of system.run(() => {***}) and still not working for some reason

#

btw const itemStack = player?.getComponent('equippable')?.getEquipment('Mainhand');

unique acorn
open urchin
#

itemStacks are like block permutations, modifying them has no in-game impact
you need to set the player's equipment again after modifying the itemStack

untold magnet
untold magnet
unique acorn
#

👍

lyric kestrel
#

I've got something pretty cool to show in about an hour when I get back

#

I was going to send a video now, but I realised a texture path issue

coral ermine
#

Why does this error happen?

const ids = [
   "minecraft:coal_ore": "minecraft:coal"
];
const id = ids[block.typeId]
player.dimension.spawnItem(new ItemStack(id), { x: x + 0.5, y: y + 0.5, z: z + 0.5 });```

error: ```[Scripting][error]-TypeError: Native variant type conversion failed. Function argument [0] expected type: string | ItemType at ItemStack(native)```
unique acorn
unique acorn
#

otherwise it won't work

coral ermine
#

ty it worked

warped blaze
#

isn't there a way to make custom slash commands without namespaces? 😭

unique acorn
#

for now, there is no way

warped blaze
unique acorn
#

a lot of people have been saying to get rid of the namespace but at the moment nobody really knows except for the people that work at mojang

#

-# im betting that SmokeyStack knows if they will tho, he knows too much

timid zenith
timid zenith
#

Well, thank you

dim tusk
untold magnet
timid zenith
distant tulip
#

Your item have a syntax error

timid zenith
#

The item already appeared but it doesn't open the menu ui

ivory bough
#

how to force the player to look at an entity?

leaden elbow
#

does anyone have an extrrnal event handler

prime zenith
#

What is the script method to play a vanilla sound

dim tusk
#

Dimension.playSound()

#

Player.playSound()

thorn flicker
prime zenith
#

So not player.playsounf

thorn flicker
prime zenith
#

Minus my typos

thorn flicker
#

2 different purposes.

prime zenith
#

Thats what i want

thorn flicker
#

so use the player method

prime zenith
#

I got to wait 2 minutes to test cause i didnt add a debug to speed up or reduce time

thorn ocean
#

Is it me, or does applyKnockback not work on players anymore? I am already using the new syntax and it works on every entity except the player.

leaden elbow
#

is there a way to check if provided type id is mob, item, or something? like for example, minecraft:diamond returns item

#

or just an array of type ids

#

and also how to get Entity as Player? just like in EntityDie, i want to get damagingEntity as a Player

prime zenith
#

What is the sound for signing a book i think its signing a book sound im thinking of

#

Wait no when a page is turned hold on let me listen for the sound i need

#

Ok its when page is turned

#

Nvm found it

fallen hearth
#

How can I identify the last item the player received via /give?

cold grove
#

but you cant know if its from a command

dim tusk
dim tusk
dim tusk
thorn ocean
dim tusk
thorn ocean
dim tusk
#
world.beforeEvents.itemUse.subscribe(({ itemStack, source }) => {
  if (source.typeId !== 'minecraft:player') return;

  const view = source.getViewDirection();

  if (itemStack.typeId === 'minecraft:stick') {
    system.run(() => source.applyKnockback({ x: view.x * 2, z: view.z * 2 }, view.y) );
  }
});```
thorn ocean
# dim tusk ```js world.beforeEvents.itemUse.subscribe(({ itemStack, source }) => { if (so...

Well this is my code: ```function* liquidRun() {
for (const DimensionTypo of DimensionTypes.getAll()) {
world.getDimension(DimensionTypo.typeId).getEntities().filter((ent) => {
let block = ent.dimension.getBlock(ent.location);
if (block == undefined) return false;
if (customLiquids.includes(block.typeId)) return true;
}).forEach((ent) => {

        try {
            ent?.applyKnockback({ x: 0, z: 0 }, 0.01);
            ent?.addEffect("slowness", 10, { amplifier: 2, showParticles: false });
            if (ent.typeId == "minecraft:player") {
                ent.runCommand("effect @s slow_falling 1 240 true");
            };
        } catch (e) { };
    });
}

}```

leaden elbow
dim tusk
#

It returns EVERYTHING that is available in the world even custom ones.

thorn ocean
# dim tusk What's the purpose?

It's a function that gets every entity inside a valid custom liquid block and applies a knockback every tick to slow the entity down as it falls. I was trying to use knockback instead of using effects.

#

I was trying to see if I could slow down an entity (mainly a player) without using effects, as I plan to expand on such a thing in the future.

#

In fact I'm starting to think that applyKnockback for players DOES NOT WORK in system.run events.

#

And I mean without being included INSIDE world.beforeEvents or world.afterEvents.

thorn ocean
# dim tusk Then why does this work?

Because it's inside a world.beforeEvent, my function is in a system.runInterval that runs continuously. It doesn't run after a specific event happens.

#

At least that is what I'm assuming.

dim tusk
#
system.runInterval(() => {
  for (const player of world.getPlayers()) {
    const view = player.getViewDirection();

    if (player.isSneaking) player.applyKnockback({ x: view.x, z: view.z }, view.y);
  }
});```
thorn ocean
thorn ocean
sharp elbow
thorn ocean
sharp elbow
#

Android?

thorn ocean
#

Yep.

sharp elbow
#

That could be it, actually

thorn ocean
#

You're joking.

sharp elbow
#

Do you take knockback from other mobs when they hit you?

thorn ocean
#

I actually don't.

sharp elbow
#

Then applyKnockback will not push you around, either

thorn ocean
#

But what's causing that?

fallow carbon
#

oh boy, as far as we know thats a platform specific bug, not 100% what the trigger for it is but we have had it happen when the player is in an npc dialog and the npc is removed using the remove method in scripting.

#

if you find a way to fix it please let us know 🙂

sharp elbow
#

It might trigger in other conditions too, that's just the only one Fetchbot and I know about

#

Affects Nintendo Switch too.

#

Oddly, not any other platform. PC is totally fine

#

But the player not being pushed can also happen through more conventional means. For example, if you set the "minecraft:knockback_resistance" component to 1 on the player, applyKnockback will not push them either

thorn ocean
#

I have no idea what these conditions might be, but ur right. I went into another world, took knockback, and the applyKnockback worked.

thorn ocean
sharp elbow
#

Likely. Sorry to hear you are another victim of the weird bug

thorn ocean
thorn ocean
timid zenith
wary edge
valid ice
#

hey also @wary edge , that issue I was having with the startup event not being subscribed to- I solved it with a buttload of dynamic imports and globalThis's in a worldLoad event

#

I hate it, but it works

valid ice
#

what do you expect me to do, then

wary edge
valid ice
#

fr

prisma shard
prisma shard
#
if (lores.length === 0) return;
#

why does this line return error

#

i am having a stroke fixing my script

sharp elbow
#

The only error I would expect that to throw is "cannot read property 'length' of undefined"

#

Are you not checking if lores is an array first?

#

There's a couple of ways to check that:

if (lores && lores.length === 0) return;
if (Array.isArray(lores) && lores.length === 0) return;
if (lores?.length === 0) return;
prisma shard
#

It only happens, when you break a block, with a "empty hand"

#

(since it is in playerBreakBlockEvent)

#

I think it is bcoz it cant get lore lenght of hand

sharp elbow
#

That's a fair assessment. Then I would first check if getItem() on the container / slot returns undefined

prisma shard
#

h,mmmmmmm

#

seems like a chaining operator fixed them

#

ok i should really practice using chaining operator

leaden elbow
#

whats the event for player obtaining or picking up an item

prisma shard
#

hmm

#

So anyone can help me how could i do this

#

So..

#

It's a custom enchantment table, where the 1st slot is tool, 2nd slot is enchantment book, 3rd slot is result. So when we take the result, the 1st and 2nd slot doesn't get remove, we have to do it by scripting.

#

But this makes that. when 3rd slot is empty (meaning result item is taken) we clear 1st and 2nd slot

#

But this would do even, when we put the item and book there, they get cleared automatically

#

bcoz the result coming is slow, the result item appears after some delay

#

and it thinks that result item has been taken,

#

so the items get cleared without even taking the result item.

#

^
Can anyone help me with this problem?

#

i have no idea how could i fix this now

#

?

sharp elbow
#

I'm not sure I understand. To me it seems reasonable to have the inputs only be consumed after the check for a valid recipe; are you consuming the inputs and determining the outputs in separate logic loops?

#

Something like the following pseudocode:

function customEnchantingLoop() {
  slot1 = get slot 1
  slot2 = get slot 2
  output = recipeLookup(slot1, slot2)
  if (output) {
    slot3 = get slot 3
    slot3.setItem(output)
    slot1.setItem(undefined)
    slot2.setItem(undefined)
  }
}
#

Or, if the 3rd slot is set to the enchanting result and must be taken, then you should design the table with a state in mind, so you can compare information across ticks

#

But I'm taking shots in the dark at how you have it structured

prisma shard
#

ok we should move to a help post

#

i am gonna post the script there

sharp elbow
#

(I am promptly going to bed)

prisma shard
#

uhhhhhhh

#

wasn't there a clearInterval()

#

I cant find it

#

there is only clearRun() and clearJob()

#

whattt

#

@dim tusk

thorn flicker
prisma shard
#

hmmm oh bruh

dim tusk
#

Why tag me 😭

prisma shard
#

lol sorry..

#

    // 5% chance of getting frozen
    if (isFrostAspect && Math.floor(Math.random()) < 0.05) {

        //freeze entity for 3 seconds
        const interval = system.runInterval(() => { 
            victim.clearVelocity();
            victim.teleport({ x: victim.location.x, y: victim.location.y, z: victim.location.z });
        });
        //stop freezing if the entity is dead
        if (!victim.isValid) {
            system.clearRun(interval);
        };
        //release entity after 3 seconds
        system.runTimeout(() => {
            system.clearRun(interval);
        }, 60);
    
    };```
#

Cma anyone tell me why this isn't working?

#

the 5% chance is not working

#

also, even when the entity is dead, the interval keeps running

shy leaf
#

instead of using runInterval

prisma shard
#

how

shy leaf
#

or... make a runInterval somewhere and do getEntities to run the function when its true

prisma shard
#

oh

#

ok k

shy leaf
prisma shard
#

but the 5% isnt work it is always true

prisma shard
#

in was thinkin abt it

shy leaf
prisma shard
#

alr

#

np

shy leaf
#

one handed too cuz i have a coffee on my other hand

prisma shard
#

haha

shy leaf
#

but it became hard to do ever since i started using visual studio code

valid ice
prisma shard
#

ooo

valid ice
#

So… “0 is less than 0.05” is always true..

prisma shard
#

so remove Math.floor

valid ice
#

Yes

prisma shard
#

alr thanks!

prisma shard
#

victim.getComponent(EntityComponentTypes.Movement).setCurrentValue(0)

#

tried this didnt work

valid ice
#

Dunno

shy leaf
#

hmm

echo tinsel
#

Could anyone help me with script for making 4 custom loot items drop with (very low and progressively lower rates) when any mob dies, I would like to make it work with add on mob?

#

I don't know what info I'm supposed to be looking at for this

#

May have found it. Is it EntityDieAfterEventSignal?

true isle
#

using oninteract how the hell do i get a block to change permutation/state with any or no item selected ?

dim tusk
true isle
#

so its not permutation.resolve got it

dim tusk
distant gulch
#

Why did RunCommandAsync and what’s the new command for it?

leaden elbow
#

how to get the item that is dropped by block after breaking it? can i use PlayerBreakBlock event for it

shy leaf
buoyant canopy
#

can we read the color of a bed item somehow?
typeId for both the block and the item is minecraft:bed

#

(and I don't want to place all the colors in a barrel and compare my item with it again)

distant tulip
#

Kinda, with runCommand

buoyant canopy
distant tulip
#

testfor + hasitem property
loop through the 16 colors

#

Used it in my banner markers addon

buoyant canopy
#

oh yeah! i forgot about the hasitem target selector

#

thank you for helping

distant tulip
#

Yeah, tbh command can be more direct and faster sometimes

#

Your welcome

shy leaf
distant tulip
#

In a small server, it doesn't really effect it much

shy leaf
#

thankfully

distant tulip
#

Actually, Beds still share same id?

shy leaf
#

maybe?

#

i dunno

distant tulip
#

Alr, i will double check when i can

buoyant canopy
leaden elbow
#

how to get the item that is dropped by block after breaking it? can i use PlayerBreakBlock event for it

buoyant canopy
leaden elbow
#

what property

buoyant canopy
#

block.getItemStack()

leaden elbow
#

how about if its BlockPermutation

buoyant canopy
#

same thing, BlockPermutation also has this method

coral ermine
#

how to applyKnockback to hurtEntity to the damagingEntity location?

        const dx = dEntity.location.x - hurtEntity.location.x;
        const dy = dEntity.location.y - hurtEntity.location.y;
        const dz = dEntity.location.z - hurtEntity.location.z;

        hurtEntity.applyKnockback(dx, dz, 1.5, 0.8)

it didn’t work

dim tusk
coral ermine
dim tusk
#

Oh you're not in beta, just retain what you have rn or just use applyImpulse({ x, y, z })

dim tusk
#

You wanna make entity move to the location?

coral ermine
#

Ty

copper lake
#

Can I have Script check for structure blocks and then summon entities on them?
If so, can I lay out an order in which they get summoned and named procedurally?
OR, if I were to make a list of the locations, could I have them be automatically summoned and named in order?
This is in 1.21.07 (education) so using server 1.11.0 stable.
Basically, I'm trying to modify one of the Education Build Plate worlds to be a little easier for the teachers to manage the students. I've already manually set up the world I need to use this week but it would be much nicer to put everything into a pack that could automatically do the added setup and save it all into a new Template world.

rapid nimbus
#

Hey @dim tusk

leaden elbow
#

just broke diamond ore with PlayerBreakBlock event but it doesnt detect, especially in getItemStack. how to know what loot was dropped by that block?

dim tusk
dim tusk
#

There's no 100% accurate way to get it.

rapid nimbus
#

@dim tusk Let me ask, does the findClosedBiome script work across dimensions when searching for recent biomes?

dim tusk
copper lake
unique acorn
copper lake
#

a literal structure block

unique acorn
# copper lake Yes exactly

it's very laggy to get all blocks in the world and check if it's a structure block or not, however what you can do is make it summon the entity when you place the block, it's better to make a list of locations then summon the entities there

copper lake
# unique acorn it's very laggy to get all blocks in the world and check if it's a structure blo...

Ok, I suppose making more of a hard code setup script is reasonable.
So this world has lots of command blocks since the creator only used structures in the BP for it's creation.
I want to avoid having to manually edit and add so many command blocks. (world is created for up to 40 students, there are 40 teleports and 40 build plates and to do it manually, I have to copy/re-orient 80 impulse command blocks and then add selectors to them and add a chain command block to each of these locations.)
How can I use scripts to help me with all the command blocks? (I'm ok with having the blocks run a script event instead of adding more blocks.)

unique acorn
copper lake
#

Can script place a command block already populated with commands? (I don't think so but just want to confirm)

unique acorn
#

yes you can clone a command block

copper lake
#

I expect I could change all the existing command blocks to call a scriptevent to procedurally handle what needs to be done.

#

I actually don't much like the command blocks since they can't actually tell who pressed the button or who stepped on the plate.

unique acorn
#

I still don't know what you're trying to do, so if you can explain please?

copper lake
#

trying to not clog up the general channel so should probably take this to a thread.

copper lake
north rapids
#

Is there any way to detect if the player is riding a mob?

unique acorn
north rapids
#

Ty

true isle
cursive yacht
#

How to spawn baby variant mobs?

north rapids
#

Is there any way to stop the night from passing by when sleeping?

thorn flicker
true isle
night acorn
#

is there a way to stop join messages showing up

night acorn
#

nevermind isSleeping doesnt exist

cursive yacht
thorn flicker
#

you can find vanilla entity jsons in bedrock samples

cursive yacht
thorn flicker
night acorn
#

or entity.triggerEvent() im pretty sure

thorn flicker
#

use the native method

night acorn
thorn flicker
#

yes

thorn flicker
night acorn
thorn flicker
#

however theres a native method you mentioned afterwards

cursive yacht
thorn flicker
night acorn
thorn flicker
cursive yacht
thorn flicker
#

im telling you to do that.

cursive yacht
thorn flicker
#

which is the native method

cursive yacht
#

Oh I didn't read the name

#

Sorry

thorn flicker
#

its fine

night acorn
#

does anyone know if there is a gamerule or a way to stop join messages showing up

thorn flicker
#

(better than microsoft docs imo)

cursive yacht
#

Thanks

cursive yacht
#

You can change the join player text to blank

thorn flicker
#

you'll still see the popup though

#

it'll be a tiny grey box

cursive yacht
night acorn
#

how do you print a log to the content log

#

i can only find Logger in server-editor

cursive forge
night acorn
#

oh

#

ok

#

how do you use translate strings in script api

#

wait hang on

#

nvm i dont got it

#

i know you can use { translate: "key" } but is there a func i can use to process them, because what im trying to do wont work

rigid torrent
#

What is this?

ran with error: [SyntaxError: Could not find export 'getEquipment' in module '@minecraft/server']
#

Happened after the update

valid ice
#

Show code

rigid torrent
#

nvm nvm I found it

#

I forgot to comment a file

#

im a dummy

untold magnet
#

i dont think it is possible to detect the realife date using scripts, right? like writing the time last time the player died or something

open urchin
untold magnet
#

like detecting the seconds, minutes, hours, days, months, years, decades?

dim tusk
#

Yes

open urchin
#
const currentDate = new Date()

currentDate.getFullYear() // 2025
dim tusk
#
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {
  ev.cancel = true;
  const date = new Date();
  world.sendMessage(`§b[${date.toLocaleString()}]§r <${sender.name}> ${message}`);
});```
#

This will display date and time

dim tusk
#

-# this is an old screenshot

untold magnet
dim tusk
untold magnet
cold relic
#

when would be the only reason I should care for watchdog slowdowns?

dim tusk
#

use runCommand and do system.run(() => {});

#

Sorry it's removed now.

alpine wigeon
vast rune
#

How could I run a UI form upon interaction with an NPC?

cold grove
pale grail
#

can anyone tell me what i would need to type into VCS to get it to update the typescript module related stuff for the newest scripting stuff

woven loom
shy leaf
#

i cant think of better ways to explain this

bronze pulsar
#

If I want to create a clan system, is there any other way of storing clan data other than in dynamic properties?

thorn flicker
stuck ibex
shy leaf
#

but thanks ill google

deep yew
#

basically just when you install something in npm and want to install it globally, like for everything you'll ever need the package in, type -g after the install. For instance, npm i @minecraft/server -g

agile flicker
#

ItemUse, It was removed in the new version?

inland merlin
#

No

thorn flicker
past blaze
#

Ok I'm back. I didn't actually solve it, but when to a module version that didn't use NoInfer. The problematic line is inside the module itself

wary edge
wary edge
past blaze
#

Unfortunately that didn't work

wary edge
#

Very interesting, it worked for me.

#

It's getting really late, but tomorrow morning if you havent solved it yet, I can try reproducing the error.

solar dagger
#

does someone know the correct equation to get the locations of the entity's fov?

past blaze
dim tusk
prisma shard
shy leaf
#

yeah ive already done it

prisma shard
# solar dagger does someone know the correct equation to get the locations of the entity's fov?

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

function calculateAngle(v1, v2) {
    const dot = v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
    const mag1 =  Math.sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z);
    const mag2 =  Math.sqrt(v2.x * v2.x + v2.y * v2.y + v2.z * v2.z);
    return Math.acos(dot / (mag1 * mag2)) * (180 / Math.PI);
}

system.runInterval(() => {
    world.getPlayers().forEach(player => {
        const viewDir = player.getViewDirection();
        const pLoc = player.location;
        const entities = player.dimension.getEntities({ location: player.location, maxDistance: 6 });

        entities.forEach(entity => {
            const eLoc = entity.location;
            const toEntityVec = {
                x: eLoc.x - pLoc.x,
                y: eLoc.y - pLoc.y,
                z: eLoc.z - pLoc.z
            };

            const angle = calculateAngle(viewDir, toEntityVec);
            if (angle >= -45 && angle <= 45) {
                player.dimension.spawnParticle(`minecraft:basic_flame_particle`,entity.getHeadLocation())
            }
        });
    })
});

this an old script
you may need to make the x fov larger
https://cdn.discordapp.com/attachments/1261618065930457148/1261775009957806161/avc_Minecraft_2024-07-13_21-00-22.mp4

livid junco
#

In server aternos, the experimental API beta works?

shy leaf
#

how can i do applyKnockback without resetting the velocity? hmmm

shy leaf
#

for some reason

shy leaf
#

using velocity directly into applyKnockback isnt 100% accurate

#

thats why

sterile epoch
#

why when I do ```js
entity.applyKnockback({ x: entity.location.x, z: entity.location.z }, 1);

the entity gets launched onto another planet
#

i thought the second argument was upwards velocity

untold magnet
shy leaf
sterile epoch
#

yeah cuz I just want the entity to fly up

shy leaf
#

applyKnockback doesnt send the mob to specific location

untold magnet
shy leaf
#

the Vector2 youre seeing there is for direction

sterile epoch
#

oh

#

I'm so slow

shy leaf
#

yeah

untold magnet
#

it should be somewhere like this (0,0,0,0) ig

shy leaf
#

youd need { x: 0, z: 0 }

untold magnet
shy leaf
#

applyKnockback takes two arguments

#

Vector2 and vertical strength

untold magnet
#

im using this on my exe addon
entity.applyKnockback(0, -0.03, 0.16, 0); to make the entities moving

sterile epoch