#Script API General

1 messages · Page 84 of 1

distant tulip
#

use replaceitem command

gilded shadow
#

and how to specify which entity?

#

nvm

distant tulip
#

replaceitem entity @s

#

entity.runCommand(👆)

gilded shadow
#

thanks

inland oracle
#

oh okay my bad i havent looked into entities i just assumed because in the enum i was looking earlier and seen in the equipment slot enum

distant tulip
inland oracle
#

oh i wonder if its a planned feature in beta, as the body enum was added to beta

distant tulip
#

probably, there is also some stuff that work on entities and not player
like applyImpuls and clearVelocity, both have been added to the player in the last preview

amber granite
#

How to make player double jump

prisma shard
jolly citrus
#

to make my code flow better & easier to manage i've set up a system where i globally store the necessary data extracted from dynamic properties on my world in their own variables & then make any updates during runtime to that variable, and autosave this data back to the dynamic property every 30 seconds

but i have an issue i'm worried about, what happens if the world crashes or i forget to run some form of save command (whatever i decide to set up) before leaving the world? how do i protect the data against these cases

#

is there any sort of event that can be listened for when the player saves & quits the world

fresh current
#

yo @fallow carbon can you help me fix the code now?

prisma shard
#

proof (1) - he always pings him like that

#

proof (2)

#

i mean bruh

prisma shard
fresh current
#

nah he was helping me put a file into vs

#

code

#

and he told me to wait till later

#

so thats why i pinged him

jolly citrus
#

can i make available command parameters change depending on what the other parameters inputted by the user are

jolly citrus
#

can command names include spaces

warm mason
woven loom
#

no

jolly citrus
woven loom
#

no

jolly citrus
#

Smh

#

Ts command system suck im going back to my chat based commands

woven loom
#

why u need that

jolly citrus
#

Faction commands

#

Warp commands

#

/f home /f sethome

woven loom
#

what ur looking for is sub commands

jolly citrus
woven loom
#

not yet

jolly citrus
#

Will they

woven loom
#

but u can mimic that

woven loom
jolly citrus
woven loom
#

use enums

jolly citrus
#

In what way will i make use of enums here

woven loom
#

sub cmds

jolly citrus
#

Telling me to use enums isnt very helpful mate sorry theres so many kinds

woven loom
#

in ctx of cmds theres only one

#

check docs

jolly citrus
#

ohhh

#

registerEnum ?

woven loom
#

ye

urban cairn
#

well enums aren't great if your subcommands need different parameters

jolly citrus
#

So is this just for like

jolly citrus
#

aliases

urban cairn
#

because you can't change the next parameter if you change enum

#

like lets say you want /f home <number> and /f create <string> then that wont work

#

obviously you wont have home as a number but you get what i mean

#

the best way of doing it for now i'd probably say just do something like /f:claim, f:home, etc..

random flint
urban cairn
random flint
wary edge
#

Ugh, - and not _

jolly citrus
#

Namespaces themselves being required in commands is unconventional

#

Custom commands as they are now arent any better than custom chat based command systems

#

Icl

urban cairn
#

the annoying thing rn is in preview it does hide the namespace but it also shows the namespace.. hopefully we'll be able to hide them with a flag or something

#

like when doing name: 'f:claim' it'll show both /f:claim and /claim in chat

woven loom
#

Simply use a single parameter and parse it like you would with chat commands.

random flint
#

The custom command pros: auto close chat 👍

jolly citrus
#

that's like the biggest benefit that slash commands bring to user experience

woven loom
#

Ur wish

jolly citrus
#

being able to automatically fill in info and see what it's actually used for

random flint
jolly citrus
prisma shard
#

several people are typing... ahhh nostalgia. this channel used to be so active

urban cairn
#

the only reason why you would want to use /commands if you continue to do it like is so that chat automatically closes for you

random flint
woven loom
#

It won't register

urban cairn
#

is it with the same identifier? i thought it was if the identifier and the command name already exists

random flint
woven loom
#

IG is based on order in setting.

urban cairn
#

i kinda wish we could have been able to modify existing commands so that we could disbale /me and shit or at least just be able to do something like .unregisterCommand or something

distant tulip
#

why

urban cairn
#

why what?

#

unregistering?

distant tulip
#

yeah

urban cairn
#

the abuse that comes from /me and /say is so bad

random flint
#

Custom Command

  • pros: Auto completion, description, close the chat.
  • cons: limited typing rules.

Chat Command

  • pros: fweedom
  • cons: need memorization, can't close chat.
distant tulip
urban cairn
#

yeah but not everyone uses custom servers or know how to disable commands if not done already

wary edge
#

Custom command and chatSend both have pros and cons. It is up to you and your userbase to decide which one to use

urban cairn
#

plus I'm more used to sticking with vanilla server anyway

#

the only server software i ever managed to use was bdsx

#

and it doesn't look like that's coming back anytime soon

#

i would use something like serenity but that's missing a lot of survival features and their api isn't user friendly. then endstone is in python.. (i don't know python or c++)

#

i wanted to look into making my own bds-based server software while hooking into the server and modifying the packets myself but i don't enough yet and i don't even want to think about messing with raknet and everything else for custom bds software

simple zodiac
urban cairn
#

There's a commands.json file?

#

Never seen that before

simple zodiac
#

Well you have to add it yourself

#

#1043783205096009768 message

#

#937091818603048971 message

urban cairn
#

oh shit, thanks for letting me know about that!

#

wish i had knew about this sooner

fallow rivet
#

Is it possible for me to test if the player presses any of these buttons?

wary edge
fallow rivet
#

Hmm

fallow rivet
#

Is this possible?

wary edge
fallow rivet
#

Controlscheme?

wary edge
#

New command.

fallow rivet
#

Hmm

#

Ok thanks

fallow rivet
wary edge
#

I suggest reading the docs and playing around.

halcyon phoenix
#

projectiles are entities right?

dusky flicker
gaunt salmonBOT
cold grove
#

oops

steady canopy
#

Actually, you can.

Detect item spawning on entitySpawn, set a dynamic property with the current Date.now() on the entity.

#

is that in the minecraft stable?

finite totem
#

how do i check for a left click using scripting?

winged gull
#

if they click the air, you can't detect it

uncut sail
#
{ 
  "format_version": "1.21.80",
  "minecraft:block": {
    "description": {
      "identifier": "um:storge",
      "menu_category": {
        "category": "construction"
      }
    },
    "components": {
      
          "minecraft:display_name": "Storage Controller"
    },
        "minecraft:tick": {
    "interval_range": [
        20,
        20
    ]
},
    "um:tick": {},
    "um:try": {
    }
  }
}

My block code

system.beforeEvents.startup.subscribe(e => {
  e.blockComponentRegistry.registerCustomComponent("um:try", {
    onTick: (even, pera) => {
            const { block, dimension } = event;
            
             world.sendMessage("hiiii")
        }
    })
})

SCRIPT

This code don't work. How can i fix this script or block json

winged gull
uncut sail
winged gull
#
{ 
  "format_version": "1.21.80",
  "minecraft:block": {
    "description": {
      "identifier": "um:storge",
      "menu_category": {
        "category": "construction"
      }
    },
    "components": {
      
          "minecraft:display_name": "Storage Controller",
        "minecraft:tick": {
    "interval_range": [
        20,
        20
    ]
},
    "um:tick": {},
    "um:try": {
    }
}
  }
}
#

you will have to fix the spacing though lol

winged gull
# uncut sail

Maybe change format_version to 1.21.70 or something?

uncut sail
#

1.21.80

#

Game version 1.21.81.2

winged gull
#

do you have the custom components v2 experimental toggle enabled?

winged gull
wary edge
#

CC v2 requires 1.21.80 or higher.

winged gull
#

then maybe he forgot the experimental toggle

uncut sail
winged gull
#

wait

#

I see issue

uncut sail
#
{
    "format_version": 2,
    "header": {
        "name": "custom component",
        "description": "Unknown Mcpe YT",
        "min_engine_version": [
            1,
            21,
            80
        ],
        "uuid": "5bc601a6-cb6f-11ef-9cd2-0242ac120222",
        "version": [
            1,
            0,
            0
        ]
    },
    "modules": [
        {
            "type": "data",
            "uuid": "65456f64-cb6f-11ef-9cd2-0242ac120222",
            "version": [
                1,
                0,
                0
            ]
        },
        {
            "type": "script",
            "language": "javascript",
            "uuid": "6f4e8fea-cb6f-11ef-9cd2-0242ac120222",
            "entry": "scripts/main.js",
            "version": [
                1,
                0,
                0
            ]
        }
    ],
    "dependencies": [
  {
    "uuid": "dd302710-e8d0-44b4-82ff-96da6bbc2222", 
    "version": [1, 0, 0]
  },
  {
  "module_name": "@minecraft/server",
  "version": "2.0.0-beta"
}
]
}
winged gull
#

you forgot to register the um:tick component

winged gull
#

what could gega be spending so long typing lol

random flint
# uncut sail

Have you tried, copying, deleting, pasting, and pasting again (replacing)?
-# It refreshes the file. Android often has a weird bug where file often don't register their existence to Minecraft

uncut sail
winged gull
winged gull
prisma shard
prisma shard
# fallow rivet Is it possible for me to test if the player presses any of these buttons?
system.runInterval(() => {
    for (const player of world.getPlayers()) {
        const inputInfo = player.inputInfo;
        const movement = inputInfo.getMovementVector();

        const normalizedX = Math.abs(movement.x) > 0.2 ? Math.sign(movement.y) : 0;
        const normalizedY = Math.abs(movement.y) > 0.2 ? Math.sign(movement.y) : 0;

        if (normalizedY > 0) console.error('forward');
        else if (normalizedY < 0) console.error('backward');

        if (normalizedX > 0) console.error('left');
        else if (normalizedX < 0) console.error('right');
    }
});
#

world.afterEvents.playerButtonInput.subscribe((event) => {
    const player = event.player;
    const button = event.button;
    const button_state = event.newButtonState;

    // Detect when the player presses the Jump button
    if (button == "Jump" && button_state == "Pressed") {
        player.runCommand("say jump");
    }

    // Detect when the player presses the Sneak button
    if (button == "Sneak" && button_state == "Pressed") {
        player.runCommand("say sneak");
    }
});```
#

You can ofcourse detect clicking these buttons.

#

Not sure why Smokey said "No"

wary edge
#

That is movement, not directly clicking the button. You cannot tell if its WASD or touchscreen.

prisma shard
#

hmm

halcyon phoenix
#

what's the most optinal coordinates for a pseudo-dimension?

wary edge
halcyon phoenix
#

oh my bad

rose light
#

Does anyone have a function that returns true if it finds a block between two vector3 coordinates?

fallow rivet
#

Is it possible to change the direction the player is looking?

ivory bough
#

How to change the player's camera to face an entity?

thorn flicker
#

entity.setRotation() does not work on players

thorn flicker
#

in the teleport method, there's a facingLocation property

ivory bough
thorn flicker
#

the entity location.

fallow rivet
thorn flicker
fallow rivet
fallow rivet
fallow rivet
#

How can I fix this?

thorn flicker
#

you cannot fix that.

fallow rivet
fast lark
#

Hi

#

Someone has the chest ui without inventory made by herobrine?

#

I dont find the github

proud saddle
#

so
applyImpulse is valid for player now but doesn't work properly

proud saddle
finite totem
#

do you mind sending th script part that does that

bold stratus
#

how do I make script when player join then gave them "Joined" tag

warm mason
distant tulip
#

add initialSpawn there

#

it doesn't matter, but better than running a code when not needed

warm mason
distant tulip
#
import { world } from '@minecraft/server';

world.afterEvents.playerSpawn.subscribe((event)=>{
    if(!event.initialSpawn) return
    event.player.addTag('Joined')
})
#

it is not

#

you are running hasTag on a player that already have it, that what pointless

warm mason
#

You'll have to check for the tag anyway, so initialSpawn is useless.

distant tulip
#

this come to what is he faster check initialSpawn or hasTag
one is a property that the event already have the other is a function that you are getting data from

#

so i would say that initialSpawn is better for this case

warm mason
distant tulip
#

well, my point still stand no matter how small the result is

jolly citrus
#

is there a limit of how many dynamic properties a world can have

finite totem
finite totem
warm mason
#

Do you need to run the code only the first time a player joins or every time?

finite totem
#

are scoreboards persistent?

warm mason
finite totem
#

would that affect scoreboards or no

finite totem
warm mason
# finite totem ig i could do every time
import { world } from '@minecraft/server';

world.afterEvents.playerSpawn.subscribe((event)=>{
    if (!event.initialSpawn) return;
    const player = event.player
    // code
})
proud saddle
warm mason
finite totem
#

i also dont know how to make the code run mcfunctions

#

since ive never done scripting

warm mason
# finite totem i wanted it to run a mcfunction that initializes many scoreboards for the player...
import { world } from '@minecraft/server';

const scoreboards = [
  "score1",
  "score2",
  "asdhajsdh"
]

world.afterEvents.playerSpawn.subscribe((event)=>{
  if (!event.initialSpawn) return;
  const player = event.player
    
  for (let scoreName of scoreboards) {
    const score = world.scoreboard.getObjective(scoreName) || world.scoreboard.addObjective(scoreName)
    if (score.getScore(player) == undefined) score.addScore(player, 0)
  }
}
inland oracle
#

I wish the new destruction particle component system would just fall back on the block texture if a custom one isnt provided because to add different particle texture and block textures on each permutation is alot longer lol

shrewd relic
#

any existing posts regarding updating durability when the item gets used? thanks in advance

finite totem
# warm mason https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/i...

for the repeating commands, would i have to do that in a script where it runs a function each tick or is there just a way to do repeating in mcfunctions?

#repeat
titleraw @a[hasitem={item=genb10:iron_battleaxe_cooldown,location=slot.weapon.mainhand}] actionbar {"rawtext":[{"text":"Cooldown: "},{"score":{"name":"*","objective":"iron_battleaxe_cd"}}]}

#chain
execute as @a unless entity @s[scores={iron_battleaxe_cd=0..}] run scoreboard players set @s iron_battleaxe_cd 0
# make sure that this checks for left click instead of crouch
execute as @a[hasitem={item=genb10:iron_battleaxe,location=slot.weapon.mainhand},scores={iron_battleaxe_cd=0}] at @s unless entity @s[y=~1.5,dy=0] run scoreboard players set @s iron_battleaxe_cd 1.1
execute as @a[hasitem={item=genb10:iron_battleaxe,location=slot.weapon.mainhand},scores={iron_battleaxe_cd=1.1}] at @s run replaceitem entity @s slot.weapon.mainhand 0 genb10:iron_battleaxe_cooldown
execute as @a[scores={iron_battleaxe_cd=1.1}] at @s run playsound mace.smash_air @a[r=15]
scoreboard players set @a[scores={iron_battleaxe_cd=1.1}] iron_battleaxe_cd 1

#repeat every 2 ticks
scoreboard players add @e[scores={iron_battleaxe_cd=0.1..}] iron_battleaxe_cd -0.1
jolly citrus
proud saddle
jolly citrus
proud saddle
jolly citrus
#

that’s the maximum that can be saved during yield of 1 tick ?

jolly citrus
#

That’s plenty

#

I can make it spread the save process i have set up throughout multiple ticks anyway

proud saddle
#

not per tick

jolly citrus
#

Huh

#

Ok

#

Where does that limit even come from bro

#

What is supposed to prevent us from saving 21mb of data in a single minute’s time

proud saddle
jolly citrus
#

Oh

#

Maybe that’s ab it of a problem then

#

Autosaving every 30 secs

#

I store player and faction data on rhe world so

#

Im not sure it would ever exceed 10mb but itd suck if it does

inland oracle
#

why dont you just use custom json file then you dont have those limits

bold stratus
#

where can I learn scripting? since youtube tutorial always using old version

jolly citrus
#

can it now

jolly citrus
#

Why are you sending a whole essay in script api general

#

Ok not anymore

inland oracle
jolly citrus
jolly citrus
#

Last time I checked it cant access

inland oracle
dim tusk
#

Hello I'm back.

halcyon phoenix
#

is there any way to stop left click or prevent it? like a weapon hit?

halcyon phoenix
halcyon phoenix
dim tusk
dim tusk
halcyon phoenix
#

what if I tp it on itself before the knockback applies

halcyon phoenix
dim tusk
halcyon phoenix
#

Oh lol

#

welp all hope is lost

dim tusk
halcyon phoenix
# dim tusk bad.

welp as long as you're moving don't stop and keep going, things will get better

warm mason
halcyon phoenix
warm mason
halcyon phoenix
#

or hit

warm mason
winged gull
halcyon phoenix
winged gull
warm mason
winged gull
#

so more than you said

#

if the player has a ton of tags, it might take even longer

warm mason
winged gull
#

try with the maximum number of tags

#

use a script to add a ton of random tags to yourself

#

so you hit the tag limit

#

then test it

#

and see how long it takes

warm mason
winged gull
#

if you have enough players online, that could be a HUGE problem

#

I know because I have ran a dedicated server

#

when you have 20 players online, it has very little room for overhead

#

so 2 MS could cause a small lag spike

#

then if a bunch of people join at once it will cause a big lag spike

#

2 MS is A LOT in terms of scripts

warm mason
#

-_-

winged gull
#

since if the total of Minecraft + scripts is more than 50 MS, you get lag

#

the further above 50 MS it goes, the more lag you have

#

you should ALWAYS try to AVOID that kind of lag whenever possible

warm mason
#

If it was in some interval or frequently called event I would understand. But it is in playerSpawn. It is not a frequent event.

#

And in his case, he'd be better off abandoning mcfunctions in the first place rather than worrying about, oh my god, 0.008 millisecond slowdowns.

winged gull
#

there file extension is .js, or .ts, NOT .mcfunction

warm mason
# winged gull scripts are NOT mcfunctions

🤯 What I meant was that if he wants to optimize the addon, he first needs to abandon mcfunctions and last of all think about how to optimize the use of ONE method that is called once every 500 years.

winged gull
#

because it will run when not needed

#

while with the event callback it only runs when necessary

warm mason
#

Moreover, this function is not called often.

winged gull
#

just take the small performance improvement bruh

#

if a performance optimization is that easy, just do it 💀

#

that is what I have been trying to get at

warm mason
#

If only it had any effect...

distant tulip
#

It is not about why would you use it when it doesn't save that much performance, it is about why would you not use it.
it may never help but it is the best way of doing things. You don't want to end up with little stuff that's add up over the development time.

deep quiver
#

I always do micro optimisations if they don’t really take long to do and don’t make the code horribly ugly

prisma shard
woven loom
#

You can have up to 128^32k properties.

prisma shard
#

mmm cool

woven loom
#

Which is impossible to reach

prisma shard
jolly citrus
#

So there's no limit

wary edge
#

Virtually no.

jolly citrus
#

Okay thank you

granite badger
woven loom
#

Permutation?

distant tulip
#

128 refer to the chars in ASCII?

woven loom
#

Ye

#

This way, you can utilize all the bytes.

distant tulip
#

what about UTF-8, there is 127 character there that can be stored in 1 byte

jolly citrus
#

Somebody told me about the amount of data you can save to properties in a minute's time is limited to 10mb

#

Can someone confirm this is true

woven loom
#

Yes

jolly citrus
#

Does it like actually hard reset some sort of limit every minute

jolly citrus
#

Why is this mechanism even set up

#

what purpose is it meant to serve

remote oyster
jolly citrus
#

So nothing willa ctually break

#

?

woven loom
#

Cuz ppl like us exists xD

remote oyster
jolly citrus
#

How much lag does saving large amounts of data actually cause

woven loom
#

More data mor elag

jolly citrus
#

If i save two properties length of 32767 bytes every 30 seconds

#

Is that OK

remote oyster
distant tulip
#

we did more than that and it worked fine

jolly citrus
#

16gb ram and decent ssd

remote oyster
jolly citrus
#

not me , the host?

#

If I host a world and others play on it will it affect them

woven loom
#

Clients should be fine ig

jolly citrus
#

I thought it's just on my end

jolly citrus
#

right

remote oyster
jolly citrus
#

Yes so to me that means it doesn't affect them

remote oyster
meager zenith
#

is there an npm package i can install for scripting v2

remote oyster
#

That's just one of them.

meager zenith
#

thank you!

#

I am trying to learn custom compnenets v2 but it isn't working for me

system.beforeEvents.startup.subscribe(e=>{
    e.itemComponentRegistry.registerCustomComponent("ms:bj_dz",{
        onConsume(e)
        {
            const player = e.source;
            const item = e.itemStack;

            const bj = world.scoreboard.getObjective('bjc');
            const bjd = world.scoreboard.getObjective('bjcd');
            bj.addScore(player,1);
            bjd.setScore(player,100);
        }
    });
});
#

it's showing me this error

remote oyster
#

I haven't personally messed with it but I do know there is an experimental setting that needs to be enabled for the World in order to use that

meager zenith
#

yes there is and I have enabled that

#

but it's still not working

remote oyster
#

You have beta API enabled? Your manifest also targets 2.0.0-beta?

meager zenith
#

yes

meager zenith
#

yep

remote oyster
#

Either the manifest is targeting the wrong version or there is an improper import within your script. May need to show both for clarity.

meager zenith
remote oyster
#

That's good.

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

system.beforeEvents.startup.subscribe(e=>{
    e.itemComponentRegistry.registerCustomComponent("ms:bj_dz",{
        onConsume(e)
        {
            const player = e.source;
            const item = e.itemStack;

            const bj = world.scoreboard.getObjective('bjc');
            const bjd = world.scoreboard.getObjective('bjcd');
            bj.addScore(player,1);
            bjd.setScore(player,100);
        }
    });
});
#

idk what else is wrong

open urchin
#

which file is that?

remote oyster
#

That's a bit odd. Your manifest is good and the script is good.

meager zenith
#

berry_juice.js but i have imported it in main.js

open urchin
#

the error is not in that file

meager zenith
#
import "./initial.js";
import "./berry_juice.js";
open urchin
#

it's in initial.js

meager zenith
#

omg i am stupid 😭 , i am so sorry

remote oyster
#

Lol

#

Live and learn

uncut lynx
#

 * @deprecated This class is deprecated and will be removed in 2.0.0.

 *

 * Contains information and methods that can be used at the

 * initialization of the scripting environment for a World.

 */

export class WorldInitializeAfterEvent {

    private constructor();

}

So if that is deprecated in 2.0.0, how do i do this? (I'm so stuck i looked at src code please help)

world.afterEvents.worldLoad.subscribe((event) => {
    world.sendMessage("World has loaded!");
    event.blockComponentRegistry.registerCustomComponent("createbedrock:creative_motor_interaction", CreativeMotorInteractionComponent);
});```
#

i want to use 2.0.0-beta

woven loom
#

system.beforeEvents.startup

uncut lynx
#

Thanks

#

Why is not a singular wiki saying that?

open urchin
#

because they're made for stable

woven loom
#

its hard to maintain

#

almost every release now bring new stuff

uncut lynx
#

Alright then i use the wiki as mild inspiration now? lmao

wary edge
uncut lynx
#

Tell me where

wary edge
#

Quick search.

open urchin
#

You'll have to wait until 1.21.90 releases for info specific to 2.0.0 on the wiki

uncut lynx
#

Also how do i correctly (i am confused by now) apply that custom component to block

#

if "minecraft:custom_components" is deprecated

sour sedge
uncut lynx
#

And the doc is saying that "minecraft:custom_components" is a way to go

#

while bridge v2 is saying otherwise

#

and to finish it, nothing of the custom component besides registering works

#

oh yeah mc is saying it is deprecated too

#

NOW it worked

#

so they deprecated it...

#

without anything to replace it to

#

obviously

remote oyster
uncut lynx
#

... how do i use those?

remote oyster
#

Requires the experimental setting to be enabled. For scripting it requires v2.0.0 and Beta API

uncut lynx
#

... alright but what do i write in "components" field

#

(Or whatever the V2 uses)

remote oyster
#

I'm honestly unsure. I haven't touched it personally so maybe someone familiar with it can answer you.

wary edge
uncut lynx
#

Ohhh

open urchin
#

you need to give the component a value, could just be an empty object
"createbedrock:creative_motor_interaction": {}

uncut lynx
#

ok i'mma try that in an hour

#

gtg

short iron
#

Is there a way to detect if a player unlocks a recipe? Asking for a friend 😅

echo tinsel
#

why am i getting this error
[Scripting][error]-SyntaxError: exported variable 'getPrimaryEquippedHat' does not exist

[Scripting][error]-Plugin [Just Cosmetics - 1.0.0] - [main.js] ran with error: [SyntaxError: exported variable 'getPrimaryEquippedHat' does not exist]

i've searched my whole addon for getPrimaryEquippedHat to triple check its not anywhere else and its not

short iron
#

Did you export getPrimaryEquippedHat?

#

@echo tinsel

uncut lynx
#

Also how do i store some sort of info block-wise

wary edge
echo tinsel
uncut lynx
finite totem
#

i have this mcfunction that runs every tick and it causes lag so i hate it. How would i make a script to check if execute as @a[hasitem={item=genb10:iron_battleaxe,location=slot.weapon.mainhand},scores={iron_battleaxe_cd=0}] at @s unless entity @s[y=~1.5,dy=0] is true, it runs the mcfunction?

#

hopefully the lag is reduced since it only checks one thing every tick instead of many

wary edge
short iron
#

@echo tinsel I don't see anything like export { getPrimaryEquippedHat }; or export in front of any of your functions

uncut lynx
wary edge
# uncut lynx Alright please tutor me onto this

You just have to learn serialization really. #1067535712372654091 should have some examples from past works. The gist of it is you place said block or whatever and you make the coordinates the key and then the value is a json object with whatever you need.

uncut lynx
#

I want form slider to modify the said data

echo tinsel
#

im actually going crazy cause i tried to just remove it but appearantly i am still calling for it somewherem but its not happy when i export it eitehr

#

holy typos batman

short iron
#

Yeah something is trying to "import" it so its asking for the export

echo tinsel
#

ive used the search to search for it anywhere else and no where else has it.

finite totem
#

i have this mcfunction that runs every tick and it causes lag so i hate it. How would i make a script to check if execute as @a[hasitem={item=genb10:iron_battleaxe,location=slot.weapon.mainhand},scores={iron_battleaxe_cd=0}] at @s unless entity @s[y=~1.5,dy=0] is true, it runs the mcfunction?

sterile epoch
# finite totem i have this mcfunction that runs every tick and it causes lag so i hate it. How ...
import { system, world } from "@minecraft/server";

system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        if (player.isSneaking) continue;

        const sb = world.scoreboard.getObjective("iron_battleaxe_cd");
        const score = sb?.getScore(player);
        if (score != 0) continue;

        const item = player.getComponent("equippable")?.getEquipment("Mainhand");
        if (item?.typeId != "genb10:iron_battleaxe") continue;

        const { x, z } = player.location;
        const y = player.location.y + 1.5;

        const entityCheck = player.dimension.getEntities({
            location: { x, y, z },
            maxDistance: 0.5
        });

        if (entityCheck.length > 0) continue;

        player.runCommand("function your_function_name");
    }
}, 1);
sterile epoch
finite totem
#

this should run automatically when the world starts too right

sterile epoch
#

yeah

finite totem
#

if i were to add more items with cooldowns, do i need a new file with altered stuff or could i just build off this

sterile epoch
#

you can just build off this

uncut lynx
#

after +1hr i got Modal Form working, now how do i store the per-block info?

hoary matrix
#

guys how to test when a player place a block ?

uncut lynx
#

With custom components

hoary matrix
#

i tried this world.beforeEvents.playerPlaceBlock

uncut lynx
#

Are u using 2.0.0-beta?

hoary matrix
#

no

#

im on 1.19.0

uncut lynx
#

Then i won't help

#

But the guys who helped me are amazing

hoary matrix
#

who ?

uncut lynx
#

Scroll up in this thread

hoary matrix
#

cozmozZz

uncut lynx
#
import { world, system, WorldLoadAfterEvent, GameMode, Player, Block, Direction, Dimension, BlockComponentPlayerInteractEvent } from "@minecraft/server"
import { ModalFormData } from "@minecraft/server-ui"

const CreativeMotorInteractionComponent = {
    onPlayerInteract(event) {
        const player = event.player;
        const block = event.block;
        const face = event.face;
        const faceLocation = event.faceLocation;
        const dimension = event.dimension;

        const CreativeMotorInteractiveUIChangePWMForm = new ModalFormData()
            .title("Change Speed in PWM")
            .slider("Speed in PWM", -255, 255)
            .submitButton("Submit");

        const result = CreativeMotorInteractiveUIChangePWMForm.show(player);
        result.then((value) => {
            if (value.canceled) {
                return;
            }
            else {
                world.getDimension("overworld").runCommand("/say " + value.formValues[0]);
            }
        });

    }
};

system.beforeEvents.startup.subscribe((event) => {
    event.blockComponentRegistry.registerCustomComponent("createbedrock:creative_motor_interaction", CreativeMotorInteractionComponent);
});```
I have this currently
#

Also i'd love to use typescript with bridge. v2

sterile epoch
#

damn why is the form name so long ☠️

uncut lynx
#

idk i like descriptive names

#

either i name stuff "x" or this

sterile epoch
#

also most of those imports are not needed

uncut lynx
#

IK

#

I used typescript

sterile epoch
#

oh

uncut lynx
#

and removed type annotations

#

??????

#

I wanna store the pwm block-wise (maybe with location idk)

shut vessel
#

you know how i can put a cooldown on ender pearl ?

dusky flicker
#

does the engine have weakrefs? i think imma need for dont cause memory leaks

uncut lynx
#

How can i detect block break?

#

like onPlace but for break

distant tulip
uncut lynx
#

yeah

distant tulip
#

onPlayerDestroy

uncut lynx
#

Thanks

#

wait it is onPlayerBreak but whatever i was on stable doc not experimental

round bone
fast lark
round bone
finite totem
# sterile epoch yeah
import { system, world } from "@minecraft/server";

system.runInterval(() => {
    for (const player of world.getAllPlayers()) {

        const item = player.getComponent("equippable")?.getEquipment("Mainhand");

        //Iron Battleaxe
        if (item?.typeId == "genb10:iron_battleaxe") {
            const sb = world.scoreboard.getObjective("battleaxe_cd");
            const score = sb?.getScore(player);


            if (player.isSneaking) continue;
            if (score <= 0) continue;

            const { x, z } = player.location;
            const y = player.location.y + 1.5;

            const entityCheck = player.dimension.getEntities({
                location: { x, y, z },
                maxDistance: 0.5
            });

            if (entityCheck.length > 0) continue;

            player.runCommand("function battleaxe_cooldown");
        }
        player.runCommand("function cooldown_scoreboards");

    }
}, 1000);
sterile epoch
finite totem
sterile epoch
finite totem
sterile epoch
#

it's in creator in the settings, should be like "enable content log gui" (set it to "warn")

sterile epoch
sly valve
#

Guys, should I download it?

valid ice
#

Double it and give it to the next person

sly valve
#

💀

finite totem
# sterile epoch <a:pepecoffee:1345159377895817368>

oookaaayyy

[item][warning]-Item 'genb10:battleaxe_cooldown' has already been overridden by a pack higher in the pack stack!
[Commands][warning]-Function cooldown_scoreboards failed to load correctly with error(s):
[Commands][warning]-Error on line 2: command failed to parse with error 'Syntax error: unexpected "genb10:iron_battleaxe_cooldown" : at "tem={item=>>genb10:iron_battleaxe_cooldown<<,location="'

@sterile epoch

#

i can send all related files if that helps

#

resolved last one

sterile epoch
#

the top error just seems self explanatory

finite totem
#

function cooldown_scoreboards:

scoreboard players add @e[scores={iron_battleaxe_cd=1..}] iron_battleaxe_cd -1
titleraw @a[hasitem={item=genb10:battleaxe_cooldown,location=slot.weapon.mainhand}] actionbar {"rawtext":[{"text":"Cooldown: "},{"score":{"name":"*","objective":"iron_battleaxe_cd"}}]}

#you can ignore this
scoreboard players add @e[scores={thunder_staff_cd=1..}] thunder_staff_cd -1
titleraw @a[hasitem={item=genb10:thunder_staff,location=slot.weapon.mainhand}] actionbar {"rawtext":[{"text":"Cooldown: "},{"score":{"name":"*","objective":"thunder_staff_cd"}}]}
finite totem
sterile epoch
#

since this is just a cool down you might as well make it an actual cool down like enderpearls

#

with the cool down component

sterile epoch
finite totem
sterile epoch
finite totem
#

i provided the code if you could help

sterile epoch
sterile epoch
finite totem
sterile epoch
#

idk then cuz I don't see any syntax errors

finite totem
sterile epoch
#

yh

finite totem
#

can you try my modpack so i know if its a me issue

sterile epoch
#

sure DM me the brproject

plucky light
#

Is there a way to find the biome a block is in? Even if in the beta scripting

uncut lynx
#

how can i query data of some block on x,y,z?

#

for e.g. facing_direction

wary edge
uncut lynx
#

How?

wary edge
#

Block.permutation.getState

uncut lynx
#

Yeah but i want on specific x,y,z

#

not on current

wary edge
uncut lynx
#

i need to be aware of surrounding blocks for my case

#

and theirs states

wary edge
uncut lynx
#

Thanks!!!!!!!!!

#

also i am using 2.0.0-beta

wary edge
#

You can also modify the url to use specific versions.

uncut lynx
#

Oh, thanks

fast lark
#

@wary edge yo smokey

#

You know that server for mcbe commissions?

#

Could you invite me?

snow jungle
#

anyone know how to make a armor stand hold a item?

uncut lynx
#

also how do i break the Block

#

with cmd or what

plucky light
#

What am I doing wrong here? It shows TypeError: not a function. I am using scripting 2.0.0-beta


world.afterEvents.playerSpawn.subscribe((event) => {
  const player = event.player;
  const dim = world.getDimension("overworld");
  const pos = player.location;

  const x = Math.floor(pos.x);
  const z = Math.floor(pos.z);

  const block = dim.getTopMostBlock({ x, z });

  if (block) {
    const y = block.location.y;
    const id = block.typeId;
    console.warn(`[TEST] Top block at (${x}, ${z}) is ${id} at Y=${y}`);
  } else {
    console.warn(`[TEST] No topmost block found at (${x}, ${z})`);
  }
});```
plucky light
winged gull
sterile epoch
#

why does the player selector argument in a custom command not return an array of players

sterile epoch
# remote oyster I thought it did?

nah I'm testing a fling command and it returns each player separately in the args array, so I've had to push them to a new array if it's a player class

#

ts so annoying

remote oyster
#

Hmm, care to share an example?

sterile epoch
# remote oyster Hmm, care to share an example?
registry.registerCommand(flingCmdInfo, ({ sourceEntity: player }, args) => {
        if (!(player instanceof Player)) return;
        console.warn(JSON.stringify(args));
        console.warn(JSON.stringify(args[0]));
        let playerList = [];
        for (const arg of args) {
            if (arg instanceof Player) playerList.push(arg);
        }

        const flingStrength = { low: 1, med: 2, strong: 5 };

        if (playerList.length == 0)
            return { status: CustomCommandStatus.Failure, message: "§cNo targets matched selector." }

        for (const selected of playerList) {
            try {
                system.run(() => selected.applyKnockback({ x: 0, z: 0 }, flingStrength));
                player.sendMessage(`§a${args[1]} flung ${selected.name}!`);
            } catch (e) {
                player.sendMessage(`§cFailed to fling ${selected.name}: ${e}`);
            }
        }
        return { status: CustomCommandStatus.Success }

    })

and in the console:

[Scripting][warning]-[{"id":"-8589934591","typeId":"minecraft:player"},{"id":"-261993005041","typeId":"minecraft:player"}]

[Scripting][warning]-{"id":"-8589934591","typeId":"minecraft:player"}
#

you can see args[0] is 1 of the players in the @a selector

#

just stupid design

remote oyster
winged gull
sterile epoch
# remote oyster Can you show your object for `flingCmdInfo`?
const flingCmdInfo = {
    name: "cz:fling",
    description: "Flign sum1",
    permissionLevel: CommandPermissionLevel.Admin,
    mandatoryParameters: [
        {
            name: "target",
            type: CustomCommandParamType.PlayerSelector
        },
        {
            name: "cz:fling_power",
            type: CustomCommandParamType.Enum
        }
    ]
}
sterile epoch
winged gull
#

and see what happens

sterile epoch
#

does nothing

winged gull
sterile epoch
#

error because idk why my custom command enum isn't working

winged gull
sterile epoch
#

it is

winged gull
#

just string

sterile epoch
#

oh ok

winged gull
#

string can be any text

#

enum must be one of the preset values

sterile epoch
#

I registered an enum tho

#

it was low, med or strong

winged gull
#

use string

sterile epoch
#

but now I don't get the auto completion

remote oyster
# sterile epoch ```js registry.registerCommand(flingCmdInfo, ({ sourceEntity: player }, args) =>...

I'm on mobile and not at a pc so visual clarity isn't as easy on my eyes. Try this though.

registry.registerCommand(flingCmdInfo, ({ sourceEntity: player }, targetPlayers, power) => {
    if (!(player instanceof Player)) return;

    const flingStrength = { low: 1, med: 2, strong: 5 };

    if (!Array.isArray(targetPlayers) || targetPlayers.length === 0)
        return { status: CustomCommandStatus.Failure, message: "§cNo targets matched selector." };

    for (const selected of targetPlayers) {
        try {
            system.run(() => selected.applyKnockback({ x: 0, z: 0 }, flingStrength[power] ?? 1));
            player.sendMessage(`§a${power} flung ${selected.name}!`);
        } catch (e) {
            player.sendMessage(`§cFailed to fling ${selected.name}: ${e}`);
        }
    }

    return { status: CustomCommandStatus.Success };
});
winged gull
#

to test what happens

#

gtg

sterile epoch
#

but I'm a little confused, it says the second callback parameter is an array of arguments

#

nevermind I read it wrong skullfan

remote oyster
tardy pivot
#
onPlayerDestroy(event) {
  const { block, dimension } = event;
  const permutation = block.permutation;
  const contentStack = permutation.getState("tap:content_stack");
  const pressState = permutation.getState("tap:press_state");
  const pressContent = permutation.getState("tap:press_content");

  console.warn(`onPlayerDestroy called with contentStack=${contentStack}, pressState=${pressState}, pressContent=${pressContent}`);

  // Do nothing if no content or fully pressed
  if (contentStack === 0) {
    console.warn("No content in stack, skipping drop.");
    return;
  }
  if (pressState === 2) {
    console.warn("Press state is fully pressed (2), skipping drop.");
    return;
  }

  const unpressedCount = Math.max(0, contentStack - pressState);
  console.warn(`Calculated unpressedCount = ${unpressedCount}`);

  if (unpressedCount <= 0) {
    console.warn("Unpressed count is zero or less, skipping drop.");
    return;
  }

  let dropItemId = null;
  if (pressContent === 1) {
    dropItemId = "minecraft:raw_copper"; // olives
  } else if (pressContent === 2) {
    dropItemId = "minecraft:raw_iron"; // grapes
  } else if (pressContent === 3) {
    dropItemId = "minecraft:raw_gold"; // white grapes
  } else {
    console.warn(`Unknown pressContent value: ${pressContent}, no item will be dropped.`);
  }

  if (dropItemId) {
    console.warn(`Spawning item ${dropItemId} x${unpressedCount}`);
    dimension.spawnItem(new ItemStack(dropItemId, unpressedCount), block.center());
  }
}
tardy pivot
sly valve
#

Any Design related ideas?

sly valve
tardy pivot
#

[Scripting][warning]-onPlayerDestroy called with contentStack=undefined, pressState=undefined, pressContent=undefined

[Scripting][warning]-Calculated unpressedCount = NaN

[Scripting][warning]-Unknown pressContent value: undefined, no item will be dropped.

random flint
tardy pivot
#

oh my bad

#

why do they return undefined?

random flint
#

Have you defined the block states on the block json?

tardy pivot
#

yes

random flint
#

use brokenBlockPermutation. the block you're referencing have technically turned into air

sly valve
#

Hey Gegaaa

random flint
#

I thought you left the server

sly valve
random flint
sly valve
#

:( anyways, 2 questions

#

Can you help me

#

and is kal'tsit okay?

#

@random flint Sorry for pinging

round bone
sly valve
round bone
sly valve
#

:)

round bone
#

I am joking right now, but don't do this next time

#

🙏

uncut lynx
#

How could i use TS with bridge. v2?

gilded shadow
#

is there a way to get which slot was player's mainhand

warm mason
gilded shadow
#

ty

halcyon phoenix
#

correct me if im wrong

playerInteractWithEntity
beforeEvents works if it interacts with an entity?

and afterEvent works if minecraft:interact component gets triggered?

uncut lynx
#

How do i use TS with bridge. v2

#

?

halcyon phoenix
#

it says structureManager doesn't have privilege

round bone
halcyon phoenix
#

why did they do this?

round bone
#
/**
 * Remember to import system from "@minecraft/server";
 * import { system } from "@minecraft/server";
 */
system.run(() => {
    placeStructure(location, dimension.id, difficulty)
})
round bone
#

they shouldn't change anything in the same tick when the event has been triggered

warm mason
halcyon phoenix
#

well dang

warm mason
halcyon phoenix
#

yep I used it a alot when I started scripting

round bone
uncut lynx
#

Thanks to that guy who told me to use coord-based block data storage, with set/getDynamicProperty, my addon would've burned everybody's pc's with entities...

uncut lynx
#

How do i rotate the block's texture via javascript

#

????

#

Note i have 511 different rotation speeds i want to use

alpine wigeon
uncut lynx
#

i have RPM from -255 to 255

alpine wigeon
#

are you making create mod or something??

uncut lynx
#

Yes xD

alpine wigeon
#

oof

uncut lynx
#

It's gonna take me year or so

distant tulip
alpine wigeon
#

yikes

uncut lynx
#

soo how can i rotate the block at all

distant tulip
#

part visibility

alpine wigeon
#

you might have to make custom geometries and cycle through them
there's probably a better way but that's the first thing i think of

uncut lynx
#

511 different geometries are u proposing?

alpine wigeon
#

um

#

yeah

#

i think so

#

actually

distant tulip
#

the max you can do is 32

alpine wigeon
#

you only need as many geometries as how smooth you want the animation to be

uncut lynx
#

Well in Create pretty much every block rotates in some or other way

distant tulip
#

actually, i might be wrong, you can combine states

uncut lynx
#

so i'd need 511 geos * the functional blocks

alpine wigeon
#

if you say
state 1: 12
state 2: 2

#

then you have 24 states maybe

#

sort of

uncut lynx
#

Yeah i can just use dynamic properties or whatever to know which one is it the state, but i want to know how to rotate the block

alpine wigeon
#

part visibility i guess and change it every tick
but that causes lag

uncut lynx
#

Do u know how my onTick function looks like?

alpine wigeon
#

no

wheat condor
#

what's the best way to check if the player has beta-api enabled?

uncut lynx
#

ugh....

distant tulip
#

you can only have 32 state
so that leave you with 32^32
possible condition you can use at part visibility

distant tulip
wheat condor
distant tulip
#

yeah?

alpine wigeon
alpine wigeon
distant tulip
wheat condor
# distant tulip yeah?

if addon is requesting -beta version and beta-api experiment isnt enabled it just doesnt load scripts

alpine wigeon
#

so turn on beta

distant tulip
alpine wigeon
#

oh

#

that's a bit different

distant tulip
#

1024

alpine wigeon
#

yeah

#

still enough tho

distant tulip
#

welp, try it and hope for the best

uncut lynx
#

so to summarize?

#

do i just rotate the block like 30 times in blockbench or what

alpine wigeon
uncut lynx
#

This is already painful

#

2 blocks take up 400 lines of javascript

#

creative motor and half-functioning shaft

alpine wigeon
#

B R U H

wheat condor
uncut lynx
#

Once i'm done with the shaft and i make stressometer/speedometer to confirm it works

#

i'll send it

#

also i guess no animations for now

distant tulip
uncut lynx
#

worse part is i now have to make the speedometer and stressometer otherwise i dont know anything about it

uncut lynx
#

how many functional blocks are there in create?

wheat condor
#

isnt it better to spawn an entity with the animation when the block is spawned so its easier to animate?

#

like end crystals but with a block hitbox

uncut lynx
#

shafts are super used

distant tulip
wheat condor
#

wdym by shafts?

uncut lynx
wheat condor
#

what's create?

uncut lynx
#

Very Cool java mod

lyric kestrel
wheat condor
#

ohh that addons with a lot of machinery

uncut lynx
#

Yeah

lyric kestrel
#

ye

uncut lynx
#

Currently working on transmitting rotational power

#

(rpm + su)

wheat condor
#

never played but i ve seen a lot of showcases/gameplay

wheat condor
uncut lynx
#

That'd take up a nice amount of disk space

ivory bough
#

How to detect if the world is in multiplayer? Detecting the number players won't work since I want to make players have a join message if in singleplayer and I don't wanna repeat the same message while in multiplayer

uncut lynx
#

Alr no animation it is

wheat condor
#

with entities you dont have to load the server for the animation, and its all rendered from the client.

uncut lynx
#

imagine 40 shafts, 20 fans, sth like that

#

already 60 entities

#

Also yay implementing entities!!!!!!!!!!!!

#

u know what

#

animations are the last of my priority

wheat condor
alpine wigeon
#

but if they have a shaft then a box then a shaft then a box then a ...
it would take a lot of entities still

uncut lynx
#

Yeah

fresh current
#

Hmm

wheat condor
alpine wigeon
#

then you have to have 512 textures

uncut lynx
#

PER BLOCK

fresh current
#

So I imported a file to vsc but the words are in some weird format that I can’t understand can anyone help me

alpine wigeon
#

and animated textures on custom geometry seems to be broken

#

also you can't control when the animated texture moves or what frame it's on

wheat condor
alpine wigeon
#

what if instead of increments of 1rpm, you used increments of like 8 or 16 rmp

#

that would cut the state count down significantly

uncut lynx
wheat condor
#

bedrock is not a place to create complex addons

uncut lynx
#

This is a challenge for me not just another bedrock addon

#

I wanted to see what was possible with such limitations

#

For a long time

wheat condor
#

well you'll have to do a lot of reverse engeneering and exploiting

uncut lynx
#

why

#

I am just practically "inspired" by real create

#

it is so different

#

And if i wanted to, i'd just look at src code

halcyon phoenix
#

is it possible to use getEntities outside render distance?

#

welp turns out you cannot

#

it returns an empty array

wheat condor
#

no becouse they despawn and they are not persistent entities

halcyon phoenix
#

what are some workarounds?

wheat condor
#

add dynamic properties to them

#

and they'll never despawn

halcyon phoenix
#

is there any function that is similar to ticking area?

wheat condor
#

its not about ticking the world

#

the entities do not get saved

ivory bough
#

Hey, so I have never used minecraft server editor. But does it work on singleplayer worlds or bds only?

wheat condor
#

even if you render the chunks you cant get entities that were there

halcyon phoenix
#

ahhh I see so a player must manually load it

wheat condor
#

when you load the world there will spawn new entities

halcyon phoenix
#

it needs to be ticking

wheat condor
#

this means that all the world needs to be ticking (impossible)

halcyon phoenix
#

how do I add dynamic properties to them if I can't even get them?

wheat condor
#

when the player loads them add dynamic properties so they never despawn

#

you cant get entities in a never loaded chunk becouse no entity ever spawned

sly valve
#

Good Morning guys

halcyon phoenix
wheat condor
#

good evening

sly valve
#

:(

wheat condor
#

european core

halcyon phoenix
sly valve
#

Well is 15:09 for me :)

wheat condor
wheat condor
wheat condor
#

but i dont think so

uncut lynx
halcyon phoenix
#

specifically armor stand

uncut lynx
warm mason
halcyon phoenix
#

structure manager?

wheat condor
#

yes

sly valve
wheat condor
warm mason
sly valve
wheat condor
#

world.getDimension(world.getDimension(block.dimension.id).id)

uncut lynx
#

Y'all will lose it when u see my main.js

sly valve
wheat condor
#

when you see a runCommand() just press CTRL + X

halcyon phoenix
#

is there anything similar to ticking area on scripts?

wheat condor
warm mason
wheat condor
#

but its a working exploit

#

so why do i need to say no if it exists

sly valve
#

Guys, Im doing a Tower Defense in Minecraft and I want to add Custom Icons (unicodes).. can someone help me in DMs? (ik its resource related but yeah)

granite badger
rugged tinsel
#

sounds like a great idea

sly valve
#

Its a great idea

wheat condor
plucky light
#

Is there a way to find the biome of a location?

warm mason
fresh current
#

@sly valve can you help me rq

uncut lynx
#

For the main.js sake, how can i cleanly write

a = sh_t();
if (a == undefined)
{
  a = 0;
}
```?
fresh current
#

join vc rq if you could

#

im trying to fix this file in my vsc

sly valve
rugged tinsel
uncut lynx
fresh current
rugged tinsel
wheat condor
#

?? basically means: if it didnt get the value assume its 0

rugged tinsel
#

not AI

sly valve
rugged tinsel
#

that's legacy scripting API

uncut lynx
sly valve
warm mason
uncut lynx
#

okay

sly valve
#

Depends on the return value

rugged tinsel
# uncut lynx So which one || or ??

?? is more strict, it checks if the value is null or undefined. || checks if it's falsy, either works unless you're dealing with potentially falsy values like 0 or false

wheat condor
#

|| = runs if the value is "" or 0 or false
?? = runs ONLY if the value is null or undefined

sly valve
#

So gotta go my fresh guys.
@fresh current Ill Ping you when im able to

wheat condor
rugged tinsel
#

only thing I miss is custom UI

wheat condor
#

there was CUSTOM UI????

rugged tinsel
#

there was, yes

#

old scripting was only available on windows though

uncut lynx
rugged tinsel
#

no

#

full html support

warm mason
uncut lynx
#

But the new OreUI

rugged tinsel
#

not talking about OreUI, legacy scripting predates that

wheat condor
rugged tinsel
warm mason
warm mason
rugged tinsel
#

here's a video that used that UI system
https://www.youtube.com/watch?v=IFH6wJj4cw4

I've added a "Quarry Planner" block, which allows you to set the size of the quarry to build, and it also requires the player to actually build the quarry structure instead of it just appearing out of nowhere. :)
If you've got any ideas on how building a quarry could be improved, leave them in the comments below so I can see! :D
(Thanks for all ...

▶ Play video
warm mason
#

Like custom components

rugged tinsel
halcyon phoenix
#

what does preload do in tickigarea?

rugged tinsel
halcyon phoenix
#

@wheat condor spawning a ticking area does work and then removing it after it was placed that's fine right?

wheat condor
halcyon phoenix
#

what?

wheat condor
#

you can add tickingarea only in alredy loaded chunks

#

meaning that you cant load a chunk far away randomly

halcyon phoenix
#

uhhhhh.....

wheat condor
#

what's the problem

halcyon phoenix
#

I created a new world the end is still unvisited
so I created a tickingarea using
'execute in the end' then genereated my maze, and it worked....

#

the maze ussrs getEntities to check for armor stands placed by the structureManger

wheat condor
#

were you in the end?

halcyon phoenix
#

nope

#

I created a new world triggered the script and it did it

sly valve
#

@plain pecan dont leavee us alone!

halcyon phoenix
#

wanna try it?

wheat condor
#

nver seen this feature

#

didnt test recently but when i tried to do that it didnt work

halcyon phoenix
#

yeah

remote oyster
halcyon phoenix
warm mason
sly valve
halcyon phoenix
remote oyster
halcyon phoenix
#

wait

#

I did that once lmao

#

inside a for loop tho

warm mason
halcyon phoenix
distant tulip
dusky flicker
#

isnt that too much?

uncut lynx
dusky flicker
#

wouldnt it?

uncut lynx
#

No

#

In both directions

#

And at scale of 32+ it doesnt change much

lyric kestrel
#

@uncut lynx instead of the -255 values, can't you replace them with a "rotation" variable?

#

Like clockwise, anti-clockwise

#

And then you'd just need 256 speed variables

#

instead of 511

uncut lynx
wary edge
#

Your best bet is to jist wait for block entity support so you can render the block as an entity which allows for animations.

jolly citrus
#

omg I hate coding

#

I hate when things dont go the way theyre supposed to

sly valve
#

(I also got a problem...)

jolly citrus
#

The issue was just that I changed the way some of my data was structured and i forgot to update the places where i fetch stuff related to it

#

i fixed it

#

heh

sly valve
#

I moved all of my files but the import didnt changed automatically...

#

anyways

#

Can someone help me with Entity.applyImpulse

uncut lynx
#

Bruh

#

i just engineered communication system

#

between adjacent blocks

uncut lynx
#

After

#

literal 18 hours

#

I have 1 block fully working

unique acorn
#

thats progress!

#

keep it up

uncut lynx
unique acorn
#

still better than nothing

uncut lynx
jolly citrus
#

What

#
Commands.instance.registerCommand(
  "who",
  "View information about a team",
  "<teamName: string>",
  [],
  1,
  "teams",
  ({ args, sender }: { sender: CustomPlayer; args: { [key: string]: any } }) => {
    const teamName = args.teamName as string;
    if (teamName) {
      console.log(`Viewing info of team: ${teamName}`);
      const team = TeamUtils.getTeamByName(teamName);
      if (team) {
        let onlines = new Set();
        for (const key of team.members.keys()) {
          if (globalThis.GlobalCustomPlayers.has(key)) {
            onlines.add(key);
          }
        }

        const leader: TeamMember[] = [];
        const coLeaders: TeamMember[] = [];
        const captains: TeamMember[] = [];
        const members: TeamMember[] = [];

        for (const member of team.members.values()) {
          switch (member.rank) {
            case "leader":
              leader.push(member);
              break;
            case "coleader":
              coLeaders.push(member);
              break;
            case "captain":
              captains.push(member);
              break;
            case "member":
              members.push(member);
              break;
          }
        }

        const formatMember = (_member: TeamMember) => {
          const nameColor = onlines.has(_member.playerId) ? "§a" : "§7";
          return `${nameColor}${
            globalThis.GlobalPlayerNames.get(_member.playerId) ?? _member.playerId
          }§r§e[${nameColor}${_member.kills}§r§e]§r`;
        };

        const message = [
          ` `,
          `§9${team.name} §7[${onlines.size}/${team.members.size}] §3- §eHQ: §f${
            team.hq ? [team.hq.x, team.hq.z].map((n) => n.toFixed(0)).join(", ") : "Not Set"
          }`,
          `§eLeader: ${leader.map(formatMember).join("§r§e,§r") || "None"}`,
          `§eCo-Leaders: ${coLeaders.map(formatMember).join("§r§e,§r") || "None"}`,
          `§eCaptains: ${captains.map(formatMember).join("§r§e,§r") || "None"}`,
          `§eMembers: ${members.map(formatMember).join("§r§e,§r") || "None"}`,
          `§eBalance: §6${team.balance.toFixed(2)}g`,
          `§ePoints: §c${team.points}`,
          `§eDeaths until Raidable: ${TeamUtils.formatDtr(team.dtr)}`,
        ];
        const timeUntilRegen = team.regenTime - Date.now();
        if (timeUntilRegen > 0) {
          message.push(`§eTime until Regen: §9${StringUtils.formatMillisecondsToText(timeUntilRegen)}`);
        }
        message.push(` `);
        world.sendMessage(message.join("\n"));
      } else {
        sender.player.sendMessage(`Team ${teamName} does not exist.`);
      }
    } else {
    }
  }
);
#

It took me 45 mins

#

To make this command

#

And it didnt even work after that i spent another 15 fixing it

uncut lynx
#

Hmm

jolly citrus
#

But i mean it wasnt 45 mins of full work

uncut lynx
#

Well i spent 18 hours

jolly citrus
#

Mines just a command

#

Its meant to be simple

uncut lynx
#

Well I am not using any sort of community-made api

#

Maybe that or idk

jolly citrus
#

Idk what that’s supposed to mean

#

Neither am I i made everything myself

#

Every library if theres any used is made by me

uncut lynx
#

ahh alright i didnt notice

#

Time for the almighty shaft

prisma shard
sly valve
uncut lynx
#

yk what i'mma just do one generic animation per block

#

so how do i do that state thing?

sly valve
#

(my) Debug screen from Wish, any ideas what I should/could add?

uncut lynx
#

Can anybody help me with my js code??

#

I keep getting weird behaviour

ruby plover
#

yooo could someone tell me how i can make this code run when the event "eventname" is triggered, rn its working as intended but i dont think it works when the event is triggered

#
const EventDetector = {
  "eventName": {
  }
}

world.afterEvents.dataDrivenEntityTrigger.subscribe((data => {
    world.afterEvents.dataDrivenEntityTrigger.subscribe((event) => {
        let entity = event.source;
        if (EventDetector[data.eventId] != undefined && entity != undefined) {
            system.runTimeout(() => {
                entity.runCommand("playsound supernova.spawn @a");
                entity.runCommand("particle moo:stars1");
                entity.runCommand("particle moo:stars2");
                entity.runCommand("particle moo:stars3");
                entity.runCommand("particle moo:stars4");
                entity.runCommand("particle moo:large-void");
                entity.runCommand("particle moo:fog");
                entity.runCommand("particle moo:fog2");
                entity.runCommand("particle moo:black-hole");
                entity.runCommand("particle moo:black-hole-dust");
            }, 0)
        }
    })
}
));```
warm mason
alpine wigeon
#

why do you use /spoiler?

wheat condor
alpine wigeon
#

lol

ruby plover
uncut lynx
sly valve
wheat condor
#
const { dimension, location } = entity;

['particle1', 'particle2', ...'particle999'].forEach(id => {
    dimension.spawnParticle(id, location)
})
wheat condor
wheat condor
uncut lynx
wheat condor
#

i do NOT want to see them