#Script API General
1 messages · Page 96 of 1
Can debug by spawning a particle at the end of the ray probably
If Minecraft uses the mesh base as the origin, which I think it does, also add 1.6 to the Y of the origin vec3 to cast from the player head
isnt it (VectorXZ, min hight)?
soooo I just checked
getBlockFromRay(location: Vector3, direction: Vector3, options?: BlockRaycastOptions): BlockRaycastHit | undefined
So it would be getBlockFromRay(player.position, (0.0, 5.0, 0.0))
yea ty
why
export class LootTableManager { public generateLootFromBlock(block: Block, tool?: ItemStack): (ItemStack[] | undefined); public generateLootFromBlockPermutation(blockPermutation: BlockPermutation, tool?: ItemStack): (ItemStack[] | undefined); public generateLootFromBlockType(scriptBlockType: BlockType, tool?: ItemStack): (ItemStack[] | undefined); public generateLootFromEntity(entity: Entity, tool?: ItemStack): (ItemStack[] | undefined); public generateLootFromEntityType(entityType: EntityType, tool?: ItemStack): (ItemStack[] | undefined); private constructor();};
New APIs damn cool
do ores have some sort of spwan pattern ? can we predict pos
Moved EntityEquippableComponent properties totalArmor and totalToughness from beta into 2.1.0
On preview 👀
it's always been possible
just with workarounds
but you're right, this will be 10x eaiser
not really
what about if they added new ore
or other addon would make one
there is no way to know what loot it drops
you update it
you can't deal with infinity addons that could be applied to the world
no workaround
????
what about if they added new ore
or other addon would make one
well sometimes you want something that works at least as Java mods do
but you can't really know what others addons adds
thats the point
How are you uploading it?
very nice
mc is probably right handed and y axis is up
Why doesn't the boss bar name update in real time?
Is there any known way to distinguish between 2 falling block entities?
Using a ModalFormData are you able to detect which submit buttons is being pressed if there are more than 1?
How much does it take to tank tps with scripting? Hosting a server and it has a fair amount of scripts but for some reason every so often tps just tanks. Ive checked chunks, entities, and the server specs and all them are fine. the only think I can think of is the scripts
use the debugger to look into it
Can somebody explain how to use parameters for custom block components? I don't quite understand how to register and use the parameters, and an example would be great.
Check the wiki.
Do you think you could give me the link to the specific page?
{
"components": {
"some_component:name": {
"first": "hello",
"second": 4,
"third": [
"test",
"example"
]
}
}
}
...
type SomeComponentParams = {
first?: string;
second?: number;
third?: string[];
};
system.beforeEvents.startup.subscribe(init => {
init.blockComponentRegistry.registerCustomComponent('some_component:name', {
onStepOn: (e : BlockComponentStepOnEvent, p : CustomComponentParameters) : {
let params = p.params as SomeComponentParams;
...
}
});
});
Probably a Bug. If you use nametag manually it'll update
Anyone tried apply impulse in the new preview?
when scriptAPI 2.0 was released they mentioned
Removed runCommandAsync as most commands did not actually run asynchronously. If you are looking to run a function asynchronously, please investigate using Jobs via System.runJob
possible that could be why in your case? try just runCommand? If that's completely off sorry, still familiarizing myself with scriptAPI.
https://learn.microsoft.com/en-us/minecraft/creator/documents/scriptingv2.0.0overview?view=minecraft-bedrock-stable
For some reason, I just updated my scripts a bit and now when I try to load into my world, it says "There was a problem loading into the server" even though I am not in a server and instead in a normal singleplayer world
Isn't this v1?
Hmm, got a JS version?
Yo, does anyone know of a default particle that we can tweak using scripts?
The only one that comes to mind would be music notes since well, they're colored by molang iirc
Anything greater or equal to 2.0
I mean, do you have a JS form of the script?
https://github.com/search?q=repo%3AMojang%2Fbedrock-samples+path%3A%2F^resource_pack\%2Fparticles\%2F%2F+variable.&type=code
most of these can be used
just look for stuff that uses vec3 float or rgba
Thhx
ahh, ok
I think so too, because if I spawn the entity in the script, it doesn't update the name in the bossbar, but if I use /summon, it updates it right away
Has anyone else had this content log before or could anyone help me in figuring out what it means
import { system, world } from "@minecraft/server";
let constantBeam;
const ignoreList = new Set([
"minecraft:minecart",
"minecraft:chest_minecart",
"minecraft:hopper_minecart",
"minecraft:tnt_minecart",
"minecraft:xp_orb",
"minecraft:item",
"minecraft:tnt"
]);
function newBeam(player,itemStack) {
const constantBeam = system.runInterval(() => {
const view = player.getViewDirection();
const head = player.getHeadLocation();
const distance = 24;
const range = {
x: head.x + view.x * distance,
y: head.y + view.y * distance,
z: head.z + view.z * distance
}
const hitEntities = player.dimension.getEntities({ location: head, closest: 1, maxDistance: 24 });
for (const entity of hitEntities) {
if (entity.location > head && entity.location < range && !ignoreList.has(entity.typeId) && !hitEntities.includes(player)) {
entity.applyDamage(15, {
cause: "lightning",
damagingEntity: player
});
}
}
}, 4);
}
world.afterEvents.itemStartUse.subscribe(({ source, itemStack }) => {
const player = source;
const item = itemStack.typeId;
if (item == "ltng:newbeam") {
newBeam(player, itemStack);
}
});
world.afterEvents.itemStopUse.subscribe(( e, ) => {
const { itemStack } = e;
const item = itemStack.typeId;
if (item !== "ltng:newbeam") return;
system.clearRun(constantBeam);
});```
This is it
which line is 49
The last one
system.clearRun(..)
if (constantBeam) system.clearRun(constantBeam);
use this instead just clearing the run
It was that simple
Thank you
yeah
if you need even more safety, just check for it's type
if (typeof constantBeam === "number" && !Number.isNaN(constantBeam) system.clearRun(constantBeam);
wtf is this error
const overworld = world.getDimension("overworld");
``` this is line 4 btw
use a provider
wdym
import { world } from "@minecraft/server"
class Dimensions {
#constructor() {}
/** @type {import("@minecraft/server").Dimension}*/
static #overworld
static init() {
this.#overworld = world.getDimension("overworld")
}
static get overworld() {
return this.#overworld
}
}
world.afterEvents.worldInitialize.subscribe(() => {
Dimensions.init()
})
and use Dimensions.overworld.
wtf is this!?!
due to 2.0.0, most of functions are native now
this code is initializing overworld as soon as the world has loaded
so where did const overworld go
use Dimensions.overworld from now
so replace everywhere where it mentions overworld to Dimensions.overworld
yeah
alright thanks
no problem
static get overworld
are the hashtags supposed to be there
😅
copy the code again
I fixed it
you can remove constructor if it's throwing you an error/warning
just delete it?
// main.js
import { world } from "@minecraft/server";
let overworld = null;
// Wait for world to fully load
world.afterEvents.worldLoad.subscribe(() => {
overworld = world.getDimension("overworld");
overworld.runCommand("say World loaded!");
console.log("Overworld is ready");
});
In Script API v2, most API calls cannot be made in global scope, especially during early script initialization. The worldInitialize event has been removed, and you now need to listen to the worldLoad event instead. That means:
Use world.afterEvents.worldLoad.subscribe(...) to get a reference to your world or dimensions.
You can either:
1 - Assign that reference to a global let variable and use it later.
2 - Export the reference from one module for use in others.
The above example references number 1 but number 2 is just as liable and simple.
Its either that or you can make multiple API calls versus just the one, but if you make multiple API calls, be sure that the API call is being called when it's appropriate, which in most cases must be during or after worldLoad.
Could someone help in figuring out what is wrong with this function and why it doesn't attack entities in a straight line within the player's view direction (as a seperate problem to the content log)
You are doing a logical comparison of objects. if (entity.location > head) @snow knoll
JavaScript does not know how to really interpret this, because how should {x, y, z} be greater than / less than another {x, y, z}?
AFAICT those comparisons always return false.
Depends on what you're wanting it to do. What should it mean for an entity's location to be greater than the head location? (or less than the range?)
Should the values of each coordinate be within those two points? Like a volume check
Yes, that was the intention
You could write a function that determines if a point lies between two points. I don't expect that to be too useful here though; such a function would be comparing each axis of those points, which would give very tight volumes along axis-aligned directions and very large volumes across diagonals
I suppose what you want is the distance instead. For that, you can use a little vector math to find out if the entity is too far or too close
for (const entity of hitEntities) {
const entityLocation = {...entity.location};
// find difference between two points
const delta = {
x: entityLocation.x - head.x,
y: entityLocation.y - head.y,
z: entityLocation.z - head.z,
};
// distance formula: sqrt(x^2 + y^2 + z^2)
const entityDistance = Math.hypot(delta.x, delta.y, delta.z)
if (entityDistance <= distance && !ignoreList.has(entity.typeId)) {
/* ... */
}
}
Thank you so much
With that, your sphere of what entities should find is limited to a shape like this.
From a point that is distance away, you grab all entities in a sphere of distance radius, then filter those who are further than distance meters away from the origin. It creates this kind of Venn diagram
Thank you
question: is it a glitch that form dividers and labels show up as null in the result.formValues array?
it's intentional
Unique Question: If I have a feature/feature rule place a block, and have that block do an onTick event (Not Repeatable, 0.5 Seconds), will it summon an entity I have it summon on that tick, or will that entity not appear because the world isn’t loaded?
As far as I know, both onTick and onPlace don't properly work if placed via features.
That’s what I thought, I have a plant that uses a block as a base and summons an entity with the geo due to restrictions with the geo size of blocks. If this is true then I unfortunately don’t see another way to do this other than maybe making these flowers have spawn rules lol, and have a timer for those that place a block
I’ll figure it out somehow, thanks for the help!
why tho?
dividers and labels have no user input value
mkay...
is there any way to get the amount of bees inside a nest?
how can i check in scripts if a player is in first person?
only work around
store beehives with all possible amounts in structure, when loading them get the items and check if they can stack with your item
ty
is there any way to get the max value of an int block state?
like the "growth" state in crops
Yes, however keep in mind that if two blocks share the same state name, it will get the min and max from both blocks.
how do I get it?
https://stirante.com/script/server/2.0.0/classes/BlockStates.html#getall
https://stirante.com/script/server/2.0.0/classes/BlockStateType.html#validvalues
Documentation for @minecraft/server
Documentation for @minecraft/server
Is it possible to get players profile pictures in local worlds with scripting? non bds
anyone used loot manager
Is there a way to save variables value so that if the player rejoins, the value remains the same as the last save?
dps
what's that? sorry im new to this 😅
dynamic properties
they gets saved onto the world nbt
player.setDynamicProperty('myvalue', 'foobar')
let myValue = player.getDynamicProperty('myvalue')
is there a docs for that? i cant find that on microsoft thing
u can find them in World, Entity andItemStack
thank you!
is there a tool to see all dynamic property of the world?
smth like DataGrip?
like this
NBT Editor?
can you import files with worldLoad or do I just need to wrap each file with it?
wasn't there something like getAllDynamicProperties?
Can't find now but I very much feel like it existed
It only returns keys
Can anyone help in https://discord.com/channels/523663022053392405/1390197363934761000
ye ik but still cant find it in the docs
getDynamicPropertyIds
Hmmm, I see it in the MS docs
But i always use jayly's docs
Can't find it in his docs, i tried searching..
I prefer using Microsoft docs
ms docs are bit messy to me
Lets see on stirante's docs
They're really simple and clean for me
why did you said getDynamicPropertiesIds 😭
its getDynamicPropertyIds
I forgot how the method was named, then I checked it in docs
Hi here! Does anyone here have a script that checks the performance of script if it perform well or the code is optimized. Like a memory usage evaluation.
VSC's miencraft debugger has it
you can also use diagnostics in game to export a file that tells you how long it takes to call functions and methods
I have a server and for some reason i manage the server thru this very complicated codes, too many codes running at once. I check the performance of it by checking the ram usage, memory usage etc.. But i notice every time that memory usage rising dramatically every 5 hours so I need to restart the server in order for other people to join.
I dont know whats causing the memory usage to go up max
its memory leak
i dont know what behavior packs youre using, but testing it in singleplayer with VSC hooked up on your game should give you live diagnostics of memory usage for scripts and your game
oohh thanks, but how can i know if whats causing the memroy leak. and how this memory leak works?
googling it should explain it better
Thanks for the time!
you can ask here anytime about it, though the best thing we can only recommend is to not use behavior packs that has bad optimization
With the new custom commands API, is it possible to create subcommands?

Welp, time to create multiple commands
sob
How would a subcommands work
hmm
you can give multiple params and get various results from one main command
but you cant do that with custom commands currently
Use the old free version of universal minecraft editor
okay, thanks!
Can dynamic properties be detected through molang?
No.
And with the key you can get the value...
and you know how inefficient it will be to get all pairs?
of course, you can use a hashmap
Use runJob
still it might take a lot of iterations
Ofc but it wont cause spikes
at least it's reducing spikes
function showVaultInvites(player) {
const VaultInvites = JSON.parse(player.getDynamicProperty("VaultInvites") ?? "[]");
if (!VaultInvites.length) return player.sendMessage("§bYou do not have any incoming vault invites!");
new ModalFormData()
.title("§bVault Invites")
.dropdown("\n§7Here is a list of vault invites you have received.\n\n§8Joining a vault will add it to your name tag and chat rank!\n\n", VaultInvites)
.toggle("§7Clear All Invites", false)
.show(player).then(res => {
if (res.canceled) return;
const [dropdown, clearInvites] = res.formValues;
if (clearInvites) {
player.sendMessage("§aSuccessfully cleared all your pending vault invites.");
player.setDynamicProperty("VaultInvites", undefined);
return;
}
if (player.hasTag("vault_owned"))
return player.sendMessage("§bYou are already in a vault. Leave your current vault to join other vaults.");
const invitingPlayerName = VaultInvites[dropdown];
const invitingPlayer = world.getPlayers({ name: invitingPlayerName })[0];
if (!invitingPlayer)
return player.sendMessage(`§b${invitingPlayerName} is no longer online.`);
const invitingVaultId = getScore(invitingPlayer, "vault");
if (!invitingVaultId) return player.sendMessage(`§b${invitingPlayerName} does not have an active vault.`);
const vaultLocation = { x: 5500, y: 100, z: 5000 + (50 * invitingVaultId) };
player.teleport(vaultLocation, { dimension: Dimensions.overworld });
player.runCommand(`tag @s add vault_member`);
player.setDynamicProperty("vaultId", invitingVaultId); // Store vault ID to player's properties
player.runCommand(`scoreboard players operation @s vault = "${invitingPlayerName}" vault `)
const updatedInvites = VaultInvites.filter(invite => invite !== invitingPlayerName);
player.setDynamicProperty("VaultInvites", JSON.stringify(updatedInvites));
player.sendMessage(`§aSuccessfully joined the vault of ${invitingPlayerName}!`);
invitingPlayer.sendMessage(`§a${player.name} has joined your vault.`);
});
}```
guys whys my modal form dropdown not working?
what error are you getting?
ohh
its giving an error at the dropdown
ohh a toggle
sorry
xD
to provide a default value, you have to use:
.toggle("§7Clear All Invites", {
defaultValue: false
})
dropdown is correct, toggle is throwing you an error
if this is correct im gonna cry
don't worry, they changed component's options to be based on interfaces now
dude thank you so muhc
What chatsend name in api 2.0.0
isn't it still chatSend?
are you using beta APIs?
No i using 2.0.0 stable
Why?
It's beta only.
In 1.21.90 beta api is which version is 2.1.0-beta right?
Yes.
Ok
What's the difference between this script ```
console.log("test" )
and this script ```
import {world} from "@minecraft/server"
world.afterEvents.worldInitialize.subscribe(()=> console.log("test"))
This is for scripting 1.0, right? They may execute at rather similar times
I would expect that the second script executes around when the world is "more finished loading" than the first, but this distinction may be blurry, I am not sure
In scripting 2.0, the world load order is much more clearly defined. The simiarly named worldLoad call happens after the first tick executes; so the difference is much more clear
You can read more about it here: https://learn.microsoft.com/en-us/minecraft/creator/documents/scriptingv2.0.0overview?view=minecraft-bedrock-stable
Does anyone know json ui?
Don't crosspost, read #welcome
Sr
ah, so they are basically the same in 1.0
Guys I think i will make me an super perfomant Scoreboard database, because the data is persistent and can't be removed when removing the addon.
Or am I just stupid?
Nvm changed my mind
is there a existing method in scripting to break a block in the world?
only with cmd
is there a way to get the position of specific block? like for example, oak leaves
Can I teleport a player into an unloaded chunk?
yes
I'll test that, ty :3
how do you get the worldspawn location
how do you get the ground height at a xz location
Documentation for @minecraft/server
vec3 without the y
where are new npms
Contains many types related to manipulating a Minecraft world, including entities, blocks, dimensions, and more.. Latest version: 2.0.0, last published: 16 days ago. Start using @minecraft/server in your project by running npm i @minecraft/server. There are 71 other projects in the npm registry using @minecraft/server.
no nothings changed, we just gotta update our games
thats cool
Is it possible to display a video on your screen
no
no.
Not even photos?
Oh ok I'll search for it
no need, theres the link
technically no but u can use animated photos or animated blocks / animated texture entities
u need to use flipbook thing in order to do that
and i think there is a tool that can change videos to a very long flipbook texture that u can use on minecraft
for sure not
its about that dude that needs to render a video on the screen
I know?
its not possible but possible at the same time
im asking how?
ah,
it would suck to implement
the same way u make flipbook blocks or making an entity has animated texture
no custom emojis needed, u can render an image by sending a specific title or even chatmessages
and that image can be modified to have a flipbook texture
using json ui
yes
right, you can use images.
animated images*
which are images
using an attachable to render a video?
I have absolute no idea how that works since i haven't touched it at all
you know that if the video is atleast 256x256, the 'video' would be big as hell, right?
animated texture that will render the video on the attachable
you got problem with the size of it, it will be simply big as hell
and you'd have to put each frame on the image
you can scale the entity/attachable down.
yah i remember someone used some kind of tool to turn a kind if flame video into a very long flipbook texture that he used on minecraft
depends on how large the video is and how much frames u need to render per second
hes/shes/whatever else is talking about the flipbook image size
which wont be a problem if you scale it down in-game, no?
it will render normally ingame,
can a model even fit it
i think so
it will be extremely laggy if the video is too large, so i prefer using jsonUi images instead
How to remove players footstep particles and noise if they have a tag?
not possible
is it possible to do without scripting or is it fully impossible?
fully
Could I just /stopsound and remove the particle from textures or would that not work?
if stopsound does work, you could not prevent other player/entity's footstep sounds being silenced aswell.
i could create a separate walking sound and script it to play when players without the tag walk
but idk
ik
is custom / command still in beta?
[Scriptinglferror-Plugin [Enderaltar BP-1.0.0]-[rmain.js] ran with error: [TypeError: cannot read property 'subscribe of undefined at <anonymous> (main.js:13)
Partially. they're now on stable but some of its functionality is still on beta.
ping?
Incorrect event name
do you guys know how to make a 5 letter Minecraft related word dictionary?
what
what...?
anyone know why the icons are off ill send code in 1 sec
help would be appreciated
probably due to an update
its not it messed up when i changed the item name prefix
@round bonehow do i get this to stop throwing this error without having the chunks generated 24/7 js system.runInterval(() => { const dimension = world.getDimension('overworld'); dimension.spawnParticle('server_icon', { x: 30.5, y: 117, z: 67.31 }) }, 10);
uhhhh,,
im using this player?.sendMessage(weakImpacts[parseInt(Math.random() * weakImpacts.length)]); to send a random message from the array
how am i going to send two messages from the array?
like there is 6 different messages in the array, and i need to send a random one twice, how?
the same message twice?
yes, the same random message, but twice instead of once
const msg = weakImpacts[parseInt(Math.random() * weakImpacts.length)]
for (let i = 0; i < 2; i++) player?.sendMessage(msg)
ill try it ig
mb
thanks though
yah that works, ty
you can just copy-paste the method 2 times
it's simpler, but using a for loop is cleaner in my opinion
did getGamemode() change in 2.0.0?
all my code related to checking gamemodes have been failing ever since I've updated
bruh
nvm they just capitalized the string now 
i think they changed it when they added spectator mode
nah, it's been working fine for me when they added that in (unless they changed it for experimental, as I'm stable exclusive).
I've literally just been going back and forth changing the update name in this hyperlink until I spotted the capitalization difference.
https://jaylydev.github.io/scriptapi-docs/1.21.50/enums/_minecraft_server.GameMode.html
apparently it has been lowercase all the way up to 1.21.80
oh lol
that will send two random messages, it wont send the random message twice i believe
const msg = weakImpacts[parseInt(Math.random() * weakImpacts.length)]
if (player instanceof Player) {
player.sendMessage(msg)
player.sendMessage(msg)
}
as far as you'll save a random message via variable, you can just re-use it
The type of people who try to make a full 3D video game without knowing how to program yet .... that's why I say learning the basics first is required.
Also, I cannot help with people who don't even have the basics down yet.
I agree.
... Math.floor() instead of parseInt()
you would get similar results, but it would be better to use math.floor.
I assume parseInt() converts it input value to a string, which means that you could get weakImpacts.length out of the result, if unlucky.
Parse int capture first number from the string
if the number is < 2³²-1 you could use bit operator 👍
// I assume this would end up as '1'
0.99999999999999999999999999999999999999999999999999999999 .toString()
parseInt('8080wave9000') == 8080
parseInt('wave9000') == NaN
Wave, the input is a number...
aside from just rewriting fishing mechanics, is there a way to detect when a player has completed a fishing event?
that would be tricky, if not impossible.
which part?
rewriting it wouldn't be that bad. dont see a vanilla way to see when the vanilla event completed though
yeah.
If you replace the entire loot table...
NaN == NaN // false
NaN === NaN // false
isNaN(NaN) // true
Number.isNaN(NaN) // true
you could detect if a dummy item spawns
Exactly.
When the item spawns in...
hmm yeah that would work. thanks
The only problem would be calculating how to do the movement arc for the item being fished.
check if the typeId is minecraft:item and get the item component, then get itemStack property.
for vanilla parity yeah. just adding itemstack to inventory / spawning under player is fine for now though.
Though, if you want to replace it, you'd just swap the itemStack out and keep (reapply?) the momentum
not just the only problem, this edits a vanilla file, which could cause compatibility issues with other addons
but lets say we dont care about that
I dont. It's a self hosted dedicated server lol
Derp, that too.
welp, thats not a problem for him
mainly just working on a fishing skill with xp/unlocks so was trying to think of a way to make experience gain possible. the dummy entity will probably work. thanks
dummy item, not an entity
well, it will be an entity
but you dont need to create an entity
yeah when it travels from water to player, right?
but the script should detect it spawning before or very quickly after it becomes visible
just despawn it as soon as it spawns
not before
there's no beforeEvents for entitySpawn
it might be rough to giving the player that did it xp though, unless you plan on spawning the xp orbs
Can you swap out the entity's itemStack without affecting anything else like velocity?
... so the only easy way is to just grab the position and velocity, destroy the item, and create the proper, new item entity with the copied position and velocity.
assuming you could set the velocity on the item entity...
... is that not possible?
Is setting the velocity of a non-player entity impossible, @rustic ermine?
I said no
there's no method for that
apply knockback wont work because items dont support it I believe.
A method isn't the same as a property... is there anything, even NBT-side, that stores it?
no really?
If nothing stores the velocity, then how does it know, after you drop an item from your inventory, which way horizontally to move it on the next tick, and the tick after, and the next after that?
So the only way to fling a player as if out of a cannon (but without any damage) is by knockback means?
apply knockback or apply impulse (which player now supports in preview I think)
yes
... and you are 100% certain neither exist for item entities?
what do you mean? I said apply impulse works on items
...
...
Nowhere do I see "item" being mentioned here
because you mentioned player...
both are entities...
- #welcome
- it works the same
what rule did they break
// Normal JavaScript btw
const getAllPropertyNames = (obj) => {
const results = new Set();
for ( ; obj != null; obj = Object.getPrototypeOf(obj)) {
for (const prop of Object.getOwnPropertyNames(obj)) {
results.add(obj);
}
}
return Array.from(results.keys()).sort();
};
say you dont want to be tagged then
its not clearly stated
you are going to screenshot this and link this everytime someone pings you? lol
I don't think that telling me the same approach, but with a different method which is returning the same value is a necessary thing
I'm going to use my own Discord app
Sorry to interrupt but:
How does player.getEntitiesFromViewDirection() actually work?
I'm just really confused, is it detecting if an entity is in the players crosshair from a certain distance (like a direct, straight line) or is it like a cone from the players view of every entity they see?
Can someone help to shed some light on the topic
how would i go about not letting players hit entities when they are in a certain place i have the location set up but how do i cancel them being able to hit entities
you probably have to make damage sensor system from scratch
you cannot.
I could help test (I have an Android device, but it is on the stable releases)
in the script api, currently.
i have this set up but it only works for players
I only use stable anyways, thank you
in player.json
you have to cancel all attacks, then hit if none of conditions to cancel a hit are true
how?
on_damage ... is this for dealing damage, or taking damage?
taking damage
- cancel all attack
- rewrite entire hitting system
ok
it requires a bit of work, but it's possible in the end
yeah how the fuck do i do that
Yeah, sorry for the late response, but I thought it was required to understand why I felt that way.
not a script api thing.
i need players with the tag not be able to deal damage to other entities
... hopefully mobile users are noticing my responses because I am not @-pinging them when they already turned their screen off / switching back to their game...
which is possible but it would take forever to edit every entity file.
cancel all entity damage using player.json, then use scripting API to implement with your cancelling conditions
any idea where i could find an example of what your suggesting with player.json
So on_damage is for taking damage... what would be for dealing damage?
well i only need a few of my npc mobs to not be hittable so its just a matter of messing with their json file in behaviour?
yes
Though I do recommend to keep void damage as something that damages it.
(you don't want a bunch of entities you don't know about at the bottom of the world, right?)
well there is 2 of them and they spawn nly via command so im chilling id say
I dont think there's a filter for location, but you can give the player a tag if they are in the location, and you can filter this tag in the damage sensor.
well it'll be based on condition though
I made something via. command blocks long ago that throws people into adventure if they are within one of several separate areas
then puts them into survival after they leave
I think its a straight line.
because thats how raycasting works
Do some testing with solid blocks, transparent blocks, and awkwardly-shaped blocks in the way… bonus to know how it works.
its a straight line that collides
Awkward?
Chest, Lectern, etc.
odd shaped, like a fence.
Fences too
I thought you meant awkward shapes made from several blocks
lol
Thanks Void, and sorry I got all agitated / etc.
its chill.
Not everyone has the same capacity of handling stress / etc. that others do.
i got it chat lets gio
nice
Just a quick off-topic, forgive me that my OCD noticed your typo…
(Only some anime / manga fans will notice the reference)
But it was me
End of the random off-topic
The part I put in bold reminded me of the joke I made… I forgot how long ago.
i got it chat lets gio
yeah ik
a lot of code tbh
can we use raw text on signs?
Yes.
Do i just write the localization key, or is there another way?
can we do it with commands?
Never heard of setting text via commands.
ok
world.afterEvents.playerInteractWithEntity.subscribe((event) => {
if (event.target.typeId == "neptune:cratesnpc") {
CrateUI(event.player);
}
});```
anyone know why this wouldnt work
can you show code of a function?
export default function CrateUI(player) {
const form = new ModalFormData();
form.title("Crate UI");
form.dropdown("Choose a crate to open", ["Common", "§2Rare", "§uEpic", "§eLegendary", "§mMythic", "§1Neptune"]);
form.slider("Amount of crates to open", 1, 64, { defaultValue: 1, valueStep: 1 });
form.show(player)
.then((r) => {
})
.catch((e) => {
console.error(e, e.stack);
});
}```
did you import this file?
yes
are you sure that entity's type ID is equal?
if your entity does not have the interact component, playerInteractWithEntity afterevent will not trigger.
like this?
yeah.
what do i put as the thing
what
in the brackets
you dont need to put anything.
yeah but that doesnt work
it should.
it doesnt
I dont know what to do then.
alternatively you could use beforeEvents instead, but keep in mind there's the beforeEvent privilege system.
okay i switched to before event and it threw an error
progress
what could this mean
?
code : ```js
export default function CrateUI(player) {
const form = new ModalFormData();
form.title("Crate UI");
form.dropdown("Choose a crate to open", ["Common", "§2Rare", "§uEpic", "§eLegendary", "§mMythic", "§1Neptune"]);
form.slider("Amount of crates to open", 1, 64, { defaultValue: 1, valueStep: 1 });
form.show(player)
.then((r) => {
})
.catch((e) => {
console.error(e, e.stack);
});
}```
I literally just said keep in mind theres the beforeEvent privilege system
did you even click the link I sent you lol
mb
is it possibel to name an entity with a double line name
like "Sheep \n 10hp" type thing
ya
how?
Just like that
system.runInterval(() => {
const [testEnt] = world.getDimension('overworld').getEntities({ type: 'minecraft:sheep', location: { x: 0, y: 0, z: 0 }, closest: 1 });
if (!testEnt?.isValid) return;
testEnt.nameTag = "Sheep \n 10hp";
}, 1)
how do i do a teleport with keepVelocity
is there a page with documentaion of all the scripting functions
bro helix is so damn cool
Ye
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]
Guys what's wrong with this
It threw no errors, no content logs, just won't work
Anyone who can help, in any way, is sincerely appreciated
import { system, world } from "@minecraft/server";
let constantBeam;
const ignoreList = new Set([
"minecraft:minecart",
"minecraft:chest_minecart",
"minecraft:hopper_minecart",
"minecraft:tnt_minecart",
"minecraft:xp_orb",
"minecraft:item",
"minecraft:tnt"
]);
world.afterEvents.itemStartUse.subscribe(({ source, itemStack }) => {
const player = source;
const item = itemStack.typeId;
if (item !== 'ltng:newbeam') {
constantBeam = system.runInterval(() => {
const entities = player.getEntitiesFromViewDirection({
maxDistance: 24
});
entities.entity.applyDamage(15, {
cause: "lightning",
damagingEntity: player
});
player.runCommand('give @s diamond');
})
};
});
world.afterEvents.itemStopUse.subscribe((e) => {
const { itemStack } = e;
const item = itemStack.typeId;
if (item !== 'ltng:newbeam') return;
try {
system.clearRun(constantBeam);
} catch (e) {
//pls catch error or give me no trouble
}
});```
constant beam isnt defined the the scope of where the clear run is
Would that affect the runInterval from running in the first place?
o wait i didnt see the let at the thing
why not remove the try and catch to get the error
Oh, mb, I misread what you wrote
I got an error
Solved the problem of the error using
if (constantBeam) system.clearRun(constantBeam)
but the runInterval still wont run
system.runInterval() returns number which is used to handle stuff
make sure constantBeam is number and not something else
Hello does anyone know How do I use the addEnchantment inside the enchantable component for items I'm trying to figure it out but couldn't find any docs on it. I tried to guess but it wouldnt throw any error but also not work
have you tried setItem?
No. I haven't
I'll try
But I don't get it setItem doesn't have any more params than any regular item param as far as I'm Aware
Doesn't work. I'll open a thread maybe I'll get more answers
can someone link a good menifest generator for scripts
thx
Is there a script where if we see an evil (monster) then a saying will appear saying it's a monster?
I need your help because I don't understand Java script
I recommend learning basics of JavaScript before getting into #1067535382285135923
Can you give me a script to "detect if we see a malicious mob, we will get an alert"? Can you write it?
If a player sees an evil mob he will get a warning /say warning
Gosh I'm not good at math -_-
you would have to check if player's camera could see it in 55 deg for each side
then check if mob is not behind some block
Hey, I don't understand. Can you just write the script? I don't understand.
I said I already fixed it but the runInterval still wont run
your best is to move the runInterval outside the event and do a variable check on each players
Should I put it into a function and call the function through the itemStartUse event instead then?
it's a bit more than just few lines
that could work? i guess?
I was asking you😭
But anyways I moved it out into a function (it was one initially in the first place) and did a variable check on all players with for (const player of world.getPlayers()) and it still didn't work
huh
Maybe I'm the problem and the script doesn't like me🥲
I finally fixed it
I was calling it incorrectly
I needed a question mark
And [0]
sob
But thing is that its only working when just the runInterval on its own
You can do this using a simple dot product check:
- First, search for nearby entities around the player.
- Loop through each entity and compute the direction vector:
entity.position - player.position. - Cast a ray from the player toward that direction.
- If the ray hits the entity and the angle between the player's facing direction and the direction to the entity is small (i.e., they’re roughly facing each other — check using dot product ≈ 1), then the player can "see" the entity. Add it to a visible list.
- If the visible entity is a monster, trigger an alert for the player.
Hmm, I don't understand.🙏🏻
Some pseudocode:
const facing_dir = player.getViewDirection()
const visible = []
const nearby_entities = player.dimension.getEntities({maxDistance: 16})
for (const entity of nearby_entities) {
const direction = Vector_sub(entity.location, player.location)
const angle = Vector_dot(direction, facing_dir)
if (angle < Math.PI / 2) continue
const ray = player.getEntitiesFromViewDirection(direction)
for (const result of ray) {
if (result.entity) visible.push(result.entity)
}
}
if (visible.length > 0) {
player.sendMessage("Evil mobs spotted! " + visible.map(_ => _.typeId).join(", ");
}
You'll want to write or download a Vector library for this. Vector addition/subtraction and the dot product are used in this implementation
anyone got an idea how to lock an entity on the block where its been placed
Guys How to put tags in items and blocks in the itemUse.subscribe event and playerBreakBlock
i think you need to define it already on the item json
anyways does anyone here know how can i spawnParticle the block particle of a specific block, like the mace?
Can you check when a recipe is unlocked?
just checked the particle list and saw block_destruct but said it is a bugged particle for /particle
was isOp() released to stable?
You can abuse commands to do so:
remove the recipe from the player and get the successCount
if (succes) give the recipe back, return true
if (failed) return false
/**@param {mc.Player} player @param {string} recipeId @returns {boolean}*/
function playerHasRecipe(player, recipeId) {
const hasRecipe = !!player.runCommand(`recipe take @s ${recipeId}`).successCount
if (hasRecipe) player.runCommand(`recipe give @s ${recipeId}`)
return hasRecipe
}
smart..
never learned commands 😔
Thank you!!
never knew you could do that with commands
where do you get knowledge like that?
@distant tulip Have you unrolled the changes for editor ?
i believe so?
you still have the selection thing?
Yes
can we clone an entity?
structures
no, i mean, if you have an entity Object, can you use it to create a clone of it in the dimension?
I want to kinda cancel the entityRemove event but entityRemoveBeforeEvent doesn't have the canceled property, so i thought i could spawn the entity back
It gives you an an Entity instance, which i want to respawn
Hi, I have a script that's working, but I'd like to add a function so that the stripped wood stays in the same position as the original log. Is that possible?
It seems there isn't a release for the 1.21.93 in the addon samples
Idk I just thought in the moment and I remembered that the /recipe command existed couse I used it to debug recipes in my addons. I’m just good at problem solving
Also could u possibly know if the block was left unbroken and how much broken it was in a percentage?
I'm pretty sure no.
playerHitBlock event. You can detect starting mining with it.
But you can't detect how much was left unbroken, it's impossible with scripts.
world.beforeEvents.worldInitialize.subscribe(data => {
data.blockComponentRegistry.registerCustomComponent('osuea:cow_spawner', {
// onStepOn: e => {
// e.block.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.Air));
// },
On
});
});
``` Never used this before can someone help, im trying to make it so it spawn a cow every 15 seconds
i have the block JSON done already just typings arent showing anything about ticks
nvm i was doing it so wrong, but i fixed the component shiz but the cow aint spawning
how to get what body part the player was hit
nvm fixed
wazzup.
👋
@wheat condor Hey, I would like to create a keyframe timeline for pos rotation, fov, etc. Any ideas on how to structure that?
how can I set molang variables on entities with scripts?
Entities? You cant.
Entity.setProperty
if I were to run playAnimation with a stopExpression that modifies some variables then returns true, it would effectively just set those variables
this
entity properties & setProperty, and reading that in client or whatever
Worth a shot, I guess
I mean is that documented? the recipe command?
I'm learning JavaScript on my phone 🤧
i still do stuff on phone
Starting to learn js with phone is very inefficient
I couldn't understand js until I got into my PC and started writing code with hand.
PC is more like a faster and practical way to learn
I mean, idk why but it's enifficient atleast for me to learn on mobile. I can't type better on it
.
I mean.... Idk If it's only to me, but, I get bit "comfort" on PC and easier to look at for long at code, write faster, etc
yeah and it's much more faster because of the shortcuts
Using Termux and Shizuku, I created a project template that automatically compiles the TS project and pushes it into the android data folder.
You can structure it like a json and run everytime the next sequence based on the tick
Not like that , more like how blockbench does it
What do you need that for?
I want to make a cinematic addon but can't decide how to handle timeline thing
Any other workaround u could think of? And thanks for the event
My idea is to make an array full of objects with tick rotation position etc and do a runinterval that runs every frame
sheesh.. 91 dynamic properties and their associated DB server cache objects/SQL rows created. that took all day.
needs to be optimized ,its pretty slow
yep you can do that
its what the command community does to do some very cool stuff, without addons
very powerfull on the visual side
man, probably obvious to anyone here, but last time I did anything with scriptAPI dynamic properties werent a thing so it was extremely limited because there was no way to have data persistance. they are amazing. combined with http .. can do a lot
Kinda late, but maybe you still need help lol. Run Set-ExecutionPolicy RemoteSigned in an powershell terminal with administrator (I think you need it, not sure)
is there localisation in scripting? or do you need to hardcode the translations
most ways of displaying text support raw text
world.sendMessage({ translate: "tile.grass.name" })
im trying to animate the first person but when i run it via script api or commands it only runs in the third person
what are you trying to animate?
player
but what about the player
im doing a dual wielding mod
bedrock doesnt support hitting with the offhand so i made an animation almost the exact as hitting using offhand
but when i run it, it animates on 3rd person
held items that aren't attachables are not part of the player model in first person
so can't be animated
so if i made an attachable for the item will it work?
yes
the animation will look different to the vanilla swing though
ohh thats why, thanks
Hey guys I am looking for a coder for my friend's pokemon server if any of you are interested dm me
(it's paid)
on that note, 10ish hours coding today, night all lol
How
Its on the wiki, pretty advanced command stuff
How can I detect what body part the player got hit?
@distant tulip (sry for ping lol)
im pretty sure this was discussed not that long ago.
uh when
recently.
I forgot if it was discussed with me but I don't know
^
you were in the post lol
Does that go with player?
That's a different plain entity
and what is a player
...what
what is a player
bruh wha
But I don't know the exact body part location of the player
figure it out.
The plain entity there he used doesn't have legs and hand or chest
dir = ray origin - entity.location
dir.y = 0
plain = normalize( dir )
plain origin = entity.location
Not the same
but can be used
once u get the plain u can then use that to find the hit location and then based on height we can aprox diff body parts
I mean, if you want to know if you hit the arm, legs, body or head you will need a bit more logic, we are delaying with rotatable cubes in that case.
yea
But if you only need the hit position in the hitbox that way simpler
I didnt say it was, but it could be used for it.
Yeah
but game's ray func already does the ray vs box and also gives u the pos
yeah, i did use that before
so now what me do
just use default thibg
default thing what
ray cast
Error: Is not a function
let players = world.getPlayers()
for (let player of players) {
const getAboveBlocks = world.getDimension("overworld").getBlockFromRay(player.location(0, 5.0, 0))```
on the getBlockFromRay line
oh
anyone knows what this is, I'm 100% sure it's nothing good at all
it means ur code is taking longer to run
Anyway to improve this?
depends on code
Have to sort through your code and see if there are more efficient ways to do certain tasks.
somehow i get warns with jobs aswell
i used debugger and it was showing 30 on avg
even tho i yielded everywhere
I didn't get any warnings but definitely had some spikes showing a lot of resources being used to execute when checking with the debugger. I fixed it.
how did u do that
Probably different reasons honestly lol.
how can I fix it
I've bee stuck on this for ages lol
what u want to do ?
detect if there is a block ontop of an entity
Error: Is not a function
let players = world.getPlayers()
for (let player of players) {
const getAboveBlocks = player.dimension.getBlockFromRay(player.location, { x: 0, y: 1, z: 0})```
@grim raft
I will try it
OH ITS PLAYER BRUH
idk why I used world
that wont work if player in some diff dim
I had a conversation about runJob a little bit ago in a forum someone created. Read up on the conversation to get an idea on how I approached it.
#1365029568670335117 message
[Scripting][error]-TypeError: Object did not have a native handle. Interface property ['type'] expected type: EnchantmentType
im trying to copy enchantments over to another item and im getting this error.
const enchantable1 = item1.getComponent('enchantable')
item2.getComponent('enchantable').addEnchantments(enchantable1.getEnchantments())
Is there any way I can put a FOV on the entity, so that it can only shoot if it is in front of it?
Hm. Perhaps you need to copy the result of getEnchantments to a variable first? This should not be necessary, but I wonder if the result is different.
// declare var item1: ItemStack, item2: ItemStack;
const enchantable1 = item1.getComponent('enchantable');
const enchantable2 = item2.getComponent('enchantable');
const enchantments = enchantable1.getEnchantments();
enchantable2.addEnchantments(enchantments);
@thorn flicker
im having an another issue currently, do you mind helping me with it
I can take a peek
im editing properties on an itemstack and its not saving.
and no, im not dealing with inventories
I think this might have to do with enchantment issue, the edits im doing to the itemstack are just not saving.
const item = new ItemStack('minecraft:diamond_sword', 1)
item.setCanDestroy(data.canDestroy);
item.setCanPlaceOn(data.canPlaceOn);
entity.dimension.spawnItem(item, entity.location)
And what is data?
Can you describe its interface? I assume its canDestroy and canPlaceOn are string[], but it's better to be certain
it is.
okay, it has to do with my object, all properties seem like its returning undefined when im trying to use them
which is weird because im checking their output, and it showing the values.
like, when I use them for the itemstack
like for example, im saving the nametag in the object, and its showing the name value, however when I assign this nametag from the property, onto the item, its undefined
I can confirm your code works when I pass it a simple data stub, so it's definitely not the API there
Yeah, I dont know what im doing wrong though
and yes, im aware that im not sharing enough code, ill just try to piece it together myself then.
Always helps to have someone else do a sanity check 😄
I did data.nametag, not nameTag
I hope you're at least a step closer to finding the problem
so the enchantment issue is unrelated.
back to this.
let me try
no difference.
What API version are you using?
2.0.0
[Scripting][error]-TypeError: Object did not have a native handle. Interface property ['type'] expected type: EnchantmentType (failed parsing interface to Array element [0], failed parsing array to Function argument [0]) at getItemstack (main.js:63)
at <anonymous> (main.js:80)
this is the full error.
I'm having trouble reproducing the error with this snippet:
function useItem(arg) {
console.warn("HI")
const player = arg.source;
const inventory = player.getComponent("inventory");
const item1 = inventory.container.getItem(player.selectedSlotIndex);
system.run(() => {
const item2 = new ItemStack("minecraft:diamond_sword", 1);
const enchantable1 = item1.getComponent('enchantable');
item2.getComponent('enchantable').addEnchantments(enchantable1.getEnchantments());
player.dimension.spawnItem(item2, player.location);
})
return;
}
world.beforeEvents.itemUse.subscribe(useItem);
Not sure if the context you're executing your instructions in is different from mine
so what I needed to do was get the enchantments, map them into a new object, indentical to EnchantmentType and create a new instance of EnchantmentType, and use the enchantment id from the data I saved.
I guess there's issues stringifying the EnchantmentType class and parsing it afterwards.
we can't detect locators location through script right?
why u want to do that
how to get the location of a specific block?
.location @livid elk
block.location property
how can I check if an entity can naturally despawn? (so I don't remove entities with names or other special properties)
thanks!
Theres no detecting that.
Youll have to check if it has a name or not tjen.
oh great... and there's no way to check if an enderman is holding a block
oh wait there is... as a molang query
oh well theres the is_persistent entity filter
no clue how to run that from a script tho
Why is the entity not being rotated?
const dx = target.location.x - machine.location.x;
const dz = target.location.z - machine.location.z;
const yaw = (Math.atan2(dx, dz) * 180) / Math.PI;
machine.setRotation({ x: 0, y: yaw });```
I Just want to spawn stuff there
I don't see a - at dx is there a minus there?
oh nevermind discord bug
math seems to ve corect does it output any errors?
What method can be used to show a player form after closing the chat menu?
I always use "!test" with slight delay 3 second.
if the cancel reason is UserBusy, attempt to open form again
this is more reliable since it always ensures the form to open after closing the chat
though you can now use custom command to do this nowadays, and it even closes the chat automatically
if (response.cancelationReason == "UserBusy") {
return system.runTimeout(() => {
GearShopUI(player);
}, 10);
}```
this will just try re open the ui every 10 ticks until the user is not busy
Oh
Guys how would i make a system that check if a player has a tag and after 3 IRL days it removes the tag
how do i like use irl days in a system
like that
use Date.now timestamps
any examples?
Use Date.now() to store a timestamp of when that tag was applied. Then after 3 days worth of milliseconds (86,400,000), you know 3 days have passed; remove the tag then
You'd probably want to check periodically when to remove the tag, like every minute
yeah
alright thanks
@sharp elbowdo you know where there is any docs on it i cant find Date.now in bedrock wiki or jaylys website
its not a script api thing.
The Date object is a feature native to JavaScript. You can read about it on the MDN docs
its part of javascript itself.
oh right lol
thanks guys
The challenging part is determining when to remove the tag.
Store the timestamp somewhere, compare it with the current timestamp and just check periodically if it's been three days since
Periodically
world.afterEvents.worldInitialize.subscribe(() => {
What name in 2.1.0-beta ??
You can use system.beforeEvents.startup or world.afterEvents.worldLoad
Thanks
system.beforeEvents.startup is for custom components/commands now.
I know
just clarifying, if thats what you are doing.
Ok.
okay.
is there a way to get the players dynamic property when they leave using the playerLeave event?
playerLeave before event
does that work?
swear i saw somewhere that didnt work
yep
made my life 10 times easier
tyty
np
i was mid way through storing the data etc etc lmao
is this for a server or an addon
server
not the NDA one you know of
im basically storing the players island in a structure
so i need their pfid and temp id
yeah, just asking to confirm
that event don't trigger in local words in some cases
ah shit
local worlds*
yeah im using a world to make the whole server
it should work fine for testing
bet ty
your welcome
first time making a skyblock so i just dont wanna mess up the island system
world.beforeEvents.playerLeave.subscribe((data) => {
const player = data.player;
const pfid = player.getDynamicProperty("pfid");
const player_id = player.getDynamicProperty("player_id");
if (pfid === undefined || player_id === undefined) return;
const islandKey = `island${player_id}`;
const island = island_save_coords[islandKey];
if (!island) return;
overworld.runCommand(`structure save island_${pfid} ${island.bottom_corner.x} ${island.bottom_corner.y} ${island.bottom_corner.z} ${island.top_corner.x} ${island.top_corner.y} ${island.top_corner.z}`)
console.warn(`✔ Saved island_${pfid} for ${player.name} on leave.`);
})
``` this is my plan for storing it
saving*
why do you need to save it tho
im having it so that the max amount of islands will be the amount of players online
so it cleans up
so like plots
cuz if u think about it these islands are gonna have loads of entities
not sure i fully understand but alright
you can use structure manager btw
native method for structure stuff
basically there can be max 20 people on at 1 time for the server right
i dont want it so that when a new player spawns it just spawns an island like 1k blocks away form the last person that joined, i want it so that it spawns the island in one of the 20 slots available
then when they leave it saves everything on their island including entities and loads it back in the available slots when they join back
my idea to save lag^
oh, so you are removing them when they leave
and having thousands of entities
yeah
wouldn't that be bad for performance
i dont feel like learning this 😭
no?
its only saving and loading on join and leave
plus max island size of 64x64
eh, it is not complicated
word.structureManager..createFromWorld(
"mystructure:test",
player.dimension,
from, //vector3
to, //vector3
{ saveMode: StructureSaveMode.World },
);
ima jus use a command for now then switch later
i seen that in the server lol
look great
i got the system to work flawlessly
import * as mc from "@minecraft/server";
const { world, system } = mc;
const TIME = 0.1;
const TIME_AT_POINT = 1;
const allWaypoints = [
{ x: -15, y: -61, z: 47 }, // START
{ x: -19, y: -61, z: 43 },
{ x: -17, y: -61, z: 41 },
{ x: -18, y: -61, z: 36 } // END
];
const stateMap = new Map();
function moveTo(entity, target, speed) {
const pos = entity.location;
const dx = target.x - pos.x;
const dy = target.y - pos.y;
const dz = target.z - pos.z;
const mag = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (mag < 0.01) return;
return {
x: (dx / mag) * speed,
y: (dy / mag) * speed,
z: (dz / mag) * speed
};
}
system.runInterval(() => {
const entities = world.getDimension("overworld").getEntities({ type: "minecraft:armor_stand", tags: ["test"] });
for (const entity of entities) {
if (!stateMap.has(entity)) {
stateMap.set(entity, { index: 0, waiting: false, waitTicks: 0 });
}
const state = stateMap.get(entity);
const target = allWaypoints[state.index];
if (!target) {
entity.removeTag("test");
stateMap.delete(entity);
continue;
}
const pos = entity.location;
const dx = target.x - pos.x;
const dy = target.y - pos.y;
const dz = target.z - pos.z;
const dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (dist < 0.4) {
if (!state.waiting) {
state.waiting = true;
state.waitTicks = TIME_AT_POINT * 20;
} else {
state.waitTicks--;
if (state.waitTicks <= 0) {
state.index++;
state.waiting = false;
}
}
continue;
}
if (!state.waiting) {
const impulse = moveTo(entity, target, TIME);
if (impulse) entity.applyImpulse(impulse);
}
}
});
Can someone explain me why this is not working? And help me with?
I wanted to make path for entity using applyImpulse, but it keeps staying on the first waypoint.
Also it should work that the latest point is the ending one, but points before are optional.
we should get Dimension#getBlocksFromRay
is it possible to change player fov using script?
Use the camera API.
Can someone help me make something similar, like there will be several commands and for one of these I need to redeem a code to redeem and with this I would get Credits to buy things on my server
It does not generate any error, but the entity is not being rotated
I didn't realise that Herobrines Chest UI had been updated to support the inventory (lets go) but I had to add the enchants, glint and custom names to the inventory since I noticed those were missing 
Looking at it now, most people would think it's just a regular chest lol until you "click" in the chests and can't click your inventory slots lol
Please don't repeatedly ask the same question. If you want help create a post in #1067535382285135923 and wait
Ok
Realms or dedicated server? Personally for a system like that Id make a separate http server to handle codes/currency/validation so you can manage them more cleanly, but can't do that on realms
Yeah I turned the inventory part off because of that. Kind of pointless if you can't interact with it or get a button ID for clicking in it
I have a server on Blaze, I just wanted to add these commands to have a store
Not really.. the whole point of having the inventory was that it looked more natural and like the Chest UIs from Java Edition
Fair
You could probably make it interactable but there's no point
Unless you're using it for trading I don't see any other reason
I was making a player trade system with it
Lol yeah
Still ways to work around it though. JSONUI is just a pain, so thankful chestUI is available