#Script API General

1 messages · Page 23 of 1

unique dragon
#

that's same thing

deep plank
#

Yeah that's the same

shy leaf
#

idk i think i had the same issue with this before

#

and kinda solved it with that? i dont remember

#

just suggesting

unique dragon
#

well, i tried and it doesn't work

#

also i'm not getting any warn

deep plank
#

In arrow functions () isn't required if there's only 1 param.

shy leaf
#

what about trying it on vanilla interactable entities

unique dragon
#

i can try, but this is weird

#

ok i see what's wrong

#

it's ridiculous

random flint
#

Try shearing a sheep

#

That 100% counts as a successful interaction.
If it still doesn't run, check your file, maybe it didn't get imported or smt

unique dragon
#

afterEvents only works if the entity has interact component

#

if i use beforeEvents

#

it doesn't matter

shy leaf
#

i just realized isSneaking is not read-only

#

💀

unique dragon
#

uh

honest spear
distant tulip
#

it is not fixed lol

random flint
#

yipeen't

shy leaf
#

i still havent figured out how on EARTH applyKnockback strength works

#

all i know is that the strength is like blocks per tick

distant tulip
shy leaf
#

but i really cant figure out the x strength

shy leaf
random flint
#

applyKnockback() takes account of Knockback Resistance right?

distant tulip
#

yeah

#

also different depending on player state flying or others

shy leaf
distant tulip
#

@shy leaf ...

shy leaf
#

dear god

distant tulip
#

lol

#

@shy leaf

shy leaf
distant tulip
#

wait that is apply Impulse 🗿
i seen hem using it for player
maybe it is another one

runic crypt
#

Can anyone please help me make a form for chat ranks ???
Form heading- Ranks
Button 1- Create Ranks
Button 2- Delete Ranks
Button 3- Add Ranks
Button 4- Remove Ranks
Button 5- About
Button 6- Cancel
the rank prefix is "rank:<rank name>"

#

it adds tags

#

like /tag @s add rank:name
the you get a rank

#

any ideas ?

runic crypt
#

if anyone knows pls ping/dm me

drifting ravenBOT
#
Free Work

If you want an add-on made for you for free, you're most likely out of luck. The best thing you can do is watch tutorials and read guides so you can learn how to develop it yourself.

People won't work for free, but you can always offer to pay them to make something for you.

runic crypt
#

i mean i asked for help/suggestions

gaunt salmonBOT
fiery solar
# distant tulip <@523382130093457418>

I can vouch for this solution. Just need to convert applyImpulse to applyKnockback for players. Here's a video of me using it to apply a single knockback command that launches the player to an exact point I specify.

fiery solar
ivory bough
#

Guys does itemCompleteUse detect eating or is it something else that detects when I eat something

prisma shard
#

hmm.. currently there's a lot of cases of that playerInteractWithEntity event isn't working

#

for some users

shy leaf
wary edge
wary edge
ivory bough
buoyant canopy
#

how to get an array of all item ids?

shy leaf
#

this may not be the one youre looking for

#

but its close enough

buoyant canopy
#

is it stable?

shy leaf
#

ofc its stable

#

its very up to date

buoyant canopy
#

it looks like it jst have air in stable

shy leaf
#

it contains every vanilla item types

ivory bough
#

Guys why does this say this? I defined it using let and it doesn't work and tried it with const and doesn't work too

shy leaf
#

are you running it in runInterval?

#

just point to the part where youre getting the error

#

i dont want to check the entire code

ivory bough
shy leaf
#

and where did you put it

ivory bough
shy leaf
#

...yeah like,

ivory bough
#

No system.

shy leaf
#

you can post the chunk of the code

ivory bough
shy leaf
#
export function center(target,vector3 = { x: 0, y: 0, z: 0}) {
    const { x, y, z } = vector3;
    const c = {
        x: target.location.x+x,
        y: ((target.location.y+target.getHeadLocation().y)/2)+y,
        z: target.location.z+z
    }
    return c;
}```
#

like this

ivory bough
shy leaf
#

no you dont have to

#

post the entire code

#

you just have to post a part of it

ivory bough
#
system.afterEvents.scriptEventReceive.subscribe((event) => {
  if (event.id == "space:randomtp2") {
    let randomo = Math.floor(Math.random() * 4) + 1;
    let randoma = Math.floor(Math.random() * 6) + 1;
    switch (randomo) {
      case 1:
        let randomint5 = Math.floor(Math.random() * (29 - 15 + 1)) + 15;
        world.getDimension("overworld").runCommand(`execute as @r at @s run tp @e[type=space:the_one_who_watches] ^ ^ ^${randomint5}`);
        break;
      case 2:
        let randomint12 = Math.floor(Math.random() * (29 - 15 + 1)) + 15;
        world.getDimension("overworld").runCommand(`execute as @r at @s run tp @e[type=space:the_one_who_watches] ^ ^ ^-${randomint12}`);
        world.getDimension("overworld").runCommand("execute as @r at @s run playsound toww.behind");
        break;
      case 3:
        let randomint21 = Math.floor(Math.random() * (29 - 15 + 1)) + 15;
        world.getDimension("overworld").runCommand(`execute as @r at @s run tp @e[type=space:the_one_who_watches] ~${randomint21} ~ ~`);
        break;
      case 4:
        let randomint6 = Math.floor(Math.random() * (29 - 15 + 1)) + 15;
        world.getDimension("overworld").runCommand(`execute as @r at @s run tp @e[type=space:the_one_who_watches] ~-${randomint6} ~ ~`);
        break;
      default:
        break;
    }
  }
  switch (randoma) {
    case 1:
      world.getDimension("overworld").runCommand("event entity @e[type=space:the_one_who_watches] minecraft:pose1");
      break;
    default:
      break;
  }
});```
#

@shy leaf

buoyant canopy
sharp elbow
#

randoma is defined inside that first if block. The switch statement near the end of the function is outside of that block, and thus the variable is not defined

shy leaf
#

and then do something like MinecraftItemTypes.DiamondSword

#

but if youre still trying to get the array

#

im not sure about that cuz there are lots of items in game

buoyant canopy
#

are you sure it's stable?

#

or do i need to add it to the manifest?

shy leaf
#

oh you probably have to add it to the manifest mb

wary edge
#

Youll need to bundle it

shy leaf
#

oh wait

#

crap you have to bundle it???

buoyant canopy
#

what does that mean???

shy leaf
#

what are the docs even smoking

shy leaf
#

means its not included by default in the game

#

i dont like how ms docs gave us that for an example in addEnchantment

#

only to make it external

wary edge
shy leaf
distant tulip
#

bruh i just keep clicking enter+up+enter to reload and end up using reload all
third time in a row

buoyant canopy
#

what is the manual way of being able to use it?

#

now what do i do?

wary edge
#

I would recommend searching in #1067535712372654091 or this channel to learn how to use that

#

I dont relly see why you would even use that module in the first place anyways

somber cedar
shy leaf
#

but

#

im honestly not sure if that works

buoyant canopy
wary edge
#

I simply would just use the ItemTypes

buoyant canopy
#

is that beta?

wary edge
#

Idk

buoyant canopy
#

it works yaya

shy leaf
#

nice

untold magnet
#

hmm, scripts will stop working on the specific entity if it is in unloaded chunks right?

distant tulip
#

yes

#

make it tick the world if needed

wary edge
#

Sad womp womp

untold magnet
# distant tulip yes

so making a custom furnace thing will stop working when the chunks aren't loadedbao_foxxo_derp

#

yah thats good

distant tulip
wary edge
#

I cant see in the types that says that its incompatible

distant tulip
distant tulip
untold magnet
#

ooh, i got a really nice idea,
end-game machines will have an upgrade, making the upgraded block works even inside unloaded chunks

#

or, having a custom block that will keep chunks loaded but requires energy

distant tulip
untold magnet
#

yah i see

runic crypt
#

Is this possible ??

a script n which there is a text box in which i can type a message
then there is drop-down menu with list of all players
finally when i press the submit button, it runs /execute as <player i selected> run say <message i input>

keen folio
#

bro

keen folio
#

there are lot of guides about it

runic crypt
#

imma try

keen folio
#

There is an example of ModalFormData
@runic crypt

import { ModalFormData } from "@minecraft/server-ui";

function showSettingsForm(player) {
    const form = new ModalFormData();
    
    form.title("Game Settings");
    form.toggle("Enable Flying Mode", false);
    form.slider("Sound Volume", 0, 100, 1, 50);
    form.dropdown("Difficulty", ["Peaceful", "Easy", "Normal", "Hard"], 2); // Dropdown (default to "Normal")
    
    form.submitButton("Confirm");
    
    form.show(player).then(response => {
        if (response.canceled) {
            player.sendMessage("Settings update canceled.");
        } else {
            const [enableFlying, volume, difficulty] = response.formValues;
            player.sendMessage(`Flying Mode: ${enableFlying}`);
            player.sendMessage(`Volume: ${volume}`);
            player.sendMessage(`Difficulty: ${["Peaceful", "Easy", "Normal", "Hard"][difficulty]}`);
            
            if (enableFlying) {
                player.runCommandAsync("ability @s mayfly true");
            } else {
                player.runCommandAsync("ability @s mayfly false");
            }
        }
    });
}```
runic crypt
#

i knew how to make modal forms tho

#

what i need help with

keen folio
#

search modalform in github or search in this server cuz im too lazy or in yt

runic crypt
#

a script in which there is a text box in which i can type a message
then there is drop-down menu with list of all players
finally when i press the submit button, it runs /execute as <player i selected> run say <message i input>

runic crypt
buoyant canopy
#

how do i filter out waterlogged blocks from BlockTypes.getAll

buoyant canopy
#

i figured out a way, i just convert the type into an id, and then the id into a type, then get rid of the duplicates

#

this will remove the waterlogged state of the block

wary edge
runic crypt
#

@wary edge
could you provide some assistance ?

#
function showMessageForm(player) {
    const form = new ModalFormData();
    
    form.title("Send a Message");
    form.textField("Enter your message:", "Your message here");
    
    // Create a dropdown with all the players' names
    const playerNames = world.getPlayers().map(p => p.name);
    form.dropdown("Select a player to speak as:", playerNames, 0);
    
    form.submitButton("Send Message");
    
    form.show(player).then(response => {
        if (response.canceled) {
            player.sendMessage("Message sending canceled.");
        } else {
            const [message, selectedPlayerIndex] = response.formValues;
            const selectedPlayerName = playerNames[selectedPlayerIndex];

            // Execute the command as the selected player
            player.runCommandAsync(`execute "${selectedPlayerName}" ~ ~ ~ say ${message}`);
            
            player.sendMessage(`Message sent as ${selectedPlayerName}: ${message}`);
        }
    });
}

// Listen for the itemUse event
world.events.itemUse.subscribe(event => {
    const { source: player, item } = event;

    // Check if the item is a stick
    if (item.typeId === minecraft:stick) {
        showMessageForm(player);
    }
});

can you fix this script ?
its showing errors and idk how to fix it, as I can't even locate the error
part of it was made by me and part of it was made by chat gpt

crude bridge
#

HELP

#
world.beforeEvents.playerInteractWithEntity.subscribe(e => {
    const { itemStack, player, target } = e;
    if (target.typeId !== 'npc:npc_prova') return;
    // HERE
})```
#

how can i run a function

crude bridge
runic crypt
#

@crude bridge
can you help ?

#

pls

crude bridge
#

sorry

#

for what*

runic crypt
#

and tell me where i went wrong ?

#

because it is not working

runic crypt
crude bridge
runic crypt
buoyant canopy
runic crypt
crude bridge
runic crypt
#

wdym?

runic crypt
#

my minecarft is reinstalling

distant tulip
#

minecraft:stick to "minecraft:stick"

runic crypt
#

ITS BLANK 😭

#

can you pls run it and see if it works for you ?

crude bridge
#
function showMessageForm(player) {
    const form = new ModalFormData();
    
    form.title("Send a Message");
    form.textField("Enter your message:", "Your message here");
    
    // Create a dropdown with all the players' names
    const playerNames = world.getPlayers().map(p => p.name);
    form.dropdown("Select a player to speak as:", playerNames, 0);
    
    form.submitButton("Send Message");
    
    form.show(player).then(response => {
        if (response.canceled) {
            player.sendMessage("Message sending canceled.");
        } else {
            const [message, selectedPlayerIndex] = response.formValues;
            const selectedPlayerName = playerNames[selectedPlayerIndex];

            // Execute the command as the selected player
            player.runCommandAsync(`execute "${selectedPlayerName}" ~ ~ ~ say ${message}`);
            
            player.sendMessage(`Message sent as ${selectedPlayerName}: ${message}`);
        }
    });
}

// Listen for the itemUse event
world.events.itemUse.subscribe(event => {
    const { source: player, item } = event;

    // Check if the item is a stick
    if (item.typeId === "minecraft:stick") {
        showMessageForm(player);
    }
});
runic crypt
#

thank you :D

crude bridge
runic crypt
runic crypt
#

count the lines ?

runic crypt
distant tulip
#

it is

crude bridge
runic crypt
#

oh 💀

crude bridge
runic crypt
runic crypt
distant tulip
# runic crypt how ??
system.afterEvents.scriptEventReceive.subscribe((event) => {
    const {id,initiator,sourceType,sourceBlock,sourceEntity} = event;

})
runic crypt
#

so something like this ?

runic crypt
# distant tulip ```js system.afterEvents.scriptEventReceive.subscribe((event) => { const {id...
function showMessageForm(player) {
    const form = new ModalFormData();
    
    form.title("Send a Message");
    form.textField("Enter your message:", "Your message here");
    
    // Create a dropdown with all the players' names
    const playerNames = world.getPlayers().map(p => p.name);
    form.dropdown("Select a player to speak as:", playerNames, 0);
    
    form.submitButton("Send Message");
    
    form.show(player).then(response => {
        if (response.canceled) {
            player.sendMessage("Message sending canceled.");
        } else {
            const [message, selectedPlayerIndex] = response.formValues;
            const selectedPlayerName = playerNames[selectedPlayerIndex];

            // Execute the command as the selected player
            player.runCommandAsync(`execute "${selectedPlayerName}" ~ ~ ~ say ${message}`);
            
            player.sendMessage(`Message sent as ${selectedPlayerName}: ${message}`);
        }
    });
}

// Listen for the itemUse event
world.events.itemUse.subscribe(event => {
    const { source: player, item } = event;
system.afterEvents.scriptEventReceive.subscribe((event) => {
gwim:open
})
    if (item.typeId === "minecraft:stick") {
        showMessageForm(player);
    }
});
distant tulip
#

huh

runic crypt
#

isnt it like id:gwim, messgae:open ?

#

or something like that ?

crude bridge
#

uhhhh

runic crypt
#

i have no idea man, scriptevent too hard for my tiny brain to comprehend

#

😭

distant tulip
#

your code is messed up
what are you trying to do

crude bridge
runic crypt
runic crypt
#

the messed up part is made by me :D

crude bridge
#

mmh

#

good

crude bridge
copper lake
#

how to use script to label something? As in I have script saving inventory in barrels. Is there a way I could get the script to label the barrels with the player name somehow when it saves them? Like could script place a sign with the name? Or summon and invisible entity with the Player name?

distant tulip
# runic crypt what ???
// /scriptevent id:test test message
system.afterEvents.scriptEventReceive.subscribe((event) => {
  const {id,message,sourceBlock,sourceEntity} = event;

  // id is "id:test"
  //message is "test message"
  //sourceBlock is the block that triggered the event
  //sourceEntity is the entity that triggered the event
  if(id === "test" && message === "test message"){
    //...
  }

})
distant tulip
#

there is a sign component in beta

copper lake
#

Ok is any of it available in stable, server 1.11.0 I'm working in education edition v1.21.05

#

and if I can't do any of it in stable. I can use 1.12.0 Beta if I have to.

runic crypt
#
function showMessageForm(player) {
    const form = new ModalFormData();
    
    form.title("Send a Message");
    form.textField("Enter your message:", "Your message here");
    
    // Create a dropdown with all the players' names
    const playerNames = world.getPlayers().map(p => p.name);
    form.dropdown("Select a player to speak as:", playerNames, 0);
    
    form.submitButton("Send Message");
    
    form.show(player).then(response => {
        if (response.canceled) {
            player.sendMessage("Message sending canceled.");
        } else {
            const [message, selectedPlayerIndex] = response.formValues;
            const selectedPlayerName = playerNames[selectedPlayerIndex];

            // Execute the command as the selected player
            player.runCommandAsync(`execute "${selectedPlayerName}" ~ ~ ~ say ${message}`);
            
            player.sendMessage(`Message sent as ${selectedPlayerName}: ${message}`);
        }
    });
}

// Listen for the itemUse event
world.events.itemUse.subscribe(event => {
    const { source: player, item } = event;

    // Check if the item is a stick
system.afterEvents.scriptEventReceive.subscribe((event) => {
  const {id,message,sourceBlock,sourceEntity} = event;
  if(id === "test" && message === "test message"){
  }

})
    if (item.typeId === "minecraft:stick") {
        showMessageForm(player);
    }
});
#

this ?

distant tulip
copper lake
distant tulip
distant tulip
copper lake
# distant tulip alr

can you point me at an example of how to summon the entity and give it the player name?

#

I have not found anything like that when I tried searching.

distant tulip
#

open a post and ping me there

runic crypt
#

I don't know

distant tulip
#

that make the event useless

crude bridge
#

pls minato

#

pls

#

plsplsplsplsplsplsplsplsplsplspslsplspsl

#

@distant tulip plapalalapalapalapaalapalplaplsplsplspslplspslpslspslpslspslpsspslspslpslspslspslspsslpsslpsls

runic crypt
# distant tulip that make the event useless

how about this ?

function showMessageForm(player) {
    const form = new ModalFormData();
    
    form.title("Send a Message");
    form.textField("Enter your message:", "Your message here");
    
    // Create a dropdown with all the players' names
    const playerNames = world.getPlayers().map(p => p.name);
    form.dropdown("Select a player to speak as:", playerNames, 0);
    
    form.submitButton("Send Message");
    
    form.show(player).then(response => {
        if (response.canceled) {
            player.sendMessage("Message sending canceled.");
        } else {
            const [message, selectedPlayerIndex] = response.formValues;
            const selectedPlayerName = playerNames[selectedPlayerIndex];

            // Execute the command as the selected player
            player.runCommandAsync(`execute "${selectedPlayerName}" ~ ~ ~ say ${message}`);
            
            player.sendMessage(`Message sent as ${selectedPlayerName}: ${message}`);
        }
    });
}
system.afterEvents.scriptEventReceive.subscribe((event) => {
  const {id,message,sourceBlock,sourceEntity} = event;
  if(id === "test" && message === "test message"){
  }
});
distant tulip
#

player is not defined

distant tulip
#

who are yo sending it to

crude bridge
#

ntw

crude bridge
#

btw*

runic crypt
crude bridge
distant tulip
runic crypt
crude bridge
#
world.beforeEvents.playerInteractWithEntity.subscribe(e => {
    const { data, player, target } = e;
    if (target.typeId !== 'npc:npc_prova') return;
    player.runCommandAsync('say ciao')
    main(player)
})

    function main(player) {
        const form = new ActionFormData()
            .title('§g§rDark menu')
            .button(`§cWarps`, 'textures/aulonia_icons/icontextures/magma_cream.png')
            .button(`§dTpa`, 'textures/aulonia_icons/icontextures/ender_pearl.png')
            .button(`§fPay`, 'textures/aulonia_icons/icontextures/coin_04c.png')
            .button(`§6Shop`, 'textures/aulonia_icons/icontextures/gold_ingot.png')
            .button(`§6Statistiche`, 'textures/aulonia_icons/Quest.png')
            .button("§o§b???\n§7[ ??? ]", 'textures/aulonia_icons/NoTexture.png')

            .show(player).then(({ canceled, selection }) => {
                if (canceled) {
                    player.playSound("random.break")
                }

                if (selection == 0) Warps(player)
                if (selection == 1) tpMenu(player)
                if (selection == 2) moneyTransfer(player)
                if (selection == 3) Shop(player)
                if (selection == 4) Menu(player)
                if (result.selection === 5) {
                    return
                }
            })
    }```
crude bridge
distant tulip
runic crypt
crude bridge
runic crypt
#

Okay

distant tulip
# runic crypt Okay
system.afterEvents.scriptEventReceive.subscribe((event) => {
  const {id,sourceEntity} = event;
  if(id === "id:send"){
    const players = world.getPlayers()
    const playerNames = players.map((player) => player.name)
    const form = new ModalFormData();
    form.dropdown("player", playerNames);
    form.textField("message","Type a message");
    form.show(sourceEntity).then((r) => {
      if(r.canceled) return
      if(!r.formValues[0] || !r.formValues[1]) return
      const player = players[r.formValues[0]]
      player.sendMessage(`<${sourceEntity.name}> ${r.formValues[1]}`)
    })
  }
})
runic crypt
#

@distant tulip
i copied the scrp to another folder, to make it run a /tag command (to add rank) however the command doesn't work
I tried other commands like give dirt and other stuff
it also didnt work

system.afterEvents.scriptEventReceive.subscribe((event) => {
  const {id,sourceEntity} = event;
  if(id === "gwim:rank"){
    const players = world.getPlayers()
    const playerNames = players.map((player) => player.name)
    const form = new ModalFormData();
    form.dropdown("player", playerNames);
    form.textField("message","Type a message");
    form.show(sourceEntity).then((r) => {
      if(r.canceled) return
      if(!r.formValues[0] || !r.formValues[1]) return
      const player = players[r.formValues[0]]
      player.runCommandAsync(`tag add ${sourceEntity.name} gwim:${r.formValues[1]}`)
    })
  }
})

can you take a look and tell me what i did wrong ?

gaunt salmonBOT
#

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 4 errors:

<REPL0>.js:9:15 - error TS2345: Argument of type 'Entity' is not assignable to parameter of type 'Player'.
  Type 'Entity' is missing the following properties from type 'Player': camera, inputPermissions, isEmoting, isFlying, and 23 more.

9     form.show(sourceEntity).then((r) => {
                ~~~~~~~~~~~~

``````ansi
<REPL0>.js:12:30 - error TS2538: Type 'true' cannot be used as an index type.

12       const player = players[r.formValues[0]]
                                ~~~~~~~~~~~~~~~

``````ansi
<REPL0>.js:13:54 - error TS2339: Property 'name' does not exist on type 'Entity'.

13       player.runCommandAsync(`tag add ${sourceEntity.name} gwim:${r.formValues[1]}`)
                                                        ~~~~

``````ansi
@minecraft/server-gametest.d.ts:3:38 - error TS2307: Cannot find module 'mojang-minecraft' or its corresponding type declarations.

3     import * as mojangminecraft from "mojang-minecraft";
                                       ~~~~~~~~~~~~~~~~~~

Lint Result

There are no errors from ESLint.

distant tulip
#

uh what

glacial widget
#

am confused, keeps saying hasTag is not defined?

world.afterEvents.entityDie.subscribe((ev) =>{
    const player = ev.damageSource.damagingEntity
    const dead = ev.deadEntity

    if(dead instanceof Player && player.hasTag("ctf")){
        world.sendMessage(`CTF >> player has dropped flag, flag has been set at its location`)
        player.removeTag("ctf")
        overworld.setBlockType({ x: -11, y: 71, z: 2 }, "minecraft:standing_banner")
        removeEffects(player)
    }
distant tulip
#

show full error?

glacial widget
#

huh i did

#

it says the if statment is were the error is

distant tulip
#

i meant show full error
as in send it

#

it probably "can't call function hasTag of undefined"

rigid surge
#

If the entity dies and it isnt caused by a player the player value would be nil

#

That could be the problem

glacial widget
#

ohhh

wheat condor
#
function hashKeyToSlot(key) {
    let hash = 0;
    for (let i = 0; i < key.length; i++) {
        hash = (hash << 5) - hash + key.charCodeAt(i);
        hash = hash & hash;
    }
    if (settings.timeWarn == true) {
        console.warn(`slot ${Math.abs(hash % (9999999999999999999999999999))}`)
    }
    return Math.abs(hash % (9999999999999999999999999999));
}

you got any ideas of how can i add arrays support for hashing keys?

wheat condor
frozen vine
#

I have a question

#

The PlayerInteractWithEntity component is used when you interact with a specific item with the mob?

#

for example, interacting with a stick will make the mob disappear and add a lore to the stick.

unique dragon
#

you can get the itemstack if u want

copper lake
#

How do I test if an entity already exists at a location before doing something.

unique dragon
distant tulip
#

dimension.getEntities({type:id,location,vector3,distance:0.5})

copper lake
#

so how would I put that in an if statement so that if the entity does exist at that spot I can have it return.

#

would it be just
if(dimension.getEntities({type:id,location,vector3,distance:0.5})) return

distant tulip
#

no that return an array
check if it is empty

copper lake
#

what is the syntax to do that?

distant tulip
#

either
if(array[0]) return
or
if(array.length == 0) return

lethal crystal
#

So if i make my own?

#

Like

#

Make a test to check wich armor is the player using and add the value of the protection and add it to the score

frozen vine
grave nebula
#

how do i display text to a actionbar again

#

lowk forget

#

whats the player. function

lone thistle
grave nebula
#

tx

copper lake
#

is it possible to summon a tamed entity with script?

fallow rivet
#

How do I detect an entity with coordinates X: 1 Y: 10 Z: 0?
Const entity = ????

untold magnet
#

uh

#

block.dimension.spawnParticle('my:particle', ???) i had to make this spawn the particles slightly above the block center

#

like 0.3 above the block center

#

block.above(0.3) spawn the particles away from the block

grave nebula
#

anyone know why this isnt working?

import { system, world } from "@minecraft/server";

world.afterEvents.playerJoin.subscribe((data) => {
    const playerName = data.playerName;
    const playerId = data.playerId;

    const player = world.getAllPlayers().find(p => p.id === playerId);
        player.teleport({
            x: 11.5,
            y: -27.5,
            z: -110.5
        })
});```
grave nebula
#

yes

shy leaf
#

then post

grave nebula
#

[Scripting][error]-TypeError: cannot read property 'teleport' of undefined at <anonymous> (systems/events/playerJoin.js:42)

#

i dont get it

#

even the debugger bot got 0 errors

shy leaf
#

the debugger checks for only visible errors like syntax error or unused definitions

grave nebula
#

still, there should be no error

shy leaf
grave nebula
#

same error

#
    const player = world.getAllPlayers().forEach(player => {if (player.id === playerId) return player;})```
even tried this and same error
half drum
#

did you try using playerSpawn instead

shy leaf
#

that also counts when you respawn

grave nebula
#

it worked but i only want when they join the world

half drum
#

if (data.initialSpawn)

shy leaf
#

isnt that for when the player joined for the first time since the world was open

#

i dont remember

grave nebula
#

^ yes

#

not when they spawn each time

#

initial is their first time ever joining

#

not each

shy leaf
#

atp you can try filter

half drum
grave nebula
#

same error

shy leaf
#
        const playerCenter = player.dimension.getEntities({
            location: player.getHeadLocation(),
            maxDistance: 3
        });
        const targetCenter = player.dimension.getEntities({
            location: {x:target.location.x-1.5, y:target.location.y, z:target.location.z-1.5},
            volume: {x: 3, y: 0.25, z: 3}
        });
        const commonEntities = playerCenter.filter(entity => 
            targetCenter.some(targetEntity => targetEntity.id === entity.id) &&
            entity.id !== target.id
        );```
#

taken from my code

grave nebula
shy leaf
#

bruj

grave nebula
#

it used to be initialSpawn was the first time ever joining

#

i guess they updated it

#

weird

#

but thx

shy leaf
#

oh yeah it makes sense

#

i still dont get why they dont let us get Player directly instead of just ids

grave nebula
#

idek

half drum
#

because the player hasn't loaded in yet

#

would explain why .teleport wouldn't work

grave nebula
#

its a afterEvent tho

shy leaf
#

but considering the teleport 'worked'

grave nebula
#

the issue wasnt the teleport, it was saying player wasnt found

#

which if it doesnt exist how did the event trigger??? 😭

shy leaf
#

oh

#

it didnt work

grave nebula
shy leaf
#

ok i have a crackshit solution

#

Map Face

grave nebula
#

💀

#

no 😭

grave nebula
shy leaf
#

idk i dont see any other solution other than Map

grave nebula
#

it worked

shy leaf
#

whar

grave nebula
#
import { system, world } from "@minecraft/server";

world.afterEvents.playerSpawn.subscribe((data) => {
    const player = data.player;
    if (!data.initialSpawn) return;
    player.teleport({x: 11.5,y: -27.5,z: -110.5})
});```
#

this works

shy leaf
#

what

#

why

grave nebula
#

@half drum was right

shy leaf
#

how

#

wjat

grave nebula
#

they changed initalSpawn

shy leaf
#

huh?????????

grave nebula
#

wait

#

oh

#

im slow

#

😭

#

ur talking abt the player find thing

shy leaf
untold magnet
#

I'll go to sleep rn,bao_foxxo_what

distant tulip
exotic raptor
#

GENTLEMEN!!!

#

Let's say the player gets a tag. When given the tag, I intend for a given item to activate a cooldown, and the player removes the tag from themselves. It works fine, but I cannot at ALL figure out how I could get the current held item's cooldown category and cooldown duration, as the damned startItemCooldown demands I get those two arguments.

random flint
exotic raptor
#

I am working with this dog water rn:

    for(const player of world.getAllPlayers()) {
      if(player.hasTag("tera_cooldown")) {
        player.getItemCooldown("teraCooldown")
        player.startItemCooldown("teraCooldown", tickValue)
        player.removeTag("tera_cooldown")
        
  }
    }
  }
  );
random flint
exotic raptor
random flint
exotic raptor
#

I can't find that anywhere in the damn beta api

random flint
#

it's ItemStack component, not entity

exotic raptor
#

IT WAS RIGHT THERE!?

#

dear god

random flint
exotic raptor
#

I skimmed over it by mistake hours ago

runic crypt
#

guys

#

i need help

buoyant canopy
#

don't ask to ask

#

just ask

unique dragon
runic crypt
#

i do know the basics, i cant figure out how to add /scriptevent

unique dragon
#

i think some people have already ask for that in this chat

shy leaf
shy leaf
#

i

runic crypt
#

in this

shy leaf
#

ok why do people post the entire code out of nowhere

#

im really curious

runic crypt
shy leaf
#

you can just post the chunk of the code

runic crypt
shy leaf
#

i dont even know what youre trying either

unique dragon
#

have u tried to make a console.warn?

buoyant canopy
runic crypt
#

i did the same in another script

#

and it worked

unreal cove
shy leaf
unique dragon
#

just need to call the function

runic crypt
#

thats the problem

unreal cove
unique dragon
#

what's the function name?

runic crypt
shy leaf
runic crypt
#

lets go with ranks ?

runic crypt
unique dragon
runic crypt
#

alright

buoyant canopy
#

call it inside the empty {}

shy leaf
#

write openRanksMenu(sourceEntity)

runic crypt
shy leaf
buoyant canopy
#

line 25 💀

unreal cove
#

u just said u knew basics

shy leaf
#

im curious how you even managed to build the functions

runic crypt
#

i think i got it

#
system.afterEvents.scriptEventReceive.subscribe((event) => {
  const {id,sourceEntity} = event;
  if(id === "gwim:rank"){
  openRanksMenu(sourceEntity)
}
#

this ?

runic crypt
shy leaf
runic crypt
#

@shy leaf

#

oh wait nvr mind

#

forget it 🙂

buoyant canopy
shy leaf
#

i dont know if i should respond to it

runic crypt
#

got it to work

#

thanks yall

slow walrus
#

you missed a bracket

#
system.afterEvents.scriptEventReceive.subscribe((event) => {
  if(event.id === "gwim:rank" && event.sourceEntity) {
    openRanksMenu(event.sourceEntity)
  }
}
#

sourceEntity can also be undefined so you need to make sure it isn't when calling the function

buoyant canopy
#

yeah, in case you run it through a command block

gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

shy leaf
gentle charm
#

One message removed from a suspended account.

shy leaf
#

its in settings

gentle charm
#

One message removed from a suspended account.

shy leaf
#

it shows your script error logs

gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

gentle charm
#

One message removed from a suspended account.

shy leaf
#

check your scripts and manifest

gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

shy leaf
#

you sure thats the right manifest?

gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

shy leaf
#

also

#

i recommend using development packs for making addons

#

you can use /reload command to reload changes in scripts and mcfunctions

gentle charm
gentle charm
#

One message removed from a suspended account.

shy leaf
#

then yep

gentle charm
shy leaf
#

you dont have it?

gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

shy leaf
#

then create development_resource_packs and development_behavior_packs in com.mojang folder

#

and then put the packs in there

gentle charm
shy leaf
#

what link?

gentle charm
#

One message removed from a suspended account.

shy leaf
#

oh right

gentle charm
#

One message removed from a suspended account.

shy leaf
#

windows

gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

sleek nexus
distant tulip
#

return to com.mojang
you should see a developer folder

sleek nexus
#

click this to go back a directory, and you want to put your pack into development_behavior_packs instead of behavior_packs.
The development... folders allow Minecraft to reload the pack when you reload a world.

In the non-development versions of the folders, each time you create a world and apply a pack to it, the pack is copied into the world folder and will not be reloaded unless the version number is incremented. This means you won't see any changes you make to your pack in a world that already has it applied, as the world now has an older outdated copy of it.

distant tulip
#

it is there by default
you don't need to make it

gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

distant tulip
#

yeah
use those for developing

gentle charm
#

One message removed from a suspended account.

distant tulip
gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

distant tulip
#

you may need to clear cashed packs from you world

gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

distant tulip
#

read 😅
why do people see list of errors and don't try to understand them

#

this is the only script related error
make the main.js file specified on your manifest

gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

gentle charm
#

One message removed from a suspended account.

distant tulip
#

translated?

gentle charm
#

One message removed from a suspended account.

distant tulip
#

send your manifest

gentle charm
gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

distant tulip
#

change "main.js" in your manifest to whatever path the script is on
including the full path

gentle charm
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

supple yoke
#

hey quick question

#

how big is the command queue?

#

and also

#

is there a way to set a lot of blocks quickly

#

(5120 blocks to be precise)

#

ok structures might work

karmic pond
#

Can I edit files with scripts ? Like I have a file that exports a giant object and I was wondering if I can edit it with script

untold magnet
# shy leaf no
~onPlayerInteract: i => { turning aThing from false to true }
~runInterval(() => { if (aThing = true) { ,,, } })```help?
#

or

#

onPlayerInteract: i => { ~runCommand('scriptevent a:thing') }
and detects the scriptevent inside of a runInterval

sharp elbow
#

Why are you insisting on using runInterval? The point of scripting's event-based system is so you can run actions precisely when, and only when, they occur

untold magnet
#

like,
const scriptEvent = ~scriptEventReceive.sub(({ id }) => { if(id === 'a:Thing') })

#

look,
when the player interacts with a block, it will do something that will be detected inside of a runInterval

sharp elbow
#

Why not just perform that action right as they interact with a block?

#

Why the looping code? It's overhead you don't need

untold magnet
#

im making something that requires runInterval

sharp elbow
#

Could you elaborate further?

untold magnet
#

interacting with the block will generate energy,
i had to make the runInterval detect that energy, i mean after interacting with the block it will do something like change the value of something,
if that something has the value of 1 it will be detected

#

just like on and off button
interact will turn it on, and after 1 second it will set back that value from on to off, gosh i cant explain well

sharp elbow
#

Mm, and that energy has a value that depletes over time, and it should do some action when it hits 0.

#

I can see a use for runInterval in something like circuitry. A ticking game loop is the most straightforward way to make it deterministic

last latch
#

Native property setter [Entity::nameTag] does not have required privileges. since when does changing nameTag require privilages??

#

it is so dumb

fiery solar
last latch
sharp elbow
#

That is precisely answered by vprufus's response. If you are working in a read-only context, you cannot (or at least, should not be able to) edit the game's state—and apparently that includes setting name tags(?)

untold magnet
slow walrus
last latch
sharp elbow
#

Stuff changes 🤷

untold magnet
sharp elbow
#

If energy is a globally scoped variable, it should be as simple as energy = 1;

slow walrus
#

this is such a basic thing

slow walrus
last latch
slow walrus
#

not in a before event

#

anything that modifies the world state is not allowed in a before event context

#

use a system.run() to change the nametag

thorn flicker
#

its really not that big of a deal wrapping your code in system.run

thorn flicker
last latch
#

better to use none

slow walrus
#

no it's not

#

it doesn't work with none

#

you have to use a system.run

last latch
#

bro

#

😭

last latch
#

it is a big deal

thorn flicker
slow walrus
last latch
#

a code

fiery solar
slow walrus
#

are you fucking stupid?

thorn flicker
#

bro is still not telling me how it is a big deal

round bone
last latch
slow walrus
#
world.beforeEvents.playerSpawn.subscribe(e => {
  e.player.nameTag = "idiot" // won't work, missing required priviliges
})
world.beforeEvents.playerSpawn.subscribe(e => {
  system.run(() => {
    e.player.nameTag = "idiot" // will work
  })
})
last latch
slow walrus
#

that's what we're telling you

#

that's how it works

thorn flicker
last latch
thorn flicker
#

lmao

last latch
#

i am telling that putting system.run is a big deal (a code)

slow walrus
#

dont come complaining here about something if you're not gonna fucking listen lmao

#

why is it a big deal?

thorn flicker
last latch
untold magnet
#

onPlayerInteract: i => { if (energy === false) return true }?

last latch
#

i dont put everything in system.run

slow walrus
#

THATS WHAT ITS SUPPOSED TO DO YOU DUMBASS

thorn flicker
round bone
#

he's talking about privilege system what was added a long time ago

#

chill out guys

idle dagger
fiery solar
last latch
slow walrus
#

you HAVE to delay the code till the next tick so it's inside the read / write context. BeforeEvents run outside of the game's tick, so they are in a read-only context

idle dagger
round bone
#

#1116091026843635732 message

#

just read this

last latch
#

i said that you putting system.run is a big deal in general

slow walrus
#

it literally is fucking not but ok

#

your arguing is pointless because you're completely wrong

grim raft
#

yo

round bone
thorn flicker
round bone
#

just calm down bro

#

you're arguing with some random on discord for some minecraft development xd

grave nebula
last latch
thorn flicker
grim raft
#

quick question if yall have time

round bone
#

i read the whole conbo and he's just trying to get answer why you can't change nametag in the same tick in before event

grave nebula
grave nebula
round bone
#

you could just redirect him to this one resource

#

instead of calling him a fucking idiot

thorn flicker
last latch
idle dagger
#

is there a before event of entityHitentity?

grave nebula
#

or you can all ignore him cuz his answer wont change

thorn flicker
grave nebula
idle dagger
last latch
thorn flicker
grave nebula
#

nope

slow walrus
grave nebula
#

its not that deep

thorn flicker
#

lets relax.

last latch
grave nebula
#

your making it more serious than it really is

slow walrus
#

I'm not angry

grim raft
#

can I make it work with max value instead of normal value?
.getComponent('minecraft:health').setCurrentValue();

grave nebula
thorn flicker
last latch
slow walrus
idle dagger
grave nebula
round bone
grave nebula
#

whats werid is isSneaking isnt read only

#

you can set it to true 😭

round bone
slow walrus
thorn flicker
grim raft
#

damn so I cant connect it with a scoreboard

round bone
fallow rivet
#
player.dimension.spawnEntity('minecraft:fireball', { x: x, y: y, z: z });  ```
Not work why?
grave nebula
round bone
idle dagger
round bone
#

just spam him link to this mini-doc

last latch
slow walrus
round bone
slow walrus
grave nebula
#

the difference

rigid surge
grave nebula
#

its writable

fallow rivet
round bone
#

i didn't read whole

#

xd

slow walrus
grave nebula
round bone
#

does this even toggles sneak?

grave nebula
#

its buggy

slow walrus
#

sometimes

grave nebula
#

it toggles it for like 1 tick out of the second

#

and it goes back to standing

#

and the camera bugs if you try to move

round bone
#

xD

#

minecraft probably updates this property every tick i guess then

grave nebula
#

its funny how i found it, i was trying to set another player value to true and picked sneaking by accident 😭

#

its weird tho

fallow rivet
#

@grave nebula @slow walrus The location where the entity spawns is in front of the player.

grave nebula
#

watchu know bout file structure 😭

round bone
#

why it would be not read-only if it's that buggy

grave nebula
slow walrus
slow walrus
thorn flicker
fallow rivet
slow walrus
#

change it back

grave nebula
#

what is the x, y, and z values

#

it needs to be a number not a string

slow walrus
#

player.dimension.spawnEntity() is fine

grave nebula
round bone
thorn flicker
round bone
#

or just some component to set it

slow walrus
thorn flicker
round bone
thorn flicker
round bone
#

but that's only my suggestion

thorn flicker
round bone
#

when did they changed it?

thorn flicker
#

before I started

#

idk specifically when

round bone
#

prob some long time ago ig

slow walrus
#

oh wait

#

lol

#

you can't spawn fireballs

grave nebula
#

^

#

java only

keen folio
#

save it

#

then load it when diamond pressed

fallow rivet
keen folio
#
player.runCommandAsync(“structure load minecraft:f ${ePos.x} ${ePos.y} ${ePos.z}”)```
slow walrus
#

yep, bedrock doesn't get any fun stuff

keen folio
#

define pos first

thorn flicker
#

theres structureManager class

thorn flicker
#

^

thorn flicker
keen folio
thorn flicker
supple yoke
#

what will happens if load 334mb worth of mcstructures into Minecraft lol

#

place your bets

#

if this goes well

#

I'll comeback with 1.5 gb of mcstrucures

#

I'll be pleasantly surprised if it goes well

#

dam

#

holy hell

#

termux copying is sloww

#

took 30 seconds to copy 330ish mb to minecraft

rigid surge
#

@fallow rivet just change fireball.json

#

Change the summonable to true

#

{
"format_version": "1.12.0",
"minecraft:entity": {
"description": {
"identifier": "minecraft:fireball",
"is_spawnable": false,
"is_summonable": true,
"is_experimental": false
},

"component_groups": {
"minecraft:exploding": {
"minecraft:explode": {
"fuse_length": 0,
"fuse_lit": true,
"power": 1,
"causes_fire": true,
"fire_affected_by_griefing": true,
"destroy_affected_by_griefing": true
}
}
},

"components": {
"minecraft:collision_box": {
"width": 0.31,
"height": 0.31
},
"minecraft:projectile": {

"on_hit": {
  "impact_damage": {
    "damage": 6,
    "knockback": false,
    "semi_random_diff_damage": false
  },
 "definition_event": {
  "affect_projectile": true,
  "event_trigger": {
        "event": "minecraft:explode",
        "target": "self"
  }
 }
},
"power": 1.6,
"gravity": 0.00,
"inertia": 1,
"liquid_inertia": 1,
"uncertainty_base": 0,
"uncertainty_multiplier": 0,
"anchor": 1,
"offset": [ 0, -0.1, 0 ],
"reflect_on_hurt": true,
"catch_fire": true

},
"minecraft:physics": {
},
"minecraft:pushable": {
"is_pushable": true,
"is_pushable_by_piston": true
},
"minecraft:conditional_bandwidth_optimization": {
"default_values": {
"max_optimized_distance": 80.0,
"max_dropped_ticks": 7,
"use_motion_prediction_hints": true
}
}
},
"events": {
"minecraft:explode": {
"add": {
"component_groups": [
"minecraft:exploding"
]
}
}
}
}
}

grave nebula
#
        player.getComponent('minecraft:inventory').container.setItem(8, { amount: 1, typeId: "minecraft:compass", keepOnDeath: true, lockMode: ItemLockMode.inventory, nameTag: `GUI` })```
has no errors but doesnt set the item
wary edge
grave nebula
#

ah

#

how exactly do i do that

wary edge
grave nebula
#

alr

#

thx

frozen vine
#

What does this mean?

fallow rivet
distant tulip
#

use what ever throwing that
inside system.run

frozen vine
# fallow rivet Code?
world.beforeEvents.playerInteractWithEntity.subscribe(async eventData => {
  let entity = eventData.target
  let player = eventData.player
  let equipment = player.getComponent("equippable")
  let hand = equipment.getEquipment("Mainhand")
  let tame = entity.getComponent( "minecraft:is_tamed" );
  let lore = hand.getLore()
  if (entity && hand && !tame && hand?.typeId == "mc:genie_lamp" && lore.length == 0 && entity.typeId != "minecraft:player") {
    let newItem = new ItemStack(ItemTypes?.get("mc:genie_lamp_captured"))
    let mobName = entity.typeId;
    let test = entity.id;
    newItem.setLore(["§fID: " + test,"§fMob: " + mobName])
    player.runCommandAsync(`titleraw @p actionbar {"rawtext":[{"translate":"function.lampc"}]}`);
    entity.runCommandAsync(`structure save ${entity.id}_mob_capture_device ${entity.location.x} ${entity.location.y} ${entity.location.z} ${entity.location.x} ${entity.location.y} ${entity.location.z} true disk false`).then(r => {
      entity.teleport({
        x: 0, y: -100, z: 0
      })
      entity.kill
      equipment.setEquipment("Mainhand", newItem)
    })
  }
  if (entity && hand && tame && hand?.typeId == "mc:genie_lamp" && lore.length == 0 && entity.typeId != "minecraft:player") {
      entity.runCommandAsync(`effect @e[c=1,r=5,type=!item,type=!xp_orb,family=!inanimate,type=!player] instant_health 1 0 false`)
      }
})
grave nebula
distant tulip
#

but why beforeEvents in the first place

grave nebula
#

question, i have my scripts in development_behaivor_packs on a server, whenever i do /reload in terminal the scripts dont actually update

frozen vine
grave nebula
#

and the scripts are on the world

#

how do i fix that

frozen vine
#

Is there any way I can identify the mob I interacted with?

grave nebula
frozen vine
distant tulip
grave nebula
distant tulip
grave nebula
#

wait

#

im slow

#

im editting it from com.mojang

#

😭

distant tulip
#

🗿

frozen vine
#

I would like that when I interact with the mob it exchanges my mother's item for another and this new item already comes with a selected lore, and it would also execute a command to save the mob as a structure and then delete the mob from the world.

untold magnet
#

i think bridge web is broken againbao_foxxo_sick

#

entity.getComponent isn't working at all

distant tulip
#

what component

untold magnet
#

all

#

nothing is working on bridge

distant tulip
#

what is it that is not working?

untold magnet
#

getComponent('allTypes')

distant tulip
#

don't work. as in game or what

untold magnet
#

const inv = entity.getComponent('inventory'). ← nothing is showing up

untold magnet
#

its fine in-game

#

is there anything else i can use to code a script for minecraft?
{ on mobile }

distant tulip
#

with auto complete you van use termux
waveplayz have some guides in the resource channel
other than that there is some simple code editors in the store

untold magnet
#

I'll do some searches

distant tulip
runic crypt
#

@distant tulip
i have a question
is it possible to use scripts to identify if an entity has a specific tag, then show its health in form of a bossbar ?

runic crypt
distant tulip
#

entity from view direction?

runic crypt
#

no i wanna make a custom boss (vanilla mob, but it shows a bossbar)

#

but it shows the bossbar only if it has tag "boss"

distant tulip
#

alr
give me a sec

runic crypt
#

oki thanks :D

woven loom
# distant tulip https://discord.com/channels/523663022053392405/1207044647919296612 <@2829655668...

there is this pkg called helix which is more cleaner than neovim setup

pkg -y i \
    helix helix-grammars \
    nodejs-lts

npm i -g typescript typescript-language-server

config at ~/.config/helix/config.toml

theme = "flexoki_dark"

[editor]
cursorline = true
cursorcolumn = true
auto-save = true
color-modes = true
completion-replace = true
# popup-border = "menu"

[editor.gutters]
layout = ["diagnostics", "spacer", "line-numbers", "diff"]

[editor.statusline]
left = ["mode","diagnostics","spinner", "file-name", "read-only-indicator", "file-modification-indicator"]
right = ["selections", "register", "position", "file-encoding"]
mode.normal = 'N'
mode.insert = 'I'
mode.select = 'S'

[editor.indent-guides]
render = true

[editor.lsp]
display-inlay-hints = true


[keys.insert]
C-s = [
    ":format",
    ":write"
]
C-S-s = "commit_undo_checkpoint"
C-q = ":quit"
C-c = "yank"
C-v = "paste_clipboard_after"
C-z = "undo"
C-y = "redo"
C-right = "indent"
C-left = "unindent"
C-f = "search"

"A-space" = "hover"
"A-r" = "rename_symbol"
"A-l" = "goto_reference"
"A-d" = [
    "goto_definition",
    "insert_mode"
]
"A-t" = "goto_type_definition"
"A-w" = "diagnostics_picker"
"A-a" = "code_action"
"A-f" = "select_references_to_symbol_under_cursor"
#

aslo @supple warren ^

#

the config is not complete yet but that is what i have rn

untold magnet
distant tulip
#

i have no idea
i am not using mobile

runic crypt
distant tulip
#

it is
i am sending a video
give it a second

runic crypt
#

oki thanks :D

distant tulip
#

@runic crypt


const distance = 45
const barLength = 20;
const empty = "█"
const full = "█"

system.runInterval(() => {
  world.getPlayers().forEach(player => {
    
    const entities = player.dimension.getEntities({
      tags:["boss"],
      maxDistance:distance,
      location:player.location,
      excludeNames:[player.name]
    });

    if(!entities.length) return;
    const bossBars = entities.map(entity => getHealthBar(entity))
    player.onScreenDisplay.setActionBar(bossBars);
  })
});


function getHealthBar(entity) {
  const health = entity.getComponent('health').currentValue;
  const maxHealth = entity.getComponent('health').effectiveMax;
  const healthPercentage = health / maxHealth;
  const filledLength = Math.round(barLength * healthPercentage);
  const emptyLength = barLength - filledLength;
  const filledBar = full.repeat(filledLength);
  const emptyBar = empty.repeat(emptyLength);
  const healthBar = `[§c${filledBar}§r${emptyBar}]`;  
  return `\n${healthBar} ${health}/${maxHealth} HP`;
}
runic crypt
#

but one more question

#

is it possible to make it like a bossbar ??

#

wait like this

#

made with this

#

add scoreboard objectives and setdisplay to sidebar

distant tulip
#

dose that support multiple entities?

runic crypt
#

see

#

i added score to a zombie and drowned

#

it worked

distant tulip
#

how dose it know the percentage

runic crypt
#

between 100 to 0

#

i set score and it reflects the score

distant tulip
#

let me see

runic crypt
untold magnet
#

i will clear termux data, and start it over

untold magnet
#

i can't do anything there

#

i already cleared up the app data, now im installing nodejs

woven loom
#

i hate nvim its too much to work with

untold magnet
#

I'll use nodejs

woven loom
#

wat?

untold magnet
#

but idk what should i do after installing it

woven loom
#

did you follow the cmds i gave

untold magnet
woven loom
#

if so then use hx file.js to open the editor

untold magnet
#

pkg -y i
helix helix-grammars
nodejs-lts

npm i -g typescript typescript-language-server
should i paste this first?

#

idk im completely lost

woven loom
#
  1. install the editor helix
  2. install the language sererv with npm
  3. setup the config
  4. use it
untold magnet
woven loom
#

remove -y

untold magnet
#

should i clear the app data again bec i installed nodejs?

woven loom
#

no need

untold magnet
#

alright its installing now

#

I really hate bridge website, it keeps glitching and sometimes removes my entire addon

woven loom
#

hm

untold magnet
#

i just need autocomplete tool for coding the addon,

#

bridge-v2 autocomplete is glitched

untold magnet
#

what next?

woven loom
#

set config

untold magnet
#

@untold magnet ← dumb person

#

~/.config/helix/config.toml?

woven loom
#
pkg i micro
mkdir -p "~/.config/helix/"
touch "~/.config/helix/config.toml"
micro "~/.config/helix/config.toml"
Ctrl+v
Ctrl+s
Ctrl+q
untold magnet
#

copy the whole thing and paste right?

woven loom
#

yes

untold magnet
#

done

runic crypt
#

@distant tulip
imma go skeep, when you figure it out, can you dm it to me ??

woven loom
#

install npm i @minecraft/server
then hx test.js
press i to start typing
write code and see auto completion
press ESC to exit insert mode

type :write to save :quit to quit @untold magnet

woven loom
#

you didnt set config ?

#

it should look black with config

untold magnet
distant tulip
# runic crypt <@704346785811923016> imma go skeep, when you figure it out, can you dm it to m...

just to be clear this is not multiplayer friendly
the first one above is


const distance = 45
const healthObj = world.scoreboard.getObjective('boss:health')??world.scoreboard.addObjective('boss:health','dummy');
world.scoreboard.setObjectiveAtDisplaySlot("Sidebar",{objective:healthObj});

system.runInterval(() => {
  world.getPlayers().forEach(player => {

    const entities = player.dimension.getEntities({
      tags:["boss"],
      maxDistance:distance,
      location:player.location,
      excludeNames:[player.name]
    });
    if(!entities.length) return;
    entities.forEach(entity => {
      healthObj.setScore(entity, getHealthBar(entity));
    })
  })
});


function getHealthBar(entity) {
  const health = entity.getComponent('health').currentValue;
  const maxHealth = entity.getComponent('health').effectiveMax;
  const healthPercentage = health / maxHealth;
  return healthPercentage*100;
}
runic crypt
#

and thanks :D

#

what are the modules needed ?
minecraft/server and ?

woven loom
#

this is how it looks with config

untold magnet
#

that means i haven't done the config one

#

~/.config/helix/config.toml?

woven loom
#

do ls ~/.config/helix

#

let me know what u have

untold magnet
#

nothing, somehow

runic crypt
#

@distant tulip
it works great !!
but how do i set the name above the bossbar ?
Like my mob is named §6§lEldrich God
how do i set it above the bossbar ??

distant tulip
#

🤷‍♂️

#

try nametag

untold magnet
woven loom
runic crypt
#

didnt work

untold magnet
woven loom
# untold magnet how tho?

copy config

micro "~/.config/helix/config.toml"

paste by doing ctrl+v
save by doing ctrl+s
exit by ctrl+q

untold magnet
#
ctrl+v
ctrl+s
ctrl+q```?
woven loom
#

those are diff steps

untold magnet
#

oh,

#

wait,

woven loom
#

micro "~/.config/helix/config.toml"

untold magnet
#

where did i go

woven loom
#

u copied? copy config

#

i sent

untold magnet
#

i think im so dumb

woven loom
#

paste this

# WavePlayz's config

theme = "flexoki_dark"

[editor]
cursorline = true
cursorcolumn = true
auto-save = true
color-modes = true
completion-replace = true
# popup-border = "menu"

[editor.gutters]
layout = ["diagnostics", "spacer", "line-numbers", "diff"]

[editor.statusline]
left = ["mode","diagnostics","spinner", "file-name", "read-only-indicator", "file-modification-indicator"]
right = ["selections", "register", "position", "file-encoding"]
mode.normal = 'N'
mode.insert = 'I'
mode.select = 'S'

[editor.indent-guides]
render = true

[editor.lsp]
display-inlay-hints = true


[keys.insert]
C-s = [
    ":format",
    ":write"
]
C-S-s = "commit_undo_checkpoint"
C-q = ":quit"
C-c = "yank"
C-v = "paste_clipboard_after"
C-z = "undo"
C-y = "redo"
C-right = "indent"
C-left = "unindent"
C-f = "search"

"A-space" = "hover"
"A-r" = "rename_symbol"
"A-l" = "goto_reference"
"A-d" = [
    "goto_definition",
    "insert_mode"
]
"A-t" = "goto_type_definition"
"A-w" = "diagnostics_picker"
"A-a" = "code_action"
"A-f" = "select_references_to_symbol_under_cursor"

untold magnet
#

oh, i completely forgot about it

#

now i click Ctrl+v and Ctrl+s and Ctrl+q right?

#

done

#

@woven loom still no autocorrectbao_block_missingtexture

woven loom
#

u installed types and grammers ?

untold magnet
#

what are these?

untold magnet
simple zodiac
#

maybe I should make a little guide on how to get vscode on android

last latch
# slow walrus it literally is fucking not but ok

well, i did some testing and we are both wrong:
I thought system.run delayed 1 Tick (which is wrong and only skips around 30 miliseconds, the currentTick stays the same) so we were both wrong
The Event Privilages have been changed in 1.20 so im right about it being new (proof #1116091026843635732 message)
And yes, since system.run executing code in the same tick it is not a big deal
But it is still sometimes a trouble.

distant tulip
last latch
# distant tulip

||it doesnt say how big of a delay but if sending this helps you, sure||

granite badger
#

the callback in the param runs in the next game tick

supple yoke
#

I can't seems for the life of me. find good nbt library for JavaScript

#

welp

#

it's rawdoggin binary time

#

sigh

woven loom
# untold magnet how?

pkg i helix helix-grammars nodejs-lts

npm i -g typescript typescript-language-server

simple zodiac
supple yoke
#

just get neovim or something

#

using vim is not that bad

woven loom
#

if he cant setup helix forget nvim

#

helix is the most easy to setup

simple zodiac
untold magnet
simple zodiac
#

If you like the customizability then yeh go for it

supple yoke
#

idk man haven't touched my config in a year lol

untold magnet
#

finally something useful more than bridge-glitch2

supple yoke
#

I spent like 3-4 hours on it

#

also I think most people use nvim because it's vim rather than the customizability of it

#

personally I use it because it's easy to install new lsp

untold magnet
#

oh, getComponent is broken here too

simple zodiac
#

nah, just stable autocompletions

wary edge
#

Stable doesnt have a map of components while beta does

untold magnet
#

i switched to termux one just for that getComponent

#

bec its just broken on bridge