#Script API General

1 messages · Page 7 of 1

nimble schooner
#

Ty

thorn flicker
#

does anyone have an issue with custom components making the block interactable even without onPlayerInteract?

open urchin
thorn flicker
#

thanks.

nimble schooner
#

How to store all metadata of an itemStack? Even if its a book and quil?

shy leaf
#

its already out in planetminecraft

distant tulip
shy leaf
#

ehhhh im not sure if i can post it here

#

just search dungeons combat

wary edge
open urchin
#

if a block has the custom components component it becomes interactable
they made it so that the interaction resulted in the held block being placed if the custom component doesn't include the onPlayerInteract listener but it doesn't work perfectly

#

but there's no way to actually stop it from being interactable

distant tulip
wary edge
amber granite
open urchin
#

no, it's not fixed

wary edge
open urchin
#

no

wary edge
#

What do you mean no?

amber granite
#

Then use playerInteractWithBlock event

open urchin
#

i hate typing on phone I can explain tomorrow

nimble schooner
#

Getting it as a string

drifting pollenBOT
open urchin
#

which versio. do they say they resolved it in

wary edge
distant tulip
open urchin
#

that change does not resolve your bug report
they just added a janky block placement system when the block is interacted with

wary edge
north rapids
#

Is there an event that detects durability damage?

unique dragon
#

anyone know about bedrock protocols? like: minecraft://?, i want to open the servers tab using web :c
#off-topic

nimble schooner
distant tulip
wary edge
north rapids
#

When attacking with a tool, even without an event to consume durability, it loses 2 durability points. I want to stop this, I already tried using entityHitEntity to detect the attack and add durability again, but when the attack does not cause damage, it still consumes durability...

#

I need to find a solution for this

north rapids
#

Yep

wary edge
distant tulip
#

remove the durability component?

wary edge
north rapids
wary edge
#

Use the onBeforeDurabilityDamage custom component @north rapids

distant tulip
#

ah

north rapids
north rapids
#

Is it possible to cancel the event with event.cancel?

north rapids
#

Ok tks ya

pale terrace
#

is there an event when an entity touch a block? I cant find one

wary edge
pale terrace
#

By the way, how do you manage to be in several places almost at the same time? you literally just wrote in minecraft feedbacks

amber granite
median stream
#

How do you detect if the held itemStack has enchantments?

pale terrace
shy leaf
#

how do i replace spawn event in summon command with scripts

#

do i just use triggerEvent

wary edge
#

Yeah

shy leaf
#

nice ty

#

also what is better to use overall

small depot
shy leaf
shy leaf
small depot
#

then spawning the entity

shy leaf
#

ah so first one is faster overall

small depot
#

and the first one already has the dimension

shy leaf
#

nice ty

small depot
shy leaf
#

well ig first one is more clean

amber granite
#

Yeah use the first

#

But it gives u the same result

wary edge
shy leaf
#

got it

wary edge
#

Which is redundant

#

Too many api calls if it matters

shy leaf
#

now this is weird

#

spawnEntity that has triggerEvent doesnt seem like its working

#

to be more specific, the entity spawns when the player uses the item, which goes boom and give effect to nearby enemies
and the event should make the player to be unaffected

shy leaf
#

turns out the entity json is more complicated than i thought

#

god

#

oh christ i found it nevermind

runic crypt
#

guys

#

can i send a file here i need some help

#

can anyone tell/make it so that

#

the select a player is a drop-down menu

#

and the select amount is a slider ?

#

with increment of $1000 per level ?

prisma shard
#

I am back

#

i was disappeared almost for a month

shy leaf
runic crypt
shy leaf
#

there is one that explains dropdown menu

neat hound
neat hound
#

I stil gotta see that....

tiny tartan
neat hound
#

He is fine. We wiped his memory. He will not remember being caged with 2 creepers in a deep dark cave. We gathered good data and will proceed to abduct the next "volunteer"

random flint
#

I had a weird dream where I was in a dark room with two green roommates.

valid ice
#

Average college experience

valid ice
#

@cinder shadow sorry for ping but I vaguely recall you saying something about getBlockFromViewDirection/getBlockFromRay stopping when it reaches any block even if it's an excludedType? Can't find anything on this, tho

cinder shadow
#

Just that if you include water, it will still require a solid block at the end to hit or it won't work @valid ice

random flint
#

BlockRaycastOptions.includeLiquidBlocks (?)

distant gulch
#

Hello

#

Is it possible to control fall damage intensity, fall speed and jump height with a score using scripts?

amber granite
#

Does someone knows how can i make customized structure using script api ?

acoustic basin
#

guys, how do i use LocationOutOfWorldBoundariesError to cancel the error which appears all the time

woven loom
#

that's an error, you aren't supposed to "use" it

acoustic basin
#

but like with watchdog how i can cancel it, maybe i can cancel this one too?

remote oyster
acoustic basin
#

so how can i try and mitigate/prevent it?

remote oyster
#

By first determining the cause and effect.

prisma shard
#

help

woven loom
prisma shard
#

i could just use the substract function from vector.js

#

I am using custom class vector

woven loom
#

sorry I missed the main thing

prisma shard
#

oh lol

#

Now i understand, i have to use math.hypot

#

thanks

pallid portal
#

Just to see if I understand this right.

A script is there to basically give a set of instructions (like an event in this case for a block). And it is supposed to make things easier for addons to use. (namely have multiple blocks use the same script)

What I got so far is, while using an example of stripping logs of a certain wood type.
The log would refer to the script for an event where Wood X log becomes Wood X stripped log.

But now, what if I want to do the same thing with a different wood type?

Would I be able to use the same script, or should I now make a separate script for Wood Y?

If I use the former, I end up with Wood Y log becoming Wood X stripped log.
And if I use the latter, I end up with a script for for each and every wood type....

Where did Mojang supposedly claim that this would make writing addons easier when they removed Holiday Creator features that had these events part of each json file!!?

distant tulip
#

send what you got currently

pallid portal
amber granite
#

Use the tchebychev distance

#

max(|x1 - x2| , |y1 - y2|)

distant tulip
pallid portal
#

ah, ok.

#

Thank you, Minato! ❤️

distant tulip
#

ur wlc

glacial widget
#
world.afterEvents.playerBreakBlock.subscribe((e) => {
    const { player, block, itemStackBeforeBreak } = e;
    const blocklocation = world.getDimension("overworld").getBlock({ x: 24, y: 87, z: 74 });

    let ckey = world.scoreboard.getObjective("commonkey");

    if (block.typeId == "minecraft:iron_ore" && blocklocation) {
        world.sendMessage(`§d§lHCV KitPvP >> §a${player.name} has found a Common key while mining iron`);
        ckey.addScore(player, ckey);
    }
});
#

how do i define addScore

woven loom
#

whats the issue in this

glacial widget
#

for some reason its not defined

distant tulip
#

ckey is the one not defined

#

"can't get function addScore of undefined" or something like this?

glacial widget
shy leaf
glacial widget
#

wait

#

i dont think so

distant tulip
#

do

const ckey = world.scoreboard.getObjective("commonkey")?? world.scoreboard.addObjective("id:commonkey","commonkey")
glacial widget
#

i fixed it, thank you somuch

glacial widget
distant tulip
#

you still need addObjective

glacial widget
amber granite
#

Is playerPlaceBlock before events exist or not ?

tiny tartan
#

yup it does

amber granite
#

I didn't find ir

#

It

amber granite
#

Beta

#

Is there something i can do about that ?

true isle
glacial widget
distant tulip
amber granite
#

beforeEvents

glacial widget
#

its probably his npm files

amber granite
glacial widget
distant tulip
glacial widget
distant tulip
#

placing blocks count as item use

#

but you can't cancel the placing with it

amber granite
amber granite
#

I ll use afterEvents

#

Then turn the player's block to air

neat hound
# pallid portal Just to see if I understand this right. A script is there to basically give a s...

From reading this, I gather you are not a programmer, correct? There is no way a programmer would make the statement you made. It is understandable that you see it this way. But I assure you, the power we have right now to create via code is infinitely better than HCF.

My suggestion is that you take a basic JavaScript tutorial and learn about object oriented programming. You will quickly learn if you have an aptitude for this or not. It is not for everyone.. and that is okay.

Side note. I have been a programmer for many many* years on other platforms and I had to fully learn JavaScript before I let myself touch scripting API. And good thing I did...

The teacher I recommend is Mosh Hamedani (CodeWithMosh...youtube or udemy or his website). Take the JavaScript Basics class and the Node JS class.. There are many other teachers/classes on youtube.

Good Luck.

pallid portal
true isle
pale terrace
#

I think to automate things?

neat hound
pallid portal
# neat hound From reading this, I gather you are not a programmer, correct? There is no way ...

not at all XD
Just a dabbler.

I was able to make a working addon before the experimental feature got nuked.
Learning how to write scripts is a new level of frustration when one tutorial teaches one thing. But that principle does not work when applied to another scenario. And looking up how a script is supposed to work in that scenario (namely using a template that supposedly works, but does not for some reason) has been frustrating.

Thanks for the advice and well wishes.
I'll need that. lol

runic crypt
#

guys how do i make a script for floating leaderboards ?

woven loom
#

armor stand with invisibilty

#

scale it down so no one can kill

amber granite
#

Make the game more modifiable

#

And easier to do that

#
  • learning js is good because is one of the most famous programming languages
neat hound
# pallid portal not at all XD Just a dabbler. I was able to make a working addon before the exp...

When I first looked at code snippets, I was lost too. There are too many ways to do the same thing and I was not used to that. After learning the language, it will make sense somewhat. Especially if people write code more for readability instead of all the built in shortcuts. Those make it so you have to really know the language to understand what the code is doing, whereas readability makes it so anyone can follow the logic. Other languages are better for this. If you kinda like programming after you have a taste, I suggest Python.

distant tulip
#

i kinda learned script api before js lol
but i have experience in other languages

amber granite
#

They said it s not good to start with python

#

It's better to start with js

#

All seniors suggest that

woven loom
#

python is stupid for this

#

mobile devs would have hard time coding with tons of spaces

neat hound
#

They say a lot of things... and since everyone is not the same, the information may or may not be true. Either is fine, but for quickness in getting into a programming frame of mind from none, then it is more readable, this can be better for a beginner to dabble in the possibilities

amber granite
#

But also js is readable XD

#

There is no typing

neat hound
amber granite
#

There are no restrictions

amber granite
#

Everything is fine and as itended 🙂 👍🏻

neat hound
woven loom
#

send nukes to anyone suggest py for mc scripting

neat hound
woven loom
#

in general

amber granite
#

Nah , all programming languages are fine except of one specific language

pale terrace
amber granite
#

So they are both important

woven loom
#

py used for front end ?

amber granite
#

Yes

woven loom
#

when did that happen

amber granite
#

Many languages

amber granite
neat hound
# pale terrace although some do automated things with py

Yes.. I wrote a few of my regolith filters in python and I did not know the language... that is how easy it is to use and understand. I was able to take another's code, understand it, look up a few things and w rite in python.

amber granite
#

Back-end

woven loom
#

js is the only front end lang i see on web

amber granite
#

Not front-end

woven loom
#

yea

amber granite
#

My bad

woven loom
#

i was like how the heck py ended up in browser all of sudden

pale terrace
amber granite
pale terrace
#

Until now I have done countless things with js and I have never seen any tutorial, I learned by myself

neat hound
woven loom
#

the sad part about js is it all ends up with node, or browser no vanilla stuff

neat hound
amber granite
neat hound
pale terrace
woven loom
#

for me its way to simple which makes it hard

pale terrace
#

even AI helps with that

neat hound
# amber granite Yeah but, which one do u prefer rn

I guess preference is for the one I know.. there are a lot of things I like about it. I use SQL daily and now I wish I could have some JS features in... and then sometimes when I look up how to do something is JS, I am like YGTBFK me...

neat hound
pale terrace
neat hound
pale terrace
amber granite
#

Ai is not good for beginners

neat hound
#

Some people here will suggest a better way to do something, but a lot of that just comes with experience in coding period

pale terrace
amber granite
#

Not really

#

Chat gpt-4o

neat hound
#

I do not use AI, have never chat gpt'd... don't even know where it is... I am old school, I'd rather do for myself

amber granite
amber granite
#

Chat gpt 4o only

pale terrace
amber granite
#

Not always

neat hound
#

Ever heard of Garbage-In, Garbage-Out?

amber granite
#

No

neat hound
#

Ah, you young people....

pale terrace
pale terrace
#

so no

amber granite
#

Yeah

pale terrace
neat hound
#

Well I do use it by using Alexa and Google home mini... but that is a far as I go...

amber granite
#

☠️ alexa and Google dosen't contain chat gpt i guess

neat hound
amber granite
#

☠️

neat hound
amber granite
pale terrace
#

I wonder how you ended up here?

neat hound
#

Well... cliffnotes.... started playing MC during "the germ era" to bond with son... => realms => command blocks => add-ons

neat hound
amber granite
#

Nvm

neat hound
#

Enough with the # off topic.... back to programming... any questions out there?

valid ice
#

Anyone know if getBlockFromRay stops if it hits a block in the excludeTypes param?

pale terrace
#

let me try

pale terrace
#

completely ignore the block

valid ice
#

excellect, ty

glacial widget
last latch
#

how much ram does a world have? 100 mbs?

glacial widget
#
world.afterEvents.playerInteractWithBlock.subscribe((e) =>{
  const {player, itemStack, block} = e
  const blocklocation1 = world.getDimension("overworld").getBlock({x: 100, y: 23, z: 142})

  if(block.typeId == "minecraft:chest" && blocklocation1){
    world.structureManager.place(`mystructure:starterkit`, player.dimension, { ...player.location, y: player.location.y + 1})
    player.playSound(`note.pling`, { pitch: 2 })
    return player.sendMessage(`§aSuccessfully loaded kit!`)
  }

why does this work on chests that are not even in the block location?

runic crypt
last latch
#

because you check if the blockLocation1 is even a thing

glacial widget
last latch
#

you need to compare its location with the saved one

runic crypt
glacial widget
glacial widget
last latch
#

your if statement is like this : if (block.typeId == "minecraft:chest" && blocklocation1 !== undefined)

glacial widget
#

so i would need to put the coords into a const

#

save*

last latch
#

yes and compare it with other coords

#

this blocklocation1 outputs either a class Block or undefined

neat hound
glacial widget
neat hound
#

check if the chest is at that location

#

Maybe a function that can compare vector3s, so you can reuse it elsewhere

#

you can start y our own vector query class (I know others made one they shared, but for learning, do your own and only reference theirs, if you cannot figure it out - that is how you get better)

glacial widget
neat hound
glacial widget
tiny fable
#

how do I detect fishing?

amber granite
#

U can use itemUse event

glacial widget
glacial widget
tiny fable
#

thats a simple behaviour, why isnt that a event 😭
I guess I may need to detect if the hook had despawned and did it catch a fish

amber granite
#

Hmm

#

Yeah maybe u can use entitySpawn event

amber granite
#

After getting the fish ?

tiny fable
#

yea

#

I'm trying to make a event like world.afterEvents.playerCaughtFish but that sadly isn't a thing

amber granite
#
mc.world.afterEvents.itemUse.subscribe((event) => {
    const { itemStack, source } = event;
    if (itemStack.typeId === "minecraft:fishing_rod") {
        const entites = mc.world.getDimension("overworld").getEntities({
            location: source.location,
            maxDistance: 30,
        });
        for (const entity of entites) {
            if (entity.typeId === "minecraft:fishing_hook") {
                const fishing = system.runInterval(() => {

                });
            };
        };
    };
});
mc.world.afterEvents.entityRemove.subscribe((event) => {
    const { removedEntityId, typeId } = event;
    if (typeId === "minecraft:fishing_hook") {

    };
});

mc.world.afterEvents.entitySpawn.subscribe((event) => {
    const { entity, cause } = event;
    if(entity.typeId === "minecraft:item"){

    };
    if(entity.typeId === "minecraft:fishing_hook"){

    };
});
#

Try one of those

tiny fable
#

a nice structure, I'll try to merge it to my existing project.
Thanks :)

amber granite
#

UW

#

There are other methods too

#

But that some of them

neat hound
#

I would start with some logging action of spawns and removal of entities around me while I am holding the rod... so I can see what is activated and in what order and for how long.

#

Then I can manipulate it for my usage.

amber granite
#

Like entity type etc...

neat hound
#

Well it is more for the event and when triggered and if triggered... I've learned some anomalies that way. Things do not always work like you think they do or should.

#

but check what the entities are so that I can see when the hook comes and goes as well as the other items.

#

sometimes getting the whole picture gives more info instead of zeroing in on what you think you are looking for. More info for analysis... and I am good at analysis

#

.Hmmm.. I wonder if can make the hook always return an item when manual fishing... cause sometimes that small window of when to pull back is tight... you'd think for accessibility reasons they would have something

amber granite
#

U mean ?

neat hound
#

which?

amber granite
#

Is there an automated fishing?

glacial widget
#
world.afterEvents.playerBreakBlock.subscribe((e) => {
    const { player, block, itemStackBeforeBreak } = e;
  
    const ckey = world.scoreboard.getObjective("ckey");

    const chance = 100;
    const randomChance = Math.floor(Math.random() * chance);
    const blocks = ["minecraft:iron_ore", "minecraft:gold_ore", "minecraft:coal_ore"]

    if (block.typeId === blocks[0]) {

        if (randomChance < 10) {
            const crateKeys = 1; 
            ckey.addScore(player, crateKeys);
            world.sendMessage(`§d§lHCV KitPvP >> §a${player.name} has found a Common key while mining iron`);
        }
    }

this doesnt work for iron blocks, why?

neat hound
#

There is if you build it... I do it all the time

amber granite
#

Ah yes fishing farm

#

That uses trapdoor ?

glacial widget
#

it works fine when the iron block is on a clone command

neat hound
#

Test it without the chance to confirm

glacial widget
neat hound
#

and iron block is not iron ore... so you actually mean the ore, right

#

and remember the deepslate versions

glacial widget
#

i meant ore my bad

#

yep tested

#

for some reason it only works if the iron ore is being cloned and i break it from there

neat hound
#

That does not sound right.. throw a debug line in near top that gives you the typeId of the block broken

#

oh wait... that is after events.... the block is not the block its the broken one

amber granite
#

Or just make it console.log the right type id of that block

neat hound
#

do a log on block, itemStackBeforeBreak to see for yourself

#

or change this to before events...

glacial widget
#

i did before events now it runs a error on iron ores i break now, which means it works

#

this is the error

neat hound
#

Remember.... when you see that... put the comand in a system run

prisma shard
neat hound
prisma shard
#

Does not have required privileges, actually happens because of the beforeEvent

distant tulip
#

or just use after event if you don't need to cancel the event

glacial widget
neat hound
#

Both are options, just have to know what holds the information you want, because different for each

distant tulip
#

is beforeEvent the only thing activate read only mod?

neat hound
#

I am not understanding your question. ? read only mod ?

prisma shard
#

How can i get the adjacent blocks?

#

like, i want to get the connected/nearby blocks of a block

neat hound
#

the block as methods for that

valid ice
#

.offset()

neat hound
#

block.south()

valid ice
neat hound
#

ects

#

and offset if not at same level

prisma shard
prisma shard
neat hound
prisma shard
#

i dont want to use the block methods so much time

#

I want to get each block at a time

valid ice
#

Well what else would you use

#

If you have one block then you can get another offset from it

distant tulip
neat hound
#

Wite a functin, then use it... then fast...

prisma shard
neat hound
#

ok

distant tulip
#

there is the getBlocks function
get the block location and use that to get all the blocks around the area

prisma shard
distant tulip
prisma shard
#

I know there is getBlovk

prisma shard
valid ice
#

You'd need a loop or something to run code for each block, in that case

prisma shard
#

how

wary edge
#

Learn basic JS first?

prisma shard
#

... uh

neat hound
#

LOL

prisma shard
#

i know loop

neat hound
#

I think you should look into the getBlocks... has iterator of vector3s and you can use that to pull the blocks into an array.

#

It would help to know.. what is the input and what do you want to end up with?

#

you said adjacent blocks.. but then said it sounded like you wanted the adjacent blocks of the adjacent blocks...

#

so... how far out... easy to build loops for that.

#

or try getBlocks.. may have what you need to get them all within....

distant tulip
#

this should work

const directions = ["east", "west", "north", "south", "above", "below"];

directions.forEach((direction) => {
    const block2 = block[direction]()
    //...
});
prisma shard
wary edge
#

@prisma shard at this point just open a post and describe exactly what you want

#

Youre just cinfusing everyone now

fast lark
#
world.beforeEvents.itemUse.subscribe(data => {
    let player = data.source
    let title = "§l§7-= ShadowCraft menu =-"
    if (data.itemStack.typeId == "grassblock:shadowcraft_gui") system.run(() => main(player))

    function main() {
        const form = new MessageFormData()
            .title(title)
            .body(`il menu è attualmente in manutenziona.\nclicca annulla per chiudere il menu`)
            .button('annulla')


            .show(player).then(({ canceled, selection }) => {
                if (canceled) return

                if (selection == 0) {
                    player.playSound("random.break")
                    return
                }
            })
    }
})
#

why the message form data is not defined

#

it's the first time that i use message from data

cinder shadow
#

did you import it?

fast lark
#

no?

amber granite
#

Does ur code
includes :

import {MessageFormData} from "@minecraft/server-ui" 
fast lark
amber granite
#

Server-ui

fast lark
#

@amber granite

#

.button('annulla')

fast lark
#

ohhhhh

#

if i want only one button? @distant gulch

cold grove
#

Add just 1 button then

fast lark
cold grove
#

Probabbly.... idk

fast lark
cold grove
fast lark
#

but it's ugly

#

thanks anyway

distant tulip
#

use modelfromdata and change the submit button text

cyan basin
#

since when could I not use a json file tf?

#

I've always stored static data inside of a config.json file and now it just reads as a js?!

valid ice
#

Could be a bug..? Or an intentional decision?

cyan basin
#

silly bugrock* as always 😭

valid ice
wary edge
#

I recall it being asked in a qna

cyan basin
#

i used to use json files in all my old projects tho?!

#

whatever, i'll just use exports i guess

valid ice
#

The game is gaslighting you, fr

neat hound
distant tulip
#

that sound like you trying to get all the blocks in the world lol

neat hound
distant tulip
#

yeah
he said adjacent blocks of adjacent blocks
basically the whole world

neat hound
#

I am thinking he means all 8 blocks... but it is the communication of it that is off...

distant tulip
#

maybe he is looking for something like A* search algorithm

neat hound
#

well 8 cubed

wary edge
neat hound
#

I forgot above and below

#

wait, that does not sound right

wary edge
#

Wait that aint even 64 i cant math

neat hound
#

how many blocks a round 3d

#

9*3 - 1

#

right

distant tulip
#

i don't think cubic area is what he is looking for
adjacent blocks will make a diamond shape

neat hound
#

I think he wanted the blocks in between and not just touching

#

good job on finding or doing the graphics

wary edge
#

And this is why we should explain clearly what we want instead of being vague

neat hound
#

Yeah we know that.. garbage in - garbage out...

#

but eveyrone is not used to requirements

#

and having to satisfy them... need to be explicit else you get what you asked for

#

I do that on projects I don't want to do.. you get what you asked for and nothing more

distant tulip
neat hound
#

Did you AI that?

distant tulip
#

no XD

neat hound
#

I wish we had code challenges....

fast lark
#

i'm new at json

distant tulip
#

json ui is the final boss of json

distant tulip
neat hound
#

no.. they have events but that is not the same.... I am thinking like code-wars, but with scripting....

dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

distant tulip
neat hound
dense wraith
distant tulip
#

you don't 🤷‍♂️

distant tulip
dense wraith
neat hound
dense wraith
#

One message removed from a suspended account.

neat hound
#

Oh I see... it's interval

#

Did you not test it? Why are are asking if anything is wrong with it, would not loading it tell you?

dense wraith
#

One message removed from a suspended account.

#

One message removed from a suspended account.

distant tulip
#

ask them to enable the console log

neat hound
dense wraith
dense wraith
dense wraith
neat hound
#

Lead... means 1st statement.. it was a the bottom.. the ignored area... just sayin....

#

What device works?

#

and is server? realm?

#

or you are just loading add-on into different worlds on different devices?

#

If so... did you check all same configuration with world setup, is content log on for each device... details...

dense wraith
#

One message removed from a suspended account.

neat hound
#

How is playstatin playing on a mobile world.. LAN Connection, attached to friends?

#

If you have a realm you can test with, would be best.... to load it there and connect via other devices... That should work fine, so it may be something non related.

distant tulip
amber granite
#

They should change json ui with html

neat hound
#

😱

amber granite
#

What ?

#

Wait , is it html ?

distant tulip
#

Ore UI?

amber granite
#

Wait

#

Yeah it s html too

neat hound
#

what does the skull mean... like poison?

amber granite
#

But instead of making mediator just let us interact with the actual html

amber granite
neat hound
#

What does that mean? I don't know the emotolingo

#

I do not know if I should be perturbed or not.

valid ice
#

It means like "bruh" or some disbelief over the given answer

neat hound
#

You can't emote to my emote

#

LOL

distant tulip
#

laughing until he died

valid ice
#

"Why does script API not have enderchest component 💀"
"I just tried to get a player using getEntities and got cows as well 💀"

neat hound
#

luhd

distant tulip
#

lol

neat hound
#

cause they tryna keep us down

#

well cows ARE entities

#

use get Players

distant tulip
valid ice
#

yes

distant tulip
#

💀

neat hound
#

That looks like a Star Wars Alien... don't know what that means either..

amber granite
valid ice
#

💀 and ☠️ are used interchangeably

distant tulip
#

it kinda dose

valid ice
#

"What (expressing disbelief), I never heard of that meaning"

neat hound
#

unless he didn't

amber granite
valid ice
#

💀

neat hound
#

Imma take it to mean... You are introducing alien utter nonsense into my world

#

and possibly poisonous

valid ice
#

Locking in for a second here

neat hound
#

I am done locking in.... for the moment

#

le't's have a code war

amber granite
#

Code war ?

neat hound
#

Start a post, challenge, get all the blocks Froggo wanted...

distant tulip
neat hound
#

THAT IS HARD

#

you just want a piston

distant tulip
#

yeah

valid ice
#

Does it make more sense for a guard to view the player by the player's head, or from their feet?
e.g. a player is hidden if their head is behind a block (out of guard's view) but their feet are visible, or
a player is hidden if their feet are behind a block (out of guard's view) but their head is visible

neat hound
#

Really

valid ice
#

Before event piston activate, my beloved ❤️

neat hound
#

feet is your location... so maybe it is tied to that

distant tulip
neat hound
#

No I am not... involves detectiing redstone

distant tulip
#

it is alright
you can do it

valid ice
neat hound
#

Head

#

we are only 2 blocks tall... now I feel short

valid ice
#

2 meters tall ain't bad

distant tulip
valid ice
#

That's like, 6'6", 6'7"

amber granite
valid ice
distant tulip
#

make hem aware of the attachable wile you are at it

#

lol

valid ice
#

Full system is:

  1. Each player scans around them for guards
  2. Raycast is sent to each guard within range to determine blocks between two locations
  3. Angle between raycast line & guard view is found
  4. A "percent guarded" is returned based on the above factors
distant tulip
#

you should send 2 raycast or 4 one from the head and the other from the feet

valid ice
#

That would be a decent amount of extra computing

distant tulip
#

is it that bad?

#

from the player point of view the head is the best option

valid ice
distant tulip
#

yeah

neat hound
#

But you only want a number if either face or feet is exposed to guards view

cinder shadow
#

Whether or not you could potentially just do the raycast, store the players' volume somewhere, and check if that raycast intersects with the players volume

amber granite
#

Hmm what if the player is crawling

cinder shadow
#

Well that's a special case and might not even be applicable here

amber granite
#

Hmm what if player is jumping

#

Or sleeping

valid ice
#

Other states that the player could be in are not applicable here

amber granite
#

Ok

valid ice
#

The map is static and will not have those conditions

#

Crouching, it will, only because that is a conscious choice the player makes

#

Same with jumping

cinder shadow
#

idk whether there would be any performance impacts though

#

you could probably just use a 2D plane tbh

neat hound
#

And you can't piggyback of off the entities target system and check who he is targeting?

valid ice
#

The entity is not targeting the player, it's just a view thing

neat hound
#

Did you already discuss see thru blocks... I suppose those are in your exclude list

valid ice
#

They are, yes

valid ice
neat hound
#

Head... because if there is an action because of it, player won't understand.. "but he can see your feet.. and you cannot see him"

#

unless baby guards, lol

valid ice
#

nah lol

#

Why would babies have a job as a prison guard? 😛

neat hound
#

take children to work day

#

or the wardens evil son pops in every now and again

neat hound
#

Don't mine me, I'm just crazy

valid ice
#

We are all a little crazy

neat hound
#

Now that is an idea... Baby warden that ventures into the overworld, pop up 10% chance if ancient city below....

valid ice
#

I have wardens (not minecraft's), enforcers and guards

#

Names are... not great tbh

neat hound
#

I know, I was thinking of the real one... I need to make a small one to see what it looks like. See if I can do it.

valid ice
#

The term I use to encompass them all is "protector"

amber granite
#

.

neat hound
#

cool... land of the giants..

#

damn... all these idea... no time

valid ice
#

lol

#

No time? Or no motivation?

neat hound
#

Time, many projects...

valid ice
#

For me, definitely the second. I get tons of motivation to script at 3:00 AM on a weekday. Good stuff.

neat hound
#

just thought of another, I like this one... baby witch (mean girl) not to kill, but throw potions like nausea, slowness, blindness

#

and talk shit

valid ice
#

lol

neat hound
#

I play with a motely crew who would love that

amber granite
neat hound
#

oh no that kinda stuff is fun... me and a friend kept spawning iron golems and wardens in an ancient city to see who would win...

deep garden
#

So I am confused, my code works but I keep getting this error? I think it's because something is not defined, got any ideas of what it could be

world.afterEvents.playerInteractWithEntity.subscribe(({ itemStack, player}) => {
    
    if (lunaAxeId.includes(itemStack.typeId)) {
        const playerEquippableComp = player.getComponent("equippable");

    if (!playerEquippableComp) return;
    
    const durability = itemUsed.getComponent("durability");
    
    if (!durability) return;
    
    let durabilityModifier = 0;

        if (lunaAxeId.includes(itemStack.typeId)) {

            durabilityModifier = 1;
        } else {
            durabilityModifier = 2;
        }

    durability.damage += durabilityModifier;

    const maxDurability = durability.maxDurability
    
    const damage = durability.damage

    if (damage >= maxDurability) {

        player.playSound('random.break', { pitch: 1, location: player.location, volume: 1 })
            playerEquippableComp.setEquipment("Mainhand", new ItemStack('minecraft:air', 1));
        }
        else if (damage < maxDurability) {
            playerEquippableComp.setEquipment("Mainhand", itemUsed);
        }
    }
});

[Scripting][error]-Plugin [Infusion - 0.1.0] - [Main.js] ran with error: [TypeError: cannot read property 'subscribe' of undefined    at <anonymous> (Main.js:91)
]

remote oyster
# last latch how much ram does a world have? 100 mbs?

A world isn't allotted RAM. The server/application is allotted RAM. How much RAM can vary depending on your environment. However, RAM isn't the real concern here if that is why you are asking. Its performance is heavily influenced by the CPU, particularly its single-threaded performance, which affects the game's responsiveness and overall smoothness. RAM is important to consider if you have a large base of players and plenty of activity currently ongoing, but the CPU will play the more crucial role here.

neat hound
deep garden
#

1.13.0 is stable right or should it be 1.11.0

neat hound
#

1.13.0 is considered the release candidate RC, so it is the stable of Preview

deep garden
#

Okay, good deal 😊

neat hound
#

1.11.0 is stabel for reg MC

#

Even tho the RC can change... chatSend is in 1.120-beta, but taken out of 1.13.0 and moved back to 1.14.0-beta

#

cause SOMEONE had to discover an exploit bug... LOL...

thorn flicker
neat hound
#

so it's readonly now, as I think it should be anyway, we should not be able to alter any user's message ever, cancel yes, alter no.

remote oyster
#

👀

neat hound
#

Note to self: watch him... too interested.... in exploits that can crash....

#

LOL

thorn flicker
#

well you can just cancel and then make the player send the message with the sendMessage method and insert the sent message text with template literals

#

so it becoming read only isnt a big deal

neat hound
#

you can make it look like something

#

Oh I remember, someone was Assasin I think encrypting message to undo on receiver...

#

so it did not crash, it got an account suspension that should not have happen

#

yeah that is it... so that is bad,

remote oyster
#

#879773489601585244 message

neat hound
#

oh, him... hi Vis

neat hound
#

I am not sure about that...

thorn flicker
#

im sure about it.

neat hound
#

I need to see it I guess

thorn flicker
#

because I did it.

#

many times

neat hound
#

I see..

thorn flicker
# neat hound I see..
world.beforeEvents.chatSend.subscribe(data => {
    const msg = data.message
    const player = data.sender
    data.cancel = true;
    player.sendMessage(`message: ${msg}`)
})
neat hound
#

but that sends a message to the player not from him

open urchin
#
world.sendMessage(`<${name}> ${message}`)
last latch
thorn flicker
#

oh.

#

Apologies

thorn flicker
remote oyster
last latch
#

Huh, I guess that number is small. We will never know.

neat hound
#

Isn't the look or font slight different so that you can tell if it was the player or code?

thorn flicker
#

lol

#

"theres 2 more pixels on this character, this is unpolished!"

neat hound
#

yeah it does, if a malicious add on makes it have one person say something "bad" to another

#

something reportable

remote oyster
thorn flicker
neat hound
#

you can take a pic of it... but if there is that difference, then they would know

#

not bad that way... unkind remarks

#

hate speech

#

bunch of stuff

last latch
last latch
thorn flicker
remote oyster
#

I'm asking because script-api is allotted memory. Exceeding it will crash it.

#

I can't remember how much memory.... I forgot haha.

neat hound
#

I noticed the diff a while back because I had monsters saying shit.... so ... maybe it is diff now, don't know

last latch
remote oyster
amber granite
last latch
remote oyster
# last latch I dont think so.

Looks like watchdog has a default setting of 250 MB. With a memory warning starting at 100 MB. This is on BDS. I would think it's best to assume these settings are the same on Realms as well. On BDS you can configure these by either increasing these values or disabling them entirely.

amber granite
#

I mean each add-on has its ram consumption

#

So u can't say how exactly u need

last latch
remote oyster
#

But I wouldn't recommend that. If you have a memory leak, or a mismanagement of memory handling then it would be highly advised to fix that problem versus ignoring it. Steadily growing memory will eventually cause issues. You do not need watchdog enabled to experience those.

#

If the memory is stable, but just so happens to use a decent amount, then instead of ignoring it entirely, I would just increase what is allotted in server.properties.

neat hound
#

Damn, you know how long it took to find the perfect gif... now I am tired

empty quail
#

What's the beforeEvent listener that checks if a player is hurt by another player?

remote oyster
empty quail
#

Alright, how can I negate damage done to a player?

random flint
empty quail
#

Oh right

#

Yeah that works

valid ice
#

First option best fr

slim spear
grave thistle
#

Hey, I've had a few months break of creating addons. Has much changed (stable)? I'm trying to use dimension.spawnItem but the vector part doesn't seem to work

wary edge
grave thistle
wary edge
#

Nope

#

Just do ({x: 0, y: 0, z: 0})

grave thistle
#

The console error I'm getting:

[Scripting][warning]-console.warn

[Scripting][error]-TypeError: Native setter cannot be assigned null or undefined. Interface property ['z'] expected type: number (failed parsing interface to Function argument [1]) at <anonymous> (mob_spawner.js:19)

woven loom
#

send code, erors isnt enough

#

think z is null, do check fornit

grave thistle
woven loom
#

send it as message its not even 1 kb

wary edge
#

No need to

wary edge
grave thistle
wary edge
#

Since that returns a Vector3, no need to construct a new one

grave thistle
random flint
grave thistle
random flint
#

ye

random flint
grave thistle
#

And when I use spawnItem i still have to include the x:, y:, z:?

random flint
#

yea?

#

u could also do this:
const loc1 = tBlock.center();
overworld.spawnItem(itemStack,loc1);

#

@grave thistle

grave thistle
#

Going to see if altering the variable like you said since i need to offset the item spawn point

#

@random flint got it working, ty. Wish I didn't take a break from coding for so long

#

Why isn't {x: bx + 0.5, y: by + 0.5, z: bz + 0.5} offsetting the spawn location?

wary edge
grave thistle
wary edge
grave thistle
wary edge
#

Thats weird

grave thistle
#

Weird, I removed and re-added the behaviour pack and it now works

wary edge
#

Are you using the dev folder by any chance?

drifting ravenBOT
#
Using the `development_*_packs` folders

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

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

We highly recommend using the development_*_packs folders.

grave thistle
wary edge
#

Yeah makes sense. You're facing caching issues

grave thistle
#

Lol so janky. Don't know why overwritting the file didn't update it. At least completely removing and re-adding it has fixed it

wary edge
#

If you could, try use the dev folders. If not, prepare to keep reapplying your pack

grave thistle
#

I'm using bridge. and I'm not sure it can upload directly to the dev folder

random flint
#

oh nvm

#

yey development folder

fickle pulsar
#

guys my scripts keeps getting put into message.txt and jayly script debugger dont work

#

how to fix

random flint
fickle pulsar
#

ok

#

doesnt work

random flint
#

bot down maybe?

fickle pulsar
#

ok

limber gate
#

Is there a way to perform raycast that goes through passable blocks but not through water? When using includeLiquidBlocks: true, includePassableBlocks: false it doesn't hit water, as it seems includePassableBlocks already includes water and it takes priority, which is a weird design choice imo

woven loom
#

make a custom raycast then. do we even have a way to test flowing water

limber gate
#

Is there a way to test which block types are considered as "passable"?

woven loom
#

my guess is that any block which let entity pass considered as passable

wary edge
limber gate
#

Is there a way to detect which block is passable based on its type? Wanting to re-implement includePassableBlocks functionality in a way that can include water in the raycast

wary edge
#

Then grab the results and those that are passable put into an array?

limber gate
#

ig that works but it's unfortunate that we even have to resort to such extreme workarounds

#

for a very simple behaviour

wary edge
distant tulip
#

or not?

wary edge
#

Idk thats why I asked

rugged tinsel
#

pretty sure isAir is only for air

#

not sure what isSolid is though

#

it's not even stable yet afaik

limber gate
#

it's not, no

distant tulip
#

pretty sure i used isSolid before to detect full blocks

rugged tinsel
#

but does isSolid mean able to transmit redstone or occupies the full block collision?

#

not really clear based on that name

rugged tinsel
#

a glass block would probably be the easiest way to test that

wary edge
#

Ive, rarely used .isSolid to test such thinga i always use it to check full blocks bc i assume it would only be restricted to that

rugged tinsel
#

it's not solid in regards to redstone and fences, but it is solid in regards to collision

wary edge
#

Im heading to work so i cant test that now 😔

distant tulip
#

full block != solid block
let me just test that

rugged tinsel
wary edge
#

Bummer

#

I was gonna suggest Veka to use isSolid as passable

rugged tinsel
#

is includeTypes stable?

#

I wonder if that overrides the passable check

limber gate
#

I think it overwrites everything

rugged tinsel
#

could u use that to check for water then?

wary edge
limber gate
#

So you'll have to list every single block except for passable types

rugged tinsel
#

ah, that sucks

limber gate
#

excludeTypes is a viable option tho, but you'd still have to list all passable blocks there

#

And that might be quite slow to execute depending on how many types you use

rugged tinsel
#

you could probably just ignore the likely options, won't be great for compat though

#

just give us a collision block component

#

though that would still suck

#

fixing that weird passable behavior would be best

limber gate
#

raycasting second time just for water is also an option, but idk how slow that would be

rugged tinsel
#

wouldn't it just immediately hit the next water block after the final destination?

#

instead of whatever the "first" one would've been

limber gate
#

No I mean do 2 raycasts in the same pos and dir, one with passable blocks excluded and another one only against water and use the closest hit

rugged tinsel
#

ah, I don't think it would be that bad, depending on how often that's ran

limber gate
#

That'd double the number of raycasts tho and when raycasting just against water, rays would have to check a lot of blocks

rugged tinsel
#

would it be worse to have a huge filter or double raycast though?

limber gate
#

that's the question

#

Filter would have a fixed performance hit while doing 2 raycasts will depend on the scene, if there isn't a lot of water nearby, then water rays will have to do more work

amber granite
#

Yes ,

grand heart
#
function getRandomSpawn() {
    
    const s = {x: random(ArenaArea[0], ArenaArea[2]), y: 265, z: random(ArenaArea[1], ArenaArea[3])};
    const t = {x: s.x, y: 254, z: s.z};
    const u =  overworld.getBlockFromRay(s, t).block.location;
    console.log(JSON.stringify(s));
    console.log(JSON.stringify(t));
    console.log(JSON.stringify(u));
    return {x: u.x, y: u.y + 1, z: u.z};
}

how is raycast like this, what even is a raycast if my assumption is wrong?

[2024-07-30 21:34:29:720 INFO] [Scripting] {"x":12014,"y":265,"z":12019}

[2024-07-30 21:34:29:720 INFO] [Scripting] {"x":12014,"y":254,"z":12019}

[2024-07-30 21:34:29:720 INFO] [Scripting] {"z":12031,"y":265,"x":12025
#

im trying to find the spawnable location in a random xz location

sharp elbow
#

The second argument passed to getBlockFromRay is the direction it should go. You should not be passing world coordinates into this

#

I'm assuming you want the topmost block, by casting downward. T should be:
const t = {x: 0, y: -1, z: 0};

#

@grand heart (pinging for visibility)

nimble schooner
#
if (enchants != `` && enchants != undefined && enchants) {
        enchants.forEach(enchant => {
            addEnchantments(itemFormatted, [{
                type: `${enchant.type}`, level: enchant.level
            }]);
        });
    }
#

Why does this not work

#

anymore

#

it used to

#

what did they replace it with

#

export function addEnchantments(item, enchants) {
const itemEnchantComponent = item.getComponent("enchantable");
if (itemEnchantComponent) {
itemEnchantComponent.addEnchantments(enchants);
}
}

nimble schooner
#

That‘s everything

#

Basically

amber granite
#

Not

tiny fable
#

Hello guys! Another problem:
I'm trying to use this chest ui
A very strange part is, changing the constant number_of_1_16_100 to +11(The amount of custom item we have) makes:
every block shift incorrectly, and item shift correctly
Did anyone encounter this before and is there a thing I can do?

GitHub

Contribute to Herobrine643928/Chest-UI development by creating an account on GitHub.

nimble schooner
#

Everything you need to know

amber granite
nimble schooner
#

Because everything else works

sharp elbow
#

So the "item" parameter is ItemStack, and "enchants" is an Enchantment array?

nimble schooner
#

Just not the enchantment adding

tiny fable
amber granite
tiny fable
steep hamlet
#

is it possible to add components to an entity without modifying its behavior file?

valid ice
tiny fable
valid ice
#

Only custom items with 1.16.100 format version & higher shift stuff- as they are inserted into the IDs at 256, shifting all IDs that exist above 256.

chrome flint
#

does pushing player in an array and checking if the player is inside the array will cause some problems?

#

it works for me but im afraid there would be problems in testing for the player

amber granite
#

Nah will not cause

chrome flint
#

okay, thanks

amber granite
#

Uw

chrome flint
#

even though i changed the player properties, right?

amber granite
#

It will changes player's propreties too

valid ice
#

You could push a property of the player- like their name, id or something instead of the entire player class

amber granite
#

Better idea ^

chrome flint
cinder shadow
#

I don't see why it would cause any problems

fiery solar
distant tulip
#

the amount of people sending dms to offer me help 🤦‍♂️

glacial widget
#
import { world, system, Player, EntityInitializationCause} from '@minecraft/server';
import { ActionFormData, MessageFormData, ModalFormData, ModalFormResponse } from "@minecraft/server-ui";

world.afterEvents.playerInteractWithBlock.subscribe((ev) =>{
    const {block, blockFace} = ev
    const tokens = ["minecraft:nether_wart", "minecraft:nether_star"]
    const ores = []

    const money = world.scoreboard.getObjective("Money")
    let player = world.getAllPlayers()

    if(block.typeId == "minecraft:lime_stained_glass" && block.x == -17 && block.y == 176 && block.z == 32){
        switch(tokens || ores){
            case tokens[0]:{
                console.warn("works")
                player.runCommand("/clear @s nether_wart")
                money.addScore(player, 100)
                player.sendMessage("you have sold your items")
            }
        }
    }
})

why does this not work, i dont get any errors at all or a console warn

#

its a interact with block i cant add source

amber granite
#

It wirk

#

It works

glacial widget
amber granite
#

It should work , because its array refrence

#

To all the players

#

Oh yeah i see

#

U are using it wrongly

#

Use

player.forEach(player=>{
//Your code})
glacial widget
#

Ohhh

#

i forgot

#

thanks bruh

amber granite
#

Idk what he is trying to do :T

glacial widget
#

at a spot

#

could i use entityHit for this aswell?

#

alr so like this?

#
world.afterEvents.entityHitBlock.subscribe((ev) =>{
    const {hitBlock, hitBlockPermutation,} = ev
    const tokens = ["minecraft:nether_wart", "minecraft:nether_star"]
    const ores = []

    const money = world.scoreboard.getObjective("Money")
    let player = world.getAllPlayers()

    if(hitBlock.typeId == "minecraft:lime_stained_glass" && hitBlock.x == -17 && hitBlock.y == 176 && hitBlock.z == 32){
        switch(tokens || ores){
            case tokens[0]:{
                console.warn("works")
                player.runCommand("/clear @s nether_wart")
                money.addScore(player, 100)
                player.sendMessage("you have sold your items")
            }
        }

    }
})
#
import { world, system, Player, EntityInitializationCause} from '@minecraft/server';
import { ActionFormData, MessageFormData, ModalFormData, ModalFormResponse } from "@minecraft/server-ui";

world.afterEvents.entityHitBlock.subscribe((ev) =>{
    const {hitBlock, hitBlockPermutation} = ev
    const player = ev.damagingEntity
    const tokens = ["minecraft:nether_wart", "minecraft:nether_star"]
    const ores = ["minecraft:coal", "", ""]

    const money = world.scoreboard.getObjective("Money")

    if(hitBlock.typeId == "minecraft:lime_stained_glass" && hitBlock.x == -17 && hitBlock.y == 176 && hitBlock.z == 32){
        console.warn("works")
        switch(tokens || ores){
            case tokens[0]:{
                player.runCommand("/clear @s nether_wart")
                money.addScore(player, 100)
                player.sendMessage("you have sold your items")
            }
        }

    }
})

does not work?

grand heart
amber granite
#

Looks good idea

amber granite
sharp elbow
#

switch(tokens || ores) is creating a boolean statement, to be compared to the tokens—true === "minecraft:nether_wart" will not succeed

glacial widget
glacial widget
#

so i thought i would count to both arrays

amber granite
sharp elbow
#

Yes, for testing conditions. It works in if() by creating a boolean statement

amber granite
#

Using dataForm

glacial widget
#

thank you though

sharp elbow
#

What should it be doing? Are you wanting to iterate over some array (or two) to see if any entries match? Or if one array includes entries from another?

glacial widget
valid ice
#

array.some(element => element === value)

#

.some() returns a true if ANY callback returns true
.every() returns true if ALL callbacks return true

sharp elbow
#

.find() is useful if you need the value of that element.

valid ice
#

That too!

#

Array methods are pretty epic poggers

sharp elbow
#

I am constantly finding new ones every time I look

valid ice
#

Those dang javascript developers just keep adding more

remote oyster
#

"The strength of JavaScript is that you can do anything. The weakness is that you will." ~ Reginald Braithwaite

amber granite
#

Are u messing with me ?

remote oyster
#

It's a quote.

amber granite
#

I will what ?

#

Don't let me get mad bro ಠ⁠︵⁠ಠ

#

JK

glacial widget
#
import { world, system, Player, EntityInitializationCause} from '@minecraft/server';
import { ActionFormData, MessageFormData, ModalFormData, ModalFormResponse } from "@minecraft/server-ui";

world.afterEvents.playerInteractWithBlock.subscribe((ev) =>{
    const {block, player, itemStack} = ev
    const tokens = ["minecraft:nether_wart", "minecraft:nether_star"]
    const ores = ["minecraft:coal", "", ""]

    const money = world.scoreboard.getObjective("Money")

    if(block.typeId == "minecraft:lime_stained_glass" && block.x == -17 && block.y == 176 && block.z == 32){
        console.warn("works")
        if(itemStack.typeId = tokens.every()){
            console.warn("works")
            player.runCommand("clear @s nether_wart")
            money.addScore(player, 100)
        }
    }
})
#

something like this?

amber granite
#

What is that ?

remote oyster
# amber granite I will what ?

Not sure I understand you or if you misunderstood the quote.

It speaks about the power of JavaScript and how versatile it can be but highlighting the pitfalls that comes with it. In JavaScript, you can achieve a lot with little code, but it's flexibility can lead to complex, difficult-to-maintain code if not managed properly.

amber granite
#

There is typescript

glacial widget
amber granite
#

So it s trading system

glacial widget
#

a sell block

amber granite
#

Then specify ur block

#

That nice

glacial widget
#

it works but for some reason the if statement does not

amber granite
#

But i thought about trading system between players, u know some players sell the goods , and wait until one of the other players buy them and get the money after that

glacial widget
#

even when i hold out the item

amber granite
#

Etc....

modest turtle
#

hello everyone, who can tell you how to make any text on top in the center of the screen? (Maybe someone knows a publication that will help you find a solution?)

amber granite
#

That will be cool , like making bank in ur server

#

Yes

glacial widget
#

then from there you can learn

modest turtle
glacial widget
amber granite
#

And so on

amber granite
#

Without creating non-existent resources

grand heart
#

it should be some

glacial widget
#

thank you sir

remote oyster
# glacial widget it works but for some reason the if statement does not

Add code to have it print off the block type to verify it's comparing the same string. Then print off the location of that block to verify it matches with the hard coded coordinates you expect it to be. If any of those conditions are not a match then your if statement will not execute the code inside the clause. Also, may I suggest using === versus ==?

=== is strict type checking. If you are trying to compare a string then it will strictly check for a string. The other isn't strict. It will try against a string, number, etc to get a match.

Hopefully this explanation is simple to understand. I didn't want to get too heavy in it lol.

glacial widget
#

so replace the every.() with some.()

amber granite
#

some()

glacial widget
#
tokens.some(item => itemStack.typeId == item)
grand heart
glacial widget
grand heart
glacial widget
#

however am still getting a error for this

itemStack.typeId === tokens.some(item => itemStack.typeId == item)
grand heart
#

no, remove the one before the first e qual signs and also the first equal signs

if (tokens.some(item => itemStack.typeId == item))
amber granite
#

☠️ bro is cooked

glacial widget
grand heart
#
import { world, system, Player, EntityInitializationCause} from '@minecraft/server';
import { ActionFormData, MessageFormData, ModalFormData, ModalFormResponse } from "@minecraft/server-ui";

world.afterEvents.playerInteractWithBlock.subscribe((ev) =>{
    const {block, player, itemStack} = ev
    const tokens = ["minecraft:nether_wart", "minecraft:nether_star"]
    const ores = ["minecraft:coal", "", ""]

    const money = world.scoreboard.getObjective("Money")

    if(block.typeId == "minecraft:lime_stained_glass" && block.x == -17 && block.y == 176 && block.z == 32){
        console.warn("works")
        if(tokens.some(item => item == itemStack.typeId)){
            console.warn("works")
            player.runCommand(`clear @s "${itemStack.typeId}"`)
            money.addScore(player, 100)
        }
    }
})
glacial widget
grand heart
glacial widget
amber granite
#

Lemme fix it

#

Ok !

grand heart
#

if so you can just put if (!itemStack) return;

amber granite
#

Yeah

#

So u must take it from the inventory i guess

#

@glacial widget

grand heart
glacial widget
grand heart
subtle cove
#
const tokens = {
    "minecraft:nether_wart": 100,
    "minecraft:nether_star": 200
}
``````js
if (itemStack?.typeId in tokens) {
    const hand = player.getComponent("equippable").getEquipmentSlot("Mainhand") 
    if (itemStack.amount === 1) hand.setItem()
    else hand.amount--
    player.addScore(player, tokens[itemStack.typeId])
} ```
grand heart
#

pro move

remote oyster
#

Or, just skip it:

const { block, player, itemStack } = ev;

if (!itemStack) {
    return; // Skip if itemStack is undefined
}
grand heart
#

also * itemStack.amount

subtle cove
#

There

#

Hmm, not sure if ev.itemStack = itemStack would work tho

amber granite
#

What is
If ( something in something)

grand heart
subtle cove
#

Is it rare to see code with ContainerSlot?

amber granite
#

I nevermind see that before

subtle cove
amber granite
#

But ,