#Script API General

1 messages · Page 15 of 1

devout dune
#

Hey I am looking to hopefully grab the players rotation, based on the 'corner' of the block they are looking at.
Id like to determine which 'quadrant' they are looking / rotating towards.
Maybe the commented out code is close?

valid ice
#

raycast has face & facelocation properties

devout dune
#

We used to be able to do this with molang, and query.head_rotation _y or something. But now I need to do it via script because of customcomponents

buoyant canopy
#

it's a rising edge and my event require a falling edge, meaning it doesn't run until the cooldown has finished.

#

your method:
sense damage -> run a function -> wait 1 second -> if sense damage -> cancel the event
my need:
sense damage -> wait 1 second -> if sense damage wait again else run a function

buoyant canopy
distant tulip
distant tulip
buoyant canopy
#

cancel all the events but the last call

#

i have found the solution

#

you probably can't, you need to create your own emote animations

devout dune
#

Helloo, having a mixup between these methods.
I am trying to grab the block that the player has **placed **on the ground. AND the block that the player is placing on

I can grab the block that the player has placed. using BlockComponentOnPlaceEvent -> event.block
BUT I dont have access to the player. so I cannot cast a ray, to get the block on the ground.

I can cast a ray using BlockComponentPlayerPlaceBeforeEvent
But then I do not have access to the block that the player has placed.
It is the beforeEvent, so it logs "air" instead of the placed block.

Do I need a mix of these methods, so that I can grab the placed block, and the block that was placeed on?
I need both blocks because I am trying to cast a ray onto the ground block, to find the coordinates that the mouse is coming from, to set a coordinate state on the block the player placed. so the model will be placed in that corner

wary edge
#

For the onPlace

#

You can use the .face property for beforeonplayer place then get the offset of the coordinates to grab the block

glacial widget
#
world.beforeEvents.playerLeave.subscribe((event) => {
    const player = event.player;

    if (player.getTags().includes("combat")) {
        player.addTag("leaves-combat");
        player.removeTag("combat");
        world.sendMessage(`§c§l${player.name} has combat logged!!`);
    }
});

does anyone now why nothing is said in the chat when the player leaves?

valid ice
#

before events cannot modify the world. That includes adding/removing tags & sending messages.

glacial widget
valid ice
#

You could, but the player would not exist at that point as they have alredy left

glacial widget
devout dune
#
 system.run(() => {
            if (player.getTags().includes("combat")) {
        player.addTag("leaves-combat");
        player.removeTag("combat");
        world.sendMessage(`§c§l${player.name} has combat logged!!`);
    }
          });```

Maybe this?
#

this worked for me. when i needed it to remove entities

glacial widget
devout dune
#

wrap system.run around ur logic

valid ice
#

Only problem with using system run is the same problem as with the after event- the player as an entity no longer exists when it runs, so they cannot be modified

glacial widget
honest spear
valid ice
#

Dynamic properties are settable in before events, funnily enough. Could be unintentional, but that is one way to "set" data.

honest spear
#

interesting, thats kinda new

valid ice
#

I mean personally I am just using databases so I can system run & then set the data in the next tick to the player's id

distant tulip
spring axle
#

That was our logic way back when anyways.

honest spear
#

Well just saying its not feature request 😅

distant tulip
#

nice to get that confirmed

spring axle
twilit crag
#

How do I get the size of a string in bytes?

#

For checking before setting a dynamic property to it

pliant tiger
#

Can some one help me

#

How to make a script that when the player look at a entity it attacks him

#

Like with any mob

#

But with there id

lethal lichen
#

Until custom component parameters become a thing, are tags the only way to pass arguments to components or has someone come up with a better workaround?

pliant tiger
#

package com.example.lookattack;

import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;

public class LookAttackPlugin extends JavaPlugin {

@Override
public void onEnable() {
    new LookCheckTask().runTaskTimer(this, 0L, 1L);
}

public class LookCheckTask extends BukkitRunnable {
    @Override
    public void run() {
        for (Player player : Bukkit.getOnlinePlayers()) {
            for (Entity entity : player.getNearbyEntities(5, 5, 5)) {
                if (entity.getLocation().distance(player.getEyeLocation()) < 5 && isLookingAt(player, entity)) {
                    attackPlayer(player, entity);
                }
            }
        }
    }

    private boolean isLookingAt(Player player, Entity entity) {
        return entity.getLocation().toVector().subtract(player.getEyeLocation().toVector()).normalize().dot(player.getLocation().getDirection()) > 0.99;
    }

    private void attackPlayer(Player player, Entity entity) {
        // Your custom attack logic here
        entity.setVelocity(player.getLocation().toVector().subtract(entity.getLocation().toVector()).normalize().multiply(0.5));
        player.damage(2.0); // Inflicts 1 heart of damage
    }
}

}

#

Does this work

#

I made it like 2 years ago

#

Can someone test it to me pls

valid ice
#

script API?

#

or bukkit

pliant tiger
#

Yes

#

Can you record it

#

If it works pls

#

@chrome flint

chrome flint
pliant tiger
#

If not

pliant tiger
#

Can you make me new one

pliant tiger
chrome flint
#

no

valid ice
#

bedrock addons yessir

pliant tiger
#

The script for both bro

pliant tiger
#

Like there was one idiot kid was trying to make my mod when i said no and he made it and i made a video on him and reported him

valid ice
#

bedrock server software users are pretty sparse in these parts, so I doubt you will find anyone who uses that kinda stuff here

pliant tiger
#

Yea

#

You know the new horror mods

valid ice
#

no

pliant tiger
#

All they are for java only with good quality and actions but bedrock creators steal it and its not that good even

#

Like WTF

#

Why do they even do it

valid ice
#

uh

#

ok

solar dagger
#

Anybody know how to set an entity pitch rotation?

distant tulip
#

none player entity

chrome flint
#

setRotation({pitch,yaw})

solar dagger
#

Okay I'll take a look at that

#

👌

solar dagger
#

@distant tulip do you know a way that I can send the rotation values over to the entity file in RP?

distant tulip
#

property

valid ice
#
  1. Why ping ._.
  2. molang queries
solar dagger
#

I'm making a custom flight path for an entity and require my animations to be in sync with those values

#

Property...will that be delayed?

distant tulip
#

also as herobrine said just use molang queries

distant tulip
valid ice
#

query.eye_target_x_rotation: Returns the X eye rotation of the entity if it makes sense, else it returns 0.0.
query.eye_target_y_rotation: Returns the Y eye rotation of the entity if it makes sense, else it returns 0.0.

query.body_x_rotation: Returns the body pitch rotation if called on an actor, else it returns 0.0.
query.body_y_rotation: Returns the body yaw rotation if called on an actor, else it returns 0.0.

solar dagger
#

Hmmm 🤔 I don't think that would make a difference

solar dagger
valid ice
distant tulip
#

molang queries is faster

solar dagger
#

Okay thanks 🙏

valid ice
#

There's an ungodly number of molang parameters for rotations lol

feral thorn
#

Hey everyone, is there a way to have an event for when a player lefts clicks an item in a custom component? I see OnUse, which I believe can only work when the item is right clicked. Thanks

valid ice
#

(or entities)

feral thorn
#

Gotcha, so for some context im trying to add a gun and wanting to have events where I can fire the weapon with left click, then aim down sights with right. From what I know there isn't a way to implement this with custom components? If thats the case, is there another method for this to work?

gaunt salmonBOT
valid ice
#

for the right-click, your best bet would be to use item charge or item start use & item stop use

#

#debug-playground please @fathom pecan

feral thorn
#

Okay, thanks appreciate it! Hope they have some way to do this in the future, especially now that events are being depreciated i guess

valid ice
#

as for the left click.. you can detect hits on entity or block, but not on air :(

feral thorn
#

Thats true, im thinking for now to just skip the whole aim down sights thing for now and just use the right click to shoot, cause im wanting to keep track of ammo and stuff in script. Thinking for the reloading to have a use on event then see if the player is sneaking to make that part function.

#

What would be great with custom components would be to subsribe to keyevents, god that would add so much functionality

valid ice
#

Keystroke detection would be perfection

fallow rivet
#

How can I prevent players from breaking blocks between the coordinates "0 10 0" and "10 0 10"?

valid ice
#

cancel before block break event if coordinates are in that bound

fallow rivet
#

I don't know how to set the coordinate

valid ice
#
world.beforeEvents.playerBreakBlock.subscribe(data => {
    const blockLoc = data.block.location;
    if (
    (blockLoc.x <= 10 && blockLoc.x >= 0) &&
    (blockLoc.y <= 10 && blockLoc.y >= 0) &&
    (blockLoc.z <= 10 && blockLoc.z >= 0)
    ) {
        data.cancel = true;
    }
});``` something like this maybe
fallow rivet
#

Hmm

#

Thanks

#

Btw What is the time there?

valid ice
#

16:21

fallow rivet
#

Where do you live?

valid ice
#

._.

fallow rivet
# valid ice ._.

Only I asked because the time was very different from where I was.

#

Here 2.23

valid ice
#

Timezones do that, yeah

fallow rivet
#

İ know, But this just seems really weird

fallow rivet
valid ice
#

whar

#

oh a giant form?

fallow rivet
#

Ye

#

9x9

valid ice
#

eh

#

if people want to add it themselves, they can.

fallow rivet
#

I added this to your chest ui 1 year ago

valid ice
#

Haven't had any complaints about 54 being the max

fallow rivet
#

The reason I added this

#

Player inventory appears empty

valid ice
#

Yes

fallow rivet
#

This was bothering me so I added this

valid ice
#

That is... something I wanted to add and never really got around to it

#

Not to say I didn't try

fallow rivet
#

I'm doing an auction and I'm not sure if I should use chest ui.

valid ice
#

You do you

fallow rivet
#

Btw I entered your realms

#

There was an auction there

#

Do you use time in Auction?

valid ice
#

Date methods? Always

#

Much more accurate than scoreboards, and no need for them to count down like scoreboards do

fallow rivet
#

Are you using dynamicproperty to save data?

valid ice
#

I use a scoreboard database system

fallow rivet
#

This is the first time I've heard of this 💀

#

There is still so much I need to learn

valid ice
#

tbf not many use a scoreboard db lol

#

I just haven't really upgraded to DPs and can't be asked as the current one I'm using works perfectly fine

fallow rivet
#

İ use dynamicproperty

fallow rivet
#

world.beforeEvents.playerInteractWithBlock.subscribe is only used in beta

valid ice
#

Yes

bright dove
kind vault
#
class AnimatedSlot {
    static Animate (inv , slot, itemStack, amountMode = "set", amount = 0) {
     //Checks if the ammount mode is remove and above 0
        if (amountMode === "remove" && amount > 0) {
            //Checks if itemStack ammount is greater than 1 and less than the max ammount
        if (itemStack?.amount > 1 && amount < itemStack.maxAmount) {
        const itemReturn = itemStack.clone();
          itemReturn.amount -= amount;
          inv.setItem(slot, itemReturn);
        } else if (itemStack?.amount === amount) {
          inv.setItem(slot, new ItemStack("air"));
        }
      } else if (amountMode === "add" && amount > 0) {
        if (itemStack?.amount > 0 && amount < itemStack.maxAmount) {
          const itemReturn = itemStack.clone();
          itemReturn.amount += amount;
          inv.setItem(slot, itemReturn);
        }
      }
    }
  }
kind vault
bright dove
misty pivot
#

if i where to temporarily remove an area and place it back later which is better to use? structures or saving each block in an array? ||(especially if i were to temporarily save a lot of areas)||

random flint
misty pivot
#

i see, thanks

celest fable
#

how to clear one item type?

lone thistle
celest fable
lone thistle
#

If statement

celest fable
#

like, how?

lone thistle
#

If the item in the slot matches the typeId you’re looking for, setItem it

celest fable
#

oowh

#

btw how to access the Android/data from acode:)

celest fable
#
let items = []
for (let i =0;i<container.size;i++) {
  const itemData = container.getItem(i)
  if (itemData.typeId == item.item) items.push()
}
if (items.length == 0) return
items.forEach((item, i) => container.setItem(i))
summer walrus
subtle cove
summer walrus
#

nvm m9 is here

subtle cove
#

Why me ;-;

celest fable
subtle cove
#

sigh thx

#

I'm just waiting for questions why my code r like those

thorn flicker
subtle cove
thorn flicker
subtle cove
#

o has no value inside the array there

thorn flicker
#

you cannot just leave it empty?

subtle cove
#

It's just there to skip the 1st param, and have the 2nd as index

fallow rivet
#

Is it possible to block the toolbox with a script?

thorn flicker
#

ill just stick to using for loops

#

lmao

#

and read up on it more later ofc

subtle cove
#
let i = c.size
while (i--) {
    if (c.getItem(i)?.typeId != itemId) continue;
    c.setItem(i)
} ```
subtle cove
#

Oh u wana see one line compact

thorn flicker
#

👀

subtle cove
#

Nvm bcaWorking1

thorn flicker
#

lmao I was gonna say use tenerary

celest fable
celest fable
thorn flicker
celest fable
#

🙂

subtle cove
#

idk what that is tho, so ehh

celest fable
#

but detect yes

subtle cove
#

Block an app, no

thorn flicker
subtle cove
#

Oh

celest fable
# fallow rivet .

you can detect how the player move or what efer called Anti Cheat lmao

fallow rivet
#

Can I detect if you are using Give item?

celest fable
#

detect if the player has nonrasional item

subtle cove
#
c[c.getItem(i)?.typeId == itemId && 'setItem']?.(i)
celest fable
thorn flicker
#

lol

subtle cove
#

If its false
It'd be like
c.false() which is not in the c

#

So ?. Is there

celest fable
subtle cove
#

Anyway gtg cook

thorn flicker
#

optional chaining

celest fable
#

it should be like item.typeId == itemId ? item.setItem(i): continue isnt?

#

wait what are you talkin abaout:v

thorn flicker
celest fable
#

does anyone have land system code?

fallow rivet
cold grove
subtle cove
#

It's just alternative ways

runic crypt
#

Can anyone make me a script in which if player doesn't have a specific tag then they can only open the chest and see the contents but not take/add any items
While players with the tag can open, add/remove items from the chest ?

cold grove
#

Yes, everyone can, even YOU

runic crypt
lone thistle
subtle cove
#

Items can't be locked in block container tho

cold grove
#

Only modding bedrock servers

subtle cove
#

The player toggleable perms is the only thing that can manipulate such perms iirc

runic crypt
#

im down to use scripts/addons

lone thistle
lone thistle
#

Using ChestUI when a player opens a chest display the UI with the items in it

subtle cove
#

On the next version or when the held item entity component bbecomes available, then u can detect if player's tryna grab sth

lone thistle
#

Still waiting for beforeEvents.entityHitEntity

cold grove
#

You can just make the block unInteractable for those players

#

And

subtle cove
#

But it's also possible to take out n drop the item out of the container without holding it

thorn flicker
lone thistle
#

Cancel block interaction -> display chest UI

cold grove
thorn flicker
#

he does

cold grove
#

You can use text or use emojis

#

You should make an emoji for every item but

lone thistle
#

Emoji for every item?

thorn flicker
lone thistle
#

Chest UI uses icons

#

For knowledge ^^

thorn flicker
#

sorry man, you have to make like a million emojis!

#

and modded items arent supported!

cold grove
#

Never used it

lone thistle
#

It’s just buttons though, they can fetch the amount and display it as the button text

summer walrus
#

when the player who asked disappeared and everyone who was tryna help is still discussing abt it:

subtle cove
#

Hmm, jayly's inv link might be of use on this one

hardy tusk
#

How?

summer walrus
hardy tusk
#

How an inv link addon could be of use in this scenario

hardy tusk
summer walrus
#

what is inv link :D

#

inventory link ?

#

or invite link

thorn flicker
hardy tusk
#

Yea

subtle cove
#

Ohno

hardy tusk
#

Inventory

summer walrus
hardy tusk
#

I think

subtle cove
#

Inventory link of players

thorn flicker
#

inventory link

subtle cove
#

Basically to lock the player's inv when they're interacting with a block, idk just an idea

summer walrus
#

:o

subtle cove
cold grove
#

X2

thorn flicker
#

or maybe you could do something with the new cursoriventory component

runic crypt
#

i have a script to display chest ui when compass is right clicked

cold grove
runic crypt
cold grove
#

Do you know js?

runic crypt
cold grove
runic crypt
#

idk how to do that

#

if its even possible

cold grove
#

World afterEvents/beforeevents

runic crypt
#

this

#

instead of right clcik on compass

#

i want it so that i open chest on specific coords and it opens the fourm

shy leaf
#

cant you use afterevent for that

#

is there one

lone thistle
lone thistle
fallow rivet
#


function createauction(player) {
const inventory = player.getComponent("minecraft:inventory").container;
const form = new ActionFormData();
form.title(`Select Item`);
form.body("");
form.button("§cBack");   
const itemButtonMap = [];    
for (let i = 0; i < inventory.size; i++) {
const item = inventory.getItem(i);           
if (item == undefined) continue;       
form.button(formatBlockName(item.typeId) + " x" + item.amount);
itemButtonMap.push(i); 
}   
form.show(player).then(result => {
if (result.selection === 0) {
auction(player);
}})}

How do I add the texture of the items to the buttons here?

shy leaf
cold grove
shy leaf
#

yeah

fallow rivet
#

İ know , But it is very difficult to write the Greek items one by one. Is it possible to make it easier?

shy leaf
#

i just noticed

summer walrus
#

separate items from blocks since they are located on diff folders

cold grove
#

Iterate your container items and add them to the form

#

You already did it lol

#

Sorry

bright dove
#

anyone here to help ?

wary edge
bright dove
tiny fable
#

is it not possible to read/write a file in the script?

shy leaf
#

write as in?

tiny fable
#

wait read is enough

#

how to do it?

shy leaf
#

uh

#

depends on what youre reading

#

if its a script file then yes

random flint
#

if it .js yes

#

if it other things... no

tiny fable
#

I'm trying to read a txt file 😭

shy leaf
#

nah

tiny fable
#

looks like its not possible

shy leaf
#

not possible

#

what is the txt file for, though

#

you could make a database using scripts and make your main script to read it

tiny fable
#

i have a uh
long chain of numbers

#

of player data

shy leaf
tiny fable
#

so

shy leaf
#

and how long is it

#

i mean uh

#

what is it

tiny fable
#

around the data size of a 4 second .mp4 file..

shy leaf
#

What the fuck

tiny fable
#

idk its just a approximation its not related to mp4

random flint
#

Just declare a const with that string

shy leaf
#

oh wait nevermind i read that wrong

random flint
#

you can just export & import across files. for readability

tiny fable
#

cool imma try it

#

👍

#

i think i fried the tokenization

random flint
#

Might as well just avoid using these numbers in the first place.

shy leaf
#

what on earth

#

are those numbers

#

i bet watchdog would dox you if you put that in your script 💀

shy leaf
#

nah

#

ips arent built like that

#

(unless)

fallow rivet
#

Is there a bedrock model on Blockbench?

wary edge
shy leaf
#

oyure in #1067535382285135923

fallow rivet
#

Oh sorry I wrote it in the wrong place

tiny fable
#

🤫 dont spoil my big plan 🤫

viral plaza
#

Anyone know why when I spawn an item with dimensio.spawnItem it flings the items sometimes, is there anyway to make it just summon In one spot?

west chasm
viral plaza
#

That’s a method?

weary umbra
#

why can't I give a player a tag?

                    header: {
                        version: 1,
                        requestId: uuid(),
                        messageType: "commandRequest",
                        messagePurpose: "commandRequest"
                    },
                    body: {
                        commandLine: `tag @a[name="${username}"] add "ps-${password}"`,
                        version: 1
                    }

it give me this status
"statusMessage":"No targets matched selector"
but the player exist. I tried with @p that did work but I want it with the username

viral plaza
#

Now my gens can actually have a reliable afk system

last latch
#

is it better to make a intervalmanager which puts every function saved into one interval or use more than one interval?
for example :

AfterEvents.onTick(() => {
  // code

  // code

  // code
})
system.runInterval(() => {
    // code
})

system.runInterval(() => {
    // code
})

system.runInterval(() => {
    // code
})
last latch
#

if you create a big project everything in one interval makes the interval big unless you use multiple functions

#

i prefer using only one with api

#

more than multiple intervals

devout dune
#

How can i set multiple states on a block?

      placedBlock.setPermutation(
        placedBlock.permutation.withState("ts:quadrant", quadrantValueToString),
        ...........
      );
wary edge
neat hound
stray jasper
#

how do I fix this error?

knotty plaza
stray jasper
# knotty plaza Show your code

`// Import necessary modules from Minecraft server API
import { world, ItemStack } from '@minecraft/server';

// Subscribe to the 'worldInitialize' event to register custom components
world.beforeEvents.worldInitialize.subscribe(eventData => {
// Register a custom component named kai:on_player_destroy for slab destruction
eventData.blockTypeRegistry.registerCustomComponent('kai:on_player_destroy', {
// Define behavior when a player destroys the slab
onPlayerDestroy(e) {
// Destructure event data for easier access
const { player, dimension } = e;

        // Extract destroyed block permutation from event data
        const { destroyedBlockPermutation: perm } = e;

        // Check if player and equipment are valid
        if (!player || !player.getComponent('equippable')) {
            return;
        }

        // Get the item in the player's main hand
        const selectedItem = player.getComponent('equippable').getEquipment('Mainhand');

        // Check if the selected item is a pickaxe
        if (!selectedItem || !selectedItem.hasTag('minecraft:is_pickaxe')) {
            return;
        }`

        // Use destroyedBlockPermutation to get the ItemStack directly
        const slabItem = perm.getItemStack(1);
        if (slabItem) {
            // Spawn the item at the destroyed block location
            dimension.spawnItem(slabItem, e.block.location);
        }
    }
});

});

knotty plaza
#

It is not called blockTypeRegistry anymore, now its called blockComponentRegistry

stray jasper
#

thank you

wise raft
#

Is it possible to change the Texture of an Item with Scripts?

neat hound
wise raft
#

alright, thanks

viral plaza
#

Anyone got a resource pack where the actionbar is normal, but the title is a custom sidebar?

cold grove
nimble schooner
#

Where do I find full inventory documentation and examples?

nimble schooner
#

How to get and set offhand/armor item?

nimble schooner
#

How are the slots called?

warm drum
#

is there a way to expose the npc ui to script?

mystic mortar
#

Progress on recreating the ominous vault

mystic mortar
#
import { world, system, ItemStack } from "@minecraft/server";

// Delay between each pool
const delayBetweenPools = 500; // 0.5 seconds (500 milliseconds)

// Helper function to create a delay
async function delay(ms) {
    const endTime = Date.now() + ms;
    while (Date.now() < endTime) {
        // Keep the script running until the delay has passed
        system.runTimeout(() => {}, 1); // Adjust this value if needed
    }
}

// Function to simulate spawning of items with a delay
async function spawnLootItems(player) {
    const { x, y, z } = player.location;

    // Pool 1: 1 roll
    const pool1Entries = [
        { item: "minecraft:emerald", weight: 5, min: 4, max: 10 },
        { item: "minecraft:wind_charge", weight: 4, min: 8, max: 12 },
        { item: "minecraft:arrow", weight: 3, min: 4, max: 12 },
        { item: "minecraft:diamond", weight: 2, min: 2, max: 3 },
        { item: "minecraft:ominous_bottle", weight: 1, min: 1, max: 1 }
    ];
    await spawnItemsFromPool(player, x, y, z, pool1Entries);

    // Delay between pools
    await delay(delayBetweenPools);

    // Pool 2: 1-3 rolls
    const pool2Entries = [
        { item: "minecraft:emerald_block", weight: 5, min: 1, max: 1 },
        { item: "minecraft:iron_block", weight: 4, min: 1, max: 1 },
        { item: "minecraft:crossbow", weight: 4, min: 1, max: 1 },
        { item: "minecraft:golden_apple", weight: 3, min: 1, max: 1 },
        { item: "minecraft:diamond_axe", weight: 3, min: 1, max: 1 },
        { item: "minecraft:diamond_chestplate", weight: 3, min: 1, max: 1 },
        { item: "minecraft:book", weight: 2, min: 1, max: 1 },
        { item: "minecraft:diamond_block", weight: 1, min: 1, max: 1 }
    ];
    await spawnItemsFromPool(player, x, y, z, pool2Entries);

    // Delay between pools
    await delay(delayBetweenPools);

    // Pool 3: 1 roll, conditional
    const pool3Entries = [
        { item: "minecraft:enchanted_golden_apple", weight: 3, min: 1, max: 1 },
        { item: "minecraft:flow_armor_trim_smithing_template", weight: 3, min: 1, max: 1 },
        { item: "minecraft:flow_banner_pattern", weight: 2, min: 1, max: 1 },
        { item: "minecraft:music_disc_creator", weight: 1, min: 1, max: 1 },
        { item: "minecraft:heavy_core", weight: 1, min: 1, max: 1 }
    ];

    // 75% chance to roll pool 3
    if (Math.random() < 0.75) {
        await spawnItemsFromPool(player, x, y, z, pool3Entries);
    }
}

// Helper function to spawn items from a pool
async function spawnItemsFromPool(player, x, y, z, pool) {
    for (const entry of pool) {
        const count = Math.floor(Math.random() * (entry.max - entry.min + 1)) + entry.min;
        const itemStack = new ItemStack(entry.item, count);

        // Spawn item slightly above the player
        player.dimension.spawnItem(itemStack, { x: x + 0.5, y: y + 1, z: z + 0.5 });

        // Delay between item spawns
        await delay(100); // Short delay between items
    }
}

// Script event listener
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
    if (id == "vault:test") {
        spawnLootItems(sourceEntity);
    }
});```
amber granite
#

That looks nice...

mystic mortar
#

Since using setblock doesnt have its behavior working right

knotty plaza
valid ice
#

Does the updated return value on Dimension::fillBlocks() have the amount of blocks that were successfully replaced by the method? I cannot seem to find it, and I don't know if it was removed or not.

mystic mortar
valid ice
#

I'm just asking a generalized question

mystic mortar
#

Idk lol.

amber granite
#

Nvm

cinder shadow
valid ice
#

add(), remove() or BlockVolume methods of getBlockLocationIterator(), getBoundingBox(), getCapacity(), getMax(), getMin(), getSpan(), isInside(), & translate

amber granite
#

What the " :: " means ?

cinder shadow
#

oh.. what happens if you did const test = dimension.fillBlocks...?

amber granite
#

is :: valid js syntax?

valid ice
#

idk, I've seen others use it

cinder shadow
#

does stringify even do anything with that

#

if you just chuck everything out

valid ice
#

lemme see

amber granite
#

It looks like c++ scope resolution operator lol

valid ice
deep quiver
#

class::function

#

Thats what you see in the script api error messages sometimes

amber granite
#

Ohhhh

#

So they are cpp functions after all

valid ice
fiery solar
# valid ice Just these

The only way would be to use getBlockLocationIterator to iterate over all the locations that were filled and count them. The number of locations could be huge though depending on the Volume you fill, so you would probably want to wrap it in a system.runJob to spread it over multiple ticks so you don't crash.

valid ice
#

sigh

valid ice
#

Is there legit no better way? 😭

oak hatch
#

if you arent using BlockFillOptions to define specific blocks to replace, then getCapacity should work

valid ice
#

The thing is, I am using fill options..

gray tinsel
#

trying to inherent the direction of vanilla log blocks

#

what would the block state for that be?

tiny tartan
#
Player.prototype.removeExp = (amount) => {
    const newAmount = this.getTotalXp() - amount
    this.resetLevel();
    this.addExperience(newAmount);
}``` `can't get getTotalXp() of undefined`
subtle cove
#

function (amount)
not (amount) =>

random flint
#

use Object.defineProperties() xd

tiny tartan
#

ima still learning stuffs so i dunno that method yet

subtle cove
tiny tartan
subtle cove
#
import 'main.js'
import './main.js'
import './other_file.js'
tiny tartan
subtle cove
#

no

tiny tartan
#

alr thx

subtle cove
#

Imagine like fixing a standard model that's used to multiply

mellow socket
#

in the docs there is this screenshot about the dynamicProperties
what program is this?

mellow socket
#

any tool that can do this for free?

shy leaf
#

j, im not sure if theres any

mellow socket
shy leaf
remote oyster
distant tulip
shy leaf
#

is RawMessage basically the same as tellraw command, but without rawtext at the beginning?

#

oh wait

#

nvm

oak lynx
#

https://i.imgur.com/BO6gxRv.png

export function getPlayerById(id: string):Player {
    world.getAllPlayers().forEach(player => {
        const otherId = player.id
        console.warn(otherId, id)
        if (player.id == id) {
            return player
        }
    })
    return undefined
}```
#

am i like stupid or something

simple zodiac
oak lynx
#

when did they add that

simple zodiac
#

a long time ago

dense wraith
#

One message removed from a suspended account.

shy leaf
dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

sharp elbow
#

Well, you are not defining player. Just event (in the worldInitialize function), blockComponentRegistry (from event), and e (in onPlayerInteract)

fallow rivet
#

@valid ice Is there a chest ui for 1.21.21 and if so can you send me the link (sorry for the ping)

shy leaf
sharp elbow
dense wraith
#

One message removed from a suspended account.

valid ice
fallow rivet
cinder shadow
#

I really with impulse and appyknockback scaled the same way

#

but holy smokes the multiplier for applyImpulse is ridiculous

valid ice
#

real

cinder shadow
#

finally have a more functional fan

valid ice
#

Is it directional?

cinder shadow
#

only working on one direction right now until I have all the base systems working

#

I need to fix my particles timing next so that the particles actually end where the range is

#

then I need to add color control to my particles

valid ice
#

dope

cinder shadow
#

It's not dope I have no idea how to get these particles working right

valid ice
#

excellent!

cinder shadow
#

I'm going to ping you for absolutely no reason and ask an incredibly dumb question

valid ice
#

I have not gotten enough of those recently, I reckon I am due up for more

burnt remnant
#

problem?
source.addEffect('regeneration', 20 * 2 , 2)

subtle cove
burnt remnant
#

ahh, thank you

neat hound
#

How come I cannot capture a custom component player interaction while player is sneaking?

#

Has anyone encountered that?

solar lake
fading sand
#

Will adding forward velocity to an rider move the ride forwards?

neat hound
#

So the world.beforeEvents.playerInteractWithBlock can get the event signal while the player.isSneaking but world.beforeEvents.worldInitialize -> event.blockComponentRegistry -> onPlayerInteract cannot.
Which means that in order to process player.isSneaking, I have to NOT use a custom component, and do it the old way. I bet it has to do with the event being cancellable or not. If the event is not cancelled and you are holding an item, it gets used.

buoyant canopy
#

hmmm, custom item component trigger when the item is used on a block while the player is sneaking, i don't know why that isn't the case with blocks?

#

probably to allow building on that block?

neat hound
#

People are going to have debug problems with this, if they do not know. If you write code for your door using a custom component, you cannot interact with that door while sneaking.

#

Maybe if I can cancel the event that would place the block

#

I wonder if I am missing something

fading sand
unique dragon
#

kind weirrd

neat hound
#

I tried cancelling the event in the world.beforeEvents.playerInteractWithBlock and it still did not register. I think because it all happens in the same tick, so the event cancellation doe not do anything.
Maybe if I cancel the placing of the block.

I am doing something where you hit a block with itself in order to change the rotation...

#

but if you sneak.. you can advance 16 rotations

valid ice
solar lake
valid ice
#

Well that's good to know- thanks

#

NPM type return value still says "number of blocks filled", so was confused what the return actually returned

neat hound
#

I just realized if I try to circuvent it (cause I was close) then I won't be able to place a block next to itself... LOL

wise raft
#

How can I get the Block five Blocks in front of a Player?

neat hound
#

offset

wise raft
#

how?

valid ice
wise raft
#

But what if between the Blocks are other Blocks?

valid ice
#

hmm

wise raft
#

Alight, thanks

wise raft
#

Thanks

twilit crag
#

Is using structures for bucket/pokeball-like items a good idea or will the world hit the structure limit from people destroying the item?

buoyant canopy
#

because all vanilla blocks can not be interacted with when a player is holding an item while sneaking

neat hound
#

If I really want to get fancy, I can use the faceLocation to map to a spot on the block, like it is a machine... but not convenient right now.. but keeping that in mind for future tech blocks.

lunar shoal
#

What am I doing wrong here? When I teleport it doesn't face me in the positive Z direction:

player.teleport( { x: x + 0.5, y: y + 1, z: z + 0.5 }, { facingLocation: { x: x, y: y, z: z + 1 } } );
deep quiver
#

Try a higher plus amount

lunar shoal
#

Alr

woven loom
burnt remnant
#

was blockTypeRegistry changed to blockComponentRegistry

#

my script that use to work using blockTypeRegistry doesnt work anymore and looking at other people's code theyre using blockComponentRegistry instead so im guessing it was changed

woven loom
#

ye

neat hound
#

This should work to cancel a subscription, right```js
const rotationBlockCustomComponentSubscriptionId =
world.beforeEvents.worldInitialize.subscribe((event) => {

    event.blockComponentRegistry.registerCustomComponent(
        "dw623:rotation_angles_components",
        {
            onPlayerInteract: e => {

                const { block, player } = e;
                if (!player?.isValid()) return;

                if (!validateBlockStates(block)) {
                    //unsubscribe without mercy to avoid world crashing
                    console.error(`§cMissing or Invalid Block State Values on ${block.typeId} : Cancelling OnPlayerInteract Subscription`)
                    world.beforeEvents.worldInitialize.unsubscribe(rotationBlockCustomComponentSubscriptionId)
                    return;
                }

...```

fading sand
#

Will adding forward velocity to an rider move the ride forwards?

knotty plaza
fading sand
#

Makes things more difficult

#

Dont wana add more code than necessary

#

Yk

dawn zealot
#

can someone help me make a system, im trying to make it so that i could make something like "common": 2,
"veryrare": 64,
"legendary": 8900

then thats the chance of getting them when u roll but you will always get 1

knotty plaza
sudden nest
#

feelsgoodman

deep quiver
#

Hmm

lunar shoal
#

Does anyone have a cps counter script?

gaunt salmonBOT
#

Description
A function to get player's clicks in a second

Credits
These scripts were written by Jayly

fervent topaz
#

herobrine

#

how do i get when tnt hits with entityhitentity

valid ice
#

dunno

subtle cove
#

explosion...

grave thistle
#

Is there a way to get the player's current biome?

fervent topaz
cinder shadow
#

You can get their biome. However, if there is a lush or dripstone cave below you, the biomes will be flipped

#

No, I did not report this bug

grave thistle
# cinder shadow Yes and no

How so? I know there's an add-on on the marketplace that has a biome detector so there must be a stable way

#

I've looked through Player and dimension and can't find anything too obvious for getting the current biome

cinder shadow
#

If I was at home I could send it

#

Basically yes, it's just two cave biomes for whatever reason flip the detection and it can be abused to find caves easily

grave thistle
#

Shouldn't be an issue for me. I just need biome detection for a spell system I'm working on. I have a druidic spell with different effects based on the biome it's cast in

sharp elbow
cinder shadow
#

Please don't do that

cinder shadow
#

kinda just yoinked this out of my script

#

make sure to import BiomeTypes

sharp elbow
#

Mm, seems kind of expensive. That is one API call for every biome in BiomeTypes

#

Would probably be OK if done on demand instead of being run periodically

subtle cove
#

Wdym by entity hit in that btw...

fervent topaz
subtle cove
#

Yeah but tnt can't hit an entity, right?

cinder shadow
granite cape
#

essentials

shy leaf
#

how do i even use multiple RawMessage into form

#

it keeps giving me unexpected end of string at the end of script line 💀

valid ice
#

show code

shy leaf
#

(it isnt)

valid ice
shy leaf
#

if this works then i did it wrong with other code too

#

ty

valid ice
#

Something like that- the transalation line is still iffy , as you need a buncha stuff for that one

#

It detects lang file stuff and replaces, I think there's an example on docs, one sec

#

{ translate: 'item.skull.player.name', with: [text] }

#

Where text is just a string value

#

or- ```js
import { world } from '@minecraft/server';

// Displays "Apple or Coal"
const rawMessage = {
translate: 'accessibility.list.or.two',
with: { rawtext: [{ translate: 'item.apple.name' }, { translate: 'item.coal.name' }] },
};
world.sendMessage(rawMessage);```

#

hope that helps somewhat :P

shy leaf
#

oh hey thats neat

valid ice
#

Script API W

shy leaf
valid ice
#

hmm

shy leaf
#

this looks better than what i wrote

#

lmao ty

valid ice
#

lol nw

#

(I have never used translates)

fervent topaz
fading sand
knotty plaza
fading sand
mystic mortar
# cinder shadow

You could have it light level powered like a certain mod from a content smp.

mellow socket
#

so there is no way to make a request to anything in a singleplayer world?

wheat condor
#
player.addEffect("minecraft:speed", 10, {amplifier=4})

why is the game saying expecting "}" ?

wheat condor
#

thanks

cold grove
#

/connect

#

But the command works only if its a player

#

(Fortunately)

mellow socket
#

Would be nice to add auth to our worlds

prisma shard
#

eyyy guys

#

how's going on

subtle cove
#

🧼 ShakeHmm

prisma shard
subtle cove
#

not my words but ur mind ShakeHmm

prisma shard
#

jk

#

can anyone teach me abt prototypes?

#

i know nothigng abt them

#

i want to learn what is it and what can i do with prototypes

shy leaf
#

since its kinda not needed unless youre making some

prisma shard
#

yea

shy leaf
#

pretty or practical scripts

subtle cove
#

imagine Player is the base model then u made changes with it,
then its player variants will have those changes that u can use

shy leaf
#

so basically modifying the class

subtle cove
#

same with Block, ItemStack, AfterEvents, System, etc

prisma shard
subtle cove
#

method, function, value, string, number stuff

prisma shard
#

can u teach me how to make them now

subtle cove
#
World.prototype.killPlayer = function (name) {
  this.getPlayers({name})[0]?.kill()
}``````js
world.killPlayer("m9")
shy leaf
#

awh im slow

subtle cove
#

Object.defineProperty(Object.prototype, 'copy', {
    value: function Copy(param = this) {
        switch (typeof param) {
            case "string": case "number": case "boolean": return param;
            case "undefined": return `${param}`;
        }
        if (Array.isArray(param) || Symbol.iterator in param) return Array.from(param, Copy);
        const O = {};
        for (const key in param) {
            const value = param[key]
            switch (typeof value) {
                case "string": case "number": case "boolean": O[key] = value; continue;
                case "undefined": O[key] = `${value}`; continue;
                case "object": O[key] = value ? Copy(value) : value !== null || null; continue;
                case "function": O[key] = value;
            }
        } return O
    }
});
```this one might look illegal
#

then do```js
world.afterEvents.playerBreakBlock.subscribe(eventData => {
const w = world.copy()
const ae = world.afterEvents.copy()
const pComps = eventData.player.getComponents('inventory').copy()
const data = eventData.copy()
const str = JSON.stringify({w,ae,pComps,data}, null, 3)
world.sendMessage(str)
})

prisma shard
#

that actualy looks illegal lol

subtle cove
#

just to help the JSON.stringify to "stringify" the "unstringifyable" properties of an object by recreating another {} and attach the props there

prisma shard
#

how can i make a custom class like the vector3 interface class?

shy leaf
prisma shard
#

@subtle cove

#

srry for ping yes im stupid

subtle cove
#
class Vector3 {
  constructor(x,y,z){
    this.x = x
    this.y = y
    this.z = z
  }
}``````js
const loc = new Vector3(1,2,3)
valid ice
#

Doesn’t vector2 exist already

sharp elbow
prisma shard
sharp elbow
subtle cove
#

Object is like the last root of most types

prisma shard
#
class Vector3 {
 constructor(Vector3) {
  this.x = Vector3.x;
  this.y = Vector3.y;
  this.z = Vector3.z;
  }
}
const loc = new Vector3({ x: 1, y: 2, z: 3 });
#

so like that?

sharp elbow
#

Yea, I believe that should work. The name of the parameter is odd (sharing the name of the class) but I don't think it poses problems here

subtle cove
#

if u wana pass {x: 1, y:3}, this.z = Vector3.z ?? 0

#

just a simple null property check if u dont wana assign a non number

prisma shard
fading sand
#

If i want to remove the y component of an vector do i have to do it like this?:

const entityDir = ridingOnEntity.getViewDirection();

let newVec = {x:entityDir.x, y:0, z:entityDir.z};

?

subtle cove
#
if (!Object.values(Vector3).every(e=> typeof e == 'number')) return
sharp elbow
subtle cove
#
entityDir.y = 0
prisma shard
fading sand
#

Ohh

fading sand
fading sand
#

Thx guys

fading sand
#

?

knotty plaza
#

The code I sent is getting the ride

fading sand
#

Yes

#

No

#

Its checking for

#

Not getting

#

Now i have to get the ride

knotty plaza
#

.entityRidingOn is an entity, not a boolean

fading sand
#

Or wait

#

Ohh

#

Its returning in that entity

#

👍

#

Thx

#

Up and down rotation is x rotation correct?

sly currentBOT
#
kaosthechaos

Hello

fallow rivet
#

Hmm

#

A nice bot

prisma shard
#

bot*

sly currentBOT
#
finnafinest_

আপনি কেমন আছেন

prisma shard
#

hehe

#

it means "how are you"

inland merlin
#

How do I access the diagnostics panel? I would like to try it out.

ionic kayak
#

Can you detect which cardinal direction a block is facing using scripts?

wary edge
ionic kayak
#

Oops forgot about that thx

inland merlin
#

How do I get the client diagnostics to allow toggle on?

wary edge
inland merlin
#

Ohhhhh

#

Ok ty

feral thorn
#

Hey, how do you add dynamic properties to an item? I am wanting to set variables on an item that I could use in my custom components, thanks!

somber echo
#

Only with non-stackable itemsjs item.setDynamicProperty('id', info);

feral thorn
#

Okay, and do you make the item non stackable by setting the component "minecraft:max_stack_size" to 1? Or is there another way to do so?

feral thorn
#

Alright awesome, appreciate it guys

ionic kayak
wary edge
ionic kayak
wary edge
#

Then in scriptapi, just get the mimecraft:cardinal_direction block state

ionic kayak
#

Ohhhhhhhhhh

#

Thx

untold magnet
#

sup

#

umm, a quick reminder, what should i do to make getDimension(?) works on every dimension?

#

it should be like this

let dim = ["minecraft:overworld", "minecraft:nether", "minecraft:the_end"]
// a Math thing that will detect those multiple dimensions
,,,,.getDimension([dim]) // or something
```idk
lunar shoal
#

Does anyone know a way to guarantee a vault loads? This usually loads a vault 80% of the time. I want it to be guaranteed

function loadVault(player) {
        const playerData = vaultDB.get(player.id);
        const x = playerData.xyz.x;
        const y = playerData.xyz.y;
        const z = playerData.xyz.z;
        
        world.getDimension('Overworld').runCommandAsync(`tickingarea add  ${x - 8} 0 ${z - 11} ${x - 8} 0 ${z - 11} vault:${player.id}`);
        world.getDimension('Overworld').runCommandAsync("tickingarea list");
        
       world.getDimension('Overworld').runCommandAsync(`structure load vault ${x - 8} 0 ${z - 11}`).then(() => {
           system.runTimeout(() => {
           world.getDimension('Overworld').runCommandAsync(`tickingarea remove vault:${player.id}`);
           playerData.vaultLoaded = true;
           vaultDB.set(player.id, playerData)
           console.warn("Structure loaded and ticking area removed");
           }, 20)
    });
}
valid ice
#

They are addon specific

#

As they are saved under the pack's UUID

untold magnet
#

well, this script:

     if (block.below(0.1)) entity.applyImpulse(,,,)
```cannot detect if the entity is starting on the block edges, can someone help me how to make it work when the entity is standing on the block or on the edges?
#

i will open a post sir

wary edge
#

If its a custom block you can use onStepOn, other than that I dont think there is a way

#

Aside from some math calculations but that probably isnt 100% foolproof

valid ice
#

Is that the problem @cinder shadow was running into?

untold magnet
#

my block is 3 pixels tall, it might be not detected with that onStepOn component

#

bec i have already tested it

#

1s

#
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry: block }) => {
  block.registerCustomComponent('exe:conveyor', {
    onStepOn: i => {
        i.entity.applyKnockback(1, 1, 1, 1)
    }
  })
})
```this should knock me up when i step on it right?
untold magnet
# wary edge Needs to be 4

well

      "minecraft:collision_box": {
        "size": [ 16, 3, 16]
      },
      "minecraft:selection_box": {
        "size": [ 16, 3, 16]
      }
```this what it is now
wary edge
#

It wont work

untold magnet
#

lemme try with 4

untold magnet
cinder shadow
#

Mm I have something somewhere

#

But that was with an early version of my potion sponges where I cared about performance

#

Now I'm just using on tick and getting all entities lol

untold magnet
#

I'll make the collection box 4, and the selection box 3 to match the block sizes

#

umm

#

that onStepOn will work only one time

#

how to make it looping?

#

i mean when the entity stands on it, not step

celest fable
#

is it possible to do multi threading on script api, and what's the benefits of doing multi threading

tiny tartan
cinder shadow
untold magnet
#

oh wait, i actually got a better idea

#

yah that makes sense

#

onStepOn will turn on an interval that moves the entities, onStepOff will turn it off

#

noticed, I'll do that tomorrow

#

thanks for the help guys, bao_doggo_happy

neat hound
# untold magnet well, this script: ```js if (block.below(0.1)) entity.applyImpulse(,,,) ```...
  1. for the math, you can use the address of the center of the block, with testing to determine how far out for a player to be fully inside the block. The player's location is a decimal number that is "kinda" down to the pixel.

  2. if the player is on the edge of the block, he is also on another block, You can test the surrounding blocks for the player and assume if they pick him up too, he is on the edge.

untold magnet
#

thanks for help but i already found a better way to do that,

neat hound
#

I played with a conveyor too. I just opted to move everyone to center of block so that I did not have to worry how it looked if they were traveling on the edge.

inland merlin
#

But you can make multiple intervals and control those

#

But threading is a no

fiery solar
#

Is there a difference in the way that the android version of the game loads chunks? I thought that if a chunk was loaded then all y positions in that chunk would be loaded, which seems to be the case on Windows, but I'm getting errors when trying to get blocks away up towards the top of loaded chunks in the overworld on mobile.

twilit tartan
#

I recently bought a graphics tablet, but when I use it in blockbench the cursor disappears, does anyone know how I can disable this?

cold grove
misty pivot
#

can i do something like this?

function myFunction()
const function = myFunction();```
subtle cove
wheat condor
#

Guys do y all know what’s new on server ui 2.0.0 alpha? Is this the first version on Ore Ui?

unique dragon
#

i don't think ore ui it's available

#

for now

#

cause server ui it's just for Forms

remote oyster
prisma shard
#

its been a long time since its outdated

wheat condor
distant tulip
untold magnet
#

sup guys, um is it possible to use onStepOn and onStepOff inside of one worldInitialize?

untold magnet
#

also

#

um

#

i should use a function that will have the runInterval that will be turned on using onStepOn and turned off using onStepOff?

shy leaf
#

just

#

add tick component

#

and set dynamic property on player on both onStepOn and onStepOff

#

make the onTick to check it

untold magnet
#

i dont wanna use onTick for each conveyor, bec its going to be so laggy

untold magnet
shy leaf
#

then put system.runInterval outside the block component

untold magnet
shy leaf
#

and use it to check for the dynamic property

shy leaf
untold magnet
#

oh,
theres something called setInterval and clearInterval

inland merlin
untold magnet
# inland merlin runInterval, clearRun

um, I'll put that inside of a function, how can i turn it on and off?
function e(entity, interv) ???
if (interv = true) interval,,,
if (interv = false) clearRun(interval) ???

#

onStepOn: i => { e(i.entity, true) }
onStepOff: r => { e(i.entity, false) }

#

like that?

untold magnet
#

when the block is broken, it will not stop that interval

#

so the entity will keep moving

#

it is bugged, I'll use something else ig

fiery solar
untold magnet
distant tulip
umbral scarab
#

How would I go about this:
When a damage source (e.g. ender crystal, creeper, or tnt) happens it only applies to the player that triggers it through a right clickable item etc

#

so event source

cold grove
#

You want to cancel player being hurt?

untold magnet
umbral scarab
vast comet
unique dragon
unique dragon
#

but ore ui will take more time

#

as i remember, It'll be another module

crude bridge
#

do i have any chance to sell this addon or does it suck?

vast comet
#

If it is yours in the first place

crude bridge
#

all the rp is not mine

vast comet
#

alr
my bad

crude bridge
#

np

remote oyster
# crude bridge the behavior

Seems your behavior is built around a custom resource pack. Guess the question is, what does it look like, and how does it compare to a vanilla environment. Since it's very likely if you only sell the behavior pack for legal reasons, then that is probably what the majority are going to experience.

untold magnet
#

so this:

   onStepOn: i => {
      const interval = system.runInterval(() => { world.sendMessage('On') })
    }
```gonna send messages when the entity steps on it, how can i turn that off when the entity is no longer above the block?
vast comet
untold magnet
vast comet
#

the entity is moving

untold magnet
#

i should put that inside of the interval right?

vast comet
#

either that or combine onStepOff and block break to clear the run

untold magnet
#

and the entities will keep moving on, jeez i cant make anything without problems

vast comet
#

sadly yes

warm drum
#

Why using block volume to replace block is so slow?

valid ice
#

?

ionic kayak
#

What should I use to detect a left click (single click on mcpe) while holding a specific item?

misty pivot
#

i made a form that lists all the players in the world into buttons but when i click it, it doesn't open the following form

const playersList = world.getPlayers();
for (let playerList of playersList) {
    formbutton(playerList.name)
    form.show(player).then((data) => {
        let result = data.selection;
        console.warn(result)
        playerInfoForm(player, playersList[result])
    })
}```
valid ice
#

what is formbutton? And why do you show the form for every player in the world?

vast comet
#
    const form = new ActionFormData()
    const players = world.getPlayers()
    for(let i = 0; i < players.length; i++) {
      form.button(players[i].name)
    }
    form.show(player).then((r) => {
      if(r.canceled) return
      const selectedPlayer = players[r.selection]
      //...
    })
untold magnet
#

is it gonna be laggy??

#

32 commands is slightly better than using onTick which is gonna be really laggy cuz u will place multiple of those blocks

#

lets say u have over 100 conveyors on ur world, and each one uses onTick, how laggy is it going to be?

vast comet
#

is it really any better?

untold magnet
vast comet
distant gulch
#

Sigma Sigma

#

Wtf is my name

#

I did not make it heil

#

Why can't I change it

distant gulch
#

Because I used that for mobile for my SCP mod

vast comet
#

what dose that mean

distant gulch
#

Bruh

#

What does what mean

vast comet
#

"certain variables"

distant gulch
#

Like ya know making a custom attack time variable in API

#

Like the attack_time in rp

ionic kayak
#

ohh yea right

distant gulch
#

Or you could use player.json in bp to detect if punching then just add a tag and detect it in API

#

Both ways work

vast comet
#

mobile users cant punch air as far as i know

distant gulch
#

Mine can

#

Prolly for certain things

#

Idk

#

I'm acoustic

vast comet
#

idk
maybe it is related to the new controls

distant gulch
#

Prolly

#

Now why the fuck is my name heil

#

I haven't used this server once till now

#

I just joined it to join

#

I don't even remember when I joined this server

#

Prolly like 3 years ago or sumting

vast comet
#

auto changed?
probably have some wired Unicodes

distant gulch
#

Bru

distant gulch
#

Barely used script API but now I do for reloading systems and stiff

distant gulch
#

It's what I use all the time

#

Is bp

#

For detecting punches

vast comet
distant gulch
#

Bru

#

Real

vast comet
#

world gen 🤡

distant gulch
#

Script API is coming to consume us

#

For all we know eventually a single JavaScript code could replace a whole addon bruv 💀

#

Besides sounds and textures I guess

vast comet
#

nah
vanilla stuff depend on most of what addons depend on

remote oyster
distant gulch
#

query.attack_time > 0.01

#

That's what I use all the time

valid ice
#

It's not a query- it's a variable

distant gulch
#

Nvm it's variable.attack_time Im stupid

#

I've been getting rusty since I haven't worked on an addon since like a month

#

Because my girlfriend keeps taking up my time

remote oyster
#

I was getting ready to share the link for query functions to have it be pointed out because I was looking like, "It ain't there" haha.

distant gulch
#

I'm pretty sure v.attack_time works in bp if not then just create a custom attack in the player.json and hook it up ig idk

valid ice
#

It does, yea

distant gulch
#

I only used it like couple times ngl, only for my BlockOps addon

vast comet
#

animation control work with variables?

distant gulch
#

Yes

vast comet
#

nice

distant gulch
#

Imma go now it's pookie time

untold magnet
#

how to make getDimension([?]) detect all 3 dimensions?

valid ice
#

loop through each possible dimension

#

const dimensions = ['overworld', 'nether', 'the_end'].map(dim => world.getDimension(dim))

woven loom
#

why we dont have them as property weird

honest spear
valid ice
#

yeh was about to say that lol

honest spear
#

properties doesn't make sense

woven loom
#

hm

valid ice
#

It makes sense to have properties at this time, but for futureproofing & later additions, the method makes sense

wary edge
#

Which will come first...Custom Dimensions or server-2.0.0

woven loom
#

in my fw i add them as property

cinder shadow
woven loom
#

con do u have any ds thats O(1) at each opertation

woven loom
cinder shadow
#

my fan block that I just started working on against this past week

glacial widget
#

does anyone know why this doesnt work?

const inventory = player.getComponent(`inventory`).container
const block = player.dimension.getBlock({ ...player.location, y: player.location.y + 2 })
const chest = block.getComponent(`inventory`).container

                           for (let i = 0; chest.size; i++) {
                                const item = chest.getItem(i)

                               if (item) inventory.addItem(item)
                          }

                            block.setType(`minecraft:air`)
cinder shadow
#

"chest.size" isn't compared to i

glacial widget
#

everything else works

cinder shadow
#

okay well I don't know what the problem was, you only said "it doesn't work"

glacial widget
#

so do you know why the chest does not turn into air?

cinder shadow
#

block.setType({id: 'minecraft:air'})

glacial widget
cinder shadow
#

oh wait mb, you don't need the id part

#

block.setType('minecraft:air') works just fine

#

I'm honestly surprised your game isn't just crashing with your for loop

#

There's no way it's not

#

unless it just errors out

glacial widget
wicked shard
#

bro

#

use

glacial widget
#

also its inside of a function so its not running globle

wicked shard
#

system.run(() => { block.setType(`minecraft:air`) });

#

this is gon work

#

trust

glacial widget
#

is it?

valid ice
wicked shard
#

try it

glacial widget
valid ice
#

huh?

glacial widget
valid ice
#

I don't get what you're asking

glacial widget
valid ice
#

oh

glacial widget
valid ice
#

That still doesn't really explain much but uhhh ok

glacial widget
glacial widget
glacial widget
#

my for loop didnt have the 2nd condition

cinder shadow
#

🗿

glacial widget
fallow rivet
#

All heads in a player's inventory are listed as "minecraft:skull"

#

How do I tell these heads apart?

valid ice
#

You don't.

fallow rivet
valid ice
#

Yes

fallow rivet
#

This made me sad

valid ice
#

indeed

distant tulip
fallow rivet
distant gulch
distant tulip
#

yo said "tell these heads apart"
So no
testfor command

fallow rivet
distant gulch
distant tulip
distant gulch
#

To tell the difference between a Data block or item either detect the Data or the Name

fallow rivet
#

I solved the problem

let banneditemslist = [[minecraft:skull]]

distant tulip
#

🗿

fallow rivet
distant tulip
#

what is that for

fallow rivet
#

Auction

valid ice
#

uh why the double braces

fallow rivet
valid ice
#

but double?