#Script API General

1 messages Β· Page 138 of 1

remote oyster
#

Nice

stray spoke
#

I used player.inputInfo.getMovementVector()

remote oyster
stray spoke
#

But yeah yours worked too

remote oyster
#

Whichever is more efficient go with that.

#

I always side with performance lol.

warm rose
#

test

crude glacier
#

How 5o make my item detectable using itemUseOnBlock event ?

safe stream
#

is there a way to check the the stack size of an item without using try catch?

wary edge
#

Just do ItemStack.amount

safe stream
safe stream
winged drift
#

ItemStack.maxAmount should work

safe stream
#

didnt know that was a thing

crude glacier
#

Guys is it possible to check when interaction with entity ends ?

#

Like when i open an entity Inventory then close it

#

I want to check when i close it

wary edge
crude glacier
#

What is called?

cyan basin
#

World Structure Manager can't read from the STRUCTURES folder in the Behavior Pack!?

wary edge
cyan basin
#

Bruh, but if I use runCommand wouldn't it just work anyway?

wary edge
#
    /**
     * @beta
     * @remarks
     * Returns a list of all structures contained in behavior
     * packs. Does not include structures saved to the world or in
     * memory.
     *
     * This function can't be called in restricted-execution mode.
     *
     * @returns
     * The list of structure identifiers.
     */
    getPackStructureIds(): string[];
    /**
     * @remarks
     * Returns a list of all structures saved to the world and to
     * memory. Does not include structures contained in behavior
     * packs.
     *
     * This function can't be called in restricted-execution mode.
     *
     * @returns
     * The list of structure identifiers.
     */
    getWorldStructureIds(): string[];
cyan basin
#

Okay.

crude glacier
distant tulip
crude glacier
#

Hmm is it beta

distant tulip
#

it is preview beta

crude glacier
#

πŸ«ͺ

#

Sad

#

Will it be stable in the next version?

crude glacier
distant tulip
distant tulip
#

everything so far moved to stable beta before releasing, if i am not wrong

crude glacier
distant tulip
#

what does that mean

cyan basin
#

It just seems to always default to mystructure even if changed.

random flint
#

it dependant on the folder name where you put the mcstructure iirc

cyan basin
#

So why pass in a namespace when saving!? That's a bit confusing if it's based on the folder when it comes to that.

#

Well thanks for letting me know and I'll give that a try.

warm mason
distant tulip
chrome flint
#

is it possible to set armor stand pose using scripts api?
or atleast get the armorstand's pose index via scripts

grim raft
#

for some reason the "hasTag" doesnt work even for vanilla items

world.afterEvents.itemUse.subscribe((event) => {
  const { source, itemStack } = event

  if (!source) return
  if (itemStack.hasTag === 'rust:semi_auto') {
    console.error('pew')
  }
})```
#

it works with typeId tho

open urchin
grim raft
#

well that explains a lot

#

even checked the docs and didnt see it 😭

#

im lwk stupid

neat hazel
#

How can I detect if a player has mined a block using a tool with a custom component ("custom:component")?

thorn flicker
cold grove
#

There should be a bot that replaces the docs urls with a descriptive embed

thorn flicker
#

item.

cold grove
#

Like fixtweet

cold grove
thorn flicker
neat hazel
wary edge
#

Huh...if you get current entity health in before entity hurt it returns the health after the damage is applied.

olive sphinx
#

So I noticed that with Dynamic Properties, you can get the Total Byte Count. I am just wondering, is the a max on how much you can use?

shy leaf
wary edge
#

Wait arent those two the exact same.

cold grove
shy leaf
#

lol

#

although that can be somehow useful

wary edge
#

Entity: 20 HP
Sword: 8 DMG
EntityHurtBeforeEvent:
Entity HP: 12 DMG
Event ends.

#

It could just be my getHealth being wonky and executing after the tick?

shy leaf
#

could be, try getting the new comp inside the event

cold grove
shy leaf
#

if its true, we would be able to tell that they basically duct taped and hotwired this event 😭

cold grove
#

That wouldn't leave to the callback to run on the next tick?

shy leaf
stray spoke
#

I made a double jump by timing it if its under 10 ticks, and limit its repetition so it wouldn't spam. However, it seems low performance, it uses interval, do y'all know what to change here

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

const cache = new Map();

world.afterEvents.playerButtonInput.subscribe(
  ({ player }) => {
    doubleJump(player);
  },
  {
    buttons: [InputButton.Jump],
    state: ButtonState.Pressed
  }
);

const counter = new Map();
const repeats = new Map();

function doubleJump(player) {
  if (!counter.has(player.id)) {
    counter.set(player.id, {
      tick: 0,
      count: 0
    });
  }

  const savedJump = () => counter.get(player.id);
  const setJumpCount = (c) =>
    counter.set(player.id, { tick: system.currentTick, count: c });
  const tick = system.currentTick;

  if (tick - savedJump().tick >= 10) {
    setJumpCount(1);
  } else {
    setJumpCount(savedJump().count + 1);
    if (savedJump().count >= 2) {
      setJumpCount(0);
      applyImpulse(player);
    }
  }
}

function applyImpulse(player) {
  repeats.set(player.id, repeats.get(player.id) - 1);

  if (repeats.get(player.id) <= 0) return;
  player.applyImpulse({ x: 0, y: 0.7, z: 0 });
}

system.runInterval(() => {
  for (const player of world.getAllPlayers()) {
    if (player.isOnGround) {
      repeats.set(player.id, 2);
    }
  }
});
knotty plaza
rough elm
#

67

random flint
# rough elm

Back then, when 69 and 360 was a brainrot meme numbers, they had something correlated to them. 67 is an overused random number, without much context. Annoying and cheap.

rough elm
#

67

#

@random flint

#

67

#

Om top

#

On*

random flint
#

Please move to #off-topic if you want to spam ts. This one is for ScriptAPI discussion, not whatever childish Gen Alpha brainrot you're sending

stray spoke
#

67 is meaningless

#

69 on top

rough elm
#

I know

stray spoke
knotty plaza
remote oyster
remote oyster
#

Its updated to implement the logic I mentioned above. Modified so I could test it in my own project. Confirmed working. Can compare the results in the debugger for vscode to see how it performs if curious.

stray spoke
#

All I needed only is to import it, very convenient

remote oyster
#

I was drinking coffee and working on some code on my end when I stumbled across your post. So it wasn't a problem for me. I was in the zone and focused lol.

stray spoke
#

Lol I had that same caffeine boost too

zinc breach
#

is there a way to cancel attack cooldowns? so using a spears lunge for example

sharp elbow
#

It's an odd choice but thankfully it is easy to reverse

wary edge
sharp elbow
#

Haha

#

I was making a "health changed" event I could subscribe to, which emitted when the entity took damage or was healed, and that's where I noticed the value being wrong

#

Even more funβ€”altering the damage property then moving outside the read-only context will update the value that currentValue returns

wary edge
#

Interesting.

sage portal
#

I feel like this is something the docs should have elaborated on, because what

crude glacier
#

What?

deep arrow
#

how can i make splash particles like when a player jumps in water

covert goblet
#

Hey folks, this might be a silly question but i'm using the world.scoreboard and getting the player.scoreboardIdentity; is there a way to set this in code?? or do i have to run it in game before hand??

crude glacier
#

Hey folks , this might be a silly question but i'm using playerBreakBlock afterEvents to check whenever the player destroys multi-blocks block, but the problem is it doesn't break consistently, like it breaks the block i broke first then it breaks the rest of the blocks , which make inconsistent breaking effect

granite cape
#

hey

nova flame
#

im using BDS for my server is there a way i can do like my own custom in game command that i run in the server console? i wanna be able to ban players without having to use the discord bot OR joining the game please help

stray spoke
#

I wanna ask if do we can edit player permissions

#

Like disabling pvp to a specific player

crude glacier
#

entityHitEntity before events cancel

stray spoke
#

That's too simple to work, but Iemme try

crude glacier
#

Ir depends on the thing you are trying to do

#

If you want to disable buildings , open chests etc....

stray spoke
#

There's no entityHitEntity before event

wary edge
stray spoke
#

There's also no beforeEvent for entityHurt to cancel it

#

But thanks y'all

wary edge
#

There is.

crude glacier
#

There is

stray spoke
#

Oh

wary edge
#

You should clarify if you're using not beta APIs.

crude glacier
#

Maybe you didn't update your npm package

stray spoke
#

I can't find in ts definition

#

Yeah maybe

wary edge
#

Therefore I will assume you're not using Beta APIs?

crude glacier
#

npm i @minecraft/server

stray spoke
#

Yes I'm on stable

crude glacier
#

In terminal

stray spoke
#

I'll try to redownload npm

wary edge
stray spoke
#

My package json says 2.5.0

wary edge
#

So you're not using Beta APIs.

stray spoke
#

Okay found EntityHurtBeforeEvent now, I'm now 2.6.0

stray spoke
wary edge
#

Ah, the docs I'm using are wrong as well!

stray spoke
#

lol

#

Thanks again, ill test for a bit

stray spoke
zinc breach
#

what I mean by this is maybe some sort of beforeEvent?

#

like itemUse or entityHurt

#

idk what I would use for the spear

thorn flicker
zinc breach
thorn flicker
#

some items you can, not all.

shy leaf
#

but uh, you can just constantly reset item cooldown of spears

zinc breach
shy leaf
#

yeah

zinc breach
#

I don't think theres a way to do that

#

you can start the cooldown

#

but I don't see a way to end it

shy leaf
#

you can also set the cooldown

#

so in this case, zero em

#

give me a second

zinc breach
shy leaf
zinc breach
#

so would that override the active cooldown

#

like say the cooldown already starts and I use this with like 1 tick

shy leaf
#

yeag

zinc breach
#

alr great

#

thanks

blissful siren
#

Guys what is the newest version of minecraft/server ?

blissful siren
trail marten
#

i need to reconfirm, does Player.id is really consistent (Entity.id to be exact), even if the name of the player changes or even if the player left the server?

#

i just returned and i have to put system.run all across my functions because early execution context 😭

blissful siren
#

Guys im trying to update an addon but i got this error:

[Scripting][error]-TypeError: cannot read property 'subscribe' of undefined at <anonymous> (rbymod.js:17)

amber berry
#

nope they are not

round bone
honest spear
round bone
honest spear
#

nah its buggy asf

#

i used to use it

#

but damn its not there yet

round bone
honest spear
round bone
#

Docker, packages, everything worked even better

honest spear
#

it just broke whole terminal

round bone
honest spear
round bone
honest spear
cinder shadow
#

Have you always been able to dupe items that have their durability handled through scripting?

#

Guess I need to add validation checks

cinder shadow
#

I swapped to a different item slot at the exact same tick and it deleted that item and replaced it with a copy

#

completely unintentionally

#

happened during a playtest and my shovel vanished and was replaced with a 2nd pickaxe

wary edge
#

Yeah, it sucks we have to set the item back into the slot of the inventory to update anything.

rough pecan
#

fr

cinder shadow
#

Doesn't look too bad to fix, but it's still dumb.

#

Just need to use the inventory .find to find the exact copy I'm looking for

#

oh wait that won't work either lmao

#

I actually can't even recreate it

subtle cove
#

Imagine firing a rail gun then swap while firing

#

Perhaps drop the gun too

sharp elbow
#

Are you using EntityEquippableComponent? "Mainhand" container slots will change indices depending on when it is queried

cinder shadow
#

guess it does go off every now and then

wary edge
#

I'm not entirely sure why we have to set Items back into the inventory though. Blocks and Items dont have to.

sharp elbow
#

I recommend using the EntityInventoryComponent and storing the slot index, or to store the ContainerSlot and write back to it

cinder shadow
#

This is using the inventory component

subtle cove
#

Make the slot a variable

cinder shadow
#

make every item have a dynamic property of it's slot πŸ˜”

open urchin
cinder shadow
#

I feel like the only perfect solution here is giving every item in the hotbar a dynamic property for it's slot lol

#

alternatively I can still use the selectedSlotIndex, and if the items don't match I do .find as a fallback

#

but if the player ends up having a copy of that item in an earlier slot that one loses durability instead

knotty plaza
wary edge
#

I never htought to see it like that.

cinder shadow
#

actually inventoryItemChanged might not be a good idea... has the same issue because now every time an item changes slots I now need to place that item back in that same slot after adding the dynamic property

subtle cove
#

Reminds me of the inventory link addon

cinder shadow
#
const slotToReplace = inventory.getItem(entity.selectedSlotIndex).typeId === itemStack.typeId ? entity.selectedSlotIndex : inventory.find(itemStack);```
#

no way this is the ideal solution

shy leaf
#

i uh, have a durability code but ive never had the duplication problem

cinder shadow
#

I've never either, I can't even replicate it even when it detects a different slot

shy leaf
subtle cove
#

Wana try transferItem in runJob πŸ‘€

sharp elbow
#

Are you synchronously reading and writing to the same slot in the same tick/function?

cinder shadow
#

I really don't think I accidentally made two iron pickaxes and got them both to the same durability while mining and forgot to make an iron shovel

#
export function reduceDurability(entity, itemStack, damageAmount) {
    const durability = itemStack.getComponent("minecraft:durability");
    const inventory = entity.getComponent("minecraft:inventory").container;
    const unbreakingEnchantmentLevel = itemStack.getComponent("minecraft:enchantable").getEnchantment("unbreaking")?.level;
    const slotToReplace = inventory.getItem(entity.selectedSlotIndex).typeId === itemStack.typeId ? entity.selectedSlotIndex : inventory.find(itemStack);
    if(!shouldDamageItem(unbreakingEnchantmentLevel)) return;
    if(durability.damage + damageAmount >= durability.maxDurability) return (inventory.setItem(slotToReplace, undefined), entity.playSound('random.break'))
    return (itemStack.getComponent("minecraft:durability").damage += damageAmount, inventory.setItem(slotToReplace, itemStack));
}```
#

should be in the same tick

sharp elbow
#

And you are invoking this with an ItemStack you acquired in that same tick? e.g.

() => {
  const player = /* ... */
  const inventory = player.getComponent("inventory").container;
  const item = inventory.getItem(player.selectedSlotIndex);
  reduceDurability(player, item, 1);
}
cinder shadow
#
itemRegistry.registerCustomComponent('runecraft:sword', {
        onMineBlock: (eventData) => {
            if (!isInstantMineableBlock(eventData.minedBlockPermutation.type.id)) {
                reduceDurability(eventData.source, eventData.itemStack, 2);
            }
        },
        onBeforeDurabilityDamage: (eventData) => {
            if (shouldDamageItem(eventData.itemStack.getComponent("minecraft:enchantable").getEnchantment("unbreaking")?.level)) return eventData.durabilityDamage = 1;
            eventData.durabilityDamage = 0;
        }
    })```
sharp elbow
#

Mm, I see.

shy leaf
#

oh custom components

#

i only have good experience with events so ill just silently slip outta here...

subtle cove
#

Why 2 durab updates tho

wary edge
#

That's the only time the engine decrements the durability automatically for you.

subtle cove
#

Oof

wary edge
#

It doesn't trigger for armour taking damage last I tested as well.

shy leaf
#

gx_cringe that sounds chaotic

cinder shadow
#

well I guess this solution works as well as possible, this at least prevents the possibility of someone's item getting straight up deleted and cloned

#

I'm fine if the 1 in a million chance occurs where it reduces the durability of a separate item

shut citrus
#

how to create custom js modules?

cold grove
shut citrus
cold grove
north rapids
#

Is there a way to detect when a chunk is generated?

random flint
#

Generated for the first time? Directly, no. But...

You can check if certain chunk is loaded by Dimension.isChunkLoaded(Vector3). And since chunk is just 16x16, you can put a metadata (like a timestamp) on that chunk via world dynamic property.
If it doesn't have one, it's newly generated, else, it had been generated in the past.

lyric kestrel
#

I'm trying to set my multiblock with updated states but it keeps breaking no matter what

block.setPermutation(
 BlockPermutation.resolve(
  block.typeId,
  {
    "minecraft:cardinal_direction": cardinalDirection,
    "foundry:lava_level": newLavaLevel,
    // Tried with and without setting multi_block_part: 0
  },
 )
);```
#

It sets the states, but it breaks afterwards giving me 2 of the blocks

wary edge
#

You need to set it on every part if I recall.

lyric kestrel
#

Ah

#

Yep, that worked

#

Damn, that's kinda a bummer, but makes sense

tidal wasp
#

How would you get put permanent text on a players screen whenever they are holding a specific item

ripe shale
#

Somebody talk spanish

#

How i paste a Code block?

#

This happen when i try:

function getDamageSourceEntity(damageSource) { const damagingEntity = damageSource?.damagingEntity ?? null; if (isValidEntity(damagingEntity)) return damagingEntity;

const damagingProjectile = damageSource?.damagingProjectile ?? null; if (!isValidEntity(damagingProjectile)) return null;

const projectileSource = damagingProjectile?.source ?? null; if (isValidEntity(projectileSource)) return projectileSource;

return null; }

night oracle
#
```js

Put code here

#

@ripe shale

#

Or copy this message:

#
Put code here
cold grove
#

```js

ripe shale
#

Thanks!

stray spoke
#

I wanna ask how do we exactly copy paste a block, like all states or data in its Block class are copied

knotty plaza
shy leaf
#

sounds (relatively) simple

tidal wasp
#

No like something above their hotbar

shy leaf
#

oh the item text that appears when you select an item

#

...or actionbar

ripe shale
# stray spoke I wanna ask how do we exactly copy paste a block, like all states or data in its...
import { BlockPermutation } from "@minecraft/server";

function copyBlockState(source: any, target: any) {
  if (!source || !target) return;

  // Copies type + block states
  target.setPermutation(source.permutation);
}

// Explicit rebuild form:
function copyBlockStateExplicit(source: any, target: any) {
  if (!source || !target) return;

  const states = source.permutation.getAllStates();
  const perm = BlockPermutation.resolve(source.typeId, states);
  target.setPermutation(perm);
}
#

That still does not copy everything a block may store. Block inventory is exposed through a separate minecraft:inventory component, and signs have their own BlockSignComponent methods for text, dye color, and wax state. Those pieces have to be copied separately if you want an exact clone of a chest, sign, or similar block

#

Permutation β†’ block type and states.
Components β†’ extra data like chest contents or sign text

ripe shale
#

Please help! How can I make a welcome UI open for the player? I've tried, but in most cases the player isn't accessible at that moment. My idea is that the UI (preferably ModalFormData) appears as soon as the player's screen loads. I would greatly appreciate a working example. Thanks!

stray spoke
#

Thanks yall

ripe shale
#

Did the code work for you?

stray spoke
#

What I commonly do is set a hardcoded state, but I want it to copy state instead, a block could possibly have more than 1 state and data, like redstone power, or other props

#

yeah that works

ripe shale
#

Okay, it was a pleasure helping you. Now I need help, lol. I need to create a welcome UI that opens right when the player spawns, but in most cases the player is inaccessible.

stray spoke
#

But if that exactly what you did, maybe try to add system.timeout delay or add a loop like 'while(cancelReason)'

#

the ActionFormData/ModalFormData can return cancel reasons, like if user is busy or not loaded

ripe shale
ripe shale
stray spoke
#

it may returns 'canceled' and 'cancelationReason', you might try repeatingly call the form until it doesn't return true for the specific cancel reason

#

Its from ActionFormResponse

ripe shale
#

Bro, I love you, thank you!! It finally works, I've been trying to fix it all day.

shy leaf
#

i dont like how setting unbreakable doesnt account for setting durability damage

#

suffering from success

thorn flicker
shy leaf
#

but no, setting durability still changes it, so if you have a custom durability function prior to unbreakable component it wont work

woven loom
#

Entity.getAABB() in which version was released?

warm mason
woven loom
#

Oh thx πŸ‘

thorn flicker
woven loom
#

how did you check

warm mason
warm mason
#

most useful thing ever

lyric kestrel
#

EquipmentSlot is now Stable

warm mason
#

EquipmentSlot.Body is in beta

lyric kestrel
#

Oh, I never even saw Body lmao

warm mason
#

but equippable doesn't work for mobs

lyric kestrel
#

Oh, I see it in attachpoint only

#

Wait, am I outdated then? πŸ˜”

warm mason
#

Im using 2.8.0-beta

median geyser
untold magnet
#

is it possible to make the projectile i am spawning right in front of the player head damages everything but the player? i am summoning the projectile entity using scripts so idrk how to connect it to the player (owner stuff)

shy leaf
#

projectile component should have owner property that can be written

untold magnet
#

currently i got the whole code working, the projectile is moving towards without issues besides damaging the player in the process

shy leaf
#

takes Entity

untold magnet
shy leaf
#

uh, youre using shoot method, right?

untold magnet
warm mason
#

js code

shy leaf
#

then spawn the projectile entity, touch the projectile components, and then shoot it

untold magnet
# warm mason js code
world.afterEvents.playerSwingStart.subscribe(({player, heldItemStack:itemStack, swingSource:source}) => {
    if (source === 'Attack') {
        const Molang = new MolangVariableMap();

        const dim = player?.dimension;
        const {x:hX, y: hY, z:hZ} = player?.getHeadLocation();
        const {x:dX, y: dY, z:dZ} = player?.getViewDirection();

        Molang.setSpeedAndDirection('xfallenwarriors', 0, {x:dX, y:dY, z:dZ});

        if (itemStack?.typeId === 'xfallenwarriors:ancient.sword.v0') {
            system.runTimeout(() => {
                const proj = dim?.spawnEntity('xfallenwarriors:ancient.sword.slash.attack', {x:hX, y: hY, z:hZ});

                proj?.getComponent('minecraft:projectile').shoot({x:dX * 2, y:dY * 2, z:dZ * 2});
                dim?.spawnParticle('xfallenwarriors:ancient_sword_attack_slash_particle', {x:hX, y:hY, z:hZ}, Molang);
            }, 2);
        };
    };
});;```
shy leaf
#

erm

#

why setRotation? i mean

warm mason
untold magnet
shy leaf
#

i see

shy leaf
untold magnet
#

i was trying to use the projectile model, but i couldnt get it to look like the slash particles

shy leaf
#

im sure setting owner prevents being shot by your own projectile, but youre using timeout in this case so i cant confirm it

#

if thats what you tried

untold magnet
shy leaf
#

but either way, just do

proj?.getComponent('minecraft:projectile').owner = player;
#

for the owner

untold magnet
#

alright, ill give it a 'shoot'

warm mason
untold magnet
warm mason
untold magnet
untold magnet
#

proj.getComponent('minecraft:projectile').owner = player;

shy leaf
#

check damagingEntity in entityHurt, this doesnt seem right

untold magnet
untold magnet
#
world.afterEvents.entityHurt.subscribe((e) => {
    console.warn(
        e.hurtEntity?.typeId,
        e.damageSource.damagingProjectile.typeId,
        e.damageSource.damagingEntity.typeId
    )
})```
#

returns iron golem, projectile id, projectile id

shy leaf
#

what in the

untold magnet
shy leaf
#

try it with arrow

untold magnet
#

something is wrong in the projectile.json

#

mhm

untold magnet
shy leaf
#

but

untold magnet
#

changed it to arrow, now it works

shy leaf
#

it works for snowball though????

#

...does it actually not work for snowball

wary edge
#

Runtime ids πŸ‘Ž

untold magnet
shy leaf
#

sob

#

mojank

distant tulip
#

it works for arrows and not snowballs?

shy leaf
#

according to them

distant tulip
#

snowball itself work fine

shy leaf
#

balls

#

its really janky

distant tulip
#

what....
dimension travel trigger item stop use??

wary edge
crude glacier
#

What is AABB() ?

warm mason
crude glacier
#

Oh

fallen cape
crude glacier
#

So a fancy way to say collision box ?

fallen cape
#

uhh basically yea

sharp elbow
#

The more precise term for its collision box. Also the way it is defined is more general, and it is defined differently from the "minecraft:collision_box" component.

weary umbra
#

why does debugText.depthTest = true not hide the debugText behinde a block?

ripe shale
#

Hello, I wanted to ask if you could help me. I need an example of two commands that are executed when closing and opening the form, and it must be able to handle whether or not the player is in the Overworld.

stray spoke
midnight ridge
stray spoke
#

The fade method makes it fade black

#

While setFov makes the zoom effect with easing type

dreamy elbow
#

yo is .setRotation() broken. It'll let me set the x rotation but not the y rotation

random tartan
#

did anyone know for what reasons an items is considered experimental. ( meaning, why in the item's .json file, in the description afield called 'is_experimental' set to true, for what reasons??? )

frank grove
open urchin
amber berry
midnight ridge
wary edge
#

They're setting both the POV and FOV and then clearing it. What the user has has not affect.

amber berry
#

When I was messing with fov i though there would be some like getFov then I can +- from that, but there aint

bold stratus
#

Is there way to make script write json(save data)

shy leaf
#

best you can do is to make a database

lyric kestrel
#

How many entries can a hashmap have before it loses it's O(1) functionality?

#

Or will it always be O(1) as long as it's below it's 16million limit?

wary edge
#

That seems like a good stackoverflow question.

nova flame
#

ong

lyric kestrel
#

Ok yes, O(1) depends on size of Map for the retrievel but only until ~1,000,000 entries or so in a database)

#

But for my size of ~600 entries it should be O(1)

remote oyster
#

It can go as high as in the billions and remain O(1).

#

So long as you don't have collisions.

lyric kestrel
#

How can I avoid collisions?

#

Or is that based on the memory allocation?

remote oyster
#

Simple Hash Map Example (with collision)

class SimpleHashMap {
  constructor(size = 5) {
    this.buckets = new Array(size).fill(null).map(() => []);
  }

  // Simple hash function (intentionally causes collisions)
  hash(key) {
    return key.length % this.buckets.length;
  }

  set(key, value) {
    const index = this.hash(key);
    const bucket = this.buckets[index];

    for (let pair of bucket) {
      if (pair[0] === key) {
        pair[1] = value;
        return;
      }
    }

    bucket.push([key, value]);
  }

  get(key) {
    const index = this.hash(key);
    const bucket = this.buckets[index];

    for (let pair of bucket) {
      if (pair[0] === key) {
        return pair[1];
      }
    }

    return undefined;
  }
}

// Demo
const map = new SimpleHashMap();

map.set("apple", 1);
map.set("grape", 2);

console.log(map.buckets);

A collision occurs when two distinct keys are assigned to the same bucket in a hash table.

Using the hash function key.length % 5:

"apple" β†’ index 0
"grape" β†’ index 0

Even though the keys are different, they produce the same index. Because of this, both values are stored in the same bucket, and the hash map must handle the collision by storing multiple [key, value] pairs in that bucket. Another note to add, JavaScript is technically designed to handle collisions under the hood, such as when using Maps, but that depends on the engine, so I am not 100% certain if this rule applies to our environment since I know Mojang does make some modifications to serve their purposes. Testing would confirm for sure.

lyric kestrel
#

Oh I see

#

Ok yeah, then I don't think I will ever get a collision if that's the case

remote oyster
#

Most likely not. Kinda like a UUID. Chances of a collision is extremely low.

#

As long as your code is written properly

tidal wasp
#

Is setPermuatation and SetType just kinda of redundant

#

Like SetPermuatation can be used outside of system.run as well as doing what setType can do and more

wary edge
#

Some events only gives you BlockPermuation others gives you Type.

tidal wasp
#

Huh

#

Which events are those?

wary edge
tidal wasp
#

I know that

#

What only gives type

wary edge
tidal wasp
#

Huh

deep arrow
#

can i get an entities mainhand itemstack?

shut citrus
#

there is no entityHitEntity before event, how to get entity hit and target entity to cancel damage, knockback and other side effects?

shy leaf
#

but side effects are kinda inevitable

shut citrus
#

any code examples?

shy leaf
#
world.beforeEvents.entityHurt.subscribe((ev) => {
    const { damageSource, hurtEntity } = ev;
    const damagingEntity = damageSource?.damagingEntity;

    if (!damagingEntity || !hurtEntity?.isValid) return;

    if (isTeam(damagingEntity, hurtEntity)) {
        ev.cancel = true;
        return;
    }
});

taken from my code

shut citrus
#

does it prevent knockback?

shy leaf
#

yes

#

but not mob effects or fire aspect

#

other effects like trident channeling are untested, you gotta check it

shut citrus
#

ok thanks

untold magnet
#

interface EntityContainerAccessEventOptions what is it used for?

crude glacier
#

Perhaps

stray spoke
stray spoke
stray spoke
#

ohh

keen dust
#

How can I have more then 1 File for Scripting? So in the manifest, i Register a Link To a JS File. And I want To have more Files for different features

stray spoke
#

You can only use one root file in manifest, I guess. But you can make your root file connect with other files

stray spoke
#

simply do

import "./myEvent1.js" 
import "./myEvent2.js" 
keen dust
#

For example in ./myEvent1 oder ./myEvent2 ?

stray spoke
#

No, the main file just imports the whole script environment from the other file so it acts like all files as one file

#

Also change the myEvent1.js to something else, it should be the path of your js file

keen dust
#

So I only need the import and No Export or Something else

#

In the other Script, right?

stray spoke
#

No need

keen dust
distant tulip
#

you only need something in the other file if you are importing a function or something from it
like import {doSomething} from "./path/to/file.js"

keen dust
#

Or Events or Something else

untold magnet
#

i do have that 'my:item' in my inventory

distant tulip
#

it is expecting ItemStack, not id

untold magnet
#

i see, hmm

untold magnet
distant tulip
#

only if the amount matter to the function

untold magnet
distant tulip
#

afaik, no

#

can't trigger the coodown

untold magnet
#

alright then, fuck the whole bug i am currently having

random flint
steel jungle
#

AΓ­ tem alguΓ©m Br?πŸ«ͺ

untold magnet
#

theyre just some visual bugs in my attachables, when u move ur hand without holding my sword, and then u switch back to that sword, the attack animation will play which can cause some visual bugs if u instantly attack with the item

#

hmm,

random flint
#

even with v.attack_time?
-# c.owning_entity -> v.attack_time

sharp elbow
#

That is precisely the issue. v.attack_time returns 0–1 in the range of the player's hand swing animationβ€”and that plays when attacking, but the player may have already began swinging before switching to the item in question

untold magnet
#

yeah, swinging the arm before switching to the item cause the attack animation to be played

sharp elbow
#

Best thing I can think is to store the state of the variable across frames. Something like v.has_attacked = v.attack_time > 0;

You can tell a swing began on a given frame if v.attack_time > 0 && v.has_attacked == 0

#

Important note: That condition would need tested before the variable is assigned its new value

untold magnet
#

mhm

sharp elbow
#

Although that might not be enough either. Attachables only update their animations when the item is selected, so that alone still has no knowledge over whether the swing began with the item in hand

distant tulip
sharp elbow
untold magnet
#

i think the player?.startItemCooldown('ancient', 60); works the best here why fixing the issue if i can just do this lol

#

yeah it works pretty fine,

random flint
#

A quick reminder, q.cooldown_time_remaining() molang query only works on you. Other players will always evaluate to 0... well, if you do c.owning_entity ->

untold magnet
#

the sword i am making is kinda strong, so making it unusable while doing everything else is better than fixing the actual bug

sharp elbow
untold magnet
#

this bug was dragging me crazy yesterday, i had to add a whole lock system just to fix it

random flint
#

Try multiplayer if the animation works as intended. Even though it works on your screen, that doesn't mean it's the same on another player's screen.

For my testing, other players don't know each other's cooldowns. That's why it evaluates 0... c.owning_entity just made sure it was the holder... but it's still effectively client-sided.
-# This is why I ended up using the janky play animation stopExpression variable injection to manipulate attachable animations.

sharp elbow
#

playAnimation my beloved

untold magnet
#

well, can i somehow use scripts to play animations from the animation controller?

#

like changing a variable value or something else to trigger the animation conditions in the controller,

random flint
#

I don't think you can trigger the animation controller directly from a script, but there are "controller" interface in playAnimationOptions (Mostly used to stacks animation). I mostly just brute force, making the script my own animation controller

untold magnet
#

mhm,

warm mason
#

what are u talking about?

untold magnet
#

i was trying to do that so i can play some first person animations using the script or to make the animations blending

#

but meh,

random flint
untold magnet
random flint
grave halo
distant tulip
#

do you guys think adding support for BlockSignComponent for a custom sign template is a good idea? or should i leave that to the user

const originalGetComponent = Block.prototype.getComponent;

Block.prototype.getComponent = function (id) {
  if (
    this.typeId === customSignId &&
    (
      id === "minecraft:sign" ||
      id === "sign" ||
      id === customSignId
    )
  ) {
    return new CustomSignComponent(this);
  }

  return originalGetComponent.call(this, id);
};
#

uh, what does 1 mean

warm mason
untold magnet
# random flint Try multiplayer if the animation works as intended. Even though it works on your...

speaking of queries and animations, i believe i can recreate the cape movements or something similar to it using some queries and animation controllers, what should i use for that?
the thing i am animating is looking like vines, where it will move when the player moves, so when the player moves forwards the vines will move backwards, if the player moves to the right, the vines will move to the left etc

#

is that even possible to do?

chrome gyro
#

Anyone know how to get the timing of a ranged_attack. I'm trying to trigger a spawn_particle if an attack is charging up through script, but don't want to do it through a locator and or have to make a behavior pack animation controller. Hoping there's data you can get from the component through script some how?

cold grove
chrome gyro
#

is there a way to query those with script?

chrome gyro
cold grove
chrome gyro
chrome gyro
nova flame
#

yo is it possible to make it so i can define what area a player can render as in blocks say for a speed build mini game makin it so the other players builds dont render for the player until match over?
dont even know where to ask this

neat hound
#

I am totally unsure if that is possible... but if I wanted to do something like that, I'd have the build area for each player somewhere else, then when it is over, bring all the builds over to a community spot..... or just build warp portals to each build spot that open when competition over.

nova flame
neat hound
#

Functional is better

cold grove
#

I guess you can create a barrier block box and add a very limited fog?

neat hound
#

It can look like a render to copy it over

#

That is a good idea

#

They just cannot see it.. until fog and barrier removed

trail marten
round bone
# trail marten fine by me

It's not fine. You're testing it as a host - in every single world, host has the same entity identifier and that's why you think it works. If you include more players in the test, you would see that they've different entity identifiers across the worlds

trail marten
round bone
fickle rapids
#

is there a way to override the default minecraft commands

#

i want to ensure that this does not succeed when run from the server console (or anywhere really)

fickle rapids
#

the host runs a tellraw that puts a message in chat

warm mason
#

this is a bedrock server..

fickle rapids
#

but on bedrock servers it uses the same command

#

i was just wondering if there was a way to modify /tellraw to not work on certain inputs

#

and anything else would get handled with the normal /tellraw

fickle rapids
round bone
fickle rapids
round bone
marble sigil
#

I'm learning TS now as I'm already good at JS, so, does anyone find having to use something like entity.getComponent('name') as EntityNameComponent (type casting for components) when working with older API versions, like 1.15.0?

round bone
#

It makes sure that you won't use anything that does not exist or makes no sense

sharp elbow
#

I wouldn't say it's type safe, as you could assert the return type as some other component than the ID you gave it. The result can be undefined if the entity lacks that component, too.

#

Might be more explicit to do a type guard.

const name = entity.getComponent('name');
if (name instanceof EntityNameComponent) {
  // ...
}
amber berry
#

I see

sharp elbow
#

Oh, well I was using whatever existing example was there. That could be EntityInventoryComponent, for example

round bone
#

You can check if it's undefined in your code and it'll be the same (but only in TypeScript)

sharp elbow
#

We're still talking about the pre-generic getComponent, right?

round bone
sharp elbow
#

In order for EntityComponentReturnType to be used in newer scripting versions, yeah

amber berry
#

Why not use something like this

cyan basin
#

wouldn't you just do if (!inv) return?

amber berry
sharp elbow
#

That is missing the purpose of this discussion, anyway

cyan basin
round bone
#

Also, it's better to use enumerations

sharp elbow
#

It is better to use enumerations.

amber berry
round bone
sharp elbow
amber berry
round bone
round bone
sharp elbow
#

getComponent being generic?

round bone
sharp elbow
#

Yeah, just double-checking that I follow

sharp elbow
round bone
sharp elbow
#

Writing type-safe code within JavaScript is an art on its own

sharp elbow
#

An art I'm willing to follow if I'm too lazy to set up esbuild lol

amber berry
#

the one from mctools.dev ?

#

or regolith ?

round bone
amber berry
round bone
#

Ohh, the Microsoft ones

amber berry
round bone
#

They're pretty empty imo

amber berry
subtle cove
#

hence it's experimental stuff here, mostly

round bone
#

I prefer to setup everything on my own. Like Prettier, ESLint, pre-commit stuff, CI actions (GitHub config files in general) etc.

amber berry
#

yes it does

round bone
last latch
#

/s

amber berry
honest spear
#

hmmm dist should be directly in behavior packs tho

#

idk

round bone
last latch
#

i used to use onedrive

cold grove
runic maple
#

Is the equippable component still only accesible for players?

runic maple
#

☹️ Gemini is so adamant on gaslighting me it works on mobs, no matter my testing. there goes my dreams I guess.

cold grove
#

??? Why use ai to ask that

runic maple
#

It says it is on all mobs and can be gotten for all players or something, Doesn't say no mob can access it

runic maple
shy leaf
#

note to self: mace smash cant be canceled

random flint
lean canopy
#

yo I be working on a thing, this is not the original code it's just a structure test, but I'm wondering if this is good or if there's still a better way to do it

#

context: my original code is gonna do this defining variables 27 times total (with a a array, b array and c array for a 3x3 cube)

#

i dumbed it down to the barebones idea and while testing I came up with this nested "while" loop which does work and would be enough if it's good enough const pos = { x: 0, y: 0, z: 0 }; let text = ""; let a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,26 ]; let h = 0; while (h <= 27) { let k = -1; while (k <= 1) { let j = -1; while (j <= 1) { let i = -1; while (i <= 1) { a[h] = "(" + [pos.x + i, pos.z + j, pos.y + k] + ")"; text += a[h] console.log(a[h]) i++; h++; ; } j++; } k++; } }

but I'm wondering if there's a better way anyone with more experience knows? :3

cobalt hollow
#

idk if that works

#

but yeah

lean canopy
lean canopy
olive sphinx
#

Ooo, a for statement. Loops it till dz equals or is greater then 1. Then it uses the dz value and add it to the z value. That is a smart way to condense it

olive sphinx
lean canopy
#

so

#

why is

#

like

#

whats the difference between using dz and dx or i and j like I used

olive sphinx
#

No difference, just preference and clarity mostly

lean canopy
#

cuz this looks exactly like a normal for loop which I forgot existed because I have never used them yet in my actionscript coding

#

oh okay

#

ok so then

#

my main question is how does y increment here

olive sphinx
#

It doesn't it is static

lean canopy
#

cuz this looks exactly like my while loops except missing one and formatted into for loops instead lol

#

okay

lean canopy
olive sphinx
#

Your y never changed, it was always y - 1 so it doesn't need to change

lean canopy
#

bruh I just said the same thing twice

lean canopy
#

in my original screenshot it never changed

#

but it does change

#

I mentioned that script would run 3 times, 1 for each layer of a 3x3 cube

olive sphinx
#

If it does change, just add another for statement loop

lean canopy
#

which again is already what I've done but just in a for statement instead :P

does that even save characters?

olive sphinx
lean canopy
#

lmao the while loop is actually a character smaller

lean canopy
#

like

olive sphinx
#

Your while statements is long vertically, a for statement compresses it. This is from what I can see

lean canopy
#

vertically yea

#

I don't really care about that tho it's honestly simpler to do the while loop

#

but yea if I did care that would be good

olive sphinx
#

It is mostly preference

lean canopy
#

okay I'm just gonna assume it was fine, somebody else pointed out that my outermost loop was completely useless so I fixed that but other than that I think I like mine better

#

yah

#

that's kindof what I'm looking for anyways I do want to see alternative methods bcuz the more I see the more I understand the langu waj better :3

hardy tusk
#

bro typescript is so stupid, apparently for test = "default" Type string is not assignable to type "default"

#

what dumbass made this shit?

#

in type definitions you can do stuff like string or Array but you can also specify how it should look so you can do ("option1" | "option2") or [ number, string ] for arrays. This works great for functions and the like but for a simple variable declaration the compiler has a brainfart, wow.

round bone
hardy tusk
#

😭

round bone
subtle cove
#

type monke:${string} is not assignable to type string

hardy tusk
hardy tusk
hardy tusk
hardy tusk
round bone
#

Shouldn't it be like that?

hardy tusk
#

read what I just said.

round bone
#

I'm on 6.0.2

hardy tusk
round bone
#

I do not get your point at all. It's an expected TypeScript behavior

hardy tusk
#

if you assign that type to an interface and do the same thing it throws an error, THATS my point

round bone
#

Show me in the code

hardy tusk
#

I dont have the original file anymore because I threw it away

round bone
hardy tusk
#

I just wanted to hack something together for which typescript is superior and it produced this awkward behaviour

hardy tusk
#

not exactly

#

but pretty much same result

round bone
#

There are many solutions.

  1. Use readonly as much as you can. It's like using const over let - more reliable.
  2. Use as/satisfies
  3. as const
#
interface IMyItem {
  readonly prop1: "option1" | "option2"
}

let arr: IMyItem[] = [
  { prop1: "option1" }
]
#

And it works fine, just a simple keyword

round bone
#

I do not have any problems with your code, but sometimes TypeScript might narrow not read-only types like in this case to just a string. If you want to not have readonly and keep the type, just use a type

hardy tusk
#

okay so you have to implement the interface and then it throws the error

round bone
# hardy tusk that does nothing

No, it works. It indicates to TypeScript that this variable is a readonly that is already assigned by the right type. Without readonly, it won't be always sure

untold magnet
#

@distant tulip whats wrong with this durability damage function?

function durDmg(player, itemStack, dmg, id) {
  const dur = itemStack?.getComponent('minecraft:durability');
  let actualDura = dur.maxDurability - dur.damage;
  if (actualDura > dmg && itemStack?.typeId === id) {
    dur.damage = dur.damage + dmg;
    player?.getComponent('minecraft:equippable').setEquipment('Mainhand', itemStack);
  } else {player?.getComponent('minecraft:equippable').setEquipment('Mainhand', undefined); player?.playSound('random.break', player?.location)};
};```it can duplicate the item when u switch slots right after calling this function,
distant tulip
#

nothing is wrong with it, that just aa problem with how the game handle stuff

untold magnet
#

mhm, so i just cant prevent it from doing that right?

distant tulip
#

afaik
maybe try to double check the slot before setting the item

untold magnet
#

if (actualDura > dmg && itemStack?.typeId === id) {

#

hmm

untold magnet
distant tulip
#

yes, but assign
player?.getComponent('minecraft:equippable')
to a variable, you are reusing it a lot

steep hamlet
#

is it possible to damage an item without re-equipping the itemstack?

steep hamlet
lean canopy
hardy tusk
lean canopy
#

o

#

darn

sharp elbow
sharp elbow
distant tulip
sharp elbow
#

For consistency and performance, I always prefer writing ContainerSlot-related item functions. The slot index doesn't change across any amount of time (since I am not reacquiring it) and it tends to be more friendly to API caching.

function durDmgSlot(player, slot, dmg) {
  const item = slot.getItem();
  const durability = item?.getComponent("minecraft:durability");
  if (durability === undefined) return;
  // ... enchantments, other systems, etc.
  slot.setItem(item);
}
#

Outside of this function, I could reduce the durability of many items in my inventory; I acquire the EntityInventoryComponent one time, acquire the slot once for each slot, then this function simply gets the item and sets it back to that slot. I think it is more elegant

#

Only issue is the EntityEquippableComponent or the EntityInventoryComponent instances need to be cached to some variable within the same scope so the ContainerSlot is valid.

sage portal
#

is 4000 lines of code reasonable for one file if it's just for something like scriptevents?

sharp elbow
#

I might add comments that show up more readily in an IDE's minimap feature, like // MARK: <Feature> for VSCode. If it doesn't make sense to split more of it off into more files, then don't

distant tulip
distant tulip
sharp elbow
distant tulip
#

const {x,yz} = block
vs
const location = block.location
is the one that my brain can't get used to lol
you would think they do the same thing

sharp elbow
#

Haha, yeah, that's a fun one too

#

I suppose even the following is different:

// Three API calls?
const {x, y, z} = block;
// One API call?
const {x, y, z} = block.location;
distant tulip
#

huh, i never looked at variables destructuring as multiple api calls

sharp elbow
#

I haven't tested performance on it, but assumedly each of the axis properties are their own API call

distant tulip
#

can we just pass the block to every function that ask for vec3 or is passing a vec3 better

subtle cove
#

back then, most params were strict with the properties

#

now, it's less strict

#

so u can pass any object

#

they'll just try to read the property needed

distant tulip
#

yeah, but would there be any performance different

sharp elbow
#

I haven't tested it, but I would think it is better to pass block.location

subtle cove
#

me when player.teleport(block, block) ;-;

subtle cove
subtle cove
sharp elbow
#

Ah, where it is safe to access regardless of the block's validity?

subtle cove
#

mhmm

#

so getting the xyz from block, instead of location, is less costly

open urchin
sharp elbow
#

Look at that, I was wrong. TIL

grave halo
#

is there any documentation on script api's syntax? like these thingies

wary edge
grave halo
cinder shadow
#

Anyone know if you can cancel eating an item properly? technically cancelling it via item.use works, but it still plays the eating animation and sounds as well as any cooldown you gave it

shut citrus
#

[Scripting][warning]-Attack 1
[Scripting][warning]-ReferenceError: Native function [Entity::teleport] cannot be used in restricted execution.
[Scripting][warning]-ReferenceError: Native function [Entity::playAnimation] cannot be used in restricted execution.

[Scripting][warning]-ReferenceError: Native function [Entity::triggerEvent] cannot be used in restricted execution.

[Scripting][warning]-ReferenceError: Native function [Entity::playAnimation] cannot be used in restricted execution.


[Scripting][warning]-ReferenceError: Native function [Entity::triggerEvent] cannot be used in restricted execution.

anyone know how to fix this?

cinder shadow
shut citrus
#

ok

half ivy
#

Can anyone help me its not puting me in spectator when live equals 0

shy leaf
#

today on scripting api:

distant tulip
#

did they remove depthTest? or is it bugged

warm mason
#

Does somebody know what is the point of CompoundBlockVolume?

#

Because it can't be used in Dimension.containsBlocks or Dimension.fillBlocks

distant tulip
ocean escarp
#

How would I fix something returning [Object Object]

shy leaf
ocean escarp
#

I figured it out

cold grove
half ivy
#

Yeah i figured out. Sorry forgot to delete

subtle cove
ocean escarp
#

So uhh we found something out

#

Apparently lowering certain types of damages iframes no more

ocean escarp
#

The /3 is applying to everything for some reason

wary edge
ocean escarp
#

Tysm

ocean escarp
half ivy
#

Hi im trying to detect when a player is not wearing anything on head but i can't figure it out.
let headEquipable = player?.getComponent("minecraft:equippable")
let head = headEquipable?.getEquipment("head");

wary edge
stray spoke
#

only ones I know is score and text

random flint
ocean escarp
#

Is entityHurt cancellable?

wary edge
#

Wait, never mind lol, just do event.cancel

ocean escarp
#

I tried to cancel it and it went through anyways

wary edge
#

You're using beforeEvents right?

ocean escarp
#

Yup

#

Had an idea that some items gave less iframes

#

And figured out how to cancel iframes too

wary edge
ocean escarp
#

Oh

#

Welp

#

If it's a bug I should stop working on it at all

olive sphinx
wary edge
#

Yes.

remote oyster
snow knoll
rough elm
#

Can someone help me rq with my first player script

world.afterEvents.playerJoin.subscribe((event) => {
    const firstPlayerJoin = Database.get("survivalPlus:firstplayerJoin")
    const player = event.playerName
    if (firstPlayerJoin == undefined) {
        Database.set("survivalPlus:firstplayerJoin", {firstPlayerJoin: player})
        console.log(`${firstPlayerJoin}, ${player}`)
        player.runCommand("say firstJoin")
    } else return
})
#

It's says not a function at anyomous 10

rough elm
#

Hmm

#

Ok

ripe dune
shut citrus
#

how to get offset from body rotation using AABB?

sharp elbow
#

I'm not sure I understand. AABBs don't involve rotation in any way.

knotty plaza
#

I think they mean like, if you are lookin north the AABB is in one position, but if you look east it rotates to always be at your right/left/front/back

#

Maybe

jade quest
cinder shadow
#

and I'm not actually removing/moving the item lol

jade quest
# cinder shadow nope

i found a solution for the animation thing, im not having the issue with sounds though so im not sure about that

jade quest
cinder shadow
#

It's because I have my item consumed instantly

jade quest
#
"animation.humanoid.use_item_progress": {
  "loop": true,
  "bones": {
    "rightarm": {
      "rotation": [ "variable.use_item_startup_progress * -60.0 + variable.use_item_interval_progress * 11.25", "variable.use_item_startup_progress * -22.5 + variable.use_item_interval_progress * 11.25", "variable.use_item_startup_progress * -5.625 + variable.use_item_interval_progress * 11.25" ]
    }
  }
}

you just gotta make these numbers negative and play it as an animation, or subtract them from whatever animation you want to play instead

jade quest
cinder shadow
#

I was trying to cancel food consumption when someone interacted with specific blocks that would use that item

#

It's the eating particles that still play

#

and sound unfortunately

#

I was just going ot leave it how it is

jade quest
cinder shadow
#

Still trying to figure out how to reproduce another bug related to item cooldowns so I can report it but it's nigh impossible to

hazy nebula
#

How can I make the entity rotate according to the player's perspective?

lethal lichen
#

does anyone have ideas on how to decrease the performance overhead of Dimension.placeFeatureRule()?

i'm doing a lot of calls into it. queueing them via system.runJob() slightly helps but it's still a blocking operation

#

if only it could be run on a separate thread

potent drift
#

One question: what is the new, or let's say latest, manifest.json plis

hazy nebula
honest spear
turbid delta
#

@honest spear Do you love kittens?

honest spear
#

Do I? idk

#

#off-topic btw

turbid delta
#

Way to dodge the question

#

You must hate them

#

I always knew you were a cat hater

granite badger
honest spear
#

Nice, you can add some post in script api resources on BAO

shy leaf
#

interesting

sage portal
stray spoke
#

I thought the opposite

subtle cove
#
  • are they relative? ==
  • are they actually the same? ===
whole saddle
#

Is there an event for falling blocks by any chance?

#

any way I could stop this dupe?

whole saddle
#

how can I stop this dupe then?

subtle cove
#

track the egg

#

states: block|item|inventory

#

save in world

#

then cancel stuff if it's not in original state...

#

contextually speaking ;-;

whole saddle
#

thanks

hazy nebula
#

Does anyone have the chestForm typeId for version 1.26.13?

subtle cove
hazy nebula
valid ice
#

πŸ—Ώ

untold magnet
#

is it possible to detect the movement direction using queries?
like detect when the entity moves towards north, south, east or west?

untold magnet
wary edge
#

Query? If you're trying to use molang please use the proper channel.

untold magnet
#

didnt even noticed that channel, my bad

honest spear
# valid ice πŸ—Ώ

Looks like its about to break in latest preview anyway, have you find a way to make it possible to generate from resource available in runtime like ItemTypes.getAll or something? and hash the item typeId?

valid ice
honest spear
honest spear
#

cus i do previews as well

#

not sure if mojang does that

#

they got preview, my bad then

#

πŸ‘

lean canopy
#

block function

#

entity function (i tried modifying it to just use the same while loop structure)

#

why does world.sendMessage("" + blockTestFunc()) correctly send the type ids of the blocks

#

but entityTestFunc just responds with blank items

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.

lean canopy
#

yeah unfortunately i cant connect to the internet on my computer rn

#

although ig i could probably transfer the file to my phone and just send the.json

#

lemme try that

#

js not .json mb

#

but yah thats better

#

forgot i had a usb cord with me

lean canopy
#

actually I think it's just ,,,

#

which makes me think its returning one vector3 or something?? idk its weird

shy leaf
#

sometimes its overworld, sometimes its Overworld and sometimes its minecraft:overworld

#

why is the game like this

lean canopy
#

rip

lean canopy
shy leaf
#

weather check

#

since getWeather is still in beta (WHY), im using weather change event to track it

#

but

#

when the weather changes via command, it returns overworld for dimension param

#

but when it changes naturally by weather cycle, it returns Overworld

#

?????

#

like excuse me

#

how

lean canopy
#

thats so cool lol

#

very fun moyang

shy leaf
#

im gonna throw a tantrum oml

#

my addon struggled a lot just because of this should-be-simple weather check solely made for trident impaling

wary edge
#

Get actually ragebaited.

shy leaf
cerulean cliff
distant tulip
#

what does the docs say it returns

shy leaf
#

for WeatherChangeAfterEvent

#

why does it not use Dimension and use string instead? i dont know!

shy leaf
#

but that MAKES IT EVEN WORSE

distant tulip
#

if only we could read the source code

shy leaf
#

oh nonononono i wouldnt want to read the source code

#

that would make me want to boil my brain, literally curse of knowledge

#

ranging from "we could do this???" to "why the fuck is it like this???"

cerulean cliff
#

I think we're better off not knowing the stuff thats happening there...

shy leaf
#

yeah this is what Tony Stark would feel

#

knowing too much

#

to the point where its going to haunt you

cerulean cliff
#

trust me, some of that shit will haunt you

#

poor freddie dug too deep and saw horrors beyond his imagination

#

functions with 60+ args....

wary edge
wary edge
#

Has anyone sent a welness check on that dev?

cerulean cliff
wary edge
#

I cannot fathom what would require that.

cerulean cliff
#

frames

wary edge
#

Ah client stuff.

#

I thought it was server side logic.

cerulean cliff
#

oh no

#

the func with 63 args is the one that renders the game

#

and one frame is like 103mb alone... add the bgfx context and uniform buffer and you'll approach 500mb

lean canopy
#

ok

#

I'm home now

lean canopy
# lean canopy
  const { x, y, z } = ev.block.location
  function blockTestfunc() {
    let bT = [] //bT stands for blockTest
    let i = 0
    let b = -1;
    while (b <= 1) {
      let c = -1;
      while (c <= 1) {
        let a = -1;
        while (a <= 1) {
          bT[i] = ev.block.dimension.getBlock({
            x: x + a, y: y + b, z: z + c
          }).typeId
          a++;
          i++;
          ;
        }
        c++;
      }
      b++;
    }
    return bT
  }
  function entityTestFunc() {
    let ET = []
    ET[0] = ev.block.dimension.getEntitiesAtBlockLocation({
      x: x - 1, y: y, z: z - 1
    }).typeId
    ET[1] = ev.block.dimension.getEntitiesAtBlockLocation({
      x: x + 1, y: y + 0, z: z - 1
    }).typeId
    ET[2] = ev.block.dimension.getEntitiesAtBlockLocation({
      x: x + 1, y: y + 0, z: z + 1
    }).typeId
    ET[3] = ev.block.dimension.getEntitiesAtBlockLocation({
      x: x + 1, y: y + 0, z: z - 1
    }).typeId
    return ET
  }```

here's the functions
#
world.sendMessage("" + blockTestFunc())``` and this message sends correctly in chat for blockTestFunc
#

world.sendMessage("" + entityTestFunc())
but entity it sends this

cold grove
potent drift
lean canopy
#

idk what the link is for but yeah looks like typeid is undefined which is weird cuz somebody else gave me a link to it which shows typeid being listed there

cold grove
lean canopy
#

i was wondering lol

#

probly just misclick

#

wait nvm typeid IS there

lean canopy
cold grove
lean canopy
#

so are entities not objects?

cold grove
#

Entity[]

lean canopy
#

ohhhh no cuz it lists each entity at that block

cold grove
#

Yup

lean canopy
#

i got it now lemme try something

#

ok so

#

basically my code is making an array of arrays of objects

cold grove
#

Is making an array of undefined bao_ext_toldyouso

lean canopy
#

right aorry

#

i mean if i take the type id out

#

its gonna make what i said

#

cuz then im setting ET[number] to getentitiesatblocklocation which returns an array