{
"format_version": "1.20.80",
"minecraft:item": {
"description": {
"identifier": "si:umbral_veil",
"menu_category": {
"category": "equipment",
"group": "itemGroup.name.sword"
}
},
"components": {
"minecraft:creative_category": {
"parent": "itemGroup.name.blocks"
},
"minecraft:display_name": {
"value": "§8Umbral Veil"
},
"minecraft:icon": "si:veil",
"minecraft:hand_equipped": true,
"minecraft:max_stack_size": 1,
"minecraft:cooldown":{
"category" : "veil",
"duration" : 0.2
},
"minecraft:custom_components": [
"si:umbral_veil"
],
"minecraft:durability":{
"damage_chance": {
"min": 10,
"max": 20
},
"max_durability": 120
}
}
}
}
#Script API General
1 messages · Page 1 of 1 (latest)
there was a way to make portals ignore block update (i forgot how ...)
bcoz students need to tranfer money sometimes
Credit card? Or debit card. Those are very different things.
:((
makes sense
me who don't know the difference between credit card and debit card: 😳
oppsies
the format version should work correctly, and min engine version?
with credit card you can have negative numbers
Credit card is when you loan/borrow money. Debit is straight up your money.
ahhh understood
try with 1.20.80
Is getParticipants still available in 1.21? If it can no longer be used, what should it be changed to?
its available
still the same
try change it to object then
but in version 1.21 it says getParticipants module not found in @somber cedar
blud pinged member
That's what they get
🤣
@somber cedar
thats a person lmao
hello I begginer In mods anyone can help I understand Javascritp and trying learning Typescript too
what do u need
phone
uh
: [
that a big ask
maybe follow a tutorial and then ask if you didn't understand something
Learn JavaScript
As the Script API is a framework built on JavaScript code, having an understanding of JavaScript is key.
If you are being shown this, then you most likely are a beginner with JS and could use a little guidance.
Videos on Learning JavaScript
Javascript in 1 hour
Javascript Classes in 1 hour
Web Guide:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
Reference Sites:
https://www.w3schools.com/jsref/default.asp
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
https://javascript.info
I javascirtp Programmer
my problem is with minecraft idk how start and Microsoft not explain much
Well do you know how to make an addon?
Eeehhh those work
o yeh
but
What is a good project to start ?
and does anyone have the source code or something like that?
?
Most of how you learn is to fuck around and find out.
Downloads
Bridge: https://bridge-core.app/guide/download/
Visual Studio Code: https://code.visualstudio.com/download
node.js: https://nodejs.org/en/download/current
Official Documentation: https://learn.microsoft.com/en-us/minecraft/creator/?view=minecraft-bedrock-stable
If your experiencing issues or have any questions feel free to join the ...
But also the reference documentation is where you will find out the capabilities of script api.
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/minecraft-server?view=minecraft-bedrock-experimental
{
"format_version": 2,
"header": {
"description": "Template",
"name": "Template (RP)",
"uuid": "e91e4d4e-0d69-4d6d-8bb0-d5426f8cef2f",
"version": [
1,
0,
0
],
"min_engine_version": [
1,
20,
80
]
},
"modules": [
{
"description": "Template",
"type": "resources",
"uuid": "78d3cedf-b610-410g-b7eb-b8dfd6209c35",
"version": [
1,
0,
10
]
}
]
}
( A simple and good project to me start)
whats wrong with my manifest?
it can be whatever u want bruhh
Tutorial for Getting General Javascript Knowledge ->
https://www.youtube.com/watch?v=lfmg-EJ8gm4&pp=ygUuSmF2YXNjcmlwdCB0dXJvcmlhOyBmdWxsIGNvdXJzZSBmb3IgYmVnZ2lubmVycw%3D%3D
Documentatation and Installing NPM Typings ->
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/minecraft-server?view=minecraft-bedrock-stable
Setting Up a Project For Scripting ->
https://wiki.bedrock.dev/scripting/starting-scripts.html
Video for Starting with the Scripting API, How to use the Documentation, How to install NPM Typings ->
https://www.youtube.com/watch?v=-34dn_mKkMA&t=797s
@naive spindle EVERY SINGLE THING YOU NEED TO KNOW ABOUT SCRIPTING API
#javascript #tutorial #course
⭐Time Stamps⭐
#1 00:00:00 JavaScript tutorial for beginners 🌐
#2 00:12:32 Variables 📦
#3 00:25:20 Arithmetic operators ➕
#4 00:33:47 Accept user input 💬
#5 00:39:09 Type conversion 💱
#6 00:44:48 Constants 🚫
#7 00:52:30 ⭐ Counter program 🔢
#8 01:01:46 Math object 🧮
#9 01:07:23 Random number genera...
Bedrock Wiki
This wiki is a knowledge-sharing website for Technical Bedrock, containing documentation, tutorials, and general how-to information.
In this video you'll learn how to add JavaScript code to your addons and packs to create a more fun and exciting experience, or simply to do things you couldn't normally do with addons.
We cover many things, so don't be overwhelmed if you don't remember absolutely everything from the video - Just go over it again as many times as necessary. The...
any log?
Eep
You’ve sent that twice
srrry
{
"format_version": "1.20.80",
"minecraft:item": {
"description": {
"identifier": "si:umbral_veil",
"menu_category": {
"category": "equipment",
"group": "itemGroup.name.sword"
}
},
"components": {
"minecraft:creative_category": {
"parent": "itemGroup.name.blocks"
},
"minecraft:display_name": {
"value": "§8Umbral Veil"
},
"minecraft:icon": "si:veil",
"minecraft:hand_equipped": true,
"minecraft:max_stack_size": 1,
"minecraft:cooldown":{
"category" : "veil",
"duration" : 0.2
},
"minecraft:custom_components": [
"si:umbral_veil"
],
"minecraft:durability":{
"damage_chance": {
"min": 10,
"max": 20
},
"max_durability": 120
}
}
}
}
this is the item it's referring to
but u sent the RP manifest
Only Beta APIs have to be enabled
send the Bp manifest
Having both HCF and Beta APIs causes conflicting schemas
{
"format_version": 2,
"header": {
"description": "Template",
"name": "Template(BP)",
"uuid": "e932ff93-7431-4ffe-a88c-33c9af0c910c",
"version": [1, 0, 0],
"min_engine_version": [ 1, 20, 80]
},
"modules": [
{
"description": "Template Data",
"type": "data",
"uuid": "dd5a9f10-bceb-4f4d-8d8a-bd7ecf4b7f3b",
"version": [1, 0, 0]
},
{
"description": "JSON",
"type": "script",
"language": "javascript",
"uuid": "160f9096-865b-4c79-b0ec-49e1648d3651",
"version": [1, 0, 0],
"entry": "scripts/main.js"
}
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.11.0-beta"
}
]
}
this is hte bp manifest
change it to beta
1.12.0-beta
do I disable one?
enable the api toggle
Disable HCF (Holiday Creator Features)
also that
nah there's no 1-12-0-beta
uh
hm
Bruh. Very outdated...
xd
i'm even more outdated lmao
Can anyone record a video for me
E
DM me if anyone wann please
chat ranks. theres like thousands out there but should get you started
Or even custom commands...
Can anyone record a video for me?
DM me if anyone can, please
do recipes uses HCF?
no
Learn to fix stuff yourself instead of asking people to do the work for you
This is a place where you learn and ask for help
what the hell?
i am not asking for making scripts
Man. I'm just waiting for server-net to not be a beta module anymore... So my add-on doesn't break every single update...
like i made a script, i'm asking someone to record a showcase for me.
"asking to record a showcase "
That is completely off topic
source.selectedSlot
This used to work. Now it doesnt.
renamed to selectedSlotIndex
player.selectedSlotIndex
I don’t think they’ll make it stable anytime soon because safety and Marketplace
I hate how MP is put first...
1.21.2
The latest preview is 1.21.20.22
Manifest isn’t an issue right?
Basically, yeah. Every single update.
It’s been 1.0.0-beta forever?
I can't use stable server module because server-net uses beta
but server-net isn’t even depended on server module
dang im getting helluva confused
latest release it's 1.21.2
Idfk. It just errors out...
What’s the error?
xd
server-net depends on server...beta stuff... Last I checked. Lemme try it again
it worked fine
server-net only depends on the common module which is stable and included by default
server-admin*
i want ore ui
oh yeah, but that’s beta anyway
☠️
same but it’s still a long way
Eeehh. IG it's changed now. Still have to use beta because of custom chat commands.
Fml
use script event or function
I'll just keep it for now... I do have a UI but yeah...
I'm just happy watching this
speaking of that, they removed the client ui one not so long ago
cat
Why is client-transfer a thing...
You'd think it would be part of server-net
Considering how it works
what is the best app or site to make mods on phone ?
It better be because of React Server Components...
bridge
Is there a mobile modder here ?
It is 1:30 am 😭
I ain't good at maths
🙂
theres atleast one here but it isnt me
challenge yourself for one week and you'll probably understand
I've always developed on PC and Laptops... Tried mobile, never went back to it, EVEN with a Bluetooth keyboard.
And because I do software development, the tools are not even available to me on mobile.
Guys kinda weird question, how's does apply impulse works exactly? If I wanted to ,ale am entity move based on a vectorial function could I take apply impulse as the velocity or the acceleration?
Idk just, how do you use it if you want more precise movement? Xd
It's basically velocity
so true
Ohm thanks that clarifies things
depends on how you view it. Impulse formula is Ft=mv and I think t is 1/20 of a second. Minecraft mass and force system is weird so you can’t construct a formula for that.
what is the best pligins to bridge?
Depends on your use case
Is there any that helps write the code?
Native bridge already does that...
better
1.21 is out
remember you cant copy your codes from bridge
Oh, so how would you recommend trying to make more precise movement using it? Or should I just use teleports for that?
Not dash compiled ones specifically.
I've seen people make Spiderman wee shooters tornadoes and stuff so there most be a way to get somewhat controlled movement
If you want velocity/smooth movement then yeah, apply impulse is the way to go.
For explicit and very precise stuff, just do a tp.
Yeah. 1.21.2 != 1.21.20
yeah. cause 2 != 20
const ClimbableBlocks = {
"ops:custom_ladder": {
ClimbSpeed: 0.1,
FallSpeed: 0.002
}
}```
how can i get the ClimbSpeed and FallSpeed from here
Alright. Item.setlore isnt working right now lol
ItemStack.setLore
also, you need to setLore into the slot.
if you try to setLore to the item, it won't work.
Wait, how would i get it of it does receive damage? The whole is to remove tick delay by setting the damage of the not counted hits (additionaly the next question would be if theres any way to check if the hit is one of the not counted hits)
like, you want to get the amount of damage,when the entity will hurt you?
Projectile mainly
If two projectiles hit you the same time only one will deal damage , i want to fix that
idk abt that
I only need change main.js to main.ts, to use ts on bridge ?
Just need to get the damage the projectile dealed in entity hit event
idk how use ts in bridge 😦
projectileHitEntity?
Yes
I need change javascript to typescript or no ?
im busy with my stuff sory
i forgor
world.afterEvents.projectileHit.subscribe((e) => {
const { projectile } = e;
console.warn(projectile.damage)
})```
it wont work
but something like that
Ty
try to figure out yourself
it something like that
i just forgor
{
"format_version": 2,
"header": {
"description": "Template",
"name": "Template(RP)",
"uuid": "78d3cedf-b610-410g-b7eb-b8dfd6209c35",
"version": [1, 1, 0],
"min_engine_version": [1, 21, 0]
},
"modules": [
{
"description": "Template Resources",
"type": "resources",
"uuid": "e91e4d4e-0d69-4d6d-8bb0-d5426f8cef2f",
"version": [
1,
0,
0
]
}
]
}
it fails to load
watdahek
Fixed it!
Bruh
The docs doesnt even tell us
How tf am i supposed to find it out lol
does minecraft has IFrames?
how does that happen though
Seems so
Not sure
dang
I'm wanting to make a database and at the moment I plan on using world dynamic properties, would it be better to treat a single entry as the whole database or just use multiple dynamic properties for each entry?
What do you plan on using it for?
At the moment just keeping certain items status stored
Such as what player has it and if it was dropped
And it will end up being quite a few items I need to keep track of
Using a dynamic property for each item would be easier but not sure if it's the best solution
You can have unlimited entries but limited entry string byte length
Use dynamic properties
Yeah I'll just go with a dynamic property for each one
Way easier then creating a whole system
Ty
Use dynamic properties, please - https://jaylydev.github.io/scriptapi-docs/features/dynamic-properties.html
is posible make new dimension ?
No
how to use?
@granite badger
Does the UIManager class from @minecraft/server-ui only exclusively work for Server Forms?
It only instructs me how to create a database, but does not tell me how to call up that database to use.
Set and get
setDynamicProperty and getDynamicProperty?
Ye
bruh. Do I need to import anything?
@minecraft/server thing
The documentation has all the instructions 👀
So can i do it:
let Test = world.setDynamicProperty("test", 1)
And then
Test.has("test")
@cold grove
I just want to test to see if there is that database or not
@cold grove
Isnt like a Map or Set
Its more simple, not like a mongodb or firebase module
Take an example for an old addon I use:
i store player data in 1 big one 
how can i get the health of an entity before it has been damaged?
hello just a quick question asap, can't test it by myself
does playerSpawn event runs when player has gone through a portal and spawned in either the nether or the end?
let TestDB = new Database("test"); //create a database named test
TestDB.set("test", "text") //set test database with value "text"
TestDB.get("test") //get all values in test database
TestDB.has("test") // Try to see if the test database exists
.TestDB.delete("test") //remove test database
Can dynamic properties do the same thing?
@subtle cove
@cold grove
it's a class
@subtle cove do you know about this
its world.afterEvents.playerDimensionChange
How to do it?
oh i see thanks, i see theres so much changed in script api after I've been gone for a year lol
Can we cancel playerjoin messages?
nah
@knotty plaza
Is it possible to do something similar?
does dimension.id returns with a "minecraft:" prefix?
yes
do ```js
console.warn(dimension.id)
console.warn(player.name)
console.warn(entity.typeId)
console.warn(block.typeId)
is it possible to get the entity health from before the projectile impact using projectile event?
world.afterEvents.entityHealthChanged
but will this trigger before the projectile hit?
no
do i need to import Vector3 class or can i just do {x:x,y:y,z:z} ?
just do...
thansk
oh, but how do i get it inside the projectile hit event?
world.afterEvents.projectileHitEntity
yea
but how do i get damage or health before
@subtle cove
quite difficult to figure out without if it didnt have that option
nest the event
dunno
healthChange event inside projectilehit
how do you console warn those, i tried doing stringify but doesnt seem to work
// let test = 1;
import('@minecraft/server').then(mc => {
(evenTypes => {
let time = Date.now(), method = function (ev, evType, evKey) {
if (evKey.includes('Permission')) return
ev[evKey].subscribe(data => {
// if (!test) return;
const now = Date.now();
// now - time > 100 && (world.sendMessage('high: ' + (now - time)))
const O = { [[this.constructor.name, evType, evKey].join('.')]: now - (time ?? now), data: {} };
time = now;
for (const key2 in data) {
const obj = data[key2];
const v = typeof obj === 'object' ? obj.name ?? obj.typeId ?? obj.id : obj;
if (typeof v === 'undefined') continue;
O.data[key2] = v;
}
console.warn(JSON.stringify(O, null, 6));
})
};
evenTypes.forEach(type =>
[mc.world, mc.system].forEach(ws => {
for (const key in (ws[type] ?? {})) {
method.call(ws, ws[type], type, key)
}
})
)
})(['beforeEvents', 'afterEvents', 'events']);
});
cool, how do you make it exclusive to one event only?
@subtle cove so, how do i put it inside each other?
Just paste it inside?
I want to remove tick delay somehow
I did
This is quite weird to explain
get creative how to use guard clauses
Whats guard clauses?
if (condition) return
Ah
nice
If two projectiles hit the same time rapidly its like:
Projectile event
Projectile event
Hurt event
Projectile event
Projectile event
Projectile event
Projeczile event
Hurt event
what are you trying to achieve specificly
Remove tick delay
Basically the issue here is that we dont know the damage at the beginning
You need to make your own constructor
:p
Good luck
dude Beta is now incompatible with HCF
yayyy
world.afterEvents.projectileHitEntity.subscribe(ev1 => {
const hitEntity = ev1.getEntityHit().entity;
if (!hitEntity) return;
const event2 = world.afterEvents.entityHealthChanged.subscribe(ev2 => {
ev2.entity.getComponent("health").setCurrentValue(ev2.oldValue)
world.afterEvents.entityHealthChanged.unsubscribe(event2)
}, { entities: [hitEntity] })
})```
this is just sample
subscribe 1
subscribe 2
unsubscribe 2
not ture?
blocks and items event
Well, after some experimenting... I found that UIManager closeAllForms is a prototype method (not static)
Ah nevermind, you just gotta import the instance directly from the module 💀
import { uiManager } from "@minecraft/server-ui"
is there a docs for uiManager
Yes
i just closes all ui? does that include npc and chatscreen?
"Forms"
I doenst specify, only server forms i asume
Hello guys
Any idea on the solution of this question?
https://discord.com/channels/523663022053392405/1261265832378499113
Sorry if this is not the correct channel
hi there, is it possible to change the nametag of shulker box after placed on floor?
ye
universal nbt editor 🤑
so not possible over API?
it should be possible
maybe use a world.afterEvents.playerPlaceBlock and changing the nametag?
thx, i would just guess that i still need to use custom projectiles which have a property with their damage for the whole, as i cant get the first value of damage otherwise i think
does anyone know how to load a mcstructure file through an addon
Place your structure in the structures folder within your behavior pack. The top-level folder inside structures will define the namespace for your structure identifier—e.g. BP/structures/webe/chest.mcstructure has an identifier of "webe:chest"
If omitted, the namespace will be "mystructure"
oh i got that part down
i just need to load it using player.runCommand(
but when i do it (with the namespace)
mystructure:StickKit2
it doesn't error
just nothing is place
placed*
tried that, but doenst work unless I m missing something ```javascript
world.beforeEvents.itemUseOn.subscribe(event => {
const { block, itemStack, source } = event;
console.log(`Item ${itemStack.typeId} used on block ${block.typeId} by ${source.id}`);
console.log(JSON.stringify(itemStack.keepOnDeath));
system.runTimeout( () => {
const setShulker = world.afterEvents.playerPlaceBlock.subscribe((event) => {
console.warn('Player placed shulker');
console.warn(JSON.stringify(event.player.id));
console.warn(JSON.stringify(source.id));
if (event.player.id === source.id) {
event.block.nameTag = 'test';
console.warn(JSON.stringify(event.block.typeId));
world.afterEvents.playerPlaceBlock.unsubscribe(setShulker);
}
},
);
}, 1 )
});```
@sharp elbow
what is hell biome? i didn't know it exists
nether
after a small testing by my script event.block.nameTag doesn't really exist...
Might have to try blockPermutation for that then
You need to change the name tag of the item- which you cannot do in a before event
bruh
Here's some workaround:
- Create a new Shulkerbox ItemStack
- Rename the ItemStack
- Use a Dispenser to place the shulkerbox (delete the dispenser afterward)
- Move all items from the old Shulkerbox to the new placed shulkerbox
can anyone help me, im trying to make it so if you have the tag spawn you can only interact with armor stands, and nothing else (example, villiger, npc)
world.beforeEvents.playerInteractWithEntity.subscribe(e=>{
world.getEntity(e.entityId).then(entity => {
const player = e.player;
const entities = e.Entity.id;
const allowedentities = [
"armor_stand" //"armor_stand", put your entity here, for a bypass for interacting with entities
];
if (player.hasTag('Spawn') && !allowedentities.includes(entities)) {
e.cancel = true;
system.run(() => {
player.onScreenDisplay.setActionBar("§cYou can't do that here");
});
}
});```
import { world, system, Block, ItemComponentMineBlockEvent, BlockComponent, Entity } from '@minecraft/server';
world.beforeEvents.playerBreakBlock.subscribe(e=>{
const player = e.player;
const block = e.block;
const allowedBlocks = [
"minecraft:stone" //"minecraft:black_shulker_box", put your block here, for a bypass for breaking blocks
];
if (player.hasTag('Spawn') && !allowedBlocks.includes(block.typeId)) {
e.cancel = true;
system.run(() => {
player.onScreenDisplay.setActionBar("§cYou can't do that here");
});
}
});
world.beforeEvents.playerPlaceBlock.subscribe(e=>{
const player = e.player;
const block = e.permutationBeingPlaced
const allowedBlocks = [
"minecraft:stone" //"minecraft:stone", put your block here, for a bypass for placing blocks
];
if (player.hasTag('Spawn') && !allowedBlocks.includes(block.type.id) ) {
e.cancel = true;
system.run(() => {
player.onScreenDisplay.setActionBar("§cYou can't do that here");
});
}
});
world.beforeEvents.playerInteractWithEntity.subscribe(e=>{
world.getEntity(e.entityId).then(entity => {
const player = e.player;
const entities = e.Entity.id;
const allowedentities = [
"armor_stand" //"armor_stand", put your entity here, for a bypass for interacting with entities
];
if (player.hasTag('Spawn') && !allowedentities.includes(entities)) {
e.cancel = true;
system.run(() => {
player.onScreenDisplay.setActionBar("§cYou can't do that here");
});
}
});
world.beforeEvents.playerInteractWithBlock.subscribe(e=>{
const player = e.player;
const block = e.block;
const allowedBlocks = [
"minecraft:black_shulker_box", //put your block here, for a bypass for breaking blocks
"minecraft:magenta_shulker_box"
];
if (player.hasTag('Spawn') && !allowedBlocks.includes(block.typeId)) {
e.cancel = true;
system.run(() => {
player.onScreenDisplay.setActionBar("§cYou can't do that here");
});
}
});
});```
thats the full code
let say the structure id is "id:name"
the file should be inside "id" folder with the name "name"
You haven't described what is going wrong with this.
What extra does the experimental version of script ui have?
please make this a forum post so the conversation is isolated and add what the problem is and/or what the error messages are.
i did it now, but ty
Also helps if your title is more descriptive of the problem, so that someone glancing through can zero in on something they know about or is interested in. Not every one will want to open and read to see what it is about.
i couldnt think of anything thats a short name that describes it
Make it click-baitable... how about How to limit player-entity interactions
i have idea now
what about now?
Better... but just so you know. In my opinion, people usually want to help with solving an error or pointing you to the right concept, and you are doing it yourself.. not help with making something... That feels like collaboration and too much work.
i am fariley new to sccript pai
api*
like a week ago i started
asking for help like that make the reader think yo are asking for more then you actually are
you have a code that not doing what you want
so the right way to ask will be how to ...
for example "how to cancel interactions for specific list of entities"
Like what he said... cause it shows you are trying to do it yourself, not ask someone to do it for you...
Welcome to the club. Do you know JS or are you taking samples and trying to make work?
samples pretty much
i dont know any coding
What are you trying to do
chech #1260715250530127985
how about cancel a players entity interation in beforeEvents
yours is still vague (pratically everyone in there has the same problem, somthing not working)
precise as can be is better in my opinon.. if the title does not tell me, I look at those last... I look for ones with titles that I can help with
dakon, why is ur profile unable to load?
Idk
Oooo skill issue
🤔
Lol joke
skill issue
Click on profile it didn't work so I said skill issue as joke
ik lol
🗿
bruh i know the skill isue joke....
i was just used a thinking emoji bcoz i was wokring with smth lol
Ok
Ok.
hi ther
hi there
its midnight here
3:00
and i haven't slept
spooky
staring at my pc at midnight lol
#off-topic is available 24 hours a day
staying up all night is script related
I did this, but still gave me not a function error, not available to do more testing you got a example?
I've done this way too many times.
did you update your manifest?
Oh wait. To what exactly, higher then 1.12.0-beta is it 13 now?
the ui one
1.3.0-beta
Perfect thx
also it is
UIManager not uiManager
Sounds good
hi there, can I get the name of an entity from the .lang files? so it get the translated name?
thx
that was a joke
go to sleep
no
whats the time in your area
11 pm
pm mean past midday
23:00 in 24h format
Hey
yeh
Yeah ?
Can I connect my script with discord.js?
discord.js
No, but you can send http requests to a http server that does
The only thing you could really do with scripting alone is using webhooks
discord.js is a nodejs module
ok, thanks
Also it only works on bedrock server
Is it just me or is did chatSend get removed from stable and moved to beta versions...?
I heard it were never in the stable
I don't remember if there was an afterEvent in stable for chatSend
damn, im using 1.11.0, so that means i need to move to 1.12.0 beta? Haven't scripted in a while
Yes, current beta is 1.12.0-beta
dang :/
How true is this?
Need more context
Oh that, maybe it will be a separated thing like commandRequest
if anyone is interested: #1250204765363638434 message
I have an afterEvents listener that should be running, but there's an error in a different part of the script (one I can't fix at the moment). That part of the script is completely unrelated to the events listener. Does the entire script shut down when something can't be completed? Is this just normal JavaScript behavior
Anybody needs Database to save Vector3 ?
i think i need one
Sure ?
but in preview they moved it back to 1.14.0 beta.. so the stable release will not be soon
Yes. Unless that error is thrown after the event registration.
[Resolved the issue]
(the scoreboard didn't exist)
The code throwing the error is as follows. The compiler in #debug-playground says there's nothing wrong but I still get the error no matter what. Can you help me determine the issue?
// Line with error (lines 27-29)
function getScore(fakePlayer) {
return world.scoreboard.getObjective("easytimers").getScore(`${fakePlayer}`);
}
//Line 30
var accColor = display["color"][getScore("display.acc.color")];
at <anonymous> (display.js:30)
]
Is it worth it to make a database to control and zip Vector3[] ?
Is ther something you can cycle thru to get the names
to make sure there
and for the names of the scoreboards.
for wut
create a function for listing scores... and another for listing scoreboards.. and use them to debug
no
No
because the limit is 100k
ohhhh
When the messages are above the limit , the first messages ever in post get deleted
ok
We are well past 100k
doesnt feel like worth it unless you store big amount of data
Sad :' (
How can I fix this error?
"[Scripting][error]-Script Debugger auto-attach failed."
It is not your error, it is theirs. Everyone is getting it as far as I know and I am not sure what to do to make it go away.
They do have a new debugger thingy... maybe get that to working
I've seen other packs that don't have this error and there's no differences between their script, manifest, etc compared to mine. Is it just an error with the current versoin of scripting?
You've run these other packs under the current system and they do not get that error?
Yeah I have and they had no error.
This sounds like a good mystery then...
I would take their pack and add my elements one file at a time to find the culprit then.
did you try listen on vscode and connect from script?
How can I do that? Is that a terminal command?
How would that impact it if he tries the other pack on his same system and it does not do that.
I created a new world and tested... it does not do it until I add a pack with scripts
Non-Script packs are fine
Did not matter stable or not, simple or complex
Even my Action-Bar Compass that I cannot live without.. simple stable one file script does that error.```JS
import { world, system } from "@minecraft/server";
function directionTextGet_Wave (angle = 0) {
//Thanks WavePlayz
const s = 360 / 8;
const dirs = [ "S", "S W", "W", "N W", "N", "N E", "E", "S E", "S" ];
let dir = Math.round(angle / s);
if (dir < 0) dir += 8;
return dirs[ dir ]
.replace("N", "north")
.replace("S", "south")
.replace("E", "east")
.replace("W", "west")
.replace(" ", "-");
}
system.runInterval(() => {
world.getAllPlayers()
.forEach(p => {
const text = directionTextGet_Wave(p.getRotation().y);
p.onScreenDisplay.setActionBar(§6${text});
});
}, 15);```
I'd like to see that pack that has scripts that does do that error... I'm curious now.
I'll send one tommorow. I'm too tired to think at the moment.
I feel ya...
Too tired ☠️
tbh I'd just use 9 commands in a function.
Oh, nothing wrong with the code, just showing that even that generates those beginning error messages. He says he has an add-on with scripts that does not. ```[Scripting][warning]-Script Debugger auto-attach mode connect...
[Scripting][warning]-Script Debugger auto-attach connect failed, retry in 2s...
[Scripting][warning]-Script Debugger auto-attach connect failed, retry in 2s...
[Scripting][error]-Script Debugger auto-attach failed.``` I even tested a script and the only thing in it was console.warn('Hello World') and I took the reference out of the manifest and it still does that... so we are curious as to why
I can only imagine that it's something to do with the loading of the JS runtime
e.g. backlog of API calls
It does that only as the world loads or a reload of scripts. I purposely made no api calls, practically empty main.js and it does that.
probably failing to do something. I had the world crash on me once by just doing one getPlayers api call because my laptop was too slow.
Is it new debugging tool ?
Don't know. I do not use it
But that is my guess... except that he says he's seen a pack that has scripts that does not do that... so I am ultra curious now. I thought it happened to everyone
Looks nice
So you have add-ons with scripts and your content log is on and you do not see that when you load into a world?
I made a pack with NOTHING BUT console.warn in it and it did that
Yeah XD
I had that on.... must have flicked it on auto pilot or it installed on
solved.... look up at the pic... toggle that middle button on right side
What it used for ?
Ah....
Right my bad
It s for the debugger XD
what?
it says invalid schema
specifically minecraft:custom_components
here is the error when I enable HCF
custom component still beta.... Sigh
is there a site where I can read the capabilities of HCF?
show your code
hi guys is it safe to use a player object as a key of a dictionary
Turn off HCF
is it possible to force show and force closed the actionform to player?
static async npcDialogue(player) {
const texta = `test if possible.`;
const dialogue = new ui.ActionFormData().title('npc.dialogue.form');
dialogue.button('');
for (let i = 0; i <= texta.length; i++) {
let testa = texta.substring(0, i);
dialogue.body(testa);
dialogue.show(player);
}
}
This is the Item.json
{
"format_version": "1.20.80",
"minecraft:item": {
"description": {
"identifier": "si:umbral_veil",
"menu_category": {
"category": "equipment"
}
},
"components": {
"minecraft:icon": "si:veil",
"minecraft:hand_equipped": true,
"minecraft:max_stack_size": 1,
"minecraft:cooldown":{
"category" : "veil",
"duration" : 0.9
},
"minecraft:custom_components": [
"si:umbral_veil"
],
"minecraft:durability":{
"damage_chance": {
"min": 5,
"max": 10
},
"max_durability": 120
}
}
}
}
im using ItemCustomComponent
it seems incompatible with HCF
ima just use stable instead pf beta
You dont need HCF dude
but my mod breaks when I disable HCF
Then fix it?
what are the stuff that HCF does specifically?
what?
but why does it not work when I disable hcf?
the recipes malformed
men...
can I have like a list or link on what HCF does?
#announcements message
Thank You Very Much. It seems that we are on 1.21.2 so HCF is basically Deprecated then?
No? HCF is being planned to be removed in 1.21.20 now
so it's no use using them then
Exactly, no need to use HCF at all now
well that's good to hear thanks a lot SomkeyStack
I cant seem to access jaylydev script docs
const prefix = './';
const { sender: player, message } = data;
if (!message.startsWith(prefix)) {
return;
} else {
data.cancel = true;
const keys = Object.keys(PermDB);
keys.forEach(key => {
const permissionData = PermDB[key];
const matches = permissionData.matchAll(/CustomCommand(\d+):\s*(.*?)\nCommand\1:\s*(.*?)\nNotification\1:\s*(.*?)\n/g);
for (const match of matches) {
const [, index, pCustomCommand, pCommand, pNotification] = match;
if (message.startsWith(prefix + pCustomCommand)) {
const tagMatch = permissionData.match(/Name:\s*(.*)/);
const tag = tagMatch ? tagMatch[1] : "defaulttag";
const pTag = `perm: ${tag}`
if(player.hasTag(pTag)) {
player.runCommand(pCommand);
if (pNotification) {
player.sendMessage(pNotification);
}
} else {
player.sendMessage('you dont have permission')
return;
}
break;
}
}
});
}
});```
"Permission infor:\nName: theking\nCustomCommand2: emerald\nCommand2: give @s emerald\nNotification2 gave 1 emerald\nCustomCommand1: diamond\nCommand1: give @s diamond\nNotification1: gave 1 diamond\n\n" is a key. When I chat with "./diamond" nothing happens
Anyone know how to fix it?
@valid ice help me 😭
Bruh, XD I can't belive this was the issue. I'm so upset but happy that it was an easy fix.
Guys
me happy too. don't have to look at that 💩 anymore
Any method to detect when players swings
wat?
I want to detect when a player hit the air
itemuse event
Oh
Axe ?
Entity hit entity / hit block, doesn’t detect air doe
I want to check just swining with items
Quick question, when im doing things in the code like:
world.getPlayers()
im using the API right? but how can i use the API when i dont have Wifi, i mean an API does need WIFI right? or am i missunderstanding it
It is probably installed in the com.mojang folders somewhere
Only way I know would be v.attack_time in an animation controller
use
player.isSwimming
ohh swining not swimming
Swinging
Can someone help with this? just a question
The API is bundled with the game itself
Okay so i wont really have a delay when using their stuff right?
Zero delay
i never used server-net, is there a way to get http data, and then use a library like fs for write a file for the server ?
Nice, my friend said he made* a own API in minecraft, is this even possible?
By “API” he likely meant a wrapper or modules pack that adds onto and extends the functionality of the vanilla API features
So like just some extra "functions" ?
Yeah
Hmm Cool, okay thank you hero
No, but you can save it into a dynamic property or make another http request to your web server for it to write down the file
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]
sorry just needed the server-net npm things
Is there a component for hostile mobs that passive mobs dont have?
Sorry i can't help you but he can @valid ice
btw Herobrine. Does server-net works?
i heard peoples saying its broken?
It works fine
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entitytypefamilycomponent?view=minecraft-bedrock-experimental
get his famiyly
okay ty
Note that the net modules only work on BDS, not local worlds or realms
like @crisp surge
yourEntity.hasTypeFamily(['monster']);
Bedrock Dedicated Servers?
yes
Unless you want to get into BDS, yep
Yep wow, i dont have the time for it nor the money
Fair
The list is here
when will oreui relase?
in future
server & server-ui are the most commonly used ones.
server-gametest is used for unit tests, and I've seen it used solely for the fake players a few times.
admin & net are BDS modules.
editor is for, well, editor mode.
Other ones are misc utility stuff
Gametest is decent. Got a lot of history behind it, and it's a pretty useful module for content testing
i mostly use it to spawn fake players / entities without ai
thats cool, im gonna use it
Anyone know where scoreboards are stored in level db?
Thought they were just in level dat but I do not see them
you can open the file?
using a 3rd party editor ye
Ah I found them but the editor I use doesn't show them -_-
lol
(I just started with server-gametest)
when i register a command with register can i get the like caller of the command?
Hi.
What extension do I have to use in visual studio code for the scripts? please
?
No one
and how do I add it to visual studio code?
its not a extension, you install it through npm cli
if they are npm files just insert them in the terminal
does it come with @minecraft/server-ui?
you have to install another one for that https://www.npmjs.com/package/@minecraft/server-ui
ohh thanks ♥️
I just saw that you need to learn html to modify ore ui
Have anyone seen the ore ui documentation
is js necessary to learn first before learning script
Learn the basics of Computer Science and JS syntax please
It makes it easier for you and others who are trying to help you
The amount of people that dont know and want to jump straight into mkaing something like Create mod is frustrating
lol
lol fr
Computer* Science is also needed?
the basics of it
Hmm like how PCs are woking?
not really.....
what then?
I meant "working" my bad, or is it more like how they are executing things
?
Is there a simple way to detect that two events happened at the same time?
Log every event and then you can see it
Like when a event happens log it in an array and clear them after every tick, before clearing it you can check if two or more events happend
Yeah I've done that before but i thought there might be a simpler way-- something like subscribing to the afterevent of the second event within the subscribe funtion of the first event
so you want to check if a event got triggered twice or of two different events got triggered
two different events got triggered in the same tick
const triggeredIds = [];
function subscribeToBeforeEvent(eventId, eventFn) {
world.beforeEvents[eventId].subscribe((eventDatas) => {
triggeredIds.push(eventFn);
return void eventFn(eventDatas);
});
};
system.runInterval(() => { triggeredIds = []; });
subscribeToBeforeEvent('anyEvent', (eventDatas) => {
// ....
});
maybe something like thatä
lists the triggered events
and before reseting them you can do what you want with the ids of it
he didnt wanted to compare the time?
How close should the event trigger tho...
either my english is broken or i drank the wrong water today
So he wanted to check if 2 different before/after events got triggered in a same tick
add system.currentTick... but I would suggest a startTick var to subtract stuff so not a big number and something that resets it
const itemUses = []
world.beforeEvents.itemUse.subscribe(ev => {
itemUses.push(ev)
})
world.afterEvents.itemUse.subscribe(ev => {
const beforeEv = itemUses.shift()
beforeEv.source.sendMessage("test")
})
Ofc
ohh he meant that, alright my bad
Good idea
There's more ways, but this is prob the closest approach to fast events that might trigger same time as the other player triggers em
He means before and after events ?
Learn the samples, always be curious, ask always (hopefully not too often here), but yk other sources like google, yt, chatgpt, etc
Yeah
It s better to understand the basics very well because they get repeated in the others programming language
So never start programming by learning low level programming language , just understand the basics then swim in the programming ocean
XD
I'm trying to link up a pistonActivate and entitySpawn lol I'll just use a list approach
Just wrap an event inside another
If ur gona detect itemspawnin their locqtion is too random to be able which piston did the thing
@subtle cove can i borrow you real quick? or @hazy garnet
Bouta go, sorry
alr' no problem
Can i spawn Simulated players without register?
i don't think so
can i then get the player who entered the command?
what command
when someone enters gametest run ... ..., i want to geet the initiator
no you can’t
use chat or scriptevent to trigger the run
but how can spawn simulated players without register
🤨
register() gives me testFunction and testFunction gives me Test, with it i can spawn a simulated player but i want to do it without register()
You can't. Simulated players are for gametest only.
you can't run gametest command from the script?
yes i know, i just dont want to do it with register, i want a other function to use it form gametets
i dont know how
right but.. idk that so simple
too simple
i just want to know if i can spawn simulated players with the stuff from server-gametest without using register
no
Okay can i then get the Initiator of the command?
For /scriptevent command, subscribe to the scriptEventReceive event - https://jaylydev.github.io/scriptapi-docs/preview/classes/_minecraft_server_1_13_0.SystemAfterEvents.html#scriptEventReceive
And their isn't any methods to listen for other slash commands
👆
okay would be an option
@granite badger scriptEventReceive gives me the initiator but register() dont...
cuz theres no initiator in register
yes but i just wanted to know that, cuz when a player is entering
gametest run ...
i thought i could get the initiator
GameTest is intended for unit testing. Its a testing framework
Why do you need a smiulated player anyways?
thats a stupid question
Is it though?
He could be trying something that doesnt need a simulated player
Okay fair
i just wanted to have a little dummy, and when im testing addons where 1 to n? players are needed its usefull
So I installed the latest npm stuff but they don't show any prompts or whatever in VSC. Any reason why this happens?
Maybe restarting VCS or killing the task will help
hm
how to get block properties value?
anyone
block.permutation.getState('block:state')
how acess item from others mods need script?, and how?
you need to use system.run
How? I'm not sure
#1067535608660107284 message
my code return undefined
did you replace 'block:state' with your custom one?
does anyone have a good structure manager script or some link to an adddon that does this?
using the api
nvm i found the problem
I know it's possible for me to get the mob's ID and add it as lore if I hit a mob, but is it possible for me to do this without hurting the mob?
just for example using the item and it getting the ID of the closest mob?
When plr press a button i want it to wait 5 secounds and run the function, how i make it ?
system.runTimeout
I think this is something very specific, I don't think it's possible
how do i get itemStack in entityHurt?
its silly question but im confsued lol
because i don't see itemStack property in entityHurt
do i use ItemStack class
Get the Mainhand slot from the EntityEquippable component
I think there is in entityHitEntity
Nope, there is not
there is not
like, i mean, in playerBreakBlock, you don't have to get the Mainhand component. Because, there is itemStackAfterBreak property.
mojang should add - itemStackAfterHit
Thats Mojang's thinking, not sure what their reasons were
lol
btw
can i dm u
Sure, but if its something that will take a lot of time then I'll help you tomorrow
alr
hm
hm is hm
how to shoot projectile use body rotation not View direction
Is there a way to enchant an item greater than level 5 using sctipt?
nah
why does my Simulated players alaways spawned outside the world when i entered my current postion as the spawn position?
Bc the coordinates are relative to where the command was executed
yes i already thought that and changed the locations, so it will spawn on the structure block, but then i didnt got spawned
and sometimes it said, invalid structure randomly
..
Syntax error
function Credits() {
new ActionFormData()
.title("Players Menu")
.body("Select players")
PlayersName.forEach(p => PlayersUI.button(p))
}
theres nothing wrong
ok
Maybe playernames IS Not a String array
nop
What do you have in Line 143
}
IS PlayersUI Even defined?
Anyone else not able to use /reload on a specific world?
I Had the same issue when i downloaded my realm world
Maybe try copying IT and use the copied version
yes
Can you provide more Code?
wait i delete it
Alright
I did it again
function Credits() {
const playerss = world.getAllPlayers().map(p => p.name)
const PlayersUI = new ActionFormData()
new ModalFormData()
.title("Players Menu")
.body("Select players")
playerss.forEach(p => PlayersUI.button(p));
}
}
okok
And why are you using two different Forms? Btw ModalFormData shouldnt have Body(...)
Just use at nodalFormData a dropdown
ModalFormData*
like?
actually forget it
I'm doing it all over again
I'll send you a code
Sure
do someone know if a method to highlight a block? like making it more white?
Use a new block that have the same texture but whiter
you think doing that works fine for a bedrock version of axiom?
or it will lag like crazy?
You could just look into editor mode
No , because it s just a block
use particles
check my publication please
huh?
what
his post
how do i check if an entity can take damage of other entities?
hi experts, is there any benefit to use system.run()?
benefit? its according to what you want to do 🤷♂️
by understanding your question, What i can only say is, system.run() can help you get rid of the error:
Does not have required privileges.
in beforeEvents. Because in beforeEvents, when you use some methods, you can get this error. And using system.run() can fix this error. Btw that error should'nt show up, if your using afterEvents.
but system.run() also works on beforeEvents? it was not runInterval with at least 1 tick?
I mean system.run() will provide any advantage in terms of stability for some critical executions? I dont know but I remember to see someone talking about it, dunno where....
system run works everwhere...
Making a function that gets the items names by their id is useful?
system.run* methods are used to shift function calls x ticks away
.
Still having an issue getting the /reload command back when downloading a world off a realm
Actually just fixed it after a long time
Is this possible somehow?
Who there ?
hi can anyone help me read the document?
like this
playerinteractwithblock is in the stable api but in what version?
Its not stable
I recommend using https://stirante.com/script/
when will it become stabled then?
No idea
I made it finally
3 - 4 businesses years 💀
itemStack from entity remove is same as in inventory of user ?
what
Use projectile components (if u make it a projectile on the JSON, that is...)
That's what I did but it seems it still turns into a specific direction
like i said the force by impluse is not effected by collisions
it keeps on going
idk if its a bug
bro is sponsored by stirante
Jaylydev >>>>

can you trigger a item cooldown on script?
Can i force an animation on an entity?
Is there a way to detect a touch on the screen or extend the block placement?
You don't need that, you can add a component from the json. Unless you want to force the mount. Although I don't know xD I'm new.
🗿 fr
real

lol
how do i add lore to my item?
ItemStack.setLore([
'line1',
'line2',
'line3'
]);```
maximum line is 20
you can't set more lines than 20
**NOTE: **
if your using inventory component, to set lore to your item.. then you need to set the lore into the slot, not the item.
okey, thank u =)
there a way to get the itemStack.typeId that matches like the itemonuse event for gui, but just if you hold it in the mainhand. Not seeing anything for an event like selection or anything. I probably over looked something.
yo guys, can anyone help me with listing all the features / explaining them (of a utility adddon) as a "reward" i will give the pack : dm me if ur intersted guys !
WHATS WRONG WITH IT??
I can't cast it to a uint... Because JS doesn't have any fucking types
And my system absolutely 100% requires the value be a uint when editing the bits otherwise it will drop the request with a code 400 HTTP response.
In my opinion you should use BigInt and once you serialize then serialize only last 32bits (uint)
but you casting via TypeArrays is also way
That ain't happening if I'm explicitly bitmasking 32 bit numbers
res &= ~(
BitmaskMap.Bitmask1Settings |
BitmaskMap.TalkBitmask1 |
BitmaskMap.ListenBitmask1
); //Reset all values we want to modify to 0.
let settings = BitmaskSettings.None;
const [TE, LE, PD, DD, VD, ED] = result.formValues;
if (TE) res |= BitmaskMap.TalkBitmask1;
if (LE) res |= BitmaskMap.ListenBitmask1;
if (PD) settings |= BitmaskSettings.ProximityDisabled;
if (DD) settings |= BitmaskSettings.DeathDisabled;
if (VD) settings |= BitmaskSettings.VoiceEffectsDisabled;
if (ED) settings |= BitmaskSettings.EnvironmentDisabled;
settings <<= BitmaskLocations.Bitmask1Settings; //Move settings into position.
res |= settings; //Set settings.
Also request responses are numbers.
Hmmm, ya JS sucks at this
At least I can use this
So, I have a rather complicated task-- I want to check whether a crafter has a valid recipe in it. Is there a simpler way to do that than having a list of all the crafting recipes and checking them systematically?
Because if the last bit is set, it will go negatives
Then my server JSON parser will go, "no, fuck you"
Yeah but when I'm parsing in C#. It interprets it as out of range
Read it as int and cast it as uint on C# side?
before validation
Ohhh
i see I hate C# Json class serialization
Doesn't work like that lmao
I use newtonsoft
Well ya, then you that shitty TypeArray cast on JS side
or use int as a end type in C#
I could change my entire bitmasking system to use int's but that requires me having to go through and change hundreds of types. Plus int doesn't work well with bitmasking in C#
ya
Why it doesn't work well?
There is bug or something?
Because 0b1... Will interpret as uint
Either way, that add-on is just supposed to provide an example networking API for people to use in their own projects.
It's already finished. I just need to compile the software now before release.
All 800 lines of pure pain.
https://github.com/SineVector241/VoiceCraft-MCBE_ProximityChat_Addon/blob/main/VoiceCraft.Addon.BP%2Fscripts%2FNetwork%2FNetwork.js
Any ideas?
what u even making
bro is if statement's final boss
whats the diff between scripts and typescripts
idk if this applies directly to minecraft, but when I looked this up a few days ago this the article I read.
script, basically to write script
but is typescript used in Minecraft and for what...
mc uses js files in scripts folder
ts is used for accurate types that's then compiled into js
ok
Hello! Any help?
https://discord.com/channels/523663022053392405/1262356253573779466
import * as mc from '@minecraft/server';
mc.system.runInterval(() => {
for (const player of mc.world.getPlayers()) {
const
family = player.hasTag(`Dragon`) ? "Dragon" : player.hasTag(`Angel`) ? "Angel" : null;
player.nameTag = family + " §c" + player.nameTag + "§r";
}
});
Help
I have the Dragon tag but it doesn't stay in my name
import { world, system } from '@minecraft/server';
const Families = {
'Dragon': '§6Dragon',
'Angel': '§eAngel',
};
function getFamily (player) {
for (const [familyTag, value] of Families) {
if (player.hasTag(familyTag)) {
return value;
};
};
return '§7none';
};
system.runInterval(() => {
for (const player of world.getPlayers()) {
const family = getFamily(player);
player.nameTag = `${family} §c${player.name}§r`;
};
}), 20;
did not work
That would be for(let [familyTag, value] of Object.entries(Families)) {}
It should work, did you probably tested it in the chat?
ohh right mybad
@winter plaza
import { world, system, Player } from '@minecraft/server';
const Families = [
['Dragon', '§6Dragon'],
['Angel', '§eAngel']
];
/**
* @param {Player} player
* @returns {string}
*/
function getFamily (player) {
for (const family of Families) {
const [tag, value] = family;
if (player.hasTag(tag)) {
return value;
};
};
return '§7none';
};
system.runInterval(() => {
for (const player of world.getPlayers()) {
const family = getFamily(player);
player.nameTag = `${family} §c${player.name}§r`;
};
}), 20;
i used now an array, so it dont need to get the entries
It would be better to simply lookup the value in Families, or to use a Map. Iterating over every key (then doing a hasTag() call) would become more expensive the more Family entries there are.
const Families = {
Dragon: '§6Dragon',
Angel: '§eAngel'
};
function getFamily(player) {
return Families[player.getTags().find(tag => tag in Families)] ?? '§7none';
}
Yes, but i prefer loops, cause of the perfomance
There isn't a benefit in this case
I just mean
Side note: is it possible to alter the player's name like that? I have not yet tried
Yes you can, its not read-only
TIL
TIL ?
Today, I Learned (something new)
Alright nice
Right thanks ig
btw is the speed/perfomance difference big between a loop and an array method when the array is small ( 1-1000 values ) ?
,
I don't believe so. Array.prototype.forEach is usually faster than for..of for really big arrays, but that is in V8. IIRC Minecraft uses quickJS
It's a micro-optimization at best.
Agree
import * as mc from '@minecraft/server';
mc.system.runInterval(() => {
for (const player of mc.world.getPlayers()) {
const
family = player.hasTag(`Dragon`) ? "Dragon" : player.hasTag(`Angel`) ? "Angel" : null;
player.nameTag = `${family} ${player.name}`;
}
});
its faster?
For the largest arrays
Use the regular for loop
1 - general for loop
2 - foreach
3 - forIn
isnt a for..of / for..in loop always faster than the array methods?
Nah not always
That may be worth benchmarking!
hmm okay, so when should i use what?
Use
For ( let i ; i< 0 , i++ )
For the biggest arrays
For the small arrays use
Regular foreach , because the optimization is not important in this situation
For In for iterables only
but then i need the length of the array and isnt the length a getter that loops the array? so i use two loops?
like IterableIterators things?
YEP
