#Script API General

1 messages Β· Page 99 of 1

deep quiver
#

but I guess it doesn't make much sense anyways, so hasMemory makes more sense

round bone
#

includesMemory

warm mason
#
const myMind = {
  memories: new Array(2*9999999).fill('JS'),
  findMemory(key = 'JS') {
    return this.memories.includes(key) || console.log("404 JS Not Found?!??!?!");
  }
};

myMind.findMemory("JS?");
dusky flicker
#

no

#

i(personally) simply dont care about patterns of writing code. the first time i started writing something with nestjs i hated it

#

the idea of controllers and services piss me off

sly valve
dusky flicker
#

eewww no, the code gets too ruled by the framework

#

i like doing stuff my way

#

for me it would be namespaces with functions

#

i agree that its good when code gets lsrger

#

but hell no, the performance of nestjs is terrible

dusky flicker
#

i like thinking on that

#

i dont like having something already pre-made for me

rare dawn
#

I need help!!

#

Can anyone write a script "if you write in the command /tag @s add lock_all body, the body and head will immediately be straight"

warped blaze
sullen ocean
jagged gazelle
rustic ermine
prisma shard
#

Ofc javascript

round bone
#

🦸

halcyon phoenix
#

more features definitely

distant tulip
#

it depends, mcfunctions can definitely be faster in some cases

oblique mica
#

#1396040869777379379 can someone help me

carmine yarrow
#

Mini-question that doesn't justify a post:
How can I translate the result of a command? It expects a string rather than a RawMessage.

rustic ermine
#

@lone mango

const entitiesOnCustomBlock = new Set()

system.beforeEvents.startup.subscribe(init => {

    init.blockComponentRegistry.registerCustomComponent('grb:regenerative_block', {
        onStepOn: (event, params) => {
            entitiesOnCustomBlock.add(event.entity)
        },
        onStepOff: (event, params) => {
            if (entitiesOnCustomBlock.has(event.entity)) { entitiesOnCustomBlock.delete(event.entity) }
        }
    });

}

then you can just check

//pseudo-code
 entitiesOnCustomBlock.has(entity)

or similar from your other function. if you need to check players etc just change the stuff in onStep from event.entity to event.entity.nameTag

halcyon phoenix
#

is runInterval unique for every trigger in customComponents?

rustic ermine
#

yes

#

but the interval will remain the same within the scope

halcyon phoenix
#

ohhh I thought it would be considered global and all blocks would have the same interval

rustic ermine
#

for example, I call this from within my runInterval in a custom block component trigger

function exitSystemLoop(player: Player, tool: ToolProperties, harvest_system: number) {
    if (player) {
        setPlayerBusy(player, false)
        player.setProperty(tool.use_animation, false)
    }
    system.clearRun(harvest_system);
}
halcyon phoenix
#

wait, example a plant growing has an interval of 20 ticks and I place each in different times would they have different times too?

rustic ermine
#

when you create a system.runInterval it returns a unique ID as a number. each system is unique

halcyon phoenix
#

I see thanks

rustic ermine
halcyon phoenix
#

I should have assumed that, I ended up making a timer using the block's location.....

rustic ermine
#

nope no need. the system gets added to the event queue within quickJS when it is created. all you need to do is provide a way for the system to stop without player input

halcyon phoenix
#

thanks Laskod

rustic ermine
#

this is how I do that..

    init.blockComponentRegistry.registerCustomComponent('grb:regenerative_block', {
        onPlayerInteract: (event, block_component) => {
            harvestRegenerativeBlock(event, block_component)
        }
    });

then you can make sure the system is working with that specific block in the function

#

can actually get kinda crazy using blockstates and permutations too like I did lol.. so when my block gets harvested, it sets permuation which swaps out components. so then the other permutation gets different custom component events

jagged gazelle
#

I want two things in blocks rn. block dynamic prop and block entities.

halcyon phoenix
#

.stop() closes a runInterval?

#

I forgot what stops it

rustic ermine
#

look at the function I put a bit above

#

the exitSystemLoop

halcyon phoenix
#

oh clearRun

rustic ermine
#
    system.clearRun(harvest_system);

clearRun takes the unique number from when the system was created

jagged gazelle
halcyon phoenix
#

yep I thought it was close or stop or somethin

#

thanks

rustic ermine
#
js
    const harvest_system = system.runInterval(() => {
jagged gazelle
#

but they're useless once the world was reloaded or /reload

rustic ermine
#

you dont even need to tbh. just declare it outside of the system's scope. it'll get copied, not referenced, so when the const drops it is still valid

jagged gazelle
rustic ermine
#

ahh

halcyon phoenix
#

purpose is glorious

#

anyways thanks it's workign fine now

#

look at this horrendous crap

#

should have used interval

rustic ermine
#

nice

halcyon phoenix
#

LOL

#

it's piratesoftware type crap

rustic ermine
#

hey if it does what you want and it works /shrug

jagged gazelle
#

-# I'm just addict.

halcyon phoenix
visual zephyr
#

is there a way to remove dynamic property of an entity

halcyon phoenix
#

how do you use EntityApplyDamageOptions on applyDamage()?

halcyon phoenix
visual zephyr
#

i dont really know but i'd try that

visual zephyr
#

like this

#
entity.applyDamage( 5, {cause: EntityDamageCause.entityAttack, damagingEntity: player} )
rustic ermine
visual zephyr
#

alright thanks

halcyon phoenix
rustic ermine
#

it will set it to undefined

#

so, no longer exists

halcyon phoenix
#

alright

rustic ermine
#

for readability / clarity though probably better to say
("prop_name", undefined)
so that there is never a question that the intention was to remove it

dusky flicker
#

both are slow

halcyon phoenix
#

is it possible to stop a player from attacking? like inputpermission

prisma shard
rustic ermine
prisma shard
#

no problem
-# bruh i kinda feel weird on apologies

subtle cove
#

apologies for interrupting

rustic ermine
#

lol all good

#

ergh. custom commands beta-only?

#

docs say 2.0.0-beta but since current stable is 2.0.0 assumed it would be there and the docs were out of date

round bone
#

you should use a hashmap

rustic ermine
#

used Set to avoid duplicates in that example since they only cared about checking if something was on the block. they were asking about it in the blocks channel

prisma shard
#

oh guys interstingly the VSCode official site has a new design

round bone
#

even if it's the same entity, this won't work

rustic ermine
#

thinking about it now I see your point, especially considering that everything would just be Object in the end

round bone
#

or just entity's identifier

rustic ermine
#

yeah. my bad. barely any sleep the past few days due to new meds, just threw that together in like 10 sec

round bone
#

this is probably the easiest way to get it working correct

round bone
rustic ermine
#

that was actually my first idea but docs for id say they are basically worthless but probably am just interpreting what it means incorrectly

#

I do understand what that would mean in an ECS context though, so thanks for correcting

halcyon phoenix
#

for WorldSoundOptions what's the max volume?

night acorn
#

so any values higher than one will be clamped to 1

halcyon phoenix
#

I see

gaunt salmonBOT
true isle
#

how do i return the face of a block a projectile hits?

sullen ocean
drifting ravenBOT
#
Finding a Dev or a Team?

This discord isn't suited for finding or offering paid work. We can't moderate these transactions, so we ask that you move to a more suitable place.

For a casual discord community, consider joining Skill Share: https://discord.gg/sZ7fkcN.

Find incredible people. Make beautiful things. A home for crafting your career in the Minecraft industry.

https://www.bucketofcrabs.net/

nova flame
#

anyone know why the commands wont appear

#

and they dont work

prisma shard
#

hmm

#

guys

#

like its beeen like a year i\ve been learning script api

#

but

#

i've learned a lot of methods but still not having practice of where to use them/when to use them

#

like i code in a simpler way which works but i want to code like those proffesionals

granite cape
#

day 1 learning script

rustic ermine
#

mining / woodcutting so far πŸ™‚

nova flame
granite cape
#

i need more knowledge

true isle
#

same i ask questions but majority of the time i figure it out myself

sly valve
sly valve
nova flame
sly valve
sly valve
nova flame
#

its enabled

granite cape
visual zephyr
rustic ermine
#

It has other cancel conditions just didn't show them. For example switching tools, moving, or getting hit

#

But looking at the block doesn't effect anything. Once you click it you'll harvest that one even if you are not looking at it

visual zephyr
#

that's good but thats just a recommendation

rustic ermine
#

I just don't see it as necessary since it doesn't effect anything and vision check is a bit expensive

visual zephyr
#

wdym expensive?

rustic ermine
#

Costly enough to calculate with quickJS for me to not consider it

visual zephyr
#

oh okay up to u

sly valve
subtle cove
#

The neko ai ;-;

weak jay
#

Hello, after a long period of not touching Minecraft, I decided to continue with an addon where I was using a script.

But I noticed that functions like beforeEvents and others have disappeared.
Do you know what they were replaced with?

open urchin
#

before events still exist, which specific ones aren't working for you?

warped blaze
#

what's World.broadcastClientMessage() even for?

weak jay
#

world.beforeEvents.chatSend.subscribe((eventData) => {
const player = eventData.sender;
if (!player.hasTag('OP')) return;
switch (eventData.message) {
case '!start':
eventData.cancel = true;
...

        break;
    default: break;
}

});

distant tulip
weak jay
#

Ok, I'll try again.

#

system.runInterval(() => {
(async () => {
await world.getDimension("overworld").runCommandAsync("function roles");
await world.getDimension("overworld").runCommandAsync("function compass");
await world.getDimension("overworld").runCommandAsync("function clear");
await world.getDimension("overworld").runCommandAsync("function triforce");
await world.getDimension("overworld").runCommandAsync("function bottespegase");
})();
}, 0);

I now have a new problem on this part of the code
Line 104: await world.getDimension("overworld").runCommandAsync("function roles");
Line 109: })();

#

I found that

"runCommandAsync" no longer exists, and I had to add "runCommand"

sly valve
sly valve
weak jay
#

Lol, this was my first project that I did a long time ago, that I'm going to modernize and update

midnight crane
#

Can someone tell me how to make it so a button shows up in a gui if you have a tag

midnight crane
thorn flicker
midnight crane
#

Thanks

midnight crane
thorn flicker
#

yep

sly valve
#

Yep

thorn flicker
sly valve
midnight crane
#

Cool I appreciate it

thorn flicker
#

just happened to say the same version of yes lol

thorn flicker
sly valve
thorn flicker
sly valve
shut vessel
#

my code doesnt work when the nezukofeu was at 1 it didnt get on fire

          for(let player of world.getPlayers()){
  const nezukofeu = world.scoreboard.getObjective('nezukofeu2').getScore(player.scoreboardIdentity) == 1
  if (nezukofeu === 1) {
     player.setOnFire(200)
}}```
sly valve
#

If it still doesnt works, ensure that the value nezukofeu is 1, by using console.log (or warn) to display it

shut vessel
#

thanks i will try that

warm mason
thorn flicker
#

im so sorry!

true isle
#

is it possible to save a local db without an exteral app?

winter plaza
#

Hi

#

How do you identify the player speed with a script, like query.modified_move_speed?

warm mason
winter plaza
#

How

#

thank you my dear πŸ™‚

#

you are incredible!

sly valve
#

I also want to be called incredible

sharp elbow
#

(this could work with a Vector2 or VectorXZ as well)

function getSpeed(velocity) {
  return Math.hypot(Object.values(velocity));
}

const speed = getSpeed(entity.getVelocity());
jagged gazelle
sharp elbow
#

What about it?

wary edge
#

Confused what typescript has to do with anything.

jagged gazelle
sharp elbow
#

I'm not a math or vector expert, so I'm not too certain I have an answer either

jagged gazelle
#

here, imagine the small box as spawn point of the arrow, the spawn point can be in any position there's no fix place.

#

and the big box is players head and the line is the view direction or line of sight or cursor of the player

#

what I want is it to travel in the direction of the player is looking ending at the cursor...

#

Frck I'm so bad at explaining 😭

sharp elbow
#

First you'd want to establish where that end point is. You have a direction, but given that the arrow isn't collinear with that direction, you need a point along that line to fire the arrow at

#

I'd probably cast two rays, one for entities and one for blocks, then determine the location of where it struck. If it found nothing, then I'd do a fixed offset in that direction, maybe 5 blocks.

jagged gazelle
jagged gazelle
sharp elbow
#

And there's no gravity or uncertainty bias on the arrow itself?

jagged gazelle
#

yes, just pure move.

jagged gazelle
# jagged gazelle

I know how to move it to the end point for example in this image, that's fairly easy but making it go to the player's view direction after that isn't easy for me or I'm just slow as hell lol

sharp elbow
#

Hm, I'm not sure. It otherwise seems accurate. And it looks like you're basically doing what I recommended

jagged gazelle
#

Hmm, I might just make the distance long. Just need to take account that having long distance make it easy to go in unloaded chunk.

subtle cove
#

Like Precedural spider following a dot?

jagged gazelle
#

I mean, huh?

#

hmm... Ignore this now.

jagged gazelle
#

Oof

#

-# my common sense don't exist rn

halcyon phoenix
#

watcha tryna do coddy?

jagged gazelle
#

projectile shoot system.

#

but without usings players head as starting point of spawn

cinder shadow
jagged gazelle
halcyon phoenix
jagged gazelle
jagged gazelle
#

especially if they're looking at the air lol

halcyon phoenix
jagged gazelle
jagged gazelle
#

Object.fromEntries(Object.entries(head).map(([a, v]) => [a, v + (view[a] ?? 0) * distance]));

cinder shadow
jagged gazelle
halcyon phoenix
jagged gazelle
# halcyon phoenix why do you not need the head as starting point here?

ok imagine the hands or chest is the starting point of the arrow spawning... I need to make it travel to go my cursor. How? We need two ways the blocks and the no blocks, the blocks way is easy as 123, I just need to get the face location my ray hit and use that as target location otherwise we do non blocks wya if theres no block was hit in the ray, to do that we need to get players head add with view direction multiply the distance and that's the new target point if there's no block found in ray.

#

Gets?

distant tulip
#

You can use the same thing with no block, you can just take any point of the ray, just add view direction head location and you get a dummy block location

subtle cove
#

add(head, view * distance) if air...

jagged gazelle
halcyon phoenix
#

I thought there were more limitation

halcyon phoenix
distant tulip
jagged gazelle
#

the arrow ain't gonna perfectly go to the location since it's a projectile and it'll hit the first pos it hit since it has collision but you get the point.

halcyon phoenix
#

it hits the same spot

jagged gazelle
#

-# I'm using the pig's head location as arrow's spawn locations.

distant tulip
#

You are using the hit location, right?

#

Not the blc location

jagged gazelle
#

the function I made to fix the face location

#

I'm kinda silly, I'll be making bouncy πŸ˜€

#

more rays... fvk.

sly valve
wary edge
#

Ts does not mean this lol.

#

πŸ’€ People are tok afraid to curse now.

final ocean
#

How to make auto inventory addon

halcyon phoenix
sly valve
fair quarry
#

Yo does someone know why the bossbar still shows "unknown" even after changing the name tag via script?

#

If i leave the world and join back, it works

#

Or maybe someone could suggest a workaround like forcing the game to update the entity

granite cape
jagged gazelle
jagged gazelle
jagged gazelle
final ocean
deep arrow
#

can i use the equippable component to set & get the mainhand item of an entity

deep arrow
sharp elbow
#

AFAIK, no

#

I thought that's what you were asking initially, haha

#

With the "minecraft:equippable" component on an entity, you can still set items with commands like /replaceitem, and read them with the 'hasitem' selector argument

#

But scripting does not really have a good way to access equipment on a mobβ€”and I suspect it won't for a while

deep arrow
#

that sucks tho, thanks for the help regarless

halcyon phoenix
vast grove
#
/**
 * @description Encodes a range of characters from a string into a byte array.
 * @param { String } s
 * @param { Number } charIndex
 * @param { Number } charCount
 * @param { ArrayBuffer } bytes
 * @param { Number } byteIndex
 * @returns { Number } The number of bytes that were successfully encoded.
 */
function getBytes(s, charIndex, charCount, bytes, byteIndex) {
  if (typeof s !== "string")
    throw new TypeError("Parameter s is not a string!");
  if (typeof charIndex !== "number")
    throw new TypeError("Parameter charIndex is not a number!");
  if (typeof charCount !== "number")
    throw new TypeError("Parameter charCount is not a number!");
  if (!(bytes instanceof ArrayBuffer))
    throw new TypeError("Parameter bytes is not an instance of ArrayBuffer!");
  if (typeof byteIndex !== "number")
    throw new TypeError("Parameter byteIndex is not a number!");
  if (s.length - charIndex < charCount)
    throw new RangeError("Argument out of range!", { cause: "s" });
  if (byteIndex > bytes.byteLength)
    throw new RangeError(
      "Byte Index must be less than or equal to bytes.byteLength!",
      { cause: "byteIndex" }
    );

  charCount = Math.min(charCount, s.length);
  let bytesEncoded = 0;
  for (let i = charIndex; i < charIndex + charCount; i++) {
    const charCode = s.charCodeAt(i);
    if (charCode <= 0x7f) {
      // 0XXX XXXX 1 byte
      bytes[byteIndex++] = charCode;
      bytesEncoded++;
    } else if (charCode <= 0x7ff) {
      // 110X XXXX 2 bytes
      bytes[byteIndex++] = 0xc0 | (charCode >> 6);
      bytes[byteIndex++] = 0x80 | (charCode & 0x3f);
      bytesEncoded += 2;
    } else if (charCode <= 0xffff) {
      // 1110 XXXX 3 bytes
      bytes[byteIndex++] = 0xe0 | (charCode >> 12);
      bytes[byteIndex++] = 0x80 | ((charCode >> 6) & 0x3f);
      bytes[byteIndex++] = 0x80 | (charCode & 0x3f);
      bytesEncoded += 3;
    }
  }

  return bytesEncoded;
}

/**
 * @description Decodes a range of bytes from a byte array into a string.
 * @param { ArrayBuffer } bytes
 * @param { Number } byteIndex
 * @param { Number } count
 * @returns { String } The decoded string.
 */
function getString(bytes, index, count) {
  if (!(bytes instanceof ArrayBuffer))
    throw new TypeError("Parameter bytes is not an instance of ArrayBuffer!");
  if (typeof index !== "number")
    throw new TypeError("Parameter index is not a number!");
  if (typeof count !== "number")
    throw new TypeError("Parameter count is not a number!");
  if (bytes.byteLength - index < count)
    throw new RangeError("Argument out of range!");

  var string = "";
  while (index < count) {
    const byte = bytes[index++];
    if ((byte & 0x80) === 0) {
      string = string.concat(String.fromCharCode(byte));
    } else if ((byte & 0xe0) == 0xc0) {
      const byte2 = bytes[index++];
      string = string.concat(String.fromCharCode(((byte & 0x1f) << 6) | (byte2 & 0x3f)));
    } else if ((byte & 0xf0) == 0xe0) {
      const byte2 = bytes[index++];
      const byte3 = bytes[index++];
      string = string.concat(
        String.fromCharCode(
          ((byte & 0x0f) << 12) | ((byte2 & 0x3f) << 6) | (byte3 & 0x3f)
        )
      );
    } else if ((byte & 0xf8) == 0xf0) {
      const byte2 = bytes[index++];
      const byte3 = bytes[index++];
      const byte4 = bytes[index++];
      string = string.concat(
        String.fromCharCode(
          ((byte & 0x0f) << 18) |
            ((byte2 & 0x3f) << 12) |
            ((byte3 & 0x3f) << 6) |
            (byte4 & 0x3f)
        )
      );
    }
  }

  return string;
}

/**
 * @description Calculates the maximum number of bytes produced by encoding the specified number of characters.
 * @param { Number } charCount
 * @returns { Number } The maximum possible number of bytes required to encode.
 */
function getMaxByteCount(charCount) {
  const num1 = charCount + 1;
  const num2 = num1 * 3;
  return num2;
}

export { getBytes, getString, getMaxByteCount };

Utf8 BABYYYY.

round bone
round bone
deep arrow
round bone
#

if you could move to TS it would take much less code

vast grove
round bone
deep arrow
deep arrow
round bone
#

Provides access to a mob's equipment slots.

#

or just write a simple script and test it on your own

vast grove
deep arrow
round bone
#
import { world, ItemStack } from "@minecraft/server"

world.afterEvents.worldLoad.subscribe(() => {
    const dimension = world.getDimension("overworld")
    const entity = dimension.spawnEntity("minecraft:zombie", {
        x: 0,
        y: 60,
        z: 0
    })

    const equippableComponent = entity.getComponent("equippable")
    if (equippableComponent) {
        equippableComponent.setEquipment("Mainhand", new ItemStack("minecraft:stick", 1))
    }
})
round bone
vast grove
round bone
#

masochist.

vast grove
#

If it was gonna be over 4k I wouldn't even bother with JS or TS at this point

deep arrow
#

hey man, if he wants to stick with JS let him be. He can code however he wants

#

typescript may have more advantadges but we cant just force it upon people

vast grove
#

wooo. some fixes and now I can encode multiple types of data into a byte array

round bone
#

TypeScript has much more benefits

#

the only worse thing is longer development time

#

but then you save this time on caching typing bugs in IDE instead on testing (in-game/Node etc.)

distant tulip
#

this conversation again

vast grove
#

Now lets hope that this is compatible with C#

halcyon phoenix
halcyon phoenix
#

I can feel that text somehow

halcyon phoenix
#

that's why I use commands to set it...

round bone
#

/replaceitem?

thorn flicker
#

yes

jagged gazelle
#

my only reaction to the previous topic: bao_comm_dead

vast grove
#

It ain't my fault

dusky flicker
#

the ram is literally a byte array

rare dawn
#

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

const frozenPlayers = new Map();

world.beforeEvents.tick.subscribe(() => {
for (const player of world.getPlayers()) {
const hasTag = player.getTags().includes("tegak");

if (hasTag) {
  const currentPos = player.location;
  const rotation = player.getRotation();

  if (!frozenPlayers.has(player.id)) {
    frozenPlayers.set(player.id, {
      pos: currentPos,
      rot: rotation
    });
  }

  const data = frozenPlayers.get(player.id);

  // Kunci posisi dan arah
  player.teleport(data.pos, {
    rotation: data.rot,
    facingLocation: null
  });

  // Hentikan gerakan
  player.velocity = { x: 0, y: 0, z: 0 };
  player.runCommand("effect @s clear");

} else {
  frozenPlayers.delete(player.id);
}

}
});

By the way, does this work?

dusky flicker
#

it could be very simpler if you could just cast data

rare dawn
dusky flicker
#

its because bro is implementinf binary serialization

rare dawn
dusky flicker
rare dawn
dusky flicker
#

programmers don't know if a code works or not just by looking at it

dusky flicker
rare dawn
vast grove
#

and well the other stuff like unsafe casting

dusky flicker
#

seriously it just sucks not being able to do lwo level stuff

distant tulip
nova flame
#

can anyone tell me why the one on the left is going up but not the one on the right

rare dawn
fast lark
#

so i have 2 questions

#

one is i can convert a string to a number bu doing parseFloat(string)?

warm mason
warm mason
fast lark
#

and second why do i get an error from this p.setDymanicProperty("money", currentMoney - amountToTransfer)
saying its not a function

fast lark
#

line 46

#

no wait

#

37

warm mason
#

dymanic ._.

fast lark
#

lmao

#

I even rewritten it twice to be sure

fast lark
#

not a function line 5

subtle cove
#

source.dAmAgInGEntity ;-;

fast lark
#

thx

prisma shard
subtle cove
#

then dont read it ;-;

fast lark
prisma shard
prisma shard
subtle cove
#

if (damager) gurad clauses

#

-# gUrAd smh

fast lark
#

wdym?

prisma shard
#

i got said you left Discord

#

and you deleted your acc

fast lark
#

i just left discord for a while

prisma shard
#

ah

fast lark
gaunt salmonBOT
prisma shard
#

hmm

tender pier
#

How can I run a cooldown when interacting with a block

distant gulch
#

someone know how to get the best piece of armor a player have on without using a lot of if?

nova flame
distant gulch
#

how do i give the player the tag "netherite" without checking every armor slot

nova flame
#

theres only 4 armor slots bro

#

also i just told u how

cyan basin
#

either way you have to scan every armor slot to know where the highest armour piece is

#

there's no avoiding that

lone mango
#

Is there a way to check if a player has "operator command" permissions?

cyan basin
open urchin
#
player.commandPermissionLevel >= CommandPermissionLevel.GameDirectors
warm mason
cyan basin
#

No

cyan basin
#

whatever

#

playerPermissionLevel returns visitor, member, op or custom

#

your choice for whatever you wanna use

warm mason
cyan basin
#

Depends on their use case

warm mason
cyan basin
#

Sure

sterile epoch
#

is there a way to test it a used item was actually a useable item in item use and not everything

jagged gazelle
rare dawn
midnight crane
warped blaze
#

like that

cyan basin
#

Does anyone here like actively use "/scoreboard" on the sidebar?

deep quiver
jagged gazelle
#

joke or not the way you said it sounds offensive.

cyan basin
# jagged gazelle y?

Cause I made this shit but it uses scoreboards.json since I still wanted to use title, subtitle, and actionbar but I was curious if people did use this if they'd be upset about it taking over scoreboards

distant tulip
cyan basin
#

I didn't realise the bossbar looked so jittery in the video rip

jagged gazelle
cyan basin
#

No.. since it uses scoreboard it's a global one

jagged gazelle
#

Yeah I forgot about that

cyan basin
#

You'd need a custom bds if you wanted it client-sided

jagged gazelle
cyan basin
#

entity has a range cap

#

even if you set the range to like 2,000,000,000 it still disappears once the entity becomes unrendered to the player

cyan basin
#

but if you're trying to display it on multiple players then what? you'd need a ton of entities

distant tulip
#

chat can be used two, with a global message

jagged gazelle
#

"two" πŸ₯€

distant tulip
#

fuck

jagged gazelle
#

I mean yeah you can...

#

It's just annoying

distant tulip
#

tow two and too get mixed in brain

cyan basin
distant tulip
#

hide them

cyan basin
#

it's still sent though..?

jagged gazelle
#

Conditional

cyan basin
#

So it doesn't cause FPS/Hardware problems on devices like mobile if it's hidden both on the hud and in the chat screen?

#

I always got told it did due to the amount of messages being sent in a given time and after so many messages are sent they still continue'd to build up

distant tulip
#

also, you can't send messages every millisecond

jagged gazelle
#

I have low end device and I don't have any lag or fps drop.

cyan basin
#

you know what i mean.. every tick :/

jagged gazelle
cyan basin
#

I guess I'll move it to that then..

distant tulip
#

the only con is that the messages that can be displayed are limited, and even if you are hiding them they still count, so other messages just get dismissed

jagged gazelle
#

Been awhile since I touched json UI... I'll be back with it I guess

true isle
#

Is their a difference creating a ui with modalformdata and json ui?

cyan basin
#

modalform is json ui

subtle cove
true isle
#

Huh. I guess i have something new to learn to use with my ui

jagged gazelle
#

I will show something stupid.

subtle cove
#

coudnt be more stupid

jagged gazelle
#

the black one is using the getBlockFromRay() while the red one is using playerInteractWithBlock().

#

The FVKIN red is placed properly in players view but the blac is offsetted.

subtle cove
#

its diff from -1 -1, -1 1, 1 1, 1 -1

jagged gazelle
#

what?

subtle cove
#

i mean the quadrants

jagged gazelle
subtle cove
#

interact, havent tested the ray tho

jagged gazelle
#

why they're fvkin different? like lmao

#

ffs

subtle cove
#

its fine as long as its not illegal ;-;

jagged gazelle
#

I can just change/adjust the function but why they're different 😭😭

#

like dude.

deep quiver
jagged gazelle
#

are you talking about the function? If yes I'm too lazy to explain.

#

idc about that rn, that's my problem rn.

deep quiver
#

you mean the message above? that you will show something stupid

#

a simple switch statement or else if chain would be better performance wise

jagged gazelle
deep quiver
#

I understand that thats not the main issue lmao

sly valve
#

hah

#

interesting

jagged gazelle
sly valve
jagged gazelle
#

-# not kidding.

sly valve
#

uhehehe~

#

who needs if or switch statements if you can have array

[
  // Button: Tower
  (player: Player) => {},
  // Button: Modules
  (player: Player) => {},
][response.selection as number]?.(player);
subtle cove
jagged gazelle
subtle cove
#
const b = e.block, f = e.faceLocation;
const loc = {
    x:b.x + f.x,
    y:b.y + f.y,
    z:b.z + f.z
}
spawnParticle(e.block.dimension, await loc)
subtle cove
#

it was in beforeevents

#

is

sly valve
#

I mean await and a vector object

jagged gazelle
#

it took me 20 mins to fix that stupid face location and discovered that face location returns different in getBlockFromRay and in playerInteractWithBlock block or other shyts

subtle cove
#

await works on any value

deep quiver
# jagged gazelle it took me 20 mins to fix that stupid face location and discovered that face loc...

just use this for the getBlockFromRay one

function fixFaceLocation(location, faceLocation, face) {
    switch (face) {
        case "Up":
            return { x: location.x + faceLocation.x, y: location.y + 1, z: location.z + faceLocation.z };
        case "Down":
            return { x: location.x + faceLocation.x, y: location.y, z: location.z + faceLocation.z };
        case "East":
            return { x: location.x + 1, y: location.y + faceLocation.y, z: location.z + faceLocation.z };
        case "West":
            return { x: location.x, y: location.y + faceLocation.y, z: location.z + faceLocation.z };
        case "North":
            return { x: location.x + faceLocation.x, y: location.y + faceLocation.y, z: location.z };
        case "South":
            return { x: location.x + faceLocation.x, y: location.y + faceLocation.y, z: location.z + 1 };
    }
}
sly valve
subtle cove
#

cus spawnParticle

jagged gazelle
sly valve
deep quiver
subtle cove
#

same as runCommand(await "say hello neko")

sly valve
#

Im scared of M9

#

please never code big softwares

subtle cove
#

idk

sly valve
#

But good to know

subtle cove
#

typescript would scream its illegal, but it works just fine, lmao

jagged gazelle
sly valve
deep quiver
#

use runCommand

sly valve
#

wait.. i just forgot to install the right npm

deep quiver
#

they removed runCommandAsync in the latest versions

sly valve
#

I know

#

I never use runCommand tho

subtle cove
#

JSON.stringify, but w/o the " on property_key

subtle cove
#

i could only suggest con's

sly valve
subtle cove
#

cant find it atm, unfortunately
-# altho i have le code

deep arrow
midnight crane
warped blaze
jagged gazelle
halcyon phoenix
#

nice

jagged gazelle
#

I just realized my aim is so bad. I'm not good at fps games bruv

halcyon phoenix
#

wat was the issue yesterday all about then?

jagged gazelle
halcyon phoenix
subtle cove
#

it doesnt have the prototype chaining map tho ;-;
'twas just old dumps

jagged gazelle
#

-# I forgot the actual spelling...

subtle cove
#

I even got to the point where human palm patterns got almost mimic'd ||accidentally||

oblique mica
#

Is there a website that list all the world events like after events and before events

halcyon phoenix
fickle dagger
#

it's possible to make more than one parameters for scriptevent, right?

rustic ermine
#

wrong place but the Bridge discord is pretty dead and it isn't a "must know now" issue.. anyone know if there is hotkey combo for multi-line JSDoc in Bridge?

edit: nvm, should have assumed since pretty sure the backend is the same. it's shift + alt + a just like vscode

#

working on probably the most essential feature and in my opinion the most fun for my project... the banking system from runescape 2007. not using dyn properties so have to do a backend server. already have a prototype made in Go but probably going to swap to Deno so I can share the database cache structure

distant tulip
distant tulip
rustic ermine
#
    /**
     * Calculates the sum of two numbers.
     * @param {number} a The first number.
     * @param {number} b The second number.
     * @returns {number} The sum of a and b.
     */
rustic ermine
#

sigh lol was hoping I could get away with functions on prototypes, but guess not

#

no ```ts
skill_level: {
value: function (skill: string) {
return this[skill] as number
}
}

prisma shard
#

waht the heck

rustic ermine
#

because I want to clean up this stuff

export function getPlayerSkillLevel(player: Player, skill: string) {
    return player[skill] as number
}

and be able to do just
player.skill_level(skill)

rustic ermine
#

that was prototype

Object.defineProperties(Player.prototype, {
    blockICD_c: {
        value: Date.now(),
        writable: true,
    },
    can_interact: {
        get() {
            if (this.blockICD_c > Date.now()) { return false; }
            this.blockICD_c = Date.now() + 1000;
            return true;
        }
    },
    skill_level: {
        value: function (skill: string) {
            return this[skill] as number
        }
    }
})
#

oh i'm dumb.

Player.prototype.skill_level = function (skill: string) { return this[skill] as number }

still new to js/ts

#

ahh.. nope. still undefined πŸ˜΅β€πŸ’«

subtle cove
#

thats getting, where's assigning?

rustic ermine
#
declare module "@minecraft/server" {
    interface Player {
        can_interact: boolean;
        skill_level(skill: string): number;
    }
}
subtle cove
#

do u assign the skill anywhere?

rustic ermine
#

yeah. it works otherwise, just trying to get the idea of
player.skill_level(skill) working. I have a different regular function that works fine

#

but it is specifically saying that
skill_level is not defined

subtle cove
rustic ermine
#

yes. can_interact works in the same function i'm trying to use skill_level from

#
    if (!event.player.can_interact) { return; }
    const player = event.player

    const mainhand: ItemStack = getPlayerMainHand(player)
    const block = block_component?.params as RegenerativeBlockProperties
    if (!mainhand?.hasTag(block.required_tool_tag)) { return; }

    const tool = mainhand.getComponent('grb:tool')?.customComponentParameters.params as ToolProperties

    if (
        player.getProperty(tool.use_animation) ||
        !tool ||
        !checkToolRequirements(player, mainhand.typeId, tool)
    ) { return; }

    // const skill_level = getPlayerSkillLevel(player, block.required_level[0])
    if (!(player.skill_level(block.required_level[0]) >= block.required_level[1])) { return; }
subtle cove
#

make a post for it
i cant help further atm

rustic ermine
#

no problem

#

oh ffs I'm dumb. I think it was fine the entire time. I just missed the fact that I was using the skill_level const a bit further down. lol

#

tunnel vision is a pita.

prisma shard
#

math related question but what would be the value of Alpha[Ξ±] in Cartesian coordinates?

#

felt like asking here instead of off-topic since we got math experts here xD

granite badger
#

depending on what the equation is

prisma shard
halcyon phoenix
prisma shard
halcyon phoenix
prisma shard
#

b rhurhurhhrr
i peek my friends exam papers in my math exam πŸ’€
and they told me the alpha value is -1 πŸ’€

#

probs gonnna fail the exam bru

cursive fog
#

@jagged gazelle sorry for ping but where do i add the variable part?

jagged gazelle
#

Not screenshot

cursive fog
#

Ok

cursive fog
# jagged gazelle Send your script but in text form.
import { world } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"

system.run(() => {
  const ui = new ActionFormData()
    .title("Form")
    .body("")
    .button("Button1")
    .button("Button2")
    .button("Button3");

  const customUi = new ActionFormData()
    .title("Custom Form")
    .body("")
    .button("Button1")
    .button("Button2")
    .button("Skibidi");

  world.afterEvents.itemUse.subscribe((event => {
    const { source, itemStack } = event
    switch (itemStack.typeId) {
      case "ssia:attachment": customUi.show(source); break;
    }
  }))
})
cursive fog
#

Uhhh wymπŸ’€

#

Am i cooked beyond measuresπŸ’”

safe stream
#

Did they change onPlayerDestroy in v2? It's not being triggered at all

jagged gazelle
fickle dagger
cursive fog
cursive fog
jagged gazelle
cursive fog
#

Ohh i see

cursive fog
#

Ohh i see nvm

#

Sorry

safe stream
#

only world before requires system.run (inside the scope) because it needs permission

jagged gazelle
safe stream
#
const BlockComponentHandler = {
    onPlace({ block, dimension }) {
        const above = block.location
        above.y += 1
        const b = dimension.getBlock(above)
        if (b && REPLACEABLE_BLOCK.includes(b.typeId)) {
            dimension.runCommand(`setblock ${above.x} ${above.y} ${above.z} ...`)
        } else dimension.runCommand(`setblock ${block.location.x} ${block.location.y} ${block.location.z} air destroy`)
    },
    onPlayerDestroy({ block, dimension }) {
        const above = block.location
        above.y += 1
        const b = dimension.getBlock(above)
        if (b && b.typeId === '...') {
            dimension.runCommand(`setblock ${above.x} ${above.y} ${above.z} air destroy`)
        }
    }
}```
jagged gazelle
safe stream
#

ight

jagged gazelle
safe stream
#

oh

#

tyy!!

cursive fog
#

Ight this should work-

jagged gazelle
fickle dagger
#

and how come do I not see it in suggestions?

sly valve
fickle dagger
#

oh, guess that means I haven't updated mine then

cursive fog
#

It should look like this

sly valve
jagged gazelle
cursive fog
#

Coddy sent the message before i booted mc

jagged gazelle
#

muscle memory to look for syntax error lol

cursive fog
cursive fog
jagged gazelle
#

should be. If it was not, I'm gay.

cursive fog
#

I thought the // parts are in the code

sly valve
sly valve
cursive fog
fickle dagger
sly valve
fickle dagger
#

oooohh that's why

sly valve
#

Good Indonesian

#

I gotta go, cya

fickle dagger
#

see ya, thanks

cursive fog
#

AAAAAAAAAAA

#

@jagged gazelle you WINNN

#

WWWWW

jagged gazelle
jagged gazelle
fickle dagger
#

guess that means I need to use something else

cursive fog
#

Gn chat✌️

safe stream
#

oh they renamed it to onPlayerBreak interesting

north frigate
#

it's been a while since I tried bridge hmmm

safe stream
#

It's pretty good

#

their script API autofill is a bit lacking tho and outdated in some areas

sly valve
#

Hello

#

How are you all

alpine wigeon
#

how do i get the player and equipment and itemStack from world.beforeEvents.playerBreakBlock

#

@minecraft/server v 1.17.0

#

can you get source from this event

sly valve
alpine wigeon
#

oh i was trying to use source

#

which is not defined

#

it's actually player

#

do you know how to check the player's gamemode?

sly valve
alpine wigeon
#

ok ty

#

it works

#

i just made bedrock mineable with a special pickaxe

#

otherwise event.cancel=true

buoyant canopy
#

How to rotate a structure by 90 degrees vertically

#

world.structureManager.place() can only rotate around the y axis

warm mason
#

I have an idea though...

#

Ah.. no.. I don't have an idea.

honest spear
#

Each of you guys! Tell me what are you all warking on?

honest spear
#

nice

#

on nodeJS?

#

or connected to addons

warm mason
warm mason
buoyant canopy
# warm mason Make a custom rotation function

I have spent hours yesterday trying to come up with a way to do this, i remembered that the structure manager exists this morning, but it turns out that it only works horizontally, so am back to square one

honest spear
warm mason
honest spear
#

DiscordJS is heavy as hell

#

i don't like it so i made own one

warm mason
warm mason
# buoyant canopy I have spent hours yesterday trying to come up with a way to do this, i remember...
await f.runJob(f.Geo.mcCube(f.Offset.none[0], f.sumObjects(structure.size, { x: -1, y: -1, z: -1 })), (location => {
        let permutation = structure.getBlockPermutation(location);
        if (permutation == undefined) return;

        if (options.rotation) {
          location = f.sumObjects(location, bottomCenter, -1)
          if (options.rotation == 180) {
            location.x = -location.x
            location.z = -location.z
          } else if (options.rotation == 90) {
            let oldLoc = { x: location.x }
            location.x = -location.z
            location.z = oldLoc.x
          } else if (options.rotation == 270) {
            let oldLoc = { x: location.x }
            location.x = location.z
            location.z = -oldLoc.x
          }

          permutation = rotateDirection(permutation, options.rotation)

          location = f.sumObjects(location, bottomCenter)
        }
        location = f.sumObjects(location, offset);

        locations.push(f.sumObjects(location, this.location));
        permutations[ID(location)] = permutation;
      }));

This is a snippet of my code that rotates a structure as structureManager, you can use this as an example to do Y rotation I think

warm mason
honest spear
# warm mason What about you?

nothing special, i finally done one of my projects so now i have more time, but there are still many to go, i released npm package for NBT serilization, its the fastest NBT package written in JS/TS and its Web compatible so its pretty nice, now i am working on some kind of tools, but i am a bit overworked rn so its hard to focus

buoyant canopy
buoyant canopy
prisma shard
honest spear
buoyant canopy
# warm mason

i know, i meant the important logic that does the magic is missing

#

rhyme unintended

honest spear
warm mason
buoyant canopy
#

do you do this for all the blocks in the structure using a loop or something

buoyant canopy
#

my brain is spinning πŸ˜‚

#

when you multiply the block x position by -1 for example, doesn't that mirror it on the x axis?

buoyant canopy
alpine wigeon
#

bro whats up with the eyes

#

i am being watched

#

oh yeah that's way better

#

πŸ™„

spark kayak
#

funfact: I forwarded that by accident, there's also #1256780864529105008 message whic was the opitmized pretty much instant version

#

(which is also why I'm replying to this so late)

untold magnet
lone mango
#

Does the scripting API have a function to create a block at a coordinate, or will I need to use the /setblock command?

lone mango
#

Can be rather difficult to find things in their documentation at times.

cinder shadow
#

Knowing where to look for things in the documentation is an learned skill πŸ˜” took me a few months and even after a few years I still can't find things sometimes

lone mango
#

I swear to god I am going to jump off a bridge at this point.
This USED TO WORK LIKE 15 MINUTES AGO:

world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
    // Block Components
    blockComponentRegistry.registerCustomComponent("shadowmavks:sit", component_sit);
    
    blockComponentRegistry.registerCustomComponent("shadowmavks:drawer", component_drawer);
    blockComponentRegistry.registerCustomComponent("shadowmavks:bedside_drawer", component_bedside_drawer);
    
    blockComponentRegistry.registerCustomComponent("shadowmavks:zone_block", component_zone_block);
});

Now I get this BS

#

deleted all my changes to my script

#

and it's still doing it

#

I have import { world, system } from "@minecraft/server";
At the top of my script

subtle cove
lone mango
#

They changed the API?

cursive fog
subtle cove
#

yuh

lone mango
#

but that doesn't explain why it worked a few minutes ago

#

I've had the @minecraft/server module set to 2.0.0 for a few days

subtle cove
#

welcome to experimental...

lone mango
#

and as far as I know, my minecraft version didn't change

wary edge
lone mango
#

so... is the javascript for the modding API on the cloud and subject to separate updates or something?

subtle cove
subtle cove
#

now its removed

lone mango
#

First I'm hearing about it

#

Removed since 15 minutes ago?

subtle cove
#

duno bout that

lone mango
#

I'm just baffled.

#

like it just magically stopped working

#

no change on my part, and as far as I'm aware minecraft didn't auto-update

#

anyway, switched it over

#

to the new syntax

lone mango
#

Now I'm getting removeTag doesn't have required privileges...

subtle cove
#

now we learn patience but in code

#

-# but in minecraft

lone mango
#

Minecraft Bedrock modding is by far the most frustrating modding experience of my 20+ years of modding games.

#

if this is what Mojang has to deal with in development (if their backend is anything like this), no wonder progress is glacial.

granite badger
lone mango
#

Now how the hell do I get removeTag working again?

#
const component_zone_block = {
    beforeOnPlayerPlace(event) {
        const pos = event.block.location;

        const canZone = event.player.hasTag("perm_zoning");
        const isZoning = event.player.hasTag("isZoning");

        if(!canZone)
        {
            event.player.sendMessage({ rawtext: [{ text: "Β§cYou don't have zoning permissions!" }] });
            event.cancel = true;
            return;
        }
        
        if(!isZoning)
        {
            event.player.addTag("isZoning");
            event.player.setDynamicProperty("zonesetup_pos1", pos.x + "," + pos.y + "," + pos.z);

            event.player.sendMessage({ rawtext: [{ text: "Β§aFirst zone block placed by Β§f" + event.player.name + "Β§a at Β§f" + event.player.getDynamicProperty("zonesetup_pos1") + " Β§a(Β§f" + event.dimension.id + "Β§a)" }] });
        }
        else
        {
            event.player.removeTag("isZoning");
            event.player.setDynamicProperty("zonesetup_pos2", pos.x + "," + pos.y + "," + pos.z);

            event.player.sendMessage({ rawtext: [{ text: "Β§aSecond zone block placed by Β§f" + event.player.name + "Β§a at Β§f" + event.player.getDynamicProperty("zonesetup_pos2") + " Β§a(Β§f" + event.dimension.id + "Β§a)" }] });

            const pos1Array = event.player.getDynamicProperty("zonesetup_pos1").split(",").map(parseInt);
            const pos2Array = event.player.getDynamicProperty("zonesetup_pos2").split(",").map(parseInt);
            const pos1 = { x:pos1Array[0], y:pos1Array[1], z:pos1Array[2] };
            const pos2 = { x:pos2Array[0], y:pos2Array[1], z:pos2Array[2] };

            let zoneForm = new ModalFormData();
            zoneForm.title("Zone Configuration");
            zoneForm.textField("Zone ID", "Type the name of your zone here.");
            zoneForm.textField("Trust Tag", "Type name of a tag trusted users must have.");
            zoneForm.dropdown("Music", musicOptions);
            zoneForm.toggle("Teleport Untrusted Players", false);
            zoneForm.toggle("Kill Hostile Mobs (and prevent spawn)", false);

            zoneForm.show(event.source).then(r => {
                // This will stop the code when the player closes the form
                if (r.canceled)
                {
                    event.dimension.setBlockType(pos1, "minecraft:stone");
                    return;
                }
            
                // The code when the player responds to the form
            }).catch(e => {
                console.error(e, e.stack);
            });
        }
    },
};
#

WIP, subject to cleanup in the future, try not to judge the code too much. If you're wondering why it's setting and getting the dynamic property again, it's just for testing to make sure the data is structured the way I want for later. Not final.

#

It just doesn't make any sense

granite badger
lone mango
#

OK, got it working again.

#

Thanks

#

That should be on bedrock.dev if it isn't already

tender pier
#

How can I make a block break when the isn't a block above it

#

like a lantern

jagged gazelle
tender pier
jagged gazelle
sly valve
#
// MARK: UI Forms
const UIForms = {
  openShopUi: function (player: Player): void {
    const form = new ActionFormData()
      .title('Shop')
      .body('Welcome to the Shop!')
      .body('Tower')
      .body('Modules');

    // @ts-ignore
    form.show(player).then((response) => {
      if (response.canceled) return;
      const selection = response.selection as number;

      if ([
        // playerBuy(item: string, player: Player, money: number, times: number = 1): boolean
        PRICES.tower.playerBuy.bind(null, "Tower"),
        PRICES.module.playerBuy.bind(null, "Module"),
      ][selection]?.(player, GameResources.money, 1)) {
        switch (selection) {
          case 0:
            break;
          case 1:
            break;
        }
      }
    });
  },
};

Is this overcomplicated/overengineered guys?

jagged gazelle
# sly valve ```ts // MARK: UI Forms const UIForms = { openShopUi: function (player: Player...
const UIForms = {
  openShopUi: function (player: Player): void {
    const form = new ActionFormData().title('').body('');

    form.show(player).then((response) => {
      if (response.canceled) return;
      
      const selection = response.selection as number;
      const itemType = selection === 0 ? 'Tower' : 'Module';
      const priceList = selection === 0 ? PRICES.tower : PRICES.module;
      
      priceList.playerBuy(itemType, player, GameResources.money, 1);
    })
  }
};```
#

-# coddyxbox

sly valve
#

I appreciate it

#

My dear

jagged gazelle
vast grove
#

hmmm

jagged gazelle
sly valve
#

Yep right

jagged gazelle
#

-# do that if you're obfuscating your code lol

sly valve
subtle cove
#

hmm

subtle cove
#
Array.prototype.with
```kewl
lone mango
#

Any way to load far away chunks, or are we screwed in that regard? Chunkloader doesn't work anymore.

inland merlin
pliant breach
#

system.runInterval(() => {
for (const player of world.getPlayers()) {
const vars = new MolangVariableMap();
const lastSwing = swingState.get(player.id);
const isSwinging =
lastSwing && Date.now() - lastSwing <= SWING_DURATION_MS;

    vars.setFloat("variable.custom_swinging", isSwinging ? 1.0 : 0.0);
}

}, 1);

#

Can i make a new variable use for my 3d tool using this MolangVariableMap

distant gulch
#
    { id: "minecraft:netherite_ingot", value: 50000 },
    { id: "minecraft:diamond", value: 10000 },
    { id: "minecraft:gold_ingot", value: 1000 },
    { id: "minecraft:iron_ingot", value: 100 },
    { id: "minecraft:gold_nugget", value: 10 },
    { id: "minecraft:iron_nugget", value: 1 }
];
```{ id: string; value: number; } There's an error in this part, but I don't know how to fix it. Is there a way?
warped blaze
#

do y'all know if successCount in CommandResult works for testing item data?

#

the one u assign In give commands

#

/give @s clock 1 >>3<< this

unreal cove
#

Not anymore iirc

warped blaze
#

damn

#

I didn't even need to use it, I was just curious abt it lol

jagged gazelle
distant gulch
round bone
distant gulch
#

"[Scripting][Error]-Plugin [My Addon Name - 1.0.0] - using unsupported runtime []." An error occurs. I used TypeScript. What is the cause

subtle cove
subtle cove
#

u gota compile ur ts files to js

distant gulch
#

how?

subtle cove
#

that, idk ;-;

round bone
rustic ermine
#

Change it from typescript to javascript. The engine does not run typescript files, only the files generated by it

oak lynx
cyan basin
#

I always wondered why they have the "language" there in the manifest

#

you don't need it in your pack for javascript to work and no other language seems to be supported

prisma shard
#

makes sense

deft nest
#
[Scripting][error]-ReferenceError: Native function [ActionFormData::show] does not have required privileges.    at show (extensions/forms.js:62)
    at showBiomeList (database.js:160)
    at <anonymous> (source.js:60)


[Scripting][error]-ReferenceError: Native function [ActionFormData::show] does not have required privileges.    at show (extensions/forms.js:62)
    at showBiomeList (database.js:160)
    at <anonymous> (source.js:60)


[Scripting][error]-ReferenceError: Native function [ActionFormData::show] does not have required privileges.    at show (extensions/forms.js:62)
    at showBiomeList (database.js:160)
    at <anonymous> (source.js:60)


[Scripting][error]-ReferenceError: Native function [ActionFormData::show] does not have required privileges.    at show (extensions/forms.js:62)
    at showBiomeList (database.js:160)
    at <anonymous> (source.js:60)```
What do you think is the source of the problem? Give a brief answer.
floral timber
#

system.run(() => /*show your form here*/)

cursive fog
#

Guys

#

How do i add functions or command on my json ui buttons?

cursive fog
halcyon phoenix
hazy copper
#

πŸ˜­πŸ™πŸ»

cursive fog
hazy copper
#

😭

cursive fog
hazy copper
#

It's in the scr*pt itself used for the menu

#

That's all I know 😭

cursive fog
hazy copper
#

Give me a min to pull another pack up (I can't explain it off memory)

#

Gg

#

I have no clue

#

But it's in the scr*pt πŸ€·πŸΌβ€β™€οΈ

cursive fog
#

I dont wanna bother people so ima ping them tmmrwπŸ’”

cyan basin
#
import { world } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";

world.afterEvents.itemUse.subscribe((data) => {
  const { itemStack: item, source: player } = data;

  if (item.typeId !== "minecraft:compass") return;

  const form = new ActionFormData();

  form.title("Title");
  form.body("Body");
  form.button("Button", "textures/items/apple");
  form.divider();
  form.header("Header");
  form.label("Label");
  form.show(player).then((response) => {
    const { canceled, selection } = response;

    if (canceled) return;

    switch (selection) {
      case 0:
        console.warn("Clicked button");
        break;
    }
  });
});
#

That's got everything in a form

#

For actionform anyway

#

@cursive fog

cursive fog
cyan basin
#

You can make it wherever..

#

Wherever your form is

cursive fog
#

Ohh so just add form

cyan basin
#

Why do you have the form in a world load?

cursive fog
cyan basin
#

I guess it's one way of doing it dviperShrug

cursive fog
#

Im new to this

cyan basin
#

but yeah you just need to do .then on the customUi.show(source)

cursive fog
cyan basin
#
import { world } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";

let customUi;

world.afterEvents.worldLoad.subscribe(() => {
  customUi = new ActionFormData()
    .title("Skibidi")
    .body("")
    .button("Skibidi Dom Ye Ye");
});

world.afterEvents.itemUse.subscribe(({ itemStack, source }) => {
  switch (itemStack.typeId) {
    case "ssia:attachment":
      customUi.show(source).then(({ canceled, selection }) => {
        if (canceled) return;

        switch (selection) {
          case 0:
            source.sendMessage("Click!");
            break;
        }
      });
      break;
  }
});
cursive fog
#

Ohh ok

cursive fog
cyan basin
#

everything after show(source).then...

#

it looks for the button selection

cursive fog
#

Okie

jagged gazelle
#

Uhmm.. Nvm-

cursive fog
#

Is this allowed btw

halcyon phoenix
#

never seen that before

#

switch
case
if
switch
case

cursive fog
halcyon phoenix
cursive fog
#

Well atleast we are tryingπŸ’”

halcyon phoenix
#

make them explain to you what's going on

halcyon phoenix
warm mason
cursive fog
subtle cove
#

switch case needs breaks

cursive fog
cursive fog
warm mason
warm mason
#

I would just use if

cursive fog
#

You wont believe what i did worst on Anim controllersπŸ’”

cursive fog
subtle cove
cursive fog
#

This one?

warm mason
cursive fog
#

Ill try re writing this yandev slopπŸ’€

subtle cove
#

i once used it like a filter kinda like door knob where key is used
it keeps going, unless sth isnt supposed to

#

but yeh, if/else is still the better practice

#

||```js
{{{{{{{{{{{{{{{{await "neko"}}}}}}}}}}}}}}}}

halcyon phoenix
#

also that's doable with if conditions

cursive fog
#

I removed it to add this new line

halcyon phoenix
#

I see

#

also try to be consistent you're using switches then if then switches why not just all if conditions?

sly valve
#

Well, I always wanted some attention, so im fine with it

sly valve
cursive fog
sly valve
sly valve
#

Or deepseek, grok, copilot

cursive fog
#

Json ui so bad it cant be considered one

#

Oh well i started off too with a snowball launching item

#

I guess thats my copium for now

jagged gazelle
sly valve
jagged gazelle
#

I meant the programming side other than that then meh...

sly valve
jagged gazelle
#

here we go with great helper.

#

Let's don't talk about it anymore.

sly valve
distant tulip
#

Math and AI, recipe for weeks of debugging

sly valve
distant tulip
#

Good for you

distant gulch
#

how can i detect if someone uses a water bucket

#

or if someone spawn an entity with an egg

#

etc

cinder shadow
#

Is anyone else unable to throw items out of a bundle if they have an itemUse event?

cinder shadow
#

the before event?

#

should have specified

distant gulch
#

oh okay

#

let me try

distant gulch
cinder shadow
#

πŸ˜” dayum

cyan basin
#

Happened while trying to install latest preview modules.. anyone know why this happened or just a bug with the modules that were released?

tender pier
#

how can I make my block not connect to blocks like grass

#

i was trying this method but it doesn't really works

warm mason
#

And you also forgot to add minecraft prefix, and spaces in block IDs are not used

sly valve
#

-# looks like he switched from python to JS

tender pier
unreal geyser
#

Is β€œDisk” an option in structure manager structure save mode? I’m having a issue with saved structures β€œdisappearing” even tho the save mode I have for them is set to β€œWorld”

#

I don’t see it in the documentation but I thought I’d ask here

#

Or if someone has a solution

The structures seem to persist for a while and then β€œdisappear” I don’t know the exact time frame they disappear from

little cedar
#

Is this even the right place to ask

thorn flicker
#

no.

#

#1067869590400544869

little cedar
#

Ok mb

tender pier
#

can someone help me with this? I can't make it work only with raytracing mode

jagged gazelle
steep hamlet
#

Does anybody happen to know why with these options it doesn't detect anything?
getEntitiesFromRay

ignoreBlockCollision: false;
includeLiquidBlocks: false;
includePassableBlocks: false;
#

i want the ray to pass through nonfull blocks and liquids only

warped blaze
#

passable blocks are grass, flowers, vines, etc

#

blocks such as fences, slabs, stairs, etc aren't full blocks but are detected if the ray reaches their hitbox

warped blaze
steep hamlet
#

oh i get it

steep hamlet
#

thanks though

warped blaze
#

β€’ Added methods to Dimension scripting API that allows creators to get the total light level and the sky light level at a specific position
nice

thorn flicker
#

I missed that

#

they didnt mention what the methods are called but you can guess it easily.

#
dimension.getLightLevel()
dimension.getSkyLightLevel()
#

really cool.

tepid fjord
tepid fjord
warped blaze
#

they're getting lazier

#

adding two extra lines was too much work

thorn flicker
#

I didnt guess the name, I used objects.keys(Dimension.prototype)

vast grove
#

Custom session protocol. I can get addons to communicate to remote applications using MCWSS.

vast grove
#

What the hell is this....

#handleUpdate() {
    if (!this.isConnected) return;
    if (Date.now() - this.#_lastPing > 5000) {
      this.disconnect();
      return;
    }
    const pingPacket = new PingPacket(this.#_sessionToken);
    this.sendPacket(pingPacket);
  }
export default class VoiceCraft {
  /** @type { Boolean } */
  get isConnected() {
    return this.#_source !== undefined && this.#_sessionToken !== undefined;
  }

  //Connection state objects.
  /** @type { Player | undefined } */
  #_source = undefined;
  /** @type { String | undefined } */
  #_sessionToken = undefined;
  /** @type { NetDataWriter } */
  #_writer = new NetDataWriter();
  /** @type { NetDataReader } */
  #_reader = new NetDataReader();
  /** @type { Number } */
  #_lastPing = 0;

  constructor() {
    system.runInterval(this.#handleUpdate, 20);
    system.afterEvents.scriptEventReceive.subscribe((e) => {
      switch (e.id) {
        case "vc:mcapi":
          this.#handleMcApiEvent(e.sourceEntity, e.message);
          break;
      }
    });
  }
...
#

k. weird thing... fixed it anyways

vast grove
#

fixed it anyways

cursive fog
#

How do i make a function (on scripts) trigger a command

chilly fractal
#

simple

cursive fog
#

Like should i just put function my stuff on function folder?

chilly fractal
#
function yourFunction(source) {
  source.runCommand('say hi');
}

// usage:
// yourFunction(<some source, like a dimension or an entity>)```
chilly fractal
chilly fractal
#

which in this case is player.

cursive fog
#

@chilly fractal one last can i replace the ('say hi') command with a mcfunction?

distant gulch
#

Is there a way to encrypt a script?

halcyon phoenix
distant gulch
cursive fog
chilly fractal
halcyon phoenix
chilly fractal
halcyon phoenix
#

or ask AI

#

there are lots of ways to encrypt/obfuscate it but it will stil be undoable

chilly fractal
#

?

#

it is doable tho?

halcyon phoenix
#

wait

chilly fractal
#

am i missing something or..?

halcyon phoenix
chilly fractal
#

yeah

#

you can obfuscate your script api code and run it fine

#

it's never really truely secure because anyone with dedication and hard time can deobfuscate it of course.

halcyon phoenix
#

yeah

chilly fractal
halcyon phoenix
halcyon phoenix
chilly fractal
#

yeah

halcyon phoenix
#

it's stilil pickable but at least normies won't be able to access it

vast grove
#

Problem with obfuscation is it may decrease performance

#

You're making the code less readable at the cost of the computer having to run the obfuscated code

chilly fractal