#Script API General
1 messages Β· Page 99 of 1
includesMemory
const myMind = {
memories: new Array(2*9999999).fill('JS'),
findMemory(key = 'JS') {
return this.memories.includes(key) || console.log("404 JS Not Found?!??!?!");
}
};
myMind.findMemory("JS?");
no
i(personally) simply dont care about patterns of writing code. the first time i started writing something with nestjs i hated it
the idea of controllers and services piss me off
I think they are very useful
eewww no, the code gets too ruled by the framework
i like doing stuff my way
for me it would be namespaces with functions
i agree that its good when code gets lsrger
but hell no, the performance of nestjs is terrible
i mean how stuff are structured on the codebase
i like thinking on that
i dont like having something already pre-made for me
I need help!!
Can anyone write a script "if you write in the command /tag @s add lock_all body, the body and head will immediately be straight"
If you want people to do all the work for you then you would be in the wrong Discord server.
if only programming language is like that.
What!!, then where am I going?
Ironically, cobol is similar and it was crap because of it
Ofc javascript
more features definitely
it depends, mcfunctions can definitely be faster in some cases
#1396040869777379379 can someone help me
Mini-question that doesn't justify a post:
How can I translate the result of a command? It expects a string rather than a RawMessage.
@lone mango
const entitiesOnCustomBlock = new Set()
system.beforeEvents.startup.subscribe(init => {
init.blockComponentRegistry.registerCustomComponent('grb:regenerative_block', {
onStepOn: (event, params) => {
entitiesOnCustomBlock.add(event.entity)
},
onStepOff: (event, params) => {
if (entitiesOnCustomBlock.has(event.entity)) { entitiesOnCustomBlock.delete(event.entity) }
}
});
}
then you can just check
//pseudo-code
entitiesOnCustomBlock.has(entity)
or similar from your other function. if you need to check players etc just change the stuff in onStep from event.entity to event.entity.nameTag
is runInterval unique for every trigger in customComponents?
ohhh I thought it would be considered global and all blocks would have the same interval
for example, I call this from within my runInterval in a custom block component trigger
function exitSystemLoop(player: Player, tool: ToolProperties, harvest_system: number) {
if (player) {
setPlayerBusy(player, false)
player.setProperty(tool.use_animation, false)
}
system.clearRun(harvest_system);
}
wait, example a plant growing has an interval of 20 ticks and I place each in different times would they have different times too?
when you create a system.runInterval it returns a unique ID as a number. each system is unique
I see thanks
yeah, they should if you code it that way
I should have assumed that, I ended up making a timer using the block's location.....
nope no need. the system gets added to the event queue within quickJS when it is created. all you need to do is provide a way for the system to stop without player input
thanks Laskod
this is how I do that..
init.blockComponentRegistry.registerCustomComponent('grb:regenerative_block', {
onPlayerInteract: (event, block_component) => {
harvestRegenerativeBlock(event, block_component)
}
});
then you can make sure the system is working with that specific block in the function
can actually get kinda crazy using blockstates and permutations too like I did lol.. so when my block gets harvested, it sets permuation which swaps out components. so then the other permutation gets different custom component events
I want two things in blocks rn. block dynamic prop and block entities.
oh clearRun
system.clearRun(harvest_system);
clearRun takes the unique number from when the system was created
system.clearRun(interval)
js
const harvest_system = system.runInterval(() => {
That's why I love storing those in maps...
but they're useless once the world was reloaded or /reload
you dont even need to tbh. just declare it outside of the system's scope. it'll get copied, not referenced, so when the const drops it is still valid
that's not my purpose tho lmao
ahh
purpose is glorious
anyways thanks it's workign fine now
look at this horrendous crap
should have used interval
nice
hey if it does what you want and it works /shrug
I will, in the future
is there a way to remove dynamic property of an entity
how do you use EntityApplyDamageOptions on applyDamage()?
have you tried setting it to undefined? does it remove it?
i dont really know but i'd try that
the damage options is used like an object
like this
entity.applyDamage( 5, {cause: EntityDamageCause.entityAttack, damagingEntity: player} )
set it to undefined or just leave blank
player.setDynamicProperty("prop_name")
alright thanks
that deletes it or can you still access it?
alright
for readability / clarity though probably better to say
("prop_name", undefined)
so that there is never a question that the intention was to remove it
both are slow
is it possible to stop a player from attacking? like inputpermission
setting to undefined actually doesn't delete the key. you have to set to null and the key will be removed. giving no parameters/leaving it blank also works aswell and deletes the key.
good to know, thanks. appologies for speaking on that incorrectly, I guess I was doing it wrong too π
no problem
-# bruh i kinda feel weird on apologies
apologies for interrupting
lol all good
ergh. custom commands beta-only?
docs say 2.0.0-beta but since current stable is 2.0.0 assumed it would be there and the docs were out of date
you can't use instances like that...
you should use a hashmap
used Set to avoid duplicates in that example since they only cared about checking if something was on the block. they were asking about it in the blocks channel
oh guys interstingly the VSCode official site has a new design
do you know how comparing class instances are working?
even if it's the same entity, this won't work
thinking about it now I see your point, especially considering that everything would just be Object in the end
yeah, it's better to use hashmap in this case
or just entity's identifier
yeah. my bad. barely any sleep the past few days due to new meds, just threw that together in like 10 sec
const entitiesOnCustomBlock = new Set()
system.beforeEvents.startup.subscribe(init => {
init.blockComponentRegistry.registerCustomComponent('grb:regenerative_block', {
onStepOn: (event, params) => {
entitiesOnCustomBlock.add(event.entity.id)
},
onStepOff: (event, params) => {
if (entitiesOnCustomBlock.has(event.entity.id)) { entitiesOnCustomBlock.delete(event.entity.id) }
}
});
}
this is probably the easiest way to get it working correct
no problem, just fixing a small issue
that was actually my first idea but docs for id say they are basically worthless but probably am just interpreting what it means incorrectly
I do understand what that would mean in an ECS context though, so thanks for correcting
for WorldSoundOptions what's the max volume?
i think its a range between 0 and 1
so any values higher than one will be clamped to 1
I see
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]
how do i return the face of a block a projectile hits?
This server is for those who want to learn how to make Add-ons, not for the self-entitled to be spoon-fed all the answers.
This discord isn't suited for finding or offering paid work. We can't moderate these transactions, so we ask that you move to a more suitable place.
For a casual discord community, consider joining Skill Share: https://discord.gg/sZ7fkcN.
Find incredible people. Make beautiful things. A home for crafting your career in the Minecraft industry.
hmm
guys
like its beeen like a year i\ve been learning script api
but
i've learned a lot of methods but still not having practice of where to use them/when to use them
like i code in a simpler way which works but i want to code like those proffesionals
day 1 learning script
mining / woodcutting so far π
nice bro
i need more knowledge
same i ask questions but majority of the time i figure it out myself
code more
How...
Check or error OR check if the file is even getting "executen"
theres no error and the file is getting executeed
Then it should work
Check if sour console is even enabled.
Or debug inside of the startUp event with some console.log
its enabled
use ai
i suggest cancelling it whenever your not looking at the block
It has other cancel conditions just didn't show them. For example switching tools, moving, or getting hit
But looking at the block doesn't effect anything. Once you click it you'll harvest that one even if you are not looking at it
that's good but thats just a recommendation
I just don't see it as necessary since it doesn't effect anything and vision check is a bit expensive
wdym expensive?
Costly enough to calculate with quickJS for me to not consider it
oh okay up to u
Which one β’ββ’
The neko ai ;-;
Hello, after a long period of not touching Minecraft, I decided to continue with an addon where I was using a script.
But I noticed that functions like beforeEvents and others have disappeared.
Do you know what they were replaced with?
before events still exist, which specific ones aren't working for you?
what's World.broadcastClientMessage() even for?
world.beforeEvents.chatSend.subscribe((eventData) => {
const player = eventData.sender;
if (!player.hasTag('OP')) return;
switch (eventData.message) {
case '!start':
eventData.cancel = true;
...
break;
default: break;
}
});
That still the same
Make sure you are using beta API
Ok, I'll try again.
system.runInterval(() => {
(async () => {
await world.getDimension("overworld").runCommandAsync("function roles");
await world.getDimension("overworld").runCommandAsync("function compass");
await world.getDimension("overworld").runCommandAsync("function clear");
await world.getDimension("overworld").runCommandAsync("function triforce");
await world.getDimension("overworld").runCommandAsync("function bottespegase");
})();
}, 0);
I now have a new problem on this part of the code
Line 104: await world.getDimension("overworld").runCommandAsync("function roles");
Line 109: })();
I found that
"runCommandAsync" no longer exists, and I had to add "runCommand"
I love you for telling me that it exists
Please... Please define dimension as a const.. please
Lol, this was my first project that I did a long time ago, that I'm going to modernize and update
Thengs
Can someone tell me how to make it so a button shows up in a gui if you have a tag
You mean in an ActionFormData?
Yeah
if (player.hasTag('tag') { ui.button('button') }
Thanks
So I'm guessing I put that where the button usually would go?
yep
Yep

:/
Cool I appreciate it
just happened to say the same version of yes lol
np
Yep thats insane
Yep, it is, indeed
Ja, Hai, Tak
my code doesnt work when the nezukofeu was at 1 it didnt get on fire
for(let player of world.getPlayers()){
const nezukofeu = world.scoreboard.getObjective('nezukofeu2').getScore(player.scoreboardIdentity) == 1
if (nezukofeu === 1) {
player.setOnFire(200)
}}```
for(let player of world.getPlayers()){
const nezukofeu = world.scoreboard.getObjective('nezukofeu2').getScore(player.scoreboardIdentity);
// removed == 1 at .getScore(player.scoreboardIdentity)
if (nezukofeu === 1) {
player.setOnFire(200)
}
}
If it still doesnt works, ensure that the value nezukofeu is 1, by using console.log (or warn) to display it
thanks i will try that
Where the hell is )?!?!?!?!?
how dare I make a mistake like this???!?!?!
im so sorry!
is it possible to save a local db without an exteral app?
Hi
How do you identify the player speed with a script, like query.modified_move_speed?
function getSpeed(velocity) {
return Math.sqrt(velocity.x**2 + velocity.y**2 + velocity.z**2)
}
const speed = getSpeed(entity.getVelocity())
I also want to be called incredible
Fun fact: Math.hypot exists too!
(this could work with a Vector2 or VectorXZ as well)
function getSpeed(velocity) {
return Math.hypot(Object.values(velocity));
}
const speed = getSpeed(entity.getVelocity());
ts annoys me so much.
What about it?
Confused what typescript has to do with anything.
I'm kinda stupid at math or common sense can you help me? Wait lemme draw it.
I'm not a math or vector expert, so I'm not too certain I have an answer either
here, imagine the small box as spawn point of the arrow, the spawn point can be in any position there's no fix place.
and the big box is players head and the line is the view direction or line of sight or cursor of the player
what I want is it to travel in the direction of the player is looking ending at the cursor...
Frck I'm so bad at explaining π
First you'd want to establish where that end point is. You have a direction, but given that the arrow isn't collinear with that direction, you need a point along that line to fire the arrow at
I'd probably cast two rays, one for entities and one for blocks, then determine the location of where it struck. If it found nothing, then I'd do a fixed offset in that direction, maybe 5 blocks.
max 20 I guess? I did this, but when it reached the target point it starts to drip off I want it to keep going the direction.
the start of the particle here is the target point as the arrow reached past that it drift away
And there's no gravity or uncertainty bias on the arrow itself?
yes, just pure move.
I know how to move it to the end point for example in this image, that's fairly easy but making it go to the player's view direction after that isn't easy for me or I'm just slow as hell lol
Hm, I'm not sure. It otherwise seems accurate. And it looks like you're basically doing what I recommended
Hmm, I might just make the distance long. Just need to take account that having long distance make it easy to go in unloaded chunk.
Like Precedural spider following a dot?
hah?
I mean, huh?
hmm... Ignore this now.
Just gonna do this.
Oof
-# my common sense don't exist rn
watcha tryna do coddy?
projectile shoot system.
but without usings players head as starting point of spawn
I know a great guy whose always available to help with math
I found a perfect example on what I'm trying to do lol
what about raytracing?
this is very easy to do if there's block as target but if there isn't I need to set a fixed value.
ohhh I see
especially if they're looking at the air lol
basically no getViewDirection?
π¦
-# who?
you still need those for end point of it. head + view * distance
Object.fromEntries(Object.entries(head).map(([a, v]) => [a, v + (view[a] ?? 0) * distance]));
chatGPT π
πββοΈ
why do you not need the head as starting point here?
ok imagine the hands or chest is the starting point of the arrow spawning... I need to make it travel to go my cursor. How? We need two ways the blocks and the no blocks, the blocks way is easy as 123, I just need to get the face location my ray hit and use that as target location otherwise we do non blocks wya if theres no block was hit in the ray, to do that we need to get players head add with view direction multiply the distance and that's the new target point if there's no block found in ray.
Gets?
You can use the same thing with no block, you can just take any point of the ray, just add view direction head location and you get a dummy block location
add(head, view * distance) if air...
hows this not working right?
it does work.
oh you already had the solution
I thought there were more limitation
yep
Yeah, i forgot about the distance
Maybe use the use duration there
the arrow ain't gonna perfectly go to the location since it's a projectile and it'll hit the first pos it hit since it has collision but you get the point.
it hits the same spot
-# I'm using the pig's head location as arrow's spawn locations.
Yes.
the function I made to fix the face location
I'm kinda silly, I'll be making bouncy π
more rays... fvk.
I think he means "this" nit "typescript"
How to make auto inventory addon
what...
Ohh "this sh*t"
Yo does someone know why the bossbar still shows "unknown" even after changing the name tag via script?
If i leave the world and join back, it works
Or maybe someone could suggest a workaround like forcing the game to update the entity
can the movement and arrow make like natural?
yes but I chose not to.
it's "this shyt" lol... I'm lazy to put whole world especially my phone is always closing my keyboard. I have lil bug
Ah i see
why you asked btw?
When mining blocks, items will be added directly to inventory.
can i use the equippable component to set & get the mainhand item of an entity
@sharp elbow says no
Dang, alr thanks. Is there any other ways to get it via scripting?
AFAIK, no
I thought that's what you were asking initially, haha
With the "minecraft:equippable" component on an entity, you can still set items with commands like /replaceitem, and read them with the 'hasitem' selector argument
But scripting does not really have a good way to access equipment on a mobβand I suspect it won't for a while
i did mean in scripting lol
that sucks tho, thanks for the help regarless
use blockbreak afterevent after a block is broken take it's location, getEntities on it then check if the corresponding item to the block is present then remove that item and add that item to the player's inventory
/**
* @description Encodes a range of characters from a string into a byte array.
* @param { String } s
* @param { Number } charIndex
* @param { Number } charCount
* @param { ArrayBuffer } bytes
* @param { Number } byteIndex
* @returns { Number } The number of bytes that were successfully encoded.
*/
function getBytes(s, charIndex, charCount, bytes, byteIndex) {
if (typeof s !== "string")
throw new TypeError("Parameter s is not a string!");
if (typeof charIndex !== "number")
throw new TypeError("Parameter charIndex is not a number!");
if (typeof charCount !== "number")
throw new TypeError("Parameter charCount is not a number!");
if (!(bytes instanceof ArrayBuffer))
throw new TypeError("Parameter bytes is not an instance of ArrayBuffer!");
if (typeof byteIndex !== "number")
throw new TypeError("Parameter byteIndex is not a number!");
if (s.length - charIndex < charCount)
throw new RangeError("Argument out of range!", { cause: "s" });
if (byteIndex > bytes.byteLength)
throw new RangeError(
"Byte Index must be less than or equal to bytes.byteLength!",
{ cause: "byteIndex" }
);
charCount = Math.min(charCount, s.length);
let bytesEncoded = 0;
for (let i = charIndex; i < charIndex + charCount; i++) {
const charCode = s.charCodeAt(i);
if (charCode <= 0x7f) {
// 0XXX XXXX 1 byte
bytes[byteIndex++] = charCode;
bytesEncoded++;
} else if (charCode <= 0x7ff) {
// 110X XXXX 2 bytes
bytes[byteIndex++] = 0xc0 | (charCode >> 6);
bytes[byteIndex++] = 0x80 | (charCode & 0x3f);
bytesEncoded += 2;
} else if (charCode <= 0xffff) {
// 1110 XXXX 3 bytes
bytes[byteIndex++] = 0xe0 | (charCode >> 12);
bytes[byteIndex++] = 0x80 | ((charCode >> 6) & 0x3f);
bytes[byteIndex++] = 0x80 | (charCode & 0x3f);
bytesEncoded += 3;
}
}
return bytesEncoded;
}
/**
* @description Decodes a range of bytes from a byte array into a string.
* @param { ArrayBuffer } bytes
* @param { Number } byteIndex
* @param { Number } count
* @returns { String } The decoded string.
*/
function getString(bytes, index, count) {
if (!(bytes instanceof ArrayBuffer))
throw new TypeError("Parameter bytes is not an instance of ArrayBuffer!");
if (typeof index !== "number")
throw new TypeError("Parameter index is not a number!");
if (typeof count !== "number")
throw new TypeError("Parameter count is not a number!");
if (bytes.byteLength - index < count)
throw new RangeError("Argument out of range!");
var string = "";
while (index < count) {
const byte = bytes[index++];
if ((byte & 0x80) === 0) {
string = string.concat(String.fromCharCode(byte));
} else if ((byte & 0xe0) == 0xc0) {
const byte2 = bytes[index++];
string = string.concat(String.fromCharCode(((byte & 0x1f) << 6) | (byte2 & 0x3f)));
} else if ((byte & 0xf0) == 0xe0) {
const byte2 = bytes[index++];
const byte3 = bytes[index++];
string = string.concat(
String.fromCharCode(
((byte & 0x0f) << 12) | ((byte2 & 0x3f) << 6) | (byte3 & 0x3f)
)
);
} else if ((byte & 0xf8) == 0xf0) {
const byte2 = bytes[index++];
const byte3 = bytes[index++];
const byte4 = bytes[index++];
string = string.concat(
String.fromCharCode(
((byte & 0x0f) << 18) |
((byte2 & 0x3f) << 12) |
((byte3 & 0x3f) << 6) |
(byte4 & 0x3f)
)
);
}
}
return string;
}
/**
* @description Calculates the maximum number of bytes produced by encoding the specified number of characters.
* @param { Number } charCount
* @returns { Number } The maximum possible number of bytes required to encode.
*/
function getMaxByteCount(charCount) {
const num1 = charCount + 1;
const num2 = num1 * 3;
return num2;
}
export { getBytes, getString, getMaxByteCount };
Utf8 BABYYYY.
Entity that is not a player?
why are you still writing in JS for things like this
yeh
if you could move to TS it would take much less code
Because. I don't want to use TS
are you a masochist at this point?
?
yes.
technically you should be able to get these slots
Provides access to a mob's equipment slots.
or just write a simple script and test it on your own
Your point being?
i tried and it didnt work sadly
import { world, ItemStack } from "@minecraft/server"
world.afterEvents.worldLoad.subscribe(() => {
const dimension = world.getDimension("overworld")
const entity = dimension.spawnEntity("minecraft:zombie", {
x: 0,
y: 60,
z: 0
})
const equippableComponent = entity.getComponent("equippable")
if (equippableComponent) {
equippableComponent.setEquipment("Mainhand", new ItemStack("minecraft:stick", 1))
}
})
Ok
telling you that this project after 4k of lines will be taking much longer to move on due to your plain JavaScript
And idc. I will stick with JS.
masochist.
If it was gonna be over 4k I wouldn't even bother with JS or TS at this point
hey man, if he wants to stick with JS let him be. He can code however he wants
typescript may have more advantadges but we cant just force it upon people
wooo. some fixes and now I can encode multiple types of data into a byte array
I don't get a point of using plain JS in projects
TypeScript has much more benefits
the only worse thing is longer development time
but then you save this time on caching typing bugs in IDE instead on testing (in-game/Node etc.)
this conversation again
Now lets hope that this is compatible with C#
you can't setEqupment somehow it is mostly limited though
that's why I use commands to set it...
/replaceitem?
yes
my only reaction to the previous topic: 
It ain't my fault
it's not that hard actually
the ram is literally a byte array
import { world } from "@minecraft/server";
const frozenPlayers = new Map();
world.beforeEvents.tick.subscribe(() => {
for (const player of world.getPlayers()) {
const hasTag = player.getTags().includes("tegak");
if (hasTag) {
const currentPos = player.location;
const rotation = player.getRotation();
if (!frozenPlayers.has(player.id)) {
frozenPlayers.set(player.id, {
pos: currentPos,
rot: rotation
});
}
const data = frozenPlayers.get(player.id);
// Kunci posisi dan arah
player.teleport(data.pos, {
rotation: data.rot,
facingLocation: null
});
// Hentikan gerakan
player.velocity = { x: 0, y: 0, z: 0 };
player.runCommand("effect @s clear");
} else {
frozenPlayers.delete(player.id);
}
}
});
By the way, does this work?
you are just recriating what the ram is
it could be very simpler if you could just cast data
Whose message are you responding to?
this
its because bro is implementinf binary serialization
Oh
the unique way i can think of is testing it
What?
programmers don't know if a code works or not just by looking at it
you gotta test it
Oke
yeah in a low level language. A goddamn scripted language is hard af when you don't have access to pointers
and well the other stuff like unsafe casting
i really pretend making a minecraft copy game and write the api on a custom language so i can enable low level stuff
seriously it just sucks not being able to do lwo level stuff
fr tho, i am not defining every freaking type and all that stuff in a personal project.
The only case i use ts is when working with someone that uses it.
no
can anyone tell me why the one on the left is going up but not the one on the right
what's wrong,What is wrong?
so i have 2 questions
one is i can convert a string to a number bu doing parseFloat(string)?
tick event does not exist. Use system.runInterval
const num = Number('123.232');
and second why do i get an error from this p.setDymanicProperty("money", currentMoney - amountToTransfer)
saying its not a function
show code
dymanic ._.
not a function line 5
source.dAmAgInGEntity ;-;
thx
what is this.... gives me nightmare
then dont read it ;-;
π₯°
Yeahhh love JS
wdym?
oh hey you got your account back?
i got said you left Discord
and you deleted your acc
i just left discord for a while
ah
nvm i got it
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
hmm
How can I run a cooldown when interacting with a block
someone know how to get the best piece of armor a player have on without using a lot of if?
assign all armor types a number and make it pick the highest one they have
no like if i have an netherite helmet and all the rest gold
how do i give the player the tag "netherite" without checking every armor slot
either way you have to scan every armor slot to know where the highest armour piece is
there's no avoiding that
Is there a way to check if a player has "operator command" permissions?
player.playerPermissionLevel
player.commandPermissionLevel >= CommandPermissionLevel.GameDirectors
commandPermissionLevel*
No
whatever
playerPermissionLevel returns visitor, member, op or custom
your choice for whatever you wanna use
Ah, I thought playerPermissionLevel didn't exist at all. In any case, commandPermissionLevel is better for this.
Depends on their use case
Well, he wants to know if a player can execute operator commands, commandPermissionLevel is better suited for this
Sure
Thanks
is there a way to test it a used item was actually a useable item in item use and not everything
Maybe you can check if it has food component (don't work vanilla item), cool down and potion components?
Just that?
Hello I'm back just to ask if you want another tag to be required I'm guessing you just add another
if (player.hasTag('tag')
if (player.hasTag("tag1") && player.hasTag("tag2"))```
like that
Does anyone here like actively use "/scoreboard" on the sidebar?
bro does not know js π
strong hater right here
and you expect all people to know js? Krazy mindset then
joke or not the way you said it sounds offensive.
y?
Cause I made this shit but it uses scoreboards.json since I still wanted to use title, subtitle, and actionbar but I was curious if people did use this if they'd be upset about it taking over scoreboards
bro don't know c++
I didn't realise the bossbar looked so jittery in the video rip
Is that bossbar thing unique to every player?
No.. since it uses scoreboard it's a global one
Yeah I forgot about that
You'd need a custom bds if you wanted it client-sided
just use entity and use the bossbar component π€·ββοΈ
entity has a range cap
even if you set the range to like 2,000,000,000 it still disappears once the entity becomes unrendered to the player
uh tp to player.
but if you're trying to display it on multiple players then what? you'd need a ton of entities
chat can be used two, with a global message
"two" π₯
fuck
tow two and too get mixed in brain
lets say you're displaying a timer.. you would need to update it every second meaning a new message is sent each time and if you have something like a speedrun timer on there then it's a new message every millisecond..
hide them
it's still sent though..?
You can hide them...
So it doesn't cause FPS/Hardware problems on devices like mobile if it's hidden both on the hud and in the chat screen?
I always got told it did due to the amount of messages being sent in a given time and after so many messages are sent they still continue'd to build up
also, you can't send messages every millisecond
I have low end device and I don't have any lag or fps drop.
you know what i mean.. every tick :/
I meant by low, it's literally low lol
I guess I'll move it to that then..
the only con is that the messages that can be displayed are limited, and even if you are hiding them they still count, so other messages just get dismissed
Been awhile since I touched json UI... I'll be back with it I guess
Is their a difference creating a ui with modalformdata and json ui?
modalform is json ui
json ui is mostly design,
formdata is the functionality
Huh. I guess i have something new to learn to use with my ui
coudnt be more stupid
the black one is using the getBlockFromRay() while the red one is using playerInteractWithBlock().
The FVKIN red is placed properly in players view but the blac is offsetted.
its diff from -1 -1, -1 1, 1 1, 1 -1
what?
i mean the quadrants
if using getBlockFromRay?
interact, havent tested the ray tho
its fine as long as its not illegal ;-;
I can just change/adjust the function but why they're different ππ
like dude.
why are you calculating all positions and then just returning one?
are you talking about the function? If yes I'm too lazy to explain.
idc about that rn, that's my problem rn.
you mean the message above? that you will show something stupid
a simple switch statement or else if chain would be better performance wise
THAT'S NOT THE PROBLEM.
I understand that thats not the main issue lmao
If you have time maybe you can tell me the quadrants lol
You are the problem.
-# jk
uhehehe~
who needs if or switch statements if you can have array
[
// Button: Tower
(player: Player) => {},
// Button: Modules
(player: Player) => {},
][response.selection as number]?.(player);
i dont even wana
wtf bruh ππ
const b = e.block, f = e.faceLocation;
const loc = {
x:b.x + f.x,
y:b.y + f.y,
z:b.z + f.z
}
spawnParticle(e.block.dimension, await loc)
why await loc ?
I dont really understand, sorry
I mean await and a vector object
it took me 20 mins to fix that stupid face location and discovered that face location returns different in getBlockFromRay and in playerInteractWithBlock block or other shyts
just use this for the getBlockFromRay one
function fixFaceLocation(location, faceLocation, face) {
switch (face) {
case "Up":
return { x: location.x + faceLocation.x, y: location.y + 1, z: location.z + faceLocation.z };
case "Down":
return { x: location.x + faceLocation.x, y: location.y, z: location.z + faceLocation.z };
case "East":
return { x: location.x + 1, y: location.y + faceLocation.y, z: location.z + faceLocation.z };
case "West":
return { x: location.x, y: location.y + faceLocation.y, z: location.z + faceLocation.z };
case "North":
return { x: location.x + faceLocation.x, y: location.y + faceLocation.y, z: location.z };
case "South":
return { x: location.x + faceLocation.x, y: location.y + faceLocation.y, z: location.z + 1 };
}
}
Did not know it, lol
But what does await on other values, why is it there
cus spawnParticle
ok thanks I'll try it later after contemplating my life.
ohhhhhhhhhhh I see
its like system.run but... smarter?
more cursed version of it
same as runCommand(await "say hello neko")
idk
But good to know
typescript would scream its illegal, but it works just fine, lmao
you never saw something even more curse from him (and me)
typescript always screams
I dont even use any of these
wait.. i just forgot to install the right npm
they removed runCommandAsync in the latest versions
JSON.stringify, but w/o the " on property_key
need it
i could only suggest con's
where is it
cant find it atm, unfortunately
-# altho i have le code
Love that
Oh sorry I never thanked you but thanks
np yw
french? "Le code" π₯
-# I'm done bruh.
I always been able tho...
I just realized my aim is so bad. I'm not good at fps games bruv
wat...
wat was the issue yesterday all about then?
Nothing, I just overthinked it lmao
Lmao
i can share this
https://github.com/RememberM9/MCBE_Addons/blob/main/KCraft_Security/scripts/utils.js#L159
it doesnt have the prototype chaining map tho ;-;
'twas just old dumps
your pfp looks like dormamu
-# I forgot the actual spelling...
got it from too much playing with this https://www.shadertoy.com/view/M33XDH
I even got to the point where human palm patterns got almost mimic'd ||accidentally||
Is there a website that list all the world events like after events and before events
Intro to ScriptAPI: https://aka.ms/startwithmcscript
Intro to Tests: https://docs.microsoft.com/en-us/minecraft/creator/documents/gametestgettingstarted
Official Docs: https://docs.microsoft.com/en-us/minecraft/creator/scriptapi
Community Docs: https://wiki.bedrock.dev/scripting/game-tests
Script API examples: https://github.com/JaylyDev/ScriptAPI
2021 Q&A: https://wiki.bedrock.dev/scripting/gametest-qna.html
2022 Q&A: https://wiki.bedrock.dev/scripting/scripting-editor-qna.html
use jalyly here or the ms docs
it's possible to make more than one parameters for scriptevent, right?
not sure off the top of my head, but wouldn't hurt to just try it if you can tbh. If it doesn't support it natively there are definitely ways to do it due to how JS treats Objects
wrong place but the Bridge discord is pretty dead and it isn't a "must know now" issue.. anyone know if there is hotkey combo for multi-line JSDoc in Bridge?
edit: nvm, should have assumed since pretty sure the backend is the same. it's shift + alt + a just like vscode
working on probably the most essential feature and in my opinion the most fun for my project... the banking system from runescape 2007. not using dyn properties so have to do a backend server. already have a prototype made in Go but probably going to swap to Deno so I can share the database cache structure
script event have a message parameter, use that an parse the input. e.g. /scriptevent id:name para1 para2 para3
multi line jsdoc? You mean editing multiple lines or what
nah just the hotkey to do the formatting for it.
/**
* Calculates the sum of two numbers.
* @param {number} a The first number.
* @param {number} b The second number.
* @returns {number} The sum of a and b.
*/
sigh lol was hoping I could get away with functions on prototypes, but guess not
no ```ts
skill_level: {
value: function (skill: string) {
return this[skill] as number
}
}
y...
waht the heck
because I want to clean up this stuff
export function getPlayerSkillLevel(player: Player, skill: string) {
return player[skill] as number
}
and be able to do just
player.skill_level(skill)
use prototype.
that was prototype
Object.defineProperties(Player.prototype, {
blockICD_c: {
value: Date.now(),
writable: true,
},
can_interact: {
get() {
if (this.blockICD_c > Date.now()) { return false; }
this.blockICD_c = Date.now() + 1000;
return true;
}
},
skill_level: {
value: function (skill: string) {
return this[skill] as number
}
}
})
oh i'm dumb.
Player.prototype.skill_level = function (skill: string) { return this[skill] as number }
still new to js/ts
ahh.. nope. still undefined π΅βπ«
thats getting, where's assigning?
declare module "@minecraft/server" {
interface Player {
can_interact: boolean;
skill_level(skill: string): number;
}
}
do u assign the skill anywhere?
yeah. it works otherwise, just trying to get the idea of
player.skill_level(skill) working. I have a different regular function that works fine
but it is specifically saying that
skill_level is not defined
is this code imported/initalized?
yes. can_interact works in the same function i'm trying to use skill_level from
if (!event.player.can_interact) { return; }
const player = event.player
const mainhand: ItemStack = getPlayerMainHand(player)
const block = block_component?.params as RegenerativeBlockProperties
if (!mainhand?.hasTag(block.required_tool_tag)) { return; }
const tool = mainhand.getComponent('grb:tool')?.customComponentParameters.params as ToolProperties
if (
player.getProperty(tool.use_animation) ||
!tool ||
!checkToolRequirements(player, mainhand.typeId, tool)
) { return; }
// const skill_level = getPlayerSkillLevel(player, block.required_level[0])
if (!(player.skill_level(block.required_level[0]) >= block.required_level[1])) { return; }
make a post for it
i cant help further atm
no problem
oh ffs I'm dumb. I think it was fine the entire time. I just missed the fact that I was using the skill_level const a bit further down. lol
tunnel vision is a pita.
math related question but what would be the value of Alpha[Ξ±] in Cartesian coordinates?
felt like asking here instead of off-topic since we got math experts here xD
depending on what the equation is
what is Alpha[Ξ±]?
uh it came in my math exam so i asked heere
what's it's value tho?
the Alpha is a constant and its value is
Ξ± = 0.0072973525643
that's interesting ima try and research about them
b rhurhurhhrr
i peek my friends exam papers in my math exam π
and they told me the alpha value is -1 π
probs gonnna fail the exam bru
@jagged gazelle sorry for ping but where do i add the variable part?
Send your script but in text form.
Not screenshot
Ok
import { world } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"
system.run(() => {
const ui = new ActionFormData()
.title("Form")
.body("")
.button("Button1")
.button("Button2")
.button("Button3");
const customUi = new ActionFormData()
.title("Custom Form")
.body("")
.button("Button1")
.button("Button2")
.button("Skibidi");
world.afterEvents.itemUse.subscribe((event => {
const { source, itemStack } = event
switch (itemStack.typeId) {
case "ssia:attachment": customUi.show(source); break;
}
}))
})
don't... do that.
Did they change onPlayerDestroy in v2? It's not being triggered at all
let ui
let customUi;
world.afterEvents.worldLoad.subscribe(() => {
ui = new ActionFormData()
.title()
// ...
customUi = new ActionFormData()
.title()
// ...
});
world.afterEvents.itemUse.subscribe(({ source, itemStack }) => {
switch (itemStack.typeId) {
case 'minecraft:stick': customUi.show(source); break;
}
});```
you don't need system.run for world events
I dont need the button 1 stuff?
I just added it because someone said soπ
Well it didnt show warnings so idk if it works
you still need to, you add it yourself. that's just an example.
Ohh i see
What about the world after events part btw?
Ohh i see nvm
Sorry
only world before requires system.run (inside the scope) because it needs permission
are you sure you registered the custom comp?
yeah, onPlace works just fine
const BlockComponentHandler = {
onPlace({ block, dimension }) {
const above = block.location
above.y += 1
const b = dimension.getBlock(above)
if (b && REPLACEABLE_BLOCK.includes(b.typeId)) {
dimension.runCommand(`setblock ${above.x} ${above.y} ${above.z} ...`)
} else dimension.runCommand(`setblock ${block.location.x} ${block.location.y} ${block.location.z} air destroy`)
},
onPlayerDestroy({ block, dimension }) {
const above = block.location
above.y += 1
const b = dimension.getBlock(above)
if (b && b.typeId === '...') {
dimension.runCommand(`setblock ${above.x} ${above.y} ${above.z} air destroy`)
}
}
}```
Try doing console.error()
ight
also block.above() exists lol
Ight this should work-
Remove the js text and the // ... it's just a placeholder lol
wait, what's worldLoad?
and how come do I not see it in suggestions?
Install the right npm
oh, guess that means I haven't updated mine then
Ohhh shiiii
How did you knowπ
It should look like this
How shouldnt he know
I mean its an syntax error ir something like that
Cinema vroπ₯
Because I read every line of code always.
Coddy sent the message before i booted mc
muscle memory to look for syntax error lol
Nawwwwππ
@jagged gazelle this should be alr?
should be. If it was not, I'm gay.
I thought the // parts are in the code
I hope an error accurs
// are comments
Nahh it would be my faultπ
Ik how i code its held by hopes and dreams
would you mind telling me which npm it was?
It isnt
Uhh I always install
@minecraft/server@beta
oooohh that's why
see ya, thanks
it should've exist in non v2 tho... From 1.18.0 iirc
Nice...
-# thank God.
looking at the jayly docs and it's only available in the beta version
guess that means I need to use something else
Gn chatβοΈ
oh they renamed it to onPlayerBreak interesting
it's been a while since I tried bridge hmmm
It's pretty good
their script API autofill is a bit lacking tho and outdated in some areas
how do i get the player and equipment and itemStack from world.beforeEvents.playerBreakBlock
@minecraft/server v 1.17.0
can you get source from this event
Look at the docs or install the npm
Im not well known with older events
oh i was trying to use source
which is not defined
it's actually player
do you know how to check the player's gamemode?
In old versions.. uhh i dont know
I think in newer you can do player.getGameMode()
ok ty
it works
i just made bedrock mineable with a special pickaxe
otherwise event.cancel=true
How to rotate a structure by 90 degrees vertically
world.structureManager.place() can only rotate around the y axis
Make a custom rotation function
I have an idea though...
Ah.. no.. I don't have an idea.
Each of you guys! Tell me what are you all warking on?
discord bot
Like I can use non JS when I can use JS
No, this is not for an addon.
I have spent hours yesterday trying to come up with a way to do this, i remembered that the structure manager exists this morning, but it turns out that it only works horizontally, so am back to square one
what lib? DiscordJS?
Well yes... are there any others?
mine, or just rest api
DiscordJS is heavy as hell
i don't like it so i made own one
I wouldn't bother figuring this out considering I need to do it quickly.
all good
await f.runJob(f.Geo.mcCube(f.Offset.none[0], f.sumObjects(structure.size, { x: -1, y: -1, z: -1 })), (location => {
let permutation = structure.getBlockPermutation(location);
if (permutation == undefined) return;
if (options.rotation) {
location = f.sumObjects(location, bottomCenter, -1)
if (options.rotation == 180) {
location.x = -location.x
location.z = -location.z
} else if (options.rotation == 90) {
let oldLoc = { x: location.x }
location.x = -location.z
location.z = oldLoc.x
} else if (options.rotation == 270) {
let oldLoc = { x: location.x }
location.x = location.z
location.z = -oldLoc.x
}
permutation = rotateDirection(permutation, options.rotation)
location = f.sumObjects(location, bottomCenter)
}
location = f.sumObjects(location, offset);
locations.push(f.sumObjects(location, this.location));
permutations[ID(location)] = permutation;
}));
This is a snippet of my code that rotates a structure as structureManager, you can use this as an example to do Y rotation I think
What about you?
nothing special, i finally done one of my projects so now i have more time, but there are still many to go, i released npm package for NBT serilization, its the fastest NBT package written in JS/TS and its Web compatible so its pretty nice, now i am working on some kind of tools, but i am a bit overworked rn so its hard to focus
This looks very complex, thank you, i will try that
hhmm there are some missing dependencies like f, and rotateDirection, and options
a flashlight addon... 
sounds nice, what it does?
Currently its fucked up
i know, i meant the important logic that does the magic is missing
rhyme unintended
oh does that imagw show
good luck with your project, i wish i had time also for addons dev
Basically, all you need to do is change the axes for the coordinates and multiply by -1 or 1, but this must be done relative to 0, and then add offset
do you do this for all the blocks in the structure using a loop or something
Yes
my brain is spinning π
when you multiply the block x position by -1 for example, doesn't that mirror it on the x axis?
oh, wait i think i am starting to get it, everything is relative to the structure center
making bedrock mineable
edit: well actually i finished that, so now im just chilling
bro whats up with the eyes
i am being watched
oh yeah that's way better
π
funfact: I forwarded that by accident, there's also #1256780864529105008 message whic was the opitmized pretty much instant version
(which is also why I'm replying to this so late)
this looks straight up ass to me, i think i can make it better, at least the texture.
check ur dm, i made u a better light for ur flashlight
Does the scripting API have a function to create a block at a coordinate, or will I need to use the /setblock command?
Thanks. Was looking on there but was having trouble locating that.
Can be rather difficult to find things in their documentation at times.
Knowing where to look for things in the documentation is an learned skill π took me a few months and even after a few years I still can't find things sometimes
I swear to god I am going to jump off a bridge at this point.
This USED TO WORK LIKE 15 MINUTES AGO:
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
// Block Components
blockComponentRegistry.registerCustomComponent("shadowmavks:sit", component_sit);
blockComponentRegistry.registerCustomComponent("shadowmavks:drawer", component_drawer);
blockComponentRegistry.registerCustomComponent("shadowmavks:bedside_drawer", component_bedside_drawer);
blockComponentRegistry.registerCustomComponent("shadowmavks:zone_block", component_zone_block);
});
Now I get this BS
deleted all my changes to my script
and it's still doing it
I have import { world, system } from "@minecraft/server";
At the top of my script
system.beforeEvents.startup.subscribe
They changed the API?
π
yuh
but that doesn't explain why it worked a few minutes ago
I've had the @minecraft/server module set to 2.0.0 for a few days
welcome to experimental...
and as far as I know, my minecraft version didn't change
2.0.0 isnt experimentak anymore.
so... is the javascript for the modding API on the cloud and subject to separate updates or something?
sike, gud to know
the worldInitialize has been marked as deprecated btw
now its removed
duno bout that
I'm just baffled.
like it just magically stopped working
no change on my part, and as far as I'm aware minecraft didn't auto-update
anyway, switched it over
to the new syntax
So, thanks for that.
Now I'm getting removeTag doesn't have required privileges...
Minecraft Bedrock modding is by far the most frustrating modding experience of my 20+ years of modding games.
if this is what Mojang has to deal with in development (if their backend is anything like this), no wonder progress is glacial.
The event is in v1 https://jaylydev.github.io/scriptapi-docs/1.21.80/classes/_minecraft_server.WorldBeforeEvents.html#worldinitialize
Documentation for Script API - v1.21.80 | A set of events that fire before an actual action occurs. In
most cases, you can potentially cancel or modify the
impending event. Note that in before events any APIs that
modify gameplay state will not function and will throw an
error. (e.g., dimension.spawnEntity)
Now how the hell do I get removeTag working again?
const component_zone_block = {
beforeOnPlayerPlace(event) {
const pos = event.block.location;
const canZone = event.player.hasTag("perm_zoning");
const isZoning = event.player.hasTag("isZoning");
if(!canZone)
{
event.player.sendMessage({ rawtext: [{ text: "Β§cYou don't have zoning permissions!" }] });
event.cancel = true;
return;
}
if(!isZoning)
{
event.player.addTag("isZoning");
event.player.setDynamicProperty("zonesetup_pos1", pos.x + "," + pos.y + "," + pos.z);
event.player.sendMessage({ rawtext: [{ text: "Β§aFirst zone block placed by Β§f" + event.player.name + "Β§a at Β§f" + event.player.getDynamicProperty("zonesetup_pos1") + " Β§a(Β§f" + event.dimension.id + "Β§a)" }] });
}
else
{
event.player.removeTag("isZoning");
event.player.setDynamicProperty("zonesetup_pos2", pos.x + "," + pos.y + "," + pos.z);
event.player.sendMessage({ rawtext: [{ text: "Β§aSecond zone block placed by Β§f" + event.player.name + "Β§a at Β§f" + event.player.getDynamicProperty("zonesetup_pos2") + " Β§a(Β§f" + event.dimension.id + "Β§a)" }] });
const pos1Array = event.player.getDynamicProperty("zonesetup_pos1").split(",").map(parseInt);
const pos2Array = event.player.getDynamicProperty("zonesetup_pos2").split(",").map(parseInt);
const pos1 = { x:pos1Array[0], y:pos1Array[1], z:pos1Array[2] };
const pos2 = { x:pos2Array[0], y:pos2Array[1], z:pos2Array[2] };
let zoneForm = new ModalFormData();
zoneForm.title("Zone Configuration");
zoneForm.textField("Zone ID", "Type the name of your zone here.");
zoneForm.textField("Trust Tag", "Type name of a tag trusted users must have.");
zoneForm.dropdown("Music", musicOptions);
zoneForm.toggle("Teleport Untrusted Players", false);
zoneForm.toggle("Kill Hostile Mobs (and prevent spawn)", false);
zoneForm.show(event.source).then(r => {
// This will stop the code when the player closes the form
if (r.canceled)
{
event.dimension.setBlockType(pos1, "minecraft:stone");
return;
}
// The code when the player responds to the form
}).catch(e => {
console.error(e, e.stack);
});
}
},
};
WIP, subject to cleanup in the future, try not to judge the code too much. If you're wondering why it's setting and getting the dynamic property again, it's just for testing to make sure the data is structured the way I want for later. Not final.
It just doesn't make any sense
wrap it in system.run(), more info: https://jaylydev.github.io/scriptapi-docs/features/script-privileges.html#read-only-mode
if (Block.above().isAir) {
Dimension.runCommand()
}```
will this break the block or is it gonna be replaced with air?
you need to use the setblock command to make it drop its loot and have the break particle
thanks
// MARK: UI Forms
const UIForms = {
openShopUi: function (player: Player): void {
const form = new ActionFormData()
.title('Shop')
.body('Welcome to the Shop!')
.body('Tower')
.body('Modules');
// @ts-ignore
form.show(player).then((response) => {
if (response.canceled) return;
const selection = response.selection as number;
if ([
// playerBuy(item: string, player: Player, money: number, times: number = 1): boolean
PRICES.tower.playerBuy.bind(null, "Tower"),
PRICES.module.playerBuy.bind(null, "Module"),
][selection]?.(player, GameResources.money, 1)) {
switch (selection) {
case 0:
break;
case 1:
break;
}
}
});
},
};
Is this overcomplicated/overengineered guys?
const UIForms = {
openShopUi: function (player: Player): void {
const form = new ActionFormData().title('').body('');
form.show(player).then((response) => {
if (response.canceled) return;
const selection = response.selection as number;
const itemType = selection === 0 ? 'Tower' : 'Module';
const priceList = selection === 0 ? PRICES.tower : PRICES.module;
priceList.playerBuy(itemType, player, GameResources.money, 1);
})
}
};```
-# 

hmmm
the binding is unnecessary tbh lol especially it's called twice
Yep right
-# do that if you're obfuscating your code lol
-# thanks for the advice
hmm
Array.prototype.with
```kewl
Any way to load far away chunks, or are we screwed in that regard? Chunkloader doesn't work anymore.
tickingarea? They must have used an entity with the ticking component and probably broke
system.runInterval(() => {
for (const player of world.getPlayers()) {
const vars = new MolangVariableMap();
const lastSwing = swingState.get(player.id);
const isSwinging =
lastSwing && Date.now() - lastSwing <= SWING_DURATION_MS;
vars.setFloat("variable.custom_swinging", isSwinging ? 1.0 : 0.0);
}
}, 1);
Can i make a new variable use for my 3d tool using this MolangVariableMap
{ id: "minecraft:netherite_ingot", value: 50000 },
{ id: "minecraft:diamond", value: 10000 },
{ id: "minecraft:gold_ingot", value: 1000 },
{ id: "minecraft:iron_ingot", value: 100 },
{ id: "minecraft:gold_nugget", value: 10 },
{ id: "minecraft:iron_nugget", value: 1 }
];
```{ id: string; value: number; } There's an error in this part, but I don't know how to fix it. Is there a way?
do y'all know if successCount in CommandResult works for testing item data?
the one u assign In give commands
/give @s clock 1 >>3<< this
Not anymore iirc
It's only used in particles... So no
Are you using js or ts?
Ah, I solved it
wrong typing
interface ISellItem {
readonly id: string
readonly value: number
}
const valueTable: ISellItem[] = [
{ id: "minecraft:netherite_ingot", value: 50000 },
{ id: "minecraft:diamond", value: 10000 },
{ id: "minecraft:gold_ingot", value: 1000 },
{ id: "minecraft:iron_ingot", value: 100 },
{ id: "minecraft:gold_nugget", value: 10 },
{ id: "minecraft:iron_nugget", value: 1 }
]
"[Scripting][Error]-Plugin [My Addon Name - 1.0.0] - using unsupported runtime []." An error occurs. I used TypeScript. What is the cause
make sure the pack runs the JavaScript files
u gota compile ur ts files to js
how?
that, idk ;-;
npm install -g typescript
npx tsc
Change it from typescript to javascript. The engine does not run typescript files, only the files generated by it
looks like bridge so it should automatically compile if it's not bridge
https://wiki.bedrock.dev/scripting/typescript
I always wondered why they have the "language" there in the manifest
you don't need it in your pack for javascript to work and no other language seems to be supported
makes sense
[Scripting][error]-ReferenceError: Native function [ActionFormData::show] does not have required privileges. at show (extensions/forms.js:62)
at showBiomeList (database.js:160)
at <anonymous> (source.js:60)
[Scripting][error]-ReferenceError: Native function [ActionFormData::show] does not have required privileges. at show (extensions/forms.js:62)
at showBiomeList (database.js:160)
at <anonymous> (source.js:60)
[Scripting][error]-ReferenceError: Native function [ActionFormData::show] does not have required privileges. at show (extensions/forms.js:62)
at showBiomeList (database.js:160)
at <anonymous> (source.js:60)
[Scripting][error]-ReferenceError: Native function [ActionFormData::show] does not have required privileges. at show (extensions/forms.js:62)
at showBiomeList (database.js:160)
at <anonymous> (source.js:60)```
What do you think is the source of the problem? Give a brief answer.
system.run(() => /*show your form here*/)
@hazy copper uhh help?
oh lol I thought all along it could be used for other molans
Tf you want me to do I don't speak json ui
πππ»
Rip
Just try i guessπ
π
Aight at ease gngπ
Hmmm
Give me a min to pull another pack up (I can't explain it off memory)
Gg
I have no clue
But it's in the scr*pt π€·πΌββοΈ
π
I dont wanna bother people so ima ping them tmmrwπ
import { world } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";
world.afterEvents.itemUse.subscribe((data) => {
const { itemStack: item, source: player } = data;
if (item.typeId !== "minecraft:compass") return;
const form = new ActionFormData();
form.title("Title");
form.body("Body");
form.button("Button", "textures/items/apple");
form.divider();
form.header("Header");
form.label("Label");
form.show(player).then((response) => {
const { canceled, selection } = response;
if (canceled) return;
switch (selection) {
case 0:
console.warn("Clicked button");
break;
}
});
});
That's got everything in a form
For actionform anyway
@cursive fog
I see
I should i write this on diffrent script?
Why do you have the form in a world load?
Uhhh
Idkπ
I guess it's one way of doing it 
Im new to this
but yeah you just need to do .then on the customUi.show(source)
It alr works(sorry for the uhh text) i just need a way to make it trigger smth
import { world } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";
let customUi;
world.afterEvents.worldLoad.subscribe(() => {
customUi = new ActionFormData()
.title("Skibidi")
.body("")
.button("Skibidi Dom Ye Ye");
});
world.afterEvents.itemUse.subscribe(({ itemStack, source }) => {
switch (itemStack.typeId) {
case "ssia:attachment":
customUi.show(source).then(({ canceled, selection }) => {
if (canceled) return;
switch (selection) {
case 0:
source.sendMessage("Click!");
break;
}
});
break;
}
});
Ohh ok
So which part here triggers a command
Okie
Uhmm.. Nvm-
yes
never seen that before
switch
case
if
switch
case
90% chance of not working if i ran this
definitely, try using AI as somesort of backup
Well atleast we are tryingπ
make them explain to you what's going on
welp that's where we all started
This should work in theory.
Ye
Maybe ai can elevate this from burnt to cooked
switch case needs breaks
The run command part?
π
runCommand definitely not, because it is a method, not a function
You wont believe what i did worst on Anim controllersπ
The function part is the ones that runs a command right?
unless theres sth weird that needs to occur, that is
This one?
In short, it's better to just use if/else
Ill try re writing this yandev slopπ
i once used it like a filter kinda like door knob where key is used
it keeps going, unless sth isnt supposed to
but yeh, if/else is still the better practice
||```js
{{{{{{{{{{{{{{{{await "neko"}}}}}}}}}}}}}}}}
weren't supposed to add breaks?
also that's doable with if conditions
My last code have it
I removed it to add this new line
I see
also try to be consistent you're using switches then if then switches why not just all if conditions?
Why is there my name
Well, I always wanted some attention, so im fine with it
This is json ui? Looks more like an action form data
I havent added the
Json partπ
Ohhh I was refering to the image
Its easy actually, ask chatgpt
Or deepseek, grok, copilot
π
Json ui so bad it cant be considered one
Oh well i started off too with a snowball launching item
I guess thats my copium for now
We. Don't. Support. AI.
I. Do
Then don't bring others to use AI bruh
I meant the programming side other than that then meh...
But AI can be a great helper sometimes.
I dont mean like using AI for everything, but for hard things like algorythms or math its super
Is it wrong?
Math and AI, recipe for weeks of debugging
For me it worked fine.
Since im not as smart as others i just use AI for things im not able todo
Good for you
how can i detect if someone uses a water bucket
or if someone spawn an entity with an egg
etc
Is anyone else unable to throw items out of a bundle if they have an itemUse event?
no?
yeah i cant
π dayum
Happened while trying to install latest preview modules.. anyone know why this happened or just a bug with the modules that were released?
how can I make my block not connect to blocks like grass
i was trying this method but it doesn't really works
I would recommend you to study JS a little and how everything works (i.e. theory). Well, in this case: ( and ) in array are not needed, and instead of block.typeId.includes(array) use array.includes(block.typeId)
And you also forgot to add minecraft prefix, and spaces in block IDs are not used
-# looks like he switched from python to JS
thanks! I didn't really learn to code in a good way, just try and test. so I'm quite bad at it, I really appreciate this thx
Is βDiskβ an option in structure manager structure save mode? Iβm having a issue with saved structures βdisappearingβ even tho the save mode I have for them is set to βWorldβ
I donβt see it in the documentation but I thought Iβd ask here
Or if someone has a solution
The structures seem to persist for a while and then βdisappearβ I donβt know the exact time frame they disappear from
Is this even the right place to ask
Ok mb
can someone help me with this? I can't make it work only with raytracing mode
Did you try to log the graphics mode? If it returns ray tracer it means the way you set up the return is the problem.
Does anybody happen to know why with these options it doesn't detect anything?
getEntitiesFromRay
ignoreBlockCollision: false;
includeLiquidBlocks: false;
includePassableBlocks: false;
i want the ray to pass through nonfull blocks and liquids only
non-full blocks are not the same as passable blocks
passable blocks are grass, flowers, vines, etc
blocks such as fences, slabs, stairs, etc aren't full blocks but are detected if the ray reaches their hitbox
so they're also affected by blockCollision as well
oh i get it
it works now.. it was smth else causing the problem xdd
thanks though
how do i do that?
β’ Added methods to Dimension scripting API that allows creators to get the total light level and the sky light level at a specific position
nice
I missed that
they didnt mention what the methods are called but you can guess it easily.
dimension.getLightLevel()
dimension.getSkyLightLevel()
really cool.
I believe by the time the world loads, the player hasnt join the world yet. So it probably sent the message, it just wont appear in the chat because you didnt join the world yet. Perhaps you would wanna use system.runTimeout(() => world.sendMessage(.....))
afterEvent.playerInteractWithItems I cant exactly remember the code, you can read it in documentation
i noticed it and i honestly dislike that
they're getting lazier
adding two extra lines was too much work
I mean, it was easy to find out in game.
I didnt guess the name, I used objects.keys(Dimension.prototype)
Custom session protocol. I can get addons to communicate to remote applications using MCWSS.
What the hell is this....
#handleUpdate() {
if (!this.isConnected) return;
if (Date.now() - this.#_lastPing > 5000) {
this.disconnect();
return;
}
const pingPacket = new PingPacket(this.#_sessionToken);
this.sendPacket(pingPacket);
}
export default class VoiceCraft {
/** @type { Boolean } */
get isConnected() {
return this.#_source !== undefined && this.#_sessionToken !== undefined;
}
//Connection state objects.
/** @type { Player | undefined } */
#_source = undefined;
/** @type { String | undefined } */
#_sessionToken = undefined;
/** @type { NetDataWriter } */
#_writer = new NetDataWriter();
/** @type { NetDataReader } */
#_reader = new NetDataReader();
/** @type { Number } */
#_lastPing = 0;
constructor() {
system.runInterval(this.#handleUpdate, 20);
system.afterEvents.scriptEventReceive.subscribe((e) => {
switch (e.id) {
case "vc:mcapi":
this.#handleMcApiEvent(e.sourceEntity, e.message);
break;
}
});
}
...
k. weird thing... fixed it anyways
VoiceCraft? what

fixed it anyways
How do i make a function (on scripts) trigger a command
simple
Like should i just put function my stuff on function folder?
function yourFunction(source) {
source.runCommand('say hi');
}
// usage:
// yourFunction(<some source, like a dimension or an entity>)```
Ok
yeah i don't think i understood what you meant entirely but hey, i gave you something to work with.
Yeah ill try
source is supposed to be named as per the paramter
which in this case is player.
Aight
@chilly fractal one last can i replace the ('say hi') command with a mcfunction?
Is there a way to encrypt a script?
there are lots of ways
yeah
How?
Nice
depends
just google javascript encryption methods
you can obfuscate your script
or ask AI
there are lots of ways to encrypt/obfuscate it but it will stil be undoable
wait
am i missing something or..?
doable?
yeah
you can obfuscate your script api code and run it fine
it's never really truely secure because anyone with dedication and hard time can deobfuscate it of course.
yeah
it just makes it harder for someone normal to steal code.
there lots of already made deobfuscator
yep kind of like a padlock
yeah
it's stilil pickable but at least normies won't be able to access it
Problem with obfuscation is it may decrease performance
You're making the code less readable at the cost of the computer having to run the obfuscated code
and AI can even help with deobfuscation, or rather beautifying the "Deobfuscated code"