#Script API General

1 messages · Page 1 of 1 (latest)

halcyon phoenix
#
{
    "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
    }
    }
   }
}
  
distant tulip
#

there was a way to make portals ignore block update (i forgot how ...)

prisma shard
#

bcoz students need to tranfer money sometimes

vast grove
#

Credit card? Or debit card. Those are very different things.

unique dragon
prisma shard
#

oppsies

unique dragon
halcyon phoenix
#

1.20.30

#

should they match?

unique dragon
vast grove
prisma shard
unique dragon
hazy nebula
#

Is getParticipants still available in 1.21? If it can no longer be used, what should it be changed to?

static orbit
#

its available

halcyon phoenix
tiny tartan
#

try change it to object then

hazy nebula
tiny tartan
#

blud pinged member

vast grove
#

That's what they get

prisma shard
#

@somber cedar

#

thats a person lmao

naive spindle
#

hello I begginer In mods anyone can help I understand Javascritp and trying learning Typescript too

unique dragon
#

what do u need

naive spindle
#

phone

unique dragon
#

uh

naive spindle
#

: [

distant tulip
drifting ravenBOT
#
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

naive spindle
#

I javascirtp Programmer

#

my problem is with minecraft idk how start and Microsoft not explain much

vast grove
#

Well do you know how to make an addon?

obsidian coyote
distant tulip
vast grove
#

Eeehhh those work

naive spindle
#

o yeh

#

but

#

What is a good project to start ?

#

and does anyone have the source code or something like that?

unique dragon
#

?

vast grove
#

Most of how you learn is to fuck around and find out.

vast grove
halcyon phoenix
#
{
    "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
        ]
      }
    ]
  }
naive spindle
#

( A simple and good project to me start)

halcyon phoenix
unique dragon
prisma shard
# unique dragon 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...

▶ Play video

Contents of the @minecraft/server module

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...

▶ Play video
unique dragon
vast grove
#

Eep

halcyon phoenix
prisma shard
halcyon phoenix
#
{
    "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

unique dragon
#

but u sent the RP manifest

obsidian coyote
#

Only Beta APIs have to be enabled

unique dragon
#

send the Bp manifest

obsidian coyote
#

Having both HCF and Beta APIs causes conflicting schemas

halcyon phoenix
#
{
    "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

unique dragon
#

1.12.0-beta

halcyon phoenix
unique dragon
#

enable the api toggle

obsidian coyote
#

Disable HCF (Holiday Creator Features)

unique dragon
#

also that

halcyon phoenix
#

nah there's no 1-12-0-beta

unique dragon
#

uh

halcyon phoenix
unique dragon
#

ur outdated

#

update ur game

prisma shard
#

hm

vast grove
#

Bruh. Very outdated...

unique dragon
#

xd

prisma shard
#

Can anyone record a video for me

vast grove
#

E

prisma shard
static orbit
vast grove
#

Or even custom commands...

prisma shard
#

Can anyone record a video for me?
DM me if anyone can, please

halcyon phoenix
#

do recipes uses HCF?

unique dragon
#

no

obsidian coyote
#

This is a place where you learn and ask for help

prisma shard
vast grove
#

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...

prisma shard
prisma shard
obsidian coyote
#

That is completely off topic

prisma shard
#

hmm

#

sorry

mystic mortar
#

source.selectedSlot

mystic mortar
static orbit
#

renamed to selectedSlotIndex

prisma shard
obsidian coyote
halcyon phoenix
#

isnt 1.20.81 the latest release?

#

1.21 is still preview

vast grove
#

I hate how MP is put first...

obsidian coyote
#

The latest preview is 1.21.20.22

granite badger
vast grove
#

Basically, yeah. Every single update.

halcyon phoenix
granite badger
#

It’s been 1.0.0-beta forever?

vast grove
#

I can't use stable server module because server-net uses beta

granite badger
#

but server-net isn’t even depended on server module

halcyon phoenix
#

dang im getting helluva confused

obsidian coyote
unique dragon
vast grove
granite badger
unique dragon
#

xd

vast grove
#

server-net depends on server...beta stuff... Last I checked. Lemme try it again

static orbit
#

it worked fine

obsidian coyote
#

server-net only depends on the common module which is stable and included by default

granite badger
#

server-admin*

unique dragon
#

i want ore ui

obsidian coyote
unique dragon
#

☠️

obsidian coyote
vast grove
#

Eeehh. IG it's changed now. Still have to use beta because of custom chat commands.

#

Fml

granite badger
#

use script event or function

vast grove
#

I'll just keep it for now... I do have a UI but yeah...

unique dragon
obsidian coyote
static orbit
#

cat

vast grove
#

Why is client-transfer a thing...

#

You'd think it would be part of server-net

#

Considering how it works

naive spindle
#

what is the best app or site to make mods on phone ?

simple zodiac
naive spindle
#

Is there a mobile modder here ?

valid ice
#

It is 1:30 am 😭
I ain't good at maths

naive spindle
static orbit
vast grove
#

I won't understand how people develop on phones 😭

#

It is so painful...

static orbit
#

challenge yourself for one week and you'll probably understand

vast grove
#

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.

meager pulsar
#

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

vast grove
#

It's basically velocity

tiny tartan
meager pulsar
#

Ohm thanks that clarifies things

granite badger
naive spindle
#

what is the best pligins to bridge?

vast grove
#

Depends on your use case

naive spindle
#

Is there any that helps write the code?

vast grove
#

Native bridge already does that...

naive spindle
#

better

mystic mortar
tiny tartan
#

remember you cant copy your codes from bridge

meager pulsar
vast grove
meager pulsar
#

I've seen people make Spiderman wee shooters tornadoes and stuff so there most be a way to get somewhat controlled movement

vast grove
#

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.

halcyon phoenix
#

dunno what happened but 1.21.2 is the latest right?

#

it wasn't showing up lately

vast grove
#

Yeah. 1.21.2 != 1.21.20

halcyon phoenix
#

yeah. cause 2 != 20

prisma shard
#
const ClimbableBlocks = {
    "ops:custom_ladder": {
        ClimbSpeed: 0.1,
        FallSpeed: 0.002
    }
}```
how can i  get the ClimbSpeed and FallSpeed from here
mystic mortar
prisma shard
prisma shard
fading sand
#

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)

prisma shard
fading sand
#

Projectile mainly

prisma shard
#

you hurt entity? or the entity hurt you?

#

which damage

fading sand
#

If two projectiles hit you the same time only one will deal damage , i want to fix that

naive spindle
#

I only need change main.js to main.ts, to use ts on bridge ?

fading sand
naive spindle
#

idk how use ts in bridge 😦

prisma shard
fading sand
naive spindle
#

I need change javascript to typescript or no ?

prisma shard
#

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

hidden badger
#

Ty

prisma shard
prisma shard
#

i just forgor

halcyon phoenix
#
{
  "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

mystic mortar
fading sand
#

The docs doesnt even tell us

#

How tf am i supposed to find it out lol

halcyon phoenix
#

how does that happen though

fading sand
fading sand
halcyon phoenix
#

dang

gray tinsel
#

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?

tight plume
gray tinsel
#

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

tight plume
#

Use dynamic properties

gray tinsel
#

Yeah I'll just go with a dynamic property for each one

#

Way easier then creating a whole system

#

Ty

hazy nebula
#

Does anyone have a similar code for version 1.21?

granite badger
naive spindle
#

is posible make new dimension ?

gray tinsel
#

No

cold grove
random flint
#

Does the UIManager class from @minecraft/server-ui only exclusively work for Server Forms?

hazy nebula
# cold grove Read....

It only instructs me how to create a database, but does not tell me how to call up that database to use.

cold grove
#

Set and get

hazy nebula
cold grove
#

Ye

hazy nebula
#

bruh. Do I need to import anything?

cold grove
#

The documentation has all the instructions 👀

hazy nebula
#

@cold grove

cold grove
#

world.getDynamicProperty("test")

#

@hazy nebula

hazy nebula
#

@cold grove

subtle cove
#

what we're recommending is using dynamic property

cold grove
#

Its more simple, not like a mongodb or firebase module

hazy nebula
fallow minnow
#

i store player data in 1 big one sadJoe

fading sand
#

how can i get the health of an entity before it has been damaged?

chrome flint
#

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?

hazy nebula
#
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

subtle cove
#

it's a class

chrome flint
subtle cove
#

its world.afterEvents.playerDimensionChange

hazy nebula
chrome flint
median stream
#

Can we cancel playerjoin messages?

subtle cove
#

nah

hazy nebula
#

Is it possible to do something similar?

chrome flint
subtle cove
#

yes

#

do ```js
console.warn(dimension.id)
console.warn(player.name)
console.warn(entity.typeId)
console.warn(block.typeId)

fading sand
#

is it possible to get the entity health from before the projectile impact using projectile event?

subtle cove
#

world.afterEvents.entityHealthChanged

fading sand
subtle cove
#

no

chrome flint
#

do i need to import Vector3 class or can i just do {x:x,y:y,z:z} ?

subtle cove
#

just do...

chrome flint
#

thansk

fading sand
subtle cove
#

world.afterEvents.projectileHitEntity

fading sand
#

yea

#

but how do i get damage or health before

#

@subtle cove

#

quite difficult to figure out without if it didnt have that option

subtle cove
#

nest the event

#

dunno

#

healthChange event inside projectilehit

fading sand
#

wait how

#

that works?

chrome flint
# subtle cove

how do you console warn those, i tried doing stringify but doesnt seem to work

subtle cove
# chrome flint 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']);
});
chrome flint
fading sand
#

@subtle cove so, how do i put it inside each other?
Just paste it inside?

#

I want to remove tick delay somehow

fading sand
#

This is quite weird to explain

subtle cove
#

get creative how to use guard clauses

fading sand
#

Whats guard clauses?

subtle cove
#

if (condition) return

fading sand
#

Ah

chrome flint
fading sand
# fading sand This is quite weird to explain

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

chrome flint
fading sand
fading sand
cold grove
#

:p

#

Good luck

halcyon phoenix
#

dude Beta is now incompatible with HCF

fallow minnow
#

yayyy

subtle cove
# fading sand Basically the issue here is that we dont know the damage at the beginning
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

halcyon phoenix
#

on the first place though what does HCF do?

distant tulip
distant tulip
random flint
#

Well, after some experimenting... I found that UIManager closeAllForms is a prototype method (not static)

random flint
#

Ah nevermind, you just gotta import the instance directly from the module 💀
import { uiManager } from "@minecraft/server-ui"

chrome flint
#

is there a docs for uiManager

cold grove
#

Yes

chrome flint
#

i just closes all ui? does that include npc and chatscreen?

cold grove
#

I doenst specify, only server forms i asume

tiny fable
sage sparrow
#

hi there, is it possible to change the nametag of shulker box after placed on floor?

distant gulch
#

universal nbt editor 🤑

sage sparrow
#

so not possible over API?

tiny fable
#

it should be possible
maybe use a world.afterEvents.playerPlaceBlock and changing the nametag?

fading sand
distant gulch
#

does anyone know how to load a mcstructure file through an addon

sharp elbow
#

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"

distant gulch
#

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*

sage sparrow
# tiny fable it should be possible maybe use a `world.afterEvents.playerPlaceBlock` and chang...

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 )

});```

distant gulch
#

@sharp elbow

chrome flint
#

what is hell biome? i didn't know it exists

sage sparrow
distant gulch
#

curse

#

do you know how load a structure thats in an addon

tiny fable
valid ice
#

You need to change the name tag of the item- which you cannot do in a before event

unique dragon
random flint
solid quail
#

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
distant tulip
sharp elbow
twilit crag
#

What extra does the experimental version of script ui have?

neat hound
neat hound
# solid quail 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.

solid quail
neat hound
#

Make it click-baitable... how about How to limit player-entity interactions

solid quail
#

i have idea now

neat hound
# solid quail 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.

solid quail
#

api*

#

like a week ago i started

distant tulip
#

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"

neat hound
#

Like what he said... cause it shows you are trying to do it yourself, not ask someone to do it for you...

neat hound
solid quail
#

i dont know any coding

rustic matrix
#

What are you trying to do

solid quail
neat hound
#

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

prisma shard
rustic matrix
#

Idk

prisma shard
#

ah

#

it fixed

#

lel

rustic matrix
#

Oooo skill issue

prisma shard
#

🤔

rustic matrix
#

Lol joke

woven loom
#

skill issue

rustic matrix
#

Click on profile it didn't work so I said skill issue as joke

distant tulip
#

🗿

prisma shard
#

i was just used a thinking emoji bcoz i was wokring with smth lol

rustic matrix
#

Ok

prisma shard
#

Ok.

stone bridge
#

hi ther

prisma shard
#

hi there

#

its midnight here

#

3:00

#

and i haven't slept

#

spooky

#

staring at my pc at midnight lol

neat hound
#

#off-topic is available 24 hours a day

distant tulip
#

staying up all night is script related

inland merlin
inland merlin
distant tulip
inland merlin
distant tulip
#

the ui one
1.3.0-beta

inland merlin
#

Ohhhhhhhhhhhh

#

I didn't ty

distant tulip
inland merlin
#

Perfect thx

distant tulip
#

also it is
UIManager not uiManager

inland merlin
#

Sounds good

sage sparrow
#

hi there, can I get the name of an entity from the .lang files? so it get the translated name?

distant tulip
#

not possible

#

lang files are client side

sage sparrow
#

thx

prisma shard
#

lol

distant tulip
#

that was a joke
go to sleep

prisma shard
#

no

prisma shard
#

whats the time in your area

distant tulip
#

11 pm

prisma shard
#

morning

#

oh

distant tulip
prisma shard
#

xd

#

i just finished making a addon

#

and now my spine hurts

amber granite
#

Hey

woven loom
#

yeh

amber granite
#

Yeah ?

umbral dune
#

Can I connect my script with discord.js?

amber granite
#

؟ what

#

Discord js ?

umbral dune
deep yew
#

No

#

Script API is not able to be connected to anything

knotty plaza
#

The only thing you could really do with scripting alone is using webhooks

umbral dune
knotty plaza
#

Also it only works on bedrock server

rough anchor
#

Is it just me or is did chatSend get removed from stable and moved to beta versions...?

umbral dune
knotty plaza
rough anchor
#

damn, im using 1.11.0, so that means i need to move to 1.12.0 beta? Haven't scripted in a while

knotty plaza
rough anchor
#

dang :/

umbral dune
knotty plaza
#

Need more context

umbral dune
#

(not me 😶‍🌫️)

knotty plaza
#

Oh that, maybe it will be a separated thing like commandRequest

umbral dune
#

if anyone is interested: #1250204765363638434 message

empty quail
#

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

amber granite
#

Anybody needs Database to save Vector3 ?

shy leaf
amber granite
#

Sure ?

neat hound
vast grove
empty quail
# vast grove 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)
]
amber granite
#

Is it worth it to make a database to control and zip Vector3[] ?

neat hound
#

Is ther something you can cycle thru to get the names

#

to make sure there

#

and for the names of the scoreboards.

amber granite
#

for locations

#

And coordinations

neat hound
#

create a function for listing scores... and another for listing scoreboards.. and use them to debug

fickle pulsar
#

les gooo

#

100,000th comment

static orbit
#

no

amber granite
#

No

fickle pulsar
#

it said 99999 tho

#

is it a glitch

amber granite
#

because the limit is 100k

fickle pulsar
#

ohhhh

amber granite
#

When the messages are above the limit , the first messages ever in post get deleted

fickle pulsar
#

ok

valid ice
#

We are well past 100k

static orbit
amber granite
#

Sad :' (

valid scaffold
#

How can I fix this error?
"[Scripting][error]-Script Debugger auto-attach failed."

neat hound
#

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

valid scaffold
neat hound
#

You've run these other packs under the current system and they do not get that error?

valid scaffold
neat hound
#

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.

static orbit
valid scaffold
neat hound
#

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.

valid scaffold
neat hound
#

I feel ya...

amber granite
vast grove
neat hound
# vast grove 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

vast grove
#

I can only imagine that it's something to do with the loading of the JS runtime

#

e.g. backlog of API calls

neat hound
#

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.

vast grove
#

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.

amber granite
neat hound
#

Don't know. I do not use it

amber granite
#

I never see it before

#

I ll check

granite badger
neat hound
#

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

neat hound
# amber granite I ll check

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?

neat hound
#

I made a pack with NOTHING BUT console.warn in it and it did that

neat hound
#

I had that on.... must have flicked it on auto pilot or it installed on

neat hound
amber granite
#

Ah....

#

Right my bad

#

It s for the debugger XD

halcyon phoenix
#

it says invalid schema

#

specifically minecraft:custom_components

#

here is the error when I enable HCF

#

custom component still beta.... Sigh

halcyon phoenix
distant tulip
runic gust
#

hi guys is it safe to use a player object as a key of a dictionary

wary edge
empty tapir
#

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);
        }
        
    }
halcyon phoenix
# distant tulip show your code

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

wary edge
#

Turn it off

halcyon phoenix
#

custom armors

wary edge
halcyon phoenix
#

but my mod breaks when I disable HCF

wary edge
#

Then fix it?

halcyon phoenix
#

what are the stuff that HCF does specifically?

halcyon phoenix
wary edge
#

At this point you dont need HCF at all

#

Using it will only hurt you

halcyon phoenix
#

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?

wary edge
halcyon phoenix
wary edge
halcyon phoenix
#

so it's no use using them then

wary edge
#

Exactly, no need to use HCF at all now

halcyon phoenix
#

well that's good to hear thanks a lot SomkeyStack

tardy pivot
#

I cant seem to access jaylydev script docs

hazy nebula
#
    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 😭

valid scaffold
amber granite
#

Guys

neat hound
amber granite
#

Any method to detect when players swings

woven loom
#

wat?

amber granite
#

I want to detect when a player hit the air

woven loom
#

itemuse event

amber granite
#

Oh

woven loom
#

not possible without item in hand

#

unless AC

amber granite
#

Axe ?

valid ice
#

Entity hit entity / hit block, doesn’t detect air doe

amber granite
distant gulch
#

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

neat hound
#

It is probably installed in the com.mojang folders somewhere

valid ice
distant gulch
#

ohh swining not swimming

amber granite
#

Swinging

distant gulch
#

Alr alr

#

my bad

distant gulch
valid ice
#

The API is bundled with the game itself

distant gulch
#

Okay so i wont really have a delay when using their stuff right?

valid ice
#

Zero delay

unique dragon
#

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 ?

distant gulch
#

Nice, my friend said he made* a own API in minecraft, is this even possible?

valid ice
#

By “API” he likely meant a wrapper or modules pack that adds onto and extends the functionality of the vanilla API features

distant gulch
#

So like just some extra "functions" ?

valid ice
#

Yeah

distant gulch
#

Hmm Cool, okay thank you hero

knotty plaza
gaunt salmonBOT
#

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]
distant gulch
#

sorry just needed the server-net npm things

crisp surge
#

Is there a component for hostile mobs that passive mobs dont have?

distant gulch
#

Sorry i can't help you but he can @valid ice

#

btw Herobrine. Does server-net works?
i heard peoples saying its broken?

valid ice
#

It works fine

distant gulch
valid ice
#

Note that the net modules only work on BDS, not local worlds or realms

distant gulch
#

like @crisp surge

yourEntity.hasTypeFamily(['monster']);
distant gulch
valid ice
#

yes

distant gulch
#

okay okay

#

So, for me its useless, wow

valid ice
#

Unless you want to get into BDS, yep

distant gulch
#

Yep wow, i dont have the time for it nor the money

valid ice
#

Fair

distant gulch
#

Does minecraft haves any other cool modulesß

#

?

wheat condor
#

when will oreui relase?

static orbit
#

in future

valid ice
#

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

distant gulch
#

alr alr

#

edit mode?

valid ice
#

yep

#

#old-editor

distant gulch
#

server-gametest smells usefull

#

nice

valid ice
#

Gametest is decent. Got a lot of history behind it, and it's a pretty useful module for content testing

static orbit
distant gulch
#

thats cool, im gonna use it

valid ice
#

Anyone know where scoreboards are stored in level db?

#

Thought they were just in level dat but I do not see them

distant gulch
#

you can open the file?

valid ice
#

using a 3rd party editor ye

#

Ah I found them but the editor I use doesn't show them -_-

distant gulch
#

lol

distant gulch
#

(I just started with server-gametest)
when i register a command with register can i get the like caller of the command?

unreal girder
#

Hi.
What extension do I have to use in visual studio code for the scripts? please

unreal girder
#

oh

#

I need autocompletion in the texts, any recommendations?

static orbit
unreal girder
#

and how do I add it to visual studio code?

static orbit
#

its not a extension, you install it through npm cli

distant gulch
unreal girder
#

does it come with @minecraft/server-ui?

static orbit
unreal girder
#

ohh thanks ♥️

prisma shard
#

I just saw that you need to learn html to modify ore ui

#

Have anyone seen the ore ui documentation

abstract cave
#

is js necessary to learn first before learning script

wary edge
#

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

distant gulch
static orbit
#

the basics of it

distant gulch
#

Hmm like how PCs are woking?

static orbit
#

not really.....

distant gulch
#

what then?

distant gulch
#

?

dense skiff
#

Is there a simple way to detect that two events happened at the same time?

distant gulch
#

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

dense skiff
#

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

distant gulch
#

so you want to check if a event got triggered twice or of two different events got triggered

dense skiff
#

two different events got triggered in the same tick

distant gulch
#
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

subtle cove
#

Use Date.now()

#

To compare ms time

distant gulch
#

he didnt wanted to compare the time?

subtle cove
#

How close should the event trigger tho...

distant gulch
#

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

neat hound
#

add system.currentTick... but I would suggest a startTick var to subtract stuff so not a big number and something that resets it

subtle cove
distant gulch
subtle cove
#

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

amber granite
#

He means before and after events ?

subtle cove
amber granite
#

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

dense skiff
#

I'm trying to link up a pistonActivate and entitySpawn lol I'll just use a list approach

subtle cove
#

Hmm, so location precision...

#

Whacha gon do with entitySpawn?

amber granite
subtle cove
distant gulch
#

@subtle cove can i borrow you real quick? or @hazy garnet

distant gulch
distant gulch
#

Can i spawn Simulated players without register?

distant tulip
#

i don't think so

distant gulch
distant tulip
#

what command

distant gulch
granite badger
#

no you can’t

distant tulip
#

use chat or scriptevent to trigger the run

distant gulch
distant tulip
#

🤨

distant gulch
#

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()

granite badger
#

You can't. Simulated players are for gametest only.

distant tulip
#

you can't run gametest command from the script?

distant gulch
#

yes i know, i just dont want to do it with register, i want a other function to use it form gametets

distant gulch
distant gulch
#

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

granite badger
#

no

distant gulch
#

Okay can i then get the Initiator of the command?

granite badger
distant tulip
distant gulch
#

okay would be an option

#

@granite badger scriptEventReceive gives me the initiator but register() dont...

static orbit
#

cuz theres no initiator in register

distant gulch
wary edge
#

GameTest is intended for unit testing. Its a testing framework

#

Why do you need a smiulated player anyways?

hardy tusk
wary edge
#

He could be trying something that doesnt need a simulated player

hardy tusk
#

Okay fair

distant gulch
lofty wharf
#

So I installed the latest npm stuff but they don't show any prompts or whatever in VSC. Any reason why this happens?

distant gulch
woven loom
#

hm

vestal zodiac
#

how to get block properties value?

vestal zodiac
#

anyone

tardy pivot
#

block.permutation.getState('block:state')

naive spindle
#

how acess item from others mods need script?, and how?

hazy nebula
#

What's wrong with it?

deep plank
#

you need to use system.run

hazy nebula
deep plank
vestal zodiac
tardy pivot
#

did you replace 'block:state' with your custom one?

inland merlin
#

does anyone have a good structure manager script or some link to an adddon that does this?

#

using the api

vestal zodiac
frozen vine
#

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?

wise notch
#

When plr press a button i want it to wait 5 secounds and run the function, how i make it ?

frozen vine
prisma shard
#

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

knotty plaza
#

Get the Mainhand slot from the EntityEquippable component

prisma shard
#

aw

#

but if there would be a itemStack propery, it would be easier

knotty plaza
#

Nope, there is not

prisma shard
#

like, i mean, in playerBreakBlock, you don't have to get the Mainhand component. Because, there is itemStackAfterBreak property.

#

mojang should add - itemStackAfterHit

knotty plaza
#

Thats Mojang's thinking, not sure what their reasons were

prisma shard
#

lol

prisma shard
#

can i dm u

knotty plaza
#

Sure, but if its something that will take a lot of time then I'll help you tomorrow

woven loom
#

hm

prisma shard
#

wat hm

stone bridge
#

hm is hm

amber granite
stiff ginkgo
#

how to shoot projectile use body rotation not View direction

hazy nebula
#

Is there a way to enchant an item greater than level 5 using sctipt?

tiny tartan
#

nah

distant gulch
#

why does my Simulated players alaways spawned outside the world when i entered my current postion as the spawn position?

wary edge
distant gulch
#

and sometimes it said, invalid structure randomly

fast lark
amber granite
#

Syntax error

fast lark
#
    function Credits() {
        new ActionFormData()
            .title("Players Menu")
            .body("Select players")
        PlayersName.forEach(p => PlayersUI.button(p))
    }
#

theres nothing wrong

amber granite
#

Syntax ?

#

Ask chat gpt to fix that syntactic error

fast lark
#

ok

distant gulch
#

Maybe playernames IS Not a String array

distant gulch
#

What do you have in Line 143

fast lark
#

}

distant gulch
#

IS PlayersUI Even defined?

deep yew
#

Anyone else not able to use /reload on a specific world?

distant gulch
#

I Had the same issue when i downloaded my realm world

#

Maybe try copying IT and use the copied version

deep yew
#

I think it's an ownership of the world thing?

#

it's weird

fast lark
distant gulch
#

Can you provide more Code?

fast lark
#

wait i delete it

distant gulch
#

Alright

fast lark
#

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));
    }
#

}

fast lark
#

@distant gulch

distant gulch
#

Hmm okay

#

Maybe add a ; at the end of .Body(...)

fast lark
#

okok

distant gulch
#

And why are you using two different Forms? Btw ModalFormData shouldnt have Body(...)

#

Just use at nodalFormData a dropdown

#

ModalFormData*

fast lark
#

actually forget it

#

I'm doing it all over again

distant gulch
#

I'll send you a code

fast lark
#

thx

#

#1262077601321848904

#

send it here

distant gulch
#

Sure

wheat condor
#

do someone know if a method to highlight a block? like making it more white?

amber granite
#

Use a new block that have the same texture but whiter

wheat condor
#

or it will lag like crazy?

wary edge
amber granite
unkempt pond
#

check my publication please

woven loom
#

huh?

prisma shard
distant tulip
#

his post

unkempt pond
#

Yes

#

my post

#

was 3 hours ago

fading sand
#

how do i check if an entity can take damage of other entities?

sage sparrow
#

hi experts, is there any benefit to use system.run()?

prisma shard
prisma shard
# sage sparrow hi experts, is there any benefit to use system.run()?

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.

sage sparrow
#

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....

prisma shard
amber granite
#

Making a function that gets the items names by their id is useful?

woven loom
amber granite
#

.

deep yew
#

Still having an issue getting the /reload command back when downloading a world off a realm

#

Actually just fixed it after a long time

fading sand
amber granite
#

Who there ?

warm drum
#

hi can anyone help me read the document?

#

like this

#

playerinteractwithblock is in the stable api but in what version?

warm drum
wary edge
#

No idea

amber granite
#

I made it finally

deep plank
woven loom
#

itemStack from entity remove is same as in inventory of user ?

random flint
#

what

woven loom
#

myabe cuz impluse ignores collisions

random flint
#

Use projectile components (if u make it a projectile on the JSON, that is...)

thorn spindle
#

That's what I did but it seems it still turns into a specific direction

woven loom
#

like i said the force by impluse is not effected by collisions

#

it keeps on going

#

idk if its a bug

fading sand
#

Wdym

granite badger
valid ice
#

Jaylydev >>>>
Gigachad

halcyon phoenix
#

can you trigger a item cooldown on script?

mellow socket
#

Can i force an animation on an entity?

turbid oriole
#

Is there a way to detect a touch on the screen or extend the block placement?

warm drum
#

how can i use script to make player ride another entity?

#

without using runcommand

turbid oriole
prisma shard
honest spear
shy leaf
#

how do you store vector3 into dynamic properties

#

nvm i got it

vast grove
prisma shard
#

lol

acoustic basin
#

how do i add lore to my item?

prisma shard
#

**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.

acoustic basin
short iron
#

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.

empty spruce
#

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 !

honest spear
vast grove
#

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.

honest spear
vast grove
#

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.

honest spear
#

Hmmm, ya JS sucks at this

vast grove
#

At least I can use this

dense skiff
#

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?

honest spear
#

JSON?

vast grove
#

Yup

#

Because HTTP fucking sucks

honest spear
#

Then why do you need uint casting?

#

just use that number

vast grove
#

Because if the last bit is set, it will go negatives

#

Then my server JSON parser will go, "no, fuck you"

honest spear
#

ya, but thats not problem you can send negative numbers via JSON

vast grove
#

Yeah but when I'm parsing in C#. It interprets it as out of range

honest spear
#

Read it as int and cast it as uint on C# side?

#

before validation

#

Ohhh

#

i see I hate C# Json class serialization

vast grove
honest spear
#

I know

#

Well use JsonDocuments its better cus its dynamic

vast grove
#

I use newtonsoft

honest spear
#

Well ya, then you that shitty TypeArray cast on JS side

#

or use int as a end type in C#

vast grove
#

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#

honest spear
#

ya

honest spear
#

There is bug or something?

vast grove
#

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.

honest spear
#

ya

#

Well good luck

vast grove
#

It's already finished. I just need to compile the software now before release.

dawn zealot
#

just gonna cause yall pain rq

prisma shard
#

bro is if statement's final boss

abstract cave
#

whats the diff between scripts and typescripts

short iron
subtle cove
#

script, basically to write script

abstract cave
subtle cove
#

mc uses js files in scripts folder

#

ts is used for accurate types that's then compiled into js

abstract cave
#

ok

tiny fable
winter plaza
#
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

distant gulch
# winter plaza ```js import * as mc from '@minecraft/server'; mc.system.runInterval(() => { ...
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;
winter plaza
#

did not work

sharp elbow
#

That would be for(let [familyTag, value] of Object.entries(Families)) {}

distant gulch
distant gulch
#

@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

sharp elbow
#

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';
}
distant gulch
sharp elbow
#

There isn't a benefit in this case

distant gulch
#

I just mean

sharp elbow
#

Side note: is it possible to alter the player's name like that? I have not yet tried

distant gulch
#

Yes you can, its not read-only

sharp elbow
#

TIL

distant gulch
#

TIL ?

sharp elbow
#

Today, I Learned (something new)

distant gulch
#

Alright nice

past blaze
#

The player's name is readonly, but their name tag isn't

#

Just want to clarify

distant gulch
#

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 ) ?

#

,

amber granite
#

They are both loops

#

U mean foreach, and forIn ?

#

Nah the impact is so small

sharp elbow
#

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.

amber granite
#

Agree

winter plaza
amber granite
#

For the largest arrays

#

Use the regular for loop

#

1 - general for loop
2 - foreach
3 - forIn

distant gulch
#

isnt a for..of / for..in loop always faster than the array methods?

amber granite
#

Nah not always

sharp elbow
#

That may be worth benchmarking!

distant gulch
amber granite
#

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

distant gulch
distant gulch
amber granite
#

YEP