#Script API General

1 messages · Page 97 of 1

cyan basin
#

So on a double chest that's 81 buttons active at one time

rustic ermine
#

Yeah. I haven't noticed any lag, but wish I could figure out how to turn off the slide-in animation

#

I'm using it as a gui for all of my skills and work block interactions so it gets kind of old lol

cyan basin
#

I'm opening it with a button at the moment and you can notice a slight freeze when initially opening it but it could just be me dviperShrug

#

The slide animation is done through the third_party shit in server_form

rustic ermine
#

Might just depend on hardware. My server is on a Ryzen AI 370. Oh, is there a way to disable?

#

Never realized how much I rely on good documentation and editor suggestions until I tried JSON UI and had neither lmao

cyan basin
#
  "[email protected]_screen": {
    "$screen_content": "server_form.main_screen_content",
    "$screen_animations": ["@server_form.exit_wait"],
    "$background_animations": ["@server_form.exit_wait"],
    "type": "screen",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "button_mappings": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.menu_exit",
        "mapping_type": "global"
      }
    ],
    "force_render_below": true,
    "size": ["100%", "100%"],
    "load_screen_immediately": true,
    "low_frequency_rendering": true,
    "render_game_behind": true,
    "render_only_when_topmost": false
  },

  "exit_wait": {
    "anim_type": "offset",
    "easing": "linear",
    "duration": 0.08,
    "from": [0, 0],
    "to": [0, 0],
    "play_event": "screen.exit_pop",
    "end_event": "screen.exit_end"
  }```This includes the exit_wait but you'd do the same for the entry
rustic ermine
#

Thanks a lot 🙂

cyan basin
#

Nevermind, I just tested what I sent you and it does just pop in and out

#

There's no sliding in or out anymore lol

rustic ermine
#

Thanks. It was driving me crazy. I have 23 skills, each with their own sub menu to show what gear etc different levels unlock, and their respective crafting menus / individual craft items.. so having that happen for every interaction.. uhg

cyan basin
#

I also ended up removing the furnace screen and pattern for the chest form out of mine.. See no point in having it

#

Does the 10 indicate the level of the skill?

rustic ermine
#

Yeah

#

Max of 99. Basing my server off RuneScape

cyan basin
#

That's neat. You can actually have it display the 1 but then it'll display everywhere lol

rustic ermine
#

Tried 120 but it clips the text

cyan basin
#

Yeah.. back when you could get over 100 it would only ever display 99+ anyway

rustic ermine
#

Yeah just thought it'd be cool. The XP can get to 200m though so can still do invisible unlocks

cyan basin
#

Only downside I see in this now is that the durability always remains green

#

It doesn't change colour as it reaches 0 durability dviperSigh

#

Oh nice

rustic ermine
#

only thing that would really need changed is that I just saw my lvl 99 guard technically stops you from gaining xp after 99 but should be easy to fix if you use any of it

#

yeah uncommenting that part is what I was looking for, thanks

rustic ermine
#

also removed inventory and furnace portions and all their associated code. much much faster now

sly valve
#

What exactly is this server?

#

I mean it says Skyblock but is there more?

dawn zealot
sly valve
dawn zealot
#

that is the point 😭

distant tulip
#

that was fast, lol

dawn zealot
distant tulip
#

oh, i thought it took 5 min

dawn zealot
distant tulip
#

You are using tick_world component?

dawn zealot
distant tulip
#

Well, that answer my question lol
It is not recommended to use ticking area command, it is limited

distant tulip
#

Sure

cinder shadow
#

anyone know off the top of their head how getEntities orders the entities?

sterile epoch
#

isn't it ordered by closest to farthest

cinder shadow
#

Hope so

proper perch
#

Is this how I add effects the fire resistance works but not the resistance effects: [{ type: MinecraftEffectTypes.FireResistance, amplifier: 0, duration: 1000000 },{ type: MinecraftEffectTypes.Resistance, amplifier: 3, duration: 1000000 }] }]

valid ice
#

How are you using that array?

proper perch
#

If someone is wearing a full set of armor these effects are supposed to be applied

#

I can send the script file

#

It was just the fire resistance but I also want to add the resistance

valid ice
#

That's a hella lot of code, but in the run interval you're just applying the first effect

#

around line 255

cinder shadow
#

Thanks

valid ice
#

Instead of just effects[0]

proper perch
#

What do I put,

meager cargo
#

Please

prisma shard
#

wait

#

what

#

location.offset() is a thing?
didnt knew that

nova flame
#

anyone know how i can test for players killing other players

fading sand
#

Anyone have an example code for w and s key pressed check?

#

Nvm, theres still no other buttons than jump and sneak

vast grove
fading sand
#

I mean its when im riding an entity

vast grove
#

It still should be enough? Or does movement vector not change if the player is riding?

dusky flicker
distant gulch
#

Can i have this version of the chest ui?

alpine ibex
#

Does anybody know how to add delays in run intervals

halcyon phoenix
#

oh wait

halcyon phoenix
acoustic basin
#

guys, i need some help with my custom component. this is the script i have, and this is the custom component on my item. it doesn't want to work on logs and woods when there's is_axe tag on my item. what am i supposed to do than?

import { toolDurability } from "utility/itemDurability.js";

export const event = {
    onUseOn({ block, source, usedOnBlockPermutation }, { params }) {

        for (const param of params) {
            if (!param.blocks.includes(usedOnBlockPermutation.type.id)) continue;

            block.dimension.playSound(param.sound, block.center());

            if (param.damage_tool) {
                toolDurability(source);
            }

            break;
        }
    }
};```
#

when i add any other block to any of these arrays, everything works

fast wind
#

Is it possible to run a function/script using voice input? I don't care if I need to use discord or some other shenanigans I'm just curious and thinking about an addon that could use voice input (it's not proximity chat)

vast grove
#

Yes. But goodluck.

fast wind
#

😭

#

Well I don't care how hard it is enlighten me

vast grove
#

HTTP or MCWSS to an outside tool which analyzes voice data

fast wind
#

Alr so minecraft bedrock's javascript can accept HTTP API requests?

vast grove
#

Yeh. BDS only

fast wind
#

Wow didn't know that

#

That's fucking cool

#

is BDS just a normal server or do you need to follow a certain procedure? I have or atleast have access to a Minecraft Bedrock Bisect Hosting server

#

Would it work?

vast grove
#

BDS is just a software you run to host an mc server.

fast wind
#

Ok

fast wind
#

I'll look into it, thank you a lot

rustic ermine
fast wind
livid elk
#

is it possible to change npc dialogue message using script?

boreal siren
#

How to disable damage between players using ScriptAPI?

fast wind
thorn flicker
#

probably not the message directly though

boreal siren
#

How to do this together with JSON and ScriptAPI?

thorn flicker
boreal siren
#

I just want to make a system that can be controlled via ScriptAPI

thorn flicker
#

so use events that swap out/remove the damage sensors with component groups.

#

you can trigger entity events within the script api

#

or you can use tags, or properties, and filter them in the damage sensor filter.

wheat condor
#

entity.triggerEvent("ev")

boreal siren
#

I was looking at the player's JSON parameters, but I'm curious if there is another identifier than the tag?

fallow rivet
#

I have been coding from my phone for years and now I have a computer, how can I code from the computer?

woven loom
#

vscode + types + debugger extention

tardy pivot
#

block placer doesnt fire any of the item events?

wary edge
tardy pivot
#

even custom components

#

nope didnt replace block item

open urchin
#

which events?

tardy pivot
#

before & after itemUse, itemCompleteUse,
custom components: onUse, onCompleteUse

#

had use modifiers also when used onCompleteUse

open urchin
#

complete use is for chargeable items (minecraft:food, minecraft:shooter, minecraft:throwable)
use modifiers and use animation don't do anything if the item isn't chargeable

#

onUse is for when the item isn't used on a block
onUseOn should work

tardy pivot
#

I aboided onUseOn because it still fires even when the block isnt placed

open urchin
#

have you tried playerPlaceBlock?

tardy pivot
#

ill try it

#

nice it works, thanks quaz youre a holy grail of knowledge

fast wind
#

How can I send audio from a minecraft player's mic to a website using HTTP request, do I need to use discord or is there another way?

whole axle
#

world.afterEvents.playerSpawn.subscribe(({ player }) => 
    transferPlayer(player, "24.19.3.41", 24302));

what changed also what version server admin

fast wind
open urchin
fast wind
#

Oh you replied to that

whole axle
fast wind
#

Sorry

whole axle
#

i have 1.0.0 it dont work

open urchin
#

1.0.0-beta

valid ice
#

Are you looking to create a proximity chat-esque thing?

wheat condor
valid ice
#

Because if you're looking to play their audio inside of minecraft, you can't. Sounds have to be defined in the resource pack.

#

I think the best you could do with just addons is have players all in a voice chat in discord, and change their audio level based on distance by sending http requests to a discord bot.

wheat condor
valid ice
#

hmm

wheat condor
#

the only way is connect it to client side script using discord browser and editing the volume values by client

valid ice
#

Gotcha

whole axle
#

How to fix Incorrect permission for command reload on bds im using pebblehosting

bold stratus
#

what is prediction extension name for visual studio?

hoary panther
#

Anyone know how to fix a world imported off a realm? I cant reload in it anymore so its very annoying to develop in it

#

Nvm I just exited the world, turned cheats off, reloaded the world, turned them on again, and boom?

valid ice
#

Change permissons from operator to custom (w/o OP perms) and back
If that doesn't work try just member permission and then back

#

nvm'

hoary panther
#

Thanks haha

#

I tried that too

#

I knew there was a way I just forgot

valid ice
pallid stag
#

Can someone teach me the basics to learn scripting?

round bone
pallid stag
#

Thanks, but about the code in the script, where can I learn?

round bone
vast grove
valid ice
#

Ah here's the guy who know's whats up

vast grove
#

They aren't trying prox chat, they're trying speech to text

#

Which then executes actions

#

On mc

valid ice
#

ahhhh

vast grove
#

Tbh you could use my program to run a speech to text inside add-ons

sly valve
#

GUYS

#

Any sites where I can get good builds from?

#

with .mcstructure extension

jagged gazelle
jagged gazelle
bold bison
minor horizon
#

is the node.js updated to 2.0.0? I'm trying to figure out how to reregister my custom components, but system.beforeEvents.startup isn't working

#

nvm I got the node updated

#

what is this error? All im doing is using the constructor for EnchantmentType to enumerate elsewhere

#
const unbreakingEnchantment = new EnchantmentType('unbreaking');
sterile epoch
minor horizon
#

That makes sense, I'll add it to an initialize event in the morning.

#

It would be world.afterEvents.worldLoad right?

sterile epoch
#

yeah

minor horizon
#

Or should I add it to the system startup

#

I can try both ig

sterile epoch
#

I don't think startup works

#

idk tho never tried

minor horizon
#

Aight, thx for the insight

sterile epoch
#

no problem

halcyon phoenix
#

hello people I need some opinion, I got this particle however it need to be rotated do I rotate it in the script or just redraw the sprite?

bold bison
halcyon phoenix
bold bison
bold bison
jagged gazelle
jagged gazelle
# bold bison

Vector3 don't exist anymore... Just do { x: 0, y: 0, z: 0 }

#

if you plan to use math libs

#

it's not ENTIRELY native, you need to download a bundle to use it properly.

thorn flicker
#

or use the minified version of minecraft-math by jayly

bold bison
jagged gazelle
#

??

bold bison
thorn flicker
#

I have a feeling a translator is being used

jagged gazelle
#

I was about to say... my autistic side is showing up again.

thorn flicker
#

what does that even mean

#

lol

jagged gazelle
thorn flicker
#

ah.

jagged gazelle
#

I'm autistic lol

thorn flicker
#

well, I understood that

jagged gazelle
#

Just 20%... I got tested last month

bold bison
valid ice
#

remove your import for Vector3

cinder shadow
#

why does useDuration in itemStopUse event return the remaining amount of time when there is no way to check the total amount of time 🗿

#

what is even the point of this property

#

and I can't even use it because the entitySpawnEvent is ran before itemStopUse

livid elk
#

is there a way to get the entity i interact with using a script? like if i interact with the npc, that npc will do something

woven loom
#

we have interact event

livid elk
#

ohhhh sht, i didn't know that xd, now i need to rewrite my whole code, thanks!

halcyon phoenix
fast wind
#

I have managed to put something up

#

Sorry do you know how the "@minecraft/server-net" module works?

valid ice
#

It's just http requests and stuff

#

Can do something like

async function discordWebhook(webhookURL, message) {
    const request = new HttpRequest(webhookURL);
    request.method = HttpRequestMethod.Post;
    request.headers = [
        new HttpHeader('Content-Type', 'application/json')
    ];
    const body = {
        content: message,
        allowed_mentions: {
            parse: []
        }
    };
    request.body = JSON.stringify(body);
    const response = await http.request(request);
    return response;
};
``` to access discord webhooks
fast wind
#

Okay let's say this, I have a flask website with a form that has text input and submit input, this works on a browser, how can I simulate putting the text input and submitting with the http request

#

?

#

You can ping me if you want

#

Well nevermind I think I know what I did wrong, still if you have an answer I appreciate it

jagged gazelle
#

Very late lol

acoustic basin
vast grove
fast wind
#

Alr thanks

distant gulch
#

Why am I getting this error?

halcyon phoenix
halcyon phoenix
fast wind
halcyon phoenix
vast grove
fast wind
#

Sorry but could you send some sort of code to let my dumb brain understand?

vast grove
#

think of it this way

Site -> MC: BufferedPacket on Site
MC -> Site: Returns BufferedPacket
fast wind
#

Ok I kinda understand then

#

I hope it works because I worked too much on this bullshit tbh

vast grove
#

I'm working on my own implementation. I just finished the MCWSS side though.

distant gulch
distant gulch
distant tulip
#

const angle = player.getRotation().y
assuming you are using the y angle for what ever that is

halcyon phoenix
#

you followed the value

#

on yours

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

world.beforeEvents.itemUse.subscribe(event => {
    const { source: player, itemStack: itemUsed } = event;
    const vectorXZ = {
        x: view.x,
        z: view.z
    };

    if (itemUsed.typeId === "minecraft:feather") {
        system.run(() => {
            player.applyKnockback(vectorXZ, 0);
        });
    }
});
#

you should take note how vectors/objects work

distant gulch
fast wind
#

?

fast wind
distant gulch
fast wind
#

No problem I asked that question not long ago too

halcyon phoenix
#

Rcos(theta) & Rsin(theta)

#

multiplying works too don't add though

distant gulch
halcyon phoenix
distant gulch
halcyon phoenix
# distant gulch yes
import { world, system } from "@minecraft/server";
const cooldown = 0; //cooldown variable for counting
world.beforeEvents.itemUse.subscribe(event => {
    const { source: player, itemStack: itemUsed } = event;
    const vectorXZ = {
        x: view.x,
        z: view.z
    };
    // added a cooldown condition if 1 then trigger then sets it to 0
    if (itemUsed.typeId === "minecraft:feather" && cooldown == 1) {
        cooldown = 0;
        system.run(() => {
            player.applyKnockback(vectorXZ, 0);
        });
        //this timeout wiill run in 100 ticks or 5 seconds. 1 sec / 20 ticks
        system.runTimeout(() =>{
            cooldown = 1;
        }, 100)//100 in TICKS
    }
});
distant gulch
#

const cooldown = 0; //cooldown variable for counting

world.beforeEvents.itemUse.subscribe(event => {
    const { source: player, itemStack: itemUsed } = event;
    const view = player.getViewDirection();
    const vectorXZ = {
        x: view.x * 4.5,
        z: view.z * 4.5
    };
    // added a cooldown condition if 1 then trigger then sets it to 0
    if (itemUsed.typeId === "minecraft:feather" && cooldown == 1) {
        cooldown = 0;
        system.run(() => {
            player.applyKnockback(vectorXZ, 0.5);
        });
        //this timeout wiill run in 100 ticks or 5 seconds. 1 sec / 20 ticks
        system.runTimeout(() => {
            cooldown = 1;
        }, 100)//100 in TICKS
    }
});``` here's the code
halcyon phoenix
#

change const cooldown to let cooldown

#

that should work

distant gulch
#

thanks

#

hmm....

distant gulch
# halcyon phoenix change `const cooldown` to `let cooldown`

let cooldown = 0; //cooldown variable for counting

world.beforeEvents.itemUse.subscribe(event => {
    const { source: player, itemStack: itemUsed } = event;
    const view = player.getViewDirection();
    const vectorXZ = {
        x: view.x * 4.5,
        z: view.z * 4.5
    };
    // added a cooldown condition if 1 then trigger then sets it to 0
    if (itemUsed.typeId === "minecraft:feather" && cooldown == 1) {
        cooldown = 0;
        system.run(() => {
            player.applyKnockback(vectorXZ, 0.5);
        });
        //this timeout wiill run in 100 ticks or 5 seconds. 1 sec / 20 ticks
        system.runTimeout(() => {
            cooldown = 1;
        }, 100)//100 in TICKS
    }
});``` Sorry it still doesn't work 😦
fast wind
#

The 4° line should be
let cooldown = 1

#

I think

distant gulch
fast wind
#

Np

halcyon phoenix
livid elk
#

is it possible to lock or disable a specific hotbar slot? for example, if I lock slot 8 and the player presses the number 8 key, it won’t let them select that slot

cyan basin
prisma shard
# livid elk is it possible to lock or disable a specific hotbar slot? for example, if I lock...

Ok so you mean to disable the 8th slot?
By doing:

player.selectedSlotIndex = 1

(This will force you to always be in the 2nd slot)```
So, You can do this logic:
Detect if you've moved to the 8th slot, then save the last slot you were on.
Then if you try to get to 8th slot, at the same tick, force it to select the slot  you were on which we saved. This will make it never able to choose slot 8 by always forcing player to not get to move the  slot he is on.
livid elk
#

oh okay i see, thank you!

summer path
#

does anyone know why my script doesn't work

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

world.afterEvents.itemCompleteUse.subscribe((event) => {
  const { itemStack: item, source } = event

  if (item?.typeId === "pezzacraft:pizza") {
    source.addEffect("minecraft:health_boost", 100, { amplifier: 1, showParticles: false })
    source.addEffect("minecraft:instant_damage", 40, { amplifier: 5 })
  }
})
summer path
#

from the addon? sure

round bone
#

yeah

summer path
#

here

#

i took the code from a post in here

#

idk which one

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

world.afterEvents.itemCompleteUse.subscribe((event) => {
  const { itemStack: item, source } = event

  console.log(item.typeId)
  if (item.typeId === "pezzacraft:pizza") {
    source.addEffect("minecraft:health_boost", 100, { amplifier: 1, showParticles: false })
    source.addEffect("minecraft:instant_damage", 40, { amplifier: 5 })
  }
})
#

could you check if it logs anything?

summer path
#

checking

#

its jsut cape errors

#

from a skinpack

#

nothing else

round bone
#

also, item will be always defined in this event, so you don't have to use nullify operator

round bone
summer path
round bone
#

I mean, you want to make it act like a food

#

are you holding it for 1.6 seconds?

summer path
#

api version? i used blockbench to make this

round bone
#

API version does not really matter in this case

summer path
#

i ate it fully

#

trying your version

round bone
#

hmmm, pretty weird

#

maybe try using this

summer path
#

trying the code you gave me

#

then i'll try that if this doesn' twork

#

nope

#

how do i even do this i have no idea on what i'm doing

#

what did i do wrong here

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

world.afterEvents.onConsume.subscribe((event) => {
  const { itemStack: item, source } = event

  console.log(item.typeId)
  if (item.typeId === "pezzacraft:pizza") {
    source.addEffect("minecraft:health_boost", 100, { amplifier: 1, showParticles: false })
    source.addEffect("minecraft:instant_health", 40, { amplifier: 5 })
  }
})

Would this work @round bone

#

Apperantally not

#

Ig i can't

open urchin
summer path
#

Ok

true isle
#

So trying to update my scripts and block jsons currently having issues when using the components it tells me that version for the data loaded is wrong but when the script is not on the block its fine. Does that mean the script is broken?

summer path
#

pls work 🙏

summer path
#

is this experimental

open urchin
#

it needs @minecraft/server v2.0.0

summer path
#

is that the beta api?

open urchin
#

no

summer path
#

i'm on newest game version

open urchin
#

you don't have the script module or dependency in your BP manifest

summer path
#

what?

#

how do i add it?

jagged gazelle
#

-# pathetic ahh plug.

summer path
#

Ok

open urchin
# summer path how do i add it?
{
    "format_version": 2,
    "header": {
        "name": "Pezzacraft Addon",
        "description": "Pezzacraft Addon Behavior Pack",
        "uuid": "85d22d47-9a5b-856e-e6f4-19850f00fd28",
        "version": [1, 0, 0],
        "min_engine_version": [1, 20, 0]
    },
    "metadata": {
        "authors": ["qAustriaaa (@qaustriaaa)"],
        "generated_with": {
            "blockbench_item_wizard": ["1.2.1"]
        }
    },
    "modules": [
        {
            "description": "Behavior",
            "version": [1, 0, 0],
            "uuid": "feb55407-756c-e5e2-842c-bf2719abda4c",
            "type": "data"
        },
        {
            "type":"script",
            "language": "javascript",
            "entry": "index.js",
            "uuid":"bcb4a18c-8815-4354-a00a-e14fdfa9746d",
            "version": [1, 0, 0]
        }
    ],
    "dependencies": [
        {
            "uuid": "77a6cc9b-3bf0-f22c-30cc-430562e13870",
            "version": [1, 0, 0]
        },
        {
            "module_name": "@minecraft/server",
            "version": "2.0.0"
        }
    ]
}```
summer path
#

sorry for being dumb

#

ty

#

ty

#

nothing happened

#

it is

open urchin
#

send the item json?

summer path
#

Ok

#
{
  "format_version": "1.20.50",
  "minecraft:item": {
    "description": {
      "identifier": "pezzacraft:pizza",
      "menu_category": {
        "category": "nature",
        "group": "itemGroup.name.crop"
      }
    },
    "components": {
      "minecraft:max_stack_size": 64,
      "minecraft:icon": {
        "texture": "pizza"
      },
      "minecraft:enchantable": {
        "slot": "sword",
        "value": 1
      },
      "minecraft:food": {
        "nutrition": 14,
        "saturation_modifier": 1.4,
        "can_always_eat": true,
        "effects": [
          {
            "name": "health_boost",
            "duration": 100,
            "amplifier": 1,
            "chance": 1.0
          },
          {
            "name": "instant_health",
            "duration": 40,
            "amplifier": 5,
            "chance": 1.0
          }
        ]
      },
      "minecraft:use_modifiers": {
        "movement_modifier": 0.32,
        "use_duration": 1.6
      },
      "minecraft:use_animation": "eat",
      "minecraft:cooldown": {
        "duration": 3,
        "category": "item_wizard"
      }
    }
  }
}
open urchin
#

you aren't using wiki:food_effects (btw you need to change wiki to pezzacraft)

summer path
#
itemComponentRegistry.registerCustomComponent("pezza:food_effects", ItemFoodEffectsComponent);```
#

this?

open urchin
#

yes

summer path
#

craft*

open urchin
#

and update to format 1.21.90 and update the icon component:

"minecraft:icon": "pizza"
summer path
#

and this

open urchin
#

if there's a }, on the next line you need to remove that and add a comma after "pizza"

summer path
#

oh mb

#

i frogot how json worked

#

😭

#

WHY

#

yeah i give up

#

@open urchin do you know any fixes

open urchin
#

the first error means your json file is invalid
you might have missed a comma or bracket somewhere

summer path
#
{
  "format_version": "1.21.90",
  "minecraft:item": {
    "description": {
      "identifier": "pezzacraft:pizza",
      "menu_category": {
        "category": "nature",
        "group": "itemGroup.name.crop"
      }
    },
    "components": {
      "minecraft:max_stack_size": 64,
      "minecraft:icon": "pizza",
      },
      "minecraft:enchantable": {
        "slot": "sword",
        "value": 1
      },
      "minecraft:food": {
        "nutrition": 14,
        "saturation_modifier": 1.4,
        "can_always_eat": true,
        "food:effects": [
          {
            "name": "health_boost",
            "duration": 100,
            "amplifier": 1,
            "chance": 1.0
          },
          {
            "name": "instant_health",
            "duration": 40,
            "amplifier": 5,
            "chance": 1.0
          }
        ]
      },
      "minecraft:use_modifiers": {
        "movement_modifier": 0.32,
        "use_duration": 1.6
      },
      "minecraft:use_animation": "eat",
      "minecraft:cooldown": {
        "duration": 3,
        "category": "item_wizard"
      }
    }
  }
}
open urchin
#

the }, shouldn't be there

summer path
#

i didn't put that there

#
{
  "format_version": "1.21.90",
  "minecraft:item": {
    "description": {
      "identifier": "pezzacraft:pizza",
      "menu_category": {
        "category": "nature",
        "group": "itemGroup.name.crop",
      }
    },
    "components": {
      "minecraft:max_stack_size": 64,
      "minecraft:icon": "pizza",
      "minecraft:enchantable": {
        "slot": "sword",
        "value": 1
      },
#

now?

open urchin
#

"itemGroup.name.crop" -> "minecraft:itemGroup.name.crop"

summer path
#

okay

open urchin
#

food:effects doesn't exist in the food component, you need to use the custom component instead

"minecraft:food": {
  "nutrition": 14,
  "saturation_modifier": 1.4,
  "can_always_eat": true
},
"pezzacraft:food_effects": [
  {
    "name": "health_boost",
    "duration": 100,
    "amplifier": 1
  },
  {
    "name": "instant_health",
    "duration": 40,
    "amplifier": 5
  }
]
summer path
#
    "minecraft:food": {
      "nutrition": 14,
      "saturation_modifier": 1.4,
      "can_always_eat": true
    },
    "pezzacraft:food_effects": [
      {
        "name": "health_boost",
        "duration": 100,
        "amplifier": 1
      },
      {
        "name": "instant_health",
        "duration": 40,
        "amplifier": 5
      }
    ]
``` done
#
{
  "format_version": "1.21.90",
  "minecraft:item": {
    "description": {
      "identifier": "pezzacraft:pizza",
      "menu_category": {
        "category": "nature",
        "group": "minecraft:itemGroup.name.crop",
      }
    },
    "components": {
      "minecraft:max_stack_size": 64,
      "minecraft:icon": "pizza",
      "minecraft:enchantable": {
        "slot": "sword",
        "value": 1
      },
    "minecraft:food": {
      "nutrition": 14,
      "saturation_modifier": 1.4,
      "can_always_eat": true
    },
    "pezzacraft:food_effects": [
      {
        "name": "health_boost",
        "duration": 100,
        "amplifier": 1
      },
      {
        "name": "instant_health",
        "duration": 40,
        "amplifier": 5
      }
    ]
      },
      "minecraft:use_modifiers": {
        "movement_modifier": 0.32,
        "use_duration": 1.6
      },
      "minecraft:use_animation": "eat",
      "minecraft:cooldown": {
        "duration": 3,
        "category": "item_wizard"
      }
    }
  }
}
``` full json
open urchin
#

remove the } before the comma

summer path
#

this one?

open urchin
#

yes

summer path
#

done

#

any errors?

open urchin
#

I don't think so

summer path
#

Ok

#

I'll show the JS too

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

const ItemFoodEffectsComponent = {
    onConsume({ source }, { params }) {
        // Iterates over each object in the component's array.
        for (const { name, duration, amplifier } of params) {
            source.addEffect(name, duration, { amplifier });
        }
    },
};

system.beforeEvents.startup.subscribe(({ itemComponentRegistry }) => {
    // Register the custom component for use in the item JSON file:
    itemComponentRegistry.registerCustomComponent("pezzacraft:food_effects", ItemFoodEffectsComponent);
});
#

Any errors in this?

open urchin
#

no

summer path
#

Ok.

#

lets see..

#

why

open urchin
#

oh there's a comma after your menu category group

summer path
#

JSON or JS

open urchin
#

json

summer path
#

ok

#

i added a comma

round bone
summer path
#

i jhave no idea on what i'm doing

#

like this?

round bone
#

😭

summer path
#

@open urchin is it fixed or not??

open urchin
#

things at the end of a json object (before a }) shouldn't have a comma after them

summer path
#

what?

#

so i remove the other comma

#

?

#

like this

open urchin
#
        "description": {
            "identifier": "",
            "menu_category": {
                "category": "",
                "group": ""
            }
        },
summer path
#

why does notepad++ do this

open urchin
#

idk i use vscode

summer path
#

discord did the same

#

bruh

#

can u send me a JSON if u can?

#

@open urchin i removed the comma you removed

#

Yeah no i'm FUCKING DONE WITH THIS

prisma shard
#

dude see the wiki example

#

and you should know the JSON structure other than asking others, which comma or bracket to add/remove

thorn flicker
#

lmao

summer path
#

i gave up

prisma shard
#

never gonna give you up

summer path
#

well i retried one more time and got it

livid elk
#

how can i get the health value of the entity?

cyan basin
open urchin
cyan basin
#

No problem.. let me know if you do have any problems since I didn't do extensive testing with it

north frigate
#

I've tested runJob and I still don't understand it use
like why would I use it

valid ice
prisma shard
# north frigate I've tested runJob and I still don't understand it use like why would I use it

The runJob method runs a generator function in small steps over multiple ticks instead of all at once. This helps avoid performance spikes and watchdog termination in Minecraft scripts. You insert yield statements to pause and resume the function.

Example

function* job () {
    console.warn("hello")
    yield;
}

system.runJob( job() )

runJob doesn't act same for everything. Trust me, try breaking or filling a lot of blocks at once, compare with and without runJob, And just see the performance difference.

north frigate
#

thank you guys for your explanation <3

prisma shard
#

gguuguaga wlc

nova flame
#
export default function ShardUI(player) {
    const inventory = player.getComponent("inventory").container;
    const coins = getScore(player, "Shards");
    const form = new ActionFormData();
    form.title("§d§l-Enchant Shop-");
    form.button("Sharpness 3 Book \n§d10 Shards", "textures/items/book_written.png");
    form.button("Sharpness 5 Book \n§d30 Shards", "textures/items/book_written.png");
    form.button("Efficiency 3 Book \n§d10 Shards", "textures/items/book_written.png");
    form.button("Efficiency 5 Book \n§d30 Shards", "textures/items/book_written.png");
    form.button("Unbreaking 1 Book \n§d10 Shards", "textures/items/book_written.png");
    form.button("Unbreaking 3 Book \n§d30 Shards", "textures/items/book_written.png");
    form.button("Protection 2 Book \n§d10 Shards", "textures/items/book_written.png");
    form.button("Protection 4 Book \n§d30 Shards", "textures/items/book_written.png");
    form.button("Fortune 1 Book \n§d10 Shards", "textures/items/book_written.png");
    form.button("Fortune 3 Book \n§d50 Shards", "textures/items/book_written.png");
    form.button("Mending Book \n§d200 Shards", "textures/items/book_written.png");
    form.show(player).then((response) => {
        if (response.selection == 0) {
            if (coins >= 10) {
                removeScore(player, "Shards", 10);
                const item = new ItemStack("enchanted_book", 1);
                const enchantability = item.getComponent("enchantable");
                enchantability.addEnchantment({ type: new EnchantmentType("sharpness"), level: 3 });
                inventory.addItem(item);
                player.sendMessage("§aPurchase Complete!");
                player.playSound("note.pling", { location: player.location });
            } else {
                player.sendMessage("§cNot Enough Shards!");
                player.playSound("note.bass", { location: player.location });
            }
        }```
#

why does this take the score but not give the item??

livid elk
#

is it possible to increase the maximum health/attack dmg of an entity using script?

distant tulip
#

if it doesn't have a max value

#

it throw ArgumentOutOfBoundsError otherwise

jagged gazelle
#

Is there a way to detect dismount in touch controls.

cinder shadow
jagged gazelle
distant tulip
#

what about the event?

cinder shadow
jagged gazelle
#

No errors?

#

Where are you running it?

nova flame
jagged gazelle
jagged gazelle
#

I meant the sneak, the jump still works the same.

#

why... 😭

nova flame
#

its a ui

jagged gazelle
#

How will you get the time if you ain't running the function?

#

Where'd you even get the player instance

distant tulip
#

put a log message there

minor horizon
#

I think dimension.getBlockFromRaycast is broken in 2.0.0, the ray is only colliding with the bottom and northwest sides. I made a script that ricocheted a vector off teh surfaces, but now it phases through the block.

cinder shadow
#

Has anyone gottem container.find() to work? I'm assuming it looks for an exact, 1:1 copy of the itemStack

#

I keep trying to use it to search for a stack of items

ripe drift
#

Is it possible to make a bunch of transparent images/glyphs/text stack on top of eachother in a text field?

final ocean
#

How to get a book with enchantment

jagged gazelle
jagged gazelle
final ocean
jagged gazelle
# final ocean Is there sample code?
import { ItemStack, EnchantmentType } from '@minecraft/server';

const book = new ItemStack('minecraft:enchanted_book');
const enchant = book.getComponent('enchantable');
enchant.addEnchantment({ type: new EnchantmentType('unbreaking'), level: 3 });```
jagged gazelle
cinder shadow
#

what does chatGPT mean by this

woven loom
#

maybe devs using gpt?

cinder shadow
#

hrrrmm

tardy pivot
#

can I get the type of block of a falling block entity?

final ocean
ripe drift
#

Did you ever figure this out

cyan basin
distant gulch
#

How can i take real life hour, day and month trough script

warm mason
livid elk
#

how to get the biome where the player is currently located?

minor horizon
open urchin
drifting pollenBOT
open urchin
#

there is no way to get a fully accurate value afaik

dense sun
#

can we obtain armor resistance?

jagged gazelle
minor horizon
#

Gotchu, makes sense to be a face location issue rather than the ray itself. Makes correcting for the big easier at least

jagged gazelle
minor horizon
#

To get the exact location of the ray impact on the block. So I added the face location and block location vectors, and used the face it collided with to get a normal vector for reflection. It worked fine for many updates until I updated to 2.0.0

#

I'd show how it works in-game but I'm at work

jagged gazelle
#

I might try to find a way to fix it... since I did it with my chess one that the piece's isn't properly placed when moving the block in xz direction

minor horizon
#

Let's dm then

jagged gazelle
#

but it's only in top face, I haven't tested it yet on sides.

minor horizon
#

The normal vector calculation I have is just an object index with the directions

export const faceDirectionVector = {
    'Up': {x:0,y:1,z:0},
    'Down': {x:0,y:-1,z:0},
    'North': {x:0,y:0,z:-1},
    'South': {x:0,y:0,z:1},
    'East': {x:1,y:0,z:0},
    'West': {x:-1,y:0,z:0}
}
jagged gazelle
minor horizon
#

it isn't, the reflection vectors are working as intended, it's just the location of the collision isn't

location = Vector3.Add(raycastReturn.hit.faceLocation,raycastReturn.hit.block.location)
#

so on specific directions the ray collides with the back side of the block and phases through the rest of it

#

or at least, the face location it gives is on theback side of the block

livid elk
#

is it still in beta?

warm mason
livid elk
#

aw

minor horizon
#

there's a more manual way using molang and environment triggers

#

but it's unreasonable if you want to use like all biomes instead of a few specific ones

tardy pivot
#

boink

jagged gazelle
minor horizon
#

? the faceLocation is a coordinate relative to the block location, if I did just the faceLocation then all the locations would end up around the world origin

warm mason
#

In new versions faceLocation became relative to the block

minor horizon
#

It's been that way for a while I feel. I wrote the original script 8+ months ago and it's been working ever since 2.0.0

#

leads me to believe it's a bug rather than a rework

warm mason
minor horizon
#

I believe you, it was probably before 1.13.0 for the api bc that's when I wrote it

open urchin
minor horizon
open urchin
#

I'm pretty sure it's impossible to correct fully

tardy pivot
#

is faceLocation youre trying to get?

minor horizon
#

I'll look into it. I quickly tested to see if the face returns are correct, and they are. Meaning I can isolate to the Top, South, and West sides of the block which is where the issue happens. Then just translate the incorrect faceLocation returns and it should work.

tardy pivot
minor horizon
#

the issue is that the face location is translating improperly on the top, south, and west sides of blocks since 2.0.0

#

otherwise it works fine

jagged gazelle
jagged gazelle
open urchin
#

and values of 1 become 0

jagged gazelle
#

face location is somewhat broken... there's some complaints in reddit and bug track about this.

#

that's it's not truly relative to block as what they claimed

#

record the values of a single position if the block is place in xz, -xz, x-z, and -x-z of the block. Same face, just different locations

minor horizon
#

I fixed it with a correction

#
//vector correction due to faceLocation bug in 2.0.0
        let correctionVec = {x:0,y:0,z:0}
        const correctionDir = ['Up','South','West']
        if(correctionDir.includes(raycastReturn.hit.face)) {
            correctionVec = c.faceDirectionVector[raycastReturn.hit.face]
        }
#

the correction vector is now added to the faceLocation and it works as intended

#

there's still an issue which depends on if the coordinate is positive or negative but that should also be fixable

#

nvm I just thought it was west instead of east

#

replacing West with East fixed it

distant tulip
#

it is relative to the world origin

#

so there is like 8 states
x y z
-x y z
x -y z
x y -z
-x -y z
x -y -z
-x y -z
-x -y -z

#

it give you diffrent value depending on if you are in a negative axes or not

distant tulip
#

if i am not wrong, this should fix it

function getRelativePositionOriginal(faceLocation){
    return {
        x: faceLocation.x >= 0 ? faceLocation.x : 1 + faceLocation.x,
        y: faceLocation.y >= 0 ? faceLocation.y : 1 + faceLocation.y,
        z: faceLocation.z >= 0 ? faceLocation.z : 1 + faceLocation.z
    }
}

distant tulip
#

hmm, something is wrong

jagged gazelle
distant tulip
#

ok this seem to work

function getRelativePosition(faceLocation, blockLocation){
    return {
        x: blockLocation.x >= 0 ? faceLocation.x : 1 - faceLocation.x,
        y: blockLocation.y >= 0 ? faceLocation.y : 1 - faceLocation.y,
        z: blockLocation.z >= 0 ? faceLocation.z : 1 - faceLocation.z
    }
}
ripe drift
cyan basin
# ripe drift Dang. Really wish we could enable it

Yeah there's honestly so much I feel like we're missing out on with BDS.. such as this new certificate thing that was added recently (may have no use but why do we see it), being able to host your resource pack off of the server via the cdn config isn't documented (can somewhat get it working but it's still not easy, has too many issues) and then we can't easily enable experiments (you'd expect to be able to enable/disable it in the properties like you can with vibrant visuals)

#

I'm sure there's plenty more stuff that we don't have access to yet, that's actually there just not documented..

ripe drift
#

I do wonder what else is hiding

cyan basin
#

you mean like the terminal permission level that doesn't work anywhere but exists? i think that is just there for the terminal but i do wonder why it's visible to us if it can't be used

ripe drift
#

like /shutdown on a server

cyan basin
#

Oh that's something in the properties? I actually didn't know that..

#

Doesn't that allow all clients to use it though?

open urchin
#

it allows "Operator" players to use it

cyan basin
#

Well yeah I kinda figured that but that would definitely then require you to make custom staff tools to avoid giving out operator to anyone who shouldn't be near it

#

But yeah, I do wonder what else is lying around that we don't have

alpine wigeon
#

how do i get the type of the block that was just broken in a custom component

open urchin
alpine wigeon
#

[Scripting][error]-TypeError: cannot read property 'type' of undefined at onPlayerDestroy (main.js:60)

open urchin
#

it's destroyedBlockPermutation in v1

alpine wigeon
#

huh

#

oh

#

ok

#
if (block.north().type.id == destroyedBlockPermutation.type.id) {
  block.north().setType("air")
}
#

how do i make it run on more blocks

#

when i break it, it should break all connected ones in a chain reaction

cyan basin
#

cancelling packets via server-net seems to be going perfectly fine (totally no problems)

#

tried cancelling the "ChangeDimension" packet and it moved me to the new portal after walking away from the original one and randomly placed real but fake lava?

#

nice.. I restarted the server and spawned in the nether.. 💀 (it should never have loaded in the first place)

#

this is so fucking scuffed dviperClown dviperLaugh (i tried going back through the portal)

#

i tp'd 3 blocks up from -2 and it sent me down!? wtf is going on.. cancelling packets are so scuffed (at least the dimension change is)

snow jungle
#

OIf you where to tell a new coder 5 things, what would you tell them related to MCBE gametest development

jagged gazelle
#

Umm the maxDistance of getBlockFromRay() don't support less than 1??

#

I tried 0.5 and doesn't eork

distant tulip
#

Everyone searching for double jump scripts will see this and get so confused

prisma shard
#

that's like months old lol

#

I got trolled so hard I remember still

livid elk
#

how can i detect if player click f8/paperdoll toggle?

jagged gazelle
shut vessel
#

is it possible to clear the /me ?

nova flame
#
const item = new ItemStack("minecraft:enchanted_book", 1);
            item.getComponent("enchantable").addEnchantment({ type: new EnchantmentType("minecraft:mending"), level: 1 });
            item.nameTag = "Mending Book";``` how would i make this give bottles of strength for example??
cinder shadow
#

I don't know if you can. Atleast not with the preferred scripting methods using ItemStack

#

There's no way to set data

#

actually, I'm wrong!

jagged gazelle
#

Is it possible to add collision to this? since tping mobs while me riding it acts like it's it doesn't have collision like it can't be drowned or suffocated...

#

and yes I tried Entity.tryTeleport() and checkForBlocks both didn't work.

cinder shadow
#

why are you using teleport for movement and not knockback?

jagged gazelle
#

I found a way already lol

cyan basin
unreal geyser
#

Does player.getViewDirection not exist anymore… I can’t see it in the documentation

unreal geyser
#

Weird

fallow minnow
jagged gazelle
#

i normalized a normalized vector.

#

wtf

woven loom
#

🫡

lethal bramble
halcyon phoenix
summer path
#

especially on json uis

north frigate
#

is there a way to check if a player is op outside of the beta module

cyan basin
#

Herobrine's Chest UI --> I now have support for enchants, custom names and 'open' and 'close' sounds to imitate a real chest. Only thing left to add is the support for potions (will only have lore support, icon will remain the same).

round bone
#

There is a new permission system

round bone
cyan basin
#

It's not a fork at the moment but I'm also not planning on keeping this to myself dviperThumbsUp

#

The only downside at the moment is there is a significant delay when having the inventory enabled even with all forms disabled. It's just an issue with having the inventory enabled due to the amount of buttons being added. Also, the scripting is slightly different when adding the chest audio.

#
import { Player, world } from '@minecraft/server';
import { ChestFormData, playChestClosed } from './ChestForm/main';

async function page1(player: Player, isInitialOpen = false): Promise<void> {
    const form = new ChestFormData('27');

    form.title('Chest #1');
    form.button(13, 'Item #1', [], 'minecraft:apple', 64, 0, true);

    // Add 'chestopen' sound to the Chest Form when it first opens and when you close out of it (via the 'E' key, the close button or, the 'ESC' key)
    const { canceled, selection } = await form.show(player, { playOpenSound: isInitialOpen, playCloseSound: true });

    if (canceled) return;

    switch (selection) {
        case 13:
            return page2(player);
            break;
    }
}

async function page2(player: Player): Promise<void> {
    const form = new ChestFormData('27');

    form.title('Chest #2');
    form.button(13, 'Item #2', [], 'minecraft:iron_sword', 1, 50, false);
    form.button(18, '§cBack', [], 'minecraft:barrier', 1, 0, false);

    // Only add 'chestclose' sound as we don't want to play the 'chestopen' sound on each page
    const { canceled, selection } = await form.show(player, { playCloseSound: true });

    if (canceled) return;

    switch (selection) {
        case 13:
            await playChestClosed(player); // Play 'chestclose' sound on final button (final = button that does not open into another Chest Form)
            break;
        case 18:
            return page1(player);
    }
}

world.afterEvents.itemUse.subscribe(({ itemStack: item, source }) => {
    if (item.typeId !== 'minecraft:chest') return;

    const player = source as Player;

    page1(player, true);
});```
#

It does require an extra import for the chestClose sound for final buttons but other than that the sounds are built in to the chest form script itself and applied using form.show(player, { playOpenSound: isInitialOpen, playCloseSound: true });.

warm drum
#

is there any documentation on 1.19.0 scripting api

#

i tried stirante website but it removed everything

cyan basin
#

The oldest is 1.19.5

distant tulip
#

Why not use v2

warm drum
distant tulip
#

Like?
Most stuff can be fixed easily

livid elk
#

what's the proper way to run multiple title to update preserve text?

player.onScreenDisplay.setTitle(`update:rpg:coin:§l§g ${playerCoins}`);
player.onScreenDisplay.setTitle(`update:rpg:gem:§l§b ${playerGems}`);
player.onScreenDisplay.setTitle(`update:rpg:lvl:Level: ${playerLevel}`);
player.onScreenDisplay.setTitle(`update:rpg:xp:XP: ${playerXP}`);
player.onScreenDisplay.setTitle(`update:rpg:mana:${manaBar}`);
jagged gazelle
#

combine them in one string...

livid elk
#

this is what happen if i do that

jagged gazelle
#

or you can do '\n'

jagged gazelle
# livid elk this is what happen if i do that
player.onScreenDisplay.setTitle(`update:rpg:coin:§l§g ${playerCoins}\nupdate:rpg:gem:§l§b ${playerGems}\nupdate:rpg:lvl:Level: ${playerLevel}\nupdate:rpg:xp:XP: ${playerXP}\nupdate:rpg:mana:${manaBar}`);
#

instead of being in one like like that in image it should go.

coin
gem
lvl
xp
mana```
livid elk
#

the way I set it up to update my elements is by running it separately
/title @s title update:rpg:coin: coin like this. how can i add a bit of delay on the onScreenDisplay i sent?

jagged gazelle
#

it's better you edit the json UI a bit.

#

So you can send one total that contains your needed UI values

livid elk
#

that's what im using before

player.onScreenDisplay.setTitle(
    `coin:§l§g ${playerCoins}§r`.padEnd(50, '\t') +
    `gem:§l§b ${playerGems}§r`.padEnd(50, '\t') +
    `lvl:Level: ${playerLevel}§r`.padEnd(50, '\t') +
    `xp:XP: ${playerXP}/300§r`.padEnd(50, '\t') +
    manaBar.padEnd(100, '\t') +
    compassBar.padEnd(180, '\t') +
    degreeLine.padEnd(500, '\t') +
    (
        `             §6§lq:Quest§r\n\n` +
        `  §s§lActive Quest:§r\n` +
        `  ${questTitle}\n\n` +
        `  §8${questObjectives}\n\n` +
        `  §2${requiredItem}\n\n` +
        `  §sRewards:\n` +
        `  ${questRewards}\n\n`
    ).padEnd(50, '\t')
);

but anyway, i already fixed it, thank!

livid elk
sly valve
livid elk
#

i only use this in the blockception vscode extension for coding json ui and other stuffs

tardy pivot
#

BlockVolume is fun

sly valve
#

Yep

warm drum
#

do u guys know where we can ask for scriptapi feature?

#

the sign block component is lacking the glow ink method

prisma shard
tardy pivot
#

I hope we get events like when redstonePower changes and send redstonePower for custom blocks and things

vast rune
#

Is there any class that contains location information when a player places a block?

jagged gazelle
vast rune
#

k, ill just use player position

#

ty

nova flame
#
const item = new ItemStack("minecraft:enchanted_book", 1);
            item.getComponent("enchantable").addEnchantment({ type: new EnchantmentType("minecraft:mending"), level: 1 });
            item.nameTag = "Mending Book";``` how would i make this give bottles of strength for example??
cinder shadow
#

Did you ever read what I sent you

nova flame
#

yes

nova flame
#

what does this even mean

sly valve
#

Any ways to keep DynamicProperties after Changing the Addon?
I tried to Upload them temporary on a scoreboard objective. But then I need the script to work but what If the Addon is outdated due an new Minecraft update..

#

Any ideas?

cyan basin
#

I was just testing the original version and the inventory doesn't even work properly and this is what 5 slots looks like 💀

#

This is what my inventory actually looks like lol

#

I'll probably remove the 5 slot until it's fixed to look like a hopper and also delete the 1 slot and furnace ui since I don't see a use in those.. also because the 1 slot just sets a slot to the far left instead of in the middle (you would have to check for the flag in slot 1 and 5 and update the grid position and size for those uis)

#

I'll most likely add the pattern back though since I'm sure quite a few people actually do use that

#

I'd like to see a custom npc form though, that would be neat

prisma shard
#

coddys new pfp seems so bald

#

is that really you coddy

cinder shadow
true isle
#

how do the new params work for the custom components?

warm mason
open urchin
#

you can set the value of the component to a boolean/string/array/object/number

"hi:component": 10

params is the value of the component

onTick(event, { params }) {
  params // value is 10
}
warm mason
#

By the way, there is a limitation on the depth of json. That is, you can't do something like this:

"my:component": {
  "list": [
    {
      "id": "kajdfkadf",
      "value": 323
    }
  ]
}
cyan basin
#

It's done... dviperHappy (just need to write out all of the potions) dviperScared

warm mason
cyan basin
#

I'm adding potion support to Herobrine64's Chest UI...

cyan basin
#

I only need specific information

#

I could probably do this a much simpler way but.. it is what it is dviperShrug

warm mason
#

It will be "fun" if you want to make a translation for your addon)

true isle
buoyant canopy
#

Can we use script to place a block itemStack as a block in the world?
for instance if i have a chest with nbt data stored as an item stack, can i spawn it as a block in the world?

buoyant canopy
#

It seems my only option is to use structures...

warm mason
#

Why would you want to store something in a chest as an item?

buoyant canopy
#

I wanted to make an addon, where you could catch fishing crates, which are renamed barrels with loot table inside them, that turns out to be impossible, so i thought of making the player catch custom blocks, that look like a vanilla barrel, and when placed i would replace them with an actual barrel with a loot table inside. and since we can't convert an item stack into a block, i will have to save each barrel in a separate structure

#

instead of using my itemStack database

true isle
#

i mean you could just make a block drop whats on a loot table when broken

buoyant canopy
#

yeah, but i wanted the loot chest interface

warm mason
buoyant canopy
#

i thought of that, but /loot doesn't randomly offset the items

true isle
#

it should?

#

or am i wrong?

buoyant canopy
#

it places the items to the barrel in order

warm mason
buoyant canopy
#

is it a random loot offsetter?

warm mason
#

Well, I can share the offset function itself.

buoyant canopy
#

no thanks, i have also thought of that, and didn't feel like recreating a loot generator when vanilla has it built-in

#
  • using structures isn't too bad
warm mason
#

Well... okay

buoyant canopy
#

There is also the option of using a ticking function, to replace the custom blocks in the player inventory with the actual loot barrel...

warm mason
#

Or use the new event...

buoyant canopy
#

what new event?

buoyant canopy
#

oh! i didn't know about it

#

it's still in preview and beta-api though, it will take forever to release lol, i will switch to using it once it releases, thank you

livid elk
cyan basin
livid elk
#

ohhh

cyan basin
#

I’ve just been updating it to support missing/broken features

livid elk
#

that's what im trying to make earlier, chest style server form but i cant show the player inventory 🥲

tardy pivot
#

can you add velocity to a spawned ItemStack?

jagged gazelle
tardy pivot
#

ay nice

jagged gazelle
#

ok, do anyone knows how to remove the gravity of player properly? Player.clearVelocity() still makes the player fall like it makes it go back to old position but not stay

last herald
#

Set a player as operator?

sly valve
sly valve
jagged gazelle
last herald
rare dawn
#

What's this?

sharp elbow
#

Pseudocode for detecting entities that the player can see, with some stipulations. Read up on WavePlayz's message for more context on what it's doing

#

Technically it's casting a ray to the entity's feet, so there are situations where part of the entity can be visible and it still not be detected

sly valve
last herald
#

I need to give a player who joins in with member permissions, to be given operator.

sly valve
#

Ohh.. i thought your message i replied to was meant as an answer to Coddy..

#

My bad..

#

So basically after he joins check his playerPermissionLevel, if its member grand him Op woth player.setOp()

If im wrong take a look in the docs

solar dagger
#

so i have a block with storage. I set the permutation to air but drops its inventory. How can i avoid that?

inland merlin
harsh robin
#

wsp

edgy elm
#

Hello here, I just want to ask how can i make a high quality item texture. Cause considering a 16x16 pixels is so low. How can I make it high-quality?

edgy elm
warm mason
#

Well, and then use attachables. #1067869136606220288

edgy elm
untold magnet
#

hmmm, how am i going to detect when the weather is raining and the player is staying unde the rain?

#

similar to when the enderman take damage from rains, but for the player all using scripts

buoyant canopy
untold magnet
#

idk

buoyant canopy
#

but it doesn't differentiate between water or rain

#

alternatively you could cast a ray from the player head to build limit and check if there are any blocks between them

untold magnet
buoyant canopy
#
if (dimension.getBlockFromRay(player.location, {...player.location, y: 319}).block) return ```
untold magnet
#

i see

untold magnet
#

or having logs after getting a point that will detect blocks higher than the build limit

buoyant canopy
#

yes, so do an overworld check first

untold magnet
#

it wont rain anywhere else tho

buoyant canopy
#

or use dimension.heightRange.max

untold magnet
#

but wait

#

raining in the desert is not a thing

#

it doesn't rain in the desert, so doing that while the weather is raining will cause the script to do my things even while its not raining in the desert

wheat condor
#

can someone help? #1393543367396167751

buoyant canopy
untold magnet
buoyant canopy
#

That's the best way if you don't want to modify player.json

untold magnet
#

i dont feel like it tbh, that might and will cause some issues i believe, so keeping it normal is better i believe

#

what i can do:
detecting the topMost block and if its raining or not

#

if the conditions where right, it will spawn one entity at the player location that will despawn after 1s just to detect the biome type

buoyant canopy
untold magnet
#

if the biome was normal (not desert or hot biomes that doesn't rain inside) it will do my things

untold magnet
buoyant canopy
#

does your code constantly check if it's raining on the player, or does it do it in demand?

untold magnet
#

runInterval, yes.

#

i can limit the interval speed

#

like forcing it to run once every 3s or something

buoyant canopy
#

so what you want to do is:
spawn an entity, use the filter, to check if it's raining on it, do a system.run() to obtain a property, and delete it

untold magnet
#

like i can detect when it's raining to start the spawn interval and stop it when its not raining, the entity will detect if it has contact with rain or not to return a value to the script so the script can work and do my stuff,

buoyant canopy
buoyant canopy
#

It looks good, but how did the player eyes become a glass window?

untold magnet
buoyant canopy
#

You could use my biome detector addon, and modify it to check for rain instead of biomes

untold magnet
#

currently:
73% not adding it
27% adding it

#

cuz i don't really think it worth the time / the hard work
and it will make the addon looks like EnhancedVisuals from java, which might causes some issues ig

prisma shard
#

You should make it like detect when there is block on top of head, Even if it's raining, It should not wet the screen

#

Just detect if the area above players head is empty, and there is no roof, And just now detect if it's raining.

fallow minnow
cyan basin
#

I mean I said it was going to be public anyway but you do you pal

round bone
cyan basin
#

Yeah I get it, I'll just stop working on it and go do something else

#

I don't care

round bone
#

you're making their development stage easier by your library

#

I have wrote a library few weeks ago, and they're using it also

tender pier
#

how can i spaw a block with an specific state?

#

the block is placed but always facing south

#

and I don't know how to change it

distant tulip
#

setPermutation

tender pier
#

nv

#

i did it

#

thanks

jagged gazelle
#
const targetYaw = Math.atan2(
  isMoving ? lastView.x : lastView.x, 
  isMoving ? lastView.z : lastView.z
) * (180 / Math.PI);```

ts is stupid.
distant tulip
#

we really need a entityDismount event

wary edge
distant tulip
#

i can't
marketplace add-on

#

runInterval is my only option here

prisma shard
#

So 1.11.0 stable API supports the latest Minecraft version right?

#

I mean, I know 1.19.0 is latest stable API, but I want to be sure that 1.11.0 works too?

thorn flicker
#

except for past beta versions

inland merlin
#

Anyone know if i can dynamically stretch a particle?

#

With scripts

#

I havent really looked into it

warm mason
inland merlin
#

Ive dynamically spawned particles for landclaim already, but i have a nice custom particle thats a wall i want to stretch if the claim changes, i can respawn the particle

#

No issues there

#

Do i just use script or do I need to modify the json of the particle

warm mason
#
import { MolangVariableMap } from "@minecraft/server";

{
    const map = new MolangVariableMap();
    map.setFloat('name', 15);
    dimension.spawnParticle('my:particle', { x: 0, y: 0, z: 0 }, map);
}
inland merlin
#

?

#

I was thinking we needed to add some form of json changes thank you!

warm mason
inland merlin
#

Awh there we go lol

#

That's perfect thank you

inland merlin
warm mason
inland merlin
solar dagger
warm mason
leaden elbow
#

PlayerPlaceBlockBeforeEvent on experimental only?

leaden elbow
#

one last thing how can i calculate player's distance travelled (in blocks)

thorn flicker
#

oh, how

#

when the player starts to move, get the block at the player's location, save the location of it, and when the player stops moving, do the same.
then calculate the distance between these 2 locations.

leaden elbow
#

i see thanks

thorn flicker
#

np

gusty bramble
#

Can someone help me make a particle trail for minecarts that spawns a particle at the charts location every gt and the particle can change colour based on a few things

Yellow = acceleration to 8 m/s
green = terminal velocity (8 m/s)
red = deceleration

jagged gazelle
abstract cave
#
  const durability = player
    .getComponent("minecraft:equippable")
    .getEquipment(EquipmentSlot.Mainhand)
    ?.getComponent("minecraft:durability").damage;

im damage an item, but its telling me that it failed to get damage property

abstract cave
#
    at <anonymous> (essentials/ultramine.js:56)```
#

i get this when i call it in before events

#

but when i use system.runTimeout to do so, it sends an error saying that it failed to get damage property

inland merlin
#

durability?

inland merlin
halcyon phoenix
verbal yew
#

Were hav i messd up at

world.beforeEvents.playerInteractWithBlock.subscribe(event => {
  const player = event.player;
  const block = event.block;
  if (!block) return;

  if (
    block.location.x !== cratePosition.x ||
    block.location.y !== cratePosition.y ||
    block.location.z !== cratePosition.z
  ) return;

  if (block.typeId !== crateBlockTypeId) return;

  showCrateMenu(player);
  event.cancel = true;
});
#

it says it cant show the ui dose not have the privilege

valid ice
#

Before events cannot modify the world at all

verbal yew
#

do i use after

#

ok i got it

#

been a min sence i coded

valid ice
#

Yes, or delay the UI open using system run

woven loom
#

hey do we need rp to use translation

verbal yew
valid ice
#

For that you would need to use before event with cancel

verbal yew
#

ok

verbal yew
halcyon phoenix
#

can you show how you modify it?

abstract cave
abstract cave
halcyon phoenix
#
const durability = itemUsed.getComponent("durability");
durability.damage += 1;

this should modify it

abstract cave
#

ok

#

cant test it rn

verbal yew
#

im slwo what is wrong here it

warm mason
# verbal yew

Why use runInterval just to count ticks, which is only used to count ticks?

#

By the way, Dimension.spawnEntity always returns Entity so the test for it being != undefined is useless, you should use try/catch.

#

Also, the tier T is useless, since score cannot be greater than 2.147... billion

#

calling runCommandAsync to trigger the event to remove the entity is a bad idea. Just use Entity.remove()

#

Otherwise everything should work, but since you didn't say anything about the problem, I can't say more.

halcyon phoenix
#

wth this still works at 1.21.93? I thought it was "2.1.0-beta" im confused

#

guys where's the guide to install node and npm packages? I forgot how

honest magnet
#

npm install @minecraft/server

honest magnet
# halcyon phoenix wth this still works at 1.21.93? I thought it was "2.1.0-beta" im confused

Using tools for enhanced editing, debugging, and profiling of JavaScript within Visual Studio Code

halcyon phoenix
honest magnet
#

wow

halcyon phoenix
#

lol I don't know why that beta works...

#

oh wait

#

LOL

#

sorry

#

wrong file

#

I was looking at the wrong file

honest magnet
#

💀

gaunt salmonBOT
halcyon phoenix
#

what should I do?

#

npm.ps1 cannot be loaded because running scripts is disabled on this system.

#

followed this and it works now

halcyon phoenix
# prisma shard ^
npm i @minecraft/server@beta
npm i @minecraft/server-ui@beta

this downloads all right?

open urchin
#

oh nvm

halcyon phoenix
#

oh there's that solution too

#

are they the same?

prisma shard
#

huh

halcyon phoenix
halcyon phoenix
prisma shard
#

Probably latest beta

tame helm
#

can I use script-api to switch player inventory?

tame helm
#

I'm new to JS/TS. Should I use TS or JS

jagged gazelle
nova flame
#

switch in the future if u want to

verbal yew
wary edge
verbal yew
tame helm
#

can you turn off auto save?

round bone
tame helm
#

the actual saving system :c

round bone
#

😭

tame helm
#

do BDS allow changing anything to it?

round bone
tame helm
abstract cave
#
    at <anonymous> (essentials/ultramine.js:59)
#
export function damageItem(durability, amount, player, item, inventory) {
  durability += amount;
  inventory.setItem(0, item)
}
#

Idk why i get this error

#

it was working as normal before

tame helm
#

can I make other players have my camera?

#

oh btw, is there a way to extend the size of the dummy name in scoreboard? (to remove that ... thingy)

distant tulip
abstract cave
#

uhh

#

let me check rq

minor horizon
#

is there a way to get the target that an entity is currently pursuing in scripts (not in beta)? Or a way to set the target for an entity via scripts?

abstract cave
#
export function damageItem(durability, amount, player, item, inventory) {
  durability += amount;
  inventory.setItem(player.selectedSlotIndex, item)
}
deep quiver
#

pass in the component

abstract cave
#

im confused

#

i got the durability

#

from before events

#

and used a system.runTimeout to run the function that changes the durability

#

anyone?

distant tulip
# abstract cave im confused

what you are doing is editing a copy of the durability value.
pass the whole durability component to the function and use it inside

abstract cave
#

aight

#

done

#
    at <anonymous> (essentials/ultramine.js:59)```
warm mason
#

I understand that everyone has moved here.

#

Or not?..

warm mason
# abstract cave ```[Scripting][error]-TypeError: 'durability' is read-only at damageItem (ess...
/** @param {ItemStack} item */
function applyDurabilityDamage(item, damage = 1) {
  const durability = item.getComponent('durability');
  if (!durability) return item;

  const unbreakingLevel = item.getComponent('enchantable')?.getEnchantment('unbreaking')?.level ?? 0
  if (damage > 3) {
    damage *= (4 - unbreakingLevel) / 4
  } else if (unbreakingLevel >= 1 + Math.floor(Math.random() * 4)) {
    damage = 0
  }

  if (durability.maxDurability > durability.damage + damage) {
    durability.damage += damage
    return item
  }
}

Just use this

abstract cave
#

will it set the item?

warm mason
#
inv.setItem(0, applyDurabilityDamage(item))
abstract cave
#

thanks

safe stream
#

Is it not possible to setCurrentValue of an entity's health back to max if it hits min?

safe stream
#

nope, im using 2.0.0 and it says it's not a valid function

gaunt salmonBOT
jagged gazelle
#

There's no .resetToEffectiveMax() it's .effectiveMax lol... Sorrey

verbal yew
#

Dose some one know what to make wheat seeds turn to grown wheat with scripting

jagged gazelle
#

Goodbye destructing addiction hello ternary addiction. 😭😭

tender pier
#

how can I send a message to any player with an specific graphics mode?

woven loom
#

smokey can we use bp side translations

wary edge
wary edge
woven loom
#

ah

tame helm
#

Is there a way to turn off player hitbox?

unreal cove
#

Can we get the effect ID that is being added using EffectAddBeforeEvent? There's effectType in it but for some reason it returns the translated string rather than the ID

harsh robin
unreal cove
prisma shard
#

coddy everytime gets a sick pfp

rustic ermine
#

custom components + blockstates are cool. got regenerating ores working. doing a runescape 2007 server. Also has randomized chance to complete mining calculated on your skill level, the skill level required to mine it, a preset chance per block, and which pick is used

untold magnet
#

uhh, can the custom item components change the item stuff via scripts? like changing its damage or name or durability

fickle dagger
#

is there a native method to run scriptevent directly in js? or is it commands only?

fickle dagger
#

aw alright then

gaunt salmonBOT
prisma shard
round bone
jagged gazelle
#

There is actually just server only tho