#Script API General
1 messages Β· Page 48 of 1
yo
ts lowkey sad, actually like nothing has changed, im looking at the dif types and events and theres deadass nothing i was hoping for π
Lmao
I want to know how to make the result number not have a dot (like 0.5)
${Math.floor(player.getComponent("health").currentValue / player.getComponent("health").effectiveMax * 24)}
.toFixed(0)
what will that do?
Round up or down
Awh
no I dont want that
1.3 -> 1
So down
Yes
I want it to like when its 1.8 it will turn into 2
Math.round(num)
change floor to round?
Dont you want it to round?
Floor always rounds down to closest smallest int
Ceil always rounds up to closest largest int
Round rounds to either closest largest int or cloest smallest int depending on the trailing decimals' values
Doesn't toFixed round?
No just removes it.
ty for the info
If you wanted some certain level of trailing decimals, for example if you wanted just 4 levels, it would turn it into (num.xxxx) and x will be 0 if the num doesn't have that level of decimals.
am i geeked or do i need something else for my pack to show in game
Nah it should work
yeah thas what im sayin
try to make it show as a title
to see if it works
what does that even mean gang
Also you can make your own function to turn a num into string and manually set the amount of decimals you want. (Me personally i hate js, so if it trys to fk with my mind i just make custom functions, i personally dont trust it lmao)
you want to see if the math is working ingame?
i want the pack to show up in game π i havnt been coding for a while so ive pretty much forgotten everything
oh
So uh?? What exactly is the error, is it like... not importing or is it not working or what?
the pack aint even in my list of packs
try using bridge if you forgot how to make the file work
it will automatically import it into the game
i actually hate bridge
Did you change the UUIDs?
i did
real
did you make it a .mcaddon file?
{
"format_version": 2,
"header": {
"name": "yurt",
"description": "yurting currently",
"uuid": "412cb0ea-b3f8-4c79-a8c8-1c9eb263f19b",
"version": [0, 0, 1],
"min_engine_version": [1, 21, 60]
},
"modules": [
{
"description": "behavior",
"version": [0, 0, 1],
"uuid": "cb70b3ea-c702-483c-a288-0bd96f2e3992",
"type": "script",
"language": "javascript",
"entry": "scripts/main.js"
}
],
"dependencies": [
{
"description": "server",
"module_name": "@minecraft/server",
"version": "1.18.0-beta"
},
{
"description": "server-ui",
"module_name": "@minecraft/server-ui",
"version": "1.4.0-beta"
},
{
"description": "debug-utilities",
"module_name": "@minecraft/debug-utilities",
"version": "1.0.0-beta"
}
]
}```
im just tryna make a standalone behavior pack
dev behavior pack so i can work on it in game
Need data module in modules section too
{
"type": "data",
"uuid": "new-uuid",
"version": [ 0, 0, 1 ]
},
the version for "@minecraft/server" should be 1.16.0
or 1.17.0-beta
I assume they are running preview
yea maybe
I'm the one who gave the template I think he didn't change it π
function toFixed(n, p) {
const s = String(n), i = s.indexOf('.');
return i < 0 ? (p > 0 ? s + '.' + '0'.repeat(p) : s) : (p === 0 ? s.slice(0, i) : s.slice(0, i) + '.' + s.slice(i + 1).slice(0, p).padEnd(p, '0'));
}
Try that...
this is what I used in chess addon lmao
Does it round or smth? Cuz i purely just did some gibberish
the native toFixed does round
Yes but you can override it using prototypes
(Its not a good practice tho so thats why i didn't do it here)
Does it work???
I'm so dumb, why didn't i test myself lmao
it do
Hmm
First one is fine, it's intended behaviour
chat said to add the this for error checking
if (typeof n !== 'number' || isNaN(n) || !isFinite(n)) {
throw new Error('Input must be a finite number');
}
if (typeof p !== 'number' || p < 0 || !Number.isInteger(p)) {
throw new Error('Precision must be a non-negative integer');
}
Yeah i knew it did that but i didn't use it anyway tbh. I like my numbers clean. But anyway my function works!
yippee!
W chat and W guy
My chatGPT has been whipped into shape by my constant correcting π
Lmao
Bro became slave
I personally don't use it as i gives me too many headaches for just one simple mistake that requires a little bit more focusing and it ends up breaking everything
yo has anyone already made a decent invenotry to work with the existing herobrine chest ui?
So ye i avoid it unless i just ask it for quick calculations for example calculating storage stuff required and stuff.
if not, its whatever... but annoying to have that visual but not have functioning invenotry... so ill have to recreate the best i can
Nah but map the items and the man himself herobrine is here, you can ask him and for the item looping... i think it's fairly simple.
i can get it working myself... its just a pain to add
because players gonna question the inventory functionality
Well you can always use automation scripts like bash, python or js.
Functioning inventory is something LeGend was gonna look into a bit ago
ohhh ok
i think a big part of the functionality would be the json ui bit (for a better experience)
Bash allows for more control over the files themselves and net requests better, and python allows for more control on the contents of files, while js is much less flexible as you need too much logic and you need to set up the files manually with the given auto generated content.
My chess is almost perfect... Just that rook eat the pawn
Basically what i am trying to say, is for you to console.log an array of all item types (existing ones) and then copy that log, store it in an array, look in in the vanilla files and probably they are the same but yea. And make a bit of json or files or whatever you need but like a part that doesn't change for certain item types and then classify which part of the code you want to be put for that specific item. And then after all that auto generation is complete, the script api part is much much much easier to do.
oh nice
Good for you man, i am really waiting for you to make the permutations now :)
You can use @minecraft/vanilla-data or smth i think or even the server one and get a list of all vanilla items.
wait... what do you mean?
i haven't done the vanilla-data ever
I won't use permutation unfortunately... only entities
I could use particles but I don't like it.
I personally suggest making a fully automatic auto generation script such as bash or python so stuff is easier to manage.
Awh man!. I was really looking forward for the "changed" you after you make your functional chess block with all these permutations that would crash the game lmao.
Idk honestly if it needs that but yea
if only there's no limitation... Tho I can't since it's coded that way.
you can't play the game because it's trillion permutation π
lmao, so what you gonna do...?
Entites
ohh
He said that
makes sense im blind
Yes, that's why i wanted to see how you'd get past that obstacle lmao
Is that hawk eye??
Nah I'm probably saying random names π€£
i can't since the permutation would be absent and can't be accessed.
Bro wants the permutation not to be absent while his pc is playing jet mode finale π
Lemme do the calculation agin
his pc exploded and now he code in mobile
Frfr
So, you can have 65 states, each with 2 possible values, to maintain 65,536 permutations.
only 2? bro chess has 64 positions and have empty, pawn, rook, bishop, queen and king... So size values. It's not even possible π
Chatgpt does the equation. Not creates & does the equation
That's how i see it
If you use it to create something from start, it's gonna fk it up
This makes my block incompatible with other addons who also uses permutation
it's 3 in the morning man... I'm lazy π
After you run that beautiful c4 bomb you have made of an addon (if you did actually finish it and tried to use it in an alternative universe)
Sometimes I use chatgpt to automate my json π
Crazy
I'd never trust it
I trust javascript in strings with all my cells and i trust it with any and everything... BUTT (WITH ANOTHER T) math.
I ask him to automate this geometry file
you can ask him to run a python or program and say to download it
What???
if you ask him to generate it thru text the limit is now there.
Ima try rn
(The reason i haven't tried is i never used it cuz it was locked out of my country for so long so idk if it works now)
AYO IT ISN'T LOCKED ANYMORE?
DAYYYYMN!
BETTT
what country are you in?
Can't say. (I like to remain anonymous)
Bruh.
I'm sure you're Chinese...
nah
ALSO YES IT WORKS AND SENDS A DOWNLOADABLE FILE?!@
WHY HAVEN'T I BEEN USIN THIS?
E
Bruh
you have 3 file limit and y'know how it works? When you upload a file... And you accidentally remove one, you can't upload anymore it counts as upload even if you didn't hit send yet.
(The reason i haven't tried is i never used it cuz it was locked out of my country for so long so idk if it works now)
You literally said it.
Yeah i know lmao
Crazy strict frfr also now this guy gave me a working download link frfr
And it WORKs?
IT AUTO GENERATES WITHOUT MISTAKES?
HAVE I BEEN USING A COMPLETELY TRASH AI FOR THIS LONG, REALLY?
Nevermind actually
Gemini has much more computing power and stuff, this one has more of a... computing smartness
Hol up, i didn't ask chatgpt for a runCommandAsync? When that shii pop up, it says 2024. I used it rn like its 1/2/2025... how tf did i ask for that?
And holy crap it says this:
Is it already insulting me bruh??
Nah ima education this dumb A about cmds :)
Nah i decided to do a little bit of trolling
And holy crap
It got gaslit quickly
Unlike gemini, gemini tells you nah and just fkin kicks you outta the page. This? Nah. This just straight up provides π₯ advise about "deobfuscating"
I don't see anything wrong in that screenshot? I think ChatGPT is probably the best free AI for coding tasks, but just like with all of them you need to teach it about the script API first
const displayComponent = itemInHand.getComponent("minecraft:display");
displayComponent.lore = [
"Power Level: 16"
];
Any one know why this is happnening
Nah gemini can actually provide near perfect api code, like the mc api and near perfect cloudflare apis and basically near perfect everything
AI!
its called item.getLore()[index]
Dont use ai
i just need to know where the docs are tbh
how do i set it
Just search "Microsoft Scripting Api Documents" and the official documentation will pop up
item.setLore(["wow1","wow2"]);
thanks
Read this tho.
world.beforeEvents.chatSend.subscribe((eventData) => {
const player = eventData.sender;
if (eventData.message === "!md") {
const inventory = player.getComponent("minecraft:inventory").container;
const handSlot = player.selectedSlotIndex;
const itemInHand = inventory.getItem(handSlot);
const displayComponent = itemInHand.getComponent("minecraft:display");
displayComponent.setLore = [
"Power Level: 16"
];
inventory.setItem(handSlot, itemInHand);
eventData.cancel = true;
}
});```
ohhhhh
You have to understand what i am saying and implement it yourself
yeah
Display component ainβt a thing
yeah i relize
So what now?
I looked at your bio. Are you gonna haunt me in my dreams?
Why'd you delete your message scary guy?
What, do you think my nordvpn and macafee subscriptions are in vain?
Do you think that i share any personal stuff online?
I wanna know your answers. "X..x.xxx" guy.
I hope you ain't banned cuz i wanna infact, hack you. Not personal, just for fun.
Cuz i infact love fellas like ya
quick quesiton about itemDynamicProperties... it keeps saying i can't add to stackable item... which currenlty is a minecraft:mob_spawner...
is there a way to make it non-stackable before adding item dynamic properties?
vanilla wise
so i have to make a custom block then that simulates it
dang
okay thank you for your quick reply
You'd need an item that places the block down when used
As a block's itemstack can't be edited to be nonstackable
or just use lore
yeah, i was probably just gonna do that
but its annoying i want the dynamic properites... because of the cap
but oh well lol
OH THE ALL MIGHTY LORD π«
OH THE ALL MIGHTY LORE β
Lore overrated
Just kinda the only viable option in this case
I advocated for lore before item dynamic properties existed
True true lore is overrated but can be really useful in lots of situations
Name doesn't even suggest that lmao, its supposed to be for stuff like "Crafted from the ingots of hell and forged in the coldest of places" like, its talking about the item's story.. imagine the story being "i2vx3wn42e4" lmao
Cap was made so the old crash methods using hacks that modified the item aspects like lore and enchants don't work
Hacks can bypass the limit still, regardless
It didn't limit the lore itself, it just limited the setLore function in scripts
yeh
Then you have every right in existence to be pissed off about the cap.
And afaik, loot table json files don't have a lore function limit, so
Nah y'all have every right to be pissed off at moyang fr
You can get around the data storage limits of the cap by storing whatever you need in a world dynamic property and writing a pointer to the property ID to the lore
It's honestly not the data storage limit that is annoying- DPs exist for that reason.
I used the whole thing for displaying stuff π
Well yes but
Incase someone uses it to actually style and give their item a story like how they named it
You can't really "get around" the limit
But in other use cases, yea sure
Also, quick js question
What impact would this snippet do on a user?
(One sec)
const n = (N) => (Number(N));document.write(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(1))))))))))))))))))))));
What impact would this do?
(Without testing)
Instant death
the world explodes
Well good for you.. (i done this already lol)
Wrong answers
It would do nothing
wrong answer
Because that number is so humongous
It is considered infinity
And repeat does not allow infinity
exactly.
yeah lol, im sure that is for alot of people
It isn't even editing the world, it is html bruh
no
Lets see the num tho
998800659780049492080923920804949780006599880001
(I used a different script to get the value, the reason i didn't use repeat is because repeat as limit, but in the first snippet it was a test)
const n = (N) => BigInt(N);let result = 1n;for (let i = 0; i < 12; i++) {result = result * n(9999);}
console.log(result.toString());
(You can go further and stretch the absolute limits using a while loop but i don't want my beautiful phone that has every possible feature (i paid some crazy money for a company to customize for me) to explode)
Now this version, if you are crazy enough to do this, sure, but be warned it will probably freeze your device.
const n = (N) => BigInt(N);let result = 1n;for (let i = 0; i < Number(`12`.repeat(12)); i++) {result = result * n(9999);}
console.log(result.toString());
Anyway have fun y'all
i want to make a skygen, and have it so you can upgrade the generators, but only the owner of the generator can do so, since blocks can't have dynamic properties, would using a database get laggy?
I'm not entirely sure how much dynamic properties lag, especially in large amounts
They're pretty efficient even in large amounts
Can I make it so if I right click my animal it gives me an item
Some one know how to teleport a player back on the position he was
Like
If(playerVelocity.x !== 0) {
Player.teleport(previous position)
}
import { ItemStack } from '@minecraft/server';
world.beforeEvents.playerInteractWithEntity.subscribe(ev => {
const { target, itemStack, player } = ev:
if (target.typeId === 'minecraft:creeper') {
const inventory = player.getComponent('inventory').container;
system.run(() => {
const itemStack = new ItemStack('minecraft:stick', 1);
itemStack.nameTag = 'My stick';
inventory.addItem(itemStack);
});
}
});```
You need to store the position of the player somewhere else like the map Mr dynamic property better in a loop like runtInterval
Oh okay
Omg so if I right click a creeper I get a stick?
Wow ty
Could I make it a custom mob?
just change the id of creeper with your own one.
Ty, could I change stick to a custom item
absolutely, everything here can be changed
Do I put this in index.js?
put it on where your main script file is.
yes?
If Iβm making a new sword whatβs the max damage
Not scripting related, but its 255 due to https://bugs.mojang.com/browse/MCPE-180073
SmokeyStack
To Do (Open)
Unresolved
Can someone help me get this to work?
import { system } from "@minecraft/server";
const TARGET_BLOCK = "minecraft:lime_stained_glass";
const PARTICLE_TYPE = "minecraft:villager_happy";
system.runInterval((eventdata) => {
const player = eventdata.player;
const block = eventdata.block;
if (block?.typeId === TARGET_BLOCK) {
player.dimension.getBlock(block.location),
player.dimension.spawnParticle(PARTICLE_TYPE, block.location);
}
}, 20);
Because you are using runInterval instead of event
Okay, so how I can use runInterval for detecting blocks (this lime glass) and run particle on them? Maybe with player near in like 50 blocks, or something
You will need a NASA computer for such operations.
I've done it another way - on invisible entity with tag and area
when using simulated players to destroy a block, does it have the mining Animation on the block?
class OnRegistry {
constructor() {
this.initialize();
}
initialize() {
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
this.registerCustomComponent(blockComponentRegistry);
});
}
registerCustomComponent(blockComponentRegistry) {
blockComponentRegistry.registerCustomComponent('cosmos:cavernous_vine', {
onTick: ({ block }) => {
},
onRandomTick: ({ block }) => {
}
});
}
}```
Is this valid code ?
How do I run commands through a script
Yeah. Should be.
I wouldn't do it like that though but yeah.
It's pretty though
import {
EntityDamageCause,
EntityHitEntityAfterEvent,
EntityHurtAfterEvent,
system,
world
} from '@minecraft/server';
export default class ClassAttack {
constructor() {
console.log('ClassAttack constructed');
this.initialize();
}
protected initialize(): void {
console.log('ClassAttack initialized');
world.afterEvents.entityHurt.subscribe(this.onEntityHurt);
world.afterEvents.entityHitEntity.subscribe(this.onEntityHitEntity);
}
private onEntityHurt(eventData: EntityHurtAfterEvent): void {
console.log(
'Testing to see whether entity hurt runs first or entity hit entity runs first'
);
console.log('Entity Hurt: ' + eventData.damage);
// throw new Error('Method not implemented.');
}
private onEntityHitEntity(eventData: EntityHitEntityAfterEvent): void {
console.log(
'Testing to see whether entity hit entity runs first or entity hurt runs first'
);
void system.waitTicks(10).then(() => {
eventData.hitEntity.applyDamage(10, {
cause: EntityDamageCause.contact,
damagingEntity: eventData.damagingEntity
});
});
// throw new Error('Method not implemented.');
}
}
Whats is this ?
Is what I would have done.
Iβm just saying, Itβs just full of bad practices and unconventional stuff
itβs good if you want your code to be unreadable :P
I know someone else who writes code like that and it drives me crazy seeing it lol. Somehow, their brain is simply wired for it. I call that style Kryptonite.
Pink kryptonite?
got an error when i ran my code in minecraft, i remember learning about this and i feel stupid for forgetting,
[Scripting][error]-Plugin [Project Friend - 1.0.0] - does not contain main file [main.js].
Idk why you would do it
Any color you desire lol.
to show their dominance
I'm not sure either. Some are just wired for it. I need clarity lol.
Reminds me of that quote by Linus Torvalds, "Bad programmers worry about the code. Good programmers worry about data structures and their relationships."
so you're a bad programmer?
Whyβs that?
Itβs in his perspective
In his perspective heβs worrying about the code
but also thatβs not the context
of it
got an error when i ran my code in minecraft, i remember learning about this and i feel stupid for forgetting,
[Scripting][error]-Plugin [Project Friend - 1.0.0] - does not contain main file [main.js].
do you have a main.js file?
Well there's your issue.
i mean where should i put it and what shoulld i put in it
It's in the sense of, a "bad" programmer will focus on syntax and immediate logic. For example if he went away from his code for a few months or created a whole system with that method of programming, anytime he goes back to something it'll be much harder to maintain.
and read
However, if you think about the design of your code and structure/organisation of the data used it's makes it much easier to read (for others aswell as yourself), on top of making it efficient, cleaner etc
challenging yourself to do the complete opposite is just a massive detriment to ur progress
my eyes... WHATS THAT
either rename it to main.js, or change the entry file in your manifets to index.js
not exactly. in this case their challenge is "how can I efficiently use this space to do what I want" , and obviously this is not being used in a collaborative environment, just something for fun to test themselves
tbh if I try to do that on an actual project, I'll probably kms
but this is just a fun project to test my binary / data structure knowledge
yeah
that's the old version, i got a better one (it works too)
let {world:W,system:S}=await import("@minecraft/server"),b=(p,b)=>W.getDimension("overworld").setBlockType({x:p>>4,y:-60,z:p&15},b+"_concrete")||p,d=1,h=0,a=3,s=1,f=c=>S.runTimeout(_=>{d=(d&3?d|48:d|3)&1<<W.getPlayers()[0].selectedSlotIndex||d;c(b(a,"red")^b(h=h+(d&17)-(d/2&17)&255,"green")?s:++s);let p=h;f(n=>n?p^h?c(n-1):z:h^a?b(p,"white"):a=Math.random()*256|0)},4);f(_=>_)
I'd rather use more space, for more readability
this is literally just obfuscation
for example
..... you scare me
it's not though, they have to use bitwise ops, efficient data structues like using arrays to hold properties instead of objects
There's literally 0 point in doing that but yk
are you just hating for the sake of it or what?
They can do what they want
that's great for you, but the complete opposite of what they're challenging themselves to do
uh you used a non existent version of @minecraft/server
You can do it in a way better way
wdym
such as?
there's no a version 17 yet, there's 17.0.0-beta
create a new post and send your entire manifest file
did i spelled that right?
nah their manifest is jsut wrong, it's looking for 1.0.0-beta
oh i see then
and server-ui 1.0.0
yeah make a post
not obfuscating everything and using bitwise ops in a cleaner manner
once again, their challenge is to use the least amount of characters, so obfuscation is obviously needed
Yes that's the problem, the challenge is just teaching you to do a TON of bad practices
not sure what are we arguing about
i just want a cool project to show off at pack jam
no it's not lmao? the only "bad practices" here is the bad formatting, which in itself is just a visual thing, it literally does not matter
I'll tell ya they'll much rather see clean code than obfuscated garbage
if you changed the variable names to be more descriptive, the code would do entire the same thing
It literally does
If you did this on a big project, and you went back to it a few weeks later you will not understand what you wrote
you're just insulting cause you can't keep track of 5 variables in your head
good thing it's a challenge for themselves
and not something they're doing in a large scale project
Exactly but it's still bad practices
For sure!!
it's a challenge
And the challenge is teaching them bad practices
ok i did use a bunch of very bad things,
multiple responsibility functions
bad naming
evil bool operation etc,
but if i know what i am doing does it really matter?
it's not teaching them anything, they're not learning anything new from the challenge, they are actively using their own knowledge to figure it out in the smallest way
i have been coding for many years lol, just writing a 300 byte code won't make me suddenly use inheritance
and apparently fun in coding is illegal now
no one likes a pompous stuck up person who thinks they're the best because they use "good practices"
I don't think I'm the best, I still have alot to learn
bruh, this is so dumb. atleast argue about something that matters, like "should inheritance exist" or something
you should learn to not pointlessly insult people because they tried to challenge themselves
I didnt insult them
"obfuscated garbage"
Maybe there's a misunderstanding
I meant in general, and it is
no one can read that easily
that's the point of obfuscation
lol
doesn't mean it's garbage though
i mean yeah?
to prevent people from reading your code
garbage would mean that the code is useless and can be thrown away, which is not what obfuscation does or is for
i have a non "obfuscated" version on my GitHub
That's probably where they got the bitwise ops from also
wha?
instead of showing hard coded values, you can bitwise op them even tho doing that can just be reversed easily. but that's not the point. The whole code can be reversed
And if they return the same values then yippee!
and? the point of it wasn't to make irreversible encryption?
what are you talking about
i don't even know
The point was the create it in the smallest possible way, which is obfuscation if you use single letter variable and function names
my point was that, It's just bad practice and not a very good challenge for yourself
It's just a detriment to yourself
also ty for arguing on my behalf, had the best laughter in a while
wait until you have to do embedded systems programming with limited memory size, every character counts
actually true, im perusing electrical engineering in a few months
Uhh I think you are misunderstanding it
You can still write clean code in embedded systems
It's the performance of the code that matters
which if you did this for that case, yeah it wont be very performant
obfuscation reduces the performance of code
ok that's just wrong, while you can have clean code in embedded. memory becomes a huge issue in those areas
nope, limited ROM size, you can't flash huge programs on to it, so as you reach the limit you have to employ stuff like obfuscation to reduce your memory footprint
the compilers play a huge role for reducing the size of code
also no
ok that was fun, I'll go have breakfast now
@slow walrus ty again for arguing with/for me
oh yeah that's just completely wrong lmao
if anything the obfuscation in the original snippet has better performance than a non obfusctaed version
since it uses bitwise ops
all good lmao
It's practically the same if you used bitwise ops in non obfuscated version
Yes but you can just obfuscate it in 2 seconds using a free tool
bad practice
It's bad practice to write it yourself
write bad code -> use a tool to fix it -> "good practice"?
I'd have to disagree with that statement because the tools you imply that should be used didn't just spring up out of thin air. Someone wrote it.
In fact, code in general didn't just appear. Someone wrote it, somewhere, somehow.
Gave it purpose and meaning. π

well the obfuscater yeah of course it has meaning but you donβt write obfuscation yourself
What do you mean when you say "don't write obfuscation"?
The act of writing code in a way that is obfuscated
Their code wasn't true obfuscation though. It just used shortened names, nested functions, bitwise operations, and minimal comments. Nothing deliberate to make the code unreadable. It being difficult to read doesn't make it obfuscated. It just means it's been compacted. In some professions, that is a necessity. Not sure if you knew that or not. I think Omniac or somebody gave an example as to why.
yeah exactly
Yeah but not for this
Depends on what their end goal is. Since neither of us know that answer we can't really say.
i think they just want to show off
function helloWorld() {
const greetingParts = [String.fromCharCode(72), String.fromCharCode(101), String.fromCharCode(108), String.fromCharCode(108), String.fromCharCode(111), String.fromCharCode(44), String.fromCharCode(32), String.fromCharCode(87), String.fromCharCode(111), String.fromCharCode(114), String.fromCharCode(108), String.fromCharCode(100), String.fromCharCode(32)];
let greeting = '';
for (let i = 0; i < greetingParts.length; i++) greeting += greetingParts[i];
return greeting;
}
console.log(helloWorld());```
Unnecessary as hell
I think this can be optimized
world.afterEvents.itemUse.subscribe(event => {
const {
source: player,
itemStack
} = event
player.getComponent("minecraft:inventory").container.setItem(player.selectedSlot);```
why the fuck does player.selectedSlot not return a number
Player.selectedSlotIndex
how? It's so hard to optimize it π
Tyyy
function helloWorld() {
const greetingParts = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 32];
return greetingParts.map(code => String.fromCharCode(code)).join('');
}
console.log(helloWorld());```
Can't you just do this ?
Uhh
no π
-# I hope you know I'm sarcastic here lol
How many participants can a scoreboard objective have?
Might aswell just write it hard coded
otherwise any other method is practically the same speed
Or you can just js console.log('Hello, World!');
LOL
dam, it's still going lmao
|| pastebin doesn't like me ||
step up your game
Okay serious question
mb idk that pastes on pastebin have to be moderated
Anyone here to help me with applyKnockback ?
this look like brainfuck language lol
And more specifically? What exactly do you need?
well, i need to applyKmockback to mimic player being pulled upward by a force
Like reverse gravity?
Yeah
how could I get this ontick class to run once at start and once at the end for an onMounted event and an onDismounted event?
let entitiesAtBlock = dimension.getEntitiesAtBlockLocation(block.location);
for (let mountEntity of entitiesAtBlock) {
if (mountEntity?.typeId === "sci:mb_mount") {
if (this.events.whileMounted) {
this.events.whileMounted({ block: block })
time = system.currentTick
}
}
}
}```
Why not just use the levitation effect?
Well, in general, just use applyKnockback once every tick with a throw to the top. player.applyKnockback(0,0,0,1)
well, then it wouldn't be accurate to what i am doinh
function grab_player(dimension) {
const players = dimension.getEntities();
players.forEach(player => {
player.applyKnockback(0, 0, 0, 0.1);
});
}```
is this valid ?
world.getPlayers()
well, i am trying to make basically half life barnacles
so it affects ALL entities
why name it players 
apperantly applyKnockback dont work on entities
it works, but not for all
Knockback resistance do effect it
Even if that were true, does it really matter? It honestly shouldn't.
how so ?
meh not really
It seems to depend on some entity component
So how do you check if its an entity or a player ?
if (entity.typeId == 'minecraft:player') {
// player
} else {
// entity
}
or instanceof
if (entity instanceof Player) {
}
else {
}
instanceof*
thanks
make sure to import the Player class from server if you do this
Can anyone tell me if itβs possible to detect when a player changes a wandering villager's name using a name tag?
you can check if you interact with a villager with a nametag in your hand.
Documentation for @minecraft/server
Thanks.
fr
Is there a native method for setBlock ?
function growth(e) {
const { block } = e;
// Get the block's current location
const { x, y, z } = block.location;
// Get the block below the current block
const blockBelow = block.dimension.getBlock({ x, y: y - 1, z });
// Check if the block below is air
if (blockBelow && blockBelow.typeId === 'minecraft:air') {
block.setType('cosmos:cavernous');
}
}```
is this valid ?
What event are you subscribed to
im trying to make a custom component for a custom vine you see
:}
Looks fine to me
Thanks, this is the function that grows the vine
function growth(e) {
let block = e.block
if (block.dimension.heightRange.min == block.y) return
if (block.below()?.typeId == 'minecraft:air') {
block.below().setType(block.typeId)
}
}
Thanks, this works too.
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
blockComponentRegistry.registerCustomComponent('cosmos:cavernous_vine', {
onTick({ block }) {
const cavernousVine = new CavernousVine();
cavernousVine.grabPlayer(block);
cavernousVine.poisonPlayer(block);
},
onRandomTick({ block }) {
const cavernousVine = new CavernousVine();
cavernousVine.vineGrowth(block);
}
});
});```
this works ?
this one is called useless
gasp!
guys, so i've found this template for player joining the world welcome message, adapted it up to myself, but i get an error that crashes all of my scripts, "unexpected await keyword", and i dont understand what's wrong with await system.waitTicks
import { world, system } from '@minecraft/server'
let playerJoinStatus = new Map()
const DELAY_TICKS = 800
world.afterEvents.playerSpawn.subscribe(data => {
const player = data.player
const playerName = player.name
if (player.initialSpawn) {
if (!playerJoinStatus.has(playerName)) {
await system.waitTicks(DELAY_TICKS)
world.sendMessage('Β§7Welcome!')
playerJoinStatus.set(playerName, true)
}
}
})```
import { world, system } from '@minecraft/server'
let playerJoinStatus = new Map()
const DELAY_TICKS = 800
world.afterEvents.playerSpawn.subscribe(async (data) => {
const player = data.player
const playerName = player.name
if (player.initialSpawn) {
if (!playerJoinStatus.has(playerName)) {
await system.waitTicks(DELAY_TICKS)
world.sendMessage('Β§7Welcome!')
playerJoinStatus.set(playerName, true)
}
}
})```
Add the async
ah, and that's it really?
but what is it for? idk, i never used it
oh hi Vlad
hi Refracted
:]
to run the code asynchronously
and allow await keyword
alr, thank u
also, the message doesn't appear, maybe bcs the world is loading longer than i set the delay, and the message appears before i enter the world so i cant c it
i extended the delay but nope, didnt send the message
playerSpawn do sometimes triggers even tho the player isn't loaded or in the game yet fully.. you can try to make a function that constantly sends a message till they're loaded.
Y'know the forceShow function for server form?
no
oh wait
it got sent
i removed if (player.initialSpawn), and it got sent
800 is 40 sec...
that triggers when the player joins for the first time in the world... Not literally, but when you join the server and you die it won't trigger unless you leave and join the world again.
thought i rejoined the world and i got it sent again
i know, but before i removed if (player.initialSpawn), i waited for like 3 minutes and it didnt appear, and then i removed the if statement and the message appeared
oh, i'd like the message to be sent only once when joining the world
i made this const const initSpawn = data.initialSpawn, and made if statement with it, will test if message will be snet only once
nope, being sent again...
kindly show us the code pls
import { world, system } from '@minecraft/server'
let playerJoinStatus = new Map()
world.afterEvents.playerSpawn.subscribe(async (data) => {
const player = data.player
const initSpawn = data.initialSpawn
const playerName = player.name
if (initSpawn === true) {
if (!playerJoinStatus.has(playerName)) {
await system.waitTicks(800)
player.sendMessage('Β§7Welcome! Β§fThank you for playing with Random Add-On! Read all the details about the Add-On on the downlaod page! Β§7Team Members: Β§6VLAD360 - Project Lead, Coder, Nerpa4ch - Visual Design Lead, Nouve More - Artist, Natitun - Concept Artist, Rofoo - Mob Artist, Steve - Musician, Pavel Kvakov - Level Designer, Ribossomo - Sound Designer, Glider - Game Designer')
playerJoinStatus.set(playerName, true)
}
}
})```
the map is always empty at world init, and player isnt there
Hmmm
Try lower ticks before the final 800 ticks for tests
For what?
idk
what? so like, another message got sent before 800 ticks?
@subtle cove is this correct though ?
Uhm, consider it as the testing phase where u test the lower tick like await system.waitTicks(100)
Uhh, did u test how often it triggers
No, i haven't tested it yet
so i lowered the ticks to 100, ive made another world, the message got sent like, after 2 seconds after i entered the world, but the message appeared again when i rejoined the same world
idk what it means, idk how to use Map, as i said, i just found the template on this server, but im trying to understand what this Map does
It's not the map that's the issue actually
So like there's another script doing it...
ik, i just replied to u saying about the map
nah, i have only this welcoming message script, it was in system.runInetrval, like, checking for player's velocity, and if it's greater then 0, send the message, but i moved it to playerSpawn, and removed this script from inetrval
there's only one script basically
Ok, so rejoining the world triggers it again.
Only if it's single player
If the world's been running it only triggers once
So like every after world start cus that's when the map used there is empty. On world start/initialization
so what should i do
what if i unsubscribe from the event when it has been triggered already?
or actually, if other players join the world, like, multiplayer, the probably won't c the message
if (data.initialSpawn)
and it did work
This should be fine. Just some minor optimizations
yes, i just had player, not data
what optimization should i do? maybe set the ticks to like, 1000, so 50 seconds?
import { world, system } from '@minecraft/server'
let playerJoinStatus = new Set()
world.afterEvents.playerSpawn.subscribe(async (data) => {
const player = data.player
if (data.initialSpawn) {
if (!playerJoinStatus.has(player.name)) {
await system.waitTicks(800)
if (!player.isValid()) return
player.sendMessage('Β§7Welcome! Β§fThank you for playing with Random Add-On! Read all the details about the Add-On on the downlaod page! Β§7Team Members: Β§6VLAD360 - Project Lead, Coder, Nerpa4ch - Visual Design Lead, Nouve More - Artist, Natitun - Concept Artist, Rofoo - Mob Artist, Steve - Musician, Pavel Kvakov - Level Designer, Ribossomo - Sound Designer, Glider - Game Designer')
playerJoinStatus.add(player.name)
}
}
})```
|| set immediately 72000, which would work only after an hour ||
The waitTicks depends on u how long u wana send the msg
bcs when player is joining the world, the loading may take too long and the player just won't c the message, the message will appear before the world loads in, is it how it works?
welp, im rejoining the world, and again, the message is appearing again
I get it... Just a hunch, what if create a forceShow then when it opens close the form and send a message
you can close forms forcefully without damage or anything
Since delay is used here and player gets used afterwards, isValid checks is necessary to check if they're still in the world or has left
Rejoining the world where, a server or ur single player world?
single player
world.afterEvents.playerSpawn.subscribe(data => {
if (!data.initialSpawn || data.player.hasTag('not_new')) return
let player = data.player
let rotation = player.getRotation()
let id = system.runInterval(() => {
if (!player.isValid()) return system.clearRun(id)
let rot = player.getRotation()
if (rot.x != rotation.x || rot.y != rotation.y) {
system.clearRun(id)
player.addTag('not_new')
player.sendMessage("hi")
}
})
})
Or use form to show the message, rather than sendMessage
just use tags / dp to tag the players who got the message
that's smart... y didnt i think of that...
This code sends a message when the player starts moving, not just after 50 seconds
Hmm, so u actually needed a permanent "tag" for the message
Map and Set and other objects in js are empty at start ||unless it's set-up in a complex way||
idk how to use it
what do forms have to do with that...
The long message
Wait until the form opens. when it opens, close it and send a message
worth a try i guess
but that may look weird
i just did this and that's it, it works perfectly how i need ```js
import { world, system } from '@minecraft/server'
world.afterEvents.playerSpawn.subscribe(async (data) => {
const player = data.player
if (data.initialSpawn) {
if (!player.hasTag('v360:welcome_message')) {
await system.waitTicks(100)
player.sendMessage('Β§7Welcome! Β§fThank you for playing with Random Add-On! Read all the details about the Add-On on the downlaod page! Β§7Team Members: Β§6VLAD360 - Project Lead, Coder, Nerpa4ch - Visual Design Lead, Nouve More - Artist, Natitun - Concept Artist, Rofoo - Mob Artist, Steve - Musician, Pavel Kvakov - Level Designer, Ribossomo - Sound Designer, Glider - Game Designer')
player.addTag('v360:welcome_message')
}
}
})```
but i think map isn't even needed here since im just testing if the player has tag or not when joining
now player.hasTag
oh wait, i had the old code copied
π
here, updated
seem fine
This code is still more reliable
okie, i'll make use of it then
-# isValid, where π
yeah, +clearRun if not
alr, another question, but i think the answer is obvious, is there a way to detect block under the entity all the time without using system.runInterval?
no
im still trying to optimize my system.runInterval script, and if possible, trying to find alternative for ceratine events to not use inetrval
welp, just how i thought
i actually got my script down from like 1000 or so lines to 251
world.afterEvents.playerSpawn.subscribe((initialSpawn) => {
for (const player of world.getAllPlayers()) {
const playerId = player.nameTag;
if (initialSpawn) {
player.onScreenDisplay.setTitle({ rawtext: [{ translate: 'testing.title', "with": ["\n"] }] }, {
stayDuration: 40,
fadeInDuration: 20,
fadeOutDuration: 20,
});
system.run(() => {
system.runTimeout(() => {
player.runCommandAsync("tp -42 -22 29 0 0");
}, 30);
});
} else {
return;
}
}
});
Can someone help me and change this script, so player will only run this title and command tp - after First time join to world
but i'm still getting the "hang" crash sometimes
ahaha, we were just discussing sending message only once player joins the world for the first time
actually, i can make, for example, detection of block under the entity in a .mcfunction file, would it be more stable then using system.runInterval in script?
thought i assume no
probably because you're checking a lot of things in single tick
how do you get the current location of a player ?
so i think ye, i'll change a few things to function and it will also be ran every tick in tick.json... which is pretty much the same thing...
aaaaargh, there r just some events in my system.runInterval which dont really have any alternatives, and so, have to be ran every tick
what is wrong with my docs
what about block location ?
player.location and block.location
poisonPlayer(block.location) {
const players = this.world.getPlayers(); // Get all players
players.forEach(player => {
player.addEffect("minecraft:poison", 2); // Apply poison effect for 2 seconds
});
}
}```
whats wrong with this ?
Debug result for [code](#1067535608660107284 message)
Compiler found 5 errors:
[36m<REPL0>.js[0m:[33m2[0m:[33m1[0m - [31merror[0m[30m TS2304: [0mCannot find name 'poisonPlayer'.
[7m2[0m poisonPlayer(block.location) {
[7m [0m [31m~~~~~~~~~~~~[0m
``````ansi
[36m<REPL0>.js[0m:[33m2[0m:[33m14[0m - [31merror[0m[30m TS2552: [0mCannot find name 'block'. Did you mean 'Block'?
[7m2[0m poisonPlayer(block.location) {
[7m [0m [31m ~~~~~[0m
[36m@minecraft/server.d.ts[0m:[33m3326[0m:[33m15[0m
[7m3326[0m class Block {
[7m [0m [36m ~~~~~[0m
'Block' is declared here.
``````ansi
[36m<REPL0>.js[0m:[33m2[0m:[33m30[0m - [31merror[0m[30m TS1005: [0m';' expected.
[7m2[0m poisonPlayer(block.location) {
[7m [0m [31m ~[0m
``````ansi
[36m<REPL0>.js[0m:[33m3[0m:[33m30[0m - [31merror[0m[30m TS2339: [0mProperty 'world' does not exist on type 'typeof globalThis'.
[7m3[0m const players = this.world.getPlayers(); // Get all players
[7m [0m [31m ~~~~~[0m
``````ansi
[36m<REPL0>.js[0m:[33m8[0m:[33m1[0m - [31merror[0m[30m TS1128: [0mDeclaration or statement expected.
[7m8[0m }
[7m [0m [31m~[0m
ESLint results:
<REPL0>.js
2:29 error Parsing error: ';' expected
its adding effect for 2 ticks btw
not seconds
oh shit
Ohh I was about to say that, a lot of examples are flipped again or not related to the function specified
Just <value> * 20
they aren't flipped again, it's been like this for over a year and I just noticed it
lol, I say again because I always open your docs, and for example getEffects and getEffect have new examples but still switched, once I saw getBlockFromRay and getEntitiesFromRay examples are switched
#1067869022273667152
Ok thanks
I am thinking of adding a report button next to the examples so you can send a github issue to me, how does that sound?
good I guess lol.. I always open your docs and it sometimes confused and makes me laugh why it does that...
Guy can you tell me again what's the actual bytes of Dynamic property values?
like the exact value
what do i use to interact with a block with any item in hand? or no item at all
the equippable component is disabled to entities yet, closest one is use runCommand and hasItem and loop all items registered in the world if something matches returns true
Testfor?
You can use testFor command and get the successCount property from it.
if it returns greater than 0, it means the command was successful.
he already knows how to do it .. that's on his post
I was not aware, clearly.
Nah you good
why is he asking "testFor" then
that's where before I answer him in his post
do you mean you already answered him after he asked here?
got it.
seems like this was directed at me.
Lol no...
maybe dont answer so many posts
lol
you'll end up getting multiple pings for sure
only if they didn't ping me first π... I have too many ghost pings lol
Y'know there's a ping but the message isn't there π€·πΊ
hate that
Definitely, I'll change my name soon lol
i was wondering why you remove ping from all your replies lately
Me?
Yeah intentionally do that since I don't want to annoy people and to kinda escape πΊ
lol
alr
lol, the escape part is relatable.
I mean I replied to them π€·, just that they didn't see it lol
I'm sorry for all the people that I happened to use this type of technique with...
I'm also surprised that you noticed it lol...
the ancient mastery of vanishing
is there a way to get blocks within taxicab distance as opposed to complete BlockVolume?
How do I identify when I'm moving by script?
you can try player.getVelocity()
Entity.setDynamicProperties()
Sets multiple dynamic properties with specific values.
i don't get this.
I guess it's just a way to make more performant modifying multiple properties at once and also a better way to do it instead of multiple lines with Entity.setDynamicProperty() or having to use loops...
i get that but the confusing part there's no identifier π
-# nvm
how better is to create a event listener for every instance of a class
or have one event that calls a method for all the classes? π€
while the code is pretty well-organized, they're some things that aren't the best of the practices
- using JavaScript
- why do you feel the need to deconstruct afterevents
- no consistency
- sometimes you use if statements and sometimes ternary operators (for one liners)
- the indentations
- using arrow functions incorrectly
while this works
()=> { return 1 }
do this
() => 1
- one liners everywhere
- using too many variables
- just export when the function is declared
export func(){}
- the file is too big
- redundant functions
2
Explain further what u mean
static event listener for all instances of the class, vs each class making their own listener
What is this report button
report mojang
ban notch
Jayly added that because of me.
so if you see the example wrong or examples are switched with some functions just click the report
import { world, system } from '@minecraft/server';
import { ActionFormData } from "@minecraft/server-ui";
world.afterEvents.playerSpawn.subscribe(async (data) => {
const player = data.source
const initSpawn = data.initialSpawn
system.run(() => main(player))
})
function main() {
const cord = { x: 125, y: -23, z: 357 };
const form = new ActionFormData()
.title('Β§lBenvenutΒ§3oΒ§rΒ§l/Β§3aΒ§r Β§lnella Β§6Fantasy Craft! ')
.body("§l§6Fantasy Craft §r§lè un mondo di avventura e fantasia, dove puoi esplorare terre nuove, incontrare creature incredibili e sfidare sfide impossibili!\n§l§9Spero che tu possa goderti il tempo con noi e scoprire tutti i segreti di Fantasy Craft!\n§l§aTi auguro una buona esperienza e una buona avventura!\n§l§esegli la tua classe per andare avanti.")
.button("Β§lΒ§6segli classe")
.show(player).then(({ canceled, selection }) => {
if (canceled) {
player.playSound("random.break")
}
if (selection == 0) {
player.teleport(cord);
}
})
}
help
index.js 17 is
.show(player).then(({ canceled, selection }) => {
The function takes no parameters
main(player)?
You indeed do not have a variable defined named "player".
???
data.source -> data.player
thx
now it works
Yo can someone suggest me a challenge for me to do? A hard one. (Scripting api challenge y'know)
Debug result for [code](#1067535608660107284 message)
Compiler found 1 errors:
[36m<REPL0>.js[0m:[33m7[0m:[33m16[0m - [31merror[0m[30m TS2551: [0mProperty 'hastag' does not exist on type 'Player'. Did you mean 'hasTag'?
[7m7[0m if(!player.hastag(tag)) {
[7m [0m [31m ~~~~~~[0m
[36m@minecraft/server.d.ts[0m:[33m5970[0m:[33m5[0m
[7m5970[0m hasTag(tag: string): boolean;
[7m [0m [36m ~~~~~~[0m
'hasTag' is declared here.
ESLint results:
<REPL0>.js
14:11 error 'form' is assigned a value but never used @typescript-eslint/no-unused-vars
22:17 warning The /tag command can be fully replaced with the Entity.addTag api in the @minecraft/server module. See https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entity#addtag for more information. minecraft-linting/avoid-unnecessary-command
27:17 warning The /tag command can be fully replaced with the Entity.addTag api in the @minecraft/server module. See https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entity#addtag for more information. minecraft-linting/avoid-unnecessary-command
okay
hastag > hasTag
Wave function collapse for ... just about anything fun you can think of. Perhaps a procedural tile generation for a 2D minigame, like a maze
Can someone help me fix this the problem is the dialogue not showing up even I click the Talk button I'm making a custom npc
Here the file
is this script related?
It's script and entity I think
Is it possible to open a form by interact to entity
sure
import { world } from "@minecraft/server";
import { ModalFormData } from "@minecraft/server-ui";
world.afterEvents.playerInteractWithEntity.subscribe((event) => {
const player = event.player;
const entity = event.target;
if(entity != "id") return
const form = new ModalFormData();
form.title("entity Interaction");
//...
form.show(player).then((response) => {
if (response.canceled) return
//...
});
});
Nice thanks
outpost script? what is that?
I think maybe something like farcry
its an area with enemies you need to clear
if that's not it, I dont know what he's referring to
seem easy enough i guess, but he need to be more specific in what he need the help on
I agree.
please describe what you need help with and maybe share your code
so a base system?
what i meant is you need to start working on it and then ask:
- how do i do this ...
and so on
you can't just ask a general question and expect someone to "have it ready/code it for you" , most of us are willing to help in small tasks but not in big stuff, unless we had a similar project.
Agreed, thats why I told them to share their code
see what they have so far, so we could help with errors, but not code it for them.
i can describe what you need to do for each part of that system, but i doubt that will help
that is great
so what do you need help with?
small suggestion, store the outpost details in dynamic properties
Working on it now πͺ
what is the next best thing to giving vanilla blocks tags?
You cant edit them tags
But you can set a world dynamic property with a json object with bloc typeid and location so you added a tag to a block
There we go
Thanks
how would you do both?
does setDynamicProperty accept two values?
accepts strings boolean numbers and vector3
I recommend creating an object then stringify it.
but you can do JSON.stringify({location:location,blockTypeId:block.typeId})
no problem
Can anyone help me and tell how I can have rawtext title here?
class ChestFormData9 {
#titleText; #buttonArray;
constructor(size = '9') {
const sizing = sizes.get(size) ?? ['Β§cΒ§hΒ§eΒ§sΒ§tΒ§0Β§9Β§r', 9];
this.#titleText = sizing[0];
this.#buttonArray = [];
for (let i = 0; i < sizing[1]; i++) {
this.#buttonArray.push(['', undefined]);
}
this.slotCount = sizing[1];
}
title(text) {
this.#titleText += text;
return this;
}
button(slot, itemName, itemDesc, texture, stackSize = 1, durability = 0, enchanted = false) {
const ID = typeIdToDataId.get(texture) ?? typeIdToID.get(texture);
this.#buttonArray.splice(slot, 1, [
`stack#${Math.min(Math.max(stackSize, 1) || 1, 99).toString().padStart(2, '0')}Β§r${itemName ?? ''}Β§r${
itemDesc?.length ? `\nΒ§r${itemDesc.join('\nΒ§r')}` : ''
}`,
(((ID + (ID < 262 ? 0 : number_of_1_16_100_items)) * 65536) + (!!enchanted * 32768)) || texture
]);
return this;
}
pattern(pattern, key) {
for (let i = 0; i < pattern.length; i++) {
const row = pattern[i];
for (let j = 0; j < row.length; j++) {
const letter = row.charAt(j);
if (key[letter]) {
const slot = j + i * 9;
const data = key[letter];
const ID = typeIdToDataId.get(data.texture) ?? typeIdToID.get(data.texture);
this.#buttonArray.splice(slot, 1, [
`stack#${Math.min(Math.max(data?.stackAmount ?? 1, 1) || 1, 99).toString().padStart(2, '0')}Β§r${data?.itemName ?? ''}Β§r${
data?.itemDesc?.length ? `\nΒ§r${data?.itemDesc.join('\nΒ§r')}` : ''
}`,
(((ID + (ID < 262 ? 0 : number_of_1_16_100_items)) * 65536) + (!!data?.enchanted * 32768)) || data.texture
]);
}
}
}
return this;
}
show(player) {
const form = new ActionFormData()
.title(this.#titleText);
this.#buttonArray.forEach(button => {
form.button(button[0], button[1]?.toString());
});
return form.show(player);
}
}
And this is not working.
.button(1, { rawtext: [{ translate: 'first.button', "with": ["\n"] }] }, ['', { rawtext: [{ translate: 'first.button.lore', "with": ["\n"] }] }], 'textures/items/amethyst_shard')
It shows [object Object] in game
you gave me an idea since rawtext sysntax is a bit hard i think tomorrow ill create an easy rawtext config.
Yeah, I'm trying this since two days, but didn't came up with any solution yet
I've used rawtext syntax for most of my projects and scripts with forms, but since this is ChestUI from github and it's already done I don't know how to change that into the same rawtext as in ActionForm
Can you ping me when you succeed?
Yeah
You can't use rawtext here because it's a custom form and needs keys for the buttons. And it turns out that you combine the key and the object into one line, so you get [object, Object]
So my only option is to make another .js file with exported data of buttons or just type the button string as plain txt?
There is no other option, for real???
I don't know how this UI works, so I can't say. Maybe there is one, but then you will definitely need to configure the UI so that it does not require a key for the button.
It's from this source, only the form construct: https://github.com/Herobrine643928/Chest-UI
And that's the construct of UI what I have sent, just it
I don't know how to edit the form so that it works with rawtext
Wym by I can have a rawtext title?
#1067535608660107284 message
title(text) {
this.#titleText += text;
return this;
}
This and buttons are not working
When I type rawtext syntax into buttons or titles in the custom form
.button({ rawtext: [{ text: '' }, { text: '' }] });```
this type of rawtext?
Yeah
Nvm, I just saw the bottom of the message... lol
I'm kinda confused about what your goal is... Why do you need to rawtext it?
To translate it?
{ rawtext: [{ translate: 'button.1', "with": ["\n"] }] } I need this into custom form
Like here
.button(1, <RAWTEXT>, ['', <RAWTEXT>], 'textures/items/amethyst_shard')
Yep
Translate
I succeed with normal actionform
give me the original format or how it should be inputted in the first place.
I open post and ping you there
Hey I have a question about Debugger! / Attaching Minecraft - Visual Studio.
I thought I have follwed this...
https://learn.microsoft.com/en-us/minecraft/creator/documents/scriptdevelopertools?view=minecraft-bedrock-stable#debugging-with-minecraft-bedrock-edition
I am following bedrock instructions.
I Ran:
CheckNetIsolation.exe LoopbackExempt -a -p=S-1-15-2-1958404141-86561845-1752920682-3514627264-368642714-62675701-733520436
I am using regolith, so my code is outside of mojang folder.
Here is my launch.json
(Using typescript, so i have sourceMapRoot, and generatedsourfceroot)
{
"version": "0.3.0",
"configurations": [
{
"type": "minecraft-js",
"request": "attach",
"name": "Debug with Minecraft",
"mode": "connect",
"preLaunchTask": "build",
"targetModuleUuid": "057766c1-5cc6-41b3-a4b2-b697881385ac",
"generatedSourceRoot": "${env:LOCALAPPDATA}/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/wildcraft_bp/scripts",
"sourceMapRoot": "${env:LOCALAPPDATA}/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/wildcraft_bp/scripts",
"port": 19144,
}
]
}
I click the green button to Run With Minecraft, I see a yellow bar around VS, which i assumed signified it is listening on the port.
I ran script debugger connect in Minecraft, but I keep getting the error 'Failed to start debugger'
The in game command wants /script debugger connect [host: string] [port: int] and i know that the port is 19144, but not sure what to put for host. I figured script debugger connect was enough
change your "mode" to "listen"
rn it's trying to connect to the client
this is my config
{
"version": "0.3.0",
"configurations": [
{
"type": "minecraft-js",
"request": "attach",
"name": "Debug with Minecraft",
"mode": "listen",
"localRoot": "${workspaceFolder}/packs/BP/scripts/",
"port": 19144
}
]
}
const BoostingPad = {
onStepOn(event) {
const { entity, block, dimension } = event;
// Ensure the entity is a player
if (!(entity instanceof Player)) return;
// Get the player's rotation (yaw and pitch)
const rotation = entity.getRotation(); // Assuming getRotation gives yaw and pitch in degrees
const yaw = (rotation.x * Math.PI) / 180; // Convert yaw to radians
const pitch = (rotation.y * Math.PI) / 180; // Convert pitch to radians
// Calculate the direction vector
const forwardX = -Math.sin(yaw) * Math.cos(pitch);
const forwardZ = Math.cos(yaw) * Math.cos(pitch);
const upwardY = Math.sin(-pitch) + 0.5; // Slight upward boost
// Boost the player by applying velocity
const boostMultiplier = 1.5; // Adjust boost strength
const velocity = {
x: forwardX * boostMultiplier,
y: upwardY * boostMultiplier,
z: forwardZ * boostMultiplier,
};
entity.applyImpulse(velocity); // Apply the calculated impulse
},
};```
[Scripting][error]-Error: applyImpulse is not supported for players at onStepOn
Anybody that knows why this isnt working and is there a workaround? (only workaround I have in mind is using a custom entity that places a roar component next to the player, I have done that before and that works but I thought I could simply use a velocity function)
How do I apply effect to entity with specified amplifier and no particles?
I tried this:
nearbyEntity.addEffect('blindness', blindnessDuration, 0, true);
But got error
nearbyEntity.addEffect('blindness', blindnessDuration, {amplifier: 0, showParticles: true});
Why doesn't anyone want to look at the documentation?π’
Thank you
I tried but I don't really know js so I sometimes can't understand simple things 
Try using typeId instead of instanceof
ApplyKnockback works @dim tusk ty
is there any reason why?
|| Try not to use AI ||
" applyImpulse is not supported for players"
just read the error man
lol, I thought it's for entities π your code returns if its players.... That's why I deleted my message
did you learn anything? That's the thing, if you use AI make sure you learn anything at all
I know how to code I mostly used it because I didn't know any javascript at that moment
now I work with it because it saves hours of time
also it comments my code nicely
You won't learn JS if you use AI
until it doesn't
hmm... I hate comments lol, because the code is in the name already, it's unnecessary
well then I have to do it myself it's not like I don't know how to use the script API
|| "I know how to code, but I don't know how to code" ||
Meh, stop convincing people not to use AI anymore they have the same excuse "Easier", "Saves time or efficiency", "if it works then it works", "nothing's wrong using AI it's just a help", "I still learn"
The interesting thing is that they eventually come here
that not the point
using ai is ok
but at least you should know what are you doing
it is useless to argue
That's the fun part. Yes they do but mostly don't for obvious reasons
Just ask here if you need help, it's better than asking the AI
I did?
I mean, yeah for someone who does not really do programming because they have other lives, it's understandable π€·
either way code is a code.... πΆ
You first went to AI, the code didn't work and you came here
i remember the first script i made was with the help of ai, so i can understand his pov
but yeah you should definitely know what are you doing (i wasn't at that time)
I also looked on wiki and documentation and since I didn't find the reason why velocity doesnt work on players I asked here
Don't argue anymore, it's useless.. at least just minimize the usage if you can't stop and just don't expect it always works since AI sometimes makes their own code or get online
Ngl, if i ever use ai, it's only to find references or documentation
I cannot fathom using ai generated code
I use AI to generat JSON
I use NI
"NI"?
Natural Intelligence
Y e s
Nico Nico Ni
I'm sharing my thoughts here because I'm open to defending them. Whether you like or dislike AI is a personal opinion, not a fact. Whether you agree or disagree that AI can assist in learning new ideas is also a personal opinion, not a fact.
At the end of the day, it falls on the individual using the tool to determine its valueβwhether they have taken the time to understand what they are looking at, how it works, why it works, and where they can go from there. The code provided, whether incomplete or not, is no more disjointed or incoherent than finding random segments and blocks of code on websites like Reddit, Stack Overflow, or any other source of your choosing.
It is still code provided by an entity that nobody knows. Regardless of whether that entity is AI or a random stranger on the internet, the individual receiving the code must still take the time to understand it, learn how it works, and decide where to go from there if they want to grow. The logic of learning does not change based on how the information is received. What truly matters is what they do with that informationβit determines whether they grow or remain stagnant.
So, stop arguing about people using AI when some of you arenβt any better at providing advice on coding. I've been writing code for over 10 years, and I use AI because I understand its strengths. By leveraging those strengths, I can extend my services at a much faster pace. If you think otherwise, come challenge me, and weβll see who wins that debate.
Arguing about this is silly and wasteful. Let's focus on what really matters, by providing help when people ask, if you want to help.
However, you also need to be able to use AI, but not everyone does it βcorrectlyβ. Most people, especially beginners, simply ask AI ββfor code and do not develop their own thinking, thereby not increasing their coding abilities. So I still remain of the opinion that it is better to use AI only when you know what you are doing, that is, not for beginners
It is still code provided by an entity that nobody knows. Regardless of whether that entity is AI or a random stranger on the internet, the individual receiving the code must still take the time to understand it, learn how it works, and decide where to go from there if they want to grow. The logic of learning does not change based on how the information is received. What truly matters is what they do with that informationβit determines whether they grow or remain stagnant.
But yes, i do agree that there's no purpose in arguing because it is a matter of opinion, as mentioned
AI code is not always correct. It can be used for studying. But again you need to be able to do this, and not just copy, see what it works or doesnβt work and look for new code instead of studying the current one
My two cents on AI generated code is, don't go posting on online forums why your AI hallucinations don't work.
My quote still remains the same. I can source you plenty of examples on Reddit and Stack Overflow where answers are marked as answers but are incorrect. So stop trying to fight my quote and take a moment to understand what I am saying.
I wholeheartedly agree. Unfortunately, most new people I've seen don't take the time to understand what the code they copy/paste actually does.
This is very true, and it ultimately falls on the individual. They must take the time to understand what they are looking at if they wish to grow, or simply remain stagnant. That's a responsibility which falls on the individual.
I just said that you need to be able to study the code that was given to you, and not just copy it and wait for it to work.
I completely agree with thisβpeople often overlook that AI is a tool, and using it doesnβt make you more or less intelligent.
Ah, yes, that is true. Whether the code is received by a stranger or AI, the individual receiving it should definitely be responsible.
When I was learning I used to copy paste other people code and asked ChatGPT what does the code mean, my ChatGPT has learned script api and now if I ask something it learned how to do script without errors
can agree with most of what you said, the only thing is you can't compare AI generated code to a code that you got from somewhere else, the AI one don't work most of the time. AI do help a lot but as smokey said, as soon as you drop a AI generated code in chat, most of us will not offer any help (if the code was really bad at least)
for the record i wasn't arguing, i personally use it, i was just suggesting for hem to learn. it is better and way more efficient to use AI as a helping tools in things that you already know
Doesn't matter if the code doesn't work. I was learning to code years before AI was even a thing. Couldn't tell you how many times I found examples of code online that appeared to suit my needs but ultimately failed and didn't work. That is why I said the following, and I still stand by it:
It is still code provided by an entity that nobody knows. Regardless of whether that entity is AI or a random stranger on the internet, the individual receiving the code must still take the time to understand it, learn how it works, and decide where to go from there if they want to grow. The logic of learning does not change based on how the information is received. What truly matters is what they do with that informationβit determines whether they grow or remain stagnant.
^ I agree with this statement above
Wadahell happened here.
My opinion is that people do start with big things without even knowing what scripts are and just use ai and copy paste code, I think they should learn first basic logic things and then Minecraft apiβs things
Today is the day to talk about AI, lol
this is kinda like blending things, when I use a blender does it mean I cheated because I used a tool?
-# what I said is very far from the topic sorry
I agree that people shouldn't rush and should definitely take the time to learn the basics. We can help them with that by pointing them in the right direction.
Won't be able to please everyone though. Unfortunately we live in a world where not everyone can be pleased lol. So make the best of every situation.
It doesnβt matter whether you cheated or not, what matters is what knowledge you learned from it that you could apply in the future.
Future doctors will have a ChatGPT assistant during surgeries
I got to go but I feel this was a very productive discussion in the end.
This may be useful, but confidence in their professionalism will be greatly reduced.
yeah
but still, there is huge different between a code generated from a language model and a human one, you won't see a human inventing functions that doesn't exist and acting like it dose work
Itβs like cooking pasta with a microwave π€
i hope so at least lol
Hey, I cook pasta in a microwave
-# jk, but what the fuck.
system.getTranslatedWords()```
Americans do it π
what? Lmfao
Aw hell nah
yeah lol
that what ai known for
World.ApplyWeaknessEffectToAllPlayers(1000) // 1000ms
Real
So from what i learned, ai is like a calculator: it improves the workflow but is redundant if you do not know what it does
Well, that's it, the marathon of inventing new methods has begun.
I also see coding as a form of art but that isn't very pertinent to this discussion
Bro i swear
I use ai to do things like Object.enteries().enteries(k=> Object.values(k))
When I create mess with objects
it is good enough in general js
really? You don't know how to use object entries?
I'm not sure what they do since i am more of a C programmer than JavaScript but it looks like an iteration
Correct me if I'm wrong, please
Damn. I lost all my files (most of them aren't saved yet)
I know but like when I create something I do like to overcomplicate it like
In my addon I used
Const food = {
meat:{
Raw:{
List:[]
daysBeforeExpiring:4
},
Cooked:{}
},
vegetables:{
}
}
returns an array of the key/value pairs of an object
that's easy to handle...
But I hate your format
Day 3.999 - tasty and juicy steak,
day 4 - steak? What are you talking about?
Yeah but I do that for every slot of the inventory every 20 ticks to check if the item matches and if it has an expire date yet
I mean it was an example
The actual code is different
No difference... But I do get your point, it's sometimes a mess
maybe because I've been handling json since I started this and I'm kinda pro identifying or understanding json and it's format
I agree with this wholeheartedly lol. To me, coding is therapeutic. My feelings towards code is the equivalence of a bookworm reading a good book.
I'm glad i found someone who shares the same opinion π
Usually i see people coding from necessity or skill, i just do it for fun
Same π
because it's their job, that's why? I dunno, I have a different job or things outside programming.
No i mean
Being a programmer but not being passionate about it, if I explained that correctly
hmm, tho it doesn't just apply to programmers.
I came back to read this again because I got a good laugh out of it. AI Hallucinations would make for a good t-shirt π
Ok I'm back
AI Hallucinationsβ’
hey, trying to add a variable into a command, its done like this right?
event.block.runCommandAsync('function raycast/setblock${randomNumber}');
but in the examples i saw the variable part was a different colour, i think mine is still just part of the string
Use backtick `
event.block.dimension.runCommandAsync(`function raycast/setblock${randomNumber}`);```
Also put dimension since blocks can't run command only entities
damn, maybe i wont bother with a command then
as the function basically just structure loads on the blocks location
is there some structure functionality in scripting
world.structureManager.place()```
https://jaylydev.github.io/scriptapi-docs/preview/classes/_minecraft_server.StructureManager.html
-# I sent the wrong link lol
thanks
@devout hazel what dose the raycast function do
I tried it with a small range, but it doesn't really work (it should be a square, right?)
Its tied to the players position so it will move up and down you may need to play with it to get a square as its only on two sides depending where the player is
Why is that?
Not that i would ever use it but how do people load world map onto like ui or something
Like genuinely, it looks like witchcraft to me
I need urgent help ;-;
Does anyone know of any code that detects when a player types certain text and executes the script? I'm trying but I always get an error in the console...
In the chat?
If so, you must enable experiments i believe
Since chat events are in a beta release always for some reason
Thank you
my use case was i needed the border to be present per player as they world border was set dynamiclly it could be 1k or 100k and thats from 0,0,0 on all axis so it made sense that if the player was within range on the border to show then that area ( they may have been under ground) this was as a line where you need it as a square
if these locations are set zones use 4 points to spawn the particles within that area
Oh
My use case is to simply have a world border that everyone can see
this is what i used that code for to show the border per player https://github.com/Pete9xi/Paradox_AntiCheat/blob/Pre-1.20.50/src/penrose/TickEvent/worldborder/worldborder.ts
how do i download chestFormData? do i have to copy paste all the files from github?
yes
i mean is there a way do download folders instead of copy paste text?!
couse copy paste code is so much inefficient
Thank you
Do chest form data work with custom items?
Want to add custom items / blocks to the form?
Download this_pack to see all item IDs and their icons, including custom ones. Add the item typeId & ID to the typeIds.js file. Note that experimental items shift the vanilla IDs at 256- make sure to manually shift the IDs up, and remember the full typeId for your custom items! You cannot use the constant number_of_1_16_100_items if you chose to add your custom items. Set it to zero!
check the README
I'm in a bit of a pickle. I am attempting to detect WASD.
My use case has the following restrictions:
- Stable only (RIP
InputInfo). - The player is riding a mount, but the mount has a mathematically-controlled location via teleports.
