#Script API General

1 messages · Page 57 of 1

radiant drumBOT
subtle cove
radiant drumBOT
wary edge
#

Last actual ScriptAPI message: #1067535608660107284 message

stark kestrel
#

hi

strange marsh
#

If you remove me, I'm demoting you.

obsidian coyote
radiant drumBOT
tiny tartan
#

tf is goin on here?

open urchin
#

avoiding discord limits

obsidian coyote
#

For context; Discord has a limit of 1000 members that can follow a single thread, causing new people to not be able to send any new messages.

unique acorn
#

are users who arent active getting removed or its random?

wary edge
neat hound
#

Well random since Hero was removed and I was not

obsidian coyote
unique acorn
#

Okay

granite badger
#

hi guys

unique acorn
#

hi

obsidian coyote
#

hello jayly

tiny tartan
#

hello

obsidian coyote
#

We didn’t know either until we reached it 😭

remote oyster
#

Haha

#

Discord Devs were ahead of us on the chess board.

drowsy scaffold
#

Resaving my spot

remote oyster
#

I suppose that's a big milestone to accomplish though lol.

deft nest
#

help chat

remote oyster
# deft nest help chat

I don't think that event triggers for every block type? I could be wrong since I don't regularly use that event myself. I would verify by adding something like "console.log("test")" somewhere in your event to confirm if it is in fact triggering when you go to "interact" with the iron block. If you find that it isn't returning that log then you may need to consider a different block.

untold magnet
fading sand
#

Anyone have an example code for an sneak input event signal?

empty yoke
#

Is there any way to prevent block collision on player?

olive rapids
#

Can someone help me fix a script?

#
world.afterEvents.itemUse.subscribe((click) => {
    let player = click.source, itemUse = click.itemStack
    if (itemUse.typeId == "minecraft:chest") { player.runCommand(`playsound random.chestopen @s ~~~ 1 1.1; itemShop(player) }
#

When this is executed, it usually has some errors such as: executing twice, this is due to lag, can someone fix it?

olive rapids
true isle
#

instead use dimension.playsound('sound_here')blockLocation

#

and do blockLocation = block.location;

boreal siren
#

Why doesn't this work?

#
import { BlockPermutation, BlockVolume, world } from "@minecraft/server";

world.beforeEvents.playerInteractWithBlock.subscribe((event) => {
    const { player, block } = event;
    const { x, y, z } = block.location;
    const overworld = world.getDimension("overworld");
    if (block.typeId === "minecraft:chest") {
        event.cancel = true;
        replaceBlock(overworld, block, x, y, z);
    }
});

function replaceBlock(overworld, block, x, y, z) {
    const blockData = block.permutation.getAllStates();
    const newBlock = BlockPermutation.resolve("minecraft:ender_chest", blockData);

    // Используем fillBlocks(), но только для 1 блока
    const volume = new BlockVolume({ x, y, z }, { x, y, z });
    overworld.fillBlocks(volume, newBlock, {
        blockFilter: { excludeTypes: ["minecraft:chest"] }
    });
}
true isle
#

change playerinteractiwithblock to just onInteract

boreal siren
#
[Scripting][error]-ReferenceError: Native function [Dimension::fillBlocks] does not have required privileges.    at replaceBlock (main.js:21)
    at <anonymous> (main.js:9)
boreal siren
true isle
#
world.beforeEvents.worldInitialize.subscribe(eventData => {
    eventData.blockComponentRegistry.registerCustomComponent('blushrooms:saplings', {
        onPlayerInteract(e) {``` like this
unique acorn
true isle
#

thats a block component

#

it would register as item component if it was item

unique acorn
# true isle thats a block component

block, yes my bad but he is testing for when vanilla chest was interacted with, and you can't edit vanilla blocks (so he can't add that component to it)

true isle
#

no but he can write it as a global thing like they do with vanilla tools

#

unless you cant overwrite vanilla sounds

random flint
warm mason
# true isle and do blockLocation = block.location;

Variables are needed to reduce the number of characters in the code and increase performance. In this case, you remove only the dot, but at the same time you need to set a variable, which already takes up a lot more characters. This is not critical, but such variables are useless

wary edge
#

That's not what variables are for entirely. You use variables to make code readable and to reuse values. It's not strictly to reduce the number of characters or increase performance.

warm mason
true isle
#

i mostly do it because i forget punctuations in scripts

#

and also cuz it makes it easier instead of random.dots.ever.time

warm mason
# boreal siren ```js import { BlockPermutation, BlockVolume, world } from "@minecraft/server"; ...
import { BlockPermutation, BlockVolume, world, system } from "@minecraft/server";

world.beforeEvents.playerInteractWithBlock.subscribe((event) => {
    const { player, block } = event;
    if (block.typeId === "minecraft:chest") {
        event.cancel = true;
        system.run(() => {
          replaceBlock(block);
        })
    }
});

function replaceBlock(block) {
    const newPermutation = BlockPermutation.resolve("minecraft:ender_chest", block.permutation.getAllStates());

    block.setPermutation(newPermutation)
}
true isle
#

yeah thats alot simpler than what he had

random flint
#

How am I supposed to use ListBlockVolume from dimension.getBlocks()?

I tried .getBlockLocationIterator(). But [...iterator] made a syntax error. And for (let e of iterator) crash my game

random flint
#

Doesn't have it anymore.

Switched to my own approach to get the blocks. Do you really need the code to analyze it?

warm mason
random flint
#

I'll try recreating it later.

I speculate that the BlockVolume I fed onto the .getBlocks() has its Y coord value exceeded the allowed build height or smt

warm mason
random flint
#

Ah I see, you use next().

You might want result instead of value for that while (arg)

fading sand
#

can anyone give me an example code of an entity hit block event signal?

fading sand
#

thx, already found it now lmao

#

how do i cancel the block break tho?

somber cedar
fading sand
#

thx

prisma shard
#

hi

tender pier
#

anyone knows how can I make the player interact with only the empty hand?

prisma shard
cold grove
#
if (selectedItem) {
    // Action with item in hand
}    else {
    // empty hand
}
#

There is a logic error because your are checking if there is an item in hand, and if true, check if there is no item in hand lol

prisma shard
#

oh i didnt see tadase

tender pier
prisma shard
#

the tadase's one was better

distant tulip
#

-# who pinged bao_foxxo_smug

dense skiff
#

[Scripting][error]-ReferenceError: Native function [Entity::addEffect] does not have required privileges.
I've never come across this scripting error before, what does it mean? Here's the line it refers to:

player.addEffect('haste', duration, { amplifier: 2 });
wary edge
dense skiff
#

Ah

#

Interesting it uses the native function name in the error

dim tusk
#

Who pinged me

untold magnet
#

the problem is solved anyway so, sorry for the ghost pings

tidal wasp
#

Can I get some help with this

dim tusk
tidal wasp
#

Im struggling to figure out how to name each plain that I named and how to tell which one I interacted with

#

wait i just figured out how to name them

#

still dont know how to tell which one I hit

untold magnet
warm mason
dim tusk
#

you also need to subtract the location and the faceLocation

#

wait, Imma check my chess addon

#

Wait what are you doing btw so I could give a proper sample and explanation (if I could)

tidal wasp
#

Im trying to figure out where on the block I touched so the block knows which permutation to place

tidal wasp
#

No

#

It's a 16x4x4 beam

dim tusk
#

wait are you doing face or 3d selection

tidal wasp
#

Or 4x16x4, or 4x4x16 depending on direction

tidal wasp
#

So if it places in the red areas it places vertically

#

If it places in the blue areas it places horizontally

dim tusk
#

2px?

#

or you want to half the block into 4 selections

tidal wasp
#

And 16 pixels long for the blue and 8 long for the red

amber granite
#

Guys

#

How can i implement binary tree to my Vector saving db

tender pier
#

Can someone help me with this error?

#

I'm trying to spawn a particle on my block, the particle spawns but I don't know what is this

dim tusk
# tidal wasp It's 4 pixels wide
world.beforeEvents.playerInteractWithBlock.subscribe(({ block, player, blockFace, faceLocation }) => {
    if (blockFace === 'Up' || blockFace === 'Down') return;

    const localX = faceLocation.x - block.location.x, localY = faceLocation.y - block.location.y, localZ = faceLocation.z - block.location.z;

    const topRegionStart = 12 / 16;
    const bottomRegionEnd = 4 / 16;
    const leftSideEnd = 6 / 16;
    const rightSideStart = 10 / 16;
    
    if (localY >= topRegionStart) console.error("top");
    else if (localY <= bottomRegionEnd) console.error("bottom");
    else if (localX <= leftSideEnd) console.error("left");
    else if (localX >= rightSideStart) console.error("right");
    else console.error("middle");
});```
tidal wasp
#

can this go into a beforeplayerplace component?

dim tusk
#

untested lol

tidal wasp
#

well time to test it lol

dim tusk
amber granite
#

Question if i make dynamic propreties , but not use the 64k bites all ,
Do they occupy just the things that is in them , or they occupy the whole 64k ?

dim tusk
#

It has 32767

tender pier
dim tusk
thorn flicker
amber granite
#

U see this db

dim tusk
amber granite
#

Like , i have vectors and they will grow linearly

#

How to say it :
I have db to save vec3 locations

dim tusk
tender pier
amber granite
#

And if u add more and more vec3 to it ,
It will take long time to get it all for u

amber granite
#

The problem is searching time itself

#

Like it gets everything

amber granite
#

That s the problem

dim tusk
#
{
   key1: { x: 0, y: 0, z: 0 },
   key2: { x: 0, y: 0, z: 0 }
}```
amber granite
#

It doesn't have keys, it safes locations like this :
/X:y:z/x:y:x/x:y:z/

amber granite
#

:-:

dim tusk
#

Lot of checks is bad

amber granite
#

;-; i want a smart way to combine between memory management and low searching time

distant tulip
dim tusk
true isle
#

can you save locations using an array?

thorn flicker
dim tusk
#

you mean this?

distant tulip
dim tusk
#

or this

[
  "0, 0, 0",
  "0, 0, 0",
]```
distant tulip
amber granite
dim tusk
amber granite
#

Then retrieve them later

amber granite
dim tusk
dim tusk
amber granite
#

But it s database,_,

#

Like i save thousands of locations there

dim tusk
amber granite
#

I made that

#

What i mean making too many object

#

Is not the gokd way tl fo it

#

It s not the good way to do it

tidal wasp
#

And i actually understand how it works

#

Also

dim tusk
tidal wasp
#

Why are you using / for the variables?

dim tusk
thorn flicker
tidal wasp
#

Is that how you make coordinates in variable?

dim tusk
amber granite
#

Hmm is there a possibility to get location arranged based on their chunk location?

#

Hmmm that looks interesting

distant tulip
amber granite
#

Yeah i need to implement binary tree somehow to make searching or loading location more efficient

#

Any ideas ?

dim tusk
#

^ unrelated but this is one of the proudest scripts I ever did.

thorn flicker
thorn flicker
#

but then again it couldve been an error on my part back when I was using setSpeedAndDirection,
but I do still remember someone telling me to use setVector3 instead

amber granite
dim tusk
amber granite
#

Like
SetDb("locsChunk-0:0:3")

tidal wasp
#

Ok yeah this officially out of my area of expertise

#

Which was miniscule to begin with

dim tusk
#

I prefer storing them in one dynamic property then keep making new ones if it's full than creating multiple dynamic properties for each one.

#

Locations i mean.

distant tulip
amber granite
#

Like i want to optimize my db as far as i can

dim tusk
#

I did my chess add-on my statistics addon with taht

#

And everything works fine

#

and yes I tried with multiple peoples like 10 people in a server and works fine.

amber granite
#

:-: yeah but when working with locations,_,

#

._.

thorn flicker
dim tusk
#

if you don't want my idea then don't.

amber granite
#

._. no i just want suggestion

#

S

dim tusk
#

like, as i said make a key

amber granite
#

._. ok question

#

Why will someone use Vec3 db ?

dim tusk
amber granite
#

:-: hmm

dim tusk
#

make a key.

amber granite
#

Hmm ok i need it for my add-on

dim tusk
#

how the hell you would differentiate each location if you don't know how to?

amber granite
#

And find out that when i add 300 locations world get low response time

amber granite
#

Like i can't make them in one dynamic proprety

dim tusk
#

you waste too much space in one dynamic property

#

-# thanks for the idea r4isen

amber granite
#

Just , do u know how much power , cpu power , ram does it consume to keep 10 mb string in ur memory:-: every 100 location

dim tusk
#

AS I SAID DO IT WITH MULTIPLE DYNAMIC PROPERTY, I JSUT GAVE AN IDEA

#

If you want multiple then do it.

#

I have mine and you have yours 🤷

amber granite
#

And what about the time for getting all data from ur db in one variable as string

amber granite
dim tusk
#

it's how you do your script. If it's bad then bad

#

Umm, I gave you this?

#

this acts like one dynamic property, at least you're not going to waste some space.

amber granite
#

I just finished my db bro

dim tusk
#

man I'm outt my head hurts with you lol

amber granite
#

Yeha here is it

amber granite
#

So u thought i didn't start making it yet :-:

dim tusk
#

I already saw that.

dim tusk
amber granite
#

But i want ideas to optimize it , that what i mean

dim tusk
amber granite
#

._. maybe

fallen hearth
#
const ovw = world.getDimension('overworld')

world.afterEvents.entitySpawn.subscribe(ev => {
  const entity = ev.entity;

  if(entity.isValid())
  for (const dono of ovw.getPlayers({ location: entity?.location, maxDistance: 16 })) {
    if (dono.hasTag("hxt")) {
     var nickName = dono.name

     var dano = 0
     var raio = 0
     var power = world.scoreboard.getObjective('power').getScore(dono);
   }
  }
}

Error: Failed to get property 'location' at <anonymous>

#

help me?

amber granite
#

I m very bad at explaining :-:

dim tusk
amber granite
#

Ok lemme link my ideas , and i ll tell u what i want precisely

#

Well, my add-on needs to load locations from the database, and this takes time because it is looping on many Dynamicpropreties, and after loading this big amount of data, it puts it in one variable, and it needs at least to save and load 300 sites every event trigger, I have no problem With saving, but I have a problem with the loading, because it consumes a lot of time, the more sites,

fallen hearth
amber granite
#

@dim tusk

dim tusk
amber granite
#

Then ?

dim tusk
#

that's why I said save it in one dynamic property to consume all spaces

#

then just add another one if it's full

amber granite
#

I did that before i implemented this

dim tusk
amber granite
#

But my problem is in the way the db load the locations

#

Like if i call a function to load locations ,
It loads everything

#

From a to z

dim tusk
cold grove
dim tusk
amber granite
dim tusk
cold grove
#

You split your array into different dynamic properties??

dim tusk
#

and why use var in the first place?

amber granite
#

No like effecient way that it only load one dynamic property

#

Like a smart db location loader

amber granite
dim tusk
amber granite
#

._.

#

Sorry

dim tusk
amber granite
#

No

#

I m using a dp until it gets full

#

Then after it gets full i add another one

#

And so on

cold grove
#

Thats not efficent 🤔

amber granite
#

So if it loads anything it loads everything with it

dim tusk
amber granite
#

Like if i saved 10 dp

dim tusk
#

it won't do that unless you load what you only need

amber granite
#

I just need the locations themselves

dim tusk
#

you just waste them.

amber granite
#

So any ideas to make it more optimized

#

Like i need to load locations, so i can spawn an entity inside the block that is in that location

#

But with no keys needed

#

Like if entity A is in Block B
I need to check if there is another block C that the entity get Teleported to it after Block B get destroyed

#

For that i need to save location, to check if there is a block or not

cold grove
#

How do you identify the block C?

#

Based on the coordinates of the inital block?

amber granite
#

Yes

#

Block C must be in range of 40 blocks radius around the destroyed block

#

Like in area of 5 x 5 chunks around it

cold grove
#

When do you save the block C?

amber granite
#

Any ideas ?

fallen hearth
amber granite
#

When block B get placed and the entity get spawned inside it ,
After that block C will get saved

tidal wasp
amber granite
#

Imagine it like u have a ball

amber granite
#

And u must through it to ur partner in football game

dim tusk
cold grove
#

You are telling that you need tp the entity to C if theres a block B

#

You are already checking if C exists, you dont need to store it

amber granite
#

No tp it after block B get destroyed

amber granite
tidal wasp
#

I'm going to have to export the values from the code you sent me into a beforePlayer Place component

cold grove
amber granite
#

I didn't understand u ?

fallen hearth
cold grove
#

Check if theres a block C in an AxB area

amber granite
#

I need to loop through the whole AxB

fallen hearth
#

How can an entity that was summoned not exist?

dim tusk
cold grove
amber granite
#

Nah that s not effecient

#

I mean at all

#

Like it can cause great lag on my world

cold grove
#

Faster than the db you have i think

#

Or store it using the entity's dynamic properties

cold grove
#

you are complicating your life

amber granite
#

Nah i need the performance ._. because it s chunk loader

amber granite
#

Elaborate

cold grove
amber granite
#

Maybe :-:

#

Hmmm

#

U won't check 80 x 80 x 256 blocks

#

U know that right

cold grove
# amber granite Elaborate
const entity = dimension.spawnEntity();
cons block = ...; 
entity.setDynamicProperty('tpto', block.location);
cold grove
amber granite
#

From down to top of the world

cold grove
#

Why

amber granite
#

Because it s chunk loader

#

Even block on Y = -63 is still have right to load the whole area

cold grove
#

You can define where the block will be placed always??

amber granite
#

The block itself is placed by player

cold grove
#

Wich one

amber granite
#

Redstone Machinerist

#

"As example"

cold grove
#

And the other one?

fallow rivet
#

Can I test a player's use of a bow?

amber granite
cold grove
#

What

amber granite
#

Big farm builder

#

Like idk , iron farm

#

A big cactus farm

#

A big computer in Minecraft bedrock

cold grove
#

Hmmm well

fallow rivet
amber granite
#

Like who will need chunk loader except them ?

cold grove
#

You can still store the blocks, load them all in once into an Set/Map when the world starts

amber granite
#

But...

#

But they keep growing every event

#

I mean if place event get triggered or break block event get triggered

cold grove
#

How you was checking it before?

amber granite
#

Same way , but using object

amber granite
cold grove
#

now

#

maybe you can set a limit of 1 block per chunk

amber granite
#

B Block get destroyed, Loading db , Searching for location that is far at least 40 block away , then spawn there , remove the location from db

dim tusk
amber granite
#

Hmmm u gave me an idea

cold grove
#

save into a MAP

amber granite
#

What about making each chunk of the game it s dynamic propreties, then when i need location from there i just use chunk id

#

Because my system works on 5 x 5 chunks

#

So i ll get Broken block chunk location

cold grove
#

not all

amber granite
marsh pebble
#
import { world, system } from "@minecraft/server";

console.log("loaded")

system.runInterval(() => {
    for (const player of world.getPlayers()) {
        const blockLocation = player.location;
        blockLocation.y -= 1;
        const block = player.dimension.getBlock(blockLocation);
        if (block && block.typeId === "skygen:plotp") {// change this to the block eg minecraft:gold_block
            console.log("Standing Ontop")
            if (player.hasTag('mytag')) {}
            player.runCommandAsync("function locationDB")// anything you put in here it will run eg a console.log or in you case the CommandRunning
        }
    }
}, 120);// the '20' is the tick delay```
marsh pebble
#

Cool thanks

amber granite
fallow rivet
cold grove
# amber granite Elaborate

when do you place the "C" block, you get a corner coordinate of the current chunk based on the location, and you relate the chunk corner to the "C" block coordinate
, if the inital block gets break, you just check the surrounding chunks, idk

amber granite
#

Good idea

dim tusk
cold grove
marsh pebble
#

What?

cold grove
#

you put the code you want to execute conditionally (if) inside of the {}

dim tusk
cold grove
tawny jungle
simple zodiac
#

I see, the purge happened

chilly fractal
#

THE PURGE SEASON 3 HAS HAPPENED@! (It didn't but, this is more pog than it)

chilly fractal
tawny jungle
#

bro

#

im saying i tried this

#

i used try catch to get the block

chilly fractal
#

In your thread i don't see any try catch calls

tawny jungle
#

no i removed it after

chilly fractal
#

Bruh

tawny jungle
#

ill throw it in again though

chilly fractal
#

Nah you are using it wrong

#

And without it

#

It will absolutely throw the error

#

Either you did:
} catch(e) { // or any other variable

#

Or you just used try catch block without moving the other code related to block inside

tawny jungle
#

maybe i did do it wrong

#
    const blockFaceValue = block.permutation?.getState("sci:block_face");
    const blockRotation = block.permutation.getAllStates();
    // Coral death function
    try {
        const block = data.dimension.getBlock({x: 16, y: -60, z: -121});
        if (block.hasTag("sci:livingCoral")) {
            const connected = mBUniqueFunctions.utilities.isConnectedToBlock(block, 2, undefined, "water")
            const coralDeath = system.runTimeout(() => {
                if (block.isValid) {
                    if (block.hasTag("sci:livingCoral") && connected.result === false) {
                        const coralTable = {
                            "sci:tube_coral_block_mini": "sci:dead_tube_coral_block_mini",
                            "sci:brain_coral_block_mini": "sci:dead_brain_coral_block_mini",
                            "sci:bubble_coral_block_mini": "sci:dead_bubble_coral_block_mini",
                            "sci:fire_coral_block_mini": "sci:dead_fire_coral_block_mini",
                            "sci:horn_coral_block_mini": "sci:dead_horn_coral_block_mini"
                        }
                        const coralStages = Object.entries(coralTable);
                        for (let [currentType, nextType] of coralStages) {
                            if (block.typeId === currentType) {
                                block.setType(nextType);
                                block.setPermutation(BlockPermutation.resolve(block.typeId, blockRotation));
                                break;
                            }
                        }
                    }
                } else {
                    system.clearJob(coralDeath)
                    return;
                }
            }, 45)
        }
    } catch (error) {
        console.warn('gvnujik')
    }```
is this incorrect?
chilly fractal
#

Correct usage (If you still don't know):
Before:

const block = <dim>.getBlock(<loc>);
console.log(block.typeId);

After:

try {
  const block = dim.getBlock(<loc>);
  console.log(block.typeId);
} catch {
  console.log('Block unloaded or other error.');
}
chilly fractal
#

Almost correct

#

But remove that (error)

#

To silence the error from being sent

chilly fractal
tawny jungle
#

oh forgor to remove

#
        const block = data.dimension.getBlock({x: 16, y: -60, z: -121});
        if (block.hasTag("sci:livingCoral")) {
            const connected = mBUniqueFunctions.utilities.isConnectedToBlock(block, 2, undefined, "water")
            const coralDeath = system.runTimeout(() => {
                ... (removed for easier reading)
            }, 45)
        }
    } catch {}```
so something more like this?
chilly fractal
#

Yeaaa

fallen hearth
#

I'm trying to get the name of the first family of my entity but it gives an error in [0]

  const familyComponent = player.getComponent("minecraft:type_family")

  const oneFamilia = familyComponent.families[0];

help me?

tawny jungle
chilly fractal
#

Nah i am frickin sure it shouldn't

#

It's literal pure js concept

wary edge
chilly fractal
#

Nah i gotta bounce anyway

#

When is the purge S4 gon happen tho lol?

tawny jungle
fallen hearth
dim tusk
#

family.getTypeFamilies()[0]

#

It returns arrays of family entities.

fallen hearth
#
  const familyComponent = player.getComponent("minecraft:type_family").getTypeFamilies()[0]
dim tusk
wary edge
fallen hearth
#

it doesn't pick up the first family listed in the component

wary edge
fallen hearth
wary edge
#

It could be returning it in alphabetical order perhaps?

fallen hearth
#
"minecraft:type_family": {"family": [ "aaa","zzz","ddd" ]}
sterile epoch
#

does anyone know why .getComponent("minecraft:scale").value; is undefined even tho the entity has scale component

fallen hearth
#

I changed the name and still

wary edge
#

Well what does it return?

fallen hearth
wary edge
fallen hearth
#

zzz

dim tusk
#

Check the order of it.

#

Then compare it in the json

fallen hearth
#

@dim tusk gives the same result

dim tusk
fallen hearth
dim tusk
fallen hearth
dim tusk
#

//json

[ "family1", "family2", ... ]```
//console
```js
[ "family1", "family2", ... ]```
fallen hearth
#
"minecraft:type_family": {"family": [ "aaa","zzz","ddd" ]}
#

console: zzz

wary edge
#

What does getTypeFamilies() return?

fallen hearth
#

zzz

#

zzz

wary edge
#

Then your component is wrong.

#

There's no way it returns only zzz if the array is 3 values.

fallen hearth
dim tusk
fallen hearth
#

but in random order

#

I've already used it

#

DOES NOT RETURN IN ORDER

tidal wasp
wary edge
dim tusk
#

What you gave us is a single string we want the whole array

fallen hearth
dim tusk
#

try adding more families to the mob and do the console log again... Maybe the first and second family are flipped

tidal wasp
fallow rivet
#
const entity = player.dimension.getEntities({type: "minecraft:arrow", radius: 2})[0]
#

I tried something like this but it still doesn't work properly, sometimes it doesn't find the entity

distant tulip
#

what do you need that for

fallow rivet
#

When the player shoots an arrow, I want to tag that arrow.

thorn flicker
#

yeah but hes asking why

fallow rivet
#

I want this to make various custom bows

dim tusk
distant tulip
#

what is the tag for

fallow rivet
fallow rivet
distant tulip
#

you can use projectile component to get the owner, if that what you are looking for

fallow rivet
#

I'll look into this

wary edge
tidal wasp
#

Actually

fallow rivet
#

Is projectileHitBlock this event?

distant tulip
#

wdym

tidal wasp
#

Is there any whay to tell where on the block the player clicked with beforePlayerPlace like faceLocation in onPlayerInteractWithBlock

fallow rivet
#

I don't understand what you mean by "projectile component"

dim tusk
fallow rivet
distant tulip
fallow rivet
#

Thanks

tidal wasp
#

Oh

fallow rivet
dim tusk
distant tulip
tidal wasp
#

1.21.70

#

I have beta api and upcomming creator features enables

#

and in the manifest its beta 2.0.0 for minecrafr server and server ui

distant tulip
#

worldInitialize is under system class now

tidal wasp
#

Still gives me those errors

#

wait then why can it read it for main.js

distant tulip
tidal wasp
#

ok so its something else

dim tusk
#

it's still under the world tho instead of the worldInitialize it's worldLoad iirc

distant tulip
#

🤷‍♂️

tidal wasp
#

???

#

You know I have nothing in particular that in even need from the beta api when it comes server wise so I'm just going to use 1.17 or something like that

dim tusk
# distant tulip 🤷‍♂️

WorldAfterEvents renamed property worldInitialize to worldLoad

WorldBeforeEvents removed property worldInitialize

WorldInitializeAfterEvent renamed to WorldLoadAfterEvent

WorldInitializeAfterEventSignal renamed to WorldLoadAfterEventSignal

Removed WorldInitializeBeforeEvent

Removed WorldInitializeBeforeEventSignal

distant tulip
#

@tidal wasp @dim tusk
yeah, as i was saying
system.beforeEvents.startup

distant tulip
#

yep

tender pier
#

how can I detect when a block has a specific state?

tidal wasp
#

ok yeah im going to need to use 2.0 beta

#

Actually no I can do what I was doing previously

dim tusk
tidal wasp
tender pier
slow walrus
#

o7

#

I survived

jovial wren
#

Is this necessary to run scripts? I'm trying to make my addon work on education edition but it doesn't have the experimental features section

#

I get this error when I remove it

cold grove
jovial wren
#

But I do though

cold grove
#

you reloaded it?

jovial wren
#

ya

#

I reloaded the world, and even restarted the game

cold grove
#

and?

jovial wren
#

Same error as before

elder spindle
#

Does the chat timeout eventually? Just need to know so I can see if i can get forms to open after a command

cold grove
jovial wren
#

No I built the addon for bedrock and then disabled experimental features to try and make it work for education edition, but the server gametest module doesn't have a non-beta version

cold grove
dim tusk
#

you can try to keep opening it

cold grove
#

So you need to keep showing the form until the response is not cancelled

elder spindle
dim tusk
#
world.beforeEvents.chatSend.subscribe(ev => {
   if (ev.message === '!test') {
      system.run(async() => [
         await forceShow(ev.sender, new ActionFormData().title('test').button(''));
      });
   }
});

async function forceShow(player, form, timeout = Infinity) {
  const startTick = system.currentTick;

  while ((system.currentTick - startTick) < timeout) {
    const response = await form.show(player);
    if (response.cancelationReason !== "UserBusy") return response;
  }
  throw new Error(`Timed out after ${timeout} ticks`);
}```
cold grove
#

You dont need a while loop

dim tusk
#

Meh, do what he wants that's just an example

#

If he won't use that then no 🤷

frozen vine
#

I would like to teleport the player to the entity that has the tag with the player's ID, but how do I make this work?

const playerId = player.id;

player.runCommandAsync('tp @p @e[tag=portal_black_${playerId}]');```
cold grove
frozen vine
elder spindle
cold grove
# frozen vine I would like to teleport the player to the entity that has the tag with the play...

Btw that string interpolation doenst work with sigle quotes:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

MDN Web Docs

Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates.

cold grove
elder spindle
ebon niche
#

@tender pier also, what kind of property is being used on the block? Thestate === '1' might be causing the issue if the state is a float or int, remove the quotes if that's the case

frozen vine
cold grove
#

my bad

#

If the entity will be at the same dimension that player use: player.dimension.getEntities()

frozen vine
cold grove
frozen vine
cold grove
frozen vine
cold grove
frozen vine
drifting ravenBOT
#
HCF Removal and Custom Components

The Holiday Creator Features experimental toggle has been removed. Along with it includes JSON block and item events. This functionality has been replaced with custom components.

Please take a look at the following links to learn more about custom components:

Bedrock Wiki

MS Docs

cold grove
#

🤔

frozen vine
#

?

cold grove
frozen vine
#
system.afterEvents.scriptEventReceive.subscribe((data) => {
    if (data.id != "mc:portal_orange_teleport") return;

    const player = data.sourceEntity;
    const playerId = player.id; // Pega o ID do jogador para identificar os portais
    const dimension = player.dimension;
    
const ent = dimension.getEntities({ tags: [`portal_black_${playerId}`] })[0];
if (!ent) return;

player.teleport(ent.location);
    player.runCommandAsync('event entity @e[type=mc:hades_portal_black] remove_tag_timer');
    player.runCommandAsync('titleraw @a actionbar {"rawtext":[{"translate":"function.horb2"}]}');
});
cold grove
#

Dont use commands in scripting btw

#

Use native functions

frozen vine
#

here he ends up activating the necessary commands with minecraft:entity_sensor

cold grove
#

Add a console.warn before the teleport. If theres no response in the content log then you should check the entities who has the tag

frozen vine
cold grove
#

#1067869022273667152

frozen vine
frozen vine
umbral dune
#

What were those messages up there?

frozen vine
#

I need to figure out how to get around this problem...

#

Yeee

#

I achieved

#

I managed to get around

frozen vine
tidal wasp
tidal wasp
#

and by might I mean definately

#

If you are facing either east or west this function when tapped in the left or right region will only give left if facing west and right if facing east

dim tusk
tidal wasp
#

basically use z values if the player is facing those positions

tender pier
#

I don't know why

ebon niche
#

Is there anything else setting fire:state to something besides 1?

tender pier
#

There's another line that works when interacting with the block, but as in this case I'm not interacting with it I don't know what's going on

tidal wasp
#

With the power of reading

#

I have finally learned how to use percise interaction

#

I still have no fucking idea what witchcraft went on in example blocks

undone cradle
#

sorry for weird question
from which version minecart start supporting the script modules and scripting in general?

dim tusk
#

umm...

#

Nvm

tidal wasp
#

what

dim tusk
tidal wasp
#

i see a backwards J

chilly fractal
#

Yo

#

I have kinda been livin' under a rock

#

Well not entirely, but like i was busy with some backend stuff

#

So uhh, what's the latest verison of mc?

untold magnet
#

is it possible to detect if the goat have horns or not?

noble bolt
#

Hi

dim tusk
untold magnet
distant tulip
untold magnet
#

as for right now, im trying to detect the panda variants

#

which is kinda interesting, cuz in the vanilla panda files, theres no variants, they're events

scarlet lynx
#

Does anyone know this error?

distant tulip
#

send line 33 and it context

fallow rivet
dim tusk
fallow rivet
dim tusk
#

use before events entityRemove

fallow rivet
#

Hmm

distant gulch
#

Too many files?

ebon niche
fallow rivet
#
world.beforeEvents.entityRemove.subscribe((data) => {
if (data.removedEntity.hasTag("Explosion")) {
data.removedEntity.runCommand(`summon ender_crystal ~~~ facing ~~~ minecraft:crystal_explode`)
}
})
distant gulch
fallow rivet
distant gulch
# fallow rivet So what should I use?
world.beforeEvents.entityRemove.subscribe((data) => {
    const removedEntity = data.removedEntity;

    if (removedEntity.hasTag("Explosion")) {
        removedEntity.runCommandAsync(`summon ender_crystal ~~~ facing ~~~ minecraft:crystal_explode`);
    }
});
#

instead of runCommand we use runCommandAsync (command will be executen in the next tick)

warm mason
distant gulch
warm mason
distant gulch
#

@warm mason Minecraft uses cjs right?

warm mason
distant gulch
warm mason
fallow rivet
#

One = missing

runic crypt
#
const TAG = "test";
const TIME = 60;

system.runInterval(() => {
    for (const player of world.getPlayers()) {
        if (!player.hasTag(TAG)) return;

        player.setInputPermission(InputPermission.Jump, false);

        system.runTimeout(() => {
            player.setInputPermission(InputPermission.Jump, true);
        }, TIME);
    }
}, TIME);

Why is this code not working ?
What I'm aiming for is that if player has a specific tag, they can jump only once every 3 seconds

#

If anyone knows, please ping me

warm mason
# runic crypt ```js const TAG = "test"; const TIME = 60; system.runInterval(() => { for (...
system.runInterval(() => {
  for (let player of world.getPlayers({ tags: ['test'] })) {
    if (player.isJumping && player.inputPermissions.isPermissionCategoryEnabled(6)) {
      player.inputPermissions.setPermissionCategory(6, false);
      player.setDynamicProperty('jumpBlockTick', system.currentTick)
    }
  }

  for (let player of world.getPlayers()) {
    if (player.getDynamicProperty('jumpBlockTick') + 60 > system.currentTick) continue;
    player.inputPermissions.setPermissionCategory(6, true);
    player.setDynamicProperty('jumpBlockTick', undefined)
  }
}, 2)
warm mason
runic crypt
tender pier
#

I tried to make it on tick but it's not working anyway

ebon niche
#

Try changing block.dimension to dimension

#

Also, do you have the minecraft:tick component in the blocks bp file?

subtle cove
#

same with Entity.prototype.matches

#

thats prob why getPlayers, getEntities, & matches are expesive
it tries to call every query properties even if the object has none
i could be wrong tho PE_PandaNompopcorn

thorn flicker
#

hm

warm mason
#

hmmm

grim raft
#

is there a way to make this more optimized/ better

world.afterEvents.entityHitEntity.subscribe((e) => {
    const { damagingEntity } = e
    const itemUsing = e.damagingEntity.getComponent('equippable').getEquipment("Mainhand")?.typeId == 'bleach:zanpakuto_2'
    const score = world.scoreboard.getObjective('z2_charge')

    if (itemUsing)
        damagingEntity.runCommand('scoreboard players add @s z2_charge 1')
    if (itemUsing && score.getScore(damagingEntity) == 0)
        damagingEntity.triggerEvent('bleach:z2_charge_reset')
    if (itemUsing && score.getScore(damagingEntity) == 3)
        damagingEntity.triggerEvent('bleach:z2_charge1')
    if (itemUsing && score.getScore(damagingEntity) == 6)
        damagingEntity.triggerEvent('bleach:z2_charge2')
    if (itemUsing && score.getScore(damagingEntity) == 9)
        damagingEntity.triggerEvent('bleach:z2_charge3')
#

still got more but discord aint letting me send bruh

#

got 20 if

warm mason
#

3 times slower

#

But this depends on the properties specified in queryOptions.

#

And if I don’t specify an argument at all in getPlayers, it will be even faster. How so?

#

.............

subtle cove
#

it has its fluctuations, so i rarely use it

wary edge
grim raft
#

still learning

#

thx

subtle cove
#
const z2_charge_list = new Map(Array.from({ length: 21 }, (_, i) => {
    return [i * 3, `bleach:z2_charge${i || '_reset'}`]
}));



world.afterEvents.entityHitEntity.subscribe((e) => {
    const { damagingEntity } = e
    const itemUsing = e.damagingEntity.getComponent('equippable').getEquipment("Mainhand")?.typeId == 'bleach:zanpakuto_2'
    const score = world.scoreboard.getObjective('z2_charge')

    if (itemUsing) {
        const z2_charge = score.getScore(damagingEntity)
        damagingEntity.triggerEvent(z2_charge_list.get(z2_charge))
        score.addScore(damagingEntity, 1)
    }
grim raft
#

oh wait I kinda get it

#

but the scoreboard doesnt match the charge lvl

subtle cove
#

runCommandAsync happens after 1 tick

chilly fractal
subtle cove
#

addScore happens same time

distant tulip
subtle cove
#

uhh, runCommand happens same tick as well, do u need the previous score?

grim raft
chilly fractal
# chilly fractal Nah, it uses esm

Also it doesn't support importing files other than .js and also it doesn't have any web apis (window.crypto and such) and doesn't have nodejs support

shut beacon
chilly fractal
chilly fractal
#

Also you don't even show any of your code that you are supposedly having problems with

shut beacon
#

2000 years is too little time to wait 🗿

chilly fractal
#

Did you wait 2000 years?

chilly fractal
#

Yup

#

Literally no code

shut beacon
#

im using herobrines chestui

chilly fractal
#

So?

shut beacon
#

no code needed

#

i found some issues there with typeids being wrong

chilly fractal
#

Alright then, have a nice day

#

I'm absolutely not gonna even try to help

shut beacon
#

average guy that never saw herobrine's chest ui

chilly fractal
#

I didn't ask for it

distant tulip
#

says the guy who didn't read the readme

chilly fractal
#

^^^^

#

@shut beacon i will help because i feel like in the mood

grim raft
chilly fractal
#

Which means when you add a custom item

#

It shifts it

subtle cove
chilly fractal
#

Every time you add an item.

#

And for the record

shut beacon
#

hu

chilly fractal
#

I didn't ever use herobrine's chest ui

shut beacon
#

i mean when i did "minecraft:diamond" it did beef

chilly fractal
#

I just readed the README.md

shut beacon
#

where is it

#

the thing you rode there

chilly fractal
distant tulip
wary edge
#

There was no need for that comment dude.

shut beacon
#

like is there any fix to that wierd typeids or should i just fix the bug by checking the ids and doing +33

#

every typeid is wrong by 33 lines

subtle cove
#

2 months outdated?

shut beacon
#

also there is inventory but its empty and im asking if there is anything to do or if there is nothing we can do

ebon niche
# tender pier Yes

Huh, strange. It might be best to make a post at this point tbh, can you ping me in one adn post the full script and block files? I'll try to check them out today

shut beacon
#

Like addon

distant tulip
grim raft
shut beacon
subtle cove
#
const charge = z2_charge_list.get(z2_charge)
if (charge) damagingEntity.triggerEvent(charge)
lofty cape
#

I know that system.runTimeout/Interval clears after we reload scripts, but does that happen to system.runJob? If yes then what's the difference between them?

grim raft
subtle cove
#

they all happen in script, so yes they should stop even in /reload

lofty cape
subtle cove
grim raft
#

thx

distant tulip
subtle cove
#

edu?

distant tulip
#

do the doc include those?

boreal siren
#

Can anyone tell me how I can fully learn the Script API?

subtle cove
distant tulip
#

chest form also include edu

distant tulip
boreal siren
#

I want to learn the entire API so that there would be a field for the concept

distant tulip
#

just look around the docs and learn from them

boreal siren
#

The problem is that sometimes there is too little information there.

#

Is there a complete manual?

subtle cove
#

nope, just a progressive doc

boreal siren
distant tulip
#

no, you will need to try and learn
most of the stuff are just knowledge sharing here

subtle cove
#

altho the one in docs is for preview

shut beacon
boreal siren
#

Thank you for your time

subtle cove
#

these are the only useable modules atm
server and server-ui are the commonly used

untold magnet
thorn flicker
untold magnet
distant tulip
#

@shut beacon updated it
replace chest form one with it and check if it work

untold magnet
distant tulip
#

actually nvm, it is somehow smaller then the chest ui one bao_ext_toldyouso

#

idk where he got the others from

untold magnet
#

( im not that good on explaining things )

untold magnet
# thorn flicker that doesnt make sense.

i am saying that cuz i have made an addon that spawn a breathing particles in some situations, i did getPlayers and it works perfectly fine on single player, but when i tested it out on multiplayer it was bugged

#

when a player is inside of a cold biome ( that player will get some breathing particles showing up )
but all other players will receive the same exact thing while knowing all other players is not inside of a cold biomes.

thorn flicker
#

both return an array with players and you are looping through it.
I dont understand how there would be issues.

untold magnet
#

understand?

#

getPlayers != multiplayer friendly
getAllPlayers == multiplayer friendly

ivory bough
thorn flicker
thorn flicker