#Script API General

1 messages · Page 16 of 1

fallow rivet
#

For example
let banneditemslist = [[minecraft:skull],[minecraft:Herobrine]]

valid ice
#

but again, why the double

#

why not just ['minecraft:skull','minecraft:Herobrine']

distant tulip
fallow rivet
distant tulip
#

alr
is that chest ui

remote oyster
#

Each comma represents an element in an array

distant tulip
fallow rivet
fallow rivet
remote oyster
remote oyster
#

But what?

fallow rivet
#

1 sec

#
let banneditemslist = [[`minecraft:skull`],[`minecraft:Herobrine`]]

İf (item != banneditemslist[0]) {

}
distant tulip
#
const skulls = {
    0: "skeleton",
    //...
}
let skullData = 0
for(let data = 0; data < 6; data++) {
    const commandResult = player.runCommand(`testfor @s[hasitem={location=slot.inventory,slot=${slot},item=${id},data=${data}}]`);
    if (commandResult.successCount > 0) {
        skullData = data
        break
    }
}
const type = skulls[skullData]
remote oyster
#

You have two arrays inside a single array.

distant tulip
remote oyster
#

Yup, wasted resources in that instance lol.

fallow rivet
#

I just realized this

remote oyster
#

All good 👍

glacial widget
#
const tier1 = new ItemStack("minecraft:chest", 1)
                            inventory.addItem(tier1)
                            tier1.nameTag == "tier 1"

Is this the right way to add a name to a item you want to give yourself?

valid ice
#

set name before adding to inventory

ionic kayak
#

Is there an alternative to world initialize event that is not beta?

glacial widget
valid ice
#

world initalize is not beta

ionic kayak
#

Good to know

valid ice
#

It's stable in 1.13.0, as are custom components 👍

valid ice
#

double is comparing it to the existing name

glacial widget
#

ohhh i didnt know because i thought double equals could do both assignment and compair

#

thanks for that

valid ice
#

Triple is strict comparison

ionic kayak
valid ice
#

It will not, no.

#

Custom components just went stable (along with world initalize) in 1.13.0

neat hound
#

Anyone master getting a Vector3 from a DynamicProperty while using ts-check and using it , i.e. passing to function with Jdoc saying expected type is Vector3, without having to use ts-ignore..??? in JavaScript. I cannot find a way to trick it.

glacial widget
#

is there a way to clear a item from your main hand?

valid ice
#

Player.getComponent('equippable').setEquipment('Mainhand')

wary edge
neat hound
valid ice
#

/** @type {Vector3} */ doesn't work?

sharp elbow
#

It will suggest it in Intellisense, but it will not highlight invalid usage as an error IIRC

neat hound
valid ice
#

hmm

sharp elbow
#

Well it is a valid error. It could return undefined.

neat hound
#

I get around almost everything else.. but this one. The code works fine, but I want to use JS with ts-check and jdoc to force me to do the things that make sure I don't mix types.

sharp elbow
#

TypeScript has the "ignore any issues" operator, !, but JS does not have an equivalent I believe

neat hound
#

Shows as error only with ts-check.. not a real error

untold magnet
#

I'm using that to get all entities, so is it possible to do that inside of runInterval?

#

i think so

neat hound
#

I can use ts-ignore above the line.. tryna avoid that if I can

valid ice
sharp elbow
#

You won't like my other suggestion then. I suggest asserting that the type is defined through a type comparison:
if(xyz == undefined) return;
Then thereafter xyz cannot potentially be undefined ... though I suppose this is not fixing the assignment step

untold magnet
glacial widget
# valid ice `Player.getComponent('equippable').setEquipment('Mainhand')`

is there a way to do it one at a time?

      world.structureManager.place("kit:1", player.dimension, { ...player.location, y: player.location.y + 2})
      const inventory = player.getComponent(`inventory`).container
      const block = player.dimension.getBlock({ ...player.location, y: player.location.y + 2 })
      const chest = block.getComponent(`inventory`).container
      for (let i = 1; i < chest.size; i++) {
           const item = chest.getItem(i)

          if (item) inventory.addItem(item)
      }
      player.getComponent('equippable').setEquipment('Mainhand')
      system.run(() => { block.setType(`minecraft:air`) });
sharp elbow
#

Or when assigning XYZ, use null coalescing:
const xyz = world.getDynamicProperty('my_property') ?? {x: 0, y: 0, z: 0};

glacial widget
valid ice
#

oh. There's no native methods for that, no

glacial widget
#

oh alright then

subtle cove
neat hound
# sharp elbow You won't like my other suggestion then. I suggest asserting that the type is de...

It seems that using xyz period is a problem as everything is typed....js const xyz = world.getDynamicProperty("deadEntityLocation") ?? {x: 0, y: 0, z: 0}; const entityLocation = !['string','boolean','number','undefined'].includes(typeof xyz) ? xyz : {x: 0, y: 0, z: 0} if (entityDimensionId && entityLocation ) msg += ` @ ${entityDimensionId} ${fn.vector3Msg(entityLocation)}`;

the last part is not happy because that function requires vector3.. pic is the annotation I see.

#

cannot seem to assure it that I am sending a Vector3

#

without using ts-ignore above the line

wary edge
#

Shrimply use typescript

sharp elbow
#

This seems to work for me:

const xyz = world.getDynamicProperty("deadEntityLocation");
if (typeof xyz != 'object') return;          
if (entityDimensionId) msg += ` @ ${entityDimensionId} ${fn.vector3Msg(xyz)}`;
ionic kayak
static nebula
#

How can I apply damage to an entity, like

player.applyDamage(2);
#

?

amber granite
neat hound
neat hound
#

Thanks Sprunkles.. nice to see ya lurking around handing out the knowledge again

granite badger
sharp elbow
#

You referring to the includes(typeof xyz) bit? Or me doing early-out return

neat hound
#

Me and ts-check with Jdoc playing hide and seek... should see what I had to do for a callback ptr... and still not sure this is the best way #1276605171635327007 message

valid ice
north rapids
#

How do I get all blocks in an certain area?

ripe swan
#

would anyone happen to know where in the writable_book item the written data is stored at? both the getlore() and getcomponents() methods are returning array sizes of zero.

neat hound
#

why did that not work.. did I do it backwards?

sharp elbow
#

There is a space between your ] (

untold magnet
#
system.runInterval(() => {
  const dimensions = ['overworld', 'nether', 'the_end'].map(dim => {
    for (const entity of world.getDimension(dim).getEntities()) {
      const block = entity.dimension.getBlock(entity.location)
      if (block.below(0.1).typeId === 'minecraft:dirt') world.sendMessage('DIRT!!')
    }
  })
})
```this should work right?
#

yes it dose

#

lemme cook nowbao_doggo_angry

untold magnet
#
entity.runCommandAsync(`execute at ${entity},,,)
```isnt working
#

especially at ${entity}

lone thistle
#

Have you tried @s as well

untold magnet
#
entity.runCommandAsync(`execute at @e[type=¢{entity}] ,,,`)
```?
lone thistle
untold magnet
#

i know how @e work,

lone thistle
#

Then you have the answer to your question

untold magnet
lone thistle
#

assuming your entity is returning a typeId, yeah

untold magnet
#

alright cool, thanks batman

#

stills the same log, anyways I'll try @e only and do some tests

lone thistle
#

Send the error

inland merlin
#

Has anyone got the inventory part to work with herobrines chest ui?

#

Hoping someone have already made a custom fix

untold magnet
#

u can see how laggy is it when i used only 2 commands, jeezbao_doggo_dead

inland merlin
#

are these commands memory leak?

neat hound
#

gets exponential real fast

inland merlin
#

thats what i was thinking many instances

#

better to use native

#

just depends on the command being used

neat hound
#

each entity should run @s for itself

inland merlin
#

hmm

#

get entities in range, and then work with object/coords?

untold magnet
neat hound
#

it works in commands.... are they not a self.... then do @e with c=1

#

they are the closest to themselves

untold magnet
#

so like this?

entity.runCommand(`execute at @s if block ~0.3 ~-0.1 ~ exe:conveyor["minecraft:cardinal_direction" = "north"] run scriptevent conv:North`)
inland merlin
#

r=1?

#

hmm

#

oh this is a conveyor thats cool

neat hound
#

c = closest #

inland merlin
#

yeh

#

ok

untold magnet
#

that actually makes sense bec entity is already a world.dim.getAllEntities

#

i mean for (const entity of world.getDimension(dim).getEntities()) {

#

lemme try @s first

#

it's working fine now

inland merlin
#

awesome

inland merlin
# untold magnet it's working fine now

do you have a a down and up for all sides? that would be so nice, it goes diagnoally down up etc... instead of just dropping off ledges, and could travel upwards

untold magnet
inland merlin
#

this would be awesome as just a standalone pack, what kinda addon?

untold magnet
#

conveyors are the basic machines

inland merlin
#

awh ok

#

would work well with the new crafting block

#

and hoppers

#

feel like true factory lol

untold magnet
#

to move entities up or down or any direction, use a block called fan ig that are enhanced machinery

untold magnet
#

actually my project is kinda huge

inland merlin
#

thinking cake factory

#

lol

untold magnet
#

over 37+ new ores tho

inland merlin
#

ooo thats cool

untold magnet
#

i will add uranium too :>

#

to create a nuclear reactor for generating infinite power from it

#

and yes

inland merlin
#

oh very fun

untold magnet
#

theres some nuclear weapons, but only on creative

inland merlin
#

oh lol

#

creating explosions with api?

neat hound
#

Here is my conveyor belt... #add-ons message

#

I just tp 0.4 in moving direction

untold magnet
#

imagine u walk up to ur house and ur friend set a nuclear bomb on it,
its just a prank tho

inland merlin
#

lol

untold magnet
#

bec TP isn't really nice

neat hound
#

I think I didn't because it makes me look like I am walking, even if I m standing still

#

tp is fine once you find the right speed, it can be smooth

untold magnet
neat hound
#

space it out... I think Iread somewhere you get 128 per tick

untold magnet
#

um, how?

neat hound
#

remember, 20 ticks in one second.. don't need everything to be every tick... can be every... 5 ot 10

#

would need to see whole block of code to follow your logic

untold magnet
#

u mean making the interval works every 5 ticks or something?

#

actually

#

putting the commands inside of a function ( a minecraft function ) will make it better right?

neat hound
#

in block you set that.. here is mine json "minecraft:tick":{"interval_range": [6,6],"looping": true},

#

and then your onTick... does the rest

#

are you not using that

warm drum
#

what /fill in scriptAPI?

#

like how can i fill an area using script?

untold magnet
neat hound
#

look up run job, still command, but from script and runJob gives it the time to finish

untold magnet
neat hound
inland merlin
#

yeah best not to use comands if too many items... i know runCommandAsync has limit

neat hound
inland merlin
#

yeah runJob is the best method for filling blocks

untold magnet
neat hound
#

but yeahj, run job can space out your multiple commands over the ticks so you don't crash

untold magnet
#

i should put the commands inside of a function right? im still running them all but in the scripts section im running only one command

neat hound
#

Did you not do command blocks before.... they all add up.. don't matter if you run one thing... if that thing runs 400, then it is 401 things

#

but I do not know how they do the queue thing.. you need to spam test it

#

just add a side chat command that can do it

untold magnet
#

i actually have 32 commands to do for the conveyor for each 4 directions

#

so

#

im getting that issue with only 8 commands

neat hound
#

but for how many entities and how often

untold magnet
#

also, runCommand or runCommandAsync?

untold magnet
#

the script works on every single entity in the overworld, nether and the end

neat hound
#

don't know.. I just use runCommand.... I don't need anything at same exact time.... humans don't register things that fast

#

how many entities on the conveyor when you test

#

I made a square track (from the video in my post) so I can control where they go and how many.

untold magnet
#

that happens when i spawned only 3 pigs

neat hound
#

So you are not using custom components?

untold magnet
#

as my calculations, 32 commands will run for every single entity in the overworld and the nether and the end, which means; 2 entities = 64 command per tick
200 entities = 6,400 command per tick
7K entities = 224,000 command per tick

neat hound
#

so taht each part of the conveyor just processes it's own entities?

#

that is the object oriented way

#

or are you testing each entity to see if they are above a conveyor?

untold magnet
#

so i think, onTick could be the right choice

untold magnet
#

this should explain

#

each entity will run a command

viral plaza
#

How do I use player.teleport, like the dimension

neat hound
#

Entity.teleport(location: Vector3, teleportOptions?: TeleportOptions): void
@remarks
Teleports the selected entity to a new location

This function can't be called in read-only mode.

@param location — New location for the entity.

@param teleportOptions — Options regarding the teleport operation.

#

so in the options is to change dimensions .. but a conveyor is local, so no need to specify

untold magnet
#

i think onTick is more often in this situation

viral plaza
#
world.afterEvents.playerDimensionChange.subscribe(evd => {
  const player = evd.player
  const from = evd.fromLocation
  const fromDimension = evd.fromDimension
  if (fromDimension.id === "minecraft:overworld") {
   if (evd.toDimension.id === "minecraft:nether") {
     //player.runCommandAsync(`tickingarea add circle ${from.x} ${from.y} ${from.z} 1`)
     player.teleport(from, fromDimension)
     //setTimeout(() => player.runCommandAsync(`tickingarea remove ${from.x} ${from.y} ${from.z}`), 10)
     return new Message(`§c§lThe Nether Is Banned.`, player)
   }
  }


})

This works other than it doesn’t switch me to the over world

neat hound
#

you do not need to specify a dimension if not changing it

viral plaza
#

I am

#

They’re in the nether and I’m trying to get them out

neat hound
#

and.. that is the wrong format... see that link and look at teleport options, it is an object, not a striung

viral plaza
#

FromDimension is not a string?

neat hound
#

the second parm would be{dimension: "minecraft:overworld"}

#

there are other options you need to read them all

#

and add them into the object

viral plaza
#

I was on the docs and there is no teleport method posted

neat hound
#

you want to specify where to, now where from

#

lemme see if beta

viral plaza
#

keep velocity is nice

neat hound
#

It is stable

viral plaza
#
world.afterEvents.playerDimensionChange.subscribe(evd => {
  const player = evd.player
  const from = evd.fromLocation
  const fromDimension = evd.fromDimension
  if (fromDimension.id === "minecraft:overworld") {
   if (evd.toDimension.id === "minecraft:nether") {
     //player.runCommandAsync(`tickingarea add circle ${from.x} ${from.y} ${from.z} 1`)
     player.teleport(from, { dimension: `${fromDimension.id}`, keepVelocity: false })
     //setTimeout(() => player.runCommandAsync(`tickingarea remove ${from.x} ${from.y} ${from.z}`), 10)
     return new Message(`§c§lThe Nether Is Banned.`, player)
   }
  }


})

neat hound
viral plaza
#

Oh wait

neat hound
#

Isn't from where they are now and you said you are trying to take them out of there

#

so your from should be wher you want them to go

#

should not be called from

#

call TO

#

but you will put them in a strange place

#

you may want to do the 8 block math

viral plaza
#

Code works just changed it from the id to the actual dimension object

untold magnet
#

hmmm

#

i.dimension.runCommand('//command that detects entities at the block')?

viral plaza
#

Idk if this is even it

#

Hold up

#

You can pass a location argument

#

dimension.getEntites({
location: Vector3
}) I think

neat hound
#

always click on the options... it is an interface with multiple useful properties to make your options object

untold magnet
neat hound
#

r=1 is big a block in each direction... what is in this script event.

#

use c=1 guarantee to pick up only the self

granite badger
#

what are they trying to do

neat hound
#

he has a non-object-oriented conveyor belt... which means doing something with all entities all dimensions.... and has runcommand issues

#

the other guy is tryna TP people out of the nether after they go in

#

I'm going to go watch TV... your turn....

granite badger
#

Will onStepOn event be a better option

neat hound
#

Jayly.. love your docs.. I don't thinik I ever close the web page....

#

of course.. be he may need to realize... woulda gave my code, but he needs to work it out... trial and error... so he can learn via experience.

viral plaza
#

Item grouper addon?

meager pulsar
#
world.afterEvents.playerInteractWithBlock.subscribe```

what´s wrong with the sintaxis of this?
#

the game doesnt recognizes the event

meager pulsar
wary edge
#

Yes

prisma shard
#

interactWithBlock still isn't stable

meager pulsar
#

😦

wary edge
meager pulsar
#

mmm d you guys know howto search in the documentation the use of block components? xd

prisma shard
#

you can learn so much about block custom components, by this

neat hound
#

then for block components.. goto world before events

#

then world initialize

#

then subscribe

#

has the stuff there

#

If you click

#

you can get to page to change latest/preview

#

click on everything, lots of examples... but I know they added to the MS learn about the block components with an example and I hear the wiki is updated with some examples too

#

good luck... if you still have trouble people around... the green people really know there stuff.. and that pink person too

wary edge
#

👁️

#

Why does the pink person sound like an insult

prisma shard
#

what

#

i didnt get the joke

#

tf is green person

#

tf is pink person

#

ahhghh

subtle cove
neat hound
#

color blind.. look at the name tags.... when have I ever insulted anyone?

#

I am just glad I am orange... master of all colors... resistance is futile

subtle cove
#

we all pink smh, no one's insulting anyone smh

neat hound
#

I am not pink... by that standard, LOL

subtle cove
#

anyway bao_icon_scripting

neat hound
#

unless you turn me insside out

burnt remnant
#

can someone smart correctly describe what the ternary operator is, cuz reading online what i have gathered its just an if statement with extra steps, but yet putting it inside an if statement changes the outcome even tho itself is an if statement???

granite badger
#

condition ? (value if true) : (value if false)

burnt remnant
#

but then cant you just use ifs and if nots/else?

subtle cove
#

if else is readable

burnt remnant
#

i mean i guess it makes sense?

subtle cove
#
const text = (isOnGround ? '§pGround' : '') + (block?.isSolid ? '§mSolid§r' : '§aair§r');
#
selection ? about(p, cs) : exit(p);
woven loom
# burnt remnant but then cant you just use ifs and if nots/else?

yes but ter. is short for eg, if you want to return a value based on condition
with if else it would be like

if (player.isSneaking)
  return 10
else 
  return 20

whereas tern. looks like this

  return player.isSneaking ? 10 : 20

clearly 2nd is better for smaller stuff otherwise if is more readable

distant tulip
#

the best use case is assigning a value on condition
with if else it will look like

let value = 20
if (player.isSneaking){
  value = 10
}

it can get longer with more conditions
but with ?

  const value = player.isSneaking ? 10 : 20
distant gulch
#

how can i filter online player?

distant tulip
distant gulch
#

oh ty

sage portal
#

do I need to always make a function to get a return variable, or is there a simpler alternative?
I'm trying to get the boolean of whether or not a tryTeleport succeeds or fails.

distant tulip
crude bridge
#

I made a new anticheat

#
If (player.hasHorion()) player.ban()
distant tulip
#

huh

#

is that a prototype or is that a joke

crude bridge
sage portal
distant tulip
#

without the return

#

tryTeleport it self is a function that return a boolean

sage portal
#

oh right, that makes sense

distant gulch
#

What is the maximum score on the scoreboard?

shy leaf
#

2,147,483,647

honest spear
#

what is ds?

woven loom
#

data structure

#

@honest spear

honest spear
#

Well object it self is 0(1)

#

its same as hash table

#

do you mean like dynamic db ds

woven loom
#

keyless ds

neat hound
#

Hey green masters... question. So..js const cb = world...subscribe((event) {stuff})I know I can use cb to cancel the subscription as in js world..unsubscribe(cb)but later, can I js world...subscribe(cb)if that is not the way, do I just put the subscribe in a function to call it again after an unsub?

distant tulip
prisma shard
fallow rivet
#

How do I detect if a player is afk?

prisma shard
distant tulip
prisma shard
distant tulip
#

no 🗿

misty pivot
#

💀

subtle cove
#
const cd = ev1.subscribe(function R() {
    console.warn({R: R === cd}) 
    ev1.unsubscribe(cd)
    const cd2 = ev1.subscribe(cd)
    const cd3 = ev1.subscribe(R)
    console.warn({
        ['cd === cd2']: cd === cd2,
        ['R === cd2']: R === cd2, 
        ['cd3 === cd2']: cd3 === cd2
    }) 
}) ```
granite cape
#

its literal work

glacial widget
shy leaf
#

but any velocity could make it misfire

#

ig making it less tight could work

distant tulip
#

velocity and rotation

untold magnet
#

i think i need help a little bit

#

if (state === 'north') i.block.dimension.runCommandAsync(execute at @e[r=1] run say Hi) is not working

hushed ravine
#

How do I make a game loop using system.runJob()?

#

It seems to be more efficient than system.runInterval(), reason why I want to use it

wheat condor
honest spear
#

ticksif you have more little task then multiple of them are executed in single tick

hushed ravine
#

I just want everything to run as expected each tick

wheat condor
untold magnet
hushed ravine
#

Also, I don't know how to use generator functions properly

untold magnet
wheat condor
#
if (state === 'north') i.block.dimension.runCommandAsync("execute at @e[r=1] run say Hi")
shy leaf
# untold magnet fr?

yeah, otherwise it will try to find the stuff what you wrote if theres no string format

#
const yeet = "say yeet";
player.runCommand(yeet);
#

but this will not work

player.runCommand(say yeet);
untold magnet
shy leaf
#

youd want to specify position too

untold magnet
#

i.dimension.runCommand
or
i.block.dimension.runCommand
?

#

both is the same ig

shy leaf
#

no

wheat condor
shy leaf
#

i mean

#

yeah but not exactly the same maybe

#

i would say use i.block.dimension for safety

untold magnet
shy leaf
untold magnet
#

should i put that command inside of system.run?

shy leaf
#

no unless youre using beforeEvents

untold magnet
#

bec worldInitialize are beforeEvents thing

shy leaf
#

no

#

dont need one for that

untold magnet
#

the command is running when i use @e or c=1
but r=1 or dy=1 isn't working

shy leaf
#

worldInitialize registers the code into the stuff, which later makes the stuff to run the code you did

#

system.run is for events that fires before the event

shy leaf
untold magnet
#

im literally confused

shy leaf
#

show the command

#

or the code

untold magnet
#
onTick: i => {,,,
if (state === 'north') i.block.dimension.runCommandAsync("execute at @e[dy=1] run scriptevent conv:North")
shy leaf
#

whats that ,,,

untold magnet
# shy leaf whats that `,,,`
    onTick: i => {
      const state = i.block.permutation.getState('minecraft:cardinal_direction');
      if (state === 'north') i.block.dimension.runCommandAsync("execute at @e[dy=1] run scriptevent conv:North")
    }
shy leaf
#

oh

untold magnet
#

thats all

shy leaf
#

so what im trying to say here

#

is that i.block.dimension points to the dimension the block is in, not the block itself

#

so you need to make the execute to have positioned

#

also why dont you just run the code directly into there

#

instead of using command

hidden crown
untold magnet
shy leaf
#

you dont know how to use execute command? or specify the location of the block

untold magnet
#

im trying to make the block detect entities above it and make them move by applyImplus, nothing else :/

shy leaf
wheat condor
untold magnet
#

i.dimension.getEntitiesAtBlockLocation?

distant tulip
shy leaf
wheat condor
# shy leaf whar

how can you do the execute? execute at @e[r=1] positioned x y z run???

shy leaf
#

also as instead of at

untold magnet
#

for (const entity of i.dimension.getEntities()) {,,,}?

honest spear
wheat condor
untold magnet
shy leaf
#

im still wondering why you dont run code directly

#

and use scriptevent

untold magnet
#

nah nah nah, that will make each entity run a command every tick

wheat condor
shy leaf
#

you can limit the number of entity i think?

#

in EntityQueryOptions

untold magnet
shy leaf
#

yeah

glacial widget
shy leaf
glacial widget
shy leaf
#

well

#

youre using JavaScripts

untold magnet
plush moss
#

is it possible with player.getComponent("inventory")
also get the data from items?

#

for example splash_potion 1 5

untold magnet
#

the important thing is the entities will be detected when they're above it

wheat condor
untold magnet
#

its quite glitched on the far edges, but no problems bec u gonna put multiple of them in the same place

untold magnet
wheat condor
untold magnet
#

dy isn't really good to deal with

wheat condor
#
const { x, y, z } = i.block.location;
i.block.dimension.runCommandAsync(`execute positioned ${x} ${( y + 0.2 )} ${z} as @e[r=1] run say Hi`)
untold magnet
buoyant canopy
#

what are you trying to do?

subtle cove
#

u gona need the center coord for dat

untold magnet
distant tulip
buoyant canopy
#
block.dimension.getEntities({location: block.center(), maxDistance: 0.5})
wheat condor
buoyant canopy
subtle cove
#
const {x,y,z} = block.center()
distant tulip
#

bottomCenter maybe better in his case

subtle cove
#

then y + 0.8

untold magnet
wheat condor
buoyant canopy
untold magnet
#

is there any way to make that detect more for X and Z but less for Y?

wheat condor
buoyant canopy
#

a radius of 1 is a sphere that's 2 blocks wide

untold magnet
wheat condor
buoyant canopy
buoyant canopy
#

you can add a y level condition if the height is the only problem

wheat condor
buoyant canopy
#
if (block.y != Math.floor(entity.location.y)) continue
untold magnet
#

my brain hurts

#

u know what, i give up

    onTick: i => {
      const state = i.block.permutation.getState('minecraft:cardinal_direction');
    }
#

im not great at all on Math thing

buoyant canopy
#

it detects the player standing above it because the player center is the center of its feet, so it's inside the sphere that is 2 blocks wide

untold magnet
# wheat condor send the code
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry: block }) => {
  block.registerCustomComponent('exe:conveyor', {
    onTick: i => {
      const state = i.block.permutation.getState('minecraft:cardinal_direction');
    }
  })
})
misty pivot
#

how would i call a function that has the value of a variable? for example

const functionName = myFunctionName;
//run function named after the value of functionName```
wheat condor
# untold magnet ```js world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry: bl...
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry: block }) => {
    block.registerCustomComponent('exe:conveyor', {
        onTick: i => {
            const state = i.block.permutation.getState('minecraft:cardinal_direction');
            const block = i.block
            for (const entity of block.dimension.getEntities({ location: block.center(), maxDistance: 1 })) {
                const eLoc = entity.location
                const bLoc = block.center()
                if (eLoc.x.toFixed(0) == bLoc.x.toFixed(0) &&
                    eLoc.y.toFixed(0) == bLoc.y.toFixed(0) &&
                    eLoc.y.toFixed(1) <= bLoc.y.toFixed(1) &&
                    eLoc.z.toFixed(0) == bLoc.z.toFixed(0)) {
                    world.sendMessage(`hi`)
                }
            }
        }
    })
})

try that should work @untold magnet

misty pivot
wheat condor
wheat condor
untold magnet
wheat condor
# untold magnet umm
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry: block }) => {
    block.registerCustomComponent('exe:conveyor', {
        onTick: i => {
            const state = i.block.permutation.getState('minecraft:cardinal_direction');
            const block = i.block
            for (const entity of block.dimension.getEntities({ maxDistance: 1 })) {
                const eLoc = entity.location
                const bLoc = block.center()
                if (eLoc.x.toFixed(0) == bLoc.x.toFixed(0) &&
                    eLoc.y.toFixed(0) == bLoc.y.toFixed(0) &&
                    eLoc.z.toFixed(0) == bLoc.z.toFixed(0)) {
                    world.sendMessage(`hi`)
                }
            }
        }
    })
})

try that

#

i deleted the half block detection

fallow rivet
#

How to test a player's game mode

wheat condor
fallow rivet
wheat condor
wheat condor
#

?

untold magnet
wheat condor
# untold magnet no logs
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry: block }) => {
    block.registerCustomComponent('exe:conveyor', {
        onTick: i => {
            const state = i.block.permutation.getState('minecraft:cardinal_direction');
            const block = i.block
            for (const entity of block.dimension.getEntities({ maxDistance: 1 })) {
                const eLoc = entity.location
                const bLoc = block.center()
                if (Math.floor.(eLoc.x) == Math.floor.(bLoc.x) &&
                    Math.floor.(eLoc.y) == Math.floor.(bLoc.y) &&
                    Math.floor.(eLoc.z) == Math.floor.(bLoc.z)) {
                    world.sendMessage(`hi`)
                }
            }
        }
    })
})

tell me the values that shows in chat when you are standing on the block

untold magnet
#

absolute nothing, u know what i can use that maxDistance: 1 bec the entity will keep falling into the block but it will move a little bit farther from the block

wheat condor
untold magnet
wheat condor
untold magnet
wheat condor
untold magnet
#

its fine if the script detects the entity a little bit higher

untold magnet
#

is the wrong thing

past blaze
#

What's going on here?

wheat condor
untold magnet
wheat condor
#
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry: block }) => {
    block.registerCustomComponent('exe:conveyor', {
        onTick: i => {
            const state = i.block.permutation.getState('minecraft:cardinal_direction');
            const block = i.block
            for (const entity of block.dimension.getEntities({ location: block.center(), maxDistance: 1 })) {
                const eLoc = entity.location
                const bLoc = block.center()
                if (Math.floor(eLoc.x) == Math.floor(bLoc.x) &&
                    Math.floor(eLoc.y) == Math.floor(bLoc.y) &&
                    Math.floor(eLoc.z) == Math.floor(bLoc.z)) {
                    world.sendMessage(`entity detected`)
                } else {
                    world.sendMessage(`no entities detected`)
                }
            }
        }
    })
})
wheat condor
misty pivot
#

is it possible to stop a script? like terminate it forcefully?

untold magnet
wheat condor
untold magnet
wheat condor
untold magnet
#

far edges are those;

  • X / + Z
  • X / + Z
  • X / - Z
  • X / - Z
amber granite
#

How queer

untold magnet
untold magnet
misty pivot
amber granite
#

If statements

#

And
/Scriptevent

#

Command

#

Just fold it with if statement

#

With outer variable

#

Global one i mean

wheat condor
#
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry: block }) => {
    block.registerCustomComponent('exe:conveyor', {
        onTick: i => {
            const state = i.block.permutation.getState('minecraft:cardinal_direction');
            const block = i.block
            for (const entity of block.dimension.getEntities({ location: block.center(), maxDistance: 1 })) {
                const eLoc = entity.location
                const bLoc = block.center()
                if (Math.round(eLoc.x) == Math.floor(bLoc.x) &&
                    Math.round(eLoc.y) == Math.floor(bLoc.y) &&
                    Math.round(eLoc.z) == Math.floor(bLoc.z)) {
                    world.sendMessage(`entity detected`)
                } else {
                    world.sendMessage(`no entities detected`)
                }
            }
        }
    })
})

@untold magnet try that:

amber granite
#

Like this

let brutalForceOff = false;
if ( !brutalForceOff ) {
//Put ur code in here
}
misty pivot
#

oh

#

alright thanks, but would that also mean i have to do it for every after and before events?

wheat condor
# untold magnet
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry: block }) => {
    block.registerCustomComponent('exe:conveyor', {
        onTick: i => {
            const state = i.block.permutation.getState('minecraft:cardinal_direction');
            const block = i.block;
            const detectionOffset = 0.5
            const bLoc = block.center()

            for (const entity of block.dimension.getEntities({ location: bLoc, maxDistance: 2 })) {
                const eLoc = entity.location;

                if (eLoc.x >= bLoc.x - detectionOffset && eLoc.x <= bLoc.x + detectionOffset &&
                    eLoc.y >= bLoc.y - detectionOffset && eLoc.y <= bLoc.y + detectionOffset &&
                    eLoc.z >= bLoc.z - detectionOffset && eLoc.z <= bLoc.z + detectionOffset) {
                    world.sendMessage(`entity detected`);
                } else {
                    world.sendMessage(`no entities detected`);
                }
            }
        }
    })
})

try that, im not that good at math either

wheat condor
#

try adding 1 to detection distance

untold magnet
wheat condor
#

const detectionOffset = 2

untold magnet
#

with 1 distance offset it works the same as that old one

#

it detects me from 1 block high

amber granite
#

U can use
scriptEvents event

wheat condor
# untold magnet with 1 distance offset it works the same as that old one
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry: block }) => {
    block.registerCustomComponent('exe:conveyor', {
        onTick: i => {
            const state = i.block.permutation.getState('minecraft:cardinal_direction');
            const block = i.block;
            const detectionOffset = 1.5
            const bLoc = block.center()

            for (const entity of block.dimension.getEntities({ location: bLoc, maxDistance: 2 })) {
                const eLoc = entity.location;

                if (eLoc.x >= bLoc.x - detectionOffset && eLoc.x <= bLoc.x + detectionOffset &&
                    eLoc.y >= bLoc.y && eLoc.y <= bLoc.y &&
                    eLoc.z >= bLoc.z - detectionOffset && eLoc.z <= bLoc.z + detectionOffset) {
                    world.sendMessage(`entity detected`);
                } else {
                    world.sendMessage(`no entities detected`);
                }
            }
        }
    })
})
amber granite
#

Or use chatSend event

wheat condor
#

try that

woven loom
#

can custom block detect redstone stuff ?@untold magnet

untold magnet
woven loom
#

what we have

wary edge
#

redstone conductivity component

wheat condor
subtle cove
#

use volume ok

untold magnet
#

take a rest from thinking

wheat condor
untold magnet
#

its just detecting the entity like 0.7p higher than the normal 0.3p block

#

the block collision box is 4, normal block is 16 so the script will detect 8px above the block

#

which is wrong but its not a huge issue

wheat condor
untold magnet
wheat condor
shut citrus
#

i still alive

#

until drone hits

woven loom
neat hound
#

Question to the vector aficionados v3 -> v2 is ?```js

/**

  • @param { import("@minecraft/server").Vector3} vector3
  • @returns { import("@minecraft/server").Vector2}
    */
    static toVector2 (vector3) {
    return {
    x: vector3.x,
    y: vector3.z // <-----
    };
    }```
#

z ----> y

neat hound
wary edge
neat hound
#

Ah man.... 2 of them...

#

which is... e/w and n/s

wary edge
#

All Vector Interfaces

wide willow
#

am i using this wrong or is it broken?

player.camera.fade({red:1, green:0, blue:0, fadeInTime:0, holdTime:10, fadeOutTime:7})```
it just goes black everytime & does its own fade time.
wheat condor
#
console.warn(`Yaw ${yawDegrees}`);
console.warn(`Pitch ${pitchDegrees}`);
player.setRotation({ y: yawDegrees, x: pitchDegrees })

whats wrong? my player wont rotate

tiny fable
#

It's telling me 1 isnt in the range of [ 0 - 5 ]

Unhandled promise rejection: EnchantmentLevelOutOfBoundsError: When trying to add enchantment instance - Tyring to set enchantment level to 1, range for type smite is [0 - 5].

I think enough context here

glacial widget
#

could someone tell me why this dont work

case "minecraft:ender_chest":
    
            if(!player.hasTag(`rookie`) || player.hasTag(`soldier`) || player.hasTag(`elite`) || player.hasTag(`general`) || player.hasTag(`overlord`) || player.hasTag(`king`) ||  player.hasTag(`emeperor`) || player.hasTag(`dragon`) || player.hasTag(`eld-dragon`) || player.hasTag(`demi-god`) || player.hasTag(`god`) || player.addTag(`eld-god`)){
                r.cancel = true
                player.sendMessage(`HCV KitPvP >> You need to be rookie rank or higher to use this`)
            }
        break;

even when i have 1 of the tags listed

tiny fable
#

is rookie rank included in this function?
cuz !player.hasTag('rookie') and You need to be rookie rank or higher seems to conflict

#

or my english is broken and i should fix it

wary edge
tiny fable
glacial widget
wary edge
#

Thats your issue

tiny fable
#

oh, I'm dumb

#

sorry

viral plaza
# glacial widget could someone tell me why this dont work ```js case "minecraft:ender_chest": ...

Try this ```js
case "minecraft:ender_chest":
if (
!(
player.hasTag("rookie") ||
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.addTag("eld-god")
)
) {
r.cancel = true;
player.sendMessage(HCV KitPvP >> You need to be rookie rank or higher to use this);
}
break;

glacial widget
#

how comes

viral plaza
#

Is it a rank requirement?

#

Oh yea

tiny fable
glacial widget
viral plaza
#
const list = {
  "member": 1,
  "rookie": 2,
  "knight": 3
};

const rank = "member";
const weight = list[rank];

if (list["knight"] - weight > 0) {
  // can rank up
 
} else {
  // can't rank up
 
}

#

I would do a system like this

#

Or some

glacial widget
#

thank you

tiny fable
#

np :)

tiny fable
viral plaza
#

So much simpler lol

#

One if statement clears all that

glacial widget
#

i have a simply system where i just use the Objs and check if the players are >= to tem

#

them*

viral plaza
#

We’ll really it’s just a shrunken one

glacial widget
viral plaza
glacial widget
#

easy to debug later on

viral plaza
#

Plus, if you can make a system that adapts to your changes, then debugging is so much easier and it’s such a better system

#

Like a shop that gets its items from an object

glacial widget
#

yeah your right

tiny fable
#

and you'll ended up with a flexible and easy-to-change system :)

glacial widget
#

i should have just put all the tags into a array and did .some()

viral plaza
#

I mean you can

viral plaza
#

I think it’s flipped tho

granite cape
remote oyster
#

You should do that if it needs updating anyways.

fallow rivet
#

How do I give a player a wither skeleton head?

twilit tartan
#

Some know if playerInteractWithEntity is stable?

fallow rivet
valid ice
fallow rivet
#

But for this I need to change the whole code

#

I used Dynamicproperty

valid ice
fallow rivet
#

Can I add a head?

#

Custom

glacial widget
#

lol

glacial widget
distant tulip
valid ice
#

Commands are stinky

distant tulip
#

don't let them hear you

wide willow
#

anyone have an example of how to use camerFadeOptions?

player.camera.fade({red:1, green:0, blue:0, fadeInTime:0, holdTime:10, fadeOutTime:7})```
this just goes black everytime & does its own fade time. idk if im using it wrong.
distant tulip
#

@granite badger
please add a sidebar for the versions so we don't have to scroll all the way down every time

wide willow
#

bro yes, thank you Minato

untold magnet
neat hound
neat hound
#

I've never seen that page before, I go directly to the page you ended up on. Edit your link.

distant tulip
#

i use multiple versions

neat hound
#

Then a folder with links to the places you go often

#

Your own pre-organization

distant tulip
#

yeah good idea

#

tnx

meager pulsar
#
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
    blockComponentRegistry.registerCustomComponent("mh:pedestal_interact", {
        onInteract: (({ player, block, dimension }) => {
            pEquipment = player.getComponent('equippable')
            itemStack = pEquipment.getEquipment(server.EquipmentSlot.Mainhand)

            const entity = dimension.getEntities({ closest: 1, location: block.location, maxDistance: 1.5, families: [`pedestal_hold`] })[0]
            if (entity) {
                if (itemStack) {
                    giveItemToPillar(player, entity)
                } else {
                    takeItemFromPillar(player, entity)
                }
            }

        })
    })

});
#

what did i do wrong?

deep quiver
# distant tulip

you should use the typings tbh they are good enough that there is no reason to use the docs

distant tulip
meager pulsar
deep quiver
deep quiver
keen gull
#

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

world.beforeEvents.chatSend.subscribe((data) => {
const player = data.sender;
const message = data.message;

if (message.toLowerCase().includes("woy")) {
    player.runCommandAsync('tag @s add woy_tagged');
    player.sendMessage("You have been tagged with 'woy_tagged'!");
}

});

Compiler found 1 errors:

ha1.js:3:20 - error TS2339: Property 'chat' does not exist on type 'WorldBeforeEvents'.

3 world.beforeEvents.chat.subscribe((data) => {
                     ~~~~

#

With what should i replace chatsend for it to work

#

It should give me tag when i send massage in chat

lament tree
#

Does anyone know if something changed in OnPlace custom component?
I had a block that altered other blocks in chain using OnPlace, but it seems that the blocks that are placed by the script do not seem to work with OnPlace in the latest version

lament tree
true isle
#

theyve changed how its registered

#

itemtype and blocktype as far as i know

#

like itemcomponent and blockcomponent

#

just change it to register as world.beforeEvents.worldInitialize.subscribe(initEvent => {
initEvent.blockComponentRegistry.registerCustomComponent('namespace:custom_component', {

lament tree
#

Oh, I already did that, the only problem I have is with OnPlace, which as I said, doesn't seem to work with blocks placed by scripts?

#

It's weird

true isle
#

is it a stair script?

lament tree
#

No, it's a pointed dripstone

#

and another that I can't describe so well

true isle
#

did u update the version?

lament tree
#

The idea is that when you place it, it changes to the pointed dripstone above it, and when its place it, it would also have an OnPlace event that would change the one above it again, and so on.

In the previous version, in 1.21.10, it worked perfectly, but now it doesn't work at all, for some reason if the block is placed by a script, using block.above().setPermutation(block.above().permutation.withState('state:lol', 'value lol')) (or something like that), the OnPlace does not seems to work

true isle
#

let me see if mine works

lament tree
#

If I place it by commands, it works fine

true isle
#

yeah mine is with commands

#

its because its split now

#

instead of the registery being a set one its now item and block

#

the next update will probably fix that

lament tree
#

damn
I guess I'll have to wait

true isle
#

i mean my stairs work but idk if thatl help with your dripstone

#

stairs are just on place with no comands

lament tree
#

The stalactite works well if it is placed by the player, but when it comes to changing the other blocks it is already ruined for the same reason I said, so I highly doubt there is a solution there.

#

Only change the first block, since the block placed was by the player, but the other block does not change the others when placed by the script

true isle
#

are they both in a seperate script?

rose light
#

Does anyone know how to fix this error?

#
 const blockview = player.getBlockFromViewDirection().block
true isle
#

;?

lament tree
true isle
#

why not just copy paste as a seperate name in the same script and change it for whatever the dripstone needs

lament tree
#

I'm going to do it, only when I did it I was a little lazy lol

true isle
#

lmao im just as lazy. i prefer hands on learning rather than looking at a boring 30min video

remote oyster
lament tree
#

Yeah, they still work the same, so I just have to use a block.typeId and that's it xD

true isle
#

see. never know till you try

rose light
#

How should I check if it is valid or not? I already set it to return undefined in case it does, but it didn't work.

true isle
#

dont feel bad im still stuck on basic scripting lol but since the update im also having issues getting things to work and im too lazy to read which makes it harder i guess lol

lament tree
# true isle see. never know till you try

Likewise, I'm going to have to wait for the previous problem to be fixed, because a current solution, I honestly can't find it, I was creating a recreation of the redstone, and I'm practically going to have to delay it because of that (unless I use OnTick 💀 )

rose light
true isle
#

every time i learn something it changes

lament tree
#

And when you ask, they send you to the documentation which doesn't say much lol

true isle
#

and im just trying to get a perm change with using an item lmao

#

i feel like im 5 again

remote oyster
lament tree
rose light
remote oyster
# rose light and what about this error?

You are attempting to access a location that is in an unloaded area. Meaning that there is no active player in that location for that chunk to be loaded in the world, therefore making it unreachable.

rose light
#

ok

chrome flint
#

squenkwark

inland merlin
#

Squidweenie

true isle
#

is it not possible to change textures with a permutation?

neat hound
worn palm
#

is there any way to get broken block location?

worn palm
#

i want to implement this inside custom component

sterile pelican
#

Hi excuse, I'm trying to replicate the same task of hammer 3x3 well in this case 3x1 HAHAHA, but I have a issue

#

If I break the block in this direction is working fine

#

but If I change the direction is working weird haha

#

I know that I need to adapt the direction of the player to the block is looking for but I don't have any idea

subtle cove
#

3x3x3

sterile pelican
#

that's the solution 🤔 ?

#

Let me try it xd

subtle cove
#

well it looks like that's only 3x3

sterile pelican
#

in every direction

subtle cove
#

oh

neat hound
#

on interact with block the face tells you alot, player facing, is not always right as they can kinda stand at an angle

sterile pelican
#

so in this case I need to adapt this to the player's view direction?

neat hound
#

They hit a block, that block has a face... use that

subtle cove
#

the blockfacelocation and the head's location

sterile pelican
#

oh okay

valid ice
#

Just rotation- face location would be used for interact (not really for break, unless you feel like it)

sterile pelican
#

rn I got lost HAHAH

#

Sorry I'm new xd

subtle cove
#

id just make explosion on le bloc

neat hound
#

what are you using now for the one direction that works

#

and maybe make a post so all the help in one place with no interuptions

neat hound
#

ok guys, he made the post, if you can go help him in there... I gotta move my car back into garage and I am so sore from cleaning garage all day, that I may not make it back to the computer....

true isle
#

so got my script stable and block set up but i still cant change the permutation with the script -_-

strong oar
#

Guys is it possible to make the have this kind of particle?

mystic mortar
sleek nexus
#

A very light maybe

unique dragon
#

that's a problem with the module?

#

uh, wait

obsidian coyote
tender ocean
#

is there a way to make an entity be killed and still drop it's items with scripting with native? applyDamage and kill seem to not do it

unique dragon
tender ocean
#

pig drops porkchop for example

#

on default it doesnt do that

obsidian coyote
tender ocean
#

with script api

shy leaf
#

isnt that a loot table thing in json?

tender ocean
#

well yeah but do i just spawn in the loottable?

shy leaf
#

uh

#

you define the loot table inside the json of the entity

#

and itll drop items

tender ocean
#

yes

#

but with scripts it doesnt

#

like im trying to kill a pig it doesnt drop items

unique dragon
#

im gonna check that

shy leaf
#

it did for me

tender ocean
#

okay

#

i had this?

#

randomy entity is just one between these

#

in a radius

#

that does not drop anything

shy leaf
#

can you put random items around and see if it doesnt disappear

tender ocean
#

they do not

shy leaf
tender ocean
#

what did you have that worked for you?

shy leaf
#

well it was a debug stick that required the player to hit the entity to instakill em

#

ig that makes it different

tender ocean
#

hm

#

wait let me test something

#

nope

#

thought i'd hit it first before it gets killed

#

maybe it dropped the loot but no

#

what did you use to kill it?

shy leaf
#

maybe try defining damagingEntity to yourself

shy leaf
tender ocean
#

there is no player its just the block and the random entity

shy leaf
#

you could still do world.getAllPlayers()

tender ocean
#

well yeah

#

ill try it but i cant keep it

#

doesnt do it

shy leaf
#

rip

tender ocean
tender ocean
shy leaf
#

yeah

#

both kill and override damage

tender ocean
#

override damage?

shy leaf
#

applyDamage with override damage cause

tender ocean
#

ah ok

#

how come

shy leaf
#

for no reason lol

#

i honestly dont know

tender ocean
#

lmao

#

kill doesnt do either

#

idk its odd

tender ocean
shy leaf
#

try making an item that kills an entity on right click

#

and see if the item drops

tender ocean
#

doesnt

#
world.afterEvents.playerInteractWithEntity.subscribe(({itemStack, player, target}) => {
    if (itemStack.typeId !== 'minecraft:stick') return
    target.kill()
})```
tender ocean
#

!==

shy leaf
#

oh wait

#

nvm

#

im blind

tender ocean
#

lol

unique dragon
# tender ocean hows that going?
system.runInterval(() => {
    const dim = world.getDimension('overworld');
    for (const entity of dim.getEntities({ excludeTypes: [ "minecraft:player", "minecraft:item" ] })) {
        entity.kill();
    }
});

idk what are you doing

tender ocean
#

bruh

#

ok wait

shy leaf
#

maybe you turned item drop gamerule off?

unique dragon
#

yeah

#

maybe

tender ocean
#

doEntityDrop?

unique dragon
#

yes

shy leaf
#

probably that

tender ocean
#

neither

#

💀

shy leaf
tender ocean
#

i dont even have extra packs

shy leaf
#

new world time

tender ocean
#

domoobloot

#

yes

#

bruh

#

got it works

shy leaf
tender ocean
unique dragon
#

lol

amber granite
#

Hillo

woven loom
#

hi

viral plaza
#

any good way of making expandable boundary’s with scripts?

woven loom
#

what is that @viral plaza

subtle cove
#

expanding a bounding box...

distant gulch
#

Is there any expedient to cancel entityhit?

shy leaf
#

sorry

distant gulch
shy leaf
prisma shard
# rose light and what about this error?

I also got this error, when doing getBlockFromViewDirection(). This error actually happens when you look at the air, and it can't get the block. So to fix it, you have to do a try{} catch{}

prisma shard
wary edge
#

You can just grab the block, if block is undefined return

#

Try Catch should be used if you plan to do something with the error

prisma shard
prisma shard
sleek nexus
fiery solar
# unique dragon very long msg

So @minecraft/server-ui has a listed dependency on a particular version of @minecraft/server. Since typescript is smart it's trying to tell you "hey, just so you know there's some differences between the Player class that you're passing in and the Player class that existed in the version of @minecraft/server that server-ui is expecting.

Since server-ui doesn't actually call any methods on Player you don't need to care about those differences and you can add this to your package.json and then do another npm install:

  "overrides": {
    "@minecraft/server": "$@minecraft/server"
  }

Which tells node "all packages that rely on a version of @minecraft/server should use the version I have specified in package.json

granite badger
#

try { throw “err” } catch(err) { throw err }

sleek nexus
#

That's how the error feels after thinking it was safely caught

sleek nexus
fiery solar
remote oyster
#

That should be put on a T-shirt 🤪

versed sage
#

does anyone know what the type id for snow is

#

ive tried minecraft:snow and just snow but neither work

unique dragon
#

snow_layer maybe

neat hound
#

can look in the blocks.json file for the samples on the github... or the npm for vanilla-data in the lib folder -> index.js ( tho need to quick format the file first)

hasty citrus
#

Can anyone make me a script that can detect when my custom block is moved by a piston and then execute a command that summon a tnt right below my block (like the tnt glitch in java (with flying machines))

#

Or atleast guide a little

#

And tell me whats wrong with this script: `import { world, BlockType, MinecraftBlockTypes } from "@minecraft/server";

// Function to monitor piston pushing the custom block
world.events.blockPistonPush.subscribe((event) => {
const block = event.block;

// Check if the pushed block is the custom TNT block
if (block.type.id === "mc:tnt") {
    // Get the position of the block below the current block
    const belowPosition = { x: block.x, y: block.y - 1, z: block.z };
    
    // Set the block below to a Minecraft TNT block
    const belowBlock = world.getDimension("overworld").getBlock(belowPosition);
    belowBlock.setType(MinecraftBlockTypes.tnt);
}

});
`

solar dagger
#

I need help with yaw rotation of an entity with custom pathing. This should rotate based on a circle path/position in the circle

  const radius = 40;
  const step = (2 * Math.PI) / 360;
  let i = 0;
  const rotateEntity = (i: number) => {
    const yTheta = center.z + radius * Math.sin((Math.PI / 60) * i);
    return yTheta;
  };```
versed sage
unique dragon
wheat condor
solar dagger
wheat condor
wheat condor
solar dagger
wheat condor
wide willow
#

im trying to use setRotation too, im tryna turn around a player. but i cant get it to work, has no errors.

            let rot = player.getRotation()
            player.setRotation({x: rot.x - 180, y: 90})```
wheat condor
wide willow
#

aawww hahah ok so .teleport is next to try

chilly moth
#

is it possible like make a block interactable and after interact it transforms but is not interactable anymore?

wary edge
shrewd wedge
#

How do I make apply knock back pull towards someone who use a sword

#

I try it now, and it just makes them go upwards like bunnyhopp

chilly moth
#

ok

honest spear
#

@umbral sun Not sure what do you mean API handling it automaticly, bc you still need to do it on your own and thats slow

#

its just a difference between 32k string and 2,147,483,647 bytes long array

#

its 2T its theory

#

also you can save some values by bits so its memory efficient as well

shrewd wedge
#

Pls help

#

How do I make knock back work

honest spear
#

Ohh

#

lmao

#

sorry silicate

honest spear
#

and seconds are horizontal strength and vertical

#

if you combine well then you have what you need

shrewd wedge
#

Oh ok, sorry it obvious now

#

I'm still learning English so it hard sorry,,

honest spear
#

Np its not just the English tho, Coding is kinda hard topic as its a new thing, and you can't really compare programming to something different

shrewd wedge
#

Yes

winter plaza
#

How do you execute a command when consuming an item?

#

mine 1.21.20

drifting ravenBOT
knotty plaza
sterile pelican
#

Hi, excuse I only have 1 question
I'm creating a custom pickaxe but I need to specify every block with the speed that will be break?
for example, stone, speed: 20, diamond_ore, speed 15, etc?
there's not a simple way?

knotty plaza
sterile pelican
knotty plaza
#

For example, all of the dirt blocks (dirt, grass, grass path, etc) have the grass tag

sterile pelican
#

oh okay, do u know where I can find the tags?

#

{
"speed": 12,
//Block will be breakable with this item
"block": {
"tags": "query.any_tag('stone')"
}
},

knotty plaza
#

Example:```json
{
"block": {
"tags": "(query.any_tag('stone','metal', 'cobblestone', 'bricks', 'iron_pick_diggable'))"
},
"speed": 10
}

sterile pelican
#

cause for stone, I use

#

oh okay

neat hound
knotty plaza
sterile pelican
#

Oh thank you so much

#

I appreciate it

#

this just a general question but

#

what's better Microsoft Learn or Bedrock Dev for documentation?

wary edge
#

Both should be used. Bedrock.dev for quick lookup, ms docs for in depth explanation. And then the wiki has tutorials

shrewd wedge
#

How to make item go down by one when use?

ionic kayak
#

Can't get worldInitialize to work. What are the common issues?

ionic kayak
#

Not at all

ionic kayak
neat hound
shrewd wedge
#

Yes on the on use thing

#

I would use run command but it might cause issue

#

I mean how to decrement item stack by 1 like how the event used to do

distant tulip
shrewd wedge
#

Thank you

knotty plaza
ionic kayak
knotty plaza
ionic kayak
#

not funny could be the manifest

knotty plaza
#

Why would the manifest be the problem if you are specificly talking about the worldInitialize event?

ionic kayak
#

You tell me 😭. Anyways, I dont really have a code I just tried a bunch of things and none of them worked

knotty plaza
#

But, how are you listening to the event?

#

At least that part of the code

ionic kayak
#

Im lost

distant tulip
knotty plaza
#

Not the entire code, just that one line

#

For example```js
world.afterEvents.worldInitialize.subscribe(() => {});

#

Is that what you are doing?

distant tulip
#

that was a joke lol
he said no error

knotty plaza
#

Maybe he is trying to send a message or a form in worldInitialize not realizing it fires before the loading screen is gone

distant tulip
#

@ionic kayak
put
console.warn("this world have this script enabled")
in the root of your script
and another one inside worldInitialize
before any if condition

#

and reload

keen gull
#

I was using 1.13.0 changed it to 1.14.0-beta and it worked

distant tulip
#

your behavior pack is not unable if so

ionic kayak
#

The rest of the script works fine

#

But not this part

knotty plaza