#Script API General

1 messages · Page 76 of 1

fathom hemlock
#
    msg.sender.sendMessage("You wrote: ");
});
#

why sendMessage not found?

lyric kestrel
#

You probably need to define it as a const, then declare it in a system.run block

#
 easy.normal.beforeEvents.chat(e => {
   const message = e.player.sendMessage("You wrote: " + e.message);
   system.run(()=>{
      message;
});

  });```
#

Try that

fathom hemlock
#

chat: cb => world.beforeEvents.chatSend.subscribe(e => cb(wrapEvent(e)))

#
  const basePlayer = e.source ?? e.sender ?? e.player ?? e.entity;
  return {
    ...e,
    player: wrapPlayer(basePlayer),
    item: e.itemStack?.typeId ?? e.item?.typeId ?? undefined,
    raw: e
  };
}```
warm mason
fathom hemlock
dim tusk
#

I think it's the library itself

#

Since if it throws an error not a function when you did system.run() then you did something wrong inside of lib.

dusky flicker
#

i am having the same issue, the best thing i can think of is to pass the js code minified and compressed(yeah, first minify the js then compress it) using lzstring, and i dont know if dynamic properties on items or entities would solve, but to bypass the max of 2048 chars of scriptevent, the best thing i thought was saving data in the lore of an item specific for that

dusky flicker
#

I've been coding other projects than addons so did not test it

dim tusk
dusky flicker
dim tusk
#

dynamic property is made for storage and why not use it?

dusky flicker
#

addons are sandboxed

#

in my head an addon dont have acces to dynamic properties of an item set by another addon

#

i gotta test it

dim tusk
#

tho, same as lore... You can't check the lore of an item in molang or any commands.

dusky flicker
#

imma test it tomorrow with both solutions

#

and see if some work

dim tusk
#

I can't really give ideas since I don't know the context or what you are doing in the first place.

dusky flicker
#

pass objects(classes instances) from one addon to another

#

the library one in case

dim tusk
#

Or name tag...

#

And for scoreboards, you get how binary works?

dusky flicker
#

yeah

#

i program in rust normally

#

i goota understand it

gray tinsel
#

Is there just a general event for when a block is broken?

#

As I need to detect when a custom crop block is broken and drop different loot depending on how it broke

dim tusk
#

otherwise you detect the crop you placed, store the location of the to be accessed by runtInterval then so on tho not really accurate

gray tinsel
gray tinsel
#

Yeah if I want to maintain the same way vanilla crop do drops

snow jungle
#

Is it possible to load a chunk/aside from keeping a chunk loaded, is it possible to actually load one?

gray tinsel
dim tusk
gray tinsel
# dim tusk hey, what type of breaking do you actually need?

I pretty much was trying to replicate the vanilla crop system drops based of this https://minecraft.wiki/w/Fortune#Seeds which lead to me trying to recreate it in scripting as having to make a loot table to account for all the fortune would be a pain, but I was able to solve this though by making the base drops drop from a loot table while the fortune drops are handled in the playerBreakBlockEvent, so was able to solve it

Minecraft Wiki

Fortune is an enchantment applied to mining and digging tools that increases the number and/or chances of specific item drops. It does not increase experience drops.

agile flicker
#
inputInfo.getButtonState('Jump');

Is this still in beta?

distant gulch
#

WAIT IT WAS STATIC

#

@random flint Thanks for saying that, i did not see it, I love you

dim tusk
thorn flicker
#

its not

chrome gyro
#

Are there any easy ways like a command that can trigger a modal menu to open. Or is it pretty much just methods like: check if an entity or player has a tag/family/property and if they do then open the modal?

distant gulch
chrome gyro
distant gulch
chrome gyro
chrome gyro
#

Perfect, it has the itemStack built in. Awesome.

distant gulch
#

yep

distant gulch
chrome gyro
distant gulch
loud frigate
#

Hey I've tried this and while it does work in third person (albeit a bit jittery at the beginning because I likely have some animation params wrong), it doesn't seem to work in first person

dim tusk
#

Because first person and third person animation of attack is way different, and has animation patterns...

loud frigate
#

So there's another one that can be used in first person?

#

Did anybody figure out an animation pattern values?

chrome gyro
#
world.afterEvents.playerInteractWithEntity.subscribe((eventData) => {
    const { player, target, itemStack } = eventData;
    if (!itemStack) return;
    if (itemStack.typeId === 'cnb:cnb_ppl_gui') {
        new Menu();
        const targetnametag = target.nameTag
        if (player.hasTag('listener')) player.sendMessage(`${targetnametag}`);
        const newtarget = oldencodeString(target.nameTag)
        manageemitteritem(player, newtarget)
    }
});

Hmm I'm using an item to open a menu:
when used on air and also when used on an entity. Each opens a different menu

The problem is, when I open the menu from interacting with the entity it opens the regular menu after I try to click on any buttons in it.

I hope this makes sense, I can make a video if needed.

#

Is there any way to force a menu to close that's opened in the background?

chrome gyro
#

This is the code that opens from the item use in general:

world.beforeEvents.worldInitialize.subscribe((initEvent) => {
    initEvent.itemComponentRegistry.registerCustomComponent("cnb:cnb_ppl_gui", new Menu());
});```
#

Essentially it's opening both menus. And I need to prevent the MainMenu The one just mentioned from opening.

dim tusk
warm mason
#

😵‍💫

dim tusk
chrome gyro
#

Like another api that does that?

chrome gyro
#
interactWithEntity(entity: Entity)

I feel like there's a way to use this? Like, if the player is interacting with the entity then don't open the other menu?

warm mason
#
const ITEM_ID = 'cnb:cnb_ppl_gui'
world.afterEvents.playerInteractWithEntity.subscribe(data => {
  const { player, target, itemStack } = data;
  if (itemStack == undefined || itemStack.typeId != ITEM_ID) return;
  // Code to open menu with entity
})

world.afterEvents.itemUse.subscribe(data => {
  const { source, itemStack } = data;
  if (itemStack.typeId != ITEM_ID) return;
  system.runTimeout(() => {
    //Code to open menu without entity
  }, 2)
})
#

In theory this should work.

dim tusk
#

How about running command part? Not just form.

dim tusk
# warm mason ?

The thing is, the itemUse one still triggers even interacting with entity especially running not just forms

#

In my part it still does, idk yours

warm mason
dim tusk
#

yeah for forms yes I know that but how about non forms

#

That's what I asked lol

warm mason
chrome gyro
#

Hmmm It's doing something weird and opening three menus now. I'll have to check it more thoroughly tomorrow, thank you both for looking into this though!

fathom hemlock
chrome gyro
chrome gyro
round bone
#

it's already permutation of a Block

#

just block.getAllStates() I think

#

block in Osuea's code is a BlockPermutation instance

dim tusk
round bone
#
// block: BlockPermutation
const block = data.brokenBlockPermutation
round bone
#

xD

#

I just opened this chat

dim tusk
#

-# I'm sorry, I'm so fuckin sorry.

round bone
#

such a nice apology, short and in the topic

dim tusk
round bone
#

that's what I am responding to

dim tusk
round bone
#

what the-

#

this is another level of cyberbullying xD

dusky flicker
#

bros got no one and now is in need to find someone across the internet

dim tusk
#

idc if it's a man, woman, alien, animal.

#

I won't die alone,

dusky flicker
#

xd

prisma shard
#

lmao

round bone
#

😳

dim tusk
#

That's fuckin disgusting

#

i like old, like 5000 years old age gap

#

Lol

round bone
#

😳

patent bane
#

would running this logic every 10 ticks cause a noticeable amount of lag? if so, how would i go about optimizing it?

round bone
#

I see that you might have 48 iterations for every player, which is pretty tough already

patent bane
round bone
patent bane
#

oki

lyric kestrel
round bone
patent bane
#

ah ok

round bone
#
    const nearbyEntities = dimension.getEntities({
        location: origin,
        maxDistance: radius,
        excludeEntities: Array.from(excludeEntites)
    });
fathom hemlock
#

to support event.

round bone
#

give me a second

patent bane
loud frigate
#

So given that attachables can only be attached to specific items, there's no way to make a first person hand swing anim for all items right?

#

Nor can I call some event to play it 💀

loud frigate
#

That was an assesment more than a question

ruby haven
#

Does using the create explosion shows the particles or not cause i don't want the particles to appear when exploding?

ruby haven
#

Nooooooo

cyan basin
#

it's a shame, it would be nice if the explosion options had a "showParticles" option. that would be nice. maybe they can add that in the future

#

these are your only options though im afraid.. so you'll have to look at creating your own explosion from scratch if you wanted to have no particles

wary edge
ruby haven
#

Cause I'm creating an ultimate mass destruction explosion effect I already made the explosion particles so no need for that I'm trying to make the addon not too laggy

#

Like a 100 radius explosion

random flint
#

Setting blocks to air isn't hard.

wary edge
random flint
#

The vanilla explosion might look round on a smaller radius, but when it's on a larger radius... not so much.

In a nutshell "Make Fancier explosion 🤪"

fathom hemlock
#

is this idea good?

#

u can bind functions to the if statement

random flint
#

Is this Scratch? But messier?

prisma shard
#

Am i doing the correct way to make callback using functions?

#

If so, Why are typings not appearing??

#

@warm mason can you help

fathom hemlock
prisma shard
random flint
prisma shard
#

help

#
/**
 * @typedef {Object} detectPickupEventObject
 * @property {Player} player
 * @property {ItemStack} droppedItem
 */

/**
 * @callback detectPickupEventCallback
 * @param {detectPickupEventObject} event
 */

/**
 * @param {detectPickupEventCallback} callback
 */

/**
* @returns {{ player: Player, droppedItem: ItemStack }}
*/
```\
#

literally tried every single JSDocs

#

but didn't work 😭

#

OH

#

FIXED

#
/**
 *  @param {function({player: player, droppedItem: item})} callBack
 */
#

this worked!!

random flint
#

Maybe make it into a class >:)

prisma shard
dawn zealot
#

Im trying to get all the scoreboard objectives in a world and list them, but when i do JSON.stringify(world.scoreboard.getObjectives()) it returns [{}]

random flint
dawn zealot
#

Ty

sage sparrow
#

I use packets events to detect when player add something to the inventory, it might be better, no? search for packet type ItemStackRequestPacket (packet received) and TakeItemActorPacket (packetsend)

round bone
#

InventoryTransactionPacket

#

it's a bit more general, but I think it'll fit the best

deep yew
#

Is there any way to view a player's live inventory with changes or should I just keep opening the chestUI after each edit? (or just say "inventory has changed - Refresh?")

loud frigate
#

is there a way to set an entity in love? i dont see a component for it

lyric kestrel
#

You could probably use Herobrine's chest UI script and change some stuff to do so

dawn zealot
#

how do i get the result of a command, for example scoreboard players list @s ?

deep yew
#

I can make it keep opening after each edit, but that would get annoying quick

#

Just wondering if there's anything I can do with UIs that is efficient or smart

lyric kestrel
#

ah I see

#

That indeed would be an issue

deep yew
#

Just an issue that doesn't exist

dawn zealot
deep yew
#

Yes and I do have instant opening UIs so it may be seamless if I try to make it seamless

#

I'll just see what I can do

gilded shadow
#

is there something like world.deleteDynamicProperty(key);

#

how do i remove one dynamic property

dim tusk
#

.setDynamicProperty(key, undefined)

nocturne berry
#
world.beforeEvents.worldInitialize.subscribe((eventData) => {
    eventData.itemComponentRegistry.registerCustomComponent("eidolon:hit", {
        onHitEntity(eventData) {
            const player = eventData.player;
            const mob = eventData.hitEntity;
            
            const loc = {
            x: mob.location.x,
            y: mob.location.y + 1,
            z: mob.location.z
            };
            const equippable = player.getComponent("minecraft:equippable");
            const item = equippable?.getEquipment(EquipmentSlot.Mainhand);
            const offhand = equippable?.getEquipment(EquipmentSlot.Offhand);
            
            if (!player) {
                return;
            }
  
            if(item?.typeId === 'eidolon:sapping_sword'){
            mob.dimension.spawnParticle("minecraft:critical_hit_emitter",loc);
            if (offhand.typeId === "eidolon:sanguine_amulet") {
            offhand.setLore(['']);
                }
            }
        }
    });
});```

Does anyone know why getEquipment is undefined?
distant tulip
#

should be damagingSource.damagingEntity iirc

nocturne berry
dim tusk
#

It's attackingEntity

#

also, since you're not setting it thru container, you need to put the item back to slot...

#

You good Minato?

distant tulip
#

lol, yeah

dim tusk
#

Wadahell those emojis 😭

distant tulip
#

confirming the two messages 😅

dim tusk
#

it shouldn't be tho since he/she is using equipment not equipmentSlot

distant tulip
#

no one... i said confirming

dim tusk
#

sorry, I just finished eating 😬

distant tulip
#

lol, alr

#

gtg to sleep

dim tusk
dim tusk
#

also, you setting the lore but you're not setting the item back to slot, just do equippable.setEquipment(EquipmentSlot.Offhand, offhand)

dawn zealot
#

is their a way to encode my js and it still function? minly because im uploading it to mcpedl

warped blaze
#

obfuscate it

dawn zealot
warped blaze
dawn zealot
warped blaze
#

"Javascript obfuscator" on Google and use any of them

warped blaze
dawn zealot
#

bet

warped blaze
dawn zealot
#

script will still work on worlds tho right

warped blaze
#

cuz "still function" sounds like a mistake that a spanish speaker could do

dawn zealot
#

still function sounds perfectly fine to me

warped blaze
warped blaze
dawn zealot
lyric kestrel
#

Function in this context just means work

warped blaze
#

mb

dawn zealot
#

ur good bro dw

leaden elbow
#

how to get the loot item stack of a block that was mined?

#

playerbreakblock returns thee block permutation but not the loot of the block

#

and also how to run an event once when player reaches specific y level

wanton ocean
#

Is there a way to check if cheats are enabled in a world??

dim tusk
dim tusk
dim tusk
#

also, why tryna to ofuscate it? Got something to hide?

remote oyster
distant gulch
#

Any way to cancel an Entity hit? or death

#

I tried using afterEvent and just re-spawning the entity, but is there any other way

prisma shard
distant gulch
prisma shard
#

i see

distant gulch
prisma shard
distant gulch
#

Yes but I would need to edit EVERY minecraft entity then

prisma shard
#

So you doing every single entity?

#

oh i thought u were doing it with one entity

distant gulch
#

I just want to cancel every damage or death on every entity

prisma shard
#

Why do you need to do so ? What are you making?

distant gulch
#

but players can hit entity maybe, so I want to make if hits a entity within the zone, it gets canceled

prisma shard
distant gulch
#

Probably you respawned the Entity when the player kills it?

prisma shard
distant gulch
#

hmm

#

Ill just "heal" the enemy on taken damage and if it dies, I will warn the Attacker and respawn it

prisma shard
distant gulch
#

I see, ill do it for death as well

#

But thanks for helping 👍

prisma shard
#

when teacher says thanks to his student

distant gulch
#

xd

gilded shadow
#

im having a problem solving a problem:

 [Scripting][error]-ReferenceError: Native function [Entity::remove] does not have required privileges.    at removePlayer (core/HitboxSystem.js:76)
    at onLeave (character/RPGPlayer.js:50)
    at <anonymous> (core/PlayerManager.js:30)

basically im trying to remove some entities on world.beforeEvents.playerLeave. but it is throwing this error.

#

HitboxSystem.removePlayer

    static removePlayer(player) {
        const hitbox = HitboxSystem.#hitboxes.get(player.id);
        const connector = HitboxSystem.#connectors.get(player.id);

        hitbox.remove();
        connector.remove();

        HitboxSystem.#connectors.delete(player.id);
        HitboxSystem.#hitboxes.delete(player.id);
    }
#

const hitbox and connector return an entity

#

and this is ran on world.beforeEvents.playerLeave

#

as mentioned

prisma shard
#

try this

gilded shadow
#

let me try that

prisma shard
#

Whenever you see the "required priviliges" error, just wrap the code in system.run(() => {})

#

It was a error with entty.remove() as always. I just put that code in system.run()

broken jolt
# loud frigate Nor can I call some event to play it 💀

Not in an add-on. You can, of course, by editing the player's animation controllers and entity definition on the client, but this bars compatibility with other packs doing the same. Should typically only be used in maps or worlds.

broken jolt
prisma shard
#

lol

chrome gyro
pseudo timber
sterile epoch
lone thistle
#

I doubt that's a component

warm mason
junior oracle
#

Any alternatives to word Initialize in 1.21.70? Minecraft/Server 2.0.0-beta

unique acorn
junior oracle
#

Example pls@unique acorn

unique acorn
#

just replace world initialize event with that...?

warm mason
junior oracle
#

THX

#

👌

north rapids
#

It is possible to access the projectile thrown by the 'throwable' component?

#

like throw a trident and access it to run something

warm mason
#

Technically yes, but you can't be sure that it's the right projectile for you.

north rapids
#

how to do this?

#

itemCompleteUse after event then getEntities and filter?

prisma shard
north rapids
#

the customComponent onUse is affected by the 'use_modifiers' component?

open urchin
#

Use modifiers are used for chargeable items (foods, shooters and throwables that are not thrown immediately such as tridents)

dusky flicker
#

its a simple stuff i dont think that code would be that bad, but instead of 48 operations and all fully sync, just create one ring particle and spawn it, or at least run stuff async ti nit block the thread

past coyote
#

halp!

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

// Function to spawn an item at a specified location
function spawnOreItem(dimension, itemType, amount, location) {
    const itemEntity = dimension.spawnItem(new ItemStack(itemType, amount), location);
    itemEntity.clearVelocity();
}

// Function to remove raw items at a location
function removeRawItems(dimension, blockLocation, rawItemType) {
    // Convert to proper block location (integers)
    const blockLoc = {
        x: Math.floor(blockLocation.x),
        y: Math.floor(blockLocation.y),
        z: Math.floor(blockLocation.z)
    };
    
    const entities = dimension.getEntitiesAtBlockLocation(blockLoc);
    for (const entity of entities) {
        if (entity.typeId === rawItemType) {
            entity.remove();
        }
    }
}

world.afterEvents.playerBreakBlock.subscribe((event) => {
    const { block, dimension } = event;
    const blockType = block.typeId;
    const centerLocation = { x: block.x + 0.5, y: block.y + 0.5, z: block.z + 0.5 };

    // Handle iron ore
    if (blockType === "minecraft:iron_ore") {
        removeRawItems(dimension, block.location, "minecraft:raw_iron");
        spawnOreItem(dimension, "minecraft:iron_ore", 1, centerLocation);
    }
    // Handle gold ore
    else if (blockType === "minecraft:gold_ore") {
        removeRawItems(dimension, block.location, "minecraft:raw_gold");
        spawnOreItem(dimension, "minecraft:gold_ore", 1, centerLocation);
    }
});```


for some reason this isn't really working the way I want it to.
#

i'm trying to make it so the raw_ore doesn't drop, and instead is replaced by the ore block itself

#

but it just doesn't work at all lol

distant tulip
#

can't you edit the loot table

past coyote
#

for a block? I dont think so

distant tulip
#

what is the current behavior of your code

past coyote
#

It does nothing, I expect it to replace the item on the ground but the item still shows up

#

break ore, then raw iron shows up, on that tick its replaced with iron_ore_block

#

that should happen with the gold too

distant tulip
#

idk if getEntitiesAtBlockLocation would work for that

#

does it expect exact location or does it return all entities in that block

dim tusk
past coyote
#

How would you make a script that does this?

#
world.afterEvents.entitySpawn.subscribe((event) => {
    const { entity } = event;
    const dimension = entity.dimension;
    const location = entity.location;


    if (entity.typeId === "minecraft:raw_iron") {
        // Remove the raw iron
        entity.remove();

        spawnOreItem(dimension, "minecraft:iron_ore", 1, location);
    } else if (entity.typeId === "minecraft:raw_gold") 
        entity.remove();

        spawnOreItem(dimension, "minecraft:gold_ore", 1, location);
    }
});```
#

like this?

#

it doesn't seem to work haha

unique acorn
dim tusk
#

Get the component first.

unique acorn
#
const itemComponent = entity.getComponent("item").itemStack;
if (itemComponent.typeId == "minecraft:raw_iron") {}
dim tusk
#

Entity.getComponent('item').itemStack

unique acorn
#

i forgor 💔

past coyote
#

yippeee it works!

dim tusk
#

When registering commands, only one namespace can be used?

#

Or do I separate them into different startup event listener?

distant tulip
#

you can use the same event

dim tusk
distant tulip
#

code?

dim tusk
#

wait...

dim tusk
# distant tulip code?
system.beforeEvents.startup.subscribe(({ customCommandRegistry }) => {
  customCommandRegistry.registerCommand({
    name: 'coddy:value',
    description: 'testing1',
    permissionLevel: CommandPermissionLevel.Any
  }, () => {});

  customCommandRegistry.registerCommand({
    name: 'coddy2:value',
    description: 'testing2',
    permissionLevel: CommandPermissionLevel.Any
  }, () => {});
});``````js
[Scripting][error]-Error: Custom Command Enum namespaces must match. Namespace 'coddy2' does not match existing namespace 'coddy'.    at <anonymous> (main.js:477)```
#

and btw, I'm in version 1.21.80.27

distant tulip
#

try coddy:value2

round bone
dim tusk
#

I hope they add permutation in the selection of blocks :)

dim tusk
wary edge
#

Block states or?

dim tusk
#

yes

#

Just how you do fill or setblock

lyric kestrel
round bone
#

Endstone has already implemented this feature

patent bane
#

script ay pi eye

prisma shard
#

lol

#

```js
// why doesnt it work
```

distant tulip
#

Finally inventory events...

warm mason
#

True, I still have to wait until it appears in the release

distant tulip
#

yeah

prisma shard
#

where

#

wdym

distant tulip
#

PlayerHotbarSelectedSlotChangeAfterEvent
PlayerInventoryItemChangeAfterEvent

prisma shard
#

Woahhhhh

#

yay

#

HotbarChangeSlot afterEvent??! damnn cool

prisma shard
#

are they just planned for future changelog

#

Or implemented in preview api

warm mason
distant tulip
prisma shard
#

UH

warm mason
prisma shard
#

WO

prisma shard
distant tulip
prisma shard
distant tulip
#

well, not in that sense
but we can use them in place of particles in some use cases

prisma shard
#

how to do this

#

how did you

#

Can you tell me please how to use that DebugLine

#

debugDrawer

#

also wow, DebugText?? No more using entity nameTags !!

#

ah they added stopSound and it broke my function... stopSound didnt exist so i did stopsound function with commands lol no longer need of functions yay

distant tulip
prisma shard
#

wohoo thanks

#

Minato also can ya help a bit

distant tulip
#

gtg in a bit but sure

prisma shard
distant tulip
#

yeah

prisma shard
# distant tulip yeah

I have the script
I just need to do a system.waitTicks() after each fillBlocks, But i don't know where you divided the operation..

distant tulip
#

iirc i have the function return chunks array

prisma shard
distant tulip
#

whats wrong with that one?

valid ice
#

I can finally make what I want 🔥 🔥 🔥

distant tulip
#

turn the function to async and remove the runjob

#

well, i recommend you to work with runJob, but that what you asked for

#

i gtg for now

warm mason
#

@prisma shard #1364266284308631594 message

dim tusk
#

Umm, quick question... Idk how v2 custom components works but those param values are only read only and can't be changed?

cinder shadow
#

do unlit campfires have a hidden block ID by any chance? Looking into making my shovels put out campfires to match vanilla, but I'm not seeing any block states or components on campfires to let me do that.

cinder shadow
#

weird

#

I yoinked permutations and got nothing

#

oh wait

wary edge
prisma shard
#

a lie can break someones heart

#

🥀

cinder shadow
#

yeah woops, I was being stupid

lyric kestrel
#

Smh smh

prisma shard
#

direction-":"

#

hmmmm

distant tulip
#

nothing wrong with it

lyric kestrel
#

That's just the : between

prisma shard
#

i see

distant tulip
#

it is for "direction"

lyric kestrel
#

"minecraft:cardinal_direction":"south"

#

Eait

prisma shard
#

lol

prisma shard
lyric kestrel
#

Why is there also "direction":0 tf. I just realised that

prisma shard
lyric kestrel
#

But why is there 2 direction states?

open urchin
#

might be block state backwards compatibility
it doesn't use direction

lyric kestrel
#

Perhaps

prisma shard
#

Cardinal is string[south,north,east,west]

#

and direction is number

lyric kestrel
#

Yes, but there's only 4 directions for a campfire, so it doesn't make sense for it to have more than just the Cardinal directions

prisma shard
#

idk

lyric kestrel
#

Also, is there any functions you would like for the files? @prisma shard

prisma shard
prisma shard
#

each hass its own class

lyric kestrel
#

I am currently unsure of what I want to add

loud frigate
#

How do I add an item to an allay hand? I've tried spawning one and getting it's inventory component but it doesn't show up visually nor drops it

loud frigate
#

How do you even do that, there is not /data set command

open urchin
# loud frigate So with scripting it's bugged?

you would set the item in the mainhand slot by getting the equippable component but it's disabled for non-player entities so you have to use replaceitem instead

/replaceitem entity @e[type=allay] slot.weapon.mainhand 0 emerald
loud frigate
open urchin
loud frigate
open urchin
#

yes

loud frigate
#

alright, luckily entities have a runCommand so i can target that one precisely

#

guess its not @ s
I could swear that was for self

open urchin
#

the command shouldn't have a / before it

loud frigate
#

it was also mising an entity. this one worked. it does support the redundant /

#

crazy that they added a component for this stuff and didnt bother to hook it up properly requiring workarounds like this

open urchin
#

it used to work, but they disabled it
only reasoning I've seen is that it's weird for foxes to hold items in their mouths by using the mainhand slot

sterile epoch
#

have they added infinite duration in the add effect method yet

north rapids
#

I'm using the spawnEntity to spawn a projectile and then apply impulse to it. Is there any way to bound the projectile to the player, so it don't cause damage and show the right death message?

meager pulsar
#

where can i find the list of valid biome types?

distant tulip
# north rapids I'm using the spawnEntity to spawn a projectile and then apply impulse to it. I...
import { world, ItemStack } from '@minecraft/server';

world.afterEvents.itemUse.subscribe((event)=>{
    const player = event.source

    const projectile = player.dimension.spawnEntity('minecraft:arrow')
    const projectileCommponent = projectile.getComponent("projectile")
    projectileCommponent.owner = player
    projectileCommponent.shoot(
        multiplyVector3(
            player.getViewDirection(),
            3
        )
    )
})

function multiplyVector3(vector3, m){
    return {
        x: vector3.x * m,
        y: vector3.y * m,
        z: vector3.z * m,
    }
}
north rapids
#

it's stable?

distant tulip
distant tulip
north rapids
#

tysm

sterile epoch
distant tulip
sterile epoch
#

yeah ik

north rapids
distant tulip
#

your welcome

#

projectile api is fun

#

you should check it methods

marsh pebble
#

Ai is developing ( I CANT SPELL)

north rapids
#

if I save a ItemStack in a variable, can I spawn it in the world?

north rapids
#

how?

#

I want it to keep all data

unique acorn
#
const item = new ItemStack("minecraft:stick");
world.getDimension("overworld").spawnItem(item, { x: 0, y: 0, z: 0 });
unique acorn
north rapids
#

I mean, if I get the item stack from a event like, itemUse after event, then store it in a var, can i spawn this item?

distant tulip
north rapids
#

nvmd

#

i was using spawnEntity

#

ty lol

full idol
#

What's the quick way to prevent TNT breaking blocks within a range? I can't cancel it so I'm trying to just set the block back?

world.afterEvents.blockExplode.subscribe(event => {
        const block = event.block;
        
        const claim = getClaimAtPosition(block);
        
        // === Standard protection check ===
        if (claim && !hasFlag(claim.flags, CLAIM_FLAGS.MODIFY)) {
            world.sendMessage("Explosion detected in claim")
            block.setType(block.type)
        }
    });
full idol
marsh pebble
wary edge
#

Detect entity spawn and remove the entity.

#

Or detect player interact.

full idol
north rapids
# unique acorn Yes

sorry for bother, but is possible to do this storing the item in a dynamicProperty?

unique acorn
north rapids
#

I tried to stringify then parse

#

but don't work

unique acorn
#

yeah

#

you can't store em

#

however you can save the important stuff like item name, lore, enchantments, etc... then when you need to load the item, create a new itemstack then set it's data

north rapids
#

maybe

lyric tiger
#

Yo does anyone know how to add hunger like a food item?

north rapids
#

as long i know, this is possible only with effects

#

like hunger or saturation

full idol
#

Though idk if I can detect where the explosion is by coordinates?

dim tusk
full idol
#

Ahh right, thank you!

north rapids
#

i think if u use something like

    if (ev.entity.typeId === 'tnt') ev.entity.remove()
})```
dim tusk
#

And?

dim tusk
north rapids
#

nvmd i thought he was trying to prevent the tnt from exploding at all...

marsh pebble
#

@dim tusk Do you know any behavior manifest generators?

marsh pebble
#

gimme

full idol
#

Stringifying event and logging it shows {}

marsh pebble
#

hacked me

dim tusk
#

event.getImpactedBlocks()

full idol
#

🤦‍♂️ Sorry my bad

dim tusk
#

You're trying to select locations to be not affected...?

full idol
# dim tusk You're trying to select locations to be not affected...?

Yeah! All working now, thanks!

        let impacted = event.getImpactedBlocks();

        for(let block in impacted) {
            
            let claim = getClaimAtPosition({"x": block.x, "y": block.y, "z": block.z});

            if (!claim || hasFlag(claim.flags, CLAIM_FLAGS.MODIFY)) {
                
                impacted.splice(impacted.indexOf(block), 1)

            }

        }
        
        event.setImpactedBlocks(impacted);
dim tusk
full idol
#

I did try creating an array, but because it wanted a Block[] I wasn't too sure how that worked. I know what that is, but in plain JS I'm a little clueless

dim tusk
full idol
#

Hmm I tried that and it said error converting array or something - just closed out so I don't know the exact error

marsh pebble
#

@dim tusk

dim tusk
#

And you're proud of it?

#

Because I'm not.

marsh pebble
#

its a rick roll chill

dim tusk
#

I literally made it as simple as possible but I guess you made it even more harder for mobile users.

dim tusk
marsh pebble
#

when u click generate a video pops up

#

did i get you

#

hello?

dim tusk
#

Haha. funny.

marsh pebble
#

im sorry sir

full idol
nocturne berry
#

Is it possible to spawn an entity facing the same direction as the player who summoned it?

vast rune
#

Do I have to add minecraft:interact if I am detecting interaction using the script api?

thorn flicker
vast rune
#

k, thanks

#

beforeEvents.playerInteractWithEntity rigth

#

right

thorn flicker
#

yes.

vast rune
#

k

past coyote
#

How do I access the afterEntityHurt event signal

dim tusk
past coyote
#

im trying to recreate beta 1.7.3's armor system but I just cant get it to work right.

#

Basically when taking damage, it should try to heal the player back to what they should be based on the armor and durability

#

for some reason though, idk how to set health to the player

#

I wish we had beforeEntityHurt :(

prisma shard
fallow minnow
#

people already abusing this 😭

prisma shard
prisma shard
dim tusk
prisma shard
#

You mean the person @smell of curry ?

#

or smell of a curry

dim tusk
prisma shard
#

jeanmajid and smell of curry ig both guys use this skin

prisma shard
dim tusk
prisma shard
#

I am not the person stealing skins

#

anyways

#

@deep quiver Why you use Smell of curry's skin

dim tusk
#

btw you know "Spyderrock"?

prisma shard
#

Yeah this conversation went from debug lines to skins Bruh

prisma shard
prisma shard
ivory bough
#

How to get how much time it takes before 8th phase of moon without manual calculation?

dim tusk
#

Starting to be off-topic lol

#

Throwback...

prisma shard
#

Yeah he makes cool showcases

prisma shard
dim tusk
# prisma shard what

Just a lil throwback since I have deja Vu that I have already talk with this guy lol...

#

And I'm not wrong...

prisma shard
#

Oh lol

prisma shard
#

He's a great guy

#

and very experienced with script api

lethal bramble
distant tulip
dim tusk
#

dude, I have very short memory... I say hi today, I'll forget 20 minutes later what I just said oof

distant tulip
#

true
I was working on a project he worked on

distant tulip
#

Withercore

prisma shard
#

But

#

It asks me to create a enterprise account

distant tulip
#

Search on YouTube
How to make GitHub pages website

prisma shard
#

You told me its free right?

#

It's a trial for 30 days, that doesnt mean free

distant tulip
#

Is that private repo

distant tulip
prisma shard
prisma shard
distant tulip
#

This is getting off topic, so...

prisma shard
#

I did it

#

wohoo

distant tulip
#

cool

dim tusk
prisma shard
#

But its for mainly downloading my addons

#

You cant reallly download files in offline right?

dim tusk
prisma shard
dim tusk
#

you can download.

prisma shard
dim tusk
#

if those files are local you can download them otherwise no

prisma shard
#

i see

spark slate
#

Heya! sometimes due to lag and stuff, playSound and camera etc are not triggered which leads to player's camera being stuck forever. how can i prevent it?

remote oyster
#

That's a tough one. First see if you can determine what is causing lag. Then try to reduce it.

ruby haven
#

Hello where do I ask about setting bridge up so I can link it to Minecraft like the development addons feature

copper egret
#

as the new minecraft bedrock beta released @minecraft/[email protected] is now released as stable version, does it mean we can use custom slash command registry in the current minecraft release version?

woven loom
#

if its stable

remote oyster
#

Aren't the slash commands still in preview?

woven loom
#

ye

copper egret
#

well I thought that if the 2.0.0 was released as stable then the custom slash command would be included in the released

woven loom
#

its stable starting from this version

copper egret
#

I hope they will add it in the next update of the minecraft release version as beta, as long as we can use it

warped blaze
buoyant canopy
#

can we read the content of a bundle with scripts?

wary edge
#

No.

cyan basin
#

¯_(ツ)_/¯

buoyant canopy
# wary edge No.

danm, i had a crazy idea of using a custom bundle item locked in a slot plus json ui to give the player extra equipment slots

ruby haven
#

How do I add auto completion to bridge in my addon development

somber cedar
ruby haven
#

Okay I already have vs code

distant tulip
#

Step 2: install node js

ruby haven
#

Where?

atomic minnow
#

on your computer preferably

ruby haven
#

No I mean the best place to download it

atomic minnow
#

your Downloads folder works fine

distant tulip
#

dude... lol

distant tulip
ruby haven
#

What version should I download the most stable one

#

V1.18

woven loom
loud frigate
#

how do i add an item tooltip?
Ive tried using itemstack.setLore(["some text"]) and on tooltip nothig happens

woven loom
#

reset item

distant tulip
#

re-set

loud frigate
#

trying

#

that works neat thanks

warm mason
#

?

prisma shard
#

......

distant tulip
#

kinda, he was dragging it out tho

prisma shard
distant tulip
#

it is, just got confused to why did you need to send the screenshot
made me question that i did something wrong

prisma shard
#

oh lol

prisma shard
#

AI is so shit

#

i told him about documentation 3 times

#

but he still cannot find getEntitiesFromViewDirection()

round bone
#

I don't use AI really often tbh

prisma shard
#

i was just testing

prisma shard
thorn flicker
#

🤖

prisma shard
#

whereas getEntitiesFromViewDirection already gets the entiy from players view direction

#

anywayys
.

#

anyone know what is the best Vector3 class among all?

#

i know @minecraft/math already has one

#

but someone know any that has most methods for vector3

loud frigate
#

how to i set an item in a bundle via scripting? i dont see a component for it

loud frigate
#

an darn. guess i'll need to store the stuff using dynamic properties

#

anybody ever did something like that? storing item id an amount is easy but anything more would get lost

wheat condor
prisma shard
#

there are a lot of vector3 script, i am unsure which is the best

distant tulip
#

check pins

prisma shard
#

as i said

wheat condor
#

Check the one from Madlad

prisma shard
#

okie

loud frigate
#

I'm getting an error saying "cannot set dynamic properties on stackable items"
My item has a max stack size of 1

#

bet its another bug

prisma shard
loud frigate
warm mason
oblique mica
#

How it will detect if I want to click the button that's say tools shops it will open the tools shops GUI what's need to be improved

#

import { world } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"

const ui = new ActionFormData()
.title("Form")
.body("")
.button("button1")
.button("button2")
.button("button3");

const customUi = new ActionFormData()
.title("Custom Form")
.body("")
.button("Tools Shop", "textures/ui/Tools")
.button("Blocks Shop", "textures/ui/Blocks")
.button("Farms Shops", "textures/ui/Farms")
.button("Ores Shop", "textures/ui/Ores")
.button("Utilities Shops", "textures/ui/Utilities")
.button("Armor Shops", "textures/ui/Armors")
.button("Foods Shops", "textures/ui/Foods")
.button("Spawn Egg Shops", "textures/ui/Egg")
.button("Template Shops", "textures/ui/Template");

world.afterEvents.itemUse.subscribe(async (event) => {
const { source, itemStack } = event
switch (itemStack.typeId) {
case "minecraft:compass": ui.show(source); break;
case "minecraft:clock": {
const res = await customUi.show(source);
res.selection //This Is Number Will Be Derived From The "collection_index" property of a button in JSON UI
world.sendMessage(Button ${res.selection} Has Been Pressed!)
break
};
}
})

#

Please tell me how

prisma shard
#

hmmm

warm mason
#

hmmmmmmmmmmmmmmmmmmmmmmmmmmm

prisma shard
# loud frigate

Also , its .getDynamicProperty("id")
your doing like .getDynamicProperty(id)

dusky flicker
#

id can be a string variable

warm mason
#

#1067535608660107284 message

#

#1067535608660107284 message

#

#1067535608660107284 message

#

Oh, I mistook you for that guy.

#

...

dusky flicker
#

xd

prisma shard
loud frigate
#

item is fine and its my item which has max stack of 1

#

item is also returning isStackable true which makes 0 sense as thats not what its documentation says

deep quiver
deep quiver
woven loom
# dusky flicker dafuck is this

Short links to my repo for viewing module details, which saves me time. I can use this to find out the most recent module version from anywhere.

thorn flicker
#

how cool would be if we could get the unique id of items

thorn flicker
distant tulip
#

json ui

warm mason
wary edge
warm mason
prisma shard
warm mason
warm mason
oblique mica
#

@wary edge can I ask something msg

distant tulip
warm mason
# distant tulip yes

Well, you can view this manually, but it would be more convenient with a script...

thorn flicker
#

I was thinking more of way to check if an itemstack in your inventory is different from another itemstack instance

warm mason
distant tulip
warm mason
#

This is bad

distant tulip
#

yeah, but it only use is json ui

#

custom renders of item icons

distant tulip
thorn flicker
distant tulip
#

@oblique mica please ask here directly
you have a bigger chance getting an answer here than dm
if it is private matter say so

oblique mica
#

Okayy

thorn flicker
#

or are you not talking about the method to retrieve it, and asking if it exists overhaul?

#

im not sure.

distant tulip
thorn flicker
#

if there is, it would be cool to get it, if not...nvm I guess

#

lol

distant tulip
#

what happen if you did itemstack == itemstack

#

lol

oblique mica
#

import { world } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"

const ui = new ActionFormData()
.title("Form")
.body("")
.button("button1")
.button("button2")
.button("button3");

const customUi = new ActionFormData()
.title("Custom Form")
.body("")
.button("Tools Shop", "textures/ui/Tools")
.button("Blocks Shop", "textures/ui/Blocks")
.button("Farms Shops", "textures/ui/Farms")
.button("Ores Shop", "textures/ui/Ores")
.button("Utilities Shops", "textures/ui/Utilities")
.button("Armor Shops", "textures/ui/Armors")
.button("Foods Shops", "textures/ui/Foods")
.button("Spawn Egg Shops", "textures/ui/Egg")
.button("Template Shops", "textures/ui/Template");

world.afterEvents.itemUse.subscribe(async (event) => {
const { source, itemStack } = event
switch (itemStack.typeId) {
case "minecraft:compass": ui.show(source); break;
case "minecraft:clock": {
const res = await customUi.show(source);
res.selection //This Is Number Will Be Derived From The "collection_index" property of a button in JSON UI
world.sendMessage(Button ${res.selection} Has Been Pressed!)
break
};
}
})

How can I make this work like if I click a form button no 1 it's open GUI I'm trying to make a shop

thorn flicker
#

wall of code

#

didnt even get to see your message minato

thorn flicker
warm mason
thorn flicker
#

I dont think it worked.

#

also isnt there problems with testing if objects equal other objects?

oblique mica
#

@distant tulip?

thorn flicker
distant tulip
oblique mica
#

That's why I want to ask privately

distant tulip
#

sure, lets move there

oblique mica
#

Can you help me script it so if I click the tools shops it will open the tools shop gui

wary edge
oblique mica
#

I did make a post

thorn flicker
#

also if you make a post, you can help other people having the same problem

oblique mica
#

But no one answer

thorn flicker
#

patience

oblique mica
#

Don't you'll understand

fallen cape
#

we can't pass item component registry to other functions from 2.0.0-beta?

fallen cape
#

nvm

#

it actually isn't working wait

#
export function registerItemComponents(data: mc.ItemComponentRegistry) {
  long_swords.register(data);
  misc.register(data);
}

I have this and it stopped working

past coyote
#

how would I make it so when a block is placed in water, the iswaterlogged is set to false after placement?

#

nvm I figured it out

#
import { world, BlockPermutation } from "@minecraft/server";

world.beforeEvents.playerPlaceBlock.subscribe((event) => {
    const block = event.block;
    const player = event.player;
    const dimension = block.dimension;
    const location = block.location;

    try {
        event.cancel = true;
        const permutation = BlockPermutation.resolve(block.typeId).withState("minecraft:waterlogged", false);
        dimension.setBlockPermutation(location, permutation);
        player.sendMessage(`Placed ${block.typeId} with waterlogged=false`);
    } catch (error) {
        player.sendMessage(`Error: ${error.message}`);
    }
});```
#
import { world, BlockPermutation } from "@minecraft/server";

world.beforeEvents.playerPlaceBlock.subscribe((event) => {
    const { block, player } = event;
    const dimension = block.dimension;
    const location = block.location;

    try {
        // First check if target location contains water
        const targetBlock = dimension.getBlock(location);
        if (targetBlock.typeId !== "minecraft:water" && 
            targetBlock.typeId !== "minecraft:flowing_water") {
            return; // Exit early if not placing in water
        }

        // Only proceed if placing in water
        event.cancel = true;
        const permutation = BlockPermutation.resolve(block.typeId)
            .withState("minecraft:waterlogged", false);
        
        dimension.setBlockPermutation(location, permutation);
        player.sendMessage(`Placed ${block.typeId} with waterlogged=false in water`);
    } catch (error) {
        player.sendMessage(`Error: ${error.message}`);
    }
});```


I tried to do it this way, but the game returns that "minecraft:water does not have the waterlogged property"
distant tulip
#

you can do that without canceling the event

#

afterevent > block.setWaterlogged(false)

past coyote
#

I wanted to optimize it by detrecting water and only running the anti-waterlog after the fact

#

I guess this works though

#

how do I prevent buckets from waterlogging blocks?

distant tulip
#

cancel itemUseOn

past coyote
#

That would work, but if a player sneaks and places water, I want the water to still be placeable on the block, just not in it and waterlogging it

distant tulip
#

need a bit of logic but it is easy enough

marsh pebble
#

i did something usefull

#

🎊

woven loom
#

which event runs after reload anyone tested ?

wary edge
woven loom
#

Have dought for the world load event

steady canopy
#

It's just a fact that is better than writing code in javascript.

remote oyster
#

🤮

steady canopy
#

You are safe from all type errors you could have

small cloak
#

TS is ok, but I still don't care for it. I prefer compiled languages with strict typing.

cinder shadow
#

Total skill issue

steady canopy
#

wtv lets you sleep well at night bro

cinder shadow
#

Don't forget your apple juice with the bendy straw

ruby haven
#

What is the most stable npm version now?

remote oyster
ruby haven
#

Npm itself @minecraft/server

remote oyster
#

Stable: 1.18.0

Stable Beta: 2.0.0-beta.1.21.70-stable

https://www.npmjs.com/package/@minecraft/server?activeTab=versions

ruby haven
#

Thanks

bronze pulsar
#

What's the best way to create the impermeability of a moving world border? Knockback won't work because people could always just stand behind a block. Teleportation is the next best thing I can think of, but it is choppy and messes with player rotation. Does anyone have any other ideas? Thank you.

ruby haven
#

I installed the node.js in my device then went to visual studio code then open the integrated terminal in my BP then went to the side where you copy paste npm then I input the version in the integrated terminal but there was a red pop up issue

cinder shadow
#

You could also do both

#

Try and knock them back and if their location isn't changing then send them to the shadow realm

#

There's also the alternative method, which is to start to kill the player, that usually makes them turn around

#

@bronze pulsar

bronze pulsar
#

I’ll probably end up doing a combination of both. Knock back first then if that’s not working, teleportation.

#

Thank you.

wheat condor
fallow minnow
#

i believe entities yes

#

there are things u can do to have client sided entities

#

particles are easier but i dont know if they can be seen through walls

#

you quite literally just do player.dimension.spawnParticle instead of world.getDimension(aaaa).spawnParticle

#

yeah i have no clue either sadly

dim tusk
#

player.dimension is equivalent to world.getDimension()

#

You just used the current dimension of the player...

fallow minnow
#

whoops

spark slate
astral quarry
#

Is there a way to import a structure file in the behavior pack as a structure?

warm mason
astral quarry
#

Its there already, my issue is importing said structure with the api at present.

Its saying it cant find the id.

prefix:test/ex/red1

world.structureManager.place(id, dim, origin);

I can confirm its in the "prefix" folder in the structure folder, I can also confirm its in "test" inside of "ex" folder.

the mcstructure file is named "red1.mcstructure"

#

Here's a better example.

#
<behavior_pack>/
└── structures/
    └── prefix/               ← my “namespace” folder
        └── test/             ← my subfolder
            └── ex/           ← second subfolder
                └── red1.mcstructure ← my structure
#

The id, I'm trying to use for the structure api is this.

prefix:test/ex/red1
#

My goal is to be able to place a structure file thats it.

world.structureManager.place(id, dim, origin);
#

Atm, its saying its missing which tells me its possibly not in the expected format?

#

Solved it, okay so it uses just a normal filepath.

#

without the extension 👍

random flint
#

👏

astral quarry
#

It just put me off because of how it is in actual features jsons 😮‍💨

warped blaze
#

or is it even possible in singleplayer?

unique acorn
# warped blaze https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-g...
import { world, system } from "@minecraft/server";
import * as GameTest from "@minecraft/server-gametest";

GameTest.register("namespace", "name", (test) => {
  const player = test.spawnSimulatedPlayer({
    x: 1,
    y: 2,
    z: 1
  }, `Player-Name`, "survival").maxTicks(100).structureName("structure").tag(GameTest.Tags.suiteDefault);
});

You need a structure in your bp so it spawns, to spawn it just do /gametest run namespace:name (you can change the name)

#

the player will despawn after 100 ticks but you can change it

warped blaze
unique acorn
#

Yes

warped blaze
#

When you finally spawn it, can it leave the generated structure?

#

by the navigation methods for it's class

unique acorn
#

yep

warped blaze
#

alr tysm

unique acorn
#

it can't move if the location you gave it is outside it's chunk tho

warped blaze
unique acorn
#

and the moveToLocation is structure location based not world location

warped blaze
unique acorn
#

it can move to entity location which could work if you spawn an invisible entity in a location and tell it to move to it

#

yet if the entity is outside it's chunk, it'll just freeze and not move

warped blaze
#

hmm, it's truly for just gameTEST, I can't do anything that funny or interesting with it 😭

remote oyster
# spark slate nothing is causing lag, it works perfectly in single player or LAN but in multip...

High ping players aren't something you can "fix" from the server side. They're always going to be out of sync, and it’s going to cause problems such as rubber banding, teleporting, missing hits, etc.

One thing you could try is to measure response times with each player in the world. A game of ping pong. Basically create a makeshift ping tool in your behavior pack to verify if a player is having extremely slow responses. Then kick them, because there isn't much that can be done beyond that in a sandbox environment.

random flint
ruby haven
#

Finally solved it I must install the npm in the window terminal not in the vs code

woven loom
#

useful stuff

wheat condor
warped blaze
woven loom
#

Ye

prisma shard
# ruby haven I installed the node.js in my device then went to visual studio code then open t...

By red pop up issue, I think you mean it says "npm i" is not a command. Even if Nodejs is installed, Means this that your Nodejs is not set up in system variables, so the npm command doesnt work globally, which i had this issue before. I fixed this issue by doing:
Go " this pc " -> right click -> properties -> Advanced system settings (on right panel) -> Environmental Variables (Advanced tab) -> There is a "system variable" named Path -> click on Path text -> click edit -> click New -> paste C:\Program Files\nodejs -> Ok -> Ok -> Ok (close all) -> restart PC -> open VSCode -> open terminal -> paste npm i @minecraft/[email protected] (your command as you want your script version) -> wait until package gets added -> open a main.js script -> import { world } from '@minecraft/server' -> If it shows the properties of world class, as typings, that means it works~!

#

And yes, I wrote a whole youtube tutorial for you~

ruby haven
prisma shard
#

lol

prisma shard
# wheat condor holy essay

yk, why i put effort writing these for him?
I suffured 1 month for not getting to install typings
For this same issue

ruby haven
#

Wait what's your yt

#

Do you also do scripting tutorials?

prisma shard
#

so i wrote this for nothing

#

you couldve told you've fixed it

#

😭 ..

prisma shard
prisma shard
random flint
prisma shard
#

lol :)

ruby haven
#

Did anyone here created there own custom explosion effect without particles

shut citrus
buoyant canopy
# wheat condor <#1364625093841522779>

that's such a cleaver way of doing it, you spawn a bundle item entity and kill it with lava to reveal its content, but does it preserve the order of the items?

distant tulip
wheat condor
buoyant canopy
sterile epoch
#

how do I open a .mcstats file from the /scrip diagnostics startcapture command?

coral ermine
#

is @minecraft/server-net and @minecraft/server-admin can be used in normal worlds like @minecraft/server

unique acorn
wanton cedar
#

How do I access a block's seconds_to_destroy property in scripting?

shut citrus
sterile epoch
#

does anyone know why when I add loyalty 3 to a trident it gives me an out of bounds error

#

loyalty 2 works tho

sharp elbow
#

Are enchantment levels 0-indexed? That would imply 3 is Loyalty IV

sterile epoch
#

no

wheat condor
#

What does .unsubscribe do?

sterile epoch
sterile epoch
# sterile epoch
[Scripting][error]-Unhandled promise rejection: EnchantmentLevelOutOfBoundsError: When trying to add enchantment instance - Tyring to set enchantment level to 3, range for type loyalty is [0 - 3].    at createItem (utils/item-maker.js:14)
    at giveLoot 
#

this game gives me a headache

#

does anyone know what's going wrong here

distant tulip
remote oyster
sterile epoch
#

and loyalty 2 is working

#

I give up, it doesn't matter anymore

remote oyster
sterile epoch
#

no clue what that was

thorn flicker
#

it just works now? lol

sterile epoch
#

yeah, possibly a problem with vscode not updating the file or smthn

#

idk

sterile epoch
#

yeah no clue then

remote oyster
sterile epoch
#

just very weird how the error is like "trying to set level to 3" then says the range is 0-3 😂 how does that make sense

remote oyster
#

I was pretty confused myself. I could only make sense of it being an internal issue with the API.

sterile epoch
#

just bedrock things

remote oyster
#

Wouldn't expect anything less.

distant tulip
#

that is a common error

#

bug*?

still rampart
fallow carbon
#

has anyone seen this error before?

[Scripting][error]-InternalError: too many closure variables
[Scripting][error]-Plugin [pack.name - 1.0.0] - [main.js] ran with error: [InternalError: too many closure variables]
deep arrow
#

what exactly are you doing?

deep quiver
deep quiver
#

Thats quite a bit

ruby haven
#

Is there any way I can detect an entity after it shoots projectiles cause I want to do something after the entity shoots the projectile?

ruby haven
#

I wanna do something about the shooter of the projectile anyway to trace it

patent bane
#

i have an addon with around 120 seperate js files in it, would i gain any performance benefit by condensing all these files into a singular main.js?

coral ermine
#

Is there a ‘Forward’ ‘Back’ ‘Left’ ‘Right’ buttons in playerButtonInput event?

round bone
#

better keep it splitted

patent bane
round bone
little hull
#
import { world } from "@minecraft/server";

world.afterEvents.entitySpawn.subscribe((event) => {
    const entity = event.entity;

    if (entity && entity.typeId === "zombie:explosion_cast") {
        const projectileComponent = entity.getComponent("minecraft:projectile");

        if (projectileComponent && projectileComponent.owner) {
            const owner = projectileComponent.owner;
            world.sendMessage(`Projectile was shot by: ${owner.typeId}`);
        } else {
            world.sendMessage("Projectile has no owner.");
        }
    }
});```
little hull
prisma shard
#

how are you here online

#

i thought you've left scripting or what\

#

DIdn't expect you to be online shock

patent bane
#

how do i check is a player is an operator?

#

if*

unique acorn
patent bane
patent bane
unique acorn
#

Also it might not work on players that aren't the ones hosting the world, only world creator

#

in bds it will only work on players with operator level 4

#

And in realms it won't work

#

good one mojang

loud frigate
#

so i have my own entity with a projectile component and im using shoot method as soon as its spawned. Thing is it looks like its taking a second for it tostart moving for the client, more than i would expect at least since theres bound to be some communication delay

#

so basically it looks like you get the projectile still infronf of you for half a secondbefore it actually starts moving

prisma shard
#

bcoz that makes somth happen after a tick

#

who knows could make the arrow lag

loud frigate
#

no spawning and shoot happens in the same script. same effect as using add impulse

prisma shard
#

hmm

loud frigate
#

i would expect a 1 tick delay, this noticeably longer