#Script API General

1 messages · Page 55 of 1

distant tulip
amber granite
#

._. no i mean i can't test it

#

To know if it works or not

distant tulip
distant tulip
#

-# i don't use typescript

#

maybe i will add that as a setting, 'language"

granite badger
#

mostly just want it to highlight syntax error, since js linting runs under ts nowadays

sharp elbow
amber granite
#

:-: someone please retry my code :

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

world.beforeEvents.playerPlaceBlock.subscribe(({ block }) => { 
    if (block.type !== "minecraft:chest") return;

    let EastConnected = (
        block.east().permutation.getState("facing_direction") == block.permutation.getState("facing_direction") &&
        block.east().getComponent("inventory").container.size == 27 &&
        block.east().type == "minecraft:chest"
    ) ? true : false;

    let WestConnected = (
        block.west().permutation.getState("facing_direction") == block.permutation.getState("facing_direction") &&
        block.west().getComponent("inventory").container.size == 27 &&
        block.west().type == "minecraft:chest"
    ) ? true : false;

    if (EastConnected || WestConnected) { 
        world.sendMessage("there is a connected chest"); 
    }
});
cerulean cliff
#

why are you all fighting with double chests since ages? I'm slowly getting curious

amber granite
#

This is the smallest chest detector u can find

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

const isConnectedChest = (b, d) => (a = b[d]())?.type === "minecraft:chest" && a.permutation.getState("facing_direction") === b.permutation.getState("facing_direction") && a.getComponent("inventory").container.size === 27;

world.beforeEvents.playerPlaceBlock.subscribe(({ block: b }) => {
    if (b.type === "minecraft:chest" && (isConnectedChest(b, "east") || isConnectedChest(b, "west"))) world.sendMessage("There is a connected chest");
});
amber granite
amber granite
#

Smallest ☠️ :

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

world.beforeEvents.playerPlaceBlock.subscribe(({ block: b }) => {
    const c = (d) => (a = b[d]())?.type === "minecraft:chest" && a.permutation.getState("facing_direction") === b.permutation.getState("facing_direction") && a.getComponent("inventory").container.size === 27;
    if (b.type === "minecraft:chest" && (c("east") || c("west"))) world.sendMessage("There is a connected chest");
});

Works only with beta api

sharp elbow
#

((mine has come the closest))

cerulean cliff
#

okay didn't mean it in a harmful way, but this is quite interesting I must say

sharp elbow
#

Agreed!

amber granite
#

Yesh now how can make it smaller ? ☠️

wary edge
#

I believe Lucy is saying, "Why and what are you all struggling with double chests" more than "Why are you fighting each ither over double chests".

cerulean cliff
#

^^^

sharp elbow
#

Given how often completely ridiculous arguments break out here, I can understand choosing the word "fight" lol

wary edge
#

As someone who has just been lurking on/off, I am quite confused what the situation with double chests.

sharp elbow
#

The question is quite simple: Can you detect if a placed chest will connect to another chest?

amber granite
#

Maybe the most accurate word to say is competition

sharp elbow
#

It has been a very fun exercise.

amber granite
#

._. yeah

#

But it soultion was so easy :-: but so tricky

#

Some said it s impossible

#

Some said it has edge cases

#

Some did extra work on it

#

But we didn't see the direct way or the simplest:-: everyone find the solution but from its point of view and it s mind processing method

neat hazel
#

How to turn this command into a script, without using runCommand??

/execute if score northern worldtime matches 1.. run scoreboard players remove northern worldtime 1
unique acorn
amber granite
#

Hilp , how can i get data from before event then put it in after event

true isle
#

what component would i use to imitate placing vines like the vanilla chrimson vines? i got all the other components i just cant seem to figure out the place block when placing it on an already growing vine

knotty plaza
#

Or itemUseOn

true isle
#
   world.beforeEvents.itemUseOn.subscribe((event) => {
        const { block, itemStack } = event;
        if (!itemStack) return;
        const below = block.dimension.getBlock(block.below().location);
        if (itemStack.typeId === "blushrooms:popple_vine" && block.typeId === "blushrooms:popple_sprout" && below.typeId === "minecraft:air") {
            block.setPermutation(BlockPermutation.resolve('blushrooms:popple_vine'));
            below.setPermutation(BlockPermutation.resolve('blushrooms:popple_sprout'));
            decrement_stack(player, itemStack, 1);
        }
    });
});
#

is this right?

amber granite
#

._.

last latch
#

how do i use the shutdown event?

#

itellisense wont show me the shutdown event

umbral dune
true isle
#

yeah idk. ive used multiple ways i cant get it lol

wicked girder
#

is it possible to force the host to quit?

remote oyster
wicked girder
#

doesnt seem to work

remote oyster
wicked girder
remote oyster
#

Do this:

world.getDimension(args.dimension.id).runCommand()
wicked girder
#

still no

remote oyster
wicked girder
#

local world

remote oyster
#

Then no, it won't work. It works in a server.

wicked girder
#

bruh i said host lol

remote oyster
#

You can test on BDS

#

As a host

wicked girder
#

Is there anything to force the host to quit?

remote oyster
#

I already told you.

wicked girder
#

thats for bds... and that doesnt even have a host

remote oyster
#

BDS, and Realms.

wicked girder
#

thats litterally the same but yeah

sharp elbow
#

Could you invoke remove() on the player?

wicked girder
#

that broke my game lol

sharp elbow
#

Ah, did it cause you to time out instead of kicking directly?

wicked girder
#

i cant enter the world?

sharp elbow
#

Oh, I guess that really busted it

#

Does restarting Minecraft help?

wicked girder
#

idk what was happening with my game but no remove doesnt work

remote oyster
#

Do you plan to run a local world only?

wicked girder
#

yeah

#

its a map idea I got

sharp elbow
#

If your project supports editing the player definition, I would look into applying the "minecaft:despawn" component with an event. That might be better than remove()?

wicked girder
#

well remove didnt work in general but im trying the compent method rn

remote oyster
#

Use to be able to explode the player to force quit but I don't know if that was patched.

sharp elbow
#

That was funny

#

If neither of those work anymore, then the only other method I know, and despite how inconvenient it may be, has to be my personal favorite, is having a mob with the "minecraft:behavior.eat_mob" component eat the player. Last I tested, that caused an instant kick

wicked girder
#

thats amazing

#

and i think the despawn one works but its buggin

#

dooooope I got it working where I can trigger an event to kick host

#

needed to set the timers and stuff to 1, which eplains why it was taking forever to kick them

sharp elbow
#

Oh, shoot, I forgot there were two despawn components.

wicked girder
#

yeah instant despawn dont work

sharp elbow
#

If you have more time to experiment, try "minecraft:instant_despawn"

#

Crud

wicked girder
#

which was annoying

#

but this works

dim tusk
wicked girder
#

though i think this could potentally lock the player in the disconnect menu

dim tusk
#

you meant this?

untold garnet
#

anything new with js?

#

can we make actual in game commands yet?

wary edge
untold garnet
#

Ooooo

#

you can cancel block breaking event now

unique dragon
#

lol

#

one of your lasts messages was in 2023 lmao

untold garnet
#

is it bad?

#

lol

#

so i guess spawn protection has been possible now?

patent tapir
#

Ok I just walked into a skygen that managed to bypass/turn off the word filtering

#

I'm way too curious of how it's done

#

If I had a system to splice the messages around the sensitive words to put an invisible character in, Minecraft would just write the character as some UTF garbage so...

#

Please don't take this seriously but how??

#

That's not the only strange thing about this skygen either, there's like 30 people here and it's running smooth as heck

#

But that's a completely different issue

valid ice
#

Optimization goes far

#

as for turning off word filtering- don't even need scripts to do it. just
"enable_profanity_filter": false in JSON UI elements

patent tapir
#

How?

#

What file path in behavior pack

valid ice
#

not Bp

#

RP

patent tapir
#

Oooooooooo ok

#

What file path tho

patent tapir
valid ice
#

RP/ui/hud_screen.json -> chat_label object in there
RP/ui/chat_screen.json -> messages_text->controls->text object in there

valid ice
valid ice
#

Doubt it just removed the filter

patent tapir
#

It was a very fancy skygen BP I'll tell you that

#

And it had an HP bar mod

#

Someone was going frickin NUTS over the fact that profanity was allowed after I pointed it out lmao

valid ice
patent tapir
valid ice
#

I can imagine

untold garnet
#

did they remove beforePistonActivate event?

valid ice
#

yes

patent tapir
#

I've never used those files before

untold garnet
#

where are the chat events?

valid ice
#

I recommend looking at the vanilla samples files

valid ice
untold garnet
#

so there is no more chat commands anymore?

valid ice
#

There is

#

Same way you did before

untold garnet
#

but whats the chat event now

valid ice
#

world.beforeEvents.chatSend or world.afterEvents.chatSend

#

Were you here when they separated before & after events?

#

1.20.0 update, it was pretty big

#

One could say it was massive

untold garnet
#

can you point me to it

patent tapir
#

Hey can I delete these garbage files in the RP like /ui/how_to_play_common.json and /sounds/sound_definitions.json

valid ice
#

try it and see

patent tapir
valid ice
#

see what's cooking

patent tapir
#

Maybe only having the pack_icon and manifest files will work

#

oh and texts folder

valid ice
#

TLDR anything that isn't needed in JSON UI can be yeeted

untold garnet
#

ahhhhhhh i was at "minecraft-bedrock-stable"

valid ice
#

that includes stuff you haven't edited in the files themselves

untold garnet
#

what version of docs is for minecraft-bedrock-experimental

#

betas?

valid ice
#

ye

untold garnet
#

i see

patent tapir
#

I'm afraid that if I try it directly from the vanilla pack without deleting anything it'll throw a lot more errors because

#

There are so many syntax errors that bridge finds in the vanilla file

#

Whatever

valid ice
#

perhaps comments

patent tapir
#

lol this is all there is in the chat_screen.json file currently

{
  "namespace": "chat",
  "messages_text": {
    "controls": [
      {
        "text": {
          "enable_profanity_filter": false
        }
      }
    ]
  }
}```
#

I'm a curious man, what can I say

valid ice
#

Try adding the stuff that's in the text object from the vanilla file

patent tapir
#

Just did EVERYTHING that was already there, if it doesn't work Ill try that

#

ooo fun, it doesn't throw errors when loading

#

That's a good sign

#

Omg

#

That's so funny

#

It's so simple

#

But so funny

#

lol the anvil renaming still doesn't like it but it did unblock chat lmao

#

Well now I know

valid ice
#

Similar process

patent tapir
#

Oh

#

anvil_screen isn't it

#

ha ha

valid ice
#

ye

patent tapir
#

Despite what I'm doing you continue to help

#

What a chad

#

Also what's the object name

valid ice
#

Dunno, haven't looked into that one

patent tapir
#

Oh gee

#

I think I found it

#

autofinish says it's a property that exists there so i guess it works ¯_(ツ)_/¯

#

Oh, thats the same for... every object

#

I started putting it in every object until I find one that finally picks it up
(I dunno if it's even possible at this point :/ )

#

Imma get a shower. Be back in a bit

patent tapir
#

Back

#

Ok

#

So

#

I just realized 2 things:

#

1, I would probably have to mess with the anvil_screen_pocket file to make this work and

#

2, someone in my skygen asked me if their weapon was fine to use and they gave me a netherite sword with the name (obfuscated)GO GO GADGET CHAT DESTRUCTOR(obfuscated) then like FIFTEEN LINES of nothing, they said it wasn't a hacked item and just a resource pack, which makes me think that these two situations are similar in the way they're done

Edit: found how it's done. This little sht: json "[email protected]_edit_box": { "anchor_from": "top_left", // the parent "anchor_to": "top_left", // this control "property_bag": { "#property_field": "#item_name" }, "max_length": 30, "$text_edit_binding_name": "#text_box_item_name", "$text_edit_box_label_size": [ "default", 10 ] } The profanity filter remains unbroken

shut citrus
#

how to break shield using scripts?

dull shell
#

so i wanna delete the command out of this and make it set the block when its destoryed is that possible?

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

world.beforeEvents.playerBreakBlock.subscribe(event => {
    if (event.block.typeId == "minecraft:wheat") {
            let block = event.block;
            let player = event.player;
            let location = block.location;
        
            event.player?.runCommandAsync(`execute @s ~~~  setblock ${location.x} ${location.y} ${location.z} wheat`); 
        }
    }
)```
#

like without running a command on the player to set the block bakc

thorn flicker
#

but it wont save the growth progress.

#

also why are you not just using cancel?

dull shell
#

wdym?

dull shell
thorn flicker
#

its in most of the beforeEvents

#

it cancels the event from happening so in this case, it would stop the block from breaking

dull shell
#

someone helped me with making that part

dull shell
thorn flicker
#

okay.

#

that would cause a duplication glitch

#

is that what you are aiming for lol

#

or are you creating an auto replanting thing

dull shell
#

yes auto replanting lol sorry for the confusion

thorn flicker
dull shell
dull shell
#

what does this mean? and how can I fix it

distant tulip
#

there is a limit of 255 cmd

valid ice
#

runCommandAsync hollow

grave thistle
#

is the latest stable version 1.16.0 or 1.17.0?

valid ice
#

Thank God it’s deleted in 2.0.0-beta, that surely won’t have any negative impacts on dev work! Clueless

valid ice
grave thistle
#

noice, thank!

distant tulip
last latch
#

Thanks

trail marten
#

how do i get a list of effects in minecraft?

dim tusk
trail marten
#

thought i need to enter into the prototype property or some sht

dim tusk
acoustic basin
#

guys, does anybody knows y im getting this error?
here's the line the error is showing error for
selectedItem.getEquipment('Mainhand').nameTag = `Bucket of ${target?.nameTag}`
and the error itself
[Scripting][error]-Error: Failed to get property 'nameTag' at <anonymous> (animal_bucket.js:189)

#

im trying to give the bucket name of an entity that player interacts with, its beforeEvents.playerInteractWithEntity

#

i tried to just give name of Bucket of cc, and it didnt give any error, so its pointing out that it cant get nameTag property from ${target.nameTag}

unique acorn
acoustic basin
#
world.beforeEvents.playerInteractWithEntity.subscribe(data => {
    const player = data.player
    const target = data.target
    const itemStack = data.itemStack
    const selectedItem = player.getComponent('minecraft:equippable')
    if (target?.typeId === 'v360:mole' && itemStack?.typeId === 'minecraft:bucket') {
        system.run(() => {
            selectedItem.setEquipment('Mainhand', new ItemStack('v360:bucket_of_mole', 1)).nameTag = `Bucket of ${target?.nameTag}`
            target.remove()
        })
    }
})```
untold magnet
#

const charged = source?.getComponent('is_charged'); isn't working? ( trying to detect if the creeper is charged )

acoustic basin
#

ive changed the selectedItem.getEquipment('Mainhand').nameTag = Bucket of ${target?.nameTag} already, trying something

acoustic basin
untold magnet
acoustic basin
unique acorn
# acoustic basin yes

has it been renamed using a name tag? or did you change it's name tag in your code?

acoustic basin
#

but the bucket didnt get mole's name

unique acorn
#

did the mole disapear?

wary edge
#

You need to set the itemstacks name first before setting it the setequipment.

acoustic basin
acoustic basin
#

wait, how do i do it actually

#

make a const for itemstack?

wary edge
#

Yeah.

acoustic basin
#

actually yes

unique acorn
#
const item = new ItemStack('v360:bucket_of_mole', 1)
item.nameTag = `Bucket of ${target.nameTag}`
selectedItem.setEquipment('Mainhand', item)
#

like this I think

acoustic basin
#

thank u both so much!

#

thought, y does it work this way, that i have to make a const for it first...

acoustic basin
amber granite
#

Are u sure that thing exists?

unique acorn
untold magnet
#

i should do console.warn(charged) to see

unique acorn
#

i did this in my world and it worked

const charged = target?.getComponent("is_charged")
if (charged) {
    world.sendMessage("entity is charged")
  } else {
    world.sendMessage("entity is not charged")
  }
#

it could be something else

untold magnet
unique acorn
#

then the entity doesn't have it

untold magnet
sage sparrow
#

hi there, I see that I can monitor when a player take a item with the packetSend events (TakeItemActorPacket), but is it possible to identify which it was picked up?

untold magnet
#

i cannot detect the charged creeper as the source

untold magnet
#

const source = damageSource.damagingEntity; ^

dawn zealot
#

are dynamic properties stored in like the manifests uuid?

#

like this one

patent tapir
celest abyss
unique acorn
patent tapir
#
data.cancel = true```
Easy cheat for realms without realms LMAO
unique acorn
#

lol

#

it doesn't say what it exactly does in docs tho 😞

patent tapir
unique acorn
#

fair

valid ice
#

Just because it's a before event doesn't mean it is cancelable 🙂

patent tapir
#

I'm now just imagining someone trying to close their world but the "save & quit" button not doing anything and instead throws an error in the console

#

hheheheehehhehehhehheehee

unique acorn
#

if playerLeave before event was cancelable, shutdown would've been possible too

#

but its too op so why would mojang do that

patent tapir
#

I wish there was a disconnectReason data value in the playerLeave event so I can send in chat why they dc'ed

#

(Like kick, reset, leave, and connection error)

unique acorn
#

that would be very useful

valid ice
#

It was not cancelable

dull shell
patent tapir
#

Why is runCommandAsync bad?

#

It just waits for the next tick after the last command (if there is one) to run it

#

Right?

dull shell
#

i think so

valid ice
#

If you want stuff to run in order like you typed in your code, then runCommandAsync ain't the way to go

patent tapir
valid ice
#

Native methods are better to use, if they exist

patent tapir
#

Please correct me if I'm wrong

valid ice
#

runCommand completely halts the code until the command finishes- which is a different problem. Lots of those, and the world can freeze until everything is finished running

valid ice
#

Try it out, see for yourself

patent tapir
#

Yeah that's an issue I didn't know I had

#

I've been using runCommand EXCLUSIVELY

#

And I have done my best to not use it, but there's still at least like 3 of them in my largest addon :/

dawn zealot
#

is there anyway i can stop dynamic properties from getting removed if i change the pack uuid?

patent tapir
#

It'll mess a lot of things up unless the pack hasn't been used yet

open urchin
#

if you're making a new version of your pack, only the "version" fields should be changed

dawn zealot
#

like updating

patent tapir
#

Yeah you seriously dont need to change the UUID for that

#

Just add the pack to the realm

#

Very simple

dawn zealot
#

yeah obv bruv

patent tapir
#

Unless you managed to use the same UUID on MULTIPLE packs in this realm

dawn zealot
#

im talking about updating the pack

patent tapir
#

If it's not in the development folders it probably should be anyway

#

So that you don't need to jump through all THOSE hoops...

dawn zealot
patent tapir
dawn zealot
#

u cant

#

literally just tested it

patent tapir
#

It just makes it so as long as the UUID is the same, newer packs overwrite older packs no matter what

patent tapir
patent tapir
#

I dont pay for realms so I guess I have to believe you

patent tapir
#

Didn't know that existed

#

Maybe there should be a forum page with the most important hyperlinks

#

Or a pinned message here

valid ice
#

shrug
Dev-resources is enough if people look for it

patent tapir
valid ice
chilly fractal
#

Yo bois

#

Is there someway to store data on the player?

#

(Across addons)

#

I know i can just use ipc or even scriptevent and set the props from one addon to another

#

But

#

I'm just asking if there is a vanilla way

distant tulip
#

scoreboard db

fast lark
#

hi i have problem with my chat rank addon

#

world.beforeEvents.chatSend.subscribe(({data}) => {
});

#

wtf

valid ice
#

What script version are you using

fast lark
#

1.17 beta

valid ice
#

hmm

chilly fractal
fast lark
chilly fractal
#

Nvm

valid ice
fast lark
#

oh okay

distant tulip
#

should i save the code inputted by the user?
currently saving only the setting

distant tulip
#

so, an auto save that it interval can be changed from the setting, how that sound?

chilly fractal
#

That sounds w

patent tapir
patent tapir
fast lark
#

lol

patent tapir
#

i don't know either

pale terrace
#

is there a way to execute an scripting code when a new chunk is loaded?

chilly fractal
#

Not really sure

#

But

#

There is a command

#

/schedule i think

#

It triggers when a chunk is loaded or smth. Go read about it

pale terrace
#

I will try thx

pale terrace
chilly fractal
#

You can do:
world.getDimension('overworld').runCommandAsync('schedule <params because idk them>').resultCount;

#

It's something

#

Idk if it's .resultCount

#

Check the docs because i think my memory is rusty

pale terrace
#

like /schedule on_area_loaded add <from: x y z> <to: x y z> <function:filepath>

#

So, I need to add a mcfunction with /scriptevent or something

fast lark
#

?

fast lark
#

For this*

#

Is*

chilly fractal
unique acorn
#

i think it returns 0 if it failed and 1 if it succeded?

#

or maybe the opposite

fast lark
#

Li idk tag list

#

Like*

unique acorn
#

idk

#

I never tried it

fast lark
#

Okay

pale terrace
# chilly fractal ^^^

but the script will not wait util its success, because the command wait until the area load, not the script, if the area isnt loaded it will return 0 and will not wait until the command is success, so, you have to use a mcfunction with scriptevent anyway

dawn zealot
#

anyone got like an anti fly?

amber granite
#

anti fly

#

You mean pesticides?

unique acorn
#

he meant a mod that stops hacker from flying

amber granite
#

._. ik , i m just trolling

unique acorn
#

👍

dim tusk
#

Erm 🤓☝️ /ability @s mayfly false

amber granite
#

Hmmm

fast lark
#

And its buggy

#

Oh sorry i just read all messages

#

Lol

dim tusk
fast lark
dim tusk
dim tusk
fast lark
#

lol

fallen hearth
#

How can I change the slot selected by the player? I want to force him to change to a specific slot in the hotbar

pale terrace
#

I dont remember the name

fast lark
#

Nah after this i want to kms

dim tusk
#

It's both get and set property dude

fast lark
pale terrace
#

try player.selectedSlotIndex = 1 for example

dim tusk
pale terrace
dim tusk
#

right?

fast lark
#

I called myself i dont know for a reason

dim tusk
fast lark
chilly fractal
#

Turn that frown upside down baaaaabyyyyy

#

Woo

#

I am feelin happy

fast lark
#

New name

chilly fractal
#

I fully revamped my shitty compact+++ almost obfuscated code into 3 different addons with each for their own purpose and everything is a bit more descriptive

chilly fractal
#

Just learn

#

Read

#

And watch

#

And listen

fast lark
#

Your right

chilly fractal
#

You'll eventually know better than anyone

#

(Impossible but just lifting your spirits)

fast lark
#

Ye i know but i usually cant learn even if I want

#

My memory is ass

chilly fractal
#

☕️

#

🐟

pale terrace
dim tusk
amber granite
distant tulip
#

i should look into implementing a workspace feature

dim tusk
amber granite
dim tusk
#

i contributed 0.5% in that

distant tulip
#

less, lol

dim tusk
distant tulip
distant tulip
#

and suggestions

dim tusk
#

I love 🐛

#

I help people find bugs in their things but I can't find bugs in my own scripts 💀😐

zinc flax
#

How do I round off a float value leaving 2 decimal places?

dim tusk
#

What'd you guys think is the best way to check if a player's full body is submerged to water

#

not player.isInWater since it will return true if it hits any part of the players collision

celest abyss
#

Is it possible to add a property to an item?

#

item.setProperty("trix:test" += 1)

dim tusk
#

closest one is dynamic property

celest abyss
# dim tusk No.

So it's not possible to make a system where taking damage changes the texture of an item?

patent tapir
#

How do I set an item's name using this js sender.getComponent(EntityEquippableComponent.componentId).getEquipmentSlot(EquipmentSlot.Mainhand)

patent tapir
#

Would that actually work?

dim tusk
patent tapir
#

Idk

#

I always looked at the value properties as just values

#

Read-only, that is

dim tusk
#
const equippable = Player.getComponent('equippable');
const mainhand = equippable.getEquipment('Mainhand');
mainhand.nameTag = 'Bruhhh!';```
ivory bough
#

How to make my entity spawn behind or next to trees?

slim spear
#

Is that a thing that's in stable?

#

sorry for late reply, I opened this channel and it showed that

true isle
#

is it possible to make bocks place in a world similar to a scatter feature using script api?

solar dagger
covert goblet
#

Or block 3 higher than players feet is water

amber granite
#

Is there a method to get beta top screen infos ?

covert goblet
#

Can we not run custom chat commands from a command block??

round bone
knotty plaza
#

If you want to do something similar then you can use the scriptevent command

amber granite
#

Is there a general module that includes everything that script api dev may use it when working on add-on ?

untold magnet
#

hmm,

#

how am i going to detect the killed entity from world.beforeEvents.entityRemove component?

#

like how?

#

What I'm trying to do:
detecting when the charged creeper killed some specific mobs.

untold magnet
#

tell me if it is possible to detect the charged creeper as the killer in the entityDie component.

dim tusk
#

nvm that question lol

untold magnet
# dim tusk ~~Hmm, how are you detecting it?~~
world.afterEvents.entityDie.subscribe(({deadEntity: eEntity, damageSource}) => {
  const source = damageSource.damagingEntity;
  if (!source) return;
  const charged = source?.getComponent('minecraft:is_charged');
  if (source?.typeId === 'minecraft:creeper' && charged) {world.sendMessage('?')}
});;```
#

should i like unsubscribe or something?

dim tusk
# untold magnet What I'm trying to do: detecting when the charged creeper killed some specific m...

Can you do something like this?

const chargedCreepers = new Map();

world.beforeEvents.entityRemove.subscribe(({ removedEntity }) => {
   if (removedEntity.typeId === 'minecraft:creeper') {
      const isCharged = removedEntity.getComponent('is_charged');
      if (isCharged) chargedCreepers.set(removedEntity.id, true);
   }
});

world.afterEvents.entityDie.subscribe(({ deadEntity, damageSource: { damagingEntity } }) => {
   if (chargedCreepers.has(damagingEntity.id)) {
      chargedCreepers.delete(damagingEntity.id);
   }
});
#

since you said that you can't check if the creeper is charged in the entityDie as the killer

subtle cove
#

datadrivenentityevent and entitydie combo...

dim tusk
#

-# I forgot that it existed ngl

subtle cove
#

they trigger an event when they swell

#

ima take a look on it

dim tusk
#
world.afterEvents.dataDrivenEntityTrigger.subscribe(ev => { 
    const { entity, eventId } = ev; 
    for (const modifier of ev.getModifiers()) { 
        const { addedComponentGroups, removedComponentGroups } = modifier; 
        console.warn(`Added component groups: ${JSON.stringify(addedComponentGroups)}. Removed component groups: ${JSON.stringify(removedComponentGroups)}.`); 
    } 
});```
thorn flicker
dim tusk
untold magnet
#

ig

thorn flicker
thorn flicker
dim tusk
#

Lol

thorn flicker
dim tusk
#

ngl, I read it as id not typeId

#

It's removedEntity

#

Mybad @untold magnet

thorn flicker
untold magnet
#

nothing is working

#

:v

dim tusk
dim tusk
untold magnet
# dim tusk ^ you did this?

all codes:

const chargedCreepers = new Map();

world.beforeEvents.entityRemove.subscribe(({ entity }) => {
   if (entity?.typeId === 'minecraft:creeper') {
      const isCharged = entity.getComponent('is_charged');
      if (isCharged) chargedCreepers.set(entity.id, true);
      console.warn('8')
   }
});

world.afterEvents.entityDie.subscribe(({ deadEntity, damageSource: { damagingEntity } }) => {
   if (chargedCreepers.has(damagingEntity.id)) {
      chargedCreepers.delete(damagingEntity.id);
      console.warn('88')
   }
});```![bao_icon_entities](https://cdn.discordapp.com/emojis/937567566442922084.webp?size=128 "bao_icon_entities")
subtle cove
#

this is in afterEvents.entityDie

dim tusk
#

I just said it 😭

untold magnet
thorn flicker
#

t17x not acknowledging you is funny

#

and also infuriating to watch

dim tusk
thorn flicker
#

lmaoo

untold magnet
thorn flicker
#

and thats his response

dim tusk
thorn flicker
#

poor guy

untold magnet
#

double checking:

world.beforeEvents.entityRemove.subscribe(({ removedEntity }) => {
   if (removedEntity?.typeId === 'minecraft:creeper') {
      const isCharged = removedEntity.getComponent('is_charged');
      if (isCharged) chargedCreepers.set(removedEntity.id, true);
      console.warn('8')
   }
});```
#

alright it works,

#

my phone is doomed, twice...

dim tusk
#

-# somewhat a reference to a movie

untold magnet
dim tusk
#
world.afterEvents.entityHurt.subscribe(({ hurtEntity, damageSource: { damagingEntity, damagingProjectile, cause }, damage }) => {
   if (hurtEntity instanceof Player) {
      const effect = hurtEntity.getEffect('resistance');
      const amplifier = effect ? effect.amplifier : -1;
      const reduction = Math.min((amplifier + 1) * 0.2, 0.8);
      const resistedDamage = damage * reduction;
      const finalDamage = damage - resistedDamage;

      console.error(`Original Damage: ${damage}, Resisted: ${resistedDamage}, Final Damage Taken: ${finalDamage}`);
   }
   console.error(damage);
});
#

Halp, my calculations are wrong

#

-# I have a similar problem before... And I forgot where was the fixed

knotty plaza
dim tusk
#

Which isn't lol

untold magnet
# dim tusk Nice.

no matter how many mobs is killed, only one of them will drop its head

untold magnet
# dim tusk Nice.

YOU,
is this really necessary? chargedCreepers.delete(source.id);?

untold magnet
untold magnet
unique acorn
#

axolotl heads is evil 😞

untold magnet
meager cargo
#

Guys, need help:
This is not working and I don't know why:

world.afterEvents.playerInteractWithEntity.subscribe((eventData) => {
    const player = eventData.player;
    const entity = eventData.target;

    if (entity.typeId !== "test:open") return;
    if (!player.hasTag("player_1")) return;
    if (player.getDynamicProperty("interacted") === true) return;

    const existingScoreboard = world.scoreboard.getObjective("TEST") ?? world.scoreboard.addObjective("TEST");
    const currentScore = existingScoreboard.getScore(player) ?? 0;
    
    existingScoreboard.setScore(player, currentScore + 1);
    player.setDynamicProperty("interacted", true);
});

What's here wrong?
After I interact with entity, I don't get scores. Also my entity has transform component, so after player interact with it it should transform but score should be added

acoustic basin
#

hey guys, how can i randomize this item list, to get one random item to insert into my entities inventory later on?

const itemList = [
    "minecraft:torchflower_seeds",
    "minecraft:pitcher_pod",
    "v360:blue_bonnets_seeds",
    "minecraft:acacia_sapling",
]```
fallow minnow
#

with server-net are you able to write json files and read them?

acoustic basin
meager cargo
#

Can someone help me with scores? Please?

acoustic basin
#

ive been reading a lot about javascript for the last couple of days, strating to understand more and more

amber granite
#

Good for u

buoyant canopy
#

is there anything i need to know about before using explosion before event?

#

any bugs?

#

or limitations

rose light
#

Is it possible to spawn a particle for a player, and have it be visible to whoever I define? I'm using the 1.17 experiment

valid ice
#

It is, yes. You can use Player.spawnParticle() instead of Dimension.spawnParticle()

rose light
#

for example I, as an admin, can see the players through the particle, there will be a particle above the normal members and only the admins will be able to see it

valid ice
#

The Player.spawnParticle() spawns it only for one player; nobody else sees it except for them

rose light
amber granite
#

Guys

#

Is there a way to change the script whilst u r in the game ?

distant tulip
#

yes

neat hazel
#

Why is this happening?

#

Code:

mc.world.afterEvents.entitySpawn.subscribe(function (event) {
  const entity = event.entity

  for (let i = 0; i < entityIds.length; i++) {
    if (entity.typeId == entityIds[i].id) {
      entity.nameTag = ("Level: " + getScore(entity, "level"));
    }
  }
})

function getScore(entity, objective) {
  try {
    return mc.world.scoreboard.getObjective(objective).getScore(entity.scoreboardIdentity);
  } catch (error) {
    return error;
  }
}
amber granite
#

._. even if it has errors ?

honest spear
woven loom
#

why are ypu returning error

amber granite
#

Because i m on the phone and i hate modifying files over and over

#

And the pc is so sloooo

honest spear
#

weird

#

@neat hazel send more!

valid ice
#

Well, if the get score errors, it returns the error, so

honest spear
#

damn i se

#

my bad haha

#

i am blind or something

#

for sec i thought the getScore is native

#

haha

neat hazel
honest spear
woven loom
#

entity is not in sb then

honest spear
#

i am not using scoreboard apis too much

neat hazel
honest spear
woven loom
#

there might be test method, you should prob use that first

honest spear
#

i am fan of returning null and handling the possibility of it, but in some cases returning number would also make sense

honest spear
sterile epoch
#

does anyone know why spawnItem is working, but the item disappears too fast?

#

it spawns for like 1 second then just vanishes, I don't get it, am I doing something wrong?

valid ice
#

There's no pickup delay, if that's what you're after

sterile epoch
#

it's not that, I'm using addItem, and if the inventory is full it drops on the floor instead,

#

but I just tested it, it spawns for 1 second and immediately despawns before the player can take it

wary edge
#

Are you in creative?

sterile epoch
#

yeah

wary edge
#

That's why.

#

Creative mode doesn't care about inventory slots. If it's full, they just suck it up into the void.

sterile epoch
#

ahh I see

#

well I'm glad it'll work then

#

thanks

neat hazel
#

I think I managed to fix it

#

One question, is there entity.getComponent("minecraft:health").setDefaultValue
Or any way to change the default life of an entity without using its Json code?

honest spear
woven loom
#

yes

#

look for that in the docs

honest spear
#

there is no way in API

neat hazel
# honest spear

Exactly, you can only set the current value, not the default

woven loom
#

i meant max one

fallow rivet
#
world.beforeEvents.playerInteractWithEntity.subscribe((event) => {
event.cancel = true;
})
fallow rivet
#

So does this include a player picking up an item?

cold grove
#

like opening villager menu

fallow rivet
#

How can I find out the highest version of Minecraft-server and server-ui modules?

gaunt salmonBOT
amber granite
#

Guys

#

Who knows how to change my code while playing?

valid ice
#

wdym

#

use dev packs & /reload command?

amber granite
#

I want to change the code while i m testing

amber granite
drifting ravenBOT
#
Using the `development_*_packs` folders

The correct way to create addons is by using the development_behavior_packs and development_resource_packs folders. Storing your addons here will allow you to reload the world to see addon changes, and will prevent pack caching issues.

You can work directly in the world, or in behavior_packs/resource_packs, but you need an understanding of manifest-versions and caching to avoid issues.

We highly recommend using the development_*_packs folders.

celest abyss
#

world.beforeEvents.playerInteractWithEntity.subscribe(({ target, player }) => {
  if (target.typeId === 'trix:cucaracha') {
    const heldItem = player.getComponent("minecraft:inventory").container.getItem(player.selectedSlotIndex);
    if (heldItem && heldItem.typeId === "trix:maracas") {
      world.playSound(`random.tick`, player.location)
    
valid ice
#

before events cannot modify the world at all

amber granite
# drifting raven

Do u have a sample or an example,

  • Does it work in Minecraft bedrock pc or mobile or both ?
celest abyss
#

Ah

celest abyss
valid ice
random flint
celest abyss
#

Ty

amber granite
#

So

#

How to access it ?

buoyant canopy
#

is there a way to make a vanilla block wither proof?

amber granite
#

@valid ice , so i must put the folder inside add-ons folder , dosent .mcaddon work with it ?

random flint
#

.mcaddon makes minecraft import the addon into the "normal" and not "development" folder

The difference is the former gets cached into the world folder, while the "development" doesn't. Since it never get cached, you can edit it and use /reload in game

distant tulip
amber granite
#

I import my addons as .mcaddon

valid ice
#

If the pack is in the development folder, you just need to update the files and then run /reload

amber granite
#

Hmm , i need to put it inside games folders in programs/ windows?

valid ice
#

Wherever your com.mojang is

amber granite
#

Oh ok

#

Thx

valid ice
#

There's regular folders and development folders for BP & RP

amber granite
#

Ok then

valid ice
#

I am suprised you never knew about dev packs up until now

distant tulip
#

he did ask about it before, either he had problems with it and didn't get how it work or idk

amber granite
#

Maybe i m doing many things wrong

amber granite
#

Question

#

What i must do ?

dim tusk
amber granite
#

They told me dev behaviour pack ?

dim tusk
amber granite
#

._.

dim tusk
#

they mean is the coming.mojang folder

amber granite
#

Oh

#

Where i find it ?

#

Please

dim tusk
# amber granite Oh

C:\Users\USERNAME\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang

amber granite
#

Thank u

dim tusk
#

Or this

%localappdata%\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang

amber granite
#

Now i found it

#

Thanks for u

#

All

#

U saved me -6 months of work

#

Jk , thx u

umbral dune
#

One thing I would like to comment on about custom components.
From what I understand, so far the custom components are more like tags, it is not possible to give more information to the game other than saying that the block has so many components.
I hope that in the future, it will be possible to use custom components as {} objects, with their own properties.

wary edge
#

Don't worry, you're not alone in thinking this.

distant tulip
#

what is this thing called
accidentally enabled it and idk how

wary edge
#

kitty_ohno Do the youngins not know about insertion?

distant tulip
#

-# getting called youngins from someone younger than me bao_ext_toldyouso
cursor block or whatever it is called
what is Insertion too?

fallow rivet
#

If I write the code like this, will it work? bao_ext_toldyouso

wary edge
distant tulip
#

i know what id does lol
just not the name
searching show result on vim, idk how my finger even reached there lol

sterile epoch
#

is there no regeneration option in ItemStack.createPotion?

amber granite
#

Hmmm is math random is even that random

#

I read about randomness while learning some c++

dim tusk
amber granite
#

I don't understand statistics: P

unique acorn
#

But it (gladly) does do it's job.

dim tusk
#

guys regarding this.

#

is this how you use it?

Entity.setDynamicProperties({
    property1: "value1",
    property2: 42,
    property3: true
});
unique acorn
#

oh nvm

#

it's properties not property

sterile epoch
#

can someone help, how do I give someone a regen potion with itemStack.createPotion

#

there's no way regen actually doesn't exist as an option

dim tusk
amber granite
#

Huge project is coming!!!!

sterile epoch
#

Healing works, and just gives me instant health

sterile epoch
#

all of the effects are uppercase

dim tusk
#

tho it doesn't matter ngl

#

Typescript?

sterile epoch
#

no, js

#

I feel like I'm actually tripping

sterile epoch
#

yeah that's the one I followed

#

nevermind I was doing the 1.21.51 version and apparently regeneration just doesn't exist there

#

bruh wtf

#

nice so I have to wait till 1.21.70 to use potion effects

#

why tf would half of them be missing anyway?

dim tusk
#

tho I didn't try it.

granite badger
sterile epoch
amber granite
#

They always forget what people needs | : ( * mad villager noices*

sterile epoch
#

my whole system relied on the create Potion method so this is really annoying

distant tulip
dim tusk
#

btw I added too many themes lmfao

amber granite
#

Please minato the next time remove the placeholder text it s annoying for mobile ppl

distant tulip
#

auto save to an empty file, it should keep it

dim tusk
#

btw is that draggable?

distant tulip
amber granite
#
  • make it so u can select text too :-:
distant tulip
distant tulip
dim tusk
dim tusk
distant tulip
#

😭

amber granite
#

I can ?

#

._.

#

Bro i m on the mobile

#

I really struggle with that

dim tusk
#

-# skill issue

distant tulip
#

drag select

sterile epoch
#

is there another way to give potion types? I'll have to change my system specifically for regen ig

sterile epoch
#

yeah could do that

dim tusk
#

since commands can't do that since it's id is only potion

amber granite
#

Or setItem

distant tulip
#

create potion should work

dim tusk
sterile epoch
# dim tusk structure?

also, I have a question, let's say 2 people stand close to a structure item, does the person with better internet pick it up?

dim tusk
#

There's data systems

sterile epoch
#

or would it be the person you load it on since they're closest?

dim tusk
#

/give @s potion 1 10

amber granite
#

Idk but , they doing it to make ppl struggle or their funds are very low

sterile epoch
#

yknow it's strange that system still exists, they changed concretes to have unique IDs but not potions

dim tusk
#

-# or notepad++ 😝

#

I'm making a plugin for notepad++ lmfao

distant tulip
distant tulip
amber granite
#

Hmm , i have question ,_,
Is there a loophole that can we use it to get more script api features

#

Idk like , getting some real in used game functionalities in c++

#

Using js

#

And some loopholes

dim tusk
#

Tho limited asf

distant tulip
#

lets move to #off-topic

valid ice
distant gulch
#

Hello Guys

valid ice
#

haii

distant gulch
#

How are you?

#

Kinda dead in here, 21.220 Members but only 227 Online

valid ice
#

227? There's 3.6k online

thorn flicker
valid ice
#

ah ye

#

Thread had to be cleared out because there's a max user limit per post :discordthink:

thorn flicker
#

im curious why its not just a channel then

#

but you would have to do that with the other forums to be consistent

#

would not look nice neither

wary edge
#

Back then we only had 10k members and scriptAPI was a niche thing.

deep arrow
distant gulch
flat dew
#

are beta scripts generally safe to use? I've been waiting for the chat functions to come out forever. HCF and beta json stuff would make it so your world was permanantly stuck like that, but can you just turn beta scripts off once the stuff you use goes out of beta?

drowsy scaffold
#

If you plan on actively maintaining and updating your addon, then yes. otherwise, no.

#

Stable is only better for the reason that it never should need upated.

wary edge
flat dew
#

i didn't realize beta-apis needed a toggle ._.

valid ice
#

They're safe in that they won't just randomly corrupt your world

And the script API toggle will be around for quite some time yet, as the team is always adding new features

drowsy scaffold
#

well I was not aware of that, interesting to know

flat dew
#

is there any way to tell what parts will come out of beta? I thought the chat functions were in beta 1.16.0 when we were on 1.15, but now they're in beta 1.17

valid ice
#

Readin' the changelogs

flat dew
#

i mean ahead of time, like if there were some other info source on what would actually come out of beta rather than just stay there each update

wary edge
wary edge
#

No, the preview changelogs.

flat dew
#

where are those?

flat dew
#

Thanks!

#

rip to chat events. unless I missed them they'll be in beta all the way to 1.19 at least

valid ice
#

Well, there ain’t no 1.19

#

It’s now 1.18.0 and 2.0.0-beta for versions, starting in 1.21.70 previews

flat dew
#

i figured since the 1.18 posts didn't say anything about them they would stay in beta through 1.18

#

I just wanna make typed-in-chat skyrim shouts. lol

#

if they remove a beta script thing can you still access it by setting your script version back to a version that had it?

valid ice
#

You cannot

#

Beta versions do not have backwards compatibility

flat dew
#

dang

#

thanks for answering my questions

full brook
#
let playerIndex = 0;
system.runInterval(() => {
  let players = world.getAllPlayers();
  if (players.length === 0) return;

  let player = players[playerIndex]; 
  if (player) {
    player.sendMessage(`${playerIndex}, ${player.nameTag}`);
  }

  playerIndex = (playerIndex + 1) % players.length; 
},1);
valid ice
#

Why not just forEach or for loop it

full brook
valid ice
#

All the same

#

Just the way that you’re doing it is a bit… unorthodox

full brook
#

ohh, I'm trying to find the most efficient way to runInterval besides changing the tick

#

.

valid ice
#

Without changing the tick?

#

So everything executes for all players in the same tick?

full brook
#
system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        const item = player.getComponent('inventory').container.getItem(player.selectedSlotIndex)
        if (item === undefined) {
            world.sendMessage('test')
        }
    }
})

if using this then the code will be executed on all players at the same time, if using the one I sent earlier then the code will be executed alternately for each player

valid ice
#

It still runs in-order, for both a for loop and a forEach

valid ice
full brook
#

so which do you think is more efficient?

valid ice
#

Do you need to sequentially run code for each player, so each runs one tick after the last player?

full brook
#

umm, I just want if there are a lot of players, it won't overload cpu

valid ice
#

I would suggest using runJob & generator functions

#

It automatically allocates as much code per tick as can be run, then runs the next stuff when it can

#

There's an example on how to use the function on that page

full brook
#

ok thanks

celest abyss
#

It is possible to obtain all blocks of a certain type within a specific radius. ?

#

getBlockFromRay
Could it work?

dull shell
#

how can I make a block run a command every x seconds?

wary edge
patent tapir
#
import { world } from "@minecraft/server"

world.afterEvents.buttonPush.subscribe((data) => {
  const source = data.source
  const block = data.block
  const buttons = [
    {
      button: {
        z: 8,
        y: 51,
        x: -14
      },
      rank: "alts:green"
    },
  ]
  const buttonMapRank = new Map(buttons.map(({ button, rank }) => [button, rank]));
  const rank = buttonMapRank.get(block.location)
  const roleTag = source.getTags().find(findTag => findTag.startsWith(rank.substring(0, 6))) == undefined ? "" : source.getTags().find(findTag => findTag.startsWith(rank.substring(0, 6)))

  if (rank == roleTag) {
    source.removeTag(roleTag)
  } else {
    if (roleTag === "") {
      source.addTag(rank)
    } else {
      source.removeTag(roleTag)
      source.addTag(rank)
    }
  }
})```
#

Why isn't this working

#

I'm trying to make a wall of buttons that you can push to add/remove a tag

#

But I only want one tag on each person of each prefix

#

So, like 1 tag from alts: and 1 tag from ranks:

#

Wait I broke the code that I was trying to show hold on

#

There we go

#

When I push a corresponding button nothing happens, at all. Not even an error. Absolutely nothing changes

dim tusk
# patent tapir ```js import { world } from "@minecraft/server" world.afterEvents.buttonPush.su...
import { world } from "@minecraft/server";

world.afterEvents.buttonPush.subscribe((data) => {
  const player = data.source;
  const block = data.block;
  
  const buttons = [
    {
      pos: "-14:51:8",
      tag: "alts:green"
    },
  ];

  const buttonMap = new Map(buttons.map(({ pos, tag }) => [pos, tag]));
  const blockKey = `${block.location.x}:${block.location.y}:${block.location.z}`;
  const tag = buttonMap.get(blockKey);

  if (!tag) return;

  const currentTag = player.getTags().find(t => t.startsWith(tag.substring(0, 6))) || "";

  if (tag === currentTag) {
    player.removeTag(currentTag);
  } else {
    if (currentTag) player.removeTag(currentTag);
    player.addTag(tag);
  }
});
patent tapir
#

Ok

#

Ill try this

#

I just realized

#

BROO

#

I FORGOT TO IMPORT IT IN MAIN.JS WTF 😭

#

But your method is probably more efficient anyway

patent tapir
#

And I can't for the life of me figure out why that is

dim tusk
patent tapir
#

Is this supposed to be replacing the original if statements

dim tusk
#

yeah.

patent tapir
#

And what's the currentTags variable

dim tusk
#

still the same

patent tapir
#

There's no currentTags variable in your code

#

Unless the if statement defines it by itself but I doubt that

dim tusk
patent tapir
#

Is the subString wrong?

dim tusk
#

can you explain what you're doing again.

patent tapir
#

I'm trying to make a wall of buttons that you can push one of them to add/remove a tag, BUT there are families of tags differentiated by their PREFIX, like "rank:" and "alts:". I only want each person to have a MAXIMUM of ONE tag per prefix

#

Does that make sense?

dim tusk
#

then the problem is the substring

patent tapir
#

Ok is it the first or second parameter (the prefixes are always 5 characters long, including the ":")

#

Substring has a tendency to confuse me because I'm not sure what character it starts and ends counting at

#

Is subString(0,5) going to select the first five characters, or four characters? Is subString(1,6) going to select the first five characters starting from the second letter, or the first? Things like that.

#

Welp

#

I figured it out by myself

#

It was in fact the substring

#

It needed to be (0,5) instead of (0,6)

subtle cove
wary edge
# subtle cove ever tried `level.dat` file?

In game. Anything is possible via external modifications. But you're not going to tell someone to edit the binary files using dll injections and hex editor to build past the 128 block height limit in the Nether.

subtle cove
#

Just text editor

subtle cove
#

It's still risky ngl

cold grove
runic crypt
#
system.afterEvents.scriptEventReceive.subscribe((event) => {
    if (event.id === `gwim:bounty` && event.initiator === `minecraft:player`) { 
        let player = event.initiator;
        player.sendMessage(`Testing`);
        setManualDailyBounty(player)
    }
});

can anyone help me ?
This scriptevent isn't working
When i use the command, it just says that the scriptevent is sent
it doesn't even give errors

#

if anyone can help, then please ping me

random flint
#

@runic crypt

runic crypt
#

Okay thank you

#

@random flint

system.afterEvents.scriptEventReceive.subscribe((event) => {
    if (event.id === `gwim:bounty` && event.sourceEntity === `minecraft:player`) { 
        let player = event.sourceEntity;
        player.sendMessage(`Testing`);
        setManualDailyBounty(player)
    }
});
#

if you meant like this
then it doesn't work :D

#

wait is it because i have event.sourceEntity twice ?

random flint
#

*Did you import it?

#

Using it twice shouldn't be a problem

random flint
#

for && event.sourceEntity ==...

runic crypt
runic crypt
#

what if i remove it btw ?

#

just keep the second event.sourceEntity

random flint
#

Yeah, kept that one. Don't change it

runic crypt
#

ok ok

#
system.afterEvents.scriptEventReceive.subscribe((event) => {
    if (event.id === `gwim:bounty`) { 
        let player = event.sourceEntity;
        player.sendMessage(`Testing`);
        setManualDailyBounty(player)
    }
});
#

imma try this 🫡

dull shell
#
  world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
    blockComponentRegistry.registerCustomComponent('jay4x:egg_block', {
      onTick() {
        if (system.currentTick % 20 === 0) {
          console.warn('tic')
        }
      }
    });
  });```
how would I run a command off this?
random flint
# dull shell ```js world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }...

Here's a janky way.

 world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
    blockComponentRegistry.registerCustomComponent('jay4x:egg_block', {
      onTick(event) {
        if (system.currentTick % 20 === 0) {
          console.warn('tic')
          const location = event.block.location;
          event.dimension.runCommand(`execute at ${location.x} ${location.y} ${location.z} run say ...`)
        }
      }
    });
  });```

If you don't care about position, then skip the `/execute` and `const location` part.
Though advised to just use native method instead of commands.
dull shell
runic crypt
#

@random flint
either im doing something wrong
or part of my code is wrong cuz its still not working :F

dull shell
#

and amen for that 🙏

runic crypt
random flint
dull shell
#

oooo okay thank you!

#

i assume theres a setblock one too? I just have to look around

random flint
dull shell
#

so like this?

  world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
    blockComponentRegistry.registerCustomComponent('jay4x:egg_block', {
      onTick(event) {
        if (system.currentTick % 20 === 0) {
          const location = event.block.location;
          event.dimension.spawnEntity("minecraft:chicken", event.block.location);
          event.block.setType("air");
          event.block.spawnParticle('minecraft:totem_particle', event.block.location);
        }
      }
    });
  });```
#

i added the spawnParticle

random flint
#

Ye. You can clean the code afterward

native orchid
#

can i change the block permutation to be place in beforeOnPlayerPlace? I tried permutationToPlace = permutationToPlace.withState(...) but doesn't work

ivory bough
#

How to make my entity despawn when there is a block in front of the player's eye or sight which blocks the player from seeing my entity.

grave thistle
#

has anyone made a way to stop pistons from pushing custom blocks? I remember there being a block component ages ago that had that as a toggle but no longer

empty yoke
#

You can use gpt API in your world?

chilly fractal
prisma shard
prisma shard
#

no way lol

chilly fractal
#

The text editor bruh

unique acorn
#
const equ = player.getComponent("equippable");
const damage = equ.getEquipment(EquipmentSlot.Chest).getComponent("durability").damage;

this keeps saying Failed to get property 'damage' at onUse (index.js:228), why?

#

the item is a diamond chestplate

sharp elbow
#

When in doubt, check every step of the way:

const equ = player.getComponent("equippable");
console.warn(equ.typeId);
const chestitem = eq.getEquipment(EquipmentSlot.Chest);
console.warn(chestitem.typeId);
const durability = chestitem.getComponent("durability");
console.warn(durability.typeId);
const damage = durability.damage;
console.warn(damage);
#

Perhaps the item is not damaged, or perhaps your scripting API version does not have an item durability component class. Need to check every edge case

subtle cove
sterile epoch
#

is there a native api method to give tipped arrows like there is for createPotion?

honest spear
#

no there is not afaik

scarlet sable
#

is the fog a json ui thing?

cold grove
wheat condor
#

rp/fog/fog1.json