#Script API General

1 messages · Page 105 of 1

dusky flicker
#

the only thing is that you cant stop

frozen vine
#

Is it possible to create custom death message when player dies by script like applyDamage ?

frozen vine
minor horizon
#

does this only work for players?

subtle cove
#

Since equippable dont work well with non-player entities, so yes

#

Toughness is from the netherite, from what I've recently observed

minor horizon
#

yeah

vagrant flame
#

Dumb question. is there anything weird about the custom commands like cant run on single player or anything?

subtle cove
#

Make sure the registration happens at startup

subtle cove
vagrant flame
#

Is ther a good way to see if registration happens?

subtle cove
#

Uhm, can't test atm
But u can see the difference that it appears doing /

vagrant flame
#

i will fiddle a bit. i found one issue... i screwed up the manifest and it unloaded my pack from the world and i was testing without the pack on...

#

okay figured it out

livid elk
#

uhh why entityHealthChanged .newValue print a lot of decimals for player?

world.afterEvents.entityHealthChanged.subscribe(ev => {
  const entity = ev.entity;

  console.warn(entity.typeId + ': ' + ev.newValue);
});
sly valve
#

Yes

round bone
#
const roundedValue = Math.ceil(ev.newValue * 100) / 100
jagged gazelle
#

I have 7 more.

sly valve
round bone
jagged gazelle
jagged gazelle
visual zephyr
#

how can i get a value of the players scoreboard

#

nvm found it

halcyon phoenix
gaunt salmonBOT
dusky flicker
#

we have no access to the internals of it, so theres literally no way to know if on minecraft its treated as a integer or float

dusky flicker
visual zephyr
#

is there a way to hide the commands with namespaces

dusky flicker
#

"cost"

granite badger
#

That’s the raw value btw, we usually see its rounded value

dusky flicker
#

wtf do the developers have in mind?

subtle cove
#

0.1 hp is still half heart

warm mason
dusky flicker
warm mason
#

at least if it was an integer it would be inconvenient

dusky flicker
#

it would be more precise

warm mason
#

I especially need this very much

dusky flicker
#

but why exactly you couldn't do so?

warm mason
#

and float has no downsides

dusky flicker
warm mason
dusky flicker
warm mason
#

What do you mean by this?

dusky flicker
#

you wanna know about how much cycles a cpu uses to make math on floats as well?

subtle cove
#

bits don't mather

warm mason
dusky flicker
warm mason
#

+0.000001 ms slowdown

warm mason
dusky flicker
#

oh wow you proved you gain 0.1ms by a message

#

incredible

warm mason
#

if health was an integer you would have to create workarounds to make it a float and that would be much less performant

dusky flicker
warm mason
dusky flicker
round bone
#

but we are in channel that uses 💩 JAVASCRIPT

#

and it's the same piece of shiii.. for engine

warm mason
warm mason
#

you have a question like "why not use an integer? and it doesn't matter that we need a float"

livid elk
#

is there a way to remove the namespace for the custom command?

floral timber
#

so why would you exactly need to remove the namespace when u have one without it?

livid elk
floral timber
#

and?

#

do /book

livid elk
#

ohhh lol

#

thanks xD

floral timber
#

np

leaden elbow
#

is there a list of blocks/items/entity param in minecraft/server

leaden elbow
#

got it

#

EntityTypes.getAll() right?

#

and so on

halcyon phoenix
#

yeah

#

it's performance intensive though so try not to call it very often

#

save it on a variable on startUp

#

or something

leaden elbow
#

got it thanks

#

last thing how can i use the localization key for my form button text?

warped blaze
leaden elbow
#

any sample snippet of it?

subtle cove
#
const form = new ActionFormData()
    .button({ translate: item.localizationKey })
livid elk
#

is there a way to control entity gravity?

subtle cove
#

no, u gotta learn bedrock physics 1st

snow knoll
sharp elbow
#

Might be easier to write your own physics engine, honestly

#

Simulating custom gravity is trivial when you are fully in control of the acceleration

#

Then, knowing the position of your simulated physics, you could simply /teleport the entity to that location.

snow knoll
#

Does anyone know what the conversion from applyKnockback to blocks per second is?
And the conversion of applyKnockback horizontally to applyKnockback vertically?

distant gulch
#

Yo someone can tell me if herobrine made a chest ui where u can see ur inventory that updates

dusky flicker
honest spear
#

@valid ice Let me ping for confirmation

valid ice
#

yes

#

Just retextured actionform

honest spear
#

Meme of the week - 1

cinder shadow
#

I think herobrine made a chest ui where you can see your inventory

distant gulch
distant gulch
#

My chest ui is broken

#

It shows random textures if i usa the item id

untold magnet
#

umm, is this even a thing?
if (player.isSneaking && whatever else) {import 'something' from 'other script'}?

untold magnet
snow knoll
#

Is it extremely taxing on performance that you really can't afford for it to run at all times?

untold magnet
sharp elbow
#

There is, kinda. Dynamic imports

#

I would not personally use it in this way, as an action as common as a player sneaking is not a good use for dynamic imports

untold magnet
#

like the other script detect whenever the player break a block, i dont want to call that all time

wary edge
#

I think this just means you need to restructure your code a different way then.

sharp elbow
#

You could choose to selectively subscribe or remove subscriptions depending on when they are needed

untold magnet
#

so all i need to do next is turning on the addon functionality only when the addon is activated

#

like:
if (addon === true) import 'smth' from 'addonScript';

#

i just want to know if that is a thing or not

untold magnet
#

like it doesnt have any delays i believe

#

anyways u get the point, i am doing that for some kind a better performances or something

sharp elbow
#

I getcha, I see the vision. There are dynamic imports, but there are drawbacks to these—they are asynchronous. Makes more sense to simply export a function that does your event subscriptions when invoked

#

So instead of dynamically importing a module where you have event subscriptions at the top level, you could export a function that subscribes to those for you

untold magnet
#

i see, how tho?

sharp elbow
#

block-breaking.js

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

export function enableBlockBreakingFunctionality() {
  world.afterEvents.playerBreakBlock.subscribe( /* ... */ );
}

main.js

import { enableBlockBreakingFunctionality } from "./block-breaking";

if (whatever) {
  enableBlockBreakingFunctionality()
}
untold magnet
#

i see..

#

so basically i need to put the whole addon functionality inside a function and run it only when needed?

sharp elbow
#

Yeah, like C-style programs in a way

#

Have a "main" function that serves as the entry to your program's logic

hazy nebula
#

Is there a way to make it so that when the player moves it runs the command. and tp an entity and this entity will face a direction

untold magnet
#

-# detecting if the player is moving or not

sharp elbow
#

Slightly better way to detect this:

const movement = inputInfo?.getMovementVector();
if (Math.fround(Math.hypot(movement.x, movement.y)) == 1) { /* ... */}
sterile epoch
#

can someone explain how you make a discord bot that sends your realm stuff to discord

sterile epoch
#

isn't it to do with a script module tho?

distant gulch
#

something wrong with the command builder

#

im pretty confused

untold magnet
#

btw, what should i use to detect when the player jumps? bec player.isJumping isnt working properly, like holding the jump button will keep increasimg my dynamic property value,

#

maybe isJumping and isOnGround somehow?

#

that could work but, i can see how buggy it will get so i need ot figure out a better method

untold magnet
cinder shadow
#

Alternatively, we have the playerButtonInput after event

untold magnet
cinder shadow
#

it activates everytime the jump button is pressed

untold magnet
#

if u look at the player exhaustion value while jumping, u will know what im talking about

untold magnet
#

how the player exhaustion value increases only after jumping

cinder shadow
#

what exactly are you trying to do then?

#

make thirst have the same rate as hunger?

untold magnet
#

recreating the vanilla exhaustion thing for my addon

cinder shadow
#

then you should just use a system.runInterval

untold magnet
cinder shadow
#

If you can directly read the exhaustion value, there's no reason to try and recreate it

untold magnet
#

that is an option, but that will make the thist bar connected to the hunger bar in a weird way

#

like getting hunger might affect the hydration bar too

#

ill try this ig if (player?.isJumping && player?.isOnGround) {***}

cinder shadow
#

wouldn't you want saturation to also affect the hydration bar though?

untold magnet
#

and i know it will be bugged if u are not jumping due to standing under a block

cinder shadow
#

jumping and slamming your head into a block above you would be pretty exhausting

untold magnet
cinder shadow
#

yeah, idk why you aren't just reading the players exhaustion numbers

#

but if you really want it to be separate I guess you could check if there's a block above the players head

#

that would probably be easiest

cinder shadow
#

because of the effect?

untold magnet
#

and u know what, that sounds good lol

#

like drinking dirty water will affect ur hydration and hunger

subtle cove
# distant gulch

U can only change the callback in /reload,
As for that error usually needs world restart

untold magnet
jagged gazelle
#

My dumbass really thought .filter() is broken. I did this js .filter(e => e?.id !== player?.id) confused why it ain't working and I just realized it's e.entity.id not e.id... lmao

untold magnet
#

i think i get it

cunning canyon
#

Guys quick question, whats the difference between setProperty and setDynamicProperty? :p

jagged gazelle
jagged gazelle
#

Imma guess that's health since 20?

untold magnet
untold magnet
jagged gazelle
untold magnet
jagged gazelle
leaden elbow
#

it only translates for me when value is localization key alone

#

rawText?

untold magnet
jagged gazelle
leaden elbow
#

got it thanks

#

one last thing, how can i retreive the information of an item like i will provide its type id, and retreive its localization key?

leaden elbow
#

i mean for entities and blocks**

subtle cove
leaden elbow
#

got it

round bone
#

Why am I coding at 3 AM

#

😭

subtle cove
#

Sth like magic when ur in void, where lota possibilities r flowing and u don't wana unsub

round bone
#

I was kinda bored and I couldn't fall asleep, so I am using my brain to eventually start sleeping

leaden elbow
#

thanks so much

#

can i make it something like new Entity(typeId).localizationKey?

#

because i was only given with type ids by EntityTypes and BlockTypes

jagged gazelle
#

for the entity summon them first then remove them, for item stack try making a constructor then do it.

subtle cove
#

EntityTypes.getAll().reduce
spawnEntity().localizationKey
remove()

#

Tbf, the localizationKey should be in (Entity|Block) Type

jagged gazelle
round bone
leaden elbow
#

just did trimming of minecraft: and adding tile.---.name in between. thanks yall

subtle cove
#

It doesn't work for a few

wicked girder
#

Is it possible to get the name of a block? not the type id?

jagged gazelle
wicked girder
#

idk what you mean but i think either or

jagged gazelle
#

Just translate it with rawtext translate...

wicked girder
#

ah

jagged gazelle
#

refer to this three messages I replied to

wicked girder
#

dang thats beta

#

wait maybe not

livid elk
#

do you guys know how i can get a player's equipped armor and use it as a server form button image?

lethal bramble
#

like

#
const chestplate = player.getComponent("minecraft:equippable").getEquipment("Chest")
if (chestplate) {
  switch (chestplate.typeId) {
    case "minecraft:diamond_chestplate":
      // use diamond chestplate texture
      break
    case "minecraft:iron_chestplate":
      // use iron chestplate texture
      break
    // etcetera
    default:
      // not a chestplate
  }
}```
granite badger
#

I might have a script with a pack that maps to item texture, if you’re interested

granite badger
#

Basically an item render in textures folder, then a json file that maps item id to texture path.

livid elk
#

sure :))

lethal bramble
#

i thought u couldnt

granite badger
granite badger
livid elk
#

thanks!

dusky flicker
livid elk
#

how can i get all entities in another dimension? i can’t get entities in the end if I’m in a different dimension

warm mason
livid elk
#
world.afterEvents.itemUse.subscribe((ev) => {
  const item = ev.itemStack.typeId;

  if (item !== "minecraft:stick") return;

  const overworld = world.getDimension('overworld');
  const theEnd = world.getDimension('the_end');

  if (overworld) {
    const endermen = overworld.getEntities({ type: 'minecraft:enderman' });
    if (endermen.length > 0) {
      console.warn(`- Overworld has ${endermen.length} enderman(s)`);
    } else {
      console.warn(`- No endermen found in Overworld`);
    }
  }

  if (theEnd) {
    const endermen = theEnd.getEntities({ type: 'minecraft:enderman' });
    if (endermen.length > 0) {
      console.warn(`- The End has ${endermen.length} enderman(s)`);
    } else {
      console.warn(`- No endermen found in The End`);
    }
  }
});
jagged gazelle
#

probably they are unloaded?

livid elk
#

does the dimension unload every time I leave it?

subtle cove
#

*chunk in the dimension

main basin
#

is it possible to check if a block is transparant or not

#

like false for stone dirt etc , true for flowers torches

buoyant canopy
#

how to make sub commands for custom commands like 'time set' and 'time add'?
the first argument is neither an enum nor string

#

is it even possible?

warm mason
subtle cove
floral timber
#

what item component trigger itemStartUse and related events?

main basin
buoyant canopy
#

i ended up splitting it into 2 separate commands

warm mason
buoyant canopy
#

well, yeah, but since i can't make it match vanilla commands anyways i might just split it

warm mason
#
system.beforeEvents.startup.subscribe(data => {
    data.customCommandRegistry.registerEnum('my:action_type', ['give','take']);

    data.customCommandRegistry.registerCommand({
        mandatoryParameters: [
            {
                "type": CustomCommandParamType.Enum,
                "name": "my:action_type"
            }
        ]
    });
});
deep quiver
warm mason
buoyant canopy
floral timber
warm mason
#

the arguments do not change depending on the previous ones.

#

so it is possible to repeat it completely

warm mason
buoyant canopy
warm mason
buoyant canopy
#

i guess it's fine

buoyant canopy
#

i have seen CustomSpawnRulesRegistry in the change logs of 1.21.100, what's that about?

untold magnet
#

well, how can i detect when the player joins the world to do something for that specific player? like not playerSpawn bec it will trigger every time u respawn

#

maybe playerJoin and add getAllPlayers inside?

#

lets give it a shot ig

wary edge
untold magnet
wary edge
untold magnet
# wary edge `!player.initialSpawn`

umm, i just need to put that inside the code? like:
world.afterEvents.playerSpawn.subscribe(({player}) => {!player?.initialSpawn; otherStuff...});;

wary edge
#

No.

#

Please learn about early returns.

untold magnet
#

i just didnt get it, lol

wary edge
#

Please read the docs.

stark kestrel
#

Refreshing actionforms? Is there a way to close them?

subtle cove
#

yes

stark kestrel
subtle cove
#
import { uiManager } from "@minecraft/server-ui";

uiManager.closeAllForms(player)
stark kestrel
subtle cove
#

ye

stark kestrel
#

Ayy tysm

subtle cove
#

havent tested tho, but since it uses forms, then it should work

valid ice
#

yes

untold magnet
stark kestrel
#

@untold magnet

untold magnet
prisma shard
untold magnet
prisma shard
#
if (!player?.initialSpawn) return;

is writing same as

if (player?.initialSpawn) {}
untold magnet
#

initialSpawn is not connected to the player, thats what the docs said

#

like the playerSpawn thing has initialSpawn and player,

prisma shard
#

oh

#

maybe

#

yeah

#

its maybe a event property not of player idkj

untold magnet
distant tulip
wary edge
#

Yeah true.

untold magnet
#

thats why i was confused in first place, SkibidiStack said !player.initialSpawn and the docs said something else

wary edge
untold magnet
#

i was reading the docs while i was asking u

distant tulip
untold magnet
#

at least its working now

distant tulip
#

I might add two commands to our bots just for you, lol

buoyant canopy
#

Can we make command errors only appear in chat and not the content log?

#

If i use throw in a custom command it sends a red message in chat and a content log error, is it possible to stop the latter?

untold magnet
# wary edge Would it kill you to read the docs?

btw, the effectiveMax of the player exhaustion is 20, then why when i try getting the currrentValue it will reach 4 and decrease the player hunger? isnt it supposed to be 20? why is it set to 4?

untold magnet
# wary edge Idk what this means.

player.json: "minecraft:player.exhaustion":{"value":0,"max":20},
script: console.warn(player?.getComponent('minecraft:player.exhaustion')?.effectiveMax) returns 20
so the player exhaustion should decrease the player hunger only when it reaches 20

thorn flicker
#

it should be 4.

untold magnet
#

but when u doconsole.warn(player?.getComponent('minecraft:player.exhaustion')?.currentValue) it will reach 4 and decrease the hunger

warm mason
#

🍿 👀

thorn flicker
#

so report it as a bug.

wary edge
#

I lowkey don't even know what exhaustion is.

untold magnet
wary edge
thorn flicker
wary edge
#

Yeah, it's saying it can be a max of 20 but it will start decerasing hunger at 4.

#

Not a bug.

thorn flicker
#

hm

wary edge
#

The wiki even shows it can go over 4 and this lines up with how it works in game.

thorn flicker
#

got it

untold magnet
#

i see, then why is the effectiveMax set to 20? for better calculations or something?

wary edge
#

That's all it is saying.

untold magnet
#

i see,

thorn flicker
#

happy that this is now stable

buoyant canopy
#

Can someone help me make a loop that goes through all the chunks around the player starting from the nearest chunk and stops once it hits an unloaded chunk?

wary edge
#

That just sounds like math. 2 for loops for x/z, increment by 16 and use getBlock

buoyant canopy
#

🤨 what?
this gives me an idea though

#

no never mind, my idea won't work

wary edge
#

Just make two loops that goes over every 16 blocks, getBlock, if undefined then its unloaded.

#

Not that hard.

buoyant canopy
#

i was thinking of creating an empty array, run some nested for loops to push chucks to it by incrementing then decrementing 16 then use the array sort method to sort them by distance from the player, but the loop will halt as soon as it hits an unloaded chuck leaving potential loaded chunks outside the array.

wary edge
#

I mean, what are you trying to achieve? You could easily just hardcode it lowkey based on simulation distance.

buoyant canopy
#

i have a slime chunk function, i wont to create a command to find the nearest slime chunk from the player location

wary edge
#

I see.

buoyant canopy
#

now i think about it, i don't even need the chunks to be loaded

wary edge
#

Since slime chunks arent seed based, why not hardcode it?

buoyant canopy
buoyant canopy
wary edge
#

You could use runJob

warm mason
wary edge
#

That's what I mean.

buoyant canopy
# wary edge You could use runJob

i was thinking of using system.runInterval until i hit an unloaded chuck, but i will still have to create the array in one tick if i go with my method, because the array needs to be sorted

#

realistically the player will never hit an unloaded chunk before hitting a slime chunk but i still want to prevent an infinite loop situation

wary edge
buoyant canopy
#

since i don't really have to worry about unloaded chunks i guess i could hardcore a sorted array of all the chunks 1000 blocks around the player and system.runinterval through it until the player hits a slime chunk or reaches the end of the array somehow

#

but i really don't want to put a large ugly array in my code

fast wind
#

Can you compare two chest inventories?

wary edge
#

You could probably decompile java code and see how the locate command works and base it off that.

buoyant canopy
fast wind
#

Yes I'm doing that

#

Wondered if there was a better way

#

Thank you anyway

buoyant canopy
#

are you using the isStackableWith() item method or just comparing the item ids?

wary edge
fast wind
#

Nice thank you

fast wind
buoyant canopy
fast wind
#

Thank you

livid elk
#

is there a way to display new text below the player name without modifiying nameTag?

buoyant canopy
wary edge
#

Yeah, arrays arent the only data structures.

buoyant canopy
#

it even generated the js code for it

warped blaze
distant tulip
warped blaze
#

oh so u can request a template with its comments in your desired language ig

distant tulip
#

yeah

dusky flicker
round bone
#

I am waiting for update in DSA that will add non-binary trees and implement non-binary searches, which will be faster

#

-# It's a joke, I am familiar with DSA

buoyant canopy
dusky flicker
buoyant canopy
#

ah, you didn't use it for a grid like i did

leaden elbow
#

is it possible to get the amount of custom items (not vanilla ones)

dusky flicker
#

wasnt made by me but a friend

#

the project is discontinued, i realized that implementing a 2D renderer is damn hard

#

and i was doing it the wrong way

warped blaze
leaden elbow
#

the amount of custom items that were added in minecraft

warped blaze
#

ig there's a way but I'm not sure if it would even work

subtle cove
#

ItemTypes.getAll().filter

dense sun
#

player.runCommand("/wsserver /connect

#

how do we do this?

#

without server-net

lethal bramble
#

is debug utilities in stable

#

like stable minecraft

#

but beta api

leaden elbow
#

can i get latest vanilla item id list by scripts

lethal bramble
leaden elbow
#

i mean not type id but the numerical ones

lethal bramble
leaden elbow
#

like this ones

lethal bramble
#

huh ive never seen those

leaden elbow
#

can be used to render in aux

floral timber
#

Ig thats what u r looking for.

leaden elbow
#

yes exactly but i need it in updated version cus seems like theres new items were added in 1.21.100

floral timber
#

you would have to work a little for that.

leaden elbow
#

its just i dont know what were the new item's IDs

floral timber
#

Idk either

buoyant canopy
#

can we give a vanilla item an enchantment glint without enchanting it?

warped blaze
subtle cove
#

yes

warped blaze
#

I thought they were all like "Compass"

#

nvm i figured out why

#

mb

#

😭

granite cape
#

when we got Custom ChestUI from Script☹️☹️☹️☹️☹️

#

i bored

lapis heart
#

How can I make an item not lose durability when hitting entity?

round bone
#

Just set item's durability damage to 0 and replace it

lapis heart
# round bone Just set item's durability damage to 0 and replace it

system.beforeEvents.startup.subscribe((initEvent) => {
    initEvent.itemComponentRegistry.registerCustomComponent("mevo:durability", {
        onBeforeDurabilityDamage(event) {
            let { attackingEntity, durabilityDamage, hitEntity, itemStack } =
                event;
            durabilityDamage = 0;
        }
    });
});

Should I replace it after making it 0?

warm mason
prisma shard
atomic blaze
warm mason
sly valve
#

because of the reference

#
event.durabilityDamage = 0
warm mason
# prisma shard Didnt he do ```js let { durabilityDamage } = event;```

so you create a new variable, and when copying values from another variable you get a reference to the original value only if it is an object. And if it is a primitive (string, number, boolean) then you get a clone of the value and their changes are not reflected in the original

round bone
warm mason
rustic ermine
#

I like how I spent a lot of yesterday (I wake up at 11pm-1am due to work schedule) trying to think of ways to disable game interactions that I didn't want (enchant table, anvil, armor stand, etc) just to think of a solution within a minute of sitting down today lol. I know the obvious answer is to check the typeID in beforeInteract, problem with that is that that still runs before and takes priority over item custom component onUseOn. Solution was to stop using an item component for the check, move my harvesting function call to vanilla events, then just blanket blacklist everything before the function is called 😅

rustic ermine
#

Now just need to think of a way to still allow players to use chests without being able to get unobtainable items like enchanted diamond equipment from the End and deep dark and unfortunately I think the only way is to remove those items from loot tables. I don't like that approach though because it requires manual review with each game update (for example if I made my pack before trial chambers released I would now need to check if trial chambers introduced any way to get unobtainable items)

halcyon phoenix
round bone
#

I didn't mean to use intervals

halcyon phoenix
#

event listeners are more performant than runIntervals right?

round bone
#
import { world, EntityHitEntityAfterEvent, Player } from "@minecraft/server"

const lastRepairs: Map<string, number> = new Map<string, number>()

world.afterEvents.entityHitEntity.subscribe(({ damagingEntity: player }: EntityHitEntityAfterEvent) => {
    if (player instanceof Player) {
         if (lastRepairs.get(player.id) ?? 0 >= Date.now()) return
        // repair action
        lastRepairs.set(player.id, Date.now() + 10_000)
    }
})
round bone
atomic blaze
halcyon phoenix
sullen grotto
#

Is there any existing lib that has java edition's ResourceLocation builder functionality?

wary edge
sullen grotto
#

It just builds resourcelocations aka identifiers like minecraft:something

wary edge
#

There is the BlockTypes.getAll() if that's what you mean?

sullen grotto
#

Nope, I want something to make identifiers. I don't like how raw strings look in my code

wary edge
#

There is the VanillaData then.

sullen grotto
#

It's not something crucial, just a matter of habit

wary edge
#

You can do MinecraftBlockTypes.AcaciaButton for example. Only for vanilla hence the module name.

sullen grotto
#

This is not quite what I need. Alright, then I'll make my own implementation

warm mason
sullen grotto
#

new ResourceLocation(<namespace>, <value>) - that's what I needed

wary edge
#

Yeah, we don't really like to implement Java modding implementation lol.

sullen grotto
#

NP, as I said, this is not crucial

safe stream
#

when will they release applyImpulse for players 😔 im so tired of applyKnockback

warped blaze
#

idk if it's still on beta

safe stream
#

not stable tho

#

(actually i havnt tested 2.1 yet, maybe it is)

prisma shard
untold magnet
#

detecting the potion type is stable on the next stable update right?

granite badger
buoyant canopy
#

there is no beforeEvent for placing blocks...

round bone
#

world.beforeEvents.playerPlaceBlock

buoyant canopy
round bone
untold magnet
sullen grotto
#

Is there a way to apply infinite effect to a player via scriptapi?

#

Something like duration.infinite

wary edge
sullen grotto
#

Is it possible to add/remove entity component groups via scripting?

wary edge
sullen grotto
wary edge
sullen grotto
#

Ok.. if this is the only way

buoyant canopy
#

I assume not but is there an equivalent of the /loot spawn command in scripts?

buoyant canopy
#

really? i can't find it in the dimension class?

#

oh it's in world

#

when was that added?

wary edge
#

.100 or maybe .110

buoyant canopy
#

great so it won't take too long to be released

wary edge
#

Maybe maybe not.

buoyant canopy
#

hmm it doesn't have an option to spawn a raw loot table...

#

is there a limit for how many permutations a custom block can have?

I could make a dummy block for the sole purpose of providing loot tables to the lootManager.

wary edge
buoyant canopy
buoyant canopy
#

65536 is definitely more than enough

rigid torrent
#

Can I make it so when I interact with a horse using a specific item something happens?

rigid torrent
#

Will try, hope it works with the horse

#

Yippie it works great

#

Thanks!

atomic blaze
honest spear
#

@atomic blaze stop spamming please

#

also looks like an autoclicker in general

sly valve
#

or jitter

sly valve
lethal bramble
livid elk
#

is it possible to hide the the copy of custom command with namespace?

halcyon phoenix
#

you're being disrespectful

sly valve
warm mason
livid elk
#

how can I change entity’s name and only specific player can see it?

livid elk
#

:(( goodbye nametag color

snow knoll
# livid elk :(( goodbye nametag color

Technically you could make an animation that would simulate the appearance of a nametag
And use the players option of playAnimation for different colours

#

It could potentially a bit janky though

halcyon phoenix
#

what about player.spawnParticle() it's client sided right??

distant tulip
#

Yes, it is per player

halcyon phoenix
#

alright thanks for confirming minato

dusky flicker
# atomic blaze i want this script combo https://streamable.com/w48wvj
MDN Web Docs

JavaScript (JS) is a lightweight interpreted (or just-in-time compiled) programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat. JavaScript is a prototype-based, garbage-collected, dynamic lan...

Landing page containing a high-level introduction of Script APIs for Minecraft: Bedrock Edition.

modest lark
#

Dose anyone know what this means?

round bone
#
world.afterEvents.worldLoad.subscribe(() => {
    world.sendMessage("")
})
modest lark
#

would this work as well? system.run(() => { //Code Here })

modest lark
remote oyster
# modest lark would this work as well? system.run(() => { //Code Here })

Considering that you are trying to use sendMessage in your code I assume this is something not to be done prematurely in the sense that you want to see it when in the world itself, so I can only safely assume that is how you have your code written. Therefore, using system.run() would be more appropriate here.

buoyant canopy
#

can we check if an entity is in love mode?

#

other than using molang?

distant tulip
#

You can check if the player interacted with it using the required item

prisma shard
buoyant canopy
sly valve
#

-# Actually I dont know

#

But very probably

buoyant canopy
#

nooo

sly valve
#

yeee

distant tulip
dense sun
#

are there any open source libraries that can convert string to functions

prisma shard
#

huh

snow knoll
buoyant canopy
#

i want to base my script on a molang query

#

I haven't use ACs since q.get_biome_tag was removed i completely forgot how to use them

dense sun
prisma shard
#

scriptEventRecieve event

buoyant canopy
#

you have to enable it in your bp manifest

dense sun
prisma shard
#

dunno wdym

dense sun
prisma shard
#

Idk use eval as he told

dense sun
#

alright

#

thanks

#

i got it

#

👍

sudden verge
#

capabilities not dependencies mb

dense sun
#

are there more capabilities?

#

other than eval

#

i didnt know bedrock offers this

prisma shard
#
{
    "format_version": 2,
    "header": {
        "name": "Bedrock Add-ons",
        "description": "Script API Template",
        "uuid": "<UUID>",
        "version": "1.0.0",
        "min_engine_version": [1, 21, 90]
    },
    "modules": [
        {
            "uuid": "<UUID>",
            "version": "1.0.0",
            "type": "script",
            "language": "javascript",
            "entry": "scripts/main.js",
        }
    ],

    // HERE
     "capabilities": ["script_eval"],

    "dependencies": [
        {
            "module_name": "@minecraft/server",
            "version": "2.0.0"
        }
    ]
}```
sudden verge
#

editorExtension, experimental_custom_ui, raytraced, and some others. not all relate to scripting

dense sun
#

is there a documentation?

sudden verge
dense sun
#

thanks

buoyant canopy
#

What's this???

warm mason
dusky flicker
warm mason
wary edge
#

It doesnt work and its an old framework that no longer works.

dusky flicker
warm mason
warm mason
warm mason
distant tulip
distant tulip
north frigate
#

1037th 100,000th message

slim forum
#

Exist a way to detect if I'm inside a house?

sudden verge
#

You could use raycasts to detect blocks around you.
For example you could check if there is a roof anywhere above you, and maybe that roof has to be say at least 3 blocks in both directions.

I don't know what you need to be considered as a "house" but simple room detection should suffice, its just checking if you have a roof & have at least one wall. As for the exact code you need to implement to perform this detection, you'll have to figure out yourself

halcyon phoenix
slim forum
halcyon phoenix
#

LOL

#

I saw that @prisma shard

#

why do you keep deleting it :<

slim forum
#

And it stops me from doing certain things

prisma shard
halcyon phoenix
slim forum
#

But then a platform would be considered underground too, even without walls

halcyon phoenix
slim forum
#

I want to stop the tornado from pulling me in if I'm inside something

halcyon phoenix
halcyon phoenix
slim forum
halcyon phoenix
slim forum
#

I don't know

halcyon phoenix
deep arrow
#

how can i detect when a player swings an item

lethal bramble
prisma shard
deep arrow
prisma shard
lethal bramble
#

but not pure left click

deep arrow
#

i've seen it before? was it possible and no longer?

lethal bramble
deep arrow
#

ah

prisma shard
deep arrow
#

well thanks nonetheless

#

sucks tho

lethal bramble
#

U would have to constantly tp an armor stand in front of the player

#

but that’s a method with commands

prisma shard
lethal bramble
deep arrow
halcyon phoenix
#

queries

final ocean
#

How to set scoreboard points over limit

alpine ibex
#

Quick question is import Location a thing?

lethal bramble
alpine ibex
#

Like this import { system, world, Location }

distant tulip
open urchin
round bone
sly valve
slim forum
slim forum
#

I want to prevent it from doing so if I am home or in a cave

halcyon phoenix
slim forum
#

I understood you asked me something like: What do you think?

#

In a rough way

halcyon phoenix
slim forum
#

I'll try to do it, thank you 💕

sly valve
#

Guys guys

#

Wait nevermind

#

Guys

#

Nvm too hard to explain

subtle cove
sly valve
#

sooo

#

If i have Dynamic Properties saved in a world

#

and remove the addon

#

add a new one with the same UUID

#

will I still have access to the data?

#

or will it be gone?

slow walrus
#

it's linked to the UUID

#

so if the new addon has the same UUID, then it'll stay

#

well it "stays" anyway

#

the new addon will just be able to access it

warped blaze
#

FINALLY
• Added Dimension.getBiome(location: Vector3) which can be used to locate the Biome of a given location.

sly valve
#

Nice

warped blaze
grim raft
#

pretty small

#

but has really important stuff

#

anyways

#

how can I put text between ModalForm buttons?

livid elk
#

how can i make my custom block do something if i right click it with specific item?

dense sun
#

can we hide the tagged player chat?

thorn flicker
dense sun
warm mason
thorn flicker
warm mason
thorn flicker
warm mason
thorn flicker
sullen grotto
#

I need some help.. is typescript drunk or is it me not knowing it good enough?

export class SignGlowingApplierComponent implements ItemCustomComponent {
    constructor() {}
    onUseOn(event: ItemComponentUseOnEvent, context: CustomComponentParameters): void {
        let source: Entity = event.source;
        let block: Block = event.block;
        let face: Direction = event.blockFace;
        if (source instanceof Player && block.getComponent(BlockComponentTypes.Sign) != undefined) {
            SpawnSimulatedPlayer(source, function (simulatedPlayer) {
                simulatedPlayer.addEffect(MinecraftEffectTypes.Invisibility, 20000000, { showParticles: false });
                let stack: ItemStack = new ItemStack(MinecraftItemTypes.GlowInkSac, 1);
                simulatedPlayer.useItemOnBlock(stack, block.location, face);
            });
        }
    }
}
sullen grotto
warm mason
# sullen grotto

aaaand? I need the code that registers the component. or is that all?

sullen grotto
#

It's just some weird type mismatch I can't figure out

untold magnet
#

finally...

untold magnet
# untold magnet finally...

Thank you Mojang for giving us the ability to detect biomes using scripts!
Now we need the ability to create new dimensions.

livid elk
#

next open entity inventory please :'))

warm mason
livid elk
#

and able to add new keybind :)))

warm mason
untold magnet
# livid elk next open entity inventory please :'))

i mean, its not that complicated to add as a feature, like u can do it using commands or scripts:
command: /openinventory <entity or block> entity:id @a
scripts: entity/block?.openInventory(Target: player);

untold magnet
untold magnet
thorn flicker
#

yeah but you say it like it is that simple

untold magnet
#

its alot easier than giving us the ability to make custom dimensions

untold magnet
thorn flicker
#

yup

#

priorities

untold magnet
#

like they could give us the ability to detect dimensions since 2019, but theyre focusing on the game content not addons

#

-# 2019 is a random guess

untold magnet
thorn flicker
#

well I did that for getBiome and getLightLevel

untold magnet
#

yeah, how much have u waited for those things?

warm mason
#

.-.

untold magnet
warm mason
untold magnet
#

at least we got the feature, and thats what matters

thorn flicker
#

findClosestBiome is trash for this

warm mason
untold magnet
thorn flicker
#

no.

warm mason
thorn flicker
#

that wont be accurate.

untold magnet
untold magnet
warm mason
#

waiting for equippable component for all entities day 500102

thorn flicker
#

waiting for entityHurt beforeEvent day 943128

untold magnet
untold magnet
#

i see,

thorn flicker
#

or just, wanting to do something before the damage happens in general

warm mason
thorn flicker
#

entityDie beforeEvent would be nice too.

thorn flicker
warm mason
untold magnet
thorn flicker
#

you mean entityHurt?

#

because you could essentially create entityDie beforeEvent with entityHurt beforeEvent

warm mason
untold magnet
warm mason
thorn flicker
thorn flicker
warm mason
warped blaze
#

like

#

Entity.getComponent("inventory").container.openContainer(secondEntity: Entity)

#

or
Entity.getComponent("inventory").openContainer(secondEntity: Entity)

warm mason
#

Nobody even believes in server-ui anymore...

untold magnet
#

what is server-ui?

warm mason
#

😭

untold magnet
#

jk i know what it is and i dont really use it

warped blaze
wary edge
warm mason
# wary edge What do you mean?

if there was a method to force a player to open a container, it should have been in server-ui... well, that's what I think..

round bone
wary edge
#

It definitely should be in server because it's interacting with the Entity.

round bone
#

It does not really make sense to pin it as a free function in server-ui module

warm mason
#

then it would be better to do it like Player.interactWith(target: Entity | Block)

untold magnet
thorn flicker
dense sun
#

can we hide tagged player chats?

cunning canyon
#

Is there a way to get the name of an entity?

“Ender Dragon” instead of “minecraft:ender_deagon”

cunning canyon
#

I can access everything normal but localizationKey returns undefined

sudden verge
#

It's not possible to get stuff like that because it's stored on the client side?

wary edge
#

No theres a scripting method fornit.

sudden verge
#

what is it?

sudden verge
#

oh sorry i misunderstood

#

i thought he wanted to get the name as a string

cunning canyon
agile lance
halcyon phoenix
agile lance
# halcyon phoenix what?

How do I make an item make a sound when holding left click or when it’s interacted as a block?

lethal bramble
#

u can use playerInterectWithBlock and then use the playSound method

halcyon phoenix
#

oh wait

lethal bramble
#

left click lol

halcyon phoenix
agile lance
agile lance
#

Oddly enough, the sound that I imported doesn’t list on the playsound command

lapis heart
#

I need array that has all double blocks!

halcyon phoenix
halcyon phoenix
lapis heart
prisma shard
#

Less go but im using 2.0.0 stable :(

untold magnet
#

1.22.0 will came out with alot of bugs, 1.22.10/40 is all about bug fixing and adding some new coding features

#

so u will be waiting, alot.

prisma shard
#

Uh what

#

1.22.0 already?

#

Interesting

#

Its a major update... Uh and whats it gonna be? The end update?

true isle
#

I doubt itl be the end update

snow knoll
#

Is there a maximum number of keys that a Map can have?

prisma shard
#

It depends on your memory

livid elk
#

what’s the button limit for a server form?

stark kestrel
#

How do I figure out the aux ids like Herobrine did, I wanna update the pack for myself, herobrine's pack is outdated rn

untold magnet
prisma shard
distant tulip
livid elk
#

perfect, thanks!

distant tulip
#

double check that, i am not too sure

distant gulch
#

Are there any scripts that detects player's movement input

wary edge
distant gulch
#

Quite, I'm searching for a script that detects the movement key inputs, where the script detects when a movement key is pressed even the player doesn't move from it's currently location

wary edge
distant gulch
#

Understood, thank you for clarifying, i glady appreciated your time, have a nice day

dusky flicker
#

on inserting, if some conflicts, it creates a new node and sets the last node to now point to this new one

snow knoll
#

How would conflicts occur?

dusky flicker
dusky flicker
#

it would occur when 2 different values, when hashed, generate the same number

#

for example, some hasher that when hashing "hello" and "world" return for both strings the number 48

#

A hash function is any function that can be used to map data of arbitrary size to fixed-size values, though there are some hash functions that support variable-length output. The values returned by a hash function are called hash values, hash codes, (hash/message) digests, or simply hashes. The values are usually used to index a fixed-size tabl...

dusky flicker
stark kestrel
#

Or maybe I'll recheck if I'm missing something

dusky flicker
#

hashset(Set in js) works as the same but doesnt create the key value pair relation

snow knoll
#

So the relationship of keys to hashes can't be many to one or it causes an error

dusky flicker
dusky flicker
#

it uses linked lists

#

and generally, it will use u64 for numbers of hashing

#

it will lead values between 0 to 2^64-1

#

so the chance to some conflict occur is little

#

maps are often made for avoiding conflicts so theyre in general O(1) for lookup

dusky flicker
#

if not i can keep explaining

round bone
#

😭

snow knoll
dusky flicker
#

is it normal i lose performance due to simply unfocus the minecraft window?

#

like seriously, im getting a bunch of warnings of slow code with in average 50ms

#

but when i focus the game window again it simply stops

loud brook
#

Hey guys, I have a bp file that appears as trojan, I tried to fix it by changing the encoding from lf to crlf (UTF-8), but not sure if it no longer appears as trojan, can I please send the pack to someone to test it?

loud brook
#

Well, if you are not on windows then yeah it is an another case

loud brook
#

This fricking file always gets detected as a trojan for some reason, how do I fix it??

#

Its encoding is utf-8 crlf btw

cinder shadow
#

For some reason I thought we had a method for getting an entity based off it's id

warped blaze
#

Dimension.getEntity(id: string)

cinder shadow
#

Doesn't exist on the documentation

#

and throws content log says it isn't a function

#

that's why I'm checking, idk whether I had a fever dream or what

#

found it

#

it's world.getEntity(id)

#

not dimension

warped blaze
#

i didn't find it in the Dimension class so i was like wtf

cinder shadow
#

well that leads me into my next point of confusion. I've been learning property overrides so I can do client based rendering for certain entities, they seem very useful, but for some reason there's no get method for property overrides

#

Seem that I'm reliant to save some sort of other data on the server side and use that to tell whether something has had it's property overriden

cunning canyon
#

is there a way to spawn very specific entities?
like entities with specific components and make those components have specific values?

dusky flicker
#

because js understands strings as utf16

#

and anyways, how is it a trokan?

#

its javascript

loud brook
dusky flicker
#

it's got literally no permission to anything on the cellphone, computer, or whatever

loud brook
#

I don’t even know why

dusky flicker
#

when i had windows it used to detect files that i compiled with gcc

#

windows os is weirdo

loud brook
dusky flicker
#

anyways, i opened a profiler on minecraft, it wrote the content as JSON, is there a way i can see the content in a better way?

loud brook
#

Another thing, I remember that I was able to solve this problem with another file long ago, but I just forgot how

dusky flicker
#

and windows is weirdo

loud brook
slow loom
lethal bramble
#

in the manifest

lethal bramble
#

your content log should be flooded with errors

livid elk
#

didnt know item also have custom component

halcyon phoenix
#

well to me I seldomly use them

livid elk
#

im trying something with custom component, is there a way to make something like this?

"rpg:test": {
                "entity": "minecraft:cow" // i want to get this value and use it on my script
            }
livid elk
#

how i can get the "entity" value?

round bone
#

🙂

distant tulip
#

we can now search for messages in post
this post almost at 300k message

lapis heart
#

Can I know the type of spawner?

honest spear
#

uhhh

subtle cove
#

jhonny gud ol question indeed

honest spear
#

thier profile pictures got me for a sec, i was about to screen shot it how Minato ps changed his one, but its diff account

honest spear
lapis heart
lapis heart
nimble schooner
#
import {
    system,
    world,
    ItemStack
} from "@minecraft/server";

onTick(event) {
    //event.block // Block impacted by this event.
    //event.dimension // Dimension that contains the block.
    if (event.block.type.id === "cc:ore_block") {
        if (event.block.getState("cc:state_ore") === 0) {
            world.getDimension("overworld").runCommandAsync(`setblock ${event.block.location.x}  ${event.block.location.y} ${event.block.location.z} ore_block ["cc:state_ore"=1]`)
        };
    };
}```

Why does this throw syntax error and how to fix it? (I ask here because I assume the answer to be simple.
weary umbra
#

change runCommandAsync to runCommand

round bone
#

also, you're missing function etc. keywords

weary umbra
#

yeah that too

round bone
#

also, consider using runCommandrather than runCommandAsync

weary umbra
round bone
weary umbra
#

oh yeah thats true

round bone
#

not that usual behavior, but he might be in 1.x.x still

halcyon phoenix
#

crap zodiac signs, how do you all import @minecraft/server?

subtle cove
#
import * as mc from "@minecraft/server";

const {
    system,
    world,
    ItemStack
} = mc;
```;-;
prisma shard
#

but its not a good practice

#
import {
    system,
    world,
    ItemStack
} from "@minecraft/server";```
importing just like that is fine
subtle cove
#

it still depends on how I use the variables, sometimes for types

prisma shard
#

why do you need to do that

honest spear
honest spear
prisma shard
#

mm alr idk

honest spear
prisma shard
#

💀 nice

honest spear
#

i use it for mocking tests and conditional script addons

#

some part of the scripts are loaded only if the modules are available

subtle cove
#

#1344125833685635138 message

granite badger
prisma shard
honest spear
granite badger
subtle cove
#

entitytypes filter of sort

halcyon phoenix
honest spear
subtle cove
#

scam ;-;

honest spear
subtle cove
halcyon phoenix
#

what does eval do? I forgor

honest spear
#

does anyone has oppened project?

#

addon project

#

and can test one snipped i have?

#

@subtle cove do you have your terminal open?

subtle cove
#

Laptop ded atm, sorry

honest spear
#

np

#

does anyone has MC opened and developing addon here?

#

Can anyone test this

import('data:application/javascript;utf8,console.warn("Test");');
#

i wonder so badly

#

please someone have to test it

#

🙏

subtle cove
#

How is that a directory path

honest spear
#

i think it would fail but i wonna know

#

its considered as ECMA feature but not official

#

i mean its not in specs directly but works in all to me known runtimes by default