#Script API General
1 messages · Page 14 of 1
Why doesn't this work?
import { world, system } from '@minecraft/server';
// Notify that scripts have been reloaded
world.sendMessage("§l§aqqq");
// Listen for chat messages
world.events.chatSend.subscribe((eventData) => {
const message = eventData.message;
const player = eventData.sender;
// Check if the message is the custom command
if (message == "!help") {
// Send a help message to the player
player.sendMessage("§l§a¡aaaaaaaaaaaaaaaaaaaaaaaa");
}
});
events property on world does not exist
How do I get the player's hp? Max Hp and damage?
Nvmd
does this event not work anymore?
potions got new components
Is it possible to test by player hunger?
sadly no
its unusable, the potion effect types are hidden for whatever reason
though you can guess some of those but some are just unknowable
ok
what dose that mean
like you need to do "Leaping" or "FireResistance" instead of "jump_boost" or "fire_resistance"
and they didnt even put the list of it in docs
there is not enum for those?
i dunno
It’s in vanilla-data
well it’s beta so they may change it…? took a while for me to figure out too
MinecraftPotionModifierTypes
MinecraftPotionEffectTypes
MinecraftPotionLiquidTypes
oml theres no regeneration enum 💀
"Healing"?
isnt that instant health
idk
there is also health boost
This scripting sure likes to get on my nerves
And so do my parents
I had a function containing the thing that needs to activate the said function
damn I’m dumb
Doesn’t help I deconstructed the whole thing trying to find the whole problem
All it took was 1 ‘}’
The interpreter will notify you about the syntax errors with Syntax error message
I already fixed it but damn did I feel stupid
bridge should have syntax errors
Do not use bridge for scripting
vsc on top
VsCode top!
@granite badger do you have any idea why this happens when i use the new typings?
It's neveer happened before
happens when using server beta and server-ui stable yeah?
invalid npm downloads?
yes
npm i @minecraft/[email protected]
this one
Could it be because im using ESNext
nah
{
"overrides": {
"@minecraft/server": "beta"
}
}
You need to add the override key, and set beta to whatever version you’re using.
in ur package.json add this
"overrides": {
"@minecraft/server-ui": {
"@minecraft/server": "$@minecraft/server"
},
"@minecraft/server-net": {
"@minecraft/server": "$@minecraft/server"
},
"@minecraft/server-gametest": {
"@minecraft/server": "$@minecraft/server"
}
}
just npm install without global??
i never have global
you gotta specify the -g thing to do global
i just npm i
npm init -y to setup package.json first in your addon directory
alright i have that
reinstall every mc package you need
why does this remind me of everything package
me when npm uninstall all
has anyone tried creating a perlin noise height map in scripting? would it be possible to use it for custom generation?
con master have one i believe
that's crazy 🤣
yeah
Mojang pls don't remove entity.target !
Mojang pls make it not read only
I am wondering whether anyone here would have information about when the @minecraft/server-net API will leave the beta phase and become standard? I have several fun applications for it that I want to try developing, but I don't want to build stuff and learn down the road that the API was removed or that it changed, etc. Thanks for you help! 🙂
Expect the API to experience changes, whether the changes are subtle or frequent. That is normal with any given API.
Thanks for your reply. 🙂
Yes, of course. But I am wondering whether there is known release date for the stable version (i.e., a release that does not require the use of the "beta APIs" flag)
None at the moment.
Considering that it's still on (1.0.0) since it's debut, it may be a while.
I understand. Thanks for the info.
Do you know if that API is popular among developers? In other words, do people appear to be using it a lot for new types of applications?
I am new to Bedrock development and I am just trying to understand towards what my "experimentation efforts" would be best directed. Obviously, I personally find that API to be pretty interesting because it allows a lot of use cases, but I'm curious to know what other people think about it.
keep in mind that server-net module is locked behind bedrock server only
They released it roughly 2 years ago. Not many use it, because the majority choose Realms over BDS due to "player base". Meaning that they feel it's easier for people to join their Realm on different platforms than a regular server.
Some people do use it, because they realize the potential it has, and think outside the box. However, I believe since it's been out for a couple of years now, it's probably only been within the last 3-4 months that it has begun to pick up popularity.
Yes, that's true. That probably means that it will be less popular than APIs that can be used everywhere. In other words, the "market" for it might not be as large as for other APIs since it will mostly appeal to server admins.
I have work with server-net in the past, i used it to comunicate with a discord bot using an rest API i built
Player report system and some rank things
I think that is one of the most interesting use cases for it. It's definitely something I want to try do myself. Another interesting use case is notifications for various "player events".
wondering @minecraft/server-gametest can make simulated players using a custom skin, like choosing a random player of the world, and then set the skin to the simulated player
Thanks for your feedback!
I have some things that i can share, maybe i will upldoad them to scripting-resources
i think i did saw a post about simulated player before
maybe bdsx
That is the one API I haven't tried yet. It's on my to-do list though. 🙂
😉
Is there any way to close the ActionForm without response from the player
How do you do that?
Yes** sorry
You can
does it work in 1.12.0-beta?
Its server-ui module.
Its Beta
how to make like auto coloring text for certain number?
something like this
const colors = {
0: "§f",
5: "§7",
10: "§8",
15: "§e",
20: "§6",
30: "§b",
40: "§d",
50: "§5",
60: "§a",
70: "§2",
80: "§c",
90: "§9",
100: "§1",
120: "§4",
140: "§3",
160: "§0",
180: "§l§f",
200: "§l§7",
220: "§l§8",
240: "§l§e",
260: "§l§6",
280: "§l§b",
300: "§l§d",
325: "§l§5",
350: "§l§a",
400: "§l§2",
450: "§l§c",
500: "§l§9",
550: "§l§1",
600: "§l§4",
750: "§l§3",
800: "§l§0",
850: "§o§f",
900: "§o§7",
950: "§o§8",
1000: "§o§e",
1050: "§o§6",
1125: "§o§b",
1200: "§o§d",
1275: "§o§5",
1350: "§o§a",
1425: "§o§2",
1500: "§o§c",
1600: "§o§9",
1700: "§o§1",
1800: "§o§4",
1900: "§o§3",
2000: "§o§0"
}
but its automatic selecting the color from color list
I checked and you need to udate your MC
1.4.0-beta
I dont see any reason to not update your game 👀
version 1.21.20 right?
import { world } from '@minecraft/server';
const colors = {
0: "§f", 5: "§7", 10: "§8", 15: "§e", 20: "§6", 30: "§b", 40: "§d",
50: "§5", 60: "§a", 70: "§2", 80: "§c", 90: "§9", 100: "§1", 120: "§4",
140: "§3", 160: "§0", 180: "§l§f", 200: "§l§7", 220: "§l§8", 240: "§l§e",
260: "§l§6", 280: "§l§b", 300: "§l§d", 325: "§l§5", 350: "§l§a", 400: "§l§2",
450: "§l§c", 500: "§l§9", 550: "§l§1", 600: "§l§4", 750: "§l§3", 800: "§l§0",
850: "§o§f", 900: "§o§7", 950: "§o§8", 1000: "§o§e", 1050: "§o§6", 1125: "§o§b",
1200: "§o§d", 1275: "§o§5", 1350: "§o§a", 1425: "§o§2", 1500: "§o§c", 1600: "§o§9",
1700: "§o§1", 1800: "§o§4", 1900: "§o§3", 2000: "§o§0"
};
world.beforeEvents.chatSend.subscribe((event) => {
const player = event.sender;
let message = event.message;
// Example condition: color based on message length
let length = message.length;
// Find the appropriate color based on the message length
let closestColorKey = Object.keys(colors).reverse().find(key => length >= parseInt(key));
if (closestColorKey) {
const colorCode = colors[closestColorKey];
event.message = `${colorCode}${message}§r`;
}
});
You don't do new UIManager(), just import { uiManager } from "@minecraft/server-ui"
Its not useable
i'm trying to make the 2d item texture not render using attachables, but i've added the file and it doesnt do anything. no content log, no nothing. i even tried just copypasting like the bow or something and it doesnt render the bow nor does it stop rendering the 2d item texture...
#1019692489596215388 message
Thats a #1067869136606220288 or #1067869590400544869
kk
[Scripting][error]-Unhandled promise rejection: ReferenceError: No constructor for native class 'UIManager'.```
What is needed for it to work?
import uiManager from module as instance
give me sec
yes
i have a question
i have this module/script that i import data from, there is the categories constant which contains raw data, and 2 functions that process them into the achievements constant,
now does the flat_category function run everytime i import achievements, or does it only run once when the script is validated?
Can you provide more details, how to use it?
there is method closeAllForms wnad first param is player
basicly import uiManager from server-ui module
like that?
the ts part isn't needed
can just do import {uiManager} from '@minecraft/server-ui'
yes
and then uiManager.closeAllForms(player)
we to pin some tutorials here
I mean General JS
like how to import
and what object is
Expanding on the wiki would be good, and getting a stable version of the API on the wiki would be exellent (so people using it don't have stuff break)
also diference between parameter and argument
real, i am really busy last bunch of weeks but i think i should contribute on wiki again
I may look into expanding script wiki today
I got spare time 
i am on vacation so i dont have much resources to work with, but i may do something
Is player.velocity a valid method?
I can add you to my fork of the wiki
function spawn(player) {
const playersInUI = new Set();
const chestui = new ChestFormData(27);
chestui.title('§l§d Event Crates');
for (let i = 0; i <= 11; i++) {
chestui.button(i, '', [''], 'minecraft:gray_stained_glass_pane', false);
}
for (let i = 15; i <= 26; i++) {
chestui.button(i, '', [''], 'minecraft:gray_stained_glass_pane', false);
}
chestui.show(player).then(response => {
uiManager.closeAllForms(player)
return;
});
}```When I open the form, it doesn't close that form. What is the issue I am facing?
Ok why not
its not, you have to call it like this entity.getVelocity()
Thank you!
Please do a section explaining how to properly update to the newest format version. Numbers are not my friend.
Hello everyone, please tell me how to load a lot of structures quickly. I have 4 64x64 structures and when loading them, the game lags a lot on a powerful computer
Well there are no properway to load them then just loading them, you can try using animations but it takes more time to load it but it may reduce lag spikes
How do I test which slot a player's item is in?
every time you call it
when you import it it is just like you declare it
"player's item"?
player.selectedSlotIndex
Has ChatSend been removed?
No, only Beta.
I don't remember how to delete the message the player wrote
You mean to cancel the event so it doesn't broadcast?
event.cancel = true
I think this is it
Yes, for the beforeEvent.
Ok
const encid = enchantments.map((ench) => {
return {level: ench.level, type: ench.type}
});
Fixed
that's in beta?
ye
interesting
How do I add a name to an item using additem?
What does this do?
closes all forms
does interval_range even have an effect to onTick?
what about looping?
Yes
"@minecraft/server-net" is incredibly powerful if you think outside the box since it lets to interface with whatever you want.
You can use it to do some wild things.
#1200260894593130496 message
why no worky?
{
"format_version": 2,
"header": {
"name": "RPG",
"description": "TYavaJ's RPG project",
"min_engine_version": [
1,
20,
80
],
"uuid": "1153bf7a-cb39-4282-b70b-ff10b7120bec",
"version": [
1,
21,
20
]
},
"modules": [
{
"type": "data",
"uuid": "cb3a43a5-ae49-4612-b945-fe7469381faf",
"version": [
1,
0,
27
]
},
{
"type": "script",
"uuid": "59a3b25f-7752-474c-8f90-a948376c6220",
"entry": "scripts/index.js",
"version": [
1,
0,
27
]
}
],
"dependencies": [
{
"uuid": "0e6331ef-fd94-4a88-8eda-5e1264e197f5",
"version": [
1,
0,
27
]
},
{
"module_name": "@minecraft/server",
"version": "1.13.0"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.2.0"
}
]
}```
that is not the source of the error
Did you read the error?
indeed
what does it mean to you
well I dunno but I can tell ya that
{
"module_name": "@minecraft/server",
"version": "1.14.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "2.0.0-alpha"
}```
doesn't work any more than anything else
You are referencing a module that doesn't exist
and then it lists out the versions that do exist
I've tried several things and that did not infact work
,_ ,
you are using the developer behavior pack folder?
yeah
does 2.0.0-alpha even have anything in it?
I have no idea
check in a new world with 1.2.0
scroll up
like create new world with the addon?
what dose the log say
yeah
unless the pic you sent was not for the code you sent
I don't think there's anything 2.0.0-alpha
read
alright
this is the current dependencies section (which does not infact work)
"dependencies": [
{
"uuid": "0e6331ef-fd94-4a88-8eda-5e1264e197f5",
"version": [
1,
0,
26
]
},
{
"module_name": "@minecraft/server",
"version": "1.14.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.3.0-beta"
}
]```
so
Okay, well use that in your manifest
then send screenshots of the errors
the invalid module ones will be gone
function addMoney(player){
const moneyObj = world.scoreboard.getObjective("Money")
new ModalFormData()
.title("Send player")
.textField("Amount, Has to be atleast 1k", "Enter amount of money")
.show(player).then(d => {
const moneyAmount = d.formValues[0];
if (moneyAmount){
moneyObj.addScore(player, `${moneyAmount}`)
player.sendMessage(`HCV KitPvP >> ${player.name} has sent you ${moneyAmount}`)
}
});
}
could someone help me with this
I......did
just update the manfiest
there is?
addScore receive number
If you're getting those errors, you are not using the development folders
or you switched the versions back

Number(moneyAmount)
or
0+moneyAmount
erm actually 🤓
stop switching the module versions back to the incorrect ones then, the errors you are getting in content log are specifically mentioning the wrong ones you had, not the correct ones
you can still have one in the other folder
wdym? This BP does not exist in the main folder
thank you so much, im going to try that
u gotta import the file
into the main js
the error don't make any sense
did you make a new world?
I did
idk man
C:\Users\redacted\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang\development_behavior_packs\RPG BP
nice chat
ikr 🔥
that is not the file the game throwing error for

it's throwing errors for RPG BP and WorldEdit
cuz like
you have something going on there
1.2.0-beta is not the version you are showing us
that mean there is a file somewhere that use that
backup your pack and delete it in game
I would perfer not to do that but like
erm
"dependencies": [
{
"uuid": "0e6331ef-fd94-4a88-8eda-5e1264e197f5",
"version": [1, 0, 26]
},
{
"module_name": "@minecraft/server",
"version": "1.14.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.3.0-beta"
}
]```
was correct
🤷♂️
Blind moment.
you're using 1.2.0-beta - @minecraft/server-ui. Error stated that module doesn't exist. The latest beta module in your list says 1.3.0-beta, use that instead.
For @minecraft/server you're using 1.12.0-beta which doesn't exist.
Use your eyes and look down on that list, and you'll find that 1.14.0-beta is the latest beta module
Another Note: You cannot mix stable module with the beta one. If you're gonna use the -beta, you need for both to be -beta
that is not true
i use both
Sometimes, the versions conflict with each other. Requesting a different version.
Good to know there's some exception.
I added custom components to my onPlayerDestroy and onPlace block and it happens that when interacting with the block it makes the swing animation, is that normal?
not normal but unavoidable
I guess it's a bug to be resolved
Help i dont understand what is the problem, can someone help me with this?
const color = { red: 0, green: 1, blue: 0 };
const colorMapVar = new MolangVariableMap().setColorRGB("color", color);
world.getDimension('overworld').spawnParticle('minimap:line_particle', {
x: -53,
y: 320,
z: -23
}, colorMapVar);```
Debug result for [code](#1067535608660107284 message)
Compiler found 1 errors:
[36m<REPL0>.js[0m:[33m7[0m:[33m4[0m - [31merror[0m[30m TS2345: [0mArgument of type 'void' is not assignable to parameter of type 'MolangVariableMap'.
[7m7[0m }, colorMapVar);
[7m [0m [31m ~~~~~~~~~~~[0m
There are no errors from ESLint.
It use to be like that, but now we can.
How can I do http requests in script api?
i heard you need server-net module
You need to use @server/net, which is only available on Bedrock Dedicated Server
getTags from a block cant get a custom tag?
like this in json
"tag:namespace:tag": {}```
and like this in scripts
```js
const tag = block?.permutation.getTags()[0];```
its returning undefined
but minecraft: works, right?
aah, it was my mistake, I was trying to get the tag of a destroyed block xd
How to use "translate" on ActionForm buttons?
.button({translate: "my.custom.text"});
How to save structure with script?
Thanks, but where do I put the value of %s?
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/rawmessage may be of use 🙂
not all the strings support rawtext, right?
Not all, but most do
nice
Thank you very much, this was very helpful 🙂
im super confused as to why my pack wont load. i changed everything to the latest beta and my pack dissapears i changed it back to what it was befor the update and the scripts dont load lol
Do dynamic properties actually resets when re-adding an addon? Doesn't happen for me when testing
no
it stores in the target
alr, thanks!
they only reset when the UUID is changed
it can't be used
How do I disable the target's shield when attacking?
is there anywhere to cancel a players hits?
player json file
item.getComponent("cooldown").startCooldown(player)
But how do I get the target when attacking?
Apparently hitting the shield does not count as a trigger for onHitEntity or onDurabilityDamage.
hit entity
you mean before the attack?
CustomComponents so, yeah
get entity from view
you can also just subscribe to hit event and apply your own damage
Ok, I'll see
hi, what manifest should I put inorder to run script in 1.21.20?
im using this but not working anymore
{
"format_version": 2,
"header": {
"name": "Dokkaebi",
"description": "script training",
"uuid": "9a5e17d3-8ca7-4f5c-83c2-c1177ac988ec",
"version": [0, 0, 1],
"min_engine_version": [1, 20, 60]
},
"modules": [
{
"type": "data",
"uuid": "49da1514-2614-49c2-a5b3-59ae21c85e67",
"version": [1, 0, 0]
},
{
"type": "script",
"uuid": "db7397bd-a1a5-4f48-933c-e88d1af1f1fe",
"entry": "scripts/main.js",
"version": [1, 0, 0]
}
],
"dependencies": [
{ "module_name": "@minecraft/server", "version": "1.12.0-beta" },
{ "module_name": "@minecraft/server-gametest", "version": "1.0.0-beta" },
{ "module_name": "@minecraft/server-ui", "version": "1.2.0-beta" }
]
}
should I also change the min_engine_version?
tysm
Is there a way to save a player's enderchest to the database?
there is no enderchest api yet
but that can be achieved with commands
you can find more info here https://discord.com/channels/523663022053392405/1268719494679756812
how to start a ride like /ride but with native method?
There is component as far as i know check docs
yup, addrider, but how to use it?
I'm beginner:)
Oh
Do you see docs? there must be some kind of parameters but not sure which one
let me look at docs
horse.getComponent("minecraft:rideable")?.addRider(player);
i didn't test it tho
oky thanks
What is the error?
item.getComponent('enchantable').addEnchantments(items[4].enchantment.id, items[4].enchantment.lvl);```
it's should be in array of object
[{
type: EnchantmentType,
level: number
}]
item.getComponent('enchantable').addEnchantments([{
type: items[4].enchantment.id,
level: items[4].enchantment.lvl
}]);``` like this?
the type is need to be the EnchantmentType,
type: new EnchantmentType(items[4].enchantment.id)
it doent work
[Scripting][error]-TypeError: must be called with new at EnchantmentType (native)
at <anonymous> (Crate.js:254)
new EnchantmentType()

import { world, Player, system, ItemStack, Block} from "@minecraft/server";
import { ModalFormData, ActionFormData } from "@minecraft/server-ui";
world.afterEvents.playerInteractWithBlock.subscribe((e) =>{
const { block, blockFace, itemStack, player } = e
if(itemStack.typeId == "minecraft:diamond" && block.typeId == "minecraft:end_portal_frame"){
system.run(() =>{
player.runCommand("/clear @s diamond")
player.sendMessage(`HCV KitPvP >> has sold your diamond for ${itemStack.amount}`)
})
}
})
why does this not start?
runcommand should not have slash on it
also system.run is not needed
still dont start
i already tried with no /
#debug-playground message
youre using afterEvents for it
also please for the love of god, use content logs
How to add a temp property to a player? ( I know it does not stay when they leave)
player.tempProperty = whatever
ah I went in too deep
It does stay when they leave-- just if the world gets closed then they are reset.
So singleplayer? Reset
Last one to leave a realm? Reset
BDS? Not reset, unless /reload or world restarts
the one bit of information I need when a block is placed is only in playerInteractWithBlock types (faceLocation)... I am trying to get where on the block face was clicked.... so I need to save it from use it in custom component
for beforeOnPlayerPlace.. so I can do simpler permutaions
Regarding this-- most people do something to separate them from available properties, like adding two underscores in front of the property name player._tempProperty
I am putting an object in a var called f3... LOL... where I can store current info)
excellent
hi
hi
What creative ways do any of you have for looking at a projectile arrow and determining the effects it may contain?
Curious to see if anyone came up with any quirky solutions since the API is limited in this area.
getEntityFromViewDirection(), check if its a arrow, get the projectile component, maybe there is a getEffects method
idk what did i just said
Hey , just realized beforeEvents.playerPlaceBlock has faceLocation but blockComponentRegistry.registerCustomComponent beforeOnPlayerPlace DOES NOTwhich makes me have to use a work around of saving the information via dynamic props or to the player.f3 object I made using beforeEvents.playerInteractWithBlock to get it saved (but for all blocks).
Oversight? Requestable to mojang to add? Do I just use the old way instead of the custom component?
If they had just added a dang horizontal_half when they did vertical_half.. I'd be set for the permutations I need... this information makes life easier to do stuff based on where clicked on block.
Where do we suggest for script api stuff anyway? Anyone?
Their GitHub has a feedback button I believe.
I would need to look really quick.
I can't find the information on it 😔. Which is odd
LOL... I thought maybe you got distracted...
not sure what to do, this affects how I JSON the block. I can ditch their states and use mine or do a hybrid to permutate the rotation of the block.... but changing state names or adding/deleting on a block in play breaks previous blocks.... I think.... I better fact check that.
I'm just baffled that I can't find the source to link you.
do you have a way and you are looking for another? or are you asking for a way to do so?
Looking for a way. To give a brief summary, I'm handling projectiles. Won't go into much detail on what I'm doing exactly because it's too much and most of that information isn't relevant. With that said, I check if the projectile is an arrow. From here I need to know if the arrow is a tipped arrow. Meaning that I need to know if it's an arrow which causes effects on its targets, like poison.
I was discussing it with someone else just recently and we think that this isn't accessible from an arrow outside of it being an item type. Which means it would be very restrictive.
there is only "work around"
duplicate it and make it hit an entity
Can't clone it. It's an entity.
structure
Not following. I'm talking about an arrow that is being projectiled through the air.
get the arrow location
save it using structureManager API
summon a dummy entity somewhere
place the structure there
get the entity effects
Oh, nah, can't do that. Way too expensive.
dose tipped arrows have effects?
Potion effects.
getEffects don't work?
Returns []. It's empty.
not sure
even the entity JSON don't have anything related to tipped arrow
https://github.com/Mojang/bedrock-samples/blob/main/behavior_pack/entities/arrow.json
Data values
those are for the item
the entity is different
it is nbt data under mobEffects list
can't do anything about both in script api anyway
Yea I'm aware. I mentioned it earlier 😀
😀
the code he sent is correct
nvm
setActionBar
uppercase bar
most javaScript functions are like that
alright
yeah, in game names should be the same
well all commands are in lowercase anyway.
Who have a code that when the player looks at the entity it stop moving but when he is looking away it moves and attacks him
means freeing the entity while looking at it, but when u look around it will start chasing the player just like the horror addon thing
that should be implemented mostly without script api
no sorry
yep
that is great
nice to meet you
it is too much work for just helping someone
Plss man we are brothers in islam
Just try
I searched alot
make the entity and i will help you with the script part
i meant the behavior
Is typescript and js same?
why is this structure of code looks different than the other?
var Something
(function (Something) {
export function other() {}
Something.other = other
})(Something || Something = {})
?
Idk if exporting function inside a function is possible
But it s not
- the last () is made for passing arguments
But it s made for making modules
why doesn't this work?
initEvent.itemComponentRegistry.registerCustomComponent('blc:on_use', {
onUse: ev => {
const player = ev.source;
const ItemStack = ev.itemStack;
if (ItemStack.typeId === 'blc:shunpo') {
source.runCommand('summon cow');
}
}});
Excuse us ? What ?
item is 1.21.10?
I got the item version wrong, I just saw it
What the error?
Ok
thankys
you try to help
Ok uw
Latest NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Beta APIs NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Preview Latest NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Preview Beta APIs NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
onRandomTicking needs the minecraft:random_ticking component?
so I was thinking about making some sort of combo system
like you right click and left click the air
and it says like "R-L-L" on the screen
or something
similar to Wynncraft
but there's like no way to detect punching the air
how to create new itemstack for stonetype that use the datafield like granite, andesite, or diorite?
Latest NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Beta APIs NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Preview Latest NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Preview Beta APIs NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
#debug-playground
@glass gull
Intro: https://wiki.bedrock.dev/animation-controllers/animation-controllers-intro.html
Running commands: https://wiki.bedrock.dev/animation-controllers/entity-commands.html
ik
well, if u know, why u do that
bc it doesnt have the @gaunt salmon bot
const newItem = new ItemStack(items[4].id, items[4].amount);
if (items[4].enchantment.id !== '') {
newItem.getComponent('enchantable').addEnchantments([{
type: new EnchantmentType(items[4].enchantment.id),
level: items[4].enchantment.lvl
}]);
}
if (items[4].lore !== '') {
newItem.setLore(items[4].lore);
}
newItem.nameTag = items[4].name;
slot.setItem(newItem);```I cannot set the item if it matches items[4].lore. Is there any way to fix this?
Can you send what items[4] actually is?
just "mythic"
No object properties?
Not even when I change it to newItem.setLore('mythic'), it still reports the error [Scripting][error]-TypeError: Native optional type conversion failed. Function argument [0] expected type: string[] | undefined at <anonymous> (Crate.js:414)
oh, setLore requires an array of strings, not a single string
newItem.setLore(['mythic'])
thask
The Minecraft Debugger settings should just be in main menu > settings > Creator right? They seem to have gone missing
or what wdym
lol, try to restart
I have several times xD
disable content log file and delete the old ones
they take a lot of storage
my log folder was like 5 Gb
true
someone use that files actually?
ik, but sometimes when i have too large logs, i can check better
some times
the log gui have a limit and don't display all the log from the start

the idea is to resolve errors, not let them accumulate xD
script warnings (printing debug info)
I use sendMessage to debug
Yes, but I usually test values or some strings
why would I need to copy it?
depend
maybe you need an exact value from the game
or yo formatted an object and want to copy it for other uses
Ah, that could be useful for databases for example, but I'm not usually in those situations.
I prefer to keep the debug and the error console separate, otherwise I get confused sometimes
yeah
i use chat too some times
tbh i hate the log covering my screen
same
if i just import a file like
import "./myFile";```
does it also import stuffs that are export? like
```js
export function myFunction()```
You'd need to import the function separately to use it in the file that you are importing "./myfile" in
I believe
import {myFunction} from "./myFile"
importing a file just make the code inside it run
Another thing
If you're wanting to import everything from one file to use in another file, I believe you can just do this
import * as blah from "./myFile"
blah.myFunction()
only exported stuff
that is the same as
import {x,y,z} from "./myFile"
the only different is that you import as an object
import * as var from "./myFile"
here the value of var is {x,y,z +anything else you exported}
I forgot to put if they didn't want to manually add each thing in the {}
Latest NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Beta APIs NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Preview Latest NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Preview Beta APIs NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
just needed thm sorry
is there some sort of function chain limit or smth like that? because i made a function run a function which runs a few functions, sorta like this
import { function1, function2, function3 } from "./differentFile";
function functionSet() {
function1()
function2()
function3()
}
function myRootFunction() {
functionSet()
}```
and it didn't seem to run
for context, im doing this because i wanna group up functions to be able to make some sort of skills system, the "root" function detects whether a specific condition is met which then runs the "set" function/group of functions
It will call each of those functions, unless a function before it returns, causing the next one to not execute.
i forgot, let's say functions 1 to 3 is from a different file and just imported
can it still run those?
Calling a function from another file will require that function to be exported and imported.
yep did that, im not sure what's the problem now
Will still run of course.
The only problem with this setup is that you do not explicitly call function1, function2, and function3 in this example, so based on this example those three functions would not execute unless explicitly called.
Wait, nevermind. I looked at your syntax wrong.
You are in fact calling
updated it so the functions 1 to 3 are now called
return in functions don't do that
It does if there's an error
maybe the problem is not the functions, lemme test something
As much as I wanted to change that earlier I decided to leave it be. Wasn't concerned lol.
ah, so the functions are fine
the if statement doesn't run tho
i cant explain it well but lemme make an example
scripts/differentFile.js
function function1(name) {
if (name == "bob") {
...
}
}```
main.js
```js
function compiledFunctions(name) {
function1(name)
function2(name)
...
}
function rootFunction(name) {
compiledFunctions(name)
}```
i have something similar to this but the if statement of function1 doesn't run idk why tho
there doesn't seem to be an error aswell
I don't know what you are passing to function1 but I would suggest using === versus == for strict type checking. You can do a quick Google search to determine the benefits of that.
Best I can say is to print the variable name in function1 to verify if it's what you are trying to conditionally check against.
alright i'll check the values being passed through
ah i see, thanks for suggesting me to check the values, it turns out im off by one object in an array
when this happen 🤡
Could someone help me? I'm making a script that if the player looks 100% up or down he gets a boost, But any other angle it gains boost forward or sideways.
Well entity in theory never can look up or down 100%
also please explain it in more details what you want to achieve
Like the 100% I'm talking about is the maximum that the entity can look up or down to
👍
just display the viewVector and save its Y values then just compare
I did this but it always gives a different value so I got confused.
check only for Y value and you can also add check for range to be less specific
for example 99.9% should be OK
sytem.runInterval(() => {
for (const p of world.getAllPlayers()) {
console.warn(p.getHeadRotation().y)
}
})
Was it headrot, idk correct me if im wrong
Let me try that
I'll try this too, thks
This worked, thank you very much
I just have one more question, how do I do it now so that when the player is looking at any other direction it gains boost in a specific direction?
player.applyKnockback()
Ohh, Let me try
holy fuck, block with custom components are a real headache
Prefer using events over that
Custom components offer a good variety of features
You could use world events, but, eh
Idk but events are more easier and no need to fix errors 2000 times
And after that u realize it was min-version problem
At least for the tick custom components, you can’t replicate that using world events
player.dimension.spawnEntity(items.projectile, spawnLoc); why does this gives error
Failed to run function
does entity need to have is_summonable: true
in json
Yes
Thx
you kinda can
but as far as we know custom component is better for performance
A custom implementation of ticking would be… interesting
@distant tulip Could you help me with my script? If so can I send you a dm?
you can send your question here
not really
just saving the block position and using runinterval
And what kind of guy am I trying to make a pig like a helicopter, Then I did that part of the script when he is looking in a direction other than up or down or It only goes forward, which is what I want when I look in a certain direction. So I wanted you to help me fix this.
open a post and share your code
Ok
Would anyone know how to make an item that can't be broken?
items are vanilla, but u can copy it and setItem when it's broken
can't we just set the item durability to something crazy high
world.afterEvents.playerSpawn.subscribe((event) => {
const check = event.player.getDynamicProperties("firstJoin") || false;
if (event.initialSpawn && !check) {
console.log(`${event.player.name} has joined for the first time. Welcome!`);
event.player.setDynamicProperties("firstJoin", true);
}
});
So do you want to know if a player has joined the world for the first time or do you want to know if it's the first time the world has been loaded?
now i have zero idea why this crashes my game
no logs either
Those are the best. Really pushes you to the next level 😂.
world.afterEvents.worldInitialize.subscribe(() => {
const check = world.getDynamicProperties("firstLoad") || false;
if (!check) {
console.log(`First time this world has been loaded!`);
world.setDynamicProperties("firstLoad", true);
}
});
Why does my friends vscode not show the autocompletion for certain things like entity.getComponent()? it just shows 'isValid', 'entity', 'typeId', while mine show the actual stuff in the component i define
JS or TS? Stable or Beta?
Because getComponent just returns a component and in beta they have the type maps. Since intellisense doesnt know what child class getComponent is referring to thats why it only shows the default component's properties
so i have to make him install the beta ones?
so I was thinking about making some sort of combo system
like you right click and left click the air
and it says like "R-L-L" on the screen
or something
similar to Wynncraft
but there's like no way to detect punching the air
How do I get the cardinal direction the player is facing?
You can get the view direction vector
getViewDirection(), right?
function cardinal_direction_2d(angle) {
if (Math.abs(angle) > 112.5) return 2.0; //North
if (Math.abs(angle) < 67.5) return 3.0; //South
if (angle < 157.5 && angle > 22.5) return 4.0; //West
if (angle > -157.5 && angle < -22.5) return 5.0; //East
return 6.0; //Undefined
};
``` is what I use for 2d placement
Ty
does the block bench default cardinal don't work?
I thought only the pillar state had the issue
how do i use getItemStack for blocks
i put it inside component registry but it returns undefined
Where are the records recorded by Dynamicproperty stored?
function getView(vec,type) {
const x = Math.round(vec.x);
const y = Math.round(vec.y);
const z = Math.round(vec.z);
switch (type) {
case "direction":
if (y !== 0) return "vertical";
if (z !== 0) return "n/s";
if (x !== 0) return "e/w";
break;
case "cardinal":
if (y > 0) return "up";
if (y < 0) return "down";
if (z < 0) return "north";
if (z > 0) return "south";
if (x > 0) return "east";
if (x < 0) return "west"
break;
default: break;
}
};
I made this function
does anyone know how to get/set an scoreboard value for a fake player?
yeah it doesn't really work
at least in a way that would be useful
only thing I can think of is replacing it with Shift+Right instead of left clicking
although I gotta make sure you can detect right clicks without holding anything
Well, if there is a block there, can't you rent it?
its there a key to open content log gui?
ctrl+h
ty
how do i apply node modules to a specific pack again?
i forgot how to do packages and stuffs
node js ?
yeah
Are u sure ?
U can't use node js modules inside the game
i know, i just need it for typescript completion for a specific pack
Oh
Cd to ur scripts directory
Then
Run command
npm install i guess
Or idk too , sorry
solved it, it just need to have a package.json first by doing "npm init -y" in the directory
how do i exclude a blockstate in a string with other blockstates
Elaborate
what if you stand on tall grass in survival mode?
import { world } from "@minecraft/server";
export function getPlayerScore(entity, objective) {
try {
return world.scoreboard.getObjective(objective).getScore(entity);
} catch (e) {
return 0;
}
}
export function setPlayerScore(entity, objective, score) {
try {
const scoreboard = world.scoreboard;
const obj = scoreboard.getObjective(objective);
if (typeof entity === 'string') {
const player = world.getAllPlayers().find(p => p.name === entity);
if (player) {
obj.setScore(player.scoreboardIdentity, score);
} else {
obj.setScore(entity, score);
}
} else {
obj.setScore(entity.scoreboardIdentity, score);
}
} catch (e) {
console.warn(`Error setting score: ${e}`);
}
}
Chill
Ik
Chilllllllllllll
I don't know I'm tired
For me its 2a.m.
Okay alex
Always depends on how you're gonna use the functions
They asked for a way of getting and setting score values for fake players, I sent two functions that can be used globally so how's that "irrelevant" ?
Yeah, that's why typeof entity === 'string' is there
I told you to chill
Didn't know it looked overcomplicated until you pointed it out, it just catches errors and checks if the returned string is an online player before proceeding
i wanna get the entities 2 blocks from the view direction of the player, i used
{x: player.getViewDirection().x*2, y: ..., z: ...}```
but yeah since it's a normalized value (i think) i would say it would be like this `0.4*2` which results in `0.8`, i am aware of local coordinates posted in script-resources but ngl it's a bit complicated for me
basically asking for a dumbed down explanation of getting local coordinates
why the system.clearRun doesnt work:/
try const?
didnt worked:(
oh i see the problem
it wouldn't run because the first if statement negates the second one
mmm so
i'll fix it for you dw, but basically make the if (setup==1 && start==0) inside the system.runInterval instead of outside
Ok
let lobbyPlayerManagement = system.runInterval(() => {
if(setup==1 && start==0){
let players = world.getAllPlayers()
for (const player of players) {
let {x,y,z} = player.location
if(y<200){
player.teleport({x:0,y:260,z:0})
}
}
}
if(setup==1 && start==1){
system.clearRun(lobbyPlayerManagement)
}
},20)```
try running it now
anyway ty
no problem
hold up, im beginning to understand, i'll try figure it out first
Can I ask if anyone knows or can make a interact on a block when it is clicked by a stick the block will change?
Is there a file for before events ordering? I know the one for after events exist, but idk if one for before exists.
men, how do i give players enchanted items, i dont get the item stack working
i tried the script api example but isnt working to me
Do you have the vanilla-data module in your addon?
It's not needed for stuff to function, and it's something that cannot be placed manually in the manifest
so?
Must be put in the addon files
.........
MinecraftItemTypes -> just use the item type id as a string
MinecraftEnchantmentTypes -> use enchant name as a string
so i can change it to make it work without changing any file
import { EnchantmentType, world, ItemStack, Player } from '@minecraft/server';
world.afterEvents.itemUse.subscribe((e) =>{
if(e.itemStack.typeId === "minecraft:stick") return giveFireSword(e.source)
})
function giveFireSword(player) {
const ironFireSword = new ItemStack('minecraft:diamond_sword', 1);
const enchantments = ironFireSword?.getComponent('enchantable');
if (enchantments) {
enchantments.addEnchantment({ type: new EnchantmentType('fire_aspect'), level: 1 });
}
const inventory = player.getComponent('minecraft:inventory');
if (inventory === undefined || inventory.container === undefined) {
return;
}
inventory.container.setItem(0, ironFireSword);
}
There's no vanilla data in this here
i think its no that file then
idk why it keeps throwing that error
i reloaded, verified any file
are you using dev folders?
yes
hmm
im relogging the whole game even if that doesnt makes sense
wtff i desactivate that JS file and then the other scripts start working
when the whole error is that file
import errors throw globally
👍
Anyone?
right or left click
?
world.afterEvents.playerInteractWithBlock.subscribe(( { block, itemStack, player } ) => {
if (itemStack?.typeId === "minecraft:stick") {
block.setType("minecraft:stone")
}
});
change "minecraft:stone" with the block typeId that you want
Like when you tap it
@strong oar yeah this ^^ will work when you tap
i sent code
^
Can I implement it on condition right?
wat u mean
is it possible to equip mobs with equipment in scripts, not players
really want to avoid using structures
I believe that as long as the entity has the equipment component you should be good
if you mean like if (player.isSneaking) and etc. yes
How?
Replaceitem command
Doesn't seem to possible to include custom item data, thanks though
Like when the player interacts with my custom block which is tapped by a stick. The value of my states will change from 0 to 1.
oh so you're talking about the states?
Yeah
block.setPermutation(block.permutation.withState("example:myState", 1))```
add this to the if statement
just change the state name
Ohhh and then?
that's pretty much it, make sure to remove the block setType here or it'll just turn into stone
Ohh then replace it with your code right?
yep
Last man, I forgot to say what if the states range to 0-6 then every tapped will change the value of the states like:
0-1
1-2
2-3
4-5
5-6
6-0
% 7
let value = block.permutation.getState("example:myState"));
if (value < 6) {
block.setPermutation(block.permutation.withState("example:myState", value+1))
} else block.setPermutation(block.permutation.withState("example:myState", value+1))```
something like this
the else part sets it back to state 0
hope it helps
Thanks man
Do you have any idea how I can make a claim?
may i see the custom component you made? or at least parts of it
and also the registry, im not sure because i haven't encountered that problem
ohh okay in here i removed the registry
import { world } from "@minecraft/server";
world.afterEvents.playerInteractWithBlock.subscribe(({ block, itemStack, player }) => {
if (itemStack?.typeId === "minecraft:stick") {
let value = block.permutation.getState("goobli:State");
if (value < 16) {
block.setPermutation(block.permutation.withState("goobli:State", value + 1));
} else {
block.setPermutation(block.permutation.withState("goobli:State", 0)); // or any reset value you prefer
}
}
});
when i removed the registry, the only error that shows is this
are you on beta?
preview
i mean beta api
ohh i use the 1.13.0
i think its still in beta api so it wont work
i would suggest using custom component
world.beforeEvents.worldInitialize.subscribe(event => {
const {blockComponentRegistry} = event;
blockComponentRegistry.registerCustomComponent('your:custom_component', {
onPlayerInteract: data => {
const {block,player} = data;
const mainHand = player.getComponent('equippable').getEquipment('Mainhand');
if (mainHand.typeId == 'minecraft:stick') {
let value = block.permutation.getState("goobli:State");
if (value < 16) {
block.setPermutation(block.permutation.withState("goobli:State", value + 1));
} else {
block.setPermutation(block.permutation.withState("goobli:State", 0)); // or any reset value you prefer
}
}
}
});
});```
?
use this instead
ohh okay im gonna try it
make sure to rename it to your custom component id
okay thank you
damn, mb, i was doin something earlier
heres what happened huhu
add this component id to your block.json
"minecraft:custom_components": [ "global:change_states" ]"
Do I need to change something on the main.js?
nah
it doesnt work, maybe you have sample file
how to clear player inventory with native method?
setItem for specific slots, clearAll for whole inventory
player.getComponent('inventory').container.clearAll();
Is there not a method for checking an entity to see if it has a specific component group or behaviour
Is there any way to check if an different script is active?
Like one from an another addon
In the main script of each add-on you have, you can insert an indicator like console.warn, or world.sendMessage, or player.sendMessage, to find out if it's active
There is, you can learn more about it here
can you directly invert an integer variable (i.e. 7 + -example), or do you have to just multiply it by -1?
cool, thanks
Already looked. I mean entire component groups not individual components. I'm trying to see if an entity has the timer component but it's not on the available list of .getComponents, so I'm wondering if I can search for component groups instead since the timer component I'm after is in one
is there a max amount of dynamic properties?
32767 for string
or if you're asking about another thing, no there's no limit only your device's storage size is the limit
I mean, couldnt i also just create an variable and check for that in the other script?
what is bro asking?
Im trying to check if an other script file is active
so they are different addons
console.warn is the simplest n most direct
but what are you trying to check?
I need to check inside the other script too
Im trying to activate a code when the other addons script isnt there
no scripts have different environment
why so complicated
whats the idea here
make it depend on scoreboard that the other addon add
how about you store it with a tag or a score
Theres an dublicated code
What is going here ?
Good idea actually
👍
How do i make a function not make an error when it fails to call
(like for example when i use applyKnockback to an entity that cant be knockbacked/is no longer existing)
check if entity.isValid()
Anyone maybe you have a template for block that changes whenever you tap it
Well just check the rotation of had if thats not changing thats all
try {code} catch {}?
it is
ah, alright, thanks
it worked thanks, i believe catch can also be used to use the errors as objects or smth like that?
that can fail in a lot of cases
walking in a straight line for example will count as afk
the best thing to do is check the rotation and if it is not changing check for a pattern in the player corrds
wdym
also try catch is not the best option in your case
if(entity.isValid()){
entity.apply...
}
hm? why so? also i tried isValid by itself earlier it sent errors to entities it cant apply damage or knockback to
Well if player is not in water or is not riding that means he is not afk
there is no need for patern
im doing so to keep the content log tidy and empty because i get a long list of errors just because some pile of xp orbs was on the ground and it tried damaging/knocking those
uh
cant you just exclude by types in entity query options
in that case?
yeah i could but that would mean i'd have to list down entities and not only that but it wouldn't work for custom entities that also cannot be damaged/etc.
hmmm
what i did here is to first do excludeTypes the stuff needed
and then do try catch
double filter
i dont understand why try catch isn't a good option, is there some sort of catch?
if i were to only do try catch, would there be a problem?
i honestly havent had any trouble using try catch but
i assume it doesnt look pretty
(and it really isnt but it does its job)
but hey if theres a better option, ill take it
also about .isValid part, im not sure what that really does tbh
hm, alright
does setBlockType keep facing rotation?
isValid returns true if entity exist or isn't dead
nope, i believe no since it returns the default of the block being set
dam ok
so basically a thing that returns boolean whether the script can touch the target?
yep
also i searched in google as one does, it just says it's bad practice to use try catch since it makes the dev miss critical errors but tbh what's stopping me from just temporarily removing it to debug the said function
it would be a bad habit if you just wrapped it up everywhere
but i think applyKnockback and applyImpulse is an exception here
of course i wouldn't put it everywhere 😂 i would just put it in stuff that are like ↑↑ yeah
but thanks for some clarification about try catch
also if you do want to catch the errors, you can just do
try {
....
} catch (e) { console.warn(e) }```
though this doesnt point to line so it can be confusing if the code is large
ahhhh, that's what i was trying to mention earlier, i misremembered it as catch {(e)} lmao
how do i change these to tuff stairs while keeping their rotation
const blocks2 = {
"minecraft:nether_brick_stairs": "minecraft:polished_tuff_stairs"
}
const { x, y, z } = player.location
const dim = world.getDimension("overworld")
for (let X = Math.floor(x) - 10; X < Math.floor(x) + 10; X++) {
for (let Y = Math.floor(y) - 10; Y < Math.floor(y); Y++) {
for (let Z = Math.floor(z) - 10; Z < Math.floor(z) + 10; Z++) {
for (const [blockName, newBLockName] of Object.entries(blocks2)) {
const block = dim.getBlock({ x: X, y: Y, z: Z })
if (blockName == block?.typeId) {
const perm = block.permutation
block.setType(newBLockName)
block.setPermutation(perm)
}
}
}
}
}
ive got this but when it sets the permuattion, it sets the block type back to the nether brick stairs
const facing = block.permutation.getState('weirdo_direction');
block.setType(newBLockName);
const perm = block.permutation.withState('weirdo_direction', facing);
block.setPermutation(perm)
``` something like that maybe
can do the same for upside_down_bit
because they want to make block stuff complicated as much as possible 
(this is obviously a joke)
const facing = block.permutation.getState('weirdo_direction');
const facing2 = block.permutation.getState('upside_down_bit');
block.setType(newBLockName);
// @ts-ignore
const perm = block.permutation.withState('weirdo_direction', facing)
// @ts-ignore
perm.withState('upside_down_bit', facing2)
block.setPermutation(perm)```
weirdo direction be weird
this doesnt do the upside_down_bit
you have to chain them
const perm = block.permutation.withState('weirdo_direction', facing).withState('upside_down_bit', facing2)
(If you don't want to make a new variable for every permutation you add)
It’s generally bad practice, and makes your code a mess
Try catch is bad practice says who?
I only use it for debugging but It's never a bad option what
it not bad
yeah it not bad
nevre
https://stackoverflow.com/questions/12609527/why-isnt-try-catch-used-more-often-in-javascript/12609630#12609630
Some browsers don't handle it well, but I can't say the same for qjs.
With my experience most of the times I use try catch, sometimes ignore the error ends up with me taking lots of time to debug and fix issues i should've fixed previously. I don't like avoiding issues temporarily.
hmmm waaait,, if you think a littlee, u can undetstand
it is a bad practice
making ur code neat and not erroring is a good practice
all knows
but try catch ignores them themporarily
That's kind of your fault if you ignore the errors. Try catch is there to handle errors. Maybe it's bad in JS but saying try catch is bad practice is a horrible statement
it has its benefits and drawbacks depending on usage. That logic applies to everything, and I use it in some places too. I just hope people here know what they're getting into when using try catch
i said it is not the best option sense we can check if the entity is loaded or not
i use it some times too
const addRider = entity.getComponent('minecraft:rideable');
const addRider1 = addRider.getSeats();
addRider1[0].position.y = 15;
``` can we edit the seat position of entity?
oh! ZAHF?
i really like your addons!
and you dissappeared out of nowhere,
i'm amazed that your back
HEY ZAHF!
lol everyone falling for him
edit as in change the entity?
the expansive fantasy addon creatted by zahf22 is just so popular
did u play that addon
trying to change the sitting position
yow
lol
No
I don't think you can move them in seats
discord is having weird name lol
That's odd
🤔 still hoping we can change its sitting position😂
is it a player or entity?
its an entity
i think you can eject them and add them back
i cant eject the rider once i eject the rider the entity will despawn, and im kinda looking for a way to not make entity for each sit,😅
how do i put a cooldown on a function, i want to not allow the function to run if it's called again within a second
its read -only😂
yeah unfortunately
store the date it is called on
and when it is called again check the date
It’s different for each device
:v
you need to edit the entity json or offset the rider using animation
btw what happen to your expansive fantasy addon?
i didn't check it since the last time i downloaded it;
it's not availavable on mcpedl now
im still working on it but on a slow phase, since i need to work first for my family, i do have an updated one but not yet for public currently only my son and his friends are playing on their realm😂
Zahf is gatekeeping
lol i wish i was your son
jk
💀
😂
💀
not sure if i understand
Store the last time they used the function and if they attempt again only allow it if it's not within the x amount you want
needed some help
oh, ok so i change the date in the function, and check it in the event that calls the function?
like this?
he's probably giong to say "dont ask to ask"
ok so, Just like, playerBreakBlock is a event, I also want to make a custom event - playerOnJump.
The question is-
So, How can I make custom event/callback?
And I want to also make it have subscribe and unsubscribe methods to the event.
I have the code for the jumping
I just don't know how to make it a event/callback.
can you help @distant tulip
(ik u dont like pings so sorry)
The more you ping the higher the pressure/stressor you're inputting the higher the chance they are overwhelmed and decide to just help you or ignore you completely
something like this
if(player["coolDown"] > Date.now()) return;
player["coolDown"] = Date.now() + 1000;
Hellooo!
Just noticed there is no easy access to the Player. via most of the CustomComponents???
How can i access the player?
Use the before place custom component instead
just use runInterval and clear run 🤷♂️
it doesn't work for my need.
i am using a damage sensor in the player file to send a scriptevent when the player recives void damage, the problem is it keeps sending scriptevents every tick and runs the event multiple times i want to not run the event until 1 second has passed since the last time the player recived the scriptevent message.
that should work
just use who ever is the source instead of the player


