#Script API General
1 messages ยท Page 137 of 1
I used to have a script for batch processing large amounts of blocks when filling in. For stuff like spheres, cubes, pyramids, etc, etc. Using runJob allowed for efficient management to eliminate blocking of other functionality and greatly improving performance. I could probably write it up again honestly but I'm not familiar with the tick manager. So I would have to experiment with that to see what kind of delays it presents, etc. I definitely can't do anything now, as I have an appointment coming up, but I would definitely consider taking advantage of runJob() to handle your tasks if it's large and many, then properly yielding to allow other micro operations between ticks.
runJob is great. I love it lol.
lol
runJob is a generator.
yea i would guess so
yield world.afterEvents.playerSpawn;
when?
You know who to ping, if bold lol.
I'm saving that lol
i got one with my own implementation but i lost it somewhere in the github mess i have
the clan is growing ๐ฅ
but i can find snippet of it here somewhere on discord more likely
Oh I'm certain of that lol
They are called generators, and to give you simple explenation imagine a function that can return multiple values while running
isn't it magic?
noway it works
with yield you have more control, await is handled by engine it self
so i had to use yield for lot of stuff before
now it would likely work with await as well but only some stuff of it
I mean, I get that yield works like return, but doesn't stop the function. But I didn't know u can get data through it
it is abusing generators on different level, its not as simple to explain
well, how do I do this?
i run the generator and handle the return values and yield parames back to the function based on its value so when it returns number i just wait x ticks and then i ask for next value and so on
but its not typescript friendly
i would have to rewrite typescript compiler to support that or idk
I get it, but what about events?
when you yield event, then it basicaly checks if it has subscribe and subscribes to it, once callback is fired i pass the value and call next iteration from the event callback + unsubscribe
its simplier than it looks like
its really basic stuff actually
i made that like 3 years ago
and how do u pass the value?
i don't have src sadly
next(param)
i love generators in this since
the reason i used generators was that i could even handle events that were running multiple times per tick
i consider my self as educated in ECMAScript so ask anything, but ofc noone knows everything
OMG
BRO
I DIDN'T REALISE TYPESCRIPT HAD INTELLISENSE FOR STUFF LIKE THAT
๐ญ
Now I wish I used Typsescript so much sooner
Bro...
Pretty fantastic, eh?
Very
๐
Damn
What happens if I assign entity hurt before event.cancel = false in the first addon and entity hurt before event.cancel = true in the second one?
they won't conflate each other. You can even define both in the same add-on.
Events are instantiated, data's not shared across multiple instances
Whichever the last function that assigned it will decide whether the event shall be canceled or not
What bro , that's what supposed to appear in JS too
Oh. .. you mean showing intellisense inside functions for parameters yeah, for that people use TS in the first place
Because the editor knows what type your parameters are
In TypeScript context
you just said js
^
Nah i just thought he didn't know there is intellisense in JS and that is the first time he found out
Just wait until you guys find out that the ts and js language server are the same thing
No wayyyyyy
When i started scripting for the first time i thought I was learning java tbh โ ๏ธ because i thought JavaScript = Java
Car vs Carpet
| true |
If you ask someone who doesn't know programming what the difference between java and JavaScript he will tell you they are the same programming language ngl
@simple zodiac
Do you have anything to say?
Nk
ohmygod ohmygod ohmygod
Added method registerCustomDimension to allow registrations of new custom dimensions in beta```
Is this a dream?
Pls tell me it's not
it's not
Introducing the basics of custom dimension support in preview in 26.20.26! Check out the one simple API that will unlock many creative new things for Minecraft.
Code sample used:
https://github.com/microsoft/minecraft-samples/tree/main/custom_dimensions
they released entityHurtBeforeEvent and then this, so nice
is there a way to use dimension.setBlockType in an unloaded chunk without using a ticking area
no
do ticking areas you make with the api show up when you list them in game then
and if the max amount is set would it just not work if I try to make one
No.
For people who have started messing around with the custom dimensions, does anyone know what's wrong with my command? If I do an itemUse event and teleport the player to the dimension it works just fine but using a command it says that my custom dimension is invalid.
Error: Dimension 'custom:test' is invalid. at <anonymous> (index.js:48)
It reaches the success message for teleporting the player, it just fails to transfer now. Originally I was registering the dimension after the command and thought that might have been it but I've since moved the dimension above the command and still the same error applies.
Im trying to store a block permutation within a dynamic property but whenever I parse then unparse it says that its not a Block Permutation
When I go to use setPermuatation
show code
what should i use to detect the type of potions inside the cauldron?
well, BlockPermutation doesn't have toJSON method, so u should do something like permutation.type.id + '|' JSON.stringify(permutation.getAllStates()) and then BlockPermutation.resolve(string.split('|')[0], JSON.parse(string.split('|')[1])) to parse
Wait isn't path finding just BFS?
what's BFS?
Breadth-First Search
still don't understand, lol
doesn't sounds efficient for long distances but might actually work for small ratios
Now im getting stack overflows
Ok now I need a more efficient way of doing this
Why use runCommand for actionbar?
And what are you trying to do that you're getting SO?
Use runJob.
Put the function inside of runjob whenever I call it?
Yeah. Or take a look at the editor mode flood function.
It doesnt call itself ๐ฅน
Unless I have to call a job within a job
Using player.onScreenDisplay.setActionBar(Foundry Invalid...\nMissing brick at ${block?.location.x}, ${block?.location.y}, ${block?.location.z}. Found: ${block?.typeId}).
How would I centre the "Foundry Invalid" part?
\t works?
That adds this ๐
Then jist spam spaces.
Oh well
function* fillArea(blockFace, radius, replace, x, z, permutation){
console.error(x, z)
if(border_blocks.includes(e.block.offset({x: x, y: blockFace == Direction.Up ? 1 : -1, z: z}).typeId) || Math.abs(x + (x > 0 ? 1 : -1)) > radius || Math.abs(z + (z > 0 ? 1 : -1)) > radius || e.block.offset({x: x, y: 0, z: z}).typeId == permutation.type.id){
console.error('failed')
return;
}
else {
//console.error('suceeded')
e.block.offset({x: x, y: replace ? 0 : 1, z: z}).setPermutation(permutation)
fillArea(blockFace, radius, replace, x + 1, z, permutation)
//yield;
fillArea(blockFace, radius, replace, x - 1, z, permutation)
//yield;
fillArea(blockFace, radius, replace, x, z + 1, permutation)
//yield;
fillArea(blockFace, radius, replace, x, z - 1, permutation)
//yield;
}
}
why you no work
Why is there a * next to function?
Apparently needed for it to be run jobbable
Worked
Now why didnt it stop
Why isnt it stopping
lol
it is called generator function
runJob require it
I see
How do you use clearJob()
Idk if this'll help ๐
https://jaylydev.github.io/scriptapi-docs/1.21.20/classes/_minecraft_server_1.13.0.System.html#clearjob
Ok, I see now. It's also mentioned in runJob
https://jaylydev.github.io/scriptapi-docs/1.21.20/classes/_minecraft_server_1.13.0.System.html#runjob
Yeah but idk the id of the job i need to stop
Buddy...
const id = system.runJob
system.clearJob(id)
(epotrictically) is there a way to "manipulate" the vanilla effects without using the actual effects?
is it possible to change features in custom dimensions like gravity, atmosphere, friction?
No.
why?
mf they just released it ๐ญ
it just came out
we only have access to registering a dimension for now and thats all
Any docs for the custom dimensions??
I never understood generator functions tbh
anyone know if you can show only the alias of the custom command in the command prompt in game?
at the moment both the alias and the namespaced version show
I can't found any built-in alias feature for custom commands
After all you are creating two different commands to emulate that, i guess is not possible
no worries i will live with it
wdym you create 2 commands?
I didnt read this message, sorry
ah were you considering the actual registering
i was only hoping to just hide the namespaced version, still regestering it i suppose
just to clean it up for my freinds who will use the command
I tough you were taling about something like /tp and /teleport, my bad
do you know if theres a way to do that
so instead of both /raycast:wand and /wand showing, its just /wand
Is there a limit to how many ticking areas we can create with api?
10 as usual
300 chunks
if two different ticking areas are ticking the same chunk, that chunk will count as two towards the limit
Those are two different things, i believe, no ?
These ticking areas are limited by a fixed amount of ticking chunks per pack independent of the command limits.
there is no area limit, but there's chunks limit
Sure ?
While entity work_tick isn't limited by quantity, is it?
Yep
dimension.setBlockType() should work if I do it at a location inside a ticking area right?
how come it is still giving me the unloaded chunk error when I put it in one
Are you waiting for the ticking area to be made first?
yeah I did a system.runTimeout() with 10 ticks
Dont do that.
Use proper methods.
Use await or .then
system.waitTicks(10)
the ticking area does get made before that though
Sample code...
Dont do that too.
Getting made vs loading it is different.
Theres a reason its an async function.
I meant for when waiting for sth else
I usually do
await createTickingArea(id, {dimension,from,to})
Im so curious why they changed from Promise<TickingArea> to Promise<void>
Is it like 99% it resolves that it created it...
You already have the object anyway
Wdym?
Is not necesary to return the same object you passed as argument
Yes, but it's kinda common for create type methods to return the thing that you created.
The same way REST APIs do return data after POST endpoint
You're telling me.
await createArea(id);
const area = getArea(id);
Is better than
const area = await createArea(id)
Well.. i guess it was useful to write all in one line
Kinda wrong example as you can get almost everything, because you can predict from the options that you provide, but in general it's better to return a created object
Wdym?
The only new thing that you get from obtaining this object from create method is an unique identifier of this ticking area. Rest of it you can calculate basing of the params that you used before to create the same ticking area
You cant get the BlockBoundingBox, chunk count(well you can, ugh math), nor if its fullyloaded or not without having the tickingarea object.
You can set isFullyLoaded to false since it won't load in the line below
And BlockBoundingBox you can also resolve with the data that you used lmao
So create boundingboxes myself instead of using the one the game gave me? You do you buddy.
Also, how are ypu going to get isFullyLoaded without the tickingarea? Exactly.
Are you sure? Discord Rest API do return data on POST method
i don't know technical details of createTickingArea but it would be easier for everyone if we could just get the ticking are from the promise
That used to be the return method.
I literally said it ๐
It would be easier, but it's not that deep as you make it
Yes, it does return
Where....are you going to get the property?
You can calculate it also
Why do you like calculations instead of...letting the game give it to you?
Yes, but the point of my solution is that you can also get it on your own. It's still possible, I do not care if it's easier or harder in this case
The point of the convo was to make things easier.
You're the type of person to say, "We can already do world gen in custom dimensions using noisejs, so who cares if Mojang adds or doesnt add feature rules to work"
I don't care about the things that don't extend functionality or make smth faster. It's just about the speed of development. Also, it'd be few lines of code more anyways so who cares atp?
Person who gets charged by lines of code written.
And someone really gets paid like that? No, it's a joke.
Congrats, you figured out my joke.
Doing manual calculations is like the anti thesis of fast development speed.
Few more lines of code. Does it matter for you?
It does yes, why write more lines of code when the previous implementation did not require you to do so.
Unless Mojang gives a reason why, it is a decision that makes 0 sense to me.
Yeah, but now previous implementation is gone. You can still achieve the result that you could use
I never said I couldnt. Im inquiring why the decision was made.
That was the whole point.
Look to the first message that I've sent. I claim that it's weird, but it does not change that much as you can still achive every single information about new ticking area except it's identifier
And to which I reply why make us do more work when previous impl did it for us.
Ask Mojang, I just give you alternative solution
๐คท
Thats...what I did.
I never said there wasnt an alternative.
My bad.
TickingAreaOptions =/= TickingArea
custom dimensions with loading screen is so fire. I can't wait for it's future updates
its like a multiworld plugin, but it resets every reload I guess
So it only needs to register once?
well, Idk what will happen if u don't register it after reload...
Like all builds are saved with the dim id, and we just need to define it by registry?
yeah
this is what happened when I removed the registration
and if u register it again, all builds in the dimension will stay
Thanks for testing it out, that's a good news for me
i thought - on the sample code, we need to build platform everytime
tru
Label and divider misalign the toggle in server-ui?
Filter out falsy values
const filteredFormValues = formData.formValues.filter((value) => value !== undefined || value !== null)
v != null to be short
Won't it filter also false values, which might be a result for toggle component e.g.?
The problem I'm having
If I remove the label, it starts working as it should again.
Could you show us the code?
I think that you simply have to slice the beginning of an array (result.formValues in this case) and you'll be fine. If you send the code, I can fix it for you ๐
And interestingly, it happens explicitly with the initial toggle.
boolean isnt close to null
Here
u might wana try ```js
form.title("%ui.biomes_beyond.mspawn.title.name")
Yeah, I forgot that null is a bit different lol
Put another way: null and undefined may be falsy, but null and undefined are not equivalent with false
But isn't this for translation?
yes, but shorter
But what could be causing this? Could it be because I didn't create the toggles list manually?
form.label()
form.toggle()
form.label()
form.dropdown()
form.divider()
form.label()
form.textField()
``````js
const formValues = [
,
boolean,
,
number,
,
,
string
]```
this is how it'll look like when using those in ModalFormData
u can put this fix```js
const formValues = r.formValues.filter(v=> v != null);
playPageTurnSound(player);
// formValues[0] is the Global
const globalValue = formValues[0];
// formValues.slice(1) are the mobs
const individualValues = formValues.slice(1);
But why does this happen explicitly with the first toggle and when trying to reactivate it, since disabling it works as it should?
as for ur current form setup, it only has one null type in formValues
Okay, I'll try.
It's works, thanks
I hope the server-ui with ddui comes soon; I'd love to see a mix of buttons with toggle switches, since the current setup requires you to choose between them.
its in beta now tho
Yes, but Marketplace doesn't allow the use of experimental (beta) content.
thats unfortunate then
u
M
TS
Argument of type '"foundries:valid_foundry"' is not assignable to parameter of type 'keyof BlockStateSuperset'
const controllerValidationState = controllerBlock.permutation.getState("foundries:valid_foundry") as boolean;
I'm a bit confused how to make it valid?
Do I just do as any?
(which defeats the purpose of types, but idk what else to do ๐
trururr
sry ive got some dumb shortcut that keeps thorwing me into discord chat in gamebar
I hate how vanilla data is set up, for some reason BlockStateSuperset isn't an interface which makes it impossible to add custom states to it
ig you could do something like this (can go in any ts file in your project, should update the types across all of them)
import { BlockStateSuperset } from "@minecraft/vanilla-data";
type CustomStateSuperset = BlockStateSuperset & {
"example:state": string;
};
declare module "@minecraft/server" {
interface BlockPermutation {
getState<T extends keyof CustomStateSuperset>(stateName: T): CustomStateSuperset[T] | undefined;
withState<T extends keyof CustomStateSuperset>(name: T, value: CustomStateSuperset[T]): BlockPermutation;
}
}
then you can do this
block.permutation.getState("example:state") // string
Oh, I didn't have vanilla-data installed ๐
I can do this now
block.permutation.getState("foundries:valid_foundry" as keyof BlockStateSuperset)
Lmao
is it true that we're getting custom dimensions ๐ค
we got it!
latest preview
Is it possible to make it when it turns night iron doors cant be powered. and if they were already powered to make them not.
what
not really..
Probably make a custom door
Evening all, does anybody know if it's would be possible to move somebody from one discord voice channel to another using a script?? I see there are bridge bots but they only seem to relay chat
Do we have a dimension change callback? Specifically before Events?
Only after event
do we can use playerDimensionChange event on v26.13 Minecraft, or is it only for preview
I remember using it in 1.21 so yes it should be on the latest version
I think there is an entity component that prevents entities from going through portals. Not sure if it works on players. That would require editing player.json tho
"minecraft:dimension_bound"
It's possible to have it be conditional right?
using component groups. Depends on what exactly you want to do
Lock nether and end behind certain events occuring
yeh you can do that with events that add a component group containing that component
Although I belive the component locks travel for both dimensions at once
with a bit of scripting logic you should still be able get your desired result
I hope so
Just use playerChangeDimension event
That doesn't prevent the player from going through the portals
yes you can tp them out but that just feels bad
Oh hmmm
Hmmm
Them feel whatever they are getting closer to the portal blocks
Detect that
And don't let em go in
sounds easier than it actually is also no one wants to spend all its performance on checking surrounding blocks every tick
Sorry I meant the new custom dimension api
firgured out 26.13 is just a hotfix, and I need to join beta on playstore
to use the minecraft beta or preview, I guess
Hmmmm
I did this once before. It's not pretty lol.
I eventually threw it out ๐
But that was a few years ago so performance may be better now since we have runJob() but I still wouldn't recommend it.
We also have block volumes. In combination with dimesnion.getBlocks with filters its really efficient
Yea, a few options have become available since then. Unfortunately there are a lot of little variables that trip you up which can be difficult to catch and sometimes they still manage to pass through. Which is when that dimension change event would come in handy but you still deal with the loading screen which isn't ideal. So it's personal preference at this point until something more ideal becomes available. Which would be a before event.
-# Soonโข๏ธ
This is probably a simplle fix and im over looking it
what's happenin here?
2026-04-10 15:11:22:237 INFO] Pack Stack - [00] ยงbFeather FPS Boost V3 ยง7[BP] (id: a3c7e8f1-5b24-4d9a-bc61-8f3e7a2d1c04, version: 3.0.0) @ worlds/MCPE - KOB MMORPG/behavior_packs/bFeatherFPSBoostV37BP
[2026-04-10 15:11:22:237 INFO] Pack Stack - [01] MMORPG MCPE CLASSES [BP] (id: eceb0d2f-8743-4867-8b84-bc95fed292c5, version: 11.0.0) @ worlds/MCPE - KOB MMORPG/behavior_packs/MMORPGMCPECLASSESBP/bp
[2026-04-10 15:11:22:311 ERROR] [Blocks] block_definitions | worlds/MCPE - KOB MMORPG/behavior_packs/MMORPGMCPECLASSESBP/bp | blocks/frozen_s.json | Unexpected version for the loaded data
[2026-04-10 15:11:22:311 ERROR] [Blocks] block_definitions | worlds/MCPE - KOB MMORPG/behavior_packs/MMORPGMCPECLASSESBP/bp | blocks/fadingsnow.json | Unexpected version for the loaded data
[2026-04-10 15:11:22:312 ERROR] [Blocks] block_definitions | worlds/MCPE - KOB MMORPG/behavior_packs/MMORPGMCPECLASSESBP/bp | blocks/frozen.json | Unexpected version for the loaded data
ignore it
it's a fake error
that's not actually an error
am i able to check the playercount of a different server using api modules like admin or gametest?
Website or Bedrock?
if you know how to edit html the text part change the ip to what you want
With this code you will need something like this https://realmbot.dev
Realm Bot is a cutting-edge Minecraft Bedrock Realm management bot designed to revolutionize the way communities operate their servers. Our platform offers a comprehensive suite of features that enable realm owners to streamline operations, enhance moderation, and drive player engagement. With Realm Bot, you can easily manage your players, contr...
If your trying to do get Bedrock Edition player count of other servers you will access to a bot of theirs or a addon you made
and have them install the addon
@nova flame
that works for me but how would i go about it
i own both servers
@nova flame Let me create you better design for the website and two server status with playercount anything else if your using realm bot?
Player Management
Action Logging
Timed Bans
Realm Management
Member Management
Discord Verification
Vanity URLs
Chat Relay
Member Gate
Bot Detection
Execute Commands
Player Lookup
Leveling System
Tebex Integration
Skin Filtering
Live Playerlist
I would do it for commision the website and help you set it up for something
@nova flame
if your using dev bot
Let me show you a better looking website first
no bro i dont need a website or anything
i have 2 bds running on 1 machine
one is a queue server
and ones the actual server
and the queu transfers you when theres free slots
cool man
@Razz with realmbot do this To run two Bedrock Dedicated Servers (BDS) on one machine with a queue system, you will use different ports and the /transfer command.
@nova flame
i know
I think you might to get two realm bots
the things is their no way to do it other wise
there definatley is
you active player like a bot
nope you need a active player on the server typeing the command /transfer with each login
that's what realmbot does
i think you still might need it for bedrock edition
@nova flame i happen to have a propsal
no homo
no ring
lol
what bro
@nova flame dming you
Boooring
Is this a actual error?
[2026-04-10 21:00:19:539 ERROR] [Scripting] Unhandled promise rejection: TypeError: cannot read property 'id' of undefined at <anonymous> (zabilities.js)
at map (native)
at <anonymous> (zabilities.js:936)
That's just the ability not selecting a target right
like it works but misses
It works but code after 936 line does not work
yeh because i have not added the hidden abilitiy
im getting the hang of this gui and scripting
it's not the best but it something i also got night vision and blood hour done for the werewolf class
Oh i know why that line does not work it's got to be in the void to work
Yess i am super getting the hang this
@round bone if their a lot of that class and they was all doing it around the same time would that spike the ram or cpu from console input for it logging it?
Try reducing amount of calls per second
how would i go about that @round bone
Anyone know if invalid permissions for selector expansion has been fixed?
it has not
Dumb gane
How would I go about spliting up a large area between an x and z cords into chunks (the minecraft kind), pretty mch just how do I split one large area into each of it's chunks inside of it
What are you trying to achieve?
Trying to fill a large area by going chunk by chunk instead of all at once, both so I can split up the ticking area's I need to use more effectively, but also because I think it would run better then just getting large areas and filling them mostly all at once (I am using a runjob but still, probably faster?)
I would convert them into 16x16 XZ areas -> load the ticking area -> fill -> unload the ticking area -> move to the next chunk.
Okay but how would you go about turning them into 16x16 areas, I'd assume math but I want to make sure
Yeah, Math.
There's like various ways, divide by 16, take the starting coords +=16 in the loop
Etc etc
got it
Oh also last question, how would you go about checking for when the chunk is done, my first thought was a let but that wouldn't be able to let the code know which chunk actually got loaded, and I think that would be a problem?
oop typo
Cause I know I'd just unload the ticking area after doing the fill, but would it end up not knowing I filled the area in the first place
const dimension = world.getDimension('overworld');
for (let x = registry_area.start.x; x < registry_area.end.x; x += 16) {
for (let z = registry_area.start.z; z < registry_area.end.z; z += 16) {
if (
!dimension.isChunkLoaded({
x,
y: 64,
z,
})
) {
log.unloaded_chunks++;
await loadChunk(new Vector3({ x, y: 64, z }));
}
const block_volume = new BlockVolume(
{
x: x,
y: registry_area.start.y,
z: z,
},
{
x: x + 15,
y: registry_area.end.y,
z: z + 15,
},
);
const blocks = dimension.getBlocks(
block_volume,
{
includeTags: ['namespace:feature_flag'],
},
true,
);
for (const location of blocks.getBlockLocationIterator()) {
const block = dimension.getBlock(location)!;
const perm = block.permutation;
block.setType('minecraft:air');
// deno-lint-ignore no-await-in-loop
await system.waitTicks(1);
block.setPermutation(perm);
}
log.chunks++;
}
}
import { Vector3, world } from '@minecraft/server';
export async function loadChunk(location: Vector3): Promise<void> {
const dimension = world.getDimension('overworld');
if (world.tickingAreaManager.hasTickingArea('namespace:temp')) {
world.tickingAreaManager.removeTickingArea('namespace:temp');
}
await world.tickingAreaManager.createTickingArea('namespace:temp', {
dimension,
from: location,
to: location,
});
}
This was an OLD code that I wrote to grab certain blocks in a chunk.
You can slightly modify it to fulfill your needs.
Ideally the area you're filling is chunk aligned.
Tyyy
Brochachos can i ask ?
Is it possible to do the next things :
Slow time in mcbe,
Do more than one entity interacting button in Minecraft bedrock
Making Red Fog
no
no
yes
Sad
Hmmm , i mean adding new buttons using json UI , and then using scripts to detect whenever they get clicked or something like that ?
u can add as many buttons as u want, but they will have the same backend so it's useless
: (
What you mean they will have the same backend
like, imagine u added 2 buttons, but it doesn't matter which one u click because the result will always be the same
Oh
You mean like they trigger the same script
You mean you can't make the script make a difference between each one of them right ?
mhm
I didn't get it fr
Oh hmm right
how would i damage the enderdragon through scripts?
im currently using applyDamage, but the enderdragon takes damage differently and this cancels out the damage
i also tried the damage command, as well as instant_damage with effects
Using health component
oh right, i forgot that existed. thank you
is there any way to know if an item has just been created? like crafted or grabbed from inventory? I was wondering if I could put some kind of data on all items and if a specific item doesn't have it then I'll assume that it's new.
use dynamic properties
but works only if the item max_stack_size is 1
yeah I'm trying to do this for all items, even vanilla ones
Yayyy I made my Foundry modular in height
So it registers only if it's a height of 1, 2, etc all the way to 10 (the limit)
Hmm
does someone know what code it was that returned how much ticks does the event take to run?
someone send it here before I forgot how
You should probably modulo by 16 so you could get the starting cords that are Minecraft's 16x16 chunks, then += 16
Ticking areas I feel like would be more efficient that way
I would suspect you just record the start time, then the end time, and do the math to determine how long it took to complete whatever tasks it was set out to do during that event call.
I'm lazy xD
20 ticks is equivalent to 1 second right
Alright thanks, sometimes ticks changes in random delay when I tested it
there's also this
its average
The TicksPerSecond is always 20, it doesn't change based on the game setting.
world.afterEvents.entityItemPickup.subscribe(({entity, items})=>{
console.log(items instanceof Array)
for (const item of items){
console.log(item?.typeId)
}
})
why is this throwing me an error? types show that items are returned as an array, instanceof check returns true, yet it always throws a value is not iteratable error
some native arrays might give this error its a bit weird, I agree
thats for the snippet I might take a look in to it
I'm a bit confused though, isn't every item pickup a different instance of the pickupItemEvent?
So how would they all get into a single array?
every instance is unique btw
every returned itemstack by engine is new instance in script api
Yeah, that's why I'm confused why items would be an array
Or why it's items and not item
But would that not be individual instances?
If I picked up an Apple, that would trigger the entityItemPickUp event.
If I picked up an iron ingot and an apple, that would trigger the event twice, no?
Guys is it possible to make a camera focus on an entity nearby
im writing a script to prevent friendly mobs to be damaged, is there a simple way to check for friendly mobs?
Can we control the maximum height of the getTopMostBlock or whatever the method name is? I've been considering using it for spawning entities, but I don't want to try to spawn an entity underground if it's just gonna end up at the top of the mountain it's under.
Hmmmmmm family component @sage portal
what
@ed the wrong guy
Hmmm
Then you need to use a loop
Or check if entity is underground or not
I'm just looking to spawn an entity on the ground, a loop is excessive
What ground you mean
You mean cave's ground
Underground?
I guess you better use json's spawn rules
the ground relative to the player.
If I were to spawn something while in a house for example, I'd expect it to spawn on the floor and not on the roof.
Not talking about natural spawning
Oh
So what you mean is , if you want to spawn it on the ground it spawns on the top of the house instead of the actual ground
the way I'm currently doing is using getViewDirection() to grab the location in front of the player, then using a getBlockBelow raycast to get the first solid block from that location to summon an entity.
But the problem is that this method only works with flat environments. Against something like a hill, this results in the entity being summoned in the ground.
Hmm understood
Then you can do something like if you want the entity to be near the player, then use if statement to check if entity Y is in safe range
Because getTopmostBlock() won't help in this situation
Ane i guess the only way you have is looping
@sage portal
But if i understood well what you are trying to achieve, yeah you have no other way
I'm not really sure where you're going with the looping thing tbh because it's a case of activating the summon once, not a constant interval of it.
I guess the closest example I can use is the evoker. The evoker is capable of summoning evoker fangs even from behind a wall, and if you were to fight an evoker on a hill, the fangs would spawn on the surface of the hill properly rather than having some spawn in midair or some spawn inside the hill.
basically, yeah.
And I considered the getTopMostBlock thing, but I didn't know if that would just make things not work if something was above the player, like if they're in a house or in a cave, or in the nether with the nether roof.
Hmm yeah if the place was hollow
It will spawn it on the exterior surface
Not inside it
well that's unfortunate
But can you tell me what the entity is supposed to do or to be
Maybe there is a better way to achieve the same behaviour
it's not like a living entity or anything, it's simply akin to like placing down a sentry.
just look in the general direction, right click, and the entity is summoned on the surface, relative to the player's position
Hmmm ok
So i recommend using mix of getBlockAbove() and getBlockBelow()
Best idea is this @sage portal
Use max dimension Y location if you are on the ground
And use getBlockBelow()
It is suitable to use with hills
Get Xand Z where the player is looking at and use it with Y = 320 , and getBlockBelow({ x : yourX , y : 320 , z : yourZ})
What do think ?
@sage portal did you understand the method?
And if player is underground use getBlockAbove()
Or mix of both above below for better accuracy
It sounds like the third option of mixing both is the closest I'll get to accurate spawning.
Man I wish there was a way to look at how Mojang did it for evokers.
I sadly don't mess around with java edition enough to know where to even begin with that.
Or Java itself really.
I need to branch out my coding language skills
Hmmm
I deadass hardcoded all the passive mobs
lol
oh well it works, for now
can i hav :)
what is the thing when the play full loads in to the world cuz im doing title thing
try Array.from(items)
why not [...items]
Thats a known bug yeah.
Lesgoo custom dimensions!!
i just got back
Wouldnt it throw an error if items isnt iterable again?
-# skibidi bop bop
Script-api used to have weird arrays from getPlayers and enchantments
And the items property from this event is quite unique as well
I wonder, if it is determining the object to not be iterable, could one check if it is iterable with Symbol.iterator in items?
should be working
how to make custom npm module and import it to minecraft scripts?
So, while working on my project, a bot supposedly joined and began spamming crap in the chat. It was something related to "Lumine Proxy". I had to leave immediately as I noticed my frames began to drop, possibly crashing my game.
My question is, is there any way to prevent something like this from happening again? I've looked up the phrase "lumine proxy" in the server and only got two results. One was a scam, the other was the same question as mine.
Well, I think in #1067535712372654091 there's a anticrash post or something
#1481643759409168457 message
is there a way to access the value simulationDistance on Stable?
Which API are you referencing because I can't find that when searching.
there is no api with that name
s
can we detect player directional movement?
yes
Documentation for @minecraft/server
getMovementVector()
epic, thanks
Is there anyway to take string with white spaces as an argument to custom commands, without using quotes
can you use emitters to make custom events or does that not work with addons
It would be wiser to handle it with quotes so it isn't treated as multiple args. Easier to handle.
but it shouldn't matter cuz it's the only aka the last of the command
Give a sample code based on your situation.
If you want to check if any class is available in the engine, I recommend checking out this repository:
https://github.com/bedrock-apis/env-types
system.beforeEvents.startup.subscribe(a =>{
const Sentence = [{ name: "message", type: "String"}];
const LocalChat = {
name: "mw:localchat",
description: "Use this to talk in normal chat when in a group.",
cheatsRequired: false,
permissionLevel: 0,
mandatoryParameters: [...Sentence]
}
a.customCommandRegistry.registerCommand(LocalChat,
(source, ...message) =>{
console.warn(message.length)
world.sendMessage(fabricateMessage(message.join(" "),source.sourceEntity,1))
}
)
});
fabricateMessage() only performs string manipulation so that shouldn't be a problem
I have a solution for you: use chatSend event and add a prefix to send messages to a local chat instead. Most of servers do that instead of just a command
Like if you place ! as a first character in your message, it'll behave the same as with your command
I was thinking of that too but wanted to figure if there is a way through custom commands
Sadly, no. There's no rest parameter or smth like this for custom commands so the only option left is to add plenty of arguments (which will be obviously a bit confusing for players) and join them using "", but that's the only option I can think of
There isn't. You are already implementing it correctly from what I can tell by joining the strings so it becomes hello world to "hello world".
hello world โ ["hello", "world"] โ "hello world"
this code actually works and doesn't throw any error when reloading but the command still only accepts one parameter ,
so : /localchat hi hi throws error , but /localchat hi works and the console.warn(message.length) even returns 1
it should do that but it isn't
Make sure your function that is manipulating the string isn't returning more than one arg. If it is then you need to adjust how it's manipulating it based on your desire, or handle how you grab the arg in the array more efficiently. Albeit arg[0] or arg[1].
An array will contain indexes. Starting from 0.
it's not , it only returs a single string
Does it return as string or string[] because that is still important. Makes a difference when calling either arg or arg[0].
string
code for reference :
function fabricateMessage(msg,player,local=0)
{
const alias = player.getDynamicProperty("mw:alias");
const chatCode = player.getDynamicProperty("mw:formatCode");
const chat_code = (chatCode == undefined)?"":chatCode;
const alias_name = (alias == undefined)?player.name:((alias == "mw:is_hidden")?"???":alias);
const group = player.getDynamicProperty("mw:group")
return `${(group == undefined || local==1)?"":`${chat_code}[ยงr${group}${chat_code}]ยงr`}${chat_code}<ยงr${alias_name}ยงr${chat_code}> ${msg}`;
}
Hmmm... Ok, so your code initially starts with string[]. Like this: message = ["hello", "world", "test"].
Then you message.join(" ") and it becomes a string like this "hello world test"
Your function function fabricateMessage(msg, player, local = 0) returns a string. So everything appears normal. I would inspect and debug that function and be sure everything, line for line, is handled correctly. Have it print everything as it executes synchronously for quality insurance.
I found smth interesting so changing ...message to just message in the customCommandRegistry , allows the command to split string into array of chars
system.beforeEvents.startup.subscribe(a =>{
const Sentence = [{ name: "message", type: "String"}];
const LocalChat = {
name: "mw:localchat",
description: "Use this to talk in normal chat when in a group.",
cheatsRequired: false,
permissionLevel: 0,
mandatoryParameters: [...Sentence]
}
a.customCommandRegistry.registerCommand(LocalChat,
(source, message) =>{
console.warn(message.length)
console.warn(message[0])
console.warn(message[1])
world.sendMessage(fabricateMessage(message.join(" "),source.sourceEntity,1))
}
)
});
so /localchat hi hi will still throw an error,
BUT
/localchat hi will hi -> [ 'h' , 'i' ]
I think the issue is that I cannot use an array of string as a manadoryParameter
/localchat hi hi
That's plausible. I don't use custom commands personally. I still stick with the old school way of handling command lines.
fair
but it's interesting that this works
You are learning and I'm sure that will be enlightening as you study it further.
not the message.join(" ") actually, that throws an error\
It's indexable as well message[3]
yes
See I donโt really wanna disable slash commands, and making custom commands is fine but making one for almost every command? Iโm not doing that.
Iโve decided Iโll use the code provided, but expand it for my liking. Itโll work like this:
- 3-5 different scoreboards, each with their own randomly generated name.
- Each scoreboard has an either big or small number attached to that scoreboard.
- The player must have all of those scoreboards with their number to be able to use slash commands, and they also need operator.
- If a player lacks at least ONE of these, they canโt use slash commands and have to default to custom commands.
did anyone make a sneak subscriber?
Heeey! Someone know how to check the available API versions for a specific minecraft version?
hey i'm getting this error, [Scripting][error]-TypeError: cannot read property 'applyDamage' of undefined at handleEntityHurt (enchant/enchantmentEffects.js:83)
at <anonymous> (enchant/enchantmentEffects.js) from this code, function handleEntityHurt(event) {
const attacker = event.damageSource.damagingEntity;
const victim = event.entity;
if (!attacker || attacker.typeId !== "minecraft:player") return;
const player = attacker;
const inventory = player.getComponent("inventory").container;
const weapon = inventory.getItem(player.selectedSlotIndex);
if (!weapon) return;
const enchantments = readEnchantmentsFromLore(weapon);
if (!enchantments) return;
let bonusDamage = 0;
// --- SHARPNESS ---
if (enchantments.sharpness) {
bonusDamage += enchantments.sharpness * SHARPNESS_DAMAGE;
}
// --- POWER (projectile only) ---
if (enchantments.power && event.damageSource.cause === "projectile") {
bonusDamage += enchantments.power * POWER_DAMAGE;
}
if (bonusDamage <= 0) return;
// Apply ONLY the extra damage; vanilla damage still happens
victim.applyDamage(bonusDamage, {
cause: event.damageSource.cause,
damagingEntity: attacker
});
} does someone know how to fix this
Documentation for @minecraft/server
Documentation for @minecraft/server
For const victim
Hey sorry to bother you days after sending this, but what's the "registry_area" thing meant to be?
That's just the coords for the area.
No I got that, but as in what did the variable stand for? Cause what's throwing me off is the ".start" thing
Oh, don't use it. Just replace that with your coords.
Ahhhhh, got it
okay thank you :D
was already going to, but wanted to make sure it wasn't important
Using PHP is like equal to being a victim
has anyone thought of a full proof way to detect if a block doesn't have a block placer item?
i tried making an item stack from the block with its id and detecting if the localization keys are the same.. but with custom blocks it seems like they are always different and for vanilla things they are the same ๐ฟ
Is there a reason to differentiate?
a use case that i thought of is having different animations on an entity based on if they are holding a block or a block placer item
since block placer items are normally a 2d icon and not a full block
ยฟthere's any script that makes that an entity move towards the current front direction like this thunder?
can anyone help me?? I have a problem where when using beforeEvents.itemUse it actually works with my function, but other items like bundle cause errors.
like this that i can use bundle in vanilla
import * as mc from "@minecraft/server";
mc.world.beforeEvents.itemUse.subscribe((eventData) => {
const { itemStack , source: player} = eventData;
const isBlocked = (itemStack.typeId === "test:magic_bundle")
if (isBlocked){
eventData.cancel = true;
mc.system.run(() => {
let score = itemStack.getComponent("test:abc").customComponentParameters.params.value
player.sendMessage(score)
})
}
});
Entity#applyImpulse
like this sample or something?
I was looking at the examples of the documentation and theyre outdated ๐ค were we have to report it?
Kinda? That sample is in Typescript tho
I'm gonna mess with the hunger component sometime in the near future, but I'm curious to know now; is the hunger value a float number like health value, or is it just an integer number?
Should be float
That's perfect, thanks
._.
So 3.14527 is a valid health? @warm mason
yeah
Damn
Why not use dynamic properties
I'm currently experiencing this, same as entityItemDrop.
It says, value is not Iteratable.
Known issue.
is there a camerashake method?
No.
This thing tends to just shit itself after a couple tries for some reason, saying it failed to place with permutation laser
that and the function not resetting at all unless I do clearjob
uhhhhh waddafak
okay so apparently its not returning the actual values its supposed to return
its just returning int
idfk how
I don't understand this at all
ok so basically what I am trying to do is find out when i place a the block and look for how many other of the same block is behind it and wheather it is a multiple of 256, 128, 64, 32, 16, 8, 4, or 2
and setting its state to that
the part after the permutationToPlace bit is fine
probably should've omitted that
where is it getting stuck?
When I try to set the permutation being placed
The function isn't returning any of the values it's supposed to return
Instead it's just incrementing by one every time I place the block
Well I'm not sure what exactly this is trying to do
And then failing unless I've placed 1, 2, 4, 8, 16, 32, 64, 128, 256 of the blocks
If the distance from the farthest like block can be evenly divided by either of those numbers it will return that number
You're trying to use these as thresholds?
What is the block state "cmd:laser" defined as? You are setting it to the value of the handler for a job; this is a rather opaque value that should not be interpreted in any meaningful way like this, and I highly doubt you've intended to use it for a block state value
aren't block states also still very limited? you can only have 16 different states
The block states are 1, 2, 4, 8, 16, 32, 64, 128, and 256
but it's only returning one of these numbers supposedly
So really there's only 9 states
should probably just give it a "default" and just do an else return 1 instead
then see where where the logic is breaking
anything % 1 is 0
When I tried to put the function into the permutationToPlace it would add onto the value of the previously placed block
That's basically the default
And the starting value would never reset back to 1
I might just try to put it into a for loop
It just visually looks very weird to me, I don't think I would ever handle counting the length of blocks in a row like this
I'm probably missing something
No matter if I call the function with 1 as the int value
I'm trying to think of ways to fix this without entirely rewriting it
I do have a version of script that does work
But it takes increasingly long the farther out you go
And uses setPermutation instead of setting the permutation to be placed
Whats the issue?
I can't read
So this laser block has a block state, 'cmd:laser', which should be equal to whatever multiple of a power of 2 you defined. Is it looking for another block of its ID that is facing the same way? And should this be assigned the instant you place this laser block?
Yes it's looking for laser blocks facing the same way, and should be instant or as close to it as possible
I think I'm going to try if I can use a for loop in a generator function
Let's talk code; does this look like something you were trying to implement?
- Given its "minecraft:block_face", pick the opposite direction.
- Look for blocks at powers of 2 in this opposite direction for another laser block facing the same way, acquiring its distance if it matches, defaulting to 1
- Assign this distance to the state "cmd:laser"
- Set the block behind this block's state "cmd:capped" to false
I'm not sure you really want to be using a generator here. You're combining something that is deliberately asynchronous with something you need to happen synchronously
Plus generator + job semantics are unwieldy
I hope you don't mind me using bit shifting, it made writing a while-loop for this rather straightforward
I do not understand bit shifting in the slightest ๐ญ
what the helly do you guys do
Here is what I did ๐ญ
const permutationToPlace = e.permutationToPlace;
const block = e.block;
const blockId = permutationToPlace.type.id;
const face = permutationToPlace.getState('minecraft:block_face');
let checkDirection;
switch(face){
case 'west':
checkDirection = {x: 1, y: 0, z: 0}
break;
case 'east':
checkDirection = {x: -1, y: 0, z: 0}
break;
case 'north':
checkDirection = {x: 0, y: 0, z: 1}
break;
case 'south':
checkDirection = {x: 0, y: 0, z: -1}
break;
case 'down':
checkDirection = {x: 0, y: 1, z: 0}
break;
case 'up':
checkDirection = {x: 0, y: -1, z: 0}
break;
default:
checkDirection = {x: 0, y: 0, z: 0}
break;
}
let count = 0;
for(let i = 1; i <= 256; i++) {
const nextBlock = block.offset({
x: checkDirection.x * i,
y: checkDirection.y * i,
z: checkDirection.z * i
});
if(nextBlock.typeId !== blockId || nextBlock.permutation.getState("minecraft:block_face") !== face) {
break;
}
count++;
}
if(count % 256 == 0) count = 256
else if(count % 128 == 0) count = 128
else if(count % 64 == 0) count = 64
else if(count % 32 == 0) count = 32
else if(count % 16 == 0) count = 16
else if(count % 8 == 0) count = 8
else if(count % 4 == 0) count = 4
else if(count % 2 == 0) count = 2
else if(count % 1 == 0) count = 1```
Bit shifting (left and right) is a convenient way to represent powers of 2 when writing out code. It takes a numerical value in binary, then "shifts" its values either left or right.
// 2^1
> (1 << 1)
2
> (1 << 1).toString(2)
'10'
// 2^2
> (1 << 2)
4
> (1 << 2).toString(2)
'100'
// 2^3
> (1 << 3)
8
> (1 << 3).toString(2)
'1000'
// 2^4
> (1 << 4)
16
> (1 << 4).toString(2)
'10000'
So in the while-loop I wrote, we're starting at 256 (1 << 8), then we're shifting the bit down by one on each iteration, going to 128, 64, 32, 16, 8, 4, 2, and ending at 1
I see
I'm not entirely certain, but I think yours is closer to what Rem is looking for. Mine just checks those 8 specific offsets and returns 1 otherwise; yours will scan the entire length of blocks along that offset
I'm looking for that
Like as you place the blocks down they should start to look like a rule
Well at least an imperial ruler
const permutationToPlace = e.permutationToPlace;
const block = e.block;
const blockId = permutationToPlace.type.id;
const face = permutationToPlace.getState('minecraft:block_face');
// O(1) lookup instead of switch statement
const directions = {
west: { x: 1, y: 0, z: 0 },
east: { x: -1, y: 0, z: 0 },
north: { x: 0, y: 0, z: 1 },
south: { x: 0, y: 0, z: -1 },
down: { x: 0, y: 1, z: 0 },
up: { x: 0, y: -1, z: 0 }
};
const dir = directions[face];
if (!dir) return;
// Start from current position (avoids object creation in loop)
let x = block.x;
let y = block.y;
let z = block.z;
let count = 0;
// Linear scan up to a hard cap (256 โ effectively constant time O(1))
for (let i = 1; i <= 256; i++) {
x += dir.x;
y += dir.y;
z += dir.z;
const nextBlock = block.dimension.getBlock({ x, y, z });
// Stop when block type or orientation changes
if (
nextBlock.typeId !== blockId ||
nextBlock.permutation.getState("minecraft:block_face") !== face
) break;
count++;
}
// Convert count to nearest lower power of 2 (O(1) math instead of branching chain)
count = Math.max(1, 1 << Math.floor(Math.log2(count)));
I think yours is better? It would just default to the next value Rem is looking for vs checking all of the blocks. There's really no need to check every single block in the row if you only need to check those markers.
What if there is a gap
not a very good laser then
Think VisualImpact struck the nail here
wtf! he STOLE both of our versions and combined them!
Although should the loop stop when it doesn't find another laser block immediately? Or should it continue searching until it reaches one?
I assumed this was traversing something like air until it found another laser facing the same way
Based on what Rem said, it should just keep going?
I thought it was all just supposed to be one connected line then stop as soon as it didn't find anything
Easy enough to account for, simply reverse the logic of the if condition within the loop.
if (nextBlock.typeId === blockId && nextBlock.permutation.getState('minecraft:block_face') === face) break;
Great usage of floor(log2(count)) by the way, I was about to propose that
Also is there any way to figure out the world simulation distance other than trial and error
๐คท I was not able to work out a better solution than that
try catch it is
You have some other options; check if the chunk is loaded, or use API calls that don't error when accessing unloaded chunks first and check if they returned anything meaningful
create ticking areas along the entire predicted length of the laser
you no longer care ๐ฟ
Nothing bad will happen trust me
๐ญ
Meow
There should a method in JavaScript for getting a binary value of a number
The if/else statements with 256 is using binary.
Binary 11111111 is = to 256
number.toString(2) (from 256 to 11111111) and parseInt('11111111', 2) (from 11111111 to 256) iirc
11111111 is actually 255, my bad
@cinder shadow
My attitude towards you = love @warm mason
๐ฟ ๐
Crazy that you know binary @warm mason
Or how to utilize it in js
Who can answer what the binary for 2
10
Hey sorry for the days later re-ask but what is "ChunksToFillRequest[]" meant to be? Is it meant to be an array? I've got my code working thanks to this but this part has bothered me as I never ended up using this exact system, just something like it, so never figured it out
It could be an array of objects
[{x1: 35, x2: 55}, โฆ]
An example of an object in an array
as far as I can see, ChunkFiller is a class that is supposed to fill chunks, so chunks in this array are the chunks, that the filler will fill
Devils nightmare and you are for sure right, no clue why I didn't click that before hand ๐ญ
oh?
I edited it
Im not saying the methods inside the object are right but [{}, {}] is an array of 2 empty objects
This wasn't my code ๐ญ
@tidal wasp for you lol
Dw I used this and modified it a bit but thanks
Here^
Just put num.toString(2) to get the value i think you wanted to return.@tidal wasp credit:@serty.name
1 will return 00000001
3 will return 00000011
7 will return 00000111
A bit holds a value 0-255
@tidal wasp
Yes
And 0 counts as a number
Yea
ยฟis written correctly?
ยฟand thereยดs a script component for entities with properties?
youre on .js, the typing is a bit different compared to .ts
This is JSON entity events stuff, it's limited to doing queue commands, component groups, or setting properties. Not a crazy one like the Script API could do.
i recently downloaded Bedrock Debugger. and i don't know how to make it work into the minecraft Bedrock files
The files folders are made here
Read the description, and the articles of the urls
You can google things
i did it, ยฟwhat i have to do now?
Is it possible to place a chest with a custom name?
Like, I can rename a chest in an anvil and it will have that name in the container
Is that possible with scripting?
There isn't a way to place an ItemStack block into an actual block for now. You may not be able to place a chest, but you can definitely dispense a renamed shulker box (via Dispenser), then relocate that block to your wanted location.
Wait, were dispensers able to place shulker boxes?
Powder Snow, Water/Lava bucket, Shulkerboxes, and various things... can be dispensed by dispenser
i have discovered a horror
canceling damage doesnt cancel mob aggression
mob effects inflicted by attacking also dont cancel
well ofc
its only cancelling damage
doesnt cancel kb either
damage sensors are just the way to go
unless ur damage logic is complex
oh my damage logic is beyond terror, trust me
but it does cancel knockback
does cancel knockback
doesnt stop knockbaxk
it was fixed a few versions ago
@shy leafu adding to sweep n slash
just exploring stuff
ah ok
You gotta put it on a quotation to act as one parameter
/lc hi hi makes it two parameters string and string even tho the required params is only one string, but /lc "hi hi" acts only as one string
Yea that is what I am trying to avoid, as I don't think people would know that and would find it annoying to use over normal chat
Tried it, doesn't work
@stray spoke here
You can't fix that actually, because the amount of parameters is fixed based on your command options
If your mandatoryParameters + optionalParameters only have 2 parameters for example, it only accepts 2
Yeaa
I am mostly gonna use chatSend with smth like !lc as command prefix, since I am already using chatSend for other things in the addons
That's still beta tho
I know but you can set the version as "beta" Instead of specifying the number as in "v2.7.0-beta" and it'll default to whatever the beta version is
So no need to update it for every Minecraft upsa
Update*
Granted you do have to turn on beta apis
Yeah, in my experience, most addon users don't follow a note to turn on beta-api option first and complain the addon doesn't work
It's kinda hassle too
Just have to make that a note in the instructions when installing.
you can make the input seperated by underscores or some other special character then do .split()
so you do /localchat hi_hi
I am not in control of the input string is the thing, this is supposed to be a replacement for sending chat messages
right but you can make that the description of the command
only real solution honestly
I meann I can do it the old way too with chatSend and !lc prefix
sure but you wanted custom commands and no beta api no?
if I HAD to usse custom commands then ya I agree buuutt I am already using chatSend in other parts of the addon, might as well use it here too
yea thats alright then
also this removess the pain of updating the addon every minecraft update so it's not that bad
That's assuming that the API's you used from Beta didn't have any breaking changes related to your code. It's a misconception that using beta in your manifest will prevent that. It just simply tells the Application to use the latest beta available during runtime. It doesn't prevent breakage though. Still recommended to test between each update to be sure everything works as intended.
yep totally agree
I don't understand tho why is chatSend in the beta api and not stable? I thought it worked pretty well
Don't know if it's still the case now, but a long while back, couple of years at least, maybe longer, I used it to implement end-to-end encryption. In doing so people were having their accounts suspended or soft banned from Microsoft. Turned out Mojang was monitoring every message being sent, which I didn't personally know at the time. This led to some serious issues which I reported to the devs. Next thing I know, they stuck to it being beta, and a lot of the functions and properties were made to be read only. Been that way since. But like I said, I don't know if that is still the main reason as of today or not.
If you look, you can find where I reported it. I believe it was in the Bedrock OSS server though. Been a while lol.
They listen to the traffic by default. It was new to me when I learned about it lol.
People do not like to read, thats none of your bussiness anymore
You can make an entity with named inventory this way:
Summon entity via command: /summon furniture:fridge_upper_container tile.furniture:fridge_upper.name ~~~ then put tile.furniture:fridge_upper.name=Freezer in the lang file
Is there another way to put rotation too
Entity.setRotation?
No using this way
@distant tulip is it possible to change entities inventory from unknown to something else using script api ?
nametag
lang files+ nametag
why tf does the explosion beforeEvent not returning getImpactedBlocks It only give dim, cancel, source, and setImpactedBlocks which it doesnt make any sense
It extends the after event so yes, it does.
[Scripting][error]-ReferenceError: Native function [ExplosionAfterEvent::getImpactedBlocks] object bound to prototype does not exist. at <anonymous> (events.js:75)
BRUHHHHHHH
let { source, getImpactedBlocks } = data
thats why lol
Thats why destructuring is bad.
You can't destructure methods
hi guys
my pvp server
has a problem
where players fps drop over time
leaving and rejoining fixes it?
possible causes?
It seems to be a problem with a for loop on the player. @nova flame
Maybe a function on the player isnโt being canceled before rerunning the function, causing another loop and lag.
Anyone want to co-op gamble on baccarat with me in my world? Microsoft:
Bob8492710
Has anyone made a keypad device or lock and key that uses dynamic properties to lock something
Because that just feels underexplored imo
A lock and key is quite simple.
I was planing to make such a thing...
Man dynamic properties would so cool if you could attach them to blocks
well, I don't see any problems with it
make ur own block dps system
The bullshit id be pulling dould be unheard of
especially now, when they added onBreak event
I mean can't you just use your namespace + block.location + block.dimension
most of our stuff is built on top of bulshit workarounds
Hell you wouldn't even need the namespace
something like that, yeah
-# me rushing to add dimension id to a submitted project that used only block location as key after reading the chat
always add the dimension id you your location hashes it it's not exclusive to i single dimension
or a an integer representing it if you need to store a lot of hashes in a dynamic property and you are worried about hitting the size limit
I had the system built from the start for testing and totally forgot about the id afterword
which system?
Is getentities laggy at all when done multiple times one after the other? I'm making a shockwave effect and I need to getentities when my particle reaches them, which leads me to my second question, is there any good way to line those up, the particle and script as in, in terms of timing
it shouldnt be laggy on its own, although it still depends on how you do it
also for particle, i doubt it since those are client sided
your best bet is to use entities with particles
So I'm screwed in terms of doing that scripting side ๐ญ ughhhh
got it
what would be a case where it would lag if you can think of any examples?
functions that are generally heavyweight in client/server, imagine every entities in your simulation distance making particles
on every tick
I see
Well I'm fine there then, all I need to do is shake any players arounds screens and knockback the entities
Also I'm guessing I should go ask in #1067869022273667152 on how to do this?
Because I'm mostly a scripting person, I am very bad at the more json side of things ;w;
sure i guess, im not an entity person either so i cant help you with it here
Guessed so, well thank you for the help so far :D
is there a way to track the output item of a specific block in a playerInteractWithBlock event
so the item someone crafts in a crafting table for example
or the armor someone adds a trim to
in a system.runInterval() you loop through players and check for player.isJumping
I think that is the only way to do it
not sure though
Alright thanks
Right timing, im also on that page
Thanks
Nvm it's different
I thought its getButtonState
you must be in Player.inputInfo
that one is for getting which button the player is pressing
this one is an event that fires whenever a player presses key, should be more preferrable in your use case
Yes I think this might be it, however I'm new to this. Do I just detect if "button" return to "Jump" ,or do I add newButtonState
Okay I get it now
Thank you
newButtonState is just to detect if its pressed or released
world.afterEvents.playerButtonInput.subscribe(({ player }) => {
// go nuts here
}, { buttons: [ InputButton.Jump ], state: ButtonState.Pressed })
_ _
you can change buttonstate with whatever you want
omitting it will fire on both press and release
I think you got syntax error
When you use block.setType() or block.setPermutation(), how would one make this trigger a block update?
Looks like just setting it to air first and then the target permutation works fine.
Is there also detection for movements
I mean the direction of movement we used
Up, down, left, right
import { system, world } from "@minecraft/server";
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
const vel = player.getVelocity();
if (Math.abs(vel.x) > Math.abs(vel.z)) {
if (vel.x > 0) {
console.warn("Moving East");
} else {
console.warn("Moving West");
}
} else {
if (vel.z > 0) {
console.warn("Moving South");
} else {
console.warn("Moving North");
}
}
}
}, 1);
So there's no other way? Like an event or input
Another one you can try:
function getRelativeDirection(player) {
const vel = player.getVelocity();
const rot = player.getRotation(); // yaw
// Convert yaw to forward vector
const yawRad = (rot.y * Math.PI) / 180;
const forward = {
x: -Math.sin(yawRad),
z: Math.cos(yawRad),
};
// Dot product (forward/backward)
const dot =
vel.x * forward.x +
vel.z * forward.z;
// Perpendicular (left/right)
const right = {
x: forward.z,
z: -forward.x,
};
const side =
vel.x * right.x +
vel.z * right.z;
if (Math.abs(dot) > Math.abs(side)) {
return dot > 0 ? "forward" : "backward";
} else {
return side > 0 ? "right" : "left";
}
}
I made something, lesser code