#Script API General
1 messages · Page 58 of 1
another explanation:
getPlayers: if one of us touches grass we will die, the script will detect if the player touches grass, all other players will die at the same time, having all players in the same array
but getAllPlayers will make each player have its own array.
( i hope u understand it )
Hey is there a way to detect if a player is 1 second away from completing sleep?
stop explaining.
idk i haven't done something like it before
Oh
Also can you help here?
https://discord.com/channels/523663022053392405/1338473303521886240
sorry for repeating question
but i couldn't find information about it
from which version minecart start supporting the script modules and scripting in general?
No, both getPlayers and getAllPlayers return the same thing. ( Array of Players )
The only difference is that, getPlayers() can use EntityQueryOptions
If you use .forEach(), it'll do the same thing for both.
What you probably have, causing "not multiplayer friendly" is a logic issue on your part.
that's what im saying
that means the code was wrong and i was have to do forEach thing,
understood
you didnt loop through the array?
probably
hmm
...
why i cant detect the pale wolf variant?
idk
if (variant?.value === 0) is the pale wolf variant
i tried console.warn it, it says undefined
detecting other variants is fine, but idk why its not the case for the normal pale one
i think it just doesn't have a variant type
cuz i did if (!variant) and it works for the pale wolf variant
yeah
maybe cuz im on beta
no
sometimes it spawns without the variant component.
just check if its undefined or 0
I spawned a wolf in the swamps and it was default skin, but it says it doesnt have the component.
i think cuz its coded to spawn with the variant 0 only inside of some specific biomes
i tried it inside of the desert, its undefined
exactly
so yah i should do if (!variant || variant?.value === 0)
yes.
that make sense, but mojang doesn't make any sense lol
I think I make sense 
isValid turned into properties but the BlockIterator uses method in the same preview introduced.
air being a block
They were trying to block air
why doesnt the if statement ever return?
even if I go ahead and do console.error(e.block.getTags()) it returns nothing
which statement?
if(e.block.hasTag('beam'))
You need to include the identifier with hasTag
I want to create a system using the JSON UI to display the player's money permanently on the screen.
I have already modified the player's title, but I need a way to attach the money display to the player's screen. My goal is that when I send a message with the title "money," the player will see both the label "money" and their current balance, positioned at a specific offset on the screen.
How can I achieve this?
can you use permutation to place to set multiple permutations to be placed
how do I get types for Custom Components? It's a pain to have to search every single component manually
Just install the npm types?
How do you make a mob spawn at a mineshaft, with spawn weight?
I need a drop down menu template with players
#1067869659757543555 not scripting related
getPlayers() and Array#map them
const player =....;
cons modal = new ModalFormData();
//etc
const players = player.dimension.getPlayers();
const playerNames = players.map((p) => p.name);
modal.dropdown(...., playerNames);
cons
I will not edit it 
fire bro
It is because I want it done using script, it's not possible through normal spawn rules. I've tried
Did you tried using features?
Is there a way to rotate or change the position of particles without having to write a function for each direction?
Can it make a mob spawn where a mineshaft is or a least at blocks or on blocks from there(BTW I have tried using "minecraft:spawns_on_block_filter": [], it doesn't work)
I've also made a post of what other ways a mob can spawn from script. That i don't know how to achieve
https://discord.com/channels/523663022053392405/1338641882913312859
You cant
Just modifying the mineshaft feature
How? Btw are anything in my post possible?
Besides the mineshaft one
You already have the json spawn rules
No
Can't you detect a block in the world and do a random chance, to spawn a entity on that location?
You need to check million of blocks per tick
Or around the player, like how spawn rules work
You can check but just checking 10 blocks at a time already does TPS drop, so it's worth it
Alright, thats sucks
How do I do that though?
I didn't see a feature file for mineshaft
closeAllForms is beta?
sounds right, it's still recent so
I think it's not.
I maybe wrong
Since iirc I tried closeAllForms in 1.3.0
-# but I have shit memory sooo.
beforeEvents.playerLeave -> Get player inventory and equippable -> iterate through each and get all -> filter and map them after
past step 1 i dont have a clue
filter and map afterwards so that you don't risk losing the player instance because if you take too long in the event the player becomes invalid
at least from what I was told
getComponents for inventory and equippable?
never used em
oh my god
ive never had a need lmao
that is seriously impressive considering you own like a very sizable server
this isnt even for me
const inventory = player.getComponent(`inventory`).container
const equippable = player.getComponent(`eqippable`)
const eqippableItems = ["Head","Chest","Legs","Feet","Offhand"]
const items = Array.from({length:inventory.size},((_, i) => inventory.getItem(i)))
equippableItems.forEach((item)=> items.push(equippable.getEquipment(item)))
maybe
idk since mapping and foreach off the top of my head without autocomplete is rough but
i understand it all but can u explain array.from?
it creates an array based on a property, like what I do with the length
it defines an array of a fixed initial size
so the size of the inventory then
and then the second argument is a .map operator, where i take each slot's index and get the corresponding item to it from the player's inventory
gotcha thanks:) understand it now
but 1 more quesiton
how exactly do i drop the item?
for (const item of items) {
player.dimension.spawnItem(item, player.location)
}
you may want to save player location and dimension so you can access it after the player becomes invalid
bet
finally a person who gives me an explanation on what things do and doesnt link me a microsfot link that doesnt have what i ask for 🙏
aka smokey cough cough
different people learn in different ways, smokey might learn best from source documentation so he refers others to it
nothing wrong with that
reading docs are so tough...
Reading docs are tough until they click with you, once you get the moment where it clicks you're basically set
bro seomtimes thyey be yappin tho
ill be reading abut pancakes next minute im talking about nuclear codes
On my way to delete the Bedrock wiki.
thanks!
Can someone explain why the if statement in the switch case statement is being ignored
whoa now let's talk about this
It will activate place weather im shifting or not
uhh
I mean...obviously people don't like reading so...
yeah i dont CUZ THEY DONT MAKE SENSE HAFL THE TIME
add a default case that logs that logs cardinal direction
I dont know dude, they make sense to me
A guide on how to read and interpret documentation would unironically be a good developer resource
funny
do i use runinterval for this orrr
I literally put an if(e.player.isSneaking){ return; } that works in front of that mf and it still happened
show me whatcha got
you arent even showing the full code
might help, but i gotta read that so no ty 🤣
you spelled equippable wrong
also the last 3 if else statements will always place the beam down sharing the cardinal permutation of the beam it was placed on
read the code before using it
i did
lol
😭 discord code without typescript completions is hard okay
lmao no worries
I gotta go sleep now though, it's like 11 for me
also pretty sure i gotta do world.dimension.spawnItem right
getDimension() and no
use player's dimension property.
i said it wrong
world.getDimension but generally saving player.dimension is better
so i gotta save player.dimension.location?
Also don’t forget to delay the spawn item, as it’s still in a before event (and definitely counts as modifying the world- aka privilege error)
so runinterval for that right
system.run
run
Or system.run
that's what I forgot
o
System timeout or system run
i thought it was too easy
Not interval, unless you want to spawn in the items every few ticks
oh hell no
that would be funny.
basically just wrap the who for-of loop in a system.run()
still got it
no shit sherlock im tryna figure it out
before you get any items create a constant for the player's dimension
world.beforeEvents.playerLeave.subscribe(data => {
const player = data.player;
const location = player.location;
if (getScore(player, `${config.combatScoreboardObjective}`) >= 1) {
//Gets the items from the players inventory
const inventory = player.getComponent(`inventory`).container
const equippable = player.getComponent(`equippable`)
const equippableItems = ["Head", "Chest", "Legs", "Feet", "Offhand"]
//Adds the items to an array
const items = Array.from({ length: inventory.size }, ((_, i) => inventory.getItem(i)))
equippableItems.forEach((item) => items.push(equippable.getEquipment(item)))
//Spawns the items on the location where the player left
system.run(() => {
for (const item of items) {
player.dimension.spawnItem(item, location)
}
})
//Tells the world that this player has left while in combat
world.sendMessage(`§f${player.name} §dhas left while §cin combat! §7[§b${(getScore(player, `${config.combatScoreboardObjective}`) / 20).toFixed(2)}§3s§7]`)
player.runCommand(`say test`)
}
})
Anything that modifies the world has to be set out of the before events read-only mode
player.runCommand is not wrapped.
world.beforeEvents.playerLeave.subscribe(data => {
const player = data.player;
const {location, dimension} = player;
if (getScore(player, `${config.combatScoreboardObjective}`) >= 1) {
//Gets the items from the players inventory
const inventory = player.getComponent(`inventory`).container
const equippable = player.getComponent(`equippable`)
const equippableItems = ["Head", "Chest", "Legs", "Feet", "Offhand"]
//Adds the items to an array
const items = Array.from({ length: inventory.size }, ((_, i) => inventory.getItem(i)))
equippableItems.forEach((item) => items.push(equippable.getEquipment(item)))
//Spawns the items on the location where the player left
system.run(() => {
for (const item of items) {
dimension.spawnItem(item, location)
}
})
//Tells the world that this player has left while in combat
world.sendMessage(`§f${player.name} §dhas left while §cin combat! §7[§b${(getScore(player, `${config.combatScoreboardObjective}`) / 20).toFixed(2)}§3s§7]`)
}
})
i just deleted that too i saw that
world.beforeEvents.playerLeave.subscribe(({ player }) => {
const inventory = player.getComponent('inventory').container;
const equippable = player.getComponent('equippable');
const equippableItems = ["Head", "Chest", "Legs", "Feet", "Offhand"];
const items = [
...Array.from({ length: inventory.size }, (_, i) => inventory.getItem(i)),
...equippableItems.map(item => equippable.getEquipment(item))
];
system.run(() => {
items.forEach(item => {
if (item) player.dimension.spawnItem(item, player.location);
});
});
});```
Somewhat like this?
ohhh i get it
-# oof I'm late to conversation lmfao
yeah basically, though I would do a .filter on the items before it
-# good, you can replace me, I dont want to be here
That only dropped the item, not clear their inventory ;D
it works but got this error
FUC- you man.
good point
-# nope, you do this to me, now its your turn, enjoy.
You can do it using playerSpawn.
Ye ik
pretty sure i already got that system setup
store player.id somewhere ig
so im thinking this error only happens the the item dropping is nothing right?
ah because undefined isn't an instance of itemStack
I WAS RIGHT
this is what I was talking about when I mentioned filtering it after
LOOK AT ME GO
im still lost
.filter
yeah but idek what that does
world.beforeEvents.playerLeave.subscribe(data => {
const player = data.player;
const {location, dimension} = player;
if (getScore(player, `${config.combatScoreboardObjective}`) >= 1) {
//Gets the items from the players inventory
const inventory = player.getComponent(`inventory`).container
const equippable = player.getComponent(`equippable`)
const equippableItems = ["Head", "Chest", "Legs", "Feet", "Offhand"]
//Adds the items to an array
const items = Array.from({ length: inventory.size }, ((_, i) => inventory.getItem(i)))
equippableItems.forEach((item) => items.push(equippable.getEquipment(item)))
//Spawns the items on the location where the player left
system.run(() => {
for (const item of items.filter((itemStack)=>{itemStack !== undefined})) {
dimension.spawnItem(item, location)
}
})
//Tells the world that this player has left while in combat
world.sendMessage(`§f${player.name} §dhas left while §cin combat! §7[§b${(getScore(player, `${config.combatScoreboardObjective}`) / 20).toFixed(2)}§3s§7]`)
}
})
copy array but without the falsy value or specific condition
it removes entries from an array that don't match a given condition, like num > 10 would remove anything less then 10 from an array
const words = ['spray', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter((word) => word.length > 6);
console.log(result);
// Expected output: Array ["exuberant", "destruction", "present"]
gotcha
A bit of googling goes a long way 🙂
smells like GPT to me (it's okay GPT is good at explaining native method functionality)
Heck, even AI could help with that, it’s a given js method
Nah
The Og
Ahh, laggy asf.
oh yeah forgot ai exists
My goofy ahh will suggest to use dynamic property
great, hes going to use ai now
being able to write dynamicProperty inside beforeEvent is so convenient
onStepOn: (({ block, entity, dimension }) => {
const { x, y, z } = block.location;
block.above().setPermutation(BlockPermutation.resolve(block.typeId, { "chiko:trap_top": true }));
block.above().setType("chiko:trap");
})
How do I set the state to true?
Probably still necessary, to log the player leaving before they leave
Yes, spreading unreliable information is my speciality
system.run(() => {
for (const item of items.filter((itemStack) => { itemStack !== undefined })) {
dimension.spawnItem(item, location)
}
})
``` this isnt spawning the items when adding the filter and i dont have a scooby doo why
no logs either
wada faq
why....this works 😭
that should work, but I would do this instead:
const above = block.above()
above.setPermutation(above.permutation.withState("chiko:trap_top", true))
i already have clear on join system
That's not my "problem" I just didn't expect it will work.
oh wait
did ai make it
-# I mean the script I just recently sent
lmfao
Depends 🤷
take that as a yes
Since when world dynamicProperty can use Array?
Yessir.
someone help i beg i just wanna sleep tonight
But not chatgpt, I used deepseek
do you use ai often
try doing a log
of what tho?
just this time
how do you feel
console.error(item.typeId)
not happy
good
I feel disappointed
in yourself or the ai
my self :(
not good but good, this is a learning moment
I feel happi, kept using AI pls
wait, I'm lagging I need to restart discord.
i get no logs inside the for
🦭
no
world.beforeEvents.playerLeave.subscribe(data => {
const player = data.player;
const { location, dimension } = player;
if (getScore(player, `${config.combatScoreboardObjective}`) >= 1) {
//Gets the items from the players inventory
const inventory = player.getComponent(`inventory`).container
const equippable = player.getComponent(`equippable`)
const equippableItems = ["Head", "Chest", "Legs", "Feet", "Offhand"]
//Adds the items to an array
const items = Array.from({ length: inventory.size }, ((_, i) => inventory.getItem(i)))
equippableItems.forEach((item) => items.push(equippable.getEquipment(item)))
//Spawns the items on the location where the player left
system.run(() => {
for (const item of items.filter((itemStack) => { itemStack !== undefined })) {
dimension.spawnItem(item, location)
}
})
//Tells the world that this player has left while in combat
world.sendMessage(`§f${player.name} §dhas left while §cin combat! §7[§b${(getScore(player, `${config.combatScoreboardObjective}`) / 20).toFixed(2)}§3s§7]`)
}
})
//Removes items when player joins
world.afterEvents.playerSpawn.subscribe((data) => {
const player = data.player;
if (player.hasTag(`${config.combatTag}`)) {
player.runCommand(`clear @s`)
player.runCommand(`scoreboard players set @s ${config.combatScoreboardObjective} 0`)
world.sendMessage(`§f${player.name} §chas logged back in after combat logging, items cleared.`)
}
})
``` this what i got
You got a post? Let's not flood the general thread xd
exactly
ehhh doesnt matter
I was gonna say
shit, I broke my breeding system
dont all humans come with that
breeding system?
I'm detecting breeding lol
I'm refurbishing my stats addon.
I'll actually try to release my stats addon and chess addon in public
only in GitHub tho..
Yeah, why should someone do that? That's morally wrong.
-# I love that idea, noted
yeah it no give error im not sleeping tn
lmao
ioma go ask ai
expected
🤢
-# why it looks goofy
-# its you
-# nah it's you.
-# yeah its me
-# its both of us
yippie!
woo hoo!!!
Too real
I'm detecting two brain cells having a conversation
theres no braincells
i equate to 0.5 of the,m
huh? Braincells?
what's that?
man, c'mon.... I broke my script then I broke my plugin?.
Imma kill myself now.
Shit just derailed so much, general script api had become offtopic#2
dont
👀
yo
I can't take it anymore man, every beginner uses ai now... When you tell them not to , they'll keep using cause it's handy....
you use your own intelligence
be proud of that
Yes, stand proud, you're smart
I suffer 5 years from this thing and ai will just replace my brain?
damn, that sucks
Imma just cook
Script API - 15%
Channel with motivational speeches - 85%
lmfao
what events are on Beta API 1.21.51?
do you need a doc link sir
I'm already dead inside :(
more reading
but in all seriousness, I'm kinda sad that people prefer to learn in ai than read.
faster]
get with the times old timer!
yeah well, nothing you can do about it.
back in my day 👴
people dont like learning, they just want to quickest way to do stuff, its not about the experience.
Create a time machine
There's a fun way, there's a quick way. My opinion on learning and AI probably.
i will learn it if it wasnt 4 20 am and i want to sleep
I just learn about labeled break from AI lol. So it do have some merits
I rather fail at something than use ai
i used ai then read the code 💪
ive never even used ai until 10 minutes ago
but will be using it more now
ngl, one of my friends thought I'm using ai since when I give a snippet it looks like ai lmfao
I dunno if I should be happy or not.
alright mr smarty pants
sad to see you go
Be happi. Ur replacing AI
eh i make minecraft realms its not that deep
just be
on my yt, we taking this deal or nah ik its very off topic but i need an answer
you good?
u didnt answer the question
no
no
Even if i hate do put EVERYTHING in one file, i needed to and its kind of still small
Hello Guys
how do i lock an item in slot using scripts
function applyJumpingEffects(entity, vector, gravity) {
const initialJumpPower = Math.max(0.0001, gravity.value / 200);
const steps = Math.max(30, Math.ceil(70 - gravity.value * 3)); //smooth ascent
// knockback steps
(function applyKnockbackStep(step) {
if (step < steps) {
const progress = step / (steps - 1); // Normalize the step
const power = initialJumpPower * Math.pow(1 - progress, 5); // Quintic power for verrryyyyyyy gradual reduction
entity.applyKnockback(vector.x, vector.z, vector.hzPower, power);
// Schedule the next step
system.runTimeout(() => applyKnockbackStep(step + 1), 2); // Call next step after 1 tick
}
})(0); // Start with step 0
}//KILL ME ;-;
Help
ItemStack.lockMode = 'slot'; //can be 'inventory' too
Line 247
player.teleport(player.location.x, player.location.y - 0.2, player.location.z)
player.teleport({
x: player.location.x,
y: player.location.y - 0.2,
z: player.location.z
})
Ty
any help with this?
How to make my entity ignore enemy's armor resistance when attacking?
make ur entity does a 1 heart of damage, and via scripts ( entityHitEntity component ) u can apply damage to the hit entity, afaik applying damage will ignore armor ( correct me if im wrong )
But it will make my entity hit two times in a row which will probably be not the best experience for the player
I attempted to use async functions for the heaviest parts of my code, but it didn't seem to have any effect. Did they render them basically useless?
I was detecting it by getting the system time before and after and getting the difference. Only an async function call is in between, so it should have been 0 or 1, but it was some larger number instead.
try making it deals no damage, like by giving it weakness 255 effect, just try to make the entity hit the player without damaging it
so u will apply the damage instantly via scripts
it's not possible to deal no damage
idk.
Yep.
well, not for me
i can make the entity follow the player but doesn't deal any damage, just like how the creeper works
so umm, cna you make the player don't deal damage to a mob without effects purely scripts without modifying player.json?
and make it damage the player via scripts ( getting the targeted player around the entity )
that's the point right now, pure scripts no editing the entity.json
he wants to make his entity damage the player, but without the armor resistance
the damage will ignore the player armor
he has a custom mob, he can make it follow the target just like the creeper and deal no damage, and via scripts u can detect the targeted entity around his custom mob and apply damage to it once every second, and u can apply the attack animation to the entity if needed
I ain't stupid.
no need to explain it to me.
-# actually I am but not that stupid.
the explaining will help him out making it works.
so satisfying
Yo, does anyone know how'd one apply knockback/impluse on the entity he hits?
Specifically like, a knockback neo
I know, entityHitEntity and etc, i am asking about the math involved
Like, just getting the knockback direction?
hi redtnt
i asked to Chatgtp how to add fuel to a steam locomotive, it showed me this script but is not working, ¿someone knows if this has a mistake?
itemUseOnEntity ain't an event
what should i write instead of it?
The AI is the mistake
Actually it is pretty good for an AI
The code is almost correct in everything
what is the mistake?
What Herobrine said
Use the playerInteractWithEntity event if you are using beta-api
If not, just add the minecraft:interact component to your entity and make it run the scriptevent command
How do I get the percentage symbol to show on my modal ui? Ingame the symbol doesn't appear
Double percentage symbol
wait till you have to do a triple percentage symbol
Then you realize that making the % show up on the items display name by doing that will also make it not show up in script forms
So then you use 4 % symbols
Why doesn't the particle appear when I use the item? I'm having extreme difficulty making it appear
This seems more of a #1067869590400544869 or #1067869136606220288 , not Scripting.
ok
Sorry for not replying earlier, i meant like what should i pass to the .applyImpluse/.applyKnockback to add like some extra force to the knockback
Have you ever heard of a knockback neo?
Ye i meant like that
Never heard of it
Oh I see
I kinda wanna do exactly what it does but just as like, like the knockback, i dont want the item checking or anything, just the math to apply correct impluse and knockback depending on both the attacker and target
For players its applyKnockback, and you have to pass the x and z direction, then the horizontal force and the vertical force
I have used it before
But what about .applyImpluse
I need to do the same for entities
Not supported for players
I know
I said
Entities also support applyKnockback
Yes, but wouldn't it better to use .applyImpluse
I don't see why
Yeah good point
no, why?
thnx
why when i try to detect the new pig/cow/chicken variants ( console.warn(variant) ) it returns undefined?
How are you defining variant?
const variant = eEntity?.getComponent('minecraft:variant');
it works for other entities, like villager or the new wolf variants but it doesn't work on pig/cow/chicken mobs
There doesn't seem to be custom components for each variant in the vanilla behavior pack
Is that already out?
idk, send me if u have it
i need the new BP of those mobs along with the new texture paths and models
I just downloaded the 1.21.60 behavior pack and there is nothing about that
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
what are the types for beta stable
The second one
mc updated
its 1.21.60 now
i dont think types are released just yet
Yeah, they aren't
where did you check
I just checked the official behavior
Idk about preview
the repo won't include it, sense it is behind experimental
all experimental have there own pack
send me the link of that BP along with the RP
i need them.
I literally just sent it
@untold magnet the experimental stuff is not there
here is the files
Yeah I recommend downloading the one Minato sent
so how am i going to detect them?
sorry, no time to check the files
"description": {
"identifier": "minecraft:pig",
"spawn_category": "creature",
"is_spawnable": true,
"is_summonable": true,
"properties": {
"minecraft:climate_variant": {
"type": "enum",
"values": [ "temperate", "warm", "cold" ],
"default": "temperate",
"client_sync": true
}
}
},```
should i just do getComponent('minecraft:climate_variant') something?
entity.getProperty("minecraft:climate_variant")
interesting
const newVariants = eEntity?.getProperty('minecraft:climate_variant');
if (newVariants?.value === 'temperate') { ,,, }
or
if (newVariants = 'temperate') { ,,, }```?
== or ===
= is for assigning values
alright.
and no .value
ik, so thats what mojang will use for the new mob variants, like all of them should use the same method right?
🤷♂️
( i mean the new pigs / cows / chickens / upcoming sheeps / upcoming goats )
mojang is known for there consistency
yes it works for all of them, the new variants is using that new method
- tell me if it is possible to detect if the goat have horns or not,
if it is hardcoded or too complicated, screw it
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
should be a variant no?
it is hardcoded
the only thing related to them are variables
variable.goat_has_left_horn
variable.goat_has_right_horn
maybe use those
What is the module for 1.21.60?
not released yet
the question is, how am i going to detect those
use animations
in behaviour pack
how long will it take to release?
animation control
aka edit the entity file
and that is not allowed in mp
screw it, twice
well
how about the new texture path of the new variants?
can playanimation play bp animations?
is it like so:
entity/pig > temperate pig
entity/pig_cold > cold pig
entity/pig_warm > warm pig
i dont even want to know
Installation for @minecraft/server-ui
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
is there any way to get the new models of these mobs now?
Can someone please help me in https://discord.com/channels/523663022053392405/1338664427301634108
anyone have the change log so i can fix these
variant.value
?
i heard that there is gamemode 6. is it possible to do that using scripting?
also, off-topic
Use 1.18.0-beta not 1.17.0
1.17.0 ain't the same as 1.17.0-beta
This has been the case for like, every version that's released for scripts so far
v1 final moments
It is.
im assuming its cuz player isnt identified
If you are getting an error, probably
ok thats it then thanks
yall know how i can the get location of a dead entity which has js died?
this is in an after death
event
it works with the player but if any other entity dies it is fully removed so idk from all dimensions
beforeEvents.entityRemove probably
oo thanks il see if it works
is that new cuz i dont remember it
nope. It's not new, you probably never heard this that's why
How to update pack on a realm without removing/resetting dynamic properties?
it doesnt seem to work
Dynamic properties should be saved to the world not the addon
but somebody said if i reset the packs uuid to update it itll reset
change the pack version
so i can change the uuid?
that is true
im confused
no, the version
im confused to now
why are you changing the uuid
i want to update the pack
so can multiple addons use the same dynamic properties? and it wont overlay
just change pack version like minato said, not the uuid.
world.beforeEvents.entityRemove.subscribe(({ removedEntity}) => {
console.error(removedEntity.dimension.id);
});```
no
do i need to make it development
no, but recommended for development
i keep getting error message
removedEntity
shii
I always forget that lol
yeah
it's removedEntity not entity mb
ty yall tht part is working now
but i got a another problem
heres the line in that
i edited the version by 1 and changed the name but when i turn it pack into a normal pack i only see the older version of it
use the development folder and make sure the pack is not cached in the world
code
what do you mean cached in the world also its a realm
just do removedEntity.dimension.spawnItem()
item is defined upper up
so if you apply a behavior pack in the world, it create a copy of that behavior pack in the world's folder
if this dont work i got a backup idea
Thank god I didn't release my addon yet since I remembered they changed the 'fluidContainer' component to 'fluid_container'
Is BDS 1.21.60 out yet?
yes.
Is it possible to make a particle that can see from far away and see through walls?
particles can already be seen from far away
and through block? is it possible?
it can be anything as long as it works
ask in #1067869590400544869
Using entities -> #1067869590400544869
Anybody know if it's possible to zero out an entitys y velocity while retaining it's x and z?
Basically stop if from going up or down, but keep it moving forward?
not sure if it's gonna work but
const velocity = entity.getVelocity();
entity.applyImpulse({ x: velocity.x, y: 0, z: velocity.z });```
How do I send the name of the pack an item belongs to?
*send a message to the player who held the item
One message removed from a suspended account.
Wdym ,can U send a screenshot of the issue Ur get?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Uhmm
Is there anyway to control the life time of a particle?
You modified the position of button?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
you made it as a stack panel?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
ok so I don't think that's a script issue side, that's more like in json ui side since it shouldn't happen if you already hid it.
One message removed from a suspended account.
Oh so the costab one?
One message removed from a suspended account.
So yeah the button will be still clickable even if it doesn't exist in the form anymore since you hardcoded define their position
One message removed from a suspended account.
like I made 3 buttons in the ui, and I added 2 buttons in script side, thee last button isn't functional at all
tho it still exists
Also let's move to #1067869374410657962
Elaborate? You could try using anything that supports raw message to translate pack.name.
tho, the best thing you could do is make a binding visibility that hides it automatically once the button text is blank
yes! that's what i'm trying to do
but in this case, the pack.name I need can be any, I have no way of predicting
I don't believe it's possible then. Best you can do is just get their namespace. What are you trying to create?
is a block inspector
Best you can do is just display the namespace.
you can format the typeId of the block to make it look like the vanilla display name
I wouldn't say that, it's an item
huh, interesting
you click and it shows entity/block information
best description
since it's intended for vanilla items, you can do the following to get a DisplayName-ish text
const displayName = block.typeId.split(":")?.pop()?.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(' ');
One message removed from a suspended account.
translations exist.
and using an item's id as display name is not even reliable,
oh I didn't even think of translations for it with lang files
that's so much smarter
fixing some things.
const displayName = block.typeId.split(":")[1].split("_").replace(/(\b[a-z](?!\s))/g, x => x.toUpperCase());
why the ??
it's a part of prototypes that I was making and I considered the possibility that someone might be stupid and try to pass an invalid namespace or manually do it
I don't even know if this is possible
anyway, thanks for the help
yeah, hopefully you at least got some idea of where to go with it from it
also unrelated but how does one just memorize regex patterns to use 😭
Regex 101 😛
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
I already told you the solution
as I said that's not a script side problem
that's json ui
One message removed from a suspended account.
i want to make a homing projectile that follows the target in a straight direction,because i want to make that the projectile doesn't move like a Shulker Bullet
It is possible to add a decimal number to a variable
Let's say for example
let timer = 0.5
timer += 0.5
timer == 1
One message removed from a suspended account.
One message removed from a suspended account.
What? No, this logically should be fine. @celest abyss The concern should more be about floating point precision loss.
They edited it 😭
Ah OK lol
I bet it was some 0.5 += 0.5 before
Jarvis, pull up those logs
I had no ideas for the variable name
For floating point arithmetic math, try this floating point approximate-equals function:
//https://stackoverflow.com/a/32334103
function f_approxEquals(a, b) {
if(a == b) return true;
let diff = Math.abs(a - b);
let norm = Math.min(Math.abs(a) + Math.abs(b), Number.MAX_VALUE);
return diff < Math.max(norm * Number.EPSILON);
}
const threeTenths = 0.1 + 0.1 + 0.1;
console.log(threeTenths == 0.3); // false
console.log(f_approxEquals(threeTenths, 0.3)); // true
One message removed from a suspended account.
@dense wraith I'm assuming this shows you only the cosmetics you have acquired, instead of all cosmetics. I would personally construct an array of selectable cosmetics that have indices consistent with the form, then index into that with the form response's selection property.
const Selectable = headcosmetics.filter((option) => player.hasTag(option.name));
for(const option of Selectable) {
costab1.button(option.name, option.texture);
}
costab1.show().then(function onCosmeticSelection(response) {
if (response.selection == undefined) throw "nothing selected case";
const selection = Selectable[response.selection];
selection.whateverElse();
});
Granted, if you have a lot of cosmetics then copying a filtered headcosmetics into an array could be memory-intensive and expensive
Might be able to optimize that with a lookup on all tags at once, by inserting player.getTags() into a Set and running has() on that Set
CAN SOMEONE TELL ME
WHY MOJANG IS NOT ADDING EntityHurtBeforeEvent in SCRIPT API
mojang even going to release script api 2.0.0..... but still not adding EntityHurtBeforeEvent 😭
Another idea is to map button indices to headcosmetics indices:
const PlayerTags = new Set(player.getTags());
const ButtonCosmeticMap = new Map();
let buttonIndex = 0;
for (let cosmeticIndex = 0; cosmeticIndex < headcosmetics.length; ++cosmeticIndex) {
if (PlayerTags.has(option.name)) {
costab1.button(option.name, option.texture);
ButtonCosmeticMap.set(buttonIndex++, cosmeticIndex);
}
}
costab1.show().then(function onCosmeticSelection(response) {
if (response.selection == undefined) throw "nothing selected case";
const selection = headcosmetics[ButtonCosmeticMap.get(response.selection)];
selection.whateverElse();
});
In either case, it's worth trying to do the lookup on some form of headcosmetics rather than try to carry the object over, because this allows your code to be more modular.
Huh, I actually like the button mapping idea, I'd personally roll with that
-# me who just reads this because I'm fascinated with the idea lol
It's an interesting problem, had me thinking more than I expected at first
sprunkles are you an ai
does not compute, does not compute, system shut down
ok bye im going for school
Asking is all you can do really. If you're actively demanding something, chances might even be lower that it gets added. You're not just asking for a feature, you are actively telling someone how they have to do their job, by requiring them to shift around their workplan and roadmap and work on this feature just for you.
And no one wants to be told how they should do their job
He just can't find another way to create what he needs.
EntityHurtBeforeEvent? we have that at home.
||entity.json 🥲||
no editing.json
Hmm yes today I will make custom enchants 
How many times did you try to make one
can I install addons in preview version
I am losing my sanity trying to emulate linux ubuntu-20.04
On my arm64 mobile device
I should probably just go get a proper host to test my server-net scripts...
I still wanna host the test server locally :(
Plz moyang release an arm64 version of the bds software
Imagine not have the 100k msg🤫🧏♂️
Guys who can help me tsc convert
ChestUI.setUIPage('home', new Page({
11: new Button('<', 'arrow', {
onClick: ({ player }) => {
let idx = ChestUI.getData(player).idx as number
if (idx > 0) idx--
ChestUI.setData(player, { idx })
}
}),
15: new Button('>', 'arrow', {
onClick: ({ player }) => {
let idx = ChestUI.getData(player).idx as number
if (idx < 2) idx++
ChestUI.setData(player, { idx })
}
})
}, {
start: (({ player }) => {
ChestUI.setData(player, { idx: 0 })
}),
update: ({ player, container_e }) => {
const idx = ChestUI.getData(player).idx as number
let item: ItemStack
switch (idx) {
case 0:
item = ChestUI.newUIItem(`Hello world`, 'command_block')
break
case 1:
const time = new Date();
time.setHours(time.getHours() + 8);
const formattedTime = time.toISOString().slice(11, 19);
item = ChestUI.newUIItem(formattedTime, 'clock')
break
case 2:
const count = world.getAllPlayers().length
item = ChestUI.newUIItem(`${count}/30`, 'oak_sign')
break
}
container_e.setItem(13, item) // setPageItem would be better
},
tickInterval: 1
}))
what's the difference between player.setDynamicProperty() and player.setProperty()
it seems like they do share the same purposes
but different function name
idk which is the optimal one though
native type conversion failed
setProperty is for entity properties while dynamicProperty is used in script only.
imagine it as a storage and it won't disappear unless you delete them.
variant
will it disappear if a player dies? (for setProperty())
Not sure.
alright thanks
no
.setProperty(): Set Entity property. Entity property is usually used in JSON logic with certain Molang query functions. Value change is delayed by a tick. Cannot be used in beforeEvent. The property is readable by all scripts from another pack.
.setDynamicProperty() Unique storage bound to the entity and the addon's script. (Other scripts from another pack can't read them... iirc). Immediately changes. Can be used in beforeEvent. Only readable through script.
Nah i had it twice and was there to witness it 12+ times
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
oh my
@dense wraith I'd integrate it like this:
(I realized I forgot to define the option variable the first time, whoops)
but meh its not that necessary
One message removed from a suspended account.
¿there's a mistake here?
content log?
But were u the 100k msg?
Yup
Well not the actual 100k message, cuz that was probably wayy too long ago, but discord keeps trippin' and it shows that we still haven't passed 100k every now and then
dammn you chatGTP
I almost broke my back today
How to remove footstep sound and particle if you have a certain score?
Is there a datapack that has all of the vanilla entity behavior and loot tables?
Datapack?
Downloadable from: https://github.com/Mojang/bedrock-samples/releases
bedrock.dev archive: https://bedrock.dev/packs
GitHub (RP & BP) : https://github.com/bedrock-dot-dev/packs
Example particles: https://aka.ms/MCParticlesPack
Java Edition's Vanilla Packs: https://mcasset.cloud/
Hey! Anyone know how i whould use my plot system to make an invite for my plot system
const form = new ActionFormData().title("Title");
form.body("Select a Player");
for (const player of world.getAllPlayers()) {
form.button(player.name);
};
form.show(target).then(responses => {
const selectedPlayer = world.getAllPlayers()[responses.selection];
selectedPlayer.addTag("tag");
});
};```
My plot system uses scores "locationID=1" Than your plot is 1 And
"locationID1=1" than that's your friend slot.
?
can i make specific item fire/lava protected?
wrong channel my bad but thanks for the link
function hasBlock(players, anomaly) {
const head = players.getHeadLocation();
const distance = Math.sqrt((head.x - anomaly.location.x)**2 + (head.y - (anomaly.location.y + anomaly.getHeadLocation().y)/2)**2 + (head.z - anomaly.location.z)**2);
let block = players.dimension.getBlockFromRay(head, players.getViewDirection(), {
maxDistance: distance+(anomaly.getHeadLocation().y - anomaly.location.y)/2
});
if (block == undefined) return false;
return true;
}
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
for (let entityHit of player.getEntitiesFromViewDirection({
ignoreBlockCollision: true,
type: "space:anomaly"
})) {
if (hasBlock(player, entityHit)) {
world.getDimension("overworld").runCommandAsync("event entity @e[type=space:anomaly] despawn");
}
}
}
}, 5);
[Scripting][error]-TypeError: cannot read property 'x' of undefined at hasBlock (anomaly.js:100)
at <anonymous> (anomaly.js:115)
How to fix this?
ok
because it can't get the entity head location
Are you sure you're looking at an entity?
Yes this detects if there is an entity behind the block that's in front of player's eye
function hasBlock(players, anomaly) {
const head = players.getHeadLocation();
const distance = Math.sqrt((head.x - anomaly.location.x)**2 + (head.y - (anomaly.location.y + anomaly.getHeadLocation().y)/2)**2 + (head.z - anomaly.location.z)**2);
let block = players.dimension.getBlockFromRay(head, players.getViewDirection(), {
maxDistance: distance+(anomaly.getHeadLocation().y - anomaly.location.y)/2
});
if (block == undefined) return false;
return true;
}
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
for (let entityHit of player.getEntitiesFromViewDirection({
ignoreBlockCollision: true,
type: "space:anomaly"
})) {
if (hasBlock(player, entityHit)) {
world.getDimension("overworld").runCommandAsync("event entity @e[type=space:anomaly] despawn");
}
}
}
}, 5);
[Scripting][error]-TypeError: cannot read property 'x' of undefined at hasBlock (anomaly.js:100)
at <anonymous> (anomaly.js:115)
Does any one know how to fix this?
Is it possible to offload a scripting process to the client, for example instead of the server checking for every block that's broken by every player every tick, can the players client not detect it and send the information to the server, doesn't have to be realtime. I'm just trying to think of efficient ways to get the data I want
Nope
Scripting if chatSend before was finally stable
facts
Review what the method getEntitiesFromViewDirection returns: https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entity#getentitiesfromviewdirection
(EntityRaycastHit array, which could also be an empty array)
If the entity was found, it returns an object with an entity property
In the function hasBlock, your distance variable is redundant, since the anomaly parameter also already has a distance property you can use (albeit, from the entity's bounds, not its location). If you wanted to calculate the distance by hand, you need anomaly.entity.location
hi there, is it possible to get via API the target a mob is targeting?
How to place a block at certain coordinates
Yes but it’s in beta so it will require experiments.
what are the packets used for crashing?
i wanna make an anti-crasher
i know that some crashers use /me spam
how to do it?
that will work to an extent
a lot of the crashers have advanced a lot
they have external methods where it sends nothing through packets
they don't join or anything
eh, what should i do to set the font back to normal?
https://cdn.discordapp.com/attachments/1253486152611004427/1339642701926105183/image0.png?ex=67af76fd&is=67ae257d&hm=ca695141884559f83bfd34c81b43168c153019ea1a6d17d049e4cc8e75b913c4&
Hello how do I send a message to a player saying "You have successfully spawned!" when the player joins the world
code
.body(`Welcome, §a${player?.nameTag}§r!\n\nThank you for downloading §lMore Heads & Plushies§r!\nWe hope you have a great time collecting and decorating with all the new mob heads and plushies.\n\nThis addon introduces heads for almost all vanilla mobs, giving you tons of options to customize your world.\nHowever, some mobs like -§aSlimes§r and §cMagma Cubes§r- don’t have anything\nbecause they are either bugged or not possible to add due to §lMinecraft Bedrock limitations§r.\n`)```
is it bec of the ( don't " ' " ) thing?
Yes
'
Use ' directly
.body(`Welcome, §a${player?.nameTag}§r!\n\nThank you for downloading §lMore Heads & Plushies§r!\nWe hope you have a great time collecting and decorating with all the new mob heads and plushies.\n\nThis addon introduces heads for almost all vanilla mobs, giving you tons of options to customize your world.\nHowever, some mobs like -§aSlimes§r and §cMagma Cubes§r- don't have anything\nbecause they are either bugged or not possible to add due to §lMinecraft Bedrock limitations§r.\n`)```
u used some special one
like?
" ' "
or
' \' '
’ compared to '
Try it and see I guess
The majority you can rate-limit and that will solve the problem.
okay but what packets usually cause issues
That can vary depending on how desperate they are. The two common ones are most certainly CommandRequest and LegacyTelemetryEvent packets. There are others too. If you know of a server or personally experience it on your own server, you can just monitor and log the traffic to see what packets are causing problems or raising flags prior to a crash.
when i try to add another .body , it will select the new body and remove the previous one
like
.body('1')
.button('hi')
.body('2')
it will just show '2' above the button
Welp
you can only have one body in the form and the body will be always on top of the form.
if you want to have two body effects, use one body effect and in json ui divide them and place where the second body will be.
Guys, my scripts stopped working on the new version. What do I need to do to make them work?
i will not touch any Ui
i know form ui is allowed to be edited in the marketplace but not freely ig
Change manifest version
Game tells you versions when you join a world
then be creative lol
entity.target
meh, spending more time on this simple addon is not a thing :v
Is it already version 3?
The script dependency version
Well, I have 1.17.0 beta
Okay
or if you want to continue using beta, just use 1.18.0-beta
Or use 1.18.0 beta, ye
Thanks for the help
How to delete a dynamic property ?
Set it to undefined
did the getScore method change in the recent update?
Updated my add-on for the first time in 8 months only for it to not be playable because my getScore function no longer works 💀
oh it didn't, I'm just bad 😔
Can I make death messages use the nameTag instead of the actual name? I'm making a nicking (.nick) system
Turn off death messages and create your own
I can... turn them off?
(You will have to make every single death message, and if an addon edited it, you won't have the "edited" death messages from lang)
Yeah
oh
Again, very very, important.
How can I detect when the time is set to a specific value?
Like 27000
Or something like that
https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server.World-2.html#gettimeofday
You mean this?
does equippable component works with entities now?
whats the other work around to replace entity's equipment with itemStack?
none. Only replaceitem command.
ig so, I wanted to make my block change if it's night time or not
I have no idea how to do it
hello here. I just want to ask how you handle button texture in a form if u are mapping inventory items. For example you want to map players inventory and u want to show it as a button. You want it to show a texture the same as the item. How can i do this?
aux id. Just like Herobrine's Chest UI
tho you should remember that aux id shift if there's custom items.
👋
Fun little stress test of some scripting basics. What's a good server time to aim for?
thank you perd hahaha
Filipino ggi
how do i remove the equipment lore
cant
breh
it goes away when you're not in search inventory tab I think
i see
don't put it in any category
But you make it not gettable in creative inventory
got it
I'm looking for a random button system in a form
const menu = new ActionFormData();
menu.title(`Test`);
menu.body(` Test`);
menu.button(target.name, target.id)
Let's say target should be a random player
I mean that among all the players who have a Tag, a randomness system is created and a button is created
put all available players in an array. Then math.random()
wait, is it only one random player??
Yes
const players = world.getAllPlayers();
if (players.length > 0) {
const random = players[Math.floor(Math.random() * players.length)];
const form = new ActionFormData()
.title('Test')
.body('Test')
.button(random.name);
}```
Ty
just talked to an ai for 2 hours to help me fix my code and it finally worked 😭
White scripts is so annoying. Even when the script doesn't work
What is a white script?
after 4 hours of asking AI i now have my lore buying enchants and xp updating 😭 🙏
looks pretty good
sup guys, why is this thing:
let rCode = new ModalFormData();
rCode.title(`title`);
rCode.textField(`Hi - under processing`, `testing`);
rCode.show(player).then(({formValues}) => {
if (formValues[0] === 'codetest') { *** }```have a log showing up when i close the form-ui without writing anything?
log:
Yeh cuz formValues is undefined when you just close the form meaning you can't read [0] from it
so how can i fix it?
either do if (canceled) return or if (formValues && formValues[0] === '')
or just if (!formValues) return; right?
Either of them works. Just choose
I recommend do it with canceled
no saved in the lore
it cycles through each line of the lroe until it matches with lets say level, then uses regex to return the level, xp and xpmax
used AI cuz i had no clue how to do it, now i can do it without ai :)
Dynamic properties are a lot easier to store data in and have a much higher limit than lore does
ik but inconvienient for updating a pack to add on a realm
i dont feel like going through the 10 step process

i disagree
20 lines, 50 characters
didnt ask for ur opinion but ok
It will happen to you
i dont need 20 lines tho
Dynamic properties are also very fast compared to lore
i have 10 enchants
parsing a single string (saved as json) vs parsing with regex
trust me, I have done both systems. Lore works, sure, but it's so much easier with DPs
doesnt matter still does it quick enough
yeah but im not doing that dumb 10 step process everytime i wanna update the pack on the realm
making a parser for each line will be more terrible..
this how mine works
just use dynamic properties 😭
not good for realms as i said before, so no
Consider it something to potentially change in the future. Just be careful of racking up technical debt
If people wanna suffer let them suffer.
const level = item.getDynamicProperty('level') ?? 0
Very easy to use, the design is very human
but when i wanna change the pack on the realm i have to go thru the process of defusing a bomb bru
It's saved on the item
so if i change the uuids?
it will still be on the item
Have you tried just updating the pack's version?
Idk if you necessarily need to go through all those steps, if just the version is updated.
i tried that it didnt say there was a new pack when i went in my realm to add it
wdym? each item stack has its own pointer
like if i change the uuids in the pack, will the item still have the dynamicproperties?
or will it reset
like player and world
it will keep them
try it yourself 💯
...
I suppose you could download the world off the Realm, apply your pack changes (including the version in world_*_packs), then reupload it, but that becomes infeasible after the world reaches a certain size
sooooo why did i not know this 😭
bro u shouldve seen the amount of debuggin i had that ai do 😭
chat length
That level of proompting is crazy
I like this whole try-catch lol
cuz ive never used lore before an everytime i ask here i get redirected to documentation that takes 10 yers to read
lmao
the ai was struggling with getting the mainhand item
it kept getting hotbar slot
well duh
or would make it mainhand instead of Mainhand
why would it know anything about that
it did
it knew about it on my enchants one
righttt
but for the pickaxeXP it didnt
What's the point of documentation if nobody is willing to read it
its worded how by friend koyh would read it, basically abunch of yap until it finally gets to the point
On my way to delete the wiki.
lmao
It could be this way. I have actually not read whatever it is you're referencing haha
Whenever I write documentation I "yap," but that's to explain what it is doing
oh it is, some things are easy like lets say the unicode but other things... god help me
by yap i mean useless information
like sometimes it will be on the right track then start talking about something thats completely different
anyway i dont wanna get offtopic
Is it some "recipe website where I tell my funny anecdote" level of yap
but if i use item.getDynamicProperties how would i display it on the lore, wouldnt i need to use lore anyway for that?
Yeah sorry, lol
not ur fault dw im the one yappin
Yep. But at least the source of truth is in the property, not the lore. The former is easier to parse and is more reliable(?) to store
Display it with lore— but you don’t have to parse the data from the lore at all, so how it’s formatted isn’t critical.
it won't be a wiki if all it provided it straight up templates
i see
so basically just run a function that updates the lore whenever i call it then
Lore has always been meant for displaying stuff; it was never meant to store data
imagine if there was a lore database
If only lore was translateable.
Just the fact that you can store an object of data on an item dynamic property should be enough to not use lore for data storage
what smokey actually wants is custom item descriptions
translatable lore is just crazy people talk
Let me put four lines of flavor text on my items for lore reasons, dammit
So...lore.
move it to ore ui and let me play Doom there

