#Script API General
1 messages · Page 63 of 1
world.beforeEvents.itemUse.subscribe((event) => {
const { source:player, itemStack } = event;
if (itemStack.typeId !== "minecraft:stick") return;
const entity = source.dimension.getEntities({type: "minecraft:cow", closest:1})[0]
{
system.run(() => {
oi(player)
})
}
function oi() {
const oi = new ActionFormData()
.title("Special Offer!")
.body(`Player id: ${source.id}\nCow Id: ${entity.id}`)
.button("...")
oi.show(source)
.then(({ selection }) => {
if (result.selection === 0) {
uknowme(player);
} //..
})
}
});
error on const entity¿
what error
source anynomys
send the full error
[Scripting][error]-ReferenceError: 'source' is not defined at <anonymous> (gui/interact.js:9)
that's source not defined
there
function oi(source)
ok
same error
You have an extra { before system.run.
scope
it's is in {}
error started on const entity sorce not defined
💀 Why are you putting a function inside a subscribe event is beyond me.
it's works for my other form 😌
Terrible.
world.beforeEvents.itemUse.subscribe((event) => {
const { source:player, itemStack } = event;
if (itemStack.typeId !== "minecraft:stick") return;
const entity = source.dimension.getEntities({type: "minecraft:cow", closest:1})[0]
{
system.run(() => {
oi(player)
})
}
});
still same error
Why are you passing in player and not source?
oh wait
still same error
const entity = source.dimension.getEntities({type: "minecraft:cow", closest:1})[0]
this line gives error
👆
Whats that even for?
You know what, please open a post.
And repost your problem there.
world.beforeEvents.itemUse.subscribe((event) => {
const { source: player, itemStack } = event;
if (itemStack.typeId !== "minecraft:stick") return;
const entity = player.dimension.getEntities({ type: "minecraft:cow", closest: 1 })[0]
system.run(() => {
oi(player)
});
});
function oi() {
const oi = new ActionFormData()
.title("Special Offer!")
.body(`Player id: ${source.id}\nCow Id: ${entity.id}`)
.button("...")
oi.show(source)
.then(({ selection }) => {
if (result.selection === 0) {
uknowme(player);
} //..
})
}
@chilly moth take this
I fixed everything
ok let me try
- you had extra unnecessary
{}brackets outsidesystem.run - you had function inside event (idk it works but looks weird)
- you already defined source as player, but your still using the source variable
can someone help me solving this strange issue?
basically the database works fine for me, but for other people, that got better specs than mine, creates a lot of lag
(read all the chat) #1252014916496527380 message
Does anyone see any error in the following code? When I enter a world the game gives me an error:
Sorry I sent the file, but Discord won't let me paste the code because it's too long and I don't have Discord Nitro xd
.
The error that appears to me is the following:
[Scripting][error]-SyntaxError: Could not find export 'Vector' in module '@minecraft/server'```
[Scripting][error]-Plugin [§aEXPANSIVE NATURE V1.2 BP - 1.0.0] - [main.js] ran with error: [SyntaxError: Could not find export 'Vector' in module '@minecraft/server']```
Vector doesn't exist in server anymore
the manifiest :
{
"format_version": 2,
"header": {
"name": "§aEXPANSIVE NATURE V1.2 BP",
"description": "§bBy Yimmplay",
"uuid": "14767ef3-6ddf-494c-9ecf-a857243b7ccf",
"version": [
0,
0,
1
],
"min_engine_version": [
1,
21,
60
]
},
"modules": [
{
"description": "§bBy Yimmplay",
"type": "data",
"uuid": "f81c088d-2a51-4530-871d-4539006c199f",
"version": [
0,
0,
1
]
},
{
"type": "script",
"language": "javascript",
"uuid": "5e8cbccc-17c5-43b7-94a7-e21cdecdcaf9",
"entry": "scripts/main.js",
"version": [1, 0, 0]
}
],
"dependencies": [
{
"uuid": "7fdd5740-e53e-4bb4-8aeb-a7cd0892d52b",
"version": [
0,
0,
1
]
},
{
"module_name": "@minecraft/server",
"version": "1.17.0"
}
]
}```
Either just use the normal math way or use a bundle.
Should I import the math module?
or how or use a bundle, I don't understand what the latter is
There's no built-in math module
Basically combine every js file into one. I have the bundled file hosted here if that's what you're looking for https://jaylydev.github.io/scriptapi-docs/assets/meta/math/latest/minecraft-math.js
So I have to put the module in the manifest and after putting it, import it into the script, right? Would that solve the error?
Nono, it's not... Just check jaylys post
more details there....
Yes, I just saw it but I don't understand anything
like with how the host id is the same on worlds , is it the same on realms too?
yes
do you guys actually bundle your scripts?
tried it once and i didn't feel comfortable using it, lol
maybe this more faster looping then for (loop)?
const player_name = ["Nandog","Dimdog","Herdog","Ferdog"];
let length_ = player_name.length;
while(length_--) player_name[length_];
tested in node js environment
why did you say so tho?
Uhhh...
donothing machine
Test thousands of elements as well
um, i know from some more advanced people, which qjs looping is the fastest
it performance gains is context dependent
Whats the best way to prevent block placing since theres no before player places block
Adventure mode
Nope cant do that using addons i know theres a way
I made every block in gane thats not listed on my map entirely unbreakable
??
there is playerPlaceBlockBeforeEvent
There is cause its not shownn on scripting pages
if you want to prevent block placing just do event.cancel = true;
Ok ty i didnt see this before
What parameters does it grab
Sweet no break no place and i got a debugger tool that i need only put in slot 9 to not be effected
Pin into PlayerPlaceBlockBeforeEvent canceling event
Is it possible to display blocks for only a specific player on bedrock dedicated servers using script API
Or in general, is it possible to only apply changes to the world or other things only to a specific client(s)? Can I somehow directly modify the packet data before it’s transmitted to the client maybe
@ivory bough dont go fishing for help, especially in unrelated channels.
You can't modify packets, you can only cancel them. and you can't display blocks for only a specific player using script API, don't think it's even possible with addons
K
it should be using 3rd party server software, i’ve seen it be done plenty of times but i guess you can’t do it w/ scripts
I'm reviewing some git repos to understand scripting and I'm noticing that people set blocks differently, is there a difference between these two?
world.getDimension("overworld").setBlockType("minecraft:stone");
world.getDimension("overworld").setBlockPermutation(BlockPermutation.resolve("minecraft:stone"));
how to get what items a block drops? (ofc using script api ) i am currently using a list of blocks and their drops is there a way to get all of them without a list or like a list with everything like block.getdrops() or something
can someone help? (100k 'th msg cool )
no.
unfortunately you aren't
setBlockType and setBlockPermutation has a missing parameter, it requires a location
also it's in the name itself, permutation you place a block with a permutation
But in your script you just place an ol' plain stone.
coddy im really confused
what...?
function chunkPos(location) {
// get the relative position within that chunk
return {
x: Math.floor(location.x % 16),
y: Math.floor(location.y % 16),
z: Math.floor(location.z % 16)
}
}```
this returns negative number..... which is wrong....
so someone said to modulus 15 instead of 16
it works but why and why should i do it
I don't get it tho, using 15 or nah will still return negative rho
modulo 15 is a value from 0 15
meh, don't ask me, I'm slow T math..
function mod(a, b) {
return ((a % b) + b) % b;
}
function chunkPos(location) {
// get the relative position within that chunk
return {
x: Math.floor(mod(location.x, 16)),
y: Math.floor(mod(location.y, 16)),
z: Math.floor(mod(location.z, 16))
};
}
fixed
What different between setBlocktype and setBlockpermutation?
mod 15 is a value from 0 to 14. 15 % 15 is 0.
do you have a TPS counter function
Suggestion for @prisma shard
Description
Simple tick event wrapper.
Credits
These scripts were written by Jayly#1397 on Jayly Discord
The former set the block type. The latter got more advanced allowing you to set the block states
how to detect slot using js
player.selectedSlot
selectedSlotIndex
ye
thanks lemme try it out
can i detect if the game is preview or release or beta
Using the editor module yes.
how can i pelase
import, and use it?
can u send me the doc of that
Documentation for @minecraft/server-editor
How to get the inventory of the player?
You ever get into that spot where you just finished a huge part of code and are now thinking now what should i tackle
Yea fr
Player.getComponent('inventory').container
I like my playerComp function no need to get components all the time 1 function and i put it all in a variable
block.dimension.runCommandAsync(/structure load ${structure} ${x + offset.x} ${y + offset.y} ${z + offset.z});
my structure s are in tree folder
how do I edit this?
tree/${structure} ?
/structure load "tree/structure name" ~~~ would be the ingame command.
it's $
You know its still funny i prevented block placing but wood is the only block they will actually get
I know...I'm giving you the ingame command. You just need to translate it to JS string literal.
Ooh i want $
To get a block interact event to work with all anvils do i need to explicitedly state all 3 damage types
How to store all the player's items from inventory in a variable and then temporarily remove all the items and then add them back
Im not sure what your trying to do but i created a function that stores all players inventory among other components to a retrievable varuable
If your talking like it saves the utems for a safe area where you have no items while there that is possibly coddy helped me create a bank system i could tweak that a bit to make it so it creates another property removes all items saved to property when conditions a are nent then readds tonplayer when condition b is met
let me write something
Im actually writing a cool thing they might be refferring to tho its hooked into my built in systems
How do i make a video snippet on my computer
Nvidia control psnrl?
import { world, ItemStack, Player, system } from '@minecraft/server';
interface Items {
slot: number;
itemStack: ItemStack;
}
let inventories: Map<string, Items[]> = new Map();
function withdraw(player: Player) {
system.run(() => {
const save = inventories.get(player.name);
if (!save) return player.sendMessage('No Saved Inventory Found');
const container = player.getComponent('inventory')?.container;
if (!container) return;
for (let item of save) {
const slot = item.slot;
const itemStack = item.itemStack;
container?.setItem(slot, itemStack);
}
inventories.delete(player.name);
player.sendMessage('Inventory Withdrawn');
})
}
function deposit(player: Player) {
system.run(() => {
const container = player.getComponent('inventory')?.container;
if (!container) return;
let save = [];
for (let slot = 0; slot < container.size; slot++) {
const itemStack = container.getItem(slot);
if (!itemStack) continue;
save.push({ slot: slot, itemStack: itemStack });
container.setItem(slot, undefined);
}
inventories.set(player.name, save);
player.sendMessage('Inventory Saved')
})
}
const prefix = '!';
world.beforeEvents.chatSend.subscribe(data => {
const player = data.sender;
const message = data.message;
if (!message.startsWith(prefix)) return;
data.cancel = true;
switch (message) {
case '!deposit':
deposit(player);
break;
case '!withdraw':
withdraw(player);
break;
default:
player.sendMessage('Invalid Command');
}
})
@ivory bough
no nvidia overlay if u have nvidia graphics
I think i have geforce
yeah u can do alt+f9 to start recording and click it again to stop
then click alt+z and you'll see the overlay pop up u can see all ur recordings and stuff
should look liek this
on the left
I hit alt f9 said a supported game is req for this feature
I believe so let me check
get the new nvidia app it was on beta before so maybe u have the old geforce now thing
app looks like this
1 sec there was a update button in the app
oh okay
Anyways i created something cool tho so im happy
nice 👍
ok i saved recording how do i share it
just click alt z
you can click the gallery open a vid and bottom left right next to trash can there's a folder icon
click it and drag ur clip into chat
crap its to big
nice
@humble lintel are you able to help me with the code you helped make i gotcquestions sndstuff
waht u need help with?
idk how to make animations 1 and 2 i need to learn it so i can get it to work with my built in systems
also chat gpt suggests i can make a exe file in my bp to get it to auto generate all the items.json i need
like the animatiosn from the wand script?
Yes and also some other questions
Can we voice chat
Sure
Im going to eat im undecided if i want to build this exe thats a little out of mybrealm of knowledge or bite the bullet and build all items manually
you can use python or node.js, or batch, tell chat gpt to make you a code of one of those, exe files take a bunch of complicated stuff to make
Not python cause python is a bad language its easy to learn sure avoid using it tho
If i use bridge i should put it in its project folder right
I don't think bridge. can run code, it's only an IDE
oh I forgot bridge saves your project locally, well then you can do that
@unique acorn how hard is it to learn this cause as im going for it and software dev i want to understand the code that im running
depends on the language
i want a second pair of eyes before i let a exe file do stuff to my project
A bit late but I added this feature for v1.21.60/70 packs, try it and see if it works - https://github.com/JaylyDev/interpreter/releases
You create a startup script via /function interpreter/starup or something like that (it has the word startup)
w jayly
can we translate a .nameTag?
that isn't an exe, and it's safe
I know but the plan is to make it into an exe if i ever get the dame exe converter to work
you can run it using node? no need to go thru all the trouble of converting it to an exe
no
it happens
Grr it didnt work im glad i ran it on a copied folder
How can i take the xuid of a player in my bds by script??(ive tried sending a extenral request to a third party api that offer xbox name to xuuid but i still cant figure out how to do that)
At this point idk if someone can answer me lol
Grrrrrrr everything but updating the item_textures.json file works
i want someone other then ai help break down the risks when i use this in my real project and maybe fix its ability to update item_textures.js i want to avoid breaking my bp again
Anybody have any damage detection system that is accurrate? When an entity dies entityHurt will always just be the damage dealt, not the actual damage dealt. My old system I used to correct this seems to have imploded and has some pretty big inconsistencies. After looking over my options, I've currently rewritten it to use the entityHealthChanged event to store the old health value, then system.run in the entityHurt event to get that value in the next tick before running all my calculations
you could run a check on its hp before i mean i run my hp threw scoreboards replacing vanilla you could try that
world.afterEvents.entityHealthChanged.subscribe((eventData) => {
const entity = eventData.entity
entity.__oldHealthValue = eventData.oldValue;
})
world.afterEvents.entityHurt.subscribe((eventData) => {
const damageSource = eventData.damageSource;
const hurtEntity = eventData.hurtEntity;
const damage = eventData.damage;
const cause = damageSource.cause;
const damagingEntity = damageSource?.damagingEntity;
const health = hurtEntity.getComponent('minecraft:health').currentValue;
system.run(() => {
world.sendMessage(`DAMAGE:${damage} HEALTH: ${health} PREVIOUS HEALTH: ${hurtEntity.__oldHealthValue}`);
})
})```
that doesn't work, the value will always be the value after the entity was hit
so then you're left with trying to find a way to store the previous health value
give it a health score that is equal to its health you can use logic so when its hit it checks its score before it sets it
my old system was setting temporary properties in every single player spawn/entity load event first and running off that
i have a way more complex system due to the fact i gutted vanilla hp so i know scores works as i had to make sure the skill xp i get doesnt give more then remaining
I mean the simplest solution is to just not use a temporary property that gets reset on reload
then the health value will always be correct and will get set appropriately on the first hit
I'm just being stubborn and don't want to save that data
Can someone look threw this i just want to be sure i wont mess up my project using it
just make a copy of it
I already tested it on a copy but i want to be sure tgeres not in game logic i may break
then paste it back into your add-on location and test it
Can i detect air in a break or interact block event if each elemental alter is opened by interacting with a block of its element in a certain area air is kind of hard
system.runInterval(async () => {
for (const player of world.getAllPlayers()) {
const { x: locX, y: locY, z: locZ } = player.location;
system.runTimeout(() => {
player.onScreenDisplay.setActionBar(`Position: ${Math.trunc(locX)}, ${Math.trunc(locY)}, ${Math.trunc(locZ)}`);
}, 2);
}
});```
Why is the position not acccurate with actual player coordinates shown on the hud screen?
You need to floor/ceil it, not just trunc
k
I tried using hasComponent('minecraft:can_destroy_in_creative')
but it always run false
thanks so much it working now omg
Do i floor along with trunc
Math.floor works fine as i want thanks!
Because that doesn't exist.
Weird, I found that on a custom item
Then any ideas?
It's not accessible to scripts.
Oh that makes sense
Pls check docs
How do I check the components that are?
I mean which part docs do I find them in?
@dim tusk hey coddy when you have time can you review some code for me snd figure out why 1 part isnt working
What scrip?
Its not necesarrily a minecraft script its a file manipulation script ill dm you it
let lastTime = Date.now();
let tickCount = 0;
function updateTPS() {
let currentTime = Date.now();
let timeDifferenceInSeconds = (currentTime - lastTime) / 1000;
let tps = tickCount / timeDifferenceInSeconds;
tickCount = 0;
lastTime = currentTime;
return tps.toFixed(2);
}
function tickHandler() {
tickCount++;
if (tickCount % 20 === 0) {
updateTPS();
}
}
system.runInterval(async () => {
for (const player of world.getAllPlayers()) {
player.onScreenDisplay.setActionBar(`TPS: ${tickHandler()}`)
}
})
why does this not work
shows error
'not a valid function'
I used this TPS counter
and it shows error
Python?
ccoddy do you have a tps counter function, please
Wait... This isn't Minecraft script? Just general accessing files using javascript?
off topic
oh @distant tulip
can u see what the issue
its still a script its still used for my minecraft bp just not in minecraft
Actually Minato is correct it's not Minecraft script but javascript outside of Minecraft sooo...
Anyways. I'll just go in dms
sorry i can't help right now, was going back to sleep
it is 6 AM
ah
still theres no general scripting channel so this is the only channel where ppl are likly to even know
@dim tusk pls help
Did you try debugger?
wahat
i try in minecrafft
let lastTime = Date.now();
let tickCount = 0;
let currentTPS = 0.00;
system.runInterval(() => {
const currentTime = Date.now();
const timeDiffSec = (currentTime - lastTime) / 1000;
currentTPS = tickCount / timeDiffSec;
tickCount = 0;
lastTime = currentTime;
}, 20);
system.runInterval(() => {
tickCount++;
for (const player of world.getAllPlayers()) {
player.onScreenDisplay.setActionBar(`TPS: ${currentTPS.toFixed(2)}`);
}
});```
I feeel the code
3 runIntervals
ahhhhhhh
what a feel
jokes aside but why 3 runInterval
I mean for the tick increase and player we can do it in one interval
yess
i finally make debug screen in minecraft bedrock!
its a big script
after lot of days finnaly i made it
now i have to just do the JSON UI part
then i'll be done making this addon
It says unexpected token "interface"
His code is in TS, you need to compile it to JS
I fixed it now
how to get all enchants / specific enchant on a item in the player's hand and the level
import { world, EquipmentSlot} from "@minecraft/server";
world.afterEvents.itemUse.subscribe((event) => {
const player = event.source;
const item = player.getComponent("minecraft:equippable")?.getEquipment(EquipmentSlot.Mainhand);
if (!item) return
const enchantComp = item.getComponent("minecraft:enchantable");
if (!enchantComp) return
let enchantments = enchantComp.getEnchantments();
for(const enchantment of enchantments){
player.sendMessage(`enchantment: ${enchantment.type} | level: ${enchantment.level}`)
}
});
how to get like a specifc one like only fortune and its levl
import { world, EquipmentSlot } from "@minecraft/server";
world.afterEvents.itemUse.subscribe((event) => {
const player = event.source;
const item = player.getComponent("minecraft:equippable")?.getEquipment(EquipmentSlot.Mainhand);
if (!item) return;
const enchantComp = item.getComponent("minecraft:enchantable");
if (!enchantComp) return;
let fortune = enchantComp.getEnchantment("fortune");
if (!fortune) return;
const fortuneLevel = fortune.level;
});
ehh What is this type error supposed to mean
Argument of type 'import("c:/Users/xxshe/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/Geki Core V1.0/node_modules/@minecraft/server/index").Player' is not assignable to parameter of type 'import("c:/Users/xxshe/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/Geki Core V1.0/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/index").Player'.
The types of 'camera.setCamera' are incompatible between these types.
Type '(cameraPreset: string, setOptions?: CameraDefaultOptions | CameraFixedBoomOptions | CameraSetFacingOptions | ... 4 more ... | undefined) => void' is not assignable to type '(cameraPreset: string, setOptions?: CameraDefaultOptions | CameraSetFacingOptions | CameraSetLocationOptions | CameraSetPosOptions | CameraSetRotOptions | undefined) => void'.
Types of parameters 'setOptions' and 'setOptions' are incompatible.
Type 'CameraDefaultOptions | CameraSetFacingOptions | CameraSetLocationOptions | CameraSetPosOptions | CameraSetRotOptions | undefined' is not assignable to type 'CameraDefaultOptions | CameraFixedBoomOptions | CameraSetFacingOptions | CameraSetLocationOptions | CameraSetPosOptions | CameraSetRotOptions | CameraTargetOptions | undefined'.
Type 'CameraSetFacingOptions' is not assignable to type 'CameraDefaultOptions | CameraFixedBoomOptions | CameraSetFacingOptions | CameraSetLocationOptions | CameraSetPosOptions | CameraSetRotOptions | CameraTargetOptions | undefined'.
Type 'import("c:/Users/xxshe/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/Geki Core V1.0/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/index").CameraSetFacingOptions' is not assignable to type 'import("c:/Users/xxshe/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/Geki Core V1.0/node_modules/@minecraft/server/index").CameraSetFacingOptions'.
Types of property 'facingEntity' are incompatible.
Type 'Entity' is missing the following properties from type 'Entity': extinguishFire, lookAt, playAnimation, setDynamicProperties, setOnFirets(2345)
it comes from player in form.show(player) here
show(player: Player) {
const form = new ActionFormData()
.title(this.#titleText);
this.#buttonArray.forEach(button => {
form.button(button[0], button[1]?.toString());
})
return form.show(player)
}
how to make a spreading mob (plant like mob that spreads 10 blocks nearby to infected grass or infected sand and spawns ants every 60 seconds also it can spawn different new types mobs depending on how many blocks it has spreaded)
don't add explanation plsss
Issa goofy error with types n’ stuff- you can add a //@ts-ignore before the show line and it will ignore the error.!
i fixed it
Okey dokey
i somehow had a separate node_modules folder with @minecraft/server inside the server-ui folder inside node_modules
...
went to the directory through file explorer manually and perma deleted it

Ah interesting lol
@valid ice , what is the purpose of these @internal type tags in your chestform pack?
class ChestFormData {
#titleText: string; #buttonArray: Array<[string, undefined | string | number]>;
constructor(size = 'small') {
const sizing = (sizes.get(size) ?? [`§c§h§e§s§t§s§m§a§l§l§r`, 27]) as [string, number];
>> /** @internal */ <<
this.#titleText = sizing[0];
>> /** @internal */ <<
this.#buttonArray = [];
for (let i = 0; i < sizing[1]; i++) {
this.#buttonArray.push(['', undefined]);
}
}
Just that they can’t be accessed outside of the class definition
does it actually prevent that functionality or is it just there to hint at the user
The comment stops it from autocompleting
The # before the variable makes it private (doesn’t hide it from autocomplete)
ah okay
guys
does too many system.runIntervals cause lag?
like if I have 20 system.runIntervals, will that cause a noticeable amount of lag?
Depends on what they are doing.
The actual execution of the interval won't cause any noticeable overhead.
But if your function is doing something expensive, then sure.
If timing isn’t terribly important, you can look into using runJob & generator functions to break up code over multiple ticks
How to detect doors every 20 ticks without crashing my game( I basically wanna want to detect doors if in range of player then have a random chance to do stuff if door is found )
Does anyone know why applyDamage wouldn't be firing at all? it's being completely skipped over in execution
well why is it crashing your game? You can really only do dimension.getBlocks and then filter
if (!entity.hasComponent('minecraft:item') && entity.typeId != 'minecraft:xp_orb') {
world.sendMessage(` before : ${entity.getComponent('minecraft:health').currentValue}`);
world.sendMessage(`Damage with retribution ${player.name}`)
entity?.applyDamage(damage, { cause: 'magic', damagingEntity: player })
system.run(() => {
world.sendMessage(`after : ${entity.getComponent('minecraft:health').currentValue}`);
})
}```
I know the pain dude, your asking this from starting of day, still haven't got a reply
i just do a ping, and they get disturbed and tends to just reply the question lol
Are you dying or is something else happening in between?
what
for applying damage
Hmmm
It normally works if I die normally, but if I use a large explosion at a location and then try and apply damage afterwards it never applies
Iframes?
Apply damage can't go past that?
Nope. I faced the same issue.
#879773489601585244 message
Did you test any causes?
I dont think causes bypasses iframes.
Is it possible to detect if an entity has broken a block?
how do i get all tags on a world
entity tags?
yes. example: input was a tag someone who isn't in the game has but it exists, how do I get that tag?
because I'd like to validate if the tag exists on the world
You can't get the tag that who doesn't even exists...
I mean it will lag
Unless you store it's data in a storage like dynamic property
can i update my scripts using /reload if i'm working with typescript
Use runJob.
i so confused why ius it so hard to set the project up smh 💔
so do i have to run npm run local-deploy every time i update my pack ..
any example?
is there any way to create global variables
Guys why does this throw an error? durability.getDamageChanceRange().max??
it works with damage or maxDurability but this one it doesn't.
system.runJob((function* () {
// ... code ...
yield;
})());```
did you make it work?
No. It only works on select vanilla items.
Did you try to use it on custom items? Does it always return the values needed?
Havent tried in a while tbh.
how to get block item variants?
For?
They should be flattened so...just use the block id.
so how can I get it using command
What command?
replaceitem
What?
What do ppl here know about bds and use of databases with them to keep players stuff safe but off of minecraft itself to both improve performace and allow multi worlds
This is goofy but it works lmfao.```js
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {
console.error('Message sent:', message);
console.error('Sent by:', sender.name);
if (message.includes('coddy')) {
ev.cancel = true;
console.error('Lezz Go!');
}
});```
Ooh you answered a question before i asked it i was about to ask if you can detect a players message and how that answered me by accident
Unless coddy is a psychic
@dim tusk are you a paychic
@wary edge hey, I have been awol for a while, did they ever fix the /place running from scripts issue?
Still broken. They added place API though so no more runCommand.
Oh cool, is place api release or beta?
I thought I was dyslexic LMFAO
So now a fully functional bonemeal custom component can be made?
Yeah. Theoretically. Still messing around with my adk lib.
Cool, not sure if I am ready to jump back in yet, but these new changes definitely help get the motivation going.
oh btw, the cancel there hides the chat message if you didn't know.
I knew that
You should do console.warn to seperste from errors
@dim tusk what do you know about bds
that's not the reason I use console.error even if you separated it or nah it's still visible to me I mean I still know if it's an Minecraft error or my error.
I'm out of it. I don't do servers lol
I found out theres a way to put a database to a server that allows you to store values outside of minecraft and even allow multi world syncing
I didn't understand what the documentation is saying
Does it work with run interval?
does getComponent work on custom ones ?
no
blocks? I mean yeah it will but accessible components as of now isn't applicable to the custom one yet. If entities and ItemStack yes very possible.
Also guys, what's does getAllStates() looks like.
like the object if returns? js { "<id>": <value>, "<id>": "<value>" }
this?
Damn nvm.
This is getting out of hand ngl.js const { container: { size, emptySlotsCount } } = inventory;
what does using unsupported runtime []. mean
i dont have ts scripts in my pack!!! wtf!!!!!
double check the manifest
what different between block.permutation.getAllStates() and BlockPermutation.resolve(blockId).getAllStates()
it's too confused
yes thx i had two packs with the same uuid lolol
i have a file like this Commands.d.ts:
import { Player, world } from "@minecraft/server";
import { CustomPlayer } from "../CustomPlayer";
export type CommandParam = { name: string; type: string; optional: boolean };
export type Command = {
name: string;
params: Array<CommandParam>;
aliases: Array<string>;
requiredRank: number;
callback: Function;
};
export class Commands {
_commands: Map<string, Command>;
/**
* Registers a command.
* @param {string} name - The primary name of the command.
* @param {string} prefix - The prefix of the command.
* @param {string} params - The parameter definition string.
* @param {Array<string>} aliases - Alternative names for the command.
* @param {number} requiredRank - The required rank to run the command.
* @param {Function} callback - The function to execute when the command is run.
*/
registerCommand(
name: string,
params: string | null,
aliases: Array<string>,
requiredRank: number,
callback: Function
): void;
}
and i wanna use these docs in Commands.ts, but i can't seem to be able to import any part of it, why
im so confused bro
is there any universal event that runs when you finish interacting with an item? itemCompleteUse only works for items that you actually do have to hold, it won't detect e.g. an ender pearl click, but itemUse will instantly fire when you begin interacting with a golden apple for example
where do i find the debug log file that's generated when u debug scripts that tells u how many ms it took to complete different actions etc.
found it
Are your typings using 1.18.0-beta?
yes pretty sure they are
nvm they not
i think
Can't hurt to double-check the package.json and run npm i
package.json says 1.17.0
.getDynamicProperty("mob") == true) {
is it like
const mob=[
minecraft:wolf]
?
what
dynamicproperties never have any values set to them by default
use components
ur supposed to set the value of dynamic properties urself
wdym
you can manually change the values of dynamic properties
what you're looking for is probably components
if u wanna know if an entity is a mob
I want to get list of mobs to work with
or whatever ur trying to do
and save tgem
What is the broader context of your question?
save mob info like tame etc
Ah, like component info?
try {
mc.world.structureManager.place(`${item.getDynamicProperty('stored_structure')}`, dimension, location)
item.setDynamicProperty("mob", false)
mc.world.structureManager.delete(item.getDynamicProperty("stored_structure"))
}```
And how should this relate to getting a list of mobs (like wolves) to work with?
I guess I am asking, what are you making
what is this supposed to mean
shadow summon
and this
summon a mob and save it's data like name etc and the same mob will spawn when summoned again
And are you (wanting to) using dynamic properties on an item to hold this mob information?
Or it seems like you are using structures to summon the mob in again
This worked for me https://jaylydev.github.io/posts/scripts-bundle-minecraft/#using-external-npm-packages-1
yes
Is there any way to make custom commands in a stable API? Like just a !something that runs a function?
no, you need beta API, however /scriptevent isn't in beta so you could use that
I need a way for non-operators to run the command. Will that work will /scriptevent? I have no clue how scriptevent works or what it is
scriptevent needs operator
What would be the most compact way (string length-wise) to store sets of 3-dimensional coordinates as a string
Must it be a string?
Anyone know how to get the exact x y z coordinates of a blocks location using block.location.
I need to get the exact value
Math.floor(location.x) or location.x.toFixed(0)
not too explicitly necessary but it does have to be a type that’s compatible with dynamic properties
Thanks, i’ll test it out
wym by exact value
block.center() maybe ??
Like the coordinates of the blocks location
they probably mean 29.823782 to 29
because using block.location doesn’t get me the coordinates it returns object object
what
I mean the whole number my bad
owwww, thats what you mean
coordinates for blocks are always integers
destructure it
const { x, y, z } = block.location;
?
@scenic bolt
Ah, I was looking around earlier and didn’t test that, thanks
dynamic properties can store Vector3 locations
but they can’t store sets of them
plus, i said i need it to be as compact as possible
Is there a way I could get the values with just spaces in between and no commas, because I need to use this for a teleport command
i don’t believe vector3 holds any less data than a comma-separated string representation of one’s coordinates does
Store as array then JSON.stringify it.
so you’re asking how you can represent coordinates as a string ..
No I got it
but it’s good that ur implementation worked
Its for connecting two teleporters together, I needed a way to get the location
can i ask why you’re using a teleport command instead of just Entity.prototype.teleport(…)
I am using entity.teleport not a command, I just mix up my words sometimes
a ok
Very frustrating getting these two teleporters to connect lol
Why does it need to be so compact though is my question? But yeah, x,y,z|x2,y2,z2|...would be the most compact.
I want to store the coordinates of all diamond ores placed down by players
I can also store it across multiple identifiers maybe
Like three groups
That’d already get me to a limit of around 7,000 storeable sets of coordinates
i need it for a system where I must broadcast a message in chat when players find veins of diamonds
and it’d be best if they couldn’t spoof those values by purposefully placing down big diamond veins
2nd option is that I somehow precompute the values of naturally generated diamond ores’ locations & save them inside a map within my script, and store mined ore locations inside dynamic properties instead
srry wrong room
lot of edge cases
pistons move the diamond block for example
ah right
is there a custom component for blocks that fires when the world initialize?
I want to send block locations to a Map, but maps restart on server close
I know there are dynamicProperties, but Map are fasters
No.
F
How can I slow down players when they step on a block like soul sand
const block = Player.dimension.getBlock(Player.location);
const movement = Player.getComponent('movement');
if (block?.below()?.typeId === 'minecraft:sould_sand') movement.setCurrentValue(0.0);
else movement.resetToDefaultValue();```
no choice.
oh god
also remember that when you sprint it resets it to default value means it looks glitchy visually

just add a little delay y'know
What about the onstep custom component thing is that an option for runInterval?
it's only for custom blocks tho
ItemDurabilityComponent having issues in version 1.21.62 script 1.17.0?
Yeah, it looks like Mojang messed up the scripts (again).
mc.world.afterEvents.itemUse.subscribe((event) => {
let itemStack=event.itemStack
let Durability=itemStack.getComponent(mc.ItemComponentTypes.Durability)
let Cooldown=itemStack.getComponent(mc.ItemComponentTypes.Cooldown)
let Enchantable=itemStack.getComponent(mc.ItemComponentTypes.Enchantable)
let Compostable=itemStack.getComponent(mc.ItemComponentTypes.Compostable)
let Food=itemStack.getComponent(mc.ItemComponentTypes.Food)
let Components=itemStack.getComponents()
console.warn(itemStack.typeId)
console.warn(Components.length)
console.warn("Durability:", Durability)
console.warn("Cooldown:", Cooldown)
console.warn("Enchantable:", Enchantable)
console.warn("Compostable:", Compostable)
console.warn("Food:", Food)
})
Try damaging the sword first?
It seems to be an ItemComponent issue.
Food doesn't have a food component XD
I think thats a vanilla issue.
Works for me for custom.
I'm screwed, I have an item that needs this, and it doesn't work :d
Hey, everyone
Is there a script that shows the title when going through biomes and dimensions? (I make a Traveler's Titles Bedrock addon)
You mean shows the name of the biome you are currently in??
Yeah
This may help you
https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server.BiomeType.html
System.timeout
system.runTimeout(() => {
floatingText.remove();
}, 9999999999);
im trying to remove a floatingtext which shows the damage i dealt a mob but it removes it too fast i dont know what it is it says its in ticks i even tried 5000000 still removed too fast
i think runTimeout may be running instantly when initialized once
and only then delaying the next iterations
but i don’t tihnk that should happen cos it seems quite identical to runInterval in that case
there is something wrong with remove() method
show more context please
also 99999999 could be the problem as it might not be real number
not really but might be executed immidietely as its too long for MC or something
there is no reason for 2 000 000
ya it’s likely there’s no such limit , after i sent that i realized it may actually the effect duration limit
hey guys! i need some help!
i'm trying to make it so when my dagger reaches the end of it's durability, when it's about to be break, it gets replace with a dagger hilt, i've tried doing something like this, but it doesn't work, any ideas?
onBeforeDurabilityDamage({ itemStack, attackingEntity }) {
const durability = itemStack.getComponent('minecraft:durability')
const equipment = attackingEntity.getComponent('minecraft:equippable')
const hilt = equipment.setEquipment('Mainhand', new ItemStack('v360:dagger_hilt', 1))
if (durability.damage === durability.maxDurability) {
hilt
}
}```
import { BiomeTypes, system, world } from "@minecraft/server";
function getBiome(location, dimension) {
let closestBiome;
for (const biome of BiomeTypes.getAll()) {
const biomeLocation = dimension.findClosestBiome(location, biome, { boundingSize: { x: 64, y: 64, z: 64 } });
if (biomeLocation) {
const dx = biomeLocation.x - location.x;
const dy = biomeLocation.y - location.y;
const dz = biomeLocation.z - location.z;
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (!closestBiome || distance < closestBiome.distance) closestBiome = { biome, distance };
}
}
if (!closestBiome) throw new Error("Could not find biome within the given location");
return closestBiome.biome;
}
const player = world.getPlayers()[0];
system.runInterval(() => {
const biome = getBiome(player.location, player.dimension);
player.onScreenDisplay.setActionBar(biome.id);
});```
yo sorry for late reply but the max is 4294967295 and its still short
never mind, figured it out with onHitEntity lol
like i said you are doing wrong before it bc actual code is never executed bc its too long
how do i make it so its long enough it read
the question is what you are doing wrong
i don't even know what you are doing
code you send is valid and propably never executed
so thats not the problem
world.afterEvents.entityHurt.subscribe((event) => {
const victim = event.hurtEntity;
const attacker = event.damageSource.damagingEntity;
const damage = Math.floor(event.damage);
if (!victim || !attacker || damage <= 0) return;
if (attacker.typeId !== "minecraft:player" || victim.typeId === "minecraft:player") return;
// Generate a random offset for floating text position
const randomOffsetX = (Math.random() - 0.5) * 1.5;
const randomOffsetZ = (Math.random() - 0.5) * 1.5;
const spawnLocation = {
x: victim.location.x + randomOffsetX,
y: victim.location.y + 1.5,
z: victim.location.z + randomOffsetZ
};
// Spawn floating text entity
const floatingText = world.getDimension("overworld").spawnEntity("floating:text", spawnLocation);
floatingText.nameTag = `§4-§c${damage}§c HP`; // Red damage text
// Auto-despawn after 1.5 seconds (30 ticks)
system.runTimeout(() => {
floatingText.remove();
}, 4294967295);
});
i asked chatgpt for help thats why there are so many comments
first of all,you code is not cross dimension, so it doesn't works in nether
ya ik
also is it even showing for a sec? Or its not even showed
maybe you have other code that kills all these entities or something
the problem is not runTimeout, but if you think so then don't remove the entity at all so thats the proof of debug
lemme try debugging
thats what you could do in the first place, before asking 😅 thats how programming works its more of debug than actual coding
only does debug 1
^^
yea, so thats the proof, the entity is not deleted in runTimeout so you have to find different code that does kills entities or removes
ok lemme think
it randomly starts working idk
onBeforeDurabilityDamage({itemStack, attackingEntity}) {
const durability = itemStack?.getComponent('durability');
const equipment = attackingEntity.getComponent('equippable');
if (durability?.damage != durability?.maxDurability) return;
equipment?.setEquipment(EquipmentSlot.Mainhand, new ItemStack('v360:dagger_hilt', 1))
}
Try this?
i already figured it out, but thank you
hmm, is it possible to change the block permutation when its in the inventory of the player?
no.
then, is it possible for the bone visibility be able to use (q.is_enchanted)?
bone visibility can't use other permutations other than block states
well, to make my block item has the enchanted glint thing, i have to do that in the hard way
umm, you already know how to use block placer component
why not just create an item to be able to show that glint.
( detecting if the item is enchanted, saving the item name / lore / durability / enchants and replace the item with a new enchanted one and apply all of those information to it )
I think you knew that there's a glint component right?
well, i have already tried it, a while ago
and still doesn't have the enchanted glint
then it's not possible then or you're doing something wrong
the right one is enchanted, without the glint
You meant the model itself?
yes,
nono that ain't possible if you're using a block model alone.
block item
( replace block item ) thing
still.
the item is enchanted but the model is not,
As I said that ain't possible
model and the glint isn't connected at all.
You need to create own.
in that case, how am i going to apply the glint?
attachables.
( for the block )
if you want to somewhat make your life harder? Make an animated block texture.
sigh
I said it many times but I guess you don't listen.
i can make that but, how am i going to change the block permutation so the glint texture will be applied ( not possible ig )
i know its not possible

This is getting off topic.
I already said that. You can't change the permutation if it's in the inventory.
but i can save everything the item has and replace it with a new enchanted one ( hardcoded )
Then why keep asking if possible in blocks?
just making sure it's 100% not possible
i should save the item information all inside of dynamic properties?
( it is really hardcoded but I'll do my best to make it works )
is there a way to cancel item from losing durability when hitting an entity?
Okay, I'll try this script someday 👍
none, just check the lost durability and put it back to item.
how do i put it back?
+= reduces it, and what puts it back...
-= then since it's damage so more you have more damage
right, thank you so much!
let scrolltype = scrolls.get(scroll);
greatest code in history
erm what is this supposed to mean
type ArmorSet = Record<"Head" | "Chest" | "Legs" | "Feet", keyof typeof MinecraftItemTypes>;
^ type of the object the pair is in
can i give effects w/ inf duration through scripts
do you know why it dont working? (I can't open this form)
replace
switch (itemStack)
to
switch (itemStack.typeId)
@minecraft/server-ui should be 1.4.0-beta or 1.3.0
and what did you name the javascript file
did you leave and rejoin the world
okey
sure
Anyone running a public bedrock server ?
can someone confirm that .addRider(entity) work?
i have the same code, one with .addRider() and the other with ride command, .addRider() didn't work while the command did
also, getRiders return empty array...
Is there a way to check if the source (player) is the owner (tamer) of the entity that's being interacted with? I'm using afterEvents.playerInteractWithEntity
hopefully this helps: https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server.EntityTameableComponent.html
You can compare entity ids
yes!! this is exactly what I needed. Thank you!
Why are you replying to me with this
anyone know a good editor on mobile for behaviour packs
I can't seem to get typings from bridge editor on my browser
im on ios
scripts/Classes/Archer.ts:9:7: ERROR: Could not resolve "../GeneralTypes"
scripts/Classes/Bard.ts:9:7: ERROR: Could not resolve "../GeneralTypes"
scripts/Classes/Rogue.ts:9:7: ERROR: Could not resolve "../GeneralTypes"
why am i gettting these errors when deploying my ts scripts
I don't know ts or what the error means. But are you sure the file path is correct?
^
Try "../GeneralTypes.js"
look at the ss …
I’m hovering over it
it’s a TypeScript file + it wouldn’t let me declare the filetype anyway due to how my project is configured
how are you compiling it
does onStepOn work if the block doesnt have a collision?
you are not stepping on it, so no
so no way to replicate the berry bush?
It needs a yvalue of 4 minimum.
onTick event
or in system runInterval, get all entities, check if the block type at the entity's location is the bush.
Code editor.
I'm not kidding that's the name.
meee, I just used it yesterday.
what does that app do
-# sarcastic?
not sure what i did but it just flips my block lmao
uh
its supposed to give the wither effect
my other block works for that so idk whats going on lmao
Just restart your Minecraft I guess
why would it transform his block though
I dunno, Minecraft thing? I can't really judge since I don't have the block.json
pfft *makes it a feature
are you stable?
yep
if yes then it's probably fixed in preview
I'm not asking you lmfao
me or the api i use?
hmmm. Both
i used it like a month ago and it was fine
yeah to both? it is for marketplace
well im not really sure i used both for testing so it doesnt work in the preview but flips in stable so im not sure
my game did crash though and had to find a work around.
dont try to spawn things and make it ride an entity as soon as it spawns..
tried it in both vanilla and custom mobs, 1.16.0 and 1.17.0 same result
🤷
I'm bored I'm making a land claim
i guess i will use EntityRidingComponent and make my own
lets hope that one is not broken too
ive used that aswell
uh... dude i never seen you release any of your work
ohh yeah imma check that again, so I'll be back.
since I'm lazy to set it up :(
I have many backlogged
the stats, chess, vanilla doors, etc.
i have only one lol
I don't find it interesting to release it since I'm pretty sure people won't use it
so yeah.
-# demotivation 101
meh, i don't give much though on what people say
i discontinued this even tho people really loved it, it is really buggy and it code i a mess
after the 4th re work, i dropped it
world.beforeEvents.itemUse.subscribe(({ itemStack, source }) => {
if (itemStack.typeId === 'minecraft:netherite_axe') {
system.run(() => {
const mob = source.dimension.spawnEntity('minecraft:horse', source.location);
const rideable = mob.getComponent('rideable');
rideable.addRider(source);
for (const ride of rideable.getRiders()) {
console.error(ride.name, ride.typeId);
}
});
}
});```
I can try to recreate it with scratch
-# but not now.
It doesn't crash on me @thorn flicker
yeah
function getRiders(entity) {
const entities = [];
const closestEntities = entity.dimension.getEntities({ location: entity.location, maxDistance: 1});
for (const closestEntity of closestEntities) {
const ridingComponent = closestEntity.getComponent(EntityComponentTypes.Riding);
if(!ridingComponent) continue;
const ridingOn = ridingComponent.entityRidingOn;
if(ridingOn === entity) entities.push(ridingOn);
}
return entities;
}
oh yeah before you say it's not a preview, yes it is, I just hide the debug screen
This is the working one? I mean the alternative one.
loading the game to try
When I compare entities I don't directly compare it thru the entity, I always grab their IDs lol entity1.id === entity2.id
yeah that work too
yep
It seems odd why it doesn't work on you, I mean the rideable component
i am really confused, it started to work now....?
i changed nothing
Best way to check a players inventory for a specific item without having to check every second? And just an fyi this item relies on time
Try every 2 seconds


hi here. quick question. how can i map a button name for example a name of a potion with deatils of what potion i am holding and what is the potions duration
does lore not work with lang keys?
damn
can't believe people use this
it STINKS
hope they reduce the number of characters
Herobrine be like:

😦
where's my beforeDamage event

cool script thing I made. Can you guess what it is?
A bunch of blocks
Fractal!
cellular automata 
its not super fast currently, but does not degrade performance much thanks to runJob.
one more photo 🙂
Awesome!
What's the chat character limit? And also, what's the character limit for Modal form textboxes?
For both?
Is there anywhere the user can paste a large string?
How to use new applyKnockback?
hello. i wonder, how can I translate my code messages? do i need to manually tranlate it or there's another way to do it?
I have an issue
Im about to add something to script that i can not test myself cause its whole thing is around how it works with multiplayer
Idk the best way to test tgat this works lol
Rawtext
world.sendMessage({ rawtext: [ { translate: '', with: [] } ] });```
edit the json ui.
Hmm I need a BP-only solution
none then... Or use chats since it's much longer than ModalFormData
Coddy i need your opinion on something
I fmed you
Have you tried am?
How would I detect if a player has more than one item in their inventory?
Container.emptySlotsCount
How to spawn an entity near the player and the distance being 30-45 and the entity spawning in a valid position and not like surrounded by blocks or spawning inside blocks?
...i think i just realized the joke
That's not a joke actually
what a better one?
world.beforeEvents.chatSend.subscribe((ev, { message, sender } = ev) => {
ev.cancel = true;
console.error(sender.name, message);
});```
literally 1984
how do you get those typings?
That's a very basic code editor app
in the video
It doesn't support Minecraft API only javascript in general
ohhhhhh okay
And the app name is literally "Code Editor"
And yes json, c++, java etc.
i saw something like getComponent in those typings, so thought like, how you got those minecraft api typings
since I already typed it previously it auto complete it like usual editor do.
How to spawn an entity near the player and the distance being 30-45 and the entity spawning in a valid position and not like surrounded by blocks or spawning inside blocks?
it'll be a bit hard
you want to spawn it randomly?
Nah when I want it
I would have used spawn rules if I wanted it to spawn randomly
Wait nvm I don't need it anymore
how do i use sendMessage in an entity instance?
this throw an error
const nearbyPlayers = sourceEntity.dimension.getEntities({ types: 'minecraft:player', location:sourceEntity.location, maxDistance:5 })
for(const player of nearbyPlayers){
player.sendMessage("...")
}
should i use getPlayer and filter them out?
Yeah.
turns out i can use maxDistance and location in getPlayer...
i remember this was not working at some point
sendMessage?.(
hmm? won't that just cancel the message? the player in that case is an entity instance, so sendMessage is not a function
the sendMessage isnt in the entity so it turns undefined and will stop at ?. then wont trigger the function
yeah, but what the point
i wanted the message to get sent, anyway, i used getPlayer, i was misremembering as always
just sharing rare feature in js, thats all
getPlayers sure is better there
didn't know that can be done with functions tbh, so thanks
probably when you're doing just world.getPlayers()
huh
they are different?
to use location property, it has to be dimension.getPlayers
It's dark ash... Wait.
edds has an example pack for thar
block custom component...
onTick applyDamage
So as I said, you can't use it in the world alone Since it gets every player in every dimension sooo.
-# i know you that
it used to be janky like /execute
Musta?
-# bored lang
entity.dimension.getPlayers get only the ones in the dimension?

Yahhh
it make sense
i feel stupid now, lol
It would be cool if there's a world.getEntities() too lmfao
asked gpt if there is any similar stuff to ?.() that i probably didn't know, here is one
~~4.9 is like Math.floor
while /execute was being added, we went crazy how to isolate entities per dimension, horrifying times
~~-1.6 turns -1 ;-;
Math.floor don't do that?
floor makes it -2
there is also x | 0
uhm, thats prob for advanced data managers...
and this
x >> n // Equivalent to Math.floor(x / 2^n)
there is ^= to swap variables
ooo, that one's new to me
I read this yesterday lmfao, I'm surprised too tho I'm not sure if it's actually working.
Tho I can't think of a situation where I would use that
imagine using that instead of temp Variable at school and getting 0 for your answer cause the teacher didn't know
welp, the job was to teach. experienced ones rarely do teaching prob cus advanced features comes with more experimentations and technical skills and schools dont have much time for the students to focus ig
-# mans bored
true
Yeah i managed to fix my block issue.
👍🏽
Perm resolve resolves the default permutation when not defined
is there any alredy done function to get the biome?
Try one of these https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server.Dimension-1.html#example-getbiomejs, note that there are places with multiple biomes overlap
ty
Does anyone know how to create a custom package in JS for other javascript files to use?
Yeah, what's up?
Well, I wanted to create a package containing several custom classes and import them into multiple files import { world, system } from "@minecraft/server"; kinda like this format if possible.
Yeah, that's possible.
https://discord.com/channels/523663022053392405/1325881561656197229 Madlad's custom package.
So, can it connect to a custom package you made on the website?
I've never dealt with such things before, so I have to be honest, I'm not entirely sure what you guys do here lol.
Yeah, you just have to learn about creating your own npm packages.
Or learning in general how to make a JS library.
I'll probably do that then.
Though I'm wondering: will this work for Minecraft on mobile? That's what I'm currently using (for now anyway).
Yeah, if they can install npm packages yeah.
idrk where to ask this but does anyone know the max tex size for particles?
not script api
#1067869590400544869
thanks, did not know it had a general forum bit
Is there a list of all causes of death and their message?
lns 2654 to 2713
can anyone give me ideas on what to code
doom.
doom is everywhere 💀
Minecraft inside minecraft
okay gusy like im not that crazy
does anyone know the event for sending a chat message?
im seeing chatSend a lot both in the stirante and ms docs
that's everything it returns
you can do data.cancel = true to cancel the message from sending
goodluck
i dont think it works
[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'subscribe' of undefined
[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'subscribe' of undefined
[Scripting][error]-Plugin [From the Void - 1.0.0] - [main.js] ran with error: [TypeError: cannot read property 'subscribe' of undefined at <anonymous> (dbg.js:3)
It's beta.
That error would never show if your manifest version of server is beta.
{
"format_version": 2,
"metadata": {
"authors": [
"Dismal"
]
},
"header": {
"name": "From the Void",
"description": "spooky description pending",
"min_engine_version": [
1,
21,
50
],
"uuid": "99fc5662-e2af-4fcf-bc00-71d60024ab8b",
"version": [
1,
0,
0
]
},
"modules": [
{
"type": "data",
"uuid": "14eabfce-6672-4113-96c4-7f7966fb03e3",
"version": [
1,
0,
0
]
},
{
"type": "script",
"language": "javascript",
"uuid": "8b5179cd-3595-49ec-9000-132cbe7f634e",
"entry": "main.js",
"version": [
1,
0,
0
]
}
],
"dependencies": [
{
"uuid": "25ca5987-1660-431c-97a6-6cd9319ea922",
"version": [
1,
0,
0
]
},
{
"module_name": "@minecraft/server",
"version": "1.11.0"
}
]
}
how do i do that?
1.18.0-beta.
instead of 1.11.0
you can't use ChatSend events in stable versions
just change to 1.18.0-beta
also consider setting min_engine_version to [1, 21, 60]
my ms store doesnt work for some reason so i cant update it
not through launcher either
or xbox app
so im stuck on 50

then use 1.17.0-beta instead of 1.18.0-beta
yep
just found that out
[Scripting][error]-ReferenceError: Native function [Entity::tryTeleport] does not have required privileges. at teleportToSafeElevation (utils.js:8)
at <anonymous> (dbg.js:12)
what on earth does this mean
https://wiki.bedrock.dev/scripting/script-server.html#beforeevents-privilege-system
in short, wrap your code in system.run
or use afterEvent
ok
YES IT WORKS
yuppii
is there a way to negate void damage
A good home system
There isn’t one that is decent
(or you can do minecraft inside minecraft 🙏)
can someone tell me how the hell script events work
how do i use them
im so confused
theres no examples 😭
The script subscribe listens for the /scriptevent chat comment
system.afterEvents.scriptEventReceieve.subscribe((data) => {
const id = data.id;
const sender = data.sourceEntity
if (id == "say:hello") {
sender.sendMessage("Hi!")
}
})
import { system, world } from "@minecraft/server";
system.afterEvents.scriptEventReceive.subscribe((event) => {
const { id, message, sourceEntity, sourceType } = event;
console.log(id); // wiki:test
console.log(message); // Hello World
console.log(sourceEntity); // Player object
console.log(sourceType); // Entity
});
world.getPlayers().forEach((player) => {
player.runCommand("scriptevent wiki:test Hello World");
});
(I found this on jayly's website)
also to run this you do /scriptevent say:hello
this ones more doable
like what makes a good home system?
(do minecraft inside minecraft pls)
minecraft is already minecraft tho 😭
remake minecraft using the script api
grab an armor stand, use /camera to make the camera show in 1st person of the armor stand, then remake your own movement system and make sure you are in a void world where you also make your own world generation system, including custom entities and stuff
and make your own damage system, combat system
🙂
maybe, what if you freeze the player using input permission and use applyKnockback to move the player, and you will know which direction using inputInfo
somebody made a world generation system using commands only in bedrock, so it should be possible with scripts too
Is it possible to detect if an entity has broken a block?
player only
😭
I've made an ore vein generator using command blocks before
I wanted to make a system that when the entity breaks a block, in this case it would be a door or glass, the block restores itself across the entire map.
so probably it's kinda cool wish I still had the world
Does anyone know how I can make my scripts continue to work on all new versions of Minecraft?
I think it's editing the manifest
if you're using beta api then you would need to update it, if you're using stable then you don't need to, and yes you edit the manifest.json, currently latest beta version of @minecraft/server is 1.18.0-beta
the versions are good (I assume you're on 1.21.6x)
I think hes asking if there is a way to not update the manifest every time there is un update
I need the scripts to always work, and not have to upload new beta versions over and over again for each update.
The response is no if u use beta