#Script API General

1 messages ¡ Page 18 of 1

cinder shadow
valid ice
cinder shadow
#

yeah I can't read that

#

that's not English

valid ice
#

git gud

cinder shadow
#

I mean it works just fine (ignore the fire, I keep doing my particle tests using one of my blocks that explode on contact)

distant tulip
#

top block always have more weight
let say we have
[
red,
green,
blue
]
the script should mix the colors like red3 + green2 blue*1
that is almost what the beam particle is doing in that equation

cinder shadow
#

ahh okay

#

I'm just doing a flat everything has equal weight

unique dragon
#

check the view direction, if that works for you

cinder shadow
#

updated it a few minutes ago so several instances of the same color would still increase it's value

median stream
#

Can we prevent players from equipping netherite armor?

inland merlin
#

Is there a way to cancel minecart chest inventory?

#

Access to?

#

I mean the only thing I can think of is disabling it entirely through json file (not sure if that's possible)

subtle cove
inland merlin
#

I must have missed it if there is now

#

Oh wait

inland merlin
#

I guess we do have that

#

Dang that's funny

shrewd wedge
#

Does anyone know why sometime, it say log that it cannot get location?

#

Lots of time it works, but sometime it say this for no reason. How to fix?

shy leaf
nocturne hazel
#

Whatever you're getting the location from is undefined

shrewd wedge
#

It just effect entity in 10 block on fire. But sometime it doesn't work for no reason

shy leaf
#

post code

shrewd wedge
nocturne hazel
#

Something like a raycast can return undefined result if it didn't find anything. Check if things are there or not. Share code?

shrewd wedge
#
    e.itemComponentRegistry.registerCustomComponent("evo:ember_blitz", {
        onUse(e) {
            const player = e.source;
            const xyz = player.location;
            const dimension = player.dimension;

            player.startItemCooldown("custom", 20);
            player.playSound("mob.blaze.breathe");

            let nearbyEntities = dimension.getEntities({
                location: xyz,
                maxDistance: 10,
                excludeTypes: ["minecraft:item", "minecraft:xp_orb"]
            });

            nearbyEntities = nearbyEntities.filter(entity => entity !== player);

            nearbyEntities.forEach(entity => {
                entity.setOnFire(7, true);
                entity.runCommandAsync("effect @s wither 5 1");
                entity.runCommandAsync("particle evo:ember_blitz ~~~");
            });
        }
    });
shy leaf
#

which line is the log pointing at?

shrewd wedge
#

The }) below particle command

simple zodiac
# shrewd wedge

This hapens when the entity handle is invalid. So in js, the object apears normal but there is no entity that it actually represents. This can happen when you execute something on an entity that has already been despawned. You can check if the handle is valid with entity.isValid()

shy leaf
#

isnt that line 58

simple zodiac
shrewd wedge
shy leaf
#

im assuming setting them on fire kills the entities and fails to run commands

shrewd wedge
shrewd wedge
shy leaf
#

or

simple zodiac
#

It was just an example, there could be other reasons for it having an invalid handle. For exaple if the chunk is not loaded. But thats not the case here... you must be missing something

shy leaf
#

wait

shrewd wedge
#

If I do in a group of pigs, sometimes one pig will do error but others will work fine. I don't understand

shy leaf
#

hmmm

#
    e.itemComponentRegistry.registerCustomComponent("evo:ember_blitz", {
        onUse(e) {
            const player = e.source;
            const dimension = player.dimension;

            player.startItemCooldown("custom", 20);
            player.playSound("mob.blaze.breathe");

            let nearbyEntities = dimension.getEntities({
                location: player.location,
                maxDistance: 10,
                excludeTypes: ["minecraft:item", "minecraft:xp_orb"]
            });

            nearbyEntities.forEach((entity) => {
                if (entity == player) return;
                entity.setOnFire(7, true);
                entity.runCommandAsync("effect @s wither 5 1");
                entity.runCommandAsync("particle evo:ember_blitz ~~~");
            });
        }
    });
#

can you try this

shrewd wedge
#

Ok

shrewd wedge
#

Yes I think it fixed. That pig still gave error but other pigs did not

#

Thank you

meager zenith
#

Are there any molang queries (except for q.scoreboard) that I can change using scripts, for player or item to be specific

#

So I want to dynamically change my elytra's color but idk how to except with using queries but idk which query to use since idk what can I change about the elytra or the player that the queries can detect

wintry valve
#

maybe use animation controllers?

rose light
#

Does anyone know of an app to take a picture of my map?

sleek nexus
#

Same, I've found it's great for understanding theory of algorithms and such. I wouldn't personally use it to write code though as that'd make tracing bugs a nightmare

prisma shard
#

fun fact: blocktopograph is a popular application and it is developed by my friend 😀

distant tulip
leaden glade
prisma shard
#

When the owner was discontinuing, he handovered the app to my friend. Because its source code. And can be lead by public.
.

#

my friends name is "NguyenDuck"

#

he is in this server

distant tulip
prisma shard
#

Yes, I said his version is latest

#

And I already said he's not the original creator

#

"When the original owner was discontinuing, he handovered the app to my friend. Because its source code. And can be lead by public."

worn sphinx
#

Does anyone know how to add money to a button, for example there are 10 buttons, if you press any button it will show money and the money will increase

empty tapir
#

how do we use PlayerInputPermissions class?

subtle cove
# worn sphinx Does anyone know how to add money to a button, for example there are 10 buttons,...

try this one```js
async function moneyForm(player, money = 0, formValues = [-1, true]) {
const moneyValues = [5, 10, 20, 50]
const form = new ModalFormData()
form.dropdown(Current Money: ${money}\n\nMoney Value, moneyValues.map(String), formValues[0])
form.toggle("Add / Remove", formValues[1])
const res = await form.show(player)
if (res.canceled) return
formValues = res.formValues
money = formValues[1]
? money + moneyValues[formValues[0]]
: money - moneyValues[formValues[0]]
return moneyForm(player, money, formValues)
}

subtle cove
# worn sphinx Ohh thank

here's another onejs async function moneyForm(player, money = 0) { const values = [-50, -20, -10, -5, 0, 5, 10, 20, 50, 100, "Done"] const form = new ActionFormData() form.body(`Current Money: ${money}\n\nMoney to contribute:`) values.forEach(n => form.button(`${n}`)) const res = await form.show(player) if (res.canceled) return const value = values[res.selection] if (value === "Done") { //code player.sendMessage(`Money: ${money}`) return } return moneyForm(player, money + value) }

distant gulch
#

Do you think its good to use typescript?

wary edge
distant gulch
random flint
subtle cove
#

script-api mainly uses js files

random flint
#

TS needs to be compiled into JS anyway

wary edge
subtle cove
#

for precision

fiery solar
# distant gulch think its an option or more of a necessity?

Using typescript is the best thing you can do to write good code and save yourself time, I would never consider making an anything in plain JavaScript now that I know typescript but if you don't already know JavaScript then it will be twice the frustration.

Start with JS and learn typescript when you feel like you know the basics

wary edge
subtle cove
#

to reduce errors

mellow socket
#

Is there a way to automatically connect to a websocket?

#

Like in the background esk way

fiery solar
unreal cove
#

prob security reasons

mellow socket
distant gulch
#

ty guys using ts 😍

runic crypt
#
function getItemCount(player, itemId) {
  if (!itemId) return 0;
  let itemCount = 0;
  const inventory = player.getComponent( "inventory" ).container;
  for (let i = 0; i < inventory.size; i++) {
    const item = inventory.getItem( i );
    if (item?.typeId == itemId) itemCount += item.amount;
  };
  return itemCount;
}
system.afterEvents.scriptEventReceive.subscribe((event)=>{
  const {id: text, sourceEntity: player} = event
  const Score = `money` //name objective
  const item = `minecraft:emerald` //typeId item
  const count = getItemCount(player,item)
  if(text == "gwim:open") { //detect when use text run code
      const Deposit = new ModalFormData()
          .title(`Deposit`)
          .slider(`Select Amount Of Emeralds To Deposit\nCurrent: ${count}\nChoose: `, 1, 64, 1)
          Deposit.show(player).then(async (rs) => {
          const { canceled, formValues } = rs;
          if (canceled) return;
          const [a] = formValues;
          if (a > count) {
            player.sendMessage(`Quantity must not exceed the number of items available`);
            player.playSound(`note.harp`,{pitch:1,volume:1});
            return
          }
          player.runCommandAsync(`scoreboard players add @s ${Score} ${a}`);
          player.runCommandAsync(`clear @s ${item} 0 ${a}`);
          player.sendMessage(`Deposited, +${a}$`);
          player.playSound(`random.orb`,{pitch:1,volume:1});
        })
    }
})

i tried this but it didn't work :(
what modules do i need to import into my manifest ?
if possible can someone make this into a full addon and send it ??

#

also the /scriptevent gwim:open doesn't work :(

#

i want it to work in npc as well

#

and if i right click a stick then also the ui opens

gaunt salmonBOT
#

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 6 errors:

<REPL0>.js:20:24 - error TS2345: Argument of type 'Entity' is not assignable to parameter of type 'Player'.
  Type 'Entity' is missing the following properties from type 'Player': camera, inputPermissions, isEmoting, isFlying, and 23 more.

20           Deposit.show(player).then(async (rs) => {
                          ~~~~~~

``````ansi
<REPL0>.js:24:15 - error TS2365: Operator '>' cannot be applied to types 'string | number | boolean' and 'number'.

24           if (a > count) {
                 ~~~~~~~~~

``````ansi
<REPL0>.js:25:20 - error TS2339: Property 'sendMessage' does not exist on type 'Entity'.

25             player.sendMessage(`Quantity must not exceed the number of items available`);
                      ~~~~~~~~~~~

``````ansi
<REPL0>.js:26:20 - error TS2339: Property 'playSound' does not exist on type 'Entity'.

26             player.playSound(`note.harp`,{pitch:1,volume:1});
                      ~~~~~~~~~

``````ansi
<REPL0>.js:31:18 - error TS2339: Property 'sendMessage' does not exist on type 'Entity'.

31           player.sendMessage(`Deposited, +${a}$`);
                    ~~~~~~~~~~~

``````ansi
<REPL0>.js:32:18 - error TS2339: Property 'playSound' does not exist on type 'Entity'.

32           player.playSound(`random.orb`,{pitch:1,volume:1});
                    ~~~~~~~~~

Lint Result

There are no errors from ESLint.

runic crypt
#
function getItemCount(player, itemId) {
  if (!itemId) return 0;
  let itemCount = 0;
  const inventory = player.getComponent( "inventory" ).container;
  for (let i = 0; i < inventory.size; i++) {
    const item = inventory.getItem( i );
    if (item?.typeId == itemId) itemCount += item.amount;
  };
  return itemCount;
}
system.afterEvents.scriptEventReceive.subscribe((event)=>{
  const {id: text, sourceEntity: player} = event
  const Score = `money` //name objective
  const item = `minecraft:emerald` //typeId item
  const count = getItemCount(player,item)
  if(text == "gwim:open") { //detect when use text run code
      const Deposit = new ModalFormData()
          .title(`Deposit`)
          .slider(`Select Amount Of Emeralds To Deposit\nCurrent: ${count}\nChoose: `, 1, 64, 1)
          Deposit.show(player).then(async (rs) => {
          const { canceled, formValues } = rs;
          if (canceled) return;
          const [a] = formValues;
          if (a > count) {
            player.sendMessage(`Quantity must not exceed the number of items available`);
            player.playSound(`note.harp`,{pitch:1,volume:1});
            return
          }
          player.runCommandAsync(`scoreboard players add @s ${Score} ${a}`);
          player.runCommandAsync(`clear @s ${item} 0 ${a}`);
          player.sendMessage(`Deposited, +${a}$`);
          player.playSound(`random.orb`,{pitch:1,volume:1});
        })
    }
})

This is a modified script ig
I want it so that if a player right-clicks a stick or interacts with an npc (npc has the following command "/scriptevent gwim:open")
What i want is that a form opens, with a slider in increments of 1 upto 100
If playwr selects a amount and clciks the deposit button, then the amount is added to the "Money" scoreboard
If player has less emeralds than the amount selected then it shows an error
(emerald are the currency that you deposit)

woven loom
#

send full code

runic crypt
#

this is the full code

restive folio
#

import { world } from "@minecraft/server"

world.afterEvents.itemCompleteUse.subscribe(yef => {
if (ev.itemStack.typeId == 'av:armor_potion') {
yef.source.runCommand('function armor_potion')
}
})

If i drink the potion why doesn't work the function

restive folio
#

Oh okay thanks

#

Yup still not working even i changed it

#

import { world } from "@minecraft/server"

world.afterEvents.itemCompleteUse.subscribe(yef => {
if (yef.itemStack.typeId == 'av:armor_potion') {
yef.source.runCommand('function armor_potion')
}
})

#

Is there any wrong with my code?

prisma shard
prisma shard
gleaming oyster
#
const heatexplode = {
    onHitEntity: target => {
        const hitEntity = target;
        const onfire = hitEntity.getComponent("minecraft:is_ignited");
        if (onfire) {
            onfire.applyDamage(20);
            onfire.extinguishFire(true);
        }
        else {
            hitEntity.setOnFire(10);
        }
    }
}
#

Hi. If I wanted to damage entity on fire, what should I edit from this code?

idle dagger
gleaming oyster
#

I get the idea of browsing 'is_ignited' tag from that 'getComponent' but no idea of testing it

mellow socket
fallow rivet
idle dagger
fallow rivet
halcyon acorn
#

I don't think that the "eventData.blockTypeRegistry.registerCustomComponent" works anymore.

#

Does anyone know a solution?

deep plank
plush moss
#

player.inputPermissions() anyone know how to use it

wanton ocean
#

True

misty pivot
#

is it possible to get the collision box of an entity? for context i'm trying to detect if an entity touched a side of a wall

steep hamlet
#

hi, what are the advantages of using ts over js? in what cases it's more reasonable to use ts?

wary edge
unique dragon
plush moss
#

thx

steep hamlet
halcyon acorn
glacial widget
#

is there a way to set stuff in players armor slots with the inventory for loop check?

scenic bolt
#

Anyone know how you’d go about making a player slow fall through a block

neat hound
#

Like a web perhaps...

scenic bolt
neat hound
#

I know of no components for that.. ancient mojang secret.. but if I had to make one.. I'd put a web inside of a block entity that can breath in blocks with no collision that did not move...

#

that is where I would start

scenic bolt
#

That sounds nice but then the texture

neat hound
#

player may see the web once inside tho. Texture the entity block thingy. and if for a custom world with NO webs... we ll, invisible the web texture

#

other idea, is to play with trying to figure out how they do the web. maybe it's a slow looping tp down pixel by pixel for each entity in web

scenic bolt
#

Sure there is no way with apply knockback and a repeating timer until out of the block

neat hound
#

block would need to check for entities within it's borders and do stuff to them

#

or entity

scenic bolt
#

If entity.location === block.location possible?

neat hound
#

no... block has no decimals.. would need some vector math... block has block.center and you can range out from there to check.

#

do test by putting your creative self in a block and getting the locations

#

build a chat command to show you

#

oh and also that statement would not work because those are object pointers, not values

#

an idea.. if the collision for the block was in permutations, such that an onStepOn, would release the collision and tag them... just a badly fleshed out idea

#

and you have to make sure breathable

wheat condor
wheat condor
neat hound
#

but not always accurate depending on negative and positive coords. I'd take the center of the block to be safe

neat hound
#

I cannot explain the details, I've just had to deal with working around that fact a lot.

wheat condor
#

not actually becouse negative cords are accurate too becouse the block is in negative but also the player so it does always get it right

neat hound
#

best to demonstrate for yourselves by going to 0,0 and the blocks around it and getting the information to make sure your calcs ring true

#

I'd rather truncate the center of the block

wheat condor
wheat condor
jolly citrus
#

what are the latest dependency versions

#

i forgot the command

neat hound
# wheat condor its the same thing

I added the different functions to the players location in my F3 info pack.

When I am dead center in the block, rounding has me at same x,z, but when I shift over a tiny bit, rounding shifts me completely as on another block, tho technically I am on both.

#

I need to test from positive side...

jolly citrus
#

what does this error mean? note i havent touched script api since 1.12.0-beta 1.21.0 rn im on 1.13.0-beta

wheat condor
jolly citrus
jolly citrus
gaunt salmonBOT
scarlet hemlock
true isle
#

any idea why this doesnt work still no errors. everthing but changing the permutation is working

inland merlin
#

im working on addon setup for bds server, and for some reason my server won't recognize my addon inside the servers dev beh and res folders

#

is there somewhere i need to specifiy something?

#

nvm ill follow protocol info

subtle cove
#

recognized packs kind of file

inland merlin
#

awh ok thx

inland merlin
abstract cave
#
world.afterEvents.itemUse.subscribe((data) => {
    const item = data.itemStack;
    const player = data.source;
    const cooldown = item.getComponent("minecraft:cooldown");
    if (item.typeId === "bm:strength_mirror" && cooldown.cooldownTicks == 1800 && cooldown.getCooldownTicksRemaining(player) == 1800) {
        player.runCommandAsync("/function strength_effect");
        cooldown.startCooldown(player);
    }
});```

for some reason the script doesnt work
unless i remove the 
```&& coolddown.getCooldownTicksRemaining(player)``` part

though i need that part so the item cant be spammed
Can anyone help
valid ice
#

if you console warn that part, what shows up?

abstract cave
valid ice
#

console.warn(coolddown.getCooldownTicksRemaining(player))

#

and just chuck it before the if statement

abstract cave
abstract cave
valid ice
#

Well that sure doesn’t equal 1800, that’s for sure

abstract cave
abstract cave
neat hound
true isle
#

No the default is 0 I had a message in the block the last attempt and it was fine I'm not sure what's going on with it. I have a question thing open but I've not gotten anywhere since

#

I'm just try to even get the perm to change. It's not the full code I'm trying to do it's just a test for now

neat hound
gaunt salmonBOT
grave thistle
#

Using .teleport, what do I have to input in the teleportOptions dimension property? I'm trying to tp a player to the End and can't figure out what needs to be inputted

grave thistle
wintry valve
#
import { world, system } from "@minecraft/server";

function initializeScript() {
    console.warn("da script has bean initialized");
}

function repairItemDurability(item) {
    if (item && item.getComponent) {
        const durability = item.getComponent("durability");
        if (durability && typeof durability.damage === "number" && durability.damage > 0) {
            const maxDurability = durability.maxDurability;
            durability.damage = 0;
            item.setComponent("durability", durability);
            return true;
        }
    }
    return false;
}

function scanAndRepairInventory(player) {
    if (player && player.getComponent) {
        const inventory = player.getComponent("inventory");
        if (inventory && inventory.container) {
            let repairPerformed = false;
            for (let i = 0; i < inventory.container.size; i++) {
                const item = inventory.container.getItem(i);
                if (repairItemDurability(item)) {
                    repairPerformed = true;
                }
            }
            return repairPerformed;
        }
    }
    return false;
}

system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        scanAndRepairInventory(player);
    }
}, 1);

world.afterEvents.itemUse.subscribe((event) => {
    repairItemDurability(event.itemStack);
});

world.afterEvents.itemUseOn.subscribe((event) => {
    repairItemDurability(event.itemStack);
});

initializeScript();
wintry valve
gaunt salmonBOT
#

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 0 errors.

Lint Result

ESLint results:

<REPL0>.js

11:19 error 'maxDurability' is assigned a value but never used @typescript-eslint/no-unused-vars

gaunt salmonBOT
#

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 0 errors.

Lint Result

ESLint results:

<REPL0>.js

11:19 error 'maxDurability' is assigned a value but never used @typescript-eslint/no-unused-vars

restive folio
#

Um is it possible to make the armor enchant even your already wearing it?

restive folio
#

I try every command and it didn't work i guess its a script

distant gulch
#

can i set runInterval time with decimal point like this system.runInterval(() => { }); }, 16.67)

wheat condor
shy leaf
#

he's having a problem where the time desyncs by going a little bit faster than normal

gaunt salmonBOT
#

Timers module
setTimeout(), setImmediate(), and setInterval() simple replica for Minecraft Bedrock Edition script APIs (experimental).

Usage

import { setTimeout } from "./timers.js";
setTimeout(() => {
  console.log("Hello World");
}, 1000);

Compile & Test

Compile only

tsc

Unit test (include tsc)

npm run test
shy leaf
#

that is

granite badger
#

don’t think that will work

shy leaf
#

awesome. ty jayly

#

damn you jayly

wheat condor
#

i saw minato doing some thing with timers he probably knows

shy leaf
#

just to make sure

#

thats ingame timer, right? and not the real-time

rapid nimbus
wheat condor
shy leaf
#

can you elaborate

wheat condor
#

it will run things like console.warn) in non ticks, but ingame action will be ran always in ticks

shy leaf
#

wait i was asking if

#

that module tracks ingame time

wheat condor
#
setTimeout(()=>{
}, 10)

idk if that works but this should be a 10ms timeout

granite badger
proud cliff
woven oyster
wheat condor
prisma shard
#

setTimeout exist in js?

#

i thought its in only script api

wheat condor
distant gulch
#
system.runInterval(() => {
    seasonHandler()
    const worldTimer = world.scoreboard.getObjective(`WorldTimer`);
    const seconds = worldTimer.getScore('seconds');
    worldTimer.setScore('seconds', seconds + 18)
}, 20)

function seasonHandler() {
    const worldTimer = world.scoreboard.getObjective(`WorldTimer`);
    const seconds = worldTimer.getScore('seconds');
    const allPlayers = world.getPlayers();
    if (0 <= seconds && seconds < 48592800) {
        allPlayers.forEach(player => {
            player.sendMessage('1')
        });
    } else if (48592800 <= seconds && seconds < 97601600) {
        allPlayers.forEach(player => {
            player.sendMessage('2')
        });
    } else if (97601600 <= seconds && seconds < 146188800) {
        allPlayers.forEach(player => {
            player.sendMessage('3')
        });
    } else if (146188800 <= seconds && seconds < 195481200) {
        allPlayers.forEach(player => {
            player.sendMessage('4')
        });
    } else if (seconds === 195481200) {
        worldTimer.setScore('seconds', 0)
    }
}``` seasonHandler doesnt work ;-;
#

how can i fix it?

wheat condor
distant gulch
#

oh ty

wheat condor
#

are you sure 195481200 is a number that 18*x can reach?

wheat condor
distant gulch
wheat condor
wheat condor
# distant gulch Better version?

yeah your method is not good scoreboards arent useful, and minecrat has its own time so you dont have to calculate it with a scoreboard

distant gulch
#

i dont want use worldTime

wheat condor
distant gulch
wheat condor
distant gulch
#

if i will use world time i can calculate day hours or minutes?

wheat condor
#
system.runInterval(() => {
    const time = world.getAbsoluteTime() // 1 minecraft day is 24000 tick || 20 minutes = 24000 ticks
    const days = time / 24000 //transforming ingame ticks into ingame days (20 minutes)
    const dayranges = [
        { max: 30, message: '1' }, //every 600 minutes season changes
        { max: 60, message: '2' },
        { max: 90, message: '3' },
        { max: 120, message: '4' }
    ]
    for (const range of dayranges) {
        if (days < range.max) {
            player.sendMessage(range.message) //sending the message for the season number that we are in
            break
        }
    }
}, 20)
distant gulch
#

ty

fickle dagger
#
world.afterEvents.itemUse.subscribe((event) => {
  const source = event.source;
  const heldItem = event.itemStack;
  if(heldItem.typeId !== 'rq:scrub_sponge') return;
  const target = source.getEntitiesFromViewDirection()[0];
  const {x, y, z} = source.getViewDirection();
  const shootStrength = {x:x, y:y, z:z};
  const projectileEntity = source.dimension.spawnEntity("minecraft:snowball", source.getHeadLocation());
  const projectile = projectileEntity.getComponent("projectile");
  projectile.owner = source;
  projectile.shoot(shootStrength);
 }
});```
anyone know how to amplify the speed of the projectile?
remote oyster
#

I'm not sure that you can? Right now you are attempting it in an afterEvent which I would imagine the projectile is already gone and reached its destination. I know this is the case for the projectile event. If you were to manage this behavior in some kind of beforeEvent I think it would result in the same way since the restrictions of read-mode, pushing you to offset the change.

Based on that, and without looking over the docs, I'm simply gonna say no on this.

gaunt salmonBOT
#

Suggestion for @idle dagger

Description
A simple to use command creator.
Parameters:

  • info (Object): An object containing the information about the command.
    • name (string): The name of the command.
    • description (string): The description of the command.
    • is_staff (boolean, default: false): Indicates if the command requires staff privileges.

Example usage

commandBuild.create(
    {
        name: 'getCommands',
        description: 'Get a list of all commands registered',
        is_staff: fa
```...
fickle dagger
gaunt salmonBOT
#

Suggestion for @idle dagger

Description
Calculate distance

Credits
These scripts were written by GlitchyTurtle32

remote oyster
fickle dagger
remote oyster
# fickle dagger does spawning it by itemUse not count?

It's different. In your case it's the afterEvent. The projectile is already shot. In a beforeEvent you are restricted by read-only mode. When you offset it using something like system.run() the results are practically the same as witnessed in the afterEvent.

This is more of what I was talking about when I said "spawn":

const location: Vector3 = { x: 0, y: -59, z: 0 };
const velocity: Vector3 = { x: 0, y: 0, z: 5 };
const arrow = world.getDimension('overworld').spawnEntity('minecraft:arrow', location);
const projectileComp = arrow.getComponent('minecraft:projectile');
projectileComp?.shoot(velocity);
fickle dagger
#

guess that means I should take a break from coding

#

been going for a few hours nonstop now

#

thank you visual1mpact for the feedback

remote oyster
#

Yea, unfortunately, I don't believe it's possible to accomplish your goal right now simply because of the restrictions in beforeEvents which is really what you need.

subtle cove
wheat condor
#
system.runInterval(() => {
    const time = world.getAbsoluteTime() + 6000; //adjust time to match the sun position
    const days = Math.floor(time / 24000); //total days passed
    const date = {
        year: Math.floor(days / 360), //current year (365 days) //1 year is 120 hours of playing
        month: Math.floor((days % 360) / 30), //the month of the year (0-12 i think)
        day: days % 30, //the day of the month (0-29)
        hour: Math.floor((time % 24000) / 1000), //the hour of the day (0-23)
        minute: Math.floor(((time % 24000) % 1000) / (1000 / 60)), //the minute of the hour (0-59)
        second: Math.floor((((time % 24000) % 1000) % (1000 / 60)) * (60 / (1000 / 60))) //the second of the minute (0-59)
    };
    world.getAllPlayers().forEach(player => player.onScreenDisplay.setActionBar("----------\n" + Object.entries(date).map(([key, value]) => `${key}: ${value}`).join("\n") + "\n----------"))
})

this is the best you can find for ingame date @distant gulch

wheat condor
shut citrus
#

script team just limited it by only read json file

fickle dagger
crude ferry
#

How can I get the velocity of a player?

fallow rivet
#

Is it possible to test the enchants of two items and then transfer those enchants to a single item?

unreal cove
# fickle dagger ```js world.afterEvents.itemUse.subscribe((event) => { const source = event.so...
function shootProjectile(entity, projectile, power) {
    const headLoc = entity.getHeadLocation();
    const viewVector = entity.getViewDirection();
    const direction = { x: headLoc.x + viewVector.x, y: headLoc.y + viewVector.y, z: headLoc.z + viewVector.z };
    const vel = { x: viewVector.x * power, y: viewVector.y * power, z: viewVector.z * power };
    const projectileEntity = entity.dimension.spawnEntity(projectile, direction).getComponent('projectile');
    projectileEntity.owner = entity;
    projectileEntity.shoot(vel);
};

world.afterEvents.itemUse.subscribe((event) => {
    const source = event.source;
    const heldItem = event.itemStack;
    if (heldItem.typeId !== 'rq:scrub_sponge') return;
    const target = source.getEntitiesFromViewDirection()[0];
    shootProjectile(source, 'minecraft:snowball', 1);
});

try that

fickle dagger
abstract cave
#
import { world, Player } from "@minecraft/server";

world.beforeEvents.worldInitialize.subscribe((initEvent) => {
    initEvent.itemComponentRegistry.registerCustomComponent('bm:magic_mirror', {
        onUse() { }
    });
});


world.afterEvents.itemUse.subscribe((data) => {
    const item = data.itemStack;
    const player = data.source;
    const cooldown = item.getComponent("minecraft:cooldown");
    console.warn(cooldown.getCooldownTicksRemaining(player))
    if (item.typeId === "bm:strength_mirror" && cooldown.cooldownTicks == 1800 && cooldown.getCooldownTicksRemaining(player) == 0) {
        player.runCommandAsync("/function strength_effect");
        cooldown.startCooldown(player);
    }
});

Can anyone help, the command wont run unless i remove && cooldown.getCooldownTicksRemaining(player)

abstract cave
abstract cave
wary edge
#

Then use <=

abstract cave
#

ok

misty pivot
#

is it possible to get/use a value from the lang file?

abstract cave
unreal cove
misty pivot
#

oh

#

alright thanks

buoyant canopy
#

the same thing as the tellraw command

misty pivot
#

how so?

misty pivot
buoyant canopy
#

so that would be like this?

world.sendMessage({tanslate: "item.minecraft:stick.name"})
misty pivot
#

ah, i see

#

can i define a raw message in a string?

#

like

const myMessage = {
    translate: "myWord.word1"
}
#

yep it worked

buoyant canopy
#

great, i haven't use it before, so i wasn't sure

wheat condor
fallow rivet
wheat condor
fallow rivet
#

I have a problem
I don't know how to combine the enchantments of items in slots 1 and 2 into an anvil

cinder shadow
#

What is the format for getBlocks' 'filter' parameter?

#

keeps telling me that the object doesn't have a native handle despite my syntax looking correct

#

oh nvm

stuck spoke
#

.getComponent('minecraft:equippable').getEquipment(EquipmentSlot.Mainhand)

Why isn't this working on my custom entity? getComponent is returning undefined even though there is item visible in the entities hand?

wary edge
stuck spoke
subtle cove
stuck spoke
subtle cove
#

try that one then

wary edge
#

Inventory is different than equippable for entities

#

You'll have to use execute command with the hasitem operator

stuck spoke
# subtle cove try that one then

If I set it to 1 size and check what item is there, it returns undefined. My plan is to save the item in the entity inventory and use replaceitem to make it appear that the item is in hand

#

failing that, I'll save the item data as a dynamic property

#

got it working, ty

subtle cove
#

nice

wheat condor
wheat condor
fallow rivet
fallow rivet
wheat condor
fallow rivet
#

Ok

neat hound
abstract cave
#
import { world, Player } from "@minecraft/server";

world.beforeEvents.worldInitialize.subscribe((initEvent) => {
    initEvent.itemComponentRegistry.registerCustomComponent('bm:magic_mirror', {
        onUse() { }
    });
});


world.afterEvents.itemUse.subscribe((data) => {
    const item = data.itemStack;
    const player = data.source;
    const cooldown = item.getComponent("minecraft:cooldown");
    console.warn(cooldown.getCooldownTicksRemaining(player));
    if (item.typeId === "bm:strength_mirror" && cooldown.cooldownTicks == 1800 && cooldown.getCooldownTicksRemaining(player) == 0) {
        player.runCommandAsync("/function strength_effect");
        cooldown.startCooldown(player);
    }
});

The script wont work, no errors given, but when i remove the && cooldown.getCooldownTicksRemaining(player), the script works, but the problem is the player can spam the item

abstract cave
#

ok

night loom
#
import { GameMode, system, world } from "@minecraft/server";
import { PlayerServer } from "api/@minecraft/Main";

world.beforeEvents.playerPlaceBlock.subscribe((eventData) => {
    const { player, block, permutationBeingPlaced: { type: { id: typeId } } } = eventData;
    const playerServer = new PlayerServer(player);
    if (playerServer.getPlayerProperty("adminPermissionModifyBlocks", true) && player.getGameMode() == GameMode.creative)
        return;
    if (player.location.x <= 100 && player.location.x >= -100 && player.location.z <= 100 && player.location.z >= -100) {
        eventData.cancel = true;
        return;
    }
    if (typeId == 'minecraft:lava' && JSON.stringify({ x: Math.floor(player.location.x), y: Math.floor(player.location.y) - 1, z: Math.floor(player.location.z) }) == JSON.stringify(block.location)) {
        eventData.cancel = true;
        return;
    }
    if (typeId == 'minecraft:slime' && JSON.stringify({ x: Math.floor(player.location.x), y: Math.floor(player.location.y) - 1, z: Math.floor(player.location.z) }) == JSON.stringify(block.location)) {
        system.run(() => {
            player.applyKnockback(0, 0, 0, 2);
            player.runCommandAsync("give @s slime")
        });
        const xBlock = block.location.x
        const yBlock = block.location.y
        const zBlock = block.location.z
        system.runTimeout(() => {
            player.runCommandAsync(`setblock ${xBlock} ${yBlock} ${zBlock} air`)
        }, 10)
        return;
    }
    eventData.cancel = true;
});

Why does this script work on a regular world but not on Realms?

neat hound
#

if I had to guess.. does it have something to do with js import { PlayerServer } from "api/@minecraft/Main";what is that?

neat hound
#

with @minecraft and no ./ offset ref?

#

guess is possible...

#

I think maybe, the folder needs to be within the scripts folder for realms

cold grove
neat hound
#

so bundle for a realm deploy

cold grove
#

maybe the mc engine accepts that syntax

neat hound
#

on your local pc, it can maybe pull from anywhere... I have not tested the limits of that, just guestimating
if you want your library code all in one place, may need to have a bundler for the deployment so the references within other systems are correct.

tawny reef
#

please help me check my post

spring dove
#

the best way to get floating texts, is invisible entitys?

neat hound
# tawny reef please help me check my post

I don't do forms yet... so can't help. Have you checked the resources, I know some people have done example or library code over there for forms... Or wait unil a forms person sees your post and helps.

shadow lark
#

I'm using custom components through scripts, but I have a doubt about if there is a way to add a condition to make the block interact or not

#

because when it was done through molang using the triggers events and events, the same was achieved with a ‘condition’.

wary edge
#

You can use if statements then return but it will still swing your arm

shadow lark
#

(should do it with a switch case)

wary edge
shadow lark
wary edge
shadow lark
shadow lark
wary edge
cinder shadow
#

they're faster calls than if you were to do block.dimension.getBlock(...)

golden condor
# wintry valve can anyone tell me why this isn't working?

not sure if someone's answered you already, but changing the durability damage value does not affect the initial item itself, only the item object. So you need to set the container item afterwards to the item with the repaired durability. its also not necessary to set the component back after, you can just return after damage = 0. I would return the repaired item itself (or undefined if already repaired/no durability). then you can set the container item after in the inventory if it returns an item stack

halcyon phoenix
#

how would people do that swiping attack?

#

like the dark souls kind

#

is it possible to disable the left click attacks?

wintry valve
wintry valve
halcyon phoenix
#

hmmmmm

ivory bough
#

Hey guys how to I run a command in the scripting api? Since I am not finding any way to

halcyon phoenix
#

player.runcommand

buoyant canopy
#

or dimension.runCommand works as well

ivory bough
#

Which imports?

ivory bough
wheat condor
buoyant canopy
#

yeah you need to get a player or a dimension to run this method on, you can't just type Player.runCommand("kill @s") and expect it to work

restive folio
#

Is the items normal seems all the sword and weapons to me don't take any damage by breaking blocks only by hitting an entity like zombie etc. do i need a script for this?

restive folio
wary edge
#

my library has a custom component for it

wintry bane
#

How do I log the potion effect inside of a cauldron?

wary edge
ivory bough
#

Hey guys is there any way to cancel damage applied to my entity in scripting api since there isn't beforeEvents.entityHurt or can I get the amount of damage applied to my entity through world.afterEvents.entityHurt.subscribe((event) => {
const damager = event.damageSource.damagingEntity
const damaged = event.hurtEntity
if (damaged.typeId == 'space:siren_head'' && damager.typeId != 'minecraft:player')
const damageAmount = event.damage after this how do I get the amount of damage applied?
});

ivory bough
wintry bane
#

Try healing after getting damage

ivory bough
#

Through event.damage then what?

ivory bough
valid ice
ivory bough
shy leaf
#

its a number

ivory bough
wary edge
#

It wojt work though if the entity dies

shy leaf
#

wait it doesnt?

ivory bough
#

Hey can someone give an example of using event.damage?

wary edge
#

@ivory bough so
Grab health component -> add the damage amount back

ivory bough
#

I need to do it through world.afterEvents.entityHurt.subscribe and event.damage

ivory bough
# wary edge <@1208112251500896327> so Grab health component -> add the damage amount back

Does this work?
world.afterEvents.entityHurt.subscribe((event) => {
const damager = event.damageSource.damagingEntity;
const damaged = event.hurtEntity;
const damageAmount = event.damage;
if (damager.typeId != 'minecraft:player' && damaged.typeId == 'space:siren_head') {
world.getDimension("overworld").runCommandAsync("effect @e[type=space:siren_head] instant_health 1 ${damageAmount}");
return;
} else {
return;
}
});

#

Then how

distant tulip
#

if the entity health is too low it will die

#

just edit the json file

ivory bough
distant tulip
#

give me a sec

distant tulip
misty pivot
#

how do i detect whether an item is dropped by a player?

cold grove
misty pivot
#

i see, thanks, i think i can find the post

buoyant canopy
steep hamlet
#

hi, jayly docs give skeleton as example for applyKnockback but from my testing it only works on player.. is it the same for everyone?

cinder shadow
#

it works on all entities

#

aside from items

wintry bane
#

Status effects and enchantments are so hardcoded, it's the final frontier for data-driven content

fallow rivet
fallow rivet
#
function mergetest(player, slot1, slot2) {
const inv = player.getComponent("minecraft:inventory").container;
const item = inv.getItem(slot1);    
const items = inv.getItem(slot2);   
var encid = "none";
var itemenchant = false;
try {
const enchantments = items.getComponent("enchantable").getEnchantments();
if (enchantments.length > 0) {
encid = enchantments.map(e => ({...e, type: e.type.id}))
itemenchant = true;
}
} catch (error) {} 
if (itemenchant == true) {
     const ench = item.getComponent("enchantable");
    ench.addEnchantments(encid.map(e => ({ ...e, type: new EnchantmentType(e.type) })))
}

console.warn("test")
inv.setItem(slot1, item);
inv.setItem(slot2, new ItemStack("minecraft:barrier", 1));
player.sendMessage("§aMerge Successful.")
player.playSound("random.anvil_use")
player.runCommand(`clear @s barrier`)
}

Digging in the book. It doesn't work when there is a spell that is not printed. How can I solve this?

restive folio
wary edge
night loom
#
import { GameMode, system, world } from "@minecraft/server";
import { PlayerServer } from "api/@minecraft/Main";
world.beforeEvents.playerPlaceBlock.subscribe((eventData) => {
    const { player, block, permutationBeingPlaced: { type: { id: typeId } } } = eventData;
    const playerServer = new PlayerServer(player);
    if (playerServer.getPlayerProperty("adminPermissionModifyBlocks", true) && player.getGameMode() == GameMode.creative)
        return;
    if (player.location.x <= 100 && player.location.x >= -100 && player.location.z <= 100 && player.location.z >= -100) {
        eventData.cancel = true;
        return;
    }
    if (typeId == 'minecraft:lava' && JSON.stringify({ x: Math.floor(player.location.x), y: Math.floor(player.location.y) - 1, z: Math.floor(player.location.z) }) == JSON.stringify(block.location)) {
        eventData.cancel = true;
        return;
    }
    if (typeId == 'minecraft:slime' && JSON.stringify({ x: Math.floor(player.location.x), y: Math.floor(player.location.y) - 1, z: Math.floor(player.location.z) }) == JSON.stringify(block.location)) {
        system.run(() => {
            player.applyKnockback(0, 0, 0, 2);
            player.runCommandAsync("give @s slime")
        });
        const xBlock = block.location.x
        const yBlock = block.location.y
        const zBlock = block.location.z
        system.runTimeout(() => {
            player.runCommandAsync(`setblock ${xBlock} ${yBlock} ${zBlock} air`)
        }, 10)
        return;
    }
    eventData.cancel = true;
});

Why does this script work on a regular world but not on Realms?

runic gust
#

does applyImpulese work on minecarts

subtle cove
#

||```js
const a = []
a.push(a)

sudden nest
#

Is this normal? Player with spectator gamemode can be killed with kill @e

subtle cove
#

not script related, but it sure looks like bug

sudden nest
#

Oh okay, I'm literally PLAYING Minecraft for the first time

true isle
#

Not sure if I can say this the way I want but is it possible to make a block drop items based off its permutations and have them triggered individually and keep data on the block with said perms? I have a block that when an item is used on it it changes permutations but I want to be able to get the item back either when broken or interacted with again with the same item

shut citrus
#

maxDistance is radius?

subtle cove
#

yes

shut citrus
subtle cove
#

minDistance is rm

shy leaf
#

sadly no

oblique heath
#

😦

abstract cave
#

hmm, i know theres a way to make a method not throw an error, but i cant seem to remember, theres no problem in the script fiile, except when the conditions for the if statements arent met. can anyone show how its done

slow walrus
#

try {} catch(e) {}

#

and you shouldn't have to use that

#

write your code so that you don't get errors

abstract cave
#

also, the code works as intended, its just that when its check the player for a specific component and the component isnt there, it gives an error

granite badger
#

What component are you looking for?

slow walrus
random flint
slow walrus
#

but anyway either of those ^^ should work

abstract cave
#

thanks yall

remote oyster
# abstract cave thats what i meant, the question mark thingy, so it can throw an undefined inste...

It throws an error if you attempt to access a property or method from getComponent() that returns undefined since whatever property or method you are attempting to access does not exist. It won't throw if the component is undefined. It simply returns undefined.

So like Gega demonstrated, you can conditionally check if it's defined or not defined before accessing the component.

Example 1 (Ternary Operator):

const comp = player.getComponent("comp");
const message = comp ? "Component is defined" : "Component is undefined";
console.log(message);

Example 2 (Logical OR Operator):

const comp = player.getComponent("comp");
const defaultComp = "default";
const effectiveComp = comp || defaultComp;
console.log(effectiveComp); // Logs "default" if comp is undefined

Example 3 (Logical AND Operator):

const comp = player.getComponent("comp");
comp && console.log("Component is defined"); // Logs message only if comp is defined

Example 4 (Nullish Coalescing Operator):

const comp = player.getComponent("comp");
const fallbackComp = "fallback";
const finalComp = comp ?? fallbackComp;
console.log(finalComp); // Logs "fallback" if comp is undefined or null

Example 5 (typeof Operator):

const comp = player.getComponent("comp");
if (typeof comp !== "undefined") {
    console.log("Component is defined");
} else {
    console.log("Component is undefined");
}
slow walrus
#

and maybe strings

#

is "" counted as false?

#

ah yes it is

#

better readability as well

#

the only ones that wouldn't need that are the typeof and nullish coalescing operator

#

yes

#

that's not the same as undefined though

remote oyster
#

There are many ways to do it. Really just comes down to knowing what your code is doing, and understanding what it could possibly do under circumstances and how you select to handle the conditions best suited for the environment.

distant tulip
woven loom
#

found better neovim alt bao_doggo_hearteyes

misty pivot
#

is it better to detect if the typeId is player or use instanceof Player?

woven loom
#

playerid is better imo

unique dragon
#

tbh it doesn't matter

misty pivot
#

alright then

distant tulip
woven loom
#

termux yes

#

😅

#

installing in just 2 step

sharp elbow
#

In my event subscriptions meant to affect only players, I filter out non-players using !(player instanceof Player) for that reason. From that line onward VSCode knows I am working with a player. This does not happen with player.typeId != 'minecraft:player'

#

Only other way I know to assert it as Player is to copy the entity instance from the function parameters. (e) => {const player = (e.sourceEntity as Player); ...}

inland merlin
#

Does anyone know if we can grab player skins on bds?

inland merlin
#

Rip

#

Ty for quick response

unique dragon
oblique heath
inland merlin
unique dragon
#

plugin*

oblique heath
#

same thing

distant tulip
#

not really

oblique heath
#

i mean you need to make a mod to retrieve that data from the server

#

¯_(ツ)_/¯

#

"plugin" is just what mods for servers are called

unique dragon
#

modification

distant tulip
#

it is not a mod unless it is directly editing the server files

#

not adding

oblique heath
#

so if a forge mod doesn't modify anything it's not a mod?

#

great logic lmao

unique dragon
#

forge modifies always the game

distant tulip
#

forge it self is a mod...

unique dragon
#

data pack in java it's like an addon

oblique heath
#

forge is the modloader but sure its a mod

distant tulip
#

you get my point

oblique heath
#

plugins are mods...

#

pointless debate lmao

distant tulip
#

alr

unique dragon
#

💪

#

getEntities({ type: yourTypeId })

distant tulip
#

dimension. what he said

unique dragon
#

cause it's getting the entities of the dimension

distant tulip
#

take the first element

unique dragon
#

array[0]

#

yesir

sharp elbow
#

I wonder how world.getEntities sorts. I assume it is by distance—and the location defaults to the world origin

fallow rivet
#

How can I spawn a particle between two locations?

#

Location

  1. 0 5 0
  2. 0 5 10
sharp elbow
#

How should it emit—one particle, halfway in between? Or a line of particles between two coordinates? If so, how many? Or should it be "x number of particles" per block? There are lots of ways to emit a particle between two points

fallow rivet
burnt remnant
#

message.js(29,35): Operator '+' cannot be applied to types '{ x: number; y: number; z: number; }' and '{ x: number; y: number; z: number; }'.

#

wdym i cant add numbers with numbers??? whats the point of numbers then???

distant tulip
#
function vector3add(a, b) {
    return {
        x: a.x + b.x,
        y: a.y + b.y,
        z: a.z + b.z
    };
}
fallow rivet
#

Is SpawnParticle for js or ts?

wary edge
#

TS transpiles to JS

fallow rivet
#

So how to use spawnparticle js?

fallow rivet
burnt remnant
distant tulip
#

no

#

also location is read only

burnt remnant
#

pretty much im trying to add 2 block positions together

wary edge
fallow rivet
#

But for ts

cold grove
#

Its only a problem if you dont code and just copypaste

small cloak
#

There are differences. Like TS does add language features (enums and decorators).

true isle
true isle
#

idk how to convert it to js

wary edge
true isle
#

yeah i got it do i import the function the same way as i do other js?

north rapids
#

ItemUseOn before event returns block before or after use?

sharp elbow
#

Try it, and see

burnt remnant
#

so why doesnt it work?

let { block } = e;
  let target = {
    x: block.x,
    y: block.y,
    z: block.z - 1
   };
  block.dimension.getBlock(target).setType("minecraft:oak_planks");
  target.y + 1
   if(target.typeId === "minecraft:oak_log"){
    block.dimension.getBlock(target).setType("minecraft:oak_planks");
    target.y + 1
     if(target.typeId === "minecraft:oak_log"){
      block.dimension.getBlock(target).setType("minecraft:oak_planks");
      target.y + 1
       if(target.typeId === "minecraft:oak_log"){
        block.dimension.getBlock(target).setType("minecraft:oak_planks");
        target.y + 1
         if(target.typeId === "minecraft:oak_log"){
          block.dimension.getBlock(target).setType("minecraft:oak_planks");
          target.y + 1
         }
        }
      }
    }
#

currently it only works up to the first set type oak planks, after that nothing happens

wary edge
#

Thats a whole load of nested code

burnt remnant
#

thats just the simplified version

#

a loop where it keeps executing the same code infinitely until the if statement fails was something i thought of initially but idk how to do that

#

but im guessing the target.y+1 is the problem since thats when its stops

glacial widget
#

can someone tell me why this dont work?

const item = new ItemStack("minecraft:potion{Potion:swiftness}", 1)
      item.nameTag = "§l§bPotion of speed"
granite badger
subtle cove
#

Cus nothin was found...

#

Is it loaded...

#

getEntities is like @e

oblique heath
#

Do items that have the minecraft:damage component take durability when used to attack by default?

wary edge
#

Yes

oblique heath
#

That's weird

#

Is this like some oversight or just convenience

oblique heath
#

I'm surprised the game does the work for you

#

Instead of handling all that manually with a script

#

With a custom component

wary edge
#

Only breaking blocks does that

distant gulch
#

can i set player speed using script? Not effect

burnt remnant
#

so why doesnt it work

        let targetblock = {
          x: block.x,
          y: block.y,
          z: block.z - 1
         };     block.dimension.getBlock(targetblock).setType("minecraft:oak_planks");
         targetblock.y + 1
         if(targetblock.typeId === "minecraft:oak_log"){
          block.dimension.getBlock(targetblock).setType("minecraft:oak_planks");
#

its not adding + 1 to y

valid ice
#

You are adding it, but not setting it back

burnt remnant
valid ice
#

Can do a few things-
targetblock.y++;
targetblock.y += 1;
targetblock.y = targetblock.y + 1;

burnt remnant
#

hmm still doesnt seem to work

#
let targetblock = {
          x: block.x,
          y: block.y,
          z: block.z - 1
         };
         block.dimension.getBlock(targetblock).setType("minecraft:oak_planks");
         targetblock.y = targetblock.y + 1
         if(targetblock.typeId === "minecraft:oak_log"){
          block.dimension.getBlock(targetblock).setType("minecraft:oak_planks");
          targetblock.y = targetblock.y + 1
           if(targetblock.typeId === "minecraft:oak_log"){
            block.dimension.getBlock(targetblock).setType("minecraft:oak_planks");
            targetblock.y = targetblock.y + 1
             if(targetblock.typeId === "minecraft:oak_log"){
              block.dimension.getBlock(targetblock).setType("minecraft:oak_planks");
              targetblock.y = targetblock.y + 1
          }
         }
        }```
cinder shadow
#

you nested your if statements when they shouldn't be nested

cinder shadow
burnt remnant
#

but i want these if statement to run only if the previous one has

neat hound
#

all if-ing the same tho

cold grove
cinder shadow
#

this is what you did

#

oh

#

they are the same

#

why

neat hound
#

redundancy

cold grove
#

whaaatt

burnt remnant
#

so it can add +1 every time the if statement runs so the height gets higher

cinder shadow
#

but yeah, targetBlock.typeId doesn't exist

neat hound
#

is the log gonna change once inside the first if?

#

so no need to ask again

cinder shadow
cold grove
#

let targetBlock = block.dimension.getBlock({ x: block.x, y: block.y, z: block.z - 1 });
if (targetBlock.typeId === 'minecraft:oak_log') {
  targetBlock.setType('...');
}
burnt remnant
#

posted a thread on all this 2 hours ago, ive been working on this for 6 hours 😵‍💫

neat hound
#

ok see what you are doing. going upp and seeing if same for a vein miner?

#

perhaps a loop

burnt remnant
#

pretty much,like a tree capitator, but instead of breaking the block, i want it to be planks

neat hound
#

with a break when fails

#

how far?

burnt remnant
#

pereferably infinite but im sure thatll be a horrible idea, so up to 30 blocks since mega taiga trees can go up to 25

neat hound
#

you are changing logs for planks

#

what?

burnt remnant
#

yeah ik

neat hound
#

a loop can do however many and stopp when not a log

burnt remnant
#

yeah when coming up with the idea i had loops in mind but realised i know 0 about loops

#

im surprised i made it this far

valid ice
burnt remnant
#

and that also works with height?

valid ice
#

It adds one to the y direction every time the loop runs

#

And if the block above is not planks, it will stop the loop

burnt remnant
#

that is not as much as i thought it would take

neat hound
#

One wayjs let more=true; do { block.dimension.getBlock(targetblock).setType("minecraft:oak_planks"); targetblock.y = targetblock.y + 1; if (targetblock.typeId != "minecraft:oak_log") more=false; } while (more)

#

for more than 4

#

so you want to go out in all directions

#

make functions for x y and z with a parm of what to add... so either 1 or neg 1 and call that for each side

#

or one function if can use eval

burnt remnant
#

thank you everyone for the help, i really appreciate it. i wouldve started to lose hair

slow walrus
#

targetblock.typeId

#

targetblock would be a vector

#

not a block

shy leaf
neat hound
# slow walrus targetblock.typeId

No idea about if his code works as intended or not. I did not analyze it. I was just putting it in a loop per how he did it with giving him more than 4. Based on this #1067535608660107284 message. But looking at it, you are right.... but I have a feeling he figured that part... out I hope.

slow walrus
#

ah right

gray tinsel
#

What would the easiest way be to see what's causing a script delay error at world load?

shut citrus
shy leaf
#

what do you mean anymore

shut citrus
#

doesn't work

#

scripts issue

muted sun
#

what do you guys use for scripting?

#

I generally use bridge but Its been some time since I last made addons so there might be better alternatives rn

cold grove
#

The classic

muted sun
#

oh well so you set up the manifest manually?

shy leaf
#

you could use bridge to get manifest and then do the rest in vscode

distant gulch
#

can i change item name using script?

meager pulsar
#

Guys, if I use Minecraft:tick_world to keep an entity "loaded" can I access it's inventory even when on unused chunks?

cold grove
distant gulch
#

% is omitted when i getting lore how do I solve it?

restive folio
#

"adk-lib:digger_75"

wary edge
restive folio
restive folio
wary edge
restive folio
#

Is this right?

wary edge
# restive folio

Lets open a post and post your item code there in #1067869136606220288

cold grove
#

😱

wise raft
#

How can I stop a cooldown?

shy leaf
shy leaf
wise raft
shy leaf
#

theres a thing that allows you to set cooldown for category

wise raft
#

and how can I do that?

deep plank
#

The player class have startItemCooldown method. This allows you to set cooldown of an item by category with specific ticks you want.

solar dagger
#

If my script is teleporting an entity at a specified location. How can I continue doing that after the world reloads?

shy leaf
#

maybe dynamicProperty?

solar dagger
shy leaf
#

i think that would be your choice

solar dagger
#

And I believe we would have to stringify it

shy leaf
#

let me check smth

#

it stores string, mumber, boolean, Vector3

#

hmmmm

solar dagger
inland merlin
#

Does anyone know a bdsx discord server link for active help?

#

Like a main one etc

inland merlin
#

Awh thx

knotty plaza
#

Idk why you want to use bdsx after the pdb getting removed but here it is

inland merlin
#

People saying endstone?

knotty plaza
#

I haven't looked into that

umbral scarab
#

Does anyone know how I would go about making a leap ability? I'm looking at applyImpulse but not too sure how to apply it in the direction the player faces

sage portal
#

applyImpulse doesnt work on players

#

alternatively you can use knockback, along with player.getViewDirection()

umbral scarab
#

ok thank you!

gray tinsel
#

just search for how to print % in string js or smth

deep quiver
#

% is used for translation keys

#

tbh idk

gray tinsel
#

it's an issue with js itself I believe

#

actually wouldn't say it's an issue it's just how js formats stuff

sage portal
#

It's dumb, but it worked for me.

unborn iris
#

do arrays not react reactivly in classes?

wary edge
inland merlin
#

.

#

What's the latest npm packages, I forgot the best link for them, or app here

gaunt salmonBOT
unborn iris
inland merlin
#

Sorry

sudden nest
#

Does onUseOn method for ItemCustomComponent work on custom blocks or not? I heard it has issues

wary edge
sudden nest
#

Ohhh, okayy. Thankss!

lone thistle
meager pulsar
#

Guys 2 questions
What's the maximum amount of dynamic properties an item can have?
What's the max length of a string that can be stored in a dynamic property?

tight plume
#

Guys is there a limit on how many participants can be in an objective? Talking about scoreboards

solar dagger
#

does EntityLifeTimeState not work?

cold grove
solar dagger
#

does it matter? im just testing

cold grove
#

bruh

#

you can use Entity#isValid()

#

theres no other mention in the docs of that

round agate
#

made a custom entity stacker

#

and item stacker

honest spear
#

nice

valid ice
#

How’d you edit the ground entity? Or did you just summon a new one?

celest fable
#

i have this method on my Entity

  mc.Entity.prototype.isMoving = function() {
    let v = this.getVelocity()
    if (v.x != 0 || v.y != 0 || v.z != 0) return true
    return false
  }

how do i detect the head movement?

#

because this one only detect the velocity or the "entity" movement

honest spear
celest fable
#

well yeah, but how do i check it at different tick when the usage of isMoving is inside of runInterval?

#

owh i know, nvm

uncut fjord
#

So I come back after a couple weeks to make a new project and now my auto completions for VScode and Bridge don’t work and I’m not getting any debugging from Minecraft either. Is there something I missed?

celest fable
#

wat?

#

btw what is "target" from the chatSend property

#

isit the @name thing?

buoyant canopy
#

how to convert an item entity into an item stack?

#

never mind, i figured it out

oblique heath
#

lmao

remote oyster
buoyant canopy
#

can i change the item entity amount without converting it to an itemStack and back to an entity?

distant gulch
#

how can i get slot1 item?

buoyant canopy
nocturne berry
#

How do you solve this?

buoyant canopy
nocturne berry
# buoyant canopy how does line 10 in main.js look like?

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

world.beforeEvents.worldInitialize.subscribe((eventData) => {
eventData.itemComponentRegistry.registerComponent("fm:on_use", {
onUse(itemEvent) {
if (itemEvent.item.typeId === 'fm:magic_wand') {
itemEvent.source.runCommand(summon zombie ~~~);
}
}
});
});

buoyant canopy
#

oh, it's surrounded by back ticks

nocturne berry
buoyant canopy
nocturne berry
shy leaf
#

not itemEvent.item.typeId

nocturne berry
distant gulch
#

how can i get items amount?

shy leaf
#

and for related stuffs,
itemStack.isStackable
itemStack.maxAmount

proud saddle
#

how work server net module?
what mean "dedicated server"?

subtle cove
#

bds

alpine ibex
#

Does anyone know how to make a command constantly be active if the player is on the ground and when you're in the air it stops?

#

I've been trying to make a script for it but nonetheless haven't figured one out

distant tulip
plush moss
#
            "minecraft:damage_sensor": {
                "triggers": [
                    {
                        "on_damage": {
                            "filters": [
                                {
                                    "any_of": [
                                        {
                                            "test": "has_dynamic_property",
                                            "subject": "self",
                                            "operator": "=",
                                            "property": "protection",
                                            "value": 1
                                        },
                                        {
                                            "test": "has_dynamic_property",
                                            "subject": "self",
                                            "operator": "=",
                                            "property": "protection",
                                            "value": 1
                                        }
                                    ]
                                }
                            ],
                            "event": "test"
                        }
                    }
                ]
            }
        },

Does anyone knows how to test dynamic property in player.json

remote oyster
#

I don't believe you can.

plush moss
#

😦

#

you can test tag with has_tag

#

but i want i with dynamic propertys xd

remote oyster
#

Gonna have to use tags I think.

sharp elbow
#

Dynamic properties are exposed only via scripting.

#

You could copy it over to entity properties, through Entity.prototype.setProperty.

plush moss
#

Smart

wanton ocean
#

What’s the difference between using a custom component and using a plain script?

#

Like for example on_use replacement

supple warren
#

Hi, does anyone know how to open an interface with an item using scripts?

shy leaf
#

but its no different in the end

#

its just that custom components have more functions
you can go for the one you find the best

valid ice
valid ice
slow walrus
#

yeah it is generally

#

specific event fired instead of a queue of events

shy leaf
#

is there a way to check how long the player has been sneaking without runInterval?

unique dragon
#

save the ticks in a dynamic property

#

then multiply by 20

shy leaf
#

without runInterval

unique dragon
#

ah

#

i haven't see that

shy leaf
#

hmmm

#

animation controller time then

unique dragon
#

yes

#

q.life_time and q.is_sneaking

shy leaf
#

i kinda wanted to do all of this in scripts but

#

ig its unavoidable lol

shy leaf
#

or do i just need RP AC and BP AC for this

#

i havent used it for so long i forgot

unique dragon
shy leaf
#

yeah but like

#

oh wait

#

yeah im stupid lol

neat hazel
#

Why is this happening?! If my code contains the entity "n:iruka"
My code:

// npc interact
mc.world.afterEvents.entityHitEntity.subscribe((data) => {
  const player = data.damagingEntity;
  const damaged = data.hitEntity;
  if (player.typeId === "minecraft:player" && damaged.typeId === "n:iruka")
    iruka(player);
    player.runCommandAsync("camera @s set minecraft:free ease 1 in_out_expo pos ~~3~-5 rot 25 0")
    player.addTag("inUi")
})
shy leaf
#

it only checks and affects iruka(player) but not the other two rn

neat hazel
distant gulch
#

Anyone have any idea how I could save an item in my inventory? Like a shulker full of stuff?

solar dagger
uncut fjord
#

did getEquipment get deprecated?

lone thistle
uncut fjord
#

Weird I just found the problem

#

Apparently getEquipment is still in beta :|

lone thistle
#

Lots of things are still in beta

lone thistle
#

They may be in a diff mc version

uncut fjord
#

Guess I messed up somewhere else. But my pack I posted 3 weeks ago is now broken and it used that class. That one was using a full release version of the api as well so idky it broke

empty yoke
#

I'm trying to figure out how to run a command as soon as the player has loaded the world and not before, like it happens with playerSpawn event

empty yoke
empty yoke
empty yoke
scarlet sable
gaunt salmonBOT
#

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 2 errors:

emojis.js:130:10 - error TS2540: Cannot assign to 'message' because it is a read-only property.

130     data.message = Object.keys(emoji).forEach(key => data.message = data.message.replaceAll(`${key}`, emoji[key]))
             ~~~~~~~

``````ansi
emojis.js:130:59 - error TS2540: Cannot assign to 'message' because it is a read-only property.

130     data.message = Object.keys(emoji).forEach(key => data.message = data.message.replaceAll(`${key}`, emoji[key]))
                                                              ~~~~~~~

Lint Result

ESLint results:

emojis.js

2:7 error 'Commands' is defined but never used @typescript-eslint/no-unused-vars

remote oyster
# scarlet sable can you help me fix this script?

You are attempting to modify message in the chatSend event which is currently not modifiable. The developers have made it read only. What you will want to do is cancel the event, and instead send the message by looping through all players in the world.

#

Modify the message by storing it in another variable.

scarlet sable
#

ty

shrewd wedge
#

Is possible to have armour in hand and put trim?

shrewd wedge
#

People can buy armour trim in my world, is possible to habe select trim, than the ore and put it on armour that player is holding?

#

You understand?

scarlet sable
#

yep

#

i think it is

shrewd wedge
#

How to do?

scarlet sable
shrewd wedge
#

Hahaha, okay

scarlet sable
#

sorry ain't that good with java script either lol

shrewd wedge
#

Ja is very hard

scarlet sable
#

ikr

shrewd wedge
#

maybe I am just a idiot

scarlet sable
#

c++ made me think coding is easy lol

shrewd wedge
#

It take me long time to learn code

remote oyster
shrewd wedge
#

that is what I was thinking

#

where to see document for component

#

I see people use .container and .currentValue when get component. But I check doc and don't see ?

tiny tartan
#

does player.id change after rejoining the world?

unreal cove
scarlet sable
#

i find it quite the opposite lol

shy leaf
#

but i find javascripts better in terms of difficulty

#

its easy to learn for most people, and i think thats why they chose javascripts for scripting

scarlet sable
#

i see

uncut fjord
#

Anyone know a way to test if the player is riding another entity using scripting?

uncut fjord
#

Thanks

#

Anyone know a way to use an arrow runtime identifier without it dropping an arrow when you touch it?

wintry bane
uncut fjord
#

I need the player to be close and the arrow to respawn in order for the rest of the mechanics to work. Is there a way to make it identify as an arrow that was shot with infinity?

#

Technically I could run a command when it is picked up to automatically clear it but I was hoping there was a way to prevent it altogether

unreal cove
#

Is there anyway to check if the dropped entity is a specific item? (For example, chest)

Without actually testing for it's name

granite badger
#

entity item component

unreal cove
shrewd wedge
#

How to detect if player hold nothing?

#

It say "undefined" and say error in console log all time if I hold nothing

shrewd wedge
#

I fix

#

Sorry

alpine ibex
#

Does anybody know how I can make a command activate when on air? and where I'm specifically looking at

alpine ibex
alpine ibex
#

Yea swing is like when you punch

#

But you don't actually punch

shrewd wedge
#

Is possible to put armour trim on item player is holding?

neat hazel
alpine ibex
#

Is it possible to make a script where when a player is outside of the sun he takes damage but doesn't set on fire

nocturne berry
#

Does anyone know why the first command executes without detecting the item in the second hand?


world.beforeEvents.worldInitialize.subscribe((eventData) => {
    eventData.itemComponentRegistry.registerCustomComponent("fm:on_use", {
        onUse(itemEvent) {
            const mainHandItem = itemEvent.itemStack; 
            const offHandItem = itemEvent.itemOffhand;
            if (mainHandItem.typeId === 'fm:magic_wand' && offHandItem?.typeId !== 'fm:avada_kedrava') {
            itemEvent.source.runCommand('function extrair');
            }
            if (itemEvent.itemStack.typeId === 'fm:fire_wave') {
                itemEvent.source.runCommand('function fire');
            }
            if (itemEvent.itemStack.typeId === 'fm:expecto_patronum') {
                itemEvent.source.runCommand('function patronum');
            }
            if (itemEvent.itemStack.typeId === 'fm:thunder_search') {
                itemEvent.source.runCommand('function light_ray');
            }
            if (itemEvent.itemStack.typeId === 'fm:levitate_search') {
                itemEvent.source.runCommand('function levitate');
            }
            if (itemEvent.itemStack.typeId === 'fm:time_search') {
                itemEvent.source.runCommand('function skip');
            }
        }
    });
});```
cold grove
#

You need to get the player equipment component to get the item equipped on off hand

shut citrus
#

how to play animation when player interact

broken dagger
#

How do I run a function when closing the form?

solar dagger
devout dune
#

Hellooo. I am trying to simply have my custom block be destroyed. if the block underneath it, is suddenly air.

I was thinking maybe having a custom_component (tick) on my blocks. subscribe to this. and constantly check the block below. if block == 'minecraft:air' destroy block?

Does this seem like a valid approach. maybe there is something more simple. Like a direct placement_rule component?
and maybe i can exclude air?

I would just like the block to destroy, instead of float. if the block below is destroyed

#

^^ custom_components. But i was hoping for maybe a more direct approach

oblique heath
#

Why is playsound in Player instead of Entity class

#

😐

cinder shadow
#

because the player playsound only plays the sound for the player

#

dimension playsound plays it for everyone

oblique heath
#

why isn't it just in the Entity base class

cinder shadow
#

because if it was, it would only play the sound for the entity?

#

What use does that have

#

no one would hear it but the entity

oblique heath
#

can you confirm this?

#

So basically you're telling me only that player can hear the sound and not other players?

#

When ever I call the player playsound

granite badger
#

player.playSound only play sounds to a specific player, I think you mean dimension.playSound?

Also playing sounds to an entity makes no sense, they can't hear anything

oblique heath
#

Wasn't aware the sound wasn't broadcasted to everyone around the player

#

Makes sense then

inland merlin
#

Any good methods to make an addon the most efficent/performance friendly as possible?

When an addon gets really big, it obviously depends on how it's made/structured but what good practices are there

I've used prototype, and for loops, and stuff like that for minor help.. but because we only have one thread is there much we can do?

granite badger
#

Use the debugger extension and the script profile, it helps showing the performance difference

inland merlin
#

On pc can I actually see a graph?

inland merlin
inland merlin
#

Oh thats cool

winter plaza
#

How do I identify if there are mobs around in 5 blocks distance to execute a command?

stuck spoke
#
toTp.clearVelocity();
toTp.teleport({ ...entity.location, y: entity.location.y + 0.2 });

when running this using system.runInterval, why does it teleport entities perfectly to everything except players? When teleporting to a zombie, pig, etc, even when moving at high speeds, it's perfectly cantered but when entity is a player, it can't handle even a slight movement, it always lags behind by a lot

umbral dune
#

redatone components, huh?

fiery solar
# inland merlin Any good methods to make an addon the most efficent/performance friendly as poss...

I've been thinking about doing a write up of this recently. The debugger and script profiler are very helpful for figuring out bottlenecks if you're already having issues.

More generally for performance you want to

  • don't use Armor Stands for anything
  • avoid using runCommand/runCommandAsync at all if possible.
  • avoid using scoreboards for storing any type of data unless you are showing that value in a scoreboard to the player
  • cache or memoize everything you can, there are a lot of things (like world.getPlayers or entity.getComponent) that people don't realize are native calls that take significantly longer than referencing an array.
  • in most cases you should only have one subscription to each event type in your entire addon
  • think hard about using any runIntervals, use the longest interval you can, not everything needs to run every tick

If you're looking for more general advice on maintainability of a large addon, use typescript and eslint, write lots of game tests and avoid modifying any of the prototypes from @minecraft/server

inland merlin
#

Yeah I break some of these rules lol. I try native as much as possible etc..

inland merlin
#

Works great, just the amount if calls

#

I use cache as much as possible

#

Dynamic properties works as well, I like I could cross save between addons

#

With scoreboard

#

Only reason I stay scoreboard method

fiery solar
inland merlin
#

If that's the case...

#

I might go back to dynamic properties, I need some solid evidence and someone to show tests

#

That would be so cool

#

Speed tests

fiery solar
#

Scoreboards are good for cross-addon storage if that's something you need admittedly.

#

I have a performance test framework that I'll share when I get home later tonight.

pale terrace
#

What types of damage ignore the shield apart from magic and override?

shy leaf
#

and prob anything that arent entityAttack and entityExplosion

pale terrace
#

thank you

carmine cloud
#

yall know why my decorators are showing up in my compiled js? i just migrated my code from using experimental decorators to the newer stage 3 decorators. do they not get "dumbed down" anymore? i dont think my tsconfig is too weird either.

{
  "compilerOptions": {
    "module": "ES2020",
    "target": "ES2021",
    "moduleResolution": "Node",
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,

    "paths": {
      "@/*": ["./packs/BP/scripts/*"]
    }
  },
  "exclude": ["node_modules"],
  "include": ["packs/BP/scripts"]
}
shrewd wedge
#

Is possible to put armour trim on item player is holding?

carmine cloud
shy leaf
#

is there a module that checks whether the player stopped hitting a block?

glacial widget
#
if (!(
            player.hasTag("soldier") || 
            player.hasTag("elite") || 
            player.hasTag("general") || 
            player.hasTag("overlord") || 
            player.hasTag("king") || 
            player.hasTag("emperor") || 
            player.hasTag("dragon") || 
            player.hasTag("eld-dragon") || 
            player.hasTag("demi-god") || 
            player.hasTag("god") || 
            player.hasTag("eld-god"))) {

            player.sendMessage(`§l§dHCV KitPvP >> §cYou need to be soldier rank or higher to claim the kit`);
            } else if(
              player.hasTag("soldier") || 
              player.hasTag("elite") || 
              player.hasTag("general") || 
              player.hasTag("overlord") || 
              player.hasTag("king") || 
              player.hasTag("emperor") || 
              player.hasTag("dragon") || 
              player.hasTag("eld-dragon") || 
              player.hasTag("demi-god") || 
              player.hasTag("god") || 
              player.hasTag("eld-god")) {

              claimKit(player)
            }

When i have the solider tag this works but with any other tag i cant run the claimKit function

shy leaf
#

you can just

#

do for loop with an array

glacial widget
glacial widget
shy leaf
#

instead of checking for every single tags

#

you can do

const tags = [ "soldier", "elite", ... ];```
glacial widget
shy leaf
#

and then do

for (let i=0; i<tags.length; i++) {
    if (player.hasTag(tags[i]) { break; }
    //code
}```
shy leaf
valid ice
#

use

#

.every

#

array method

#
const tags = [ "soldier", "elite", ... ];
if (tags.every(tag => player.hasTag(tag))) ...
carmine cloud
#

wouldnt u want to use tags.some not .every?

carmine cloud
shy leaf
#

language barrier

#

lol

#

but yeah

shy leaf
valid ice
#

many, likely

valid ice
#

.some for OR, .every for AND

shy leaf
#

noted

#

how does volume for EntityQueryOptions work?

#

aside from it being Vector3

valid ice
#

x, y, z, dx, dy, dz selectors in commands

shy leaf
#

so if i do { x:1, y:1, z:1 }, it includes entities that are inside the cube with volume of 1 centered on the location?

#

sorry ive never used those target selectors in my life so i dunno much lol

misty pivot
#

can i use functions in constants like this?

const object = {
    "onSneak": function(player) {
        player.sendMessage("test")
    }
}

object.onSneak(player)```
because when i tried it, player is said to be undefined
shy leaf
#

the player is actually and literally undefined

#

you could wrap object.onSneak(player) in world.getAllPlayers().forEach()

misty pivot
#

the one on the bottom is how i'd used it/typed it out, i did use the object in a getPlayers

misty pivot
#

player was still undefined tho

valid ice
#

the location defines one corner, and the volume specifies the distance along each axis

misty pivot
glacial widget
#

i just did a typo on "emeperor" which messed up everything

shy leaf
glacial widget
cinder shadow
#

me when "minecraft:soul_torch" is not included as a passableBlock in raycast options 🗿

cinder shadow
#

ahh so I just can't seem to detect a decorated pot with getBlockFromRay period

#

thought I just did something wrong

#
                const hitBlock = block.dimension.getBlockFromRay(block.south(1).location, {x: 0, y: 0, z: 1}, { maxDistance: range - 1, includePassableBlocks: true, excludeTypes: ['minecraft:soul_torch'], includeTypes: ['minecraft:decorated_pot'] });
#

it just doesn't detect it at all :]

thorn flicker
#

gotta love it

distant tulip
#

block.south(1).center()

#

or bottom center

#

reminded me of when i tried to detect double chest by shouting a ray between the tow
turns out the collision box have a gap

winter plaza
#

How do I identify if there are mobs around in 5 blocks distance to execute a command?

distant tulip
#

what component trigger onCompleteUse?

shy leaf
distant tulip
shy leaf
#

isnt that used for food too

#

welp close enough Face

distant tulip
#

yeah
but not only food