#Script API General

1 messages Β· Page 78 of 1

round bone
#

or even 10-yo

remote oyster
#

.bat files is what started my hunt to learn more. My brother sent me an email that shut down my PC and I was so intrigued that I started soaking up the knowledge lol. Now I write code on the regular as a hobby and I tell people it all started from my brother crashing my computer when I was young haha

round bone
#

I don't remember

honest spear
#

i was 9 years old 😭 why tf was my dad doing to me

round bone
wheat condor
#

my dad just hoped for the billionare football player project. (i dont even like football)

honest spear
#

i was bad guy ngl

#

i am sorry for that teacher now

#

i was a kid

#

Β―_(ツ)_/Β―

round bone
#

my classmates are stealing markers from classrooms

honest spear
#

nice at least not crashing the teachers PC

#

πŸ‘

#

idk why i know that password tho

round bone
#

is stealing from school better than a single restart of a PC?

#

they stole like already 40-50 of them

#

πŸ’€

honest spear
#

boys do that in school

round bone
#

I'm just a chill guy who is trying to learn something at school

honest spear
#

Β―_(ツ)_/Β―

#

i was also chillding but in different way

round bone
#

I had 9th the best GPA in the entire school

#

last year

wheat condor
#

2 years ago using only powershell and cmd i installed minecraft in the pc class, school pc assistants are absolutely a$$ at stopping you from doing something on the pc

honest spear
#

ohh

#

i thought we are talking about times that were more than 5 years ago

#

i am old

#

sorry guys

round bone
#

I am almost in the middle of high school

honest spear
#

i have to leave now

distant tulip
round bone
#

ahh polish schools

#

β˜•

wheat condor
honest spear
round bone
#

I'm listening to teachers and that's the only effort that I am putting into school tbh

distant tulip
wheat condor
#

minato older?! i thought you were like 18

honest spear
distant tulip
wheat condor
#

you were born perfectly in 2000

honest spear
#

what that means?

wheat condor
#

hes 25

distant tulip
wheat condor
#

9 years difference from me

#

What did i just see

distant gulch
#

neat

distant tulip
honest spear
#

i like this community and i wish i will never forget about it

wheat condor
honest spear
distant tulip
honest spear
#

don't tell Smokey, bc this topic is getting too hot for script api channel

remote oyster
honest spear
#

we should end this talk

distant tulip
wheat condor
#

we should delete this chat

distant tulip
wheat condor
honest spear
#

how got newbie protection

wheat condor
#

is smokey the owner of the server?

honest spear
#

CICI is

distant gulch
round bone
#

you all are older than me

#

😭

distant tulip
#

it is alt, lol
the topic kinda die if you tell someone to move to #off-topic

honest spear
wheat condor
distant tulip
#

dude, all we learn in high school is fucking word and exel
and a bit of algo

abstract girder
#

im the youngest

honest spear
wheat condor
#

in high school im just learning cmd stuff, excel, word, java (obviously using eclipse on eye frying mode)

#

and i choosed a scentific subjects school

honest spear
#

it was absolute sh*t

wheat condor
#

hey java, but on version 1.8

distant tulip
#

i remembered using a software to turn algorithm to code, pascal? not sure about the name

honest spear
#

but at least i know something about electronics

wheat condor
honest spear
#

btw i was learning a bit of Italy but nothing much

distant tulip
#

nah, it have pascal in the name iirc

abstract girder
wheat condor
honest spear
abstract girder
#

we in russia studying only pascal

wheat condor
honest spear
lyric kestrel
#

I really need to change my spacings in vscode. They're 8 spaces each I think 🀣

distant tulip
honest spear
#

@pulsar sparrow was 2 and i was 4 so we decided to use 3

wheat condor
#

in school i used to study french (i hate it) and BRITISH english (i also hate it)
US en > GB en

honest spear
#

yea

#

color vs colour

wheat condor
#

us english has a latin pronunciation, gb english has a french like pronunciation

honest spear
#

yea

#

any we are getting too much offtopic now

#

so lets stick to the JS and TS at least

wheat condor
#

like i dont understand why sometimes letters have a sound and sometimes they dont

distant tulip
#

to be fair that is in English too

wheat condor
honest spear
#

I am proud Czech guy 🍻

#

πŸ‡¨πŸ‡Ώ

lyric kestrel
#

Are dynamic imports back? Or are they still gone?

lyric kestrel
random flint
#

dynamic imports has been back for a while

wheat condor
#

and in italian every letter has its own sound like it has sound rules, even if you dont know the word you can pronunce it correctly.. and for me its harder to read like the E sometimes as an I or an E

honest spear
lyric kestrel
honest spear
wheat condor
#

what are they?

honest spear
#

dynamic imports?

wheat condor
#

ye

honest spear
#
const module = await import("index.js");
lyric kestrel
#

Importing anywhere in a file that isn't at the statt

wheat condor
#

like import('')

random flint
wheat condor
#

that's good

honest spear
wheat condor
#

so now we can use the function worldLoad to load the pack when the world is loaded

random flint
#

Nah, I'd await null;

lyric kestrel
#

Lol

honest spear
#

another one

wheat condor
#

i used an horrible method to fix that in my database
i just wrapped the constructor of the class in a system.run() 😭 πŸ₯€

wheat condor
distant tulip
honest spear
#

idk who made that first one on top

remote oyster
lyric kestrel
#

What does await null even do?

remote oyster
lyric kestrel
#

Like does it just fire instantly?

honest spear
distant tulip
lyric kestrel
lyric kestrel
#

I am still confused 🀣

wheat condor
#

so why is await null not reccomended?

honest spear
#

it defers the execution in bit but always depends how its manage by engine

honest spear
honest spear
#

but for before events it works pretty well

distant tulip
random flint
#

Bruh I did await system.waitTicks(1) inside a beforeEvents, thinking there would be no tick gap. Thank god they can now accept 0. πŸ™πŸΌ

honest spear
#

i actually use it for before events

honest spear
wheat condor
honest spear
#

ohh

#

i got notification for preview hotfix

distant tulip
#

huh

wheat condor
#

1.21.90, im still processing what they added in 1.21.70

random flint
wheat condor
#

that was in 1.21.0

#

in 1.20.50 they added the gray biome

random flint
#

Ah, the spooky wooden creature

wheat condor
#

the scp statue like entity

lyric kestrel
lyric kestrel
wheat condor
#

im the only one that has noticed that the cave and cliffs update got nerfed a lot like at the start there were rivers and land was like everywhere at y 100 + and now it looks like it isnt?

random flint
#

Maybe you're getting unlucky with the world seed

wheat condor
#

I want to do something, but idk what..
does someone have something useful to work on?

acoustic basin
#

guys, i'm trying to set a damagingEntity in my applyDamage options, but i can't understand how to do it... can someone please explaine me?

entity.applyDamage(3, { damagingEntity: { } });

wheat condor
acoustic basin
#

for test, i've set the entity parameter to attackingEntity (i'm using onHitEntity custom component)

#

didn't work

random flint
#

send code

wheat condor
#

Found a way to put items inside a shulkerbox

random flint
#

I bet you simply put the itemStack inside a placed down shulkerbox and then use block.getItemStack()

random flint
# wheat condor

Btw, if you tried Ctrl+Pickblock a filled regular chest, and then throw the chest into- like Lava, it actually drops its item content like a shulkerbox.

wheat condor
#

mh ill keep that in mind

full idol
#

Trying to export JSON through console logs, but there seems to be a logs max length?

random flint
#

You can probably shrink it by using "Greedy Voxel Meshing" algorithm. This additionally would allow you to use Dimension.fillBlocks() to fill up blocks faster than individual Dimension.setBlockType()

full idol
lyric kestrel
full idol
lyric kestrel
#

Save them as separate maps in the scripts?

full idol
#

I might have a bad approach to the scan but I think it's cool. Use world ticking entities, with a 6 chunk radius, place them in a grid with 120 blocks between each, then I can just get the block at each point, taking the average of 9 blocks in an 8x8 area

#

nah the export is working fine now, I just copy from the TXT and it's all there in one big block

lyric kestrel
#

Ah ok

proven hill
#

there is crazy stuff going on

full idol
#

Does console.log not work for people other than the host?

lyric kestrel
#

Anyone that has it on

full idol
#

Hmm ok it doesn't show for me

#

Had to get my friend to send over the logs

frozen vine
#

Can the script check the graphics configuration?

distant tulip
thorn flicker
#

which is in v2 beta

frozen vine
thorn flicker
frozen vine
thorn flicker
#

you can see if its in versions or not

frozen vine
winter plaza
#
import { world, system } from "@minecraft/server";

world.beforeEvents.chatSend.subscribe((event) => {
  const
    message = event.message,
    sender = event.sender;
  if (message === 'test') {
    event.cancel = true;
    event.sender.runCommandAsync("say Oi2");
  }
});
#

Help me, I don't know why I can't use runCommand

sterile epoch
#

runCommandAsync was removed

#

it is runCommand

thorn flicker
#

there's a native method for sending messages.

#

world.sendMessage('0i2')

true isle
#

directional checks are getting to be a huge pain in the ass

#

one of them works so well that i need it to not work so well

analog salmon
#

Hey guys I have no idea about script api but I want my functions only work when a player break event happens, would you guys pls breakthrough this problem and give me the edit 😟

hexed fox
#

How I can to do when player click to villager with tag shop1 it opened form with name "showMainMenu" i don't know because my script for this is don't working right.

round bone
prisma shard
round bone
#

also send the code if you have some issues with it in the first place

round bone
prisma shard
#

huh?

#

what are the difference to mine and you

round bone
# prisma shard huh?
  • player -> target for hasTag method
  • additional curly brackets for first if statement
prisma shard
#

ooooooh

#

i see now, he wanted tag for villager

#

I didn't notice, I thought player needed to have shop1 tag

round bone
#

at least he got a solution

#

πŸ‘

prisma shard
#

guguga

untold garnet
#

[Scripting][error]-ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (main.js:9)

[Scripting][error]-Plugin [IntoCMD Skyblock Behavior - 1.0.0] - [main.js] ran with error: [ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (main.js:9)
]

untold garnet
#
//imports
import { world, system } from "@minecraft/server";
import { ActionFormData, ModalFormData, MessageFormData } from "@minecraft/server-ui"

//chat command prefix
const cmdPrefix = ".";

//initial SCB obj
world.scoreboard.addObjective("player_info", "Player Info");

//player chat event
world.beforeEvents.chatSend.subscribe((eventData) => {
    var {message:message, sender:sender, targets:targets } = eventData;
    if (!message.startsWith(cmdPrefix)) return;
    eventData.cancel = true;
    if (message.split(" ")[0] === cmdPrefix+"island" || message.split(" ")[0] === cmdPrefix+"is") {
        world.sendMessage("island CMD")
        
    }
})```
prisma shard
# untold garnet ```js //imports import { world, system } from "@minecraft/server"; import { Acti...
//imports
import { world, system } from "@minecraft/server";
import { ActionFormData, ModalFormData, MessageFormData } from "@minecraft/server-ui"

//chat command prefix
const cmdPrefix = ".";

//initial SCB obj
system.run(()  => {
    world.scoreboard.addObjective("player_info", "Player Info");
})

//player chat event
world.beforeEvents.chatSend.subscribe((eventData) => {
    var {message:message, sender:sender, targets:targets } = eventData;
    if (!message.startsWith(cmdPrefix)) return;
    eventData.cancel = true;
    if (message.split(" ")[0] === cmdPrefix+"island" || message.split(" ")[0] === cmdPrefix+"is") {
        world.sendMessage("island CMD")
        
    }
})
#

try this

#

@untold garnet

untold garnet
#

worked

#

thank you so much sir

#

is system.run required now in experimental?

#

usually i create a scb in global code it should work

prisma shard
untold garnet
#

i see

#

thank you!

round bone
#
import { world, system } from "@minecraft/server"
import { ActionFormData, ModalFormData, MessageFormData } from "@minecraft/server-ui"
const cmdPrefix = "."

world.afterEvents.worldLoad.subscribe(() => {
      world.scoreboard.addObjective("player_info", "Player Info");
})

world.beforeEvents.chatSend.subscribe((eventData) => {
    const { message, sender, targets } = eventData;
    if (!message.startsWith(cmdPrefix)) return;
    eventData.cancel = true;
    const [commandName] = message.split(" ")
    if (commandName === `${cmdPrefix}island` || commandName === `${cmdPrefix}is`) {
        world.sendMessage("island CMD")
    }
})
untold garnet
#

is there a getScore function that I can use to get both real and fake player score?

#

nvm got it haha

hexed fox
#

but this is don't working now also

round bone
hexed fox
round bone
#

sure

prisma shard
#

my terminal crashes whilst i was installing npm package

#

i dont want to reinstall my vscode what do i do

#

i only get this fucking problem on my laptop

#

my pc vscode works fine

#

aaaaaa

random flint
#

Anyway of setting a block permutation without causing block updates?

#

-# (like door)

ivory bough
#

How to rotate the player's camera to different axis?

wheat condor
copper egret
#

is there a way to detect if plauer is about to drop a certain item from his inventory and cancel it

prisma shard
#

kill the dropped item

#

then add the item again to the inventory

#

so it acts like cancelling

copper egret
#

I just found a new way to detect dropped items. However, it's only available in minecraft 1.21.90.20+

#

it's more reliable and accurate than using entitySpawn, but of course it's not currently available in the release version of minecraft

copper egret
#

^^

untold garnet
#

is there a way to add button to form using for loop?

unique acorn
untold garnet
#

thank you brother

hexed fox
#

any know when is the bug?

Script
import { world, Vector, system } from "@minecraft/server";
import { ModalFormData, ActionFormData, MessageFormData } from "@minecraft/server-ui";

unique acorn
unique acorn
#

...?

hexed fox
#

when is the Vector need to be

#

for the script was working

hexed fox
unique acorn
#

remove Vector

#

no

hexed fox
#

also

unique acorn
#

create a post and send the whole code there

hexed fox
remote oyster
remote oyster
# hexed fox I try Vector3 later also

You need to import it from @minecraft/math. What you are importing from @minecraft/server is just an interface. An interface defines the structure of an object by specifying the properties and their types. It acts as a contract that classes or objects must follow. To get the actual object itself you need @minecraft/math.

#

You won't need the interface unless you are writing your code in TS. Possibly using JS Docs as well, but not sure why that may be necessary.

hexed fox
#

import { Vector3 } from "@minecraft/math";

remote oyster
# hexed fox js

Then you shouldn't be importing the interface. You need the object itself which is in @minecraft/math.

hexed fox
#

what is a version for Vector3 in math

#

"dependencies": [
{
"module_name": "@minecraft/server",
"version": "2.0.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "2.0.0-beta"
}
]
}

remote oyster
#

@minecraft/math is not a module. It's merely a dependency. So you have to bundle it with your behavior pack in order to use it.

hexed fox
#

When I need active

somber cedar
#

Bundle the script or use this file

somber cedar
prisma shard
#

"@minecraft/math" is not a module (visual1mpact said) You gotta download the dumped JS file

#

@minecraft/math is not a module. It's merely a dependency. So you have to bundle it with your behavior pack in order to use it.

#
import { Vector3Builder } from "./minecraft-math.js";

Then you shouldn't be importing the interface. You need the object itself which is the Vector3Builder in @minecraft/math.

hoary matrix
#

world.beforeEvents.worldInitialize.subscribe(e => {
  e.propertyRegistry.registerEntityTypeDynamicProperties({ blocksBroken: "number" }, "minecraft:player");
});```
#

can you guys help me ?

wheat condor
hoary matrix
#

how to know to the good version

#

im using 1.18.0

wheat condor
valid ice
#

You don't need to register properties any more; you can just straight use them

prisma shard
#

yep

#

world.setDynamicProperty(`id`, value)

honest spear
#

damn

#

i remember the truggle with dynamic properties back then

valid ice
#

haha yeah

honest spear
#

it was easier to use scoreboards

valid ice
#

Was interesting

honest spear
#

scoreboards DBs were fun

valid ice
#

indeed

random flint
#

I've searched, even under the rock... I guess setting a block permutation without causing block updates around it is currently impossible.

And, no, Dimension.setBlockPermutation still causes block updates. The reason why a wither/golems doesn't spawn, is because they only detect player placement and dispensers...

valid ice
#

You’re updating the block

There’s gonna be block updates

random flint
#

I need that Java's strict block placement option πŸ™πŸΌπŸ˜­

#

Even loading a structure has janky block update correction.

fallow minnow
#

are you able to have image links with server-net on action forms?

like

form.button("text", http.get("https://www.youtube.com/imagetest.png"))```
random flint
grim raft
#

is there anyway to detect running?

distant tulip
#

movement component

grim raft
random flint
grim raft
#

I've been searching in docs for ages 😭

distant tulip
random flint
#

Movement input is still good tho

grim raft
#

doesnt detect sprint

grim raft
#

pretty stupid question ik

random flint
#

Probably. Not sure if you were swiming, crawling, sneaking, or gliding (elytra) tho

grim raft
#

k gonna test it out myself ty

thorn flicker
#

it does

grim raft
#
entity.applyKnockback(viewDirection.x, viewDirection.z, 3, viewDirection.y / 2);```
want to make this only does knockback in the x and z axis
#
system.afterEvents.scriptEventReceive.subscribe((event) => {
    const id = event.id;
    const entity = event.sourceEntity;
    const viewDirection = entity.getViewDirection();

    switch (id) {
        case 'sp:dash':
            entity.applyKnockback(viewDirection.x, viewDirection.z, 3, viewDirection.y / 2);
            break;```
full code
thorn flicker
#

make vertical 0

grim raft
#

also

#

is there a way to detect when sneaking it runs a code 1 time only until you unsneak and resneak

#

basically this but it runs 1 time until you resneak

if (player.isSneaking && (normalizedX === 1, -1 || normalizedY === 1, -1)) {
            player.runCommand('scriptevent sp:dash')
        }```
thorn flicker
#

you can use playerButtonInput afterEvent

grim raft
#

ym this?
inputs.getButtonState(InputButton.Sneak)

#

oh nvm

thorn flicker
#

use the afterEvent.

grim raft
#

k

thorn flicker
#

but if you must use it system.runInterval for some reason, you can do that too.

grim raft
#

wait nvm u just told me lol

thorn flicker
grim raft
#

well I just need it for sneaking actually

thorn flicker
grim raft
#

sprinting I need it to be constant so I was gonna use runInterval anyway

grim raft
thorn flicker
#

let me link it

grim raft
#

I still cant do code from scratch just modify it

thorn flicker
grim raft
#

so just 1 month actually

thorn flicker
#

its for something else

grim raft
#

well I wasnt really trying to learn

thorn flicker
#

when I started I was the same for a short period of time

#

then I finally said to myself "I cant copy and paste forever"

grim raft
#

well I will do that when summer vac starts

grim raft
thorn flicker
#

instead of making it for you

#

look at other code, and use that logic to create this

grim raft
#

I searched for ages on this server in the search feature in dc

#

suprisingly nobody ever did that lol

thorn flicker
#

you dont have any code that includes an event listener

grim raft
#

just this guy

#

and I still dont know how to use classes

thorn flicker
#

my food is getting cold

#

brb

grim raft
#

mb

thorn flicker
#

np lol

alpine wigeon
#

in my script i need the block running it to access the adjacent block in a specific direction

#

how do i do that

#

@unique acorn can you help maybe?

unique acorn
#

use whichever one you want!

alpine wigeon
#

wow

#

it's that simple

unique acorn
#

also you can put number inside parentheses to tell it how many blocks to go to

alpine wigeon
#

oh

#

thx for helping meee

thorn flicker
# grim raft
world.afterEvents.playerButtonInput.subscribe(data => {
    const player = data.player
    const button = data.button
    const state = data.newButtonState


})
lyric kestrel
#

Is there no way to check if something is a typeof Array?

#

I am unsure if I should use string or not

#

ah wait, I can just do Array.isArray()

#

Also, what is the Enum to get the switch of panels a person is hovering over?

native patio
#

How to make it that a player can’t hit another player in the radius of 10 from an entity ( v:spawn )

native patio
unique acorn
native patio
unique acorn
#

instant health does that

#

it removes knockbac and getting red

#

idk about sharpness 5 netherite sword or mace tho

native patio
#

Without sword aswell

unique acorn
native patio
#

Oh

#

That kinda works

unique acorn
#

you can edit the player.json which indeed disables all damage

#

but if you're making a public addon, I don't suggest it as it can break compatibility with other addons

native patio
lyric kestrel
safe stream
#

Is it not possible to edit dialogue's content (text) via scripts?

mighty igloo
#

how do i check if a player has op

chrome gyro
#

How do you remove a certain amount of letters from a name tag?

        const lengthoname = (`${entitys.nameTag}`.length - 10)
        const codedintstack = `${entitys.nameTag}`.replace(lengthoname.length, "")

Here's one of the 20 things I've tried... any ideas?

remote oyster
chrome gyro
#

Using a length of text number then removing that much from the beginning of the entities name.

chrome gyro
remote oyster
#

You are wanting to remove Β§ as well?

chrome gyro
remote oyster
#
const lengthofname = 10; // number of characters to remove from the start
const nameTag = `${entitys.nameTag}`;
const trimmedName = nameTag.slice(lengthofname); // removes the first 'lengthofname' characters
const cleanName = trimmedName.replace(/Β§/g, ""); // removes all Β§ symbols if needed
chrome gyro
#

I forgot about the / and g for the Β§ too, thanks!

remote oyster
#

No problem

mighty igloo
#

so i have an issue with typescript

#

when detecting a gamemode. typescript uses Creative with a capital C, but js uses creative with a lower case c

#

and when i try to put creative with lowercase c in the typescript file, it errors./

#

is there anyway to make exceptions for errors

remote oyster
#

@mighty igloo, are you referring to the GameMode enum?

random flint
cunning canyon
#

Why am I getting equippable as undefined? bao_foxxo_crying

random flint
#

Player can always use it

warped blaze
#

you have to use JSON.stringify()

cunning canyon
#

I assumed sourceEntity was the player instead of the actual entity lol

#

my bad, thanks for the help

#

is there a way of getting the player entity using 'event: ScriptEventCommandMessageAfterEvent'?

random flint
cunning canyon
warped blaze
#

do you think it is a good idea to protect a spawn by storing the position of its blocks in an array in a dymamic property and canceling the event in case its coordinate is in the array?

valid ice
#

If you can define min & max coordinates for each (e.g. a cubical zone) it would be easier to handle overall

winter plaza
#
export function estrutura(block) {
  const blocoPos = block.location;
  const radius = 30;

  const dimension = block.dimension;
  const playersNearby = dimension.getEntities({ location: blocoPos, type: "minecraft:player", maxDistance: radius });
  if (playersNearby.length === 0) return;
  const jinwooNearby = dimension.getEntities({ type: "wesl3y:mob.jinwoo", location: blocoPos, maxDistance: radius });
  if (jinwooNearby.length === 0) {
    playersNearby.runCommandAsync(`tag @s add unlock.jinwoo`);
    playersNearby.runCommandAsync(`tellraw @s{"rawtext":[{"selector":"@s"},{"text":" has made the advancement Β§a[Jinwoo]Β§r"}]}`);
  }
}
winter plaza
mighty igloo
#

I just found that recently

#

When it compiles it shows as GameMode.creative in js

warped blaze
mighty igloo
#

So it works

warped blaze
valid ice
#

if above min and below max

warped blaze
winter plaza
#

ok

winter plaza
warped blaze
winter plaza
warped blaze
valid ice
#

@past coyote your logic looked sound, as far as I could see.. z

warped blaze
valid ice
#

Console warns to see data throughout the code would help you see where stuff is going wrong, if you aren’t already doing so

warped blaze
#

you must do a .forEach() loop

winter plaza
#

Can you show me where I should put it?

valid ice
#

Also runCommandAsync doesn’t exist any more

#

So there’s that

warped blaze
warped blaze
valid ice
#

Ah ok gotcha

winter plaza
#

Oh ok ok

valid ice
#

Nvm then

valid ice
past coyote
#

im working on a minecraft beta 1.7.3 server

#

and I wanted to make scripts that feel non-invasive, especially for something like block/land protectionm

warped blaze
#

@winter plaza also next time send the code directly, not a screenshot

past coyote
#

Ive noticed when doing things with blocks that are bigger than 1x1 (door, or double chest) that things can sometimes fail.

Is there a method or reliable way for handing double chests or doors with a script?

#

(ie I have a sign that players can place on a door or chest to lock it, however when doing the checks to see where the sign is, or what block its attached to it only sees the single chest block or the door block)

past coyote
#

Can I check which way a chest is facing???

prisma shard
leaden bear
#

does anyone know how to make custom commands on version 1.21.51, I tried to use the code from bedrock wiki, but it doesn't work for this version?

warped blaze
#

idk what could be wrong with the wiki example

#

it still works as far as i know

#

maybe your code is wrong

leaden bear
shy leaf
#

but it will be replaced with something else in future updates

honest spear
#

yes πŸ‘†

leaden elbow
untold garnet
#

can script set a block where chunk is not loaded?

#

i remember the OG gametest can do that

untold garnet
#

what can be a good work around?

#

can we run a temp ticking area and then setblock?

remote oyster
#

Sure

#

Probably your only option.

remote oyster
leaden elbow
#

when i place blocks it logs but logging returns undefined

remote oyster
#

Hmm. I'm unsure.

#

I wonder if it's a bug with the API.

remote oyster
leaden elbow
#

okay thanks

leaden elbow
remote oyster
leaden elbow
#

oak planks to be specific

remote oyster
#

Oh, well then that would be odd. I would need to get on my PC to investigate the situation but at face value this sounds like a bug with the API.

leaden elbow
#

okok

granite cape
#

p

#

Wanna do Something

leaden elbow
#

so the property in docs is for latest preview?

distant tulip
#

the property have different naming between custom components and events, so maybe they fixed that in the latest preview

#

seem so

#

beta stable

#

latest preview

leaden elbow
#

oh okay that works thanks

distant tulip
#

leave a comment there so you remember updating it later

remote oyster
# distant tulip beta stable

Oof, I just realized I was looking at the preview docs when talking to that person lol. That's why I couldn't give a proper answer. 😁

#

No, I was looking at the correct one. For 2.0.0-Beta.

distant tulip
#

the docs are outdated?
this is what i used

wheat condor
#

that's not event relased

granite cape
#

where can i get documentation for module v3.0.0-alpha?

wheat condor
#

my preview minecraft is at 1.21.80

remote oyster
#

@leaden elbow it would be permutationBeingPlaced. I'm just now realizing you had a typo in your example that used permutationToPlace.

wheat condor
distant tulip
#

he seem to be doing the same thing over #1367797461795602432

leaden elbow
remote oyster
#

A simple overlook.

#

Oh wait. I'm an idiot.

#

You gave two examples showing the change.

#

I'm gonna go drink some coffee.

fast lark
#

How can i detect how many blocks a player has traveled

distant tulip
remote oyster
distant tulip
gaunt salmonBOT
wheat condor
distant tulip
remote oyster
#

Those edge cases is what will make that a challenge lol.

distant tulip
#

yeah, jayly had a statistic addon, maybe look into that

fast lark
#

Too much work for a single quest..

wheat condor
#

like

const previousLocation = new Map()
system.runInterval(()=>{
    world.getPlayers.forEach(player=>{
        const loc = player.location
        const befLoc = previousLocation.get(player)
        const distance = Math.cbrt((befLoc.x- loc.z)^2 + (befLoc.y - loc.z)^2 + (befLoc.z - loc.z)^2) 
        //........
    })
})
fast lark
#

Mh

leaden elbow
#

how to use item component consume event

leaden bear
prisma shard
leaden elbow
leaden bear
# prisma shard Send direct code instead of sending a zip file
import { world } from "@minecraft/server";

world.beforeEvents.chatSend.subscribe((eventData) => {
    const player = eventData.sender;
    if (!player.hasTag("Admin")) return;
    switch (eventData.message) {
        case "!gmc":
            eventData.cancel = true;
            player.runCommandAsync("gamemode c");
            break;
        case "!gms":
            eventData.cancel = true;
            player.runCommandAsync("gamemode s");
            break;
        default:
            break;
    }
});
prisma shard
leaden bear
prisma shard
#

are you serious

prisma shard
#

Either use the stable, or 2.0.0-beta

leaden bear
prisma shard
#

To use the latest version you need to have latest minecraft

wary mango
#

Does anybody have documentation for literally any functions for scripting api?

leaden bear
prisma shard
wary mango
#

oh okie

leaden bear
wary mango
#

Also, im trying to make a item when consumed, removes all effects (just like a milk bucket), problem is:

round bone
shy leaf
#

just curious

wary mango
round bone
round bone
# wary mango

you have to get all effects and loop through them and remove each one

#
for (const effect of entity.getEffects())
    entity.removeEffect(effect.typeId)
wary mango
round bone
wary mango
#

thanks

round bone
#

no problem

#

do you know how to plug it into an event listener?

untold garnet
#

is there a way to place a vanilla tree using script?

#

as a structure

round bone
#

World.prototype.structureManager

untold garnet
#

thanks

prisma shard
untold garnet
#

i think he meant 2.0.0-beta

leaden bear
shy leaf
#

i mean i asked why, not how

prisma shard
#

lol

leaden bear
wary mango
prisma shard
prisma shard
leaden bear
prisma shard
#

Yeah change it either to latest stable or 2.0.0-beta

untold garnet
#

the actual minecraft command register is looking very exciting, any speculation on when will it make it to regular released version?

round bone
#

should work tbh

leaden bear
round bone
#

this wednesday if I'm correct

leaden bear
untold garnet
leaden bear
untold garnet
#

just a chat command with 1 optional argument

#

shouldnt be too hard i guess

#

very looking forward for future releases

granite cape
#

just back to the topic

prisma shard
warm mason
warm mason
granite cape
round bone
#

I mean, you're using some class to create a command?

granite cape
#

1.18.0 stable for now

thorn flicker
#

you didnt get me

granite cape
#

πŸ™πŸ™ πŸ™πŸ™πŸ™πŸ™

thorn flicker
#

unless you mean closing the post

#

you sure got me mid-sentence

leaden bear
thorn flicker
thorn flicker
#

chatsend is in beta

#

ofc it wont work in 1.18.0

#

but you said its also not working in beta?

#

it should.

prisma shard
thorn flicker
#

...right, and do you have content logs on?

#

it would've told you something was up with runCommandAsync

granite cape
#

runCommandAsync The Real Impostor

shy leaf
#

did

granite cape
shy leaf
#

the

leaden bear
shy leaf
#

does runCommandAsync even work in read only mode?

#

im confused

prisma shard
shy leaf
#

then there we have it

thorn flicker
#

we already had it though.

#

runCommandAsync was removed.

#

but yes, that would be another issue.

prisma shard
shy leaf
#

theyre on 1.21.51

thorn flicker
#

they should update their game

#

but yeah, 1.21.51 server beta version is 1.17.0-beta

prisma shard
thorn flicker
#

ignore them

prisma shard
#

What happened to him

#

He looks very sussy today

#

import world as http
import system as www
lol

#

i saw that post

leaden bear
#

its strangely

shy leaf
#

have you enabled beta api

prisma shard
#

and please turn on content log as voidcell said

prisma shard
leaden bear
shy leaf
#

then do us a favor and enable content logs

prisma shard
granite cape
prisma shard
#

why u sad

granite cape
#

im not sad

#

πŸ˜‚ πŸ˜‚πŸ€£πŸ˜­πŸ˜‚

shy leaf
#

how many potions did you take today

prisma shard
#

probably 69

#

so he gone wild

leaden bear
prisma shard
#

are you even running the exact script file

#

do console.warn(`god help`)

#

to seee if the script running

leaden bear
granite cape
#

goodbye runCommandAsync

prisma shard
#

lmao

lyric kestrel
#

I've finished all the try catches for my Custom Crafter function. I will now begin the actual functionality of the function edurp

untold garnet
#

@round bone can you give me an example on how to fill 0 0 0 to 5 5 5 with dirt replacing air only

#

thank you

round bone
#

Dmension.fillBlocks

untold garnet
#

how sure how to use it

#

:C

round bone
#
import { world, BlockVolume } from "@minecraft/server";

world.afterEvents.worldLoad.subscribe(() => {
    world.getDimension("overworld").fillBlock(
        new BlockVolume({
          x: 0,
          y: 0,
          z: 0,
         }, {
          x: 5,
          y: 5,
          z: 5
         }
    ), "minecraft:air", {
        includeTypes: [
            "minecraft:dirt"
        ]
    })
})
#

smth like this

grim raft
#

@thorn flicker Im really grateful of the code you gave me, you just tought me the js syntax just by a simple code πŸ™

warped blaze
#

since you're using new to create an instance of that class

round bone
#

what am I doing

#

😭

#

hold on

#

this is corrrect rn

warped blaze
#

also you missed a comma

round bone
#

where?

warped blaze
#

-# actually two

warped blaze
round bone
#

there is a comma

lyric kestrel
#

not at the y:5 part

warped blaze
round bone
cinder igloo
#

Are custom commands dropping on 1.21.80 release?

wary edge
cinder igloo
#

because it doesn’t look like I can use them with the beta api on 1.21.70

cinder shadow
#

What version of scripting are you on?

#

If custom commands existed in the .80 preview cycle, they will be available in the .80 stable version via beta APIs

cinder igloo
#

Thanks, that was my question

cinder igloo
#

anyone know if there are plans in the future to update the packet stuff in server-net?

#

atm you can just acknowledge and cancel packets, can’t read them

wanton cedar
#

Does anyone know, in general, how to use scripting to give a specific entity an item and make them hold it in their right hand, so that it actually displays as held?

For example, zombies are capable of picking up and holding swords. Is there a way to make a mob like that where it can hold any item, and then I can give it an item for it to hold?

valid ice
wanton cedar
#

That sounds workable. Do you know what specific components I need on my custom entity in order to make that possible?

valid ice
#

Only thing you need, afaik, is a point named β€œrightItem” in the entity model and "enable_attachables": true in the client entity

wanton cedar
valid ice
#

RP/entity/your_file.json

wanton cedar
#

Oh snap, that worked already (mostly). Just one problem. How do I specify a specific entity? I just ran it with @e and it worked just like I expected it to, but now EVERYONE has the item.

#

I summoned the entity in scripting. How do I target it now?

valid ice
#

The spawnEntity function does return an Entity class, which you can use to run a command off of

#
const spawnedEntity = dimension.spawnEntity(…)
spawnedEntity.runCommand('replaceitem @s …')
wanton cedar
#

Perfect. You're my hero.

hoary matrix
#

someone is here ?

#

i need help with properties

#

pls

distant tulip
#

-# how to not get help ^

#

dude just ask your question

true isle
#

Is it possible to get the offhand using the on place component?

granite cape
patent bane
#

is there any way to check if a specific item can be worn on a specific slot using scriptapi?

leaden bear
#

Hi all, maybe someone knows why this code from the documentation doesn't work:

import { world } from "@minecraft/server";
console.warn(`god help`)
world.beforeEvents.chatSend.subscribe((eventData) => {
    const player = eventData.sender;
    if (!player.hasTag("Admin")) return;
    switch (eventData.message) {
        case "!gmc":
            eventData.cancel = true;
            player.runCommandAsync("gamemode c");
            break;
        case "!gms":
            eventData.cancel = true;
            player.runCommandAsync("gamemode s");
            break;
        default:
            break;
    }
});

Also to clarify that I have Minecraft version 1.21.51.1, and I say right away that I used the version of Scripting api and 2.0.0-beta and 1.17.0-beta, still does not work, which is quite strange. Thank you in advance for your help

valid ice
#

Do you know what part of it doesn’t work? Because if you’re on 1.17.0-beta it looks fine..

#

Any console errors

leaden bear
distant tulip
#

Do you have the tag

leaden bear
distant tulip
#

Yeah, the hasTag is case sensitive

leaden bear
native patio
thorn flicker
leaden bear
#

Can anyone tell me how to make a scriptevent? I tried to ask chatgpt(I know bad idea, but still), but he gives out code that doesn't work.

woven loom
#

Whats troubling you

leaden bear
round bone
#

why there is no PATCHfield for HttpRequestMethod enum

#

😭

woven loom
# leaden bear well, like creating a script event that can be called via /scriptevent
import {
    world
    ,system,
    Player
} from "@minecraft/server"


system.afterEvents.scriptEventReceive.subscribe(e => {
    const { id, message, sourceType, initiator, sourceBlock, sourceEntity } = e


if (sourceEntity instanceof Player) {
    /**
     * @type {Player
     */
    let player = sourceEntity


    player.sendMessage("id: " + id + " message: " + message)
}

})```
warm mason
#

Does anyone know if I put a Player as a key in a WeakMap and then he re-enters the world, will it be a new Player or will the old one just become valid again?

hoary matrix
#

guys why MinecraftBlockTypes does not work ?

leaden bear
round bone
round bone
#

@minecraft/vanilla-data is not supported navitely by engine

hoary matrix
#

i used an other methode

gaunt salmonBOT
deep quiver
#

ah sorry I misread that

#

they prolly forgot it

gaunt salmonBOT
round bone
fallow minnow
#

if thats even possible

gaunt salmonBOT
prisma shard
#

hi

shut vessel
#

Did you know how I can make a knockback edit menu?

prisma shard
#

no i didn't know

#

show me how you can

#

-# jk

round bone
shut vessel
untold garnet
#

is it possible to detect what player is holding?

#

nvm found it

lyric kestrel
#

Is there a way to check if the player has just interacted with a specific inventory slot?

#

Like taken an item from the slot

round bone
lyric kestrel
round bone
#

Player.prototype.selectedSlotIndex of course

lyric kestrel
#

Ah, thank you

#

I was about to ask xD

round bone
#

no problem

sharp elbow
#

Isn't that only which hotbar slot they have selected? Would that not necessarily correlate with a given slot the player interacted with?

sharp elbow
round bone
#

if he's detecting interaction via PlayerInteractWithEntity or PlayerInteractWithBlock event, it's a good way

lyric kestrel
round bone
#

ohh, container interaction?

lyric kestrel
#

So I need to check when the person takes the item, then the recipe slots are emptied stack

lyric kestrel
round bone
#

ohh

lyric kestrel
round bone
#

are you using stable or beta API?

lyric kestrel
#

stable

#

I don't mind using either

#

Nothing in the function is beta, yet

#

If it's not possible for stable, I can use Beta

round bone
#

if PlayerInventoryItemChangeAfterEvent is not in stable Minecraft, then you probably are forced to wait for 3 days (to 1.21.80)

lyric kestrel
#

And it's preview 2.1.0-beta

round bone
#

ahh, sorry, but you're forced to use intervals and check both (block's and player's) containers every tick

lyric kestrel
#

hmm, I could use PlayerCursorInventoryComponent

#

It seems right for what I want to do

round bone
#

check every tick if it changed

lyric kestrel
#

ye

#

Thank you btw

round bone
#

no problem

#

atleast I tried

lyric kestrel
#

You helped, not just tried

#

I was able to find PlayerCursorInventoryComponent which is exactly what I need

#

I think

#

xD

gaunt salmonBOT
agile flicker
#

Server net, not working un 1.21.72?

marsh pebble
#

"afk"

unique acorn
#

and server net is only usable in bds

narrow patio
#

are you able to change a cmd inside a cmd block using a script

agile flicker
unique acorn
#

bedrock server

round bone
#

if you would like to test it, you can use my API for Discord webhooks just to check if it works

round bone
#

πŸ˜…

chrome gyro
#

Hmmm anyone know how we go about giving an item that has a specific dye already? Been trying solutions related to:

    const texture = new item.getComponent("minecraft:dyeable");
    item.set(texture, 4)
#

This is inside a basic giveItem function

fast lark
#

For some reason

round bone
fast lark
round bone
#

are you using BDS?

fast lark
#

I tried to use ur api some time ago, and i ended up doing a normal message and not a beautiful embed

fast lark
round bone
round bone
#

you can send me it

fast lark
fast lark
round bone
#

you can leave a star or smth if you like it xD

#

I would like to push it to 16 stars just for achievement xD

fast lark
#

I cant

#

I dont have a github account

round bone
#

ahh no problem

#

if you're a programmer I would recommend to create an account

#

GitHub is pretty important

remote oyster
#

GitHub is great for managing projects. Git is a great tool to have and utilize.

#

Gerrit is phenomenal if working on large projects.

shut vessel
#

Hi, could someone show me how I can make a menu to change the kb?

fast lark
round bone
rose light
#

has anyone here done some codicate, which simulates a spwan rules, by Js/Ts ??

oak lynx
#

praying mojang will make dimension.getBlocks() useful

marsh pebble
#

can anyone help me?

wary mango
#

guys i have a little problem tho, I need to check if entity has a specified effect. How do i do it?

thorn flicker
wary mango
#

thanks

wary mango
thorn flicker
#

just do if (getEffect())

#

it'll return true because the effect is on the player and valid.

wary mango
thorn flicker
#

okay

prisma shard
#

i don't think i am right....

#

Someone correct me

chrome gyro
#
    const texture = new item.getComponent("minecraft:dyeable");
    const redscore = 0
    const greenscore = 1
    const bluescore = 0
    texture.color = ({ red: redscore, green: greenscore, blue: bluescore })
    item.set(texture)
prisma shard
#

idk too then lol

#

bruh moment

chrome gyro
#

"Typeerror" lol np. Thank you for trying... tbh I'm still learning how to unpack the documenation, was on that page earlier today... I'll keep trying.

true isle
#
 if (block.permutation.getState('minecraft:cardinal_direction') === 'west') {
                    // Check for the south block
                    if (
                        adjacentBlocks.south?.permutation.getState('blushrooms:shape') === 'straight' &&
                        adjacentBlocks.south.permutation.getState('minecraft:cardinal_direction') === 'north'
                    ) {
                        // Validate if the south block's neighbor to the west has the 'straight' shape and if it has a special shape
                        const hasWestNeighbor = (
                            adjacentBlocks.south.west()?.permutation.getState('minecraft:cardinal_direction') === 'north' &&
                            adjacentBlocks.south.east()?.permutation.getState('minecraft:cardinal_direction') === 'north'

                        );

                        const hasSpecialShape = ['outer_left', 'outer_right', 'inner_left', 'inner_right'].includes(
                            adjacentBlocks.south?.permutation.getState('blushrooms:shape')
                        );

                        if (!(hasWestNeighbor || hasSpecialShape)) {
                            adjacentBlocks.south.setPermutation(
                                adjacentBlocks.south.permutation
                                    .withState('blushrooms:shape', 'outer_left')
                                    .withState('minecraft:cardinal_direction', 'west')
                            );
                        }
                    }
#

whats the best way to do a check like this im stumped

#

one half of the whole check system but only half of it works while the other half overrides the other if that makes sence

valid ice
#

What’s your code

true isle
#

Part of it's above. It's long af for the whole thing.

#

I'll post a help thing later

true isle
mighty igloo
#

Is dynamic properties commonly used? Does it cause lag if you have to many? Does it use up a lot of storage? Is it efficient?

#

Can someone answer these questions?

distant tulip
onyx lantern
#

anyone knows why I cant use script api 1.18.0-beta? it says the only beta version I can use is 2.0.0-beta

sudden nest
#

Anyone have a clue why and when does FormRejectError occurs?

unique acorn
sudden nest
fast lark
worn palm
#
    blockComponentRegistry.registerCustomComponent('kevrox:pressure_plate', {
        onStepOn: ({ block }) => {
            console.warn('stepped on!')
            if (block.hasTag('kevrox:pressure_plate') && !block.permutation.getState('kevrox:is_active')) {
                const currentStates = block.permutation.getAllStates();
                const newStates = { ...currentStates, 'kevrox:is_active': true };   
                block.setPermutation(BlockPermutation.resolve(block.typeId, newStates));
            }
        },
        onStepOff: ({ block }) => {
            console.warn('stepped off!')
            if (block.hasTag('kevrox:pressure_plate') && block.permutation.getState('kevrox:is_active')) {
                const currentStates = block.permutation.getAllStates();
                const newStates = { ...currentStates, 'kevrox:is_active': false };   
                block.setPermutation(BlockPermutation.resolve(block.typeId, newStates));
            }
        },
        beforeOnPlayerPlace: ({face, cancel}) => {
            if(face != Direction.Down) { cancel = true }
        }
    })
#

why the onStepOn & onStepOff event not working

remote oyster
# mighty igloo Is dynamic properties commonly used? Does it cause lag if you have to many? Does...

Dynamic properties are commonly used by developers to store custom data such as player stats, quest progress, and custom flags. By default, they don’t cause lag, but there are important caveats that determine when this holds true. Small to moderate use (a few dozen properties per entity or player) is usually fine. However, using hundreds or thousands, especially if they are frequently read or written to within a tick loop, can lead to lag due to memory and CPU strain. Performance also depends on how often the properties are updated; frequent changes every tick are more demanding than static or infrequently modified data. Additionally, how you read and write the data can impact performance if not handled efficiently.

Dynamic properties are much more efficient and scalable than workarounds like storing data in scoreboards or entities with custom tags. Storage requirements will vary depending on how much data you store, it could range from just a few bytes to several gigabytes, depending on your design, structure, and the relevance of the stored data.

At the end of the day, dynamic properties are highly recommended. However, how effectively you implement them will depend on your understanding and experience, which will ultimately shape your experience using them.

wheat condor
# mighty igloo Is dynamic properties commonly used? Does it cause lag if you have to many? Does...

Basically they re the most used to store data in a way that can't be accesed with commands. they re very versatile you can set a property to particular entities or itemstacks but you can also use them generally by saving them in world.

In dynamic properties you can save strings numbers booleans and vector3s, but you can also save objects by stringifing the data.

They re the current fastest method to save data like strings numbers booleans and locations, and its the most efficient rn

distant tulip
warped blaze
#

is there a way to mess with recipe unlocking using scripts?

#

like force the unlocking after some event or smt

wheat condor
untold garnet
#

is there a way to cancel mob damage in script?

#

like player hitting mobs

fast lark
#

U could add back the health

#

But idk

untold garnet
#

thats so.....

#

ehh

wheat condor
#

What is the correct syntax for BlockVolumeBase

#

bridge doesnt have type for that

distant tulip
wheat condor
#

i just solved

distant tulip
#

new BlockVolume(from, to) iirc

wheat condor
#

i used a for x y z

distant tulip
#

huh

wheat condor
#

no it was BlockVolumeBase

#
for (let x = ....)
    for (let y  ...)
        for (let z = ...)
#

i just needed to get all blocks

distant tulip
#

Use getBlocks...

wheat condor
#

im doing a block database but i feel that: getting the blocks, using that with the function, placing the blocks at a far away area and saving them its actually pretty inefficient

wheat condor
distant tulip
wheat condor
#

VolumeBASE]

distant tulip
remote oyster
#

Something like this example:

import { ListBlockVolume, world } from "@minecraft/server";
import { Vector3Builder } from "@minecraft/minecraft-math";

const min = new Vector3Builder(0, 0, 0);
const max = new Vector3Builder(10, 10, 10);

const volume = new ListBlockVolume([min, max]);

world.getDimension("overworld").getBlocks(volume, {}, true);
#

Actually, that would be pointless.

distant tulip
#

ListBlockVolume?
never seen that

i am pretty sure i used BlockVolume alone before

remote oyster
#

getBlocks returns ListBlockVolume lol.

thorn flicker
#

why vector3builder if you can just an object

distant tulip
#
world.getDimension("overworld").getBlocks(new BlockVolume({x,y,z}, {x,y,z}), {}, true);
remote oyster
remote oyster
wheat condor
#

like why cant they just do
{from:{x,y,z},to:{x,y,z}}

mighty igloo
#

Does anyone know how to give the player a potion with a certain level or length? Alsk how do I read a potions length and level.

mighty igloo
#

And for containers. How can I save the contents json string data to a dynamic property value?

mighty igloo
mighty igloo
#

Not yet?

#

You can stringify some items.

wheat condor
thorn flicker