#Script API General

1 messages · Page 66 of 1

shy leaf
#

it also counts as 'not in rain'

prisma shard
#

oh

#

then

#

you have to make a for loop
then do y++ on the player.location
until the block isSolid()

dim tusk
#

getBlockFromRay() exists

#
system.runInterval(() => {
  for (const player of world.getPlayers()) {
    const { dimension } = player;
    const { min, max } = dimension.heightRange;
    const weather = dimension.getWeather();

    if (location.y < min || location.y > max || weather === 'Clear') continue;

    const blocks = dimension.getBlockFromRay(player.getHeadLocation(), { x: 0, y: 1, z: 0 }, {
      maxDistance: max - location.y,
      includeLiquidBlocks: true,
      includePassableBlocks: false
    });

    if (!blocks) {
      // ...
    }
  }
});```
#

@shy leaf

shy leaf
#

getting if the block above is air is not an issue

#

but the rain depends on biomes

dim tusk
#

ahh, then good luck.

#

I just got annoyed with the guy above lmfao, you're literally saying if in the rain bro just keep insisting getWeather() is the solution

prisma shard
#

sorry

pine grove
#

Can I define a custom property inside a script instead of using entity's behavior json file and defining it there like below?

          "client_sync": true,
          "type": "bool",
          "default": false
        }```
random flint
shy leaf
#

cant have a tick delay in the slightest

#

and no, i need to check it for victim, not the damaging entity

wary edge
shy leaf
wary edge
#

Im so confused what youre trying to do, stop the damage?

shy leaf
#

no uh

#

i actually just did resolve it a while ago

random flint
wary edge
shy leaf
#

hold on let me check my messages

wary edge
#

The chad Based answer ngl.

random flint
wary edge
#

My intent was to say it isnt in JE right now but it is in BE.

shy leaf
#

though the most problematic part is checking biomes to check if the biome can rain

#

like, im in savanna, why are you giving me dripstone cave

random flint
#

What are going to use the inRain detection for

shy leaf
#

for trident impaling

random flint
#

custom one?

shy leaf
#

no im recreating the entire combat

wary edge
shy leaf
#

uh yeah

#

and i was making that

wary edge
#

Im so confused.

shy leaf
#

ok uh

#

yeah i think i didnt explain whats going on

random flint
#

Probably custom damage calculation

#

you're recreating its mechanic right

shy leaf
#

the entire java combat actually

#

i did finish it a while ago but i forgot trident exists and

#

yeah

random flint
#

So you're importing Java's trident into Bedrock?

shy leaf
#

well not everything

#

im keeping the 'more damage against mobs in water or rain' cuz java trident sucks ASS

random flint
#

Are you planning to adjust its damage or keep it as default like vanilla?

shy leaf
#

i already set it to 9

#

i think its 8+1 in bedrock iirc?

#

and 9 in java

shy leaf
#

trident damage

random flint
#

Trident damages (Java & Bedrock)

  • Melee damage: 9
  • Ranged Damage: 8
  • Impaling adds 2.5 damage to each level.
#

So, you're keeping it as vanilla?

prisma shard
#

How do i execute a scriptevent

#

do i use runCommand

#

to start the scriptevent

random flint
#

system.sendScriptEvent() idk if its preview but its beta

shy leaf
distant tulip
random flint
prisma shard
#

then how would i

shy leaf
random flint
#

I see, so it's the melee problem.

Why not switch the player attack back to 1 if they hold the trident?

shy leaf
#

tick delay

#

and uh

#

theres no reason to

distant tulip
# prisma shard what

what your goal, i don't see any point in triggering scriptevent from the script, you already is at the script side at that point

round bone
#

I think you can directly plug the code for swing

#
system.afterEvents.scriptEventReceive.subscribe(({ sourceEntity: player, id }) => {
    if (id != 'script:swing') return;
    if (player instanceof Player) {
        // ur code
    }
})
prisma shard
#
world.afterEvents.playerJoin.subscribe(() => {
  player.runCommandAsync(`scriptevent script:swing`)
})
#

@distant tulip

#

i'd have to do this

prisma shard
distant tulip
distant tulip
distant tulip
#
world.afterEvents.playerJoin.subscribe(() => {
  //put the code that you want to trigger here directly
})
woven loom
#

using funcs?

prisma shard
#

;-;

distant tulip
#

Ok

prisma shard
#

so how

pine grove
#

How to fix this?


[Scripting][error]-[Watchdog] Unhandled critical exception of type 'Hang' in behavior pack 'PACK'```

This did not work:

```system.events.beforeWatchdogTerminate.subscribe(eventData => eventData.cancel = true);```
prisma shard
#

there's afterEvents or beforeEvents

pine grove
#

👀

prisma shard
#

did u use ai

pine grove
#

Not in this case.

woven loom
#

you should see the docs

round bone
#

it's just slowing down

#

and pretty useless additional logic

dim tusk
prisma shard
#

it was a- example

#

ofc event.player

dim tusk
#

player doesn't exist in playerJoin.

prisma shard
#

then just world.getAllPlayers().forEach(() => {})

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

world.afterEvents.playerSpawn.subscribe(({ initialSpawn, player }) => {
    if (!initialSpawn) return

    player.runCommandAsync("scriptevent script:swing")
});
dim tusk
#

bro tryna be intelligent but failed.

distant tulip
#

There is a native method

prisma shard
#

is it preview

#

idk

#

or beta

distant tulip
#

One question, why scriptevent?

round bone
round bone
prisma shard
#

i see

#

is your mental health good?

round bone
round bone
dim tusk
#

It's annoying...

distant tulip
prisma shard
distant tulip
#

Wrong channel
-# somehow

round bone
#

but on phone I have turned off auto correct

#

it's really annoying sometimes

prisma shard
#
system.afterEvents.scriptEventReceive.subscribe(({ sourceEntity: player, id }) => {
    if (id != 'script:swing') return;
 // my code
})```
cant i do this? (from here: https://discord.com/channels/523663022053392405/1323024128877527211)
prisma shard
round bone
#

it executes a scriptevent command as a player if he has just joined the world/server (Realms too)

past coyote
#

Its so funny

#

The API is so inconsistent, I can do the most invasive thing, spawn a structure from the world data...

but I can't get the beforeEvent for a player hurting an entity.

round bone
#

but yeah, pretty inconsistent

round bone
#

tbh most of things are possible using some work-arounds

#

I only need slash commands and player's XUID and address

#

I know, that I can use a mod-loader like Endstone or just my own proxy, which also have more advantages, but I would like to do implement all of it directly in my add-on

pine grove
#
]```
Oof, I am not in @minecraft/server 2.0.0-beta. What is the equivalent of this in 1.17.0?
round bone
#

can you send full code?

pine grove
#
import { checkEntities } from "./entityChecker.js";

system.beforeEvents.watchdogTerminate.subscribe((event) => {
    event.cancel = true;
    console.warn(
        `[Watchdog] Canceled critical exception of type '${event.terminateReason}`
    );
});

system.runInterval(() => {
    checkEntities();
});

Code

#

It works in 1.18.0-beta but not in 1.17.0.

cold grove
#

Beta features are not accessible on stable, because its beta

pine grove
pine grove
#

Well, I know. Thanks I guess.

warped kelp
#

I seee. Thanks, ima just spam chance in scripts with every hit they do :L

humble lintel
#

Does anyone know if using setDynamicProperty() on an item automatically replaces the itemStack with one that includes the dynamic property or do I have to replace it manually

humble lintel
#

damn racist alright thanks

#

sorry i meant the unction is racist bc i wishd it already did that to me;

granite badger
prime zenith
#

I think they mean outside in the rain so if there in a house your funtion would still be true

humble lintel
#

without having to replace item?

#

because im using an item with use modifiers and I don't want the event itemstopuse to run when i set the dynamic property

thorn flicker
wheat condor
#

with scripts can i get if an armor has a trim on it?

wheat condor
#

damn

chilly moth
#

how to get all death conditions?

#

damageSource.damagingEntity;

I am trying to get all death conditions

round bone
#

reasons?

chilly moth
#

it didn't work when blown by creeper for some reason

#

or lava damage

round bone
#

which event are you using to handle entity's death?

chilly moth
#

entitydie

round bone
#

pretty weird

chilly moth
#

why

#

afterevents

round bone
#

wait, the player has died due to a creeper explosion or the creeper just blew up?

chilly moth
#

creeper blew up

#

and my entity died

#

blow up by creeper is what it said in chat

round bone
#

try using entityRemove event

#

it might be a bit more complicated to handle death, but will work all the way

wary edge
#

joe_shrug IF creeper blow up, creeper is gone.

chilly moth
#

it's not gone it returns in creative inventory

prime zenith
#

Creeper just wants a hug

prisma shard
#

Hi

sterile epoch
#

is it possible to give a monster spawner with a mob inside

prime zenith
#

can someone get me an invinsible armor stand json ive tried but always failed my other project i had to turn off collision but wont work here as i need ppl to see the name of the armor stand

random flint
#

Set the size to zero

#

or just close to 0

dim tusk
#

and btw, not possible to grab the chest's name right?

prime zenith
#

how does animations prevent ppl destroying my armor stand

random flint
prime zenith
#

I tried that with my other so ima need more then that

valid ice
#

You’re looking for a display name entity?

prime zenith
#

i want it so my armor stands cant be broken as there what displays the city owner

valid ice
#

Damage sensor component can cancel all damage

prime zenith
#

i tried that in my last project and it didnt work

#

even with all of this {

"minecraft:entity": {
  "description": {
    "identifier": "minecraft:armor_stand",
    "is_spawnable": false,
    "is_summonable": true,
    "is_experimental": false
  },
  "components": {
    "minecraft:type_family": {
      "family": [
        "armor_stand",
        "inanimate",
        "mob"
      ]
    },
    "minecraft:collision_box": {
      "width": 0.0,
      "height": 0.0
    },
    "minecraft:health": {
      "min": 600,
      "value": 999,
      "max": 999
    },
    "minecraft:knockback_resistance": {
      "value": 1.0
    },
    "minecraft:nameable": {},
    "minecraft:persistent": {},
    "minecraft:physics": {},
    "minecraft:pushable": {
      "is_pushable": false,
      "is_pushable_by_piston": true
    },
    "minecraft:conditional_bandwidth_optimization": {},
    "minecraft:damage_sensor": {
      "triggers": [
        {
          "cause": "all",
          "deals_damage": false
        }
      ]
    }
  },
  "events": {}
}
}``` there was still a small are that if hit you could kill the armorstand
#

on this project that is less effective as i need collision box

valid ice
#

Even if you do hit the hitbox of the entity you should not be able to kill it; the damage sensor makes sure of that

#

Consider opening a post in #1067869022273667152

prime zenith
#

is my syntax off i just tested with 2 2 hit box (dont do this if you want the armor stand next to water lol) it still breaks after a few hits

sharp elbow
#

Amor stands may be special.

valid ice
#

Custom entity would be ideal

prime zenith
#

to what version

#

that was what vanillas had

valid ice
#

cough #1067869022273667152

prime zenith
#

@valid ice if i did a custum entitity to resemble an armor stand and replaced armor stands with it how would i do that i know 0 about entities and entities chat is dead

wary edge
valid ice
#

Open a post and I can help out there

prime zenith
#

I did ask it in general but 1 second

#

Posted

night acorn
#

does anyone know how you can get a block to output a redstone signal?

#

and detect inputs?

wary edge
wary edge
thorn flicker
safe stream
olive rapids
#

Is it possible to improve this script to have less lag?

#
import { world, system } from "@minecraft/server"
system.runInterval(() => {
    world.getDimension("overworld").runCommand("gamerule commandblocksenabled true")
world.getDimension("overworld").runCommand("gamemode a @a[m=!survival]")
}, 0)```
valid ice
#

you can use native methods for those

#

world.gameRules.commandBlocksEnabled=false; and gamemode change event for the other one

olive rapids
thorn flicker
valid ice
#

I am not going to rewrite the code for you lol

olive rapids
#

.

#

@wary edge

valid ice
#

😭

thorn flicker
solar dagger
#

Bro just copy what he wrote

lyric kestrel
#

so...

#

It seems I forgot how to cancel block interaction with playerInteractWithBlock beforeEvent xD

lyric kestrel
#

I keep getting a read-only error or it doesn't work

#

I realised I can't put it in system.run, but still doesn't fix the not working part

#

Oh wait, I have it outside of system.run but still getting read-only error

#

tf

dim tusk
lyric kestrel
#

OHHHH

#

I had this

#
world.beforeEvents.playerInteractWithBlock.subscribe(e => {
    const { block, player, itemStack, isFirstEvent, cancel } = e;
    const blockType = itemStack?.typeId;
    cancel = true
  //....
})
#

I didn't realise I couldn't do that

lyric kestrel
#

ye, I just did xD

dim tusk
#

(ev, { block, player } = ev)

lyric kestrel
#

although, I'm a bit confused why structuring doesn't work for cancel

dim tusk
lyric kestrel
#

ah

dim tusk
#

for simple, don't destruct when you cancel

lyric kestrel
#

ye

#

thank you

#

appreciate the help

prime zenith
#

Can you force close chat window from a chat event

past coyote
#

how do I make this apply when the player has a tag?

shy leaf
past coyote
#

its not in here but I was trying to make it so if I have a tag I can't hurt any non-player entity, and if I have a different tag I can't hurt any player.

#

but im thinking it would be tedius to do.

prime zenith
#

Do dynamic properties follow the same integer limit of 2.147b

past coyote
#

32 bit yeah @prime zenith

#

2,147,483,647

deep yew
#

I am trying to use player TP and ticking areas, while also teleporting the player 10k blocks away and saving a structure then deleting those blocks and then TP back. This causes issues and varies in severity depending on network speeds, causing loss or deleted structures. What would be the fastest way to load chunks that aren't in render/simulation distance?

slow walrus
#

and they both take a few ticks to actually load the chunks

deep yew
#

what is a ticking entity?

#

One that has the tick component?

slow walrus
#

an entity that has the tick world component

deep yew
#

I tried making one and failed, so maybe not that

#

I know it can't all be done instant or fast, but I also need to save and unload those blocks using structures for when that player leaves

#

because it's a plots system that loads and unloads but is far away from spawn

deep yew
#

Do ticking areas cause chunk loading or do they just keep the last player-loaded chunks intact?

slow walrus
#

ticking areas load the chunks

#

the chunks have to be loaded for ticking to happen

deep yew
#

that sounds like it counters itself

#

It sounds like I'd want to make a tickingarea for each player that isn't currently at their plot, but there must be 1 tickingarea for spawn and 1 for each player

slow walrus
#

why would you need tickingareas for players who aren't at their plot?

deep yew
#

If they leave or unload the plot, the ticking area will have the chunks loaded and unload the island and remove the blocks from the world. I am thinking I can just add a ticking area when they leave and not try to worry about it being super fast like 5 ticks or less and more like 5 seconds or less, but I was just trying to find fast efficiency

ivory bough
#

is there any way to get the current render distance of a player?

subtle cove
distant tulip
deep yew
#

Way better, how?

distant tulip
#

Not limited in term of count, and you have much control over it sense it is an entity

ivory bough
deep yew
#

I immediately agreed when you said it because of the count of the entities not being as restricted, but I wonder about the loading and persistence of the entity when it's far away

#

or it just keeps itself loaded because it's ticking?

distant tulip
#

You have control over that too

deep yew
#

Over what, the persistence and stuff?

distant tulip
#

Yeah

deep yew
#

Simply, all I need is a way to keep some, preferably all, islands loaded basically at all times so everything that needs to tick does tick and when a player unloads the plot, it doesn't lose data or chunks

#

and I need it to work when the player's device is slow

#

as I know from the alt account on the laptop next to me, it can cause some good issues

chilly moth
#

how do I check if entity is tamed before death

dim tusk
deep yew
chilly moth
#

I want to store that, it is tamed before death

prisma shard
chilly moth
#

how

dim tusk
# chilly moth how

Entity.setDynamicProperty('<name>', <value | Boolean | string | Vector3 | number>); Entity.getDynamicProperty('<name>');

prisma shard
#

btw you'd have to use entityDie event

#

wait no

#

your storing it before death.

dim tusk
#

use dataDrivenEntityTrigger to detect the tabe

chilly moth
#

ok

dim tusk
#

Or use playerinteractwithblock and get the tameable items

chilly moth
#

I am using command

prisma shard
#

aw hel naw

dim tusk
chilly moth
#

check
If died entity is tamed and revive it tamed

#

it wasn't checking if died entityis tamed but revied entity was always tamed and it's chosing the last killed entity and saves it's data for revival
leading to making the killed wild pets revive being tamed

chilly moth
chilly moth
#

I don't know how it will affect multi-player though

shut citrus
#

How to spawn fake lightning?

prisma shard
# shut citrus How to spawn fake lightning?

maybe more of a #1067869022273667152 question?
you'd have to make a entity someting same as the lightning but not damage the player. i think is this what you meant by a fake lightning?

distant tulip
prisma shard
#

or do i change player.json to make players nametag editable

dim tusk
#

tho in chat's it doesn't change.

prisma shard
dim tusk
prisma shard
#

i am simulating a player in the game right

#
  • go third person
#
  • look at my own player
#
  • can i see my name tag?
#

thats what i mean

dim tusk
#

No.

#

use a dummy entity and ride the player or tp them.

ivory bough
#

Is there any way to cancel vanilla commands? Like for instance, "kill @a" any way to cancel this?

round bone
ivory bough
round bone
#

what do you mean by file installation?

#

in script? you can't even handle these files

ivory bough
solar dagger
#

is there a way to detect the color of water in a couldron?

wary edge
#

You can also set the colour.

solar dagger
wary edge
solar dagger
#

Like leather armor

wary edge
#

Just use the dyeable component?

solar dagger
#

Oh that's a thing...okay forget what I asked them

thorn ocean
#

Does anyone know to use scripts to display particles that only the targeted player can see?

unique acorn
gaunt salmonBOT
#

Health display
Display player's health below player's name tag using scripts.

warm apex
#

Does anybody have any tips with folder/structure layout for scripting? I'm pretty decent with coding, but because I'm self taught I don't have a good way of knowing when to separate things into different files (I usually end up with most things running on main.js with a few folders for my own math related classes like vector maths or trig)

((Sorry if this is a bad place to ask))

cold grove
#

I personally dont like to put things on the main script file
I separate events in different files, same with server forms

warm apex
#

Thanks ^^

fast lark
#

i dont remember how can i block the movements of a player

dim tusk
fast lark
thorn flicker
thorn flicker
#

2 is movement

thorn flicker
#

check out the link to see what number is what

thorn flicker
#

also would be nice if there was a input permission for sprint

#

hopefully in the future

fast lark
dim tusk
#

Either import InputpermissionCategory for easy choice for Camera, Movement etc. or just number.

dim tusk
fast lark
#

lol

thorn flicker
#

kind weird it's numbers though, why not a string

prime zenith
#

The cat destroyed all the string

prime zenith
#

Im surprised at how msny structures a script can make before it has idmssues

unique acorn
#

how much

prime zenith
#

I made 20k before a watchdog error

#

Whats the game rule to turn off the recipe unlocking

unique acorn
prime zenith
#

If im making a rts game about attacking and conquering players ciries should input the cities underground making you need to mine in order to find other cities

prime zenith
#

I had ai generate random names for my cities i liked it up until 1 of the cities name was volsungstead

prime zenith
#

Hmm if its a realistic name even if foreign ill keep it i thought it was over the top

prime zenith
#

I was this many years old when i learned BigInt was a thing

#

Considering i got it to acuratly display the result of 123456789 × 123456789 which is way past integer limit that is cool

chilly moth
#

I want to set up a command script to see list of tamed pets by owner can anyone help

prime zenith
#

New habbit to get into add n to every number for dynamics and integar limit becomes a non issue lol

ivory bough
unique acorn
#

I don't know any way at the moment

prime zenith
distant tulip
#

client side rendering (preview)

prime zenith
#

Who plans to watch minecraft live saturday

prisma shard
#

thirst bar update?

prime zenith
#

What time is it on exactly

prisma shard
#

11 pm

prime zenith
#

Its game deletion update

prisma shard
#

if u wanna talk about it more lets go to #off-topic !

ivory bough
ivory bough
#

@distant tulip how to use that?

distant tulip
warped kelp
#

How do I fix this?

[Scripting][error]-Plugin [The Black Silence Trial 1.2 - 0.0.1] - [main.js] ran with error: [ReferenceError: 'world' is not defined    at <anonymous> (custom/on_hit_gebura_2.js:12)
]
distant tulip
#

Import world

warped kelp
#

OHh

#

I forgor

#

I forgot the most important thang in a script

chilly moth
#

can anyone help provide snippet
im trying to list player tamed entities
by making list command but pet is not getting listed 😕

distant tulip
chilly moth
#

yes

distant tulip
#

It doesn't work for vanilla entities or any entity that remove the component ehen tamed

chilly moth
#

than what I supposed to use¿

#

it revives tamed pets untamed ,and retames i did it through entity die and entity spawn

the list is available after at least all pets are killed once

any other way?

#

can the same be done using type_family
@distant tulip

distant tulip
#

wdym

chilly moth
#

using type_family to get tamed

distant tulip
#

How...

#

That doesn't make much sense

#

Ok i could thing of a way, what if we used the data driven event and prevented the removal of the tameble component for a second untill we stored the player id somewhere @chilly moth

#

There is a thing in that event called commponentGroupToRemove

chilly moth
#

does bedrock support delay

distant tulip
#

In what way

chilly moth
#

Entity Actions Documentation - minecraft:remove_component_group

#

this

distant tulip
#

I don't know what do you mean by that

#

gtg for now, i might visit this ide later

chilly moth
#

tags?

gaunt salmonBOT
#

Health display
Display player's health below player's name tag using scripts.

prime pine
#

not sure where to post this or ask about it but does anyone know how i can fix this

#

have the better on bedrock, a magic way relics and rings true weapons and java combat addons on

#

worked fine for 40 in game days

#

then randomly the world froze but i didn't

#

and this popped up

#

tried removing and readding the packs

#

still doesn't do anything i unless i remove all the packs

#

then the world works

#

1.21.51

chilly moth
#

so their isn't any method to store pet dynamically?

fast lark
#

how can i make a timer of a hour and when it finish someting happens

sharp elbow
unique acorn
# fast lark how can i make a timer of a hour and when it finish someting happens

Method 1: declare a variable and assign the value 3600 to it, then use a runInterval to decrement 1 number every second then check if the number is equal to 0.
Method 2: make a variable with the value Date.now() then every once in a bit keep checking if the current date is bigger than that variable + 3600000.
Method 3: same as method 2 but instead use system.currentTick and check if the current tick is bigger than that variable + 72000

sharp elbow
#

Method 2 is your most time-accurate choice. There is no guarantee that the server's tick rate per second will be consistent enough for an hour.

chilly moth
#

I tried adding tag to custom mob and this happened

ivory bough
prime pine
sharp elbow
#

Hm. You're sure having any one of those packs applied caused the exception?

prime pine
#

till i download an older version of the relics addon

#

cause it had a feature that wasn't in the newer on

#

one

#

and when i removed the new version and added the old one

#

it worked fine for a few hours

#

then randomly the world just froze

#

but i was still able to move

#

like lag in a multiplayer world

#

then it won't let me play the world

#

unless i remove all the addons

#

made a new world same exact addons

#

works perfectly

sharp elbow
#

Does it seem to occur when you perform any particular action?

prime pine
#

no but i just removed the novelty api from active behaviour packs and got the same message

sharp elbow
#

Ah, it's also in A Magic Way

prime pine
#

what could be the cause

#

also why does it persist despite not being enabled

#

novelty api isn't active but i still get that message

sharp elbow
#

I suspect that A Magic Way has merged the contents of the Novelty API into its pack, so they are basically carbon copies

prime pine
#

is there a way i clone the world without the magic addons then delete everything and download them from the web so they start working again

prime pine
sharp elbow
prime pine
#

this novelty manager is in both

#

could that be the problem?

sharp elbow
#

I wouldn't think so, as Minecraft should be keeping these modules separate. It should be redundancy at worst

prime pine
#

was it me removing the behavoiur pack

#

cause it said it might cause problems

sharp elbow
#

Not sure. It is not easy to ascertain the cause without a stack trace, which Minecraft has so conveniently left out for us

#

There's a lead, at least, but the API is deeper than I first thought

prime pine
#

any temp solution i can try

#

to just atleast get the world back

#

like can i somehow clone the world istelf without the addons

sharp elbow
#

You could make a copy of the world, then remove the add-ons from the copy, I suppose

prime pine
#

then re add them?

sharp elbow
#

Re-adding them may very well re-introduce the issue

#

Actually, had a thought. Could you send me the world? I can try debugging it

prime pine
#

it's 150mb need to upload it to something

#

you willing to trust a mediafire link

sharp elbow
#

haha, sure

prime pine
#

or is there somethign you trust more

sharp elbow
#

No worries with Mediafire

prime pine
#

idk if it did it right

#

just made a .zip with winrar

#

then renamed it to .mcworld

distant tulip
#

seem to work "fine"

prime pine
#

why won't it workf or me

prime pine
#

cause i'm supposed to have a katana in the first slot

#

and a dane axe in the last slot

#

and in your screenshot they're not there

distant tulip
prime pine
#

I'm so confused

distant tulip
#

actually, no
you removed the one causing the hang

prime pine
#

should i send that one?

distant tulip
prime pine
#

yeah

#

could this just be a weak pc issue?

distant tulip
#

nope, that addon is causing it

prime pine
#

hhmm

#

so just removing it will fix everything?

#

but it's not even active and i still get that message

distant tulip
#

i didn't get it in the world you sent, only when i added it

prime pine
#

yeah

#

so

#

any ideas

distant tulip
#

let me look into it code

#

this is the worse addon i ever seen in term of performance

prime pine
#

lmao

trim cedar
#

lemme see that code i gotta get me a good laugh

#

it cant be that bad

#

:clueless:

prime pine
#

it is a older version cause the newer version straight up didn't work at all for me

trim cedar
#

DEAR GOD THE TPS, THE FRAME LOSS

prime pine
#

so what're your essentially saying

#

is that it's over and i'm cooked

ivory bough
#

Any way to make my entity break blocks like the player but not instantly? I know its not possible with entity.json

night acorn
#

does anyone know how to actually spawn / create a simulated player from the gametest module

unique acorn
#

replace structureName with that

past coyote
#

Grok is amazing @inland merlin

#

I fed it my entire codebase bit by bit, and had it refactor everything, it found stuff that was being called 600 times per second and dropped it to 20 per second. Like it found stuff that I had no idea was causing performance issues.

#

I also fed it my CPUPROFILE capture, so it had more context of what might be causing performance issues

#

it actually improved the sound system script too, like audio for waves plays the way I originally wanted it to, but I never noticed!

#

Its pretty insane, it would have been HOURS of debugging and comparing profiler data, but it was done in 10 minutes.

#

Thank you so much for letting me know about it, normally I dont touch elons stuff but grok really is just good at what it does objectively.

inland merlin
past coyote
#

Its been like integral to my development workflow 😭

distant tulip
#

Grok 3?

untold magnet
#

uh, count++ will increase the counter, count-- will decrease it?

#

( making sure )

wary edge
#

Yeah.

pulsar pike
#

hi guys i have this code

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

const NightStoneOnUse = {
    onUse({ source }) {

        const item = source.getComponent("minecraft:equippable").getEquipment(EquipmentSlot.Mainhand)
        source.runCommand("time set night")
    }
};

world.beforeEvents.worldInitialize.subscribe(({ itemComponentRegistry }) => {
    itemComponentRegistry.registerCustomComponent("SurEx:NightStoneActivate", NightStoneOnUse);
});

i am trying to get the name of the item to reuse the code and just get item name and apply the necessary time change.

my question is where can i see more about the "getEquipment" and what data can i get out of it.

item.name doesnt give anything, item.typeId, nothing. and thats only from checking discord history but could f ind nothing in the wiki

chilly moth
#

minecraft tameable component gets removed on tame so check
has component is_tamed
@distant tulip

#

it worked for me

distant tulip
#

that doesn't work for getting the owner

chilly moth
#

I haven't tested multiplayer so I don't know about that

pulsar pike
unique acorn
#

set the slot to null, that's a way to remove an item

pulsar pike
#

thank you

fallow rivet
#

Is it possible to place a sign with writing inside?

unique acorn
#
const block = world.getDimension("overworld").getBlock(location);
const signComponent = block.getComponent("sign");
signComponent?.setText("Hello, world!");
untold magnet
#

uh, which component can detect the player movement? besides that input key component thing

untold magnet
#

ah,

dim tusk
#

You'll use velocity

dim tusk
untold magnet
#

i see,

untold magnet
dim tusk
#

Everything as long as he's moving the getVelocity() it will return values.

untold magnet
#

to make sure that not happened, i should detect it only when the player is not riding another mob

dim tusk
#

Either use beta or wait for it to be stable next version

untold magnet
#

well, my addon isn't for marketplace anyway so i can use it

drifting ravenBOT
#
Info

This bot was created by SmokeyStack for the purpose of making a FAQ bot for the Bedrock Add-Ons Discord Server.

Managing Entries

To manage entries, please make a pull request on GitHub.

Source Code
untold magnet
#

i dont have to detect up/down,

untold magnet
dim tusk
#

I mean WASD movement detection

untold magnet
#

i mean is there anything stable i can use to detect if the player is moving or not?

dim tusk
untold magnet
#

i see,

dim tusk
#

What I mean by stable is a stable version of the script.

#

1.17.0 or 1.18.0-beta

#
system.runInterval(() => {
    for (const player of world.getPlayers()) {
        const { inputInfo } = player;
        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');
    }
});```
untold magnet
dim tusk
untold magnet
#

i know, but im not using beta,

marsh pebble
#

what's the run command to go to that develoment pack

cold grove
#

Huh?

dim tusk
marsh pebble
#

too lae

#

already found it

#

CODDY OPP

#

WHAT ARE U DOING HERE

untold magnet
#

uh, is it possible to detect if the player is riding a mob?

unique acorn
untold magnet
#

so i just have to get the riding component,

#

dude json ui broke my scripts skills

unique acorn
#

you can check if the entityRidingOn exists

#
if (entityThatThePlayerIsRidingOnTopOf) {
   //run code...
}
warped kelp
#

What script can I use to limit a specific mob to only allow 1 to exist at a single time?

dim tusk
#

to check entities in the world just do entity.dimension.getEntities({ type: '<id>' })

dim tusk
dim tusk
#

why you're so surprised as if you don't see me everyday.

warped kelp
#

Is this right?

function canSpawnEntity(og:roland_tier1) {
  const entities = world.getDimension("overworld").getEntities({ type: og:roland_tier1 });

  if (entities.length > 0) {
    return false;
  }
  return true;
}


world.afterEvents.entityCreate.subscribe((event) => {
  const entity = event.entity;

  if (entity.typeId === "og:roland_tier1") {

    if (!canSpawnEntity("og:roland_tier1")) {
      entity.remove();

      console.warn("Only one tier_1 can exist at a time!");
    }
  }
});
dim tusk
warped kelp
#

A hallucination from deepseek 🔮

dim tusk
dim tusk
warped kelp
#

Lmao. It sounded smart, too. Create entity? Waw

warped kelp
dim tusk
#

it can be anything you want.

warped kelp
#

Ah, right. I'll place the entity's name

dim tusk
warped kelp
#
{
world.afterEvents.entitySpawn.subscribe(({ entity }) => {
  if (entity.typeId === 'og:roland_tier1) {
    const BlackSilencephaseI = entity.dimension.getEntities({ type: 'og:roland_tier1' });
    if (BlackSilencephaseI.length > 1) {
      entity.remove();
    }
  }
});```
#

Ima remove the numbers on the name

dim tusk
warped kelp
#

Ikr? Idk, makes it feel complete

dim tusk
warped kelp
#

Alright boss, thank you boss 💯

scarlet sable
#

Is there a way to know what pixel in a block the player is looking at?

#

Or smtg close to that

#

Not what block

scarlet sable
#

It gives the angle of the head

dim tusk
scarlet sable
#

What does face location give?

#

Maybe I'm wrong

distant tulip
#

Add hitBlock.location to faceLication

scarlet sable
#

Ok

dim tusk
#
world.beforeEvents.playerInteractWithBlock.subscribe(({ block, faceLocation }) => {
  console.error(JSON.stringify(faceLocation));
  console.error(JSON.stringify(block.location));
});```
scarlet sable
#

Ty

boreal siren
#

Guys, I faced a very difficult task, I need a database with a small and non-critical number of minuses. I thought to use a dynamic property of the world, but faced a problem in the form of speed and volume of data, as well as an optimization problem. Then I thought to use NBT, but I realized that it also has problems, in the form of inconvenience in management, complexity of control and use in the future. Before that I thought to use ScoreBoarb, but immediately refused this torment, almost the same problem as a dynamic property, but it also supports only the method (key, value in a digital type) and in addition it loads the world very much, as well as tags.

#

Do you have any ideas on how to create a database?

slow walrus
#

dynamic properties are generally the best in-game database option

#

if you're having issues with performance, then you probably just need to optimise how you actually store stuff

prisma shard
#

um, why do people use scoreboards to make a entity kill counter?
woulldn't this be easier?

let counter = 0; 
world.afterEvents.entityDie.subscribe(({ damageSource.damagingEntity: player, deadEntity}) => {
  if (player instanceof Player) {
    counter++
  }
  player.onScreenDisplay.setActionBar(`Kill Counter: ${counter}`)
})
thorn flicker
#

also the variable's value wont save when you leave the world or reload the script

boreal siren
#

I want to create a base for developing different mini-games (that is, a basis or foundation for further development), such as SkyWars, BedWars, ... and the basis for this is a database in which information is stored (arena locations, statistics, settings), a system (or, more simply, a core or template with which it will work).

#

and that's why the option with the dynamic property is not suitable for me, its functionality, as it seemed to me, is not suitable

dim tusk
#

I think you should already know why they use the scoreboard.

prisma shard
#

hmm

#

right

#

yeah okay

#

thanks guys

prime pine
#

anyone know how to fix this or if this is an issue

#

is there something wrong with the code

slow walrus
prime pine
#

not in the Novalty API script folder atleast

slow walrus
#

there has to be an Amputate.js somewhere, since it's being used, and it never said it's inside the Novalty API

prime pine
open urchin
#

they are separate messages

#

so might be from separate packs

prime pine
#

oh yeah i found it

#

was in a seperate pack

#

but they both happened simoultanuesly when i did one specific actions

#

i got grok to explain it makes sense

#

and fix works

scarlet sable
#

Have anyone here made a stonecutter recipe before?

ivory bough
#

Any way to make the host of a world unable to use commands even if cheats are enabled?

sharp elbow
prime pine
#

and placing or removing a ring from the accesory menue

#

would trigger it

#

then to reduce the slow down thing

#

it basically just reduced runtimes and shi ion really know

#

but like making it run every 5 ticks instead of every tick

#

and some other stuff

#

i just told it to optimise the code

#

and copy pasted

sharp elbow
#

That does seem like some neat software

prime pine
#

don't get a slowdown at all anymore and works fine

prime pine
#

i wonder if i could literally get it to code an addon for me without doing anything myself

#

besides resources and textures which even that it might be able to do haven't tried

untold magnet
#

uh, how am I going to detect the itemStack data? ( like detecting the water bottle, its id is just potion thing,

untold magnet
unique acorn
#

yeah but it's in beta

#

the potion component is in beta

untold magnet
#

well, i think im good with make players sick with all kinds of potions

ivory bough
#

Any way to make the host of a world unable to use commands even if cheats are enabled?

unique acorn
ivory bough
unique acorn
#

no

coral ermine
#

How to spawn named entity with spawnEntity?

unique acorn
untold magnet
#

uuh, is it possible to detect when the dynamic property number has been changed?

midnight ridge
#

a system.runInterval will be enought

untold magnet
#

but how exactly

#

detecting if the value have been changed and run something for once

midnight ridge
#

or it is variable

untold magnet
# midnight ridge or it is variable

the value will be updated every like a minute or via other things like interacting or walking, so i have to detect if the value have been changed or not.

#

the value i am talking about is from 0 to 20
lets say the value is 0 and it has been updated to 5 or 6, the script will detect that update and run something for once.

midnight ridge
untold magnet
#
  • its inside of an interval
midnight ridge
#

if it is

untold magnet
#

yup,

midnight ridge
#

then give the player a tag

#

like

untold magnet
midnight ridge
#

and controle it value

unique acorn
#
let previousValue = world.getDynamicProperty("name");

system.runInterval(() => {
  if (world.getDynamicProperty("name") !== previousValue) {
    //run code...
  }
  previousValue = world.getDynamicProperty("name");
}, 2);
#

this could work

midnight ridge
#

or idk

untold magnet
#

uh,

unique acorn
#

what does that mean

untold magnet
#

my whole entire issue is with titles, i don't want to spam the titles and for some reason its kinda bugged for some reason

#

like when i change the value and send the title with the new dynamic property value, it will show the previous one instead of the new one

unique acorn
#

it only runs once btw

untold magnet
#

i tried having it inside of a runTimeout and it has the same exact issue

untold magnet
# midnight ridge do have an existing code?

if (hyd === 0) {player?.setDynamicProperty('hyd', 5); player?.onScreenDisplay.setTitle(xHydTB:${hyd})};
it should update the dynamic property value and apply it into the title, which did update the value but didn't apply it to the title

unique acorn
untold magnet
unique acorn
# untold magnet `let hyd = player?.getDynamicProperty('hyd');`
world.setDynamicProperty('hyd', 'value');
let hyd = world.getDynamicProperty('hyd'); // hyd will have the value 'value' assigned to it.
world.setDynamicProperty('hyd', 'newerValue')
console.log(hyd) // should return 'value' and not 'newerValue'

Here is an example, so in your code it should show xHydTB:0 to the player

#

does that make sense

#

I tried explaining it

#

if that is even the issue you're having

untold magnet
#

well i think i know how to fix it, instead of using a good method that is causing this issue, I'll use my bad method to make it worke 100% better than ever

#

so let's just remake somethings...

untold magnet
#

i literally used if else and it fixed everything, literally everything

fast lark
#

how can i store a string in a dynamic property

dim tusk
dim tusk
#

String, Boolean, Number, Vector3 are possible

distant tulip
#

<player|item|world|entity>.setDynamicProperty("key", "string")

distant tulip
#

Never

distant tulip
#

Np

feral geyser
#

what is a generator function and how do I use it in the context of filling large areas

shut vessel
#

what didn't work ?

                        case '!unfreeze':
                        if(!eventData.sender.hasTag("host")) return;
    var arg = msg.message.slice(11).toLowerCase();
    if (arg.startsWith("@")) {
        arg = arg.slice(1);
    }
    
    for (let i = 0; i < players.length; i++) {
            const player = players[i];
        eventData.sender.runCommandAsync(`inputpermission set ${arg} movement enabled`);
    }
    break;```
shut vessel
#

I would like that when the command executes the command according to conditions but it tells me that the "case" does not work and that the error is this famous "case"

valid ice
#

Can you send the error you’re getting

shut vessel
slow walrus
# shut vessel

you're missing the closing } of the for loop. also, please fix your formatting

shut vessel
#

the msg isnt not definited

slow walrus
#

?

#

what player name

#

there's no player name in that snippet

shut vessel
#

I have to add a "PlayerName" in const?

slow walrus
#

I got no clue bro

shut vessel
#

okk

woven loom
#

We have so many database solutions now, I believe we should make a list and add it to the wiki, so help people find them easily.

simple zodiac
#

or teach people aproches to not rely on these hacky solutions

woven loom
#

Why?

stuck ibex
woven loom
#

Hmm true IG as I have not seen anyone use more than 32kib in one go yet.

distant tulip
#

i did, but i felt like that was not efficient so i changed my method
i believe Jayly did too, although i am not sure if that was for testing or what

slow walrus
#

waiting for someone to make a SQL database

stuck ibex
#

a wiki section that guides people how to use external databases would be great

night acorn
#

is there a way to attatch a particle to an entity in script?

unique acorn
#

try slot 0

gaunt salmonBOT
#

Health display
Display player's health below player's name tag using scripts.

#

Description
Replaces chat emoji when a player types name of emojis in chat.

Credits
These scripts were written by GlitchyTurtle32

chilly moth
#

@distant tulip you can save player id with dynamic property

I tried it,
it saves my gamertag name

distant tulip
#

your method is not multiplayer friendly

chilly moth
#

hm I guess so

chilly moth
#

does anyone knows why sidebar gives number to every line?

ivory bough
#

How to detect if a block was broken in a specific structure?

distant tulip
ivory bough
# distant tulip not possible

What about using the getting block permutation through structure class and see if the block exists or not according to the structure's origin

distant tulip
ivory bough
distant tulip
#

game files or saved using structure block or command or script api

ivory bough
distant tulip
#

make a custom ticking block that run some code that let you know it is loaded

distant tulip
#

custom components

ivory bough
#

Related to what I wanna make

distant tulip
#

on tick trigger automatically

ivory bough
#

Ok maybe I am just not understanding

#

Oh wait I think I should make a dummy block in my structures and then use it's position to get the blocks in structure

untold magnet
#

uh, how am i going to detect when the player is left the world and give him a dynamic property?
playerLeave have only the playerId and playerName, i cannot give the player the dynamic property in that way..

sharp elbow
#

Can you use the PlayerLeave BeforeEvent?

#

I believe setting dynamic properties is supported within a read-only context. Correct me if I am wrong.

unique acorn
oak lynx
#

[2025-03-23 18:36:09:456 ERROR] [Scripting] Unhandled promise rejection: ReferenceError: Native property setter [ItemStack::nameTag] does not have required privileges.

#

this has to be one of the stupidest things ever ngl

unique acorn
#

I remember Coddy said that it wont be an issue anymore in before events in 2.0.0

ivory bough
untold magnet
dim tusk
unique acorn
#

wait what

dim tusk
#

Yeah, dynamic property doesn't modify the world it's just scripts so the script doesn't throw the required privilege

#

always has been, since dynamic property was out it always worked like that.

distant tulip
#

that doesn't apply to all functions that dose not modify the world

dim tusk
#

but I'm only talking about dynamic property 🤷...

distant tulip
dim tusk
#

yeah, the before events and dynamic property works fine with me.

#

I didn't try it in .70 yet.

distant tulip
#

that is how dynamic property work from the start, .70 shouldn't be any different

dim tusk
distant tulip
#

didn't read that tbh

dim tusk
#

-# my bad if it's a long video.

rose light
#

Is there any way to remove the item's durability when I use it, through CustomComponent?

shut vessel
#

Do you know what is wrong with it? There is no error message about it, but the commands are not executed as they should be.

rose light
#

I don't know why, but every now and then when I use the item, it doesn't remove the durability, but executes the command.

coral ermine
#

how to make subtitle visible without doing command for title?

coral ermine
unique acorn
#
function giveItem(player, itemId, name) {
    let newItem = new ItemStack(itemId, 1);
    newItem.nameTag = `§r` + name;
    newItem.lockMode = "inventory";

    const playerContainer = player.getComponent('inventory')?.container;
    if (!playerContainer) return;
    playerContainer.addItem(newItem);
}
coral ermine
#

it won’t work with just title command?

unique acorn
unique acorn
unique acorn
#

since there is no one running the command except for the dimension

#

which means there is no @p

#

yw

quiet oriole
#

hello i want to make a hostile entity attack a player that the player receives in the entity and can't go down until something specific happens example a ghost hits the player and the player cannot be heard go down until the ghost dies or reaches a certain height, I wanted to know if someone can help me

untold magnet
#

uh, how am i going to detect the world difficulty?

untold magnet
serene lava
#

i downloaded a train addon that use scripts for rotating the wagons inmediately, when you spawn them, so i found this script, how can i make a script with that function?

leaden elbow
#

can ayone send sleep or wait function like sleep(ticks)

wary edge
dawn zealot
#
        commands.forEach(command => {
            world.getDimension(`overworld`).runCommand(`execute as ${sender.name} at ${sender.name} run ${command}`);
        });
```anyone know why this shit just not working
unique acorn
#

idk maybe provide more of the code

#

make sure your min_engine_version is 1.20 or higher

dawn zealot
#

it is

#

is it because its in a beforeChat event

unique acorn
#

are you using system.run?

dawn zealot
#

no

unique acorn
#

then that's why

#

wrap the runCommand part in system.run

dawn zealot
#

oh yeah i gforgot that existed

shut citrus
#

How to check all block's data can't be saved?

#

or the block

untold magnet
#

detecting chatmessages is beta right?

dim tusk
untold magnet
#

damn, but whatever

untold magnet
#

i mean making u not losing thirst with the peaceful difficulty is not that necessary tbh

distant tulip
#

yeah, you could make your own entity
but that is the only way in stable currently

untold magnet
leaden elbow
#

is it possible to check if player has operator permission wo using tags

distant tulip
terse pulsar
#

Help

thorn flicker
terse pulsar
#

I hate that

#

I have some issues that i got on #debug-playground

#

I dont know how to solve

valid ice
#

Anyone know why glass is considered a "passable block" in raycasts?

wary edge
valid ice
#

Then they should introduce a third filter for solid/non-solid and separate the two

valid ice
#

Because by "passable" I assume "walkable by player" (vines, ladders, flowers, glow lichen, etc)

wary edge
#

Vsauce, Smokey here.

valid ice
#

However, it also includes leaves, scaffolding, slabs, cauldrons(!!), campfires, grindstones, lecterns, end portal frames, glass panes & glass in that category

wary edge
#

I wanna check the Java code again because i think my adk script lib references passable.

valid ice
#

added some things I just tested to the list

#

yikes 😬

dim tusk
#

iirc someone made a post in #1067535382285135923 saying includePassableBlocks doesn't work as intended.

valid ice
#

welp

prisma shard
leaden elbow
#

i need help regarding setting preserved title text on all players. these values exist, its just only 1 title shows. i tried to use waitTicks but still showing the last setTitle but i want to show them all

system.runInterval(() => {
 function setTitle(title) {
   return world.getDimension("overworld").runCommand(`title @a title ${title}`)
 } 
  
   const active = db.getByIndex("quests", 0);

 setTitle(`qt:${active.name}`)
 setTitle(`qd:${active.type}`)
 setTitle(`qp:${active.progress}`)
})
prisma shard
leaden elbow
#

its a customized db made by me

#

for arrays

prisma shard
#

one sec

prisma shard
#

@leaden elbow

leaden elbow
#

let me try one sec

prisma shard
dim tusk
#

nvm

#

either way that's unnecessary

#

Why put in dimension if you still use title @a

#

Or use the player's dimensions itself

distant tulip
prisma shard
#

oops

prisma shard
#

thx

distant tulip
prisma shard
shut citrus
#

how to save 1 block using structure manager?

prisma shard
#

why would you

leaden elbow
dim tusk
#

There's no better way to check if the player is actually loaded, like see the blocks etc

leaden elbow
#

also are javascript Set() supported in script api?

dim tusk
lyric kestrel
#

Ah I just realised I could use Set in a better system for my blocks if I ever want to improve it that horrendously more

prisma shard
dim tusk
prisma shard
#

thanks!

dim tusk
#

i benchmark it before and doing Set.has() is faster than Array.includes() not noticeable in small cases but yeah

dim tusk
#

like you do the [0] if you get what I meant.

prisma shard
#

oh

#

there's no way to?

dim tusk
prisma shard
#

ah

dim tusk
# prisma shard ah
const set = new Set([10, 20, 30]);
const array = [...set];
console.log(array[0]);```
#

ohh shiit

slow walrus
#

pretty cool

prisma shard
#

yeah cool

dim tusk
#

You can also dojs const set = new Set([10, 20, 30]); const [first] = set; console.log(first);

dim tusk
terse pulsar
#
system.runInterval(() => {
    world.getAllPlayers().forEach((player) => {
        const chakra = player.getDynamicProperty('chakra')
        const chakraLimit = player.getDynamicProperty('chakraLimit')
        const dojutsuMode = player.getDynamicProperty('dojutsuMode')
        const cost = player.getDynamicProperty('cost')
        player.onScreenDisplay.setActionBar(`§e ${chakra}`)
        if (dojutsuMode !== 'none') {
            player.setDynamicProperty('chakra', chakra - cost)
        } else {
            if (chakra <= chakraLimit) {
                player.setDynamicProperty('chakra', chakra + 1)
            }
        }
    })
},20)
#

Why doesnt work?

gaunt salmonBOT
# terse pulsar ```js system.runInterval(() => { world.getAllPlayers().forEach((player) => {...

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 3 errors:

<REPL0>.js:9:49 - error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.

9             player.setDynamicProperty('chakra', chakra - cost)
                                                  ~~~~~~

``````ansi
<REPL0>.js:9:58 - error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.

9             player.setDynamicProperty('chakra', chakra - cost)
                                                           ~~~~

``````ansi
<REPL0>.js:12:53 - error TS2365: Operator '+' cannot be applied to types 'string | number | boolean | Vector3' and 'number'.

12                 player.setDynamicProperty('chakra', chakra + 1)
                                                       ~~~~~~~~~~

Lint Result

There are no errors from ESLint.

terse pulsar
#

Here the error that i got with full code

#
main_6.js:100:41 - error TS2365: Operator '>=' cannot be applied to types 'string | number | boolean | Vector3' and 'number'.

100                                     if (player.getDynamicProperty('chakra') >= mode.cost) {
                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``````ansi
main_6.js:123:49 - error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.

123             player.setDynamicProperty('chakra', chakra - cost)
                                                    ~~~~~~

``````ansi
main_6.js:123:58 - error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.

123             player.setDynamicProperty('chakra', chakra - cost)
                                                             ~~~~

``````ansi
main_6.js:126:53 - error TS2365: Operator '+' cannot be applied to types 'string | number | boolean | Vector3' and 'number'.

126                 player.setDynamicProperty('chakra', chakra + 1)
                                                        ~~~~~~~~~~

```
granite badger
#

you just repeated what i did... would be great to get the error from content log

terse pulsar
#

Ok

small cloak
# stuck ibex probably redundant cus dnyamic properties are already good

Dynamic properties are good, but I wish they had functions similar to Map's. You kind of need to make a wrapper to make them actually usable (Especially if you value performance).

Also not sure how I feel about string chunking. I feel like you're doing something wrong if you're storing that much data.

#

Something to also consider is that the dynamic property API can change in the future. Having a wrapper is good so you only need to update your code in one place instead of a million different places.

lyric kestrel
#

like Set("a", "b", "c"), etc

stuck ibex
small cloak
#

There's just little things that are annoying. Like deleting a property shouldn't require setting it to undefined.

#

Checking if a property exists isn't straightforward too. Especially if the value can be falsy.

small cloak
#

I never said it was hard. It just doesn't look good when you're reading the code. An explicitly named function that returns a boolean is better.

slow walrus
#

hmm, well that's what a wrapper is good for

small cloak
#

That's exactly my point. 😅

slow walrus
#

otherwise if you're checking if a value exists, then grabbing it, you're wasting an extra native call instead of just checking if the fetched value is undefined

ivory bough
#

How to make my entity have a chance to replace the block beneath it with another block when its walking?

dim tusk
shut citrus
#

how to detect a block can store like chest, shulker box?

dim tusk
shut citrus
dim tusk
#
const inventory = Block.getComponent('inventory')?container;
if (inventory) {
  // ...
}```
dim tusk
#

I'm lazy to fix. 😝

round bone
#

😅

shut citrus
#

ok

shut citrus
dim tusk
shut citrus
#

sign block

ivory bough
#

How to make my entity have a chance to replace the block beneath it with another block when its walking?

dim tusk
lyric kestrel
ivory bough
#

need

dim tusk
#

This is for entities not players right? If yes then that's the only thing you could do.

boreal siren
#

Guys, is it possible to use scripts to make an item fly in the air and be impossible to pick up?

dim tusk