#Script API General

1 messages · Page 124 of 1

midnight ridge
#

yep

whole pulsar
#

i really liked the slash commands

#

but very sad they dont fix such things like this

#

but wouldnt string also work instead of player selector

midnight ridge
#

this map addon had the command without needing to activate cheasts

midnight ridge
#

in this for normal player

last latch
#

cant you just add string parameter and check if it equals to any players name?

midnight ridge
last latch
#

why is there no bds related channel?

#

editor mode but no bds 🗣️

#

bds related: Can you make a player be the "host" of the server? Essentially, I want to use reload all.

autumn pewter
#

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

system.runInterval(() => {
console.log("Running")
world.getAllPlayers().forEach(player => {
console.log("Player")
let inventory = player.getComponent("minecraft:inventory")
let container = inventory.container
for (let i = 0; i < container.size; i++) {
console.log(${i} Slot)
let item = container.getItem(i)
console.log(${item})
if (item) continue;
if (item.typeId === "minecraft:stick") {
let nitem = new ItemStack("minecraft:stick", item.amount)
console.log(${nitem})
nitem.setLore(["Isso e um Graveto", "Nossa que ligal!"])
container.setItem(i, nitem)
}
}
})

}, 100)

Why this code is not working? Only on reload

warm mason
autumn pewter
#

Oh

ivory bough
#

How to make a dash that makes the player move 6 blocks forward and up simultaneously? I tried but it doesn't work.

hoary matrix
#

guys is it possible to add lore to any items ?

gaunt salmonBOT
flat barn
#

Is this preview only?

sharp elbow
#

Aye

flat barn
stray spoke
snow knoll
wheat plaza
#

i know how to fix

#

{
"binding_type": "view",
"source_property_name": "((#form_button_texture - (#form_button_texture % 65536)) / 65536)",
"target_property_name": "#item_id_aux"
}

#

search for aux and find something in the chest-server_form.json that say what i have below
{
"binding_type": "view",
"source_property_name": "(#form_button_texture * 1)",
"target_property_name": "#item_id_aux"
}

should be in the array aux_id

wheat plaza
jolly citrus
#

is there any better way to store data on realms/worlds than dynamic properties

#

cause i only have 33k bytes used yet it already lags a ton

sudden nest
#

I just learned that u cannot make any fish mobs ride any entity even custom ones, cuz it's hardcoded.

jolly citrus
#

Is it true that updating any key on a world's dynamic properties means it also re-indexes the rest in the process

slow walrus
#

it has to resave every dynamic property when you update one yes

flat barn
agile lance
jolly citrus
#

How am i meant to combat this

wary edge
#

How often are you updating?

jolly citrus
jolly citrus
wary edge
#

What are you saving every 60s? Any reason?

jolly citrus
#

Up to 32k bytes big

jolly citrus
wary edge
#

Thats not helpful

jolly citrus
#

Strings bro

#

Its just serialized json

#

Big strings

wary edge
jolly citrus
#

So yes i think every 60s is reasonable

jolly citrus
#

What data I'm saving I mean

#

Player data
Market data
Staff audits
Player activity logs

#

And more

wary edge
jolly citrus
#

I think all of this must be

#

Some of it even more often esp market data

buoyant canopy
#

how to make onUse not fire when onUseOn fire for custom item components?

thorn flicker
buoyant canopy
#

until i tested my addon with mobile today and realized how bad raycast is for touch screens

thorn flicker
#

maybe dont do this and use sneak interactions instead for your alt use

buoyant canopy
#

...

thorn flicker
#

idk what you are doing

buoyant canopy
#

anyway, now i am putting the player id in a set if the onUseOn event is called, call the the onUse event one tick layer if the player id isn't in the set and remove it from it 2 ticks later
i was hoping for a native way

thorn flicker
#

..

buoyant canopy
thorn flicker
buoyant canopy
thorn flicker
#

my suggestion is worse?

buoyant canopy
#

because it writes data on the player file that might get stuck if something unexpected happen

thorn flicker
#

not if you use a temp property.

#

dont use dynamic.

#
player.randomProperty = true
last latch
thorn flicker
last latch
#

damn

buoyant canopy
last latch
thorn flicker
last latch
#

nothing, its peak javascript behavior

buoyant canopy
# last latch thats possible?

i know, but i not calling the onUse function from the onUseOn function and passing the player instance to it so that property won't exist

thorn flicker
#

somehow

last latch
thorn flicker
#

lol

buoyant canopy
thorn flicker
#

and also make sure to get rid of it after a tick or 2

buoyant canopy
# thorn flicker yes it will.

no, because it only be saved on that instance of Player, so unless i pass that instance to the onUse function, the property won't exist on it, i have tested that before

buoyant canopy
#

i am almost willing to bet on it, let me test that again real quick

thorn flicker
#

because that would get rid of the property

buoyant canopy
#

ik

buoyant canopy
thorn flicker
#

but yeah try what i suggested

#

I believe it would work

dapper copper
jagged gazelle
#

pipol

#

how do I get the data in a custom component?

#

I registered it in the item so doing item.getComponents() it shows up but me doing item.getComponent('<id>') returns undefined

small depot
#

The other one is more simple

dapper copper
thorn flicker
dapper copper
thorn flicker
#

they are indeed

dapper copper
#

ok cellvoid

#

llecdiov

#

vellcoid

chrome river
#

I'm still new to scripting and trying to figure it out. I'm trying to get a block to emit particles using onTick but this just breaks it:

const EmitParticleComponent = {
    onTick() {
        runCommand("particle ser:chem_smoke ~~~")
    }
};

I am confused on what to do and where I am going wrong

#

I am also using itemComponentRegistry.registerCustomComponent("ser:emit_particle", EmitParticleComponent); in the system.beforeEvents.startup.subscribe(({ itemComponentRegistry }) => {} and have "ser:emit_particle": {} in my block components

dapper copper
#

try that

#

but why are you using itemComponentRegistry if this is for a block?

chrome river
#

I might be stupid

#

is there a blockComponentRegistry?

#

That is exactly what was happening. Thank you

wicked girder
#

Is it possible to check if the sprint key is pressed? like when movement is disabled

amber granite
#

Hmmm , not directly

thorn flicker
wicked girder
#

Dang

#

I made a free cam and wanted the ability to sprint

subtle cove
#

hb using the movement component

halcyon phoenix
#

can't believe I can do OOP now

amber granite
#

Oop ?

wicked girder
amber granite
#

Ooohh ._. o o p

#

U can calculate the velocity of player per 20 ticks

wicked girder
#

not with movement locked

subtle cove
#

hmm, ye thats fair

cursive fog
#

anybody knew why my dynamic property wont work?

#
world.afterEvents.playerSpawn.subscribe((data) => {
    const { player, initialSpawn } = data;
    if (!initialSpawn) return;
    const inv = player.getComponent('inventory')?.container;
    if (!inv) return;
    const itemStack = new ItemStack("vdg:akm");
    itemStack.setDynamicProperty('vd:akammo', 30);

});


world.afterEvents.itemUse.subscribe(ev => {
    const { source: player, itemStack } = ev
    if (itemStack.typeId !== gun) return
    const ammo = itemStack.getDynamicProperty('vd:akammo');

    const dpshoot = system.runInterval(() => {
        if (typeof ammo === 'number') {
            itemStack.setDynamicProperty('vd:akammo', ammo - 1);
        }
    }, 1)

    system.runInterval(() => {
        if (itemStack.getDynamicProperty('vd:akammo') <= 0) empty = true
        if (itemStack.getDynamicProperty('vd:akammo') > 0) empty = false
    })


    const container = player.getComponent("minecraft:inventory")?.container
    if (!container) return
    container.setItem(player.selectedSlotIndex, itemStack)

})

world.afterEvents.itemUse.subscribe(ev => {
    const { source: player, itemStack } = ev
    if (itemStack.typeId !== mag) return

    itemStack.setDynamicProperty('vd:akammo', 30);
    const container = player.getComponent("minecraft:inventory")?.container
    if (!container) return
    container.setItem(player.selectedSlotIndex, itemStack)
}) ```
#

i removed the null part alr

#

so for the systemruninterval on the if part idk why it wont set empty var to either to true or false

#

anybody knew why?

stray spoke
stray spoke
#

How do I set the value of can_fly component

open urchin
# stray spoke How do I set the value of can_fly component

scripting can't change the value of components, you have to set the value of components in the entity JSON
you could add an event to your entity that adds a component group with the can_fly component and then trigger that event with scripts

stray spoke
#

Can fly is not a client entity json component, and it does can change just like minecraft:health

open urchin
#

health is different since it's an attribute component where the JSON definition sets a max, min and default value

stray spoke
#

Yeah I think for some components, we can set and read values. Idk if can_fly can set

#

because using the command /ability we can change it

#

So I think there might be an api for it also

open urchin
#

mayfly is separate from the can_fly component
only players have abilities

#

can_fly is just for pathfinding afaik

stray spoke
#

Ahh alright

#

I guess I'll stick to runCommand

#

Thanks

dapper copper
stray spoke
#

Why does getDefaultSpawn always have maximum height level

open urchin
stray spoke
#

I see, thanks a lot

wicked girder
devout sandal
#

how can I get the potion type of the potion ENTITY.. in the EntityDieAfterEvent? (posting in entities general as well)

devout sandal
stray spoke
turbid delta
# devout sandal how can I get the potion type of the potion ENTITY.. in the EntityDieAfterEvent?...

there is no way to do this at in this event. if you want to do this you will have to add a dynamic property or a tag to the potion entity you can use. for example if the potion is always from a player create a itemUse event that gets the potion type and add the tags to the potion spawned either with a separate entitySpawn event or an area around the player. if its from a dispenser or witch i dont think you can do anything

#

same applies to entityRemove event

novel goblet
#

Hey silly question

#

Are dynamic properties only beta API?

sudden nest
novel goblet
#

What’s the best method to learn scriptAPI if I already have some experience with JS or Java

sudden nest
novel goblet
#

Any good recommendations for projects to check out?

sudden nest
#

Most of the time, i learned by porting some small mods from java to bedrock

granite cape
#

p

weary umbra
#

guys how does onRedstoneUpdate works? Do I need to give the block a component? if yes which one and does it work like a tick intervall? when powered

#

someone? Please

weary umbra
mystic harness
#

can i get component a shulker box that is inside the inventory?

devout sandal
stray spoke
shy leaf
#

since a component can be anything else other than "value"

#

what youre probably thinking of is attribute components, which includes health

#

although i wish we could freely edit attribute values...

sudden nest
#

Anyone know a way to store a data to a block (no entity involved) cuz eith states u can only store like 16 bits, mine used 24 bits (i am using hex per state to store some data) , i know some ways but i wanna know what you guys have done, cuz mine is probably more work.

stray spoke
subtle cove
#

toJSON() is crazy

#

just some random free food ;-; ```js

getPlayerPlots() {
    const data = JSON.parse(world.getDynamicProperty("playerPlots"));
    const convert = (allowBlocks) => {
        if (typeof allowBlocks === "number") {
            return [
                {
                    chest: (allowBlocks & (1 << 0)) !== 0,
                    barrel: (allowBlocks & (1 << 1)) !== 0,
                    undyedShulkerBox: (allowBlocks & (1 << 2)) !== 0,
                    enderChest: (allowBlocks & (1 << 3)) !== 0,
                    dropper: (allowBlocks & (1 << 4)) !== 0,
                    hopper: (allowBlocks & (1 << 5)) !== 0,
                },
            ];
        }
        if (typeof allowBlocks === "object") {
            let ab = 0;
            if (allowBlocks.chest) ab |= 1 << 0;
            if (allowBlocks.barrel) ab |= 1 << 1;
            if (allowBlocks.undyedShulkerBox) ab |= 1 << 2;
            if (allowBlocks.enderChest) ab |= 1 << 3;
            if (allowBlocks.dropper) ab |= 1 << 4;
            if (allowBlocks.hopper) ab |= 1 << 5;
            return ab;
        }
    };
    data.forEach((p) => {
        if ("ab" in p) {
            p.allowBlocks = convert(p.ab);
            delete p.ab;
        }
    });
    // should trigger when JSON.stringify(data)
    Object.defineProperty(data, "toJSON", {
        enumerable: false,
        value() {
            return this.map((p) => {
                const copy = { ...p };
                if ("allowBlocks" in copy) {
                    copy.ab = convert(copy.allowBlocks[0]);
                    delete copy.allowBlocks;
                }
                return copy;
            });
        },
    });
    return data;
}```
granite cape
#

abcd

earnest meadow
stray spoke
#

Is initialSpawn in playerSpawn a first time join, or first time spawn in the world so it resets on joining again

open urchin
stray spoke
#

Alright thanks again

subtle cove
amber granite
#

Bitwise are very easy

#

They are made to shift the numbers binary numbers

#

Like
1 << 2
0000.0001 << 2

0000.0100
= 4

#

@subtle cove

#

Those bitwise turning the both right and left value to binary then compare each bit of both like : | , & , !

subtle cove
#

welp, not a language I wana learn for now, i just let ai speak it's own lang ;-;

amber granite
#

It s easy to not to learn

#

U will need it to optimize your code trust me

#

Betwise just turns numbers to binary form and compare each position that s all :
Like
2 & 1

0010 & 0001
= 0 0 0 0
= 0

subtle cove
#

in any length, right?

amber granite
#

They give you a binary result not true or false like the regular one

subtle cove
#

like the (allowBlocks & (1 << 45678))

amber granite
amber granite
#

And then it will give you very big number in return ._.

earnest meadow
amber granite
#

Hmm there are something called :
// Comments

amber granite
subtle cove
#

the db on our server was reaching limits so had to come up with anything necessary

amber granite
#

What the problem so i can help you ._.

subtle cove
#

w/o using split, it's using [{},{}] atm

#

like 70+ entries

amber granite
subtle cove
#

on nxt one we'll use separate objects for specific data use like one object dyprop per plot etc

#

the '[]' was abt 31k length

amber granite
#

._.

subtle cove
#

data was lota this in the array

amber granite
#

Oh i guess i want to save data in the most optimized way righr ?

subtle cove
#

i didnt have time to make changes on it's setup before, that's why

#

i wana avoid looping, and just use one object for specific use on the nxt season

amber granite
#

🤦‍♂️ can u tell me what you are trying to do , and what s your problem instead of explaining me how it works ? @subtle cove

#

Oh you want to avoid looping and use one object for all players data ?

subtle cove
#

it's not a problem... ;-; dont solve it, it's already handled

amber granite
#

Sure ? :-: because i have an idea that make it better than using 999 object

subtle cove
#

do tell

amber granite
#

So u use one object that have multiple keys that uses arrays

#

And then using
name , members , from to , center , tp extra

#

Use Plural words

#

And make the key an array

#

So when u want a player data u use
playersPlots[1][1][1] etc...

#

It will be more optimized

#

U can bring all datas in one object in one dynamic array by looping only the players names

subtle cove
#
const DB = new Database("PLOT");// dprop of IGNkeys[]
const plot = DB.get(player.name);// dprop plotData
amber granite
#

Then after getting the index , u use it for the rest thing , because each player's data are having the same index

#

I think it s better to use a code so u understand me

subtle cove
amber granite
#

Hmmm no just using arrays

subtle cove
#

that's how i'd name em instead of plain numbers

amber granite
#
const playerPlots = {
names : [],
memberes : [[]],
froms : [] ,
tos : [],
center : [] ,
tps : [],
allowBlocks : [[]],
playerTages : [[]]
}
#

So instead of using multiple objects u use only one

subtle cove
#

is it like a 2d table?

stray spoke
subtle cove
#

matching their indexes...

amber granite
#

And use a loop to search The concerned player index

#

And use that index to reach the rest of its data

amber granite
#
const DB = new 
Database("PLOTS") ;
const plot = DB.set(playerPlots) ;
#

And just for your knowledge, if u a big array instead of of keys u will get better results

#
const playerPlots = [ [] , [[]] , .... , [[]] ] 
subtle cove
#

values are saved alone eh

#

it's hard to teach it to the co-devs tho

amber granite
#

Can i be of em :-: ?

#

Do u need volunteers?

subtle cove
#

not rly ;-;

#

it's just a free server for kidz

amber granite
#

;-; ._. i would be happy to help optimization

#

:-: np

subtle cove
#

thx for the offer btw

subtle cove
amber granite
#

._. u are using js or ts ?

subtle cove
#

before ai was a thing

#

just js

amber granite
#

._. is your problem with memory or storage?

#

Or watchdog usage threshold

subtle cove
#

storage for now since it's using []

amber granite
#

Oh ._.

subtle cove
#

changing the data w/o testing in-game ;-;

amber granite
#

Are u sure memory is a big deal ?

#

I mean storage*

#

Like will you store 1 TB of datas ;-;

subtle cove
#

no, not that storage, it's the 32k limit per property i dont wana reach

amber granite
#

🗿

subtle cove
#

btw, whatcha think of storing player's locations per minute?

#

big object eh

amber granite
#

I actually don't store players locas as raw objects

#

I omit everything and let only numbers

#

Like instead of
{ X : 8272 , y : 8272 , z : -9282 }
I turn them into string and :
Let locString = "8272:8727:-9282/"

#

And do concatenation to the rest ._.

subtle cove
#

yup, same thing ig

amber granite
#

And i got a little string like this instead:
Let locsString "x1:y1:z1/x2:y2:z2/etc../"

subtle cove
#

was thinking if there's other way than vectors

amber granite
#

And i made a function to make them into objects again

amber granite
#

What do u mean , u just turn numbers into string then put commas between each location, and by that you are getting much bigger storage

subtle cove
#

i mean compacting the vectors collected

#

oh well it's too much to think of anyway

#

was just an idea to the bin

amber granite
#

._.

#

I made a database for it

#

@subtle cove

subtle cove
#

that's cool then

#

how much storage does it occupy now?

amber granite
#

:-: ._.

subtle cove
#

how long has it been recording 👀

amber granite
#

☠️ i made its code

subtle cove
#

ohw

amber granite
#

But i can compact it more by using @subtle cove hexadecimal format

#

It s size will be nearly - 50%

subtle cove
#

hmm, idk abt using hex yet. im not entering any multiple big numbers yet

amber granite
#

I just said

#

Because js supports hex

#

So it would be better

subtle cove
#

i could only take note if it for now 'til i need it soon, thx

amber granite
#

But it will needs the vectors to be totally integers

#

Not float point numbers

dapper copper
sudden nest
#

why is it that after taming the nautilus, then calling that nautilus entity with script api then checking if it's tamed by EntityTameableComponent and EntityTameMountComponent returns undefined instead of something that has value? i cannot seem to get who's owner of this entity or even the tamedMob.getComponent(EntityTameMountComponent.componentId)?.isTamed and tamedMob.getComponent(EntityTameableComponent.componentId)?.isTamed doesn't return any value. I mean it should be cuz it's tamed i think.. is this a bug?

wheat condor
#

Tame mount? i never seen that component

wary edge
#

You are completely misreading what they're asking.

#

They even stated they used both TameMount and Tameable

wheat condor
wary edge
#

You should read the whole thing next time.

wheat condor
#

you re right

sudden nest
fallow minnow
#

endstone is sick

last latch
#

Yeah I love the script sdk

#

Although there is someone cooking a supercharged BDS

whole saddle
#

Is there a way to make players fly faster? cause I can't set the value of the custom component called "flying_speed"

stray spoke
#

Speed effect while in flying state

whole saddle
#

I don't think that works

#

yeah it doesn't

fallow minnow
dapper copper
dapper copper
snow knoll
# whole saddle yeah it doesn't

Creative Flight dampens the effect of movement outside of flight itself
A really high level of speed coukd do something, can't remember if flight cancels the effects of speed or not
Either way, I believe both applyImpulse and applyKnockback can be used to increase flight speed but would need to be constantly run in a runInterval

snow knoll
#

No problem

dull shell
#

How would I go about making it run commands off a player being hit by 2 different entities?
Im trying to make it so when hit by jay:zombie it runs a set of commands then hit by jay:boss_zombie it runs a different set

#

rn im using

      "events": {
        "jay:player_hit": {
        "queue_command": {
            "command": [
                "scoreboard players operation @s Health -= ZomDamage Settings",
                "execute @s[scores={Health=..0}] ~~~ kill @s"
            ]
        }
    },```
in the player.json but thats j when the player is hit at all so its very inaccurate
haughty gust
#

Can server-admin transferplayer be used in realms?

remote oyster
haughty gust
remote oyster
dapper copper
#

if not they must've changed it, however ive seen no updates on that

jagged gazelle
dull shell
tidal wasp
#

How do you do anything with getAllStates()?

wary edge
tidal wasp
#

Oke

wheat plaza
fallow minnow
wheat plaza
#

dang is that like plugin or script api but only for endstone

fallow minnow
#

its script api and optional plugins

#

script api + extra on top

wheat plaza
#

ah

fallow minnow
#

so u can do just script api and access like

#

xuid

#

os

#

ip

#

boss bars

#

client sided nametags

wheat plaza
#

wait u can do all oh that on ednstone

#

endstone?

fallow minnow
#

yes

#

without plugins

#

just using their sdk

wheat plaza
#

Bruh tf

#

i needa look at endstone now to make a ip ban and vpn detection

wheat plaza
fallow minnow
#

i mean yeah

#

only thing that really matters is performance

#

so vps

#

im using ovhcloud right now

#

just the vps1 server

#

$4.90 USD for pretty crazy things

jagged gazelle
#

are you batman and a silver surfer??

fallow minnow
#

yes

tidal wasp
wary edge
tidal wasp
#

No Blockpermutation.resolve?

wary edge
#

Well, yeah, setPermutation(BP.resolve(getAllStates()))

tidal wasp
#

Huh

wary edge
#

I'm quite confused tbh.

#

This is all ovee complicated.

#

Why don't you just setPermutation(block.permutation)

tidal wasp
#

because im trying to copy a block from a specific location

#

and any states it may have

wary edge
#

What does that have to do with anything?

#

If you have access to the block you have access to its permutation. So just use that permuation and pass it into setPermutation.

tidal wasp
#

I'm lost

wary edge
#

What are you lost about?

#

blockB.setPermutation(blockA.permutation)

tidal wasp
#

wait you can just use e.block.permutation in setPermutation and it will just use the permutations found?

#

damn

wary edge
#

Yes.

tidal wasp
#

thanks

wheat plaza
wheat plaza
#

nvm found it

last latch
fallow minnow
#

also 36 ping and the server is 12 hours away in a different country

chrome gyro
#
       const volume = new BlockVolume({ x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0 });
        for (const eachb of volume.getBlockLocationIterator()) {
              const blockt = block.dimension.getBlock(eachb);
                  console.error(`${blockt.typeId}`)
            }

Anyone know what I'm doing wrong. It doesn't return the typeId. Says it's undefined, but it's clearly a block I'm looking at.

chrome gyro
#

Oooooh aparently it gives the coords relative to the block, but not the global coords so I just had to add those into it:


        const volume = new BlockVolume({ x: -9, y: 1, z: -9 }, { x: 9, y: 11, z: 9 });
        for (const eb of volume.getBlockLocationIterator()) {
              const blockt = block.dimension.getBlock({x:loc.x+eb.x,y:loc.y+eb.y,z:loc.z+eb.z});
                  console.error(`${eb.x},${eb.y},${eb.z},${blockt.typeId}`)
            }```
untold magnet
#

umm, how can i detect when an entity explode?

#

world.afterEvents.explosion.subscribe(({source: entity}) => {}) or something?

broken pawn
#

oh afterEvents.... what are you gonna do with that?

#

i always use beforeEvents to prevent specific entity from exploding

#

🗣️ 🔥 🔥

#

world.beforeEvents.explosion.subscribe((E)=>{
if(E.source?.typeId=="minecraft:creeper")E.setImpactedBlocks([])
})

#

it used whenever a creeper explode, any impacted block still remain untouched

untold magnet
broken pawn
#

haven't tried using that method

#

try it then, mostly beforeEvents used if the following entity removed where you cannot execute some component with afterEvents

untold magnet
#

yup, that works

cursive fog
#

are there any script equivalent to /say or /tell

#

smth that sends message using scripts basically

runic maple
#

Can any mob apart from players use the eqquipable component?

wary edge
snow knoll
#

When the player is looking straight, what is the x rotation value in player.getRotation()

sharp elbow
#

0. x-rotation is around the x-axis, which involves looking up and down. Minecraft defines straight forward as 0 rotation

midnight ridge
#

can we trigger the minecraft:ageable event on the animal to simulate eating/breeding?

midnight crane
#

This is my gui script how do I make it so you need a tag to see a button and where would I put it

world.afterEvents.itemUse.subscribe(async (data) => {
   const player = data.source;
    if (data.itemStack.typeId === 'minecraft:apple') {
            await test(player);
    }
})

function test(player) {
    const menu = new ActionFormData()
        .title("title")
        .button("1")
        .button("2")
        .button("3");

    menu.show(player).then(result => {
        if (result.canceled) return;

        switch (result.selection) {
            case 0:
                // response for first button 
                break;
            case 1:
                                // response for second button 
                break;
            case 2:
                // response for third button 
                break;
        }
    });
} ```
amber granite
#

Make different uis

#

Or make if statement between button and other

#

Like this

....
.title("title");
if ( player.TagsMethod = "your Name tag" ) menu.button("1") ;
#

And so on

#

Sorry i don't remember the exact method to get players tag or tags

#

So it must be pussting if statement and use if else too

#

@midnight crane

midnight crane
#

Okay thanks

stray spoke
thorn flicker
warm mason
thorn flicker
warm mason
stray spoke
#

Js wanna ask if ItemStack or ItemStack.clone() returns an object that consists also all method functions, so that it can be stored and return again

#

Nvm, it returns {} or error if I stringify it

devout sandal
#

Does anyone know if we can use getBlockFromViewDirection and or getEntityFromViewDirection to get blocks/entities from BEHIND the view direction?

stray spoke
#

Its "View Direction" for a reason

#

But I think math can make it

#

Reversing the facingLocation I think (BlockRaycastHit)

#

And reversing the entity.location (EntityRaycastHit)

cinder shadow
#

do we not have any getPlayer method that uses a players id? Only thing I'm seeing is to do world.getPlayers(); and going through each one and checking it

stray spoke
#

We dont

#

Needs to check all players first

#

You can make your own Prototype or Function as a shortcut instead

cinder shadow
#

yeah, all just to send the player a message that they left a party

#

damn, id isn't even an entity filter

#

maybe I should be saving players in a party as just their player name

#

or include both ig

stray spoke
#

If it's about player leave event, they also have playerName

cinder shadow
#

nope, making a party system

stray spoke
#

Why id if the player exist in the world

stray spoke
cinder shadow
#

So that they persist in the party if they leave the world

cinder shadow
stray spoke
cinder shadow
#

It's used for world.getPlayers(), player leave event isn't remotely what I'm trying to do right now

stray spoke
#

Yeah I think make database to save the names would be right

cinder shadow
#

all good, already solved it. I just needed to know if there was a native getPlayer(entityId) call anywhere. It's for a party system and I'm building out the commands for it

midnight crane
tidal wasp
#

Generally what's the point of unsubscribing from an event like afterPlayerInteractWithBlock?

cinder shadow
#

There isn't one unless you're embedding one event inside of another for whatever reason

#

But there are usually better alternatives then having to do that

stray spoke
#

Noway

#

No way

#

I mean

#

A developer of RuneCraft

cinder shadow
#

What

twilit sky
# cinder shadow all good, already solved it. I just needed to know if there was a native getPlay...

Seems like you can use world.getEntity() to get players as well.

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

world.afterEvents.playerJoin.subscribe(e => {
  const { playerId } = e

  system.runInterval(() => {
    const entity = world.getEntity(playerId)

    if (!entity) {
      world.sendMessage("nothing found")
      return
    }

    world.sendMessage(entity.id)

    if (entity instanceof Player) {
      world.sendMessage("found a player!!")
      world.sendMessage(`player has slot ${entity.selectedSlotIndex} selected`)
    }

  }, 100)
})
#

It only says Entity in the docs. I guess it includes players too though.

/**
 * @remarks
 * Returns an entity based on the provided id.
 *
 * @param id
 * The id of the entity.
 * @returns
 * The requested entity object.
 * @throws
 * Throws if the given entity id is invalid.
 */
getEntity(id: string): Entity | undefined;
cinder shadow
#

Although I just realized I should also be storing player names

#

I wonder which is more efficient to do, I'd assume several world.getEntity calls vs a world.getPlayers with a name filter

twilit sky
#

I'd say it depends on how many players you're planning to get.

You could always do a filter afterwards using JavaScript's .filter() method on .getAllPlayers() if EntityQueryOptions doesn't provide enough options.

world.getAllPlayers().filter(player => player.name === "player1")
thorn flicker
#

could use that instead

cinder shadow
#

I guess the flow is either A) js players = world.getPlayers(filter by name if included in list of players in party) -> for loop of players -> send message or B) ```js
for loop of players in the party that I stored -> player = world.getEntity(id) -> send message

cinder shadow
#

I think B makes more sense lol

thorn flicker
#

how come

cinder shadow
#

easier to read, I don't know about the runtime, it's likely negligible

thorn flicker
#

I disagree

#

but alright

#

whatever floats your boat ig lol

thorn flicker
cinder shadow
#

Won't really be helpful if it's just a bunch of entity Id's

thorn flicker
#

just use tags or dynamic properties

#

and make a custom command that lists the players

cinder shadow
#

That's what I'm doing

thorn flicker
#

ah

#

alr

cinder shadow
#

I'm going to look at both ways to see which ones actually easier to read now lol

thorn flicker
#

lol

twilit sky
#

I'd like to highlight the off-chance that a player might change their username, and if something would break as a result of that.

Were you planning on storing both ids and name?

cinder shadow
#

It was originally just going to be player Id but now it's this js const partyInfo = { partyId: playerId, players: [{ name: player.name, id: playerId, online: true }] }

thorn flicker
#

use ids instead

cinder shadow
#

I'm using ids for everything, name is display purposes only

cinder shadow
#

It's a very rare chance for that to occur anyways since the party would have to be persisting long enough for a player to leave, change their username, then rejoin

#
export function partyDisband(source) {
    const player = source.sourceEntity;
    const playerId = player.id;

    let parsedPartyListInfo = JSON.parse(world.getDynamicProperty('party_list') ?? '[]');
    const index = parsedPartyListInfo.findIndex(entry => entry.partyId === playerId);
    const listedParty = parsedPartyListInfo[index];
    if(index != -1) {
        for(const entry of listedParty.players) {
            const playerInParty = world.getEntity(entry.id);
            if(playerInParty.id === listedParty.partyId) continue;
            playerInParty.sendMessage(`The party you were in has disbanded.`)
        }
        parsedPartyListInfo.splice(index, 1);
        world.setDynamicProperty('party_list', JSON.stringify(parsedPartyListInfo));
        player.sendMessage(`Party disbanded.`)
    }
    else {
        player.sendMessage(`You are not in a party or are a party leader.`);
    }
}``` this seems easy enough to read through though
thorn flicker
#

why are you not just giving them a dynamic property or tag to make them part of the party

#

doing this seems like extra work, and worse because you need to stringify/parse

cinder shadow
#

players can stay in a party after they leave the world

#

as long as one player is still active

#

This way I can just access all of the relevant data in one place

#

I really need to set up a dual gameplay system so I can test these out though

thorn flicker
cinder shadow
#

But I'm pretty sure I wouldn't be able to read if a player was in a party after they had left the world

#

I don't know though, I can't test this stuff out

cinder shadow
#

Though this does have a potential limit compared to storing this data per player

#

Doesn't world.getPlayers return all players, offline and online?

thorn flicker
#

all players that exist

#

so not offline

cinder shadow
#

then why does getAllPlayers specify that they are all active players

#

that would essentially make getAllPlayers and getPlayers pretty much identical minus not having filter options on getPlayers

thorn flicker
stray spoke
#

Who even uses getPlayers

thorn flicker
#

honestly idk why getAllPlayers exists

cinder shadow
#

Actually, I don't think I would ever have to worry about reaching the limit

stray spoke
thorn flicker
stray spoke
#

Yeah I think getAllPlayers would be useless

#

It's just a long typing clone that doesn't have better filtering

thorn flicker
#

yeah.

cinder shadow
#

mk.. so this method can store around 400-450 players

#

I don't think I'd ever run into issues unless something weird happened

#

they would also all have to be concurrent players in active parties

stray spoke
#

-# I mostly trust the getAllPlayers as its name says its purpose

twilit sky
#

{"partyId":"playerId","players":[{"name":"player.name","id":"playerId","online":true},{"name":"player.name.2","id":"playerId","online":true},{"name":"player.name.3","id":"playerId","online":true},{"name":"player.name.4","id":"playerId","online":true}]} is around 250 characters, or 500 bytes (assuming UTF-16 string encoding).

String dynamic properties have a limit of around 32Kb the last time I checked. That makes it so you can have something along the lines of 50 parties at maximum. Does that seem like something that might be hit?

cinder shadow
#

Unless something weird happens and my add-on explodes into popularity out of nowhere and gets put in a giant server with thousands of people, there's no way it's ever hitting that limit

#

I could alternatively build it out by having each party by a separateId and just referencing all active parties in another dynamic property by an Id

twilit sky
#

Maybe put an easter egg if someone ever does hit that limit 😆

cinder shadow
#

this would support ~12k players

#

I mean I can try and lock parties down to be present on the player, but last time I tried it it was a total mess

#

dream big right?

#

My add-on will be played by 60k + on a single server

twilit sky
#

You'd probably get a user messaging you if they ever did hit that limit. That's when I'd start to worry about it.

cinder shadow
#

I would be ecstatic if that were ever a problem

#

But we love future proofing for scenario's that will almost never happen

#

so I guess I'll try and redo this tomorrow, I only built out a create, leave, and disband command anyways

#

I think if per player parties doesn't work, the only other option is to just scale it up, create multiple party Id lists, and simplify the id's down to be incremental starting from 0 -> whatever

thorn flicker
#

is that the only option?

cinder shadow
#

That's what It seems like

#

even that theoretically has a breaking point lol

thorn flicker
#

because of how many properties you can have

cinder shadow
#

What do I do if I my server has 10 million players on it active concurrently?!?!?

thorn flicker
#

who the hell has that many anyway?!?

#

lol

cinder shadow
#

I will

thorn flicker
#

oh

#

well shit

cinder shadow
#

I'll look into it more I guess tomorrow. If I store it on per player, it really is infinite

thorn flicker
cinder shadow
#

I think getPlayers does return offline?

thorn flicker
#

I mean, you could just make them leave the party when they leave

#

probably not a good option

thorn flicker
cinder shadow
#

I wanted to let them be able to leave and come back and be in the same party

#

without needing to be reinvited

#

This creates a whole bungle of annoying extra work imo

#

I have to now update the party info on every single player in the world each time

#

anytime I want to do anything with a party, I need to get all players in the world and then filter them based on if they have a specific property

cinder shadow
#

If a server ever got so large where the other methods would break the runtime on something like this would be painful

#

at least I think it would, I don't really know 🤷‍♂️

thorn flicker
#

im not an expert here clearly, I wish you luck

cinder shadow
#

Neither am I, I just do things

thorn flicker
#

same

cinder shadow
#

This would probably be a bigger issue whenever I add in guilds since that would store a lot more information

#

so I probably should come up with a better sorting method now that I can just paste later

thorn flicker
#

if it does, thats news to me

#

i cant test it rn

cinder shadow
#

I'm too lazy to make a simulated player

thorn flicker
#

because like, how would it return offline players?

#

they dont exist anymore when they leave

#

doesnt make sense

cinder shadow
#

well, now I'm curious enough hold on 😭

thorn flicker
cinder shadow
#

I've actually never used gametest, no clue what I'm doing

thorn flicker
#

-# thats why I said I cant

cinder shadow
#

okay, I can't make a simulated player leave the game

#

so this won't work lol

#

maybe?

#

and now my game crashed :]

#

I'm assuming I would need to use bot.disconnect();

thorn flicker
cinder shadow
#

It would certainly be much easier lol

thorn flicker
#

i can be your tester

cinder shadow
#

I really just need to get a 2nd version of minecraft running

#

but that's a little tedious in itself

#

are you able to join preview worlds?

#

I think it works on same platform, just not on cross platform

thorn flicker
#

I have preview downloaded

cinder shadow
#

yeah

thorn flicker
#

we're good then.

cinder shadow
#

can you test now?

thorn flicker
#

mhm

#

we need to be friended on xbox app right?

cinder shadow
#

what's your gt

thorn flicker
#

ill dm you it

broken pawn
#

can we uae afterEvents.playerInteractWithBlock to move the interacted block into our equipmentSlot? and the following block still with it's data?

#

like how setEquipment

stray spoke
#

You can, but why not pick block feature

#

Does player interact with block still works like clicking any block, I think in the new update it's only detectable when interacting a block like chest, furnace, crafting table, anything that has interactions

broken pawn
stray spoke
#

Yes you can

broken pawn
#

nice

jolly citrus
#

is there any better way to detect if a player is sneaking than to check for the value of the isSneaking property every tick

last latch
#

There is no event to check

#

Not sure why you would need a different way tho

last latch
jolly citrus
#

not like it matters much tho

#

im assuming the effect is negligible

jolly citrus
#

but why do i fall down so slop

#

slow

last latch
last latch
jolly citrus
#

it happens every time too not rng

#

i guess this means i was right about spamming sneak making you fall slower then

#

LMAO

last latch
#

Haha thanks for the tip 💀

jolly citrus
#

i feel like this is a result of the recent movement cheat prevention measures theyve been pushing out

#

ive had a lot of issues with movement but this is probably the most apparent if it is caused by it

last latch
jolly citrus
#

so i can't configure that

last latch
#

Oh.

last latch
#

But that’s kinda good

jolly citrus
#

pretty sure it is on worlds too

#

even singleplayer

last latch
#

I’m in so mood for coding rn bro

#

Gotta install mcpe on my pc asap

worldly heath
#

is there any downsides for allowing achivements in an addon ?

#

like does it disable triggering commands or block anything else

snow knoll
jolly citrus
last latch
alpine wave
#

@last latch yoo is it possible to make a hud_screen.json where I can add a button that shows on every player screen and when you press the button it opens the menu from the bp

#

Oh shoot wrong channel my bad

#

I ment to say it in Json ui general

jolly citrus
#

i wanted sneaking to act as like a dismount button basically which meant it cleared player velocity

#

but it fired multiple times so if you kept sneaking itd just repeatedly clear and clear it

#

is it possible to close an action/modal form for a player

last latch
alpine wave
#

How do I make it where PC people can press it too @last latch

next frost
#

Is it possible to spawn an entity with a dye color?

for example, a red sheep?

alpine wave
#

@last latch is this a thing in scripting

EntityEquippableComponent

#

For import { EntityEquippableComponent } @minecraft/server;

alpine wave
#

What about EquipmentSlot

#

I just trying to learn here okay @last latch so sorry if I asking too many questions

last latch
#

you have all the info there

round bone
#

Also, try pinging other people less

untold magnet
#

hmm, is it possible to detect the target of my entity? aka if the zombie is targetting a villager,

round bone
#

I can't really remember the answer and I am currently on my phone, so that's the best thing I can tell you right now :/

untold magnet
round bone
#

Are you in stable or preview?

blissful siren
#

Guys, I want to create a system that will have several codes stored within the addon itself, and if you use, for example, `?item ABCDE, it will delete the command from the chat and give you a compass only once, then this code would be set as used

untold magnet
last latch
untold magnet
# last latch wdym "as always" 😭

i never use beta api, bec im god damn lazy (u can see it next to my name) i just dont want to update my addon every time the api gets updated

somber cedar
last latch
#

Nowadays old things rarely change

round bone
untold magnet
untold magnet
#

im using the 2.0.0-stable, no experimental toggles, and it works.

untold magnet
silver agate
#

Is there any way to detect a chest the player interacted after the player closing it? To possibly detect what items player put in there

stable shadow
#

My friends and I managed to expand the player's inventory using serenity + json ui.

#

hehhehe

jagged gazelle
#

Is there a way to make that we prioritize onUseOn over onUse?

#

onUse is prioritize over onUseOn that's why I'm asking for solution

unique trellis
#

It was supposed to turn into a swap shelf when I hit the shelf with the stick.

Era para quando eu bater com o graveto na prateleira era para virar uma prateleira de troca

sudden nest
#

Is it possible to ".replace" A RawMessage?

frosty yoke
sudden nest
#

Like, let's say u have a lang file containing your custom item that has an additional string something like "\nSomethingFancy", then inside the script, i want to erase or remove that "\nSomethingFancy", cuz i just used it for Creative Inventory and i don't want it to be displayed when i am calling it's name.

#

Wait, i think my message is confusing, even I am confused

#

Imma send an image

#

i don't want to include the whole thing

#

i don't want to create a hardcoded names for each items just for this cause that's not maintainable if you have many items

halcyon phoenix
cold shoal
#

Is it possible to subscribe to console logs and warns from scripting API to /connect websocket just like "PlayerMessage" event?

cold shoal
#

Do you know what event I need to subscribe?

round bone
sour sedge
blissful siren
#

Guys im doing a system that gives a shulker box full of items

#

How can i do It?

#

I know i cant make it drop, and i need to use structure blocks

#

But idk how to put structure loads in scriptinf

jolly citrus
blissful siren
jolly citrus
#

yeah

blissful siren
#

But how would that help me?

jolly citrus
# blissful siren But how would that help me?

example of my implementation but for kits

static fetchKitItems(kitId: KitId): ItemStack[] {
    const dimId = cfg.kitChests.dimensionId as string;
    const dim = world.getDimension(dimId as any);
    const pos = this.getKitChestLocation(kitId);
    const block = dim.getBlock(pos as any);
    const container = (block as any)?.getComponent?.("inventory")?.container;
    if (!container) return [];

    const slots: number[] = ((cfg.kitChests.kitSlots as any)[kitId] as number[]) ?? [];
    const out: ItemStack[] = [];
    for (const slot of slots) {
      try {
        const it = container.getItem(slot);
        if (!it) continue;
        out.push(it.clone());
      } catch {}
    }

    return out;
  }
#

place the filled shulker in a chest

#

then load it from there

blissful siren
#

Ohhhhhhhhhhh

jolly citrus
#

get the coordinates the chest is at

blissful siren
#

Makes much more sense

jolly citrus
#

and know the slot (just place it on the first slot , index 0)

#

then get the item from the chest's container

#

chest.getItem(0)

#

then you have the shulker stored in memory simple as that

#

very clean way to do it

blissful siren
#

Wowwwww so cool

jolly citrus
#

you can do whatever with it that you can with a normal itemstack in script api

blissful siren
#

My system looks a bit like the kit system

jolly citrus
#

clone, delete, edit, add to inventory etc.

blissful siren
#

The only diff is im trying to like

#

Create several codes and save them set to false; when they are used, they will be set to true.

jolly citrus
#

or

#

like codes that you can redeem to receive a shulker

#

or what do you mean by a code

blissful siren
#

Like

#

Is a kit system

#

And like

#

I have the code blablabla-12344

jolly citrus
#

yes

blissful siren
#

When i use It i got the pvp kit

jolly citrus
#

and the code becomes unusable ?

blissful siren
#

Yes

jolly citrus
#

okay

#

do you want it to persist between sessions ? (e.g. world/server leave -> its still unusable)

blissful siren
#

I tried using gpt but he is so dumb i gave up and started trying looking myself in wikis

jolly citrus
#

okay you can use dynamic properties for this

#

do you want self-configured codes or do you want like a list of procedural, random-generated codes

#

i have a system similar to what you want but used for redeeming gift cards to receive gems

blissful siren
#

I was going to make random ones from websites and put them in the addon lol

jolly citrus
jolly citrus
blissful siren
#

Yea

jolly citrus
#

you can use PRNG

#

random generation from seed

blissful siren
blissful siren
jolly citrus
#

but it's predictable, meaning you can generate the same random sequence again whenever

blissful siren
jolly citrus
#

the amount doesn't really matter

blissful siren
#

Bro is you an angel 😭😭😭😭😭😭

jolly citrus
#

the only information you need to really 'know' yourself is a static seed configured in your code

#

you can for example make a form that generates a valid gift code later

jolly citrus
#

so you can distribute them to players

#

example of mine

#

but instead of what i have like GEMS_100 GEMS_50, you could have KIT_1, KIT_2 and so on

blissful siren
#

Ohhhhh cool

jolly citrus
#
static generateCode(seed: string, table: string, index: number): string {
    const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    let state = this.hash32(`${seed}:${table}:${index}`) || 0x6d2b79f5;

    const nextU32 = () => {
      // xorshift32
      state ^= state << 13;
      state ^= state >>> 17;
      state ^= state << 5;
      return state >>> 0;
    };

    const chars: string[] = [];
    for (let i = 0; i < 16; i++) {
      const r = nextU32();
      chars.push(charset[r % charset.length]);
    }

    const groups = [chars.slice(0, 4), chars.slice(4, 8), chars.slice(8, 12), chars.slice(12, 16)].map((g) =>
      g.join("")
    );
    return groups.join("-");
  }

  private static hash32(input: string): number {
    // FNV-1a 32-bit
    let h = 0x811c9dc5;
    for (let i = 0; i < input.length; i++) {
      h ^= input.charCodeAt(i);
      h = Math.imul(h, 0x01000193);
    }
    return h >>> 0;
  }

this is what i use to generate codes

blissful siren
#

Wow

jolly citrus
#

generateCode will always output the same code as long as you input the same values used to generate the state

#

which here are seed, table (for me this is like GEMS_100, GEMS_5) and the index

shy leaf
#

that seems like a nice way for generating random codes

jolly citrus
#

it is

blissful siren
jolly citrus
#

the key is in using predictable RNG

shy leaf
#

no use of Math.random() which can be predictable

#

oh wait

jolly citrus
#

the seed is meant to be kept secret

shy leaf
#

ok to be honest theres practically going to be no one whos gonna predict this just for something

#

so yeah ig it works

jolly citrus
#

with these values

seed = "abc123"
table = "GEMS_50"
index = 0

generateCode() might output e.g. "123" (obviously my formaat isn't the same but i cba to type it out), but if i switch any of these values (key value here is the seed since it's the only one that only the server only has authority to access), it could output "321"

#

the list of gift codes is predictable and that's why it works

#

you dont need to have them all stored individually somewhere

jolly citrus
shy leaf
#

it is nice

jolly citrus
#

as long as they dont have additional intel that reduce the pool

jolly citrus
#

which is why its useful to use a mix of symbols and make it long

shy leaf
#

i reckon a few coders/codebase using emojis for random stuff

#

like MCPE-IPC

jolly citrus
#

yeah it doesnt matter what it is as long as its not guessable

#

but bruteforcing a 20-char seed using any possible unicode will take astronomically long

blissful siren
#

@jolly citrus But like, how would I link the code to the main command? Would I create a codes.js file, store it there, set its values to true/false, and then import it into main.js?

jolly citrus
#

and what values to true/false

devout sandal
#

Can beforeEvents.entityRemove REALLY not check the removed entitys tag..? its a before event... wth

snow knoll
devout sandal
#

I’ll try it out

devout sandal
snow knoll
#

You could cancel the event and then kill them afterwards

devout sandal
#

Ahhhhh good idea!

devout sandal
warm mason
warm mason
#

or did u already solve it?

jolly citrus
#

Why do i get such low fps on my world

#

With scripts

#

Theres not rlly any tps issues its just that im stuck playing on like 5 fps

warm mason
jolly citrus
#

Sometimes it can jump up to like 80-90 but other than that i get 5-15

jolly citrus
#

if i remove the pack completely i get 200

warm mason
jolly citrus
#

there's no particles

#

i mean i do get tps drops aswell

devout sandal
# warm mason what do u need?

I’m trying to make renewable deepslate by converting stone splashed by a thick potion into deepslate, I currently am getting the itemUse before event to add a tag to the player who threw the potion, getting the entity spawn after event to check if the projectile owner has the tag, removing the owners tag and applying a new tag to the projectile, and then I wanted to use beforeentityremove to get the tag and then convert the blocks at the location if the projectile had the tag, but that’s giving me an invalid entity error. I just need a good way to do this, idc how.

snow knoll
# warm mason "Anything" is anything that changes the world, while anything that simply reads ...

You make a great point
When I said anything I was referring to all the things we can do through scripting and more often than not, I've found that these methods don't tend to work when in read-only.
As for the lack of an event cancel in this scenario, it should've been something I should've assumed, given its name and definition, but I tend to assume and find out the hard way with these things 😅

chrome gyro
#
entity.playAnimation("animation.cnb_crp_sg1_l1.attack", {controller: "variable.gh=48;"})

Any ideas why this variable isn't transferring to the animation?

#

Feel like it's something with my formatting.

devout sandal
# devout sandal I’m trying to make renewable deepslate by converting stone splashed by a thick p...

I have it working right now where I am using the projectileHitBlock hook and just checking the owners tags for a "threwThickPotion" tag, then removing it and doing the conversion. But I feel like this is not a good way to do it. I think the projectile should have the tag, because if there are multiple it might break, but you cant get the potion type from the ENTITY, so i have to get it from the owner in a before event, then apply it to the entity when its created by the owner if its of type splash potion and the owner has the tags. if anyone has any recs or suggestions id credit them with the help when i release my addon. Im so burnt out from this one stupid problemXD

snow knoll
jolly citrus
devout sandal
jolly citrus
#

i left my content log file on holy shit

#

i have like 30gb of logs

#

thats why

snow knoll
#

🤣

snow knoll
#

They have like 5 components at most

#

So you're in luck

snow knoll
chrome gyro
#

Because I don't know how to read this 😂

devout sandal
chrome gyro
snow knoll
snow knoll
chrome gyro
chrome gyro
snow knoll
#

Cool

devout sandal
#

am i not thinking of a better way to do this though? it makes sense right?

#

could i add an event/ component group to the splash potion that the script activates when the entity is created/removed??

chrome gyro
#

You should even be able to store the location of the place where it "died".

#

Nope, doesn't count as dying, just tested it.

fading sand
#
player.camera.fade({
        fadeColor: { red: 1.0, green: 0.0, blue: 0.0, alpha: 0.1 },
        fadeTime: {
            fadeInTime: 1.0,   // 1 second fade in
            holdTime: 10.0,    // Hold for 10 seconds (max allowed)
            fadeOutTime: 1.0   // 1 second fade out
        }
    });

why is the alpha setting not working?

fading sand
#

ah i see

#

thats unfortunate

chrome gyro
#

Been thinking for the last 20 mins.

chrome gyro
#

Wait, @devout sandal is the issue just that you can't get the location of the splash potion?

chrome gyro
chrome gyro
blissful siren
#

@jolly citrus what the diff between the Typescript and the javascript and if i use js instead of ts the code will break?

snow knoll
# chrome gyro Yes please, that would be awesome.

BlendOutTime?:

  • defines the amount of time taken for the last frame of the animation to transition into the entities base geometry, or into the next frame of the animation currently playing. The default value is 0
    Controller?:
  • defines the identifier of the animation controller. This matching an existing animation controller in the resource pack will cause it to override the controllers animations. This being a different value to another playAnimation controller will cause the 2 animations to play simultaneously. This being the same value as another playAnimation controller will stop the first animation from playing and cancel it, with animation the second playing normally, the default value is __runtime_controller
    nextState?:
  • defines an animation identifier or shortname (found in an entity's resource pack file) to immediately transition into playing upon the prior animation finishing or it's stopExpression being met. The default value is none
    Players?:
  • passes a player object defining all the players capable of seeing the animation play. The default is all players
    StopExpression?:
  • a string molang expression value made up of molang queries and/or variables defined in an entity's resource pack file. When the defined conditions are met, the animation will immediately stop playing or gradually transition from for the duration of time stated in the blendOutTime to the animation in nextState. The default value is query.any_animation_finished
fading sand
chrome gyro
snow knoll
chrome gyro
#

I thought about it, but my properties are super full right now, at like 29 so trying to spare them and not sure I wanted to route all the attacks through properties either.

Oh... wait I think I could just run it from a command 🤦‍♂️ . Thank you for explaining all that though!

snow knoll
#

Absolutely no problem 👍

chrome gyro
#

It's such a tiny thing, but when the entity that's attacking get's knocked back there's a little jump they do because the entity gets thrown up. I was trying to neutralize that so the attack animation doesn't get muddled by all the jumping. Thankfully I was able to do this:

        const eloc = damagingEntity.location
        const topb = entity.dimension.getTopmostBlock(ploc)
        const gh = topb.y - ploc.y
        entity.runCommand(`playanimation @s "animation.cnb_crp_sg1_l1.attack" none 0 "variable.gh=${gh};"`);
devout sandal
devout sandal
# chrome gyro Wait, <@392519345936269313> is the issue just that you can't get the location of...

the issue is differentiating between what potion type it was when it died, I can get location pretty easily with any of the above mentioned hooks, but the splash potion ENTITY, type id is just "minecraft:splash_potion" and its localization key is similarly non specific, so I am having to use tag/dynamicProperties. A
nything that is an after event throws the invalidentityerror, and the only before event I could find that was relevant "entityRemove" throws it as well..

jolly citrus
#

Just rempve all the ts specific features

#

Type declarations annotations etc

subtle cove
sudden nest
wicked girder
#

Anyone know the best way to plan/make a route for a camera cutscene?

halcyon phoenix
#

how do I check for this?

wary edge
halcyon phoenix
#

thanks

#

I thought it's isValid()

fickle dagger
#

what's the amount limit of dynamicProperty? and does it share with other addons too?

jagged gazelle
tepid kindle
#

In the manifest uuid?

jagged gazelle
#

sorry, I phrased it wrong...

tepid kindle
#

Get it, thanks

granite cape
#

legacy

broken pawn
#

how do i get value of component from an item or entity?

tepid kindle
#

Why does block.above().location always on the very corner, or something wrong

broken pawn
#

i do know if it uses getComponent

tepid kindle
#

Or if dp getDynamicProperty(id)

jagged gazelle
jagged gazelle
tepid kindle
#

I tried to spawn an entity in that location but it's always on the corner of the block

#
world.beforeEvents.playerInteractWithBlock.subscribe(data=>{
  const {faceLocation,block,player,itemStack: item} = data;
  player.dimension.spawnEntity("minecraft:allay",block.above().location)

Like that

#

I mean it did spawn, just not centered

tepid kindle
#

Centered at the top of the block

tepid kindle
#

Thanks

#

It can be like block.above().center() right

jagged gazelle
jagged gazelle
tepid kindle
#

Understandable thankyou

#

I thought if its whole number it's automatically centered

broken pawn
#

import {EntityComponentTypes as ect} from "minecraft/server";

for(const Target of world.getAllPlayers(){
const A = Target.getComponent(ect.Health);
const B = A.currentValue;
const C = A.effectiveMax;
if(A){if(B<C){A.setCurrentValue(B+1,C)}}
})

#

wait

#

is it correct?

#

i mean how player.Health component works? and if player has Health_Boost effect, will it affect it's max value in the json? and how to detect if the player's health is full before make the script stops detecting it?

#

also saturation.component

tepid kindle
#

Oops misunderstood

midnight ridge
#

does script api supports write and read the data of this thing or not yet

tepid kindle
tepid kindle
tepid kindle
broken pawn
#

maybe, may i have to check other example

tepid kindle
#

In your example, you use alias A,B,C so:

if(A === B){
  player.sendMessage("Im full health") //or something 
}
broken pawn
#

can we create a function inside a function? i hope so

jagged gazelle
jagged gazelle
broken pawn
#

understandable, and if i create it inside the function, will the other type can detect the function that is inside the function?

jagged gazelle
broken pawn
#

nice, then i can relax now

jagged gazelle
#

you need to expose it if you want to access it outside that scope...

broken pawn
#

understandable, have a good night

midnight ridge
midnight ridge
jagged gazelle
midnight ridge
jagged gazelle
midnight ridge
jagged gazelle
#

I wrote something there, bruh and lol

#

using clay block

jagged gazelle
#

yes lol

#

I also said something in chat

#

I guess it didn't load?

#

I played around there for like 20 minutes then dip

tepid kindle
halcyon phoenix
#

how would you connect two entity each other?

example
I have Entity A that is connected to Entity B I want Entity A to always follow Entity B via applyImpulse() or teleporting to it's direction however the issue is that if there are multiple Entity A and B it's hard to have a unique identifier on where to connect it

halcyon phoenix
broken pawn
#

i guess yes

halcyon phoenix
#

Entity A to Z depending on the length

#

or duplicates

#

following each other

#

a worm system

#

yeah

broken pawn
#

maybe not me can answer this, i haven't understand how this thing works

jagged gazelle
jagged gazelle
jolly citrus
#

Are properties of Player.inputInfo easy to spoof ? should i not rely on it

distant tulip
#

how so?

jolly citrus
#

I'd like to use it to make matching touch players with other touch players, KBM players with other KBM players etc. in duels more likely

#

but i presume its not the hardest of tasks for a hacked client to spoof this information

honest spear
distant tulip
#

yeah i guess you can spoof your input and device

honest spear
#

only thing you can trust is that xuid is actual xuid of the account haha

jolly citrus
#

idk if it's worth trying to implement it or if it'll just cause more hassle

distant tulip
#

just go for it
you wouldn't get anywhere trying to avoid spoofing