#Script API General
1 messages · Page 139 of 1
technically for a specific entity
but i also want the player to have only the ender crystals in that position
so i think this is better
cuz i already have a way to check for it once i have that array of type ids
actually no that would be wrong cuz i dont think its controllable how they would go into the array
hmm
yeah do you have a better way to test for specific entities?
okay actually i think thisll work now
i just changed it to this
cuz it appears to go by order they were placed into the world
which it's pretty unlikely you're gonna have a entity go into the spot of the ender crystal since it will explode and kill the entities near it, so the player probably will not want them to be near the reactor
but still if there's a better way I do wanna see other methods
on a side note, is there a way to check the state of the block using getBlock? cuz I'd like the respawn anchors to have to be fully charged, but rn it doesn't matter if they're charged or not
You should keep the array and, in your other code, add a find() method
const targetEntityType= '';
const entitiesAtDirections = entityTestFunc();
entitiesAtDirections[0].find((e) => e.typeId === targetEntityType);
https://stirante.com/script/server/2.6.0/classes/Dimension.html#getentities
And use the query option to filter stuff out.
Did you look at the doc I sent?
i saw it before when i was originally looking and it looked like it wasn't helpful to me but maybe i missed somethjng
yeah what am I missing? cuz this doesn't seem helpful (in this scenario)
How is it not?
What are you missing from the query?
ok where the heck is this cuz this is not the doc you sent
oh nvm im stooooopid
😭
ya okay for some reason i didnt think entity query options was clickable
so i just thought the examples given showed off all the query options
oki
this is very good to know
last thing I need is the side note here if theres a way to either check this in the script api
or to check the output of a .runCommand either of those would solve the last problem i have
if there's a block equivalent of this that would also be epic
Get blocks?
ye i figured it would be that but what i mean is does it have a bunch of filters like that
You're not gonna believe this
https://stirante.com/script/server/2.6.0/classes/Dimension.html#getblocks
Documentation for @minecraft/server
ok yeah i probably missed it the same way
Why loop?
whats the difference between this site and microsoft learn btw cuz this seems way nicer and ive been looking at the microsoft learn documentation previously and just constantly been missing stuff apparently
check on all directions
Use volume for that.
Its already built into the query.
whats this for :o
not "all" directions anyway
How so?
since we're on the subject of volume, is there a way to control which blocks it checks for in different parts of a blockvolume, or does it just check that the volume contains all the block types you list
Make multiple volumes then?
ok thats what i thought
and i couldn't get it to work when I was testing it but it seems like it should be possible to check for blocks diagonally like, in an x shape? or am i thunking wrong
Honestly, what are you trying to do?
right now I'm just learning
I have solutions, though I need to implement this I think for the respawn anchors
but rn everything should at least work
so I just wanted to see alternate days of doing it
but what are you trying to implement?
but for this specific instance I'm trying to make it so that when the player clicks a block, it checks for specific blocks (and for one of my custom blocks, also checking entities, which is why i was asking here) in the first place) in a 3x3x3 area
my function for the blocks works fine except for checking states, which is fine bcuz only the one custom block needs to check those states
so i was focusing on entities here
once all of it is checked and if the player placed it correctly then it places a structure
https://discord.com/channels/523663022053392405/1496535965303443638
this is what i was working on before if you're curious
uhhh so for respawn anchors, the charge would be one of its "permutations" right?
so actually it might be better for me to use that method instead of getblocks filters
Is there a way to check if a block is flowing_water instead of water?
Check the typeId?
it is always water
Are you talking about water from a source?
Thats not flowing water.
alright thanks
oh also @wary edge @cold grove thank you for all your help :)
What is the glyph (unicode) for the mc heart?
for the love of god i cannot remember the event that was triggered once the player that joined was ready to get an actionform opened
does anyone know the event?
i cant find it either
I dont believe thats ever a thing.
We have playerSpawn and playerJoin only.
What people do is have retry attempts.
That is weird as hell, cuz i can remember that some friend said I should use that event if I want to show a form right after join
it was like weirdly named
An ancient technique called gaslighting.
i might have dementia 😢
Good idea. Seems like a better option than bruteforcing showForm()
Is there a eay to increased player swim speed
can script give player yellow heart?
Thankz
how to covert movement value to speed value?
like movement value is 0.25 but speed value is 1
You can't?
I do not understand your question lol.
@crude ferry I pinging you because idk if any one else is online on here but I get this error
[Scripting][error]-TypeError: cannot read property 'subscribe' of undefined at <anonymous> (main.js:3)
[Scripting][error]-Plugin [Custom Chat System - 1.0.0] - [main.js] ran with error: [TypeError: cannot read property 'subscribe' of undefined at <anonymous> (main.js:3)
]
import { world } from "@minecraft/server";
world.beforeEvents.chatSend.subscribe((data) => {
const player = data.sender;
const message = data.message;
data.cancel = true;
if (message.toLowerCase().startsWith("-me ")) {
const actionText = message.substring(4);
world.sendMessage(`${player.name} ${actionText}`);
} else {
world.sendMessage(`${player.name}: ${message}`);
}
});
Why am I getting that error
Because it's looks fune
What version of minecraft/server are you using?
1.10.0 without -beta
how?
Can you explain your question better?
I only do Script and never worked much with entity components but I am very sure the "value" of the minecraft:movement cannot give you the speed at a given instant. If that's what you're asking.
I experienced a bug but unrecorded, it was when I knockback myself with wind charge while I stopped using fly
Then I stayed in mid air going up and down a little repeatingly
And then a few seconds after it continues to fall down and back to normal
Second bug is this, but I think this is just in bad timings of heal and death
I think the golem needs some help

Lol
If I want File A to import a function from File B, but said function imports something from File C, do I have to import both B and C, or just B?
just b
finally some convenience, thanks
When you import even just a function from a file, the whole file runs once. So 'technically' you already import C when you import B in A.
What 😭
Yeah, tested
idk why
I used some imported functions and I forgot that I haven't deleted some of my debug codes in there that auto-runs
But when I use something like
const DEBUG = true
export function sendLog(txt){
if(DEBUG) console.warn(txt)
}
It says DEBUG is undeclared
You also have to export the variable DEBUG.
DEBUG is a variable only in your debug(whatever you named it.) file scope.
When I said it runs the file once. That does NOT mean all of B's variable is exposed to A.
Oh wait actually. If you use the function, it should work.
I had to put the variable inside the function
Can you show how you were calling sendLog() function though?
Incase if something wrong here, here's the full example:
import "./src/event1.js"
import "./src/event2.js"
const DEBUG = true;
export function sendLog(txt){
if(DEBUG) console.warn(txt)
}
in event files, I use it like:
import {sendLog} from "../index.js"
function something(){
sendLog("Something successfully happened")
}
that function is calling itself
did you mean
const DEBUG = true;
export function sendLog(txt){
if (DEBUG) {
console.log(txt);
}
}
whats the problem
It's small issue though and it's working if I put the variable inside. It's just idk why it didn't work and says variable DEBUG is undeclared when I use the sendLog function
-if the variable DEBUG is outside
Donnt trigger the function instantly while importing
Yeah.
Ohh
The two imports on the DEBUG file are most probably causing it.
Like the timing
Function do have access to variables of their original file.
Yes.
By the way, just wondering, why are you using that version lol?
I mean is there any specific use case you had to use such an old version for lol?
Does anyone have working code for camera.playAnimation?
Tbh the most interesting thing in math is matrices
Does anyone know how to actually use Potions.resolve? I can't figure it out
Potions.resolve ?
I am trying to give a potion as an ItemStack
Then write its type id
That s all
Wait sorry...
Use it this way
Potion.resolve("minecraft:effect_type_id" , "delevery_type")
Tbh , i didn't find no enums in index.ts for it
const item = ItemStack.createPotion({ effect: 'WaterBreath', liquid: 'Regular', modifier: 'Long' })
if this is what you are looking for
Doesn't this not exist anymore?
let me double check
Not in stable
Not even in beta seemingly
Are you trying to make custom effect or use already existing one ?
existing one
yeah
i mean this look straight forward, no?
Yeah , but it have no enums that s the problem
You don't know what to put in potionDeliveryType
As a string
apparently you use vanilla-data
there is getAllDeliveryTypes
Try using Potions.getAllDeliveryTypes()
Or just make generic key-word function
Like you give it a key word from the effect type and the delivery type
And you get the potion
const potion = Potions.resolve("minecraft:Healing", "Consume")
inventory.addItem(potion)
Wait this specfically works, like the first one have "minecraft:" and the 2nd one not
Yes
...
cool so I think my problem the whole time was I expected both to have the minecraft: prefix or not to have it
I mean they should add that i guess to make it more intuitive
Oh its listed that way on these docs too dang I can't read
like you know you can use itemStack item's type id without or without Minecraft
right
Thanks for the help guys
Uw
If anyone wants them, here's all of the current Types available. The main file include simple use cases for both TypeScript and JavaScript.
Guys is there a way ,to enforce breaking a black
wdym
are you asking if there's a method for destroying a block at a location? no
you'll have to use the setblock command with destroy set to true
fill command with destroy
hmm intersting
what about breaking multi blocks
but the problem is one block is getting destroyed before the other ones
FILL command
not setblock
what's the problem with using it?
well, the delay is just one tick...
no
sad
hmm for small multiblock structures
im assuming you are making a hammer
but for bigger ones the impact is not negligible
no furniture
oh
fuh wasted my time to know there is already a component named multiblock to solve it
yeah I was gonna say
lol
damn that sucks
just be happy there's official support
but does it support horzontal parts
let the happiness overshadow your frustration
yeah then time well spent
well you could make it hybrid...
hmmm yeah but it would be harder maybe
hm
vsync?
you know when you screen generated unsynced frames
there is technology name vsync that fixes it
or gsync free sync
it solves the frames cut problem
i know the technologies im just confused what it has to do with it
when u break a block
and it breaks before the other ones
i mean the one tick delat
lol
well... you could cancel the break, then break it again
but the block will flash for like a tick
yeah it s like making new problem
so i will stick with what i have for now
smol question
how to make fill command dosen t drop item
when i saw you guys talking about breaking with fill command i thought you guys were talking about veinminer like this but then i saw the multiblock so i guess not
._.
@cyan basin how did u make items no spawn
gamerule dotiledrops false?
/fill should just replace the blocks. How are you using it?
either do gamerule dotiledrops false or check the block that was broken to it's item that drops within a small radius around the block and then kill it 🤷♂️
hmmm , i mean i am making multiblock furnitures i don t want the parts to be dropped as items
that s all
so kill them when broken -_-
Could disable the game rule for a tick, I suppose
i want something performance wise
what's not performant about that?
hmm
If only we had a BlockItemDrop event.
Do we?
No, we have Entity.
lol
Silly
Which works for disabling certain loot.
hmmm
Or just give loot table for blocks 😉 so blocks can either drop nothing or custom items all together
You are talking to a man who had to make block breaking from scratch lol. I am more than aware.
i am too lazy to do... wait i can use one loot table
I'm just saying in general to this channel lol
I had to disable tiledrops, check for bamboo, cactus, and then all the edge case, use loot table manager, and shebang.
1+1+1+1 = 4 ☠️
give it an empty loot table, but spawn an item when you break 1 piece
About performing one entity query on the dimension L×W×H times, looking up the item component on that entity, then checking the typeId against the block's typeId? This sounds nightmarish for performance
resonable
Oh I got mixed up, I thought the vein miner was arthur's use case. Yeah, just give the block an empty loot table and use loottablemanager if you want to still utilise the engines loot table system.
yeah, smart
Wait so you can just do an empty loot table like I said about here? lol
yep
Only works for custom blocks. In this case yeah. Again, I got mixed up and thought that vanilla coal ore.
yeah np
wish we could give spawned items the pickup delay though
Sure you can. Cancel the Item Pickup no?
right, forgot about that.
how long is the delay anyways?
no way fill command is faster than setBlock
?
fill command is faster than setBlock somehow on my script
tbh noice cancelation using sound files and script api would be a crazy idea ☠️
Why non-marketplace add-ons aren't compatible anymore with vibrant visuals
You have to add ”capabilities”: [“pbr”] to your pack manifest to add support for Vibrant Visuals.
"
Oh , ☠️
So i need a custom block to open storage space "inventory" when i click on it, Is it possible to do it ?
No way right?
Does anyone have a way to find solid blocks?
why doesn't keepVelocity in teleport method support players?
while clearVelocity does
getblockfromray, set IncludePassableblock option to false
There is Block.isSolid() in beta, but that's the thing
It's still in beta
Ye
If it’s the first open why make me have to hold the button first, that’s so dumb 💀
Use getBlockFromRay with options
Thanks though, I hadn’t notice it there.
There are options to include/exclude passible blocks
Please, what is the beta version of the latest version of the manifest? Thank you.
2.7.0-beta for 26.10 minecraft/server iirc
And 2.1.0-beta for minecraft/server-ui
Thank you 😊
I tried using it a good while ago, but it just crashed my game, no matter what
I reported it to darknavi, let me see if I can find the code
/**
* @type {import("@minecraft/server").AnimationOptions}
*/
const animation = {
totalTimeSeconds: 10,
animation: {
progressKeyFrames: [
{
alpha: 0,
timeSeconds: 0,
},
{
alpha: 1,
timeSeconds: 10,
},
],
rotationKeyFrames: [
],
},
};
for (const player of world.getAllPlayers()) {
const location = player.location;
location.x -= 3;
location.y += 2;
const spline = new LinearSpline();
spline.controlPoints = [location, { x: 438.0, y: 187.0, z: -714.0 }, { x: 450.0, y: 187.0, z: -714.0 }];
player.camera.setCamera("minecraft:free", { location: location, facingEntity: player, });
player.camera.playAnimation(spline, animation);
}
});
maybe I did it wrong tho, I just ended up doing manual animating
Same it keep crashing the game
Microslop did it again
How do I make the server UI options save when I log out and log back into the world? Is it possible?
Dynamic properties
Thanks
Is it possible to rename a boss bar using .nameTag? Can't make it work
I don’t think so
Only using the name tag works
oof, that's unfortunate
I just tried it, adding at least 1 rotation keyFrame stops the crashes
But the animation isn't working
Many have been on that before,
so you can proceed with using
"version": "beta"
Yes 🙁
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
Installation for @minecraft/server-ui
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
so is this still valid or no
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "beta"
}
]
Yes
Can we use "beta" for format versions yet or is that not in stable/preview yet?
Ah, just found out that if entity.setProperty and entity.getProperty are used in the same tick of system.run that it doesn't output the updated property with getProperty.
Yes you need to wait 1 tick.
Yeah, I realise that now 😅
I've been at it for the last half hour wondering why it wasn't logging the correct property value lol
For some reason this code removes landing particles entirely. Is there a way to fix it? Should I report it to Mojira?
import { EntityDamageCause, world } from "@minecraft/server";
world.beforeEvents.entityHurt.subscribe((event) => {
event.cancel =
event.damageSource.cause == EntityDamageCause.fall &&
event.hurtEntity.getBlockStandingOn()?.typeId == "minecraft:hay_block";
});
According to the docs, damage in EntityHurtBeforeEvent is not read-only. Can I possibly try changing this value to 0 to remove damage?
event.damage = 0
I'll try, thanks. Hope that will fix the lack of particles
How can I summon a Lightning Bolt when a player dies? Especially if they have a tag like "skywars"?
import { world } from '@minecraft/server';
world.afterEvents.entityDie.subscribe((event) => {
const { deadEntity } = event;
if (deadEntity.typeId !== 'minecraft:player') return;
if (!deadEntity.hasTag('skywars')) return;
deadEntity.dimension.spawnEntity('minecraft:lightning_bolt', deadEntity.location);
});```
You can try this, I'm not sure if the location would be valid still, especially if you have instant respawn on.
How would do i detect if a certain item has been clicked
Is there any way for me to see the current weather?
i tried using this script for the bulletdamage but nothing happens
It's possible your entity is not being considered a projectile.
i'll give the entity code:
It is currently only available in preview/beta.
Perhaps this new experiment will solve the problem, but I'm not sure.
how can i do it? its a plugin?
I'm trying to remove the durability but it won't work
if (item.typeId === "bizarrecraft:stand_arrow" && !player.isSneaking && cooldown.cooldownTicks == 100 && cooldown.getCooldownTicksRemaining(player) == 0) {
player.runCommand('function stand_arrow')
durability.damage(1)
cooldown.startCooldown(player)
}
Are you setting the item back to the player once it gets damaged?
wdym?
I made this Anticheat for people to use its a Anticheat to detect hacks, exploits and even lumine proxy bots but idk if they did the lumine proxy bots detection right and also when I not using hacks it detects me as using hacks is there any way to make it not detect regular players only hackers.
-# Note: I making a post thing for this
How could i get the coordinates of a player using the script api?
I coding you one that way you can learn of it
I using the new slash cmds api
uh
what do you mean by that?
The getting any coordinates of any player
I testing the code to see if it works first
ok
@grave halo I adding some notes for you
alright
I do it to teach new people
thats a great thing to do
so how is it going there?
whats the goal here?
I currently fixing the errors
oooh
Trying to make it when you use the item it removes durability
remove durability as in
- turning it into fresh state?
- make it unbreakable?
- deplete durability?
deplete
then you need to get the durability damage, add the amount of durability damage you want to apply, set it back, and then set equipment back
durabilityComp.damage = Math.min(
durabilityComp.damage + durabilityModifier,
durabilityComp.maxDurability
);
equippableComp.setEquipment(EquipmentSlot.Mainhand, itemStack);
_ _
Okay thanks
import {
world,
system,
Player,
CommandPermissionLevel,
CustomCommandParamType,
CustomCommandStatus
} from "@minecraft/server";
system.beforeEvents.startup.subscribe(({ customCommandRegistry }) => {
customCommandRegistry.registerCommand(
{
name: "utils:coords",
description: "Get the coordinates of a specific player.",
permissionLevel: CommandPermissionLevel.Any,
cheatsRequired: false,
mandatoryParameters: [
{
name: "target",
type: CustomCommandParamType.PlayerSelector,
},
],
},
(origin, [target]) => { // Destructure directly as `target`, not `players`
// Safety check to ensure target is valid
if (!target) {
return {
status: CustomCommandStatus.Failure,
message: "No player found.",
};
}
const { x, y, z } = target.location;
// Format coordinates
const posX = Math.floor(x);
const posY = Math.floor(y);
const posZ = Math.floor(z);
const response = `§a${target.name} §f- Coords: §b${posX}, ${posY}, ${posZ}`;
// Send message to the command sender
const sender = origin.initiator ?? origin.sourceEntity;
if (sender instanceof Player) {
sender.sendMessage(response);
}
return {
status: CustomCommandStatus.Success,
message: response,
};
}
);
});
There
@grave halo you can change the any to Admin so only admins that are op can use cmd
import {
world,
system,
Player,
CommandPermissionLevel,
CustomCommandParamType,
CustomCommandStatus
} from "@minecraft/server";
system.beforeEvents.startup.subscribe(({ customCommandRegistry }) => {
customCommandRegistry.registerCommand(
{
name: "utils:coords",
description: "Get the coordinates of a specific player.",
permissionLevel: CommandPermissionLevel.Operator,
cheatsRequired: false,
mandatoryParameters: [
{
name: "target",
type: CustomCommandParamType.PlayerSelector,
},
],
},
(origin, [target]) => { // Destructure directly as `target`, not `players`
// Safety check to ensure target is valid
if (!target) {
return {
status: CustomCommandStatus.Failure,
message: "No player found.",
};
}
const { x, y, z } = target.location;
// Format coordinates
const posX = Math.floor(x);
const posY = Math.floor(y);
const posZ = Math.floor(z);
const response = `§a${target.name} §f- Coords: §b${posX}, ${posY}, ${posZ}`;
// Send message to the command sender
const sender = origin.initiator ?? origin.sourceEntity;
if (sender instanceof Player) {
sender.sendMessage(response);
}
return {
status: CustomCommandStatus.Success,
message: response,
};
}
);
});```
Here you have
I hope, IT will work
Thank you so much for replying, but I already know which one it was. I was able to update, thank you so much 😊😅
._.
With "beta", we don't need to worry abt what version to change in our manifest every update
thank you
Does it work
yep
because the response is given twice
on here and here
@grave halo that's an easy fix people can do
yeah ik
How to control how far the camera is from the player when using "follow_orbit"?
is there any example for assigning a value to a resource side variable with playAnimation and changing it afterwards through a controller or pre-animation?
in my test it worked making a variable true but it didnt work changing it afterwards inside another controller.
or are there any better alternatives for script-client communication?
Is there a way to fly like elytras using scripts?
Entity Properties?
There's a way to bounce off the player but not to activate flying
I love codeboxes
anyone know why doesn't it bounce sometimes?
I did just have a discussion about that last week here: https://github.com/EndstoneMC/endstone/pull/387
And here are the instructions on how to get it going:
https://endstone.dev/latest/getting-started/installation/#with-docker-latest--macos--with-emulation
It's hard to tell without seeing the code.
It says there's no matching distribution
Tho it exists on the website
Does it work with Docker?
docker pull --platform linux/amd64 endstone/endstone
Then
docker run \
--platform linux/amd64 \
-p 19132:19132 \
-it \
-v ${PWD}:/home/endstone/bedrock_server \
--name endstone-server \
endstone/endstone
is getGeneratedStructures actually going to be released in 2.7.0?
⬆️
can.........I........... dm..........you?????😨
is there some debugging tool i can use to find out which part in my scripts is causing a hang
Could someone help me? How can I make an action trigger when I hit the air (swing without hitting anything)? Could you give me an example? Thanks!
However, it does not work for mobile users.
The event works on mobile, you just have to map the left click of a mouse input to something like the volume button, then you can swing your arm on air.
The problem is with the vanilla touchscreen attack button, it doesn't allow you to punch the air.
-# TLDR; You're correct but I yapp anyway
Wait, you can make the right click on the air work with the volume button instead?
Guys need smol help
👀
Can you help ? @crude ferry
So , basically you know when a witch finishes drinking potion, is there an event for that to detect it ?
Witch drinks only 4 kinds of potion so I am pretty sure you just check for them yourself.
How
☠️
What event
afterEvents.effectAdd
Yes.
'-'
minecraft:instant_health
Hmmm
What ? ☠️
No i mean how to check when an entity drinks the regeneration
Potion
world.afterEvents.effectAdd.subscribe((event) => {
const { entity, effect } = event;
if (entity.typeId === "minecraft:witch") {
if (WITCH_POTIONS.includes(effect.typeId)) {
console.warn(`Witch finished drinking. Effect: ${effect.typeId}`);
}
}
});```
You can do something like this where WITCH_POTION is an array of every potion witch drinks.
Oh ☠️ thx very much
- can i use it to trigger a custom event in json right ?
Yes
"events" : {
"Custom:event" : {"add component" }
}
No i just want to wire js with json ☠️
Oh yes.
Oh thx you saved me much time
entity.triggerEvent()
Is it better to use world.afterEvents.entitySpawn.subscribe for Clearing items or should i stick to using functions in my tick.json that kills them. For example starter kit
Event Driven (EntitySpawn) is always better in performance than polling (function tick.json)
Does someone know why my entity stops holding here crossbow back when i add "minecraft:drink_potion" behaviour, is there any fix using js and events , or something i did wrong in the behaviour file ?

Is there a way to make damage cancel eating?
Detect both player taking damage and player eating food ( so world.beforeEvent.itemUse) and when it takes damage give the player a tag and also use system.runTimeout to remove that tag after a 1 tick, and with world.beforeEvent.itemUse, detect the tag and do event.cancel = true, so in this case you will not use event.isFirstInstance I think it's called?
Wouldn't this only cancel the start of eating?
Never used system.runTimeout
No clue what it does lol
Its like run interval but it waits a number of ticks and does something once
It literally runs a code after the specified amount of ticks, that's it
Ah
Also does itemUse fire the entire time an item is being used or only the beginning?
Just the beginning
I mean do you want the player completely lose the ability to eat after taking damage? Or just if they're eating and they take damage then stop eating
Take damage = stop eating
making it be canceled
It's for a combat system I plan to make
I think it fires the entire time but there is a boolean event.isFirstEvent that'll be true only when it starts
Ya so what I described should work
The only reason I challenge this is because a friend was using this callback and it only fired once
Let me check smth
Ok I was wrong it does just trigger only at the start
No
I was hoping to use the on start and on finish to hold a var
iirc food items do trigger itemStartUse
and item use
so just use that
and there is a consume event iirc
@distant tulip man can you hilp me
with?
With this : "Does someone know why my entity stops holding here crossbow back when i add "minecraft:drink_potion" behaviour, is there any fix using js and events , or something i did wrong in the behaviour file ?"
It is a pillager like entity
That should be a lot easier
shouldn't you make component group if the components collide with each other
it is only for the end of eating
Is that the problem?
i would assume so, both thing require eqipment. potion or crossbow
I assume when the entity is drinking a potion it replaces its held item with that potion
Ohh hmm
Well yeah but consuming can just remove the tag while starting eating can add it
I tried using equip, equippable and the entity didn't put its cross bow back
remove the component then try
Same
add this to a component group
Add 1hat
?
world.afterEvents.effectAdd.subscribe((e) => {
console.log("h");
world.sendMessage("jksjqmkledqjs")
});
do i combine it with effectAdd event to trigger it and activate ranged mode ?
yeah, if we can't trigger events from that component
Hmm thank you then
Even if it's just the log, it comes out? I use Warn.

yes
const Vec3 = new Vetor3();
static function 1() {
const dirX = 1, dirY = 2, dirZ =3;
Vec3.set(dirX, dirY, dirZ);
}
static function 2() {
const dirX = 4, dirY = 5, dirZ =6;
Vec3.set(dirX, dirY, dirZ);
}
I have codes above, does it confict eachother?
Yes, as function 1 and function 2 can simultaneously modify Vec3. Especially if ran asynchronously.
Correct me if I'm wrong but can you define a function as a number in JavaScript? I've personally never done that before 👀
ok
that's just an example
so I gonna create a lot of new Vector3() class
for each function
If you don't want to return Vec3 and/or overwrite it since it's currently global then yes, your best option is to create a new instance within each function. Just know that it's only available within the scope of that function so you will have to return the variable if you wish to access it outside the function.
function f() {
const v = new Vector3();
return v;
}
const a = f();
const b = f();
a !== b // true (different instances)
With this logic you can just call f() in your other functions that need it to create a new instance of Vector3 and they won't interfere with each other as it creates a new object in memory each time, and return v just passes a reference to that specific object, not a shared one.
How does "or" work in if conditions again?
I want to check if a damageType is 1 of 2 things
Im a bit rusty
"Or" returns true when at least 1 of 2 or more conditions is true
can I do like
if (damageType == "fireTick" or "magic") {}
I really hope I don't have to write the check twice
if (damageType == "a") or (damageType == "b") {}
I doubt I can run it through some kind of array
Just want to compact this a little
This would work, except its a ||
Bruh
Im rusty, ill and running on empty
So this should work?
Also poison is magic damage right?
Or is it its own type
I can say that poison is not its own type, but don't know what it falls under
You can verify yourself by logging what the damage cause is by poisoning yourself.
I keep forgetting I can do that
I'm still tryna get good with functions
I can do em in Lua but js is still a bit iffy to me
I think I fixed it
I'm so lost.. it's treating all damage as 0.5
The else isnt running
Thats not how you do the or.
damageType == 'fireTick' || damageType == 'magic'
Logical OR operator a || b will first evaluate a, and if a is falsy then it evaluates b.
Oh
In an if-condition, this essentially means it will first evaluate a for being truthy and continue if so, then try evaluating b likewise
I feel like a dumbass
Sometimes that's the first step to true learning 🙂
Im reteaching myself scripting after a long break
Also curious that you're using a property on the function clampMin itself. I'd sooner expect it to return a variable. This makes the function more "pure" (without side-effects)
function clampMin(damage, damageType) {
let finalDamage = damage;
// ...
return finalDamage;
}
Or heck, you could probably just return the parameter damage
I would return damage but then it gets confused with my already existing const
I thought annotation via
function.variable
Made more sense
It shouldn't, since the scope of your function is isolated. Any reference to damage as a parameter/variable/whatever will refer to the damage parameter you defined in the function
const damage = 5;
function clampMin(damage, damageType) {
// Entirely separate reference than the "damage" on the first line
damage = 3;
return damage;
}
console.warn(damage) // 5
console.warn(clampMin(100)) // 3
Where is the 100 coming from?
Just some arbitrary number, it doesn't matter since I have clampMin reassigning the value anyway, for the sake of a simpler example
I guess coming from Lua, func.var just makes more sense to me
It's easy to backtrack
Because what if I'm returning more than 1 value?
object
But it also mutates data on the function; you could, in theory, read the value of the property var on the function outside the function. As the old adage goes, "in Javascript, everything's an Object"
like
{3, "hello"}
?
It would still be one value
function myFunc() {
myFunc.var = "hi";
return myFunc.var;
}
console.warn(myFunc.var) // undefined
console.warn(myFunc()) // "hi"
// State is now mutated, I can read this on the function
console.warn(myFunc.var) // "hi"
technically 
Idk this just feels a lot more confusing to me
Agreed, this is exactly what you are doing now
Wait no, I'm so lost at both atp
maybe I shouldn't be coding while ill
Less brainpower to go around
The scope is the current context of execution in which values and expressions are "visible" or can be referenced. If a variable or expression is not in the current scope, it will not be available for use. Scopes can also be layered in a hierarchy, so that child scopes have access to parent scopes, but not vice versa.
Kinda. You could return an object literal:
function multipleReturn() {
return {
a: 1,
b: 2
};
}
const foo = multipleReturn();
// foo is an object; we can pull values from it
console.warn(foo.a) // 1
console.warn(foo.b) // 2
Im just looking at this and clampMin()
Doesn't make as much logical sense to me
I can tell it would work
Oh wait...
I think I get it now
Nvm?
I don't know anymore
Im trying to put it into context of my code
when in doubt, take a rest
this won't work, cuz damage is a const
overworking while ill doesnt help much
I'm returning early just so it doesn't chat spam
damage defined in clampMin is a separate reference from the damage defined on the first line. Look again
I usually comment that out
don't u need to use let, const or var when doing it?
I see, you are deliberately using the mutated function state in a further assignment. Indeed, if you did the one change I am suggesting, it would break your code
So you're saying instead of running the function standalone that I should ev.damage.clampMin()
?
These are foreign concepts to me ok, im good at simple javascript not embedded functions
u can't do "Number.clampMin()", because there is no .clampMin() method
Ok so . something() means method
Ill get there slowly
I've never heard of the term "mutating the function"
Or whatever it was
This was never a thing when I did Lua
So it's taking me a bit to understand
Here's a more full example of the refactor I am suggesting:
world.beforeEvents.entityHurt.subscribe((ev) => {
// Changing declaration to mutable
let damage = ev.damage;
const source = ev.damageSource;
const damageType = ev.damageSource.cause;
// applyArmor() commenting because implementation is missing
// Reassigning the value to the returned value of the function!
// Passing "damage" as an argument to the function
damage = clampMin(damage, damageType);
ev.damage = damage;
return world.sendMessage(/* ... */)
});
function clampMin(damage, damageType) {
if (damage <= 1) {
if (damageType == "fireTick" || damageType == "magic") {
damage = 0.5;
} else {
damage = 1;
}
}
// We've modified 'damage', so let's return 'damage'
// Nothing changes outside of this function, so this function is 'pure'
return damage;
}
More specifically, you are mutating the object that comes about from declaring the function. It's a weird concept—function declarations create objects at runtime, much like any other variable, that you can reassign or add properties to or remove properties from
Oh.. I feel very stupid now
Don't, I didn't fully examine your use-case
What you were doing was not wrong per se, just unconventional for typical JavaScript
I've said this many times. I come from Lua so I guess the standards are a bit different
Is there any reason that it's not
Let damage = function(a,b)
I've had it ingrained in my brain that variable declarations need a prefix
Variables need to be declared the first time they are used within a scope. Thereafter they exist in that scope, and depending on how you declared it, you can reassign the value for that variable
I really should just go back and relearn js huh?
Im making so many beginner mistakes
What's bad is my explanation is not actually consistent, just convention. Indeed, you can redeclare variables if you declared them with var:
function foo() {
// This is perfectly fine, no errors
var a = 1;
var a = 2;
return a; // 2
}
But the same doesn't apply if you declare variables with let 🙃 That nets you a runtime error
You certainly could write it this way too, if you go for the approach I went (using a pure function that returns a numerical value)
Like, you could write it as: let damage = clampMin(ev.damage, ev.damageSource):
youre learning and thats why youre making beginner mistakes, its normal
i also had that phase
This is the first time I'm using functions instead of writing everything in 1 block
Trying to get better with optimization
The only reason that applyArmor is empty rn is I don't actually have an armor to test with
This could almost work. You declared damage as a constant, so reassignments will throw an error. Change const to let on line 4 and it should work
Is it worth just using let as a default? It'll be a bit less optimized but will solve so many headaches early on
Working code before clean code
Yea, nothing wrong with that. const and let share very similar rules, just that one is writable and the other is not
yes but with a bit more experience youll intuitively likely be able to know whether or not youre gonna want a variable to be a const or not
and regardless you can change it to another type later
Yeah thats my thought process. use let, make it work, change to const and see if it breaks
If not keep it
If yes change it back
there's no issue with using let for everything at your stage imo
I like to think of const as a form of self-commenting code. "This variable is not intended to change"
My brain sees const as "does not change" but yet its used in a callback with variable outcomes
So it's a little confusing at times
no that's different
changing here means mutating
tbh i think ive rarely used let recently
but when a callback returns the value it's been initialized to be that very value
it doesnt change later
by itself
Oh so const means
"For this function's iteration, this value is fixed and does not change contexts"
idk what this function's iteration means but yea i guess
Take damage: iteration 1
Take damage again: iteration 2
oh
No; function parameters exist as part of the declaration. I'm sure you've worked with them before; I expect the only confusing concept is which value damage should refer to, and that comes down to variable shadowing
You can hyperlink in discord messages now?
The more you know
Yup; [text to hyperlink](URL to link to)
select some text then paste a link
or that
Good to know
if you have a link copied and you pasted it while selecting a text it auto does that
It does, I just like having more control. Especially since I prefer disabling the embeds, which I do with angled brackets (<URL>), and pasting over text means I have to navigate back and add them in more tediously
ah, yeah
when im debugging scripts where do i see the table of how long each function took to run
Native property setter cannot be assigned null?
Where is it getting null from
Is it because 1 of my functions isn't returning?
Ok yeah that was it
I like formatting stuff
Nested functions are a thing in Js right?
functions inside other functions?
Cause to apply armor I would need to getArmorValue()
why would they not be
Im writing a custom armor system that'll be used for all future custom armors (I plan to replace all the originals eventually)
Tho there isn't really much I can do until I create custom armor
They exist, but know that it means JavaScript must re-declare the function each time the parent function is called. It would be more performant to move the code out if possible
there is an event for that
not for eating specifically but item interaction end
i forgot the exact name but it should be in the docs it's an afterevent
Im trying to add a tag while the player is eating so I can cancel it if hit
for players eating, the itemStart/StopUse events would work
But is there an event I can even cancel to stop the action midway?
I don't think there is an "itemUsing"
Is it similar to const f = () => new Vector3() ?
How would I even check if a component exists?
I know you can grab the data of a component
I remember seeing something similar to this
But idk the exact formatting of it
Yes, both essentially do the same. One is simply an arrow function and the other isn't. They both have their purpose and behavior. In this case it's your choice.
Apparently golden carrots are not food
the food component only exists for data-driven items, for most vanilla items you'll need to check that the item either has the minecraft:is_food tag or that its identifier is minecraft:glow_berries (glow berries don't have the food tag for some reason)
Thanks
Now I just have to figure out how to cancel itemuse mid use
perhaps try this ;-;
I would need to save all the itemstack data no?
the itemStack itself is already the cloned one
You could just wait until the next tick the player eats that piece of food
Well yeah but itemUse only fires once at the beginning
If it was a constant event while use was being held it would be way easier to cancel
Yeah this won't let me cancel it
I might have a way
But it depends if I can access something
No luck
change the source.selectedSlotIndex = s ? s-1 : s+1 then change it back if u want
world.afterEvents.itemStartUse.subscribe((e) => {
const s = e.source.selectedSlotIndex;
e.source.selectedSlotIndex = s ? s - 1 : s + 1;
system.runTimeout(() => (e.source.selectedSlotIndex = s), 2);
});```
or move it to an empty one, or transfer the item
What do you mean lol?
If you mean what I think you do,
You can by:
Number.prototype.double = function() {
return this * 2;
}```
Then you can do console.log((5).double());
i think they meant a function identifier being a number
functions themselves can't since the grammar doesn't accept it, but with methods you could do that
e.g.
class A {
1() {}
}
new A()[1]();
internally it gets inferred as a string property of the object, so it's valid
I thought they meant
function 1(){
return 1
}```
wouldn't be valid :p
ik
I have an idea what if it moves randomly left or right if you get hit while eating?
There isn't really better alternative, unless changing the slot contents for a single gametick doesnt cause a flicker
No, because what I'm referring to is declaring a function with a name and that name being a literal number and what you are doing is assigning a function as a property value on an object.
no
You should check the documentation before using properties or methods of API classes
or install the server module
The problem im not trying to grab this value from the event data as the thing I'm triggering it on usually doesn't care about itemStack
Im just not sure how the grab the itemStack outside of event data
entity.getComponent('equippable').getEquipment('Mainhand')
Oh.. well I sure feel stupidn
where did you get this from
I just assumed that since selectedSlotIndex existed that the data would too in a similar variable
that's why the documentation exists
dont assume
theres docs
yeah
I need to save this data as im going to have to reconstruct this itemStack
Im not a big fan of the slot change implementation to force the cancellation of the eating action
So I'm going to remove the item and then reconstruct it
If there was a simpler way I'd use it trust me
yea but you can't do that afaik
for(let i of 256)
console.log(i);
yeah but numbers don't have iterators
you can change that
i mean yeah, just override the prototype, i meant by default
Yes sir!!
anyway
I get more of funny stuff thats possible
let me dig up that specific JS snippets i test ppl with lol
Am I blind or does itemStack not have a remove method?
- Implement a function named
rangethat can be used in the following expression:
for (let i in range(10)) console.log(i);
Your goal is to ensure the function produces the expected output of numbers from0to9.
Bonus: Try to achieve this without allocating O(n) keys in objects or array elements.
- Implement a class or function named ExampleClass that enables the following code to work as expected:
const object = new ExampleClass();
object.onLoad += logHello;
object.trigger();
object.onLoad -= logHello;
object.trigger();
function logHello() {
console.log("Hello World");
}
Your goal is to allow event handling for onLoad, where logHello can be added and removed dynamically. Ensure that calling trigger() executes the currently assigned event handlers.
the first one is pretty easy
@thorn flicker apologies for the ping but I'm looking at jayly's docs but there doesn't seem to be a remove method for itemStacks?
you just leave the itemStack argument empty
its optional
if left blank, it'll replace it with nothing
leave the itemStack argument of the setEquipment blank.
setEquipment(slot, undefined)
no difference
you are calling the function on the target, not the component
oh shit
yesn't
nah, it happens
I wouldn't say that
so
target.getComponent(). setEquipment()
yes
save the component to a variable so you are not calling it two times
Fewer API call is more performance (especially when you're doing it on a runInterval)
Let me see if it works first then I'll change it
you already have the equippable component stored
just make another variable for the item
I just hope my system in general will work smoothly
he doesn't
itemInfo...
Yup it disappears
he use it to get itemstacks
I know?
If I re-add it in the same tick it would just continue to eat no?
get rid of the getEquipment and make a new variable
what I mean is, its already in the variable
Im trying to cancel the eat action as smoothly as possible
Hotbar slot switching looked odd
im not saying it returns the equippable class
Im hoping removing and re-adding the item will be cleaner
const equip = target.getComponent('equippable')
const item = equip.getEquipment('Mainhand')
equip.setEquipment('Mainhand')
let damageType = ev.damageSource.cause
damage = applyArmor(damage, damageType)
damage = clampMin(damage, damageType)
ev.damage = damage
system.run(() => {
if (target.hasTag("verarc:is_eating")) {
let slot = target.selectedSlotIndex
const equippable = target.getComponent("equippable")
let itemInfo = equippable.getEquipment("Mainhand")
// world.sendMessage(itemInfo.toString())
equippable.setEquipment("Mainhand", undefined)
return
}
slot = slot ? slot - 1 : slot + 1
system.run(() => {
target.selectedSlotIndex = slot
system.run(() => {
target.selectedSlotIndex = slot + 1
})
})
})
yeah... which I was suggesting
you were wrong when saying he had it stored 🤷♂️
Would make this 10x easier
I explained it wrong.
sure.
what are you trying to do
Cancel eating midway through
itemStartUse?
Only fires on the first tick
yea first one isn't too bad, i did some cursed decorator stuff before so it was obvious
function range(length: number) {
return new Proxy({}, {
ownKeys() {
return Array.from({ length }, (_, i) => i.toString());
},
getOwnPropertyDescriptor() {
return {
enumerable: true,
configurable: true,
};
},
});
}
for (const i in range(10)) console.log(i);
2nd one is a bit tough, maybe i could do some symbol stuff
Then check for itemStopUse?
itemStartUse->logic->itemStopUse->stop logic
yeah im currently doing this for my full auto weapon.
no O(1) solution? 👀 if you use arrays you don't even need the proxy
I've got a variable for whether or not they are eating
but you are on right way
That much is done but you can't cancel a var
i wanted to do Proxy for the funsies :p
It's supposed to be taking any kind of damage interrupts eating
but there isn't an event I can cancel to stop the eating action midway
Hence why I'm trying hacky solutions
hmm, don't think it's possible to have O(1), at least not without generators which you can't use in for-in
It is possible ands its really claver way to do that
i'm guessing it's without generators then
yea pretty much
Wait this comes with its own set of problems
It can accidentally delete items if you switch slots on the same tick as you take damage
Maybe the hotbar switch was better..
I cant think of any other actions that could cause a player to stop eating
Well I can think of 1 but I don't think scripts can touch it
Nevermind
was thinking Array(length).fill(0) but that's still O(n) xD
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
Generators would be ideal for this though. Not sure why this is a for in question and not a for of question.
"Clever" tells me this is intentionally obtuse design and further implicates my point
yeah i'm thinking the same
Installation for @minecraft/server-ui
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
A more appropriate place for getting bot output would be #bot-usage @viral osprey
i'm reading through the for...in spec but doesn't seem like anything will help
Sprunkles could you help me out with a slight alteration to my code?
Sure. Assume I have read none of the chat history for two hours
This current part after the return handles switching hotbar slots to an adjacent 1, however I want to randomise the direction if not on either of the edges
ignore the 2nd system.run
That was to test if it looked good snapping back
(it didn't)
I would write a function for the modulo operation. This lets you perform division on two numbers, then take the remainder.
function mod(a, b) {
return ((a % b) + b) % b;
}
// ... inside your event
{
// Pick either -1 or 1
const direction = Math.sign(Math.random() - 0.5);
// Divide the slot index by 9, take the remainder
// number in range of 0..8, perfectly valid for hotbar slots
slot = mod(slot + direction, 9)
}
Im trying to understand how this works logically
A modulo of a / b is this not rather complex for picking 1 or -1?
Well, for picking -1 or 1 is on a step handled separately. That's what the expression Math.sign(Math.random() - 0.5) does
We're rolling a random number in the range (0, 1], subtracting 0.5 to make the range (-0.5, 0.5], then taking the sign of that number. It's a nearly perfect 50/50 split between -1 and 1 (with an infinitesimally small chance of returning 0)
The modulo operation is being used here so the slot that we pick stays within the bounds of 0..8 (for slots 1..9)
isnt there a function to randomly pick from an enum?
From an enum; can you elaborate? That could mean a number of different things
An enum is a collection of set values you can choose from no? Or maybe my illness is clouding my memory
I agree on that definition, but there are several different implementations for enums. Most nefarious of all being a TypeScript enum
Im only familiar with the standard definition
I'm still tryna figure out what
slot = slot ? slot - 1 : slot + 1
Actually does
Well I know what but not how
What it does plainly might not follow what you expect. If slot is truthy (in the case of numbers, a non-0 value), then we return slot - 1, or otherwise slot + 1
ah so that means 1+ always goes down and 0 always goes up
slot is just the indexId in this scenario which I guess does make sense
function assignSlot(slot) {
return slot ? slot - 1 : slot + 1;
}
assignSlot(0) // 1
assignSlot(1) // 0
assignSlot(2) // 1
assignSlot(3) // 2
// Negative numbers are also truthy
assignSlot(-1) // -2
so I guess I can replace slot + 1 with slot + math.round(randInt(-1, 1)) or equivalent unless slot = 8
If slot == 8, then it's possible it assigns to 9, which would be out of range. Similarly, if slot == 0, then it's possible it assigns to -1, which is also out of range
Ah, you meant if you replaced only the false condition in the ternary, I misread. Then yeah, I suppose it would
Although now that you're adding more branching logic, it becomes less clear at a glance what it's doing, as there's more cases to consider and more code to read. I like the modulus approach since the function handles wrapping for us:
if (slot = 8) {
slot = slot - 1
return
}
slot = slot ? slot - math.round(rand(-1, 1)) : slot + 1
Im trying to avoid wrapping as it looks unclean
If you're having the player's slot change, wrapping is a natural consequence, no? If I scroll past slot 9, I end up on slot 1; that's not unexpected, at least to me
I also just realized that math.round does not work here as values can round to 0 resulting in movement
While true this condition is not controlled directly by the player and I would like to avoid the player having to scan both sides of their hotbar to see where their "cursor" ended up
Fair
I need an alternative to round that will always round away from 0
0.002 -> 1
-0.31 -> -1
I'd probably write it this way then:
if (slot == 8) {
slot = slot - 1;
}
else {
const push = Math.sign(Math.random() - 0.5) || 1;
slot = slot ? slot + push : slot + 1;
}
Can you explain math.sign to me? never used it and I would like to understand what I write
Yup. The sign function returns the signed value of a number:
- If < 0, return -1
- If > 0, return 1
- If 0, depends (some implementations return 0, some 1)
Oh so like exactly the function I was looking for
Quite nice, eh? haha
How many dp does math.random go to?
Sorry, DP?
Decimal places
Ah. Well numbers in JavaScript are 64-bit floating point values; that might not have an exact answer, since that depends on how close to 0 the resulting number is. But it has a fair amount of precision in that range
Just was wondering the chances on rolling exactly 0
Really, really, really small. Infinitesimally small
This also handles for that edge case right?
Imagine if I gave them a diamond for being that ungodly lucky lol
Aye, if it does roll 0 for whatever reason, my example uses the OR operator to evaluate it to another value.
As a simpler example, Math.random() || 0.5 will return a random number in the range [0, 1], with any 0 rolls turning to 0.5
Well I appreciate the help
This should finally be a functioning cancel system
Yep it works
Eating gets cancelled by taking damage
And it actually is a tiny bit punishing
What's is the and operator again?
I need to exclude 2 damage types
It's just && right?
Yup, a && b
Maybe starvation damage too
Honestly thanks for the catch there
Maybe I should just create an array
Cause wither is it's own damage type too
You definitely could. Though it would be good to delcare the array outside of the function, so the game isn't building a new one every time you or any other entity takes damage
I have no clue what to call these
1 is all types that don't cancel eating and the other is all types that get a reduced damage floor
Actually tbh they're probably the same
When in doubt, super long variable names: eating_cancel_ignored_damage_types
special_damage_types
And if you're still unsure about the name, you could always add a docstring above it, so you know what it is used for
True
I think this is good
Now I gotta figure out how to implement this
If the damage type is not in the list. Cancel eat
Any solution would involve iterating the array. You have many different solutions at your disposal for that; probably the simplest is using the includes() method.
if array.includes(damageType) ?
Yup, pretty much
Can you give an example?
unless (conditions) {}
I suppose you could use logical negation. if (!condition) {}
I think that should work?
Aye; if it is any of those damage types, then the condition fails
Well I've ran into a bug
Sometimes the slot changes but not visibility on the hotbar
Hm. I'm guessing it's a client–server desync
I am using system.run instead of system.runTimeout(code, 2)
That don't look like a gap
No that isn't possible then.
Identifier cannot start with a digit.
Even:
function 1add () {
}```isn't valid.
I guess just add a prototype to Number class
Tho it works on all numbers
Nvm it didn't work
It does work lol?
Did you use an arrow function? They do not have this. (At least, they do not have this of their own.)
we discussing cursed js... 
Oh well.
how to get blocks break duration or detect how soft blocks are?
you should be able to
if you just directly use translation key
well, at least thats how it is with description
tried this, and it works js return { status: CustomCommandStatus.Failure, message: `${origin.sourceEntity.name} failed to %gui.confirm` }
I need to pass extra translation args in
oh well
time to put yet another thing onto the weirdo list
this is probably why its not done with RawMessage or something
you register a custom command at the start of world(server) which cant be changed later on
but like that should be fine for a command result
the client gets a raw message that it translates itself
at least it works this way i guess
