#Script API General

1 messages Β· Page 85 of 1

uncut lynx
#

Oh, come on

ruby plover
#

will it still work in the same format i used?

uncut lynx
#

it's just 400 lines of code

alpine wigeon
#

jeez

uncut lynx
#

we can vc

#

and i can explain what i am doing

wheat condor
# uncut lynx *it's **just** 400 lines of code*

brooooooo what's this 😭

world.setDynamicProperty(`createbedrock:add_stress_units_${facingDirection}_${facedOppositeBlockLocation.x}_${facedOppositeBlockLocation.y}_${facedOppositeBlockLocation.z}`, 
uncut lynx
wheat condor
#

i mean ${} ${} ${} ${} ${}

uncut lynx
#

also face-wise too

uncut lynx
alpine wigeon
#

πŸ’€

uncut lynx
#

shorter and nicer than appending to string

uncut lynx
alpine wigeon
#

i fear no man
but that thing... it scares me:
your code

wheat condor
#

just use JSON.stringify(facedOppositeBlockLocation)bruh

uncut lynx
#

L M F A O

uncut lynx
#

deserialize every tick?

#

for 100+ blocks?

wheat condor
#

Object.values(facedOpp......).join('_')

uncut lynx
#

Nah that aint simplistic

#

(my code is obv simplistic duh)

wheat condor
#

shortening the name?
like FOBLoc

wheat condor
#

idk

uncut lynx
uncut lynx
wheat condor
#

// FOBloc = facedOppositeBlockLocation

uncut lynx
#

Damn

#

Smart

#

anyways

wheat condor
uncut lynx
#

i still have the issue

#

when i first place motor -> shaft it says RPM: 0 ... opposite RPM: 0

#

opposite RPM in that case should be some value

#

(which it becomes after i replace the shaft)

wheat condor
#

75% of your script is just setting dynamic properties

uncut lynx
#

yeah

#

lol

wheat condor
#

are 0 and -0 the same number?

uncut lynx
#

Idk and idc, in that case the motor would need to be giving 0/-0

#

but motor gives some lets say 123

#

i'll send u vid

#

watch the log up top to see what i mean

#

(the log is all i got currently for knowing what happens)

#

obs just had some attack or sth

#

but this is what i got

#

also shaft texture is half broken but blockbench failed to export it correctly for some reason

sly valve
uncut lynx
warm mason
#

400 lines is very little

uncut lynx
sly valve
lyric kestrel
#

lol

warm mason
sly valve
#

My pretty wave file

warm mason
wheat condor
#

no one beating me

warm mason
sly valve
warm mason
wheat condor
sly valve
wheat condor
#

they re not big they re 300 lines each

warm mason
wheat condor
#

that's a whole crafting system

wheat condor
sly valve
warm mason
sly valve
warm mason
wheat condor
#

more than 500 lines per file is crazy work

granite badger
sly valve
lyric kestrel
warm mason
lyric kestrel
#

For each of my blocks, I have 21 files, each with 16 states, and there's 9 blocks ehappy

warm mason
#

And the total weight?

sly valve
#

My Largest addon got: (1.753.088 Bytes)

lyric kestrel
sly valve
#

(including node_modules)

granite badger
sly valve
lyric kestrel
#

lmao

sly valve
#

ugh

#

i hate jsons

lyric kestrel
#

I had to split each into a separate block, otherwise 1 block would be too much for the world

granite badger
distant tulip
lyric kestrel
warm mason
warm mason
uncut lynx
granite badger
lyric kestrel
#

And it uses vanilla textures, so it's completely texture pack compatible

wheat condor
uncut lynx
#

In the create mod stuff rotates, and for each point in rotation it'd need permitation

warm mason
wheat condor
#

allat just to not finishing the project and never posting the addon 😭 πŸ”₯

lyric kestrel
#

If I want to do it all in 1 block, it'd be way too much of a performance hit, and would actually use a lot more permutations

warm mason
lyric kestrel
wheat condor
#

its not even finished –_–

granite badger
lyric kestrel
#

I can help when I'm finished updating my add-on @wheat condor if you want

wheat condor
lyric kestrel
distant tulip
lyric kestrel
#

Wait, is it json UI?

warm mason
wheat condor
granite badger
lyric kestrel
#

Did not know that was a thing

wheat condor
lyric kestrel
#

Damn, that's even more impressive

#

I thought it was JS

wheat condor
#

wdym?

#

that's js with json ui to display the menu

lyric kestrel
#

I thought you were using the forms that JS has access to

lyric kestrel
wheat condor
#

i AM using forms

lyric kestrel
#

I don't have much know how with JS forms xD

#

I would like to learn though

#

Seems interesting

uncut lynx
#

they're like really limited

lyric kestrel
#

ye

distant tulip
#

they are good enough

wheat condor
#

its just actionFormData, and im using ChestFormData that is a class to display forms like a chest with clickable items

wheat condor
#

my goal is to create an addon that makes minecraft feel like a new game more challenging and complex

lyric kestrel
#

How do you seek to accomplish that?

wheat condor
#

wait a second

lyric kestrel
uncut lynx
#

Or is that not what you want

wheat condor
lyric kestrel
#

Kinda. good biomes

lyric kestrel
#

Goofy was his name

wheat condor
lyric kestrel
#

interesting

#

a timeout for attacks

wheat condor
lyric kestrel
#

Ye

#

What else have you done so far?

wheat condor
lyric kestrel
#

Actually, lets take this out of here, since this is js chat

uncut lynx
#

Okay i gave this messy ass code to claude ai

#

and it gave me some real nice code

#

YAAAAY

#

IT WORKS

#

Just 23 hours of work over 2 days

unique acorn
#

why no spin :(

#

no spin shaft = bad

uncut lynx
#

Alr alr

hoary matrix
uncut lynx
#

How do i animate the thing tho?

rough jackal
#

I tried to transfer my javascript behavior pack from education edition over to bedrock edition and... well it's not going well
I'm getting errors like this

[Scripting][error]-Plugin [Box Scripts - 0.1.0] - [index.js] ran with error: [ReferenceError: Native function [World::getDimension] does not have required privileges.    at <anonymous> (index.js:3)]
[Scripting][error]-Plugin [Box Scripts - 0.1.0] - [index.js] ran with error: [ReferenceError: Native function [World::sendMessage] does not have required privileges.    at <anonymous> (index.js:2)]

Does anyone know how i fix that

unique acorn
uncut lynx
rough jackal
#

yeah I can't find any documentation on worldLoad

uncut lynx
#

r u using 2.0.0-beta?

unique acorn
#

in the script api v2, scripts start as soon as the world starts loading, so if you think about it, when you run getDimension there is no dimension because world didnt load yet

rough jackal
unique acorn
uncut lynx
#

so maybe via system.run

unique acorn
lyric kestrel
#

It's changing in 2.0.0

remote oyster
# rough jackal I tried to transfer my javascript behavior pack from education edition over to b...

When calling API methods that potentially alters something in the world in a subscribed beforeEvent then it will throw an error because it's read only. In such cases you can handle it in the afterEvent if applicable or you can offset the execution at a later time, typically at the end of the same tick, or following tick. Most common way to do this is to create a function that can be called to execute the API methods and use system.run() to call that function.

uncut lynx
#

also how do i make that flipbook texture to animate

plucky light
#

This is great - thanks.

Does get closest biome find biomes in unloaded chunks or is it limited to aim distance + previously loaded?

fast lark
#

How do you make the text big?

#

@sly valve

warm mason
sly valve
fast lark
#

Oh nice

fast lark
lyric kestrel
fallow minnow
fast lark
fallow minnow
#

to make that it is

lyric kestrel
fallow minnow
#

yes ik

#

thats what i was talking about

shy leaf
sweet seal
#

How to cancel players turning item frames?

warm mason
dull jungle
shy leaf
#

was about to say that

steady canopy
shy leaf
#

oh bruh

dull jungle
#
world.beforeEvents.playerInteractWithEntity.subscribe((event) => {
  if (event.block.typeId === "minecraft:frame") {
    event.cancel = true;
  }
});

It cancels the item frame from turning, but it also cancels adding items to the frame.

fallow minnow
#

well duh

rough jackal
#

every time i try to get players using @a or @s in tick.json functions or in scripts it always returns "Player"

#

nevermind it's a problem with my internet and not being signed in...

tame helm
#

100000 comments

shy leaf
#

is there a script resource for storing and tracking mob effects?

wheat condor
# fallow minnow 450?? thats a lot

Nah it isn’t, it includes also all the ui patterns and options in abig json structured like object, and fully functional crafting

halcyon phoenix
#

is this a good maze algorithm?

#

any suggestions?

#

still works

#

shifted it to 2000, 2000

halcyon phoenix
fallow minnow
#

are you able to dynamically choose to have more segments?

sterile epoch
#

is there a way to make it so some custom commands are hidden if you don't have a specific tag?

halcyon phoenix
shy leaf
halcyon phoenix
#

woah

small cloak
prime zenith
#

Is it possible to run a check that an item is in the game before running a function

#

Or somehow have it set every item avail to a component

ivory bough
#
const despawnableMobs = [ "bat", "drowned", "glow_squid", "phantom", "bee", "allay", "fox", "cat", "goat", "tropicalfish", "panda", "pufferfish", "dolphin", "trader_llama", "wandering_trader", "turtle", "hoglin", "piglin", "piglin_brute", "sniffer" ]

world.afterEvents.entitySpawn.subscribe((event) => {
if (despawnableMobs.includes(event.entity.typeId)) {
Β    event.entity.remove();
Β  }
});

Why doesn't this despawn the given entities?

sterile epoch
#

typeId will include the minecraft: prefix so it won't match, you should to typeId.replace("minecraft", "")

prime zenith
#

Thats only the events to run after world loads which may be useful however it doesnt answer how to loop threw every item in game

If ppl know if where items are stored list array map ect maybe its possible but jdk

sterile epoch
#

oh I misunderstood your question

#

mb

prime zenith
#

I want to put every item into an object to use for my ge

sterile epoch
#

it's ```js
Dimension.getEntities({ type: "minecraft:item" });

prime zenith
#

Also whats all needed to earn the scripting role

#

Wait that gets all items in game including modded items

sterile epoch
#

I think you can choose which roles you have somewhere

sterile epoch
#

however, if you want to test for specific items, you have to get the ItemStack component from the item first

prime zenith
#

I need to make it so my grand exchange can work without my itemComp dependency

#

I may need help porting that

Thats a 600 line file thats plugged in to my old pack i need to be able to use it as a standalone feature for my currency addon

sterile epoch
#

damn

prime zenith
#

Alot went in to that to allow buying and selling acrossed logged in state of game

sterile epoch
#

what

prime zenith
#

You can make buy or sell orders that will be fulfilled even if you log off game as long as someone buys it

sterile epoch
#

I see, that's cool

#

I'm guessing it stores a dynamic property for when you log in and gives the money you received?

prime zenith
#

Yup to world using your player id

#

You need to claim it from ge

#

The issues however are

1 it uses that packs itemComp which are all the items that game uses which is an object

It uses a scoreboard currency

So i need to make it not dependent on that comp or add all items dynamicually to an itemComp in that project

And be coded to use my coins instead of scoreboard

#

Its alot and i could use a hand on it

sour sedge
#

I thought script chat would be most likely to know: there really is no way to define and iterate over ordered data in regular Molang except by using a bunch of conditionals ...right?

#

...I have a looong page of very silly looking code here...

echo tinsel
#

oop accidently put a space on the script

meager zenith
#

what does this mean?
code

import { world} from '@minecraft/server'

world.beforeEvents.playerInteractWithBlock.subscribe(ph =>{
        const item = ph.itemStack;
        const block = ph.block;

        if(ph.isFirstEvent && item && item.typeId == "ms:broken_mellohi" && block.typeId == "minecraft:jukebox")
        {
                console.log('hi')
                const d = ph.block.dimension;
                const l = ph.block.location;
                d.playSound("sounds.broken_mellohi",l, { pitch: 1.0,  volume: 1.0   });
        }
});
shy leaf
meager zenith
#

oh ok

#

it worked !! thank you :D

round bone
#

πŸ™

halcyon phoenix
#

does entity.runCommand() require cheats on?

random flint
#

no

#

-# (If it does, I would be surprised)

halcyon phoenix
#

thanks

round bone
sly valve
round bone
#

I hope that Gega is not contributing to any OSS projects

sly valve
#

OSS?

round bone
#

open-source software

sly valve
round bone
sly valve
#

hmm?

round bone
#

this code is unreadable

sly valve
#

Gega still could read it

#

Once i tried to steal a code

#

and this code was..

#

well idk how to explain

#

but not even chat gpt were able to help me reading that

uncut lynx
#

I asked on block general but nobody answers, how do i convert java model made of sub textures with multiple cubes into one png texture with bedrock model

thorn flicker
thorn flicker
#

or just be patient

fresh current
#

Neko Waddup man

sly valve
fresh current
#

down to vc?

sly valve
#

not atm, doing my TD script

fresh current
#

alr

#

question tho

#

have you ever made a blocking/parrying script?

sly valve
#

nope

sly valve
fresh current
#

interesting

sly valve
sly valve
random flint
sly valve
#

smart humans dont need explaining variable names

remote oyster
# sly valve You got that from kal'tsit
// [Kal'tsit Log - Rhodes Diagnostics Terminal v3.1]

// Hex-encoded variable names (for... reasons.)
const _6772656574696E67 = "Hello, ";   // 'greeting'
const _746172676574 = "World!";        // 'target'
const _6D657373616765 = _6772656574696E67 + _746172676574; // 'message'

// Output result
console.log("[Rhodes Terminal] " + _6D657373616765);

// Kal'tsit's reaction
console.log("\n[Kal'tsit] You named your variables in hex.");
console.log("[Kal'tsit] The system is running, but barely. Memory integrity: 57%.");
console.log("[Kal'tsit] This is either brilliance... or sabotage.");
lyric kestrel
remote oyster
lyric kestrel
#

I quite like it

sly valve
remote oyster
halcyon phoenix
#

welp I hope no one does that

#

Anyways how do you crete those flying nametags?

random flint
#

entities, with nameable component always_show true

#

vanilla (no rp). or custom (require rp)

copper egret
#

In gametest module, does the simulated player load chunks?

random flint
#

It should.

Alternatively, You can load chunks using ordinary custom entity and tick_world component

copper egret
#

can I use tickingarea and remove it later via script right?

random flint
#

You can... but that'll require a command since there's not yet a native one.

Take note that the tickingarea also has a limit too.

lyric zealot
#

anyone got a template for the custom command script?

lyric kestrel
warm mason
#
console.warn(weapon.typeId, weapon.getComponent('cooldown'), weapon.hasComponent('cooldown'))

-# "Great Script API" moment

jolly citrus
#

Doesn't that just mean it returns en empty component

#

empty component = no component

warm mason
jolly citrus
warm mason
#

In short, hasComponent is broken.

jolly citrus
#

that would be a component without any keys or values

#

just {}

uncut lynx
#

I changed my stress/rpm distrib system to graph-based

#

lotta more peformant

uncut lynx
#

Hey so uhm how do i do the flipbook animations that are controlled by js (rotation stages: none, slow, medium, fast)?

warm mason
#

Although it's better to just put an entity there

wary edge
uncut lynx
#

if i define custom state of the block, how do i set default value for it or sth

uncut lynx
warm mason
uncut lynx
#

thanks

cold grove
uncut lynx
#

Yoo i think i know how

cold grove
#

the worst is that if someone dont know what is doing probably will believe in you

warm mason
#

It was sarcasm

uncut lynx
#
{
                "condition": "q.block_state('createbedrock:rotation_15') == true",
                "components": {
                    "minecraft:geometry": "geometry.shaft_15"
                }
            },
            {
                "condition": "q.block_state('createbedrock:rotation_30') == true",
                "components": {
                    "minecraft:geometry": "geometry.shaft_30"
                }
            },
            {
                "condition": "q.block_state('createbedrock:rotation_45') == true",
                "components": {
                    "minecraft:geometry": "geometry.shaft_45"
                }
            },
            {
                "condition": "q.block_state('createbedrock:rotation_60') == true",
                "components": {
                    "minecraft:geometry": "geometry.shaft_60"
                }
            },
            {
                "condition": "q.block_state('createbedrock:rotation_75') == true",
                "components": {
                    "minecraft:geometry": "geometry.shaft_75"
                }
            },
#

then i switch them using script

#

every tick

warm mason
#

Just use entities

uncut lynx
#

that's gonna be laggy

warm mason
#

+this will make the animation smoother

uncut lynx
#

how do i make the entity spin first question

#

second lotta entities = big lag

warm mason
uncut lynx
wary edge
warm mason
#

yes, just use entity properties and sync them with the client

uncut lynx
#

how would i implement the entity rotation thing though for concise answer with what to e.g. set speed to -67 rpm or 213 rpm

warm mason
wary edge
warm mason
# uncut lynx well that's smart

You can ask in #1067869022273667152 how to use entity properties in animations, and then just set the property to the entity via entity.setProperty('name', 'value')

uncut lynx
#

imagine 100 of them

#

entities

#

for simple relatively machine

warm mason
#

Also, are you using custom components V2?

warm mason
uncut lynx
#

for create 1000 aint a lot

distant tulip
warm mason
# uncut lynx Y

Then I recommend you create a component that binds an entity to a block, and removes it if the block is broken, etc.

prime zenith
#

Your 2.147b limit wont stop me from flawlessly making a currency system to far exceep it take that mojang

warm mason
warm mason
#

And make them less than 1000 by 1000 blocks

uncut lynx
#

brb

warm mason
#

In any case, it's up to you, I just suggested it as one of the ways. And you 100% will have to take great care of optimization if you want 1000 such blocks not to lag

inland merlin
#

does anyone have the same issue where reload all doesn't work because of permission level issue? im operator... doesn't show any other options to raise it

#

since last update mostly

sterile epoch
#

if you trigger .setOp(true) it fixes it, I just made it trigger when I clicked a stick

round bone
#

they have much higher limits

prime zenith
#

No need i did something better and realistic

#

I used an item

#

Or items

#

Aka coins physical holdable currency

inland merlin
prime zenith
#

@sterile epoch hey did you sleep well

prime zenith
#

Ouch

#

I got the remove working

sterile epoch
#

Oh dope

prime zenith
#

Now all we need is the grand exchange

sterile epoch
prime zenith
#

Wanna help with that

sterile epoch
#

sure in like 30 mins or sum

prime zenith
#

Ok just let me know

#

@sterile epoch i dmed you btw

#

THEY ADDED CUSTUMIZED SUPERFLATS!!!!!!

jolly citrus
#

Does system.beforeEvents.shutdown fire when /reload is executed

uncut lynx
jolly citrus
uncut lynx
#

/reload all reloads the world

lyric kestrel
#

I am unsure of what I want to try now

#

Maybe a multiblock structure?

dreamy elbow
#
    let test = new ModalFormData()
    test.title("Test")
    test.dropdown("test", ["one", "two", "three"], 2) // Function argument [2]                       //expected type: ModalFormDataDropdownOptions | undefined
    test.show(player).then((r) => {
        if (r.cancelationReason == "UserBusy") {
            testText(player)
        } else {
            console.warn(r.formValues[0])
        }
    })
}```
#

basically it keeps not letting me set the default value of modalformdata. how would I fix this

#

btw I have to drive an hour to help someone, so might take a minute to answer any question

finite totem
#

I keep recieving this error every tick and I don't know how to fix it

``[Scripting][error]-TypeError: cannot read property 'getComponent' of undefined at <anonymous> (cooldown_timers.js:19)`

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

world.afterEvents.entityHitEntity.subscribe(({ damagingEntity: player }) => {
    if (player.typeId !== "minecraft:player") return;

    const item = player.getComponent("equippable").getEquipment("Mainhand");
    if (!(item.typeId.includes("battleaxe") || item.typeId.includes("echo_warhammer"))) return;

    const cooldown = item.getComponent("cooldown");
    const ticksLeft = cooldown.getCooldownTicksRemaining(player);
    if (ticksLeft == 0) cooldown.startCooldown(player);
})
system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        const item = player.getComponent("equippable").getEquipment("Mainhand");
        const cooldown = item.getComponent("cooldown");
        const ticksLeft = cooldown?.getCooldownTicksRemaining(player) ?? 0;

        //Battleaxes
        if (item.typeId.includes("battleaxe")) {
            if (cooldown.cooldownTicks >= ticksLeft - 1) { player.runCommand("function battleaxe_sfx") }
            if (ticksLeft > 0) {
                player.addEffect("weakness", 3, { showParticles: false, amplifier: 255 });
            }
        }

        //Thunder Staff
        if (item?.typeId === "genb10:thunder_staff" && player.isSneaking) {
            if (cooldown.cooldownTicks >= ticksLeft - 1) { player.runCommand("function thunder_staff") }
        }

        //Echo Warhammer
        if (item?.typeId === "genb10:echo_warhamer") {
            if (cooldown.cooldownTicks >= ticksLeft - 1) { player.runCommand("function echo_warhammer") }
            if (ticksLeft > 0) {
                player.addEffect("weakness", 3, { showParticles: false, amplifier: 255 });
            }
        }
    }
})
#

anyone know how to fix it?

remote oyster
# finite totem anyone know how to fix it?
// Issues here
player.getComponent("equippable").getEquipment("Mainhand")

You need to verify that the player has an item in their main hand by checking if item is undefined or not, before trying to get a component for the item.

prime zenith
#

is there a way to make a player not take fall damage but only if a condition is ment

prime zenith
#

no that would make it perm it needs to be depending on a dynamic property

#

basicually if they wear full diamond they get a dynamic property that lets them not take fall damage

dusty temple
#

Does my behavior manifest look correct? Or is it missing something?

{
    "format_version": 2,
    "header": {
        "name": "Minigames BP",
        "description": "Super epic minigames",
        "uuid": "fbcc63f0-3127-4e46-9800-e5740ffe203d",
        "version": [
            1,
            0,
            0
        ],
        "min_engine_version": [
            1,
            20,
            80
        ]
    },
    "modules": [
        {
            "type": "data",
            "uuid": "fdbb01d8-aa61-4321-be91-a2c9fca6607e",
            "version": [
                1,
                0,
                0
            ]
        },
        {
            "description": "Scripting module",
            "type": "script",
            "uuid": "7feae44b-34d9-4322-b774-f8a4de2fdece",
            "version": [
                0,
                0,
                1
            ],
            "entry": "scripts/main.js"
        }
    ],
    "dependencies": [
        {
            "uuid": "98f4459d-f3d1-4ea6-9497-b7f254bc5f0e",
            "version": [
                1,
                0,
                0
            ]
        },
        {
            "module_name": "@minecraft/server",
            "version": "1.11.0-beta"
        },
        {
            "module_name": "@minecraft/server-ui",
            "version": "1.1.0"
        }
    ]
}
warped blaze
shy leaf
#

or 2.0.0-beta if you need beta stuff

dusty temple
# shy leaf are you on latest version of minecraft? you should be using 1.19.0 version of se...

Sorry I sent the incorrect manifest, here it is

{
    "format_version": 2,
    "header": {
        "name": "Peakness BP",
        "description": "Straight peak",
        "uuid": "e56c2196-e745-4dc6-98da-d9f0d09446d3",
        "version": [
            1,
            0,
            0
        ],
        "min_engine_version": [
            1,
            21,
            50
        ]
    },
    "modules": [
        {
            "type": "data",
            "uuid": "db32f58d-78bc-4658-8c45-84314290dd5b",
            "version": [
                1,
                0,
                0
            ]
        },
        {
            "description": "Scripting module",
            "type": "script",
            "uuid": "7feae44b-34d9-4322-b774-f8a4de2fdece",
            "language": "javascript",
            "version": [
                0,
                0,
                1
            ],
            "entry": "scripts/main.js"
        }
    ],
    "dependencies": [
        {
            "module_name": "@minecraft/server",
            "version": "1.13.0"
        },
        {
            "module_name": "@minecraft/server-ui",
            "version": "1.3.0"
        }
    ]
}
prime zenith
shy leaf
#

unless you intended it

dusty temple
warped blaze
dusty temple
#

or minecraft/server

prime zenith
#

How do i write that

thorn flicker
#

you use the damage sensor component with filters

shy leaf
#

its outdated

#

both

prime zenith
#

It can test that you have full dosmond?

dusty temple
#

do i have dependencies incorrect?

#

Here is my resource manifest as well

{
  "format_version": 2,
  "header": {
    "name": "Peakness RP",
    "description": "Straight peak",
    "uuid": "2daa78c9-ddb1-4602-9d90-46cf393d70a5",
    "version": [
      1,
      0,
      0
    ],
    "min_engine_version": [
      1,
      21,
      80
    ]
  },
  "modules": [
    {
      "type": "resources",
      "uuid": "81d12a5c-02ba-4d67-9c82-3dc7fbb5dcbf",
      "version": [
        1,
        0,
        0
      ]
    }
  ]
}
#

Actually confuzzled

prime zenith
#
                "minecraft:damage_sensor": {
                    "triggers":{
                        "cause": "fall",
                        "damage_modifier": 0
                    }
                }
            }``` this in components group where do i trigger it
thorn flicker
#

get rid of the modifier.

thorn flicker
wary edge
shy leaf
dusty temple
dusty temple
#

this is all I have

shy leaf
#

uh

shy leaf
#

i think you have resources as dependency in resource pack

#

which is why its probably not working

prime zenith
#

Where do i add the filter

dusty temple
#

resources as dependency?

#

what do you mean?

thorn flicker
shy leaf
#

wait no

#

thats not dependency

prime zenith
#

Im not seeing any way to add a filter into that component

shy leaf
#

facepalm sleep deprivation is hitting way too hard rn

thorn flicker
dusty temple
#

does the resource manifest need dependencies?

prime zenith
#

"minecraft:damage_sensor": {
"triggers":[
{
"cause": "fall",
"deals_damage": false
}
]
},

thorn flicker
#

inside of triggers, you can use a filter.

thorn flicker
shy leaf
#

and vice versa

#

i still dont know the actual reason why its not working, sorry

dusty temple
#

Just going to assume a bit flipped in my computer or something i don't know

shy leaf
#

welcome to addon development!

#

everything can stop and start working mysteriously out of nowhere

#

(and its painful)

prime zenith
#

None of the filters says anything about player equipment

thorn flicker
#

I sent you a doc to the filter

prime zenith
#

Not a dude

dusty temple
shy leaf
#

yw

thorn flicker
prime zenith
#

im looking and i still dont understand as in filters there is no has_equipment the docs are not as straight forward as you think

thorn flicker
#

you should move to #1067869022273667152 since this is no longer a script thing.

prime zenith
#

it shouldnt be that hard moving for this is rather pointless but the docs are useless

thorn flicker
prime zenith
#

In the filter for damage sencer trying to do it throws error

thorn flicker
#

you have to give more info than that.

#

show what you did.

prime zenith
thorn flicker
#

all_of

prime zenith
#

i did that has same option

thorn flicker
#

ill send you a doc to learn how to setup filters.

prime zenith
#

i already read the docs and still not gotten closer

thorn flicker
#

you cant just experiment?

#

put "test", and then put "has_equipment" as the value.

pale terrace
#

is there a native function for camerashake command?

prime zenith
#

Ty

thorn flicker
#

define the domain and the value which will be the item id.

#

you'll see the domain values in the doc.

prime zenith
#
                "triggers":[
                    {
                        "on_damage": {
                            
                            "filters": [
                                {
                                    "all_of": [
                                        {
                                            "test": "has_equipment",
                                            "value": "diamond_leggings",
                                            "domain": "armor"
                                        },
                                        {
                                            "test":"has_equipment",
                                            "value": "diamond_helmet",
                                            "domain": "head"
                                        },
                                        {
                                            "test":"has_equipment",
                                            "value": "diamond_boots",
                                            "domain": "feet"
                                        },
                                        {
                                            "test":"has_equipment",
                                            "value": "diamond_leggings",
                                            "domain":"leg"
                                        }
                                    ]
                                }
                            ]
                        },
                        "cause": "fall",
                        "deals_damage": false
                        
                    }
                ]
            }```
thorn flicker
#

leg, not armor

#

oh

#

you defined it below.

prime zenith
#

hold on that was meant to be chestplate

thorn flicker
#

make that torso.

prime zenith
#

or torso ok

#
                "triggers": [
                    {
                        "on_damage": {
                            "filters": [
                                {
                                    "all_of": [
                                        {
                                            "test": "has_equipment",
                                            "value": "diamond_chestplate",
                                            "domain": "torso"
                                        },
                                        {
                                            "test": "has_equipment",
                                            "value": "diamond_helmet",
                                            "domain": "head"
                                        },
                                        {
                                            "test": "has_equipment",
                                            "value": "diamond_boots",
                                            "domain": "feet"
                                        },
                                        {
                                            "test": "has_equipment",
                                            "value": "diamond_leggings",
                                            "domain": "leg"
                                        }
                                    ]
                                }
                            ]
                        },
                        "cause": "fall",
                        "deals_damage": false
                    }
                ]
            },```
thorn flicker
#

not the order I would put it in, but yeah.

prime zenith
#

i still take fall damage in full diamond tho

thorn flicker
#

any error

prime zenith
#

no

thorn flicker
prime zenith
#

1.21.0 im 100% positive

#

thats full player.json

valid ice
#

have you tried with mineraft:diamond_chestplate and similar? Dunno if that would do anything or not

prime zenith
#

ill try that

#

the suggestions gave without

valid ice
#

Probably doesn't do anything, then

thorn flicker
#

I was thinking that but I thought that wouldnt matter

valid ice
#

Doesn't hurt to try, ig

thorn flicker
#

ive used it witout the namespace

thorn flicker
prime zenith
#

I doubt it will work but here goes my sanity

#

Nope still broke a leg

thorn flicker
#

I swore using filters in on_damage would go with the properties for damage sensor.

#

I also see other people doing it too

prime zenith
#

I wonder if its a deeper issue on player.json

#

Because if damage sensor worked but filter didnt wouldnt i take no damage from fsll at all

thorn flicker
#

it should still trigger.

#

maybe something is wrong with the filter

valid ice
#

doing this worked for me:

"minecraft:damage_sensor": {
    "triggers": [
        {
            "on_damage": {
                "filters": [
                    {
                        "all_of": [
                            {
                                "test": "has_damage",
                                "value": "fall"
                            },
                            {
                                "test": "has_equipment",
                                "value": "diamond_chestplate",
                                "domain": "torso"
                            },
                            {
                                "test": "has_equipment",
                                "value": "diamond_helmet",
                                "domain": "head"
                            },
                            {
                                "test": "has_equipment",
                                "value": "diamond_boots",
                                "domain": "feet"
                            },
                            {
                                "test": "has_equipment",
                                "value": "diamond_leggings",
                                "domain": "leg"
                            }
                        ]
                    }
                ]
            },
            "deals_damage": false
        }
    ]
}
fallow minnow
#

guys can someone hepl it no working

// Quantum calculator powered by vibes
function calculate(a, b) {
if (a = b) { // Oops: assignment, not comparison
return "same same but different";
}

let result = a + b - "banana"; // NaN time
console.log("Calculating result:", result);

try {
result **= "πŸ¦„"; // unicorn-powered exponentiation
} catch (e) {
alert("Math broke. Send help. πŸ†˜");
}

return result ?? maybeDefinitelyUndefinedProbably;
}

const output = calculate("5", [1, 2, 3]);
document.body.innerHTML = <marquee>${output}</marquee>; // bring back the 90s

thorn flicker
valid ice
#

It did not

thorn flicker
#

thats weird.

fallow minnow
#

it dont displae ore ui like it siad it wuld

valid ice
#

It cancelled all damage with the "cause": "fall" weirdly enough

fallow minnow
#

it for quantumn equations

#

for ore ui

valid ice
#

ore ui only takes leibniz equations, sorry

fallow minnow
#

what error??

prime zenith
#

Ima test herobrines method

#

Still hurt

thorn flicker
#

make sure you saved properly

prime zenith
#

Its def my player.json i tested a feature i know works and nope

fallow minnow
#

ummm thats not script api

thorn flicker
prime zenith
#

Omfg if it was due to this comma ill scream

thorn flicker
#

you would get an error.

#

are you sure you have content logs enabled

prime zenith
#

I do

#

And no it didnt player.json is somehow not loaded

#

Is 1.21.0 still a valid format version

thorn flicker
prime zenith
#

Idk what else it is i tried changing values the player.json is essentually not loaded

#

I checked the pack file to just to be sure and its there minecraft is just notbloading it at all

sour sedge
# halcyon phoenix welp I hope no one does that

Some do, to avoid innovative/complex work getting quickly ripped off I guess. Marketplace is kinda full of that thing (but it's harder to rip off complex beautiful structures and get away with it, than the code behind the scenes). I've seen worse. I assume they don't actually code in it unless they're insane, this would be done before delivery.

Sadly, the International Obfuscated JavaScript Code Contest doesn't appear to be running any more. That was true art. Happily, there's still mind-bending examples in that and many other languages to marvel at.

winged gull
#

nope, the add-on won't even attempt to load the scripts if the manifest.json specifies a beta version and the toggle isn't enabled

winged gull
prime zenith
#

Ive been looking i dont see any can you help me look

winged gull
#

send it as .json

prime zenith
#

i changed format version to test did not fix

winged gull
#

not .txt

#

just upload the file

prime zenith
#

how do i get discord to do that

winged gull
prime zenith
winged gull
#

yeah there you go

#

I don't see any errors

#

but I am on my iPhone

prime zenith
#

thats conserning

winged gull
#

so I can't use VSCode

prime zenith
#

i dont see any either

winged gull
#

so it doesn't have error detection

#

so I could have easily missed it

winged gull
#

check the content error log

prime zenith
#

i did and in bridge

#

wait i wonder something

winged gull
#

check content error logs

prime zenith
#

Omfg im an idiot i fixed it

#

So because bridge gives all my packs a player.json i was over riding it

#

If i want a pack to add to another packs player.json without over riding it how do i do that

#

look at my parrot

winged gull
winged gull
#

also I have already done that before

#

Except mine also allows you to make things like experience orbs, ender dragons, armor stands, and players ride you too (you can let anything ride anything).

prime zenith
#

that wasnt the point that was not what the goal was that was a test

shy leaf
#

actually, i might just make a post

carmine quail
#

Can anyone help me with this?

#

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

const commandPrefix = "!";

async function handleCommand(command, args, player) {
const dimension = player.dimension;

switch (command) {
    case "balance":
        await dimension.runCommandAsync(`tellraw "${player.name}" {"rawtext":[{"text":"Β§c${player.name}Β§b's balance: ","score":{"name":"${player.name}","objective":"money"}}]}`);
        break;
    case "test":
        await dimension.runCommandAsync(`say test`);
        break;
    default:
        await dimension.runCommandAsync(`tellraw "${player.name}" {"rawtext":[{"text":"Β§4Unknown command: Β§f${command}"}]}`);
}

}

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

if (message.startsWith(commandPrefix)) {
    event.cancel = true;
    const args = message.slice(commandPrefix.length).trim().split(/\s+/);
    const command = args.shift().toLowerCase();
    handleCommand(command, args, sender);
}

});

#

2.0.0 beta

shy leaf
#

and what help do you need

carmine quail
#

Everytime I type "!test" it's days error

#

Says*

#

I'm making a custom command if I type "!p <page>" every page triggers a function from mc command /function

shy leaf
#

no content logs?

#

or anything?

carmine quail
#

W8

shy leaf
#

also runCommandAsync is deprecated in 2.0.0-beta

#

you need to switch to runCommand

carmine quail
#

[Scripting][error]-Unhandled promise rejection: TypeError: not a function at handleCommand (main.js:13)
Β  Β  at <anonymous> (main.js:27
)

carmine quail
#

So just dimension.runCommand?

shy leaf
#

yeah

carmine quail
#

I'll try

#

[Scripting][error]-Unhandled promise rejection: ReferenceError: Native function [Dimension::runCommand] does not have required privileges. at handleCommand (main.js:13)
at <anonymous> (main.js:27)

sterile epoch
carmine quail
#

Did u use @minecraft/server-admin?

carmine quail
#

Nvm got it

tardy pivot
tardy pivot
# tardy pivot

why doesnt the block update its neighbours when destroyed

prime zenith
#

Its such a great feeling when something just a few days ago you had no clue how to build is working flawlessly

carmine quail
#

All i do is copy paste from gpt I'm such a noob TvT

#

function handleCommand(command, args, player) {
const dimension = player.dimension;
system.run(async () => {
// Check if admin
const result = await dimension.runCommand(tag "${player.name}" list);
let hasAdminTag = false;

if (result.statusCode === 0) {
const match = result.statusMessage.match(/tags:\s*(.*)/);
if (match && match[1]) {
const tags = match[1].split(",").map(tag => tag.trim());
hasAdminTag = tags.includes("admin");
}
}

#

Is this right?

remote oyster
halcyon phoenix
carmine quail
#

I'm giving up

lyric kestrel
carmine quail
lyric kestrel
#

I'll be able to help in 5mins

carmine quail
#

In here?

lyric kestrel
#

Nah, I see you made a thread

carmine quail
#

Thanks can i ask if there's any bots runs the code if theres an error smthin

lyric kestrel
#

Yes, in #debug-playground

carmine quail
#

Idk how to use it tho

granite badger
granite cape
#

we need event trigger right click

halcyon phoenix
#

in terms of scripting that is, but when comes to jsons files like the entities and blocks, it gets most stuff wrong

meager cargo
#
world.beforeEvents.itemUse.subscribe(event => {
    const player = event.source
    const item = event.itemStack

    if (!item || item.typeId !== "minecraft:compass") return

    const riding = player.getComponent("riding")?.entityRidingOn
    if (!riding || riding.typeId !== "test:riding_entity") return

    const tags = riding.getTags()
    if (tags.includes("ride_1")) {
        player.runCommand("execute if entity @e[type=test:riding_entity,tag=ride_1] run event entity @e[type=test:riding_entity,tag=ride_1] ride_2")
    } else {
        player.runCommand("execute if entity @e[type=test:riding_entity,tag=ride_2] run event entity @e[type=test:riding_entity,tag=ride_2] ride_1")
    }
})

What is wrong here?
Error in line with first player.runCommand

gaunt flare
#

That’s a beforeEvents. Wrap your functions inside a system.run

meager cargo
#

Thank you

prime zenith
#

If im seperating my rpg packs up should i also make a seperate pack for quests

#

Wait ill need to unless the quest only uses that skills level

worldly heath
#

is it possible to make an alternative for is_in_village filter using scripts?

#

i had to replace the environmental_sensor ,now I can't detect villages to trigger raids

halcyon phoenix
#

what's the dofference though they're almost all the same

uncut lynx
#

claude ai is like 10x better

#

trust me

#

it made me a graph-based propagation system

halcyon phoenix
#

wouldn't chatgpt or deepseek can do that to?

#

I think what matters is the data they were trained and the dellivery of the data requested

uncut lynx
#

chatgpt has length limits lower

halcyon phoenix
#

I see...

#

I'll prompting it and compare it to others

#

thanks for the suggestion

uncut lynx
halcyon phoenix
jolly citrus
#

someone explain why the menu shows up twice ples

Commands.instance.registerCommand(
  "cape",
  "Switch your cape",
  "",
  undefined,
  1,
  null,
  ({ sender }: { sender: CustomPlayer }) => {
    const availableCapes = Capes.getCapeListForPlayer(sender);

    const form = new ActionFormData();
    form.title(`${mainConfig.mainColor}Β§oCapes`);

    // "None" cape should always be shown first
    form.button(availableCapes[0].displayName || availableCapes[0].identifier);

    form.divider();
    form.label("Β§9Teams Capes");

    // team capes
    const teamCapes = availableCapes.slice(1).filter((cape) => cape.lockToFaction);
    teamCapes.forEach((cape) => {
      form.button(cape.displayName || cape.identifier);
    });

    form.divider();
    form.label("Β§9Other Capes");

    // rank-based etc.
    const otherCapes = availableCapes.slice(1).filter((cape) => !cape.lockToFaction);
    otherCapes.forEach((cape) => {
      form.button(cape.displayName || cape.identifier);
    });

    const runId = system.runInterval(async () => {
      const response = await form.show(sender.player);

      if (!(response.cancelationReason === FormCancelationReason.UserBusy)) {
        system.clearRun(runId);

        if (response.canceled || response.selection === undefined) {
          return;
        }

        const selectedCape = availableCapes[response.selection];
        if (selectedCape) {
          sender.player.setProperty("ultra:cape", selectedCape.identifier);

          const capeName = selectedCape.displayName || selectedCape.identifier;
          if (selectedCape.identifier === "none") {
            sender.player.sendMessage(`Β§9Your cape has been deactivated.`);
          } else {
            sender.player.sendMessage(`Β§bCape set to: ${capeName}`);
          }
        }
      }
    });
  }
);
distant gulch
#

Could someone tell me how to fix this? My menu has disabled buttons

random flint
jolly citrus
#

Diagnose my code next plz

distant gulch
#

Hm

fresh current
#

yo

#

quick question man

#

@random flint

#

im watching this scripting video right

pale terrace
#

???

#

did u ping me?

random flint
fresh current
#

and hes says to put " these lines"

#

yea

fresh current
#

so

#

bascially

#

im watching this video

#

and he says to put "theses lines"

#

and it look like this

#

l l

#

idk what it is

#

or how to place them

#

look like 2 l

jolly citrus
random flint
#

you mean these? ||

fresh current
#

ye

#

what is that?

random flint
random flint
#

You might want to use an available forceShow to see how it works. There's reason its using custom interval like while (true) instead of the built-in system.runInterval

jolly citrus
sterile epoch
#

I remember hearing a while ago that mojang is changing the way permissions work, is this true?

random flint
jolly citrus
#

I take disrespect in that

random flint
#

So, you know what you're doing? Okay, you must be good then πŸ‘

random flint
# jolly citrus Indeed I am

Instead of runInterval to tries to attempt and force the form, its commonly done like this:

async function forceShow(player,ui) {
    while (true) {
        const respond = await ui.show(player);
        if (respond.cancelationReason !== "UserBusy") 
        return respond;
    }
}

In your code, you can potentially do it like these:

const r = await forceShow(player,ui);

or

forceShow(player,ui).then(r=>{})```
#

That's my diagnosis while Im typing this on my phone at 1 AM midnight 😊

random flint
# fresh current what is that?

Sorry, got too hooked up on a stranger getting offended.

Maybe check this link:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR

MDN Web Docs

The logical OR (||) (logical disjunction) operator for a set of operands
is true if and only if one or more of its operands is true. It is typically used with
boolean (logical) values. When it is, it returns a Boolean value. However,
the || operator actually returns the value of one of the specified
operands, so if this operator is used with non...

jolly citrus
thorn flicker
#

alr lets not

random flint
jolly citrus
thorn flicker
#

average script beef forming

sterile epoch
#

I remember hearing a while ago that mojang is changing the way permissions work, is this true?

jolly citrus
#

Idk why you even bothered to say something that you hopefully clearly knew could potentially offend someone

jolly citrus
#

Anyway I already implemented my own fix

const _ = () =>
      form.show(sender.player).then((response) => {
        if (!(response.cancelationReason === FormCancelationReason.UserBusy)) {
          world.sendMessage("show success");
          if (!(response.canceled || response.selection === undefined)) {
            const selectedCape = availableCapes[response.selection];
            if (selectedCape) {
              sender.player.setProperty("ultra:cape", selectedCape.identifier);

              const capeName = selectedCape.displayName || selectedCape.identifier;
              if (selectedCape.identifier === "none") {
                sender.player.sendMessage(`Β§9Your cape has been deactivated.`);
              } else {
                sender.player.sendMessage(`Β§bCape set to: ${capeName}`);
              }
            }
          }
        } else {
          world.sendMessage("show fail");
          _();
        }
      });
    system.run(_);
jolly citrus
random flint
#

sorry

jolly citrus
#

It's alright

thorn flicker
sterile epoch
#

I meant like a new permissions system

thorn flicker
#

I dont know.

#

thats not a script question then.

sterile epoch
#

it relates to custom command permission level

random flint
jolly citrus
#

Let's be real the probability of getting an answer to your minecraft inquiries in any of the other channels in this server are low compared to this one

jolly citrus
#

I also sometimes find myself attempting to sneak in a few questions clearly not related to scripts in here

sterile epoch
#

people in this channel just know shit

sterile epoch
thorn flicker
#

mb

sterile epoch
#

Someone said that mojang was changing the way permissions work in bedrock

sterile epoch
random flint
distant tulip
#

what permissions

thorn flicker
#

I am curious though

sterile epoch
#

I can't find the message but I know someone said it at one point

thorn flicker
#

1 person

#

thats it

sterile epoch
#

I mean I js wanted to see if anyone knew more about that

thorn flicker
#

I just sent them that.

random flint
#

forgot to *reply

thorn flicker
#

gega.

sterile epoch
thorn flicker
#

lol

random flint
#

Im so used to microsoft docs, other docs feel weird 😎

thorn flicker
sterile epoch
thorn flicker
#

they dont think so

#

whatever floats their boat

random flint
sterile epoch
random flint
#

The addon I made 😎

thorn flicker
#

which is?

sterile epoch
random flint
#

._.

thorn flicker
#

is that what the addon is called

#

interesting

fresh current
#

yo @random flint

#

import { PlayerInteractWithBlockAfterEvent, PlayerInteractWithEntityAfterEvent, system, WeatherType, world, Entity, EntityTypes, ItemStack } from "@minecraft/server";
import { ActionFormData, MessageFormData } from "@minecraft/server-ui";
import "cc.js";

world.beforeEvents.playerBreakBlock.subscribe(data => {
const player = data.player
world.sendMessage('Poof! ${player.name} broke a block!')
})

world.beforeEvents.chatSEnd.subscribe(data => {
const message = data.message;
const sender = data.sender;
const prefix = '!';
const rankTags = sender.getTags().filter(tag => tag.startsWith('rank:'));
const formattedRanks = rankTags.length > 0
? rankTags.map(tag = tag.replace(/(rank:)/, ' '))
: [ 'Β§bMember' ];

if (message.startsWith(prefix)) return; {} 

data.cancel = true


world.sendMessage('[ ${formattedRanks} ] ${sender.name}: ${message}')

})

world.beforeEvents.chatSEnd.subscribe(data => {
const sender = data.sender;
const message = data.message;
const prefix = '!';

if (message === '${prefix}spawn') { 
data.cancel = true 

system.run(() => {
sender.teleport({ x: -7, y: 65, z: -7 }); 
sender.sendMessage("Β§aTeleported To Spawn Location!");
    })
} else if (message === '${prefix}gmc' || message === '${prefix}gmc') {
    if (!sender.hasTag("admin")) { 
        data.cancel = true;
        sender.sendMessage("Β§gYou do not have permissions to run this command!");
        } else {
        data.cancel = true; 
        const gameMode = message === '$(prefix)gmc' ? "creative" : "survival"; 
        system.run(() => { 
            world.getDimension('overworld').runCommand('gamemode ${gamemode} ${sender.name}');
            sender.sendMessage('Β§aGamemdoe set to ${gameMode} sucessfully!');
        });
    }
}

})

#

its not working

thorn flicker
#

damn

random flint
#

damn

distant tulip
thorn flicker
#

wall of text

random flint
sterile epoch
thorn flicker
sterile epoch
#

it makes 10x easier to read

thorn flicker
#

it does

fresh current
#
import { ActionFormData, MessageFormData } from "@minecraft/server-ui"; 
import "cc.js";

world.beforeEvents.playerBreakBlock.subscribe(data => {
    const player = data.player
    world.sendMessage('Poof! ${player.name} broke a block!')
})


world.beforeEvents.chatSEnd.subscribe(data => { 
    const message = data.message; 
    const sender = data.sender; 
    const prefix = '!';
    const rankTags = sender.getTags().filter(tag => tag.startsWith('rank:')); 
    const formattedRanks = rankTags.length > 0 
    ? rankTags.map(tag = tag.replace(/(rank:)/, ' '))
    : [ 'Β§bMember' ];


    if (message.startsWith(prefix)) return; {} 

    data.cancel = true


    world.sendMessage('[ ${formattedRanks} ] ${sender.name}: ${message}')
})

world.beforeEvents.chatSEnd.subscribe(data => { 
    const sender = data.sender;
    const message = data.message; 
    const prefix = '!';

    if (message === '${prefix}spawn') { 
    data.cancel = true 

    system.run(() => {
    sender.teleport({ x: -7, y: 65, z: -7 }); 
    sender.sendMessage("Β§aTeleported To Spawn Location!");
        })
    } else if (message === '${prefix}gmc' || message === '${prefix}gmc') {
        if (!sender.hasTag("admin")) { 
            data.cancel = true;
            sender.sendMessage("Β§gYou do not have permissions to run this command!");
            } else {
            data.cancel = true; 
            const gameMode = message === '$(prefix)gmc' ? "creative" : "survival"; 
            system.run(() => { 
                world.getDimension('overworld').runCommand('gamemode ${gamemode} ${sender.name}');
                sender.sendMessage('Β§aGamemdoe set to ${gameMode} sucessfully!');
            });
        }
    }
}) ```
jolly citrus
#

with js tag

thorn flicker
#

why send it again

jolly citrus
#
import { PlayerInteractWithBlockAfterEvent, PlayerInteractWithEntityAfterEvent, system, WeatherType, world, Entity, EntityTypes, ItemStack } from "@minecraft/server";
import { ActionFormData, MessageFormData } from "@minecraft/server-ui"; 
import "cc.js";

world.beforeEvents.playerBreakBlock.subscribe(data => {
    const player = data.player
    world.sendMessage('Poof! ${player.name} broke a block!')
})


world.beforeEvents.chatSEnd.subscribe(data => { 
    const message = data.message; 
    const sender = data.sender; 
    const prefix = '!';
    const rankTags = sender.getTags().filter(tag => tag.startsWith('rank:')); 
    const formattedRanks = rankTags.length > 0 
    ? rankTags.map(tag = tag.replace(/(rank:)/, ' '))
    : [ 'Β§bMember' ];


    if (message.startsWith(prefix)) return; {} 

    data.cancel = true


    world.sendMessage('[ ${formattedRanks} ] ${sender.name}: ${message}')
})

world.beforeEvents.chatSEnd.subscribe(data => { 
    const sender = data.sender;
    const message = data.message; 
    const prefix = '!';

    if (message === '${prefix}spawn') { 
    data.cancel = true 

    system.run(() => {
    sender.teleport({ x: -7, y: 65, z: -7 }); 
    sender.sendMessage("Β§aTeleported To Spawn Location!");
        })
    } else if (message === '${prefix}gmc' || message === '${prefix}gmc') {
        if (!sender.hasTag("admin")) { 
            data.cancel = true;
            sender.sendMessage("Β§gYou do not have permissions to run this command!");
            } else {
            data.cancel = true; 
            const gameMode = message === '$(prefix)gmc' ? "creative" : "survival"; 
            system.run(() => { 
                world.getDimension('overworld').runCommand('gamemode ${gamemode} ${sender.name}');
                sender.sendMessage('Β§aGamemdoe set to ${gameMode} sucessfully!');
            });
        }
    }
})
#

There

#

change to .chatSend

thorn flicker
#

more wall of text

distant tulip
#

what is chatSEnd

sterile epoch
thorn flicker
jolly citrus
#

Also It would help if you told us what part of it does not work

sterile epoch
#

this one is no longer beta

jolly citrus
#

So we know what part we should look at

fresh current
#

when im typing in game

thorn flicker
#

chatSend is beta.

fresh current
#

it doesnt pop up as member

random flint
sterile epoch
thorn flicker
sterile epoch
#

I was joking

distant tulip
#

how is that a joke, lol

thorn flicker
#

I got minato's joke but the beta joke did not make sense

sterile epoch
#

are we deadass

thorn flicker
#

sometimes there's a miss, its fine bro

distant tulip
#

i mean, if he didn't see the follow up you will find him latter saying that he heard it from one guy

sterile epoch
#

I said "this one"

#

whatever ion even care

fresh current
#

yea

thorn flicker
random flint
#

I like your joke 😊

thorn flicker
#

im so slow

#

too slow

fresh current
#

yo @random flint

#

can you help me fix this rq

sterile epoch
fresh current
#
import { PlayerInteractWithBlockAfterEvent, PlayerInteractWithEntityAfterEvent, system, WeatherType, world, Entity, EntityTypes, ItemStack } from "@minecraft/server";
import { ActionFormData, MessageFormData } from "@minecraft/server-ui"; 
import "cc.js";

world.beforeEvents.playerBreakBlock.subscribe(data => {
    const player = data.player
    world.sendMessage('Poof! ${player.name} broke a block!')
})


world.beforeEvents.chatSEnd.subscribe(data => { 
    const message = data.message; 
    const sender = data.sender; 
    const prefix = '!';
    const rankTags = sender.getTags().filter(tag => tag.startsWith('rank:')); 
    const formattedRanks = rankTags.length > 0 
    ? rankTags.map(tag = tag.replace(/(rank:)/, ' '))
    : [ 'Β§bMember' ];


    if (message.startsWith(prefix)) return; {} 

    data.cancel = true


    world.sendMessage('[ ${formattedRanks} ] ${sender.name}: ${message}')
})

world.beforeEvents.chatSEnd.subscribe(data => { 
    const sender = data.sender;
    const message = data.message; 
    const prefix = '!';

    if (message === '${prefix}spawn') { 
    data.cancel = true 

    system.run(() => {
    sender.teleport({ x: -7, y: 65, z: -7 }); 
    sender.sendMessage("Β§aTeleported To Spawn Location!");
        })
    } else if (message === '${prefix}gmc' || message === '${prefix}gmc') {
        if (!sender.hasTag("admin")) { 
            data.cancel = true;
            sender.sendMessage("Β§gYou do not have permissions to run this command!");
            } else {
            data.cancel = true; 
            const gameMode = message === '$(prefix)gmc' ? "creative" : "survival"; 
            system.run(() => { 
                world.getDimension('overworld').runCommand('gamemode ${gamemode} ${sender.name}');
                sender.sendMessage('Β§aGamemdoe set to ${gameMode} sucessfully!');
            });
        }
    }
})
thorn flicker
random flint
thorn flicker
#

also might as well migrate to custom commands instead of chatsend.

#

both are in beta

fresh current
#

its not

#

i already fixed that

thorn flicker
#

the code you sent doesnt reflect that

random flint
thorn flicker
random flint
#

both have unique pros and cons

random flint
# thorn flicker and what are these limitations that would lead you to use chatSend instead?

Well, custom command is good for basic commands. And helps show what argument should be filled. And what it does from the description.
You can't really change the enum dynamically or have subcommands. typing spaces on the string argument require you to type quotation marks "bob fish"

ChatSend is more the freedom alternative. Thought it would lack the tooltip or autocompletion.

finite totem
#

how can i get the highest score in the scoreboard using scripts?

fallow minnow
#

idk

finite totem
# thorn flicker get the objective and use the getScores method.

like this?

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

world.afterEvents.entityDie.subscribe(event => {
    if (event.deadEntity.typeId !== "minecraft:warden") return;
    const player = event.damageSource.damagingEntity;
    if (player?.typeId !== "minecraft:player") return;
    player.runCommand("scoreboard players set @s wardenDefeated 1")
})

system.runInterval(() => {
    let setWardenDead = 0;
    for (const player of world.getAllPlayers()) {
        if (player.getScores(wardenDefeated) > setWardenDead) {
            setWardenDead = 1
        }
    }
})
thorn flicker
finite totem
#

oh

#

i think i got this now though

thorn flicker
#

world.scoreboard

finite totem
#

and check what it was if possible

finite totem
prime zenith
#

i need some ideas ```// cobblestone
// - common: stone table, gravel, gem table
// - uncommon: iron nugget, gold nugget
// - rare: diamond
// - lore: lost lore

// red sand
// - common: cactus, terracotta (random mesa colors 1–25)
// - uncommon: bones, sand table

// clay
// - common: bricks, flower pot
// - uncommon: slimeball, ink sac
// - rare: painting
// - legendary: ancient pottery loot table

// cobbled deepslate
// - common: coal, cobblestone
// - uncommon: redstone dust, lapis
// - rare: amethyst shard
// - legendary: echo shard

// soul sand / soul soil
// - common: bone
// - uncommon: nether wart
// - rare: ghast tear, soul torch, dried ghast
// - legendary: wither skeleton skull, soul relic

// podzol
// - common: sapling table

// mycelium
// - common: mushroom table
// - legendary: mooshroom spawn egg

// mud
// - common: clay ball, dirt
// - uncommon: wheat seeds, fern
// - rare: leather
// - legendary: muddy pig spawn egg, swamp totem

// moss_block
// - common: moss carpet, azalea
// - uncommon: glow berries, vines
// - rare: spore blossom
// - legendary: flowering azalea tree, ancient druid relic

// netherrack
// - common: gold nuggets, glowstone dust
// - uncommon: quartz
// - rare: ruby, fire charge
// - legendary: demon horn, nether relic

// magma_block
// - common: gold nugget, lava bucket
// - uncommon: fire charge
// - rare: blaze rod, magma cream, nether brick
// - legendary: blaze spawn egg, inferno core

// end_stone
// - common: end rod, chorus fruit
// - uncommon: purpur block
// - rare: ender pearls, shulker shells, dragon breath
// - legendary: end table, void crystal, dragon egg fragment

prime zenith
#

anyone even here

#

like ive seen down times at night but this is dead dead during the day

tender pier
#

does anyone know how to fix the last part of my code ? I'm tryin to get the blocks above to update the at the same time i interact with other blocks, like if they were connected

#

I'm so lost rn

prime zenith
#

I have done it my pack if you kill an axolotl you will spend the rest of eternity or until you keave that world in the nether

jolly citrus
#

And i think you’d have better luck asking in #off-topic

#

or really anywhere else

granite cape
prime zenith
#

@jolly citrus i need ideas to fill out the loot table for those to fill up alchemy skill

wary edge
#

That seems like a general #add-ons not a scripting specific question.

prime zenith
#

Its done with script but its ideas

plucky light
#

Is there an event I can subscribe to that helps me know when a player has intereacted with a villager? itemUse won't tell me which villager

thorn flicker
plucky light
#

thanks

sterile epoch
#

is btoa / atob supported in the api

prime zenith
#

@sterile epoch hey whats up

sterile epoch
#

hi

prime zenith
#

I made my forced eternal nether for ppl who kill an axolotl

prime zenith
#

How do i get a loot table to drop a written book that i custumized

prisma shard
prisma shard
#

idk

sterile epoch
#

(tamed)

#

also

#

is btoa / atob supported in the api

prisma shard
#

btoa??

#

what is atob?

#

atom bomb?

sterile epoch
#

a built in function that converts text to base 64 I want to use it for an encrypter

prisma shard
#

what

#

bro please dont flood

prime zenith
#

a news post villagers just posted

#

stop calling me bro please

halcyon phoenix
#

sir this is #1067535608660107284 this doesn't relate to scripting at all

prime zenith
#

Im not a sir

prisma shard
#

ok ma'm

prime zenith
#

@prisma shard that person did it deliberatly to attack me i blocked it

prisma shard
#

what>

dusky flicker
dusky flicker
#

actually i dont know the need of saving data in base64, i dont think you will be able to send to some where that enforces utf8 or some other encoding than utf16(js builtin)

halcyon phoenix
#

talk about offense

prime zenith
dusky flicker
prime zenith
#

You replied to me

dusky flicker
#

is that an argument?

prime zenith
#

You replied to me with no context so

dusky flicker
#

think whatever you want. ur life is yours idc

#

im not going to waste my time

prime zenith
#

Someone i knew online took her life due to bullying so im not in a good mood right now

prisma shard
#

jeez

dusky flicker
#

good times

prime zenith
#

Im blocking that is not ok

prisma shard
#

you need to calm down

sterile epoch
#

easy peasy yeah

dusky flicker
sterile epoch
#

idk probably

#

but asking chatgpt is easier

dusky flicker
#

as i only code with ts i prefer using it and bundling the file

sterile epoch
prime zenith
#

@sterile epoch how are you doing

dusky flicker
#

but why do you need base64, by the way?

#

isnt there some specific part of the code to look at?

sterile epoch
sterile epoch
dusky flicker
#

anyone can get the data

sterile epoch
#

ascii character safety

prime zenith
#

Wanna work on hrand exchange tommorrow @sterile epoch

halcyon phoenix
#

is there a beforeevent for entityHurt?

shy leaf
#

πŸ˜”

halcyon phoenix
#

welp

tardy pivot
leaden elbow
onyx lantern
#

is it possible to detect if a block is waterlogged?

halcyon phoenix
#

block.isWaterlogged

prime zenith
halcyon phoenix
onyx lantern
onyx lantern
halcyon phoenix
#

oh wait

#

yes

#

you need to

onyx lantern
#

does ticking causes a lot of lag?

halcyon phoenix
#

it depends on what you do inside that ticking

#

I only use runInterval as I can manipulate when will it check

onyx lantern
#

I was told to avoid runInterval

halcyon phoenix
onyx lantern
#

But is it really any better than ticking?πŸ€”

halcyon phoenix
#

it's the same I guess

#

but you don't need to mind that

onyx lantern
#

I think maybe making runInterval async could give some advantage

halcyon phoenix
#

what matters is what you do inside of it

distant tulip
#

Async is not always good for performance

sly valve
#

runJob is better instead

halcyon phoenix
#

oh yeah runJob exists too

distant tulip
#

Well, still depends

sly valve
#

I think its peak

distant tulip
#

Just need to make each job not resource expensive

sly valve
#

Shouldnt be a big matter

halcyon phoenix
distant tulip
#

It is
runJob is useless if each job is causing lag

sly valve
#

Yes, I use runJob for my Custom Chunk Generators and its the best thing ive done

distant tulip
#

Yeah, it is the best in handling heavy tasks

halcyon phoenix
#

should I do runJob for my maze generator?

distant tulip
#

Yeah

halcyon phoenix
#

how would i know the difference?

distant tulip
#

Different between?

halcyon phoenix
#

in performance

#

is there any tool that measures lag?

distant tulip
#

If you are in pc use the debugger

halcyon phoenix
#

the extension in vsc?

distant tulip
#

Yeah

halcyon phoenix
#

alright

dusky flicker
#

and keep things running