#Script API General

1 messages · Page 127 of 1

fallow minnow
#

im about to fully restart the vps so i can use docker

#

i have so much random stuff on it 😭

#

and docker is so nice

round bone
#

😉

fallow minnow
#

yeah its so easy to run multiple things at once

#

so i dont have to use pm2

#

but i will only use docker for the database and othe rmisc stuff

#

i think i should run a discord bot and the bds on pm2 just for easy production

fallow minnow
#

does script api have access to process env?

round bone
#

The closest thing are server's secrets

supple perch
#

yoo

#

i haven't scripted in a while

#

hope y'all are doing nice

#

so anyone know how many ticks i have to wait before a chunk is loaded by a ticking area command?

wary edge
#

Any reason you're using commands and not the ticking area manager?

supple perch
#

there's a ticking area manager?

#

wow

#

got a link to the docs?

supple perch
#

thanks

honest spear
#

Nice

untold magnet
#

so, im making my entity summons other entities close to it, and its showing alot of logs when the entity is not loaded or the spawning area is inside an unloaded chunk, so how am i going to detect if the spawning location is valid or not?

fallow minnow
#

chunk.isvalid or something

#

and entity.isvalid

untold magnet
#

what i should do is adding a limit to the amount of mobs it will spawn, so it wont really not spawn anything by leaving the entity inside the unloaded chunks, like it waits for the chunks to be loaded to spawn the entities.

#

but wait, that means there will be a runinterval that detects the loaded chunks, which is not great for TPS, so i think ill just remake the idea or something

untold magnet
#

yeah, i just tested it out, the way it spawns those entities are just too bad, so i have to remake it completely.

native osprey
#

has someone managed to do a right click run command on item that can spare some code?

round bone
native osprey
round bone
native osprey
#

Oh ok, hmm, there is a way to replace sendMessage with running a function or not?

#

Like the idea i have is creating a magic system that uses a staff as the running object and depending on the offhand item it runs a different spell

snow knoll
#

But you should really just read the documentation to see what you can do with what

native osprey
snow knoll
#

Not everything is a custom component

native osprey
#

It isnt?

snow knoll
#

This is just a scripting method

#

And the script is just an event

native osprey
#

No wonder why i was lost

snow knoll
#

Understandable, things are a little hard to understand at first but its really good your addon when you get the hand of it

native osprey
#

Yeah, tbf i had no idea of scripting until like 2 weeks ago...

snow knoll
#

Late to the party, I see (I was too but we all got to start somewhere)

#

Want an explanation of the way these things work
By these things, I mean events, custom components, classes and objects?

native osprey
#

Im so lost now

native osprey
#

okay im here... i have to replace surce.sendMessage with runCommand right?

round bone
#
import { world, Player } from "@mincraft/server"

world.afterEvents.itemUse.subscribe(({ source, itemStack }) => {
    if (source instanceof Player) {
        switch (itemStack.typeId) {
            case "magic:elemental_staff":
                source.runCommand(`say test!`)
                return
        }
    }
})
native osprey
#

with this i can then make it run a function and in the function create all the different cases

native osprey
honest spear
#

i am refering to the gift you send

snow knoll
# native osprey Im so lost now

Basically:

  • Events are listeners that set of when subscribed to with code used. They come in the form of either a beforeEvent or an afterEvent, which run the code either before or after the actual event occurs in-game. If using a BeforeEvent there is the chance of being able to cancel the event from occurring, which would stop the effects of the event from happening. For example, canceling the itemUse beforeEvent would prevent an item from being used
  • Custom components are simplified events, of which you can access event handler functions, like onUse, and work in a similar way to events, designed yo be more beginner friendly and more reliable (so I've heard)
  • Classes are representations of the state of any given thing in the game. A thing being sonething like items, the world, blocks, dimensions, players, and more (those are some of the most important ones, though)
  • For each of these classes, an object is the actual instance of said class, for example, an object of the item class is a real item, an object of the entity class is a real entity, an object of the player class is both an object of the player and entity classes, since the player class extends/adds onto the entity class
native osprey
#

oh! thanks that helps, now it makes more sense now

#

i have another question then, is possible to add another event in here right?

#

in this case to add cooldown to the object im using i would need to link it with world.afterevents.itemuse?

#

oh wait...

snow knoll
native osprey
native osprey
cunning canyon
#

Should I use arrow functions or normal functions?

I usually always use arrow functions but don’t know why exactly, I just took the advice lol

subtle cove
sharp elbow
#

One major disadvantage to arrow function literals is they have no assigned name. Across larger projects or larger teams, it may not be as easy to navigate stack traces when they frequently say at <anonymous>
Arrow functions have their use yet IMO they are best saved for either object properties (being more like lambdas) or for preserving the this callsite (for classes and similar cases)

native osprey
#

Hi again, so after the help with runCommand i managed to advance a lot on my mod! The only thing left is... How can i add a cooldown... Accidentally... Made a super op attack named "Extermination light" that people can spam ._.

last latch
#

if they do have a cooldown, cancel the extermination light

#

for cooldowns use "Date.now()" to get the current time and add "Date.now() + (1000 * cooldownInSeconds)"

native osprey
#

Um... Can you put it in simpler terms?

#

I havent modded since 1.15

last latch
#

Not sure how to say it any simpler

#

hold up gimme a sec

last latch
#

Date.now() returns the time in miliseconds of the server. So when the player uses the item you set the players dynamic property to the Date.now(), but you will have to add the cooldown to the overall time. so Player.setDynamicProperty("cooldown", Date.now() + 1000 * cooldownInSeconds).

Once the player tries to use that item, you check using Player.getDynamicProperty("cooldown") if Player.getDynamicProperty("cooldown") < Date.now()

#

@native osprey

native osprey
#

This goes in main.js?

#

it has to go here?

last latch
marble sigil
#

@minecraft/server-gametest still experimental?

round bone
round bone
marble sigil
# round bone Yes

Bruh.

I’m building something very cool, that many players wanted but other add-ons couldn’t give. 👀

marble sigil
#

Lemme send a video

marble sigil
shell sigil
#

jk

native osprey
native osprey
round bone
native osprey
round bone
#
"minecraft:cooldown": {
    "category": "magic:elemental_staff_cooldown",
    "type": "use",
    "duration": 0.8
}
#

Category is a namespace of this, "use" that you've provided should be in "type" field. Just copy it and should work fine. I think you just need to check if cooldown is over 0

round bone
# native osprey it has to go here?

So in this script, you just have to check for cooldown:

import { world, Player } from "@mincraft/server"

world.afterEvents.itemUse.subscribe(({ source, itemStack }) => {
    if (source instanceof Player) {
        switch (itemStack.typeId) {
            case "magic:elemental_staff":
                if (source.getItemCooldown("magic:elemental_staff_cooldown") > 0) return
                // This code will only trigger, if cooldown has passed.
                source.runCommand(`say test!`)
                return
        }
    }
})
native osprey
#

im trying but now it doesnt let me use the item at all

#

it doesnt show errors or anything, it just doesnt run the command

round bone
#

Can you show me your current code?

#

Try coping and pasting again

native osprey
#
    "format_version": "1.20.50",
    "minecraft:item": {
        "description": {
            "identifier": "magic:elemental_staff",
            "menu_category": {
                "category": "equipment"
            }
        },
        "components": {
            "minecraft:max_stack_size": 1,
            "minecraft:icon": "elemental_staff",
            "minecraft:glint": true,
            "minecraft:allow_off_hand": true,
            "minecraft:damage": 5,
            "minecraft:cooldown": {
                "category": "magic:elemental_staff_cooldown",
                "type": "use",
                "duration": 0.8
            },
            "minecraft:can_destroy_in_creative": false,
            "minecraft:durability": {
                "max_durability": 1080
            },
            "minecraft:repairable": {
                "repair_items": [
                    {
                        "items": ["amethyst_shard"],
                        "repair_amount": 270
                    }
                ]
            }
        }
    }
}```
#

world.afterEvents.itemUse.subscribe(({ source, itemStack }) => {
    if (source instanceof Player) {
        switch (itemStack.typeId) {
            case "magic:elemental_staff":
                if (player.getItemCooldown("magic:elemental_staff_cooldown") > 0) return
                // This code will only trigger, if cooldown has passed.
                source.runCommand(`say test!`)
                return
        }
    }
})```
round bone
#

3 backticks (`)

marble sigil
#

Copy paste like this:
```js
cide```

fallow minnow
#

@round bone i exposed the database i think its all secure

#

hopefully no one can access or write to the data

last latch
last latch
native osprey
#

The black message it shows?

last latch
distant tulip
#

anyone have a working A* algorithm? i had problems with the one from nox7

north rapids
#

Is there a way to call a scriptEvent without using commands? I've never used it before.

round bone
round bone
#

Do you refresh these keys?

#

You don't really have to tbh, if you have a constant key that you'll change every single few weeks, it should be already fine

fallow minnow
#

its super simple but eh

#

if anyone somehow gets access they will need to find both jwt so

round bone
devout sandal
#

for dimension.playSound(sound, location, {pitch: }), what is the default pitch, and what are the ranges, i cant find info on it anywhere..

marble sigil
devout sandal
snow knoll
round bone
snow knoll
#

Damn
News to me

round bone
marble sigil
#

But you can execute the command also.

#

In simple words, it’s possible to call command if you can call that method.

worldly heath
#

how lightweight is dynamic properties?

#

is it a bad idea to use getdynamicproperty() every tick

woven loom
#

ye

marble sigil
worldly heath
#

is it same case for scoreboards if i use getscore

round bone
round bone
summer cloud
#

How do i create my own custom unicode charecter

distant tulip
north rapids
north rapids
marble sigil
round bone
#

Also, it's always better to use native methods

marble sigil
marble sigil
round bone
round bone
#

There are some samples on #1067535712372654091 also

fallow minnow
#

does anyone know why bds is corrupting my worlds?

#

i made a void world and applied it to the server but when i join its just a default vanilla worldf

#

every single time i put a world on it

round bone
fallow minnow
#

i had to zip then download it

round bone
#

Nice

fallow minnow
#

it says its running on endstone yet the SDK doesnt wanna work

round bone
fallow minnow
#

no they have a script api sdk so i dont have to use python or c plugins

#

it just builds on top of bds

#

u can grab xuid, ip, ping, set boss bars and other things

round bone
#

This error is probably related only to Endstone rather than pure BDS

fallow minnow
#

yeah for sure

#

but its running endstone so like idk

round bone
fallow minnow
#

wdym??

round bone
# fallow minnow wdym??

XUID you can read out of console, bossbars are possible via JSON UI, for rest of props you can use a proxy

fallow minnow
#

boss bars are possible via json ui yes but endstone has client sided ones

#

which i need for displaying stats

last latch
#

Is it one related to permissions on windows?

cyan basin
#

All I get is this error when trying to use the ScriptSDK on Endstone

last latch
#

Someone said use docker but I installed Linux instead so yeah

#

I wish endstone wouldn’t be that dead support-wise

fallow minnow
#

but i found out what was wrong

cyan basin
#

Yeah I used docker and for whatever reason it killed my internet connection on my computer

fallow minnow
#

i didnt have the whl plugin in my plugins folder

#

but it all works now

cyan basin
#

Not sure how it corelates to that but somehow it was slowing my speed down so much it made my PC unuseable until I uninstalled it

last latch
last latch
#

It would be harder to develop using it but still better than nothing

haughty kernel
#

Is it possible for me to make an entity catch fire via the API?

woven loom
#

yes

haughty kernel
#

;-;

#

How could I do that?

haughty kernel
#

I thought it was something more complex.

midnight ridge
#

is there a way to get the texture of a specific item even if it is in another addon and put it as an icon to the buttons inside forms?

strange marsh
round bone
cyan basin
#

Yeah, I wouldn't recommend it lol

unique apex
#

hey does anyone mess with simulated players? i cant get mainhand and offhand to update correctly (or more accurately, automatically) as even if its inventory is full nothing appears in the mainhand unless I reload the world.

cyan basin
# warm mason no

why not? it's all just resource packs right.. forms can read from any resource pack lol

distant tulip
#

you can't know the texture path from script api

cyan basin
#

what?

#

if they meant pulling the texture from an item then sure you can't do that but just putting a texture from any resource pack is fine

distant tulip
#

yes that what he asked for

cyan basin
#

🤷‍♂️

distant tulip
#

i guess you could use json ui

cyan basin
#

oh actually true.. if you use aux ids lol

latent wing
#

Does anyone know why the subscribe property isn't being read when I use this line? I want to display ranks and such when a player sends a message.

mc.world.beforeEvents.chatSend.subscribe(eventData => {
latent wing
wary edge
#

That's your issue.

latent wing
latent wing
#

I need to get the beta test, right?

wary edge
#

Use beta apis and the beta module.

latent wing
#

👍

#

Thanks for the help

fresh comet
#

How do I still getBlockFromViewDirection() even if its air with maxDistance of 10, I just want to get the location to what my cursor is pointing in certain distance

fresh comet
#

Thanks, I'll try that

#

I knew it needs MATH

fresh comet
unique dragon
buoyant canopy
#

I am checking before i commit into an idea i end up scrapping, can we get and set mob equipment? like the weapon a zombie is holding?

buoyant canopy
#

so commands won't really work for me

wary edge
#

Then no.

buoyant canopy
#

most likely a no, but is it possible to force a mob to swing their arms? not by playing a custom swing animation

#

like the java swing command

sharp elbow
#

There is the hasitem selector argument. It can query item ID, slot, amount, and data value. Though it doesn't sound like it is very useful in your case

buoyant canopy
sharp elbow
#

Aye, enchantments on non-player equipment seems to be a rather big hole in Bedrock tech right now

buoyant canopy
#

it's a simple class inheritance that could fix the problem but they still didn't do it

buoyant canopy
#

What happened to dimension.getGeneratedStructures()?

thorn flicker
#

its in beta.

buoyant canopy
distant tulip
#

last time it was mentioned is in .120 experimental section

woven loom
#

Hey @distant tulip, could you please send me your replaymod pack that includes entity riding and other stuff?

distant tulip
fallow minnow
#

are the inventory events in here yet?

#

or something where i can get the item they pickup

distant tulip
fallow minnow
distant tulip
#

No

fallow minnow
#

yay 2 month wait

cobalt hollow
tidal wasp
#

Can getComponent be used with actually minecraft block components like material_instances and redstone_consumer

wary edge
marble sigil
#

Anybody knows how to know if a player is in “i-ticks”? Ideally for how long too.
I-ticks are likely the Invulnerability Ticks, that Red state when hurt.

#

In a script

deep arrow
#

I hate quickjs 😔

stray spoke
#

quick?

round bone
distant tulip
jade grail
#

afterevent it is im prety sure

#

its not in stable

warm mason
marble sigil
#

How to make a Splash potion of instant health II ItemStack?

warm mason
#

inventory change event is in stable

warm mason
distant tulip
jade grail
distant tulip
#

that is not how "pretty sure" work but alright

fallow minnow
#

im having some issues

#

im just trying to detect certain items the player picks up and re name them

#

but some of the items error

#

like when i drop cobblestone its fine

#

but when i pick it up it errors

#

yeah its weird

#

i need to detect the picked up item

midnight ridge
#

any one know where can i found the exact same behavoir files for the vanilla pickaxes?

fallow minnow
#
world.afterEvents.playerInventoryItemChange.subscribe((data) => {
    if (!data.beforeItemStack.typeId || !data.itemStack.typeId) return
    console.warn(`${data.itemStack.typeId} picked up`)
    if (SELLPRICES.find(v => v.id === data.itemStack.typeId)) {
        const price = SELLPRICES.find(v => v.id === data.itemStack.typeId)?.price ?? 1;
        const mutationLore = data.itemStack.getLore()?.find(lore => lore.startsWith("§")) ?? null;
        if (mutationLore) {
            const invisibleId = mutationLore.split(" ")[0].split("").map(ch => ch.replace("§", "")).join("");
            const mutation = MUTATIONS.find(m => m.id === invisibleId);
            if (mutation) {
                const finalPrice = Math.floor(price * mutation.multiplier);
                data.itemStack.setLore([`§f`, `\uE141 §r§v${finalPrice} §7each`]);

            }
        } else {
            data.itemStack.setLore([`§f`, `\uE141 §r§v${price} §7each`]);
        }
    }
})``` i just get cannot read property typeId of undefined
subtle cove
#

?.typeId

fallow minnow
#

yeah but why is it erroring when i pick up cobblestone

#

or any item

subtle cove
#

beforeItemStack can be undefined

#

and when dropping an item, itemStack can be undefined

fallow minnow
#

okay that fixes the error

#

but

#

when i drop it doesnt log anything

#

i dont get a "picked up"

subtle cove
#

the top guard clause should different then

drowsy scaffold
#

How does the volume property work for entityQueryOptions? I'm trying to use it to get entities to remove, but it returns a empty array

const removedEntities = overworld.getEntities({volume:cosmetics.from, location:cosmetics.to, excludeTypes:["minecraft:player"]})
subtle cove
#

its like dx

drowsy scaffold
#

ah I see I see

#

thank you sir

floral copper
#

guys can anyone briefly explain how custom components work?

subtle cove
#

from my perspective, it's just like a frozen json object where u can only read it's contents (string, number, boolean)

#

which is defined in .json

warm mason
# floral copper guys can anyone briefly explain how custom components work?

U have to register a component in a script, like this:
⁨⁨```js
system.beforeEvents.startup.subscribe(startup => {
startup.blockComponentRegistry.registerCustomComponent('my:custom_block_component', {
onPlayerBreak: ((data, params) => {
data.player.sendMessage('You broke ' + data.block.typeId + ' with params: ' + JSON.stringify(params.params));
})
});
});

then, when you're making a block, in it's components u need to add your component, for example:
⁨⁨```json
"components": {
  "my:custom_block_component": {
    "param1": 1,
    "param2": [1, 2, 3]
  }
}
```⁩⁩

then u can add some events in component (in script) and if a block has this component, it will trigger the events. All events u can find here: https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/blockcustomcomponent?view=minecraft-bedrock-experimental

And u also can use the params, that u specified in json

Contents of the @minecraft/server.BlockCustomComponent class.

gaunt salmonBOT
subtle cove
warm mason
subtle cove
#

just some object crawler

wary edge
warm mason
wary edge
#

Performance reasons.

#

As always.

zinc breach
#

is there a function or something that lets you cause explosions and control their power

#

and like when are we getting an event that listens for crafting bro 💔

lucid dust
#

np

deep arrow
last latch
deep arrow
#

also its not using script api

knotty plaza
deep arrow
warm mason
knotty plaza
deep arrow
#

SerenityJS

warm mason
knotty plaza
deep arrow
#

When I tried on script api first it got about 1.7% the normal speed of a gameboy

deep arrow
#

So my sanity is still gone

#

But it's functional

deep arrow
last latch
#

if serenity is out of beta

deep arrow
#

Oh

#

Umm idk tbh

#

I didnt know there was a "beta"

#

Its constantly updating but has beta releases like script api does, stuff that is in testing before stable

gaunt salmonBOT
last latch
fresh comet
#

I just need some help with this formula, I want to increase the view distance by atleast 5, afterany tries I still dont know how.
If possible, how do I make it detect the nearest block in range instead of bypassing it

export function blockFromView(player,prop){
  const lastPlace = player.getDynamicProperty(prop)
  
  if(!lastPlace) return;
  const viewDir = player.getViewDirection()
  const headLoc = player.getHeadLocation()
  const facing = {
    x: (headLoc.x + viewDir.x),
    y: (headLoc.y + viewDir.y) - 1,
    z: (headLoc.z + viewDir.z)
  }
  return player.dimension.getBlock(facing)
}
snow knoll
fresh comet
#

That will not detect air tho

#

But I've tried to do both functions that if getBlockFromViewDirection failed, it uses getViewDirection instead

stray spoke
#

Yo

#

What script do I make

buoyant canopy
#

in pistonActivate afterEvent, when does piston.isMoving return false?

buoyant canopy
last latch
marble sigil
#

I have a duration parameter in my custom command, should I have it in ticks or in seconds, and should I specify the format in name like "Duration in ticks"?

distant tulip
#

Depends

lucid dust
#

what's the best way to check if a slot in the player's inventory is empty? my script keeps crashing because it "cant read property 'typeId' of undefined" when the slot is empty :(

thorn flicker
lucid dust
lucid dust
thorn flicker
lucid dust
lucid dust
#

the entire script stopped working after though?

thorn flicker
#

I thought you meant crashing your game/world.

subtle cove
lucid dust
subtle cove
#

return item?.typeId ?? ""

thorn flicker
subtle cove
#

well, that's how itemStacks has been anyway

lucid dust
round bone
nova flame
#

in addition?'

buoyant canopy
#

why is entity.getRotation().y always 74.51033...

#

i want to get the block the entity is looking at but the result of getBlockFromViewDirection is incorrect
so i am trying to calculate it myself but rotation is also incorrect

#

entity.getRotation().y seems to return the rotation the entity spawned facing

jagged gazelle
buoyant canopy
jagged gazelle
buoyant canopy
buoyant canopy
jagged gazelle
#

I guess u already knew that??

buoyant canopy
jagged gazelle
#

I dunno then, I never had a problem with ray casting

jagged gazelle
buoyant canopy
jagged gazelle
#

Don't need to send it twice bruh

buoyant canopy
#

meant to send this

buoyant canopy
jagged gazelle
#

It's the direction of the entity

#

Not the ray casting itself...

buoyant canopy
#

wdym?

jagged gazelle
buoyant canopy
#

ok...

jagged gazelle
#

obviously but what I meant is the value you put itself

#

try to create a particle ray using the direction of the zombie facing

buoyant canopy
#

what value do i put? getRotation is bugged also

buoyant canopy
#

how do i get the direction?

jagged gazelle
#

getViewDirection

jagged gazelle
buoyant canopy
#

i already know the result but i am trying it anyway

jagged gazelle
#

yeh, I just want to know if the direction is actually correct

buoyant canopy
#

it's spawning in the direction the entiry spawned facing

jagged gazelle
#

I can't think of anything to why wouldn't ray casting work properly unless the params put is broken

buoyant canopy
#

even relogging doesn't change the view direction, it's definitely bugged

#

commands it is

jagged gazelle
#

then it's the getViewDirection and getRotation not the blockRay

round bone
jagged gazelle
#

oh btw, use ruInterval and keep checking the view direction value

#

if it's actually not changing if they turn, then that's the problem but if it does, then it's how you set it up is the problem

buoyant canopy
#

i have discord on laptop but i don't launch it on startup to save battery

buoyant canopy
sage sparrow
#

hi there! have mojang made any change to the item consumption after cooldown ends? something is happening to my when I use a item that has cooldown it is being removed when the cooldown ends

nova flame
#

legendary bio

snow knoll
buoyant canopy
#

how can a man get which block a mob is looking at???

warm mason
buoyant canopy
buoyant canopy
#

except player

warm mason
#

I mean, API version

buoyant canopy
#

2.4.0

#

stable

warm mason
#

or wait

#

it's preview only..

buoyant canopy
#

it wouldn't matter because even the command using ^ ^ ^ doesn't work

#

what is preview only?

warm mason
#

or no?

buoyant canopy
#

yeah

warm mason
buoyant canopy
#

in a new world, i ran the command to spawn a particle at ^^^1

buoyant canopy
#

the x and z direction only update when the entity spawns, moves or gets hurt, but the y direction updates immediately when they move thier head

#

i am wondering if molang queries would work

pearl wave
#

Hello! Do I need to install npm to run script api inside of minecraft? It's throwing an error of not finding "@minecraft/server"

warm mason
#

and show manifest.json

#

there should be a dependency with server module

#

Like this

pearl wave
#

This is what I have

#

And this is the error

nova flame
#

@pearl waveshow full manifest

warm mason
pearl wave
fallow minnow
#

is it possible to give myself a spawner with data already in it without using structures

#

like a cow spawner

nova flame
#

wtf is that

warm mason
fallow minnow
#

actually i might know a way

nova flame
#

what am i saying

fallow minnow
#

can i set blocks with certain data?

nova flame
#

noob

warm mason
pearl wave
fallow minnow
warm mason
#

use structures

fallow minnow
#

ughhhhh

#

structures for each spawner

nova flame
#

@fallow minnowwhat u making now

fallow minnow
#

and i dont wanna do custom spawners

#

well the only reason is performance

warm mason
fallow minnow
#

because they are for different mobs

warm mason
buoyant canopy
fallow minnow
warm mason
fallow minnow
buoyant canopy
#

i am done. it's just impossible

distant tulip
#

what are you truing to do @buoyant canopy

buoyant canopy
distant tulip
fallow minnow
# warm mason .

well the mob spawner doesnt just spawn every mob.. so i need spawners for each mob

weary merlin
#

I kinda did something similar

fallow minnow
#

i was thinking of like

#

giving them a spawner with invisible lore on it ( not stackable ) which determines the type, then i just have structures that load when i place the block to replace it with the correct type

buoyant canopy
north rapids
#

Is there any way to detect which face a block has been mined on?

weary merlin
jagged gazelle
fervent topaz
#

anyone know how to register new js files

#

mid game

marble sigil
fervent topaz
#

no i mean when i import it

#

it says my file doesnt exist

fallow minnow
#

Can’t mid game

marble sigil
#

It’s a ES standard. It shall be possible.

deep arrow
alpine ibex
#

Hello May I ask a Question here but erm can you Use Get Component for Potion effects or some way? In beta or stable

#

Nvm

thorn flicker
#

there's a potion class

marble sigil
# deep arrow Do u mean cant..?

Shall = must. Think will + must.
My statement is that “dynamic imports” are a ECMAScript standard, so they must be possible in the game.

granite cape
#

hi

weary merlin
#

hey

fallow minnow
#

can i add xp to someone without summoning it and using run command

weary merlin
#

Nope they have to be in game

weary merlin
weary merlin
wary edge
weary merlin
#

Quick question, is there any tool to help with development? I want my BP and RP to be in the same file and export it to the right folders

weary merlin
wary edge
fallow minnow
#

im using beta api

#

2.5 beta

#

is that why

wary edge
#

It shouldn't. Do you have any other NPM types installed?

fallow minnow
#

nope just these

wary edge
#

Is there any conflicts? I know there are times where installing server-ui meant the server npm types got outdated.

fallow minnow
#

i mean i can try to reinstall the types

#

or ill just try server

wary edge
#

#1067535608660107284 message

#

#1067535608660107284 message

#

Yeah I was right.

fallow minnow
#

soo do i just uninstall all node modules

#
{
  "dependencies": {
    "@minecraft/server": "^2.5.0-beta.1.21.132-stable",
    "@minecraft/server-admin": "^1.0.0-beta.1.21.131-stable",
    "@minecraft/server-net": "^1.0.0-beta.1.21.131-stable",
    "@minecraft/server-ui": "^2.1.0-beta.1.21.131-stable"
  },
  "overrides": {
    "@minecraft/server": "2.5.0-beta.1.21.132-stable"
  }
}
``` i uninstalled server and added ovverride then installed it back and i still dont get the correct things
#

i deleted my node modules now all types are fucked

#

after re installing

#

yeah im reverting back to my other node modules, i dont need addExp that bad

#

not until they fix their shit node modules

wary edge
#

5036shrug I mean, you can always just use it without the types.

fallow minnow
#

true actualy

weary merlin
#

Or add it directly to the Player class thats what I do when I know it is a thing and not showing

wary edge
#

Summon creeper -> trigger the event to apply the component. You can check the files for the exact event.

nova flame
#

?

#

WHAT

steep hamlet
#

yall think ⁨playerInventoryItemChange⁩ is supposed to trigger everytime on ⁨/reload⁩ or does it make sense to?
for my script its usefull doing that but if its not intended and it could be "fixed" one day id rather change it now

wary edge
sharp elbow
#

Last I recall it did. And it triggers once for every item in the inventory IIRC

steep hamlet
#

it triggers it 8 times on worldLoad

#

it doesnt trigger for reload though mb

weary merlin
#

I'm guessing when the player loads or the world loads into the world, the item in that slot is changed or added from previously stored data

#

but i could be wrong

covert goblet
#

I have a lot of dynamic properties being read and written for a stats addon, does anybody know of any resources that could point me towards better efficiency?? Ive read that using a map to cache the data and writing it to the property at a later date is better??

median radish
#

Also sure, map will be more efficient if you save stuff in a smart way (risk loosing data on server shutdown or crash)

covert goblet
inland merlin
#

Does the damage cancel stop players from destroying armor stands?

valid ice
round bone
#

You can access this via:

import { world } from "@minecraft/server"

// And all methods/props etc. will be there
world.scoreboard
nova flame
#
const form = new ModalFormData()
        .title("Add Bounty")
        .label(`§fCoins: §e$${getScore(player, "Coins")}`)
        .dropdown(
            "Select player to add bounty on:",
            allPlayers.map((p) => p.name),
        )
        .textField("Enter bounty amount:", "e.g. 100");

    form.show(player).then((res) => {
        if (res.canceled) return;

        console.warn(parseInt(res.formValues[1]));```
#

im pretty sure this used to work fine

#

idk whats wrong

warm mason
nova flame
#

ohh ok

warm mason
#

well, u need to get res.formValues[2] instead of res.formValues[1]

nova flame
#

is this a new thing?

warm mason
nova flame
warm mason
#

in this case u can use .body

wicked girder
#

Anyone know why this specific new Date() doesnt wanna work? If I put anything inside it (ive tried nothing, any kit value, any number), it crashes the world. but removing it works fine.

marble sigil
#

I have a custom command, but it uses logic in system.run using ModalFormData and it can’t return a CommandStatus instantly. I get an error in console.
It doesn't mess with functionality, but when I want to error, it doesn't let me.

#

Shall I use await somehow?

buoyant canopy
#

how to check if a string resolves to a block id?

#

preferably without commands or try catch

deep quiver
#

store a map with all valid block ids

buoyant canopy
#

surely there is a better way

wicked girder
warm mason
cobalt hollow
#

for dyanmic properties is it 8MB total across every DP in the world including item DP's? Or is it only ones saved to the world.

distant tulip
cobalt hollow
#

by ages ago i mean like 2 years ish ago

#

its just always been in my mind

distant tulip
#

there is no limit afaik
unless you hit the key limit
and that is kinda imposible

cobalt hollow
#

key limit is 32k im guessing

distant tulip
#

there is a warning when writing stuff to fast, bu that is it

cobalt hollow
#

oh weird, im not sure where i got that 8mb max from its just always been in the back of my mind

distant tulip
#

you get a 10mb warning iirc
10mb was saved last minute or something like this

distant tulip
cobalt hollow
#

ohh gotcha, im just saving player data, so each player will have their own DP with their json Data, and i have alot of other databases so just wanted to make sure, i dont think a whole 10mb will ever be saved in the span of a minute though

distant tulip
#

you shouldn't worry about it
i had a project where i saved more than 1 dp per tick for 20 minute with no problem

cobalt hollow
#

gotcha, thanks

distant tulip
#

just keep performance in mind

cold grove
#

Hii

#

I was reading the v2 api changes to update my scripts and optimize them, i havent tested anything yet, now i can run block related operations during worldLoad right?
During v1 i used to use ``fillBlocks()` after playerSpawn was fired

wary edge
cold grove
wary edge
#

I have not messed with those so I have no idea.

fallow minnow
#

how can i get the players view direction in 90 degree intervals

knotty plaza
fallow minnow
#

like normalize the view direction into 90 degrees

#

like north is 0, east is 90, south is 180 etc

knotty plaza
#

I see

shy leaf
knotty plaza
#

I didn't understand what you meant by interval in degrees

#

Just use player.getRotation().y

fallow minnow
fallow minnow
shy leaf
#

oh wait i see your question now

knotty plaza
shy leaf
#

my memory is foggy so i dont know if .getRotation() does 0 to 360 or not

#

gotta test that out

#

(not me though)

knotty plaza
fallow minnow
#

ohh wait yeah i meant rotation not view direction oops

knotty plaza
#

So again, let's say you have 80, you want it to be round to 90, or 15 to 0

#

Is that correct?

fallow minnow
#

but yeah basically i have a particle that i can rotate via variables and im just trying to rotate it 90 degrees based on where they were looking towards

#

like itll always rotate correctly facing them

#

instead of being in a static state of 1 rotation

knotty plaza
#

But there already is a look_at_xyz property for particles

#

I think that's what its called

tidal wasp
fallow minnow
#

yes ik but im going for something else

tidal wasp
knotty plaza
#

You want the particle to only align with the owner's rotation?

fallow minnow
#

like if i break it from that side it should face me

knotty plaza
#

I see

fallow minnow
#

so i need to get the rotation or whatever it is

knotty plaza
#

Wait me a minute

fallow minnow
#

i already have the particle all set up for rotations but i just need the script side of it

#

idk what to use

tidal wasp
#

wrong reply but it frankly doesnt matter

shy leaf
#

theres something you might be interseted in

#

give me a second

tidal wasp
shy leaf
#

go7hn

tidal wasp
#

Oh

fallow minnow
#

at first i was going to make a fake block particle but

#

i got it down

#

and its just

#

too much

#

it would be like a locked outline thing so im just doing this

shy leaf
#

ok so instead of getting player's view direction, we can instead go by getting which direction of the block the player is at

fallow minnow
#

like the face?

shy leaf
#

close enough

knotty plaza
#

I think this should work

function snapYaw(yaw) {
  yaw = ((yaw + 180) % 360 + 360) % 360 - 180;
  const cardinals = [-180, -90, 0, 90, 180];

  let closest = cardinals[0];
  let sDiff = Math.abs(yaw - closest);

  for (const angle of cardinals) {
    const diff = Math.abs(yaw - angle);
    if (diff < sDiff) {
      sDiff = diff;
      closest = angle;
    }
  }
  return closest === -180 ? 180 : closest;
}
shy leaf
#

yeah uh thats

#

i think its overkill for just particle rotation

knotty plaza
#

I can be simplified a lot for sure

shy leaf
#

it should be similar to block's face location from there

knotty plaza
#

Ok I reduced the lines

yaw = ((yaw + 180) % 360 + 360) % 360 - 180;
const cardinals = [-180, -90, 0, 90, 180];
const angle = cardinals.reduce((a, b) => Math.abs(yaw - b) < Math.abs(yaw - a) ? b : a);
knotty plaza
#

Again, Idk anything about particles

shy leaf
fallow minnow
#

which one thing weirdly happens

#

it only supports 90, -90, 180, -180

shy leaf
#

yeah thats basically how most programs handle angles

knotty plaza
fallow minnow
#

and 0 yeah

shy leaf
#

actually

shy leaf
#

we can just go back to .getRotation()

#

just gotta handle the snap part

#

i wish i could test it in game but i cant rn 😭

#

@fallow minnow

Math.trunc(yaw / 90) * 90

feed .getRotation().y in yaw and try it

fallow minnow
#

THATS IT??

shy leaf
#

i mean

#

you gotta try it, i cant even test in game so i cant guarantee it

fallow minnow
#

its

#

wait im confused

shy leaf
#

whuh

fallow minnow
somber cedar
#

How does Jayly get what coordinates a player sees?

shy leaf
somber cedar
#

I am too dumb for this

shy leaf
#

this is why i first suggested using location to get direction

also i cant help with it too much since i am absolutely horrible when it comes to math 😭

zinc breach
#

is there a way to check what type of armor trim a player has on their armor

jagged gazelle
marble sigil
summer cloud
#

Im trying to add @minecraft/server-net but my servers world dosent have beta api's enabled, how can i enable it without world corruption, and creating a new world? i tried via a nbt editor and after i add gametest to experiments and set all 3 to 1, then restart the server and redownload the level.dat file its still dosent exist

cold grove
cold grove
marble sigil
#

I’m returning js { status: CustomCommandStatus.Success } or js { status: 1, message: msg }

subtle cove
#

Least u could do is return when the form is shown without awaiting

    form.show(player).then(...);
    return {status, message}
marble sigil
#

but the problem is that I have to manually validate the form, so I can't say success or fail instantly

#

I guess I will do sendMessage with §c?

subtle cove
#

After the form show, yeah u can sendMessage

marble sigil
#

What status does?

subtle cove
#

Just to color the cmd result, i think

#

Whether it's "error" or not

marble sigil
#

Then it’s... practically useless.

shy leaf
marble sigil
#

Possible to cancel critical hits and make them normal?
I don’t want to integrate my 18KB i-frame disabled giant with cooldowns.

normal spire
#

When I make a mistake in the code, the entire add-on stops working. Minecraft's debugger shows the error, but since everything else stops working, the resulting errors obscure the main problem.

#

Is there a way to solve this?

cold grove
#

Using Try-catch statements, defensive code and..

#

Or even typescript, that helps you preventing unexpected cases, and write cleaner code

gaunt salmonBOT
inland merlin
summer cloud
#

does world.beforeEvents.entityHurt not exist?

#

if so does it require Beta API's

wary edge
noble ibex
#

Is the command syntax different when you use dimension.runCommand()? This command runs fine when I run it from chat, but the syntax breaks down from the script.

execute positioned ~~~ run stopsound @a[r=50] record.lucas_bowl vs
execute positioned ${block.x} ${block.y} ${block.z} run stopsound @a[r=50] record.lucas_bowl

plucky junco
#

Hi, i want to get into scripting, and i need a up-to-date tutorial about scripting. Any chance anyone has what im looking for?

dusky flicker
#

whats with this new ddui?

#

and what has it to do with data driven?

#

cuz on the docs i didn't see anything related to it

wary edge
#

Look at #1468349958221729823

dusky flicker
#

i mean, does it relate to data driven programming, or am i confusing things?

wary edge
#

It's the new UI.

#

I think the docs explain it very well.

dusky flicker
wary edge
#

What are you thinking?

dusky flicker
#

data driven programming, cache hits, and stuff like that

wary edge
#

Ah no, not at all.

#

I see your confusion now.

dusky flicker
#

i thought it'd be ui with that kind of thing in mind

#

well, thanks

#

imma checkout the docs

marble sigil
warped blaze
#

damn, i need a full tutorial for the new ddui, can't even understand ts 😭

cunning canyon
#

How can I use dimension.setBlockType in an unloaded chunk?

I’m trying to use the tickingarea command before calling setBlockType but it doesn’t seem to work.

knotty plaza
#

It is async so you have to await it before continuing your process

cunning canyon
knotty plaza
cunning canyon
knotty plaza
#

I didn't notice it was still in beta

#

In that case you can either switch to beta or wait 1-2 ticks after running the tickingarea command

cunning canyon
knotty plaza
#

How are you running the command?

#

Maybe it's failing because of the syntax

cunning canyon
# knotty plaza How are you running the command?
dimension.runCommand(`tickingarea add circle ${string(previousLocation} 2 blah`);
system.runTimeout(() => {
dimension.setBlockType(etc)
dimension.runCommand(“ticking area remove etc”)}, 20);
#

Sorry for the formatting I wrote it from my phone lol

#

The commands always return result.successCount = 1

knotty plaza
#

Try tickingarea add circle ${pos.x} ${pos.y} ${pos.z} 2 something true

#

I think string() isn't even a thing

#

Also check if the ticking area list is not full

#

The command has a limit of 10

cunning canyon
cunning canyon
knotty plaza
#

Also you didn't close the function

#

Also add "true" at the end

cunning canyon
#

Don’t pay attention to the syntax, I wrote it from memory xd

But the logic is correct, it does run without any errors but the block doesn’t get replaced

#

I’m 90% sure is not about the code itself but rather a Minecraft quirk

granite cape
#
console.log('Hello World')
cunning canyon
# knotty plaza Isn't string is a reserved word?

Here's the actual code:

console.warn("1");
const unloadedPosition = { ...previousPosition };

previousDimension.runCommand(
    `tickingarea add circle ${Vector.toString(unloadedPosition)} 2 ${TICKING_AREA_NAME} true`,
);
system.runTimeout(() => {
    console.warn(Vector.toString(unloadedPosition));

    previousDimension.setBlockType(unloadedPosition, MinecraftBlockTypes.Air);
    previousDimension.runCommand(`tickingarea remove ${TICKING_AREA_NAME}`);
    console.warn("2");
}, 20 * 5);
#

I hopped back to my pc to test and still doesn't work... anyways probably a Minecraft quirk, thanks for the help regardless

knotty plaza
# cunning canyon Here's the actual code: ```js console.warn("1"); const unloadedPosition = { ......

That's weird, I used that method before and it worked for me

let tickPos;
let block = dimension.getBlock(current);
if (!block) {
    if (tickPos) {
        dimension.runCommand(`tickingarea remove "${tickID}"`);
        await system.waitTicks(2);
    }

    tickPos = current;
    tickID = `namespace:${system.currentTick}`;
    dimension.runCommand(`tickingarea add circle ${current.x} ${current.y} ${current.z} 2 "${tickID}" true`);

    await system.waitTicks(1);
    block = dimension.getBlock(current);
}
cunning canyon
#

thanks for the help regardless!!!

young swan
woven loom
#

How are u detecting key pressesw

distant tulip
#

looks like third party code

thorn flicker
#

why share it here then

young swan
#

WebSocket is kind of a ScriptAPI, I think.
If not, I apologize for posting this here — there doesn’t seem to be a chat specifically about WebSocket scripts.
You can do a lot of things with it, and a lot of people just ignore it XD.

thorn flicker
#

i kinda forgot that was a thing lol

young swan
# thorn flicker with server-net right

server-net isn’t fun
WebSocket connects directly to the client.
It’s almost like a mod that can be used on any server
You just need to have it to use it

fiery solar
# cunning canyon I even give the game 5 full seconds and it still ignores the setBlock function. ...

The tickingarea command has a few issues, but you can work around them in the meantime until the API comes out of beta.

  1. The big one is that in my testing if you use the "circle" tickingarea it will keep the entities loaded, but not actually load the blocks. (This might have been fixed since then, but it was definitely true at one point).

  2. After you create a ticking area it can take any amount of time to load the chunk. Usually around 5-6 ticks, but sometimes more than 10 seconds. It's best for you to wait until dimension.isChunkLoaded returns true.

  3. When you remove a ticking area with the command it isn't removed right away. You need to wait until at least a tick after the chunk is done saving (when isChunkLoaded starts to return false) before you add a tickingarea with the same name back or else the add command will succeed, but the game will never actually add the tickingarea.

dusky flicker
fiery solar
young swan
young swan
#

At least can make a command macro :3

dusky flicker
young swan
# dusky flicker can you share the code? so i inspect it and maybe i generate some docs for it

There’s a PDF floating around somewhere
I saw it once, but it was on a site that wouldn’t let you download it without paying.
I made a simple one using TypeScript.

interface SendCommandWS
{
    header: {
        version: 1,
        /**
         * uuid
         */
        requestId: string,
        messagePurpose: "commandRequest",
        messageType: "commandRequest"
    },
    body: {
        /**
         * minecraft command
         */
        commandLine: string
    }
}
#

The upside is that the site doesn’t block screenshots

cunning canyon
wary edge
#

Anyone made a system like Hytale where you can mine 1 block together to speed it up/track progress?

wary edge
#

😔 Oh, there's not swing stop.

#

Oh wait, Mine keeps activating swing.

wary edge
#

Can't believe I found a use for unsubcribe.

summer cloud
#

does the @minecrafter/server-net api module, have a request limit when talking to a server?

fallow minnow
#

if you exceed the memory limit it may crash you

#

but im listening for discord messages and online players through a bot and bridging it with server net every second with no issues

#

left the server on for hours and no issues

summer cloud
#

thats pretty much what im doing, i just have a constant connection, and i created a runTimeout where if theres no response itle close the connection to the websocket, and i was getting randomly disconnected, so just making sure it was somthing wrong with the code rather than something else

worldly heath
#

is it possible to use addEffect() with infinite duration?

wary edge
worldly heath
#

ah alright

#

thanks

round bone
jolly citrus
#

I'm using setCurrentValue for a custom damage system on my addon but with absorption hearts in play it gets weird, it seems like the hearts shown to the client do not match what the server knows

#

i can right click any item in my hotbar and suddenly, all my absorption hearts are back

#

and then i just see normal hearts suddenly lower

midnight ridge
#

guys how can i make something for exampl i want to make an ore scanner that scans the area and shows the ores behind the walls but the problem is how can i show them and make them appear behind walls??

distant tulip
#

Entities with custom materials

fallow minnow
#

anyone else notice that inventory change after event fires upon player join?

#

meaning the game re-gives their items upon joining

#

which is kinda cool

wary edge
#

Yeah.

#

No idea if its WAI or Bug.

fallow minnow
#

and for them to update they just rejoin

#

or just re pick up the item again

wary edge
#

Are you talking about PlayerInventoryChange or EntityPickupItem that was recently introduced?

fallow minnow
#

inventory change

#

and you just use the item not before item

#

so it only runs on pickup

distant tulip
fallow minnow
#

yeah its pretty neat

#

it gives all your items on join

distant tulip
#

Armor too i assume

hexed pier
#

What is the Minecraft server API 1.21.130+?

somber cedar
wary edge
#

Any way to get the item entity that is dropped from a block?

weary umbra
wary edge
#

It does not return the actual entity instance.

tidal wasp
#

Does return in a OnPlayerInteract stop the player from breaking blocks?

wary edge
tidal wasp
#

Ok the why tf cant i break dirt

wary edge
#

Are you in adventure mode?

tidal wasp
#

No im like something stops me every time I start breaking something

#

I can break something if it can be instamined

#

Its my fucking controller 😭

#

Because I have x to destroy block

#

And for some reason the game doesnt like that

#

Ok so I fixed it party_potato

#

What happens when you dont use return at the end of something like world.beforeEvents.playerInteractWithBlock or something like that

wary edge
#

Nothing.

lethal bramble
marble sigil
#

Will DDUI be replacing ModalFormData and etc?

#

Those FormData stuff

buoyant canopy
#

but they will eventually

marble sigil
#

but they keep archives for these modules right?
like we still have and can use @minecraft/server 1.8.0.

weary umbra
zinc breach
#

is there a way to make a player glide without an elytra

warm mason
wary edge
zinc breach
#

any documentation on that?

warm mason
weary umbra
warm mason
wary edge
#

Too many edge cases such as non full blocks.

zinc breach
#

is saving items in dynamic properties reliable with itemstack

#

in terms of duarbility names enchants and that sort of thing

#

also want to know if I can save a big object in a dynamic property with all the inventory slots as keys for an item

weary umbra
#

Wait what you can change the selected slot with
player.selectedSlotIndex = 9

I didnt know that. I thought it only returns the slotIndex

tame spear
#

How can I .nameTag with translate? 😔😔😔😔

warm mason
distant tulip
#

what does getEffects return in duration if the effect is infinite?

supple perch
#

either Infinity

#

or undefined

#

or maybe it gets ignored

#

let me test for you rq

#

-1 actually

#

interesting

#

slowness had a real number, night vision had infinite

#

i wonder why they won't/can't add infinite to addEffect

#

anyway

distant tulip
supple perch
#

no

#

the bounds error will appear

#

i think

jagged gazelle
#

that's crazy work ngl

distant tulip
#

alright, thanks

supple perch
#

i'll test tho

jagged gazelle
#

just add the ability to set it as Infinity like...

supple perch
summer cloud
#

is it possible to cancel join msgs?

#

or atleast edit how they look if i cant cancel it

cold grove
summer cloud
cold grove
#

/texts/ directory, edit the .lang files

summer cloud
#

and put what?

cold grove
cold grove
supple perch
cold grove
#

Use the vanilla resource pack and download the file and edit it

supple perch
cold grove
#

I dont know if theres a command to the repo

supple perch
cold grove
#

No

#

Here

supple perch
#

fair enough

summer cloud
#

k got it
multiplayer.player.joined=%s joined the game

worldly heath
#

how do u shoot an ender pearl like projectile ?

#

when i use spawnEntity() and shoot() it gets stuck in unloaded chunks

#

but if i throw an ender pearl normally it'll land as usual

fiery solar
worldly heath
#

i tried spawnEntity with vanilla ender pearl and it is also having the same effect, its not loading chunks while spawned with scripts but does when i throw manually

#

i had to edit ender pearl.json to make it spawnable idk if that broke anything

worldly heath
nova flame
#
import { system, world } from "@minecraft/server";

const trackedItems = new Map();

const DESPAWN_TIME = 30;

system.runInterval(() => {
    for (const [entity, data] of trackedItems.entries()) {
        data.remaining -= 1;

        if (!entity.isValid) {
            trackedItems.delete(entity);
            continue;
        }

        const item = entity.getComponent("item").itemStack;
        let name = item.typeId.split(":")[1] || item.typeId;
        name = name.replace(/_/g, " ");
        name = name.replace(/\b\w/g, (char) => char.toUpperCase());

        entity.nameTag = `§f${name} §cx${item.amount}\n§e${data.remaining}s`;

        if (data.remaining <= 0) {
            entity.kill();
            trackedItems.delete(entity);
        }
    }
}, 20);

world.afterEvents.entitySpawn.subscribe((ev) => {
    const entity = ev.entity;
    if (!entity || entity.typeId !== "minecraft:item") return;

    trackedItems.set(entity, { remaining: DESPAWN_TIME });
    const item = entity.getComponent("item").itemStack;
    let name = item.typeId.split(":")[1] || item.typeId;

    name = name.replace(/_/g, " ");
    name = name.replace(/\b\w/g, (char) => char.toUpperCase());

    entity.nameTag = `§f${name} §cx${item.amount}\n§e${DESPAWN_TIME}s`;
});```
 ive had this system for a while and i wanted to change it to display the items "display name" instead of the split up typeId
#

possible?

warm mason
nova flame
#

no possible way at all

#

to get the items name?

#

like named in an anvil say

warm mason
nova flame
#

bruhhh

zinc breach
#

how do I check what type of armor trim is on an armor piece in an itemStack

zinc breach
#

is there a way to make a vanilla block a ghost block? so just make it so people can walk through it basically

jagged gazelle
zinc breach
#

what do I need to do for this to work then

jagged gazelle
#

vanilla blocks are data-driven

#

you can't modify them

#

either you give up on that idea or create a custom block having no collision that looks exactly with the block ur trying to make "ghost block"

zinc breach
#

thanks anyways

jagged gazelle
#

not really perfect but almost there

deep arrow
#

If i change a block state's name, will old versions of it change or?

marble spruce
#
 if (item.typeId === "ocp:set_sequence") {
    const checks = [
      { scores: [0,3,4,0], func: "omnip_decouple" },
      { scores: [4,4,6,2], func: "unlock_feedback" },
      { scores: [3,4,1,1], func: "unlock_upchuck" },
      { scores: [1,2,1,9], func: "failsafe_off" },
      { scores: [3,8,2,1], func: "failsafe_on" },
      { scores: [0,0,2,3], func: "unlock_iguana" },
      { scores: [9,3,9,4], func: "unlock_blob" },
      { scores: [7,3,3,7], func: "unlock_fungal" },
      { scores: [3,2,6,7], func: "unlock_eyeguy" },
      { scores: [1,0,3,4], func: "unlock_buzz" },
      { scores: [0,4,0,0], func: "destruct_timer" },
      { scores: [9,0,3,6], func: "unlock_master" },
      { scores: [7,0,8,4], func: "unlock_playlist_two" },
      { scores: [1,4,6,0], func: "unlock_idem" },
      { scores: [5,5,3,1], func: "unlock_spitter" }
    ];

    for (const check of checks) {
      player.runCommandAsync(`execute if score @s default_one matches ${check.scores[0]} if score @s default_two matches ${check.scores[1]} if score @s default_three matches ${check.scores[2]} if score @s default_four matches ${check.scores[3]} run function ${check.func}`);```

Hey guys,is this well structured?
supple perch
#

first move the array outside the event loop

#

second runCommandAsync has been removed

#

use runCommand instead

#

third, use scripting API's native scoreboard feature

cursive fog
#

in action data form can i display a variable for the body of ui instead of message?

supple perch
#

is that variable a string?

#

if it is, then you can

cursive fog
supple perch
#

then you can.

cursive fog
#

like .body(variable)

supple perch
supple perch
#

but aye it ain't my business

supple perch
#

(accessible via world.scoreboard)

cursive fog
#

do i need server ui for onscreen display component?

supple perch
#

just use player.onScreenDisplay.method
Exmample: player.onScreenDisplay.setActionBar('hi')

cursive fog
cursive fog
supple perch
#

what????

#

player.onScreenDisplay isn't a real ui element

#

do you mean the actionbar?
player.onScreenDisplay.setActionBar('actionbar lol')

#

or what exactly?

cursive fog
# supple perch what????

i wanna add a custom png using json ui on the player screen. is it possible with onscreen display?

supple perch
#

if that's what you mean, then idk

#

it's probably possible but it'll be very JSON UI heavy and will be complicated as heck

#

player.onScreenDisplay doesn't give us an option to render a custom hud element.

cursive fog
supple perch
#

honestly my advice: whatever the hell you're gonna do with a custom hud is NOT worth it

distant tulip
#

onScreenDisplay is a class used to access other functions such as setTitle and setActiobar
it doesn't relate to json ui in it's own

supple perch