#Script API General
1 messages ยท Page 88 of 1
already exists
knockback isnt easy todo with my current system
yes
Then times have became hard (:
no... i dont want to do math again
bruh
?
If I remember correctly, I helped you make the movement system.
It's pretty easy to do knockback on it.
Yep, With some lend code from github i made a distance based movement system
22:38:54[Scripting][warning]-[Watchdog] Spike from 'Oraria' (130ms)
is this bad, on start up?
can anyone share their tsconfig.json? i think mine is not working because after compiling it messes up any await or async calls
22:21:47[Scripting][error]-ReferenceError: '__awaiter' is not defined at <anonymous> (core/PlayerManager.js:36)
{
"compilerOptions": {
"lib": ["esnext"],
"target": "esnext",
"module": "esnext",
"outDir": "./scripts",
"rootDir": "./source",
"allowJs": false,
"checkJs": false,
"useDefineForClassFields": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noImplicitAny": true,
"alwaysStrict": true,
"noFallthroughCasesInSwitch": true,
"noImplicitThis": true,
"noUnusedParameters": true,
"moduleResolution": "node",
"baseUrl": "./source",
"paths": {
"*": ["*"]
}
},
"include": ["source"],
"exclude": ["node_modules"]
}
Bro had that shit on speed dial ๐ญ
thank you, ima try this rn๐ญ ๐
for exchange of help , can you please help me with json ui ๐ญ ๐
i will if this fixes that error
XD ok
Found 46 errors in 21 files.
ima cry๐ญ
tsconfig should match with coding style thats why
i think the one i sent is has too strict checks
wait what
what would happen if i use runTimeout inside runInterval
it just works, but... why
Hello! How would I get the item im currently holding? The inventory component is really confusing for me xd
hai
function getMainhand(player) {
return player?.getComponent('equippable')?.getEquipment(EquipmentSlot.Mainhand);
};
Oh I see, so that's why I couldn't get anything from the inventory component one
Thank you so much! I didn't knew that
or this:
const heldItem = player.getComponent('inventory')?.container.getItem(player.selectedSlotIndex)```
selectedSlotIndex doesn't seem to appear in my types although I'll try the first one!
it fixed the issue, so what do you need help with?
How do you get item types from item names?
In previous updates you could import the class Items from the server @ thing but now it doesnt seem to have an export
Ok figured it out
it was replaced with ItemTypes
is there any perf diff b/w set property vs set properties
I think the second one will be a little faster
runInterval executes a block of code repeatedly at a fixed interval, measured in ticks. If you nest a runTimeout inside runInterval, you're adding an additional delay before the inner code runs. For example, if runInterval is set to trigger every 20 ticks, and you include a runTimeout with a 20 tick delay inside it, the inner code (inside runTimeout) will effectively execute every 20 ticks after the interval fires, so every 40 ticks in total.
However, it's important to note that the first execution of runInterval happens around (tick 0 tick 1), and the runTimeout inside it would delay execution by 20 ticks, meaning the first inner execution happens at tick 20. After that, runInterval will fire every 20 ticks (20, 40, 60...), and each time the inner code will be delayed by another 20 ticks (40, 60, 80...), leading to an effective execution of the inner code every 40 ticks.
However, it's important to note that the first execution of runInterval happens immediately (tick 0)
you sure it doesn't get delayed by 1tick? afaik it can be used to exit read only mode, so i was under the impression that it does delay the execution to the next tick
That's a valid point.
I know run delays at the end of the tick. I'm unsure if runInterval does the same but it's very likely now that you mentioned it.
all the system function does afaik
run, runtimeout, runJob, runinterval
Yea it would make sense. In either case, the nested function for runTimeout basically increases the already delayed runInterval.
yeah, just making sure i don't have it wrong
I edited my comment above to reflect it.
Whether at the end of the tick or the following tick, the math is still the same lol. ๐
do we have a way to disable this kind of output or is this yet another random content log I will have to live with forever?
If you have multiple help commands in a single pack, you should properly consider rename those 2 command names to better ones to distinguish each other. And no you can't disable that warning.
It's already distinguished by needing the rc: identifier, adding the capability to do the commands without an identifier was a mistake imo and I will die on this hill
this should be info rather than a warning imo
nobody should be relying on the alias outside of chat so the warning is unnecessary
I'm still using old school CLI until the new custom commands feature gets worked out a little more.
Technically both are CLI.
Yea, that's true but for context and clarity so as to not create confusion, that's why I referenced it as "old school" ๐
I do also hope we are given the ability to put commands into "groups" so they are only alphabetized within that group
makes sense why minecraft has a /? command
otherwise the actual /help command which you would want at the top of the list would end up in the middle
If anyone knows, ping me. ๐
#879773489601585244 message
can you do dynamic properties or something similar on a sign?
oh they dont
does anyone know any alternative?
or a way to see who owns/placed a block
you can detect when a player places a block
you can use that for what you are trying to do.
Im making a sign shop but I cant seem to assign the sign shops to players without having them place their name in the sign. The issue ofc with that is that they can put any person as the owner
My only idea is to save the block and its location within world properties but it seems a little too complicated for this. I mean if its the only method then I will but...
that's what I was going to suggest
In a span of a day i remade the system myself from scratch. i reduced code size by 50% vs what ai gave me.
I'll send a vid of it
and code
made with 0% ai
i enjoyed the process more actually
again, compressed from 400mib srry for the quality
Oh, i forgor the part where the parts break etc.
i'mma send that rq
why is this void?
Also my source code https://pastebin.com/YmvBwwyR
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
use .filter
filter for what?
@thorn flicker
ok it worked
what
Since u basically said that my ai code was worthless
i have remade it.
from scratch.
myself.
I did not say that
I said I was less interested in it because it was made by ai.
and again, my criticism is not about the ai's accuracy.
... I take such thing (from people i find valuable), to mean, that i did not, in fact, do it right.
Also ai's code was piece of sh#$
?
.
^
okay
if this is true, I commend you
Thank you
also what is the byte limit of world.setDynamicProperty
@remote oyster did you work with dbs already? im confused about memory alignment of pages. is it based on the table size or the page size? im thinking about, if pagesize = 4kb, and the data being stored is 40bytes, sometime it will overflow and go to another byte, and so data will get corrupted
wait, byte limit? i can store only up to 65k chars on a world?
The size is ultimately up to you I think. Just make sure you verify the size before writing it because if it is larger than you intend it to be then you have an overflow of data. So you must split it up to keep it within its limits. If you are writing to the same data while reading and modifying the same data then that could lead to runtime issues.
Like when i serialize network data for when i have big network (like the one i've shown), it screams that i exceed byte limit
im thinking about before writing it, check if it will overflow, if so, get the amount of bytes until overflow, fill them with 0 and write on the next page
i dont think actually the limit is 32kb of data, well, i did some tests before(more than a year ago) and i could save a string with max len of 32767, that means i can store 65kb(since js is utf16), but i think thats in a single string, probably it doesnt mean i cant write more than that
It's 32,767 characters (32 KB) for strings in dynamic properties as a value. However, if you write 10mb or more in 60 seconds then it will throw a warning letting you know you are exceeding what they suggest but it won't bug out or prevent you from still writing to that key-value pair.
okay
thanks!
as Visual1mpact said above, each value allow 32 KB, and you can have as many key as a 32 KB allow (keys also have a limit of 32 KB) so 32KB keys with 32 KB for each
Indeed, it's common to limit each value to 30,000 and splitting them into chunks. Should you decide to not take the approach of keeping your database flattened.
probably imma chunk the database in 4kb data such as in normal dbs
i pretend making an in memory art
the normal linux gives permission to people chunk data
not 100% sure about that, but its what i saw on web
i think sqlite uses pages of 4kb
keep in mind the number is to high and you will never reach it, so you might find some people saying it is unlimited (might as well be)
if the game didn't break that is
in that note, is more performance to get one dp with 30k or a set of dp flattened?
That's a tough decision. Each one has its benefits. I think it really depends on the structure of your database. Flattening the data can definitely be faster, so long as you are directly accessing the dynamic property in question and not attempting to acquire an entire list to sort through, because if you were doing that, then it may defeat the purpose of flattening them.
If you do globs of data then I would suggest pointers to do faster lookups. Or something of the sorts.
can't see a use case where i would search and sort through them
Me either. Not flattened anyways. That would be pretty wild I think.
just wasn't sure if the amount of api calls would be better than one call, and if the value size affect the call that much
Oh no, definitely limit API calls. For example, if you break your glob of data into chunks, instead of trying to write each chunk to its own dynamic property, making numerous API calls, you could utilize world.setDynamicProperties() and make it a batch process. Run it asynchronously and you got something going for yourself.
uh... setDynamicProperties is a thing?
Yup, and it's fantastic lol. I just wish they had one for get.
i'd not use 30k, quickjs is not as hell optimized as v8, strings are copied, and allocated on heap, each time calling it would allocate 30kb, and any modification, on the string creates a new copy of it. supposing your string is a json, reading it is 30k, modifying it and then writing it into the dynamic properties is more 30k
What would it return? An array? A map? A set?
for sure the api call has its overheads, but as its implemented in C++, i think its lesser(i dont know if this word exists) than copying 30kb of data
that supposing each 1 char = 1byte
good to know
The setDynamicProperties() method is highly useful for efficiently storing multiple dynamic properties in a single call, reducing overhead and improving performance.
any of those is fine
thinking about it, i don't really see a use for it, but it would have been nice to have the option
is it limited in any way? can i just use as many values as i want
keeping in mind the 10mb/min limit
You can definitely break them down into much smaller chunks of concerned about memory and performance. Although in this instance I think memory will be the biggest concern and a lot less on performance due to the constraints within the API and it's limited memory usage. Just keep in mind that there may still be overhead for gathering up all of your chunks, piecing them together, and then doing whatever it is that you plan to do. Unless you plan to get extremely complex to where you access part of the glob, modify that section, and write it back like a delta update.
It's not limited other then the fact that you can't use it to delete a dynamic property by setting it to undefined. It will throw.
what do you mean about break into smaller chunks? if i store 30kb in a single dynamic property i cannot slice it
that is a big BUT
the unique way i think is creating different dynamic properties
If you have 60,000 characters you will exceed the limitation for the value (string). So you break it down.
database/settings_1 (30,000)
database/settings_2 (30,000)
There are many ways to go about this too.
It's all personal preference and how you design your database.
im going to do a lot of benchmarks to decide what to use for performance
If you go back to the link I shared in that other place where I showed my database. You can plug it into ChatGPT and have it quickly describe the pros and cons for educational purposes.
hm this is from 2.1.0 right?
2.0.0-beta
How can i use setDynamicProperties here?
const saveDataString = JSON.stringify(saveData);
const numberSaveDataParts = saveDataString.length / 32767;
for (let i = 0; i < numberSaveDataParts; ++i) {
world.setDynamicProperty(`createbedrock:rotation_system_components_${i}`, saveDataString.slice(i * 32767, (i + 1) * 32767));
}```
setDynamicProperties(values: Record<string, boolean | number | string | Vector3>): void;
the for-loop is still needed
but:
const DATA_LENGTH = 32767
const saveDataString = JSON.stringify(saveData);
const numberSaveDataParts = Math.ceil(saveDataString.length / DATA_LENGTH);
const saveRecord = {}
for (let i = 0; i < numberSaveDataParts; ++i) {
saveRecord[`createbedrock:rotation_system_components_${i}`] = saveDataString.slice(i * DATA_LENGTH, (i + 1) * DATA_LENGTH);
}
world.setDynamicProperties(saveRecord);
@uncut lynx
like that
Hmm... is that gonna be faster?
less API calls. so maybe
instead of 1-3 API calls, you only do one
but as far as i remember, the max. value length of an dynamic property was 4096 ?!
instead of 32767
for me 32767 works
Could you help me debug my code
?
I have an issue, where randomly components destroy themselves (i.e. rpm conflict occurs), when i place sth too fast or ranomly.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
i'm working on a possible solution but well... idk
my possible solution (since while (this.needsUpdate) {} crashes my world) is to have separate copy of the components made upon call of update()
then we dont care bout anything new until next update()
but then how do i copy the components back w/o breaking possible changes...
obv i could copy it one by one
but that'd be kinda slow
but i do so much iterating anyway
it doesnt matter
That's very cool https://youtube.com/shorts/zOseJFD447U?si=zw_Pk3kqkDSoNvSO
Become a TypeScript Wizard with my TypeScript course:
https://www.totaltypescript.com
Follow Matt on Twitter
https://twitter.com/mattpocockuk
Join the Discord:
Did not know that was a thing you could do with ts
Tbh thats cool
okay i figured it out
turns out it was destroying when the value was 0 vs positive value, which failed the check (a>0 !== b>0)
how can i run sth in async
add async before the function
world.afterEvents.someEventIDk.subscribe(async () => { /* */ })
system.run(async () => { /* */ })
(async () => { /* */ })();
or
async function someAsyncFunction(): Promise<any> {
const someData = await someFetchingStuff();
return someData;
}
Async/Promises are peak stuff
everyone needs to know how it works
Ye. Stuff like that is making me like TS more
Just the little small things
Better alternative to system intervals that won't lag as much?
system.runJob - depends on what you want
I'm making like a system that clears certain items from players and alerts admins
if (id == "genb10:teleporter") {
const randomPlayer = world.getAllPlayers()
player.teleport(randomPlayer, { facingLocation: targetLocation, });
return;
}
how do i check for if the player it is trying to teleport to is not the player itself?
i dont want the player to tp to themself, unless ig, there is no one else to tp to
probably going to also add an "allow teleport" feature that only lets people tp to them if they have it on
Check the player id.
That code also would not work.
For nosql database-lik inside mc, should memory usage or performance be prioritized?
7
7
1
Performance
is there anyway i can make the playerInteractWithBlock not fire multiple times when i niteract with a block
yea ofc, gonna make it check for random player and if it isnt the player id
its probably better to just exclude the source from players array
you dont have to check for id that way
const players = world.getAllPlayers().filter(p => p !== source);
how do you spawn projectiles with motion?
you can either do spawnEntity and use .shoot() method from projectile component
or do .applyImpulse() method after spawning
or do both
how do i use .shoot()
There should be like a "Is first event" property on the event data or something like that
oh yeah that works
const randomPlayer = players[Math.random() * players.length];
first, get projectile component
kinda
import { world } from "@minecraft/server";
function shootArrow(targetLocation) {
const velocity = { x: 0, y: 1, z: 5 };
const arrow = targetLocation.dimension.spawnEntity("minecraft:arrow", {
x: targetLocation.x,
y: targetLocation.y + 2,
z: targetLocation.z,
});
const projectileComp = arrow.getComponent("minecraft:projectile");
projectileComp?.shoot(velocity);
}
this is an example code
is there a way to throw a projectile without consuming an item?
uh, depends on your use case, i guess?
i want it to work like you're on creative, but for every gamemode
you mean for like, all the projectiles?
for a specific item i just made
only that one
no others
do you know how to do that?
uhhhh i dont know much
player.teleport(randomPlayer);
this should tp to the random player, right?
especially since i dont know how your code is
teleport method takes Vector3 location
give me a second
{
"format_version": "1.21.50",
"minecraft:item": {
"description": {
"identifier": "content:infinity_disc",
"menu_category": {
"category": "equipment"
}
},
"components": {
"minecraft:max_stack_size": 1,
"minecraft:display_name": {"value": "Infinity Disc"},
"minecraft:icon": "infinity_disc",
"minecraft:hand_equipped": true,
"minecraft:throwable": {
"do_swing_animation": true
},
"minecraft:projectile": {
"projectile_entity": "content:infinity_disc"
}
}
}
}
im not too sure but, isnt that kinda hardcoded to consume on throw?
player.teleport(randomPlayer.location)
{
"format_version": "1.21.50",
"minecraft:item": {
"description": {
"identifier": "content:infinity_disc",
"menu_category": {
"category": "equipment"
}
},
"components": {
"minecraft:max_stack_size": 1,
"minecraft:display_name": {"value": "Infinity Disc"},
"minecraft:icon": "infinity_disc",
"minecraft:hand_equipped": true,
"minecraft:custom_components": ["content:infinity_disc"]
}
}
}
ig custom components could work? but
items arent my expertise sadly
so i cant help much here
these are second parameters
https://jaylydev.github.io/scriptapi-docs/latest/interfaces/_minecraft_server.TeleportOptions.html
so you could do like
player.teleport(randomPlayer.location, { keepVelocity: true });
Scripts can make the player unable to enter portals?
Are you answering me or someone else?
you
what's wrong with this?
source.spawnEntity("content:infinity_disc", source.location)
Oh, with my addon on, I can't enter portals
I don't know if it is caused by your scripts or something else
source.dimension.spawnEntity()
when i did try entering other dimensions, it crashed the world
So that scripts is the "problem"
Since I'm changing almost everything on the main script, I will try to remove some lines to see what happens
Hacky method?
the uh
Wdym?
I'm using your movement scripts
i see
Since it's the only thing that makes the player move like dungeons
just letting you know that you can revamp the whole code using new camera features in future updates
they added something similar to that
using only camera presets
So only with camera presets we will be able to change player movements?
yep
i lost the test video by someone but its somewhere in this server
When it was posted?
iirc the attack direction also changes
and aim assist is a thing too
I hope i can make something similar to what you did
it seems plausible
But that will require a lot of scripts lessons lmao
I'm actually using those hitboxes to run events
Really?
(i still have nightmares about the horrid code)
I thought that was just a side project of yours
And it is being my first ever project to require scripts
I'm learning new things because of that
Works just fine to me
Sometimes the player teleport 1 block back but it's fine
yeah
good luck with that
I only have my phone
Can i send a short showcase of it to you?
i would love it
._.
now what
source.dimension.shootProjectile("content:infinity_disc", source.location)
it's broken again ๐ญ
...whats shootProjectile() method
Screenshots are hard to read, and photos even more so. This is especially true if you are using bridge or another tree editor, as this format obscures the JSON format.
We can help you best if you copy and paste your code here, or send it directly as a file.
idk but i fixed whatever the problem was
i cant see anything
can you click on the image
Screenshots are hard to read.
.
Screenshots are hard to read.
no it isnt
I clicked on it and its the same I see on my screen
if I can read it then you can
Screenshots are hard to read.
this is a horrible readability
its the same size as text
i cant see all the codes in a screen
You do realise people are on different devices and aspect ratios?
I can litterally read it in your screenshot of a screenshot
screenshots prevent us from performing some analysis code as well such as typechecking it locally and making tweaks or the issue being excluded from the snippet
Sounds sus
Read my message above. This is the exact same thing as "It works on my machine"
bruh okay ill test it on my phone too
Good for you that you can read, screenshots are still hard to read.
.
i literally cant see the whole code because of screen size
"Ive committed crimes before and no one complained"
bruh I can read the text in the screenshot of a screenshot on my phone
the same device
yall cant be serious
how do i set the velocity to match the player's facing direction?
the code gets cut off
so what thats all you need to see
Additionally.
Be specific and include relevant details about the question upfront.
- What are you trying to accomplish?
- If you have code, which part is not working? Any content logs?
- What have you already tried?
- Have you searched the Bedrock Wiki?
Im not sending all my code
Get the players view direction.
you can multiply xyz by player's view direction
ok and how do i get the view direction
im not wasting my time on unnecessary responses. you all have trouble with answering a question thats not my problem. Ill just wait for someone who actually cares to help
Documentation for @minecraft/server
player.getViewDirection()
stirante and jayly docs are useful here
Or just actually follow our guidelines and we can help? Stop being stubborn?
says the moderator
so would i change 'player' to 'source' in this context?
Yes, follow our guidelines. Duh?
but heres a catch
well your guidelines are not guiding me
You didnt even follow them but sure.
didnt have any problems till you showed up
you cant do multiply math using objects, so you cant do smth like
velocity * player.getViewDirection()
itll not work as intended
you have to split velocity into 3 values right?
"Ive committed crimes before and no one complained"
yes sorta
oh wait yeah
do smth like;
const dir = player.getViewDirection();
p.shoot({ x: dir.x, y: dir.y, z: dir.z * 4 });
uh
probably should multiply z value instead
i forgot how vector3 works in this case
lol yeah
hmm it wants a number for the vector and can't parse the getViewDirection function for some reason
Not following guidelines is not a crime. I get your analogy but it incorrect in the scenario when Im able to recreate the situation the other user is experiencing and know for sure that they are able to read the screenshot. Whether or not it was the full code is not your concerns. If I would giving the code away I wouldve sent the full thing, but no. So I sent a screenshot. Screenshots help simplify the process of copying. If I pasted it, it would also display differently. Here is what you need to do. You need to respect that I prefer screenshots over copy and paste. If you cant respect it then this conversation is over.
i edited the snippet, try it again
yup
common vector3 mistake
ohhh ok
The thing is the screenshot would be easier to read with the formatting
mate, the readability is horrible
something's wonky with the direction still
it works
but it shoots off to the side most of the time
Bro thinks im an idiot
try adjusting the values, i forgot which is the forward direction
z i think
the attitude makes me think you as one
dude just do what they say
smokey is mod and kinda makes the rules lowkey
yeah i pointed it out
i couldve GLADLY helped you if i could actually comprehend what the bloody hell is happening in the code
thats all you and smokeystack
bruh chill
I am but he doesnt know how to end the conversation
i know whyyyyy
i'm only multiplying the z so it sends it mostly in the global z direction
but i'm not scaling the x and y only the z
x: dir.x, y: dir.y, z: 5*dir.z
You should only scale the y.
yeahhhhh it works a LOT better now that i'm uniformly scaling it
vector3 is weird
if that resolves it im gonna crashout
it did resolve it...
๐
now the problem is that it spawns the entity inside the player hitbox
so it deletes the entity before it goes anywhere
Im still mad they wont include a native Vector3 class in the server module.
You should spawn it in an offset.
owner property, maybe?
Spawn in front of the player and then shoot it.
projectile component has owner property
At least there's an interface sooooo it's not really a math object...
its probably disappearing because it hits the owner as soon as it spawns
...thats why im complaining?
yes
Vector3 was originally a class before they switched it to interface.
entity?
Still available on their math utils npm package I think.
the code that throws projectile
Which is NOT the server module which is what Im complaining about.
oh
I guess the point was overrideable customizability
const dir = source.getViewDirection()
const velocity = { x: 5*dir.x, y: 5*dir.y, z: 5*dir.z };
const projectile = source.dimension.spawnEntity("content:infinity_disc", {
x: source.location.x,
y: source.location.y + 2.5,
z: source.location.z,
});
const projectileComp = projectile.getComponent("minecraft:projectile");
projectileComp?.shoot(velocity);
try adding
projectileComp.owner = source;
below projectileComp
do you not use /reload
i did but i changed some code in the entity so i had to exit
oh rip
OMG TYSM GUYS it works!!!!!!!
voila (pretend i have the accent on the a)
mkv ๐ญ do you not have mp4 convert enabled
does anyone know if you can hide code like on a github for an addon to use
WAIT YOU HAVE TO DOWNLOAD???
yeah
OMG I DIDN'T REALIZE
i fixed dw
im on phone
IM SO SORRY
Wdym?
can u see this?
cant play mkv 
yeag
๐ญ
Mkvs dont embed on desktop anyways.
Society if Discord supported more formats.
What's the best obfuscation method for javascript for free?
or atleast
under 20$
For a friend
we had a lot of questions like this but
im talking about software
Obfuscation is very easy to reverse, but to entertain this thought I would use a bundler to minify your code and obfuscate it.
Yup that's why it is for my friend. i make all my websites and stuff open sourced
i dont understand the whole obfuscation thingy
Elaborate. Do you mean the appeal of it or how it works?
The appeal of it,
False sense of security.
I already understand it's suppose to be un-readable for humans only,
How i think of it, No matter how secure your code is there is a person or software that can always crack it,
well
yeah
is this good system
its just test code for now
gonna make classes for the database thing
Deff not bad
Code obfuscation with the really stupid way of how JavaScript handles coercion...
even tho i know it can be cracked i still need an obfuscation software for my friend
I lovee that i got the db fully working and all that
im actualy goinmg to
uh
?
i cant even try to learn it
rip
That's not... You need motivation to learn it. Otherwise someone teaching you it won't help anymore than putting in the effort to learn it.
lowkey been trying for 8 months
no luck
maybe ido need motivation
it has been a year since i started javascript
and i can say im fairly alright with javascript now
its all trial and error, full of practices
did u make sweep and N' slash
yep
so sad
why
so many popular ppl in here
๐ค
My experience with programming is 12+ years and I still don't know a lot of things because I don't need to. You can't learn something if you don't have a goal to create something.
holy unc ๐
yes that
so much potential wasted bc you're aussie (IM KIDDING)
I had to learn JavaScript because of webdev and now mc. I had to learn C# because I wanted to create a cross platform application in an OOP specific environment, also because it was easier for me.
I don't know CSS and HTML
well js is easy

until it isnt
I use to be a head admin at leaf essentials if yk what that is (Now im just a bum) ๐
I know vue, xaml, cshtml. But raw html and css I am hopeless
lowkey never heard vue and xaml in my life
So it's not about (knowing) things. It's about achieving things
Nah I think I did ok. I made my own 3D engine
i was kidding
anyways i cant even run minecraft, vscode, and my browser at the same time without my cpu capping over 90%
Eeeehhh well Minecraft itself is very power sucking without capping your fps
Dawg. Tech moves so fast. Ryzen 9 9950x exists and I'm still on ryzen 9 3900x...
im on a work laptop
literally for a 300$ laptop im so suprised
Me who spent way too much on a desktop that I hardly use 
im too poor for tjat
im only 14 ๐
im getting a new mouse tmrw tho
mine has been broken for a week lmao
Better to have a horrible laptop then a nasa pc
I think I spent $1.5k for a laptop, 4k for the desktop and 1k for a phone
though I don't spend much on anything else so it's slightly justifiable
Idk. I should probably wipe my desktop and install a linux distro on it for rendering stuff
Or like some compile server with gitlab integration. Would be kinda cool
Ok i should stop speculating and work on mclink with VC
Guys, Im doing a Tower Defense, Anyone got ideas which enemy types I can add? (the images are my current enemies I already have or will have soon)
Please ping on Response
add more
.... I was asking for enemy ideas
what are those name files
๐ญ
Zombie_horse -> ZombieHorse
Wither_Skeleton -> WitherSkeleton
oh, okay
looks cool
Are you available rn? lets move onto DM\s
if (!isFirstEvent) return;```
that naming scheme
mmm
player.dimension.getEntities().length
i am getting entities count using this
but
it kindof flickers
idk why but it shouldnt
lets say i kill one entity.. it was 7 before
its like suddenly 2 adds up, then turns to 6
its inside runInterval with a runTimeout(()={}, 2) inside
it's okay then
you have 7 entities
you killed one
and you should have 6 entities
everything is okay
are you sure that there aren't any other entities spawning for a ms?
.
idk but
why should 2 entities spawn
then disspaear immediately
so its maybe script problem
isn't this entity dropping some items maybe?
the counter is like -> 7 -> (-1) kill -> 9 -> 6
but it should just go 7 -> (-1) kill -> 6
oh wait
mmmmmmmm\
i gotta test then
you might be right
yeah i am stupid sorry ๐
which entity are you killing?
its just giving me nightmares why am i using runTimeout inside runInterval
i mean that loooks nested but it works if it works
You can use .remove() and they wont drop anything
omg no
why
what
i am making debug screen
that loses functionbality of vannilla
Bruh i love async
it made my addon not lag the hell out of it when block is placed
well the lag is lesser
but it still is
should i keep my AStar synchronous or asynchronous ?
let me ask, what is getComponent of hunger?
firstly, how would've the entities handled that, huh?
they'd lag the hell outta it
secondly, see the lag when i place?
it happens for my mod only, rest of the game is unaffected
alright the cause is propagateRotation function
but that func is already async...
there ain't much better way of doing it other than BFS
time for micro optimizations i guess
it depends on your code
show it
which is basically https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entityattributecomponent?view=minecraft-bedrock-experimental
why is it wrong
Code
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
const playerhunger = player.getComponent("minecraft:player.hunger");
console.warn(playerhunger.currentValue)
}
}, 20);
https://pastebin.com/mLR8v6WY
could smbdy tell me how can i improve said lag ?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
i switched to Queue taken from the internet
the lag is lesser
but still is
This component is only available in the latest preview versions.
whats that???
it's preview-only I guess
Oh
because i use version 1.17.0 so it probably doesn't work
is it goodhabit to add semicolon?
your preferences tbh
but I don't like them
in production they does not matter
why can't i use console.time ???
wait, i know why the lag
whatever it is just the visuals
gosh i cannot convert large cogwheel texture properly from java to bedrock
Semicolons make it clear where a statement ends, similar to how you end a sentence with a period, exclamation point, or question mark. They're a form of proper punctuation in code. You aren't obligated to use them just like you aren't obligated to end a sentence with a period, but others may look at it differently.
I see thanks
how do i get the entity's power from the projectile component
get the power property.
how does one do that
dot notation
use Blockbench for models
did you check EntityComponentTypes?
should learn what dot notation is.
like source.runCommand?
or source.spawnEntity
then i do know
good.
Documentation for @minecraft/server
these are the properties you can get from the projectile component.
i sent
you're looking for Inertia props ig
It's hard to browse scripting docs on phone xD
i already do
i don't see power as an option
isn't there an option to convert models there?
yeah there is
@alpine wigeon
:(((((((
@alpine wigeon
but the models look like a potato
but inertia is different i think
(i mean raw models w/o txts are fine)
check docs and you'll get to know what you need
inertia is how quickly it will slow down
power is how fast it goes at the start
weird
power is the damage modifier from the power enchantment on a bow
oh really?
are you being sarcastic
velocity or power?
the thing in the entity
idk really
huh
whenever i tested power changes it made it go faster with higher power value
describe your idea
it's a regular throwable item?
Yes power is initial speed, inertia is how much speed the projectile keeps over time
i just want to use the "power" that i set in the entity when i set the velocity with the script
there's no property for it then
yup
dang
but im setting the velocity on like the next line
const projectile = source.dimension.spawnEntity("content:infinity_disc", {
x: source.location.x,
y: source.location.y + 1.6, //1.6 is eye height
z: source.location.z,
});
const projectileComp = projectile.getComponent("minecraft:projectile");
projectileComp.owner = source
const dir = source.getViewDirection()
const power = 10
const velocity = { x: power*dir.x, y: power*dir.y, z: power*dir.z };
projectileComp?.shoot(velocity);
just multiply it by a value
but then it's hard coded
Make a variable.
there is a variable.
i want it to use this value
{
"format_version": "1.16.0",
"minecraft:entity": {
"description": {
"identifier": "content:infinity_disc",
"is_spawnable": false,
"is_summonable": true,
"is_experimental": false,
"runtime_identifier": "minecraft:snowball"
},
"components": {
"minecraft:collision_box": {
"width": 0.3,
"height": 0.1
},
"minecraft:projectile": {
"on_hit": {
"impact_damage": {
"damage": 1000000000
},
"remove_on_hit": {}
},
"power": 2, //<<<POWER HERE
"gravity": 0.001,
"angle_offset": 0.0,
"liquid_inertia": 1.0
},
"minecraft:physics": {},
"minecraft:pushable": {
"is_pushable": true,
"is_pushable_by_piston": true
}
}
}
}
I'm out of context here lmao I just got here.
you cannot.
just because you cant get it in scripts doesnt mean its hardcoded though.
thanks
i guess i'll just nerf the damage and be done with it then
yeah don't look at the dmg value
๐
or just use 2 as the value
nah it's insanely expensive to craft
so it has to have high dmg
What do y'all thing of this line btw
world.getDimension(currentConnectedComponent.component.block.dimension.id).runCommand(`setblock ${currentConnectedComponent.component.block.location.x} ${currentConnectedComponent.component.block.location.y} ${currentConnectedComponent.component.block.location.z} air destroy`);```
if you are just using it in scripts, remove power, and then just use the variable in the scripts for the power.
Try https://jaylydev.github.io/scriptapi-docs/latest/ it's good for searching on phone.
its terrible
lmfao
Block.setType()``````Dimension.setBlockType('<block>', <location>)
ooof nvm
not dimension for the first one
๐
and I was gonna say why are you using the block's dimension to change the block's type
lol
you fixed it though
is there any native method that's giving me a drop of block like /loot does it?
no
not yet
okay okay i shortened it
currentConnectedComponent.component.block.dimension.runCommand(`setblock ${currentConnectedComponent.component.block.location.x} ${currentConnectedComponent.component.block.location.y} ${currentConnectedComponent.component.block.location.z} air destroy`);
that's one of the thing you should expect soon
its in the roadmap.
ohh, that's nice then
i hope that gives us a destroy method
I dont remember if that specifically was mentioned or not
can't you destruct block, or even block's dimension and xyz?
const { dimension, location } = currentConnectedComponent.component.block;
dimension.runCommand(`setblock ${location.x} ${location.y} ${location.z} air destroy`);```
what's the point if u use them one singular time?
you call it multiple times and it annoys me.
they were intentionally trying to annoy I believe
make your code shorter
good point
No you didn't call it once, you called it multiple times especially this currentConnectedComponent.component.block...
he's from Poland
-# ๐ฉ๐ช??
that makes you automatically not be able to annoy people intentionally?
-# mbmb
reverse
why would the f. i annoy somebody? also this is my full usage.
if (currentConnectedComponentRPM > CONFIG.RPM_LIMITS.max || currentConnectedComponentRPM < CONFIG.RPM_LIMITS.min) {
//console.log(`ยง4[RotationSystem] RPM LIMIT EXCEEDED! Destroying block at ${currentConnectedComponentKey}`);
//console.log(`ยง4[RotationSystem] RPM ${currentConnectedComponentRPM} is outside limits [${CONFIG.RPM_LIMITS.min}, ${CONFIG.RPM_LIMITS.max}]`);
currentConnectedComponent.component.block.dimension.runCommand(`setblock ${currentConnectedComponent.component.block.location.x} ${currentConnectedComponent.component.block.location.y} ${currentConnectedComponent.component.block.location.z} air destroy`);
this.removeComponent(currentComponent.block, true);
continue;
}```
AYO
Oh, I see now
?
nvm nvm
WW2.
CHILL BRO
also it's WWII
NAHHH
you said ww1
probably? To be more annoying use random shit not that, it's still easy to decode.
๐๐
that's why I edited it?
W T F
i am not tryna annoy anybody tf?
don't give them tips
๐ญ
i thought my line of code was funny?
Sorry, I thought you were making your code annoying. Lol.
Anyways, you can just do it like this.
okay just look at my code bro, it's not just that one line or whatever.
https://pastebin.com/LPjuEB0x
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I must have typos or missing but like a reference yes.
Ok what the actual fvk is this, lmao
that's imo slower
wdym?
explain.
u copy it one more time
context.
what's the sound called that's played when you throw a snowball?
ok, I'm not in mood to explain... So people who's around do it.
uh
1 sec
want explanation of sht or nah
also how do you play a sound at location w/ script
dimension.playSound
not anymore.
Documentation for @minecraft/server
slowly
huh
you could use mob.witch.throw
haven't seen coddy for a while. how's going on?
dimension.playSound("mob.witch.throw", source.location)
something's wrong
looks right to me.
something's undefined tho
you gotta comprehend you're code and the logic of it
no i do have dimension apparently so it's something else
show me the code.
onUse({ itemStack, source, dimension }) {
const projectile = source.dimension.spawnEntity("content:infinity_disc", {
x: source.location.x,
y: source.location.y + 1.6,
z: source.location.z,
});
const projectileComp = projectile.getComponent("minecraft:projectile");
projectileComp.owner = source
const dir = source.getViewDirection()
const power = 10
const velocity = { x: power*dir.x, y: power*dir.y, z: power*dir.z };
projectileComp?.shoot(velocity);
dimension.playSound("mob.witch.throw", source.location)
}
oh i have an idea
onUse does not have a dimension property
oh
ehh it works good enough for me
this fixed it
or just import @minecraft/server via npm
i just needed to add a sound because the discs move so fast you can't even tell if it threw
yeah, you could see if it autocompletes or not
import * as mc from '@minecraft/server'; :>
i hate this shit..
i always have to do
/** @param {Dimension} dim */
otherwise the function doesn't show typings
if you hate it so much then use typescript.
that's the point of it
noooooo i also hate those as string shittt
I hate alot of things in life
`noooo its not readable when it comes to <T idk smth
TS are mostly for people who wants to be as precise as they can be
not the hardest thing to do anyways.
finish script -> compile TS to JS -> compile addon -> copy addon to development folder -> reload game; the loop goes on
luckily i dont do that
what do you do?
I dont use ts
๐ญ
Serty uses js too I guess
same I stopped for a while
I use copilot to check for typings
im so unbothered by the typing stuff
I dont care enough yet
i will some day
especially if its a big project or something
yeah and it's good for collaborative projects
Someone know a server where people need scripts? (Paid)
you can go to bucket of crabs
Can you send me a invite?
nice name
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.
or Skillshare
what's one way to filter blocks that only a player can break?
whitelist some blocks
breakblock beforeEvent?
is there a script for checking hotbar?
If you get the players inventory you can then get their selectedSlotIndex which is their hotbar
Yes
docs for slected slotIndex
https://jaylydev.github.io/scriptapi-docs/1.21.80/classes/_minecraft_server.Player.html#selectedslotindex
there's a sample below it you can use it
if you want to get the inventory which If I remeber correctly also includes the hotbar
https://jaylydev.github.io/scriptapi-docs/1.21.80/classes/_minecraft_server.Container.html
use this
How do we run commands as blocks nowadays?
thank you
You dont. You run it via Dimension or Entity.
can someone rq help me testing a feature of my revive addon?
i need a quick test, just 1 minute, dm me
I can't remember what it's called, but on VSCode there's a Java Datapack add-on that turns the icons in your file and folders into the relevant images, and it works for bedrock
Does anyone know the name of it?
Should be in #1072983602821861426
Made within 2 days of scripting.
cool
-# but cross posting is against the server rules
Any GitHub experts here?
I think in any case it's better to ask the question right away
Fresh windows install... and projects folder is moved. How to link folder back to Repo?
If you cloned the repo and just moved or renamed the folder it is still linked
you can confirm with "git remote -v"
or just type
"git remote add origin git-link"
if not
Not cloned, all my stuff.
git clone <repo link>
Cloning the repo versus downloading the project will have it set up for git.
Hmm, seems that after adding git , vscode recognises everything....
Yea I figured you did. That's why I suggested using the git clone command. No need to try and "link" your folder to GitHub this way. Cloning it from upstream will pull in everything from the repo on GitHub, including commit history.
Great.. cause I moved the folder from under my user to the c:\ and was not sure it would play nice
Once you clone it, you can move it wherever you like. Or just go to the directory where you want it to be, then execute the command there.
Cloning is probably the easiest and most efficient way here.
4 repos.. was not looking forward to that.. I really need to do my github turorial
So it has been a while (4 months) What is new?
too many stuff changed with v2, I didnโt catch up with all of them
Version 2 to be released soonish?
i hope so
Jayly, why do you want to see text and images cop[ied to the clipboard? LOL
Wait what?
level 100 lag generator
lag errors
So I made a custom door using 2 blocks, and it spawns an infinite amount of bottom doors atop every bottom door, when the code tells it to spawn the top block: https://www3.online-convert.com/v2/dl/web7/download-file/f1fa6bbd-08fb-4e5f-8b69-975d8ddda0d0/vid.mp4
cool
what's the gun for
its apart of my mod
wdym?
i didn't use ANY entities
the "lag" u see
is that block geo is constantly changing
hence u cannot place anything directly on it
js is NOT complex

