#Script API General
1 messages · Page 24 of 1
well you have the freedom to just npm i @minecraft/server@beta
i dont think so
its working now
u have stable doc use beta one if u dont knowi have repo that auto fetch latest ones here https://github.com/WavePlayz/minecraft-npms-auto or use cmd here
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
wait a god damn moment, after i finished termux, bridge back to work somehow
bridge is now working for me
/s
well, now i can complete working on my project
hmm,
how can i remove one item from the entity inventory?
itemStack.amount - 1 or something?
Yes
if (itemStack.amount >= 1) itemStack.amount - 1 this should remove the item only if the amount is 1 or higher right?
Yeah
-= 1 or itemStack.amount = itemStack.amount -1 as you need to set the data back
or .amount--; as well. But you also have to consider that when it's 1, set it to undefined
all works the same right?
itemStack.amount - 1 will not work on its own
itemStack.amount -= 1
itemStack.amount--
itemStack.amount = itemStack.amount - 1
will work the same
itemStack.amount-- will remove one item
itemStack.amount = itemStack.amount - 1
.amount-- is more simpler and smaller
smaller != more readable
block.dimension.spawnItem(itemType, { x: x, y: y, z: z + 1 }) returns a log
should i do something like new ItemStack(itemType)?
well whats itemType
thats inside a function
itemType will be different all time
whats the type of itemType
like
if (itemStack.typeId === itemType) ItemStack.amount - 1
}
// aFunction(itemStack, 'minecraft:dirt')```
if its a string then yes you need to do new ItemStack(itemType)
you could also just pass in the item stack directly and
so block.dimension.spawnItem(new ItemStack(itemType), { x: x, y: y, z: z + 1 })
every time i do something my knowledge is enhanced
gosh,
z: z + 1 returns a log
@simple zodiac 
oh, wait
const { x, y, z } = block.center
should be like this
const { x, y, z } = block.center()
my bad
um, how can i make the item just spawn, without throwing away?
is there a way to get DisplaySlotId of a scoreboard?
i want to test if a scoreboard is displayed on the sidebar
yasser,
how to spawnItem normally without spreading away?
also,
itemStack.amount - 1 isn't working
the item is still there
itemStack.setVelosity({x:0,y:0,z:0)
amount can't go lower than 1
hmm, if (amount = 1) will clear that slot
new ItemStack(itemType)
where should I put that?
in a variable
amount = 0 will not be a thing bec, how tf can u get 0 item in ur inventory
or directly into your slot
nonono, i mean it will just return undefined instead of an itemStack
that would simplify lots of scripte
i know what u mean
true
new ItemStack(itemType)
edit it for me :>
bec idk where should i put that thing
const item = ...
and then use it wherever
i just ran out of braincells, idk how to write that fr
what are you trying to do with it?
block.dimension.spawnItem(new ItemStack(itemType), { x: x, y: y, z: z - 1 })
the item will spawn at some specific locations
hmmm
, ItemStack.setThatThing(x: x, y: y, z: z - 1)?
ooh wait, making it throw the item will be nicer
just like how the crafter block threw items, the system should throw items like it
block.dimension.spawnItem(new ItemStack("diamond").setVelosity({x:0,y:0,z:0}), block.location)
haven't thought this way
but i am not sure if that method would return the itemStack back or not so do this to be safe:
const diamond = new ItemStack("diamond")
diamond.setVelosity({x:0,y:0,z:0})
block.dimension.spawnItem(diamond, block.location)
setVelocity isn't showing up on bridge for some reason
maybe i got the name wrong, wait a second
You cant set velocity on an ItemStack
oh yeah, you need to convert it into an entity first
sup llama
uh, lets not think about making the item not spread away,
this just gets triggered whenever any entity is triggered right?
i gotta make it throwing like how the crafter block works
const diamond =
block.dimension.spawnItem(new ItemStack("diamond"), block.location)
diamond.setVelosity({x:0,y:0,z:0})
Yes
i am not exactly sure what data driven entity event means
When an entity fires an event
That's all
the events can be empty in the json right?
sssoooo
how can i make the item spawn and throw it away like the crafter block?
Yeah
SpawnItem -> Set Velocity
yeah, just set the velocity to something other than 0
propably in the direction of the crafter
i already made the directions
i just need the spawn item system

getVelocity
clearVelocity
theres no setVelocity
getVelocity
clearVelocity
no setVelocity?!
Then apply impulse or knockback
Is essentially the same
how do i set velocity?
the item will spawn and spread anyway
Thats how item spawning works
i remember someone made me a script that will not spread the items when i spawn them
i didn't use that script bec i was making an ore block
oh yeah, i knew i got the name wrong, it's applyImpluse, applyKnockback doesn't work on item entities
applyImpulse works
yes
no it does
it will spawn the item without spreading right?
Try it and see
Anyone know of any way to get biome tags of current location, or block in location or anything in location... ????
Looks like there's no way to get biome tags via ScriptAPI
erm, wrong
its working!!
Need to get without building big if/case... they have MinecraftBiomeTypes... so must be a use
spawning the item normally without spreading away
Ah, must be beta then
Expand please
dimension.findClosestBiome is using tags
It's a little annoying though
becuase that's only going to find one biome
wait... I want to get the biome... not test for them
If you want to get ALL of the biomes part of that biome, you'll need to make a loop through biomeTypes
Ye, but it will only show logs. Any warnings or errors won't show up
there is reverse engineering 👀
if only it was simple
What?
If we're going to go out of the scope of ScriptAPI just look at the vanilla files at that point.
like recreating the algorithm that decides where biomes should generate in Minecraft and use it to return the biome in a location.
What about the BiomeTypes class?
completely within the script API
That just seems like way too much work
the work is already done by minecraft java players, we just can't access it
Ye, that's Java
bedrock and java share the same biome generation now
and converting java code into js code won't be impossible
oh man,
bugs, issues
damn it
the dynamic property is setting for all of them at the same time
i think,
damn it...
the only way to fix that issue is by making a tag or dynamic property for each entity
right?
How are you doing this?
const dimension = ['overworld', 'nether', 'the_end'].map(dim => {
for (const entity of world.getDimension(dim).getEntities()) {
const block = entity.dimension.getBlock(entity.location);
if (entity.typeId === 'my:entity') {```
you can do entity.setDynamicProperty you know?
this will work on every entity
alr
if one of those entities have a specific item inside it, the script will work and set the same dynamic property for every same entity
uh
wait
the script works on the entity that has the item inside the slot 0
if there are 2 entities that have the same item at the same slot, the script will spawn the item to the first entity for some reason
hmmmmm
@neat hound
My bad, I don't think it gives you all the biome tags, only the main one
There is also overlap between biome borders
if the first entity has an item in the first slot, it will set a dynamic property of the block location that the entity is inside
but
the second entity will get a different dynamic property location
gosh my brain really hurts
fun fact, if all entities have the same item at the same slot, the script will remove the item from all entities without spawning any items
hmm,
entity.setDynamicProperty('loc', block.location)
const loc = entity.getDynamicProperty('loc')
how can i detect the dynamic property location?
likeif (loc === block.location) { ,,, }?
Try it
You won't know until you try it
wont work you can't compare object either compare each property or json stringify
whats your issue
^
pretty hard to fix
if theres 2 entities have the same item at the same slot, the script will work on both of them if one of those entities got energy
I do see that
yeah you gotta store the data somehow in a better way
its a marketplace addon, i cant make it unplayable on multiplayer
You're on a marketplace team?
not yet, and not even nearly
i will be one but soo later
ah so its supposed to be in marketplace
so you can't be sharing it
you will have to sign an nda sooner or later
marketplace addons can be used on realms right?
yes
if 2 players purchased the addon they can use it in the same world
only 1 needs to purchase
uh,
theres strict rules on addon stuff for market place tho
Ye, only the owner of the world needs it
the issue happens when u put multiple of the same block and putting the same item at the same slot on each block
if one block got energy, all other blocks that get energy
and all blocks will lose the item from that slot
and only one of them will actually drop only one item
hmmmmmm
if the entity got the item in that slot, it will get a tag or dynamic property, after that the script will detect if other entity have the same item at the swme slot and give it a different tag or dynamic property
damn....
damn it
I'll go sleep for now..
maybe I'll find a way tomorrow
if i did my freaking best and stay having the same issue or even more issues
I'll left it behind, and say the addon might have problems on multiplayer,
hopefully i dont have to do that
don't json stringify, mobile has a different order of properties than windows for some reason.
both should still stringify the same tho right?, but I also would never use stringify as its probably slower and just looks more unreliable
i had an issue with stringifying coordinates, where my script works fine on a computer but breaks if run on a mobile, and reason for that was JSON.stringfy returned {z, y, x} instead of {x, y, z}
I FOUND IT
the handcrank system is sending energy to every single entity
thats why that bug happening
the handcrank isn't giving the block underneath energy, it's giving energy for all entities
i just have to make a system for the handcrank and make it give energy for the block underneath it only
that will fix the issue
itemStack.amount - 1 isn't working even if there are more than 1 items there
itemStack.amount = itemStack.amount - 1 has a log
itemStack.amount-- has a log
What else should i use?
Is JavaScript decorator supported now?
hmm,
itemStack.maxAmount = itemStack.amount - 1;
??
I wasn't wrong, I told you that system.run delays it until the next tick (I didnt say it delayed by 1 tick), because all beforeEvents are handled before game tick
ye
s
why are my actionformdatas acting weird?
whenever i click a button in the actionformdata it doesnt close the form and makes me spam until it finally closes
I have to press one of the buttons 8-10 times before the form finally closes. I created a fresh pack with nothing but the most basic form and it still does this
Make sure to share your forms in a new Post!
And what version of the @minecraft/server-ui are you using?
If beta than issues are common
that's not a version issue, that's just some incorrect code
the form works when i use any other afterevent besides playerinteractwithblock
player interact with block fires multiple times, so I assume it's firing while your form is opening, so like 8 forms open instead of one
yep
i didnt know it fired multiple times
what would be the best way to deal with that? is it possible to have it only fire once?
can you try moving your form variable outside of showForm?
so that it's only the form.show().then part inside of the function
Just set a cooldown before showing the form
If the player is still in cooldown then return
I think 5 ticks is enough
Is it possible to read wearable armor protection value through script?
There doesn't seem to be an item component type for in in the API
Is their a way to access the skin of your player through scripting cause I wanted to make a realistic death addon where you die and spawn another entity which takes your skin
I love ffmpeg
One message removed from a suspended account.
The run_command part should be changed to que_command because they depracted it after the update
queue_command
let items = [];
if (this.#getDataType(key)) {
for (let i = 0; i < 256; i++) items.push(inv.getItem(i));
for (let i = 255; i >= 0; i--) if (!items[i]) items.pop(); else break;
} else items = inv.getItem(0);
is there a better way to do this?
i wanted to delete all undefined from right till it gets an item
like if the array is
[ item | undefined | item | undefined | undefined ]
it needs to convert it to this:
[ item | undefined | item ]
I would do it the opposite, go from the end to the start
And start adding elements to the array once you find one item
At the end you can do .reverse() to the array
let u = 0;
for (let i = 0; i < 256; i++) {
const s = inv.getItem(i)
if (s) u = i + 1;
items.push(s)
};
let f = items.splice(u)
thanks
hi there, the block component onPlayerInteract only works if you have no item on hands? it doesnt trigger if you are holding any item?
It triggers with items as well
sure? because mine only triggers with empty hands, look it is very simple: ```javascript
world.beforeEvents.worldInitialize.subscribe(eventData => {
// On Interact
eventData.blockComponentRegistry.registerCustomComponent('awp:on_interact', {
onPlayerInteract: (event) => { onBlockInteract(event.player, event.block, event.dimension, event.face, event.faceLocation) }
});
})
export function onBlockInteract(player, block, dimension, face, faceLocation) {
console.log(JSON.stringify(on block interact))
}```
What items are you using?
anything, like weapons, iron ingot, blocks, bone
One message removed from a suspended account.
Its talking about the errors not the script
First screenshot
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Are there any possible ways of powering a redstone lamp, piston, etc without having redstone beside them? I'm basically trying to make a redstone lamp become powered through scripting without needing to actually put a power source beside it
@distant tulip
can you check your dms ??
i wanna know what modules i need to import for the script
because the ones i added
dont work for sm reason idk why :(
When you ask a question via DM, you are restricting the total number of people who can help you from all potential server members to just one. Asking in the public channels is the best way to get a good, community-sourced answer to your question, allowing other observers to give their input.
While you are certainly welcome to DM with each other, please be aware it is against our rules to send unsolicited DMs requesting help.
I'm not sure where to look or ask this question so asking here to find out what I need to be searching for.
I would like to create a setup script that will help me prepare a new world for classroom use. There are several steps I currently have to go through in the process. Most of it is /function commands but I generally need to make sure I do them in the right order, make sure each step complete before moving on as some steps include entity behavior pack animations, and I have to make sure that I'm in the right place before I do each step.
Can't script api help me with any of this? Or must I keep using a checklist?
what does this error mean?
not sure but reloading world should help
Would anyone be able to explain to me how you can make loot spawn at the entity rather than 0 0 0 in a command in scripting.
For reference, my current command setup is source.dimension.runCommandAsync(‘loot spawn ~~~ loot my_loot_stuff’);
keep using command bc there are no APIs for loots
Entity's can run command as well. No need to run from dimension
world.structureManager.place("start:1", player.dimension, { ...player.location, y: player.location.y + 2})
why do i get this error?
make sure you re not using a before events
if you re using before events then wrap it in a system.run(()=>{})
are there any addons for vs code ide,
Yes, they all them extensions
how can I make some one fly when I teleport them. As in I want to teleport them up in the sky and I want them to stay there and not fall down. They will be in creative mode but how to I make it so they are already flying?
If an item has the component to not break blocks while in creative is there a way to reference the block that is hit without it being destroyed?
how do i detect whether a location/chunk is loaded?
is it possible to enchant something like a arrow with enchantments ??
like enchant an arrow with sharpness ??
No
oki
oh ok 🫡
how do I detect potion thrown with js? or on_hit of some sort
I want to make all of my throwable potion script-based but I don't know how to trigger it from the item.js
iirc there are afterEvents projectileHitBlock and projectileHitEntity
You can use them
I'm on phone rn so can't help much
And for potion thrown you sbould listen to entitySpawn event
oh lol I forgot about those
THanks a lot
I forgot afterEvents exists
np 🙂
how do i detect a specific level of fortune?
any way to apply sharpness on a pickaxe using scripts ??
i tried using inventory editors and nbt and it works
so i thought there is a way of doing it using scripts ?
i mean you can do it with a loot table lmao i just figured that out oddly enough
is getEquipment still usable? or hsould I use getEquipmentSlot instead?
getComponent('equippable')?.getEquipment('Mainhand');
Use getComponent(“inventory”).container.getItem(player.selectedSlotIndex)
Pretty sure that’s how it goes but I could be wrong
is there like a create-script CLI or something
yeah i use that
which one?
One message removed from a suspended account.
import EquipmentSlot
They are both useable btw
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
that should fix the log error yea
One message removed from a suspended account.
One message removed from a suspended account.
what's wrong with this code```js
world.afterEvents.playerInteractWithBlock.subscribe(data => {
const block = data.block;
const player = data.player;
const itemChest = block.getComponent("inventory");
for (let i = 9; i < 18; i++) {
const item = itemChest.container.getSlot(i);
const enchantable = item?.getComponent('enchantable');
let enchantmentMessage = `${item.typeId}: `;
if (enchantable) {
const enchantments = enchantable.getEnchantments();
if (enchantments.length > 0) {
enchantments.forEach((enchant, index) => {
enchantmentMessage += `id:${enchant.type.id}, lvl:${enchant.level}`;
if (index < enchantments.length - 1) {
enchantmentMessage += '.';
}
});
console.error(enchantmentMessage);
}
}
const itemLore = item.getLore();
const itemName = item.name;
const itemAmount = item.amount
const dataMessage = `[\nid|${item.typeId}\nAmount|${itemAmount}\nname|${itemName}\nlore|${itemLore}\nenchantment|${enchantmentMessage}\n]`;
player.sendMessage(dataMessage)
player.playSound('random.orb');
}
});
you need to be more specific
- it is throwing this error
- it should do this but it is doing that
- ...
lot of scenarios
in the line let enchantmentMessage = `${item.typeId}: `; it always says type not a function
show full error
[Scripting][error]-TypeError: not a function at <anonymous> (Crate.js:724)
try use getItem not getSlot?
also 724 is not the typeId one
also add a check if there is item or not
hello boys and girls
Yo! long time no see
yes... amost 5 months? man
im rusty asf :(
i got pretty small problem
you will get back quick
didn't take you much to learn in the first place lol
i hope it is solved soon
actually i started boring project
about?
i don't know how to solve it and i remeber i have joibed this server
this one dude, I can't seem find a way how to put a comma on the numbers
eww opera
i hope so... been awhile since i touched mc cause college sucks
the buttons one or the body
that's not the problem dude hahaha
you have no idea
lot of cool stuff
hmm?
you see the = 8991?
you mean 8,991
i want it to be = 8,991
yes idk how
function evaluateExpression(expression) {
expression = expression.replace(/(^|[\s+*/()-])0+(?=\d)/g, '$1');
try {
let result = eval(expression.replace(/x/g, '*'));
if (result !== undefined) {
let formattedResult = result.toLocaleString();
return Number.isInteger(result) ? formattedResult + '.' : formattedResult;
} else {
return 'Syntax ERROR';
}
} catch {
return 'Syntax ERROR';
}
}```
bruh
just stringify the number and slice it and insert the coma
ohhh YEAHHH
i frgot how to stringify now
wait lemme check my memory boop
dose q js have toLocaleString
whuh?
nice
try number.toLocaleString()
you rarely talk here
hi? you new here or something... ( i missed alot of people here )
a friend lol
👀
that's my first idea but im confused cause sometimes it works someitmes it doesn't
like WTH
no
i joined 1 year ago
really? wow how long i never touch discord lol
You will use json ui. right ?
lol
probably but idk im more focused on system than style first
first time seeing it tbh
maybe try toLocaleString('en-US') to make it consistent
function evaluateExpression(expression) {
expression = expression.replace(/(^|[\s+*/()-])0+(?=\d)/g, '$1');
try {
let result = eval(expression.replace(/x/g, '*'));
if (result !== undefined) {
let formattedResult = result.toLocaleString();
return Number.isInteger(result) ? formattedResult + '.' : formattedResult;
} else {
return 'Syntax ERROR';
}
} catch {
return 'Syntax ERROR';
}
}
here's what i did but bruh
don't use eval 
In this case, the style is also important.
oh thats' the reason it doesn't work?
look at me mr i did json ui and now i recommend it
no
eval is bad
here's what I did to make to make it work lmfao... a lot of shenanigans and shits
function evaluateExpression(expression) {
expression = expression.replace(/(^|[\s+*/()-])0+(?=\d)/g, '$1');
try {
let result = eval(expression.replace(/x/g, '*'));
if (result !== undefined) {
let resultStr = result.toString();
let parts = resultStr.split('.');
let integerPart = parts[0];
let withCommas = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
let formattedResult = withCommas + (parts[1] ? '.' + parts[1] : '');
return Number.isInteger(result) ? formattedResult + '.' : formattedResult;
} else {
return 'Syntax ERROR';
}
} catch {
return 'Syntax ERROR';
}
}```
loooooooooooooooooooooooooooool
idk first time using eval cause i saw it on jayly's website
if anyone can input stuff to it, it can go badly if not handled
i don't like it cause i suck there but json ui is pretty powerfull i just suck at learning and understanding that topic oof.
ik
you messed this lol
https://discord.com/channels/523663022053392405/1280301965271896124
this is messy cause i'm lazy to format it yet but as long as it work then we got no problem there buddy
bruh.js
huh? wdym i messed this? btw what you did was pretty similar what i saw in jayly's github page lmfao
but yors was more organized i guess? i forgot
hmm? i meant i played around with json ui
not related
btw i spent only 10-15 mins making this... i was just warming up my scripting skills
i miss a lot of people here, especially herobrine, ash, smokey, you and other people i frgot the names cause i am dyslexic have short term memory
what if input
world.getPlayer({name:"Minatocraft1"})[0].runCommand('give @s command_block')
why? i get what does it do but just why?
i can do it if i wanted too.
man i also miss cyberaxe
is he still live sometimes?
if you are using eval
don't
who is that 😅
nvm lol

he changed his pfp
good luck
minato sorry for ping but do you know the hole filler mod in mc java?
yeah?
custom entities have EntityEquippableComponent ?
they do but don't work
is there a solution for this component works ?
what are you trying to do
set and get the item holding by my custom entity in his mainhand
you can set the item with commands
Hey guys
Why do onPlayerInteract work when I place a block?
I mean i want to place the block without it running the interacting function
world.beforeEvents.chatSend.subscribe(e => {
function run(any, e) {
system.run(() => any(e))
e.cancel = true
}
const { sender: plr, message: msg } = e
if (canSendSave.get(plr) && msg != ".cancel") run(saveInv, e);
if (canSendLoad.get(plr) && msg != ".cancel") run(loadInv, e);
if (msg == ".save") run(initSave, e);
if (msg == ".load") run(initLoad, e);
if (msg == ".cancel") run(cancel, e);
})
will this cancel the message only when its used to save the inv??
const block = data.block
if(block.typeId == "minecraft:red_concrete")
console.warn("test")
}) ```
why does this basic code bug out when i use 1.15.0-beta?
it only runs the console.warn if i place another block on the block im trying to interact with
a normal interaction does nothing, but it does run if i stand farther away and interact while simultaneously placing a block down in front of me if that makes sense
playerplaceblock fires before playerinteractwithblock, you can use those to cancel playerinteractwithblock
How do I cancel it?
for me, i do this
world.afterEvents.playerPlaceBlock.subscribe(({player}) => {
player.__cancel = true;
});
world.afterEvents.playerInteractWithBlock.subscribe(({player}) => {
if (player.__cancel == true) {
player.__cancel = false
return;
}
});```
Damn, that’s actually genius
I am pretty dumb ngl
Thanks!!
what the
similar to the opposite of the problem im having
I want to place a block of wool when a chunk loads but only when a player loading that chunk has the tag "wooly_curse". Is it possible? I'm making a strange add-on with sheep-evokers
why does this interact event only run if a block is placed at the same time as me interacting?
is it just me or is WorldInitializeBeforeEvent not working when i either use ESNext or put the await keyword in the top-level
addendum: it was the latter
how do i make a class that like handler, has .open(player, callback) that when called it will show form with buttons that has customized text like literal template, i have one but it doesn't work
selectPlayerHandler.js
import { world } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"
class SelectPlayer {
constructor() {
this.title = "Select Player"
this.body = ""
this.buttonText = ""
}
body(text) {
this.body = text
}
buttonText(text) {
this.buttonText = text
}
open(player, callback) {
const players = world.getPlayers
const form = new ActionFormData()
.title(this.title)
.body(this.body)
players.forEach(f => form.button(this.buttonText.replace(/\{([^{}]+)\}/g, (match, key) => player[key] || '')))
form.show(player).then(res => {
if (res.canceled) return
const target = players[res.selection]
callback(player, target)
})
}
}
// uses
/**
const form = new SelectPlayer()
.buttonText("{name}\n{getTags().find(f => f.startsWith('tes'))}")
.open(player, (player, target) => {
new ModalFormData()
.title("SetPerm")
.textField("permission", "tes")
.show(player).then(res => {
if (res.canceled) return
target.sendMessage("added permission")
})
})
*/
so ive been lookng at geyser's source code to see how they deal with air swing for bedrock
and
they used sound event oml
why mojang
why cant you just allow us to swing air???
Brilliant
/**
* @param {ItemStack}
*/
world.afterEvents.entitySpawn.subscribe((e) =>{
if(e.entity.nameTag == "§d§lStarter" && e.entity.typeId == "minecraft:item") return e.entity.kill()
if(e.entity.nameTag == "§d§lStarter") e.entity.kill()
})
What did i do wrong?
The item entity nameTag is not the actual item identifier
You have to get the EntityItemComponent
Hey where/when was the change log for 1.14-beta -> 1.15-beta?
use https://stirante.com/script/diff.html to compare
Thxs
It was just my shitty ass code lol
am i r3tarded, is bds broken or is the api broken?
it says that damageSource is undefined
How do I detect a specific level enchant?
||1.14.0-beta||
new ItemStack("minecraft:dirt").getComponent("enchantable").getEnchantment("protection").level
This event fires whenever entity was hurt, they're hurt in ways without someone hurt them (e.g. fall damage)
but damageSource cannot be undefined
entityHitEntity not hurt
entityHurt
i prefer entityHurt over entityHitEntity
how do you define damaging entity in entityHurt event? Use entityHitEntity so it will work
i define using damageSource.damagingEntity
but damageSource is undefined for some reason, even tho it needs to be defined
cuz hustEntity gets hurt somehow
I did that but idk where to put the level for it I'm dumb lmao
Well you are trying to get damagingEntity so if it's undefined then no one hurt the player
i am saying that damageSource is undefined
damageSource needs to be defined
always
i cannot get damagingEntity because damageSource is undefined
It is always defined, it's not broken
If it's not damagingEntity then it's damageSource.cause
but it isnt
it says damagingEntity cannot be read of undefined
TypeError: cannot read property 'damagingEntity' of undefined
It's the api I get the error for get component (equippable) constantly and it works fine
i dont get it, could you elaborate?
Send the snippet
I'm trying to detect separate levels of the enchant like fortune 1 fortune 2 and fortune 3 for 3 separate loot tables for ores
world.afterEvents.entityHurt.subscribe(({ damageSource, hurtEntity: entity }) => {
const { x, z } = damageSource.damagingEntity.getHeadLocation();
entity.applyKnockback(x, z, 0, 0.356);
});```
Works fine 🙂
I'm an idiot and don't know where to put the level of the enchant I'm trying to get only how to get the enchant itself
Bds?
i meant @lone thistle
it is a server made by mojang
BedrockDedicatedServer
could you open a post
Ah
Yeah, I'm on 1.21.30
That should still work
It could be other things, like the scripts are not reloaded
Done
once i clear my issue i will try clearing yours
lemme try console logging it in main
I appreciate the help ::)
well, it works correctly with
world.afterEvents.entityHurt.subscribe(({ damageSource }) => {
console.warn(damageSource);
});```
in `Main.ts`
It's supposed to function like this, right?
yup, pretty much like this
are you using the same code that i sent?
I am
Your code is fine
Most likely other things
BRO WHAT
i just commented it, saved it, reloaded bds, then uncommented my snippet, saved, reloaded bds
and it works now
i dont get why
but it works now
(i change nothing in my snippet)
thanks for the help tho
Any ideas about how to locate an Island as in the most time efficient way? Would I be able to use script to locate an ocean biome and teleport me there and then run some other script to search for an Island?
is there a event which is triggered whenever the world loads?
worldInitialize triggers when it reloads
but i want it to trigger whever world loads for the first time
You can store a variable hasLoaded to ch3ck if its the first time load
but how do i know if the initialization isnt done by reloading if i dont have a "worldShutdown" event
unless im dumb
On initialize -> if world doesnt have dynamic property called hasLoaded, then initialize dynamic property and do what you want. If dynamic property exists, dont do anything
okay, after the dp (dynamicproperty) is undefined and set to true how do i set it to false before shuting down the world
You can check for playerLeave before event
but if noone is online doesnt mean the server is down
what's your use case?
i want to send a webhook, which states that the server is down/up
Oh, cant you just use world before initaliziation and check if there are players? If so then it means it was using reload?
well, that is a idea
so the "worldLoad" event is possible, what about "worldshutdown" event
There isn't one
by "worldshutdown" i meant doing a custom one
for myself
i will try figuring it out on my own
i found a issue;
if you reload using /reload and no player is online the "event" triggers
Yes...hence why I said, check if there are players online, if there is, dont do your function
but i want only to know when the server is loaded
Im kind of confused
Wont the server only be online if there are players? If not this seems lile something scriptapi cant do
hey smokey, can u show me the marketplace allowed and denied list? like what things that aren't allowed to be inside the marketplace addons.
sorry for pinging/replaying u
Not allowed
- Anything beta
- Anything experimental
- Shaders
- Guns, drugs, violence, religion etc.
Allowed
Everything that isn't shown above. Custom items for example are allowed, as long as you don't use the new experimental components.
Pretty much, if it works in a non-beta and non-experimental world it's good to be on the marketplace.
Why did I see a map using experimental features?
Some maps get special permission from Microsoft to use experimental features. These are usually free, or intended specifically to show-off the new creator-features. You are unlikely to get the same permission.
This is the only publicly available list because the full list is under nda. Sorry
someone kept telling me that custom UI isn't allowed, really?
🤷
he said vanilla UI like chest_ui or horse_ui aren't allowed on addons,
for an example, this isn't allowed on the marketplace addons,
it's allowed only on maps
i just wanted to make sure it's allowed or not
wait, guns aren't allowed?
does it include nuclear weapons too?
Is there a way to detect if the player is near certain coordinates?
like detecting if the player is near 0, 0, 0
System.runInterval -> grab all entities near coordinates
Could you give an example?
What does ItemStack.prototype do?
Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2) + Math.pow(z2 - z1, 2))
this will return the distance
is there a limitation of dynamic properties for the single entity?
it only takes string, number, boolean, and vector3
well thats more of a limitation of dynamic property in general
i'm not expert with js/ts, but from my perspective, it adds methods and properties to an existing class, like for example (This is probably not the best example), i want to create a new method for itemStack that checks if the current owner is not the original owner:
ItemStack.prototype.isCurrentOwnerAThief = function(){
// Your code
// Let's say parentSource property is existing (player who first owns this item), and currentSource property is existing.
return this.parentSource.id !== this.currentSource.id;
}
Mostlikely, prototypes are used to make it readable as well as make data communication be easily accessible.
I mean you can just use functions for this, but creating new methods or properties to something that makes sense is more readable imo, like for example:
player.inventory.giveItem(new ItemStack(...)) instead of giveItem(player, item). It's just personal preference to the developer on how they want to maintain their codebase, if they like suffering with OOP or just wanna do straight forward implementation with functional.
P.S. i'm no expert or whatnot 
It's where the Inherited method and property for class instances are.
It is used to add a method or property to pre-existing classes without changing the source code directly.
Type '"creative"' is not assignable to type 'GameMode'. anyone else get this error ? script works like it should even with this
which part of the code are you using it?
No. Same as any other type of dynamic properties
else (viralia_ore.includes(block.typeId) && !player.matches({ gameMode: 'creative' }))
just gets the gamemode and id of a block before its broken
the script itself works fine though
i think its better to use getGameMode()
it returns enum (or string)
also i think you kinda did an oopsie on typeId check
how so ? its part of an array
isnt it supposed to be block.typeId.includes(viralia_ore)?
I think it be best if you posted your full code in a post and the full content error
it can be done a few different ways
well i just find this more comfortable to read tbh lol
but yeah use that
player.getGameMode() === "creative"```
.includes() is a method on strings and arrays. I assume that they had it the other way becauseviralia_ore is an array
still
Hello, does anyone know how to get a player's experience points? Also, is there an event for a welcome message? (I'm new to scripting)
- https://stirante.com/script/server/1.14.0/classes/Player.html#getTotalXp
- You can use the PlayerJoin event to detect a player joining then send a message
Documentation for @minecraft/server
Thanks
my inferior javascript can’t bare witness to typescript:(
x: -592,
y: -17,
z: -1912
}
portalLocation.dimension.spawnParticle('myth:void_portal_travel_particle', portalLocation)``` anyone know why this isnt working? "cannot read property 'spawnParticle' of undefined"
entity.dimension.spawnParticle?
perhaps world.getDimension('overworld').spawnParticle
np
@distant tulip
i sent you a dm can you see it ?
great!, i will use soo many dynamic properties in my addon
hmm
const deniedEntities = [ /// ];
if (entity.typeId !== deniedEntities) { ,,, };
??
fr I forgot
const deniedEntities = []
if (!deniedEntities.includes(entity.typeId)) { };
Can a code that works for the world work when there is no one there?
ty but i already remembered it
i somehow found a log, especially at this line
if (block?.typeId !== 'my:block') { ,,, }
i think this should fix it
if (block?.typeId !== 'my;block' && entity.isValid()) { ,,, }
isnt type.id?
i think that log showed bec the entity was inside an unloaded chunk.
lemme do some tests
only when the entity is inside unloaded chunks
slap a ? inside there and youre good to go
yah fixed
i found a bug
squash it
when the block is inside unloaded chunks it will not be detected and the entity will instantly disappear
if (block?.typeId !== 'my:block' && entity.isValid()) ?
should i add block.isValid() to it?
or !block.isValid()?
idk
How are you geting the entity?
If the chunk is unloaded.. the entity is unloaded too..
since isValid requires you to get the entity, you should just do if (entity) or if (block)
isValid checks whether the target can be manipulated with scripts
combine both
so both entity and block will be detected inside the unloaded chunks
entity?.isValid()
so if (block?.typeId !== 'my:block' && entity?.isValid() && block?.isValid())
kinda busy
i will check when i have time
Okay
can you tell me how i can make a script in which if i look down and crouch, i sit down
yeah
only use if you are not sure the block or entity are loaded
doesn't make sense to use it on block/entity events
yah it fixed
you will have to make a variable and keep track of both states
once you reach a point without any change perform your task
oki
also thats a simple system, detecting if the entity is outside the specific block or not
i could use block.isAir but what will happen when u replace that block with something else? ( any other blocks except air )
testing if the entity is inside the specific block inside loaded chunks and unloaded chunks is the better way to do it
example
const sit = new WeakMap()
system.runInterval(() => {
world.getPlayers().forEach((player) => {
if(player.isSneaking && player.getRotation().y <= 88){
sit.set(player,(sit.get(player)??0)+1)
} else {
sit.set(player,0)
}
if(sit.get(player) >= 60){ //20*3 => 3 seconds
//sit animation/logic
//don't forget a way to disable it for example if(player.isJumping) sit.set(player,0)
}
})
});
WeakMaps are supported in the API now?
they weren't?
Last time I tested, no.
ive heard of Maps but WeakMaps?
used them for long time
It's like a map that has some special interactions with the garbage collector
it is useful for memory management
hmmmm
avoiding memory leaks
imma ask GPT about this cuz im interested
hmm, is this the best way to do it?
if (item2.typeId === 'minecraft:raw_copper') {
if (energy === true) {
if (copper2 === 0) entity.setDynamicProperty('copper2', 1)
if (copper2 === 1) entity.setDynamicProperty('copper2', 2)
if (copper2 === 2) entity.setDynamicProperty('copper2', 3)
if (copper2 === 3) entity.setDynamicProperty('copper2', 4)
if (copper2 === 4) entity.setDynamicProperty('copper2', 5)
if (copper2 === 5) entity.setDynamicProperty('copper2', 6)
if (copper2 === 6) {
entity.setDynamicProperty('copper2', 1)
grinder(item2, inv, 2, 'minecraft:raw_copper', block)
world.playSound('block.grindstone.use', block.center())
}
entity.setDynamicProperty('energy', false)
}
} else entity.setDynamicProperty('copper2', 0)```or u guys have a better way? grinding system ^

const sitDuration = 60;
const sitMap = new WeakMap();
system.runInterval(() => {
world.getPlayers().forEach((player) => {
if (player.isSneaking) {
sitMap.set(player, (sitMap.get(player) ?? 0) + 1);
} else {
sitMap.set(player, 0);
}
if (sitMap.get(player) >= sitDuration) {
player.runCommand('');
const jumpCheck = system.runInterval(() => {
if (player.isJumping) {
sitMap.set(player, 0);
system.clearInterval(jumpCheck);
}
}, 5);
}
});
});
@distant tulip
yes this is partly made by chatgpt
changing the dynamic property value each time the entity gets energy
would recommend against that
bro gave me a ride command 😭
no im asking gpt about javascript
not the api
first energy will change the value from 0 to 1
second one will change it from 1 to 2, ect.
if the player leave the game all weak maps that uses hem as key will clear his data
ive fed good enough info to gpt about how i style the code so its gonna be good at explaining it in my language
if the item has been changed, the value will be set back to 0
clearInterval 
oh thats definitely useful
that system works perfectly like the furnace, u know what i mean
You might want to set the property value to (copper2 % 6) + 1, although that won't be exactly the same as what your script does currently
idk man i asked chat gpt
so is the script correct ?
and whats the animation of player riding a horse called ?
clearRun
asking GPT about JavaScript: ✅
asking GPT about Minecraft API: ☠️
why did you even ask it
Did you test the script
its good at making forms tho
yeaaa
cuz youve fed infos about it
chatgpt has memory now
let me test that 
what 💀
weeks ago
how do i delete it 🙂
brb i gotta delete some stuff
so thats what garbage collecting is for
didnt understand it until now
not bad but it is a simple example
cleared it memory
using mcbe scipt api
make a form that have 3 buttons
each one send a message with it index to the player when clicked
import { world, system, Player } from "@minecraft/server";
import { ModalFormData } from "@minecraft/server-ui";
// Function to create and display a form with 3 buttons
function showButtonForm(player) {
// Create a new modal form
let form = new ModalFormData();
// Add buttons to the form
form.title("Choose a Button");
form.button("Button 1"); // index 0
form.button("Button 2"); // index 1
form.button("Button 3"); // index 2
// Show the form to the player
form.show(player).then((response) => {
// Check if form was not canceled
if (!response.canceled) {
let buttonIndex = response.selection;
player.sendMessage(`You clicked button ${buttonIndex + 1}`);
} else {
player.sendMessage("You canceled the form.");
}
});
}
// Event listener to trigger form display when a player joins the world
world.events.playerJoin.subscribe((event) => {
let player = event.player;
showButtonForm(player);
});
apart from the event
i guess it did learn enough from all the people
interesting
its like drawing AI but for code
it always get the events wrong
providing info do help
though i do think the ai couldve done js world.afterEvents.playerJoin.subscribe(({player}) => { showButtonForm(player); })
not sure what the person who made it provided to it
me neither
and that won't work btw
yeah
join ui
but iirc you can just force open ui in function if the cancelation reason was "UserBusy"
so that the player can see the ui after loading up
yep
@distant tulip
it worked
how do i position myself a bit up ?
animation
const playerStatus = new WeakMap();
function initializePlayerStatus(player) {
const status = {
sprintKnockbackHitUsed: false,
sprintKnockbackValid: false,
critSweepValid: true,
shieldValid: false,
mace: false,
attackReady: false,
lastSelectedItem: undefined,
lastSelectedSlot: undefined,
cooldown: 0,
lastAttackTime: 0,
shieldDelay: 0,
fallDistance: 0,
};
playerStatus.set(player, status);
}
export function getPlayerStatus(player) {
if (!playerStatus.has(player)) {
initializePlayerStatus(player);
}
return playerStatus.get(player);
}```
new knowledge acquired
i can say, the grinder is done for now
What's this?
something ive been using (will use) for the addon im making
Hmm
Btw ?
which one ??
in js player.runCommandAsync(`playanimation @p <animation name>`)
what do i put in <animation name> ??
@distant tulip
make your own animation
how ??
idk how to make animations
i can make models :D
animate the humanoid model from here
yes sir 🫡
geometry.humanoid.custom
is the more accurate geo
pretty sure that's the one players are based off of
this one?
better learn then
also bruh, you really used chatgpt...
thats what im doing :D
you know fillipino language ?
yea 💀
no
aw man ok np
@thorn flicker @distant tulip
now what do i do ?
like put it in a resource pack ?
"sit": "animation.gwim.sit"
i added this in player.json
at the end of the animations
This is Off topic
oh yea good point sorry :(
@distant tulip can you give me file save player ender chest inventory addon file!
huh?
you mean the ender chest inspector
Please select an option you have problem with
yes
Anyone can help of the litter code issue?
About of dynamic properties
import "./index";
import { world, Player, system } from "@minecraft/server";
world.afterEvents.entityHitEntity.subscribe((eventData) => {
if (!eventData.hitEntity.hasTag('ffa_sumo')) return;
eventData.hitEntity.setDynamicProperty(
"last_hit_by",
eventData.damagingEntity.id
);
eventData.hitEntity.setDynamicProperty(
"last_hit_by",
JSON.stringify(eventData.damagingEntity)
);
console.warn(eventData.hitEntity.getDynamicProperty("last_hit_by"));
})
world.afterEvents.entityDie.subscribe(({ deadEntity }) => {
const LastHitEntity = world.getEntity(deadEntity.getDynamicProperty('last_hit_by') ? JSON.parse (deadEntity.getDynamicProperty('last_hit_by') : null);
const die = deadEntity
die.runCommandAsync("scoreboard players add @s deaths 1");
die.removeTag('InGame');
die.runCommandAsync('clear @s');
system.runTimeout(()=>{die.runCommandAsync('replaceitem entity @s[tag=!NotPlayed] slot.hotbar 4 compass 1 0')},35);
LastHitEntity.runCommandAsync("scoreboard players add @s kills 1");
LastHitEntity.runCommandAsync("playsound random.explode @s");
LastHitEntity.dimension.spawnParticle("minecraft:huge_explosion_emitter",LastHitEntity.location)
world.sendMessage({
rawtext: [
{ text: `§l§7${LastHitEntity.name}§c擊殺了` },
{ text: `§l§7${die.name}` }]});
})
Debug result for [code](#1067535608660107284 message)
Compiler found 5 errors:
[36m<REPL0>.js[0m:[33m18[0m:[33m102[0m - [31merror[0m[30m TS2345: [0mArgument of type 'string | number | boolean | Vector3' is not assignable to parameter of type 'string'.
Type 'number' is not assignable to type 'string'.
[7m18[0m const LastHitEntity = world.getEntity(deadEntity.getDynamicProperty('last_hit_by') ? JSON.parse (deadEntity.getDynamicProperty('last_hit_by') : null);
[7m [0m [31m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[0m
``````ansi
[36m<REPL0>.js[0m:[33m18[0m:[33m147[0m - [31merror[0m[30m TS1005: [0m',' expected.
[7m18[0m const LastHitEntity = world.getEntity(deadEntity.getDynamicProperty('last_hit_by') ? JSON.parse (deadEntity.getDynamicProperty('last_hit_by') : null);
[7m [0m [31m ~[0m
``````ansi
[36m<REPL0>.js[0m:[33m18[0m:[33m154[0m - [31merror[0m[30m TS1005: [0m':' expected.
[7m18[0m const LastHitEntity = world.getEntity(deadEntity.getDynamicProperty('last_hit_by') ? JSON.parse (deadEntity.getDynamicProperty('last_hit_by') : null);
[7m [0m [31m ~[0m
``````ansi
[36m<REPL0>.js[0m:[33m29[0m:[33m34[0m - [31merror[0m[30m TS2339: [0mProperty 'name' does not exist on type 'Entity'.
[7m29[0m { text: `§l§7${LastHitEntity.name}§c擊殺了` },
[7m [0m [31m ~~~~[0m
``````ansi
[36m<REPL0>.js[0m:[33m30[0m:[33m24[0m - [31merror[0m[30m TS2339: [0mProperty 'name' does not exist on type 'Entity'.
[7m30[0m { text: `§l§7${die.name}` }]});
[7m [0m [31m ~~~~[0m
ESLint results:
<REPL0>.js
18:146 error Parsing error: ',' expected
// Define the blocks that should be regenerated
const regenBlocks = [
"minecraft:dirt",
"minecraft:stone",
"minecraft:coal_ore",
// Add more block types as needed
];
// Define the regeneration delay (in seconds)
const regenDelay = 10;
// Listen for the 'BlockBreak' event
events.listen('BlockBreak', (event) => {
// Get the broken block's location and type
const blockLoc = event.block.location;
const blockType = event.block.type;
// Check if the broken block is in the regeneration list
if (regenBlocks.includes(blockType)) {
// Schedule a regeneration task for the block
setTimeout(() => {
// Get the block's current state
const currentState = world.getBlock(blockLoc);
// If the block is still air, regenerate it
if (currentState.type === "minecraft:air") {
world.setBlock(blockLoc, blockType);
}
}, regenDelay * 1000); // Convert seconds to milliseconds
}
});```
can you give me this :((
Make that lever thingy play a sound when you use it :p
no sorry
it may come out sometime in the coming days
Please select an option you have problem with
Uptime: 1 hours, 40 minutes, 16 seconds
Latency: 108 ms
import "./index";
import { world, Player, system } from "@minecraft/server";
world.afterEvents.entityHitEntity.subscribe((eventData) => {
if (!eventData.hitEntity.hasTag('ffa_sumo')) return;
eventData.hitEntity.setDynamicProperty(
"last_hit_by",
eventData.damagingEntity.id
);
eventData.hitEntity.setDynamicProperty(
"last_hit_by",
JSON.stringify(eventData.damagingEntity)
);
console.warn(eventData.hitEntity.getDynamicProperty("last_hit_by"));
})
world.afterEvents.entityDie.subscribe(({ deadEntity }) => {
const LastHitEntity = world.getEntity(JSON.parse (deadEntity.getDynamicProperty('last_hit_by') ?? "{}"));
const die = deadEntity
die.runCommandAsync("scoreboard players add @s deaths 1");
die.removeTag('InGame');
die.runCommandAsync('clear @s');
system.runTimeout(()=>{die.runCommandAsync('replaceitem entity @s[tag=!NotPlayed] slot.hotbar 4 compass 1 0')},35);
LastHitEntity.runCommandAsync("scoreboard players add @s kills 1");
LastHitEntity.runCommandAsync("playsound random.explode @s");
LastHitEntity.dimension.spawnParticle("minecraft:huge_explosion_emitter",LastHitEntity.location)
world.sendMessage({
rawtext: [
{ text: `§l§7${LastHitEntity.name}§c擊殺了` },
{ text: `§l§7${die.name}` }]});
})
Anyone pls help me fix the bug
Debug result for [code](#1067535608660107284 message)
Compiler found 3 errors:
[36m<REPL0>.js[0m:[33m18[0m:[33m55[0m - [31merror[0m[30m TS2345: [0mArgument of type 'string | number | boolean | Vector3' is not assignable to parameter of type 'string'.
Type 'number' is not assignable to type 'string'.
[7m18[0m const LastHitEntity = world.getEntity(JSON.parse (deadEntity.getDynamicProperty('last_hit_by') ?? "{}"));
[7m [0m [31m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[0m
``````ansi
[36m<REPL0>.js[0m:[33m29[0m:[33m34[0m - [31merror[0m[30m TS2339: [0mProperty 'name' does not exist on type 'Entity'.
[7m29[0m { text: `§l§7${LastHitEntity.name}§c擊殺了` },
[7m [0m [31m ~~~~[0m
``````ansi
[36m<REPL0>.js[0m:[33m30[0m:[33m24[0m - [31merror[0m[30m TS2339: [0mProperty 'name' does not exist on type 'Entity'.
[7m30[0m { text: `§l§7${die.name}` }]});
[7m [0m [31m ~~~~[0m
ESLint results:
<REPL0>.js
2:17 error 'Player' is defined but never used @typescript-eslint/no-unused-vars
20:5 warning The /scoreboard command can be replaced by the functionality in Scoreboard/ScoreboardObjective in the @minecraft/server. See https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/scoreboard for more information. minecraft-linting/avoid-unnecessary-command
22:5 warning The /clear command can be fully replaced with the Container.clearAll api in the @minecraft/server module. See https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/container#clearall for more information. minecraft-linting/avoid-unnecessary-command
23:28 warning The /replaceitem command can be replaced by the functionality in Container/ContainerSlot in the @minecraft/server. See https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/container for more information. minecraft-linting/avoid-unnecessary-command
24:5 warning The /scoreboard command can be replaced by the functionality in Scoreboard/ScoreboardObjective in the @minecraft/server. See https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/scoreboard for more information. minecraft-linting/avoid-unnecessary-command
use #debug-playground
No I just ask for help
Can u help me just fix the first error?
I'm anxious with it
nope, bds will be up 24/7 (may crash so i want it to ping administration)
i can detect when the server is going to start (using date and the last tick, but i cant check whenever the server shuts down, maybe with net module)
thanks for the help tho
There's no distinction between running /reload and performing the initial startup from the script API's point of view.
If you're running it yourself you could build a wrapper for BDS that could report the uptime and query that with an HTTP request.
Or you could save the current time in a dynamic property every few seconds, then when the worldInitializeAfterEvent is called check that last time and try to determine based on that if it was a reload or not
isn't there a way too just ping the server and see?
there is also a way; use a modloader and implement webhooks directly in the api :yay:
@distant tulip
i need your help
can you hop on Minecraft ??
sure
@runic crypt
wait 2 min imma be on
Minatocraft1
the joining is taking so long
wdym ?
More natural than a degree, less arbitrary
try now ?
wdym by natural?
give it a minute or so
try tan(pi/2)
@distant tulip ill make new world
Ah, it's self choice, I'm more familiar with the degrees.
oh no
also, Math.sin, Math.cos etc in js params use radians btw
Well that’s just an asymptote mate
@distant tulip
join now
I know but if I am more familiar with the degrees, it is easier to do the calculations for me
@distant tulip
nvr mind imma go sleep, will try tomorrow ok ?
also pls see your dms
nah, same shit, It's like comparing temperature units
Don’t even get me started 😛
world.beforeEvents.chatSend.subscribe(data => {``` in version 1.21.20 what is it
the same
nah, I give you a reason, the length of the radian is related to the radius of the circle, for physical calculations they are better than degrees.
xD
world.beforeEvents.chatSend.subscribe(data => {``` in version 1.21.30 what is it
the same
1.21.30
still.. the same, change ur api version to 1.15.0-beta tho
Does had a way to test when the player is using a specified item in his hand open a ui?
and js getComponent("minecraft:inventory").container.getItem(13)
const players = world.getAllPlayers();
players.forEach(player => {
const item = player.getComponent("equippable").getEquipmentSlot("mainHand").getItem();
if (player.isSneaking && item && item.typeId === "namespace:ITEM") {
//code
}
})```
yea that too remains the same
TY
can i ask a question here?, about scripts
obviously
np
I did this but it failed
i have this:
.getComponent(EntityComponentTypes.Health).currentValue;
Is there a way that instead of being the current life, it is the maximum life?
Sorry ping but did u know how to lock a item in hotbar with script?
which part?
[Scripting][error]-TypeError: cannot read property 'container' of undefined at <anonymous>
const itemStack = block.getComponent("minecraft:inventory").container.getItem(13);
[Scripting][error]-TypeError: cannot read property 'container' of undefined at <anonymous>
you can do it with /give command
ur code is correct, just make sure that block actually exists and is a container
thanks i fixed it
So didn't have a script way?
Documentation for @minecraft/server
health.setCurrentValue is to increase the player life?
to set the current health (not to set the maximum higher or lower)
Ok ty
how i can make when a have a specific tag, when a click a block this turns into another block
Hi
Anyone
Does anyone know how to detect an interaction on a block with an empty hand?
is "isOnGround" broken?
world.beforeEvents.playerInteractWithBlock.subscribe(event => {
let player = event.player;
let block = event.block;
let itemInHand = event.itemStack;
if (!itemInHand) {
player.sendMessage("empty hand");
if (block.typeId === "minecraft:stone") {
player.sendMessage("empty hand");
}
} else {
player.sendMessage(`You are holding: ${itemInHand.typeId}`);
}
});
no
Has anyone attempted to do structure generation with scripts?
Thanks
Yes, SmokeyStack has, I believe
And a few others I can't remember the names of
ConMaster made his own world generation with scripts lol
Is there a way to damage a Item without playing the "item change" animation?
I miss this project so much, i miss these times 😅
import { world } from '@minecraft/server'
world.afterEvents.playerBreakBlock.subscribe((data) => {
const { player, itemStackAfterBreak: item } = data
const inv = player.getComponent('inventory').container
const durability = item.getComponent('durability')
if (item && durability) {
if (durability.maxDurability < durability.damage) {
durability.damage = 1;
inv.setItem(player.selectedSlot, item);
}
else if ((durability.maxDurability - durability.damage) == 0) {
inv.setItem(player.selectedSlot);
}
else {
durability.damage += 1;
inv.setItem(player.selectedSlot, item);
}
}
})```
i think that doesn't do the animation. Haven't used it in a while, so not entirely sure xD
I mean when I use the Item
I tested it and it still works with items in hand
werent these times like a month ago?
Ye it wasnt that long ago
I made mine like a year ago, but it was worse
It was just basic genereation
I have a newer on, but the issue is that the blending between biomes is horrible
Do you have any projects in progress right now?
wtf thats so sick!!
Yes but not related to Script api
It feels like 6 months lmao
last push was 5 months tho
time flies
yes
Thank you 🙂
Is it possible to spawn a particle then rotate it dynamically with scripting?
You can't modify perticle behavior after it spawns
Or maybe spawn a particle everytime I need to change teh rotation?
you can only set initial molang variables
oohh, unfortunate
well you still can do a lot of things via Molang Variable Maps
Will read abt that. I'm so noob at particles. Thanks!
Well if you tell me more about your case i could say if thats possible or not
It's like a straight line particle that connects 2 locations. Kinda like how the ender dragon heals. I'm still starting to read more about particles so I'm not even sure if I'm in the right track
Well you can create particle line with custom length and direction with molang but as far as i know it would be really hard to make it move
Check #add-ons and ask there about particles
Can spawned particles change direction mid-animation?
Well you can set some kind of velocity but once is particle spawned there is no way to change its behavior
I think with some kind of randomess its possible but not sure
Yeah, this is my progress so far
hi there, what is the difference between world.afterEvents.itemReleaseUse and world.afterEvents.itemStopUse?
release is only for items like bow cross biw and others
but on the descript both look like doing exactly same thing, no? I mean... even the properties of it are identical
yeah but not dynamically
¯_(ツ)_/¯
🙂
just wondering which one would be better to use, dunno if there is any advantage over other
even if it is from an animation?
let say we passed a molang var to it
will it keep it value or update it?
like i send releaseItem doesn't fire for all items
charge a trident,
throw - release & stopUse
change itemslot - stopUse
there is no way to control particle after its spawn from server side
afaik
yeah i know that much
animations are client side
maybe that can
or local rotation and controlling the anchor
¯_(ツ)_/¯
🤷♂️
Yeah I mean I just expected when someone says these times its been a year or more xd
But time really did fly
well my life completely changed woth in these 5 months
😅
using deprecated features feels so wrong lol
yet so good
it makes me so uncomfortable lol
the autocomplete and the linter is screaming at me to not use it.
how do i get the lore of a dropped item?
entity.getComponent("item").itemStack.getLore()
First one
is that the picture for that first formula I sent
Is there a way to get when a projectile hits an entity if the projectile does no dmg?
entity hit entity event and check the damage value
How do i get the typeId of an item when its dropped?
becouse entity.typeid returns minecraft:item
@wheat condor
thanks 👍
If you do mean the entityHitEntity event, you can only get the damagingEntity and the hitEntity
hmm
did you try EntityHurt
how can i use "can_be_siphoned_from" and make it take items from one slot only?
maybe i dont have to use that
Ok, technically entityHurt works, but it won't work if I do 0 dmg so I guess I just need to set it to a small number
i mean using a script that will take the item from that specific slot and send it to the hopper under the block
youu can combine both EntityHurt and entityHitEntity
you can't do that + off-topic
ask in the behavior channel
i think its possible using scripts
by making a system that will detect items from that specific slot and drop them at the block center only if there's a hopper under it
ok?
but don't use can_be_siphoned_from with that
yah i will not use it
Create custom gameplay styles in Minecraft with TypeScript! This YouTube walkthrough will show you how, on our new channel for Minecraft Creator Tutorials - the Minecraft Creator Channel!
📽️: Build gameplay with TypeScript (https://t.co/gsGXCIQWVc)
I see they are advertising script api now, but ngl typescript still has some issues with the the types definitions. It be complaining that something could be undefined even tho I know that it will never be, but thats how it be like. Atleast thats how it was the last time I used it
Will it be possible to store objects and arrays in dynamic properties?


