#Script API General
1 messages Β· Page 119 of 1
yeah it hasn't happened for me or the few playtesters I've had. An unintentional but welcome side effect.
im talking about the setCurrentValue method for it in scripts
but it should be the same
ah, yeah I've never messed with movement in script, so I wouldn't know
sounds like another thing that'll be in the back of the fridge, but I'll be optimistic
im guessing that it doesnt do that when you edit it directly in the player.json?
nope, never had any problems with speed in .json
my only issue is that it's, well, incompatible
yeah
i wonder how long its been since the movement component class was added in the script api
was added in 1.12.0
that's admittedly later than I expected, but still early enough that I'm surprised they didn't work on this yet
then again, we still can't do things like teleport players with velocity or set rotation
yeah we can
we can now?
I recently heard someone complaining that they couldn't, but I might be misremembering
you cant use the setRotation method on players
maybe you got confused? or hell maybe im misremembering
ah, yeah that's what I figured.
just another thing to hope they fix
What's wrong?
their custom blocks are not getting detected by getBlockFromRay
thats not good for this
Sounds like he is just doing something wrong
that sounds egregriously complicated
Its not
If you don't want to use movement component, at least use applyImpluse instead of this
And I understand that it's bad for performance but its just a matter of what is more worth it to you
Hence offering it as an option
Better than applyKnockback
What makes applyImpulse better than Knockback anyways
applyImpulse is smother
For context: I'm using this movement for a boss rush map
Did I write that correctly?..
for stuff like this #add-ons message
I know
Which is why I said anyways
smoother
Wrong @
wasnt talking to you
I meant myself
So using things like impulse and knockback seems like too many variables to account for when the goal is to have the players input control where they're moving
oh oops, my chat wasn't scrolling
small intervals of speed boosts vs just the speed being consistent
i wouldnt touch impulse/knockback stuff
yeah, same idea. the map is a high paced fighting game, so janky movement is really going to make it unfun, especially on the higher difficulties which were designed with movement in mind.
If you need applyImpulse, go for it in single applications. Things like flinging a player one way one time (which applyKnockback will do just fine with too)
I'm guessing I'll stick with player.json for now, I'll probably have a dev mode to mess around with the script movement component on the side to see if I'll fully commit to it.
in this context, would it be good for changing movement speed overall? i wouldnt think so
like, I think it would be glitchy
No; if you need the player to move slower, modify the movement component either in the player behavior or in scripting. It's got some quirks of its own, but it puts full interpretation of the movement on the client
thats what I suggested
however
.
Yup, not great
Some attribute components need a "modifier" or "multiplier" property
I have wanted to write a small attribute system that abstracts over stuff like the movement component. Like the attribute system Java Edition has
I already did
:p
It just passes through some of my blocks
really stupid stuff
Show js code and code of the blocks
And does the result change if u use vanilla blocks?
yes, it works fine for vanilla blocks
.
nothing in them are particularly different to the usual way of doing it, just used dimension get block from ray
It should work with custom blocks, there is probably something wrong with the code
it works fine to some of my custom blocks
not entirely
so that's the functions problem or something
Show the block codes
I don't understand how that's relevant, does the block json affect the function?
Yes
Since the function takes into account blocks collision box
I guess that makes much more sense but basically, it's thin like a vine block
I'm not on my PC rn
Well.. it still should work..
Or maybe not
Yeah, the block still takes in 16x16 but just thin
which doesn't make sense of the function not working
Minecraft has troubles with thin blocks
Rays perform a check every n step, if your block is really thin the ray may skip it in some cases
It also skip blocks if the ray is towards the edge
Bruh
kinda related, but have you had any success with the entity ray cast method
ive never got that to work properly
It works fine for me, what is the problem you are having with it
They could make it more optimized and accurate
i dont remember
How so?
so im just asking if anyone else had an issue with it, and if not, maybe I did something wrong I guess
My current project uses it, so yeah, it works
I tried shooting the ray at the block's center, no luck there either
Oh shoot, come to think of it, basically like a vine, nothing
but I need it to be player passable
yeah sure
you don't need to worry about that
btw is it possible to have optional dependencies now or no?
i haven't been keeping up with script api much tbh
by this, i mean having dependencies like @minecraft/server-net in your dependencies array in manifest.json
that won't stop the scripts from working
sorry if i didn't word it correctly
english is not my native language π
Importing the script without the dependency throws an error; you could catch and swallow that error.
yea i know
it's just
the game disables your script altogether
before that part
if one of the dependencies aren't available
Does it do this if you use a dynamic import? With import("@minecraft/server-ui")
not exactly
because it's available in all environments
unlike @server-net
it's not even there unless it's in the bds environment
though i could be wrong and it does the same behaviour for it too
Ah, server-net. I should have read a little more closely
i heard they were working on optional dependencies a while ago
no worries
though i haven't exactly been keeping up
if anyone knows an answer to my question:
i would absolutely appreciate it
does any one has an creative fly function? I tried to recreate the creative fly so I can use it in survival mode but I failed, (I dont want use /ability)
Can i make a npc dislogue entirely with script
What is the script syntax to opendialogue
what is command macro, any example?
Is there a native way to call a function from a script or only run command
did what
World.beforeEvents.chatSend is not a valid event anymore
I verified syntax with an old pack they changed domething
I cant get it to work at all i went threw all avail options bridge has but nothing is available idk how to find whatever the change is
Oh shit chat send is in beta thats why
Does anyone have a link to something that talks about where the new file locations are after the update?
Wow chat send has been in beta for years why just why
Im really annoyed at the 3 errors im getting that are minecrafts problem 3 duplicated vanilla recipes my pack has nothing to do with
#announcements message
does anyone know why system.run does absolutely nothing for required permissions?
like what
wrapping it in system.run does nothing
maybe if you put it in worldLoad event
it is π
i had to do something like this
Because you aren't using it, lol
no
U are using getDimension without system.run
yes i know
wrapping it in something does nothing either way
Wrap the function call in system.run and it should work
doesnt
Show code
i already got it working its fine
How then?
this
since the dimension is used in mapForm
i have to do allat
Weird way...
literally unusable docs
Oh wait. that's actually how hunger and exhaustion are defined
why
Use enumerations to bypass it
do bossbars dont change dynamically? i tried to set nametag intervally but seems like it doest change at all
theres no way im gonna use hud title text for it once again ππ
Does not change :/
πππ
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]
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]
If a block JSON object contains minecraft:tick but uses the custom component onRandomTick, is the component considered or completely ignored?
All blocks randomly tick even if you aren't hooked into the onRandomTick event using custom components
The queued ticking applied to a block with the tick component requires the game to store an additional tick delay value for each block that has the tick component
if you aren't using onTick you shouldn't have the tick component since it's adding additional unnecessary data to the world
queued ticking (minecraft:tick & onTick) is completely separate to random ticking
In other words, it doesn't affect onRandomTick at all, it just makes the internal save code unnecessarily heavier?
yes, onRandomTick is purely controlled by randomtickspeed, onTick is controlled by minecraft:tick
Okay, thank you for the information. I was unsure because it was used in the leaves of the add-on I'm working on, and I'm updating them. I wanted to know if I can remove it or not.
But according to the information I can remove this without any problem, I think it's just a missing component because before the leaves used onTick and it was changed to onRandomTick.
leaves shouldn't use queued ticking, I assume it was implemented incorrectly originally
Yes, because he wasn't affected by the random tick world option like vanilla leaves.
With onRandomTick, it is affected.
Is there a way to detect if a block that has been jumped on got broken by a subscribed event?
huh?
wdym "by a subscribed event"?
a event
there are a lot of events
If you mean all events, then definitely not
darn
Iβm having problems related to modal forms. Apparently it canβt define the default value of my dropdown correctly
.dropdown("Β§rLock Mode", lockModes, { defaultValueIndex: ruleLockValue })
K, Iβll try out
It worked, ty
add a dynamicProperty to player to that specific block that was "jumped on" then if it on break event, trigger your logic when player dynamic property is set
Is OnBreak a custom component or a normal component
they probably mean the playerBreakBlock event
thats a event they prob want to define a custom component to a block
if so yes its not a normal component you have to make one in scripts
yes
so update on this
i found the mob and changed it's component
but i need it to be dynamic
how exactly do i integrate it with player.setPropertyOverride
by this, i mean i don't want it to just target players with tag, i want it to target everyone without a said tag/property
now as far as this goes
i don't think it exactly is server side
i haven't used it tho tbh
so idk what I'm doing
i kinda need some more guidance
also don't mind my very late replies and such, I'm just a bit busy irl
yea i don't think it's possible to select what players not to target based on a changing property
there isn't a single filter that does that
they all require a static value
how to add names or nametags in entity spawn?
sry im rly bad at scripting, does anyone know how can I make a script so my projectile can break all the glass blocks when thrown ? (when it hits that glass block)
probably use projectileHitBlock after event
spawn the entity with something like:
const entity = dimension.spawnEntity(...);
and set the nameTag by doing:
entity.nameTag = "Β§aLime, slime? crime!";
btw just ended up using has_tag filter and settled on making the tag for targets, not teammates
if you mean detecting when an entity spawn, just use entitySpawn afterEvent
Documentation for @minecraft/server
bonus: you can modify entity names (the default ones) in RP/texts/<language>.lang if you want that too
and do the last thing he suggested
dw i don't mind it, the name.
using βheβ is better tho
huh
oh I changed "some dude" to "he" because i thought it would make more sense because im responding to your message, which shows your name.
no like
uh
how do i explain
like
i can't explain π
but i do hope somehow you understand what i mean π
that wasnt a problem lol
but now I know what you meant
Hey peeps
can somebody give me hint why I get "not a function" for Dimension.getWeather(); ? I saw something about beta so I did enabled Beta APIs and Im on "min_engine_version": [1, 21, 120] which looked also correct 
it may be a preview feature?
and how would I activate that? π
A preview feature means it's on Minecraft preview... (Some kind of Snapshot for early-access update)
its a different version
go on minecraft launcher and select latest preview
I got that but I dont believe I have launcher, Im on MS store version
Is Dimension the class? Or the instance?
maybe try: world.getDimension("overworld").getWeather()
I did simplified it, I do use basicaly what you wrote
it might be in beta
yeah its on preview
Well, weatherChange afterEvents doesn't seem to be on beta~
-# Try using the event listener instead XD
afaik its in beta
π it sais beta ... Im confused
thats beta in preview docs
yea but its also available in stable mc in beta modules
just sayin
To use the Beta API, you also need to define the API's version dependency on the manifest JSON.
Hey, guys... does the legendary EntityHurt before Events fires regardless of whether the entity has iframe when being attacked?
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]
latest version its 2.4.0-beta
i dont think so, hurt doesnt mean hit
Thanks so much, it stopped complaining π ... now I can go back to figuring out if my idea works π
Welp, I guess I could manage that... entity hit listener already exists... so just add that to the spaghetti.
im investing in this
This bot was created by SmokeyStack for the purpose of making a FAQ bot for the Bedrock Add-Ons Discord Server.
To manage entries, please make a pull request on GitHub.
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]
lol
Its a class
thats not what they are asking
they are asking if they are importing Dimension and trying to execute the method off of that, or getting the dimension properly from an event,
because obviously the first thing wont work.
Oh i see, my mistake i didnt fully see the replied message
i think the question was not worded the best anyway
Well to be fair at times it can be a race to say what you want while you can as to not get ignored in this chat
huh
Nothing lol just at times this channel gets chaotic
I wrote it at 2 AM (midnight)βοΈπ€
Anyone got tips for dealing with dyslexia
Not here
Good eveningg, would anyone happen to know why this script no longer works? The version is 1.21.124, and it does not seem to run :(
The functions exist, the sword has the trigger component
{
const array = [
"sword_check",
"shield_bash_snow",
"empty_check1",
"empty_check2",
"empty_check3",
"empty_check4",
"empty_check5",
"sword_check1",
"sword_check2",
"sword_check3",
"slash_retreat",
"spell_check_1",
"spell_check_2"
];
world.beforeEvents.worldInitialize.subscribe(({ itemComponentRegistry }) => {
itemComponentRegistry.registerCustomComponent("hoarforst_antumbra:trigger", {
onHitEntity(event) {
const player = event.attackingEntity;
player.runCommand(`function ${array[Math.floor(Math.random() * array.length)]}`);
}
});
});
}
world.beforeEvents.worldInitialize -> system.beforeEvents.startup
Documentation for @minecraft/server
That did not work
If it threw any warnings or errors you should share that.
How hard is it to make my swords run a function on hit π
The first one (which worked previous versions) ran no warnings, but it wasn't working either
10 lines of code
:3
Is it possible to prevent withers from breaking blocks? not the explosions but when they move and stuff
I'm sticking to components
When you say previous version, which version specifically? Because your original code tried to implement the logic using an outdated method that was changed quite some time ago when they released the 2.0 version of the API.
A detailed video about the infrastructural changes in how Script API v2.0.0 beta works -- it's not that different from v1.0.0, but we'll cover the subtleties in this video. Warning: there isn't really any discussion about newer APIs in this video, so not a lot of new fireworks on display :)
Scripting API 2.0.0 Documentation: (docs coming soon,...
That video explains the changes in the order of operations.
Going on a year now. They didn't change much externally back then. It was mostly on how everything executed under the hood and in what order. We just had to adapt our current code at that time to follow suit with that new order. For the majority it was a seamless change with very little issues. For others, it was a learning curve.
Ohk
1.21.113
The addon worked fine on that version
Not sure how it could have? worldInitialize wasn't supported in that version, whether using Beta or Stable.
It had already been replaced by that point.
tbh i don't know at all how to make a script
π
ik ik π
its okay
one sec
@small river
import { world } from "@minecraft/server";
world.afterEvents.projectileHitBlock.subscribe((ev) => {
if (ev.projectile.typeId !== "minecraft:snowball") return;
const block = ev.getBlockHit()?.block;
if (!block) return;
if (block.typeId.includes("glass")) {
block.setType("minecraft:air");
}
});
just a guess, correct me if im wrong
damn ty so much i'll try it
bro thank you it works @mystic harness
nice
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]
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]
πΏ
still works for you?
because its shows no item texture for me
after the .130 update
Thatβs crazy
Well, you can try to fix it yourself, or wait until I get home from work
idk how to fix this tbh
ill wait you
No guarantees that I know either
hope the best

function summonCharrette(targetNation: Nation): Entity | undefined {
const location = getEnemySpawnLocation(targetNation);
if (!location) return undefined;
try {
// @ts-ignore
return location.dimension.spawnEntity("cb:charrette", location);
} catch (e) {
console.warn("Erreur spawn charrette: " + e);
return undefined;
}
}
hi, someone knows how to bypass or an alternative solution to that
There is a mistmatch, why is your content saying cb:flag but your code says cb:charrette
yes, normal I have two almost identical functions for each entity
function summonFlag(targetNation: Nation): Entity | undefined {
const location = getEnemySpawnLocation(targetNation);
if (!location) return undefined;
try {
// @ts-ignore
return location.dimension.spawnEntity("cb:flag", location);
} catch (e) {
console.warn("Erreur spawn drapeau: " + e);
return undefined;
}
}
Ok so...is cb:flag a valid entity?
is a custom entity
And you can summon it
yes
oh no indeed not flag I hadnβt paid attention
{
"format_version": "1.16.100",
"minecraft:entity": {
"description": {
"identifier": "lu:flag",
"is_spawnable": true,
"is_summonable": true,
"is_experimental": false
},
"components": {
"minecraft:scale": {
"value": 1.5
},
"minecraft:physics": {
"has_gravity": true,
"has_collision": true
},
"minecraft:pushable": {
"is_pushable": false
},
"minecraft:push_through": {
"value": 1
},
"minecraft:fire_immune": true,
"minecraft:damage_sensor": {
"triggers": {
"cause": "all",
"deals_damage": false,
"damage_modifier": 0
}
},
"minecraft:knockback_resistance": {
"value": 1
},
"minecraft:nameable": {
"always_show": true,
"allow_name_tag_renaming": true
}
}
}
}
cb:flag isn't summonable but it's summonable in json file ?
I mean, that clearly says lu:flag not cb:flag
oh shit indeed sorry I am an idiot
What's the up-to-date version of minecraft/server? Is it 2.3.0 or 2.4.0?
2.4.0 as of today's release, 1.21.130
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]
Starting to think I trust the docs more than the botβ¦
(permalink: https://jaylydev.github.io/scriptapi-docs/latest/modules/_minecraft_server.html#installation)
2.5.0-beta
and for stable?
2.4.0
If I wanna spawn alot of XP at one location, do I just do this:
for(let i = 0; i < 64; i++) {
dimension.spawnEntity("minecraft:xp_orb", {
x: x + ((Math.random() - 0.5) * 5),
y: y + ((Math.random() - 0.5) * 5),
z: z + ((Math.random() - 0.5) * 5)
});
}```
?
have you find a fix?
I never got an answer to this how many custum items do you think minecraft can handle
I feel like i need to find an alternative to thd parts i want to add
The parts alone adds 209 items not counting ore an bars tools weapons and many more
How to detect right-clicks when player is empty-handed?
Use interact with block event check mainhand snd offhand to be empty
If you want @runic crypt i have a file that can help you thats actually is pretty easy to do
I want to detect a right-click without interacting with any block π
Maybe item use idk but i think if you use nothing it comes back undefined you can test that its undefined ima test
Nvm i dont think theres an even reading judt a right click im looking at how the gsme does a right click snd it does nothing on its own
I think i can detect a left click with no item tho lol
Ya i can detect a left click and i know i can detect sneaking just no right click
@runic crypt there is no way to detect a right click thats in the air
You can detect every other thing they can target but they need to be targetting something
yea block entity or item in hand
Keep in mind even if the block or entity has no interaction aspect it still triggers event
Its weird as i can detect every other thing crouch left click ect just not right click
whats new in 2.5.0-beta
I need advice
So i have 11 parts of 19 tiers plus each tier has its own set of ores bars armor tools weapons im wondering is there a better way so im not making hundreds of custum items
check changelog
Could anyone help me with the camera thingy? Is it possible to rotate the camera with in_out_cubic animation whilst facing a location?
Minecraft's?
cus im not used to check mc changelog in terms of server module change nad now server module is missing 2.5.0 changelog
dang
maybe there some update in json ui ig that makes unable to use aux item id
Is it possible to hide form
I want to hide a server form Evey 1s if player don't click anything
I think you're forced to use a command to accomplish it
May be easier to create a new entity whose sole purpose is to die and drop EXP. You could pass in the value to drop as a property, then read that property in the entity's "minecraft:experience_reward" component
how do i know which biome im in
2.4.0 has Dimension.getBiome(location: Vector3)
it returns BiomeType, which has id property
wait
when did getBiome
get into stable
im not seeing it
Respect that
I need advice
So i have 11 parts of 19 tiers plus each tier has its own set of ores bars armor tools weapons im wondering is there a better way so im not making hundreds of custum items
depends on how the functionality of these items should differ
Well parts are just crafting components made from a parts crafter
I mean im half tempted to just create my own inventory using properties
I mean i already made 1 parts crafter be able to act as 19 different parts crafters threw an upgrade system
system.beforeEvents.startup.subscribe(init => {
init.blockComponentRegistry.registerCustomComponent('sample:my_custom_block_component', {
onEntity: (e: BlockComponentEntityEvent) => {
if (e.name !== "sample:my_entity_named_event") return;
const block = e.block;
const source = e.entitySource;
...
},
});
});```block entities?
No.
damn it
just suffering in silksong
I wouldnt mind tool softwares that charge a 1 time fee of $50 for high end recorders and such but i do mind monthly subscription softwares its do annoying beyond belief why are all new softwares even when it doesnt req a server suddenly monthly subscriptions
Can anyone teach me how you add a sound file and call the sound file in screipt
still no fix for this?
i guess it's working
Can anyone teach me how you add a sound file and call the sound file in screipt
Am I dumb or is there no stopSound() method?
there is but it's on beta
odd, i know
I don't even know if I wanna facepalm or laugh
And more funily enough stopSound was added in a bit ago recent update
you can put sounds in the sounds/my_new_sounds folder for example
and define them using sound_definitions.json.
Then you can play the sounds using /playsound or using playSound method in scripts as of the name you defined in your sound definitions.
look at the wiki for complete information:
https://wiki.bedrock.dev/concepts/sounds
Ohh thats super easy
Minecraft accepts a .wav file for dound correct
Btw dont ever let ai try to read 1 of your poems to you it did horrible
are custom crossbows only works in script API?
what?
the provided vanilla bp official pack repo does not contain crossbow.json nor the bow.json similarly how they removed blocks.json files. the shooter component in the bp items/item.json doesnt specify the properties of a crossbow, all options are only similar to bows such as charge on draw, launch powerscale, etc.
I recently saw in the script resources of someone making a crossbow template as someone provided it to me, but they only used script API on the crossbow loading system.
Why is the watchdogTerminate code broken in version 1.21.30?
Code:
system.beforeEvents.watchdogTerminate.subscribe((event) => {
event.cancel = true;
console.warn(
`[Watchdog] Cancelled critical exception of type '${event.cancelationReason}'`
);
});
mojang doesn't provide any source code for their vanilla items and it is normal to not see crossbow.json there. If you want to make a crossbow, You can just look at this template: https://discord.com/channels/523663022053392405/1429411289402441798
I don't know what problem you're having about it using Script API for loading system.. The template i sent is not outdated.
are u using beta-APIs?
if not, that's the reason
"2.4.0"
watchdogTerminate is in beta, you can't use it in stable versions
Okay, I'll fix it.
why do u need the event tho?
Idk, I saw some addon was broken so I had to fix it
How do you make an entity follow the player after interacting with it?
Like a pet
welcome
Is there any way to spawn an item with enchantments and durability with dimension.spawnItem()?
You can modify the itemStack before spawning the item and it will have all of the enchantments/durability you set
So i put:
const i = new ItemStack(βidβ,1);
i ..
(Changes I need..)
dimension.spawnItem(i)```
??
yes
const newItem = new ItemStack('minecraft:diamond_sword', 1);
newItem.getComponent("minecraft:enchantable").addEnchantment(new EnchantmentType({type: 'unbreaking', level: 3}));
Dimension.spawnItem(newItem, player.location)```
Ok, ty
Fixed the Aux IDs not displaying and updated the Type IDs. I've somewhat rewritten it in typescript so some of the code will be different. Also I removed the Furnace Form (if you used it).
https://github.com/Sprixvy/Chest-Form
hey, did you know how one can efficiently store an entity in a dynamicProperties ?
You can't store/get all it data, use structure api
Do you have a script to view all AUX ID?
i don't have a script to view them i just have a python script that fetches all aux ids from some guys api and then creates a ts file for it
he seems to always keep it up to date so why not use it
Could you send an API? I was looking for this for a bit longer
Hey @valid ice how do you generate this: https://github.com/Herobrine643928/Chest-UI/blob/main/BP/scripts/extensions/typeIds.js
Wondering if there is a way to automate this, as your really slow to update it
yea i need this too
would be fantastic to have
you can get it from https://github.com/Mojang/bedrock-samples/blob/main/metadata/vanilladata_modules/mojang-items.json
yo fr
thank you
so yeah, something was wrong in json ui about aux id
adding inventory checks next π
ignore the names π€£ was just adding custom nametag visibilty, enchant support and clickable inventory slots
i made this a while ago but lost it to the unknown π
Then you would just check the type by doing res.type ('container' or 'inventory') ```ts
const res = await form.show(player);
if (res.canceled) return;
if (res.type === 'container') {
console.warn(container, ${res.slotIndex});
return;
}```
oh weird... why was this needed?
it seems you need a - ']' now compared to the last update?
did mc add something?
it's just some goofy bypass for it lmao
how did you figure this out?
what changed
honestly.. my friend figured it out for his server then gave it to me lol
he knows a bit more json ui than me
this is important, can you mention him here?
he said he doesn't even know either π that's just what he does and it works
theres no way you would randomly do that
we need to figure out who did this
@naive tinsel
sup
how did you figure this out #1067535608660107284 message
i had it in my ui already and mine was working after the update
well that one thing is the reason it works
you can do percentage multiplication on the string or minus some random character and it fixes it
yeah i know
so minecraft must have changed something?
ig so
@spring axle any idea what changed in JSON-UI to cause this? (#1067535608660107284 message) Basically, now you need to subtract something for a string to convert to a number?
We updated some text formatting stuff recently, so maybe that?
is there docs anywhere for what was changed?
as this might break a ton of my UI's
this was the change that was in the changelog
('%.10s' * #title_text)
(#title_text - ']')
either of these methods work, you have to manipulate the string in some way and it fixes, idk why lol
oh shoot, @deep arrow
There was also this Added resolve_ancestor_scope boolean to view bindings as a way to bind to an ancestor that matches the source_control_name but it's not much use to me. Also maybe move this to #1067870274894172260 lol
Could someone help me understand why this doesn't work? (Console.warn isnt being ran)
const boots = new ItemStack("minecraft:leather_boots", 1);
const dyeComp = boots.getComponent(ItemComponentTypes.Dyeable);
if (dyeComp) {
console.warn("1");
dyeComp.color = {blue: 255, red: 255, green: 255};
}
Shouldn't leather boots have that component though?
it is called that
ok tyty
you said that you using typescript, can you also provide the typescript code in the github cause i also use typescript
Yeah, I'll do that shortly
Hey so i was told theres a way to make npc's move with script how is this done
does anyone know where the downloaded multiplayer textures go in the new GDK update?
the file location i mean

if You mean packcache its somewhere in %temp%/Minecraft Bedrock
thanks!
Hey so i was told theres a way to make npc's move with script how is this done
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]
Will this Works?
AE.entitySpawn.subscribe(({cause,entity})=>{let EFamily=entity?.getComponent(EntityComponentTypes.TypeFamily);
if(EFamily?.hasTypeFamily("monster")){
if(entity.dimension.id=="minecraft:overworld"){ImplantEffect(entity,EffectPools,0);}
else if(entity.dimension.id=="minecraft:nether"){ImplantEffect(entity,EffectPools,1);}
else if(entity.dimension.id=="minecraft:the_end"){ImplantEffect(entity,EffectPools,2);}
};
});
i mean the "entity.dimension.id=="
yep, should work
well, imma test this
also it's always better using else for performance right?
now it's my 1st year learning Js
π£οΈ π₯ π₯
don't focus on this optimalizations they are meanless, focus more on structures of your code for example, avoid heavy loops in loops and more thats where performance hit the most
sure enough, i'd love if my code can use UpperCase
const N = ["overworld","nether","the_end"].findIndex(dim=> dim==entity.dimension.id.substring(10));
ImplantEffect(entity,EffectPools,N);
const N = {o:0,n:1,t:2}[entity.dimension.id[10]];
ImplantEffect(entity,EffectPools,N);
mind me not, it'll only get confusing
wait
i forgot about the implant function
function ImplantEffect(A,B,C){A.runCommand(`Effect @s ${B[(Math.floor((Math.floor())*B.length))]} Infinite ${C} True`)};
const EffectPools = [`Speed`,`Strength`,`Resistance`,`Slowness`,`Weakness`];
bro even stated to minifying the code, afaik using id as whole is the fastest as you don't create any strings at runtime
what am i looking at
const dId = {"minecraft:overworld":0,"minecraft:nether":1,"minecraft:the_end":2}[entity.dimension.id];
ImplantEffect(entity,EffectPools,dId);
not sure why using id as number tho if you already have string
i guess i'll test it out
why are you using a command to use the effect
how to put infinite with api
i can use addEffect, but i wanted the Infinite
if it doesn't work, i'll write it down here
good
how does -1 behave on it
it throws invalid
looks like it doesn't detect entity.dimension.id
can i use array for this?
const NetherFamily = ["Piglin","Wither_Skeleton"]
entity?.getComponent(EntityComponentTypes.TypeFamily)?.hasTypeFamily([NetherFamily])
use getTypeFamilies
and use the includes function
the "hasTypeFamily" to "getTypeFamilies"?
sounds similiar like "getGameMode"
its just a different method.
sure, i'll try it
dont use includes only actually, it doesnt support an array as an argument
use some or every, and within the method, use includes.
will forEach works?
this is gonna help a lot
and I know its showing them using a string rather than array, but it'll still work.
very Understandable π£οΈ π₯
i'll try it next day after wake up
better
Crazy specific tutorial
But fair
Don't doubt that
Find me a tutorial for getting a substring and inserting it in the middle of an existing array
Lmao
No way for something as random as that
well I couldnt find a specific one for that, but there's stack overflow questions for inserting elements in the center of arrays
and just use indexOf for the element to insert
hm
The hard part about finding something like that, is the "and" part, you can easily find a tutorial for either separately
Oh nothing, i didnt actually "need" a tutorial for it. It was more of a question of if one such tutorial existed
lmao
I know how to do what i asked anyways
Also, really?
Pretty useful in alot of cases, well formatting cases ig
yeah, I just dont see a need for it for what ive been doing.
:(
typescript really does seem nice
Its great
Once i switched from js, to ts i can never go back
You should frfr
I just dont need it
You may not need it but you should want it
everything in js, and what im doing right now, is not that infuriating for me to switch
like, im comfortable
Thats fair
I just cant live without the ease of ts anymore
So i must spread the gospel of typescript
well atleast you arent spreading it with a superiority complex
Like the type safety is so great, being able to see errors before runtime.
Don't get me wrong, I completely believe its better than js in every way. But i respect everyone's choice to do as they please
If others dont like it, they dont like it. Simple as that
other people are not as cool as that
respect
one thing I need to do is move off Bridge, like really
If typescript is complex , then try c++
Also like the auto completes and intellisence is big w too
this software is getting slow
π
Bridge is crazy work
No one said complex
im lazy to switch man
yeah difficulty isnt the issue, I would adapt quickly
my first software for developing addons, its hard to let go
No its not π₯
hey man, what about happened to respecting other people's choices
loll
Respect has nothing to do with that lmao
nah but I know im only limiting myself by just using this software
Very true.
ive known this for awhile now
same logic when it comes to this too though
@honest spear you said something?
message was instantly deleted lol
I guess i don't like that tutorial i guess, but if you don't care about performance then good enought Β―_(γ)_/Β―
then which would be a more performant method?
For some reason i don't like ppl who uses anything else than substring on strings π
Guys we cant be friends now
in this specific case just check for both it might be the best solution, once you get bigger arrays then use sets to checks the availability
OK, let me ask mods to ban you lol
:0
hm
okay
substring is goated
the right way to do stuff and the fastest
Β―_(γ)_/Β―
also Uint8Array.subarray is the same thing
with only 2 elements, yeah.
yea and if you have more then use sets not arrays
π
do you have a link to compare the performance
O(1) vs O(n) multitples by counter part
just sayin
Script api engine is really specific tho
but still works well
anyway my solution would propably be entity.match(selectorWithFamilies)
like a page that just goes into detail about arrays vs sets
idk, i didn't write such a page
but maybe someone did
so check if google has something
there has to be an example one Sets vs Arrays
Also Sets in newer ES versions has methods like symetricDifference() thats perfect for large operations
I know there is.
ok
but since you had a problem with that one article above, maybe you had a page that you specifically like when it comes to sets and arrays
idk
Well i have the problem with the code in the article to be precise, i never used something in this sence that means it could be written better
maybe some really annoying edge case
only thing i miss sometimes is map and filter being one method
never used Uint8Array lmao
or the other similar classes
i prefer the seperation
but technically u can filter with map, just make it undefined
arr.map(x => x > 5 ? x : undefined)
Hello, quick question, u can't put dynamic property to stackable items, aren't ya?
Did they add something new , idk like new events ?
yes
What is it ?
entityHurt beforeEvent, entityHeal after/BeforeEvent
entityItemPickup after/beforeEvent
Hmmm , looks good
world seed property
Ohhh entityItemPickup, haven't seen that one
yeah its in newest preview
Hmmm , is anything new related to blocks ?
well there's the connection stuff, but if you mean completely new, there's a new event for block custom component
onEntity
triggers when an entity reachs the block if its defined as a home block
script api is evolving so fast
no
Huh
well, there's cooldown related stuff
json components
we can thank darknavi, and the rest of the mojangsters for that
Yeah i guess i know them
I would argue slowly but yeah, things take time
just things that you could alredy do with scripts
2 years ago addons were absolutely garbage
2 years is fast?
1 month is fast , two i don't guess so
considering its a "side quest" not the main game
U know in 2 years how Minecraft java modding com get evolved
mods are community based that's a totaly different thing
they still have to do a LOT of stuff about ui-scripting connection
another 2 years for that
i'd say more seeing ore ui isnt even customisable yet
that would still create same array of n elements
I guess they gonna change it with the new one ui
I heard they are doing something to the furnace ui
yeah .filter is better
all the ui
getting a new style
no both methods does different thing you always have to use both if you want to map it and filter some and thats why is annoying
Isn't that going to interfere with the json uis ?
you can use reduce π§
Like they will remove them ?
yes it will basically use ore ui for everything'
So using html right?
its based on react right
I heard it s based on html or something
Interactable inventory and potion support in the custom Chest Form π₯³ π
Hey, sorry.. I completely forgot about this last night. I've pushed the typescript repo under a new branch:
This is modified so go careful, I've changed the way the buttons work so you might need to adjust some code.
Buttons now look like this: ts form.button(12, 'Grass Block', 'minecraft:grass_block', { amount: 1 }); form.button(14, 'Diamond Sword', 'minecraft:diamond_sword', { description: ['Β§7Sharpness V', '', 'Test (1)', 'Test (2)'], durability: 50, enchanted: true, });
They have an options object for the other parameters. You'll see that in the index.ts file
Hey so i was told theres a way to make npc's move with script how is this done
The most you can do through a script is to teleport an entity or give it an impulse/knockback in a certain direction
I wish someone would teach me how to make a custum entity the learn dics did not help me
there is a wiki
maybe this?
https://youtu.be/gKtvlLr7SR8?si=bUrFQ8qrvRcSxVTf
In this session, Mike Ammerlaan covers the basics of the systems of entities and how they work, describe a couple of example usages, and then use mctools.dev and Blockbench to build a first entity.
Samples:
You can see samples (including a Camp Ghost) for Creator Camp at https://github.com/microsoft/minecraft-samples/tree/main/creator_camp
No what i need is some how a walk threw that actually builds 1 that doesnt jump right to a get your x from y and assuming i understood x
And i understand the mob.json
I do not understand custum geometry annimatuon how i get a creation from blockbench to minecraft ect
That's not a scripting thing. I also don't know where you heard that.
What if shes thinking about gametest for fake player?
Seems different tho from what was explained
No i think someone told me something wrong its fine npcs have strong legs
I both love and hate the forms they look awefyl but im no good with json ui the inventory systems i make are effective but ugly and complex
how do people update https://github.com/Herobrine643928/Chest-UI/blob/main/BP/scripts/extensions/typeIds.js
Yes, I got that. But it still does not generate all of them/all my vanilla icons/id's still render blank
then idk dude just forwarded an answer to an identical question
ok thanks
Has anyone seen an addon that has over 1000 custum items noones given me a limit so id like to see if i can figure out safe zones
What is this?
Is there a way to put dynamic property to a block?
Whats this error mean?
Figured it out was providing a null array to a dropdown lol
Does startItemCooldown() reset if you exit the world?
item cooldowns dont reset
it wouldnt make sense if it did
I used it and when I exited and re-entered the world the cooldown was 0
How long was the cooldown?
If its like 3 seconds, before your client stops loading it will probably end.
try with like 10 minutes or so
between 30 and 120 seconds, I just tried to activate the ability and set the cooldown to 30 seconds, I exit after about 3 seconds and when I rejoined in the world I find the cooldown at 0
Can you try with a longer time?
It doesn't work it resets, I don't think 200 seconds ends when exiting and loading the world even though it takes 10 seconds to enter the world
Did they break the cooldown or has it always been this way?
if its really true, cant really help.
but it is really weird if that cooldown resets. Never has been like this
Maybe I'm doing something wrong, I'm setting the cooldown on the player, and in the item's cooldown I put duration: 0, correct?
idk, im a json ui typa guy
Can anyone tell me if this is a problem with the new update or if I'm doing something wrong?
thats quite odd ngl
it could be that they actually dont keep track of the cooldown since theyre usually short
so this kind of situation wouldnt matter
what you could try is to store the cooldown as dynamic property in player and load it when the player rejoins
Is there any property that returns game time?
const time = world.getTimeOfDay(); for script
Thanks, but I was looking for the time on the specific player, I think there is nothing for that
Maybe standard Date.now() from js (I guess it would be server time?) - it should be possible to use something like that for maunal CD handling I guess
Yes, in fact I opted to use that, saving the current time when the player uses the ability and then comparing it with the recent time, even though I would have preferred to recover the player's life time in the world, saving the moment in which he used the ability so that in case the player exited it would stop, and it would resume the time only when the player re-entered and compared it with the old time, but I assume that you have to create an internal timer for each player to use such a system?
or should I save the moment you exited and restart from that data?
that would sound better to me but Im not yet familiar with all events and possibilities API provides ... I do js for work but Im kinda new to MC modding π
Thinking about it if I did it from standard server gamedev perspective I would have probably some loop on server through all active players and handle their CDs there ... but when I tried it in my game in Unity way back it was still not great - timings over network are horrible to deal with π ...
So you think the best way to avoid performance issues is to save the time and compare it to the current time avoiding loops, but having the problem that when you are offline the cooldown runs the same, so it ends, even if it would make sense if it was a world always online like a realm
Question is - does it even make sense to pause CD if player logs off? Depends what you want to achieve but for ability CDs is it worth the extra hassle? π
depends also if you have 6s CDs or 12h CDs I guess
You've convinced me, I don't think it's worth pausing the CD so I'll go ahead with the Date.now() system, thanks for the reflection. ππ»
No problem, discussion tends to help π
Out of curiosty - do you show the progress in UI somehow? (maybe its not even possible in MC, I have still lot to explore)
I'm not the right person to answer this, but I think almost anything is possible in Bedrock. Thanks again.
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]
Can you not use the latest stable beta debug util with the latest stable beta server?
npm no like when I install it after installing server
was able to get it to install by installing debug util first then the server
if (e.projectile.typeId === "ww2:spot_projectile") {
const player = e.source;
const coord = getCoords(e.location);
const validNations = ["american", "german"];
const playerFaction = player.getTags().find(tag => validNations.includes(tag));
if (!playerFaction) return;
if (!globalAnnounce) {
for (const p of world.getPlayers()) {
if (!p.hasTag(playerFaction)) {
ClassBroadcast(player, "Spots", coord, e.location);
}
}
} else {
ClassBroadcast(player, "Spots", coord, e.location);
}
}
});
my brain power aint up for this π is there any way to send messages to people with the same tag?
cant you just use entityfindoptions or whatever the interface is called to query all players with a specifc tag
nvm
heya
anyone know if it's possible to use animation controllers to detect when the player lands after they jump?
i can do it with script but i already got around 3 intervals, and I don't want a fourth
and a 20 ticks interval isn't doing me any well either tbh
I'm fairly new with animation controllers so if anyone can give me some pointers too that'd be great
nvm solved
As far as it's not using Array.prototype.filter, he's safe.
im soo bored
hi
There is no need for 3 intervals. You can combine all intervals into one.
nah
one is ran every 20 ticks
one is ran every 40 ticks
and one is ran every 60 ticks
they all serve different purposes
and they're across packs.
but they complement eachother
also I'm using a PlayerPulseScheduler for even better performance
what is it
from @bedrock-oss/bedrock-boost
it basically splits the work into ticks.
if you schedule for 20 ticks and have 1 player, every 20 ticks it'll do something
if you have two players and 20 ticks, every 10 ticks one will be handled
and so on
Basically splits the work across ticks
I'm not sure if the logic done in it is exactly the same as i explained, but it's what it does one way or another
port a mod into bedrock for fun
or idk play something
or watch dragon ball π
i binge watched the classic series across a month
π
if (e.projectile.typeId === 'ww2:spot_projectile') {
const player = e.source;
const coord = getCoords(e.location);
const validNations = ['american', 'german'];
const playerFaction = player.getTags().find(tag => validNations.includes(tag));
if (!playerFaction) return;
if (globalAnnounce) {
for (const p of world.getPlayers())
ClassBroadcast(p, 'Spots', coord, e.location);
return;
}
for (const p of world.getPlayers()) {
if (p.hasTag(playerFaction))
ClassBroadcast(p, 'Spots', coord, e.location);
}
}```
i cleaned up the code a bit.
i use 2 spaces for indentation and single quotes but you are welcome to change those as much as you like.
I made this code on pure guess of what ClassBroadcast does, feel free to provide the function definition if this doesn't work.
and maybe some context.
you should avoid branching too deep since qjs is interpreted not just in time compiled, so it hurts performance unlike in something like V8
(the scriptapi environment is qjs currently)
Damn cool I guess
how do i add an effect without particles using addEffect() ?
entity.addEffect("regeneration", 30, {
showParticles: false
});
tysm
How do I fix the "unknown" parameter errors in the @gaunt salmon bot with custom components?
With script how do you summon an entity with a specific display name and how do you get that display name
the spawnEntity method returns the entity being spawned
Im asking to summon it tho
But can i detect if script was its sourse
Spawn entity gets the dntity after its spawned tho
Ohhh
i didnt say anything about the entity spawn event
I have dyslexia so i read that as entitySpawn
okay
For that i need to pull dimension? Or just world
so you could just put the spawnEntity method in a variable, and then just edit the property
its on the dimension class.
const entity = dimension.spawnEntity('minecraft:creeper', location)
entity.nameTag = 'test'
Location is an object x:,y,z:, right
yes
Does it run just set as a var or do i need to call it
it'll run
its already being called
And i can also set dynamic properties right then snd that sweet
yup
and just get the same nametag property and use it in an if statement.
So if not set it will return undefined or null
hm? you mean if it has no nametag?
yes, it'll return undefined
spawnMob.nameTag = "test"``` says not a function and before you say caps i tested it for some reason the export for Dimension is capital i tried
yes
that wont work.
you need to retrieve the class from something.
either from a block, entity or the world class.
what class i thought dimension was the class
it is.
ohhh dso world.dimension
Its in a use event for testing
Ohhh i get it now
and to get the dimension class from world, you need to do world.getDimension(dimension id)
So whatever the activater of the event is
Does that mean if i ran this in an uncontrolled entityspawn event id spawn entities til i crashed
probably
lol
yeah
you should set up a dynamic property or a temporary variable if don't want that
Already crashed once today accidently had my get player comp call a func that called get player comp lol
maybe a tag
just something
less efficient
plus tags have a limit. could be reached faster than dps
Oh i dont plan to do that i was curious
a boolean property in script or dynamic property are the best method
alr
I need to do it in a system.run dont i
well depends on the context
depends.
if you are in a read-only context like a before event, you do
Yup i am
if you intend to run it from something like an after event or in an interval, then no
then yeah
then you need system.run
That makes alot more sence with how you worded it
no worries
I'd recommend reading the script v2 change and also the permissions update
they'd help understand this with visuals
If i applied a damage of 0 that calls entity hurt correct
yeah
I enjoy reqritting the entire combat system i just wish adhd and dyslexia didnt get in my way
Wait if i spawn entity then set nametag if i have entity spawn event looking for mobs without a nametag will it detect the mob before it gets its name tag
Y can't lore have %? Is this intended?
Yes, it's because % indicates the start of a localisation key
Wait if i spawn entity then set nametag if i have entity spawn event looking for mobs without a nametag will it detect the mob before it gets its name tag
no, because it essentially edits these properties before it spawns I believe.
you should be good
How do u get the translated or localization key of enchantment?
Just learned this today as well as adding newline in lang files actually work now.
i dont think you can
Ok cool
1 more question
Is there a way to set players max health based on a dp in a way that wont cause current health to be effected unless it was higher then new max
You can't set max health
there will be a workaround with EntityHurtBeforeEvent
but it still won't work perfect
you could use player.json or health_boost effect
Theres a workaround now just gut and change health to a new system
But sadly health boost effect caps at 255 and effects current health
I am eager for an entityhurt before event tho cause then i can take out vanilla combat entirely and replace it with my own
No more hit spllater on a missed attack
Whens it ezpected
is it posisble to just summon a mob/entity that is considered as a projectile but just a normal mob, just to create an owner for the mob instantly without the heart particles with tame component?
Question
So i want to get a mob to display its name then under it didplay a dynamic property i have set
How would i do this
so you want to get the dynamic property value, and display it under the entity's current name?
Yes
entity.nameTag = `${entity.nameTag}\n${entity.getDynamicProperty('name')}`
But its dp is set by its name
what
Meaning i have a script setting every entities dp based on what its nameTag is
Actuslly that should be fine still
Cause its set to skip if it slready has dp
is this a custom entity
nvm then
i was gonna suggest just intercepting the event triggered by nameable component
But the dp changes so ill just update it on change
Whats the syntax to kill the player or entity
entity.kill()
Ty
Can we not use debug utilities on bds?
Needs to be configured to do so.
How so?
Monsters spawned by a script will trigger entity spawn event right
Either in server.properties or Mojang needs to update it.
Im an idiot
Im sitting here debugging code
I forgot to attach the event listener to main
I dont see anything in there, unless its a hidden property
Why are my entities spawning with a dynamic prpperty entityStats before i even set it and its causing my code to fail even tho i have a safety net in place thats supposed to fix it if it if its not valid
Wait nvm on that still got an issue tho
Ok so i have a rare but problematic bug
Occasionally an entity spawn but either derenders or disapears after event tagged it but before events ran and it causes a hard error
Ima put a if no entity return tag there in hopes i dont see it aby more
figured it out, didnt know about the config folder lol
Can anyone send me the hud code that lets you hide hp food armor snd waterbreating bar
Ohhh i forgot they added commands for it now
player.onScreenDisplay.setHudVisibility(HudVisibility.Hide);```
Dont need it i forgot about the command but ty
I get better and better and better at script every day i have gotten nowhere in understanding json ui
are debug utilities broken? cuz for some reason i am not able to use the intellisense as well, I have done
npm i @minecraft/debug-utilities@latest but all i get is
I am in Stable 1.21.130
Bruh, it works, but intellisense is bugged??
Are you using Deno?
Nope, i am not