#Script API General
1 messages · Page 69 of 1
There is seve the function of the set home
or
function homesystem (){}
export {homesystem}
main.js: import "homesystem"
Guys, how do I use the scoreboard class or anything else that uses the world
oops.
If it says it has no permissions, surround needed code with system.run()
It doesn't work like that anymore
is my using script v2
I could have enabled you to the priv
he should use const anyway
Then I am not sure what exactly you need or have an issue with.
[Scripting][error]-ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (modulo/all_class/database/ScoreboardAapi.js:2)
[Scripting][error]-Plugin [script expansion - 1.0.0] - [main.js] ran with error: [ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (modulo/all_class/database/ScoreboardAapi.js:2
I can talk to you about the DM
.
you can import all of your scripts in world.afterEvents.worldLoad
As I said, you can do system.run(()=>{world.scoreboard.otherstuff} for simply giving it permission, or use worldLoad with premade variables
How would this work? Should I call all scripts through it?
Ummm
but this code doesn't use BeforEvents for this kind of thing
You define variable names before worldLoad like let var1; let var2; then in worldLoad you give them the values they need like var1 = "test"; var2 = world.scoreboard.getScore();
humm
just set up your main.js (or whatever the entry is called), to have worldLoad.
make seperate script files for your stuff, and import them.
// entry
import { world } from '@minecraft/server';
world.afterEvents.worldLoad.subscribe(() => {
import("./scripts/example_1.js");
import("./scripts/example_2.js");
import("./scripts/example_3.js");
})
it doesn't need to use beforeEvents to use system.run().
would I have to do this for all my codes?
ahhhhhhhh
I thought I couldn't do that kind of thing
...
Could I simply call a function there? But if I want to use an event, for example ItemUse, what happens?
@thorn flicker
Random question... has anyone ever ran into lag from having too many scoreboards. I'm trying to figure out if I want to go full lore variables somehow or just keep using scoreboards.
[Scripting][error]-ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (world/modulo/all_class/database/ScoreboardAapi.js:2)
[Scripting][error]-Plugin [script expansion - 1.0.0] - [main.js] ran with error: [ReferenceError: Native property getter [World::scoreboard] does not have required privileges. at <anonymous> (world/modulo/all_class/database/ScoreboardAapi.js:2)
]
if you make 6 trillion, you will have lags using scoreboard
Well... probably, but have you actually heard anything about it? Seems like an arbitrary number to me.
From my research someone didn't notice anything at 10,000 so it should probably be ok for my purposes. But curious for future use as well.
The amount I think doesn't really matter but the items you set values on that identity can probably contribute to it.
can anyone tell me what change in the 2.0.0 beta
Makes sense, when they're active it would have a bigger load, I didn't think about that... hmm ok I'll have to just test it then.
You're the script API itself, you should've already know that.
but really
Read the changelogs.
oh right
No seriously, read the changelogs. It's a shit ton.
someone should compile a list of change
😭 That's what the changelogs are.
Literally
Or… a community hosted docs site and you can compare changes between versions
LIAR!!!
😝
Could you tell me why this is happening to me please :c?
[Scripting][warning]-Error getting dynamic property: ReferenceError: Native function [World::getDynamicProperty] does not have required privileges.
function safeGetDynamicProperty(propertyId) {
try {
return world.getDynamicProperty(propertyId);
} catch (error) {
console.warn("Error getting dynamic property:", error);
return null;
}
}
function safeSetDynamicProperty(propertyId, value) {
try {
world.setDynamicProperty(propertyId, value);
} catch (error) {
console.warn("Error setting dynamic property:", error);
}
}
export function loadConfig() {
try {
const savedConfig = safeGetDynamicProperty(CONFIG_PROPERTY);
if (!savedConfig) return;
const parsedConfig = JSON.parse(savedConfig);
if (!parsedConfig || typeof parsedConfig !== 'object') {
console.warn("La configuración guardada no es válida");
return;
}
config = {
idleTime: 300,
enableKick: true,
kickDelay: 60,
afkMessage: "§e{player} §6ahora está AFK",
notAfkMessage: "§e{player} §6ha vuelto",
warnMessage: "§cSerás expulsado en §e{kickDelay} §csegundos por inactividad",
kickReason: "Has sido expulsado por inactividad",
ignoreAdmins: true,
notifyKick: true,
notifyStatus: true,
showActionBar: true,
stillDetectionTime: 5,
activeMessage: "§a§lBien, estás Activo",
adminMessage: "§6§lEres Moderador, estate tranquilo",
actionBarUpdateThreshold: 3,
...parsedConfig
};
} catch (error) {
console.warn("Error al cargar la configuración AFK:", error);
}
}
export function saveConfig() {
try {
safeSetDynamicProperty(CONFIG_PROPERTY, JSON.stringify(config));
} catch (error) {
console.warn("Error al guardar la configuración AFK:", error);
}
}
put them in worldLoad.
Yes, I was just told that it is because of the new update.
This dog.
both
How do we do blockComponentRegistry and itemComponentRegistry now?
world.afterEvents.worldLoad ?
pain
What do u mean?
some people here didn't work for them and did work for others
knockback is also change....
applyKnockback method now takes a VectorXZ parameter for the knockback horizontal force (which includes the strength/magnitude), as well as a vertical strength parameter. To convert from V1, you should normalize your previous direction vector and multiply it by the old horizontal strength value. Vertical strength is the same as before.
This is my first time dealing with custom commands so no hate lmao
~~js system.beforeEvents.startup.subscribe(({ customCommandRegistry }) => { customCommandRegistry.registerCommand({ name: 'creator:hellocustomcommand', description: 'Celebration size', permissionLevel: 'Any', optionalParameters: [{ type: 'Integer', name: 'celebrationSize' }] }, (celebrationSize) => { world.sendMessage('Lezz go!'); }); });
I'm kinda confused about what's wrong here.~~
-# fixed it.
not a big change.
fromjs Entity.applyKnocback(x, z, 2, vertical)tojs Entity.applyKnocback({ x: x * 2, z: z * 2 }, vertical)
did they ever make equippable work for entities other than the player yet?
No.
the type should be a number or use CustomCommandParamType.Integer, you might've already fixed it to cuz of those lines
same thing for permission level
tbh this is so dumb, why couldn't it be string
Guys, how do I make a cooldown?
Yeah, it annoys me so much.
Tho i won't really complain since it's newly released lol
item cooldowns?
Yep
wait, is this script API question? or
I tried using JSON and it didn't work, so I thought maybe it's now being done through a Script
Wdym it didn't work?
I mean, Cooldown doesn't work for some reason.
AFAIK you need JSON to create cooldown category and set the max cooldown ticks
and you use script API to start cooldowns, i think?
I wanted to use a Script for this, but when you said about the JSON in which you need to make a Cooldown category, I broke down at that moment. Has this innovation been introduced long ago? I just remember that they used to do this in the item file.
actually no, i think im remembering smth wrong
this is vanilla example, ill grab some codes from addons, brb
TY
ok so yeah, you can follow the vanilla JSON
and then you start cooldown using scripts
there are various ways of starting cooldowns, ill tell you if you need
Can you tell me how to use it via Script? I'll need it for the future, in case I need it
do you know the basics of JavaScript?
Yep
so the first one is Player.startItemCooldown(), this allows you to start cooldown of specified category on player
Thank you very much
the second one is ItemStack's cooldown component's startCooldown() function
it gets the category from the ItemStack itself, so you need to specify the player only
const item = player.getComponent("equippable")?.getEquipment("Mainhand");
item?.getComponent("cooldown")?.startCooldown(player);
player.startItemCooldown(cooldownCategory, tickDuration);
the former one starts the cooldown of duration set in JSON, while the latter can be anything, even beyond the max cooldown ticks
tbh, this is what I loved
The same goes to setCurrentValue of health, tho the health icons don't increase :(
wait, it doesnt clamp?
Nope, try doing setCurrentValue(999) and do /damage @s 20 the health, you don't die.
You can try it.
what the devil
well that could be considered a problem in some cases
what if you heal with broken health
will it clamp the health back to 20?
I dunno, go test it.
bet
is there a "workaround" to make a entity Invincible, just like when a player is in creative, and you hit him, he doesnt get hit. By workaround, I meant that something like if applying 255 amplifier resistance or instant health every tick, something like that
what's the problem of using 255 resistance?
anyways, if the entity is yours, or you can edit its json, use damage sensors
the red hit overlay still appear ig? which i dont want
nope, its not custom entity
its vanilla entity, thats why
apply weakness 255 to the player when the player is looking at that entity?
bruh-
thats some real goofy workaround
yeah
nah like i heard that 255 instant health every tick does that
so i am curious to know if its real
bcoz i dont have minecraft to test
the red overlay would still appear probably
can ya test
nah i'm busy rn
👍 np
Is it possible to initialise a block in JS yet, or no?
no
it actually doesnt show damage color when instant healing heals the damage away in a tick
so yes that could work
guys, what Minecraft version is this script "1.0.0-beta.11940b24" and below.
Just curious
Never heard about it
Then the npm is funny lol
Does anyone know how to get the players current speed?
can anyone show example of
JSON.parse dynamic property and using it in json ui bindings/variables
That was what i am talking about
i heard someone do it
so was asking abt that
:whenme:
Damnit, Nitro ran out
const movementComp = player.getComponent("movement");
const speed = movementComp?.currentValue
or if youre talking about velocity,
player.getVeloicty()
Does this work with knockback?
uhhh what are you talking about
oh
no, it gets the player's movement speed
not the player's speed
So I have like a fly tag that works with appyKnockback
Alr thanks, anyway I found a way even if not really efficient
What's so hard about it?
You just grab the value of dynamic property and thats it.
Use it to somewhere else, there no special thing tho.
also, you shouldn't problem in script side... Json ui is harder
yeah I guess I am confused in bindings and stuff
let slots = JSON.parse(world.getDynamicProperty(`slots_${player.id}`) || "[]");
I have made it using sidebar so just trying to remake it with json
What json?
you mean actionbar?
Then do setActionBar()
like that but actionbar disappears

Found it!
Preview 1.19.60.22
hey, how would i make a entity follow the player?
add tame component and tame it to the player
like setting its location to player.location each tick, then doing entity.remove() other entities that is not on the player.location is very unoptimized way, what would be a easiest way to do it?
If an entity is teleported to a location where a block is present. Does the game teleport the entity above that block or in the block?
@distant tulip
yeah that is unoptimized a bit
in the block, you want it to avoid putting the entity in the block?
Yes, I'm guessing I have to detect the block first? If present, move the entity up by one block. Maybe even higher if there's a lot of blocks above it
so, no way to optimize it?
you could do that or use spreadplayers command
is it custom entity?
no
what entity
I don't believe using a command would be wise. But thank you for the insight
its light block, trying to make a simple dynamic light thingy
huh, light block is not an entity
if (Math.floor(entity.location) === Math.floor(block.location)) {
dimension.spawnEntity("minecraft:pig", { x, y + 1, z })
}```
something like this, im guessing, (that is a example)
oops, accidentaly said light block as a entity
where is my mind at lol
i know- Math.floor doesnt work there- uh
thats why its an example
that is not a fix anyway
you will have to do y++ until the entity.location is air, then spawn it, (wait.. how would you check the location before spawning.. .hmmmm)
anyways, what would be an optimized way (i accidentaly said the block as a entity ignore it)
The dimension class has a native method getTopMostBlock
ooh, i forgor, yeah you have to use it
then its all fixed, just spawn the entity there
BRUHH.
No.
i forgor getTopMostBlock existed
I mean I know, how about you?
?
You also forgot that getBlockFromRay() also exists.
i replying to thi.
I mean I know, how about you?
good
i never used that so
can you tell me some uses of getBlockFromRay()
its like getBlockFromViewDirection() right?
yeah, but accurate
since getBlockFromViewDirection() has ray limit
also can ya help me a bit in off topic
Try looking at the edge of a block it passes through it
Unlike getBlockFromRay() it doesn't.
Huh?
Why does my VSCode auto-complete this?
instead of: js import { world } from "@minecraft/server"
Why is it doing this?
Because require is like import {} from? And vscode can read it but Minecraft can't?
and what's the connect?
connect?
what's the connect of Script APi npm istalled?
what is connect?
Im not stating here btw, I'm asking.
connecting is merging things... what would you mean by "connect of script API"
you mean version?
sigh
change the "type" in your package.json to "module"
what I meant is, what's the connect of Script APi installed to it auto completing it.
still the same thing
did you do npm init?
nope
then how tf are you even using typings
any reference? i have no idea how would i do that
delete it and do npm init
the package.json
delete that file
and then in the same folder it was in, open terminal and run npm init, and then reinstall the dependency
okay..
but the typings work.
it ask for a package name
what i put
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]
@prisma shard
if you're doing the 2.0.0-beta stable, then npm i @minecraft/[email protected]
If you're doing the lastest then the top one
uh, worldInitializes stable or beta?
stable
it's stable, but it got removed in 2.0.0-beta
and been replaced with worldLoad and startup
well, is it stable on 1.17.0 or 1.18.0?
anyone know how to get the itemstack currentlyin the players offhand slot?
im trying to use getSlot() but its index based
Equippable component.
it is stable on on both
good.
Can custom command get a command executor?

After the new update worldInitialize stopped working and so my code for custom crops now is broken. What was it replaced with?
I've been using it to register a custom component
Ummm
System.beforevent.startup.
Thank you
Please open a post.
Well
Ready
Can you use script to make npc dialogues
sadly no
How big can a title form body be
how do custom components work in the new 2.0.0-beta?
Registered in startup.
it's now system.beforeEvents.startup.subscribe()
the rest should be the same
ty
Why does js world.beforeEvents.playerInteractWithBlockExecute 4 times?
use property
wym
world.beforeEvents.playerInteractWithBlock.subscribe
if ( ! e.isFirstEvent) return
ur code
})
Ty
in the sendMessage part, you should do
world.sendMessage(celebrationSize.toString() + " " + string);
Motehr ufck I'm stupid
I didn't realized I'm using sendMessage
All this time I thought I'm using console
Mbmb
pfft
lol, he got ashamed of that
me living knowing what my first message in this server is
preserved text its on wiki
or refer to LeGend's samples
Why does the Proxy native object no longer work?
uh, afaik there's a way to add emojis kind of things into the game, so try adding one somehow and apply it there.
-# idk how btw
well, try making the emoji longer
like increase the actual image size of that emoji, horizontally and diagonally and test if it works.
-# get the player input mode and detect if the humanoid-creature is pressing the sneak button or not
yep figured it out
they said nvm
ik, im just giving him the hard way to detect sneaking

what is the best way to get the player inventory when he died?
doing it at the start of the event before anything else is fired to ensure that it's gotten, easiest to do with Array.from() and setting a size component of the player's inventory size and then mapping that but also manual for looping is usable as well
You can save the players' inventories in a map that's being updated every few ticks and/or every time the inventory is updated. After the death, you can just get the inventory from the map
just use keep inv and get it on death
actually yeah this would be a better means of doing it
Is there a way to check if an item stack is a block without manually inputting every block id?
making a pickup notification thing and i need to differentiate between purely items and blocks
so i can put item. or tile.
In 2.0.0 there is a get localization key.
any ideas when that is gonna be stable?
No.

Scaling the whole glyph file makes the bounding box larger
If that's what you're talking about
Yeah just make a line on a bigger scale glyph file
hey hey, can you give me your package.json (2.0.0-beta)
how did you detect picking up items???
btw can you share your package.json? (2.0.0-beta)
the system in that video was detecting item entities but the new system i made js compares old and new inv every 1/4 of a second
ugh
ooo i see
here it is if you were curious
function updateInventory(player: Player) {
const items: {[typeId: string]: {amount: number, item: ItemStack}} = {}
function addItem(item: ItemStack) {
const key = item.nameTag ? item.nameTag : item.typeId
if (items[key]) {
items[key].amount = items[key].amount + item.amount
} else {
items[key] = {amount: item.amount, item: item}
}
}
const equippable = player.getComponent(EntityEquippableComponent.componentId) as EntityEquippableComponent | undefined
if (equippable) for (const equipSlot in EquipmentSlot) {
if (equipSlot === EquipmentSlot.Mainhand) continue
const slot = equippable.getEquipmentSlot(equipSlot as EquipmentSlot)
if (!slot) continue
const item = slot.getItem()
if (!item) continue
addItem(item)
}
const inv = (player.getComponent(EntityInventoryComponent.componentId) as EntityInventoryComponent | undefined)?.container
if (inv) {
for (let i = 0; i < inv.size; i++) {
const item = inv.getItem(i)
if (item) addItem(item)
}
}
const cursorComponent = player.getComponent(PlayerCursorInventoryComponent.componentId) as PlayerCursorInventoryComponent | undefined
if (cursorComponent && cursorComponent.item) addItem(cursorComponent.item)
inventories[player.id] = items
}
function*job(player: Player) {
if (!player || !player.isValid()) return
const lastItems = inventories[player.id]
updateInventory(player)
if (!lastItems) return
const items = inventories[player.id]
if (!items) return
for (const id in items) if (!lastItems[id] || (lastItems[id].amount < items[id].amount)) {
const item = items[id]
}
}
you can use a Record for items
Record<string, { amount: number, item: ItemStack }>
what's the difference?
wdym
You want the package version to install?
Should be @minecraft/[email protected] or smth like that
nope, like the package.json file which generates after installing the module
Entity.applyKnockback({ x: 0 * 0.3, z: 1 * 0.3 }, launchPower)
thanks!
hurtEntity.applyKnockback(view.x, view.z, power, view.y * power); will turn into?
Entity.applyKnockback( { x: view.x * power, z: view.z * power }, view.y * power );
okayy. thanks
uh
how would i set blockVolume and get it again as a global variable, to do setType() on it?
@dim tusk
import { world, system } from '@minecraft/server';
let volume;
world.afterEvents.worldLoad.subscribe(() => {
volume = new BlockVolume({ x, y, z }, { x, y, z });
});```
ujhh is there no way to get interacted block in itemUse?
i want to get the block interacted, but playerInteractWithBlock only works with interactable blocks
getBlockFromRay().
hmM ok
I'll send a snippet wait.
pretty genious workaorund lol
lemme see if i can do it before sending your snippet lol
do i have to get the first intersection using [0] in getblockfromray?
world.beforeEvents.itemUse.subscribe(({ source, itemStack }) => {
if (source.typeId !=== 'minecraft:player') return;
const head = player.getHeadLocation();
const view = player.getViewDirection();
if (itemStack.typeId === 'minecraft:stick') {
const blocks = player.dimension.getBlockFromRay({ x: head.x, y: head.y + 0.1, z: head.z }, view, { maxDistance: 10 });
if (!blocks) return;
const { block, face, faceLocation } = blocks;
console.error(block.typeId);
}
});```
this, in fact, did not work
thanks
Maybe it's fixed.
yeah
i want to set volume variable in itemUse event, and i also need to use volume variable outside
declaring it like this only works in worldLoad
Try it then.
i tried export let volume
then set it inside the event
then did console.warn(volume)
then bruh returns undefined, meaning it wasnt set
Are you entirely sure? Did you try to put values like string or numbers?
I will try it, if it works means you did something wrong.
if you want to export a variable between files and change it, try using some singleton pattern
And yes, it works in my side....
const exportingObject = {
"volume": "some value"
}
export { exportingObject }
i had to go, sorry for the late reply, and yes. I tried with string and numbers
um i think it works
it said its read-only
so i removed the export and works
how can i get the messege that has been sent?
@dim tusk
how can i get the messege that has been sent?
Wdym message that's been sent?
the mesege that has been just sent by player
chatSend...
if ( mesege === "helo")
this just check for if the messege matches
and yes it's beta, and no I don't know when it will become stable.
but i want to get the whole message as a variable,, that has been just sent
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {
if (message === 'hello') {
ev.cancel = true;
}
});```
bruh
this just check for if the messege matches
suppose player sent a text in chat, i want the whole string in the script.
Then use the whole message...
uhh, where'd common sense go? Obviously get the message properties
btw how do i setType in BlockVolume? forEach doesnt work
OH WHAT THE-
FU
fillBlocks...
damn, cant belive im THAT STUPID
BlockVolume, returns locations from point1 to point2, so it returns array of locations
messeeg just returns the string 😭 why im stupid
k
thx
for getting individual locations just do js const volume = new BlockVolume(); for (const location of volume.getBlockLocationIterator()) { Dimension.setBlockType(location, 'minecraft:tnt'); }
alr thats genius
but fillBlocks is faster
uhm uhmmmm\
@dim tusk so i just updatedd tto 2.0.0-beta today, and.. i think i just saw that system.run() works to give privilage, why is everyone doing global variablle or await null?
Not 100% reliable
why do that if you can just make that you store variable after world is loaded.
uhm
world.beforeEvents.chatSend.subscribe((ev) => {
const { message, sender: player } = ev;
if (player instanceof Player && message === `!set minecraft:stone`) {
ev.cancel = true;
player.dimension.fillBlocks(volume, "minecraft:stone")
}
})
How would i make it for every block.typeId ?
like even if i type "!set minecraft:dirt", it will fillBlock dirt..
Doing instanceof is very unnecessary
Can a zombie or mobs chat? No right?
yeah lol ik lemmme remvoe that
lmao i was thinking of it
animals cant chat 💀 ahh moment
can you know answer the question then
world.beforeEvents.chatSend.subscribe((ev, { message, sender: player } = ev) => {
if (message.startsWith('!set ')) {
ev.cancel = true;
const blockId = message.substring(5).trim();
player.dimension.fillBlocks(volume, blockId);
}
});```
As simple as that
"as simple as that". regex is not for everyone
Hmm, very obvious... You're doing a world edit.
Tf, it's not even regex
Where'd you get that?
ok lol
message.substring(5).trim()
regex? Where?
Substring get the text from 1 to what value, in this case we get 5 so it's !set including space, next is we trim(), its literally in the name.
uh- i removed the space after "!set " but it works somehow
import { world } from "@minecraft/server";
world.beforeEvents.chatSend.subscribe((eventData) => {
const { sender: player, message } = eventData
if (message === "!hello") {
// code
}
})
solved
already
Sorry I made a mistake it's index 0, not index 1
what?
let text = "Coddy";
let substring = text.substring(0, 2); // Extracts "Co"```
so, change .substring(5) to .substring(0, 2) ?
Nono, I didn't say that.
hm,mmmm. fillBlocks cannot perform single fill greater than 32768 blocks
how would i divide it so, it would perform 2 fillBlocks if it is greater than 32768 blocks?
@distant tulip
Calculate the locations of the volume.
why do you even need it
get if the blocks are more than that if yes dividie that.
is it possible to add multiple thing in one line like this?
player.addTag('max').setproperty('max', 1).getComponent('projectile')
That's not valid.
addTag().setProperty()
i know but this there a way?
You're saying setProperty() is under addTag()??
why?
i want to summon entity with setproperty and getcomponent
player.dimension.spawnEntity(projectile, direction).getComponent("projectile");
then put it like it used to do.
const entity = Dimension.spawnEntity();
const projectile = entity.getComponent('projectile');
projectile.owner = player;
entity.nameTag = 'bruh';```
wdym then
how to teleport entity like tp @s ^^^5
Guys, how can I use the beforeEvents.playerBreakBlock event to determine the color of a bed?
I'm not entirely sure but you can check if it has states that corresponds to color by doing.js world.beforeEvents.playerBreakBlock.subscribe(({ block, player }) => { if (block.typeId === 'minecraft:bed') { console.error(JSON.stringify(block.permutation.getAllStates())); } });
{"direction":2,"head_piece_bit":false,"occupied_bit":false}
There is no mention of color here.
const entity = ...; // Your entity
const distance = 5; // How far to teleport forward
const view = entity.getViewDirection();
const head = entity.getHeadLocation();
entity.teleport({
x: head.x + view.x * distance,
y: (head.y + 0.1) + view.y * distance,
z: head.z + view.z * distance
});```
Then unfortunately you can't.
0_0
omg hel naw
bro wrote a whole script for me
who told you to make a whole script
💀 .
uhm
world.beforeEvents.chatSend.subscribe((ev) => {
const { message, sender: player } = ev;
if (!message.startsWith('!set ')) return
ev.cancel = true
player.dimension.fillBlocks(volume, message.split(" ")[1])
})
would that work too?
what is the difference between yours and this?
Can I be annoying?
what
sure
whats going on
function splitIntoChunks({ from, to }) {
const max = 32768;
const [xMin, xMax] = [Math.min(from.x, to.x), Math.max(from.x, to.x)];
const [yMin, yMax] = [Math.min(from.y, to.y), Math.max(from.y, to.y)];
const [zMin, zMax] = [Math.min(from.z, to.z), Math.max(from.z, to.z)];
const totalBlocks = (xMax - xMin + 1) * (yMax - yMin + 1) * (zMax - zMin + 1);
if (totalBlocks <= max) return [{ from, to }];
const chunkSize = Math.floor(Math.cbrt(max));
const chunks = [];
for (let x = xMin; x <= xMax; x += chunkSize) for (let y = yMin; y <= yMax; y += chunkSize) for (let z = zMin; z <= zMax; z += chunkSize) {
chunks.push({
from: { x, y, z },
to: {
x: Math.min(x + chunkSize - 1, xMax),
y: Math.min(y + chunkSize - 1, yMax),
z: Math.min(z + chunkSize - 1, zMax),
}
});
}
return chunks;
}```
here.
wtf is a math.cbrt
cuberoot
oh
Hi Google
Hello, how can i help you today?
I definitely missed something from rawdogging it.
i miss the days when "several peoples are typing" in this channel
would be cool if there is a general root function that you pass it n and it uses that for
root(number, n)
-# that function is ai generated
aww man :(
lol
lol, i mean you did a great job
the problem is I didn't understand anything, I just simplified it.
Especially I love destructing so much.
i am confused if i wanna use it or not..
i dont wanna make my sscript that complicated
It's not just interactble blocks. It's just if you click the interact button on any block
it is not that complicated, the main thing is that we used cuberoot of the max blocks to get the max cube size possible (31)
the rest is just us looping using that size maxStep
uh, how am i going to decrease the itemStack amount? (const itemStack = player?.getComponent('equippable')?.getEquipment('Mainhand');)
itemStack?.amount -= 1?
I love this, did you make it?
has log
is it by getting the entity inventory or something?
yeah
Will they add anything like this for getting texture paths?
This might be better than what I did for my inventory sounds system
I’ll check when I can, replying so I remember
would be amazing if they did. But doubt it, at least for years
So like I am trying to do regions for my server and like I am storing player data in an external DB
any way to be sure that a player joining the server is the same player
I guess I can use a different server software that isn't pure bds for the routing server
pretty cool
If the server they are joining is the same then the id property from the player will suffice. Can have multiple players with the same name, each ID will be different. How you utilize that for tracking in your environment is the question.
New pfp?
Yea, some time ago. Lol.
How does the new applyKnockback work?
Before I used this to make a character fly:
const { x, y, z } = player.getViewDirection();
player.applyKnockback(x, z, 4 - Math.abs(y) + player.getDynamicProperty('acceleration'), y)
How would it work now?
I get how it works just not how to add speed to x and z
player.applyKnockback({ x: x * 4 - Math.abs(y) + player.getDynamicProperty('acceleration'), z: z * 4 - Math.abs(y) + player.getDynamicProperty('acceleration')}, y)
you multiply the x and z value by the Horizontal strength
Thank you very much
How do you make text like this btw? I don't want to look like a dumbass
Please use variable assignment for acceleration 🙁
If doing that does anything, it makes it more readable
that's how I code lol
It's interesting seeing people's approach to variables. Some people minimize their use as much as possible. Others use them quite liberally
the routing server will be the same but the region servers will be different I will probably use that
me when 500 character long lines
i use it when there is a get function or functions in general, i think most people do it this way too
What's your use case for this, curious.
prolly ui related
Applying textures to button icons
It’s generally tedious
I ended up deciding to map items in a giant file that’s exported
for custom items I just made it so that the texture matches their ID
Oh that's an excellent suggestion.
but for vanilla you kinda just need to have a big map
I havne't messed with Server-UI that much and I glanced over that you can define an icon path!
My wishlist for script api:
- a method that can get an area of blocks because getBlock() is slow
- commands without namespaces (in case of no conflict)
- ability to get player XUID
- ability to use node js workers 🗣️
- other stuff I forgot about
Isn't the first one possible with blockvolume? I thought that's what it was for.
minecraft updates is shit
no you need to iterate over all the blocks and use getBlock() (it takes forever)
what
u mean like putting icon on buttons?
Documentation for @minecraft/server-ui
you want a method to get a 3d array of blocks?
I just need blocks in a format I can store in an external DB
you don't need a 3d array if you know the size of the area
uh, why is my itemStack not decreasing?
i tried all of those:
itemStack.amount--;
itemStack.amount -= 1;
itemStack.amount = itemStack.amount - 1
and i tried having all of them inside of system.run(() => {***}) and still not working for some reason
btw const itemStack = player?.getComponent('equippable')?.getEquipment('Mainhand');
const itemStack = player?.getComponent('equippable')?.getEquipment('Mainhand');
itemStack.amount -= 1;
player?.getComponent('equippable')?.setEquipment("Mainhand", itemStack);
maybe you're not placing it back into the inventory
itemStacks are like block permutations, modifying them has no in-game impact
you need to set the player's equipment again after modifying the itemStack
more specifically, beforeEvents/block?.registerCustomComponent/onPlayerInteract({player, block}) {
its now working but its bugged with 1 item ( i know how to fix that btw )
👍
I've got something pretty cool to show in about an hour when I get back
I was going to send a video now, but I realised a texture path issue
Why does this error happen?
const ids = [
"minecraft:coal_ore": "minecraft:coal"
];
const id = ids[block.typeId]
player.dimension.spawnItem(new ItemStack(id), { x: x + 0.5, y: y + 0.5, z: z + 0.5 });```
error: ```[Scripting][error]-TypeError: Native variant type conversion failed. Function argument [0] expected type: string | ItemType at ItemStack(native)```
const ids = {
"minecraft:coal_ore": "minecraft:coal"
};
const id = ids[block.typeId]
player.dimension.spawnItem(new ItemStack(id), { x: x + 0.5, y: y + 0.5, z: z + 0.5 });
use {} instead of [] in ids
same error
make sure the item type id is correct
otherwise it won't work
ty it worked
isn't there a way to make custom slash commands without namespaces? 😭
for now, there is no way
Do you know if it will be possible in the future? Or will it stay that way?
a lot of people have been saying to get rid of the namespace but at the moment nobody really knows except for the people that work at mojang
-# im betting that SmokeyStack knows if they will tho, he knows too much
A question there is no tuturial of how to create a custom item and with that item one can open a user interface
you can use itemUse after event to open form
Well, thank you
:v I don't know the item sjsj
Just check if the current amount is 1 if he's undefined the one you will place otherwise keep decreasing it.
( ( i know how to fix that btw ) )
Does anyone know why I don't see the dam um
Your item have a syntax error
The item already appeared but it doesn't open the menu ui
how to force the player to look at an entity?
does anyone have an extrrnal event handler
What is the script method to play a vanilla sound
dimension.playSound('use.wood', {x: 0, y: 0, z: 0})
So not player.playsounf
or you can use the method on the player class which plays the sound just to them
Minus my typos
2 different purposes.
Thats what i want
so use the player method
I got to wait 2 minutes to test cause i didnt add a debug to speed up or reduce time
Is it me, or does applyKnockback not work on players anymore? I am already using the new syntax and it works on every entity except the player.
is there a way to check if provided type id is mob, item, or something? like for example, minecraft:diamond returns item
or just an array of type ids
and also how to get Entity as Player? just like in EntityDie, i want to get damagingEntity as a Player
What is the sound for signing a book i think its signing a book sound im thinking of
Wait no when a page is turned hold on let me listen for the sound i need
Ok its when page is turned
Nvm found it
How can I identify the last item the player received via /give?
you can detect new items on the inventory
but you cant know if its from a command
Probably only you, it works fine with mine.
you can do, get() it will return undefined if it doesn't exist in the array of it...js ItemTypes.get('<name>') EntityTypes.get('<name>') BlockTypes.get('<name>')while if you plan getting all IDs available, just do getAll() in any of that above...
??js world.afterEvents.entityDie.subscribe(({ deadEntity, damageSource: { damagingEntity, damagingProjectile, cause } }) => { if (deadEntity.typeId === 'minecraft:player') { // ... } });
Are u using the 2.0.0-beta?
yeah.
Can I show u my code then?
world.beforeEvents.itemUse.subscribe(({ itemStack, source }) => {
if (source.typeId !== 'minecraft:player') return;
const view = source.getViewDirection();
if (itemStack.typeId === 'minecraft:stick') {
system.run(() => source.applyKnockback({ x: view.x * 2, z: view.z * 2 }, view.y) );
}
});```
Well this is my code: ```function* liquidRun() {
for (const DimensionTypo of DimensionTypes.getAll()) {
world.getDimension(DimensionTypo.typeId).getEntities().filter((ent) => {
let block = ent.dimension.getBlock(ent.location);
if (block == undefined) return false;
if (customLiquids.includes(block.typeId)) return true;
}).forEach((ent) => {
try {
ent?.applyKnockback({ x: 0, z: 0 }, 0.01);
ent?.addEffect("slowness", 10, { amplifier: 2, showParticles: false });
if (ent.typeId == "minecraft:player") {
ent.runCommand("effect @s slow_falling 1 240 true");
};
} catch (e) { };
});
}
}```
does this also work on custom item ids and not minecraft: ids?
yes.
It returns EVERYTHING that is available in the world even custom ones.
What's the purpose?
It's a function that gets every entity inside a valid custom liquid block and applies a knockback every tick to slow the entity down as it falls. I was trying to use knockback instead of using effects.
I was trying to see if I could slow down an entity (mainly a player) without using effects, as I plan to expand on such a thing in the future.
In fact I'm starting to think that applyKnockback for players DOES NOT WORK in system.run events.
And I mean without being included INSIDE world.beforeEvents or world.afterEvents.
minecraft start destroying
At least in 2.0.0 beta.
Then why does this work?
Because it's inside a world.beforeEvent, my function is in a system.runInterval that runs continuously. It doesn't run after a specific event happens.
At least that is what I'm assuming.
Uhh no?
system.runInterval(() => {
for (const player of world.getPlayers()) {
const view = player.getViewDirection();
if (player.isSneaking) player.applyKnockback({ x: view.x, z: view.z }, view.y);
}
});```
Hold on let me see if this works.
It's not working for some reason.
Out of curiosity, what device are you testing on?
Mobile.
Android?
Yep.
That could be it, actually
You're joking.
Do you take knockback from other mobs when they hit you?
I actually don't.
Then applyKnockback will not push you around, either
But what's causing that?
oh boy, as far as we know thats a platform specific bug, not 100% what the trigger for it is but we have had it happen when the player is in an npc dialog and the npc is removed using the remove method in scripting.
if you find a way to fix it please let us know 🙂
It might trigger in other conditions too, that's just the only one Fetchbot and I know about
Affects Nintendo Switch too.
Oddly, not any other platform. PC is totally fine
But the player not being pushed can also happen through more conventional means. For example, if you set the "minecraft:knockback_resistance" component to 1 on the player, applyKnockback will not push them either
I have no idea what these conditions might be, but ur right. I went into another world, took knockback, and the applyKnockback worked.
I never modified the player file, so I know that ain't it. I probably ran into the bug unintentionally and now I'm just suffering lol.
Likely. Sorry to hear you are another victim of the weird bug
It's fine. Hope Mojang fixes it soon.
Look's like your code and even my code was fine lol. I was just a victim of a bug.
Someone to help me .....
That is a #1067869136606220288 question. Your custom item is invalid.
hey also @wary edge , that issue I was having with the startup event not being subscribed to- I solved it with a buttload of dynamic imports and globalThis's in a worldLoad event
I hate it, but it works
what do you expect me to do, then
It's not a you thing. I completely understand the need for why 2.0.0 executes the way it does...but it leads to a mess of upgrading from 1.X.X....Im so glad its still beta.
fr
bro are you a teacher damn theese gifs how do you make
if (lores.length === 0) return;
why does this line return error
i am having a stroke fixing my script
The only error I would expect that to throw is "cannot read property 'length' of undefined"
Are you not checking if lores is an array first?
There's a couple of ways to check that:
if (lores && lores.length === 0) return;
if (Array.isArray(lores) && lores.length === 0) return;
if (lores?.length === 0) return;
yes yes, it is this error Cannot read property "length" of undefined
It only happens, when you break a block, with a "empty hand"
(since it is in playerBreakBlockEvent)
I think it is bcoz it cant get lore lenght of hand
That's a fair assessment. Then I would first check if getItem() on the container / slot returns undefined
h,mmmmmmm
seems like a chaining operator fixed them
ok i should really practice using chaining operator
whats the event for player obtaining or picking up an item
hmm
So anyone can help me how could i do this
So..
It's a custom enchantment table, where the 1st slot is tool, 2nd slot is enchantment book, 3rd slot is result. So when we take the result, the 1st and 2nd slot doesn't get remove, we have to do it by scripting.
But this makes that. when 3rd slot is empty (meaning result item is taken) we clear 1st and 2nd slot
But this would do even, when we put the item and book there, they get cleared automatically
bcoz the result coming is slow, the result item appears after some delay
and it thinks that result item has been taken,
so the items get cleared without even taking the result item.
^
Can anyone help me with this problem?
i have no idea how could i fix this now
?
I'm not sure I understand. To me it seems reasonable to have the inputs only be consumed after the check for a valid recipe; are you consuming the inputs and determining the outputs in separate logic loops?
Something like the following pseudocode:
function customEnchantingLoop() {
slot1 = get slot 1
slot2 = get slot 2
output = recipeLookup(slot1, slot2)
if (output) {
slot3 = get slot 3
slot3.setItem(output)
slot1.setItem(undefined)
slot2.setItem(undefined)
}
}
Or, if the 3rd slot is set to the enchanting result and must be taken, then you should design the table with a state in mind, so you can compare information across ticks
But I'm taking shots in the dark at how you have it structured
(I am promptly going to bed)
uhhhhhhh
wasn't there a clearInterval()
I cant find it
there is only clearRun() and clearJob()
whattt
@dim tusk
clearRun works for runInterval
hmmm oh bruh
Why tag me 😭
lol sorry..
// 5% chance of getting frozen
if (isFrostAspect && Math.floor(Math.random()) < 0.05) {
//freeze entity for 3 seconds
const interval = system.runInterval(() => {
victim.clearVelocity();
victim.teleport({ x: victim.location.x, y: victim.location.y, z: victim.location.z });
});
//stop freezing if the entity is dead
if (!victim.isValid) {
system.clearRun(interval);
};
//release entity after 3 seconds
system.runTimeout(() => {
system.clearRun(interval);
}, 60);
};```
Cma anyone tell me why this isn't working?
the 5% chance is not working
also, even when the entity is dead, the interval keeps running
try a runTimeout with for loop value as tick value
instead of using runInterval
how
or... make a runInterval somewhere and do getEntities to run the function when its true

also for freezing entities, try setting movement conponent value to 0
but the 5% isnt work it is always true
Oh! how would i do i?
in was thinkin abt it
im on phone rn i cant make a quick code
one handed too cuz i have a coffee on my other hand
haha
this is funny cuz i used to be able to make quick codes on my phone
but it became hard to do ever since i started using visual studio code
Math.floor(Math.random()) will always return 0
ooo
So… “0 is less than 0.05” is always true..
so remove Math.floor
Yes
alr thanks!
how would i set entity;s movement conponent
victim.getComponent(EntityComponentTypes.Movement).setCurrentValue(0)
tried this didnt work
Dunno
that should work though
hmm
Could anyone help me with script for making 4 custom loot items drop with (very low and progressively lower rates) when any mob dies, I would like to make it work with add on mob?
I don't know what info I'm supposed to be looking at for this
May have found it. Is it EntityDieAfterEventSignal?
using oninteract how the hell do i get a block to change permutation/state with any or no item selected ?
block.setPermutation(block.permutation.withState('<name>', <value>))
so its not permutation.resolve got it
You can also use that, resolve resets the states you didn't defined to default one, while with state only change what you changed and it retains the rest.
Why did RunCommandAsync and what’s the new command for it?
how to get the item that is dropped by block after breaking it? can i use PlayerBreakBlock event for it
runCommand is the way
can we read the color of a bed item somehow?
typeId for both the block and the item is minecraft:bed
(and I don't want to place all the colors in a barrel and compare my item with it again)
Kinda, with runCommand
the clear command?
testfor + hasitem property
loop through the 16 colors
Used it in my banner markers addon
imagine the tickrate drop when doing this

In a small server, it doesn't really effect it much
thankfully
Actually, Beds still share same id?
Alr, i will double check when i can
yeah, i was surprised too
how to get the item that is dropped by block after breaking it? can i use PlayerBreakBlock event for it
you can get the item of the block
what property
block.getItemStack()
how about if its BlockPermutation
same thing, BlockPermutation also has this method
how to applyKnockback to hurtEntity to the damagingEntity location?
const dx = dEntity.location.x - hurtEntity.location.x;
const dy = dEntity.location.y - hurtEntity.location.y;
const dz = dEntity.location.z - hurtEntity.location.z;
hurtEntity.applyKnockback(dx, dz, 1.5, 0.8)
it didn’t work
hurtEntity.applyKnockback({ x: dx * 1.5, z: dz * 1.5 }, 0.8)
arguments error: Expected 4, received 2
Oh you're not in beta, just retain what you have rn or just use applyImpulse({ x, y, z })
And what are you doing again?
You wanna make entity move to the location?
Ty
Can I have Script check for structure blocks and then summon entities on them?
If so, can I lay out an order in which they get summoned and named procedurally?
OR, if I were to make a list of the locations, could I have them be automatically summoned and named in order?
This is in 1.21.07 (education) so using server 1.11.0 stable.
Basically, I'm trying to modify one of the Education Build Plate worlds to be a little easier for the teachers to manage the students. I've already manually set up the world I need to use this week but it would be much nicer to put everything into a pack that could automatically do the added setup and save it all into a new Template world.
Is this what you mean?
I guess its perfect for you
but else than idk
Hey @dim tusk
just broke diamond ore with PlayerBreakBlock event but it doesnt detect, especially in getItemStack. how to know what loot was dropped by that block?
What?
Mix playerBreakBlock and entitySpawn.
There's no 100% accurate way to get it.
@dim tusk Let me ask, does the findClosedBiome script work across dimensions when searching for recent biomes?
umm, it depends... Since it's under dimensions it will work based on that dimension only... if you do world.getDimension('overworld').findClosestBiome() it will work on overworld only, while if you do player.dimension, it use the dimension based on players current dimension
Hum, not exactly what I mean since it isn't like I'm creating a pattern with multiple blocks that the detector could watch for. This is more of a script that I want to run once after initial world load to set things up whenever I load the world template.
do you mean the script will look for structure blocks in the world, then spawn entities on top of it?
Yes exactly
a literal structure block
Nobody cobtest
it's very laggy to get all blocks in the world and check if it's a structure block or not, however what you can do is make it summon the entity when you place the block, it's better to make a list of locations then summon the entities there
Ok, I suppose making more of a hard code setup script is reasonable.
So this world has lots of command blocks since the creator only used structures in the BP for it's creation.
I want to avoid having to manually edit and add so many command blocks. (world is created for up to 40 students, there are 40 teleports and 40 build plates and to do it manually, I have to copy/re-orient 80 impulse command blocks and then add selectors to them and add a chain command block to each of these locations.)
How can I use scripts to help me with all the command blocks? (I'm ok with having the blocks run a script event instead of adding more blocks.)
script can't edit text inside a command block, or edit it in general if that's what you mean, if you can explain more because I don't really understand yet
Can script place a command block already populated with commands? (I don't think so but just want to confirm)
yes you can clone a command block
I'm willing to give up the command blocks if I can figure out a way to do what needs done without them.
I expect I could change all the existing command blocks to call a scriptevent to procedurally handle what needs to be done.
I actually don't much like the command blocks since they can't actually tell who pressed the button or who stepped on the plate.
I still don't know what you're trying to do, so if you can explain please?
trying to not clog up the general channel so should probably take this to a thread.
moved here #1355903755362766949 message
Is there any way to detect if the player is riding a mob?
const ridingComponent = player.getComponent("riding");
if (ridingComponent.entityRidingOn) {
//run code
}
Ty
well i know i can use either one for permutations but i havent really messed around with anything other than resolve but when i use with state it keeps telling me it cant set property for a block. but with resolve it only half works lol
How to spawn baby variant mobs?
Is there any way to stop the night from passing by when sleeping?
you can trigger the event that makes them a baby
what are you trying to accomplish? the main point of sleeping is to pass night
is there a way to stop join messages showing up
pretty sure you could use player.isSleeping every tick or interaction and then freeze the time until its false
nevermind isSleeping doesnt exist
Specifically? What event are you referring to?
the ones defined in their entity file.
you can find vanilla entity jsons in bedrock samples
Oh maybe you mean is_baby, ageable... etc, I've tried using summon but it failed, when I summon the mob it stays in adult version
no you can use /event
no
or entity.triggerEvent() im pretty sure
use the native method
wait what
yes
you can
but in API
however theres a native method you mentioned afterwards
Which one?
yes, use the native method.
entity.triggerEvent()
the one dismal mentioned.
I think I should try this one
I don't really understand what you mean, especially since I'm still a beginner.
im telling you to use the one dismal mentioned
which is the native method
its fine
does anyone know if there is a gamerule or a way to stop join messages showing up
Thanks
doesnt seem like there is
You can change the text in the resourcepack, I forgot how it's written, but the point is it's in the language section.
You can change the join player text to blank
Yeah, I find it a bit annoying.
oh
how do you print a log to the content log
i can only find Logger in server-editor
console.log()
it is native js function
oh
ok
how do you use translate strings in script api
wait hang on
nvm i dont got it
i know you can use { translate: "key" } but is there a func i can use to process them, because what im trying to do wont work
What is this?
ran with error: [SyntaxError: Could not find export 'getEquipment' in module '@minecraft/server']
Happened after the update
Show code
i dont think it is possible to detect the realife date using scripts, right? like writing the time last time the player died or something
You can.
you can get the date/time of the server with Date
fr?
like detecting the seconds, minutes, hours, days, months, years, decades?
Yes
const currentDate = new Date()
currentDate.getFullYear() // 2025
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {
ev.cancel = true;
const date = new Date();
world.sendMessage(`§b[${date.toLocaleString()}]§r <${sender.name}> ${message}`);
});```
This will display date and time
good to know!
That's just debugging, those are valid values Scaffolding has.
i dont have any idea how scaffolding works, not even ingame
when would be the only reason I should care for watchdog slowdowns?
thx
How could I run a UI form upon interaction with an NPC?
player interact with entity before event?
can anyone tell me what i would need to type into VCS to get it to update the typescript module related stuff for the newest scripting stuff
@pale grail npm i @minecraft/[email protected]
thank you
just a question, how can i install types without cluttering the pack folder up?
i cant think of better ways to explain this
If I want to create a clan system, is there any other way of storing clan data other than in dynamic properties?
dynamic properties would be the best way
install them globally or something im not sure but it shouldn't clutter
im not familiar with vsc so i dunno how to install npm globally yet 
but thanks ill google
basically just when you install something in npm and want to install it globally, like for everything you'll ever need the package in, type -g after the install. For instance, npm i @minecraft/server -g
ItemUse, It was removed in the new version?
No
itemUseOn was
got it ty
Ok I'm back. I didn't actually solve it, but when to a module version that didn't use NoInfer. The problematic line is inside the module itself
I actually ran into this and it worked if i updated the typescript npm package.
How did you update it?
npm install -g typescript
Unfortunately that didn't work
Very interesting, it worked for me.
It's getting really late, but tomorrow morning if you havent solved it yet, I can try reproducing the error.
does someone know the correct equation to get the locations of the entity's fov?
It's ok. I figured out. I also had to reinstall the local dev dependency
Sorry again @distant tulip give this guy your code again.
bruh npm install -g <package>
yeah ive already done it
import { system, world } from "@minecraft/server";
function calculateAngle(v1, v2) {
const dot = v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
const mag1 = Math.sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z);
const mag2 = Math.sqrt(v2.x * v2.x + v2.y * v2.y + v2.z * v2.z);
return Math.acos(dot / (mag1 * mag2)) * (180 / Math.PI);
}
system.runInterval(() => {
world.getPlayers().forEach(player => {
const viewDir = player.getViewDirection();
const pLoc = player.location;
const entities = player.dimension.getEntities({ location: player.location, maxDistance: 6 });
entities.forEach(entity => {
const eLoc = entity.location;
const toEntityVec = {
x: eLoc.x - pLoc.x,
y: eLoc.y - pLoc.y,
z: eLoc.z - pLoc.z
};
const angle = calculateAngle(viewDir, toEntityVec);
if (angle >= -45 && angle <= 45) {
player.dimension.spawnParticle(`minecraft:basic_flame_particle`,entity.getHeadLocation())
}
});
})
});
this an old script
you may need to make the x fov larger
https://cdn.discordapp.com/attachments/1261618065930457148/1261775009957806161/avc_Minecraft_2024-07-13_21-00-22.mp4
In server aternos, the experimental API beta works?
how can i do applyKnockback without resetting the velocity? 
It doesn't reset it right?
why when I do ```js
entity.applyKnockback({ x: entity.location.x, z: entity.location.z }, 1);
the entity gets launched onto another planet
i thought the second argument was upwards velocity
uh, thats what i used it for #art-and-modeling
youre applying knockback with entity location's value
yeah cuz I just want the entity to fly up
applyKnockback doesnt send the mob to specific location
its, not like that
the Vector2 youre seeing there is for direction
yeah
it should be somewhere like this (0,0,0,0) ig
youd need { x: 0, z: 0 }
he probably needs Vector3 bec he's trying to make his entity fly up
...no?
applyKnockback takes two arguments
Vector2 and vertical strength
mhm,
im using this on my exe addon
entity.applyKnockback(0, -0.03, 0.16, 0); to make the entities moving
I did this, do you know why sometimes my entity fly's a little bit and other times goes way further
oh right are you on stable?