#Script API General

1 messages · Page 100 of 1

chilly fractal
#

yup.

#

oh it does impact performance. but really, it depends on your ways of obfuscation and how big the codebase is.

#

personally, i am not much of a fan of obfuscation.

#

but that's my opinion.

cursive fog
#

Help

chilly fractal
#

it doesn't export dimension

#

it exports a method to get a dimension tho

#

do this:

#
const overworld = world.getDimension('minecraft:overworld');
#

make sure to import world at the top

#
import { world } from "@minecraft/server";
cursive fog
#

Ohh ok

chilly fractal
vast grove
#

One thing. Avoid running commands from script api as much as possible. It introduces an extra overhead as opposed to running a dedicated script api function for the same result

cursive fog
#

Idk i uhh try to grasp stuff

chilly fractal
#

you need to learn the basics of javascript first

#

i'll teach you some rn

cursive fog
chilly fractal
#

firstly, you can initialize let, const, and var with some value as so:
let someProperty = 23;
let, and var don't need an initial value and can be changed later.
const needs an initial value and cannot be changed later.
let, and const are scoped to their braces. for example:

try {// <-- braces
  const someProperty = 83;
/* end of braces scope -->*/} catch {
}
console.log(someProperty); // fails, because it is not in the same scope, therefore you can't access it.```
cursive fog
chilly fractal
#

var is scoped to it's function.
for example:

function coolFunction() {// <-- function
  const someProperty = 93;
}//<-- end of function
console.log(someProperty); // fails, because it is not in the same function scope, therefore you can't access it.```
chilly fractal
#

you can't change it's type

chilly fractal
#

?

#

oh it just prints whatever you give it to the console

chilly fractal
#

i'd use console.error if you wanna make it always log regardless of your console level.

cursive fog
#

For creator gui right?

chilly fractal
#

yeah

#

if you want, i can send you a free and good javascript course. it's on youtube.

cursive fog
#

Btw can run command work without dimension part?

chilly fractal
#

not really

#

you need a source

#

either an entity or a dimension or a command block

cursive fog
chilly fractal
#

and dimension is the most stable source to run commands on

chilly fractal
#

the player is an entity

#

and so are simulated players.

cursive fog
chilly fractal
#

functions and rest paramaters (cuz why not?)

cursive fog
cursive fog
chilly fractal
#

say you have function like:

function openGripMenu() {
  source.runCommand('say grip');
}```
you want to give it dynamic access to source, but how? you add a parameter.
```js
function openGripMenu(source/*<-- parameter*/) {
  source.runCommand('say grip');
}```
chilly fractal
#

they are normal javascript "things" that help in modularity and keeping code clean.

vast grove
#

Functions are basically things that allow you to input something and get a result.

chilly fractal
# chilly fractal say you have function like: ```js function openGripMenu() { source.runCommand...

then to call.

import { world } from "@minecraft/server";

function openGripMenu(source/*<-- parameter*/) {
  source.runCommand('say grip');
}

world.afterEvents.worldLoad.subscribe(() => {
  const overworld = world.getDimension('overworld');
  /* this calls the function(runs) "openGripMenu"  we defined --->*/openGripMenu(overworld/*<-- call the function with the paramter you want to give it*/);
});```
chilly fractal
ruby haven
#

I'm trying to make an attack system triggered by data event entity trigger and will be used by most of my custom entities will that be a big impact to performance issues?

chilly fractal
#

event based things are very performant.

cursive fog
ruby haven
chilly fractal
chilly fractal
#

plus if you optimize everything to be minimal, it wouldn't be much of an issue.

cursive fog
#

@chilly fractal can you give me a example of how to write the comments part

chilly fractal
#

i'll send you the javascript course

#

it's long but very, VERY important

cursive fog
chilly fractal
#

and will pay off in the end.

chilly fractal
#

i don't think you get it,just watch the course.

cursive fog
chilly fractal
#

just watch the course i sent you

#

you don't need to watch it all in one sitting

#

but make sure to watch it all or at least half of it.

#

and also i gotta go

#

cya

cursive fog
chilly fractal
#

oh yeah

#

i gotta say something

#

it's a normal javascript web APIs course

#

but you can use the basics that are purely javascript in any javascript enviroment like nodejs and minecaft's quickjs engine.

#

anyway, ima go now

jagged gazelle
tardy pivot
#

does the beacon beam have a typeId?

visual zephyr
#

can i change an entity's component group using script api

#

can i use trigger event?

distant tulip
visual zephyr
#

alr thanks

thorn flicker
halcyon phoenix
#

does stringifying an entity and parsing it would work inside dynamic properties?

subtle cove
#

use structureManager

subtle cove
halcyon phoenix
#

I've used structureManger before but I believe that one is for structures

subtle cove
#

its the script-api way of /structure

halcyon phoenix
#

oh yeah

#

/structure

#

I mean that could work too

#

is there any other methods?

subtle cove
#

uhm, how do u wana use the entity as data?

oak lynx
#

why do you censor script when it's literally the only normal part of addons

rustic ermine
#

has anyone that has done profiling recently recall if

.getComponent(ENUM.X)

has much performance impact?
trying to think of an event-driven way to make sure player has required level for equipment, but I am concerned about checking 5 times every time a hitEntity event happens. My profiling shows 0ms but am not able to profile to fractional ms.. expecting about 20 players to be running this check at any given time. I would be checking mainhand of attacking entity, then equipment components of each slot for the receiving entity.

#

wish we could run deno profiling for bds lol

subtle cove
#

calling a variable sure does cost more than using string

rustic ermine
#

interesting -- I would assume that is because JS does not support true enum / union types?

subtle cove
#

maybe..
its just taking the value string or enums are same on it

rustic ermine
#

yeah makes sense. I guess I assumed it would be the same cost since it should just be referring to a memory location that has the string, but it really depends if it is stored on stack or heap

#

or if it is doing PBV or PBR

round bone
warm mason
rustic ermine
#

every little bit counts 😛 I already am using a good bit of performance budget with http / database handling

#

not that it would ever be noticeable to a player probably, but usually there is always a way to get something to work nearly perfectly

warm mason
rustic ermine
#

I get what you are saying but there is a 25ms network delay with http that is not avoidable

subtle cove
#

btw, u can store the component object in a map for brute executions

rustic ermine
#

when would be the appropriate time to store that though? because it will not refer to the current component if they equip something else

round bone
subtle cove
#

using getComponent() a lot is also expensive

rustic ermine
warm mason
round bone
#

framework?

rustic ermine
#

so a new connection is established every time

#

keepAlive on the backend doesn't seem to care

rustic ermine
subtle cove
round bone
#

I think we are working on pretty similar systems

#

I am using Express.js with Clustering and MongoDB + Redis for storage

#

😅

rustic ermine
#

I also have a go version of the backend but didnt see any benefit for my case

subtle cove
#

I'd keep it simple, then w8 for it to break. then do the compact coding

#

otherwise keep it simple

rustic ermine
#

meh I have the time to test and tweak until it's good. this is my only non-work project atm

rustic ermine
warm mason
#

I thought so..

#

Did you know that when you do await minecraft leaves it for other ticks. It won't pause the whole game just to wait for a response from the server

#

So your 50ms don't create that kind of load.

rustic ermine
#

yes, but the point I was trying to put into words was that there is still a delay from when the player sees the result. for example when they open their bank, or switch bank tabs, etc, the menu can't update until it has received the item data from backend

#

and I don't want to cache within scriptAPI

warm mason
rustic ermine
#

because there is a memory limit

round bone
warm mason
#

I need to check this limit by the way...

rustic ermine
#

its 200mb. and no, not currently storing that much, but in the long term it could be so planning around that

rustic ermine
#
const a = performance.now()
const players = database.database.prepare("SELECT * FROM players").all();
const skills = database.database.prepare("SELECT skill_name, level, current_xp, remaining_xp FROM player_skills WHERE ID = 1").all();
const b = performance.now()
console.log(`${b - a}`)

0.05379999999999541ms

#

ignore database.database

#

just crap testing code

sly valve
#

Ohh thats Cool, I also tried this ince but gave up because im stupid and will never achieve this type of smartness

rustic ermine
#

packet size comes out to about 2kb counting headers for entire player profile not counting items. but multiply that by player count, then 800 items in bank per player, then auction house system, etc, is why not caching within minecraft JS

subtle cove
#

why not make it like

["mining", 1, 0, 83]
rustic ermine
#

I could, just threw this together yesterday, still havent optimized the packets

#

player skills do get cached on the minecraft side though. just loaded once on login

#

then player['skill_name'] to get level etc behind a function

#
export function skillMenu(player: Player) {
    let skillMenu = new ChestFormData('single')
    skillMenu.title('§l§5Skills')
    SKILL_DEFINITIONS.forEach((skill: string[], index: number) => {
        skillMenu.button(index, `§l§6${skill[0].toUpperCase()}`, [`Current XP: ${player[skill[0] + "_xp"]}`,
        `XP Remaining: ${player[skill[0] + "_xp_r"]}`], `${skill[1]}`, player[skill[0]])
    })

    skillMenu.show(player).then(response => {
        if (response.canceled) return;
        world.sendMessage(`${player.name} has chosen item ${response.selection}`);
    })
};
round bone
dusky flicker
#

you gotta bind

sly valve
rustic ermine
dusky flicker
#

the code normally understands this.stuff, when passing as callback, without the 'this'

#

so you gotta bind it to the instance

#

weird functionalities of js

#

but its what its

sly valve
round bone
rustic ermine
#

yeah it can. I've used LINQ a lot in the past and it was nice, but once upon a time I tried to force myself not rely on having something like that so almost just prefer raw statements now I guess

dusky flicker
dusky flicker
#

they just build a query

#

has a small overhead but nothing that will make the code slow

rustic ermine
#

good to know. part of the reason though is that a lot of my past projects have been in different languages so never really bothered to learn one single ORM because there's been a few times it wasn't available for X language

dusky flicker
#

but if theyre not

rustic ermine
#

rust is the main offender lol

dusky flicker
#

in theory you can make your own

#

the db server is literslly a server that waits for requests via tcp

round bone
dusky flicker
#

so you can simply make some requests with the query as the content

#

and in theory it might work

rustic ermine
#

yeah, usually I would try to program with some adapter pattern so the backend wouldn't matter, just have been very lazy about it this time around 😦

dusky flicker
rustic ermine
#

i'll try it since the backend is still in early stages, any recommendations?

dusky flicker
#

i generally prefer using rust orms

#

since ima rustcean guy

rustic ermine
#

they are good now, but they werent a few years ago (rust ORMs)

rustic ermine
#

yes

dusky flicker
#

im using drizzle for a webapp im doing

#

i think it's pretty straightforward

#

theres prisma and typeorm

#

well, im just talking about ts orms

#

normally i'd use seaorm, but its for rust

rustic ermine
#

thanks. I'm not up to date on what people use these days. my peak of learning libraries was 10 years ago when I had to for work. It was exhausting keeping up so have just stuck with what I am familiar with, i'll check them out

dusky flicker
rustic ermine
#

uhg good luck. I thought about switching to a webdev job a while ago but ended up just staying put. so many requirements on the job postings for different stacks. I currently do cybersec for DOD

round bone
#

I am not using raw queries but ORM's will always be a bit slower than raw queries

dusky flicker
#

there are more chances that we as developers make the code slow than an orm

rustic ermine
#

bit slower but 99% of the time doesn't matter for a db server

rustic ermine
#

will say, have been a bit impressed with the quickJS engine minecraft uses. was expecting bottlenecks all over but haven't really found anything deal breaking

dusky flicker
rustic ermine
#

yeah you pretty much had to learn the current stuff in school and have done it as a hobby for real projects the entire time then have some solid work to show for the interview it feels like. feels like it would take more time to catch up than it is worth

round bone
#

web dev is pretty hard for beginners, especially learning all more stuff when it comes to learn NPM + back-end services

rustic ermine
#

it's easy if you pick one thing and stick with it. the problem comes from the "one thing to know" being different every year today

#

if PHP was still mainsteam in the US i'd be all over it lol

round bone
#

you have to learn new JavaScript framework every 2 weeks

#

just joking, but you have to move from one framework to another every few years

round bone
#

😃

distant tulip
#

every gov and uni site still using that shit

round bone
#

if I would eventually start working for government or any university, I would rewrite every site without using WordPress and jQuery

#

🤮

rustic ermine
#

lmao

distant tulip
#

you just stated why you will not get hired in those

rustic ermine
#

in DOD its all contracted out now anyway

#

which has the amazing side effect of them never understanding our actual requirements. at this point it feels like its intentional so they can keep the money tree alive

halcyon phoenix
dusky flicker
#

and how things work

#

instead they just show how to use it

#

i like understanding what in hell is a state on react

#

its better than simply "oh const[state, setState] = useState(0)"

#

and thats all

#

but the concepts on the web their self is pretty simple

#

seriously i did struggle more learning about Arc in rust

#

and deadlocks

round bone
round bone
#

information like this is also giving a lot for newbies tbh

dusky flicker
round bone
#

getting to know framework, library or even an entire language is making you a better programmer in thic topic

dusky flicker
#

to batch stuff

dusky flicker
#

seriously i made a batcher on wgpu

#

but i didnt get react

round bone
#

I am not doing much front-end development, beacuse I am colorblind a bit

#

😦

dusky flicker
#

REACT DOENST FUCKING ALLOW HOOKS INSIDE IFS AND FUNCTIONS

#

bro

round bone
#

but when I have design with UI/UX checked I can actually implement it

dusky flicker
#

that just piss me so much

dusky flicker
rustic ermine
# dusky flicker seriously i did struggle more learning about Arc in rust
#[pin_project(project = MapProjection)]
pub struct MapFuture<'m, F: Future + 'm, O> {
    #[pin]
    future: F,
    output: PhantomData<O>,
    mapper: Option<BoxedMapper<'m, F::Output, O>>,
}

impl<'m, F: Future, O> MapFuture<'m, F, O> {
    fn new<M: Mapper<'m, F::Output, O>>(future: F, mapper: M) -> Self {
        Self { future, output: PhantomData, mapper: Some(Box::new(mapper)) }
    }
}

impl<F: Future, O> MapProjection<'_, '_, F, O> {
    fn map(&mut self, input: F::Output) -> O {
        (self.mapper.take().unwrap())(input)
    }
}

impl<F: Future, O> Future for MapFuture<'_, F, O> {
    type Output = O;

    fn poll(
        mut self: Pin<&mut Self>,
        cx: &mut Context<'_>,
    ) -> Poll<Self::Output> {
        let mut projection = self.as_mut().project();
        let maybe_ready = projection.future.as_mut().poll(cx);

        maybe_ready.map(|input| projection.map(input))
    }
}

this was the worst for me in rust. manual futures

round bone
dusky flicker
#

the only thig i struggle is login

round bone
#

it took me few hours to implement my first auth system

dusky flicker
#

because no one explains what the fuck is oauth2

round bone
dusky flicker
round bone
#

I think all of these YouTubers are trying to make their tutorial as hard as possible to make people quit programming

round bone
#

but hey, our salary is even higher then!

dusky flicker
#

ive seen a video that "teaches" oauth2

#

bro the solution was just

rustic ermine
dusky flicker
#

"copy my code and trust 👍"

dusky flicker
dusky flicker
#

but i laughed a lot

halcyon phoenix
#

most courses/tutorials, and even school does that

#

no need to explain it

#

just do this and voila there you go

#

then on exams all you have to do is memorize

#

and move on then forgot

#

no need to explain why it happens why you do that, why is this part important, it's all just do this and it will work

#

it's frustrating

dusky flicker
#

gotta agree

#

my math teacher, when i was on 11th grade i guess(here on Brazil the system is different so im using some equivalents)

#

he simply used to teach "logic"

#

by doing that you said

#

i wnated to understand what an equation meant and why is that the way it is

#

he literally said "i think you might ask math itself then"

halcyon phoenix
#

I also got blessed by a teacher that's opposite he teaches some script/coding stuff and math, and was very in-depth however, every single one of my classmate and as well as other section he handles hated him for that.

#

man...

dusky flicker
#

generally people dont like studying

#

well, here in Brazil thats the norm

#

the thing is that, math, coding and that stuff is complex

round bone
dusky flicker
#

nobody wants to face the truth that "hm, im dumb as hell"

dusky flicker
#

if you think that doesn't apply, then it wasnt meant to you

halcyon phoenix
dusky flicker
halcyon phoenix
#

LOL

round bone
cyan basin
#

Simulated players seem to be scared of ladders being on the top most block.. I had to remove the top ladder for them to climb on it.

subtle cove
subtle cove
obtuse plover
#

Do someone know how to keep the player able to place block on top of one with onPlayerInteract custom component?

open urchin
#

not possible

rustic ermine
#

Hold crouch then put it on it

obtuse plover
visual zephyr
cyan basin
#

I don’t know

#

I’m trying to figure that out

#
test.setSkin({
    personaPieces: [{
        id: "",
        packId: "",
        productId: "",
        type: PersonaPieceType.Skin,
    }],
    armSize: PersonaArmSize.Wide,
});```
#

This exists but you need the id, pack id and product id as they’re all required but I don’t have a clue on where to get those ids from

open urchin
round bone
cyan basin
#

What about for custom skins though?

#

This is just for using a skin that already exists within the world

visual zephyr
#

maybe it can use some workarounds like if your just doing it solo change your skin temporarily and get that skinID then apply it to the simulatedPlayer

#

not sure

round bone
visual zephyr
#

how to get that tho?

cyan basin
#

Fr

#

That doesn’t help me.. I can tell what it requires from reading it (not trying to sound like a dick)

visual zephyr
#

i assume packId and productId is meant for marketplace skinpacks

round bone
valid ice
#

😭 🙏

cyan basin
somber sundial
#

Is there something other than playerLeave to run code when the host leaves the game? I am trying to remove entities on leave yet nothing i try is working. I've tried doing it in the afterEvent and also the beforeEvent with a system.run() call but I assume they're both running too late for me to do anything to the world. The same code works when running from a command so it's definitely related to when it's being called

somber sundial
#

i have resorted to creating a ticking area and removing the entities in the first playerSpawn(), even worldLoad after event doesn't work (despite it supposed to be running after the world has started ticking)

sharp elbow
#

Are you aware of the "minecraft:transient" component? @somber sundial

somber sundial
buoyant canopy
#

i just learned that you can write new properties to a class instance

sly valve
distant gulch
#

with server net would it b possible to create an ai in minecarft chat?

buoyant canopy
#

you could call it later with block.whatever

sly valve
sly valve
distant gulch
#

ill add it to my list of projects

sly valve
distant gulch
#

oh nicee

wintry bane
#

block.isSolid when?

open urchin
#

never

#

their plan is to eventually split it up into what it actually represents

#

e.g. .isBreathable, .isSpawnable, .isRedstoneConductor

cyan basin
open urchin
#

I doubt it will ever exit beta

cyan basin
#

oh is that what they were wondering?

#

if it would become stable?

open urchin
#

probably

cyan basin
wintry bane
open urchin
#

isSolid does exist in beta but don't expect it to exist forever

wintry bane
#

entity.target bao_mob_t_hoglin

#

Still in beta purgatory

cyan basin
#

a lot of them would be

#

a lot of us will be jumping for joy once we see playerHurtBeforeEvent dviperScared

#

it honestly might scare the devs 🤣

wintry bane
#

Or player saturation component

cyan basin
#

we have access to saturation now no?

wintry bane
#

Beta

cyan basin
#

oh yeah, well that was recent so it'll be a pretty while before it becomes stable

#

i mean i'm quite surprised beforeChat still isn't stable yet

#

not sure why that's taken so long

granite badger
#

y’all making me double check everything

wintry bane
#

It's too powerful for stable folk

cyan basin
#

i'm checking myself lmao

wintry bane
cyan basin
#

everytime they mention something lol

#

Jayly just be lurking 🤣

wintry bane
#

Block entities vs block dynamic components

#

Which would be better..

#

Diff usecases i believe

cyan basin
#

I thought you said dynamic props for a sec there.. I was about to say lmao

jagged gazelle
lone mango
#

Trying to remove all monster entities within a volume, and this is executing, but not picking up any monsters:

            const eqo = {
                families: [ "monster" ],
                location: pos1,
                volume: pos2,
            };

            for (const entity of dimension.getEntities(eqo)) {
                world.sendMessage("Entity Removed");
                entity.remove();
            }
#

The "entity removed" never shows up, so that's the part that isn't executing, but I dunno why.

#

I made sure to put some monsters in the area

halcyon phoenix
halcyon phoenix
#

however

#

I just need for the interacted entity

#

if in case I save a entity in that location and somehow there's another entity in there it would save 2 of them instead of just the interacted one

#

so it's doable but not the solution

subtle cove
#

Good point, now with the concept of array.filter u now have the entities list, replicate the copy elsewhere and reduce it to one then save that specific entity, officially

#

U can separate em by tags or dynamic property, they get saved as well

shut vessel
#

who know how to detect bow hit ?

subtle cove
#

projectileHitBlock, projectileHitEntity

shut vessel
#

thanks

#
world.afterEvents.projectileHitEntity.subscribe(({ projectile, hitEntity, damagingEntity }) => {
  const wifmatscore = world.scoreboard.getObjective("kit").getScore(damagingEntity);

  if (wifmatscore === 29) {
    if (Math.random() <= 1) { 
      hitEntity.applyDamage(999, {
        cause: "void",
      });
    }
  }
});```
#

when i get the projectile it i had a error

#

and i try like this but it didnt work

warped blaze
#

nvm

#

@shut vessel

world.afterEvents.projectileHitEntity.subscribe(eventData => {
  const { projectile, source } = eventData;
  const target = eventData.getEntityHit().entity;
  if (!source || !target) return;
  const wifmatscore = world.scoreboard.getObjective("kit").getScore(source);

  if (wifmatscore === 29) {
      target.applyDamage(999, {
        cause: "void",
      });
  }
});```
#

also
Math.random() <= 1
doesn't make any sense since it will always be true, Math.random() generates a number between 0 and 0.9999

shut vessel
#

ahhh my bad

#

thanks

warped blaze
#

does anyone know if the new shelves use the BlockInventoryComponent?

thorn flicker
warped blaze
thorn flicker
#

also why do chiseled bookshelves not drop anything lol

#

okay then

little hull
#

is there a script for making damage area something?

warped blaze
warped blaze
#

i hope they add a way to get and edit it

little hull
#

no i wanna create like a dmage area like the how the create explosion works

warped blaze
little hull
thorn flicker
#

getEntities supports entityQueryOptions.

little hull
thorn flicker
#

define the location, and the maxDistance

warped blaze
thorn flicker
little hull
thorn flicker
#

well

little hull
thorn flicker
#

you are going to get lag then, no doubt.

#

100 entities would cause lag alone anyways

warped blaze
#

you can always just implement it via the entity.json iirc

little hull
#

the reason im using this is because the delayed_attacking component behaviour has this bug regarding collision issues when the entity is too close it doesnt detect it as delayed_attacking thats why

thorn flicker
#

if you want an explosion, you could disable it destroying blocks in the method.

#

if thats the issue

#

maybe you want a custom particle

little hull
#

im making a more accurate attack system that doesnt require path finding thingy

final ocean
#

What name event blockBreak in api 2.0.0-beta

warped blaze
thorn flicker
final ocean
warped blaze
#

oh

#

mb

thorn flicker
final ocean
#

But how to make it automatically added to inventory when mining a block?

halcyon phoenix
halcyon phoenix
#

welp

#

dang

jagged gazelle
#

try parsing it in log.

#

Look what's only accessible

#

same goes to itemStack. itemStack returns {}

#

also stringifying it lost lots of data.

#

and no you can't spawn entity by parsing it since spawnEntity requires STRING

halcyon phoenix
#

dang i can't save data

#

thanks coddy I'll try and find other ways

subtle cove
#

Hence, Entity.prototype.clone() when

cursive fog
#

What does source.runCommandAsync do?

subtle cove
#

Sth similar to ```js
system.run(() => d.runCommand('say hi'))

halcyon phoenix
#

one day, one day...

rustic ermine
cursive fog
rustic ermine
#

yeah

#
Dimension: Removed runCommandAsync as most commands did not actually run asynchronously. If you are looking to run a function asynchronously, please investigate using Jobs via System.runJob

from scripting 2.0 release

cursive fog
#

Like Case 0

rustic ermine
#

it can be done wherever you want in code

regal folio
#

Can someone help?

#

#1397807239892566138

cursive fog
#

@rustic ermine sorry for ping
One last
Does runCommand work like tick.json or it only runs the command once?

rustic ermine
#

the command itself only runs once, but that does not stop you from making it run like a tick

#
    system.runInterval(() => {
        player.dimension.runCommand(...)
    }, 20)      //Once per second

etc

regal folio
#

How do I get an array of blocks from an area similar to full but only returning an array of blocks that I can edit after

#

?

thorn flicker
halcyon phoenix
final ocean
#

But how to make it automatically added to inventory when mining a block?

regal folio
#

How do I make things comma separated but if there’s a space, ignore it like eg. “hello,what, bedrock, end, hello what” = [“hello”, “what”, “bedrock”, “end”, “hello what”]

rustic ermine
regal folio
#

This makes no sense

#

Please explain

rustic ermine
#

what doesn't make sense about it?

regal folio
rustic ermine
#

a placeholder for the split that would not naturally occur in a string

regal folio
#

There’s no code that does that in there

rustic ermine
#

because it replaces all ", " with §T, then splits at the §T and returns a string[] without any §T

regal folio
rustic ermine
#

probably a way to regex that but I dont have time to mess with it atm sorry

regal folio
#

How do I make things comma separated but if there’s a space, ignore it like eg. “hello,what, bedrock, end, hello what” = [“hello”, “what”, “bedrock”, “end”, “hello what”]

valid ice
regal folio
#

This is coming from a user input

#

Text box

valid ice
#

Why do that in the first place

#

Oh

regal folio
#

Now you see what I mean?

#

I need something robust

valid ice
#

Why not have them input \n for new lines, if that’s your goal

regal folio
#

How do I do this (with commas)

rustic ermine
#
const my_string = "hello,what, bedrock,  end, hello what";
const new_string = my_string.replace(/,\s*/g, ",").split(",");
rustic ermine
#

regex

regal folio
#

Ok Lemme try

rustic ermine
regal folio
#

Oh wait yea

subtle cove
#
textField.split(/(?:\s+|),(?:\s+|)/)
jagged gazelle
final ocean
jagged gazelle
#

The API version only

final ocean
cursive fog
#

Anything wrong with this?

jagged gazelle
cursive fog
# jagged gazelle Send the code, I can't just assume it especially it was cut off
import { world, system, Dimension } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"


let ui
let customUi;

world.afterEvents.worldLoad.subscribe(() => {
  ui = new ActionFormData()
    .title("Form")
    .body("")
    .button("Balls")


  customUi = new ActionFormData()
    .title("Skibidi")
    .body("")
    .button("Grip")
});

world.afterEvents.itemUse.subscribe(({ source, itemStack }) => {
  switch (itemStack.typeId) {
    case 'ssia:attachment': customUi.show(source).then(({ canceled, Selection }) => {
      if (canceled) return;
      switch (source.selection) {
        case 0:
          source.runCommand('say Grip Equiped')
          break;
      }
    })

  }
});
jagged gazelle
#

same how you used canceled

cursive fog
jagged gazelle
cursive fog
#

The case 0 is ok?

jagged gazelle
#

Hmm

#

I might give you a better system later or never

cursive fog
#

So if i press
The first button will it trigger case 0?

jagged gazelle
cursive fog
cursive fog
#

Sorry for these uhh
Dumb questions

#

😭

cursive fog
#

W i see

distant tulip
cursive fog
#

@jagged gazelle uhh sorry for ping
What now💔

#

Wym canceled is not defined

jagged gazelle
#

wha?

rustic ermine
#

I hate that I'm starting to like AI for tedious things

cursive fog
#

I think this is problem
Should i uhh add a space on it

cursive fog
jagged gazelle
# cursive fog Wym canceled is not *defined*
world.afterEvents.itemUse.subscribe(({ itemStack, source: player }) => {
  if (itemStack.typeId === 'minecraft:stick') {
    customUi.show(player).then(({ canceled, selection }) => {
      if (canceled) return;

      switch (selection) {
        case 0: break;
        case 1: break;
      }
    });
  }
});```
rustic ermine
cursive fog
visual zephyr
#

i added an equippable cmponent in my entity and when i used script api to access the equippable component it says its undefined

subtle cove
#

since when did lore got updated to max of
100 lines and 1000 string.length

visual zephyr
#

thanks ill use commands

halcyon phoenix
#

I loathe mojang

subtle cove
# jagged gazelle Been awhile
const hmm = (raw) => new Proxy(raw, typeof raw == "function"
    ? {
        apply(fn, thisArg, args) {
            console.warn(fn.name, args);
            return fn.apply(thisArg, args);
        }
    } : {
        get(n, k) {
            console.warn(k);
            return n[k]
        }
    })
halcyon phoenix
#

can you do

bundle_itemstack.getComponent(inventory)

?

#

is that possible?

halcyon phoenix
#

this is doable it seems

halcyon phoenix
#

Smokey*

wary edge
halcyon phoenix
#

awright

#

how do I navigate to other version with stirante's?

distant tulip
cursive fog
#

I dont understand why my runcommand wont work

world.afterEvents.itemUse.subscribe(({ source: player, itemStack }) => {
  switch (itemStack.typeId) {
    case 'ssia:attachment': customUi.show(player).then((
      { canceled, Selection }) => {
      if (canceled) return;
      switch (Selection) {
        case 0:
          system.run(() => Dimension.runCommand('say Grip Attached'))
          break;
      }
    })

  }
});
visual zephyr
#

how can i make my custom entity react with playerinteractwithentity

#

i already added the interact component

cerulean cliff
#

Can we not check if a block is replaceable if via the script api?

visual zephyr
#

use player.sendMessage instead or world.sendMessage

halcyon phoenix
#

is it possible to disable the bundle interaction? the drop on interact?

cerulean cliff
#

sad :(

#

but good to know!

loud brook
#

Hey guys, so I want to summon an entity and giving it a tag at the same time any ideas how can I do that?, I tried to look in dimension.spawnEntity for perhaps any answer but I couldn't find a way to add a tag to a mob spawned through script.

Dimension.runCommand(`summon ${type} ${Math.floor(Location.x)} ${Math.floor(Location.y)-1} ${Math.floor(Location.z)-1} 180`)
halcyon phoenix
#
    const {itemStack, source} = e;
    mc.system.run(() =>{
        if (itemStack && itemStack.typeId == "tm:mob_container") {
            sc.print("clear");
        }
    })
});

why the heck does this cancel bundle interaction?

wary edge
halcyon phoenix
#

is this a bug?

loud brook
halcyon phoenix
#
mc.world.beforeEvents.itemUse.subscribe((e) =>{});

this disables bundle on use, why??????

#

bug?

#

am I missing something?

loud brook
cursive fog
loud brook
halcyon phoenix
#

open the console

loud brook
#

it doesn't say anything tho

loud brook
halcyon phoenix
#

"minecraft:zombie"

loud brook
#

btw, is initialRotation in spawnEntity new? (I am asking this just for the possibility that my script isn't update it enough)

halcyon phoenix
#

yeah it's on beta

#

make sure you're on beta

loud brook
#

bruh, but I don't want to use beta, hmmmmm

#

perhaps I could change its rotation by teleport

loud brook
loud brook
wary edge
loud brook
#

and how do I wait 1 tick?

somber sundial
#

system.runTimeout(() => {}, 1)

loud brook
loud brook
jagged gazelle
jagged gazelle
cursive fog
#

So...
player.dimension.runCommand?

dusky flicker
#

its slow as hell

#

verifying for each entity on the world and seeing if theyre in a radius will suck

#

i got no idea on how to solve that but for sure i'd use what you said as a prototype

somber sundial
#

you did put the console.warn inside of the timeout function also, right?

cursive fog
#

AAAAAAAAAAAAAQ

#

@jagged gazelle THANKSSSS

loud brook
loud brook
halcyon phoenix
jagged gazelle
#

I dunno...

halcyon phoenix
#

that's clearly a bug

#

@wary edge can you shed some light on this?

visual zephyr
#

how can i make an entity target another entity

#

like for example i will command a zombie to target this specific player using custom commands

#

using script api

jagged gazelle
#

damage...

#

Entity.target is beta and read-only.

visual zephyr
#

like i want my entity to go there

visual zephyr
north frigate
#

imagine if all the community worked on one project

cyan basin
#

it would end up being a stressed mess

#

everyone has their own way of doing stuff and would just get tangled in with each other

jagged gazelle
#

I forgot what JAM was that

subtle cove
#

Things happens for unexpected reasons,
but perhaps another JAM for everyone... 👀

gaunt salmonBOT
loud brook
#

Hey guys,How do I detect a tag that starts with 'pd:' for example?

round bone
round bone
#
player.getTags().filter((tag) => tag.startsWith("pd:"))
#

list of every tag that player has and they have to start with pd:?

round bone
#

no problem

#

👍

sly valve
#

Hey guys

#

would anyone be so nice to help me with a Script?

#

I need a Tick Scheduler.
It should be able to register intervals or timeouts.

// e.g
const scheduler = new TickScheduler()
scheduler.interval(() => {}, 5) // returns an ID

works like basically like system.runInterval
but its different.
it contains scheduler.tick()
its a clock.
so i can easily stop executing .tick and the game will be paused.
I need this for my game

#

I need it to be optimized. not just an array with data. more like a bucket maybe

#

or some other algorythms

#

I'd appreciate any help

warm mason
sly valve
warm mason
#

I will make a script resource

sly valve
halcyon phoenix
cursive fog
#

Help? Why is bridge screaming at me?

#

💔

subtle cove
cursive fog
#

Thanks

#
import { world, system, Dimension } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"


let ui
let customUi
let scarUi

world.afterEvents.worldLoad.subscribe(() => {
  ui = new ActionFormData()
    .title("Form")
    .body("")
    .button("Balls")


  customUi = new ActionFormData()
    .title("Skibidi")
    .body("")
    .button("Grip")
    .button("Scar H")
});

world.afterEvents.itemUse.subscribe(({ source: player, itemStack }) => {
  switch (itemStack.typeId) {
    case 'ssia:attachment': customUi.show(player).then((
      { canceled, selection }) => {
      if (canceled) return;
      let response = selection
      switch (response) {
        case 0:
          system.run(() => player.dimension.runCommand('say its working'))
          break;
        case 1:
          scarUI(player)
          break;
        case 3:
          system.run(() => player.dimension.runCommand('give @s minecraft:diamond'))
      }
    })

  }
});

function scarUI(player) {
  world.afterEvents.worldLoad.subscribe(() => {
    scarUIform = new ActionFormData()
      .title("SCAR H Attachment")
      .body("")
      .button("Test1")
      .button("test2")
      .button("test3")
      .button("test4")
      .button("test5")

    scarUi.show(player).then((
      { canceled, selection }) => {
      if (canceled) return;
      let response = selection
      switch (response) {
        case 0:
          system.run(() => player.dimension.runCommand('say your sigma'))
      }

    })
  });
} 
#

Help pls

gaunt salmonBOT
cursive fog
#

Wait

warped blaze
warped blaze
#

you don't need those privileges to create an ActionFormData instance afaik

warped blaze
cursive fog
jagged gazelle
# cursive fog ``` import { world, system, Dimension } from "@minecraft/server" import { Action...
import { world, system, Dimension } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"

let customUi
let scarUi

world.afterEvents.worldLoad.subscribe(() => {
  customUi = new ActionFormData()
    .title("Skibidi")
    .body("")
    .button("Grip")
    .button("Scar H")
  
  scarUi = new ActionFormData()
    .title("SCAR H Attachment")
    .body("")
    .button("Test1")
    .button("test2")
    .button("test3")
    .button("test4")
    .button("test5")
});

world.afterEvents.itemUse.subscribe(({ source: player, itemStack }) => {
  if (itemStack.typeId !== 'ssia:attachment') return

  customUi.show(player).then(({ canceled, selection }) => {
    if (canceled) return
    
    switch (selection) {
      case 0:
        player.dimension.runCommand('say its working')
        break
      case 1:
        scarUi.show(player).then(({ canceled, selection }) => {
          if (canceled) return
          if (selection === 0) player.dimension.runCommand('say your sigma')
        })
        break
      case 3:
        player.dimension.runCommand('give @s minecraft:diamond')
    }
  })
});```
cursive fog
cursive fog
jagged gazelle
cursive fog
#

Ohh ok

cursive fog
jagged gazelle
#

yes.

cursive fog
#

if (selection === 1) run whatever i put in here?

cursive fog
jagged gazelle
#

Wait.

#

I'll make it cleaner because using switch inside of another switch is ugly ash

jagged gazelle
cursive fog
cursive fog
jagged gazelle
jagged gazelle
# cursive fog Ill keep ts i guess

the buttons have two required things, the name of the button which is text and funct... You use the name you put in funct to be used in the buttons_funct to adjust what it runs.

jagged gazelle
cursive fog
#

Ye that one looks modular

jagged gazelle
#

I guess it's better you don't use that lol

distant tulip
cursive fog
#

But currently i need smth that works💀
So ill be sticking on the ones i currently worked on

cursive fog
#

My release schedule is wayy off now because of ts💔

warped blaze
#

like

#

some guy opening a ui with a blue apple and thanking coddy

cursive fog
#

This ones diffrent

#

Basically second menu

#

The first one is to test functional button

rustic ermine
#

Dead in the water unless I can solve either of these.. trying to mimick OSRS combat, which I have done with scriptAPI, but two entity related issues make it feel awful and wondering if anyone has a solution.

  1. Knock back Resistance component does nothing on the player. Makes my combat system feel awful when the player is in a timer based combat loop but gets thrown back every time enemy hits.
  2. If 1 is not solvable, trying to get an entity to pathfind into melee range then fire an event for script to read.. which I understand is not possible, so thought of maybe having them get into melee range then fire invisible projectiles so script can detect the collision event. That one is easy but feels weird and has the side effect of the enemy being able to "miss" outside of the normal damage negation calculation

Any inputs or recommendations? Wish we had more entity script control but meh. Is almost deal breaker enough considering going back to Java 😵‍💫

halcyon phoenix
rustic ermine
#

Don't want to rely on that because I've been waiting for that since scriptAPI first released lol

prisma shard
prisma shard
deep quiver
#

since when do we have skin apis

unreal cove
deep quiver
round bone
#

Filter is returning all elements that are returning true for applied function

stark kestrel
#

is there a way to cancel damages? since theres no god dayum beforeEvents for entityHurt

#

😭 why

#

or if i just want to disable every player vs player damage?

#

WITHOUT weakness effect

untold magnet
#

uh, is it possible to do camerashake using scripts? like without runCommand it?

wary edge
#

No.

untold magnet
#

alright, i have to use runCommand for it

cinder shadow
final ocean
#
import { world } from '@minecraft/server';

function isInventoryFull(player) {
    const inv = player.getComponent("minecraft:inventory");
    if (!inv) return true;

    const container = inv.container;
    if (!container) return true;

    for (let i = 0; i < container.size; i++) {
        const slot = container.getItem(i);
        if (!slot || slot.amount < slot.maxAmount) return false;
    }
    return true;
}

world.beforeEvents.playerBreakBlock.subscribe((event) => {
    if (isInventoryFull(event.player)) {
        event.cancel = true;
        event.player.sendMessage("§cTúi đồ đầy! Không thể phá block.");
    }
});

world.afterEvents.playerBreakBlock.subscribe((event) => {
    const { dimension, block, player } = event;

    if (!isInventoryFull(player)) {
        const drops = dimension.getEntities({
            type: "minecraft:item",
            location: block.location,
            maxDistance: 3
        });

        for (const item of drops) {
            item.teleport(player.location);
        }
    }
});

My code has no errors so why can I still mine blocks when the inventory is full?

#

I will go to sleep and wait until tomorrow
Good night!!!

floral timber
#

well, if any of ur slots arent entirely filled even when its not the desired block, from what i see, ur isInventoryFull func will return false.

#

make sure all of ur slots are fully filled, and it should work.

floral timber
#

if (!slot) //code or u might wanna check if there's that particular block in the inv and if its filled or not.

warped blaze
#

stringifying ItemStacks and then parsing them was a valid way of saving them, right?

#

or am i wrong?

distant tulip
warped blaze
#

idk why but i felt like it was the way

warped blaze
distant tulip
#

#1252014916496527380

warped blaze
#

yeah i saw that but I'd have to update it to work on 2.0.0 so i thought i could do it another way

#

anyway thx

distant tulip
jagged gazelle
buoyant canopy
#

is there a checklist for updating from scripts 1.x to 2.0?

#

i really don't want to just update and manually test my scripts and fix them one by one

floral timber
#

Np

little hull
#
world.afterEvents.dataDrivenEntityTrigger.subscribe(({ entity, eventId }) => {
    if (entity.typeId === "mz:goblin_general1" && eventId === "mz:aoe1") {
        const hits = entity.getEntitiesFromViewDirection({ maxDistance: 4 });

        for (const hit of hits) {
            const target = hit.entity;
            if (target.typeId !== "mz:goblin") {
                target.applyDamage(1);
            }
        }
    }
});

does anyone have a better idea in this its an attack system

hoary panther
#

How do I go about building a block permutation from scratch? Like if I want to place a block and i need to set certain states of it how do I get the base permutation to edit or generate the permutation to feed into the setblock call?

warped blaze
#

-# argument for .setBlockPermutation() has to be a BlockPermutation class instance, not Block

hoary panther
#

Oh thats not what I did but thanks for helping

hoary panther
warped blaze
#

yeah you can also do that

hoary panther
#

Well thanks for helping!

warped blaze
hoary panther
#

Nah it was the generation part

#

I got it all working now

granite cape
#

Day 2 Learning ScriptAPI🛏️

halcyon phoenix
jagged gazelle
halcyon phoenix
sly valve
granite cape
sly valve
granite cape
sly valve
granite cape
#

🛏️

sly valve
#

🛏️

sour sedge
#

If I want to give custom loot for a vanilla block (in this case a bed that the player breaks), should I use PlayerBreakBlockBeforeEvent or PlayerBreakBlockAfterEvent ?

sly valve
unreal cove
#

You can’t edit the vanilla blocks btw

sly valve
unreal cove
#

Yeah, there block json definition isn’t exposed yet

sly valve
#

Isnt it cool btw that Minecratft stores all Languages and lang files of every language but you will only use one for years

#

So many useless stuff and I cannot delete it

#

I wonder how unoptimized Windows is..

deep quiver
sly valve
#

Oh i've seen this before, for what do you need Entity.target?

jagged gazelle
#

I mean it's already self explanatory.

sly valve
#

you can only read it

jagged gazelle
sly valve
#

I were distracted by the read-only

#

but it seems like it's a accessory or how its called

jagged gazelle
sly valve
#

indeed

unreal cove
#

interesting

sly valve
distant tulip
halcyon phoenix
#

I was spawning entity not looping it's self

#

next time I'll ouroboros some script

cursive fog
#

Whats the problem here?

#

So i plan to import attachment.js

granite cape
#

must like this path,

import './attachment'
#

or maybe can this (untest)

import 'attachment'
cursive fog
round bone
#
import "./attachment"

is better in this case

untold magnet
#

uh, just making sure*
is it possible to rotate the player head without having to teleport it?

untold magnet
round bone
untold magnet
#

it doesnt

#

ywah whatever

warm mason
untold magnet
subtle cove
#

is tp facing not an option for that...

untold magnet
#

but it kinda looks good in this way

final ocean
#

How can I create a bedrock mining function where I hold a pickaxe and when I hold it for 7 seconds the bedrock block breaks and drops an item.
Yes I think it is difficult but after I learn it I won't need help

round bone
# untold magnet it doesnt

I was thinking the same at the moment, but docs does not mention that this method is not working for players, so I thought it might work

midnight crane
#

Is there a way to make it so if an entity is near another entity with a tag they first entity blast back the way the player/user is looking
-# I know a very random request

cursive fog
#

Can someone uhh give me example of code where if i step on a specific block it explodes💀

#

Its for uhh

#

Jump boost thing

subtle cove
wise raft
#

Is it possible to modify a enum?

subtle cove
#

enum in mc or enum in cmds...

hazy copper
#

Idk if anyone could help out.
Basically Im trying to tame a mob without using an item but just clicking on it. Ive treid doing it through interact and the tameable component with minecraft:air and it didnt work. Finally tried a script and I still cant get it to work. if anyone can look over it and tell me if anythings wrong

#

im getting no content logs, im getting no console warns when interacting wih the mob either

#

(I know theyre running because ive intentionally put parse errors in them and the game picks it up)

subtle cove
#
const { player, beforeItemStack, target } = ev;
// Empty hand?
if (!beforeItemStack) return;
hazy copper
subtle cove
#

yes

hazy copper
#

oh

#

bro edited it

#

now its saying it cant find export beforeItemStack

subtle cove
#

i sent a snippet, not a whole code

hazy copper
#

still dont work I think

subtle cove
hazy copper
#

no console either

wise raft
hazy copper
#

yeah nope

subtle cove
hazy copper
#
import { world } from "@minecraft/server";


const allowedMobs = [
    "ve:dunk"
];


world.beforeEvents.playerInteractWithEntity.subscribe(ev => {
    const { player, beforeItemStack, target } = ev;

    if (!beforeItemStack) return;

    if (!allowedMobs.includes(target.typeId)) return;

    let tameable;
    try {
          system.run(() => {
            tameable = target.getComponent("minecraft:tameable");
});
    } catch (err) {
        return; 
    }
    if (!tameable) return;


    if (tameable.isTamed) return;


    let success = false;
    try {
         system.run(() => {
        success = tameable.tame(player);
         });
    } catch (err) {
        console.warn("Error on taming:", err);
        return;
    }

    if (success) {
        player.sendMessage(`You have tamed: ${target.id}!`);
    } else {
        player.sendMessage(`Couldn't tame.`);
    }    
});```
subtle cove
#

hb removing that if item statement, it should do sth

hazy copper
#

nope

#

im basically making a cat but I dont want it to require an item to tame. idk if I need to do smt specific to its behavior file either

buoyant canopy
#

What does world.afterEvents.worldLoad do?
i tried to use world.getDimension inside it and it told me that it doesn't have privileges

subtle cove
hazy copper
#

well not want I need it to work like that in groups

subtle cove
buoyant canopy
warm mason
hazy copper
buoyant canopy
warm mason
buoyant canopy
#

I guess i will have to call it every time i want to use the overworld

warm mason
# buoyant canopy

So the error is somewhere else, because the same code works for me

buoyant canopy
warm mason
#

.......

buoyant canopy
#

this is stable 2.0.0 btw

warm mason
#

Are you sure you reloaded the scripts?

wary edge
#

Not system.run

buoyant canopy
buoyant canopy
#

Insane coincidence

buoyant canopy
#

I didn't read the file name, just the line number

full island
#

does anyone know if its possible to add the traits of an allow block to a custom block? (where you can place or break blocks only above it in adventure mode) I've tried a few ways but nothing works as soon as Im in adventure mode

hazy copper
subtle cove
hazy copper
#

I created a post in entities and was told to just script and got kinda ignored afterwards

#

We've been at this nearly a week I think

agile bone
#

T-T

hazy copper
#

this 1 behvaior

subtle cove
#

yikes

hazy copper
#

like the mob basically requires it

agile bone
#

if only tame actually accepts air

hazy copper
#

fr

subtle cove
#

if only i could clone myself ;-;

hazy copper
#

like theres nothing wrong with minecraft:air I dont understand

agile bone
hazy copper
#

why it wont work

subtle cove
agile bone
#

is there a resource of basic playerinteract with entity script

hazy copper
#

they claim scripts is heavily documented but when you ask for examples its crickets

warped blaze
#

@hazy copper idk if this is specifically what you wanted to do but there you go

import { world } from "@minecraft/server";

const allowedMobs = ["ve:dunk"];

world.afterEvents.playerInteractWithEntity.subscribe(({ player, beforeItemStack: item, target }) => {
  const tameable = target.getComponent("tameable");
  if (!allowedMobs.includes(target.typeId) || !tameable || tameable.isTamed || item) return;
  tameable.tame(player)
})```
hazy copper
#

@agile bone

#

Wanna try this rq im not at my pc T-T

warped blaze
#

k

#

gimme a minute

hazy copper
warped blaze
#

mb

hazy copper
#

You're good, also I think so Its literally jsut me trying to make follow, attack, and tamed to a player without an item

#

ive had a hell of a time getting it to work

warped blaze
agile bone
#

hold

hazy copper
#

im holding

warm mason
# warped blaze why?

afterEvents on interact events only fires when the interaction did something, for example you fed a cow, but if you have nothing in your hands then afterEvents simply won't fire

agile bone
#

O

#

I mean, I think it tamed, there were hearts

hazy copper
#

WHAT

agile bone
#

but you can't make it sit though

hazy copper
#

t-t

agile bone
#

hold on

#

EYYYY

hazy copper
#

WHAT??

agile bone
#

it worked, thank you so much

hazy copper
warm mason
hazy copper
#

Finally

hazy copper
#

we've been at this forever

warped blaze
agile bone
#

works like a charm

#

thank you so much

warped blaze
agile bone
#

yes, also it should also have the tame_event set up, or else, it won't be able to sit

#

again thank you so much sensei goated

tidal wasp
#

can you use Math.random in beforePlayerPlace components?

wary edge
#

Yeah.

jagged gazelle
grim raft
#

yo is there a way to decrease or disable damage knockback taken on players?

#

the knockback_resistance component doesnt work on the player

wheat condor
jagged gazelle
wheat condor
#

then just use the damage sensor and cancel the damage from entities and with the afterEvent entityHitEntity you can create your custom knockback

limber leaf
#

is there some way to debug addons other than using vscode?

grim raft
wheat condor
wheat condor
grim raft
#

can you detect the damage taken with entityHitEntity or entityHurt?

limber leaf
#

if the extension is open source atleast imma try to create a cli for it

jagged gazelle
grim raft
#

alr

wheat condor
limber leaf
#

im for sure not using vscode

wheat condor
#

why?

limber leaf
#

my computer gets slow when using vscode

#

too much ram usage

wheat condor
#

how much ram you have?

limber leaf
#

i got 8gb

#

and im not used to use the mouse while coding anymore

wheat condor
#

have you tried to use some memory trimmer?

limber leaf
#

i didnt even know there was this on vscode

wheat condor
#

that's not from vscode its just a tool that i think compresses memory

#

its only for win 10 btw

limber leaf
#

i use linux

#

i dont think it would work then

#

well, the extension is open source

#

i might do some fork

flat barn
#

category: this member was found in the input, but is not present in the Schema

#

what does this mean?

open urchin
wicked girder
#

How is scripting threaded? Ive heard the system run is ran on the main thread but idk

grim raft
#

why these errors appearing

[Scripting][error]-ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (combat.js:4)

[Scripting][error]-Plugin [Arise BP - 1.0.0] - [main.js] ran with error: [ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (combat.js:4) ]

#
const blockResist = world.scoreboard.getObjective('blockResist')```
wary edge
#

You need to put it in worldLoad event.

grim raft
#

oh

#

cuz of v2?

wary edge
#

Yes.

grim raft
#

damn

grim raft
wary edge
fallen cape
#

does vibrant visuals strip away the color of debug renderer?

grim raft
wary edge
#

Yeah.

limber leaf
#

i dont know the internals but normally minecraft is single thread

#

things on mc like jobs, system.run, etc, might be added on a scheduler and run on parallel

untold magnet
#

uh, i tried using worldLoad, but it cant send messages for players for some reason

limber leaf
open urchin
#

you should use playerSpawn instead and check that initialSpawn is true

untold magnet
#

like its not always showing the images, sometimes the message is sent but without my jsonUi images

warped blaze
#

what happened to the "precise interaction" part of the wiki?

untold magnet
#

so i need to send the messages as soonest the world is fully loaded

open urchin