#Script API General
1 messages Β· Page 138 of 1
I used player.inputInfo.getMovementVector()
Didn't know about that
But yeah yours worked too
test
How 5o make my item detectable using itemUseOnBlock event ?
is there a way to check the the stack size of an item without using try catch?
Why would you need a try catch?
Just do ItemStack.amount
Simulate if an item stack size is 1 (like weapons, armours etc) or 16 or 64 and listen to whether there was a fail or not and from there determine what size it is
But I need the max stack size
ItemStack.maxAmount should work
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
There is an event for that.
What is called?
World Structure Manager can't read from the STRUCTURES folder in the Behavior Pack!?
yes, for now
I believe the previews gave a way to.
Bruh, but if I use runCommand wouldn't it just work anyway?
/**
* @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[];
Okay.
What is it called
EntityContainerOpenedAfterEvent
Hmm is it beta
it is preview beta
Can it check when interaction ends ?
EntityContainerClosedAfterEvent
no
everything so far moved to stable beta before releasing, if i am not wrong
Oh, what about interactionEnds
what does that mean
Unfortunately, it's unable to get the namespace of the structure that was saved to the pack. This kind of sucks, I guess I'll just have to make sure it's included in the name when saving it.
It just seems to always default to mystructure even if changed.
it dependant on the folder name where you put the mcstructure iirc
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.
well, it matters when u save it in world
the folder is for compatibility
is it possible to set armor stand pose using scripts api?
or atleast get the armorstand's pose index via scripts
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
hasTag is a method
hasTag("my:tag")
ohh
well that explains a lot
even checked the docs and didnt see it π
im lwk stupid
How can I detect if a player has mined a block using a tool with a custom component ("custom:component")?
give the custom component the onMineBlock event.
How?
There should be a bot that replaces the docs urls with a descriptive embed
item.
Like fixtweet
Sorry
Thanks, I'll take a look
Huh...if you get current entity health in before entity hurt it returns the health after the damage is applied.
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?
wait, you mean returns the health after the damage is applied? or it returns health value that an entity would have if they took damage?
The Latter.
Wait arent those two the exact same.
No, just 32,767bytes per string
i was confused by what you said and thought it was being delayed
lol
although that can be somehow useful
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?
could be, try getting the new comp inside the event
Sounds more like the way they handle components/expose entity attributes
if its true, we would be able to tell that they basically duct taped and hotwired this event π
That wouldn't leave to the callback to run on the next tick?
well scripting usually dont do that unless otherwise specified (like Entity.triggerEvent)
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);
}
}
});
Just save the tick that the player jumped at, then when checking the difference, you can do it like this
if (system.currentTick - oldTick > 10) return;
67
67777
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.
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
I know
I don't know how can I use this, doesn't this stay the last count
Use a Map to store it on the player's id
When looping through players I highly suggest using runJob() to account for large player base and long tasks, and use runInterval to recall the job while monitoring to ensure there is no overlaps. It's extremely more performant this way.
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.
You did a lot tbh, genuinely thanks a lot
All I needed only is to import it, very convenient
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.
Lol I had that same caffeine boost too
is there a way to cancel attack cooldowns? so using a spears lunge for example
I noticed this too. Just add the health's currentValue to the event parameter's damage to get the original health value.
It's an odd choice but thankfully it is easy to reverse
I originally had current HP - damage to see if it would kill the entity so I was quite confused why it kept saying I would one shot my entity.
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
Interesting.
I feel like this is something the docs should have elaborated on, because what
What?
how can i make splash particles like when a player jumps in water
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??
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
What do you mean?
hey
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
I wanna ask if do we can edit player permissions
Like disabling pvp to a specific player
entityHitEntity before events cancel
Wait, idk if that'll work
That's too simple to work, but Iemme try
Ir depends on the thing you are trying to do
If you want to disable buildings , open chests etc....
There's no entityHitEntity before event
There is entityHurt if that helps?
There is.
There is
Oh
You should clarify if you're using not beta APIs.
Maybe you didn't update your npm package
Therefore I will assume you're not using Beta APIs?
npm i @minecraft/server
Yes I'm on stable
In terminal
I'll try to redownload npm
EntityHurt is Beta APIs.
My package json says 2.5.0
So you're not using Beta APIs.
Okay found EntityHurtBeforeEvent now, I'm now 2.6.0
Sorry idk what you mean, 2.6.0 stable has EntityHurt also
Ah, the docs I'm using are wrong as well!
This is great, I can cancel and customize damage, probably gonna use for attributes addon or team damage
?
what I mean by this is maybe some sort of beforeEvent?
like itemUse or entityHurt
idk what I would use for the spear
you can edit the spear file.
I thought you couldn't edit item jsons?
some items you can, not all.
spears are data driven, surprisingly
but uh, you can just constantly reset item cooldown of spears
through script API?
yeah
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
this?
oh nice
so would that override the active cooldown
like say the cooldown already starts and I use this with like 1 tick
yeag
Guys what is the newest version of minecraft/server ?
2.6.0
Oh thx
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 π
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)
Only across the same world.
player.id is same between all worlds i think
nope they are not
No, they aren't. Only PFID and XUID are
for an localhost i might be the same evertime, but thats only bc is the first creted entity afaik
Yes, but it's not good to use across many worlds anyway
Bun's still better
I've been using it for a longer time and I didn't really encounter edge cases
yea i wanted to port big project to bun directly but damn it was sometimes broken
I didn't have any struggles with porting mine projects lol
Docker, packages, everything worked even better
i haved problem with canceling scripts runned via bun run
it just broke whole terminal
Wdym canceling? While running them?
ctrl c
What did you run? I don't have any problems with it
it was nested propably like bun run bun run something
Have you always been able to dupe items that have their durability handled through scripting?
Guess I need to add validation checks
Dupe how?
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
Yeah, it sucks we have to set the item back into the slot of the inventory to update anything.
fr
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
Are you using EntityEquippableComponent? "Mainhand" container slots will change indices depending on when it is queried
guess it does go off every now and then
I'm not entirely sure why we have to set Items back into the inventory though. Blocks and Items dont have to.
I recommend using the EntityInventoryComponent and storing the slot index, or to store the ContainerSlot and write back to it
This is using the inventory component
Make the slot a variable
make every item have a dynamic property of it's slot π
item stacks are equivalent to block permutations
container slots are equivalent to blocks
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
I guess because we also have getSlot() instead of getItem();
I hate how you're right.
I never htought to see it like that.
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
Reminds me of the inventory link addon
const slotToReplace = inventory.getItem(entity.selectedSlotIndex).typeId === itemStack.typeId ? entity.selectedSlotIndex : inventory.find(itemStack);```
no way this is the ideal solution
i uh, have a durability code but ive never had the duplication problem
I've never either, I can't even replicate it even when it detects a different slot
or this kind of problem as whole, to be exact

Wana try transferItem in runJob π
Are you synchronously reading and writing to the same slot in the same tick/function?
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
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);
}
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;
}
})```
Mm, I see.
oh custom components
i only have good experience with events so ill just silently slip outta here...
Why 2 durab updates tho
onBeforeDurabilityDamage only triggers when you hit an entity to my knowledge.
That's the only time the engine decrements the durability automatically for you.
Oof
It doesn't trigger for armour taking damage last I tested as well.
that sounds chaotic
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
how to create custom js modules?
You can import from other files
import { MyClass, myFunction } from './modules/myModule'
oh, I mean creating and importing custom npm modules
I guess you can the same way you can use @minecraft/math
If you go to "Core build tasks" it says it works in other repositories https://learn.microsoft.com/en-us/minecraft/creator/documents/scripting/libraries?view=minecraft-bedrock-stable#core-build-tasks
Is there a way to detect when a chunk is generated?
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.
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
You need to set it on every part if I recall.
How would you get put permanent text on a players screen whenever they are holding a specific item
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; }
```js
Thanks!
I wanna ask how do we exactly copy paste a block, like all states or data in its Block class are copied
Idk about the data, but you can change just 1 state by doing
const { permutation } = block;
block.setPermutation(permutation.withState('namespace:something', true));
json ui?
sounds (relatively) simple
No like something above their hotbar
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
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!
Thanks yall
Did the code work for you?
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
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.
Maybe use world.afterEvents.playerSpawn where you first detect if its data.initialSpawn before showing the form
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
I did that, but it's still inaccessible. I even tried adding a delay to the action to test the UI, and it opened, but it's a weakness to depend on the load of each device.
Great idea, I'll try it, thanks
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
Bro, I love you, thank you!! It finally works, I've been trying to fix it all day.
i dont like how setting unbreakable doesnt account for setting durability damage
suffering from success
i thought that property would be so the item doesnt break when the damage is greater than max durability, that you can define in the component, disappointed when that wasnt the case lol
and i thought the durability would just freeze entirely
but no, setting durability still changes it, so if you have a custom durability function prior to unbreakable component it wont work
Entity.getAABB() in which version was released?
2.5.0 iirc
Oh thx π
just checked, 2.4.0
how did you check
most useful thing ever
Huh, I think you're using an outdated npm π
EquipmentSlot is now Stable
it's not outdated
EquipmentSlot.Body is in beta
the thing is that it's for mobs
but equippable doesn't work for mobs
It's probably getting added again in Preview?
mbmb
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)
projectile component should have owner property that can be written
currently i got the whole code working, the projectile is moving towards without issues besides damaging the player in the process
takes Entity
how can i use that while summoning it using scripts?
uh, youre using shoot method, right?
show code
yeah
js code
then spawn the projectile entity, touch the projectile components, and then shoot it
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);
};
};
});;```
add view direction to head location
forgot to remove it lol
i see
its a whatever anyway, but yeah also do that
i was trying to use the projectile model, but i couldnt get it to look like the slash particles
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
like const proj = dim?.spawnEntity('xfallenwarriors:ancient.sword.slash.attack', {x:hX + dX, y: hY + dY, z:hZ + dZ});?
yeah
but either way, just do
proj?.getComponent('minecraft:projectile').owner = player;
for the owner
alright, ill give it a 'shoot'
so it will be spawned in front of the player and not in his head
the 'owner' one should work the best here, to make the projectile make other mobs targets the player when they get hit by it, in aLOT of the marketplace addons, they add new weaopons/projectiles that wont make other mobs like irongolem targets the player when get hit by the new projectile
I know, I always add owner when I use projectile component
the projectile no longer hurts the player, but it doesnt agro the iron golem or other mobs
uh, it should aggro...?
proj.getComponent('minecraft:projectile').owner = player;
check damagingEntity in entityHurt, this doesnt seem right

it shows the projectile id not player id
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
what in the
try it with arrow
it works there
something is wrong in the projectile.json
mhm
apparently having the runtimeId set to snowball doesnt make ur projectile have an owner,
but
changed it to arrow, now it works
Runtime ids π
yeah, it doesnt work for the snowball runtimeId,
it works for arrows and not snowballs?
according to them
snowball itself work fine
what....
dimension travel trigger item stop use??
bruh
When you're standing still.
What is AABB() ?
entity collision box
Oh
Axis aligned bounding box
So a fancy way to say collision box ?
uhh basically yea
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.
why does debugText.depthTest = true not hide the debugText behinde a block?
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.
Wild encounter system, but no pokemons yet
how did you make this camera transaction effect?
Im using camera class from player class
The fade method makes it fade black
While setFov makes the zoom effect with easing type
yo is .setRotation() broken. It'll let me set the x rotation but not the y rotation
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??? )
i have the same issue. The render distance doesnt work as well
The is_experimental parameter does nothing
Its functionality was removed when experimental gameplay was split into separate toggles
using setPov will be weird no? cause people play on diffrent pov so using a set pov will make it look diffrent for all players
setFov ? so thats new emm
How?
They're setting both the POV and FOV and then clearing it. What the user has has not affect.
I ment fov not pov sorry, I ment if you set fov to 80 at first, for player at 60 fov it will fell like zooming out and for people with 110 fov it will fell like zooming in right ?
When I was messing with fov i though there would be some like getFov then I can +- from that, but there aint
Is there way to make script write json(save data)
very no
best you can do is to make a database
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?
That seems like a good stackoverflow question.
ong
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)
As long as you manage for potential collisions, which can happen as it grows, then it will remain O(1).
It can go as high as in the billions and remain O(1).
So long as you don't have collisions.
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.
Oh I see
Ok yeah, then I don't think I will ever get a collision if that's the case
Most likely not. Kinda like a UUID. Chances of a collision is extremely low.
As long as your code is written properly
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
SetPermutation is for specific permutation while type is for BlockType.
Some events only gives you BlockPermuation others gives you Type.
Permutation to place.
CustomCommandParamType
Huh
can i get an entities mainhand itemstack?
there is no entityHitEntity before event, how to get entity hit and target entity to cancel damage, knockback and other side effects?
entityHurt beforeEvents is the only way to do this atm
but side effects are kinda inevitable
any code examples?
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
does it prevent knockback?
yes
but not mob effects or fire aspect
other effects like trident channeling are untested, you gotta check it
ok thanks
interface EntityContainerAccessEventOptions what is it used for?
I guess for entity open and close inventory after before events
Perhaps
We can only setFov in a range of only 30 to 100, might be weird but it's not extreme
Yeah Player.camera.setFov(number, options)
30 to 110 i think
ohh
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
You can only use one root file in manifest, I guess. But you can make your root file connect with other files
How I can do this?
simply do
import "./myEvent1.js"
import "./myEvent2.js"
And do I need for example in the other File Some Special Things?
For example in ./myEvent1 oder ./myEvent2 ?
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
Ok, thank you < 3
So I only need the import and No Export or Something else
In the other Script, right?
No need
Thanks
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"
But Like commands I dont need this
Or Events or Something else
const inv = player?.getComponent('minecraft:inventory').container;
console.warn(inv?.find('my:item'))```returns a log
```js
[Scripting][error]-TypeError: Native type conversion failed. Function argument [0] expected type: ItemStack at <anonymous> (xFallenWarriors.js:62)```
i do have that 'my:item' in my inventory
it is expecting ItemStack, not id
i see, hmm
so i cant just use it to find my specific item, i have to use a loop to search for it ig
only if the amount matter to the function
can i find a specific item in my inventory and trigger its cooldown? only one item is enough here, no need to trigger it multiple times
alright then, fuck the whole bug i am currently having
You can start item cooldown with player.startItemCooldown(category, ticks)
-# You can't individually set a unique cooldown on each item tho
ill use that for something else, the current bug i am having is not from my script, rather from the client side so i thought about starting the cooldown to prevent those bugs from happening
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,
even with v.attack_time?
-# c.owning_entity -> v.attack_time
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
yeah, swinging the arm before switching to the item cause the attack animation to be played
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
mhm
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
i was searching for this in the cooldown component...
why is in the player class
Perhaps this could be combined with q.life_time? If the difference in the new value and the last known value is noticeably larger than before (any larger than q.delta_time, as an approximation) then the player might have switched from another item to your attachable
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,
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 ->
the sword i am making is kinda strong, so making it unusable while doing everything else is better than fixing the actual bug
I hadn't thought about that, but it makes sense. Thanks for sharing
"transitions":[{"lock":"q.cooldown_time_remaining('slot.weapon.mainhand', 0) != 0"},{"is_charging":"q.cooldown_time_remaining('slot.weapon.mainhand', 0) == 0 && c.is_first_person"}]
i just have to add c.owning_entity -> there ig
this bug was dragging me crazy yesterday, i had to add a whole lock system just to fix it
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.
playAnimation my beloved
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,
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
mhm,
what are u talking about?
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,
oh you mean changing the variable? Yeah, that works. Even in attachable pre-animation molang too.
so how can i do that? i will be using it in a future project.
The concept of how it works is basically FMBE, but the variable can actually bleed into the attachable. This one showcases their method: https://discord.com/channels/523663022053392405/1463304436330922014
thanks,
||tem sim|| but we only can speak english here
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
"good idea"
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?
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?
The best way is to do it client-side, and use q.is_charging and q.is_charged
is there a way to query those with script?
Just to check when is charged
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entityischargedcomponent?view=minecraft-bedrock-stable
const charge = entity.getComponent("minecraft:is_charged")
console.error(charge.currentValue)
So I would do this to test right?
Just do this or check if its undefined
entity.hasComponent(EntityComponentTypes.IsCharged);
"When added, this component signifies that this entity is charged."
Hmmm ok, thanks. So that would test if it's fully charged up it seems? I've done a little bit of testing.
yes
Thank you!
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
No
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.
yeah but the rendering is cooler
Functional is better
I guess you can create a barrier block box and add a very limited fog?
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
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
i don't plan for the identifier to be the same for every world. just wanna make it reference to a player, in a world.
If it's just an addon (not a server add-on), it's okay to use it, but just remember that if you want to have a consistent player identifier across the worlds, use XUID
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)
"clickEvent" is not a thing
oh this command is for java edition
the host runs a tellraw that puts a message in chat
idk then
this is a bedrock server..
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
damn i wish it bricked the entire command
At most you can change their permission
the command is executed from the server console by my server host
You can just override who's permitted to a command. You cannot change it's behavior directly
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?
Yes
Yes, as it's type safe for custom components.
It makes sure that you won't use anything that does not exist or makes no sense
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) {
// ...
}
I see
Oh, well I was using whatever existing example was there. That could be EntityInventoryComponent, for example
I understood
TypeScript automatically assigns a type of a certain component due to type mapping
You can check if it's undefined in your code and it'll be the same (but only in TypeScript)
We're still talking about the pre-generic getComponent, right?
getComponent is generic?
In order for EntityComponentReturnType to be used in newer scripting versions, yeah
const inv = entity.getComponent(EntityComponentTypes.Inventory)
if (inv == undefined) return;
Why not use something like this
wouldn't you just do if (!inv) return?
that works too, I just said cause they were talking about undefined detection
That is missing the purpose of this discussion, anyway
Yeah, it's better and that's what I was trying to get the convo to
Also, it's better to use enumerations
It is better to use enumerations.
Why ?
If values do change, enums are also updated
This isn't a good solution in older versions of the scripting API where the type of getComponent returns EntityComponent. And my stance on the debate is asserting a type using as isn't fully safe either
Ohh i saw worse, idk why, I need to sleep ngl
Good night
I have thought that this is a generic function for a longer time
getComponent being generic?
Yeah, isn't it?
Yeah, just double-checking that I follow
That's fair, the generic typing is quite convenient. Those QOL improvements do make for interesting discussions when we go back to older API versions
Since I've picked up TypeScript, add-on API is much smoother heh
Writing type-safe code within JavaScript is an art on its own
A banned art
An art I'm willing to follow if I'm too lazy to set up esbuild lol
What workspace do u use ?
the one from mctools.dev ?
or regolith ?
I setup everything on my own
cool
yeap
They're pretty empty imo
It works good for me
hence it's experimental stuff here, mostly
I prefer to setup everything on my own. Like Prettier, ESLint, pre-commit stuff, CI actions (GitHub config files in general) etc.
I think Microsofts one has prettier and ESLint
yes it does
It's very poorly configured IIRC, also I use Bun instead of Node
This is how the workspace looks like
It's just wrong for me, but it's only my opinion
i used to use onedrive
I like it personally
Is the equippable component still only accesible for players?
Yes π
βΉοΈ Gemini is so adamant on gaslighting me it works on mobs, no matter my testing. there goes my dreams I guess.
The documentation says it explicitly
??? Why use ai to ask that
It says it is on all mobs and can be gotten for all players or something, Doesn't say no mob can access it
"Provides access to a mob's equipment slots. This component exists on player entities."
note to self: mace smash cant be canceled
There's a workaround using runCommand using hasitem selector filter to check specific items on a certain slot, then retrieving success count of it...
-# basically a bruteforce method of guessing
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
function coolfunction(dimension, { x, y, z }) {
const blockTypes = [];
const belowY = y - 1;
for (let dz = -1; dz <= 1; dz++) {
for (let dx = -1; dx <= 1; dx++) {
const block = dimension.getBlock({ x: x + dx, y: belowY, z: z + dz });
blockTypes.push(block?.typeId ?? "minecraft:air");
}
}
return blockTypes;
}
idk if that works
but yeah
so what da heck is this dz dx thing doing
also how do you increment belowY
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
dz & dx are like variables. These go up till it meets the value that is greater then or equal to another value, which in this case is 1
so
why is
like
whats the difference between using dz and dx or i and j like I used
No difference, just preference and clarity mostly
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
It doesn't it is static
cuz this looks exactly like my while loops except missing one and formatted into for loops instead lol
okay
cuz this is literally what I came up with but with for loops instead lol
Your y never changed, it was always y - 1 so it doesn't need to change
bruh I just said the same thing twice
uhhh incorrect
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
If it does change, just add another for statement loop
which again is already what I've done but just in a for statement instead :P
does that even save characters?
What do u mean by save characters?
lmao the while loop is actually a character smaller
Your while statements is long vertically, a for statement compresses it. This is from what I can see
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
It is mostly preference
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
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.
It works right, if you want to specify the string, you have to do this:
const test: string = "default"
bro did not get at all what I meant
π
I get it, you didn't declare a full type and now TypeScript interprets it as a constant. Specify the type to avoid situations like this
type monke:${string} is not assignable to type string
you can do stuff like ```ts
function test(param1: "option1" | "option2") {}
// and run that with
test("option1")
test("option3") // would create an error
// doing
let arr: { prop1: ("option1" | "option2") }[] = [ { prop1: "option1" } ]
// throws an error however
wdym I didn't declare a full type??
it makes no sense why this syntax is supported for parameters but not properties or variables.
oh right so this doesn't even produce an error it seems. It is strictly when you use it with an Interface it does it
const array: ({ prop1: "option1" | "option2" })[] = [
{
prop1: "option1"
}
]
Shouldn't it be like that?
read what I just said.
It does not throw error for me at all
I'm on 6.0.2

I do not get your point at all. It's an expected TypeScript behavior
if you assign that type to an interface and do the same thing it throws an error, THATS my point
Show me in the code
I dont have the original file anymore because I threw it away
interface IMyItem {
prop1: "option1" | "option2"
}
let arr: IMyItem[] = [
{ prop1: "option1" }
]
Like this?
I just wanted to hack something together for which typescript is superior and it produced this awkward behaviour
yeah like that
not exactly
but pretty much same result
There are many solutions.
- Use
readonlyas much as you can. It's like using const over let - more reliable. - Use
as/satisfies as const
interface IMyItem {
readonly prop1: "option1" | "option2"
}
let arr: IMyItem[] = [
{ prop1: "option1" }
]
And it works fine, just a simple keyword
that does nothing
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
okay so you have to implement the interface and then it throws the error
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
@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,
as u can see
nothing is wrong with it, that just aa problem with how the game handle stuff
mhm, so i just cant prevent it from doing that right?
afaik
maybe try to double check the slot before setting the item
const stackItem = player?.getComponent('minecraft:equippable').getEquipment('Mainhand');
if (stackItem?.typeId !== id) return; works just fine
yes, but assign
player?.getComponent('minecraft:equippable')
to a variable, you are reusing it a lot
is it possible to damage an item without re-equipping the itemstack?

check ur recycling bin u probably still do
It's not that deep bro. I was just ranting. The file was a temp unsaved file in the vscode editor, so its not been saved anywhere. And Im not even home anymore so theres no point anyhow.
Depends on how you are grabbing the ItemStack instance. I have heard people encountering an issue like this with custom components more than item-related world events
Since the logic is branching, it is technically used only once. But DRY could make the result prettier
yeah, i ignored that in his first message, but not sure where he is adding the check
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.
is 4000 lines of code reasonable for one file if it's just for something like scriptevents?
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
yeah, small stuff like this seem unnecessary, but you quickly find out they are when scaling up
stuff inside scriptevent itself can be imported from different files
beside readability do keep in mind other stuff might suffer from large files (4000 is nothing, but i am just saying) like the spellchecker or formatter
It's kinda silly where you can find optimizations. Even location property access on entities is an API lookup. If you're iterating 1000 times and acquiring location each time, the game will cry.
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
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;
huh, i never looked at variables destructuring as multiple api calls
whaat? that's a thing? noted
It only happens to be here because both a Block instance and the location property technically satisfy the Vector3 interface; Block instances have properties x, y, and z.
I haven't tested performance on it, but assumedly each of the axis properties are their own API call
can we just pass the block to every function that ask for vec3 or is passing a vec3 better
it works on entityqueries, and other params
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
yeah, but would there be any performance different
I haven't tested it, but I would think it is better to pass block.location
me when player.teleport(block, block) ;-;
i think the only difference would be the object's byte size... or somewhere along the lines of new objects being created during the execution
fun fact, that xyz from block is value similar to id and not getter. I might be wrong tho
Ah, where it is safe to access regardless of the block's validity?
yes, since their values are already present on the Block object whereas .location requires an additional native call
Look at that, I was wrong. TIL
is there any documentation on script api's syntax? like these thingies
Thats normal JS stuff.
ok
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
Confiscate the item for a tick

[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?
The functions you are trying to call cannot be used in "before" events. You will need to either move them to an after event, or enclose them in a system.run(() => {})
ok
Can anyone help me its not puting me in spectator when live equals 0
did they remove depthTest? or is it bugged
Does somebody know what is the point of CompoundBlockVolume?
Because it can't be used in Dimension.containsBlocks or Dimension.fillBlocks
you can push voulums into it and use all the functions and properties it have
there is some good use cases
How would I fix something returning [Object Object]
for console.log and/or chat?
I figured it out
track when it spawns again i guess?
Yeah i figured out. Sorry forgot to delete
i remember this ;-;
So uhh we found something out
Apparently lowering certain types of damages iframes no more
== not =
Tysm
I was trying to teach my friend and completely forgot
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");
const comp = player?.getComponent("minecraft:equippable")
const equip = comp.getEquipment(EquipmentSlot.Head)
Yeah it got the same syntax but click event doesn't exist on bedrock
only ones I know is score and text
or do "Head"
It's case sensitive for the Enums too If I remember correctly. So "Head" instead of "head"
Is entityHurt cancellable?
Set the damage to 0 in the before events.
Wait, never mind lol, just do event.cancel
I tried to cancel it and it went through anyways
You're using beforeEvents right?
Yup
Had an idea that some items gave less iframes
And figured out how to cancel iframes too
https://discord.com/channels/523663022053392405/1492966394474659961 Could be related?
It also can be === too right
Yes.
The preferred way honestly
Real
Read up on the difference one time, and I dont even fully understand what it meant, but that one is better
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
use playerSpawn instead
how to get offset from body rotation using AABB?
I'm not sure I understand. AABBs don't involve rotation in any way.
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
did you end up finding a solution for this other than removing/moving the item from the slot its in?
nope
and I'm not actually removing/moving the item lol
i found a solution for the animation thing, im not having the issue with sounds though so im not sure about that
good idea xD
It's because I have my item consumed instantly
"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
ohh right, i would have thought the eating animation would stop in that case
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
ohh i guess we had a different problem then, for me it was playing the eating animation on an item with the use animation set to none
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
How can I make the entity rotate according to the player's perspective?
like fireball?
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
One question: what is the new, or let's say latest, manifest.json plis
It's like whichever direction the player turns, the entity turns in that direction.
you can use "beta" tag for server and server-ui modules so you don't have to worry
@honest spear Do you love kittens?
Hey folks, I've been inactive here but I've been working on making chatbots generate simple and decent scripting code by going through my docs through a custom prompt.
Try it yourself https://jaylydev.github.io/scriptapi-docs/meta/llms.html
Nice, you can add some post in script api resources on BAO
interesting
yeah let's do that https://discord.com/channels/523663022053392405/1498272572079603763
== checks for equal value, === checks for equal value and equal type: boolean, integer, string, etc.
0 == false //returns true, same value
"true" == true //returns true, same value
0 === false //returns false, integer and boolean
"true" === true //returns false, string and boolean
I thought the opposite
- are they relative?
== - are they actually the same?
===
Claude code might help
Is there an event for falling blocks by any chance?
any way I could stop this dupe?
no
how can I stop this dupe then?
track the egg
states: block|item|inventory
save in world
then cancel stuff if it's not in original state...
contextually speaking ;-;
thanks
Does anyone have the chestForm typeId for version 1.26.13?
So that's how it works
Thanks
hello
would this help?
Update typeIds.js
It's still giving the wrong textures; maybe no one has updated to this version yet.
πΏ
is it possible to detect the movement direction using queries?
like detect when the entity moves towards north, south, east or west?
Get the movement vector.
using what? like what query?
Query? If you're trying to use molang please use the proper channel.
didnt even noticed that channel, my bad
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?
Would have to be from latest mojang docs on GitHub , and idk how to do that
i will try to dig in, as i need the ids for me as well
If you want to be ready ahead of time in some kind of branch you can use mine scrapple
https://github.com/bedrock-apis/bds-docs/tree/preview/metadata/vanilladata_modules
cus i do previews as well
not sure if mojang does that
they got preview, my bad then
π
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
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.
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
anyways, replacing entityTestFunc() with blockTestFunc() makes it correctly output minecraft:air,minecraft:obsidian,minecraft:air
etc. etc. but the entityTestFunc() gives ,,,,,,, or smthn
actually I think it's just ,,,
which makes me think its returning one vector3 or something?? idk its weird

sometimes its overworld, sometimes its Overworld and sometimes its minecraft:overworld
why is the game like this
rip
wuhts dis for?
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
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
Get actually ragebaited.
sob
we have our own little bug list just for weather shit now π
what does the docs say it returns
for WeatherChangeAfterEvent
why does it not use Dimension and use string instead? i dont know!
but this could be the reason and Dimension class doesnt work with it so they had to pass string instead
but that MAKES IT EVEN WORSE
if only we could read the source code
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???"
I dont think we want to read that
I think we're better off not knowing the stuff thats happening there...
yeah this is what Tony Stark would feel
knowing too much
to the point where its going to haunt you
trust me, some of that shit will haunt you
poor freddie dug too deep and saw horrors beyond his imagination
functions with 60+ args....

1 function or nested functions that eventually is basically 60 args.
1 function
Has anyone sent a welness check on that dev?
with 63 args π
also uses some of the largest classes... with like 200mb of data
I cannot fathom what would require that.
frames
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
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
Dimension#getEntitiesAtBlockLocation returns Entity[]
So Array#typeId is undefined
I don't understand, I'm asking for the latest one, is it beta-2.6.0 or beta-2.7.0?
what is this link for
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
???
Sorry i pasted the wrong documentation
oh wait
It returns an array
so are entities not objects?
Entity[]
ohhhh no cuz it lists each entity at that block
Yup
i got it now lemme try something
ok so
basically my code is making an array of arrays of objects
Is making an array of undefined 

