#Script API General

1 messages Β· Page 48 of 1

inland merlin
#

Looks like json ui subtraction for the forms in server_form

grim raft
#

yo

quick vapor
#

ts lowkey sad, actually like nothing has changed, im looking at the dif types and events and theres deadass nothing i was hoping for 😭

chilly fractal
#

Lmao

grim raft
#

I want to know how to make the result number not have a dot (like 0.5)
${Math.floor(player.getComponent("health").currentValue / player.getComponent("health").effectiveMax * 24)}

chilly fractal
#

.toFixed(0)

grim raft
#

what will that do?

chilly fractal
#

Remove the trailing decimals

#

It will turn it into a string tho.

inland merlin
#

Round up or down

chilly fractal
#

Neither

#

It will just remove them

inland merlin
#

Awh

grim raft
chilly fractal
#

1.3 -> 1

inland merlin
#

So down

chilly fractal
#

Yes

grim raft
#

I want it to like when its 1.8 it will turn into 2

chilly fractal
#

Math.round(num)

grim raft
#

change floor to round?

chilly fractal
#

Dont you want it to round?

#

Floor always rounds down to closest smallest int

#

Ceil always rounds up to closest largest int

#

Round rounds to either closest largest int or cloest smallest int depending on the trailing decimals' values

valid ice
#

Doesn't toFixed round?

chilly fractal
#

No just removes it.

grim raft
#

ty for the info

valid ice
#

Indeed

chilly fractal
#

If you wanted some certain level of trailing decimals, for example if you wanted just 4 levels, it would turn it into (num.xxxx) and x will be 0 if the num doesn't have that level of decimals.

quick vapor
#

am i geeked or do i need something else for my pack to show in game

chilly fractal
quick vapor
#

yeah thas what im sayin

chilly fractal
grim raft
#

to see if it works

quick vapor
#

what does that even mean gang

chilly fractal
# chilly fractal 🀷

Also you can make your own function to turn a num into string and manually set the amount of decimals you want. (Me personally i hate js, so if it trys to fk with my mind i just make custom functions, i personally dont trust it lmao)

grim raft
quick vapor
#

i want the pack to show up in game 😭 i havnt been coding for a while so ive pretty much forgotten everything

grim raft
#

oh

chilly fractal
#

So uh?? What exactly is the error, is it like... not importing or is it not working or what?

quick vapor
#

the pack aint even in my list of packs

grim raft
quick vapor
grim raft
#

it will automatically import it into the game

quick vapor
valid ice
#

Did you change the UUIDs?

quick vapor
#

i did

grim raft
grim raft
quick vapor
#
{
    "format_version": 2,
    "header": {
        "name": "yurt",
        "description": "yurting currently",
        "uuid": "412cb0ea-b3f8-4c79-a8c8-1c9eb263f19b",
        "version": [0, 0, 1],
        "min_engine_version": [1, 21, 60]
    },
    "modules": [
        {
            "description": "behavior",
            "version": [0, 0, 1],
            "uuid": "cb70b3ea-c702-483c-a288-0bd96f2e3992",
            "type": "script",
            "language": "javascript",
            "entry": "scripts/main.js"
        }
    ],
    "dependencies": [
        {
            "description": "server",
            "module_name": "@minecraft/server",
            "version": "1.18.0-beta"
        },
        {
            "description": "server-ui",
            "module_name": "@minecraft/server-ui",
            "version": "1.4.0-beta"
        },
        {
            "description": "debug-utilities",
            "module_name": "@minecraft/debug-utilities",
            "version": "1.0.0-beta"
        }
    ]
}```
#

im just tryna make a standalone behavior pack

#

dev behavior pack so i can work on it in game

valid ice
#

Need data module in modules section too

quick vapor
#

aight

#

lemme try

valid ice
#

{
"type": "data",
"uuid": "new-uuid",
"version": [ 0, 0, 1 ]
},

grim raft
#

or 1.17.0-beta

valid ice
#

I assume they are running preview

grim raft
#

yea maybe

dim tusk
#

I'm the one who gave the template I think he didn't change it 😭

chilly fractal
# valid ice
function toFixed(n, p) {
  const s = String(n), i = s.indexOf('.');
  return i < 0 ? (p > 0 ? s + '.' + '0'.repeat(p) : s) : (p === 0 ? s.slice(0, i) : s.slice(0, i) + '.' + s.slice(i + 1).slice(0, p).padEnd(p, '0'));
}

Try that...

dim tusk
chilly fractal
valid ice
#

the native toFixed does round

chilly fractal
#

Yes but you can override it using prototypes

#

(Its not a good practice tho so thats why i didn't do it here)

#

Does it work???

#

I'm so dumb, why didn't i test myself lmao

valid ice
#

it do

#

First one is fine, it's intended behaviour

#

chat said to add the this for error checking

  if (typeof n !== 'number' || isNaN(n) || !isFinite(n)) {
    throw new Error('Input must be a finite number');
  }
  if (typeof p !== 'number' || p < 0 || !Number.isInteger(p)) {
    throw new Error('Precision must be a non-negative integer');
  }
chilly fractal
#

Yeah i knew it did that but i didn't use it anyway tbh. I like my numbers clean. But anyway my function works!

valid ice
#

yippee!

valid ice
#

My chatGPT has been whipped into shape by my constant correcting πŸ˜›

chilly fractal
#

Lmao

dim tusk
#

Bro became slave

chilly fractal
#

I personally don't use it as i gives me too many headaches for just one simple mistake that requires a little bit more focusing and it ends up breaking everything

inland merlin
#

yo has anyone already made a decent invenotry to work with the existing herobrine chest ui?

chilly fractal
#

So ye i avoid it unless i just ask it for quick calculations for example calculating storage stuff required and stuff.

inland merlin
#

if not, its whatever... but annoying to have that visual but not have functioning invenotry... so ill have to recreate the best i can

chilly fractal
inland merlin
#

i can get it working myself... its just a pain to add

#

because players gonna question the inventory functionality

chilly fractal
#

Well you can always use automation scripts like bash, python or js.

valid ice
#

Functioning inventory is something LeGend was gonna look into a bit ago

inland merlin
#

i think a big part of the functionality would be the json ui bit (for a better experience)

chilly fractal
#

Bash allows for more control over the files themselves and net requests better, and python allows for more control on the contents of files, while js is much less flexible as you need too much logic and you need to set up the files manually with the given auto generated content.

dim tusk
#

My chess is almost perfect... Just that rook eat the pawn

chilly fractal
#

Basically what i am trying to say, is for you to console.log an array of all item types (existing ones) and then copy that log, store it in an array, look in in the vanilla files and probably they are the same but yea. And make a bit of json or files or whatever you need but like a part that doesn't change for certain item types and then classify which part of the code you want to be put for that specific item. And then after all that auto generation is complete, the script api part is much much much easier to do.

chilly fractal
chilly fractal
# inland merlin oh nice

You can use @minecraft/vanilla-data or smth i think or even the server one and get a list of all vanilla items.

inland merlin
#

i haven't done the vanilla-data ever

dim tusk
#

I could use particles but I don't like it.

chilly fractal
#

I personally suggest making a fully automatic auto generation script such as bash or python so stuff is easier to manage.

chilly fractal
chilly fractal
dim tusk
dim tusk
inland merlin
chilly fractal
#

Entites

inland merlin
#

ohh

chilly fractal
#

He said that

inland merlin
#

makes sense im blind

chilly fractal
chilly fractal
#

Nah I'm probably saying random names 🀣

dim tusk
chilly fractal
dim tusk
#

Lemme do the calculation agin

distant tulip
#

his pc exploded and now he code in mobile

chilly fractal
dim tusk
#

So, you can have 65 states, each with 2 possible values, to maintain 65,536 permutations.

#

only 2? bro chess has 64 positions and have empty, pawn, rook, bishop, queen and king... So size values. It's not even possible 😭

chilly fractal
#

Chatgpt does the equation. Not creates & does the equation

#

That's how i see it

#

If you use it to create something from start, it's gonna fk it up

dim tusk
#

This makes my block incompatible with other addons who also uses permutation

chilly fractal
#

If

#

There are even any other addons.

#

Or even a coddy

#

Or even a coddy's house

dim tusk
chilly fractal
dim tusk
#

Sometimes I use chatgpt to automate my json πŸ˜‚

chilly fractal
#

Crazy

#

I'd never trust it

#

I trust javascript in strings with all my cells and i trust it with any and everything... BUTT (WITH ANOTHER T) math.

dim tusk
chilly fractal
#

Chatgpt doesn't have a max chars limit??

#

Damn y'all be privileged lmao

dim tusk
chilly fractal
#

What???

dim tusk
#

if you ask him to generate it thru text the limit is now there.

chilly fractal
#

HE CAN GENERATE IT IN FILES?

#

Crazy

dim tusk
#

you can try

chilly fractal
#

Ima try rn

#

(The reason i haven't tried is i never used it cuz it was locked out of my country for so long so idk if it works now)

#

AYO IT ISN'T LOCKED ANYMORE?

#

DAYYYYMN!

#

BETTT

chilly fractal
#

Can't say. (I like to remain anonymous)

dim tusk
#

I'm sure you're Chinese...

chilly fractal
#

nah

#

ALSO YES IT WORKS AND SENDS A DOWNLOADABLE FILE?!@

#

WHY HAVEN'T I BEEN USIN THIS?

#

Bruh

dim tusk
# chilly fractal E

you have 3 file limit and y'know how it works? When you upload a file... And you accidentally remove one, you can't upload anymore it counts as upload even if you didn't hit send yet.

dim tusk
chilly fractal
#

And it WORKs?

#

IT AUTO GENERATES WITHOUT MISTAKES?

#

HAVE I BEEN USING A COMPLETELY TRASH AI FOR THIS LONG, REALLY?

#

Nevermind actually

#

Gemini has much more computing power and stuff, this one has more of a... computing smartness

#

Hol up, i didn't ask chatgpt for a runCommandAsync? When that shii pop up, it says 2024. I used it rn like its 1/2/2025... how tf did i ask for that?

#

And holy crap it says this:

#

Is it already insulting me bruh??

#

Nah ima education this dumb A about cmds :)

#

Nah i decided to do a little bit of trolling

#

And holy crap

#

It got gaslit quickly

#

Unlike gemini, gemini tells you nah and just fkin kicks you outta the page. This? Nah. This just straight up provides πŸ”₯ advise about "deobfuscating"

fiery solar
# chilly fractal

I don't see anything wrong in that screenshot? I think ChatGPT is probably the best free AI for coding tasks, but just like with all of them you need to teach it about the script API first

south heart
#
        const displayComponent = itemInHand.getComponent("minecraft:display");
          displayComponent.lore = [
            "Power Level: 16"
          ];

Any one know why this is happnening

chilly fractal
chilly fractal
#

its called item.getLore()[index]

#

Dont use ai

south heart
#

i just need to know where the docs are tbh

chilly fractal
#

Of why not to use ai

south heart
chilly fractal
chilly fractal
south heart
#

thanks

south heart
#

yeah i am

#

do i need a setLore function

chilly fractal
#

Bruh

#

On the item

#

Like

south heart
#
world.beforeEvents.chatSend.subscribe((eventData) => {
    const player = eventData.sender;
  
    if (eventData.message === "!md") {
      const inventory = player.getComponent("minecraft:inventory").container;
  
      const handSlot = player.selectedSlotIndex;
      const itemInHand = inventory.getItem(handSlot);
  
        const displayComponent = itemInHand.getComponent("minecraft:display");
          displayComponent.setLore = [
            "Power Level: 16"
          ];
            inventory.setItem(handSlot, itemInHand);
      eventData.cancel = true;
    }
  });```
chilly fractal
#

itemInHand.setLore(["foo", "bar"])

#

I am not an ai

#

I will not provide full code

south heart
#

ohhhhh

chilly fractal
#

You have to understand what i am saying and implement it yourself

south heart
#

yeah

valid ice
#

Display component ain’t a thing

south heart
chilly fractal
#

So what now?

#

I looked at your bio. Are you gonna haunt me in my dreams?

#

Why'd you delete your message scary guy?

#

What, do you think my nordvpn and macafee subscriptions are in vain?

#

Do you think that i share any personal stuff online?

#

I wanna know your answers. "X..x.xxx" guy.

#

I hope you ain't banned cuz i wanna infact, hack you. Not personal, just for fun.

#

Cuz i infact love fellas like ya

inland merlin
#

quick quesiton about itemDynamicProperties... it keeps saying i can't add to stackable item... which currenlty is a minecraft:mob_spawner...

is there a way to make it non-stackable before adding item dynamic properties?

#

vanilla wise

valid ice
#

Nop

#

Can't modify vanilla blocks

inland merlin
#

so i have to make a custom block then that simulates it

#

dang

#

okay thank you for your quick reply

valid ice
#

You'd need an item that places the block down when used

#

As a block's itemstack can't be edited to be nonstackable

inland merlin
#

oh

#

ok

valid ice
#

or just use lore

inland merlin
#

yeah, i was probably just gonna do that

#

but its annoying i want the dynamic properites... because of the cap

#

but oh well lol

chilly fractal
inland merlin
#

might just make a copy of the spawner

#

no worries

#

best option honestly

valid ice
#

Lore overrated
Just kinda the only viable option in this case

#

I advocated for lore before item dynamic properties existed

chilly fractal
inland merlin
#

well, until lore was capped

#

its still ok....

valid ice
#

Still pissed about that cap ngl

#

Always will be

chilly fractal
#

Name doesn't even suggest that lmao, its supposed to be for stuff like "Crafted from the ingots of hell and forged in the coldest of places" like, its talking about the item's story.. imagine the story being "i2vx3wn42e4" lmao

#

Cap was made so the old crash methods using hacks that modified the item aspects like lore and enchants don't work

valid ice
#

Hacks can bypass the limit still, regardless

#

It didn't limit the lore itself, it just limited the setLore function in scripts

chilly fractal
#

Really?

#

Huh

valid ice
#

yeh

chilly fractal
#

Then you have every right in existence to be pissed off about the cap.

valid ice
#

And afaik, loot table json files don't have a lore function limit, so

chilly fractal
#

Nah y'all have every right to be pissed off at moyang fr

fiery solar
#

You can get around the data storage limits of the cap by storing whatever you need in a world dynamic property and writing a pointer to the property ID to the lore

valid ice
#

It's honestly not the data storage limit that is annoying- DPs exist for that reason.
I used the whole thing for displaying stuff πŸ˜›

chilly fractal
#

Well yes but

#

Incase someone uses it to actually style and give their item a story like how they named it

#

You can't really "get around" the limit

#

But in other use cases, yea sure

#

Also, quick js question

#

What impact would this snippet do on a user?

#

(One sec)

inland merlin
#

here we go, custom spawner

#

now i should be able to add itemDynamicProperties

chilly fractal
#
const n = (N) => (Number(N));document.write(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(n(`9999`.repeat(1))))))))))))))))))))));
#

What impact would this do?

#

(Without testing)

valid ice
#

Instant death

thorn flicker
#

the world explodes

chilly fractal
#

Wrong answers

#

It would do nothing

thorn flicker
#

wrong answer

chilly fractal
#

Because that number is so humongous

#

It is considered infinity

#

And repeat does not allow infinity

valid ice
#

nuh uh

#

It would end the world

thorn flicker
#

exactly.

inland merlin
chilly fractal
chilly fractal
chilly fractal
#

Lets see the num tho

#

998800659780049492080923920804949780006599880001

#

(I used a different script to get the value, the reason i didn't use repeat is because repeat as limit, but in the first snippet it was a test)

#
const n = (N) => BigInt(N);let result = 1n;for (let i = 0; i < 12; i++) {result = result * n(9999);}
console.log(result.toString());
#

(You can go further and stretch the absolute limits using a while loop but i don't want my beautiful phone that has every possible feature (i paid some crazy money for a company to customize for me) to explode)

#

Now this version, if you are crazy enough to do this, sure, but be warned it will probably freeze your device.

const n = (N) => BigInt(N);let result = 1n;for (let i = 0; i < Number(`12`.repeat(12)); i++) {result = result * n(9999);}
console.log(result.toString());
#

Anyway have fun y'all

sterile epoch
#

i want to make a skygen, and have it so you can upgrade the generators, but only the owner of the generator can do so, since blocks can't have dynamic properties, would using a database get laggy?

#

I'm not entirely sure how much dynamic properties lag, especially in large amounts

valid ice
#

They're pretty efficient even in large amounts

errant plover
#

Can I make it so if I right click my animal it gives me an item

crude bridge
#

Some one know how to teleport a player back on the position he was

#

Like

#

If(playerVelocity.x !== 0) {
Player.teleport(previous position)
}

dim tusk
# errant plover Can I make it so if I right click my animal it gives me an item
import { ItemStack } from '@minecraft/server';

world.beforeEvents.playerInteractWithEntity.subscribe(ev => {
   const { target, itemStack, player } = ev:
   if (target.typeId === 'minecraft:creeper') {
      const inventory = player.getComponent('inventory').container;
      system.run(() => {
         const itemStack = new ItemStack('minecraft:stick', 1);
         itemStack.nameTag = 'My stick';

         inventory.addItem(itemStack);
      });
   }
});```
dim tusk
crude bridge
#

Oh okay

errant plover
errant plover
#

Wow ty

errant plover
dim tusk
errant plover
dim tusk
errant plover
dim tusk
tawny jungle
#

is there a way to get runInterval running again after a reload?

#

(automatically)

sterile epoch
#

world initialize

#

since world initialize restarts when u do /reload

tawny jungle
#

hmm

#

would that work in a custom block component property?

errant plover
#

If I’m making a new sword what’s the max damage

meager cargo
#

Can someone help me get this to work?

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

const TARGET_BLOCK = "minecraft:lime_stained_glass";
const PARTICLE_TYPE = "minecraft:villager_happy";

system.runInterval((eventdata) => {
  const player = eventdata.player;
  const block = eventdata.block;

  if (block?.typeId === TARGET_BLOCK) {
    player.dimension.getBlock(block.location),
      player.dimension.spawnParticle(PARTICLE_TYPE, block.location);
  }
}, 20);
warm mason
meager cargo
#

Okay, so how I can use runInterval for detecting blocks (this lime glass) and run particle on them? Maybe with player near in like 50 blocks, or something

warm mason
meager cargo
#

I've done it another way - on invisible entity with tag and area

dim tusk
#

when using simulated players to destroy a block, does it have the mining Animation on the block?

bright dove
#


class OnRegistry {
    constructor() {
        this.initialize();
    }

    initialize() {
        world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
            this.registerCustomComponent(blockComponentRegistry);
        });
    }

    registerCustomComponent(blockComponentRegistry) {
        blockComponentRegistry.registerCustomComponent('cosmos:cavernous_vine', {
            onTick: ({ block }) => {
            },
            onRandomTick: ({ block }) => {
            }
        });
    }
}```
#

Is this valid code ?

errant plover
#

How do I run commands through a script

wary edge
#

I wouldn't do it like that though but yeah.

bright dove
wary edge
# bright dove It's pretty though
import {
    EntityDamageCause,
    EntityHitEntityAfterEvent,
    EntityHurtAfterEvent,
    system,
    world
} from '@minecraft/server';

export default class ClassAttack {
    constructor() {
        console.log('ClassAttack constructed');
        this.initialize();
    }

    protected initialize(): void {
        console.log('ClassAttack initialized');
        world.afterEvents.entityHurt.subscribe(this.onEntityHurt);
        world.afterEvents.entityHitEntity.subscribe(this.onEntityHitEntity);
    }

    private onEntityHurt(eventData: EntityHurtAfterEvent): void {
        console.log(
            'Testing to see whether entity hurt runs first or entity hit entity runs first'
        );
        console.log('Entity Hurt: ' + eventData.damage);
        // throw new Error('Method not implemented.');
    }

    private onEntityHitEntity(eventData: EntityHitEntityAfterEvent): void {
        console.log(
            'Testing to see whether entity hit entity runs first or entity hurt runs first'
        );
        void system.waitTicks(10).then(() => {
            eventData.hitEntity.applyDamage(10, {
                cause: EntityDamageCause.contact,
                damagingEntity: eventData.damagingEntity
            });
        });
        // throw new Error('Method not implemented.');
    }
}
wary edge
flat barn
#

Obfuscated code

#

that’s literally the worst challenge ever

supple yoke
#

hey :(

#

i was going to say banger name but nvm

flat barn
#

I’m just saying, It’s just full of bad practices and unconventional stuff

#

it’s good if you want your code to be unreadable :P

remote oyster
#

I know someone else who writes code like that and it drives me crazy seeing it lol. Somehow, their brain is simply wired for it. I call that style Kryptonite.

errant plover
#

got an error when i ran my code in minecraft, i remember learning about this and i feel stupid for forgetting,
[Scripting][error]-Plugin [Project Friend - 1.0.0] - does not contain main file [main.js].

remote oyster
dim tusk
remote oyster
flat barn
#

Reminds me of that quote by Linus Torvalds, "Bad programmers worry about the code. Good programmers worry about data structures and their relationships."

flat barn
#

Why’s that?

slow walrus
#

you're worrying about the style of code

#

or complaining

flat barn
#

It’s in his perspective

#

In his perspective he’s worrying about the code

#

but also that’s not the context

#

of it

errant plover
#

got an error when i ran my code in minecraft, i remember learning about this and i feel stupid for forgetting,
[Scripting][error]-Plugin [Project Friend - 1.0.0] - does not contain main file [main.js].

errant plover
#

nope

#

i have an index.js

wary edge
#

Well there's your issue.

errant plover
#

i mean where should i put it and what shoulld i put in it

flat barn
# slow walrus you're worrying about the style of code

It's in the sense of, a "bad" programmer will focus on syntax and immediate logic. For example if he went away from his code for a few months or created a whole system with that method of programming, anytime he goes back to something it'll be much harder to maintain.

#

and read

#

However, if you think about the design of your code and structure/organisation of the data used it's makes it much easier to read (for others aswell as yourself), on top of making it efficient, cleaner etc

#

challenging yourself to do the complete opposite is just a massive detriment to ur progress

distant gulch
#

my eyes... WHATS THAT

slow walrus
slow walrus
supple yoke
#

tbh if I try to do that on an actual project, I'll probably kms

#

but this is just a fun project to test my binary / data structure knowledge

slow walrus
#

yeah

supple yoke
# distant gulch my eyes... WHATS THAT

that's the old version, i got a better one (it works too)

let {world:W,system:S}=await import("@minecraft/server"),b=(p,b)=>W.getDimension("overworld").setBlockType({x:p>>4,y:-60,z:p&15},b+"_concrete")||p,d=1,h=0,a=3,s=1,f=c=>S.runTimeout(_=>{d=(d&3?d|48:d|3)&1<<W.getPlayers()[0].selectedSlotIndex||d;c(b(a,"red")^b(h=h+(d&17)-(d/2&17)&255,"green")?s:++s);let p=h;f(n=>n?p^h?c(n-1):z:h^a?b(p,"white"):a=Math.random()*256|0)},4);f(_=>_)
flat barn
flat barn
#

for example

slow walrus
flat barn
#

There's literally 0 point in doing that but yk

slow walrus
#

are you just hating for the sake of it or what?

flat barn
#

They can do what they want

slow walrus
supple yoke
#

uh you used a non existent version of @minecraft/server

flat barn
slow walrus
supple yoke
slow walrus
supple yoke
#

did i spelled that right?

slow walrus
supple yoke
#

oh i see then

slow walrus
#

and server-ui 1.0.0

supple yoke
#

yeah make a post

flat barn
slow walrus
flat barn
supple yoke
#

not sure what are we arguing about

#

i just want a cool project to show off at pack jam

slow walrus
flat barn
slow walrus
#

if you changed the variable names to be more descriptive, the code would do entire the same thing

flat barn
#

If you did this on a big project, and you went back to it a few weeks later you will not understand what you wrote

slow walrus
flat barn
#

if you did this in a project with others

#

It's the same problem

slow walrus
#

and not something they're doing in a large scale project

flat barn
slow walrus
flat barn
#

And the challenge is teaching them bad practices

supple yoke
slow walrus
supple yoke
#

i have been coding for many years lol, just writing a 300 byte code won't make me suddenly use inheritance

slow walrus
#

and apparently fun in coding is illegal now

#

no one likes a pompous stuck up person who thinks they're the best because they use "good practices"

flat barn
supple yoke
#

bruh, this is so dumb. atleast argue about something that matters, like "should inheritance exist" or something

slow walrus
#

you should learn to not pointlessly insult people because they tried to challenge themselves

slow walrus
flat barn
#

Maybe there's a misunderstanding

flat barn
#

no one can read that easily

#

that's the point of obfuscation

#

lol

slow walrus
#

doesn't mean it's garbage though

flat barn
#

That's quite literally what obfuscation is supposed to be

#

It's a form of encryption

supple yoke
#

i mean yeah?

flat barn
#

to prevent people from reading your code

slow walrus
#

garbage would mean that the code is useless and can be thrown away, which is not what obfuscation does or is for

supple yoke
#

i have a non "obfuscated" version on my GitHub

flat barn
#

That's probably where they got the bitwise ops from also

supple yoke
#

wha?

flat barn
#

instead of showing hard coded values, you can bitwise op them even tho doing that can just be reversed easily. but that's not the point. The whole code can be reversed

#

And if they return the same values then yippee!

slow walrus
#

and? the point of it wasn't to make irreversible encryption?

supple yoke
#

what are you talking about

slow walrus
#

i don't even know

flat barn
#

The point was the create it in the smallest possible way, which is obfuscation if you use single letter variable and function names

supple yoke
#

bro i was followig until he drops that

#

uhuh

#

yes?

flat barn
#

my point was that, It's just bad practice and not a very good challenge for yourself

#

It's just a detriment to yourself

supple yoke
slow walrus
supple yoke
flat barn
#

You can still write clean code in embedded systems

#

It's the performance of the code that matters

#

which if you did this for that case, yeah it wont be very performant

#

obfuscation reduces the performance of code

supple yoke
#

ok that's just wrong, while you can have clean code in embedded. memory becomes a huge issue in those areas

slow walrus
supple yoke
#

the compilers play a huge role for reducing the size of code

supple yoke
#

ok that was fun, I'll go have breakfast now

#

@slow walrus ty again for arguing with/for me

slow walrus
#

oh yeah that's just completely wrong lmao

#

if anything the obfuscation in the original snippet has better performance than a non obfusctaed version

#

since it uses bitwise ops

slow walrus
flat barn
flat barn
flat barn
slow walrus
flat barn
#

no

#

anyways it's likely he just obfuscated it

#

instead of writing it

remote oyster
#

In fact, code in general didn't just appear. Someone wrote it, somewhere, somehow.

#

Gave it purpose and meaning. πŸ˜„

subtle cove
flat barn
remote oyster
#

What do you mean when you say "don't write obfuscation"?

flat barn
#

The act of writing code in a way that is obfuscated

remote oyster
#

Their code wasn't true obfuscation though. It just used shortened names, nested functions, bitwise operations, and minimal comments. Nothing deliberate to make the code unreadable. It being difficult to read doesn't make it obfuscated. It just means it's been compacted. In some professions, that is a necessity. Not sure if you knew that or not. I think Omniac or somebody gave an example as to why.

slow walrus
#

yeah exactly

remote oyster
#

Depends on what their end goal is. Since neither of us know that answer we can't really say.

flat barn
#

i think they just want to show off

dim tusk
#
function helloWorld() {
    const greetingParts = [String.fromCharCode(72), String.fromCharCode(101), String.fromCharCode(108), String.fromCharCode(108), String.fromCharCode(111), String.fromCharCode(44), String.fromCharCode(32), String.fromCharCode(87), String.fromCharCode(111), String.fromCharCode(114), String.fromCharCode(108), String.fromCharCode(100), String.fromCharCode(32)];
    let greeting = '';
    for (let i = 0; i < greetingParts.length; i++) greeting += greetingParts[i];
    return greeting;
}

console.log(helloWorld());```
#

Unnecessary as hell

bright dove
nimble schooner
#
world.afterEvents.itemUse.subscribe(event => {
    const {
        source: player,
        itemStack
    } = event
player.getComponent("minecraft:inventory").container.setItem(player.selectedSlot);```

why the fuck does player.selectedSlot not return a number
dim tusk
nimble schooner
bright dove
bright dove
flat barn
#

Uhh

dim tusk
bright dove
#

oh 😭

#

Lol

nimble schooner
#

How many participants can a scoreboard objective have?

flat barn
#

otherwise any other method is practically the same speed

dim tusk
#

Or you can just js console.log('Hello, World!');

bright dove
#

LOL

bright dove
#

I cant access it πŸ’€

#

oh yeah

supple yoke
bright dove
#

Okay serious question

supple yoke
bright dove
#

Anyone here to help me with applyKnockback ?

distant tulip
warm mason
bright dove
bright dove
tawny jungle
#

how could I get this ontick class to run once at start and once at the end for an onMounted event and an onDismounted event?

        let entitiesAtBlock = dimension.getEntitiesAtBlockLocation(block.location);
        for (let mountEntity of entitiesAtBlock) {
            if (mountEntity?.typeId === "sci:mb_mount") {
                if (this.events.whileMounted) {
                    this.events.whileMounted({ block: block })
                    time = system.currentTick
                }
            }
        }
    }```
warm mason
warm mason
bright dove
bright dove
#

function grab_player(dimension) {
    const players = dimension.getEntities(); 
    players.forEach(player => { 
        player.applyKnockback(0, 0, 0, 0.1); 
    });
}```
#

is this valid ?

bright dove
#

so it affects ALL entities

distant tulip
#

why name it players bao_ext_toldyouso

bright dove
warm mason
distant tulip
#

Knockback resistance do effect it

remote oyster
bright dove
warm mason
bright dove
warm mason
thorn flicker
#
if (entity instanceof Player) {

}
else { 

}
warm mason
thorn flicker
#

thanks

thorn flicker
velvet swallow
#

Can anyone tell me if it’s possible to detect when a player changes a wandering villager's name using a name tag?

crude bridge
bright dove
#

Is there a native method for setBlock ?

bright dove
#
function growth(e) {
    const { block } = e;

    // Get the block's current location
    const { x, y, z } = block.location;

    // Get the block below the current block
    const blockBelow = block.dimension.getBlock({ x, y: y - 1, z });

    // Check if the block below is air
    if (blockBelow && blockBelow.typeId === 'minecraft:air') {
        block.setType('cosmos:cavernous');
    }
}```
#

is this valid ?

granite badger
#

What event are you subscribed to

bright dove
#

:}

granite badger
#

Looks fine to me

bright dove
warm mason
bright dove
# granite badger What event are you subscribed to

world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
        blockComponentRegistry.registerCustomComponent('cosmos:cavernous_vine', {
            onTick({ block }) {
                const cavernousVine = new CavernousVine();
                cavernousVine.grabPlayer(block);
                cavernousVine.poisonPlayer(block);
            },
            onRandomTick({ block }) {
                const cavernousVine = new CavernousVine(); 
                cavernousVine.vineGrowth(block);
            }
        });
     });```
#

this works ?

dim tusk
supple yoke
#

gasp!

acoustic basin
#

guys, so i've found this template for player joining the world welcome message, adapted it up to myself, but i get an error that crashes all of my scripts, "unexpected await keyword", and i dont understand what's wrong with await system.waitTicks

import { world, system } from '@minecraft/server'

let playerJoinStatus = new Map()

const DELAY_TICKS = 800

world.afterEvents.playerSpawn.subscribe(data => {
    const player = data.player
    const playerName = player.name
    if (player.initialSpawn) {
        if (!playerJoinStatus.has(playerName)) {
            await system.waitTicks(DELAY_TICKS)
            world.sendMessage('Β§7Welcome!')
            playerJoinStatus.set(playerName, true)
        }
    }
})```
dim tusk
#
import { world, system } from '@minecraft/server'

let playerJoinStatus = new Map()

const DELAY_TICKS = 800

world.afterEvents.playerSpawn.subscribe(async (data) => {
    const player = data.player
    const playerName = player.name
    if (player.initialSpawn) {
        if (!playerJoinStatus.has(playerName)) {
            await system.waitTicks(DELAY_TICKS)
            world.sendMessage('Β§7Welcome!')
            playerJoinStatus.set(playerName, true)
        }
    }
})```
#

Add the async

acoustic basin
#

ah, and that's it really?

acoustic basin
acoustic basin
bright dove
#

:]

noble bolt
#

and allow await keyword

acoustic basin
#

alr, thank u

#

also, the message doesn't appear, maybe bcs the world is loading longer than i set the delay, and the message appears before i enter the world so i cant c it

#

i extended the delay but nope, didnt send the message

dim tusk
#

Y'know the forceShow function for server form?

acoustic basin
#

oh wait

#

it got sent

#

i removed if (player.initialSpawn), and it got sent

distant tulip
#

800 is 40 sec...

dim tusk
acoustic basin
#

thought i rejoined the world and i got it sent again

acoustic basin
# distant tulip 800 is 40 sec...

i know, but before i removed if (player.initialSpawn), i waited for like 3 minutes and it didnt appear, and then i removed the if statement and the message appeared

acoustic basin
#

i made this const const initSpawn = data.initialSpawn, and made if statement with it, will test if message will be snet only once

#

nope, being sent again...

subtle cove
#

kindly show us the code pls

acoustic basin
#
import { world, system } from '@minecraft/server'

let playerJoinStatus = new Map()

world.afterEvents.playerSpawn.subscribe(async (data) => {
    const player = data.player
    const initSpawn = data.initialSpawn
    const playerName = player.name
    if (initSpawn === true) {
        if (!playerJoinStatus.has(playerName)) {
            await system.waitTicks(800)
            player.sendMessage('Β§7Welcome! Β§fThank you for playing with Random Add-On! Read all the details about the Add-On on the downlaod page! Β§7Team Members: Β§6VLAD360 - Project Lead, Coder, Nerpa4ch - Visual Design Lead, Nouve More - Artist, Natitun - Concept Artist, Rofoo - Mob Artist, Steve - Musician, Pavel Kvakov - Level Designer, Ribossomo - Sound Designer, Glider - Game Designer')
            playerJoinStatus.set(playerName, true)
        }
    }
})```
subtle cove
#

the map is always empty at world init, and player isnt there

#

Hmmm

#

Try lower ticks before the final 800 ticks for tests

acoustic basin
acoustic basin
bright dove
subtle cove
subtle cove
bright dove
acoustic basin
#

so i lowered the ticks to 100, ive made another world, the message got sent like, after 2 seconds after i entered the world, but the message appeared again when i rejoined the same world

acoustic basin
subtle cove
#

It's not the map that's the issue actually

subtle cove
acoustic basin
acoustic basin
# subtle cove So like there's another script doing it...

nah, i have only this welcoming message script, it was in system.runInetrval, like, checking for player's velocity, and if it's greater then 0, send the message, but i moved it to playerSpawn, and removed this script from inetrval

#

there's only one script basically

subtle cove
#

Ok, so rejoining the world triggers it again.
Only if it's single player

If the world's been running it only triggers once

#

So like every after world start cus that's when the map used there is empty. On world start/initialization

acoustic basin
#

what if i unsubscribe from the event when it has been triggered already?

#

or actually, if other players join the world, like, multiplayer, the probably won't c the message

distant tulip
subtle cove
acoustic basin
acoustic basin
subtle cove
#
import { world, system } from '@minecraft/server'

let playerJoinStatus = new Set()

world.afterEvents.playerSpawn.subscribe(async (data) => {
    const player = data.player
    if (data.initialSpawn) {
        if (!playerJoinStatus.has(player.name)) {
            await system.waitTicks(800)
            if (!player.isValid()) return
            player.sendMessage('Β§7Welcome! Β§fThank you for playing with Random Add-On! Read all the details about the Add-On on the downlaod page! Β§7Team Members: Β§6VLAD360 - Project Lead, Coder, Nerpa4ch - Visual Design Lead, Nouve More - Artist, Natitun - Concept Artist, Rofoo - Mob Artist, Steve - Musician, Pavel Kvakov - Level Designer, Ribossomo - Sound Designer, Glider - Game Designer')
            playerJoinStatus.add(player.name)
        }
    }
})```
warm mason
dim tusk
#

why you add Delay btw?

#

I'm lost in this topic lol

subtle cove
#

The waitTicks depends on u how long u wana send the msg

acoustic basin
# dim tusk why you add Delay btw?

bcs when player is joining the world, the loading may take too long and the player just won't c the message, the message will appear before the world loads in, is it how it works?

#

welp, im rejoining the world, and again, the message is appearing again

dim tusk
#

I get it... Just a hunch, what if create a forceShow then when it opens close the form and send a message

#

you can close forms forcefully without damage or anything

subtle cove
subtle cove
subtle cove
#

Then it's works fine

#

-# oh well i ain't gona edit that msg ;-;

warm mason
#
world.afterEvents.playerSpawn.subscribe(data => {
  if (!data.initialSpawn || data.player.hasTag('not_new')) return  

  let player = data.player
  let rotation = player.getRotation()
  let id = system.runInterval(() => {
    if (!player.isValid()) return system.clearRun(id)

    let rot = player.getRotation()
    if (rot.x != rotation.x || rot.y != rotation.y) {
      system.clearRun(id)
      player.addTag('not_new')
      player.sendMessage("hi")
    }
  })
})
subtle cove
#

Or use form to show the message, rather than sendMessage

distant tulip
#

just use tags / dp to tag the players who got the message

acoustic basin
warm mason
subtle cove
dim tusk
#

Try, forceShow of server form 😭

#

I've been saying this multiple times 😭

acoustic basin
distant tulip
#

what do forms have to do with that...

subtle cove
#

The long message

warm mason
distant tulip
#

worth a try i guess
but that may look weird

acoustic basin
#

i just did this and that's it, it works perfectly how i need ```js
import { world, system } from '@minecraft/server'

world.afterEvents.playerSpawn.subscribe(async (data) => {
const player = data.player
if (data.initialSpawn) {
if (!player.hasTag('v360:welcome_message')) {
await system.waitTicks(100)
player.sendMessage('Β§7Welcome! Β§fThank you for playing with Random Add-On! Read all the details about the Add-On on the downlaod page! Β§7Team Members: Β§6VLAD360 - Project Lead, Coder, Nerpa4ch - Visual Design Lead, Nouve More - Artist, Natitun - Concept Artist, Rofoo - Mob Artist, Steve - Musician, Pavel Kvakov - Level Designer, Ribossomo - Sound Designer, Glider - Game Designer')
player.addTag('v360:welcome_message')
}
}
})```

#

but i think map isn't even needed here since im just testing if the player has tag or not when joining

subtle cove
#

now player.hasTag

acoustic basin
#

oh wait, i had the old code copied

acoustic basin
#

here, updated

distant tulip
#

seem fine

acoustic basin
#

alr, ive got the result i needed

#

thanks y'all

warm mason
acoustic basin
#

okie, i'll make use of it then

distant tulip
#

yeah, +clearRun if not

acoustic basin
#

alr, another question, but i think the answer is obvious, is there a way to detect block under the entity all the time without using system.runInterval?

warm mason
#

no

acoustic basin
#

im still trying to optimize my system.runInterval script, and if possible, trying to find alternative for ceratine events to not use inetrval

acoustic basin
#

i actually got my script down from like 1000 or so lines to 251

meager cargo
#
world.afterEvents.playerSpawn.subscribe((initialSpawn) => {
    for (const player of world.getAllPlayers()) {
        const playerId = player.nameTag;
        if (initialSpawn) {
            player.onScreenDisplay.setTitle({ rawtext: [{ translate: 'testing.title', "with": ["\n"] }] }, {
                stayDuration: 40,
                fadeInDuration: 20,
                fadeOutDuration: 20,
            });
            system.run(() => {
                system.runTimeout(() => {
                    player.runCommandAsync("tp -42 -22 29 0 0");
                }, 30);
            });
        } else {
            return;
        }
    }
});

Can someone help me and change this script, so player will only run this title and command tp - after First time join to world

acoustic basin
#

but i'm still getting the "hang" crash sometimes

acoustic basin
meager cargo
#

Yh yh, I'm reading right now

#

πŸ˜„

acoustic basin
#

actually, i can make, for example, detection of block under the entity in a .mcfunction file, would it be more stable then using system.runInterval in script?

#

thought i assume no

dim tusk
bright dove
#

how do you get the current location of a player ?

acoustic basin
acoustic basin
#

aaaaargh, there r just some events in my system.runInterval which dont really have any alternatives, and so, have to be ran every tick

granite badger
#

what is wrong with my docs

granite badger
#

player.location and block.location

bright dove
# granite badger player.location and block.location

poisonPlayer(block.location) {
        const players = this.world.getPlayers(); // Get all players
        players.forEach(player => {
            player.addEffect("minecraft:poison", 2); // Apply poison effect for 2 seconds
        });
    }
}```
#

whats wrong with this ?

gaunt salmonBOT
# bright dove ```js poisonPlayer(block.location) { const players = this.world.getPlay...

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 5 errors:

<REPL0>.js:2:1 - error TS2304: Cannot find name 'poisonPlayer'.

2 poisonPlayer(block.location) {
  ~~~~~~~~~~~~

``````ansi
<REPL0>.js:2:14 - error TS2552: Cannot find name 'block'. Did you mean 'Block'?

2 poisonPlayer(block.location) {
               ~~~~~

  @minecraft/server.d.ts:3326:15
    3326         class Block {
                       ~~~~~
    'Block' is declared here.

``````ansi
<REPL0>.js:2:30 - error TS1005: ';' expected.

2 poisonPlayer(block.location) {
                               ~

``````ansi
<REPL0>.js:3:30 - error TS2339: Property 'world' does not exist on type 'typeof globalThis'.

3         const players = this.world.getPlayers(); // Get all players
                               ~~~~~

``````ansi
<REPL0>.js:8:1 - error TS1128: Declaration or statement expected.

8 }
  ~

Lint Result

ESLint results:

<REPL0>.js

2:29 error Parsing error: ';' expected

acoustic basin
#

not seconds

bright dove
dim tusk
dim tusk
granite badger
timid zenith
dim tusk
dim tusk
timid zenith
granite badger
#

I am thinking of adding a report button next to the examples so you can send a github issue to me, how does that sound?

dim tusk
#

Guy can you tell me again what's the actual bytes of Dynamic property values?

#

like the exact value

true isle
#

what do i use to interact with a block with any item in hand? or no item at all

odd path
#

@dim tusk

#

Dude, can you tell me how I can identify that an entity is holding an item?

dim tusk
# odd path <@916617172313321533>

the equippable component is disabled to entities yet, closest one is use runCommand and hasItem and loop all items registered in the world if something matches returns true

thorn flicker
#

if it returns greater than 0, it means the command was successful.

dim tusk
#

he already knows how to do it .. that's on his post

thorn flicker
dim tusk
thorn flicker
#

why is he asking "testFor" then

dim tusk
thorn flicker
#

do you mean you already answered him after he asked here?

thorn flicker
dim tusk
#

I'M NOT FLASH WAIT.

#

Too many people are pinging me for help

thorn flicker
#

what?

#

All I said was I got it

dim tusk
#

no, I'm not saying you're the one of them too

#

lol, I was showing my expression

thorn flicker
dim tusk
thorn flicker
#

lol

#

you'll end up getting multiple pings for sure

dim tusk
#

Y'know there's a ping but the message isn't there 🀷😺

dim tusk
distant tulip
dim tusk
#

Me?

#

Yeah intentionally do that since I don't want to annoy people and to kinda escape 😺

distant tulip
#

lol
alr

thorn flicker
dim tusk
#

I'm sorry for all the people that I happened to use this type of technique with...

dim tusk
thorn flicker
tawny jungle
#

is there a way to get blocks within taxicab distance as opposed to complete BlockVolume?

winter plaza
#

How do I identify when I'm moving by script?

dim tusk
#

Entity.setDynamicProperties()

Sets multiple dynamic properties with specific values.

#

i don't get this.

steady canopy
# dim tusk i don't get this.

I guess it's just a way to make more performant modifying multiple properties at once and also a better way to do it instead of multiple lines with Entity.setDynamicProperty() or having to use loops...

dim tusk
slim spear
#

almost 6kb main.js 😭

#

actually nvm, it ain't as bad as I thought it was gonna be

cold grove
#

how better is to create a event listener for every instance of a class
or have one event that calls a method for all the classes? πŸ€”

supple yoke
#

while the code is pretty well-organized, they're some things that aren't the best of the practices

  1. using JavaScript
  2. why do you feel the need to deconstruct afterevents
  3. no consistency
  • sometimes you use if statements and sometimes ternary operators (for one liners)
  • the indentations
  1. using arrow functions incorrectly

while this works

()=> { return 1 }

do this

() => 1
  1. one liners everywhere
  2. using too many variables
  3. just export when the function is declared
export func(){}
  1. the file is too big
  2. redundant functions
slow walrus
somber cedar
#

What is this report button

noble bolt
#

report mojang

slim spear
#

ban notch

dim tusk
#

so if you see the example wrong or examples are switched with some functions just click the report

crude bridge
#

import { world, system } from '@minecraft/server';
import { ActionFormData } from "@minecraft/server-ui";

world.afterEvents.playerSpawn.subscribe(async (data) => {
const player = data.source
const initSpawn = data.initialSpawn
system.run(() => main(player))
})

function main() {
const cord = { x: 125, y: -23, z: 357 };
const form = new ActionFormData()
.title('Β§lBenvenutΒ§3oΒ§rΒ§l/Β§3aΒ§r Β§lnella Β§6Fantasy Craft! ')
.body("§l§6Fantasy Craft §r§lè un mondo di avventura e fantasia, dove puoi esplorare terre nuove, incontrare creature incredibili e sfidare sfide impossibili!\n§l§9Spero che tu possa goderti il tempo con noi e scoprire tutti i segreti di Fantasy Craft!\n§l§aTi auguro una buona esperienza e una buona avventura!\n§l§esegli la tua classe per andare avanti.")
.button("Β§lΒ§6segli classe")

    .show(player).then(({ canceled, selection }) => {
        if (canceled) {
            player.playSound("random.break")
        }

        if (selection == 0) {
            player.teleport(cord);
        }
    })

}

#

index.js 17 is

.show(player).then(({ canceled, selection }) => {

crude bridge
#

main(player)?

sharp elbow
#

You indeed do not have a variable defined named "player".

crude bridge
crude bridge
warm mason
crude bridge
#

now it works

chilly fractal
#

Yo can someone suggest me a challenge for me to do? A hard one. (Scripting api challenge y'know)

gaunt salmonBOT
#

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 1 errors:

<REPL0>.js:7:16 - error TS2551: Property 'hastag' does not exist on type 'Player'. Did you mean 'hasTag'?

7     if(!player.hastag(tag)) {
                 ~~~~~~

  @minecraft/server.d.ts:5970:5
    5970     hasTag(tag: string): boolean;
             ~~~~~~
    'hasTag' is declared here.

Lint Result

ESLint results:

<REPL0>.js

14:11 error 'form' is assigned a value but never used @typescript-eslint/no-unused-vars

22:17 warning The /tag command can be fully replaced with the Entity.addTag api in the @minecraft/server module. See https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entity#addtag for more information. minecraft-linting/avoid-unnecessary-command

27:17 warning The /tag command can be fully replaced with the Entity.addTag api in the @minecraft/server module. See https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entity#addtag for more information. minecraft-linting/avoid-unnecessary-command

distant tulip
#

hastag > hasTag

sharp elbow
shell sigil
#

Can someone help me fix this the problem is the dialogue not showing up even I click the Talk button I'm making a custom npc

#

Here the file

distant tulip
#

is this script related?

shell sigil
#

It's script and entity I think

distant tulip
#

send the script part
entity seem fine

#

do the talk button close the dialog?

shell sigil
#

Is it possible to open a form by interact to entity

distant tulip
#

sure

#
import { world } from "@minecraft/server";
import { ModalFormData } from "@minecraft/server-ui";

world.afterEvents.playerInteractWithEntity.subscribe((event) => {
  const player = event.player;
  const entity = event.target;
  if(entity != "id") return
  const form = new ModalFormData();
  form.title("entity Interaction");
  //...

  form.show(player).then((response) => {
    if (response.canceled) return
    //...
  });
});
shell sigil
#

Nice thanks

distant tulip
#

outpost script? what is that?

thorn flicker
#

its an area with enemies you need to clear

#

if that's not it, I dont know what he's referring to

distant tulip
#

seem easy enough i guess, but he need to be more specific in what he need the help on

thorn flicker
#

I agree.

#

please describe what you need help with and maybe share your code

#

so a base system?

distant tulip
thorn flicker
#

Agreed, thats why I told them to share their code

#

see what they have so far, so we could help with errors, but not code it for them.

distant tulip
#

i can describe what you need to do for each part of that system, but i doubt that will help

#

that is great

#

so what do you need help with?

#

small suggestion, store the outpost details in dynamic properties

tawny jungle
#

what is the next best thing to giving vanilla blocks tags?

wheat condor
#

But you can set a world dynamic property with a json object with bloc typeid and location so you added a tag to a block

tawny jungle
#

There we go

tawny jungle
#

does setDynamicProperty accept two values?

wheat condor
wary edge
wheat condor
#

but you can do JSON.stringify({location:location,blockTypeId:block.typeId})

tawny jungle
#

isee

#

thanks guys

wheat condor
meager cargo
#

Can anyone help me and tell how I can have rawtext title here?

class ChestFormData9 {
    #titleText; #buttonArray;
    constructor(size = '9') {
        const sizing = sizes.get(size) ?? ['Β§cΒ§hΒ§eΒ§sΒ§tΒ§0Β§9Β§r', 9];
        this.#titleText = sizing[0];
        this.#buttonArray = [];
        for (let i = 0; i < sizing[1]; i++) {
            this.#buttonArray.push(['', undefined]);
        }
        this.slotCount = sizing[1];
    }
    title(text) {
        this.#titleText += text;
        return this;
    }
    button(slot, itemName, itemDesc, texture, stackSize = 1, durability = 0, enchanted = false) {
        const ID = typeIdToDataId.get(texture) ?? typeIdToID.get(texture);
        this.#buttonArray.splice(slot, 1, [
            `stack#${Math.min(Math.max(stackSize, 1) || 1, 99).toString().padStart(2, '0')}Β§r${itemName ?? ''}Β§r${
                itemDesc?.length ? `\nΒ§r${itemDesc.join('\nΒ§r')}` : ''
            }`,
            (((ID + (ID < 262 ? 0 : number_of_1_16_100_items)) * 65536) + (!!enchanted * 32768)) || texture
        ]);
        return this;
    }
    pattern(pattern, key) {
        for (let i = 0; i < pattern.length; i++) {
            const row = pattern[i];
            for (let j = 0; j < row.length; j++) {
                const letter = row.charAt(j);
                if (key[letter]) {
                    const slot = j + i * 9;
                    const data = key[letter];
                    const ID = typeIdToDataId.get(data.texture) ?? typeIdToID.get(data.texture);
        
                    this.#buttonArray.splice(slot, 1, [
                        `stack#${Math.min(Math.max(data?.stackAmount ?? 1, 1) || 1, 99).toString().padStart(2, '0')}Β§r${data?.itemName ?? ''}Β§r${
                            data?.itemDesc?.length ? `\nΒ§r${data?.itemDesc.join('\nΒ§r')}` : ''
                        }`,
                        (((ID + (ID < 262 ? 0 : number_of_1_16_100_items)) * 65536) + (!!data?.enchanted * 32768)) || data.texture
                    ]);
                }
            }
        }
        return this;
    }
    show(player) {
        const form = new ActionFormData()
            .title(this.#titleText); 
    
        this.#buttonArray.forEach(button => {
            form.button(button[0], button[1]?.toString());
        });
    
        return form.show(player);
    }
}

And this is not working.
.button(1, { rawtext: [{ translate: 'first.button', "with": ["\n"] }] }, ['', { rawtext: [{ translate: 'first.button.lore', "with": ["\n"] }] }], 'textures/items/amethyst_shard')

#

It shows [object Object] in game

wheat condor
meager cargo
#

Yeah, I'm trying this since two days, but didn't came up with any solution yet

#

I've used rawtext syntax for most of my projects and scripts with forms, but since this is ChestUI from github and it's already done I don't know how to change that into the same rawtext as in ActionForm

meager cargo
wheat condor
warm mason
meager cargo
#

So my only option is to make another .js file with exported data of buttons or just type the button string as plain txt?
There is no other option, for real???

warm mason
meager cargo
#

And that's the construct of UI what I have sent, just it

warm mason
dim tusk
warm mason
meager cargo
#
    title(text) {
        this.#titleText += text;
        return this;
    }

This and buttons are not working

#

When I type rawtext syntax into buttons or titles in the custom form

dim tusk
#

this type of rawtext?

meager cargo
#

Yeah

dim tusk
#

I'm kinda confused about what your goal is... Why do you need to rawtext it?

#

To translate it?

meager cargo
#

{ rawtext: [{ translate: 'button.1', "with": ["\n"] }] } I need this into custom form
Like here
.button(1, <RAWTEXT>, ['', <RAWTEXT>], 'textures/items/amethyst_shard')

#

Yep

#

Translate

#

I succeed with normal actionform

dim tusk
#

give me the original format or how it should be inputted in the first place.

meager cargo
#

I open post and ping you there

devout dune
#

Hey I have a question about Debugger! / Attaching Minecraft - Visual Studio.
I thought I have follwed this...
https://learn.microsoft.com/en-us/minecraft/creator/documents/scriptdevelopertools?view=minecraft-bedrock-stable#debugging-with-minecraft-bedrock-edition
I am following bedrock instructions.
I Ran:
CheckNetIsolation.exe LoopbackExempt -a -p=S-1-15-2-1958404141-86561845-1752920682-3514627264-368642714-62675701-733520436

I am using regolith, so my code is outside of mojang folder.
Here is my launch.json
(Using typescript, so i have sourceMapRoot, and generatedsourfceroot)

{
  "version": "0.3.0",
  "configurations": [
    {
      "type": "minecraft-js",
      "request": "attach",
      "name": "Debug with Minecraft",
      "mode": "connect",
      "preLaunchTask": "build",
      "targetModuleUuid": "057766c1-5cc6-41b3-a4b2-b697881385ac",
      "generatedSourceRoot": "${env:LOCALAPPDATA}/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/wildcraft_bp/scripts",
      "sourceMapRoot": "${env:LOCALAPPDATA}/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/wildcraft_bp/scripts",
      "port": 19144,
    }
  ]
}

I click the green button to Run With Minecraft, I see a yellow bar around VS, which i assumed signified it is listening on the port.
I ran script debugger connect in Minecraft, but I keep getting the error 'Failed to start debugger'
The in game command wants /script debugger connect [host: string] [port: int] and i know that the port is 19144, but not sure what to put for host. I figured script debugger connect was enough

slow walrus
#

rn it's trying to connect to the client

#

this is my config

{
    "version": "0.3.0",
    "configurations": [
        {
            "type": "minecraft-js",
            "request": "attach",
            "name": "Debug with Minecraft",
            "mode": "listen",
            "localRoot": "${workspaceFolder}/packs/BP/scripts/",
            "port": 19144
        }
    ]
}
sage hamlet
#
const BoostingPad = {
    onStepOn(event) {
        const { entity, block, dimension } = event;
        
        // Ensure the entity is a player
        if (!(entity instanceof Player)) return;

        // Get the player's rotation (yaw and pitch)
        const rotation = entity.getRotation(); // Assuming getRotation gives yaw and pitch in degrees
        const yaw = (rotation.x * Math.PI) / 180; // Convert yaw to radians
        const pitch = (rotation.y * Math.PI) / 180; // Convert pitch to radians

        // Calculate the direction vector
        const forwardX = -Math.sin(yaw) * Math.cos(pitch);
        const forwardZ = Math.cos(yaw) * Math.cos(pitch);
        const upwardY = Math.sin(-pitch) + 0.5; // Slight upward boost

        // Boost the player by applying velocity
        const boostMultiplier = 1.5; // Adjust boost strength
        const velocity = {
            x: forwardX * boostMultiplier,
            y: upwardY * boostMultiplier,
            z: forwardZ * boostMultiplier,
        };
        
        entity.applyImpulse(velocity); // Apply the calculated impulse
    },
};```

[Scripting][error]-Error: applyImpulse is not supported for players at onStepOn

Anybody that knows why this isnt working and is there a workaround? (only workaround I have in mind is using a custom entity that places a roar component next to the player, I have done that before and that works but I thought I could simply use a velocity function)
alpine nebula
#

How do I apply effect to entity with specified amplifier and no particles?
I tried this:
nearbyEntity.addEffect('blindness', blindnessDuration, 0, true);
But got error

sage hamlet
#

nearbyEntity.addEffect('blindness', blindnessDuration, {amplifier: 0, showParticles: true});

warm mason
alpine nebula
#

Thank you

alpine nebula
dim tusk
sage hamlet
#

ApplyKnockback works @dim tusk ty

sage hamlet
warm mason
distant tulip
#

" applyImpulse is not supported for players"
just read the error man

dim tusk
sage hamlet
#

If it works it works

dim tusk
sage hamlet
#

I know how to code I mostly used it because I didn't know any javascript at that moment

#

now I work with it because it saves hours of time

#

also it comments my code nicely

warm mason
#

You won't learn JS if you use AI

distant tulip
dim tusk
#

hmm... I hate comments lol, because the code is in the name already, it's unnecessary

sage hamlet
#

well then I have to do it myself it's not like I don't know how to use the script API

warm mason
dim tusk
#

Meh, stop convincing people not to use AI anymore they have the same excuse "Easier", "Saves time or efficiency", "if it works then it works", "nothing's wrong using AI it's just a help", "I still learn"

warm mason
distant tulip
#

that not the point
using ai is ok
but at least you should know what are you doing

sage hamlet
#

it is useless to argue

dim tusk
warm mason
sage hamlet
#

I did?

dim tusk
#

I mean, yeah for someone who does not really do programming because they have other lives, it's understandable 🀷

#

either way code is a code.... 😢

warm mason
distant tulip
#

i remember the first script i made was with the help of ai, so i can understand his pov
but yeah you should definitely know what are you doing (i wasn't at that time)

sage hamlet
#

I also looked on wiki and documentation and since I didn't find the reason why velocity doesnt work on players I asked here

dim tusk
#

Don't argue anymore, it's useless.. at least just minimize the usage if you can't stop and just don't expect it always works since AI sometimes makes their own code or get online

jolly veldt
#

Ngl, if i ever use ai, it's only to find references or documentation

#

I cannot fathom using ai generated code

dim tusk
#

I use AI to generat JSON

sage portal
#

I use NI

warm mason
sage portal
#

Natural Intelligence

jolly veldt
dim tusk
remote oyster
#

I'm sharing my thoughts here because I'm open to defending them. Whether you like or dislike AI is a personal opinion, not a fact. Whether you agree or disagree that AI can assist in learning new ideas is also a personal opinion, not a fact.

At the end of the day, it falls on the individual using the tool to determine its valueβ€”whether they have taken the time to understand what they are looking at, how it works, why it works, and where they can go from there. The code provided, whether incomplete or not, is no more disjointed or incoherent than finding random segments and blocks of code on websites like Reddit, Stack Overflow, or any other source of your choosing.

It is still code provided by an entity that nobody knows. Regardless of whether that entity is AI or a random stranger on the internet, the individual receiving the code must still take the time to understand it, learn how it works, and decide where to go from there if they want to grow. The logic of learning does not change based on how the information is received. What truly matters is what they do with that informationβ€”it determines whether they grow or remain stagnant.

So, stop arguing about people using AI when some of you aren’t any better at providing advice on coding. I've been writing code for over 10 years, and I use AI because I understand its strengths. By leveraging those strengths, I can extend my services at a much faster pace. If you think otherwise, come challenge me, and we’ll see who wins that debate.

Arguing about this is silly and wasteful. Let's focus on what really matters, by providing help when people ask, if you want to help.

warm mason
remote oyster
# warm mason However, you also need to be able to use AI, but not everyone does it β€œcorrectly...

It is still code provided by an entity that nobody knows. Regardless of whether that entity is AI or a random stranger on the internet, the individual receiving the code must still take the time to understand it, learn how it works, and decide where to go from there if they want to grow. The logic of learning does not change based on how the information is received. What truly matters is what they do with that informationβ€”it determines whether they grow or remain stagnant.

jolly veldt
#

But yes, i do agree that there's no purpose in arguing because it is a matter of opinion, as mentioned

warm mason
wary edge
#

My two cents on AI generated code is, don't go posting on online forums why your AI hallucinations don't work.

remote oyster
wary edge
remote oyster
warm mason
noble bolt
remote oyster
wheat condor
distant tulip
# remote oyster I'm sharing my thoughts here because I'm open to defending them. Whether you lik...

can agree with most of what you said, the only thing is you can't compare AI generated code to a code that you got from somewhere else, the AI one don't work most of the time. AI do help a lot but as smokey said, as soon as you drop a AI generated code in chat, most of us will not offer any help (if the code was really bad at least)
for the record i wasn't arguing, i personally use it, i was just suggesting for hem to learn. it is better and way more efficient to use AI as a helping tools in things that you already know

remote oyster
# distant tulip can agree with most of what you said, the only thing is you can't compare AI gen...

Doesn't matter if the code doesn't work. I was learning to code years before AI was even a thing. Couldn't tell you how many times I found examples of code online that appeared to suit my needs but ultimately failed and didn't work. That is why I said the following, and I still stand by it:

It is still code provided by an entity that nobody knows. Regardless of whether that entity is AI or a random stranger on the internet, the individual receiving the code must still take the time to understand it, learn how it works, and decide where to go from there if they want to grow. The logic of learning does not change based on how the information is received. What truly matters is what they do with that informationβ€”it determines whether they grow or remain stagnant.

fickle dagger
#

^ I agree with this statement above

dim tusk
#

Wadahell happened here.

wheat condor
warm mason
#

Today is the day to talk about AI, lol

dim tusk
#

this is kinda like blending things, when I use a blender does it mean I cheated because I used a tool?

#

-# what I said is very far from the topic sorry

remote oyster
warm mason
wheat condor
remote oyster
#

I got to go but I feel this was a very productive discussion in the end.

warm mason
distant tulip
wheat condor
dim tusk
wheat condor
dim tusk
dim tusk
distant tulip
wheat condor
#

World.ApplyWeaknessEffectToAllPlayers(1000) // 1000ms

jolly veldt
#

Real

#

So from what i learned, ai is like a calculator: it improves the workflow but is redundant if you do not know what it does

warm mason
#

Well, that's it, the marathon of inventing new methods has begun.

jolly veldt
#

I also see coding as a form of art but that isn't very pertinent to this discussion

wheat condor
#

When I create mess with objects

distant tulip
#

it is good enough in general js

dim tusk
jolly veldt
#

Correct me if I'm wrong, please

dim tusk
#

Damn. I lost all my files (most of them aren't saved yet)

wheat condor
dim tusk
dim tusk
#

But I hate your format

warm mason
wheat condor
wheat condor
#

The actual code is different

dim tusk
#

maybe because I've been handling json since I started this and I'm kinda pro identifying or understanding json and it's format

remote oyster
jolly veldt
#

Usually i see people coding from necessity or skill, i just do it for fun

remote oyster
#

Same πŸ˜…

dim tusk
jolly veldt
#

Being a programmer but not being passionate about it, if I explained that correctly

dim tusk
jolly veldt
#

Ok guys i gtg

#

See ya

remote oyster
jolly veldt
#

Ok I'm back

devout hazel
#

hey, trying to add a variable into a command, its done like this right?

#

event.block.runCommandAsync('function raycast/setblock${randomNumber}');

#

but in the examples i saw the variable part was a different colour, i think mine is still just part of the string

dim tusk
#
event.block.dimension.runCommandAsync(`function raycast/setblock${randomNumber}`);```
devout hazel
#

ahhh

#

little things

dim tusk
#

Also put dimension since blocks can't run command only entities

devout hazel
#

damn, maybe i wont bother with a command then

#

as the function basically just structure loads on the blocks location

#

is there some structure functionality in scripting

dim tusk
devout hazel
#

great, thanks so much

#

wait can you send the doc again

devout hazel
#

thanks

distant tulip
#

@devout hazel what dose the raycast function do

hushed ravine
#

I tried it with a small range, but it doesn't really work (it should be a square, right?)

hot gust
jolly veldt
#

Not that i would ever use it but how do people load world map onto like ui or something

#

Like genuinely, it looks like witchcraft to me

latent wing
#

I need urgent help ;-;
Does anyone know of any code that detects when a player types certain text and executes the script? I'm trying but I always get an error in the console...

jolly veldt
#

In the chat?

#

If so, you must enable experiments i believe

#

Since chat events are in a beta release always for some reason

latent wing
#

Thank you

hot gust
# hushed ravine Why is that?

my use case was i needed the border to be present per player as they world border was set dynamiclly it could be 1k or 100k and thats from 0,0,0 on all axis so it made sense that if the player was within range on the border to show then that area ( they may have been under ground) this was as a line where you need it as a square

#

if these locations are set zones use 4 points to spawn the particles within that area

hushed ravine
#

My use case is to simply have a world border that everyone can see

hot gust
wheat condor
#

how do i download chestFormData? do i have to copy paste all the files from github?

wheat condor
wheat condor
#

couse copy paste code is so much inefficient

wheat condor
wheat condor
#

Do chest form data work with custom items?

distant tulip
# wheat condor Do chest form data work with custom items?

Want to add custom items / blocks to the form?

Download this_pack to see all item IDs and their icons, including custom ones.
Add the item typeId & ID to the typeIds.js file. Note that experimental items shift the vanilla IDs at 256- make sure to manually shift the IDs up, and remember the full typeId for your custom items!
You cannot use the constant number_of_1_16_100_items if you chose to add your custom items. Set it to zero!
#

check the README

misty dagger
#

I'm in a bit of a pickle. I am attempting to detect WASD.
My use case has the following restrictions:

  • Stable only (RIP InputInfo).
  • The player is riding a mount, but the mount has a mathematically-controlled location via teleports.