#Script API General

1 messages · Page 34 of 1

unique yoke
#

ohhh thanks

sterile epoch
#

how do people get items in ender chest

unique yoke
dim tusk
#

I always notice a lot of people do this.

sterile epoch
unique yoke
remote oyster
sterile epoch
#

but ive seen people do it

dim tusk
remote oyster
unique yoke
#

let me look at the addon

sterile epoch
#

admin utils on mcpedl

dim tusk
sterile epoch
#

they have an ender chest viewer

remote oyster
#

They are probably using commands.

fiery solar
#

It's pretty hacky, uses a ton of commands, but it's the best we have unfortunately

remote oyster
#

One day they will introduce a component lol.

sterile epoch
#

Hasitem

remote oyster
dim tusk
dim tusk
sterile epoch
#

I was right it was hasitem

fiery solar
sterile epoch
#

what about replaceitem

#

oh yeah

#

attached data

#

nbt editor in commands like java would go hard

valid ice
#

Ender chest component hopefully soon pain

inland merlin
scenic bolt
#

is it possible to make it so that on weather change I set an event that changes all of a specific block to change.

For example i’m making clouds that turn into rain clouds when it starts raining

#

I already have the weather change event, but it does not allow for block

fallow minnow
warm mason
warm mason
valid ice
slow walrus
#

and iirc they're faster to render

scenic bolt
#

I’m trying to avoid using onTick

#

Instead I tried out the weatherChange event, but I don’t have a way using that to set all cloud blocks to rain blocks that I can find

warm mason
#

make the blocks invisible and spawn the necessary particles there

scenic bolt
#

Still does not solve the fact that I can’t get the block

#

Because I can detect the change in weather yes, but nothing beyond that in the event

slow walrus
#

hmm

#

that is an interesting problem

scenic bolt
# slow walrus ah like terraria?

Yeah, I want to do it my own way though.

I have this idea where there’s structures and stuff high in the clouds, but I want to make it so that the white clouds turn into rain clouds when it starts raining, this is where the issue is

slow walrus
#

you could use onRandomTick

#

it might look better as well

#

so they all slowly become rain clouds

scenic bolt
#

I’m doing that now but with onTick, and setting an interval so it happens slowly

#

The issue is when you multiply that by 100’s of blocks i’m afraid of the consequences

slow walrus
#

I wouldn't set an interval

#

get the current tick at the start and compare it

#

it should be a bit faster

scenic bolt
slow walrus
#

wdym?

#

that doesn't really make sense

scenic bolt
#

it sets a max limit for how long it’s allowed to stay a white cloud while it’s raining

#

Otherwise with random tick there’s a chance it does not happen at all right?

slow walrus
#

can you send what you have so far?

#

make a post actually

scenic bolt
#

But I was hoping to avoid ticking in general because of how bad it would get with lots of blocks

slow walrus
#

ah wait I got an idea

#

how are your blocks being placed?

#

you could try onPlace and then inside of that subsribing to the weatherChangeEvent

#

might work, not sure though

#

would be better than checking every tick

scenic bolt
slow walrus
#

worldgen?

scenic bolt
scenic bolt
slow walrus
#

yeah

#

wdym

#

the player puts it down?

scenic bolt
#

Like i’m placing it around now for testing, and eventually i’ll make it a structure

#

here go to the post I made

north depot
#

afterEvents works with worldInitialize?

#

its the same as beforeEvents?

slow walrus
#

slightly different, only the beforeEvent has the custom component registry

north depot
#

so i cant use it with the custom component?

slow walrus
#

what?

north depot
#

without the custom_component_registry, what can i do with worldInitialize?

warm mason
neon thunder
#

Heyas. I'm wondering if there is a way to tell if an entity is a player? I'm new to JavaScript so its likely a simple is class of type thing, right?

#

Is it js if (typeof(entity) == Player)?

#

or do I need the '===' test?

quick shoal
neon thunder
#

ahh... Okay

quick shoal
neon thunder
quick shoal
neon thunder
#

Oh I haven't got to the part where I need it yet, just planning what I'm going to do and making sure I can

neon thunder
#

I have to re-establish the state of things when the world is initialised, including testing what has happened to entities which may or may not be players

quick shoal
#

Sry I don't fully understand of it

neon thunder
#

I'm building a Ferris Wheel but I need to control how players dismount otherwise they will kill themselves. I need to check the riders of the seat entities to see if they are players or not, in order to know how to do it.

#

I'm not entirely sure what will happen if you log out while riding and log back in again

#

Yes, just as I suspected, you will try to log in again in the seat... I wonder what will happen if the seat has changed since then? I guess you'll fall...??

quick shoal
#

Can U send image

neon thunder
#

Oh of what do you mean?

quick shoal
neon thunder
#

ok...

#

one sec

#

Here it is

#

I'm going to build a ferris wheel controller block which will manage 12 ferris seats (which can actually seat 2 entities) and I need to know at all times, what the entites are that are riding it and if they are players or not

#

Once I establish that its a player, I do not let them have no riding component else I force them back into the seat they were riding

quick shoal
#

Did U alr have the code now

neon thunder
#

I have the prevent dismount code... ```js
if (ferrisSeat == undefined) {
//if (ferrisPlayer) {
//ferrisSeat = ferrisPlayer.dimension.spawnEntity("mewp:ferrisseat", ferrisPlayer.location);
//}
} else {
if (ferrisPlayer) {
const riding = ferrisPlayer.getComponent("minecraft:riding");
if (!riding || !riding.entity) {
if (ferrisDegrees <= 250 || ferrisDegrees >= 290) {
const rideable = ferrisSeat.getComponent("minecraft:rideable");

                rideable?.addRider(ferrisPlayer);
            } else {
                ferrisPlayer = undefined;
            }
        }
    }
#

But I'm going to need to scan the seats and their riders every "tick" I suspect

quick shoal
#

So what do U want to add rn

#

I will help if I can

neon thunder
#

I need to scan the seat entities's rideable components for entities and determine if they are players. I think I'm good now that I know how to detect the type of the entity

neon thunder
#

And I guess I just give a warning not to log out while riding 😉

quick shoal
neon thunder
#

Oh you can do that??

quick shoal
#

repeat addRide ?

#

I try it first

#

Whats the full code

neon thunder
#

for what sorry?

quick shoal
#

Your Ferris wheel code

neon thunder
#

Well its only testing what happens when I try to control a rideable entity at the moment

#

and moving it around

#

and preventing dismounts

#

You need the rideable entity

quick shoal
#

So U are not actually coded yet?

quick shoal
neon thunder
#

sure

#

You can ride the seat around and around

#

and dismount only when its at the bottom

#

here is the function I call every "tick": ```js
let ferrisPlayer = undefined;
let ferrisSeat = undefined;
let ferrisLoc = {};

let ferrisDegrees = 270;

function ferrisTick() {
if (ferrisSeat == undefined) {
} else {
if (ferrisPlayer) {
const riding = ferrisPlayer.getComponent("minecraft:riding");
if (!riding || !riding.entity) {
if (ferrisDegrees <= 250 || ferrisDegrees >= 290) {
const rideable = ferrisSeat.getComponent("minecraft:rideable");

                rideable?.addRider(ferrisPlayer);
            } else {
                ferrisPlayer = undefined;
            }
        }
    }

    const radius = 11;
    const rads = ferrisDegrees * (Math.PI / 180);
    const z = radius * Math.cos(rads);
    const y = radius * Math.sin(rads);

    const loc = { x: ferrisLoc.x, y: ferrisLoc.y + y, z: ferrisLoc.z + z };

    if (Math.trunc(loc.y) == Math.trunc(ferrisSeat.location.y) && Math.trunc(loc.z) == Math.trunc(ferrisSeat.location.z)) {
        //world.sendMessage(`loc x: ${loc.x}, y: ${loc.y}, z: ${loc.z}`);

        ferrisDegrees += 5;
        if (ferrisDegrees > 360) {
            ferrisDegrees -= 360;
        }
    } else {
        ferrisSeat.teleport(loc);
    }
}

}```

#

and the event to get it going... ```js
world.afterEvents.playerInteractWithEntity.subscribe((event) => {
const { beforeItemStack, player, target } = event;

world.sendMessage("interact after");

if (target.typeId == "mewp:ferrisseat") {
    ferrisPlayer = player;

    if (!ferrisSeat) {
        ferrisSeat = target;
        ferrisLoc = { x: target.location.x, y: target.location.y + 11, z: target.location.z };
        //ferrisSeat.teleport(ferrisLoc);
    }
}

});

#

I had to use teleport because trying to apply impulses wasn't working. Maybe its because Ididn't know what I was doing but oh well

#

Here is the json for the seat entity (in behaviour pack): { "format_version": "1.21.40", "minecraft:entity": { "description": { "identifier": "mewp:ferrisseat", "is_spawnable": true, "is_summonable": true, "is_experimental": true }, "component_groups": {}, "components": { "minecraft:type_family": { "family": [ "vehicle", "ferriswheel" ] }, "minecraft:conditional_bandwidth_optimization": {}, "minecraft:collision_box": { "width": 2, "height": 1 }, "minecraft:damage_sensor": { "triggers": { "deals_damage": "no" } }, "minecraft:persistent": {}, "minecraft:physics": { "has_collision": true, "has_gravity": false }, "minecraft:can_fly": {}, "minecraft:behavior.float": {}, "minecraft:rideable": { "seat_count": 2, "interact_text": "action.interact.ride.minecart", "pull_in_entities": true, "seats": [ { "position": [ -0.4, 0.1, 0.0 ] }, { "position": [ 0.4, 0.1, 0.0 ] } ] } }, "events": {} } }

#

The entity had to have can_fly, behavior.float and no gravity physics to work properly. The collision stuff isn't working I suspect because its rideable.

#

I'm surprised it doesn't try to turn but I haven't enabled any of that kind of thing in the behaviours, I suppose.

quick shoal
#

What thing U lack yet

neon thunder
#

Yeah, if it has a player then it makes sure they keep riding

#

Its a bit strange when you do try to dismount, you do jump out briefly but get grabbed back in

#

Okay, so preventing them from logging out if you say I might be able to do that, that would be nice... And then also, every tick, I need to check the seat for changes in its rideable component's seated entities to see if they are players or not

#

Once I have multiple seats, I need to "attach" one to a player

#

I can't persist all that data so I need to be able to regenerate it on the fly

quick shoal
#
function checkSeatEntities() {
    if (ferrisSeat) {
        const rideable = ferrisSeat.getComponent("minecraft:rideable");
        if (rideable && rideable.seatedEntities.length > 0) {
            rideable.seatedEntities.forEach(entity => {
                if (entity.isPlayer()) {
                }
            });
        }
    }
}

I think can try this to check entity

untold magnet
#

is there any way to detect if the entity gets an explosion near it?

distant gulch
olive rapids
#

Does anyone know how to make a script that makes an arrow disappear when it hits a block?

untold magnet
distant gulch
olive rapids
#

;O

distant gulch
#

yes

olive rapids
#

thank you so much ! ;D ❤️

distant gulch
# untold magnet ping me when finished
world.beforeEvents.explosion.subscribe((event) => {
    const { dimension, source } = event;

    const initialLocation = source.location || event.getImpactedBlocks()[0].location;

    const nearEntities = dimension.getEntities({
        location: initialLocation,
        maxDistance: 12, // can be changed
        closest: true // can be removed if you want to get all entities within the maxDistance
    });
});```
Should work
simple zodiac
distant gulch
neon thunder
#

ok

distant gulch
untold magnet
#

hm, const onFire = entity.getConponent('onfire') should detect when the entity is on fire

#

if (onFire) { ,,, }?

distant gulch
#

wait let me check

untold magnet
#

maybe if (onFire === true) { ,,, }

#

anyways I'll be back soon

distant gulch
#
export class EntityOnFireComponent extends EntityComponent {
    private constructor();
    /**
     * @remarks
     * The number of ticks remaining before the fire goes out.
     *
     */
    readonly onFireTicksRemaining: number;
    static readonly componentId = 'minecraft:onfire';
}
distant gulch
simple zodiac
covert goblet
#

folks am i right in saying you cant have some configuration variables stored in a JSON file and load them in using the Script API??

untold magnet
#

all explosions has radius, when the explosion happens nearby the entity will the radius be detected too or the explosion location only?
trying to explainbao_foxxo_blank

distant gulch
quick shoal
#

For custom knockback

distant gulch
untold magnet
quick shoal
#

The API better or Json?

distant gulch
wary edge
#

@quick shoal please stop crossposting.

quick shoal
distant gulch
# quick shoal The API better or Json?

yourFile > entities > player.json

{
  "format_version": "1.18.20",
  "minecraft:entity": {
    "description": {
      "identifier": "minecraft:player",
      "is_spawnable": false,
      "is_summonable": false,
      "is_experimental": false
    },

    "component_groups": {
      "minecraft:knockback_resistance": {
        "value": 0.6
      }
    }
  }
}
distant gulch
distant gulch
distant gulch
#

sure

quick shoal
distant gulch
#

missing parts are implemented "inside of" minecraft

untold magnet
quick shoal
#

Oh

untold magnet
#

this fog has 25% to spawn from mining sulfur ore in the nether

quick shoal
#

Then the closest property is what

untold magnet
#

whenever the entity sets on fire it will cost the fog to explode

distant gulch
#

Nice, no problem

quick shoal
distant gulch
quick shoal
#

Oh

#

I misunderstanding

distant gulch
#

dont worry

distant gulch
quick shoal
#

Why the people they who made the custom kB doesn't use player.json?

distant gulch
#

hmm, maybe because if you would do it via script you have more control over it

distant gulch
quick shoal
#

If via the script that is so weird

#

And also

distant gulch
#

also a point

quick shoal
#

I found

#

If using script

#

When the player pvping they will have a long range reach

#

💀

distant gulch
#

well

quick shoal
#

I never thought it would be so easy

distant gulch
#

I thin if you do it via scrit you have mroe control over what happens BUT it won't work that fluently

quick shoal
#

I'm just need a ** low knockback **

#

Imma test it now:)

distant gulch
#

then put the value on 0.6-0.9

#

you need to restart the world if you edit entity json files

#

/reload wont work

quick shoal
#

Bro I put 0.4

distant gulch
#

okay

#

use /reload all

#

then the json file will be updated too

quick shoal
#

No I using phone so I always reimport addons and delete world then recreate it

distant gulch
#

uhhh.. okay?

#

(just rejoin the world..)

#

well - idk how it works on MCPE

#

so i better shut up

quick shoal
#

It say

#

Knockback components value doesn't parsed

distant gulch
#

uhh

quick shoal
#

What is that means

distant gulch
#

wait

quick shoal
#

What

untold magnet
#

@distant gulch

world.beforeEvents.explosion.subscribe(({ dimension, source, getImpactedBlocks }) => {
  const iLoc = source.location || getImpactedBlocks()[0].location;
  for (const entity of dimension.getEntities({ location: iLoc, maxDistance: 7 })) {
    if (entity.typeId === 'entity') entity?.triggerEvent('exe:explode') ←←←
  }
})```has a log
#

[Scripting][error]-ReferenceError: Native function [Entity::triggerEvent] does not have required privileges. at <anonymous> (index.js:465)

distant gulch
# quick shoal What

that was the reason why people are using scripts...i i guess player knocback can't be overwritten

untold magnet
#

forgot it was beforeEvent

quick shoal
#

Fine
The issue you're encountering is because the "minecraft:player" entity cannot directly apply the minecraft:knockback_resistance component in this way. The minecraft:player entity is a special built-in entity type in Minecraft Bedrock Edition, and it doesn't follow the same behavior as custom entities in many cases.

distant gulch
#

hah

quick shoal
#

No:(

distant gulch
#

!hah

covert goblet
#

folks, has anybody come across a skyblock quests system, I'm looking for a point in the right direction of how to record and reward players in my realm for simple skyblock-like quests (mine 64 cobble, collect 32 leaf blocks etc) all i can find at the moment are fancy UI's that you tick off manually

wary edge
untold magnet
#

for, some reason

covert goblet
#

Very true @wary edge its the counting/rewarding part i was looking for. I'm ok with creating my own, but its always good to smooth a wheel than re-invent it

untold magnet
#

if (entity.typeId === 'entity' && entity?.isValid()) system.run(() => {entity?.triggerEvent('exe:explode')});

#

is it bec of entity→?←.triggerEvent?

distant gulch
#

wait

#

@untold magnet do

world.beforeEvents.explosion.subscribe(({ dimension, source, getImpactedBlocks }) => {
    const iLoc = source.location || getImpactedBlocks()[0].location,
        entitiesInArea = dimension.getEntities({ location: iLoc, maxDistance: 7, type: 'entity' });

    system.run(() => {
        for (const entity of entitiesInArea) {
            if (!entity.isValid()) continue;
    
            entity.triggerEvent('exe:explode');
        };
    });
});
#

will be more perfomant

untold magnet
distant gulch
#

okay then:

distant gulch
#

and not entity

untold magnet
#

hmm,

distant gulch
#

you want the family of it? like "mob" or "monster" ?

#

@untold magnet ??

distant gulch
#

what then?

untold magnet
#

it just detecting if the fog entity gets an explosion nearby it

#

lemme test if this would work

world.beforeEvents.explosion.subscribe(({ dimension, source, getImpactedBlocks }) => {
  const iLoc = source.location || getImpactedBlocks()[0].location;
  system.run(() => {for (const entity of dimension.getEntities({ location: iLoc, maxDistance: 7, type: 'entity'})) if (!entity?.isValid()) continue; entity?.triggerEvent('event')})
})```
distant gulch
#

should but "type" wont ig

#

@untold magnet this should do it

world.beforeEvents.explosion.subscribe(({ dimension, source, getImpactedBlocks }) => {
    const initLocation = source.location || getImpactedBlocks()[0].location;

    system.run(() => {
        const entitiesInArea = dimension.getEntities(
            { location: initLocation, maxDistance: 7 }
        );

        for (const entity of entitiesInArea) {
            if (!entity.isValid()) continue;
    
            entity.triggerEvent('exe:explode');
        };
    });
});
warm mason
distant gulch
#

well if source is undefined it should take the first block but when its empty we got a problem

warm mason
#

I don't see "?" in source.location

distant gulch
#

ohh my bad i forgot it

#

@untold magnet use this - Thanks for the remark @warm mason

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

world.beforeEvents.explosion.subscribe(({ dimension, source, getImpactedBlocks }) => {
    const initLocation = source?.location || getImpactedBlocks()[0].location;

    if (!initLocation) return;

    system.run(() => {
        const entitiesInArea = dimension.getEntities(
            { location: initLocation, maxDistance: 7 }
        );

        for (const entity of entitiesInArea) {
            if (!entity.isValid()) continue;
    
            entity.triggerEvent('exe:explode');
        };
    });
});
warm mason
#

Well, it will also give an error if the array of blocks is empty

distant gulch
#

ughhh i saw it

#

waiiiiit

untold magnet
warm mason
#

By the way, why use beforeEvents?

distant gulch
#

it was like an instinct to use it

#

but maybe afterEvent would be better

#

due i dont need to run system.run

warm mason
#

Because mega bugs are mojang when the entity is in front of your face but it is not valid #1067535608660107284 message

distant gulch
#

right right, wait

#
world.afterEvents.explosion.subscribe(({ dimension, source, getImpactedBlocks }) => {
    const initLocation = source?.location || getImpactedBlocks()[0]?.location;

    if (!initLocation) return;

    const entitiesInArea = dimension.getEntities(
        { location: initLocation, maxDistance: 7 }
    );

    for (const entity of entitiesInArea) {
        entity.triggerEvent('exe:explode');
    };
});
#

Thats should fixxxx it

#

looks so much cleaner now

warm mason
distant gulch
untold magnet
untold magnet
#

errors logs both hurts

#

edit this

world.afterEvents.explosion.subscribe(({ dimension, source, getImpactedBlocks }) => {
  const iLoc = source.location || getImpactedBlocks()[0].location
  if (!iLoc) return;
  const entities = dimension.getEntities({ location: iLoc, maxDistance: 7 });
  for (const entity of entities) if (entity.typeId === 'entity' && entity.isValid()) entity.triggerEvent('event')
})```if needed
distant gulch
#

@warm mason since you are here

#

i gotta go

#

:))

warm mason
untold magnet
#

bec i have no idea how

distant gulch
# warm mason I changed my mind about writing this
function getAverageBlockLocation (blocks) {
    if (blocks.length === 0) { return null; };

    const blocksLength = blocks.length;
    let xSum = 0, ySum = 0, zSum = 0;
    
    for (const block of blocks) {
        const { x, y, z } = block.location
        xSum += x; ySum += y; zSum += z;
    };  
    
    return {
        x: xSum / blocksLength,
        y: ySum / blocksLength,
        z: zSum / blocksLength
    };
};
untold magnet
untold magnet
distant gulch
# untold magnet same log
world.afterEvents.explosion.subscribe(({ dimension, source, getImpactedBlocks }) => {
    const initLocation = source?.location || getAverageBlockLocation(getImpactedBlocks());

    if (!initLocation) return;

    const entitiesInArea = dimension.getEntities(
        { location: initLocation, maxDistance: 7 }
    );

    for (const entity of entitiesInArea) {
        entity.triggerEvent('exe:explode');
    };
});

function getAverageBlockLocation (blocks) {
    if (blocks.length === 0) { return null; };

    const blocksLength = blocks.length;
    let xSum = 0, ySum = 0, zSum = 0;
    
    for (const block of blocks) {
        const { x, y, z } = block.location
        xSum += x; ySum += y; zSum += z;
    };  
    
    return {
        x: xSum / blocksLength,
        y: ySum / blocksLength,
        z: zSum / blocksLength
    };
};
untold magnet
distant gulch
#

well, yes

#

you can round the coords

untold magnet
#

howbao_foxxo_blank

distant gulch
#

Reasons

#

1 to be exact

untold magnet
distant gulch
#

no

#

different ones

#

btw use this as return ```js
return {
x: Math.round(xSum / blocksLength),
y: Maph.round(ySum / blocksLength),
z: Math.round(zSum / blocksLength)
};

#

will be better

untold magnet
#

it now has math

distant gulch
#

Yes

#

Maph

#

(typo)

#

@untold magnet

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

world.afterEvents.explosion.subscribe((event) => {
    const initLocation = event.source?.location
        || getAverageBlockLocation(event.getImpactedBlocks());

    if (!initLocation) return;

    const entitiesInArea = event.dimension.getEntities(
        { location: initLocation, maxDistance: 7 }
    );

    for (const entity of entitiesInArea) {
        entity.triggerEvent('exe:explode');
    };
});

function getAverageBlockLocation (blocks) {
    if (blocks.length === 0) { return null; };

    const blocksLength = blocks.length;
    let xSum = 0, ySum = 0, zSum = 0;
    
    for (const block of blocks) {
        const { x, y, z } = block.location
        xSum += x; ySum += y; zSum += z;
    };  
    
    return {
        x: Math.round(xSum / blocksLength),
        y: Math.round(ySum / blocksLength),
        z: Math.round(zSum / blocksLength)
    };
};
#

This should be the final

untold magnet
distant gulch
#

what

#

well you would need to add a if statement

untold magnet
#

the event 'exe:explode' isn't for every entity

#

lemme try it and see

distant gulch
#

either use entity.typeId or his "family"

untold magnet
#

first of all, no edits or changes

#

I'll test it out without doing anything

#

if it works fine I'll edit it a bit

distant gulch
#

alr

untold magnet
#

const initLocation = event.source?.location here

distant gulch
#

how

wary edge
#

Ok this needs to be moved to a post now.

distant gulch
distant gulch
untold magnet
#

@distant gulch, should we try to unsubscribe it?

#

also what the actual hell will the unsubscribe will do to the event?

distant gulch
#

take "unsubscribe" by word

untold magnet
#
        const entities = entity?.dimension.getEntities({location: entity?.location, maxDistance: 1});
        for (const eEntity of entities) {eEntity?.addEffect('poison', 1, {amplifier: 1, showParticles: false}); eEntity?.addEffect('blindness', 3, {showParticles: false})};```is not working
#

it should

#

detect entities around my specific entity in 1 block radius

#

and give them 2 effects

#

^ no logs

distant gulch
#

try

#

debugging

#

best way

quick shoal
distant gulch
#

what?

quick shoal
#

Bot is down

distant gulch
#

i meant with console.warn

quick shoal
#

Oh

distant gulch
#

Console.warn is the best way in my op.

untold magnet
distant gulch
#

try everything

#

.. typeof entity

#

.. entity

#

typeof entities.length

#

typeof entities

#

Maybe entities arent found or entity is undefined

untold magnet
distant gulch
#

nah

#

only needable when you got a entity and you want to use it a tick later

untold magnet
#

console.warn(typeof entities.length) ill try this

distant gulch
#

sure

#

it can throw errors because entities can be undefined

untold magnet
#

lemme test something else

distant gulch
#

if you do typeof it will always return anything

untold magnet
#

the entire interval is broken

#

somehow

distant gulch
#

lol

untold magnet
#

fixed

distant gulch
#

good

untold magnet
#

it will give u fetal poison, which means if u stay there for a while u will die

distant gulch
#

nice

#

Nice

#

good then we got it

#

at the end we needed to use beforeEvent

#

If anything is, just dm me ahgain

untold magnet
distant gulch
#

yes...

#

maybe i know why this error appeared

#

source: (the exploding entity) we used afterEvent. so it isnt existant at this moment

#

gtg

quick shoal
#

Guys how to use

damaingEntity

option in applyDamage

quick shoal
#

Is apply damage like this?

#
p2.applyDamage(0, {
            cause: EntityDamageCause.entityAttack,
            damagingEntity: p1
        });
gaunt salmonBOT
gaunt salmonBOT
# quick shoal ```js p2.applyDamage(0, { cause: EntityDamageCause.entityAttack, ...

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 2 errors:

<REPL0>.js:1:1 - error TS2304: Cannot find name 'p2'.

1 p2.applyDamage(0, {
  ~~

``````ansi
<REPL0>.js:3:29 - error TS2304: Cannot find name 'p1'.

3             damagingEntity: p1
                              ~~

Lint Result

There are no errors from ESLint.

dim tusk
quick shoal
#

Okay

distant tulip
north depot
#

there is any bug related to 'minecraft:block_face' state and getState, getAllStates?

quick shoal
dim tusk
dim tusk
north depot
#

How can i place only one of the list?

listBlock[Math.floor(Math.random() * listBlock.length)]

north depot
#

nop, Did you wanna check the list?

#

const listBlock = [
block.setPermutation(BlockPermutation.resolve(${block.typeId}, configStates)),
block.setPermutation(BlockPermutation.resolve(${block.typeId}, configStates)),
block.setPermutation(BlockPermutation.resolve(${block.typeId}, configStates)),
block.setPermutation(BlockPermutation.resolve(${block.typeId}, configStates))
]

#

it places all list... :c

wary edge
#

I...do not see any difference between the elements?

north depot
#

wdym?

wary edge
#

What are you trying to achieve, exactly?

north depot
#

a expand block event.... 👉 👈
after interact with a item it will placed only one the variables at a time...

wary edge
#

Right...but...all those elements are exactly the same no?

north depot
#

in my file, no.... 👀

#

do you want to see that part?

#

with using the runCommand and on the list the {}, i didnt had that issue...

wary edge
#

So the issue is just the blocks then? Perhaps not referencing the proper blocks?

north depot
#

no, the issue is because its placing all the blocks of list...

wary edge
#

What is blockNorth?

north depot
#

i just want one for each interact...

north depot
wary edge
#

What happems if yoi do listBlocks[0]?

north depot
#

where in the const ?
or the part with math?

wary edge
steady canopy
#

Does someone know why when i try to set dynamic properties in my item it says "Cannot set dynamic properties on stackable items" but this item isn't stackable, it's max _stack_size is 1 and it was working good before.

#

This is my item json

{
    "format_version": "1.20.0",
    "minecraft:item": {
        "description": {
            "identifier": "item",
            "category": "Items"
        },
        "components": {
            "minecraft:max_stack_size": 1,
            "minecraft:icon" : {
                "texture": "item"
            }        
        }
    }
}
wary edge
north depot
#

there? with 0, 1, any number, its the same, it placed all at the same time

wary edge
#

Could you make a post and upload the full thing.

north depot
#

there is a post... xD

steady canopy
distant gulch
#

cant player.runCommandAsync(`setmaxplayers 5); ?

warm mason
distant tulip
#

setmaxplayers need high permission level i think

quick shoal
#

Guys

#

Who can fix this pls

quick shoal
ruby haven
#

Is there any way I can disable the ability of the player to look around cause I tried it on the behavior side by adding a movement:basic property with a value of zero but it doesn't work so I wonder if I can achieve that in scripts

subtle cove
quick shoal
subtle cove
#

;-;

#
getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined
```this should make sense
#

that's why there's no need to register em,
altho u should create a function if u need defaults

chilly fractal
#

Oh yea vec3s not date object

#

Sorry my mind is just a bit uhh, foggy rn

steady zinc
#

Is there a way to detect what potion effect a splash potion did when hitting an entity?

quick shoal
#

@subtle cove can U help me a bit

#

Just that error

#

Idk how

distant gulch
#

get the direction im looking at with getViewdirection(); and draw a straight line in the direction you are looking at? (Straight line is shown with particles)

quick shoal
idle dagger
#

How do I make it with 3-4 arguments?

world.structureManager.place("charge", overworld, x, -60, z);

quick shoal
#
world.structureManager.place('test', dimension, { x:0, y:0, z:0 }, { integrity: 1, animationMode: "Layers", animationSeconds: 1 });

@idle dagger

idle dagger
#

I need place it at defined x, y and z

quick shoal
#

Oh

#

Wait

quick shoal
#

I changed

#

@idle dagger

#

Btw U need to const dimension

#
const dimension = world.getDimension('overworld');
#

@idle dagger is it worked?

#

@idle dagger

#

@idle dagger tell me if it working

idle dagger
#

k wait

quick shoal
#

Ok

sharp elbow
#

You don't need to be so aggressive in getting an answer. Go take a walk

quick shoal
quick shoal
quick shoal
#

Just idk how to use property registry

sharp elbow
#

The documentation is completely worthless this time around

idle dagger
sharp elbow
#

I'm not familiar enough with world initialization to know right this second, sorry

quick shoal
#

Oh

#

Nvm

#

What are U changed @subtle cove

subtle cove
quick shoal
#

What U changed

subtle cove
quick shoal
#

Wdym

#

Can it work normally

subtle cove
#

yes

quick shoal
#

Thank U so much

subtle cove
#

the way the entity gets defined there seems okay

quick shoal
#

I will test it

#

U help me a big

#

@subtle cove

#

The vector is has problem too

#

It said vector is not export member at minecraft/server

#

Wait

#

The code is not have vector

#

But the contents log said

#

Oh

#

Is the other file

subtle cove
#

wrong file ;-;

quick shoal
#

How

#

Change it to vector3?

#
import { Vector, ItemStack } from '@minecraft/server'
import { ChestUI, Page, Button, exitUI } from './YBchestUI/ChestUI'

new ChestUI('home')

const home_btn = new Button(0, '回首頁', { icon: 'bed', pageAfterClick: 'home' })

new Page('home')
    .newButton(13, '進入', { icon: 'acacia_door', pageAfterClick: 'menu' })
    .sameButton({ from: 0, to: 9 }, '背景', { icon: 'camera' })
    .sameButton({ from: 17, to: 26 }, '背景', { icon: 'camera' })

new Page('menu',
    home_btn,
    new Button(11, '傳送至大廳', {
        icon: 'ender_pearl', onClickFunc(v) {
            exitUI(v.player, true, true)
            v.player.teleport(new Vector(0.5, -60, 0.5))
            v.player.playSound('mob.endermen.portal')
        }
    }),
    new Button(13, '播放音效', {
        icon: 'goat_horn', onClickFunc(v) {
            v.player.playSound('mob.enderdragon.growl')
        }
    }),
    new Button(15, '獲得食物', {
        icon: 'beef_cooked', onClickFunc(v) {
            v.inventory.addItem(new ItemStack('minecraft:cooked_beef', 1))
            v.player.playSound('random.orb')
        }
    })
)
#

This file

subtle cove
#
import { ItemStack } from '@minecraft/server'
import { ChestUI, Page, Button, exitUI } from './YBchestUI/ChestUI'

new ChestUI('home')

const home_btn = new Button(0, '回首頁', { icon: 'bed', pageAfterClick: 'home' })

new Page('home')
    .newButton(13, '進入', { icon: 'acacia_door', pageAfterClick: 'menu' })
    .sameButton({ from: 0, to: 9 }, '背景', { icon: 'camera' })
    .sameButton({ from: 17, to: 26 }, '背景', { icon: 'camera' })

new Page('menu',
    home_btn,
    new Button(11, '傳送至大廳', {
        icon: 'ender_pearl', onClickFunc(v) {
            exitUI(v.player, true, true)
            v.player.teleport({ x: 0.5, y: -60, z: 0.5 })
            v.player.playSound('mob.endermen.portal')
        }
    }),
    new Button(13, '播放音效', {
        icon: 'goat_horn', onClickFunc(v) {
            v.player.playSound('mob.enderdragon.growl')
        }
    }),
    new Button(15, '獲得食物', {
        icon: 'beef_cooked', onClickFunc(v) {
            v.inventory.addItem(new ItemStack('minecraft:cooked_beef', 1))
            v.player.playSound('random.orb')
        }
    })
)
#

{x,y,z} is enuf

quick shoal
#

I alr know this method but I'm not ensure before

subtle cove
#

Vector3 is basically {x,y,z}
Vector2 {x,y}
-# iirc

quick shoal
#

Oh

#

What situation will need import Vector3 @subtle cove ?

subtle cove
#

the old Vector class had methods like add, subtract, distance of two vectors

quick shoal
#

So the export member is now removed by mojang?

subtle cove
quick shoal
#

@subtle cove ar U remove the export in the file just now?

#

It cause erro

#

Wait it original not exist

ruby haven
#

Is it possible to run a command before a player spawns in the world

quick shoal
#

Yes

#

@subtle cove can U help me change again the file

ruby haven
#

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

world.afterEvents.entityLoad.subscribe((data) => {
const player = data.source;
})

I just want the player to be the executor in running a command how do I do it

quick shoal
#

Because the file I give at begin is changed by ai

ruby haven
#

So after an entity.loads the player will run the command

quick shoal
quick shoal
# quick shoal

@subtle cove same problem, but this is DynamicPropertiesDefinition

#

Just use the method U used just now

#

Sry for the rehelp

ruby haven
quick shoal
#

Wait

ruby haven
#

Cause after the player spawns I will run a command where the player can't move so he will be forced to watch a cutscene

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

world.afterEvents.playerSpawn.subscribe(({ player, initialSpawn }) => {
    if (initialSpawn) {
    
    }
});

@ruby haven

ruby haven
#

What does initial spawn checks?

quick shoal
#

If not joined spawn event it will return

ruby haven
quick shoal
ruby haven
quick shoal
quick shoal
#

Or U just tell me how solve thiis

#
[Scripting][error]-Plugin [api play - 1.0.0] - [Main.js] ran with error: [SyntaxError: exported variable 'setPlayerPage' does not exist]
gaunt salmonBOT
# quick shoal

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 8 errors:

ChestUI.js:1:38 - error TS2305: Module '"@minecraft/server"' has no exported member 'DynamicPropertiesDefinition'.

1 import { world, system, EntityTypes, DynamicPropertiesDefinition, Player, Vector } from '@minecraft/server';
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~

``````ansi
ChestUI.js:1:75 - error TS2724: '"@minecraft/server"' has no exported member named 'Vector'. Did you mean 'Vector2'?

1 import { world, system, EntityTypes, DynamicPropertiesDefinition, Player, Vector } from '@minecraft/server';
                                                                            ~~~~~~

``````ansi
ChestUI.js:3:74 - error TS2792: Cannot find module './exports'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?

3 import { Entrance, Page, Button, UIerror, checkTypes, ICON, ICONR } from './exports';
                                                                           ~~~~~~~~~~~

``````ansi
ChestUI.js:154:11 - error TS2339: Property 'propertyRegistry' does not exist on type 'WorldInitializeAfterEvent'.

154         e.propertyRegistry.registerEntityTypeDynamicProperties(player_def, EntityTypes.get('minecraft:player'));
              ~~~~~~~~~~~~~~~~

``````ansi
ChestUI.js:157:11 - error TS2339: Property 'propertyRegistry' does not exist on type 'WorldInitializeAfterEvent'.

157         e.propertyRegistry.registerEntityTypeDynamicProperties(entity_def, EntityTypes.get('yb:inventory'));
              ~~~~~~~~~~~~~~~~

``````ansi
ChestUI.js:184:24 - error TS2339: Property 'itemDefinitionEvent' does not exist on type 'WorldBeforeEvents'.

184     world.beforeEvents.itemDefinitionEvent.subscribe((e) => {
                           ~~~~~~~~~~~~~~~~~~~

``````ansi
ChestUI.js:206:29 - error TS2339: Property 'selectedSlot' does not exist on type 'Player'.

206         const slot = player.selectedSlot;
                                ~~~~~~~~~~~~

``````ansi
ChestUI.js:221:38 - error TS2345: Argument of type 'string | number | boolean | Vector3' is not assignable to parameter of type 'string'.
  Type 'number' is not assignable to type 'string'.

221         var player = world.getEntity(entity.getDynamicProperty('ownerID'));
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Lint Result

ESLint results:

ChestUI.js

159:9 warning The /tag command can be fully replaced with the Entity.addTag api in the @minecraft/server module. See https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entity#addtag for more information. minecraft-linting/avoid-unnecessary-command

160:9 warning The /tag command can be fully replaced with the Entity.addTag api in the @minecraft/server module. See https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entity#addtag for more information. minecraft-linting/avoid-unnecessary-command

quick shoal
#

It's so hard to fix

granite badger
#

well you don't need DynamicPropertiesDefinition, it's outdated.
Vector is also an outdated class, so remove it

quick shoal
#

But idk how remove

#

I afraid of I will removed the important part

subtle cove
#

whats the itemDefinitionEvent for?

quick shoal
#

Idk

#

Oh

#

ItemUse I think

#

I really can't fix that

#

Plz help

subtle cove
#

yb:seek?

quick shoal
#

That is custom item

#

Wait

#

Lemme see

#

Bruh

#

That things

#

Is use for

#

See the vaild Icon(item at chest gui

subtle cove
#

i cant find any item event to use for that

quick shoal
#

Idk

#

U just

#

Change to itemUse

subtle cove
quick shoal
#

Yea

subtle cove
#

k

quick shoal
#

I found in items folder

#

I have try to fix it by myself

#

But it always goes error

#

Especially the export issues

#

I have no idea what caused it.

#

But the issue maybe is did by me

#

@subtle cove did U could fix the code?

subtle cove
gaunt salmonBOT
north depot
#

can i remove variables from a const after i already set up?
like this:

const listVariables = [Varible1,Varible2,Varible3,Varible4]
if (//a simple check filter//) {
listVariables - Variable2
}

wary edge
north depot
#

question...
i need to use index, indexOf(#V), and splice?

#

nevermind i figure it out...

#

i need all 3

#

Xd

#

correction....
only the last one its necessary

jolly citrus
#

is it possible to make custom slash commands yet

jolly citrus
#

sad

chilly fractal
#

It's not stable yet which means mojang has got plans to change it in the feature.

jolly citrus
#

for registering a command

warm mason
jolly citrus
#

there would be no way to display it in the list of command suggestions if they were to be checked through a chat event

chilly fractal
jolly citrus
#

but u were replying to my inquiry about custom slash commands so i mean i figured

chilly fractal
#

Yes I was replying telling you that the current state of the event is unfinished.

warm mason
#

Then what does the event have to do with it?

jolly citrus
#

anyone have a good way of detecting inventory slot interaction like clicking on a slot with an item

#

i need to be able to read the item stack of the slot its moved to as well

chilly fractal
jolly citrus
chilly fractal
#

You mean detecting when a player moves an item?

jolly citrus
#

idk if you've seen what i mean but for example on a lot of java servers you can apply things like enchanted books to items by clicking with them on the item you want to enchant

chilly fractal
#

Ye

jolly citrus
#

ϟ ViperMC | FULL NETWORK SERVER | Infernal / Kits / Practice EU/US & Hub!

➛ Paypal Price: $3.20 USD
➛ BUY FROM: https://hsdevs.tebex.io/package/4819829

➛ Website: http://hsdevs.xyz
(HSDevs | Official New Website).
➛ Discord: http://discord.hsdevs.xyz
(HSDevs | Official Discord Server).

❃ Hub Setup Information:

  • ViperMC Builds ...
▶ Play video
#

watch it from the timestamp i set

random flint
#

Possible, but it's sloppy

jolly citrus
#

i need any reliable way that wont be too bad performance wise

chilly fractal
#

I don't think there is a performance wise way

#

Nah

random flint
#

Check each item change in inventory :D

jolly citrus
#

is the only way the way i suggested?

#

save old inventory from last tick and compare?

chilly fractal
#

It's laggy.

#

Ye

random flint
jolly citrus
#

bc i feel like with 10-11 players it will become very bad performance wise

chilly fractal
random flint
jolly citrus
#

how do i detect it being necessary if they can click on the item with an enchanted book at pretty much any time

chilly fractal
warm mason
#

If the player's speed = 0, he does not move, which means the inventory can be opened

random flint
jolly citrus
#

crash server method = spam swap items in your inventory with 10 alt accounts

warm mason
random flint
#

preview maybe

chilly fractal
warm mason
chilly fractal
#

"Not used on touch controls"

chilly fractal
#

Ima try to make some script, yall improve it

warm mason
#

But this does not prevent mojangs from using this function on all devices

chilly fractal
#

Idk how to make inv saving & checking performant

#

I'll try my best tho

warm mason
#

In our case, we need to check the swap of equipment and books

random flint
# jolly citrus smart

Here's a better idea: Instead of doing the "drag and drop" mechanic, why not just "use and select"?

jolly citrus
#

give an example of "use and select"

random flint
#

Right-click the enchant book (on the Hotbar)
Scroll to other slots
Then right-click your equipment (on the Hotbar)

or

Enchant book on the offhand.
Equipment on the mainhand.
Right-click to apply "enchantment"

jolly citrus
random flint
#

You can make a custom Item look like a book without a resource pack

jolly citrus
#

no

#

and positioning

warm mason
#

I wanted to write this code, but I got lazy

jolly citrus
#

if the user has a custom pack enabled

#

and uses like 32x or 64x for book

#

it will look gigantic

#

and the orientation when held is also off

random flint
chilly fractal
#
import { world, system } from "@minecraft/server";
let iS = {}; // Inventorys
function compareItems(i1, i2) { // Item 1, Item 2
  let aC = ['lore', 'canPlaceOn', 'canDestroy']; // Array Components
  for (let k in aC) {
    if (i1[k].length !== i2[k].length) return false;
    if (i1[k].filter((v, _) => i1[k][_] == i2[k][_]).length !== i1[k].length) return false;
  }
  
  let cC = ['typeId', 'amount', 'lockMode', 'keepOnDeath']; // Constant Components (Like Not Array, I Should Change the Name...)
  for (let c of cC) {
    if (i1[c] !== i2[c]) return false;
  }
  return true;
}

function sI(p) { // Save Inv, Smaller Names For Tiny Micro Optimizations
  let iC = p.getComponent('inventory').container;
  for (let i = 0; i < iC.size; i++) {
    let I = iC.getItem(i);
    if (!iC) continue;
    iS[p.id][i] = I;
  }
}

function cI(p) { // Compare Inv, Smaller Names For Tiny Micro Optimizations
  let iC = p.getComponent('inventory').container;
  for (let i = 0; i < iC.size; i++) {
    let I = iC.getItem(i);
    if (compareItems(I, iS[p.id][i])) continue;
    // Code For Being Different ItemStack
  }
}

system.runInterval(() => {
  // idk
}, 3);

Some Basic Code, Y'all Can Go On Right?

jolly citrus
#

what are these variable names

#

thank you tho

chilly fractal
chilly fractal
#

Ain't clear

jolly citrus
#

apart from file size

chilly fractal
#

It does optimize but "Tiny Micro Optimizations" Very very little, basically unnoticeable..................

#

Probably

warm mason
#

For small optimizations it is better to use loops in the format (let i =0; i < 123...)

#

They are faster, I checked

chilly fractal
#

Yeah, just compareItems I didn't do that, cuz it was just a yeeted function I just had lying around in my blissSMP addon

#

I never actually used it so ye

#

I cared less about it (at that time)

remote oyster
# chilly fractal Yeah you can see on the comments, "Smaller Names For Tiny Micro Optimizations"

Very short variable names like that only make it difficult to read and understand what is going on and what they represent. Especially when you return back to the code at a later date. There really isn't any noticeable benefits for doing that with the JavaScript engine these days. Their lengths have no significant impact on performance. Bottlenecks are typically related to algorithms, data structures, or I/O operations, not variable name length.

chilly fractal
#

Welp at least my addon is unreadable, so I just obfuscate it and even if one does deobfuscate it they'll have absolutely no idea what the code means :)

#

Cool perk from doing dumb shii ig

remote oyster
#

Lol

chilly fractal
#

Oh Gemini can reverse engineer my voodoo rituals that I did to my code..

#

Nah ima just troll my friends with this

remote oyster
#

Gega has been typing for a long while now 👀

chilly fractal
#

Yea

#

Is bro making a stanza or a poem or a book or what?

remote oyster
#

Lol

chilly fractal
#

Nahhhhhh

remote oyster
#

@random flint you did not just type all that time and stop lol

chilly fractal
#

Bruh you tempted me this long? Nvm.

remote oyster
#

I'm invested haha

chilly fractal
#

Same fr

random flint
# chilly fractal ```js import { world, system } from "@minecraft/server"; let iS = {}; // Invento...

In my theory, Custom enchantments "drag and drop" mainly check for three states on each slot:

  • Is an Empty Slot
  • Is an Enchant Book
  • Else (Equipment, Unenchantable)

So basically you only want to check for slots that have the enchanted book first. Then, if the slot becomes empty, it assumes the player has picked it up.

Check each tick again, if the player decides to drop the book, or place it on another container.

If the player decides to just not enchant anything, their emptySlotsCount would increase since they're putting back the enchanted book on an empty slot.

Otherwise, we kept checking the filled slots if they suddenly changed into a book.

This process probably took a soft copy of what each filled slot has to compare it.

If it's found, then stop the check, and began "enchanting" or smt, idk...

remote oyster
#

I was expecting it to be way longer than that 😂😂😂😂

random flint
chilly fractal
remote oyster
chilly fractal
#

If it was me.... Nahhhhh I wanna wait a long time, but for something worth the wait.

random flint
remote oyster
#

Lol

chilly fractal
#

And go get some sleep

random flint
chilly fractal
dim tusk
distant tulip
inland merlin
#

any way to get the world current setworldspawn coords?

inland merlin
#

thank you

#

i forgot if there was something

jolly citrus
#

is there an event for when a player fires a projectile

warm mason
#

But you can use entitySpawn and check what you need

jolly citrus
jolly citrus
#

sometimes it works sometimes it doesnt

dim tusk
remote oyster
#

☝️

jolly citrus
jolly citrus
#

but the thing is i also need to know what itemstack they sent the projectile out of

jolly citrus
#

you said get the owner

#

on projectileHitEntity

jolly citrus
# dim tusk Huuuh?

when another ntity gets hit by the projectile that causes this event to fire, it has a property that tells you who threw the particle? is that what u mean

remote oyster
jolly citrus
#

stop acting dumb you knew exactly what i meant bro

#

🤦

jolly citrus
dim tusk
# jolly citrus projectile
// Script by WavePlayz

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

// Subscribe to the `projectileHitEntity` event, which is triggered when a projectile hits an entity
world.afterEvents.projectileHitEntity.subscribe((eventData) => {
    // Destructure the eventData to get the source entity (the one that shot the projectile)
    const { source } = eventData;

    // Get the entity that was hit by the projectile
    const hitEntity = eventData.getEntityHit()?.entity;

    // Check if the hitEntity is valid
    if (hitEntity) {
        // Extract the x, y, and z coordinates from the hitEntity's location
        const { x, y, z } = hitEntity.location;

        // Create a string representing the coordinates in the format "x, y, z"
        const coordinates = `${x}, ${y}, ${z}`;

        // Construct a message indicating which player hit which entity and where
        const message = `${source.name} hit the entity at location ${coordinates}`;

        // Send the message to all players in the world
        world.sendMessage(message);

        // Immediately kill the hit entity
        hitEntity.kill();
    }
});```
warm mason
#
world.afterEvents.entitySpawn.subscribe(data => {
  let entity = data.entity
  system.runTimeout(() => {
    if (!entity.isValid()) return
    let comp = entity.getComponent("minecraft:projectile")
    if (comp && comp.owner?.typeId == "minecraft:player") {
      playerShot(comp.owner, entity)
    }
  })
})

function playerShot(player, projectile) {

}
warm mason
dim tusk
jolly citrus
#

there's no need to question it if you actually did not get confused by it

#

mistakes happen, i thought about particles so my brain decided to type out particle instead of projectile

warm mason
dim tusk
#

Not worth it to fight, small things just forget it

jolly citrus
#

i need to get the info of the item stack the projectile was thrown out of

#

but i only need that info when an entity is hit by that very projectile

warm mason
jolly citrus
#

thanks

#

seems like it would work im just concerned about them swapping slots after shooting

warm mason
dim tusk
#

Kinda need small help, i want to create a bounding box in two locations, imagine the structure block bounding box one... I store the location in point1 and point2

#

My smol brain kinda forget how to do this..
-# excuse cause I'm tired asf

sharp elbow
#

Sounds like you already know what to do. Unless you need help with something specific?

quick shoal
#

guys who know how remove shade of locked item

distant tulip
north depot
#

can some one throw me docs or can tell me...
how can i use:
return;
i use it to avoid things, like a cancel.event
buts some time i saw some files likes:
return; something;
how does that work?

#

please...

lavish surge
north depot
lavish surge
north depot
#

any way thank you was hoping it maybe be like a 'callback checkpoint' or something like that

valid ice
distant gulch
#

guys can you help me make a cooldown system for my tool. I'm trying to use this code but it not working.

const CooldownComponent = {
onHitEntity({ attackingEntity, source }) {
// Ensure the source is a player
if (!(source instanceof Player)) return;

    // Get the equippable component from the player
    const equippable = source.getComponent("minecraft:equippable");
    if (!equippable) return;

    // Get the mainhand item
    const mainhand = equippable.getEquipmentSlot(EquipmentSlot.Mainhand);
    if (!mainhand.hasItem()) return;

    // Retrieve the item
    const item = mainhand.getItem();
    const itemTags = item.getTags(); // Retrieve all tags of the item

    // Check tags and apply corresponding weakness effect
    if (itemTags.includes("minecraft:is_hoe")) {
        attackingEntity.addEffect("weakness", 12, {
            amplifier: 1,
            showParticles: false
        });
    } else if (itemTags.includes("minecraft:is_pickaxe")) {
        attackingEntity.addEffect("weakness", 15, {
            amplifier: 1,
            showParticles: false
        });
    } else if (itemTags.includes("minecraft:is_sword")) {
        attackingEntity.addEffect("weakness", 15, {
            amplifier: 1,
            showParticles: false
        });
    } else if (itemTags.includes("minecraft:is_axe")) {
        attackingEntity.addEffect("weakness", 24, {
            amplifier: 1,
            showParticles: false
        });
    } else if (itemTags.includes("minecraft:is_shovel")) {
        attackingEntity.addEffect("weakness", 15, {
            amplifier: 1,
            showParticles: false
        });
    }
}

};

world.beforeEvents.worldInitialize.subscribe(({ itemComponentRegistry }) => {
itemComponentRegistry.registerCustomComponent("hollow:cooldown", CooldownComponent);
});

dim tusk
#
function CooldownComponent = {
   // code //
}

world.beforeEvents.worldInitialize.subscribe(({ itemComponentRegistry }) => {
   itemComponentRegistry.registerCustomComponent('hollow:cooldown', CooldownComponent);
});```
chilly fractal
distant gulch
#

-# Burn the Witch!!

ruby haven
#

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

world.afterEvents.playerSpawn.subscribe(({ player, initialSpawn }) => {
if (initialSpawn) {
player.runCommand("function movenot");
player.runCommand("scoreboard objectives add Trauma dummy");
player.runCommand("scoreboard players add @s Trauma 10");
player.runCommand("scoreboard objectives add Days dummy");
player.runCommand("scoreboard players add @s Days 30");
}
});

As you can see in the script there Is a Days dummy and I want to make a system where the moment the value of the scoreboard dummy named Days becomes 0 I want to run a command the player is the one executing it

ruby haven
#

Scripting is hard

quick shoal
#

Sry

#

What do U trying to do

ruby haven
#

Do you know scoreboards?

quick shoal
#

Ye

#

Oh

#

Wait

#

I think I understand

ruby haven
# ruby haven Do you know scoreboards?

You see I added a Days dummy to the player and a gave it a value of 30 to represent the time before the player dies so everytime a day passes the 30 is being subtracted by 1 which I already made the problem is I don't know how to detect when the the Days dummy value becomes 0 so I can run a command

quick shoal
#

U can just use scoreboard class

#

sadly I never learned at that

#

But I will try

warm mason
warm mason
#

No, I’m just writing what I came up with.

quick shoal
#

Oh U want getScore of dummy not a player?

#

Okey

warm mason
quick shoal
#

I will try it

quick shoal
#

Wait

#

Bro

#

I misunderstood

#

I thought serty is U @ruby haven

ruby haven
#

Oh no hahaha

warm mason
quick shoal
#

My eyes 😵‍💫

quick shoal
#

Lemme try first

warm mason
#

I already told him how to do it

ruby haven
#

Okay thanks bro if you need help other than scripting you can ask help for me

quick shoal
#

I think I must goto check docs

warm mason
#

For what

quick shoal
#

Dummy or player

warm mason
#

He needs to check whether the value has reached 0

quick shoal
#

Nvm

#

I'm just learn that

#

I think if we need deduct score can do like this

addScore(dummy, -1)?
#

@ruby haven wait a moment if U can't do it yourself I will help u

quick shoal
ruby haven
#

To detect when the score becomes 0

ruby haven
#

Wait serty how do I add it in this code import { world, system } from "@minecraft/server";

world.afterEvents.playerSpawn.subscribe(({ player, initialSpawn }) => {
if (initialSpawn) {
player.runCommand("function movenot");
player.runCommand("scoreboard objectives add Trauma dummy");
player.runCommand("scoreboard players add @s Trauma 10");
player.runCommand("scoreboard objectives add Days dummy");
player.runCommand("scoreboard players add @s Days 30");
}
});

warm mason
#
system.runInterval(() => {
  for (let player of world.getAllPlayers()) {
    if (world.scoreboard.getObjective("Days").getScore(player) <= 0) {
      player.sendMessage("Time over")
    }
  }
})
quick shoal
#

So I'm just need change run command to scoreboard class for U @ruby haven

warm mason
#

If that's how it works for him. Why change?

quick shoal
#

After I ate I will start coding it

warm mason
# quick shoal He using runCommandAsync

AND? Using commands is not good when you are using API methods and suddenly you need a command. There is basically nothing like that here, because it only uses the commands

ruby haven
quick shoal
#

Don't use command

#

Okey I can help U now

ruby haven
#

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

world.afterEvents.playerSpawn.subscribe(({ player, initialSpawn }) => {
if (initialSpawn) {
player.runCommand("function movenot");
player.runCommand("scoreboard objectives add Trauma dummy");
player.runCommand("scoreboard players add @s Trauma 10");
player.runCommand("scoreboard objectives add Days dummy");
player.runCommand("scoreboard players add @s Days 30");
};
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
if (world.scoreboard.getObjective("Days").getScore(player) <= 0) {
player.sendMessage("Time over")
}
}
})
});
This is the current progress only problem is it loops

quick shoal
#

Wdym of loop

#

I coding for U

#

Dont worry

warm mason
ruby haven
warm mason
#
system.runInterval(() => {
  for (let player of world.getAllPlayers()) {
    if (world.scoreboard.getObjective("Days").getScore(player) <= 0) {
      player.sendMessage("Time over")
      world.scoreboard.getObjective("Days").removeParticipant(player)
    }
  }
})
ruby haven
full brook
#

how to detect if player select an item in inventory?

warm mason
quick shoal
#
import { world, system, Scoreboard, ScoreboardObjective } from "@minecraft/server";

world.afterEvents.playerSpawn.subscribe(({ player, initialSpawn }) => {
    if (initialSpawn) {
        player.runCommand("function movenot");
        world.scoreboard.addObjective('Trauma', null);
        world.scoreboard.addObjective('Days', null);
        world.scoreboard.addScore(player, 'Trauma', 10);
        world.scoreboard.addScore(player, 'Days', 30);
    }
});

system.runInterval(() => {
    for (let player of world.getAllPlayers()) {
        if (world.scoreboard.getObjective("Days").getScore(player) <= 0) {
            player.sendMessage("Time over")
        }
    }
})
warm mason
warm mason
full brook
#

sad

warm mason
#

If you are on a computer then you can

ruby haven
quick shoal
#
import { world, system, Scoreboard, ScoreboardObjective } from "@minecraft/server";

world.afterEvents.playerSpawn.subscribe(({ player, initialSpawn }) => {
    if (initialSpawn) {
        player.runCommand("function movenot");
        world.scoreboard.addObjective('Trauma', null);
        world.scoreboard.addObjective('Days', null);
        world.scoreboard.addScore(player, 'Trauma', 10);
        world.scoreboard.addScore(player, 'Days', 30);
    }
});

system.runInterval(() => {
  for (let player of world.getAllPlayers()) {
    if (world.scoreboard.getObjective("Days").getScore(player) <= 0) {
      player.sendMessage("Time over")
      world.scoreboard.getObjective("Days").removeParticipant(player)
    }
  }
})

@ruby haven

ruby haven
# warm mason How?

Example environment sensor component there is a filter their where you can check if the player is holding a specific item

warm mason
quick shoal
full brook
warm mason
quick shoal
warm mason
quick shoal
#

I follow documents

ruby haven
warm mason
ruby haven
#

Check the filters side

quick shoal
#

never mind, maybe I really need to learn scoreboard class as seriously

warm mason
quick shoal
#

Ok

granite badger
#

Which docs are you using

warm mason
quick shoal
#

Microsoft

#

I forget to getObjective

granite badger
warm mason
#

You can't change the value right away, you need to get the scoreboardObjective class first

warm mason
quick shoal
#

Thanks for teaching scoreboard class

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

world.afterEvents.playerSpawn.subscribe(({ player, initialSpawn }) => {
    if (initialSpawn) {
        player.runCommand("function movenot");
        world.scoreboard.addObjective('Trauma', null);
        world.scoreboard.addObjective('Days', null);
        world.scoreboard.getObjective('Trauma').addScore(player, 10);
        world.scoreboard.getObjective('Days').addScore(player, 30);
    }
});

system.runInterval(() => {
    for (let player of world.getAllPlayers()) {
        if (world.scoreboard.getObjective("Days").getScore(player) <= 0) {
            player.sendMessage("Time over")
            world.scoreboard.getObjective("Days").removeParticipant(player)
        }
    }
})

@ruby haven fixed

granite badger
quick shoal
warm mason
granite badger
ruby haven
quick shoal
ruby haven
warm mason
ruby haven
warm mason
ruby haven
warm mason
#

Not,
that's not it.

ruby haven
warm mason
#

Only now I need to check whether the item is selected in the inventory

warm mason
ruby haven
warm mason
#

No

ruby haven
warm mason
ruby haven
ruby haven
distant gulch
#

I got problems with Naming classes/variables e.t.c and structuriing problems, i dunno how i can fix it

quick shoal
distant gulch
#

hah, yes

warm mason
neon thunder
#

Guys, I've got a problem where I'm starting a job in world after initialise and I'm getting an error in that job telling me that I'm trying to access a block that's in a chunk that's not initialised and ticking. How do I check for that and how should I start a job after the world is properly loaded?

remote oyster
#

Otherwise, don't attempt to access the block(s) unless you can do so through another player, or entity.

neon thunder
#

I'm doing this on world initialise

remote oyster
neon thunder
#

Yeah, so how do I determine whether the area is a "ticking" one then?

remote oyster
subtle cove
#

U can use entitySpawn like pings

neon thunder
#

And it seems there are no entities loaded at the time, either

remote oyster
#

If the block returns empty (undefined) then you keep checking until it returns. Have to handle it with conditions.

neon thunder
#

Its not a block that its complaining about, its the location for a spawn

remote oyster
neon thunder
#

So, how to I start a job that will actually be started after the world is properly initialised?

gentle mist
#

Yo does any server plugins exist for mcpe

remote oyster
neon thunder
#

I am trying to re-establish internal state about entities and there aren't any loaded after world initialise

#

Even though they are persistent

remote oyster
#

Who or what is persistent?

subtle cove
#

I'd use entitySpawn event

remote oyster
#

That would be the best option.

neon thunder
#

I guess I will have to have some flag to determine whether a player is logged in

remote oyster
neon thunder
#

I'll just set a flag whenver the spawn event is fired and wait on that as a latch. That way, there is some player spawned before I try to access the entities

random flint
neon thunder
#

Well that didn't seem to work, either

remote oyster
neon thunder
#

Even releasing a latch by use of playerSpawn after event didn't work, btw

#

But I have got a work-around yeah...

#

I don't know if it will stand up in the real world

jolly citrus
#

is there a way to make name tags display in a different color for different clients

#

i want people in the same faction to see the names of their team members in green n enemies in yellow

jolly citrus
distant gulch
jolly citrus
gentle mist
#

Can i get a side with the actual item ids

#

please

cold grove
#

Try
ItemTypes.getAll()

jolly citrus
#

any way to make a player fully invisible w/o using size component ? i mean hiding the armor fire n everything

gentle mist
#

Bro i want the ids

warm mason
gentle mist
#

I just want a site where i can see them