#Script API General

1 messages · Page 112 of 1

shy leaf
#

uh

#

ok

#

ig

eager oriole
#

I just need the lightning bolt skill, so I can complete my mob

hazy kraken
thorn flicker
stark kestrel
#

is there no script native way to use the tickingArea command?

rare plume
warped kelp
#

-# These messages remind me of when I was new :D

stark kestrel
sly valve
eager oriole
sly valve
#

Okay great, if you need help with the code part, ask us
(Not for the whole code)

sly valve
meager zenith
#

Does anyone know how to use player.setRotation(), I am trying to use it but it's not working

distant tulip
#

it is locked for entities only

meager zenith
#

oh

#

thx

#

wait then why does it exists ??

distant tulip
#

🤷‍♂️

untold magnet
# sly valve Nice

btw, let currentValue = 'Default'; will never reset after leaving and rejoining the world, right?

#

like it will work similar to dynamicProperties, right?

distant tulip
#

no

#

whats in memory always reset after rejoin or /reload

sly valve
untold magnet
sly valve
#

Sure

untold magnet
#

yup, it is indeed bugged

untold magnet
#

lol

#

currentValue.includes(['Default', 'Cool']) is more than enough to fix the issue,

sly valve
#

I dont think includes works like that...

untold magnet
#

includes([array of values]);

sly valve
#

Hmm really? Let me check the docs

#

Nvm im busy

floral timber
#

it doesn't

untold magnet
#

but this one does ['Default', 'Cool'].includes(currentValue)

sly valve
#

Yes

hazy kraken
#

Is there a way to change the name of an NPC? I can't give it a name tag, and changing its display name doesn't change its acc entity.nameTag

hazy kraken
jolly citrus
#

is world.playMusic the same as world.playSound

#

seems that it isn't

#

so what is the equivalent of world.playSound now

thorn flicker
jolly citrus
#

ah thx

jolly citrus
#

can i remove xp from players

#

not levels, xp

fiery solar
jolly citrus
#

oh

#

i just did this

#

is it basically the same

#
const remainingXP = xpComp - price;
      player.resetLevel();
      player.addExperience(remainingXP);
#

i assumed it doesnt work with a negative number since /xp doesn't either

valid ice
cursive fog
#

Is there anyway to damage a durability using scripts?

safe stream
#

Why am I just finding out addExperience() is a thing. Is it a new method? (Or at least released to stable recently)

valid ice
timid zenith
#

A question what is the last manifesto of 1.21.101

cursive fog
valid ice
cursive fog
#

I need the thing to be used 6 times before it replace item(ill use json if possible)

dapper smelt
#

hi

dapper smelt
warped kelp
#

runCommandAsync can be used with await?

drowsy geyser
#

Quick question see how there are tags on a item like a pickaxe for example

How do I get / find the whole list of tags like I know stuff like wood stone iron\pick_diggable but where to find the list of options ?

devout sandal
#

Is there a way to add custom tags to blocks when they are placed? Or a good way to distinguish between generated blocks and player placed blocks?

devout sandal
#

would I have to add a custom state to every single block in the game?

wary edge
#

Yeah.

devout sandal
#

heck, ok thanks

prisma shard
#

use runCommand

#

and yes technicaly you can use await with anything

warped kelp
#

Alright thank you for clarifying

prisma shard
#

and put async in calllback (async => {
})

gaunt salmonBOT
final ocean
#
world.beforeEvents.chatSend.subscribe((event) => {
  const { message, sender } = event;
  if (!sender) return;

  if (message.startsWith("!cratekey ")) {
    event.cancel = true;

    const keyName = message.split(" ")[1];
    if (!keyName) {
      sender.sendMessage("§cDùng: !cratekey <tên>");
      return;
    }

    const inv = sender.getComponent("inventory")?.container;
    const selectedSlot = sender.selectedSlotIndex;
    let item = inv?.getItem(selectedSlot);

    if (!item || item.typeId !== "minecraft:tripwire_hook") {
      sender.sendMessage("§cCầm tripwire hook trên tay để thêm lore!");
      return;
    }

    const lore = item.getLore() || [];
    lore.push(`Crate: ${keyName.toLowerCase()}`);
    item.setLore(lore);

    inv.setItem(selectedSlot, item);

    sender.sendMessage(`§aĐã tạo tripwire hook thành key cho crate: §e${keyName}`);
  }
});

[Scripting][error]-ReferenceError: Native function [ItemStack::setLore] does not have required privileges. at <anonymous> (scripts/gacha.js:54)

How to fix ???

lethal bramble
#

means something is probably changing the world in a beforeevent or smth

#

ah classic error

#

Put a system run around the setlore

final ocean
lethal bramble
#

makes it run inthe nexts vailable time

cursive fog
lethal bramble
warped kelp
#

Nevermind, it's not fixed

unique dragon
#

I don't think this is the correct channel

prisma shard
warped kelp
#

Btw, are component group switching more laggy/resource using than scripts?

round bone
warped kelp
#

Yeah, makes sense

chilly fractal
#

is it possible to make client sided entities?

#

much like roblox doors's glitched rush, ambush and screech

#

i am implementing something close to it

#

by client sided, i mean that they can only be seen by a player, they can only attack/interact with that player, and no one else.

#

not strictly ran on the client, cuz that's impossible

#

any help would be very appreciated. (ps. sorry for grammer and other stuff, i am kinda in a rush)

wary edge
chilly fractal
#

i guess i can try to work with that

#

but i was really hoping for a different answer

chilly fractal
wary edge
chilly fractal
wary edge
#

Ibxtoycat showed off the capabilitites a while back.

distant tulip
#

just make an entity with a property and client sync set to true
than use setPropertyOverrideForEntity

chilly fractal
wary edge
chilly fractal
#

ah

distant tulip
#

render control, or animation

chilly fractal
#

what's the most performant?

distant tulip
#

i guess render controller

chilly fractal
#

hm, ok.

#

thank you both

#

have a great afternoon

distant tulip
#

you too

drifting ravenBOT
true isle
#

This is mine lol

woven loom
proper pumice
#

is there a way to actively check if the player is punching a block?

prisma shard
#

mine in potrait

safe stream
rigid torrent
#

Is there any better way to check when a block is touched by water that doesnt involves the scary ticking?

cinder shadow
#

Considering it would have to be ran on the block, no

safe stream
#

is setCooldown for items v2? im using v1 stable and im getting errors from using it

shy leaf
#

i think its also in v1?

pallid stag
#

Why doesn't it work???

wary edge
#

Open a post.

#

And please.

drifting ravenBOT
#
Please, no screenshots or photos!

Screenshots are hard to read, and photos even more so. This is especially true if you are using bridge or another tree editor, as this format obscures the JSON format.

We can help you best if you copy and paste your code here, or send it directly as a file.

safe stream
#

you havent defined health

const health = player.getComponent("health")```
Put it before the `player.sendMessage`
vast grove
#

Aaaahhhh. Abusing TS.

  public async SendInternalPacketAsync(
    packet: InternalPacket
  ): Promise<{ Packet: InternalPacket; Entity?: Entity }> {
    if (this._requests.has(packet.RequestId))
      throw new Error(
        `A request with the id ${packet.RequestId} already exists!`
      );

    this._requests.add(packet.RequestId);
    this._writer.Reset();
    packet.Serialize(this._writer);
    const data = Z85.GetStringWithPadding(
      this._writer.Data.slice(0, this._writer.Length)
    );
    system.sendScriptEvent(`vc:${packet.PacketType}`, data);
    return this.GetInternalPacketResultAsync(packet.RequestId);
  }

  private async GetInternalPacketResultAsync(
    requestId: string
  ): Promise<{ Packet: InternalPacket; Entity?: Entity }> {
    let result: { Packet: InternalPacket; Entity?: Entity } | undefined =
      undefined;
    const callback = (ev: { Packet: InternalPacket; Entity?: Entity }) => {
      if (ev.Packet.RequestId === requestId) result = ev;
    };

    this.OnInternalPacketReceived?.Subscribe(callback);
    while (result === undefined) {
      await system.waitTicks(1);
    }
    this.OnInternalPacketReceived?.Unsubscribe(callback);
    this._requests.delete(requestId);
    return result;
  }
warped kelp
#

Can I use a scriptevent on a custom mob from a different addon as long as the scriptevent used exists?

prisma shard
granite badger
nova flame
#

where do i ask about bedrock debugger

distant tulip
#

Or a post

nova flame
#

@distant tulipty

woven loom
#

@distant tulip u should update the link of hacker's keyboard

#

also there is no 2.2.0 in the ver list

distant tulip
#

I will look into it

full idol
#

Any ideas about a 10MB limit on dynamic property write speed? Keeps coming up in BDS logs

valid ice
#

can you send the message?

full idol
#

This is what it said. I'm guessing I know what it means, but it's none of my addons, though they probably contribute. There's a few addons used, some of which are... badly coded at best by others

woven loom
#

What do u want now tho

valid ice
#

That's a console warn, so... probably inside one of your packs somewhere?

shy leaf
#

how on earth did you even

#

go 21.5MB

#

with dynamic property alone

woven loom
#

Using a wrapper

distant tulip
#

is that a warning or an error tho
21 mb were saved last minute

woven loom
#

Just a warn

coral cypress
#

I just got back into scripting after months and months. First thing I try is apply knockback but it's not working. Did they change my favorite thing to do? What's different now?

#

It said to use an XZ vector

#

So I tried

#
const dir = player.GetViewDirection();
player.applyKnockback([dir.x, dir.z], 3);
#

to test

#

but it didn't work either

#

I am so out of practice 😭

coral cypress
valid ice
#

New format for apply KB is

applyKnockback({ x: x * hStrength, z: z * hStrength }, vStrength)
instead of applyKnockback(x, z, hStrength, vStrength)

coral cypress
#

([{x: dir.x, z:dir.z}], 3):

valid ice
#

No square braces

coral cypress
#

I'm not familiar with how that will change things

#

Is the change an improvement or is it worse?

#

😭

valid ice
#

If you translate it as above, there's no change

coral cypress
coral cypress
#

so normall I would do

#

(viewdir.x, viewdir.z, 2, 0)

#

but

#

that would js be

valid ice
coral cypress
#

({viewdir.x * 2, viewdir.z * 2}, 0);

valid ice
#

Got changed a few updates back to the new format

valid ice
coral cypress
valid ice
#

Need the x & z object properties

coral cypress
#

Thanks!!!

#

Now I gotta uh

#

find something to make

#

smh

#

I'm making an RPG. Decided

#

New combat system and all

#

I'll probably stop abt 30% way thru

#

but

valid ice
#

Good luck 🫡

coral cypress
#

I can dream

coral cypress
#

HA

#

IM BACK IN THE GAME

#

now I js gotta remember how to do literally everything else

#

also, first time seeing vibrant visuals and I hate it

#

My black concrete was light grey

#

Also, I lied. It did not function

#

OHH

#

nvm I realize

#

no i dont

coral cypress
#

I used that

#

and it says it expects 4 arguments??

#

It should just expect the vector and vertical strength

valid ice
#

Well, that's the old version

#

What version of MC and script API are you using

coral cypress
#

checking my game version now

#

I js installed minecraft so I assumed it should be the newest version

#

Running 1.21.101

valid ice
#

Yeah 1.19.0 scripts still uses the old format

coral cypress
#

Like what should I change it to?

valid ice
#

2.1.0

#

You can keep using the old version, nothing wrong with that

#

It's stable, so it'll never change

coral cypress
valid ice
#

Just won't get new features

coral cypress
#

I'll switch to 2.1 and see if that fixes things

coral cypress
valid ice
#

ya

coral cypress
#

ohhh

#

alright

#

well im trying 2.1.0 :)

#

Thanks again

#

I'm a talkative and questioning person, so I'm sure you'll see me again lol

#

LOTS

valid ice
#

Knockback was changed in 2.0.0 stable version

coral cypress
valid ice
coral cypress
#

yep

#

lol

grave halo
#

is there any way to detect when a player punches?

valid ice
coral cypress
#

nvm got itt

valid ice
coral cypress
#

yk

#

I got it to do smth when I removed the vel.x and vel.z

#

but its fixed to one direction

valid ice
#

Makes sense

coral cypress
#

yeah

#

and when I do

valid ice
#

Console warn the velocity to debug it then

coral cypress
#

vel.x * 3 it doesnt do anything

#

ima try viewdir

grave halo
coral cypress
#

yeah that worked

#

ill try to get velocity working

#

oh it does work

#

its js rlly weak so i gotta beef it up

coral cypress
#

I DID IT

#

I'M GETTING INTO THE GROOVE FR

#

I'll work on optimizing the code later

distant tulip
#

@woven loom
it is working fine?

coral cypress
#
world.beforeEvents.chatSend.subscribe((e) => {
    const player = e.sender;
    const msg = e.message;
    system.run(() => {
    if (msg.startsWith("!dash")) {
        const slot = msg.slice(6);
        player.sendMessage(`${slot}`);
    }
    })
})
#

Am I going crazy?

valid ice
#

If you’re on stable chat send doesn’t exist

coral cypress
valid ice
#

2.2.0-beta, if I remember correctly

coral cypress
#

Thanks dude 😭

valid ice
#

Be warned the version changes very frequently (generally every major update) and stuff can change inside scripts without warning

#

Hence, beta

coral cypress
#

also

#

its

#
@minecraft/server-beta
#

or ```@minecraft/server@beta

valid ice
#

For imports?

#

Or what

coral cypress
#

for the uuhh

#

manifest

valid ice
#

Same as stable

coral cypress
valid ice
#

Just version is different

#

Ya

coral cypress
#

yep

#

awesome

#

and if not, ill trial and error like a real man fr

#

yep we good :)

#

Ughhh

#

Trying to make it an integer rn

#

Ooo idea

coral cypress
#

YES

valid ice
#

We do have slash command capabilities now, btw

coral cypress
valid ice
#

Ya

coral cypress
#

How? 😭

valid ice
#

system.beforeEvents.startup.subscribe(data => {
  data.customCommandRegistry.registerCommand(
        customCommand: CustomCommand,
        callback: (origin: CustomCommandOrigin, ...args: any[]) => CustomCommandResult | undefined,
    ):
})
#

Can set a lot of things

coral cypress
#

thanks!

#

Next goal!

#

Make this health bar actually work

#

It's js an actionbar with a bunch of |||| and some colors lol

distant tulip
#

now to the easy part, json ui

coral cypress
#

nor will I ever use it lol

distant tulip
#

been there

coral cypress
#

You're basically my spirit animal atp

distant tulip
coral cypress
#

I'd love to but

#

When I first tried it

#

It about made my brain explode

distant tulip
#

yeah it is hard to learn

vast grove
deep arrow
full idol
valid ice
#

Ah, apparently it is a thing, yeah

full idol
cursive fog
#

Guys i need help on ItemDurabilityComponent Class

#

So im trying to make a script that everytime i use an item the durability would go down

#
import { world, ItemStack, EntityInventoryComponent, EntityComponentTypes, ItemDurabilityComponent, DimensionLocation } from '@minecraft/server';

world.afterEvents.itemUse.subscribe(({ source: player, itemstack }) => {
  switch (itemstack.typeId) {
    case 'vdg:coltwalker' 
  }
})

#

Uhh

#

What do i do next

shut citrus
#

What happens if I subscribe 10000 eventTypes/ entityTypes in afterDataDrivenTrigger?

buoyant canopy
#

is it still not possible to make the player open an entity gui?

shut citrus
valid ice
#

Like subscribing to events inside of data driven trigger? Or having multiple subscriptions to data driven trigger?

shut citrus
valid ice
#

Oh, the options

#

Shouldn’t matter too much I don’t think

vast grove
dusky flicker
distant tulip
dusky flicker
#

i was thinking in a protocol to do so these days, since im implementing quic

#

i've written an specification

vast grove
dusky flicker
#

it's a good project though

vast grove
#

All I wanted was something that doesn't care what environment I have to use. Heck I can even get it to talk through socket io, websockets, dp's. Anything

#

All it cares is converting a packet to a string and vice versa.

#

It doesn't care about the transport

dusky flicker
#

a way to simply establish connections and send raw bytes

#

in fact i was thinking in a way of using the less amount of scriptevent calls as possible

#

so i had to think on a way to send multiple requests to one end, and be able to make so for various ends per scriptevent call

#

thanks to quic

shy leaf
#

you could technically do only one call

dusky flicker
#

one scriptevent call sends N requests to 1 Addon, and can do this to N addons

#

i just wanted to know what are the weaknesses of the ipc project to really have a reason to implement so

#

on mine is that it aint got this multiplexing, it sends 1 request per scriptevent, or per N scriptevent calls if the size is too big since it was made when script event did limit the size to 2kb

shy leaf
#

scriptevent command doesnt have the limit for some unknowable reason

#

also im checking the docs rn and theres no mention of limit in .sendScriptEvent() now

cursive fog
#

Guys i need help
How do i make my script damage the durability of my item when i use it

shy leaf
#

i wonder if the limit is actually gone?

cursive fog
dusky flicker
#

it had, now you can send any amount of data you like

shy leaf
#

so it is actually unlimited now?

dusky flicker
#

yeah

shy leaf
#

lovely

dusky flicker
#

thats why im thinking on the project to start with 8kb but connectiond be able to handle more or less

#

i really just need to have a reason to implement

shy leaf
dusky flicker
#

i still cant understand the code

#

holy hell

shy leaf
#

i thought you were still working on it

shy leaf
#

it does???

slow walrus
shy leaf
#

oh

slow walrus
shy leaf
#

oh so the limit is still there

#

just not mentioned in the doc

slow walrus
#

yeah it's never been mentioned

slow walrus
shy leaf
#

huh

#

i swear i remember seeing the doc mentioning the limit...

dusky flicker
slow walrus
#

probably in the id?

dusky flicker
#

no

#

the message itself

#

imma test it again and show you later

#

im at cellphone right now

slow walrus
#

yeah you should test it again

#

anyway what about the code isn't understandable?

#

im interested if I need to make stuff more clear

dusky flicker
#

i dont understand how you send the data

slow walrus
#

like the format?

dusky flicker
#

the serialization and de serialization is comprehensive

dusky flicker
slow walrus
#

well it's binary data that gets turned into a utf16 string

#

so 2 bytes to one utf16 character

#

that's pretty much it

dusky flicker
#

no way

#

maybe its cause i've implemented it using arrays instead

#

just used the buffers and thats it

slow walrus
#

the id uses the format (0xHEX) where HEX is the binary data of the header in ofc hex codes

dusky flicker
#

oh thats why i didnt understand

slow walrus
#

yeah the id is very limited in the characters it supports so it can't use the same format as the data

dusky flicker
#

does the id have limitations? really?

slow walrus
#

yes

dusky flicker
#

@slow walrus

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

const text = "a".repeat(8192);

world.afterEvents.playerButtonInput.subscribe(e => {
  system.sendScriptEvent("test:data", text);
  console.warn("Sent", text.length, "chars");
})```

addon1

```js
import {system} from "@minecraft/server";

system.afterEvents.scriptEventReceive.subscribe(e => {
  console.warn(e.message);
  console.warn("Received: ", e.message.length, "chars");
});```

addon2
#

dont try to allocate 256mb of memory guys

vast grove
#
while(true)
   system.waitTicks(1)
#

That will eat your ram

dusky flicker
#

out of memory

dusky flicker
vast grove
#

I accidentally did it for some custom even handler I made. The world ran but it would get progressively worse.

dusky flicker
#

xd

#

didnt you await atleast?

vast grove
#

Oh yeah that was it. I just forgot the await

dusky flicker
#

8 mega tf

rare plume
#

bro what is the point of this

vast grove
#

You can go up to 2gb total though

dusky flicker
#

this shit might use shared memory

slow walrus
dusky flicker
dusky flicker
vast grove
dusky flicker
#

a signed one

vast grove
#

Oh yeah C# is the same. That ain't new to me

slow walrus
dusky flicker
#

holy shit i tried to console log 8mb string

#

i forgot to save the change to 4kb

#

on the receiver one

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

system.afterEvents.scriptEventReceive.subscribe(e => {
  console.warn(e.message);
  console.warn("Received: ", e.message.length, "chars");
})```
dusky flicker
#

to double the amount possible

slow walrus
#

hugh I guess the limit got removed in .101 then

dusky flicker
#

and it still cannot receive null byte

#

sadly

slow walrus
#

looks like fragmenting will still be needed though, sending heaps of data at once causes lag spikes

dusky flicker
#

fragmentation will always be required in fact

slow walrus
#

bruh I'm dumb lmao

#

thought the job system broke

#

but it was just cause I was doing "a".repeat(200000) each time instead of caching it

#

yeah nevermind it doesn't really need fragmentation

#

nvm it does

dusky flicker
#

the main problem would be to transform from string to bytes

#

since strings are immutable, theyre cloned everytime

cursive fog
#

What does ev mean in script

dusky flicker
#

probably the engine uses some kind of caching and shared memory because i only started to face problems when i sent about 8mb

coral cypress
#

Like when people do

#

subscribe((ev) => {
xx
})

cursive fog
#

That

#

What does ev mean

coral cypress
#

But

#

"ev" could be anything

#

You could type "dog" and it work js as fine

cursive fog
#

Ye he made my script because idk anything abt scripts

open urchin
#

it's more common for it to just be called e

small river
#

how can I get the rider's x and y head rotation and apply it in animations to my entity ?

cursive fog
dusky flicker
#

(ARGUMENTS_GO_HERE) => {BODY_GO_HERE}

this is an anonymous function

#

function name_of_function(argument){
dothing()
}

something.subscrive(name_of_function)

this does the same as if it was using an anoymous function

tranquil junco
#

i'm learning javascript from being forced to use the script api 😭

full idol
#

What's the easiest way to test addons for BDS that need server-net? Do I just run a server locally and develop in the development directories?

small river
slow walrus
full idol
slow walrus
#

yeah that should work

full idol
#

Also, any ideas on how to get the first tick a player is able to see in the world? I tried playerSpawn after event, but it triggers about 1-3 seconds before they can actually see on realms

full idol
shy leaf
#

but maybe you could try to use server form to constantly check if the user is busy

#

just a random idea tho, cant guarantee

full idol
#

Alright, thank you!

full idol
# shy leaf but maybe you could try to use server form to constantly check if the user is bu...

Hmm what are your thoughts on pressureplate event where they spawn on the pressureplate? Would it likely still trigger before they can see? I'm not very familliar with world loading (https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server.WorldAfterEvents.html#pressureplatepush)

shy leaf
#

the player actually spawns way before the player can play

#

hence why the playerSpawn event happens early

full idol
#

Hmm. Would their targetted block be null if they can't see?

#

I'm gonna have to go set up my PS5 or something to test

shy leaf
#

eh i doubt it

full idol
#

Maybe vibrant visuals delays the load time more

rare plume
#

But still that probably wouldn’t work

#

unless you could find a consistent way to use a delay or something

full idol
#

Sorry for all the questions, I just saw on a server that you can change a player's render distance? I feel like at this point I've read through every major doc possible, but did I miss something to enable this?

#

Oh unless it's geyser?

shy leaf
#

idk if thats possible at all????

valid ice
#

Yeah that's not possible with scripts

#

Render distance is a server/world property, and a client thing as well

coral cypress
#

For the setCamera option, I'm confused as to the method. It's setCamera(cameraPreset:string, setOptions?: then lists a bunch of options)

#

If I wanted to do camera roeset then only update CameraSetFacingOptions would I js do

#

setCamera("minecraft:third_person", CameraSetFacingOptions: wtv)

#

woah nvm

#

I got it I think

coral cypress
#
system.runInterval(() => {
    const players = world.getAllPlayers().forEach((player) => {
        const hand = player.getComponent("equippable").getEquipmentSlot("Mainhand");
        if (hand.getItem()?.typeId == "minecraft:stick") {
            const playLoc = player.location;
            const viewDir = player.getViewDirection();
            player.teleport({x: viewDir.x + 1, y: playLoc.y, z: viewDir.z + 1});
        }
    })
}, 0)
#

How would I change this to teleport me 1 block forward to whichever direction I'm facing?

#

I tried playLoc * viewDir + 1

#

I don't get how I could implement viewDir though. It's a rotation

#

And added + 1 to playLoc is js coords and can't be kept like

#

idek

#

And with the new updates since I've joined, is there a way to track movement inputs, like if ur holding A or moving ur joystick left?

#

without riding an entity

verbal aurora
coral cypress
#

thats simpler than I thought lol

#

wait then

#

How do you control how many blocks?

verbal aurora
#

You can also throw in * distance on the end and create a const if you want to change how much distance you move

verbal aurora
#

Was just getting to that lol

coral cypress
#

thanks so much

coral cypress
verbal aurora
#

No problem ha

oblique mica
#

#1421307791993339974 Can anyone help me fix this

deep arrow
#

can local worlds use @minecraft/debug-utilities

prisma shard
rare plume
#

What is the size limit for a dynamic property?

fiery solar
prisma shard
gaunt salmonBOT
safe stream
#

If you want it to contain more data you can use base62 for encoding

slow walrus
#

well ig it depends what the data is

#

if it's raw binary that just convert it directly to a utf8 string

#

not sure how the game handles control chars in dynamic properties but hopefully it doesn't do anything weird

dusky flicker
#

else it interprets as termination char, and ends tje string at there

#

and actually js strings are utf16, not utf8

gaunt salmonBOT
slow walrus
#

cause c++ uses utf8 strings

dusky flicker
coral cypress
#

am I being dumb?

#

is elif not a thing?

safe stream
#

No

coral cypress
#

Has it been this long since I've used if statements 😭

woven loom
#

else if

coral cypress
#

thanks lol

safe stream
coral cypress
full idol
coral cypress
#
system.runInterval(() => {
    world.getAllPlayers().forEach((player) => {
        const hand = player.getComponent("equippable").getEquipmentSlot("Mainhand");
        if (hand.getItem()?.typeId == "minecraft:stick") {
            const viewDir = player.getViewDirection();
            const speed = player.getDynamicProperty("speed");
            player.applyKnockback({x: viewDir.x * speed, z: viewDir.z * speed}, 0);
            if (player.isJumping) {player.setDynamicProperty("action", 0)}
            else if (player.isSneaking) {player.setDynamicProperty("action", 1)}
            else if (player.isSprinting) {player.setDynamicProperty("action", 2)}
            else {player.setDynamicProperty("action", 0)};
            player.onScreenDisplay.setActionBar(`${Math.round(speed * 10)/10}`);
            switch(player.getDynamicProperty("action")) {
                case 0:
                    if (speed <= 0.4) {player.setDynamicProperty("speed", 0)}
                    else {player.setDynamicProperty("speed", speed - 0.4)}
                case 1:
                    if (speed <= 0.05) {player.setDynamicProperty("speed", 0)}
                    else {player.setDynamicProperty("speed", speed - 0.05)}
                case 2:
                    if (speed >= 2) {player.setDynamicProperty("speed", 2)}
                    else {player.setDynamicProperty("speed", speed + 0.08)}
            }
        }
    })
})
#

It's continuing to increase my speed

#

even when I'm shifting

#

Now it's stuck at max speed

#

How can I fix this?

#

Or should I put it as it's own forum? 😭

#

I have a code that works, but I tried consensing it this way

harsh dawn
#
world.sendMessage(event.itemStack.hasComponent("minecraft:food"))})```

does anyone know why  this is always returning false even when im eating food?
distant tulip
harsh dawn
distant tulip
#

yes

#

try it with apples

harsh dawn
#

thats kinda weird

full idol
#

I'm really struggling to get the camera to fade to white:
player.camera.fade({fadeColor: {red: 255, green: 255, blue: 255}, fadeTime: {fadeInTime: 0.2, holdTime: 1, fadeOutTime: 3}}); // Error value must be 0-1.0
player.camera.fade({fadeColor: {red: 1, green: 1, blue: 1}, fadeTime: {fadeInTime: 0.2, holdTime: 1, fadeOutTime: 3}}); // Fades to black
player.camera.fade({fadeColor: {red: 0, green: 0, blue: 0}, fadeTime: {fadeInTime: 0.2, holdTime: 1, fadeOutTime: 3}}); // Also Fades to black
player.camera.fade({fadeColor: {red: 0, green: 1, blue: 0}, fadeTime: {fadeInTime: 0.2, holdTime: 1, fadeOutTime: 3}}); // ALSO Fades to black

#

AH found the issue. For anyone else seeing this, Vibrant Visuals MUST be off to see camera fades

vast grove
#

Yeh. VV messes with it for some reason

lethal bramble
#

is that inntentional?

full idol
restive light
#

could I impliment a sql database into mc?

subtle cove
#

its the module commonly used for http methods

restive light
subtle cove
#

well, what else is there than http methods tho...

#

websockets...

restive light
subtle cove
#

the api only uses js files afaik

#

and with limited modules

restive light
#

but using server net and http requests is slow asf

subtle cove
#

mhmm, 'tis what it is as of now

restive light
subtle cove
#

somewhere around 32k bytes

restive light
subtle cove
#

as much as u want ig

#

but itll affect the game

#

u might also wana utilize structureManager for better minecraft data stuff

restive light
subtle cove
#

wdym

restive light
subtle cove
#

uhm, not really, but i like playing with em

restive light
full idol
#

I'm seeing something really weird when spawning my custom entity.

Image 1 is this code, where it spawns a little in the air, but centered on the block.

let toSpawn = ev.block.center();
let newTNT = ev.player.dimension.spawnEntity(block, toSpawn);

Image 2 is with a small adjustment to move it down a little bit, and it also shifts the X to +1. I've tried also correcting the X, but it snaps either side of the block.

let toSpawn = ev.block.center();
toSpawn.y -= 0.5;
let newTNT = ev.player.dimension.spawnEntity(block, toSpawn);
harsh hare
#

Is it possible to use RawMessage on CustomCommandResult?
I know its possible to do { status: CustomCommandStatus.Success, message: "translated.message" }, but is it possible to do RawMessage?

shy leaf
harsh hare
#

Hope they will add RawMessage support in future update

shut citrus
#

how to convert movement speed into speed multiplier?

cursive fog
#

Wdym i cant?

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

const TARGET_ITEM = "vdg:coltwalker"  // target item ID
const DAMAGE_PER_USE = 1    // durability consumed per use
const USE_ITEM = world.getDynamicProperty("vd:shooting")

world.afterEvents.itemUse.subscribe(ev => {
  const { source: player, itemStack } = ev
  if (!player || !itemStack) return
  if (itemStack.typeId !== TARGET_ITEM) return
  if (USE_ITEM == false) return

  const dur = itemStack.getComponent("minecraft:durability")
  if (!dur) return
  if (dur == 0
  ) system.run(() => player.runCommand('function coltwalker/empty'))

  dur.damage += DAMAGE_PER_USE
  const container = player.getComponent("minecraft:inventory")?.container
  if (!container) return
  container.setItem(player.selectedSlotIndex, itemStack)
});


console.warn
#

The shiiit code in question..

granite badger
#

That's an interface, not an actual JS object

cursive fog
#

Do i need the get dynamic property or no
I just need it to return when my property is false

granite badger
#
import { world, system, ItemStack } from "@minecraft/server"

const TARGET_ITEM = "vdg:coltwalker"  // target item ID
const DAMAGE_PER_USE = 1    // durability consumed per use
const USE_ITEM = world.getDynamicProperty("vd:shooting")

world.afterEvents.itemUse.subscribe(ev => {
  const { source: player, itemStack } = ev
  if (!player || !itemStack) return
  if (itemStack.typeId !== TARGET_ITEM) return
  if (USE_ITEM == false) return

  const dur = itemStack.getComponent("minecraft:durability")
  if (!dur) return;
  if (dur.damage == 0) system.run(() => player.runCommand('function coltwalker/empty'))

  dur.damage += DAMAGE_PER_USE
  const container = player.getComponent("minecraft:inventory")?.container
  if (!container) return
  container.setItem(player.selectedSlotIndex, itemStack)
});
gaunt salmonBOT
# granite badger ```js import { world, system, ItemStack } from "@minecraft/server" const TARGET...

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 2 errors:

<REPL0>.js:15:7 - error TS2367: This comparison appears to be unintentional because the types 'ItemDurabilityComponent' and 'number' have no overlap.

15   if (dur == 0
         ~~~~~~~~

``````ansi
<REPL0>.js:16:5 - error TS2304: Cannot find name 'system'.

16   ) system.run(() => player.runCommand('function coltwalker/empty'))
       ~~~~~~

Lint Result

There are no errors from ESLint.

cursive fog
#

Not cooked but incinerated i guess

gaunt salmonBOT
cursive fog
#

Thanks

cursive fog
#

Uhh
What are the required privilages?

#

Idk im just following things on script documentation

fallen cape
#
let USE_ITEM;

world.afterEvents.worldInitialize.subscribe(() => {
      USE_ITEM = world.getDynamicProperty('...')
})
#

or, it's even better to fetch the dynamic property inside the itemUse event itself (in your context)

prisma shard
thorn flicker
fallen cape
floral copper
#

guys is it possible to transform 1 mob to another mob?

#

undercertain conditions

#

for eg the health comp being less than 10

#

or smth like that

wary edge
floral copper
#

thankss

dusky flicker
#

i can provide you the doc of quick, but we cannot use it

#

what you can do is use dynamicProperties as the storage system

#

but that'd be inefficient as hell

dusky flicker
warped kelp
harsh dawn
subtle cove
pallid stag
#

Does anyone know why this code is not working?

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

world.afterEvents.entityHurt.subscribe((event => {

    const hurt = event.hurtEntity;

  if (hurt.hasTag(hurt0)) {

  hurt.removeTag(hurt0);
  hurt.addTag(hurt1);

  } else if (hurt.hasTag(hurt1)) {
  
  hurt.removeTag(hurt1);
  hurt.addTag(hurt2);

  } else if (hurt.hasTag(hurt2)) {

  hurt.removeTag(hurt2);
  hurt.addTag(hurt3);

  } else (hurt.hasTag(hurt3)) {

  hurt.removeTag(hurt3);
  hurt.addTag(hurt4); 

  }
)}; ```
subtle cove
#

are those tags declared, or do u mean them to be string?

pallid stag
#

Well, I thought that hasTag(tag) would check directly in the game if the entity has the described tag

subtle cove
#

if there's const tag = "something", then itll refer to the variable

#

u can use "hurt3" as well if ud like

subtle cove
#

ok, then make em strings like

hurt.removeTag("hurt1");
hurt.addTag("hurt2");
pallid stag
#

Ok

#

Still doesn't work

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

world.afterEvents.entityHurt.subscribe(event => {

  const hurt = event.hurtEntity;
  const hurtTag = hurt.getTags().find(tag => tag.startsWith("hurt"));
  if (!hurtTag) return;
  const hurtX = hurtTag[4]; // 5th char or index 4
  hurt.removeTag(hurtTag);
  hurt.addTag(`hurt${parseInt(hurtX) + 1}`);
  //other code to handle 4+...
}); 
#

@pallid stag there's still js syntax u gona have to learn btw

pallid stag
#

Bro

#

I already fixed it, it was a syntax error, plus I didn't put the "" in the tag

#

🤡

#

Anyway, thank you very much for helping.

subtle cove
#

np bao_panda_munching

full idol
tranquil junco
#

you might be able to grab the entity's location

full idol
tranquil junco
#

yeah

#

minecraft explosions originate at a specific coordinate that is definitely passed in somewhere

#

no idea why it isn't kept and passed into callbacks

full idol
#

Maybe I missed something but the docs have nothing

restive light
#

anybody here good at geomatry?

full idol
#

Slightly different question, I'm trying to lock the camera for like a 2D camera movement where it can only be up and down. setRotation seemingly doesn't work for players, and teleport is all glitchy because we can't maintain velocity. Ideas?

system.runInterval(() => {
  for (const player of world.getPlayers()) {
    player.setRotation({x:player.getRotation().x, y: 0});  
  }
}, 1);
prisma shard
full idol
# wary edge Use the camera command.

Oh wait really, I thought that was only visual? I would need the actual camera to be elsewhere but the player can only look at a vertical row of blocks

wary edge
prisma shard
#

What is this????!!!

full idol
#

The camera would be stationary elsewhere, so it's not just visuals, mostly the crosshair, kinda like terraria I guess

wary edge
full idol
#

AH awesome, thanks, I'll give that a go and see. The camera command is probably where it's at, just gotta keep learning!

snow knoll
#

Any one have any ideas as to why the js blockDistance constant from this script is returning as undefined?

Any help given is appreciated

#
world.afterEvents.itemStartUse.subscribe((e) => {
  const { itemStack, source } = e;
  const player = source;
  const item = itemStack.typeId;
  const type = "ltng:web_test";
  const entity = player.getEntitiesFromViewDirection({ maxDistance: 75 })[0]?.entity;
  const block = player.getBlockFromViewDirection({ maxDistance: 75 });
  const blockDistance = distance(player, item, type, entity, block);
});
function distance(player, item, type, entity, block) {
  if (block && !entity) return;
  if (item !== type) return;
  const blockLocation = block.block.location;
  const headLoc = player.getHeadLocation();
  const deltaBlock = {
    x: blockLocation.x - headLoc.x,
    y: blockLocation.y - headLoc.y,
    z: blockLocation.z - headLoc.z
  };
  const blockDistance = Math.hypot(deltaBlock.x, deltaBlock.y, deltaBlock.z);

  return blockDistance;
}```
pallid stag
#

Is it possible to make the player unable to attack?

#

Even if he clicks on the screen to hit the entity he can't

shy leaf
warped kelp
#

Is it okay to remove console warns when done testing scripts?

dusky flicker
#

yeah

#

why to keep them?

warped kelp
#

Cuz idk

#

Unless if it's like, catch errors

shy leaf
#

its ok to remove them

#

you can always add them back if you were to debug

warped kelp
#

That's fair

#

Thank you

lethal cloak
#

hello guys

#

Does anyone know how to execute the command? For example, I wrote in caht !gmc to give me creative, I've tried several other things without using tags like creative survival etc., I want to do the commands using the code itself, even though I use runCommand(' gamemode creative, it doesn't work, does anyone have an idea that is w

valid ice
#

Can you show your code?

hazy nebula
final ocean
broken pawn
#

may i ask abt something

#

what's the difference between runCommand and runCommandAsync

#
AE.itemUse.subscribe(({source:A,itemStack:B})=>{
    if(B.typeId.includes("_axe")){A.runCommand("tp @e[type=item,r=24] @s")};
    if(B.typeId.includes("_hoe")){A.runCommand("tp @e[type=item,r=24] @s")};
    if(B.typeId.includes("_pickaxe")){A.runCommand("tp @e[type=item,r=24] @s")};
    if(B.typeId.includes("_shovel")){A.runCommand("tp @e[type=item,r=24] @s")};
    if(B.typeId.includes("_sword")){A.runCommand("tp @e[type=item,r=24] @s")};
});```
#

i figured it out using non-async fix the problem with my code

coral cypress
#

And does it the exact tick the code is ran

deep quiver
#

runCommandAsync got removed in the newer versions

#

Async simply means that the command can be awaited until its done. Also It put the commands in some sort of queue so you had a limit of 120 commands per tick or something like that

#

They removed it bcs most commands didn’t run async anyways

#

Or maybe none

coral cypress
coral cypress
#

Thanks for the correction

broken pawn
#

Nice information

#

then i have to re-write all of that

deep quiver
broken pawn
#

like "else if" right?

subtle cove
# broken pawn like "else if" right?

this is another way as well

const AE = world.afterEvents;
const equipmentRegex = /_(axe|hoe|pickaxe|shovel|sword)/;

AE.itemUse.subscribe(({ source: A, itemStack: B }) => {
    if (equipmentRegex.test(B.typeId)) {
        A.runCommand("tp @e[type=item,r=24] @s")
    }
});
thorn flicker
#

would be cool if there was an OnIgnite event for blocks.

wary edge
#

You want to detect fire tick is all?

thorn flicker
safe stream
coral cypress
#

cut it in half

coral cypress
#

loll

#

and its shorter

#

awesome

broken pawn
#

nice tho

coral cypress
#

or obviously an array like

#

array = [ "_axe", "_hoe", etc ]

#

then check if it has anything in that areay

broken pawn
coral cypress
#

a few diff ways to minimize it

coral cypress
#

Also, how long have you been scripting? I just got back into it an I'm SUPER rusty

broken pawn
#

if(C1.typeId.includes(":")||C2.typeId.includes(":"))

coral cypress
coral cypress
broken pawn
coral cypress
broken pawn
#

just a casual use

#

for my realms

#

Specific project: QoL

coral cypress
coral cypress
#

If you'd like, I'd love to work with you on it. I need something to do to keep me motivated 😭

#

ive hit my creative/motivation block for scripting

broken pawn
#

🗣️ 🔥

#

but actually, i don't working too much

#

i just open my laptop and think a lot

#

then write it
then....

#

re-write it again

#

🗣️ 🔥

coral cypress
#

I do too

coral cypress
#

then never finish

#

I got trouble keeping consistent when I'm not writing for anyone but myself lol

broken pawn
#

yes, but it kinda fun and frustating at the same time

coral cypress
#

I'm also not very skilled or knowledgeable right now anyways

#

js tryna improve

coral cypress
#

exactly

broken pawn
#

from @minecraft/server 1.19.0 to 2.1.0, there's some changes

#

like how runCommandAsync doesn't work somehow

broken pawn
#

so i have to change it to runCommand

coral cypress
#

and applyKnockback (my favorite)

broken pawn
#

🗣️ 🔥 Apply 100%

#

it happened to RLCraft bedrock, which every mob that deals knockback is buffed

#

they got the same knockback range, but gladly they fixed it

#

that's why i'm still do scripting for my RLCraft experience

onyx locust
#

can someone tell why does beforeEvents is not working?

system.beforeEvents.startup.subscribe((e) => {
    console.warn("startup")
});
#

no errors or whatsoever

coral cypress
coral cypress
#

I use it for things like uhh

#

can I dm you a quick vid

#

in a sec

coral cypress
coral cypress
#

like a diff and better teleport

#

and dashes ofc

unique stag
#

is there a way to detect TPS using scripts?

coral cypress
coral cypress
unique stag
#

I thin we have to use like Date.now()

#

then do the calc?

coral cypress
#

i pinged u

coral cypress
# unique stag then do the calc?
let checkTime = Date.now();
let currentTicks = 0;
let TPS = 0;
system.runInterval(() => {
    currentTicks++;
    const currentTime = Date.now();
    if(currentTime - checkTime > 970){
        TPS = currentTicks;
        checkTime = currentTime;
        currentTicks = 0;
    }
},1);

Try

#

It's in a forum post

unique stag
#

ooo thanks :)

coral cypress
unique stag
#

so trying to shotern those down, and also use less of them

#

just optimizing stuff

#

got it working

coral cypress
coral cypress
coral cypress
full idol
#

Do we know what beta version is releasing tomorrow? I'm using 2.2.0-beta right now

coral cypress
#

What will be added?

full idol
# wary edge Then 2.3.0

Sorry, better question, is it confirmed that it's actually updating, like, 2.3.0 would be next, but idk if drops actually always come with a new version

distant tulip
#

versioning latest beta module with "beta" is this update or still in preview?

full idol
#

AH thanks yeah perfect

lethal cloak
#

Guys, I'm trying to create a script code that is always saved even if players leave the world or server or the server restarts as well, how do I do this?

lethal cloak
# shy leaf what are you saving?

stetando saves tags, and the UI shows statistics, for example, I have tga1, the UI appears for the player when using an item and serves the player with tag2

shy leaf
#

uhhhhhh

lethal cloak
#

I've been trying to do this for a long time, it would be a clan code

#

like I wrote !clan after 3 seconds I opened a UI, depending on the tag I opened a specific UI, like there are 3 clan leader members: (clan name) au I'm trying to save them on the server

#

can you help me?

#

???

shy leaf
#

use dynamic properties

lethal cloak
#

ok, I'll try

tranquil junco
#

should i truncate the numbers to save space

#

this is stored in a dynamic property as a string

sudden verge
tranquil junco
#

trimming it to 7 should be fine considering that bedrock edition only stores positions to about this precision anyways

broken pawn
#

thank you sir

magic peak
#

does anyone need help with script?

safe stream
magic peak
#

if anyone need to learn javascript you watch https://youtu.be/0Kbd3ZH50xU?si=MP4RDNtk0gEWnJwR

Are you ready to master JavaScript and become a confident web developer?
In this complete course, I’ll take you on a journey from zero to hero, covering everything you need to know about JavaScript — from the basics to advanced concepts.

📚 What You’ll Learn:
✅ JavaScript fundamentals (variables, data types, operators)
✅ Functions, ...

▶ Play video
safe stream
#

..

floral timber
safe stream
#

what even is pageX and pageY

shy leaf
#

whats up with the

#

large texts

#

also what the devil is that video

wicked girder
#

do entities have a unique id that we can get? or should I make a system with dynamic properties?

wicked girder
#

is that unique? I searched the chat and its mixed on if its same as type id or not

#

ima just check

distant tulip
#

it is, some guys reported that it change some times, but i have never had that

deep quiver
#

it only changes when you change world. I heard somewhere they also change if you switch server

distant tulip
#

That kinda obvious, the entity is not the same anymore, i am talking about same world

deep quiver
#

same world if you change server

#

let me test it real quick, it doesn't make sense in my head

#

it maybe also is just the player id

safe stream
#

so far I have yet to find an issue with it but I do remember seeing people claiming that the id changes

#

Maybe it was a bug or that it changes with worlds (for players)

cinder shadow
#

I can't remember how I fixed it before or if I even fixed it, but is there a solution to this?

#

I think last time I ran into it I said screw it and just multipled all my base values by 10 and rescaled everything

rare plume
#

or round

#

so if you just want 2.4 do

num.toFixed(2)

cinder shadow
rare plume
distant tulip
meager pulsar
#
import * as server from "@minecraft/server"

import * as v3 from "./v3.js"

import * as f from "./functions.js"


const world = server.world
const system = server.system

system.beforeEvents.startup.subscribe((init)=>{
    let resetWorldCommand= new server.CustomCommand  
    resetWorldCommand = {
        description: `Reset the map`,
        permissionLevel: 0,
        cheatsRequired: true,
        name: `rareloot_mm:reset_world`
    }

    init.CustomCommandRegistry.registerCommand(resetWorldCommand)
})```

i'm trying to reguster a custom command, but it isnt working
#

is this line in specific what's giving me problems

let resetWorldCommand= new server.CustomCommand```
#

any idea what i am doing wronf?

full idol
#

Does anyone know the 2.3.0-beta patch notes?

cinder shadow
rare plume
cinder shadow
#

I only know what I need to know at the time I need to know it

rare plume
cinder shadow
#

like .find, .filter and .some?

#

found out about all of those like 5 or 6 months ago when chatGPT randomly used them and my mind exploded

full idol
#

Random issue popped up on BDS after update, damaging any entity as the player doesn't work. It's probably one of the addons ofc, but they aren't all mine. There's about 15, any ideas what could be breaking it? The entityHitEntity event fires but nothing happens visually, not even the sound queue for hitting someone who can't take damage

simple zodiac
full idol
simple zodiac
#

This also happens in low level languages. However, you have the option to change the type of the variable to something that might handle it

#

The problem exists in the first place cuz we have a hard time representing fractions in binary

rare plume
#

was scripting touched in todays minecraft update?

rare plume
wary edge
#

Read the changelogs.

rare plume
wary edge
rare plume
sharp elbow
#

In any case, toFixed works, but you can also try using Math.fround to find the nearest 32-bit precision float of a number. That should catch some of those cases

full idol
dusky flicker
#

each float will be about 4 bytes only

restive light
#

is it possible to cancel death messages?

tranquil junco
dusky flicker
#

you can do so using DataView

#

and converting the byte array to a string

tranquil junco
#

wait does JavaScript provide a way to serialise objects into bytes

dusky flicker
#

not directly

#

its got DataView and typed arrays

tranquil junco
#

so no python pickle ahh thing

dusky flicker
#

so yeah you can abstract it

dusky flicker
tranquil junco
#

pickle is python's module for serialising objects

dusky flicker
tranquil junco
#

oh I shouldn't have those

dusky flicker
#

but you can avoid so by using something like Base32767

tranquil junco
dusky flicker
#

floats are more bytes

#

so yeah

#

you can

#

you can save any type of data you want

#

im really thinking in writing something for this, to avoid the usage of json on dynamic properties

deep arrow
#

:(

magic peak
shy leaf
magic peak
shy leaf
#

no it isnt

magic peak
#

it is

shy leaf
#

it isnt

magic peak
#

not all andriods are the same

shy leaf
#

idk what android you even have but ok

magic peak
shy leaf
#

that isnt even your channel

magic peak
pale terrace
#

there is a Potion.resolve in the new update, what is that? can we create custom potion effects or its for get a vanilla potion?

rare plume
pale terrace
#

oh, alright, thx

floral timber
floral timber
#

hey guys, was entity scale component value always read only?

#

iirc, we could set it back in the days.

shy leaf
floral timber
shy leaf
#

i forgir tho

floral timber
#

what does it even set? why does the description say that lol?

#

sets the entity's visual size.

shy leaf
#

idk either, its just there

#

and they prolly forgot about it

floral timber
#

makes sense

sharp elbow
#

Peak trolling

#

In any event is is really obnoxious and I'd ask staff to discourage this behavior

magic peak
#

i am helper here if any one need help @

wary edge
#

@magic peak Quit it dude. One more time I see those big messages or you keep being annoying thats a 1 day mute.

pallid stag
#
world.afterEvents.entityHitEntity.subscribe((event) => {
  const hurt = event.hitEntity;
  const hit = event.damagingEntity;
  const velocity = hit.getVelocity();
  
  if (hurt.hasTag("hurt3") && hit.isOnGround) {
    const hitView = hit.getViewDirection();
    const impulseStrength = 3;
    const impulseStrengthy = 7;
    const finalImpulseVector = {
      x: hitView.x * impulseStrength,
      z: hitView.z * impulseStrength,
    };
    hurt.applyKnockback(finalImpulseVector, 0);
    hurt.playAnimation('animation.hurt4');
    hit.playAnimation('animation.susie_attack3');
    
  }
  if (hurt.hasTag("hurt3") && hit.isFalling) {
    const hitView = hit.getViewDirection();
    const impulseStrength = { x: 0, z: 0 };
    const impulseStrengthy = 7;
    const finalImpulseVector = {
      x: hitView.x * impulseStrength,
      z: hitView.z * impulseStrength,
    };
    hurt.applyKnockback(impulseStrength, -1);
    hurt.playAnimation('animation.hurt4');
    hit.playAnimation('animation.downslam');
    
  }
  if (hurt.hasTag("hurt3") && !hit.isOnGround && velocity.y > 0) {
    const hitView = hit.getViewDirection();
    const impulseStrength = { x: 0, z: 0 };
    const impulseStrengthy = 7;
    const finalImpulseVector = { x: 0, y: 4, z: 0 };
    hurt.applyKnockback(impulseStrength, 0.5);
    hurt.playAnimation('animation.hurt4');
    hit.playAnimation('animation.uppercut');
    
  }
}); ```
#

How do I make it identify the item in the player's hand?

dusky flicker
magic peak
distant tulip
#

@magic peak can you help the guy above
nvm

wary edge
distant tulip
# pallid stag ```js world.afterEvents.entityHitEntity.subscribe((event) => { const hurt = ev...
import { world } from '@minecraft/server';

world.afterEvents.entityHitEntity.subscribe((event) => {
    const { hitEntity: hurt, damagingEntity: hit } = event
    if (!hurt.hasTag("hurt3")) return;
    const item = hit.getComponent("equippable").getEquipment("Mainhand")
    if(item) {
        //...
    }

    const velocity = hit.getVelocity();
    const hitView = hit.getViewDirection();

    // using a function so we don't repeat part of the code in *1 *2 and *3
    const handleHit = (animHurt, animHit, kb, kbY = 0) => {
        hurt.applyKnockback(kb, kbY);
        hurt.playAnimation(animHurt);
        hit.playAnimation(animHit);
    };

    // passing diffrent data to the function depending on the condition
    if (hit.isOnGround) {
        // *1
        handleHit("animation.hurt4", "animation.susie_attack3", { x: hitView.x * 3, z: hitView.z * 3 });
    }
    else if (hit.isFalling) {
        // *2
        handleHit("animation.hurt4", "animation.downslam", { x: 0, z: 0 }, -1);
    }
    else if (velocity.y > 0) {
        // *3
        handleHit("animation.hurt4", "animation.uppercut", { x: 0, z: 0 }, 0.5);
    }
});

magic peak
wary edge
distant tulip
#

if someone need help you will find him asking here or in a post

pallid stag
#

Thanks

#

I'm starting out in this scripting area

granite cape
#

now we can make rpg system?

dusky flicker
full idol
#

After changing my manifest to 2.3.0-beta, it just doesn't update in Minecraft? It's in the development folder and I normally have no issues. Restarted Minecraft and nothing, it's absolutely the right addon. This is starting to get much more common, ideas?

#

If I remove the pack from my development folder then it notices and hits an error, put it pack, same 2.2.0 error. Notepad confirms it's not VS Code

#

Changed the UUID and pack name, shows in game, still thinks I'm requesting 2.2.0-beta

#

I can even update this label right above, and it shows