#Script API General
1 messages · Page 57 of 1

Last actual ScriptAPI message: #1067535608660107284 message
hi
uh oh
tf is goin on here?
avoiding discord limits
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.
are users who arent active getting removed or its random?
Ooh...random would be fun.
Well random since Hero was removed and I was not
I might’ve done something wrong because it was supposed to remove people who haven’t sent a message in the last month.
Okay
hi guys
hi
hello jayly
hello
Interesting. Didn't know that.
We didn’t know either until we reached it 😭
Resaving my spot
I suppose that's a big milestone to accomplish though lol.
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.
next time:
Anyone have an example code for an sneak input event signal?
Is there any way to prevent block collision on player?
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?
When I have a bad wifi connection, when I click on the chest, it usually runs twice in a row
instead use dimension.playsound('sound_here')blockLocation
and do blockLocation = block.location;
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"] }
});
}
change playerinteractiwithblock to just onInteract
[Scripting][error]-ReferenceError: Native function [Dimension::fillBlocks] does not have required privileges. at replaceBlock (main.js:21)
at <anonymous> (main.js:9)
Okay, I will check now
world.beforeEvents.worldInitialize.subscribe(eventData => {
eventData.blockComponentRegistry.registerCustomComponent('blushrooms:saplings', {
onPlayerInteract(e) {``` like this
thats an item component, and you cant edit a block's code
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)
no but he can write it as a global thing like they do with vanilla tools
unless you cant overwrite vanilla sounds
I'll call this "the great purge"
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
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.
Don't use getDimension unless you want to do something in only one dimension. In this case, you have player and block, you can use their dimension property.
i mostly do it because i forget punctuations in scripts
and also cuz it makes it easier instead of random.dots.ever.time
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)
}
yeah thats alot simpler than what he had
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
show the code
Doesn't have it anymore.
Switched to my own approach to get the blocks. Do you really need the code to analyze it?
Well, I just don’t know how it works, but I have a guess.
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
let list = volume.getBlockLocationIterator()
let value = list.next().value
let locations = []
while (value != undefined) {
locations.push(value)
value = list.next().value
}
Ah I see, you use next().
You might want result instead of value for that while (arg)
can anyone give me an example code of an entity hit block event signal?
https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server.WorldAfterEvents.html#example-hitblockjs Example: hitBlock.js
You have to use a different event - playerBreakBlock
thx
hi
anyone knows how can I make the player interact with only the empty hand?
what is in the selectedItem variable
⬇️
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
thanks. I'll try that
the tadase's one was better
-# who pinged 
[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 });
You probably need to wrap it around a system.run since you're probably calling this in a before event.
Who pinged me
me
me
the problem is solved anyway so, sorry for the ghost pings
What's that problem?
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
congrats, u figured it out and wasted his time🎉
I thought faceLocation returns the center from the side of some block... And this turns out to be a really cool thing
they are an object
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)
Im trying to figure out where on the block I touched so the block knows which permutation to place
the block is a full block?
wait are you doing face or 3d selection
Or 4x16x4, or 4x4x16 depending on direction
Face
So if it places in the red areas it places vertically
If it places in the blue areas it places horizontally
how big is the selection?
2px?
or you want to half the block into 4 selections
It's 4 pixels wide
And 16 pixels long for the blue and 8 long for the red
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
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");
});```
can this go into a beforeplayerplace component?
Yah, just copy paste it.
untested lol
well time to test it lol
That's a variable thing inside of your particles not a script problem
Wym by that?
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 ?
they only occupy what they occupied while the remaining is empty
It has 32767
weird, I'm using vanilla particles
What particle
some vanilla particles have variables.
U see this db
Nope. Because bot deleted it 😭
Like , i have vectors and they will grow linearly
How to say it :
I have db to save vec3 locations
it can't fit inside one dynamic property?
minecraft:soul_particle
And if u add more and more vec3 to it ,
It will take long time to get it all for u
That s not the problem
The problem is searching time itself
Like it gets everything
make a key for each location
That s the problem
{
key1: { x: 0, y: 0, z: 0 },
key2: { x: 0, y: 0, z: 0 }
}```
It doesn't have keys, it safes locations like this :
/X:y:z/x:y:x/x:y:z/
Then create one.
:-:
Lot of checks is bad
;-; i want a smart way to combine between memory management and low searching time
try using setSpeedAndDirection from MolangVariableMap
how are you saving them that's the question
can you save locations using an array?
they would need to do setVector3
[
{ x: 0, y: 0, z: 0 },
{ x: 0, y: 0, z: 0 },
]```
you mean this?
why?
or this
[
"0, 0, 0",
"0, 0, 0",
]```
sure
I m saving them as strings
either save them as an object and add a key or add key the very start. "key1:0/0/0"
Then retrieve them later
But :-: i want like a smart way to get them
ngl, I prefer to make them as an object.
So it works?
then create multiple dynamic property 😝
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
Yey, I'm not shit at math.
Why are you using / for the variables?
Divide?
we had this conversation already lol
since the full block has 16x16px fave
Hmm is there a possibility to get location arranged based on their chunk location?
Hmmm that looks interesting
More maths? Lezz go
😅
time to refresh my fish brain memory
Yeah i need to implement binary tree somehow to make searching or loading location more efficient
Any ideas ?
^ unrelated but this is one of the proudest scripts I ever did.
#1067535608660107284 message
Modulo their location by 16
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
I want like making the dynamic peoprety id like based on chunks locations
yeah, I'm dividing them .
Like
SetDb("locsChunk-0:0:3")
Ok yeah this officially out of my area of expertise
Which was miniscule to begin with
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.
i definitely remember using both
but i guess setVec is better for his case
Hmm, making one dynamic proprety for all making work with them messy
Like i want to optimize my db as far as i can
If you don't know how then yes but if you know how then no problem
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.
I guess I need to mess with it again
uhh? What? Mine is a lot bigger than location dude.
if you don't want my idea then don't.
like, as i said make a key
.. but ,,
._. ok question
Why will someone use Vec3 db ?
Ask yourself
:-: hmm
Hmm ok i need it for my add-on
how the hell you would differentiate each location if you don't know how to?
And find out that when i add 300 locations world get low response time
I want retrieving process to be faster
Like i can't make them in one dynamic proprety
ngl it's bad if you do that
you waste too much space in one dynamic property
-# thanks for the idea r4isen
Just , do u know how much power , cpu power , ram does it consume to keep 10 mb string in ur memory:-: every 100 location
uhh. Unless You're saving it multiple times then yes
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 🤷
And what about the time for getting all data from ur db in one variable as string
Bro my problem is not with the idea itself :-:
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.
I just finished my db bro
Then good?
man I'm outt my head hurts with you lol
Discord didn't let me send links for 30 mins
So u thought i didn't start making it yet :-:
I already saw that.
then why ask about the "key"?
But i want ideas to optimize it , that what i mean
making it in one string isn't one of them
._. maybe
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?
I m very bad at explaining :-:
world.afterEvents.entitySpawn.susbcribe(({ entity }) => {
if (entity.typeId !== '<mob id>') return;
for (const player of entity.dimension.getPlayers({ location: entity.location, maxDistance: 16 })) {
if (player.hasTag('hxt')) {
const nickname = player.name;
let dono = 0, raio = 0;
const power = world.scoreboard.getObjective('power').getScore(dono);
}
}
});```
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,
Could you explain to me why this change?
@dim tusk
that's the thing, if you save multiple locations into multiple dynamic property
Then ?
that's why I said save it in one dynamic property to consume all spaces
then just add another one if it's full
I did that before i implemented this
and?
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
it's not because of db, it's how you get them or you load them
Are you using a big array into a single dynamic property?
nope, it's multiple dynamic property
Yeah now i want more efficient way to load them
I didn't really change anything, all I did was use const and let instead of var and instead of using world get dimension we use the dimensions of the spawned entity
You split your array into different dynamic properties??
and why use var in the first place?
No like effecient way that it only load one dynamic property
Like a smart db location loader
To split string and convert it to vector 3 again
hhuh? I'm not talking to you 😭
okay, thankys
Wait lemme clarify again. You're using multiple dynamic properties for each location
No
I m using a dp until it gets full
Then after it gets full i add another one
And so on
Thats not efficent 🤔
So if it loads anything it loads everything with it
because you don't have a key?
Like if i saved 10 dp
it won't do that unless you load what you only need
Yes and no , but i don't need keys
I just need the locations themselves
it depends since if you saved a location in each separate dynamic property, the remaining storage of it is not used and useless
you just waste them.
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
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
When do you save the block C?
Any ideas ?
Error: Failed to get property 'dimension'
When block B get placed and the entity get spawned inside it ,
After that block C will get saved
Im realizing that putting it into a beforePlayerPlace event I dont need the localxyz variables
Imagine it like u have a ball
Then why you are storing it?
And u must through it to ur partner in football game
Then the entity is not even existing
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
No tp it after block B get destroyed
I need C location lol
I'm going to have to export the values from the code you sent me into a beforePlayer Place component
Just check it again
I didn't understand u ?
exists
Check if theres a block C in an AxB area
I need to loop through the whole AxB
How can an entity that was summoned not exist?
try doing console.error(entity.dimension.id)
Yes
Faster than the db you have i think
Or store it using the entity's dynamic properties
you are complicating your life
Nah i need the performance ._. because it s chunk loader
Elaborate
Maybe your way is less efficent and you dont realized
const entity = dimension.spawnEntity();
cons block = ...;
entity.setDynamicProperty('tpto', block.location);
You said 40 blocks radius, why 265
From down to top of the world
Why
Because it s chunk loader
Even block on Y = -63 is still have right to load the whole area
You can define where the block will be placed always??
The block itself is placed by player
Wich one
And the other one?
Can I test a player's use of a bow?
Farms builder
What
Big farm builder
Like idk , iron farm
A big cactus farm
A big computer in Minecraft bedrock
Hmmm well
Or give a tag to the arrow the player is shooting at
Like who will need chunk loader except them ?
You can still store the blocks, load them all in once into an Set/Map when the world starts
But...
But they keep growing every event
I mean if place event get triggered or break block event get triggered
How you was checking it before?
Same way , but using object
U mean how i check it now or , in first of all
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
world.afterEvents.itemStartUse.subscribe();
world.afterEvents.itemStopUse.susbcribe();
world.afterEvents.itemCompleteUse.susbcribe();
world.afterEvents.itemUse.subscribe();
Hmmm u gave me an idea
dont load the db everytime it gets broke
save into a MAP
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
just store the corner location of the chunk
not all
Corners ?
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```
Hmm
I'll try this
if (player.hasTag('mytag')) {}
Cool thanks
Elaborate
so whould it look like this?
What is the difference between these?
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
Good idea
It's in the name itself
Does the tag look right?
no
What?
you put the code you want to execute conditionally (if) inside of the {}
you can aslo
const block = player.dimension.getBlock(player.location);
if (block?.below()?.typeId === '') {}```
Hmmm
if (has tag) {
do this
}
I tried this, but it doesn't seem to affect anything. Something to do with checking the tag. I made a post about it
https://discord.com/channels/523663022053392405/1338271484841562192
I see, the purge happened
THE PURGE SEASON 3 HAS HAPPENED@! (It didn't but, this is more pog than it)
Brother, use:
try {
const block = (dim).getBlock({x: 0, y: 0, z: 0});
// some other code with block
} catch {
// log or not
}```
In your thread i don't see any try catch calls
no i removed it after
Bruh
ill throw it in again though
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
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?
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.');
}
Nah, you catching error
Almost correct
But remove that (error)
To silence the error from being sent
Also, why the fk do u have 2 block(s)?
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?
Yeaaa
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?
its still giving the error on the block.hasTag line
Please move to the thread. https://discord.com/channels/523663022053392405/1338271484841562192
familyComponent.getTypeFamilies()
-# https://stirante.com/script/server/1.16.0/classes/EntityTypeFamilyComponent.html#getTypeFamilies
Documentation for @minecraft/server
well darn thanks anyway
getType Non-organic families, you can't get the first family of the component
what?
family.getTypeFamilies()[0]
It returns arrays of family entities.
I've already tried and he's taking another family
const familyComponent = player.getComponent("minecraft:type_family").getTypeFamilies()[0]
console.error(JSON.stringify(family.getTypeFamilies()))
What do you mean "he's taking anothrr family"?
it doesn't pick up the first family listed in the component
Then what does it pick up?
the third family
It could be returning it in alphabetical order perhaps?
"minecraft:type_family": {"family": [ "aaa","zzz","ddd" ]}
does anyone know why .getComponent("minecraft:scale").value; is undefined even tho the entity has scale component
no
I changed the name and still
Well what does it return?
zzz
I meant the array.
Try doing this pinho
Check the order of it.
Then compare it in the json
@dim tusk gives the same result
Wdym gives the same result? The order is the same in json?
json is in another order
Send the order in json and the order console gave
what?
what do you mean what? send the order of families in json, and what console gave.
//json
[ "family1", "family2", ... ]```
//console
```js
[ "family1", "family2", ... ]```
...
"minecraft:type_family": {"family": [ "aaa","zzz","ddd" ]}
console: zzz
No. I meant console.log(familyComponent.getTypeFamilies())
What does getTypeFamilies() return?
Then your component is wrong.
There's no way it returns only zzz if the array is 3 values.
it returns the values
^ pinho, I said this.
Why can't beam.js read property subscribe?
Please tell us the order it returns.
Send the order.... That what we meant.
What you gave us is a single string we want the whole array
zzz, aaa, ddd
try adding more families to the mob and do the console log again... Maybe the first and second family are flipped
Also would these 2 scripts event work the way I want them do even if it could readbit properly
So how do I tag the arrow when the player shoots it?
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
what do you need that for
When the player shoots an arrow, I want to tag that arrow.
yeah but hes asking why
I want this to make various custom bows
Making a custom item?
what is the tag for
Teleport bow, explosion bow, oto aim bow
In order to change the direction of the arrow in the auto aim bow, I need to tag that arrow.
you can use projectile component to get the owner, if that what you are looking for
I'll look into this
Here's what I would do:
EntitySpawn event.
Grab the projectile component.
Grab the owner.
Check if the owner is holding a bow.
Apply tag.
Actually
Is projectileHitBlock this event?
wdym
Is there any whay to tell where on the block the player clicked with beforePlayerPlace like faceLocation in onPlayerInteractWithBlock
I don't understand what you mean by "projectile component"
entity.getComponent('projectile').owner
It's great that something like this happens.
PlayerPlaceBlockBeforeEvent do have faceLocation
Thanks
Oh
that's nice.
version?
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
worldInitialize is under system class now
this is not true 😅
ok so its something else
wadahell.
it's still under the world tho instead of the worldInitialize it's worldLoad iirc
🤷♂️
???
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
WorldAfterEvents renamed property worldInitialize to worldLoad
WorldBeforeEvents removed property worldInitialize
WorldInitializeAfterEvent renamed to WorldLoadAfterEvent
WorldInitializeAfterEventSignal renamed to WorldLoadAfterEventSignal
Removed WorldInitializeBeforeEvent
Removed WorldInitializeBeforeEventSignal
@tidal wasp @dim tusk
yeah, as i was saying
system.beforeEvents.startup
This is what I meant lol
Yeah, I just read the channelog
yep
how can I detect when a block has a specific state?
ok yeah im going to need to use 2.0 beta
Actually no I can do what I was doing previously
cosnt state = block.permutation.getState('<name>')
if (state === '') {}```
Yep that worked
Mmmm, I not sure If I wrote it correctly but It's not working at all
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
you dont have a main.js
But I do though
you reloaded it?
and?
Same error as before
Does the chat timeout eventually? Just need to know so I can see if i can get forms to open after a command
idk anything about bridge but you didnt missed a file while pasting into your development behaviour packs?
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
If you try to show a form to a player what is in chat it gets cancelled with the userbusy reason
you can try to keep opening it
So you need to keep showing the form until the response is not cancelled
And current way is to spam requests or damage?
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`);
}```
If the cancelation reason is "user busy" run the function again
You dont need a while loop
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}]');```
const ent = world.getEntities({ tags: [player.id] })[0];
if (!ent) return;
player.teleport(ent.location);
what do you mean? in this case I would find the entity with the player's ID?
Yes
So if i use that to keep sending requests, it will open the form if i manually close the chat? Or after a while will the chat close automatically and the form shows?
Btw that string interpolation doenst work with sigle quotes:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
Logically, when the player closes the chat
need to use `?
Okay thanks, still surprised there isnt an offical way to force chat to close.
Can you send the whole event? As dimension might not be defined.
@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
I tested it on the bot and it said that "getEntities" does not exist in "world"
Ah sorry
my bad
If the entity will be at the same dimension that player use: player.dimension.getEntities()
look it works, but I have a small problem, when I the player activate the command with /scriptevent test it works as it should, but when my entity activates nothing happens
When you entity activate it????
when I lean against her
What?
With the minecraft:entity_sensor
Via Queue command?
Yea
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
- Block Events
- Block Events Migration to Custom Components
- Item Events
- Item Events Migration to Custom Components
MS Docs
🤔
?
Show your full code
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"}]}');
});
yes i still need to migrate, im just going through the hard part initially
the entity
here he ends up activating the necessary commands with minecraft:entity_sensor
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
I don't think it will solve the problem because in this case for some reason no command is being triggered.
If no commands get triggered then the problem is the entity json
#1067869022273667152
but curiously without what you suggested it works, well I added the console.warm I will do more tests okay
const player = data.sourceEntity; // Player activating the portal
if (!(player instanceof Player)) {
console.warn("The event was triggered, but the entity is not a player.");
return;
}
this was the error i got
What were those messages up there?
apparently the event is catching my entity and not me, that's why it's not working
I need to figure out how to get around this problem...
Yeee
I achieved
I managed to get around
thanks for the help
why isnt the switch working
also I might have found a flaw with this
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
Because you need to add other checks for that
basically use z values if the player is facing those positions
The particle works but It only appears once
I don't know why
Is there anything else setting fire:state to something besides 1?
Not really, those lines are the only ones
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
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
sorry for weird question
from which version minecart start supporting the script modules and scripting in general?
what
you see the pattern.
i see a backwards J
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?
is it possible to detect if the goat have horns or not?
Hi
Hola
Nĭ hăo
hard coded into nbt tag
int GoatHornCount
eh
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
send line 33 and it context
world.afterEvents.projectileHitEntity.subscribe((eventData) => {
const { source, projectile } = eventData;
if (projectile.hasTag("Explosion")) {
console.warn("a")
}
})
Because the projectile already disappeared you can't access it's data now
Then I need to use before event
uhh no, there's no before events for projectileHitEntity
use before events entityRemove
Hmm
Too many files?
Oh, well, this custom component is a player interaction one, so it will only trigger when you interact with the block. If you want it to send the particle every so often, you'll need an onTick custom component, and a minecraft:tick component on the block
But RunCommand for Removedentity does not work
world.beforeEvents.entityRemove.subscribe((data) => {
if (data.removedEntity.hasTag("Explosion")) {
data.removedEntity.runCommand(`summon ender_crystal ~~~ facing ~~~ minecraft:crystal_explode`)
}
})
runCommand can't be executen in beforeEvents
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)
world.beforeEvents.entityRemove.subscribe((data) => {
const entity = data.removedEntity;
if (entity.hasTag("Explosion")) {
let location = entity.location
let dimension = entity.dimension
system.run(() => {
let crystal = dimension.spawnEntity("ender_crystal", location)
crystal.triggerEvent('minecraft:crystal_explode')
});
}
});
Or take this @fallow rivet , its better
Also, you don't have to use ender_crytal. You can use the createExplosion method
@warm mason Minecraft uses cjs right?
I don't understand what you're talking about.
common JavaScript
let location
idk
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
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)
|| I tried to use propertyOptions but for some reason it doesn't work ||
Thanks, I'll try it out 🫡
Can't I do it on the same script?
I tried to make it on tick but it's not working anyway
Try changing block.dimension to dimension
Also, do you have the minecraft:tick component in the blocks bp file?
kewl
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 
hm
hmmm
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
lol
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?
.............
it has its fluctuations, so i rarely use it
anyone?
This makes me cry...what you could do is just.
if(itemUsing){
damagingEntity.runCommand('scoreboard players add @s z2_charge 1')
switch(score.getScore(damagingEntity)){
case 0:
damagingEntity.triggerEvent('bleach:z2_charge_reset');
break;
case 1:
damagingEntity.triggerEvent('bleach:z2_charge1');
break;
// etc
default:
break;
}
}
sorry lol
still learning
thx
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)
}
ehh can u explain whats happening here
oh wait I kinda get it
but the scoreboard doesnt match the charge lvl
runCommandAsync happens after 1 tick
Nah, it uses esm
addScore happens same time
even better
const charge = score.getScore(damagingEntity);
const events = {
0: 'bleach:z2_charge_reset',
3: 'bleach:z2_charge1',
6: 'bleach:z2_charge2',
9: 'bleach:z2_charge3'
};
damagingEntity.triggerEvent(events[charge]);
uhh, runCommand happens same tick as well, do u need the previous score?
oh just realized you added a *3 mb
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
can anybody help me with chestui? https://discord.com/channels/523663022053392405/1338522867687489620
Ehhh....
???
Be patient
Yeah that's impatience
Also you don't even show any of your code that you are supposedly having problems with
2000 years is too little time to wait 🗿
Did you wait 2000 years?
did you even check my post
im using herobrines chestui
So?
average guy that never saw herobrine's chest ui
Keep your opinion to yourself sir
I didn't ask for it
says the guy who didn't read the readme
I want the last one to be like >= 51 how can I do that?
The chest ui says it uses aux values
Which means when you add a custom item
It shifts it
length: 18
Which means you have to shift the type ids manually.
Every time you add an item.
And for the record
hu
I didn't ever use herobrine's chest ui
i mean when i did "minecraft:diamond" it did beef
I just readed the README.md
in short
the item aux id shift when there is a custom item
There was no need for that comment dude.
ikik but idk like where
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
2 months outdated?
also there is inventory but its empty and im asking if there is anything to do or if there is nothing we can do
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
Like addon
I'll do that, thanks
yeah, the chest form could also be outdated
this error appears
[Scripting][error]-InvalidArgumentError: Unexpected type passed to function argument [0]. Expected type: string at <anonymous> (main.js:122)
at
damagingEntity.triggerEvent(z2_charge_list.get(z2_charge))```
im sure i downloaded the newest version
const charge = z2_charge_list.get(z2_charge)
if (charge) damagingEntity.triggerEvent(charge)
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?
I want it so at specifically 52 or higher it runs an event
they all happen in script, so yes they should stop even in /reload
Ah, thanks for information
if (charge) damagingEntity.triggerEvent(charge)
if (z2_charge >= 52) damagingEntity.triggerEvent('custom:event_01')
thx
could be a bug
edu?
do the doc include those?
Can anyone tell me how I can fully learn the Script API?
there's element in the repo, idk
chest form also include edu
you know javascript?
Yeah
I want to learn the entire API so that there would be a field for the concept
just look around the docs and learn from them
The problem is that sometimes there is too little information there.
Is there a complete manual?
nope, just a progressive doc
Eh... I see.
no, you will need to try and learn
most of the stuff are just knowledge sharing here
altho the one in docs is for preview
probably
Thank you for your time
these are the only useable modules atm
server and server-ui are the commonly used
do getAllPlayers to make the system work for each player to make it multiplayer friendly,
it does work for each player.
but all of them will receive the same event at the same time
@shut beacon updated it
replace chest form one with it and check if it work
having getAllPlayers will make it that each player will get its own events,
like applying an effect for one player using getPlayers will give all players the effect, not only one of them will receive that effect.
holy moly thx!
actually nvm, it is somehow smaller then the chest ui one 
idk where he got the others from
that doesnt make sense.
@distant tulip explain to him
( im not that good on explaining things )
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.
both return an array with players and you are looping through it.
I dont understand how there would be issues.
just do getAllPlayers
getPlayers => [player0, player1, player2] array that will do the same exact event for all players at the same time
getAllPlayers => [player0], [player1], [player2] array that will work for only one player at the time, like if one of all other players is sneaking and the other is not, that one who is sneaking will receive an event.
understand?
getPlayers != multiplayer friendly
getAllPlayers == multiplayer friendly
Can anyone help here?
https://discord.com/channels/523663022053392405/1338473303521886240
you said that already.
ill mess with it on my own time.