#Script API General

1 messages · Page 63 of 1

formal delta
#

does anyone agree with this?:

// We need API like:
entity.navigateTo(location)
entity.queueNavigation(location)
chilly moth
#
world.beforeEvents.itemUse.subscribe((event) => {
    const { source:player, itemStack } = event;
    if (itemStack.typeId !== "minecraft:stick") return;
    const entity  = source.dimension.getEntities({type: "minecraft:cow", closest:1})[0]
{
    system.run(() => {
        oi(player)
    })
}

function oi() {
    const oi = new ActionFormData()
        .title("Special Offer!")
        .body(`Player id: ${source.id}\nCow Id: ${entity.id}`)
        .button("...")
      oi.show(source)
        .then(({ selection }) => {
        if (result.selection === 0) {
            uknowme(player);
        }    //..
        })
}
    });
#

error on const entity¿

distant tulip
#

what error

chilly moth
#

source anynomys

distant tulip
#

send the full error

chilly moth
#

[Scripting][error]-ReferenceError: 'source' is not defined at <anonymous> (gui/interact.js:9)

#

that's source not defined

chilly moth
distant tulip
#

function oi(source)

chilly moth
#

ok

chilly moth
wary edge
chilly moth
#

scope

chilly moth
#

error started on const entity sorce not defined

wary edge
#

💀 Why are you putting a function inside a subscribe event is beyond me.

chilly moth
#

it's works for my other form 😌

wary edge
#

Terrible.

chilly moth
#

so tried the same

#

but the error is not that

chilly moth
# wary edge Terrible.
world.beforeEvents.itemUse.subscribe((event) => {
    const { source:player, itemStack } = event;
    if (itemStack.typeId !== "minecraft:stick") return;
    const entity  = source.dimension.getEntities({type: "minecraft:cow", closest:1})[0]
{
    system.run(() => {
        oi(player)
    })
}

    });
#

still same error

wary edge
chilly moth
#

oh wait

#

still same error

#
    const entity  = source.dimension.getEntities({type: "minecraft:cow", closest:1})[0]
#

this line gives error

chilly moth
wary edge
#

You know what, please open a post.

#

And repost your problem there.

chilly moth
#

ok

#

it's for passing id for horse_renderer #entityid

prisma shard
# chilly moth ``` world.beforeEvents.itemUse.subscribe((event) => { const { source:player,...
world.beforeEvents.itemUse.subscribe((event) => {
    const { source: player, itemStack } = event;
    if (itemStack.typeId !== "minecraft:stick") return;
    const entity  = player.dimension.getEntities({ type: "minecraft:cow", closest: 1 })[0]
    system.run(() => {
        oi(player)
    });
});

function oi() {
    const oi = new ActionFormData()
        .title("Special Offer!")
        .body(`Player id: ${source.id}\nCow Id: ${entity.id}`)
        .button("...")
      oi.show(source)
        .then(({ selection }) => {
        if (result.selection === 0) {
            uknowme(player);
        }    //..
        })
}

@chilly moth take this

#

I fixed everything

chilly moth
#

ok let me try

prisma shard
wheat condor
#

can someone help me solving this strange issue?
basically the database works fine for me, but for other people, that got better specs than mine, creates a lot of lag
(read all the chat) #1252014916496527380 message

next fjord
#

Does anyone see any error in the following code? When I enter a world the game gives me an error:

#

Sorry I sent the file, but Discord won't let me paste the code because it's too long and I don't have Discord Nitro xd

#

.
The error that appears to me is the following:

[Scripting][error]-SyntaxError: Could not find export 'Vector' in module '@minecraft/server'```

[Scripting][error]-Plugin [§aEXPANSIVE NATURE V1.2 BP - 1.0.0] - [main.js] ran with error: [SyntaxError: Could not find export 'Vector' in module '@minecraft/server']```

dim tusk
next fjord
#

the manifiest :


{
  "format_version": 2,
  "header": {
    "name": "§aEXPANSIVE NATURE V1.2  BP",
    "description": "§bBy Yimmplay",
    "uuid": "14767ef3-6ddf-494c-9ecf-a857243b7ccf",
    "version": [
      0,
      0,
      1
    ],
    "min_engine_version": [
      1,
      21,
      60
    ]
  },
  "modules": [
    {
      "description": "§bBy Yimmplay",
      "type": "data",
      "uuid": "f81c088d-2a51-4530-871d-4539006c199f",
      "version": [
        0,
        0,
        1
      ]
    },
        {
            "type": "script",
            "language": "javascript",
            "uuid": "5e8cbccc-17c5-43b7-94a7-e21cdecdcaf9",
            "entry": "scripts/main.js",
            "version": [1, 0, 0]
        }
  ],
  "dependencies": [
      {
      "uuid": "7fdd5740-e53e-4bb4-8aeb-a7cd0892d52b",
      "version": [
        0,
        0,
        1
      ]
    },
        {
            "module_name": "@minecraft/server",
            "version": "1.17.0"
        }
  ]
}```
dim tusk
#

Either just use the normal math way or use a bundle.

next fjord
next fjord
dim tusk
granite badger
dim tusk
#

Mannn.. I was late

#

LMFAO

#

your website was done earlier...

next fjord
dim tusk
#

more details there....

next fjord
sterile epoch
#

like with how the host id is the same on worlds , is it the same on realms too?

distant tulip
granite cape
#

maybe this more faster looping then for (loop)?

const player_name = ["Nandog","Dimdog","Herdog","Ferdog"];
let length_ = player_name.length;
while(length_--) player_name[length_];
distant tulip
subtle cove
granite cape
distant tulip
#

it performance gains is context dependent

prime zenith
#

Whats the best way to prevent block placing since theres no before player places block

random flint
#

Adventure mode

prime zenith
#

Nope cant do that using addons i know theres a way

#

I made every block in gane thats not listed on my map entirely unbreakable

prisma shard
#

there is playerPlaceBlockBeforeEvent

prime zenith
#

There is cause its not shownn on scripting pages

prisma shard
prime zenith
#

Ok ty i didnt see this before

#

What parameters does it grab

#

Sweet no break no place and i got a debugger tool that i need only put in slot 9 to not be effected

round bone
jolly citrus
#

Is it possible to display blocks for only a specific player on bedrock dedicated servers using script API

#

Or in general, is it possible to only apply changes to the world or other things only to a specific client(s)? Can I somehow directly modify the packet data before it’s transmitted to the client maybe

wary edge
#

@ivory bough dont go fishing for help, especially in unrelated channels.

unique acorn
jolly citrus
safe stream
#

I'm reviewing some git repos to understand scripting and I'm noticing that people set blocks differently, is there a difference between these two?

world.getDimension("overworld").setBlockType("minecraft:stone");

world.getDimension("overworld").setBlockPermutation(BlockPermutation.resolve("minecraft:stone"));
hybrid island
#

how to get what items a block drops? (ofc using script api ) i am currently using a list of blocks and their drops is there a way to get all of them without a list or like a list with everything like block.getdrops() or something

#

can someone help? (100k 'th msg cool )

dim tusk
hybrid island
#

can you just answer

#

i saw that it was 99999 then it became 100k

dim tusk
#

also it's in the name itself, permutation you place a block with a permutation

#

But in your script you just place an ol' plain stone.

dim tusk
prisma shard
# dim tusk what...?
function chunkPos(location) {
  // get the relative position within that chunk
  return {
   x: Math.floor(location.x % 16),
   y: Math.floor(location.y % 16),
   z: Math.floor(location.z % 16)
  }
}```
this returns negative number..... which is wrong....
so someone said to modulus 15 instead of 16
#

it works but why and why should i do it

dim tusk
#

I don't get it tho, using 15 or nah will still return negative rho

#

modulo 15 is a value from 0 15

#

meh, don't ask me, I'm slow T math..

prisma shard
#

fixed

shut citrus
#

What different between setBlocktype and setBlockpermutation?

sharp elbow
prisma shard
gaunt salmonBOT
#

Suggestion for @prisma shard

Description
Simple tick event wrapper.

Credits
These scripts were written by Jayly#1397 on Jayly Discord

random flint
hidden perch
#

how to detect slot using js

woven loom
distant tulip
woven loom
#

ye

hidden perch
#

thanks lemme try it out

prisma shard
#

can i detect if the game is preview or release or beta

wary edge
prisma shard
#

import, and use it?

#

can u send me the doc of that

ivory bough
#

How to get the inventory of the player?

wheat condor
#

Smokey can i ask you why did you delete my message asking for help?

#

@wary edge

prime zenith
#

You ever get into that spot where you just finished a huge part of code and are now thinking now what should i tackle

wheat condor
prime zenith
#

I like my playerComp function no need to get components all the time 1 function and i put it all in a variable

chilly moth
#

block.dimension.runCommandAsync(/structure load ${structure} ${x + offset.x} ${y + offset.y} ${z + offset.z});

#

my structure s are in tree folder

#

how do I edit this?

#

tree/${structure} ?

wary edge
chilly moth
#

it's $

prime zenith
#

You know its still funny i prevented block placing but wood is the only block they will actually get

wary edge
# chilly moth it's $

I know...I'm giving you the ingame command. You just need to translate it to JS string literal.

prime zenith
chilly moth
prime zenith
#

To get a block interact event to work with all anvils do i need to explicitedly state all 3 damage types

ivory bough
#

How to store all the player's items from inventory in a variable and then temporarily remove all the items and then add them back

prime zenith
#

If your talking like it saves the utems for a safe area where you have no items while there that is possibly coddy helped me create a bank system i could tweak that a bit to make it so it creates another property removes all items saved to property when conditions a are nent then readds tonplayer when condition b is met

prime zenith
#

How do i make a video snippet on my computer

humble lintel
#

i use nvidia's app

prime zenith
#

Nvidia control psnrl?

humble lintel
#
import { world, ItemStack, Player, system } from '@minecraft/server';

interface Items {
    slot: number;
    itemStack: ItemStack;
}

let inventories: Map<string, Items[]> = new Map();

function withdraw(player: Player) {
    system.run(() => {
        const save = inventories.get(player.name);
        if (!save) return player.sendMessage('No Saved Inventory Found');
        const container = player.getComponent('inventory')?.container;

        if (!container) return;
        for (let item of save) {
            const slot = item.slot;
            const itemStack = item.itemStack;
            container?.setItem(slot, itemStack);
        }

        inventories.delete(player.name);
        player.sendMessage('Inventory Withdrawn');
    })
}

function deposit(player: Player) {
    system.run(() => {
        const container = player.getComponent('inventory')?.container;
        if (!container) return;
        let save = [];
        for (let slot = 0; slot < container.size; slot++) {
            const itemStack = container.getItem(slot);
            if (!itemStack) continue;
            save.push({ slot: slot, itemStack: itemStack });
            container.setItem(slot, undefined);
        }
        inventories.set(player.name, save);
        player.sendMessage('Inventory Saved')
    })
}

const prefix = '!';
world.beforeEvents.chatSend.subscribe(data => {
    const player = data.sender;
    const message = data.message;

    if (!message.startsWith(prefix)) return;
    data.cancel = true;

    switch (message) {
        case '!deposit':
            deposit(player);
            break;
        case '!withdraw':
            withdraw(player);
            break;
        default:
            player.sendMessage('Invalid Command');
    }
})
#

@ivory bough

humble lintel
prime zenith
#

I think i have geforce

humble lintel
#

yeah u can do alt+f9 to start recording and click it again to stop

#

then click alt+z and you'll see the overlay pop up u can see all ur recordings and stuff

#

should look liek this

#

on the left

prime zenith
#

I hit alt f9 said a supported game is req for this feature

humble lintel
#

oh?

#

click alt z

#

then go to settings video

#

and turn on desktop capture

prime zenith
humble lintel
#

u update ur graphics driver?

#

or nvidia app?

prime zenith
#

I believe so let me check

humble lintel
#

get the new nvidia app it was on beta before so maybe u have the old geforce now thing

#

app looks like this

prime zenith
#

1 sec there was a update button in the app

humble lintel
#

oh okay

prime zenith
#

Anyways i created something cool tho so im happy

humble lintel
#

nice 👍

prime zenith
#

ok i saved recording how do i share it

humble lintel
#

just click alt z

#

you can click the gallery open a vid and bottom left right next to trash can there's a folder icon

#

click it and drag ur clip into chat

prime zenith
#

crap its to big

humble lintel
#

yeah might have to record a quick one

#

or post it jere

prime zenith
#

69 mb kinky

humble lintel
#

nice

prime zenith
#

@humble lintel are you able to help me with the code you helped make i gotcquestions sndstuff

humble lintel
#

waht u need help with?

prime zenith
#

idk how to make animations 1 and 2 i need to learn it so i can get it to work with my built in systems

#

also chat gpt suggests i can make a exe file in my bp to get it to auto generate all the items.json i need

humble lintel
prime zenith
#

Can we voice chat

humble lintel
#

rn im just watching something about json ui

#

so maybe after if thats okay

prime zenith
#

Sure

#

Im going to eat im undecided if i want to build this exe thats a little out of mybrealm of knowledge or bite the bullet and build all items manually

unique acorn
prime zenith
#

Not python cause python is a bad language its easy to learn sure avoid using it tho

unique acorn
#

there is a bunch of languages

#

whatever you want really

prime zenith
#

If i use bridge i should put it in its project folder right

unique acorn
#

I don't think bridge. can run code, it's only an IDE

prime zenith
#

I know but it has a project folder which is a file

#

Explprer

unique acorn
#

oh I forgot bridge saves your project locally, well then you can do that

prime zenith
#

@unique acorn how hard is it to learn this cause as im going for it and software dev i want to understand the code that im running

fast lark
#

Im trying to take the xuid of a player with script but idk how

#

Ill do a post

prime zenith
#

i want a second pair of eyes before i let a exe file do stuff to my project

granite badger
#

A bit late but I added this feature for v1.21.60/70 packs, try it and see if it works - https://github.com/JaylyDev/interpreter/releases
You create a startup script via /function interpreter/starup or something like that (it has the word startup)

pale terrace
#

can we translate a .nameTag?

unique acorn
prime zenith
#

I know but the plan is to make it into an exe if i ever get the dame exe converter to work

unique acorn
#

you can run it using node? no need to go thru all the trouble of converting it to an exe

distant tulip
prime zenith
#

Thats what im foing now and its doing nothing

#

Im a dumbass

#

I forgot to save

unique acorn
#

it happens

prime zenith
#

Grr it didnt work im glad i ran it on a copied folder

fast lark
#

How can i take the xuid of a player in my bds by script??(ive tried sending a extenral request to a third party api that offer xbox name to xuuid but i still cant figure out how to do that)

#

At this point idk if someone can answer me lol

prime zenith
#

Grrrrrrr everything but updating the item_textures.json file works

prime zenith
#

i want someone other then ai help break down the risks when i use this in my real project and maybe fix its ability to update item_textures.js i want to avoid breaking my bp again

cinder shadow
#

Anybody have any damage detection system that is accurrate? When an entity dies entityHurt will always just be the damage dealt, not the actual damage dealt. My old system I used to correct this seems to have imploded and has some pretty big inconsistencies. After looking over my options, I've currently rewritten it to use the entityHealthChanged event to store the old health value, then system.run in the entityHurt event to get that value in the next tick before running all my calculations

prime zenith
#

you could run a check on its hp before i mean i run my hp threw scoreboards replacing vanilla you could try that

cinder shadow
#
world.afterEvents.entityHealthChanged.subscribe((eventData) => {
    const entity = eventData.entity
    entity.__oldHealthValue = eventData.oldValue;
})

world.afterEvents.entityHurt.subscribe((eventData) => {
    const damageSource = eventData.damageSource;
    const hurtEntity = eventData.hurtEntity;
    const damage = eventData.damage;

    const cause = damageSource.cause;
    const damagingEntity = damageSource?.damagingEntity;
    const health = hurtEntity.getComponent('minecraft:health').currentValue;

    system.run(() => {
        world.sendMessage(`DAMAGE:${damage} HEALTH: ${health} PREVIOUS HEALTH: ${hurtEntity.__oldHealthValue}`);
    })
})```
cinder shadow
#

so then you're left with trying to find a way to store the previous health value

prime zenith
#

give it a health score that is equal to its health you can use logic so when its hit it checks its score before it sets it

cinder shadow
#

my old system was setting temporary properties in every single player spawn/entity load event first and running off that

prime zenith
#

i have a way more complex system due to the fact i gutted vanilla hp so i know scores works as i had to make sure the skill xp i get doesnt give more then remaining

cinder shadow
#

I mean the simplest solution is to just not use a temporary property that gets reset on reload

#

then the health value will always be correct and will get set appropriately on the first hit

#

I'm just being stubborn and don't want to save that data

prime zenith
cinder shadow
#

just make a copy of it

prime zenith
#

I already tested it on a copy but i want to be sure tgeres not in game logic i may break

cinder shadow
#

then paste it back into your add-on location and test it

prime zenith
#

Can i detect air in a break or interact block event if each elemental alter is opened by interacting with a block of its element in a certain area air is kind of hard

prisma shard
#


system.runInterval(async () => {
    for (const player of world.getAllPlayers()) {
        const { x: locX, y: locY, z: locZ } = player.location;
        system.runTimeout(() => {
            player.onScreenDisplay.setActionBar(`Position: ${Math.trunc(locX)}, ${Math.trunc(locY)}, ${Math.trunc(locZ)}`);
        }, 2);
    }
});```
Why is the position not acccurate with actual player coordinates shown on the hud screen?
wary edge
loud brook
#

Guys, is it possible to detect if the item is a melee item?

#

e.g. swords, mace, etc

prisma shard
loud brook
#

I tried using hasComponent('minecraft:can_destroy_in_creative')

#

but it always run false

hidden perch
prisma shard
prisma shard
dim tusk
loud brook
#

Then any ideas?

dim tusk
loud brook
dim tusk
#

Pls check docs

loud brook
#

I mean which part docs do I find them in?

prime zenith
#

@dim tusk hey coddy when you have time can you review some code for me snd figure out why 1 part isnt working

prime zenith
#

Its not necesarrily a minecraft script its a file manipulation script ill dm you it

prisma shard
#
let lastTime = Date.now();
let tickCount = 0;

function updateTPS() {
    let currentTime = Date.now();
    let timeDifferenceInSeconds = (currentTime - lastTime) / 1000;
    let tps = tickCount / timeDifferenceInSeconds;
    tickCount = 0;
    lastTime = currentTime;
    return tps.toFixed(2);
}
function tickHandler() {
    tickCount++;
    if (tickCount % 20 === 0) {
        updateTPS();
    }
}

system.runInterval(async () => {
    for (const player of world.getAllPlayers()) {
    player.onScreenDisplay.setActionBar(`TPS: ${tickHandler()}`)
}
})

why does this not work
shows error
'not a valid function'
I used this TPS counter
and it shows error

prime zenith
#

its javascript

prisma shard
prime zenith
#

it want letting me dm

#

for the safety of the future never use python

dim tusk
# prime zenith

Wait... This isn't Minecraft script? Just general accessing files using javascript?

prime zenith
#

yes

#

it adds the files it adds the textures it will not update items_textures.json

distant tulip
#

off topic

prisma shard
#

can u see what the issue

prime zenith
#

its still a script its still used for my minecraft bp just not in minecraft

dim tusk
#

Anyways. I'll just go in dms

distant tulip
prisma shard
#

ah

prime zenith
#

still theres no general scripting channel so this is the only channel where ppl are likly to even know

dim tusk
prisma shard
#

wahat

prisma shard
dim tusk
# prisma shard i try in minecrafft
let lastTime = Date.now();
let tickCount = 0;
let currentTPS = 0.00;

system.runInterval(() => {
    const currentTime = Date.now();
    const timeDiffSec = (currentTime - lastTime) / 1000;
    currentTPS = tickCount / timeDiffSec;
    tickCount = 0;
    lastTime = currentTime;
}, 20);

system.runInterval(() => {
    tickCount++;
    for (const player of world.getAllPlayers()) {
        player.onScreenDisplay.setActionBar(`TPS: ${currentTPS.toFixed(2)}`);
    }
});```
prisma shard
#

3 runIntervals

#

ahhhhhhh

#

what a feel

prisma shard
dim tusk
prisma shard
#

yess

#

i finally make debug screen in minecraft bedrock!

#

its a big script

#

after lot of days finnaly i made it

#

now i have to just do the JSON UI part

#

then i'll be done making this addon

ivory bough
unique acorn
ivory bough
shut citrus
#

how to get item variants?

#

like leave block variants

hybrid island
#

how to get all enchants / specific enchant on a item in the player's hand and the level

distant tulip
# hybrid island how to get all enchants / specific enchant on a item in the player's hand and th...
import { world, EquipmentSlot} from "@minecraft/server";

world.afterEvents.itemUse.subscribe((event) => {
    const player = event.source;
    const item = player.getComponent("minecraft:equippable")?.getEquipment(EquipmentSlot.Mainhand);
    if (!item) return

    const enchantComp = item.getComponent("minecraft:enchantable");
    if (!enchantComp) return

    let enchantments = enchantComp.getEnchantments();

    for(const enchantment of enchantments){
        player.sendMessage(`enchantment: ${enchantment.type} | level: ${enchantment.level}`)
    }
});

hybrid island
unique acorn
# hybrid island how to get like a specifc one like only fortune and its levl
import { world, EquipmentSlot } from "@minecraft/server";

world.afterEvents.itemUse.subscribe((event) => {
    const player = event.source;
    const item = player.getComponent("minecraft:equippable")?.getEquipment(EquipmentSlot.Mainhand);
    if (!item) return;

    const enchantComp = item.getComponent("minecraft:enchantable");
    if (!enchantComp) return;

    let fortune = enchantComp.getEnchantment("fortune");
    if (!fortune) return;
    const fortuneLevel = fortune.level;
});

jolly citrus
#

ehh What is this type error supposed to mean

Argument of type 'import("c:/Users/xxshe/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/Geki Core V1.0/node_modules/@minecraft/server/index").Player' is not assignable to parameter of type 'import("c:/Users/xxshe/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/Geki Core V1.0/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/index").Player'.
  The types of 'camera.setCamera' are incompatible between these types.
    Type '(cameraPreset: string, setOptions?: CameraDefaultOptions | CameraFixedBoomOptions | CameraSetFacingOptions | ... 4 more ... | undefined) => void' is not assignable to type '(cameraPreset: string, setOptions?: CameraDefaultOptions | CameraSetFacingOptions | CameraSetLocationOptions | CameraSetPosOptions | CameraSetRotOptions | undefined) => void'.
      Types of parameters 'setOptions' and 'setOptions' are incompatible.
        Type 'CameraDefaultOptions | CameraSetFacingOptions | CameraSetLocationOptions | CameraSetPosOptions | CameraSetRotOptions | undefined' is not assignable to type 'CameraDefaultOptions | CameraFixedBoomOptions | CameraSetFacingOptions | CameraSetLocationOptions | CameraSetPosOptions | CameraSetRotOptions | CameraTargetOptions | undefined'.
          Type 'CameraSetFacingOptions' is not assignable to type 'CameraDefaultOptions | CameraFixedBoomOptions | CameraSetFacingOptions | CameraSetLocationOptions | CameraSetPosOptions | CameraSetRotOptions | CameraTargetOptions | undefined'.
            Type 'import("c:/Users/xxshe/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/Geki Core V1.0/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/index").CameraSetFacingOptions' is not assignable to type 'import("c:/Users/xxshe/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/Geki Core V1.0/node_modules/@minecraft/server/index").CameraSetFacingOptions'.
              Types of property 'facingEntity' are incompatible.
                Type 'Entity' is missing the following properties from type 'Entity': extinguishFire, lookAt, playAnimation, setDynamicProperties, setOnFirets(2345)

it comes from player in form.show(player) here

show(player: Player) {
        const form = new ActionFormData()
            .title(this.#titleText);
        this.#buttonArray.forEach(button => {
            form.button(button[0], button[1]?.toString());
        })
        return form.show(player)
    }
raven mica
#

how to make a spreading mob (plant like mob that spreads 10 blocks nearby to infected grass or infected sand and spawns ants every 60 seconds also it can spawn different new types mobs depending on how many blocks it has spreaded)

#

don't add explanation plsss

valid ice
valid ice
#

Okey dokey

jolly citrus
#

i somehow had a separate node_modules folder with @minecraft/server inside the server-ui folder inside node_modules

#

...

#

went to the directory through file explorer manually and perma deleted it

valid ice
#

Ah interesting lol

jolly citrus
#

@valid ice , what is the purpose of these @internal type tags in your chestform pack?

class ChestFormData {
    #titleText: string; #buttonArray: Array<[string, undefined | string | number]>;
    constructor(size = 'small') {
        const sizing = (sizes.get(size) ?? [`§c§h§e§s§t§s§m§a§l§l§r`, 27]) as [string, number];
        >> /** @internal */ <<
        this.#titleText = sizing[0];
        >> /** @internal */ <<
        this.#buttonArray = [];
        for (let i = 0; i < sizing[1]; i++) {
            this.#buttonArray.push(['', undefined]);
        }
    }
valid ice
#

Just that they can’t be accessed outside of the class definition

jolly citrus
valid ice
#

The comment stops it from autocompleting

#

The # before the variable makes it private (doesn’t hide it from autocomplete)

jolly citrus
#

ah okay

wintry valve
#

guys

#

does too many system.runIntervals cause lag?

#

like if I have 20 system.runIntervals, will that cause a noticeable amount of lag?

sharp elbow
#

Depends on what they are doing.

#

The actual execution of the interval won't cause any noticeable overhead.

#

But if your function is doing something expensive, then sure.

valid ice
#

If timing isn’t terribly important, you can look into using runJob & generator functions to break up code over multiple ticks

ivory bough
#

How to detect doors every 20 ticks without crashing my game( I basically wanna want to detect doors if in range of player then have a random chance to do stuff if door is found )

cinder shadow
#

Does anyone know why applyDamage wouldn't be firing at all? it's being completely skipped over in execution

cinder shadow
cinder shadow
# cinder shadow Does anyone know why applyDamage wouldn't be firing at all? it's being completel...
 if (!entity.hasComponent('minecraft:item') && entity.typeId != 'minecraft:xp_orb') {
                world.sendMessage(` before : ${entity.getComponent('minecraft:health').currentValue}`);
                world.sendMessage(`Damage with retribution ${player.name}`)

                entity?.applyDamage(damage, { cause: 'magic', damagingEntity: player })
                system.run(() => {
                    world.sendMessage(`after : ${entity.getComponent('minecraft:health').currentValue}`);
                })
            }```
prisma shard
#

i just do a ping, and they get disturbed and tends to just reply the question lol

cinder shadow
cinder shadow
#

for applying damage

prisma shard
#

Hmmm

cinder shadow
#

It normally works if I die normally, but if I use a large explosion at a location and then try and apply damage afterwards it never applies

cinder shadow
#

Apply damage can't go past that?

wary edge
cinder shadow
#

I didn't even think about that

#

Well shoot

wary edge
#

#879773489601585244 message

cinder shadow
#

Did you test any causes?

wary edge
#

I dont think causes bypasses iframes.

cinder shadow
#

Well thanks anyways 3 days of wasted time lol

#

Completely forgot about that

rose light
#

Is it possible to detect if an entity has broken a block?

sterile epoch
#

how do i get all tags on a world

dim tusk
sterile epoch
#

yes. example: input was a tag someone who isn't in the game has but it exists, how do I get that tag?

#

because I'd like to validate if the tag exists on the world

fast lark
#

Can i show case an minecraft-discord addon?

#

Nothing special

dim tusk
dim tusk
#

Unless you store it's data in a storage like dynamic property

jolly citrus
#

can i update my scripts using /reload if i'm working with typescript

dim tusk
fast lark
#

No wait

#

Peep

jolly citrus
#

i so confused why ius it so hard to set the project up smh 💔

#

so do i have to run npm run local-deploy every time i update my pack ..

shut citrus
jolly citrus
#

is there any way to create global variables

dim tusk
#

Guys why does this throw an error? durability.getDamageChanceRange().max??

#

it works with damage or maxDurability but this one it doesn't.

dim tusk
#

did you make it work?

wary edge
dim tusk
wary edge
#

Havent tried in a while tbh.

shut citrus
wary edge
shut citrus
#

like leave block variants

#

to use replace command

wary edge
#

They should be flattened so...just use the block id.

shut citrus
wary edge
shut citrus
#

replaceitem

dim tusk
prime zenith
#

What do ppl here know about bds and use of databases with them to keep players stuff safe but off of minecraft itself to both improve performace and allow multi worlds

dim tusk
#

This is goofy but it works lmfao.```js
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {
console.error('Message sent:', message);
console.error('Sent by:', sender.name);

if (message.includes('coddy')) {
ev.cancel = true;
console.error('Lezz Go!');
}
});```

prime zenith
#

Ooh you answered a question before i asked it i was about to ask if you can detect a players message and how that answered me by accident

#

Unless coddy is a psychic
@dim tusk are you a paychic

zealous wing
#

@wary edge hey, I have been awol for a while, did they ever fix the /place running from scripts issue?

wary edge
zealous wing
#

Oh cool, is place api release or beta?

dim tusk
zealous wing
wary edge
zealous wing
#

Cool, not sure if I am ready to jump back in yet, but these new changes definitely help get the motivation going.

dim tusk
prime zenith
#

I knew that

#

You should do console.warn to seperste from errors

#

@dim tusk what do you know about bds

dim tusk
dim tusk
prime zenith
#

I found out theres a way to put a database to a server that allows you to store values outside of minecraft and even allow multi world syncing

ivory bough
shut citrus
bright dove
#

does getComponent work on custom ones ?

unique acorn
dim tusk
#

Also guys, what's does getAllStates() looks like.

#

like the object if returns? js { "<id>": <value>, "<id>": "<value>" }

#

this?

dim tusk
#

Damn nvm.

dim tusk
#

This is getting out of hand ngl.js const { container: { size, emptySlotsCount } } = inventory;

jolly citrus
#

what does using unsupported runtime []. mean

#

i dont have ts scripts in my pack!!! wtf!!!!!

distant tulip
shut citrus
#

what different between block.permutation.getAllStates() and BlockPermutation.resolve(blockId).getAllStates()

#

it's too confused

jolly citrus
#

i have a file like this Commands.d.ts:

import { Player, world } from "@minecraft/server";
import { CustomPlayer } from "../CustomPlayer";

export type CommandParam = { name: string; type: string; optional: boolean };

export type Command = {
  name: string;
  params: Array<CommandParam>;
  aliases: Array<string>;
  requiredRank: number;
  callback: Function;
};

export class Commands {
  _commands: Map<string, Command>;

  /**
   * Registers a command.
   * @param {string} name - The primary name of the command.
   * @param {string} prefix - The prefix of the command.
   * @param {string} params - The parameter definition string.
   * @param {Array<string>} aliases - Alternative names for the command.
   * @param {number} requiredRank - The required rank to run the command.
   * @param {Function} callback - The function to execute when the command is run.
   */
  registerCommand(
    name: string,
    params: string | null,
    aliases: Array<string>,
    requiredRank: number,
    callback: Function
  ): void;
}

and i wanna use these docs in Commands.ts, but i can't seem to be able to import any part of it, why

jolly citrus
#

im so confused bro

jolly citrus
#

is there any universal event that runs when you finish interacting with an item? itemCompleteUse only works for items that you actually do have to hold, it won't detect e.g. an ender pearl click, but itemUse will instantly fire when you begin interacting with a golden apple for example

jolly citrus
#

where do i find the debug log file that's generated when u debug scripts that tells u how many ms it took to complete different actions etc.

#

found it

jolly citrus
#

HOW DO I NOT HAVE

#

CHATSEND ON BEFOREEVENTS

#

im using 1.18.0-beta

sharp elbow
#

Are your typings using 1.18.0-beta?

jolly citrus
#

nvm they not

#

i think

sharp elbow
#

Can't hurt to double-check the package.json and run npm i

jolly citrus
#

package.json says 1.17.0

chilly moth
#
.getDynamicProperty("mob") == true) {

is it like
const mob=[
minecraft:wolf]

?

jolly citrus
#

what

#

dynamicproperties never have any values set to them by default

#

use components

#

ur supposed to set the value of dynamic properties urself

chilly moth
#

wdym

jolly citrus
#

what you're looking for is probably components

#

if u wanna know if an entity is a mob

chilly moth
#

I want to get list of mobs to work with

jolly citrus
#

or whatever ur trying to do

jolly citrus
#

huh im so confused

chilly moth
#

and save tgem

sharp elbow
jolly citrus
#

ur code snippet is a bit

#

^

#

yeah

chilly moth
#

save mob info like tame etc

jolly citrus
#

cant tell what ur actually trying to do

#

send more code

sharp elbow
#

Ah, like component info?

chilly moth
#
                        try {
                            mc.world.structureManager.place(`${item.getDynamicProperty('stored_structure')}`, dimension, location)
                            item.setDynamicProperty("mob", false)
                            mc.world.structureManager.delete(item.getDynamicProperty("stored_structure"))
                        }```
sharp elbow
#

And how should this relate to getting a list of mobs (like wolves) to work with?

#

I guess I am asking, what are you making

jolly citrus
#

what is this supposed to mean

chilly moth
jolly citrus
chilly moth
#

summon a mob and save it's data like name etc and the same mob will spawn when summoned again

sharp elbow
#

And are you (wanting to) using dynamic properties on an item to hold this mob information?

#

Or it seems like you are using structures to summon the mob in again

somber cedar
prisma shard
#

HI

#

ops caps lock

viral mirage
#

Is there any way to make custom commands in a stable API? Like just a !something that runs a function?

unique acorn
viral mirage
unique acorn
#

scriptevent needs operator

viral mirage
#

Thanks anyway

jolly citrus
#

What would be the most compact way (string length-wise) to store sets of 3-dimensional coordinates as a string

scenic bolt
#

Anyone know how to get the exact x y z coordinates of a blocks location using block.location.

I need to get the exact value

unique acorn
jolly citrus
scenic bolt
jolly citrus
#

block.center() maybe ??

scenic bolt
unique acorn
scenic bolt
#

because using block.location doesn’t get me the coordinates it returns object object

jolly citrus
scenic bolt
jolly citrus
#

coordinates for blocks are always integers

hexed fox
#

Why its dont work&

jolly citrus
#

const { x, y, z } = block.location;

hexed fox
#

?

jolly citrus
hexed fox
scenic bolt
unique acorn
jolly citrus
#

plus, i said i need it to be as compact as possible

scenic bolt
#

Is there a way I could get the values with just spaces in between and no commas, because I need to use this for a teleport command

jolly citrus
#

i don’t believe vector3 holds any less data than a comma-separated string representation of one’s coordinates does

wary edge
jolly citrus
#

theres no way that’s as compact as it gets, though

#

even x,y,z|… would be better

scenic bolt
#

ok I thought of something

#

it worked

#

awesome

jolly citrus
scenic bolt
#

No I got it

jolly citrus
#

but it’s good that ur implementation worked

scenic bolt
#

Its for connecting two teleporters together, I needed a way to get the location

jolly citrus
#

can i ask why you’re using a teleport command instead of just Entity.prototype.teleport(…)

scenic bolt
#

I am using entity.teleport not a command, I just mix up my words sometimes

jolly citrus
#

a ok

scenic bolt
#

Very frustrating getting these two teleporters to connect lol

wary edge
jolly citrus
#

I can also store it across multiple identifiers maybe

#

Like three groups

#

That’d already get me to a limit of around 7,000 storeable sets of coordinates

jolly citrus
#

and it’d be best if they couldn’t spoof those values by purposefully placing down big diamond veins

#

2nd option is that I somehow precompute the values of naturally generated diamond ores’ locations & save them inside a map within my script, and store mined ore locations inside dynamic properties instead

prime zenith
#

srry wrong room

distant tulip
pale terrace
#

is there a custom component for blocks that fires when the world initialize?

#

I want to send block locations to a Map, but maps restart on server close

#

I know there are dynamicProperties, but Map are fasters

pale terrace
#

F

rigid torrent
#

How can I slow down players when they step on a block like soul sand

dim tusk
rigid torrent
#

Thanks!

#

Best way to do it?

#

runInterval sounds creepy

dim tusk
rigid torrent
#

oh god

dim tusk
# rigid torrent oh god

also remember that when you sprint it resets it to default value means it looks glitchy visually

rigid torrent
dim tusk
rigid torrent
#

What about the onstep custom component thing is that an option for runInterval?

dim tusk
rigid torrent
#

That's fine that's what I want it for

#

excellent

young swan
#

ItemDurabilityComponent having issues in version 1.21.62 script 1.17.0?

young swan
#

Yeah, it looks like Mojang messed up the scripts (again).

mc.world.afterEvents.itemUse.subscribe((event) => {
    let itemStack=event.itemStack
    let Durability=itemStack.getComponent(mc.ItemComponentTypes.Durability)
    let Cooldown=itemStack.getComponent(mc.ItemComponentTypes.Cooldown)
    let Enchantable=itemStack.getComponent(mc.ItemComponentTypes.Enchantable)
    let Compostable=itemStack.getComponent(mc.ItemComponentTypes.Compostable)
    let Food=itemStack.getComponent(mc.ItemComponentTypes.Food)
    let Components=itemStack.getComponents()
    console.warn(itemStack.typeId)
    console.warn(Components.length)
    console.warn("Durability:", Durability)
    console.warn("Cooldown:", Cooldown)
    console.warn("Enchantable:", Enchantable)
    console.warn("Compostable:", Compostable)
    console.warn("Food:", Food)
})
young swan
wary edge
#

Works for me for custom.

young swan
#

I'm screwed, I have an item that needs this, and it doesn't work :d

rapid nimbus
#

Hey, everyone

#

Is there a script that shows the title when going through biomes and dimensions? (I make a Traveler's Titles Bedrock addon)

loud brook
loud brook
hybrid island
#

System.timeout

    system.runTimeout(() => {
        floatingText.remove();
    }, 9999999999);

im trying to remove a floatingtext which shows the damage i dealt a mob but it removes it too fast i dont know what it is it says its in ticks i even tried 5000000 still removed too fast

jolly citrus
#

and only then delaying the next iterations

#

but i don’t tihnk that should happen cos it seems quite identical to runInterval in that case

honest spear
#

show more context please

#

also 99999999 could be the problem as it might not be real number

jolly citrus
#

^

#

might be capped at 2 million iirc

#

2000000

honest spear
#

there is no reason for 2 000 000

jolly citrus
acoustic basin
#

hey guys! i need some help!
i'm trying to make it so when my dagger reaches the end of it's durability, when it's about to be break, it gets replace with a dagger hilt, i've tried doing something like this, but it doesn't work, any ideas?

onBeforeDurabilityDamage({ itemStack, attackingEntity }) {
            const durability = itemStack.getComponent('minecraft:durability')
            const equipment = attackingEntity.getComponent('minecraft:equippable')
            const hilt = equipment.setEquipment('Mainhand', new ItemStack('v360:dagger_hilt', 1))
            if (durability.damage === durability.maxDurability) {
                hilt
            }
        }```
dim tusk
# rapid nimbus Yeah
import { BiomeTypes, system, world } from "@minecraft/server";

function getBiome(location, dimension) {
    let closestBiome;

    for (const biome of BiomeTypes.getAll()) {
        const biomeLocation = dimension.findClosestBiome(location, biome, { boundingSize: { x: 64, y: 64, z: 64 } });
        
        if (biomeLocation) {
            const dx = biomeLocation.x - location.x;
            const dy = biomeLocation.y - location.y;
            const dz = biomeLocation.z - location.z;
            const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
            
            if (!closestBiome || distance < closestBiome.distance) closestBiome = { biome, distance };
        }
    }

    if (!closestBiome) throw new Error("Could not find biome within the given location");

    return closestBiome.biome;
}

const player = world.getPlayers()[0];
system.runInterval(() => {
    const biome = getBiome(player.location, player.dimension);
    player.onScreenDisplay.setActionBar(biome.id);
});```
hybrid island
acoustic basin
honest spear
hybrid island
honest spear
#

the question is what you are doing wrong

#

i don't even know what you are doing

#

code you send is valid and propably never executed

#

so thats not the problem

hybrid island
#
world.afterEvents.entityHurt.subscribe((event) => {
    const victim = event.hurtEntity;
    const attacker = event.damageSource.damagingEntity;
    const damage = Math.floor(event.damage);

    if (!victim || !attacker || damage <= 0) return;
    if (attacker.typeId !== "minecraft:player" || victim.typeId === "minecraft:player") return;

    // Generate a random offset for floating text position
    const randomOffsetX = (Math.random() - 0.5) * 1.5;
    const randomOffsetZ = (Math.random() - 0.5) * 1.5;
    const spawnLocation = {
        x: victim.location.x + randomOffsetX,
        y: victim.location.y + 1.5,
        z: victim.location.z + randomOffsetZ
    };

    // Spawn floating text entity
    const floatingText = world.getDimension("overworld").spawnEntity("floating:text", spawnLocation);
    floatingText.nameTag = `§4-§c${damage}§c HP`; // Red damage text

    // Auto-despawn after 1.5 seconds (30 ticks)
    system.runTimeout(() => {
       floatingText.remove();
    }, 4294967295);
});
#

i asked chatgpt for help thats why there are so many comments

honest spear
#

first of all,you code is not cross dimension, so it doesn't works in nether

hybrid island
#

ya ik

honest spear
#

also is it even showing for a sec? Or its not even showed

hybrid island
#

it shows

#

but delets very fast

honest spear
#

maybe you have other code that kills all these entities or something

#

the problem is not runTimeout, but if you think so then don't remove the entity at all so thats the proof of debug

hybrid island
#

lemme try debugging

honest spear
#

thats what you could do in the first place, before asking 😅 thats how programming works its more of debug than actual coding

hybrid island
#

only does debug 1

honest spear
# hybrid island only does debug 1

yea, so thats the proof, the entity is not deleted in runTimeout so you have to find different code that does kills entities or removes

hybrid island
#

it randomly starts working idk

humble lintel
acoustic basin
untold magnet
#

hmm, is it possible to change the block permutation when its in the inventory of the player?

untold magnet
# dim tusk no.

then, is it possible for the bone visibility be able to use (q.is_enchanted)?

dim tusk
untold magnet
dim tusk
#

why not just create an item to be able to show that glint.

untold magnet
#

( detecting if the item is enchanted, saving the item name / lore / durability / enchants and replace the item with a new enchanted one and apply all of those information to it )

dim tusk
#

I think you knew that there's a glint component right?

untold magnet
#

and still doesn't have the enchanted glint

dim tusk
untold magnet
dim tusk
untold magnet
#

yes,

dim tusk
#

nono that ain't possible if you're using a block model alone.

untold magnet
#

( replace block item ) thing

dim tusk
untold magnet
#

the item is enchanted but the model is not,

dim tusk
#

model and the glint isn't connected at all.

#

You need to create own.

untold magnet
dim tusk
untold magnet
#

( for the block )

dim tusk
#

if you want to somewhat make your life harder? Make an animated block texture.

dim tusk
#

I said it many times but I guess you don't listen.

untold magnet
untold magnet
wary edge
#

This is getting off topic.

dim tusk
untold magnet
dim tusk
untold magnet
untold magnet
acoustic basin
#

is there a way to cancel item from losing durability when hitting an entity?

rapid nimbus
dim tusk
acoustic basin
#

+= reduces it, and what puts it back...

dim tusk
acoustic basin
hybrid island
#
let scrolltype = scrolls.get(scroll);

greatest code in history

jolly citrus
#

erm what is this supposed to mean

type ArmorSet = Record<"Head" | "Chest" | "Legs" | "Feet", keyof typeof MinecraftItemTypes>;

^ type of the object the pair is in

jolly citrus
#

can i give effects w/ inf duration through scripts

hexed fox
unique acorn
unique acorn
hexed fox
#

@unique acorn

unique acorn
# hexed fox

@minecraft/server-ui should be 1.4.0-beta or 1.3.0

#

and what did you name the javascript file

unique acorn
hexed fox
#

also dont working now, I try 1.3.0 and 1.4.0-beta

#

2.0.0-alpha also

unique acorn
#

did you leave and rejoin the world

hexed fox
#

okey

hexed fox
#

Can I DM you?

unique acorn
#

sure

normal aurora
#

Anyone running a public bedrock server ?

distant tulip
#

can someone confirm that .addRider(entity) work?
i have the same code, one with .addRider() and the other with ride command, .addRider() didn't work while the command did

#

also, getRiders return empty array...

safe stream
#

Is there a way to check if the source (player) is the owner (tamer) of the entity that's being interacted with? I'm using afterEvents.playerInteractWithEntity

safe stream
#

yes!! this is exactly what I needed. Thank you!

jolly citrus
humble lintel
#

anyone know a good editor on mobile for behaviour packs

#

I can't seem to get typings from bridge editor on my browser

#

im on ios

jolly citrus
#

scripts/Classes/Archer.ts:9:7: ERROR: Could not resolve "../GeneralTypes"
scripts/Classes/Bard.ts:9:7: ERROR: Could not resolve "../GeneralTypes"
scripts/Classes/Rogue.ts:9:7: ERROR: Could not resolve "../GeneralTypes"

why am i gettting these errors when deploying my ts scripts

random flint
#

I don't know ts or what the error means. But are you sure the file path is correct?

humble lintel
#

^

jolly citrus
#

I’m hovering over it

jolly citrus
humble lintel
#

how are you compiling it

true isle
#

does onStepOn work if the block doesnt have a collision?

thorn flicker
true isle
#

so no way to replicate the berry bush?

wary edge
thorn flicker
#

or in system runInterval, get all entities, check if the block type at the entity's location is the bush.

dim tusk
#

I'm not kidding that's the name.

thorn flicker
dim tusk
thorn flicker
#

-# yes

#

-# yes not #- yes

true isle
#

not sure what i did but it just flips my block lmao

true isle
#

its supposed to give the wither effect

#

my other block works for that so idk whats going on lmao

dim tusk
#

Just restart your Minecraft I guess

thorn flicker
#

why would it transform his block though

dim tusk
#

I dunno, Minecraft thing? I can't really judge since I don't have the block.json

thorn flicker
#

I wasn't really asking

#

lol

true isle
#

pfft *makes it a feature

true isle
#

yep

dim tusk
#

if yes then it's probably fixed in preview

dim tusk
distant tulip
dim tusk
thorn flicker
distant tulip
#

yeah to both? it is for marketplace

true isle
#

well im not really sure i used both for testing so it doesnt work in the preview but flips in stable so im not sure

thorn flicker
#

my game did crash though and had to find a work around.
dont try to spawn things and make it ride an entity as soon as it spawns..

true isle
#

game crashes every time i try to edit it

#

nice

distant tulip
dim tusk
#

I'm bored I'm making a land claim

distant tulip
#

i guess i will use EntityRidingComponent and make my own

#

lets hope that one is not broken too

thorn flicker
#

ive used that aswell

distant tulip
dim tusk
#

ohh yeah imma check that again, so I'll be back.

dim tusk
#

I have many backlogged

#

the stats, chess, vanilla doors, etc.

distant tulip
#

i have only one lol

dim tusk
#

I don't find it interesting to release it since I'm pretty sure people won't use it

#

so yeah.
-# demotivation 101

distant tulip
#

meh, i don't give much though on what people say
i discontinued this even tho people really loved it, it is really buggy and it code i a mess
after the 4th re work, i dropped it

dim tusk
dim tusk
#

It doesn't crash on me @thorn flicker

distant tulip
# dim tusk ```js world.beforeEvents.itemUse.subscribe(({ itemStack, source }) => { if (it...

yeah

function getRiders(entity) {
    const entities = [];
    const closestEntities = entity.dimension.getEntities({ location: entity.location, maxDistance: 1});
    for (const closestEntity of closestEntities) {
        const ridingComponent = closestEntity.getComponent(EntityComponentTypes.Riding);
        if(!ridingComponent) continue;
        const ridingOn = ridingComponent.entityRidingOn;
        if(ridingOn === entity) entities.push(ridingOn);
    }
    return entities;
}
dim tusk
#

oh yeah before you say it's not a preview, yes it is, I just hide the debug screen

dim tusk
distant tulip
#

loading the game to try

dim tusk
#

When I compare entities I don't directly compare it thru the entity, I always grab their IDs lol entity1.id === entity2.id

distant tulip
#

yeah that work too

dim tusk
distant tulip
#

i am really confused, it started to work now....?
i changed nothing

solar dagger
#

Best way to check a players inventory for a specific item without having to check every second? And just an fyi this item relies on time

solar dagger
edgy elm
#

hi here. quick question. how can i map a button name for example a name of a potion with deatils of what potion i am holding and what is the potions duration

cinder shadow
#

does lore not work with lang keys?

wary edge
#

Lore isn't translateable.

cinder shadow
#

damn

#

can't believe people use this

#

it STINKS

#

hope they reduce the number of characters

dim tusk
wary edge
#

Man who cares about him.

#

Where's my scriptAPI wishlist implemented?

cinder shadow
cinder shadow
valid ice
prisma plaza
#

cool script thing I made. Can you guess what it is?

cinder shadow
#

A bunch of blocks

sharp elbow
#

Fractal!

prisma plaza
#

cellular automata bao_foxxo_smile

#

its not super fast currently, but does not degrade performance much thanks to runJob.

prisma plaza
#

one more photo 🙂

dense skiff
#

Awesome!

#

What's the chat character limit? And also, what's the character limit for Modal form textboxes?

dense skiff
#

For both?

dense skiff
#

Is there anywhere the user can paste a large string?

shut citrus
#

How to use new applyKnockback?

edgy elm
#

hello. i wonder, how can I translate my code messages? do i need to manually tranlate it or there's another way to do it?

prime zenith
#

I have an issue

Im about to add something to script that i can not test myself cause its whole thing is around how it works with multiplayer

Idk the best way to test tgat this works lol

dim tusk
#
world.sendMessage({ rawtext: [ { translate: '', with: [] } ] });```
dim tusk
dense skiff
dim tusk
prime zenith
#

Coddy i need your opinion on something

prime zenith
#

I fmed you

valid ice
#

Have you tried am?

empty light
#

How would I detect if a player has more than one item in their inventory?

ivory bough
#

How to spawn an entity near the player and the distance being 30-45 and the entity spawning in a valid position and not like surrounded by blocks or spawning inside blocks?

shy leaf
dim tusk
shy leaf
#

oh

#

i was just overthinking

dim tusk
#
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {
  ev.cancel = true;
  console.error(sender.name, message);
});```
shy leaf
#

literally 1984

dim tusk
#

I'm somewhat addicted to destructing

#

Lmfao

#

-# I knows it's bad.

prisma shard
dim tusk
prisma shard
#

in the video

dim tusk
#

It doesn't support Minecraft API only javascript in general

prisma shard
dim tusk
#

And the app name is literally "Code Editor"

dim tusk
prisma shard
#

i saw something like getComponent in those typings, so thought like, how you got those minecraft api typings

dim tusk
prisma shard
#

i see

#

ok i gotta eat gtg

ivory bough
#

How to spawn an entity near the player and the distance being 30-45 and the entity spawning in a valid position and not like surrounded by blocks or spawning inside blocks?

prisma shard
ivory bough
#

I would have used spawn rules if I wanted it to spawn randomly

ivory bough
#

Wait nvm I don't need it anymore

distant tulip
#

how do i use sendMessage in an entity instance?
this throw an error

const nearbyPlayers = sourceEntity.dimension.getEntities({ types: 'minecraft:player', location:sourceEntity.location, maxDistance:5 })

for(const player of nearbyPlayers){
    player.sendMessage("...")
}

should i use getPlayer and filter them out?

distant tulip
#

turns out i can use maxDistance and location in getPlayer...
i remember this was not working at some point

distant tulip
# subtle cove sendMessage?.(

hmm? won't that just cancel the message? the player in that case is an entity instance, so sendMessage is not a function

subtle cove
#

the sendMessage isnt in the entity so it turns undefined and will stop at ?. then wont trigger the function

distant tulip
#

yeah, but what the point
i wanted the message to get sent, anyway, i used getPlayer, i was misremembering as always

subtle cove
#

just sharing rare feature in js, thats all
getPlayers sure is better there

distant tulip
#

didn't know that can be done with functions tbh, so thanks

dim tusk
distant tulip
#

huh
they are different?

subtle cove
#

to use location property, it has to be dimension.getPlayers

dim tusk
#

It's dark ash... Wait.

chilly moth
subtle cove
#

block custom component...
onTick applyDamage

dim tusk
subtle cove
#

it used to be janky like /execute

dim tusk
distant tulip
#

entity.dimension.getPlayers get only the ones in the dimension?
bao_foxxo_what

distant tulip
#

it make sense
i feel stupid now, lol

dim tusk
#

It would be cool if there's a world.getEntities() too lmfao

distant tulip
#

asked gpt if there is any similar stuff to ?.() that i probably didn't know, here is one
~~4.9 is like Math.floor

subtle cove
#

while /execute was being added, we went crazy how to isolate entities per dimension, horrifying times

distant tulip
#

Math.floor don't do that?

subtle cove
#

floor makes it -2

distant tulip
#

there is also x | 0

subtle cove
#

uhm, thats prob for advanced data managers...

distant tulip
#

and this
x >> n // Equivalent to Math.floor(x / 2^n)

#

there is ^= to swap variables

subtle cove
#

ooo, that one's new to me

dim tusk
#

Tho I can't think of a situation where I would use that

distant tulip
#

imagine using that instead of temp Variable at school and getting 0 for your answer cause the teacher didn't know

dim tusk
#

I'm done with this god damn land claiming system.

#

Oof wrong channel.

subtle cove
#

welp, the job was to teach. experienced ones rarely do teaching prob cus advanced features comes with more experimentations and technical skills and schools dont have much time for the students to focus ig

subtle cove
true isle
chilly moth
#

👍🏽

true isle
#

Perm resolve resolves the default permutation when not defined

wheat condor
#

is there any alredy done function to get the biome?

granite badger
wheat condor
#

ty

thorn ocean
#

Does anyone know how to create a custom package in JS for other javascript files to use?

thorn ocean
# wary edge Yeah, what's up?

Well, I wanted to create a package containing several custom classes and import them into multiple files import { world, system } from "@minecraft/server"; kinda like this format if possible.

wary edge
#

Yeah, that's possible.

thorn ocean
#

I've never dealt with such things before, so I have to be honest, I'm not entirely sure what you guys do here lol.

wary edge
#

Or learning in general how to make a JS library.

thorn ocean
thorn ocean
wary edge
#

Yeah, if they can install npm packages yeah.

night acorn
#

idrk where to ask this but does anyone know the max tex size for particles?

thorn flicker
#

#1067869590400544869

night acorn
#

thanks, did not know it had a general forum bit

fast lark
#

Is there a list of all causes of death and their message?

humble lintel
#

can anyone give me ideas on what to code

dim tusk
humble lintel
#

doom is everywhere 💀

unique acorn
humble lintel
#

okay gusy like im not that crazy

night acorn
#

does anyone know the event for sending a chat message?

humble lintel
#

world.sendMessage?

#

or something?

#

or beforechat

night acorn
#

im seeing chatSend a lot both in the stirante and ms docs

humble lintel
night acorn
#

but i cant actually find any docs on what it returns

#

and how to use it

humble lintel
#

that's everything it returns

#

you can do data.cancel = true to cancel the message from sending

night acorn
#

huh

#

ok

#

ill wing it

humble lintel
#

goodluck

night acorn
#

i dont think it works

#
[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'subscribe' of undefined

[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'subscribe' of undefined

[Scripting][error]-Plugin [From the Void - 1.0.0] - [main.js] ran with error: [TypeError: cannot read property 'subscribe' of undefined    at <anonymous> (dbg.js:3)
night acorn
#

oh

#

i have beta apis on tho

humble lintel
#

what does urt manifest look like

#

oh?

dim tusk
#

That error would never show if your manifest version of server is beta.

night acorn
# humble lintel what does urt manifest look like
{
    "format_version": 2,
    "metadata": {
        "authors": [
            "Dismal"
        ]
    },
    "header": {
        "name": "From the Void",
        "description": "spooky description pending",
        "min_engine_version": [
            1,
            21,
            50
        ],
        "uuid": "99fc5662-e2af-4fcf-bc00-71d60024ab8b",
        "version": [
            1,
            0,
            0
        ]
    },
    "modules": [
        {
            "type": "data",
            "uuid": "14eabfce-6672-4113-96c4-7f7966fb03e3",
            "version": [
                1,
                0,
                0
            ]
        },
        {
            "type": "script",
            "language": "javascript",
            "uuid": "8b5179cd-3595-49ec-9000-132cbe7f634e",
            "entry": "main.js",
            "version": [
                1,
                0,
                0
            ]
        }
    ],
    "dependencies": [
        {
            "uuid": "25ca5987-1660-431c-97a6-6cd9319ea922",
            "version": [
                1,
                0,
                0
            ]
        },
        {
            "module_name": "@minecraft/server",
            "version": "1.11.0"
        }
    ]
}
humble lintel
#

instead of 1.11.0

night acorn
#

oh ok

#

i try

#

bridge being bridge

round bone
night acorn
round bone
night acorn
#

im testing rn

round bone
#

also consider setting min_engine_version to [1, 21, 60]

night acorn
#

not through launcher either

#

or xbox app

#

so im stuck on 50

unique acorn
night acorn
#

just found that out

night acorn
#
[Scripting][error]-ReferenceError: Native function [Entity::tryTeleport] does not have required privileges.    at teleportToSafeElevation (utils.js:8)
    at <anonymous> (dbg.js:12)
#

what on earth does this mean

unique acorn
#

or use afterEvent

unique acorn
#

yuppii

night acorn
#

is there a way to negate void damage

fast lark
#

There isn’t one that is decent

unique acorn
night acorn
#

can someone tell me how the hell script events work

#

how do i use them

#

im so confused

#

theres no examples 😭

valid ice
#

The script subscribe listens for the /scriptevent chat comment

fast lark
#

Oh

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

system.afterEvents.scriptEventReceive.subscribe((event) => {
    const { id, message, sourceEntity, sourceType } = event;

    console.log(id); // wiki:test
    console.log(message); // Hello World
    console.log(sourceEntity); // Player object
    console.log(sourceType); // Entity
});

world.getPlayers().forEach((player) => {
    player.runCommand("scriptevent wiki:test Hello World");
});

(I found this on jayly's website)

unique acorn
humble lintel
#

like what makes a good home system?

unique acorn
humble lintel
unique acorn
#

remake minecraft using the script api

#

grab an armor stand, use /camera to make the camera show in 1st person of the armor stand, then remake your own movement system and make sure you are in a void world where you also make your own world generation system, including custom entities and stuff

#

and make your own damage system, combat system

#

🙂

humble lintel
#

okay good idea

#

maybe remaking the movement system sounds fire

unique acorn
#

maybe, what if you freeze the player using input permission and use applyKnockback to move the player, and you will know which direction using inputInfo

#

somebody made a world generation system using commands only in bedrock, so it should be possible with scripts too

rose light
#

Is it possible to detect if an entity has broken a block?

distant tulip
#

player only

rose light
#

😭

humble lintel
rose light
#

I wanted to make a system that when the entity breaks a block, in this case it would be a door or glass, the block restores itself across the entire map.

humble lintel
#

so probably it's kinda cool wish I still had the world

dim tusk
#

goofy ahh, I made a land claim system

#

Only one thing is my problem.

#

disable damages.

humble lintel
#

fair

#

i would use spread entity command

#

for ores lmao

#

and go layer by layer

olive rapids
#

Does anyone know how I can make my scripts continue to work on all new versions of Minecraft?

#

I think it's editing the manifest

unique acorn
olive rapids
#

My manifest uses beta versions

unique acorn
fast lark
olive rapids
fast lark
#

The response is no if u use beta