#Script API General

1 messages · Page 73 of 1

fathom hemlock
#
    const def = ev.propertyRegistry;
    def.registerEntityTypeDynamicProperties({
        command: "string"
    }, "minecraft:entity"); // für alle Entity-Typen
});

// Entity Editor öffnen
function openEntityEditor(player) {
    const form = new ModalFormData()
        .title("§lEntity Editor")
        .textField("§eEntity Type", "z. B. minecraft:villager", "minecraft:villager")
        .textField("§bDisplay Name", "z. B. §r§aShopkeeper", "§aShopkeeper")
        .textField("§dCommand", "z. B. give @s diamond 1", "say Hello @s!")
        .toggle("§6Spawn now?", true);

    form.show(player).then(res => {
        if (res.canceled) return;

        const [type, nameTag, command, spawnNow] = res.formValues;

        const data = {
            type,
            nameTag,
            command,
            spawnNow
        };

        if (spawnNow) {
            const entity = player.dimension.spawnEntity(type, player.location);
            entity.nameTag = nameTag;
            entity.setDynamicProperty("command", command);
            player.sendMessage(`§a✔ Spawned ${type} with command: §r${command}`);
        } else {
            player.sendMessage(`§ePreview only. No entity spawned.`);
        }
    });
}```
random flint
#

Maybe check on that code if command holds a value

fathom hemlock
#

wait wait

#

thats the command its a string

random flint
#

What the, you don't need to register dynamicProperty like that to use them anymore. That's not even the correct event for it.

fathom hemlock
#

but worldInitialize is not working

random flint
#

worldInitialize is called worldLoad now

past coyote
#
import { world, system, Player } from "@minecraft/server";


function disableSprinting() {
    const players = world.getAllPlayers();


    for (const player of players) {
        if (player.isSprinting) {
            player.isSprinting = false;
        }
    }
}

system.runInterval(() => {
    disableSprinting();
}, 1);```
#

So isSprinting is readOnly?

shy leaf
#

sprinting is read only

past coyote
#

sigh

shy leaf
#

i actually tried to make force stop sprints but

#

nothing was good

past coyote
#

Blindness works, but it creates a distant fog (even when set to infinite)

shy leaf
#

and it doesnt stop already ongoing sprints either

past coyote
#

yeah

#

I can set the players hunger with effects, but I would need to do some math and such to keep them under 6 hunger

#

or can you manually set hunger with minecraft:hunger

#

in scripting

shy leaf
#

no

random flint
#

yes

shy leaf
#

we lack a lot of stuff for attributes

random flint
#

edit the player.json

past coyote
#

Yes or no 😭

#

ahhh

shy leaf
past coyote
#

I could do that in my environment

#

What would I edit to make it so the player is always at hunger 6 or less, or set their max hunger to that

#

in order to disable sprinting

shy leaf
#

you could remove the entirety of exhaustion too

past coyote
#

its not hard to see what im trying to make haha

shy leaf
#

i noticed it

#

lol

past coyote
#

Can we directly set health btw?

shy leaf
#

yeag

#

theres health component for scripting

past coyote
#

thats great, that means I can make the food system accurately

past coyote
#

or wait only natural regen

shy leaf
#

only natural regen

cinder shadow
past coyote
#

Would that make them not sprint too?

cinder shadow
#

nope. I do this for my add-on since I removed saturation

#

"minecraft:exhaustion_values": {
"heal": 0,
"jump": 0,
"sprint_jump": 0,
"mine": 0,
"attack": 0,
"damage": 0,
"walk": 0,
"sprint": 0,
"swim": 0
},

#

well technically it's still there, but the player is always at max saturation since there is nothing that can reduce it

shy leaf
#

wait

#

if healing doesnt reduce saturation

#

would it just

#

keep healing

cinder shadow
#

you turn natural regeneration off

#

but yes

past coyote
#

If I add this, I wont have a "reliable" system for removing sprint by abusing the exhaustion system though

#

I was going to just spam effects on a player to lock them at a hunger level below that of which allows sprinting

#

because there is no other way 😭

#

Can we set player speed? I could do that I guess, but I cant remove the sprint FOV thing

#
import { world, system } from "@minecraft/server";
await null;

const WALKING_SPEED = 0.1;

function capMovementSpeed() {
    const players = world.getAllPlayers();

    for (const player of players) {

        const movement = player.getComponent("minecraft:movement");

        if (movement) {

            if (player.isSprinting) {
                movement.setCurrentValue(WALKING_SPEED);
            } else {
                movement.setCurrentValue(WALKING_SPEED);
            }
        }
    }
}


system.runInterval(() => {
    capMovementSpeed();
}, 5);```
random flint
past coyote
#

DUH!

#

Pffft thats so obvious why didn't I think of that

random flint
#

Cancel consumable item in beforeEvent itemUse or smt so they have 0 chance to increase their hunger

past coyote
#

Thats what i'll do, then i'll query the health, and do the math for the end result (with a clamp for max health) and set the player health

#

unless we can just add health, idk. I have to check the method

#
      "minecraft:damage_sensor": {
        "triggers": {
          "on_damage": {
            "filters": {
              "any_of": [
                {
                  "test": "has_tag",
                  "subject": "self",
                  "value": "protect"
                },
                {
                  "test": "damage_type",
                  "operator": "==",
                  "value": "starvation"
                }
              ]
            },
            "deals_damage": false
          }
        }
      },```

Am I doing something wrong 😭
random flint
#

"test":"damage_type" to "test":"has_damage"

past coyote
#

oh

random flint
#

"value" to starve

past coyote
#

This works great! However when a player first joins, they can sprint for a moment until their hunger drains.

when using this:
/effect @s hunger infinite 255 true

random flint
#

Disable their input permission for a few seconds

past coyote
#

Lmao, I guess so

#
      "minecraft:damage_sensor": {
        "triggers": {
          "on_damage": {
            "filters": {
              "any_of": [
                {
                  "test": "has_tag",
                  "subject": "self",
                  "value": "protect"
                },
                {
                  "test": "has_damage",
                  "operator": "==",
                  "value": "starve"
                }
              ]
            },
            "deals_damage": false
          }
        }
      },```
Still results in damage :\
random flint
#

well, there's one like this:

"minecraft:damage_sensor": {
  "triggers": {
    "cause": "fall",
    "deals_damage": false
  }
}
past coyote
#
"minecraft:damage_sensor": {
    "triggers": [
        {
            "on_damage": {
                "filters": {
                    "test": "has_tag",
                    "subject": "self",
                    "value": "protect"
                }
            },
            "deals_damage": false
        },
        {
            "cause": "starve",
            "deals_damage": false
        }
    ]
},```

Nope :\
wary edge
past coyote
#

yeah thats a really great decision

fathom hemlock
#

why is this not working: const distance = player.location.distanceTo(entity.location);

#

Error: typeerror not a function

random flint
#

.distanceTo() isn't a thing

#

You need to make it yourself

fathom hemlock
#

okay

random flint
#

player.location might be Vector3, but it's just an x y z interface

#

No unique method you could do there

fathom hemlock
#

should work

#
const dy = player.location.y - entity.location.y;
const dz = player.location.z - entity.location.z;
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);

nova flame
#

anyone wanna help me out in vc with actionformdata

#

im new to js

thorn flicker
#

@wanton cedar
https://wiki.bedrock.dev/scripting/scripting-intro

world.afterEvents.dataDrivenEntityTrigger.subscribe(data => {
    const entity = data.entity;
    const id = data.eventId;
    const mods = data.getModifiers();

    if (id === 'example:event') {
    // code
    }
})
fathom hemlock
#

umm I need hekp

#

why is this just working for me not for other player (or mobile players idk)

    const player = event.player;
    const entity = event.target;
  
    if (!(player instanceof Player)) return;
    if (!entity || !entity.id) return;
  
    const tagMap = getTagMap(player);
    const entry = tagMap[entity.id];
    if (!entry) return;
  
    const finalTag = `${entry.tag}`;
  
    system.run(() => {
      if (player.hasTag(finalTag)) player.removeTag(finalTag);
      player.addTag(finalTag);
      player.sendMessage(`§aYou got tag: §e${finalTag}`);
    });
  
    event.cancel = true;
  });
thorn flicker
#

not about the problem you are having, but you dont need if (!(player instanceof Player)) return; because it'll always be a player.

fathom hemlock
nova flame
#

anyone wanna help me out in vc 😉

humble lintel
#

what is it about

valid ice
#

Why not just send your problem here

fathom hemlock
#

I don't get any errors in the logs

nova flame
#

ui is done but making the buttons work is the part im stuck on

fathom hemlock
# nova flame im very new to js and im tryna make a ui
    new ActionFormData()
    .title("§l§aTest")
    .body("§7This is a test.")
    .button("§aTest Button 1")
    .button("§cTest Button 2")
    .show(player)
    .then(res => {
        if (res.canceled) return;
        if (res.selection === 0) player.sendMessage("§aYou clicked Test Button 1!");
        if (res.selection === 1) player.sendMessage("§cYou clicked Test Button 2!");
    });
}```
#

or

thorn flicker
# nova flame .

yeah, and hes showing you how to make the buttons do things

fathom hemlock
nova flame
#

ik how to make them do things but like im stuck on the thing i need it to do

thorn flicker
#

"buttons work"

fathom hemlock
#

.button("name", "texture")

nova flame
valid ice
#

loop through inventory -> get item -> check against map -> if item exists, clear slot and total = total + item amount * sell price

fathom hemlock
#

just looks good

nova flame
#

okay

fathom hemlock
gilded shadow
humble lintel
#

Does anyone know why my interact event activates multiple times?

#

nothing's wrong with my script it just activates multiple times

distant tulip
humble lintel
#

ohh okay than k you

#

i added a debounce lol

#

that's def a better solution

thorn ocean
#

Has anyone used the place feature command in scripts?

wary edge
#

Use the native method instead.

thorn ocean
#

Are there any docs on this?

dim tusk
dim tusk
thorn ocean
echo tinsel
#

Still looking for setting up realtime seasonal loot drop if anyone has any experience in setting up real time events

dim tusk
#

use new Date()

#

if you meant like rea-life time.

echo tinsel
#

I had tried that. I'm not on PC right now to grab my code.
I do mean real time yes.

I had got it where console log was detecting whether it was the actual date. And had the seasons set up, but the drops weren't doing anything and I wasn't getting errors.

#

It's the event part I'm struggling with

dim tusk
#

Or your own made season?

echo tinsel
#

Yeah 4 holidays 2 weeks(1 before one after)of mobs having a low chance of dropping loot for that specific holiday

#

Eventually more but just 4 for now

#

Easter, 4th of July, Halloween and christmas

#

So technically each season

dim tusk
#

Ahh, we need to check if the current time of player is a real time holiday? Just confirmation

echo tinsel
#

Yes

#

Well 1 week before, holiday and 1 after. Not the exact date

dim tusk
# echo tinsel Yes
function getDateRangeInfo(currentDate, targetDate, range) {
  const current = new Date(currentDate);
  const target = new Date(targetDate);
  
  current.setFullYear(2000);
  target.setFullYear(2000);
  
  const timeDiff = current.getTime() - target.getTime();
  const absTimeDiff = Math.abs(timeDiff);
  
  const rangesInMs = {
    milliseconds: range.milliseconds || 0,
    seconds: (range.seconds || 0) * 1000,
    minutes: (range.minutes || 0) * 1000 * 60,
    hours: (range.hours || 0) * 1000 * 60 * 60,
    days: (range.days || 0) * 1000 * 60 * 60 * 24,
    weeks: (range.weeks || 0) * 1000 * 60 * 60 * 24 * 7,
    months: (range.months || 0) * 1000 * 60 * 60 * 24 * 30
  };
  
  const totalRangeMs = Object.values(rangesInMs).reduce((sum, val) => sum + val, 0);
  
  const timeUnits = {
    days: Math.floor(absTimeDiff / (1000 * 60 * 60 * 24)),
    hours: Math.floor((absTimeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
    minutes: Math.floor((absTimeDiff % (1000 * 60 * 60)) / (1000 * 60)),
    seconds: Math.floor((absTimeDiff % (1000 * 60)) / 1000)
  };
  
  return {
    isInRange: absTimeDiff <= totalRangeMs,
    timeDifference: {
      milliseconds: absTimeDiff,
      ...timeUnits
    },
    direction: timeDiff < 0 ? 'before' : timeDiff > 0 ? 'after' : 'same',
    isPast: timeDiff > 0,
    isFuture: timeDiff < 0,
    isSame: timeDiff === 0
  };
}

const testDates = {
  christmas: new Date(2000, 11, 25),
  halloween: new Date(2000, 9, 31),
  newYears: new Date(2000, 0, 1),
};

const now = new Date();

console.error('Christmas info:', JSON.stringify(getDateRangeInfo(now, testDates.christmas, {days: 1})));
console.error('Halloween info:', JSON.stringify(getDateRangeInfo(now, testDates.halloween, {weeks: 2})));
console.error('Today info:', JSON.stringify(getDateRangeInfo(now, now, {days: 3})));```
#

I didn't include years since who would wait a whole year in Minecraft for this if in the end they can just delete the addon and wait for it to be 1 week of that time.

#

best thing I made so far...

lyric kestrel
#

WOOOOOO

#

It's mostly powered by JS, with permutations ofc needed to change the textures of the block itself

#

ah, don't mind the audio

#

Was listening to an NBC clip

lyric kestrel
#

That took a lot of work to just figure out

echo tinsel
untold magnet
#

uh, probably a stupid question but, is it possible to detect the player saturation?

echo tinsel
#

Thank you. I'll also share my code, I think I have the date stuff figured out. It's the rest of it I'm struggling with.

echo tinsel
lyric kestrel
echo tinsel
#

Whatttt

#

They seem happy lmao

#

Fitting your pfp is a dog 😂

lyric kestrel
#

Since everytime you clicked it with the same block, it gives you another on the same block, which isn't supposed to happen

lyric kestrel
lyric kestrel
#

And I got a texture name wrong too xD

echo tinsel
#

I honestly did not see the number and thought you were in creative and happy it didn't take the block since it already was copper

lyric kestrel
#

For the waxed copper variant

dim tusk
echo tinsel
#

No worries I just got home and had only just responded.

I have this set up in a case situation

#

So I'll give this a shot

untold magnet
# dim tusk No...

damn, with that being said, i will have to detect it all by myself, like detecting everything that could make the player saturation goes down faster and detect the vanilla food saturation values

#

in general, so much work

dim tusk
#

It's better than checking everything...

untold magnet
echo tinsel
untold magnet
dim tusk
#

Sorry what I meant I didn't include the year since every holiday happens every year so I don't think I need to put years

#

Unless you needed it, I can just do it...

echo tinsel
#

I'll just check it first. As I said I do have a date system that was detecting that date. But I didn't know how to set up the event after to get the entities to drop the items during that time.

untold magnet
dim tusk
echo tinsel
#

did you remove the time you had there lol

echo tinsel
# dim tusk Expected output... Obviously the time would vary... ```js {"isInRange":false,"t...

[Scripting][error]-Christmas info: {"isInRange":false,"timeDifference":{"milliseconds":22295412178,"days":258,"hours":1,"minutes":10,"seconds":12},"direction":"before","isPast":false,"isFuture":true,"isSame":false}

[Scripting][error]-Halloween info: {"isInRange":false,"timeDifference":{"milliseconds":17543412178,"days":203,"hours":1,"minutes":10,"seconds":12},"direction":"before","isPast":false,"isFuture":true,"isSame":false}

[Scripting][error]-Today info: {"isInRange":true,"timeDifference":{"milliseconds":0,"days":0,"hours":0,"minutes":0,"seconds":0},"direction":"same","isPast":false,"isFuture":false,"isSame":true}

#

ye

#

awesome!

#

christmas is so close, im disgusted lol

#

Thank you! could you perhaps help me set up the entities having a 1 percent chance of dropping the loot(each season has its own) on death? With 4 entities being able to drop it

dim tusk
#

I added, as many as possible datas so it's not useless on just Boolean.

echo tinsel
#

thank you!!

dim tusk
# echo tinsel thank you!!

you know how to grab those datas right?```js
function getDateRangeInfo() { ... }

const { isInRange, direction } = getDateRangeInfo(date, date, { days: 3 });

if (isInRange) { ... } else { ... }```

fallen hearth
#

Is it possible to launch a projectile with some event?

dim tusk
echo tinsel
#

Thank you!

fallen hearth
#

minecraft:spawn_entity is very boring

dim tusk
#

it's still the same.

echo tinsel
#

I don't know how to use the fact that it confirms the date as true to then make the mobs drop

dim tusk
echo tinsel
dim tusk
echo tinsel
#

so yes lol thank you

#

wait, why was it before in the last one?

#

sorry im trying to understand howto read it as well

#

or understand why

dim tusk
echo tinsel
#

i think i see, it would check if 3 days before?
i get it was a sample i was asking what that meant.

dim tusk
#

don't worry you don't really need to understand anything except for what it return...

dim tusk
# echo tinsel i think i see, it would check if 3 days before? i get it was a sample i was ask...
  • isInRange: A boolean that is true if the two dates are within the specified time range (e.g., within 2 weeks). It checks both before and after the target date by default.
  • direction: A string indicating whether currentDate is 'before', 'after', or 'same' as targetDate.
  • isPast: true if currentDate is after targetDate.
  • isFuture: true if currentDate is before targetDate.
  • isSame: true if both dates are identical.
  • timeDifference: An object showing the difference in days, hours, minutes, seconds, and milliseconds.
echo tinsel
#

thank you

#

i kind of did need to understand since this whole time i was asking about setting up the return because i had the dates already returning as true but didnt know how to grab them and then turn that into my event. but you just rewrote dates and i didnt understand the set up. And if i ever wanted to add to it, i have to understand why/ and what

dim tusk
#

ohh lol yeah, these are the description, just read them... For grabbing just do the sample I gave ```js
const { isInRange, direction, isPast, isFuture, isSame, timeDifference } = getDateRangeInfo();

const { milliseconds, days, hours, minutes, seconds } = timeDifference;```

woven loom
#

can someone send me ts pack setup

tropic geyser
#

why is player join deprecated??

wary edge
tropic geyser
tropic geyser
# wary edge It isn't.

is it possible to remove the players hud in scripting like they cant see it like the equivalent to f1

wary edge
#

HudVisibility

tropic geyser
#

is it a component?

wary edge
#

No scripting.

tropic geyser
#

nvm i found it ty

toxic ore
#

Is there a way to use scripts to diversify generating structures? As in check for more things

toxic ore
# wary edge Such as?

Just any way to incorperate scripts into structure generation so I can make more stuff possible (I am new to this and come from java)

wary edge
#

What functionality is missing?

toxic ore
#

Well I'd like to check "conditions" on more than a single block where the structure will be spawned at, currently I use "grounded" and that works fine but I also don't know how to incorperate supported feature rules from the bedrock dev wiki into my feature rules for the structure I spawn so I am also looking for the limitations in general to world generation of structures

dusky flicker
#

how could i implement cables? just a line which lists blocks of the same id next to each others, and when i place / break a block it modificates the line.
I thought in well, recursion, but its O(M^N) M is the sides of the block, my idea is only xz axis so its O(4^N) thats heavy as hell. Do anybody know some way better? space does not matter by now later i can improve it

#

Searching on web i ended with union find, must implement it tomorrow, but if anyone has some idea, ill appreciate

random flint
#

That sounds complicated.

What is 'line'? Is it equal to a network?

dusky flicker
#

something like minecraft redstone, nothing different from that

#

except the fact i dont pretend making it go up or down

random flint
#

So nothing large? Just two blocks that need visual change for showing connection?

dusky flicker
#

in case the state is simply a number from 0 to 16, 0 as a C boolean is false, so its got no energy, any other just mean the energy intensity from the source

#

but then if i break some and the new "line" is not connected to any source, i must set the energy to 0

#

to implement the source to energize everything was actually simple, just used recursion and runJob with the O(4^N) implementation i told before, the problem is to de-energize(sorry for bad english, its been a while since i talk in english)

random flint
#

It's fine. Since there's energy intensity, you could use the broken cable's energy intensity to guess which adjacent cable needs to be checked.

Well, technically you can skip the check, and immediately set all those cables with lower energy intensity to 0.

dusky flicker
#

if its too complicated to implement what im trying to, imma implement it this way

random flint
#

I see, then you could make a new one solely to track its distance from a nearby source.

brittle marten
#

hey sorry to jump in the conversation, is it possible to get the attack value specified in a entities .json file similar to the getComponent('health').currentValue

dusky flicker
#

i've faced worse stuff before, imma try to implement something later and anything i come here to show. I hope that the Union Find data structure work, if not imma try to find another one

random flint
brittle marten
#

i also dont want to use some basic health boost effect thats why lol

random flint
#

Understandable, the vanilla health limit has a cap anyway. A custom one would be fancy, but won't guarantee compatibility with a third-party addon

brittle marten
#

yeahhhhh

#

its also mostly for smaller value like 1 percent lol

#

the only other way i can do something like that from what im thinking is to make a default repository of entities that can be updated via in game but i would like to not do that because of issues like having to define each single one lol

round bone
#

#1067869232395735130

#

also, you can't test it?

marsh pebble
prisma shard
#

@humble lintel can you send your VSCode extensions you have, please

shy leaf
#

waiting for an option to keep velocity on applyKnockback...

shy leaf
#

i wonder if giving entity velocity to applyKnockback method is good enough for "keeping velocity"

distant tulip
#

applyKnockback don't effect velocity afaik

shy leaf
#

try applyKnockback with all zero on entityHurt event

shy leaf
#

for vertical strength, at least

fathom hemlock
distant tulip
#

onPlace don't have a player reference?
nvm, there is beforeOnPlayerPlace

dusky flicker
# prisma shard <@335307151881011202> can you send your VSCode extensions you have, please
prisma shard
#

and i liked it

#

and asked which theme he uses

shy leaf
#

does DataDrivenEntityTriggerAfterEvent fire when the event is applied or triggerEvent() is fired?

shy leaf
fathom hemlock
#

yoo how do I do a libary?

#

I think with typescript and javascript(js ofc)

#

like waterdb,prismarinedb or herobrinws chestui

fathom hemlock
#

how do I make custom dash commands

wary edge
#

You mean like, -home

distant tulip
prisma shard
#

and for making custom commands you use chatSend event

wary edge
#

The presence of custom indicates there is a vanilla dash command.

#

Hence why I asked OP to clarify.

distant tulip
#

wait, nvm

prisma shard
#

what Minato you were right, why delete your messege

distant tulip
#

nope, i was wrong, lol

#

idk

prisma shard
#

Triggering a dash with commands? just weird
Why not a custom item

distant tulip
#

i just assumed he meant dash move
hence why my brain ignored the command bit

prisma shard
#

OH WAIT

#

his way of asking the question sounds weird to my mind 😭

#

I also realize

#

Dash means '/'

wary edge
#

joe_shrug That's why I asked OP to clarify.

prisma shard
#

custom dash ( / ) commands

random flint
#

that's slash

prisma shard
#

hmm some ppl say dash idk

random flint
#

According to google, this is dash: (—)

prisma shard
#

that's the horizontal line symbol

#

😭 he made us confuse

#

okay he just meant
-command

wary edge
#

Let's not assume anymore and just wait for OP to clarify please.

dusky flicker
#

is it possible to execute something right after runJob execution?

#

it seems to run on another thread or in parallel idk

dusky flicker
#

because it seems to be async

#

and i dont know how to make the code block until it finishes

prisma shard
#

not while something is happening ig?

#

okay i just dont know

dusky flicker
#
export function* set_energized(block: Block, level: number): Generator<void, void, any> {
  console.warn(OtsukiTrail.network.is_vec3_cable(block.location));
  ...
}``` 
```ts
...
onPlayerDestroy(arg0: BlockComponentPlayerDestroyEvent): void {
    system.runJob(set_energized(arg0.block, 0));
    console.warn("eita");
  }
...
#

im sure it's not sync

prisma shard
#

like your country

fallow minnow
#

kind of odd to ask

dusky flicker
valid ice
prisma shard
prisma shard
#

If that returns a promise, you can do
.then(() => {})
annd that can fix the thing

fallow minnow
#

i think it returns a pinky promise

dusky flicker
fallow minnow
dusky flicker
#

just a number which is the id of the running job

dusky flicker
fallow minnow
#

oh

#

have u ever used vs code

dusky flicker
#

yeah, i used to, but i switched and actually prefer it now

fallow minnow
#

im havving issues with typescript code intellisense being super slow

valid ice
fallow minnow
#

vs code lowkey buns

#

its literally only typescript

#

like NOTHING else

#

im gnna check javascript

#

yep only typescript

#

what the freak

dusky flicker
#

try downloading minimal lsp for it

#

i only have 3 stuff for ts on my configs

fallow minnow
#

i restarted my pc like a month ago so i barely have anything on vs code

#

uuid generator, live server, blockception, git and snowstorm

#

wherer do i get minimal lsp from

dusky flicker
#

as you use vscode it probably have installed ts or js by default

honest spear
#

language server is build in

#

but nodeJS is not installed or any other runtimes

#

there is node maybe running under the vscode but not usable

fallow minnow
#

its just so weird

#

i disabled git temporarily and its not that

#

all extensions as well

dusky flicker
#

bros gonna start using grep only

fallow minnow
#

and like my pc is newwwww

#

its new to thiss

#

3 months old

honest spear
#

does mattern how new the PC is

fallow minnow
#

true

#

but this never happened on my poopy laptop

honest spear
#

i might be out of context what exactly?

dusky flicker
fallow minnow
#

my code intellisense is super slow on typescript

fallow minnow
#

but it just started happening 2 days ago

honest spear
fallow minnow
honest spear
#

of not then you better reinstall VSCode or something

fallow minnow
#

tried that too 😭

honest spear
#

hmmmm

gilded shadow
#

is there a way to force close chat, for like sending form menu to player

honest spear
#

Send me a screen shot in general and let me check if there is something sus or not

fallow minnow
#

wait im dumb

#

so the typings are sometimes fast

#

most of the time slow

#

and then u see the error pop up like 5 whole seconds after

honest spear
#

How big is your workspace?

fallow minnow
#

not big at all

honest spear
#

Do you have any other projects related to nodeJS?

#

nodeJS packages are heavy asf

fallow minnow
#

nope

honest spear
#

try loading only that folder with single proejct so we are sure its not related to it

dusky flicker
# fallow minnow nope

what packages did you install? when i work with rust it starts slowing down when i have 100+ dependencies

fallow minnow
dusky flicker
#

and as we are talking about the node modules rabbit hole, its not unusual to js require 300+ dependencies only for ts

fallow minnow
#

minecraft ui and whatever the other one is

#

and when i remove that line thats error'd the error stays there for like 5 more seconds 😭

honest spear
#

create folder on desktop and add TS file there and thry how fast it would be

fallow minnow
#

oh my okay

#

its the project thats slowing it down @valid ice

#

grr

#

doesn't make sense though

dusky flicker
#

what do you have to slow it down that much

honest spear
#

there could be option to disable some kind of this stuff

fallow minnow
#

actually we do have some constant files that have like 8k lines in them just for item data

honest spear
#

bruh

#

i thought so

fallow minnow
honest spear
fallow minnow
honest spear
#

it would prevent loading this file

fallow minnow
#

but wym convert to js then turn into d.ts

#

it just breaks it

honest spear
#

I don't know how the data looks like so i can't really help you more

fallow minnow
slow walrus
#

not how it works anyway

fallow minnow
#

i just need something that works 😭

slow walrus
#

have you tried opening the folder that the project is in instead of a single file?

fallow minnow
#

yes

#

actually its not even that file

#

i deleted it and the issue still occurs

slow walrus
#

are you using global typings?

fallow minnow
#

no

slow walrus
#

and your task manager performance is fine?

fallow minnow
#

yes

dusky flicker
#

do you guys know how to implement hashmap? i need to map an object to another but from js maps based on the pointers

fallow minnow
slow walrus
fallow minnow
#

16gb

slow walrus
#

hmm

#

that's pretty weird

fallow minnow
#

yeah its very weird

#

its only that project too

#

like i did what con master said and created a ts file in a folder on my desktop and its fine

#

code intellisense is fine

slow walrus
#

is it on a different drive?

fallow minnow
#

nope

#

only have 1 ssd

#

gen 4 1tb

valid ice
#

Maybe try deleting the project and redownloading it from GitHub?

fallow minnow
#

could yeah

slow walrus
#

yeah dont think itd make any difference anyway

fallow minnow
#

re clone

slow walrus
#

eh that's pointless

valid ice
#

Just to see shrug

slow walrus
#

when did you open the project for the first time?

fallow minnow
#

uhh like a few months ago

#

i guess

#

actually basically a month ago since i restarted my pc

slow walrus
#

on this pc?

fallow minnow
#

yes

prisma shard
#

the conversation is going cool watcthing

#

lol

slow walrus
#

and it's only suddenly doing this?

fallow minnow
#

yes it started happening 2 days ago

slow walrus
#

you tried just like restarting ur pc?

fallow minnow
#

yes

#

re downloading vs code

#

its also none of my extensions i tested

prisma shard
#

at this point just reinstall windows

#

lol jk

fallow minnow
#

i am using ES2020 could that be a reason?

prisma shard
#

what is a ES

fallow minnow
#

actually i dont think it would matter

#

its the compiler module

honest spear
#

it does works like that TSS loads only declaration file if its available

thorn flicker
#

versioned by year

gilded shadow
#

how does @gaunt salmon works?

unique acorn
# gilded shadow how does <@948686094986264716> works?
  1. send a javascript or typescript file OR send code wrapped in three backquotes with js/ts in them (like in the image show)
  2. right click on your message or long hold on it.
  3. click apps then choose Debug script
  4. choose version of api
  5. wait
gilded shadow
#

thanks

fathom hemlock
#

how?!

#

how do I make / commands (I found a way to make dash commands)

thorn flicker
#

in preview, you can register custom commands

#

no need for chatsend

fathom hemlock
#

how

thorn flicker
#

was trying to find the video

fathom hemlock
#

thx

humble lintel
#

then npm intellisense

fathom hemlock
#

can someone install mc preview cuz I get 1000 Erros

#

*Errors

#

idk If I just get thatr

humble lintel
#

can I get feedback from anyone

#

I was just wondering if I should make right click to harvest similar to vein mine or just harvest one by one

random flint
#

right click what

humble lintel
#

right click to harvest

random flint
#

vein mine should be optional ig. Maybe button combination like crouch + right click

humble lintel
#

okay done

#

maybe ill post in mcpedl

random flint
#

custom crops compatibility?

humble lintel
#

if they have growth state

nova flame
#

anyone wanna help me out in vc 😇

humble lintel
#

@gega do u think i should insert the item directly into the player's inventory or no

humble lintel
#

yes

thorn flicker
#

maybe make that optional as well.

humble lintel
#

okay

thorn flicker
#

more optional stuff the better honestly, player's opinions may differ ofc

humble lintel
#

that's true

humble lintel
#

I made it so that when you right click the air it while crouching, it will switch them odes

tidal wasp
#

e.permutationToPlace = permutationToPlace.withState(BlockPermutation.resolve(playerEquipment.typeId,
{
[horzhalf]: horzState,
[blockStateHalf]: state
}));
return;

#

so this is giving me the error of expect 2 arguments but only recieving one

#

and the line that it says the error is at is the }));

#

which is weird

#

also here are what the variables are

#

const blockStateHalf = 'minecraft:cardinal_direction';
const horzhalf = 'cmd:horizontal_half'
const state = blockToCheck.permutation.getState(blockStateHalf);
const horzState = blockToCheck.permutation.getState(horzhalf)

full idol
#

If world.beforeEvents.playerPlaceBlock.subscribe((event) => { is still in the beta APIs what's the correct way currently?

wary edge
full idol
#

Sorry! So many things I'm not accounting for... Just general players placing vanilla blocks. I'm working on a basic claims plugin

wary edge
unique acorn
full idol
full idol
unique acorn
fast lark
#

[index.js] ran with error: [TypeError: cannot read property 'subscribe' of undefined at <anonymous> (chat.js:13)

#

there are some problem with chat send in 1.18.0?

unique acorn
fast lark
#

so 2.0.0-beta?

unique acorn
#

yep

fast lark
#

k

distant tulip
#

block placer component don't trigger custom component?

wary edge
#

Known issue.

distant tulip
#

yikes

#

hmm

full idol
#

Does 2.0.0-beta mean it needs the experiment "beta APIs" enabled in the world?

full idol
#

Alr ty

cyan basin
midnight ridge
#

i have a qus now if the player died but he have a keepOnDeath item do i can get this item using script or the system will rejecte because the player is died and there is not inventory to get?

fallow minnow
#

does anyone know the max length a player/entity id can be?

fallow minnow
#

for SOME reason there was like duplicated node modules in 3 or 4 folders

#

so i had like double the node modules in random folders and it was looping a whole bunch

valid ice
dim tusk
fallow minnow
#

is there any way i can edit padEnd to notice that unicode like this "\uE121" is 3 characters instead of 1?

dim tusk
#

padEnd() will take account the length even if its a whole Unicode.

fallow minnow
#

but it takes account the length of § which is 2 instead of 1

dim tusk
dim tusk
fallow minnow
#

so weird

#

both have a length of 1

#

but neither are truly 1

echo tinsel
#

is there anyway for me to exclude those in the inanimate family in this?
'''js
world.afterEvents.entityDie.subscribe((eventData) => {

try {
    const deadEntity = eventData.deadEntity;
    const damagingEntity = eventData.damageSource.damagingEntity;
    const deadEntityId = deadEntity.typeId;
    const deadEntityLocation = deadEntity.location;
    const deadEntityDimension = deadEntity.dimension;
    if (deadEntityId == 'minecraft:item') return;
    if (Math.random() <= 0.01) switch (true) {
        case (getDateRangeInfo(Date.now(), holiDates.christmas, { weeks: 2 }).isInRange): {
            eventData.deadEntity.dimension.spawnItem(new ItemStack(`minecraft:apple`, 1), eventData.deadEntity.location)

'''

dim tusk
fallow minnow
#

its fine ill just adjust my padEnd sizes a little

echo tinsel
#

?

#

what?

dim tusk
#
world.afterEvents.entityDie.subscribe(({ deadEntity, damageSource: { cause, damagingEntity, damagingProjectile } }) => {
  const family = deadEntity.getComponent('type_family');

  if (deadEntity.typeId === 'minecraft:player' || deadEntity.typeId === 'minecraft:item' || family.hasTypeFamily('inanimate')) return;

  const { dimension: deadEntityDimension, location: deadEntityLocation, typeId: deadEntityTypeId } = deadEntity;

  const now = Date.now();
  const christmas = getDateRangeInfo(now, holiDates.christmas, { weeks: 2 });

  if (Math.random() <= 0.01) {
    if (christmas.isInRange) {
      deadEntityDimension.spawnItem(new ItemStack('minecraft:apple', 1), deadEntityLocation);
    }
  }
});```
echo tinsel
#

oof

#

the whole thing is rewritten

#

i have cases

dim tusk
echo tinsel
#

world.afterEvents.entityDie.subscribe((eventData) => {

try {
    const deadEntity = eventData.deadEntity;
    const damagingEntity = eventData.damageSource.damagingEntity;
    const deadEntityId = deadEntity.typeId;
    const deadEntityLocation = deadEntity.location;
    const deadEntityDimension = deadEntity.dimension;
    if (deadEntityId == 'minecraft:item') return;
    if (Math.random() <= 0.01) switch (true) {
        case (getDateRangeInfo(Date.now(), holiDates.christmas, { weeks: 2 }).isInRange): {
            eventData.deadEntity.dimension.spawnItem(new ItemStack(`minecraft:apple`, 1), eventData.deadEntity.location)
        };
        case (getDateRangeInfo(Date.now(), holiDates.easter, { weeks: 2 }).isInRange): {
            eventData.deadEntity.dimension.spawnItem(new ItemStack(`minecraft:gold_ingot`, 1), eventData.deadEntity.location)
        };
        case (getDateRangeInfo(Date.now(), holiDates.halloween, { weeks: 2 }).isInRange): {
            eventData.deadEntity.dimension.spawnItem(new ItemStack(`minecraft:diamond`, 1), eventData.deadEntity.location)
        };
    }
}
catch { }

})

echo tinsel
dim tusk
#

don't directly do the getDateRangeInfo()

dim tusk
#

Looks what I did in Christmas

echo tinsel
#

you want me to do that everytime for each season?

#

how is what i have right now, including all seasons not shorter

#

if (christmas.isInRange) {
deadEntityDimension.spawnItem(new ItemStack('minecraft:apple', 1), deadEntityLocation);

id do this part for each season?

dim tusk
humble lintel
#

does anyone know why /particle is not working

humble lintel
#

i dont see any particles

#

am i cooked

#

when i do /particle i xdont see them

echo tinsel
dim tusk
#

Dimension.spawnParticle() or Player.spawnParticle()...

humble lintel
#

uh yes

#

that's how you sapwn the,

#

them

dim tusk
echo tinsel
#

i was just trying to add the exclusion of entities with the inanimate tag to what i already had

#

what?

humble lintel
#

okay wait some work

dim tusk
# echo tinsel what?

I repeated this twice... Don't do this...js case (getDateRangeInfo().isInRange) {} do thisjs const christmas = getDateRangeInfo(); case (christmas.isInRange) {}

#

also pls code block when sending scripts.

echo tinsel
#

an i repeated all im looking for is how to add the exclusion of Inanimate entities to the dead entities

drifting ravenBOT
#
Formatting Your JSON Or JS Code

Please format your code as code-blocks! This makes the text monospaced, and has support for syntax highlighting.

JSON
```json
{
"example": 123
}
```

JavaScript
```js
console.log("Hello World");
```

The character used here is the backtick. This symbol is usually at the top left of your keyboard, occupying the tilde key (~). On mobile, it will be on the second or third page of symbols.

dim tusk
#

damn.

echo tinsel
#

i did but like i said. to me its hard to read

dim tusk
#

anyways... Again. js const family = deadEntity.getComponent('type_family'); if (family.hasTypeFamily('inanimate')) {}

dim tusk
echo tinsel
#

thats really black and white thought, but thank you for your help !

dim tusk
# echo tinsel thats really black and white thought, but thank you for your help !
world.afterEvents.entityDie.subscribe((event) {
  const deadEntity = event.deadEntity;
  const damageSource = event.damageSource;
  const cause = damageSource.cause;
  const damagingEntity = damageSource.damagingEntity;
  const damagingProjectile = damageSource.damagingProjectile;

  const family = deadEntity.getComponent('type_family');

  if (deadEntity.typeId === 'minecraft:player' || deadEntity.typeId === 'minecraft:item' || family.hasTypeFamily('inanimate')) {
    return;
  }

  const deadEntityDimension = deadEntity.dimension;
  const deadEntityLocation = deadEntity.location;
  const deadEntityTypeId = deadEntity.typeId;

  const now = Date.now();
  const christmas = getDateRangeInfo(now, holiDates.christmas, { weeks: 2 });

  if (Math.random() <= 0.01) {
    if (christmas.isInRange) {
      deadEntityDimension.spawnItem(new ItemStack('minecraft:apple', 1), deadEntityLocation);
    }
  }
});
#

Now, don't tell me it's still hard to read because you might need glasses now lol....

echo tinsel
#

that is easier, so if i was going to add the rest of the seasons id do this for each one right?




  const christmas = getDateRangeInfo(now, holiDates.christmas, { weeks: 2 });

  if (Math.random() <= 0.01) {
    if (christmas.isInRange) {
      deadEntityDimension.spawnItem(new ItemStack('minecraft:apple', 1), deadEntityLocation);
    }
  }
});
dim tusk
# echo tinsel that is easier, so if i was going to add the rest of the seasons id do this for ...

Yes.

  const christmas = getDateRangeInfo(now, holiDates.christmas, { weeks: 2 });
  const newYear = getDateRangeInfo(now, holiDates.newYear, { weeks: 2 });

  if (Math.random() <= 0.01) {
    if (christmas.isInRange) {
      deadEntityDimension.spawnItem(new ItemStack('minecraft:apple', 1), deadEntityLocation);
    } else if (newYear.isInRange) {
      deadEntityDimension.spawnItem(new ItemStack('minecraft:apple', 1), deadEntityLocation);
    }
  }
});
echo tinsel
#

  if (deadEntity.typeId === 'minecraft:player' 
#

what is that part saying?

dim tusk
glacial widget
#

How do i check if a player killed a someone using a ender crystal?

dim tusk
glacial widget
dim tusk
valid ice
#

Well that's new

humble lintel
#

yeah particles are being weird

#

even custom particles

dim tusk
humble lintel
#

yep might be

dim tusk
#

I tried in my mc both preview and stable and it works fine...

humble lintel
#

can u spawn totem_particle?

#

like my normal particles are okay

#

i cant spawn particles tho that's the issue

#

bruh no way

#

it was a resource pack

dim tusk
humble lintel
#

better weather

humble lintel
#

idk how better weather resource pack ruins all the other particles

dim tusk
#

Check if there's material folder

humble lintel
#

yes no particles spawned

#

its oaky i dont need it anyways

dim tusk
humble lintel
#

nah they just made the particles texture transparent lol

dim tusk
# tidal wasp Help

You meant this?js e.permutationToPlace = BlockPermutation.resolve(playerEquipment.typeId, { [horzhalf]: horzState, [blockStateHalf]: state }); return;

tidal wasp
#

Huh thanks

dim tusk
#

using with state and BlockPermutstion instance isn't valid. I meant combining them.

tidal wasp
#

Ok good to know

echo tinsel
#

its doing just before

dim tusk
#
  const christmas = getDateRangeInfo(now, holiDates.christmas, { weeks: 2 });

  if (Math.random() <= 0.01) {
    if (christmas.direction === 'after') {
      // ...
    }
  }
});
#

Or that wasn't your question?

#

Also, didn't I sent it yesterday the description of datas it returns?

echo tinsel
#

thats what i was just doing, looking for that

#

lol

#

damn ok, so i have to do the whole if, else if. ect again for the after week

dim tusk
# echo tinsel damn ok, so i have to do the whole if, else if. ect again for the after week
  • isInRange: A boolean that is true if the two dates are within the specified time range (e.g., within 2 weeks).
  • direction: A string indicating whether currentDate is 'before', 'after', or 'same' as targetDate.
  • isPast: true if currentDate is after targetDate.
  • isFuture: true if currentDate is before targetDate.
  • isSame: true if both dates are identical.
  • timeDifference: An object showing the difference in days, hours, minutes, seconds, and milliseconds.
echo tinsel
#

the isInRange says it checks both? but it doesnt do both?

dim tusk
echo tinsel
#

ohhh

#

ok

tidal wasp
#

Also any way to make this redstone script more efficient

dim tusk
echo tinsel
dim tusk
echo tinsel
slow walrus
#

i have a one liner which can get the right size after its converted

#

gimme a sec

#
const utf8_size = char_code <= 0x7f ? 1 : char_code <= 0x7ff ? 2 : char_code <= 0xffff ? 3 : 4```
echo tinsel
dim tusk
#

use new Date()

echo tinsel
#

Also using the drop script you gave me now too so if it says date.now it's because that's what you sent me lol

#

But nothing does day date.now

dim tusk
#

try using new Date...

echo tinsel
#

Oh wait. One does say date.now

#

But regardless that is not what it sending the log

#

It's the console.error log you set up in the holiday. That is a different script and that is new Date. Already

#

I changed the holiday date for Halloween to 3, 12 to check something and the log came back at whatever time zone it has its already the 13th.

dim tusk
#

you're starting to make me confuse...

echo tinsel
#

This

#

const holiDates = {
    easter: new Date(2000, 3, 20),
    festive: new Date(2000, 3, 6),
    halloween: new Date(2000, 3, 12),
    summer: new Date(2000, 7, 4),
};

const now = new Date();

console.error('Christmas info:', JSON.stringify(getDateRangeInfo(now, holiDates.festive, { days: 1 })));
console.error('Halloween info:', JSON.stringify(getDateRangeInfo(now, holiDates.halloween, { weeks: 2 })));
console.error('Today info:', JSON.stringify(getDateRangeInfo(now, now, { days: 3 })));

dim tusk
#

I used the original one and it works fine. With me...

echo tinsel
#

there is nothing wrong with it, other then im trying to figure out what timezone the game is using lmao

#

because whatever that time zone is, its the 13th already

#

its not going off my timezone

dim tusk
#

date is in +0 iirc

#

Wait lemme research again.

dim tusk
echo tinsel
#

yes cause now im confused lol,

echo tinsel
dim tusk
echo tinsel
#

all good, i should of seen it as well. literally put it under 3 of them that say error

echo tinsel
#

ill just set all my holidays to 2 days after the holiday then

#

im not trying to add a config for people to set their offset

humble lintel
gilded shadow
humble lintel
#

uhh i see the,

#

them

dim tusk
gilded shadow
stuck ibex
#

Is there an event that checks for /reload

#

Is it worldLoad?

gilded shadow
valid ice
#

Base scripts run when reload is fired, but also when the world is loaded

shut citrus
#

how to fix this?

nova flame
#

how do i make a button appear here ONLY for people with a certain Tag

round bone
#
if (player.hasTag("some_tag")) form.button("")
#

also you have to include this when you're handling a response from form

nova flame
round bone
nova flame
#

okay ill mess around w it i just started js like 2 days ago

round bone
#

have a nice one then

dim tusk
# nova flame how do i make a button appear here ONLY for people with a certain Tag

you cns try to sue this as reference

const form = new ActionFormData().title('test');

const buttons = [
    { name: 'warp', texture: 'textures/ui/' } // Always shown button with texture
]; 

// Add conditional buttons with their textures
if (player.hasTag('shop')) buttons.push({ name: 'shop', texture: 'textures/ui/' });
if (player.hasTag('sell')) buttons.push({ name: 'sell', texture: 'textures/ui/' });
if (player.hasTag('invite')) buttons.push({ name: 'invite', texture: 'textures/ui/' });

// Add all buttons to the form
for (const btn of buttons) form.button(btn.name, btn.texture);

form.show(player).then(({ selection, canceled }) => {
  if (canceled) return;
  const choice = buttons[selection].name; // Get the button name from the array

  if (choice === 'warp') {}
  else if (choice === 'shop') {}
  else if (choice === 'sell') {} 
  else if (choice === 'invite') {}
});```
nova flame
#

@dim tuskthanks this helped

fathom hemlock
#

whats current scriptapi version, cuz mc got updated

jolly citrus
#

what happened to .runCommandAsync

open urchin
#

removed in 2.0.0-beta

jolly citrus
#

o

#

are the custom command builders on ly avcailable in preview

#

or are they in 1.21.70

zinc flax
#

How is setPropertyOverrideForEntity used?

round bone
ivory bough
#

How to get the repawn point of a player?

ivory bough
zinc flax
#

Can it be applied to player properties?

shy leaf
#

this returns DimensionLocation

interface DimensionLocation {
    dimension: Dimension;
    x: number;
    y: number;
    z: number;
}```
#

i have no idea why the coordinates are deconstructed

prisma shard
leaden elbow
#

is the Date on script accurate enough on realtime

errant wadi
#

and it's the only way to get realtime.

#

(unless you use bds and http request)

leaden elbow
#

got it thanks

#

one last thing

#

how to get the Entity (which is Player constructor) by using provided playerName? since playerJoin event returns playerName and playerId

#

or can i just use the playerId instead to get the Player

dim tusk
leaden elbow
#

oh well

#

so basically

#

initialSpawn is when player is respawning?

cyan basin
leaden elbow
#

okay thanks

round bone
shy leaf
#

oh yeah now that i think about it

#

it is better that way

echo tinsel
dim tusk
#

Id it's runtInterval

echo tinsel
#

How do I add a delay because I'm not doing anything to check the time?

#

Loading in it does it and then randomly there's a terrible stutter

errant wadi
#

system.runInterval/runTimeout

echo tinsel
#

Is that just going to make it where it stutters on a timer basically?

#

Loading in is pretty bad. I'm assuming it's going to do that Everytime regardless on the timeout.

echo tinsel
thorn flicker
#

its just a grey screen, even when I download it

#

try a different format

thorn flicker
#

there's going to be a new tooltip option for modal forms in the future btw

#

you'll be able to hover a little icon that shows a description of an option, which will be way neater.

round bone
#

it's already in-game for preview version

thorn flicker
round bone
#

but it already exists in the game, it's not for stable yet

thorn flicker
#

what I said is still valid, not everyone wants to have their addons running on preview.

round bone
wary edge
#

😐

round bone
#

it already exists in the preview, so how it's valid?

thorn flicker
#

you are one of those huh

wary edge
round bone
wary edge
#

Until it becomes stable, it will always be coming soon™️

round bone
#

why they would even remove it?

wary edge
#

Anyways, not going to argue woth strangers on the internet. 🙂 You should know what VoidCell means by "in the future"

thorn flicker
#

arguing for no good reason at all

round bone
#

the migration made Mojang developers easier to maintain new updates for creators I think

wary edge
thorn flicker
#

you are right

#

lol

thorn flicker
# thorn flicker <@335307151881011202> its great

@humble lintel
maybe you can make it per-player? Maybe other players want different options.
Unless you did that already, if so nvm.

and if the host of the world does not want that, make it so they can override it in an admin version of the menu.

distant tulip
wary edge
#

A lot of HCF functuonality people thought would be coming in the future didnt!

thorn flicker
#

lol

round bone
#

we have changed our topic to a HCF

#

tell me why they would remove a tooltip for modal form data components?

terse pulsar
#

The itemStack.getComponent('minecraft:cooldown') returns a number or bool?

terse pulsar
#

Thanks

fast lark
#

Someone have the spawner like donut smp addon

coral ermine
#

is there a way to open shulker in hand?

fast lark
#

Shulker

coral ermine
random flint
#

place it using dispenser

thorn flicker
distant tulip
#

Ah, Gega said so

prisma shard
sage sparrow
#

hi there, do someone used the camera to set a kind of security camera? javascript innerTV.camera.setCamera("minecraft:free", { offsetFromTargetCenter: testloc, targetEntity: target });
shouldn't it track the target? the camera is placed but it doesn't follow

wary edge
#

To my knowledge.

weary umbra
#

how can I change the scale of an entity bc the value is now read only

random flint
#

component group

weary umbra
#

yeah thats the issue

#

[Scripting][error]-TypeError: 'value' is read-only at <anonymous> (script/minigames/map_3.js:93)

random flint
#

Try lower script api version

terse pulsar
#

If i put a while inside system.run it will loop until while be false?

terse pulsar
fathom hemlock
#

whats the playerDie event?

wary edge
fathom hemlock
#

okay

meager pulsar
#

since worldInitialize and itemComponentRegistry are deprecated, what do you use now?

meager pulsar
#

can i ask about this 2 too?

aftertEvent world Initialize and playerSpawn.suscribe

#

startUp is only as a beforeEvent, as for playerSpawn idk why its suscribe in specific is deprecated

wary edge
meager pulsar
wary edge
carmine cloud
#

would yall know how to get the default gamemode set for a world from within the script api?

marsh pebble
#

How do i add script events to open up my guis

distant tulip
distant tulip
marsh pebble
#

yes

distant tulip
# marsh pebble yes
import { world, system, ItemStack, Player } from '@minecraft/server';
import { ActionFormData } from '@minecraft/server-ui';

system.afterEvents.scriptEventReceive.subscribe((event) => {
    const { id, message, sourceEntity } = event
    if (sourceEntity instanceof Player) {
        new ActionFormData()
            .title("Special Offer!")
            .body("Do you want a free diamond?")
            .button("Yes!")
            .button("No")
            .show(sourceEntity)
            .then(({ selection }) => {
                if (selection !== 0) return;
                sourceEntity.getComponent("minecraft:inventory")?.container?.addItem(new ItemStack("minecraft:diamond", 1));
                sourceEntity.sendMessage("You received a free diamond!");
            })
    }
})
marsh pebble
gilded shadow
distant tulip
gilded shadow
#

I wanna Check what .subscribe provides to callbacks

wary edge
gilded shadow
wary edge
#

MS Docs is terrible.

granite badger
gilded shadow
#

I see

gilded shadow
#

thanks

carmine cloud
fathom hemlock
marsh pebble
#
import { world, system, ItemStack, Player } from '@minecraft/server';
import { ActionFormData } from '@minecraft/server-ui';

system.afterEvents.scriptEventReceive.subscribe((event) => {
    const { id, message, sourceEntity } = ticket

    if (sourceEntity instanceof Player) {
        new ActionFormData()
            .title("Special Offer!")
            .body("Do you want a free diamond?")
            .button("Yes!")
            .button("No")
            .show(sourceEntity)
            .then(({ selection }) => {
                if (selection !== 0) return;
                sourceEntity.getComponent("minecraft:inventory")?.container?.addItem(new ItemStack("minecraft:diamond", 1));
                sourceEntity.sendMessage("You received a free diamond!");
            })
    }
})

@distant tulip

distant tulip
#

huh

#

why

marsh pebble
#

@distant tulip

#

how to open a form with

#

/scriptevent form:open <er>

dim tusk
#

stop tagging him men...

marsh pebble
#

opp 🙏

dim tusk
#

also, just do```js
if (id === 'from:open') {

}```

dim tusk
fathom hemlock
#

why is this not working, its not cloning the thing:

  if (!arenaPos1 || !arenaPos2) return null;
  if (arenaClones.length >= MAX_ARENAS) return null;

  const index = arenaClones.length;
  const sorted = getSortedPositions(arenaPos1, arenaPos2);
  const width = sorted.to.x - sorted.from.x + 1;
  const height = sorted.to.y - sorted.from.y + 1;
  const length = sorted.to.z - sorted.from.z + 1;

  const xOffset = (width + arenaSpacing) * index;

  const targetStart = {
    x: arenaBase.x + xOffset,
    y: arenaBase.y,
    z: arenaBase.z
  };

  const cloneCommand = `clone ${sorted.from.x} ${sorted.from.y} ${sorted.from.z} ${sorted.to.x} ${sorted.to.y} ${sorted.to.z} ${targetStart.x} ${targetStart.y} ${targetStart.z} replace`;
  world.getDimension("overworld").runCommand(cloneCommand);

  const arena = {
    index,
    start: targetStart,
    end: {
      x: targetStart.x + width - 1,
      y: targetStart.y + height - 1,
      z: targetStart.z + length - 1
    },
    p1: null,
    p2: null,
    spawn1: null,
    spawn2: null
  };

  arenaClones.push(arena);
  return arena;```
real whale
#

Hello, how can I create a manifest.json file in a script manner?

fathom hemlock
#

oh should I do: world.getDimension("overworld").runCommand(`${cloneCommand}`);

distant tulip
dim tusk
dim tusk
fathom hemlock
#

okay

real whale
fathom hemlock
real whale
#

thanks

granite badger
real whale
#

Yes, this is very good.

dim tusk
marsh pebble
distant tulip
#

to the ui?

distant tulip
dim tusk
sage sparrow
marsh pebble
# distant tulip to the ui?
import { world } from "@minecraft/server";
function showMainForm(player) {
  if(event.id !== "form:open") return
  const form = new ActionFormData()
    .title("Choose an option please")
    .button("Names")
    .button("Ranks")
    .button("Clans")
    .button("Cancel");
#

is this it?

distant tulip
#

yes, the code is not finished tho

sage sparrow
marsh pebble
#

but my ui activates with an item

#

but i'd also like it to activate with script event

#

@dim tusk

marsh pebble
#

how would i do /scriptevent to open this

elder remnant
#

am I able to load something before a script reloads

dense sun
#

I want to disable players to be visible when then they are visible in XRAY

#

is there a way to make them visible only if a player is looking at it

dense sun
#

like line of sight based rendering

terse pulsar
remote oyster
terse pulsar
remote oyster
distant tulip
terse pulsar
#

And...

#

Why this

#
world.beforeEvents.itemUse.subscribe(ev => {
    system.run(() => {
        equip(ev.source, ev.itemStack, ev.cancel, ev.itemStack.getComponent('minecraft:cooldown').cooldownTicks(ev.source))
    })
})
#

Its sendig this error

#
[Scripting][error]-TypeError: not a function    at <anonymous> (activation.js:54)
distant tulip
#

it is a number

#

use getCooldownTicksRemaining

terse pulsar
#

But on wiki its cooldownTicks(player: Player)

#

I think

distant tulip
#

link?

dim tusk
distant tulip
#

there is not a single use of the cooldown component in the wiki

terse pulsar
#

I think that i need some good sleep hours

floral vessel
#

tf does it mean "Expected 4"

distant tulip
#

the docs you are looking at don't match you version

floral vessel
#

Is there a version switcher other than the one that toggles between stable and experimental?

dense skiff
#

Do we have a way of making text displays that doesnt use a custom entity?

dim tusk
#

Make an animation scaling them into 0

#

Play them using playerAnimation()

terse pulsar
#

On setTimeOut uses ticks or seconds?

dim tusk
#

And it uses ticks.

#

setTimeout() uses milliseconds tho it doesn't exist in Minecraft script API.

terse pulsar
dim tusk
terse pulsar
#

Ok

#

Thanks again

narrow patio
#

how do you import in 2.0.0-beta?

cold grove
#

import what

prisma shard
cold grove
#

the import of the imports

prisma shard
#
import {world, system} from "@minecraft/server";```
#

thats it

#

Idk what did he meant by Import

floral vessel
#

what units is getVelocity in?

solar dagger
#

how can i offset the player's camera when riding an entity?

wheat condor
#

How does setDynamicProperties work?

prisma shard
#

today's not april fool day

#

setDynamicProperties( values: Record<string, string | number | boolean | Vector3>, )

#

the guy who made a whole database ask that how does setDynamicProperties work hmmmm.

unique acorn
solar dagger
wheat condor
#

i used setDynamicProperty but not properties

solar dagger
solar dagger
wheat condor
#

no i mean that multiple dynamic properties needs an object

setDynamicProperties({
  key:value,
  ket:value
})

and single dynamic property doesnt

setDynamicProperty(key,value)
nova flame
#
if (player.hasTag("2xSell")) {
        addScore (player, "Coins", totalAmount * 2)
    }  
    else addScore (player, "Coins", totalAmount)
    return totalAmount
``` any ideas on why this dont work?
shy leaf
nova flame
nova flame
shy leaf
#

still missing context

nova flame
#

like what

shy leaf
#

did you get any content log

nova flame
#

no

#

i figured it oout

round bone
#

if you'll have more tags like {x}xsell in the future, consider using:

const highestSellMultiplier = player.getTags().filter((tag) => /^\d+xSell$/.test(tag))?.map((tag) => +tag.split("x")[0])?.sort((a, b) => b - a) || 1
addScore(player, "Coins", totalAmount * highestSellMultiplier)
return totalAmount
fathom hemlock
#

I can't use await wait(5) in functions

```commandManager.addCommand("ui-builder", {description: "Open UI menu", category: "Open", format: ${commandManager.prefix}ui-builder}, ({msg,args})=>{
let plr

openUIBuilderMenu(plr)

})```

#

wait is function made by e

#

*me

fathom hemlock
#

nvm

untold magnet
#

does the onRandomTick requires the onTick component?

#

my copper pot is using the onTick component to do somethings, but i need to make it get exposed or weathered like vanilla copper

glacial widget
#

what's the villager sound?

#

nvm ill just look online

cyan basin
fathom hemlock
#

how do I use typeId?

leaden elbow
#

player.nameTag = "value" sets a nametag of player right

leaden elbow
#

typeId returns type id

glacial widget