#Script API General
1 messages · Page 56 of 1
Its execution timing should make things more efficient.
isn't there a way to add entity filtering to an event subscription?
if typeid != entity return
Pseudocode.
ik that one, but i remember seeing smthn that looked like ```js
world.afterEvents.entityHurt.subscrive(() => {
}, entity filtering here)
but i looked on the docs and dont see it
apparently it improves performance
Pretty sure that not a thing.
yeah thanks
Well would you look at that.
Yes, btw, ask in the proper channel #1067869590400544869
Ty
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
blockComponentRegistry.registerCustomComponent('jay4x:egg_block', {
onTick(event) {
if (system.currentTick % 20 === 0) {
const location = event.block.location;
event.dimension.setType("air", event.block.location);
event.dimension.spawnParticle('minecraft:totem_particle', event.block.location); (L 129)
event.dimension.spawnEntity("minecraft:chicken", event.block.location);
}
}
});
});```
what does that mean?
Is that line on setType("air", event.block.location)?
no i put it in the thing its the SpawnParticle
spawnParticle should work
setBlockType instead of setType maybe?
Why do you use the system.currentTick, curious.
One of my friends helped me with it im not to sure the reason why
he uses it for his stuff
You should not. Use the tick component instead.
i am inside of my block
"minecraft:custom_components": [
"jay4x:egg_block"
],
"minecraft:tick": {
"interval_range": [600, 2000]
}, ```
if you want to do it every second it should be [20, 20]
im trying to have it function as a egg so like it doesnt hatch automaticly
thats why i put those numbers
more randomized
Is there a way to check if a block is natural or player-placed? I need to check if a torchflower on farmland blocks are player-placed or grown from a seed
yes ask in resurce packs
they're separate blocks
minecraft:torchflower
minecraft:torchflower_crop
not when fully grown
a fully grown torchflower's ID is minecraft:torchflower. the crop ID isn't what I need since I need to detect if it's fully grown
it's just so dead 
Is there no way to use anything that was only available in 1.18.0-beta anymore without moving to 2..0.0-beta?
No.
darn, I shouldn't have updated my preview version
now I can't work onmy add-on for a week
What are you trying to use
I'm pretty sure I use nearly everything available in scripting atm, so I don't have a choice lol
I'll just move the files I intend to be for the next stable release somewhere else and start updating
ahh that was relatively easy to fix, only had to update world intitialize and knockback scripts
entity.target?
I have a script that adds ticking areas when a player joins the world and removes them when they leave. I have done this to stop the ticking areas continue on the server noone is online
The problem is it seems they aren't loading correctly every time. Essentially the area gets truncated. I assume they are trying to load too quick? (before the world loads properly?) so they get set to smaller areas?
for (const key of Object.keys(DefaultTickingAreas)) {
let ChosenArea = DefaultTickingAreas[key]
const TLocation = ChosenArea.Coords1
const T2Location = ChosenArea.Coords2
const TName = ChosenArea.Name
console.log('Added Ticking Area ' + TLocation.x + ' ' + TLocation.y + ' ' + TLocation.z + ' '+ T2Location.x + ' ' + T2Location.y + ' ' + T2Location.z + ' ' + TName)
joinedplayer.runCommandAsync('tickingarea add ' + TLocation.x + ' ' + TLocation.y + ' ' + TLocation.z + ' '+ T2Location.x + ' ' + T2Location.y + ' ' + T2Location.z + ' ' + TName + ' true')
}
}```
run from
world.afterEvents.playerSpawn.subscribe((eventData) => {
Is there a way to directly get the entity which another entity is riding directly from said entity?
Pick:
(you probably want this one)
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entityridingcomponent?view=minecraft-bedrock-stable
Ah, it's tied to a component.
Adding bodies to my procedural spider.
Previous Videos:
2. https://youtu.be/r70xJytj0sw
All my links:
https://heledron.com/links/
Source Code:
https://github.com/TheCymaera/minecraft-spider
World Download:
Spider Garden: https://www.planetminecraft.com/project/spider-garden/
Ambertry Forest: https://www.planet...
Ah, I like that guy. He literally made an orbital laser, an eerily accurate walking spider, and a custom screen/particle renderer, only using entity displays.
Guys does anyone know how to control .getEntities volume option ?
does .addItem() returns the remainder amount that has not been added?
yeh
aren't there a .tryAddItem() function?
nope
const overflow = inv.addItem(itemStack);
//drop item to the floor
if (overflow)
player.dimension.spawnItem(overflow,player.location);
Doesn't .addItem drop it if they dont have any space left?
No. It just returns leftover in the form of an ItemStack class instance
One sec ima test
Oh, you're right..
It used to throw it on the ground in the previous versions iirc
Hi here. I just want to ask if how do other backpack ui works. Like it can drag item from players inventory to the form. I just guest that it is a chest form. But how does it works? like the draging and putting it all.
its not a chest form i think, there is an entity component that gives them inventory
this is more of an #1067869022273667152 question but here
thanks! i thought, its scripting or json ui something
How can I run commands after a player has joined?
Either use playerJoin or playerSpawn
oh playerSpawn also works?
so something like:
if (!ev.initialSpawn) {}
from jayly docs:
import { world } from "@minecraft/server";
world.afterEvents.playerSpawn.subscribe((eventData) => {
let { player, initialSpawn } = eventData;
if (!initialSpawn) return;
// This runs when the player joins the game for the first time!
console.log(player.name, 'joined');
});
Okay, thanks!
Does anyone have a list of all icons from Minecraft bedrock ( textures/ui/… )
Yup
Download one of the versions and go to resource packs
And then textures/ui/ and have fun
Is it possible to make an island system with script?
A system used on Skyblock servers
that does not have everything
for that you want to install bedrock launcher on pc and look in the version files
also if they are using the textures for a form button texture, then if they just type loading instead of a texture name, then it will use an animated loading texture.
I believe 1.21.40 or 50. The alt is to play from entity.
world.dimension.playSound isn't working either
But this only plays the sound for the player still?
Then runcommand?
Is your volume on 0% ?
I guess vanilla equip sounds don't matter 😔
dimension.playSound work fine
Oh wait. I think you're tripping Koala.
I was thinking of entity.spawnParticle which is gone I believe. or maybe it never existed.
player.spawnParticle (beta)
dimension.spawnParticle (stable)
how to put "0" in playAnimation method?
world.dimension.playSound doesn't work for me
world.getDimension() ?
Did you specify the location, what kind of sound are you playing
Ew, beta.
It'll only be seen by that player iirc
to a variable?
why would I use this
Make sure your sound isn't 0.
ye
dimension is not a property of the world class
world.dimension return undefined
Blast that game volume to 200% to check if it is there
By that I mean, settings -> audio -> make sure it isn't 0.
yeah but with getDimension I need to specify the dimension
pass it through the stopExpression
I had a few instances where I was testing sound and was baffled why it didn't work.
My sound is definitely not off lol
stopExpression: ""0""
Idk this change just seems pretty bad
"v.name=0;"
const dim = world.getDimension('overworld');
dim.playSound(armor.equipSound, player.location);```
so, what if the player is in the Nether?
do I need to do a separate getDimension?
i mean, you could get the dimension class from the player
or where ever you are working on
what does it mean
player/entity.dimension
armor.equipSound —> "armor.equip_generic" ?
it is setting that variable to 0
maybe the problem lies on armor.equipSound
yeah I'm not a fan of this change, I don't get why it was removed
world.getDimension(`${player.dimension.id}`).playSound(armor.equipSound, player.location);
What aren't you just doing player.dimension.playSound()?
it tastes like sarcasm
Because this dude said to use getDimension
bruh

i said world.dimension is not a thing
back in my day
Maybe he shortened it idk
i don't see why
am I deleveling
Is your issue fixed Koala?
yep and now I need to go back through and change every instance of world.playSound
random
Has anyone else had issues where pausing the game will sometimes break anything running on a timer?
in minecraft preview?
or stable
any version with game pausing
not on stable but in preview yes sometimes
Break how?
but it does not break or something just minor lag difference
the timer is completely cancelled
I have a passive health regeneration system for example js //passive health regeneration if(healthComponent.currentValue == healthComponent.effectiveMax) { player.__passiveHealthRegeneration = 400; } else { player.__passiveHealthRegeneration == 0 ? (healthComponent.setCurrentValue(healthComponent.currentValue + 1), player.__passiveHealthRegeneration = 400): player.__passiveHealthRegeneration--; }
I've had this completely stop working between pauses at times
that's not a timer (?), that's just counting how many js frames has been through
Is it possible to move a camera across dimensions? Via scripting?
So far it seems impossible to me, but I'd believe that there's a way I just don't know.
is there a function that detects when you left click a block
A camera can only show things rendered around the player
If you were to move it around another player I mean.
So there would be a player at each location.
world.afterEvents.entityHitBlock.subscribe(({ damagingEntity, hitBlock }) => {
// ...
});```
100000 msgs
For the 100000th time
thanks but i just did it a lil diffrent
entity.playAnimation(s, { nextState: "x", blendOutTime: 0.1, stopExpression: `${"0"}`,
controller: ctrl})```
is it right?
Guys, can someone remind me again if the 'dyeable' component doesn't work on vanilla items
it doesn't? oww man 😔
iirc 'food' component too
Unless it's fixed in the current preview
how to know if minecraft:falling_block entity is anvil
You don't. You guess. Maybe you store every existing anvil in the world and check if a falling block spawns on that particular coordinate.
block.typeID is return undefined. Any reason why?
const { player, block } = eventData;
const eventLoc = block.location
console.warn(block.typeID + ' ' + eventLoc.x + ' ' + eventLoc.y + ' ' +eventLoc.z)
if (block.typeId === "minecraft:barrel" && eventLoc.x === -538 && eventLoc.y === 112 && eventLoc.z === 1980) {
console.log("Barrel Used ");
return;
};
});```
[main.js] ran with error: [SyntaxError: Could not find export 'Vector' in module '@minecraft/server']
How to solve this?
block.typeId
..... thanks. I missed that
u could use this https://discord.com/channels/523663022053392405/1131984839151714354
but then I don't understand why the scripting documentation has Vector3 as class and even if I import that, it doesn't work
I'm trying to detect if the player moved the camera But this doesn't work
const player_direction = new Map();
const CHECK_INTERVAL = 30;
system.runInterval(() => {
world.getAllPlayers().forEach(player => {
if (red == true) {
const vm = player.getViewDirection()
const previousDirection = player_direction.get(player.name);
if (previousDirection) {
const dx = vm.x - previousDirection.x;
const dy = vm.y - previousDirection.y;
const dz = vm.z - previousDirection.z;
if (Math.abs(dx) > 0.01 || Math.abs(dy) > 0.01 || Math.abs(dz) > 0.01) {
player.runCommandAsync("gamemode spectator @s")
}}}
})
}, CHECK_INTERVAL)
its not a class, its interface for typescript types purposes
then how do I make my script work
getRotation() exist too, right?
This is the file
Is there any application for minecraft bedrock that allows to generate entire packs automatically based on the user's requests?
Make yours using python or nodejs or even if you are that insane,.... bash.
Like M9 said, its not a class, you can't exactly use it. Use the vec3 lib that con made, M9 pointed you to the post.
let plrLoc = player.location, plrView = player.getViewDirection(), runID = system.runInterval(() => {
if (!this || !this.isValid()) {
system.clearRun(runID);
return;
}
if (!Object.keys(plrLoc).every(key => plrLoc[key] === player.location[key]) || !Object.keys(plrView).every(key => plrView[key] === player.getViewDirection()[key])) {
system.clearRun(runID);
// moved
player.sendMessage(`§g[§6§lServer§r§g] §cYou Moved!.`);
return;
};
}, 20);
You can remove the .location part of the snippet above.
why don't you design it, such a system would make content creation fast and low cost, it would no longer require paying programmers. Bridge and other editors would be useless in front of such a system
Bruh
In addition to this, an integrated editing system for each file type generates the content and you can send requests on specific files where the bot intervenes and modifies every particularity requested by the user.
I ain't no volunteer
And i certainly don't do commissions either
My code is closed source until i decide not
So either you make the code that generates the pack by yourself or get a team to help or even just let them make it completely or don't ask me or anyone else to make it.
If there is a tool that already exists and you wanna use it sure but don't go around guilt trippin' people
I am looking for specialized people who can do this, I can finance every part of the product development process. I don't know here to criticize other people's work
can dynamic property affect player's performance? (even the world dynamic property)
@subtle cove
import { world, system, Player } from "@minecraft/server";
import { Vec3 } from "./vector/vec3.js";
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
if (player.isSleeping) {
Player.runCommandAsync("function sleep");
};
if (!player.isSleeping) {
Player.runCommandAsync("event entity @e[type=space:shadow_anomaly despawn")
}
}
}, 5);
system.runInterval(() => {
for (let player of world.getPlayers()) {
let srcLoc = player.getHeadLocation();
const blockList = [
"minecraft:oak_log",
"minecraft:spruce_log",
"minecraft:dark_oak_log",
"minecraft:birch_log",
"minecraft:jungle_log",
"minecraft:acacia_log",
"minecraft:mangrove_log",
"minecraft:cherry_log"
];
let blockRaycastHit = player.getBlockFromRay(
new Vec3(srcLoc.x, srcLoc.y + 0.1, srcLoc.z),
player.getViewDirection(),
{ maxDistance: 10 }
);
let block = blockRaycastHit?.block;
if (block && blockList.includes(block.typeId)) {
Player.runCommandAsync("function block");
}
}
}, 10);
system.beforeEvents.watchdogTerminate.subscribe((event) => {
event.cancel = true;
});
Scripting][error]-TypeError: not a function at <anonymous> (anomaly.js:9)
[Scripting][error]-TypeError: not a function at <anonymous> (anomaly.js:32)
the Player is uppercased. it should be player
The class in the documentation is described as "Player"
but you're trying to run a command on all player
I am playing on singleplayer
Player is a class. you've defined player in for (const player of world.getAllPlayers()) already
try changing all uppercassed Player to lowercased player
Hmm ok I will try
Now it says not a function (anomaly.js:32)
have you reloaded yet? (/reload)
import { world, system, Player } from "@minecraft/server";
import { Vec3 } from "./vector/vec3.js";
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
if (player.isSleeping) {
player.runCommandAsync("function sleep");
};
if (!player.isSleeping) {
player.runCommandAsync("event entity @e[type=space:shadow_anomaly despawn")
}
}
}, 5);
system.runInterval(() => {
for (let player of world.getPlayers()) {
let srcLoc = player.getHeadLocation();
const blockList = [
"minecraft:oak_log",
"minecraft:spruce_log",
"minecraft:dark_oak_log",
"minecraft:birch_log",
"minecraft:jungle_log",
"minecraft:acacia_log",
"minecraft:mangrove_log",
"minecraft:cherry_log"
];
let blockRaycastHit = player.getBlockFromRay(
new Vec3(srcLoc.x, srcLoc.y + 0.1, srcLoc.z),
player.getViewDirection(),
{ maxDistance: 10 }
);
let block = blockRaycastHit?.block;
if (block && blockList.includes(block.typeId)) {
player.runCommandAsync("function block");
}
}
}, 10);
system.beforeEvents.watchdogTerminate.subscribe((event) => {
event.cancel = true;
});
figured out the problem
Bruh, it's like "Make it for me for FREE"
coddy, how are you
such nice meeting you
you remember me
let's move to off-topic
import { world, system, Player } from "@minecraft/server";
import { Vec3 } from "./vector/vec3.js";
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
if (player.isSleeping) {
player.runCommandAsync("function sleep");
};
if (!player.isSleeping) {
player.runCommandAsync("event entity @e[type=space:shadow_anomaly despawn")
}
}
}, 5);
system.runInterval(() => {
for (let player of world.getPlayers()) {
let srcLoc = player.getHeadLocation();
const blockList = [
"minecraft:oak_log",
"minecraft:spruce_log",
"minecraft:dark_oak_log",
"minecraft:birch_log",
"minecraft:jungle_log",
"minecraft:acacia_log",
"minecraft:mangrove_log",
"minecraft:cherry_log"
];
let blockRaycastHit = player.getBlockFromViewDirection({ maxDistance: 10 });
let block = blockRaycastHit?.block;
if (block && blockList.includes(block.typeId)) {
player.runCommandAsync("function block");
}
}
}, 10);
system.beforeEvents.watchdogTerminate.subscribe((event) => {
event.cancel = true;
});
the error lies from player.getBlockFromRay() which is not a function.
i've replaced it
I remember you as a meanie redstone block
bro's request is like making an AI
I'm intrigued by the idea.
and you as a TNT?
I'm fine, thank you for asking.... Yes I remember you, you love to annoy people before.
haha
Aren't you TNT anymore?
My skin still do
Bro getBlockFromRay is actually a property of the player
he said getBlockFromRay
I meant ray
is it?
Yeah
import { world, system, Player } from "@minecraft/server";
import { Vec3 } from "./vector/vec3.js"
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
if (player.isSleeping) {
world.getDimension("overworld").runCommandAsync("function sleep");
};
if (!player.isSleeping) {
return;
}
}
}, 5);
system.runInterval(() => {
for (let player of world.getPlayers()) {
let srcLoc = player.getHeadLocation();
const blockList = [
"minecraft:oak_log",
"minecraft:spruce_log",
"minecraft:dark_oak_log",
"minecraft:birch_log",
"minecraft:jungle_log",
"minecraft:acacia_log",
"minecraft:mangrove_log",
"minecraft:cherry_log"
];
let blockRaycastHit = player.getBlockFromRay(
new Vec3(srcLoc.x, srcLoc.y + 0.1, srcLoc.z),
player.getViewDirection(),
{ maxDistance: 10 }
);
let block = blockRaycastHit?.block;
if (typeof block !== "undefined" && block.includes(block.typeId) && blockList.includes(block.typeId)) {
world.getDimension("overworld").runCommandAsync("function block");
}
}
}, 10);
system.beforeEvents.watchdogTerminate.subscribe((event) => {
event.cancel = true;
});
[Scripting][error]-TypeError: not a function at <anonymous> (anomaly.js:32)
Oh but what website is this?
Minecraft Server API Analysis
not published yet
also how to fix my problem? If I import the module "dimension" or "Dimension" it says "dimension" export not found
NativeTypeConversionFailed already sent you a fix
-# nice name btw
@distant tulip
?
I finally finish it
it?
Yes
i will assume you meant the chunk loader
Yes
cool
How to spawn signs with text?
how do i detect the splash potion type thrown? I need to detect when a standard water splash potion is used
Has anyone given me a function to listen to a block event?
what event
get sign component and setText
we can't do that
Play places a block
shame, i hope they change that through this "flattening" of many IDs
world.afterEvents.playerPlaceBlock.subscribe((event)=>{
const {block, dimension, player} = event
})
same
hey guys
And this if you wanna cancel.
world.beforeEvents.playerPlaceBlock.subscribe((event) => {
const {permutationBeingPlaced, dimension, player} = event;
event.cancel = true;
})
permutationBeingPlaced
hello
@distant gulch you can set a global var after you finish stuff
Or other things ofc
Send your code so i can give you a more personalized answer
Oop
Mentioned someone else lol
Can you give an example code? Like how to spawn a sign behind the player for example
Fixed it now
private async generateLayer(height: number, startVector: Vector2Interface, endVector: Vector2Interface): Promise<void> {
const startX = startVector.x;
const startY = startVector.y;
const endX = endVector.x;
const endY = endVector.y;
return new Promise((resolve) => {
const generator = function* () {
for (let x = startX; x <= endX; x++) {
for (let z = startY; z <= endY; z++) {
yield;
}
}
resolve();
}
system.runJob(generator.bind(this)());
});
I want to resolve my promise when the iterations have been complete, is this how it works?
Also where did you fully learn js from? I mean I know it but not much
U know math ?
This bot was created by SmokeyStack for the purpose of making a FAQ bot for the Bedrock Add-Ons Discord Server.
To manage entries, please make a pull request on GitHub.
As the Script API is a framework built on JavaScript code, having an understanding of JavaScript is key.
If you are being shown this, then you most likely are a beginner with JS and could use a little guidance.
Videos on Learning JavaScript
Javascript in 1 hour
Javascript Classes in 1 hour
Web Guide:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
Reference Sites:
https://www.w3schools.com/jsref/default.asp
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
https://javascript.info
@ivory bough
The contents.json file is meant to list everything in your add-on for better performance.
Here's a link to a more in-depth description: https://wiki.bedrock.dev/concepts/contents.html
Is the Microsoft scripting documentation best for bedrock scripting or jayly's scripting documentation?
Both
import { world, SignSide } from '@minecraft/server';
const dimension = world.getDimension("overworld")
const block = dimension.getBlock({x:0,y:-60,z:0})
block?.setType("minecraft:sign")
const signComponent = block?.getComponent('minecraft:sign')
signComponent?.setText("text in the front face.",SignSide.Front)
signComponent?.setText("text in the back face.",SignSide.Back)
you learn overtime
learn the basics and start coding
and searching and asking about stuff you don't know
- practice
Programming is like math , the more u practice the more u get professional in it
Also how to get type definitions in mobile? I mean bridge works but, it's buggy
Use Vscode
"mobile"
help with ItemStack, specifically how to find out what item the player is holding and how to set lore and check it.
belated apologies, was sleeping that time 💀
anyhow, everyone's tryna help everyone here either way
ah yes, I love it
[Scripting][error]-Plugin [pack.name - 0.0.1] - [main.js] ran with error: [SyntaxError: Could not find export 'MinecraftDimensionTypes' in module '@minecraft/server']
2.0.0 is awesome
remove 'Minecraft'
Anyways,
import { world, SignSide } from '@minecraft/server';
const loc = world.getDimension("overworld")
const block = loc.getBlock({x:0,y:-60,z:0})
block?.setType("minecraft:sign")
const signComponent = block?.getComponent('minecraft:sign')
signComponent?.setText("hello.",SignSide.Front)
signComponent?.setText("hola.",SignSide.Back)
How to make the sign spawn relative to the player's local coordinates of my choice?
Use a blockVolume, or something along these lines, and get the volume of the blocks inside and in each iteration, increment the blocks checked by one and once it reaches volume resolve
Okay thanks, ill keep that in mind
I'd use ContainerSlot if there's no enchantments or durability thingy needed
import { world, system, Player } from "@minecraft/server";
/**@param {Player} param */
function getMainHand(param) {
const hand = param.getComponent("equippable").getEquipmentSlot("Mainhand");
return hand.hasItem() && hand;
};
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
const hand = getMainHand(player);
if (!hand || hand.typeId !== "minecraft:dirt") continue;
const lore = hand.getLore();
if (!lore.includes("dirty")) {
hand.setLore(["dirty"])
}
}
})
@subtle cove
import { world, system, Player, SignSide } from "@minecraft/server";
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
const location = player.location
location.y = -60
const block = player.dimension.getBlock(location)
block?.setType("minecraft:sign")
const signComponent = block?.getComponent('minecraft:sign')
signComponent?.setText("hello.",SignSide.Front)
signComponent?.setText("hola.",SignSide.Back)
}
})
Bro tysm
uhh, wdym by "spawn"?
I basically meant I wanna place signs using scripts with custom texts
ok, btw, only use the part where the player is used, not entirely with the runInterval
const location = player.location
location.y = -60
const block = player.dimension.getBlock(location)
```specifically just this sample
Hey I used this code but for some reason, it doesn't place a sign I set the location.y to location.z =2 and replaced getComponent("minecraft:standing_spruce_sign")
console.warn(BlockTypes.getAll().filter(p=>p.id.includes('sign')).map(e=>e.id))
?
just to get a list of all available block types
Spruce standing sign is the new spruce sign identifier
?
But how to fix the code not working? The code you gave gives no errors but it doesn't place a sign
try block.setType('spruce_standing_sign')
yo
Ok
@distant tulip
world.afterEvents.entityDie.subscribe((event) => {
const { deadEntity } = event
const variant = deadEntity.getComponent('minecraft:variant')
const dimension = deadEntity.dimension
if (deadEntity.typeId === 'minecraft:player' && variant?.value == 0) {
let { x, y, z } = deadEntity.location
const inventory = deadEntity.getComponent("inventory").container
const graveEntity = dimension.spawnEntity('bleach:corpse', { x, y, z })
const graveInventory = graveEntity.getComponent("inventory").container
graveEntity.nameTag = `§c${deadEntity.nameTag}§r \n R.I.P`
graveEntity.addTag(deadEntity.id)
for (let i = 0; i < 36; i++) {
const item = inventory.getItem(i)
inventory.moveItem(i, i, graveInventory)
}
const equipment = deadEntity.getComponent('equippable')
let i = 37
for (const slot of equipmentSlots) {
const item = equipment.getEquipmentSlot(slot).getItem()?.clone()
graveInventory.setItem(i, item)
equipment.setEquipment(slot)
i++
}
deadEntity.triggerEvent('bleach:get_plus')
deadEntity.runCommand('gamemode a @s')
}
}
);```
I want to tp `deadEntity` to the death cords
when it dies
You can't do that
(It's already dead, how tf are you gonna move something that doesn't exist anymore?)
after it dies
You mean after it respawns?
yea
the last part also happens after the respawn
deadEntity.triggerEvent('bleach:get_plus')
deadEntity.runCommand('gamemode a @s')```
world.afterEvents.playerSpawn.subscribe((data) => {
if (data.initialSpawn) return;
// entity respawned, do some code.
});
breh
I just need to get the entity's cords before it dies
isnt initialSpawn for when player joins for the first time?
How to make entity immune to kill command
Yes, that's why i return for that case
okay
Do the same stuff you did, in the entityDie event, and put a global object outside, and within the event do: yourObj[deadEntity.id] = deadEntity.location;
And in the playerSpawn event, retrieve the coords from that object
Do:
player.teleport(yourObj[player.id] || {x: 0, y: 0, z: 0});
I need to put a World.getAllPlayers().forEach, right?
Also make sure to to save the dimension so edit a little bit
Yeah
That code is for a player, so use world.getPlayers() if you want to run it for all
ty
Dont work, But the console does not show errors
It will work
Show your code
L
what
THE PRUGE.
I know there is a limit of 1000 people right? is it because of that?
ah didn't know you guys were chilling here
So may the purge continue
PURGE TIME.

why three dots
cuz the variable is not used
Hello dingsel 
hello
How are you?
good
that s not why it was written event
In the destructure you used event instead of ev
world.getAllPlayers().forEach(player => {
let plrView = player.getViewDirection()
system.runInterval(() => {
if (gm == true && red == true) {
if (Object.keys(plrView).every(key => plrView[key] === player.getViewDirection()[key])) {
player.kill()
};
};
})
}, 30);
you put a runtInterval inside of another runtInterval?
No
Why
One word, actually two, "Just why?"
Plus that looks fundamentally incorrect unless there is another part of it you are not showing
Here, use this:
const views = new WeakSet();
system.runInterval(() => {
const players = world.getPlayers();
for (let i = 0; i < players.length; i++) {
const player = players[i], plrView = player.getViewDirection(), cachedView = views.get(player.id);
if (!cachedView) {
views.set(player.id, plrView);
return;
}
if (gm == true && red == true) {
if (!Object.keys(plrView).every(key => plrView[key] === cachedView[key])) {
player.kill()
};
};
}
}, 30);
system.runInterval(() => {
world.getAllPlayers().forEach(player => {
let plrView = player.getViewDirection()
if (gm == true && red == true) {
if (!Object.keys(plrView).every(key => plrView[key] === player.getViewDirection()[key])) {
player.sendMessage("Gustambo")
};
}
})
}, 30);
That simply won't work
As you are not exactly "caching"
You are checking a value against the same value
Of course it won't flag
Use this, it is optimized for speed & memory and should work.
[Scripting][error]-TypeError: cannot read property 'set' of undefined at <anonymous> (main.js:112)
Line 112:
if (!cachedView) {
//line 112
cachedView.set(player.id, plrView);
[Scripting][error]-TypeError: not an object at set (native)
at <anonymous> (main.js:110)
Line 110
views.set(player.id, plrView);
Nah is there a typeError not an object
I'm just gonna test in the web rq
Oh wait
I used WeakMap not WeakSet, my bad.
(WeakMap needs the keys to be objects)
There, updated again.
Not at function
Line
const player = players[i], plrView = player.getViewDirection(), cachedView = views.get(player.id);
onPlace custom component throw when the world is loaded?
Try this.
const views = new Map();
system.runInterval(() => {
const gm = true;
const red = true;
for (const player of world.getPlayers()) {
const plrView = player.getViewDirection();
const cachedView = views.get(player.id);
if (!cachedView) {
views.set(player.id, plrView);
continue;
}
if (gm && red) {
if (plrView.x !== cachedView.x ||
plrView.y !== cachedView.y ||
plrView.z !== cachedView.z) {
player.kill();
}
}
views.set(player.id, plrView);
}
}, 30);```
Yep, this works
Is there a way to reset the Map? Since it only works the first time But if you want to use it again the address you see has to be the previous one
set the key 'player.id' to undefined
Ty
why does applyDamage not accept 'projectile' as a cause?
hurtEntity.applyDamage(bonusDamage, {cause: 'projectile', damagingEntity:damagingEntity} )
Looks like if I wanted it to be via a projectile, I need to use damagingProjectile: instead
is there a way to get a player's XUID with only scripts? I can use server-net too if needed
no only the id
Maybe xbox live api?
But you will need to build up your own rest api for that
I guess your script is not public
true, there's a request you can make with names to get information like that right?
You should check it out
anyone gonna help this guy https://discord.com/channels/523663022053392405/1337628157057957899
const totalDamageMilestone = {
totalDamage: getScore(player, `totalDamage`),
current_milestone: getScore(player, "mile_dmg_count")
}
switch (totalDamageMilestone) {
case totalDamageMilestone.totalDamage >= 250 && totalDamageMilestone.current_milestone == 0:
player.runCommand(`function milestones/damage`)
break;
}
``` is there a reason this isnt working?
console warn values and see what things are returning
solved, i guess
im trying a different way now
const totalDamageMilestones = [
250,
2500
]
totalDamageMilestones.forEach(milestone => {
for (let i = 0; i <= 14; i++) {
if (getScore(player, `totalDamage`) >= milestone && getScore(player, "mile_dmg_count") == i)
player.runCommand(`function milestones/damage`)
}
})
``` however its running alot more than it should
oh i see the problem
i cant seem to find anything but does anyone know how to get the length of the current array being used in a foreach?
totalDamageMilestones.forEach(milestone => {
console.warn(milestone.length)
if (getScore(player, `totalDamage`) >= milestone && milestone.length == getScore(player, "mile_dmg_count"))
player.runCommand(`function milestones/damage`)
})
use damagingProjectile
-# nvm you fixed it already
get the array instead not the single string of array
totalDamageMilestone.length
but i need the current array length its on
because its cycling through them
yeah but.. I basically just made myself the damagingProjectile
You can't use length in a single string....
I mena yes you could nvm, but it will return the lengths of the string not an array
i didnt mean length there
i meant like the current one its cycling through
const totalDamageMilestones = [
250,
2500
]
totalDamageMilestones.forEach(milestone => {
console.warn(milestone.length)
if (getScore(player, `totalDamage`) >= milestone && milestone.length == getScore(player, "mile_dmg_count"))
player.runCommand(`function milestones/damage`)
})
``` full code
basically if its cycling through 2500 i need it to return a 1
ahh, the current position of that string you mean?
yes
this is me getting rid of this THING...
const array = ['apple', 'banana', 'cherry'];
array.forEach((item, index) => {
console.warn(`Item: ${item}, Index: ${index}`);
});```
Could do something using js const mile_dmg_count = [ 0, 0, 7500, //index 2 12500, ... 500000000, ]
what the fuck
hey hey i made that when i was dookie at js okay
why did you used a function in SCRIPT 😭
The redundancy is insane
^ here btw
Literally command function execution in script using runCommand is insane
works 👍
erm this is going to be more lines than just a bunch of if statements
Clearly less lines is more efficient
eh sometimes easier for certain things e.g. running a load of particles
then elsewhere, call stuff from that class
you see, this can cause a billion imports from different part of the code, but mist often, ít works
native methods always better
quick ≠ performant
perfect
runCommands are wildly inefficient, just saying
yeah well im not some guys who spends his life perfecting it for the minecraft marketplace just for them to decline it bc u forgot to change the texture of a grass block
Would recommend native methods, or using async
i got thousands of them on my realm doesnt lag 1 bit
skull
nah, most marketplace studios make very bad code
and they accept it just fine
if it works and runs why not
i am looking at you Honeyfrost
I used 'em for mine and had delays of up to 5 ms. Removed them, and it went away.
dunno what you're using, but they are not good in large amounts.
I agree
runCommand is an easy way to obliterate your addon
old system
async obliterated in Scripting 2.0.0
I mean
new:)
that is going to gut the game 0.0
good, I guess?
What's the smartest plot system you've seen
runJob OP?
nah it doesnt lmao
oops wrong server
One that did vector calculus for me
I tried and failed to use it, ended up just removing the word async and my stuff that was async still worked
mines better

native methods are the most efficient way to does thing, small things adds up, native methods means your addon can be super large and still be performant(other addons can also work off it too !)
Not mine. it was an old yt vid like 8 yrs ago used old execute and everything. Video didnt reach over 200 views and owner took down
maybe until you add more addons
so now i have a plot addon that works and i have no idea if any 1 else has it.
why would i add other people addons to my realm?!?!
😭
those runCommand hurts my soul
Maybe there addons are posted for people to use
im glad
I hope one day Navi deletes runCommand (all commands are available with native methods)
eh i just make my stuff
for "dumb" people
made realm servers for 6 years hell no
runCommand is so bad, especially runCommand with a function string
that literally cause your game to drop by like 10ms
Have you made a skygen b4 (Those lazy servers that people like)
ik lmao
From what I've seen, function files are really efficient
But coupled with a runCommand they become useless lol
yeah but sometimes the identifiers are different to the scoreboards
I'm talking about the values in the array
ew no only prisons and pvp/pve/rpg
@dawn zealot bro I see that you're using commands, not bad for starting out but the API actually has methods for these things
thanks i didnt know that..
Yeah just go to the Microsoft wiki and look in the API section. Scoreboard is a thing. And the Item stack can be removed too
I agree
It is better to call native methods
it doesnt matter breh
For now the cmds are fine but I would recommend to update it in the future
its justt a realm that runs perfectly fine with 11 people on it
Or if you need help with it just ask here
Hey have you heard of this thing called native methods, I'm pretty sure they haven't been talked about at all before in the last ten minutes
nah i havent
I've made a couple prison servers and rpg servers. Tho i like to make them simple and not add too much modded stuff.
yes
i forgot the word modded existed
Why
who rly calls it mods nowadays
df
const totalDamageMilestones = [];
for (let milestone = 250, i = 0; i < 14; i++, milestone *= 2) {
totalDamageMilestones.push(Math.round(milestone));
}
console.log(totalDamageMilestones);```
also to make u more mad, whenever an entity kills and entity it spawns an entity to say it, it dies too dw
"Addons"
the world modded should be added to automod tbh
😭
This looks.... BLAND
Will bring it up with Sean tomorrow
?
The building.
this just completely gets rid of the other milestones
Bro is using "hypixel pit elemental" map 😭
was made by hypixel
i got permisson like 3 years ago to use it
Lol.
what no u dont get it
its set damage breh the image u replied to does not follow the set milestones
for example number 8 is 500k damage
Hmm
ur number 8 is 32k in the image u sent
I mean in the end you can automate it 😝
not when its set damage
Nahh 😝
coddy is alil goofy today
So What's your fav server you've made guys?
aquiver prisons
had 40k realm members when realms were peak
Can i see some Screen Shots
😤 there we go
nah it's good I'm kinda bored today
look up aquiver prisons on google
Galacticraft
I want to redo my whole life
yeah look on google
i cant
mid get better 🥱 (joke)
no internet
buddy
Hi
we have planets
i have the coolest gameplay
Let me see
its in a supershiftery video somewhere
my eyes
when scoreboards were massive
Minecraft Bedrock Edition Top 5 Best Realms 2021 [Xbox One/MCPE,PS4] #18
Hey guys and today I will be going over the top 5 realms for Minecraft Bedrock Edition. These realms will have game modes such as pixelmon, skyblock, and even Factions. Watch the video to the very end to join all the working realms and get their realm codes!
#5 Dynasty Fa...
found it
number 4
ignore shiftery acting like an npc
My friend has a realm that he won from a giveaway that is locked on a paypal acc that he doesnt have access too and it's for like another 4 years or sum
But he's using it for fucking smp
Nice!
I've actually seen this video b4
Project realms is a minecraft bedrock edition realm that focuses on the popular java gamemode: prisons. The realm is pretty well made and is pretty fun!
discord - https://discord.gg/253FtDpES8
code - https://realms.gg/eJuivJKANU8
not me ^
on aquiver prisons the club had 40k realm members at one point yeah
The ppl came from this vid?
no
aquiver was peak lock down
xbox group posts were the shit
man now i wanna remake that prisons
fuck sake 6am motivation gonna make me do it
I like xbox groups Bc most ppl on there havent seen much of any good servers other than "skygens" Or "Bedrok boxes"
or the "13 looking for gf" posts 🤣
They've evolved
"Need women" "Who can be my dog" "just talking 17+"
oh and like some time in summer the group post were getting botted and xbox didnt fix for like 4 weeks
Like 2022 i think
that was pain bruh
script API where
We are talking Script Api.. 😊
i wanna remake old realm now

Russian ?
Russian*
also i got a quesiton for u
yk on ur chest ui thingy majig
how do i change the title font to minecraftten?
" 100 Flip Resets" what does this mean
🤔
Good question
Oh yeah does anyone know who the discord user "zoro" is?
Tiktok is eaiser getting "follows" on
i send u a link and ur instantly trying to undermine me 🤣
no u get no followers from that
Im not saying your 20k isnt "impressive" but 15k on youtube is prob more inpresive than "Tiktok"
okay? why are we on this topic
#off-topic guys
thats cod timing right there
anyway how do i change it?
Rocket league ain't script API
i meannnnn tewchnicallyyyy
font
Dunno
...
I ain't the json UI guy
dumbest but smartest person i ever met
Anyone wanna change my script api
const location = {
y: player.location.y,
x: player.location.x,
z: player.location.z + 2.5
};
How to covert this from ~~~2.5 to ^^^2.5
world.afterEvents.playerInteractWithBlock.subscribe((event) => {
if (event.block.typeId == "jay4x:gold_block") {
let player = event.player;
event.player?.runCommand(`say interact`);
}
})```
I have no errors but this isnt working?
okay so it works when I place a block on it
const view = player.getViewDirection();
const location = player.getHeadLocation();
const vector = { x: location.x + view.x * 2.5, y: location.y + view.y * 2.5, z: location.z + view.z * 2.5 };```
there's a property player.id for every player. does that mean we could use it to identify them even though if they have changed their gamertag/name?
Yes.
their id is consistent thru worldd
*through names. It changes cross-world.
pretty solid
how to check passable block in getBlock method
sup, is it possible to detect the entity component group via scripts?
alright :v
so, how am i going to detect if the entity is angry, like detecting angry wolf or angry bee's?
No idea tbh...
try using the js world.afterEvents.dataDrivenEntityTrigger.subscribe(ev => { const { entity, eventId } = ev; for (const modifier of ev.getModifiers()) { const { addedComponentGroups, removedComponentGroups } = modifier; } });
Using proprety method i guess
Or just detect whenever player damages that dog
u want it universal ?
if (entity.hasComponent("minecraft:movement") && entity.hasComponent("minecraft:target")) {
console.log("Entity is likely in attack mode (angry).");
}
I checked the wolf file and
eventId = 'minecraft:become_angry' or 'minecraft:become_calm'
added = 'minecraft:wolf_angry' or 'minecraft:wolf_wild'
removed = vice versa
Good ?
either way just use 'target' (beta)
Uhhh. What?
Trying to get target component
So if it s angry it will target someone
Like wolf and vex etc...
Ok umm, first of all there's no target component second of all why bother checking if entity has movement component
That doesn't work.
Sure ?
or won't
^
in short inaccurate
just do this
I feel like someone who has a little bit of json ui knowledge made a chest ui before
I wanna know if there is a chest ui that exists or not...
unfortunately there's no real 'chest' ui with just scripts you can fake drag and drop or drop icons but it's not actually a container
The best example is obviously, Herobrine's one
Ahhh i knew i wasn't having deja vú
Actually no. Someone already made a drag and drop i forgot where it's probably in the #1072983602821861426
What?
like a server form acting like an inventory screen or chest screen with drag and ddrop
Man i feel tired
I can't type as fast as i used to a few weeks ago
Nah i dont see a chest ui
detecting if the entity IS angry or not ( just checking if it is possible )
||yippie, its raining :D||
There is only herobrine's chest ui
Not sure what other ui you are talkin' about coddy
I'm so frickin' tired
I'm gonna go sleep even tho it's 12pm over here
sleep then
just sleep
Its probably in the #1046947779118895114 I'll try to find it for you
sweet nightmares
You saw what I replied?
no ig?
^
this thing?
beta or stable?
^
stable iirc.
good, i just have to learn how it works exactly
step 1:
detect when the entity gets angry, or when the bee become a nectar bee thing and give them a dynamic property,
step 2:
in the entiryDie component, i can detect the dynamic properties of the deadEntity, so i can detect if the bee is angry or nectar or angry + nectar, and detect if the wolf is angry or not
thats all right?
Yeah.
import { world, system } from "@minecraft/server"
world.afterEvents.itemUse.subscribe(data => {
const player = data.source;
const item = data.itemStack;
if (item.typeId == "kaos:grappling_hook") {
const entity = player.dimension.spawnEntity("kaos:grappling_hook", player.location);
entity.addTag(`Grappling:${player.name}`);
}})
How can I change the direction the spawned entity is looking towards the player's direction?
system.afterEvents.scriptEventReceive.subscribe((event) => {
if (event.id == "space:sign1") {
for (const entity of world.getDimension("overworld").getEntities(typeId: "space:anomaly")) {
const player = world.getAllPlayers(();
const message1 = "I am always watching you,";
const message2 ="Always watch your back,";
const message3 = "Don't sleep,";
const random = Math.floor(Math.random() * 3) + 1;
const location = entity.location;
const block = player.dimension.getBlock(location);
if (random === 1) {
block?.setType("standing_sign");
const signComponent = block?.getComponent("minecraft:sign");
signComponent?.setText(message1 + player.name,SignSide.Front);
};
if (random === 2) {
block?.setType("standing_sign");
const signComponent = block?.getComponent("minecraft:sign");
signComponent?.setText(message2 + player.name,SignSide.Front);
};
if (random === 3) {
block?.setType("standing_sign");
const signComponent = block?.getComponent("minecraft:sign");
signComponent?.setText(message3 + player.name,SignSide.Front);
};
}
}
});
You have an extra ( here
Doesn't work
Also here, the parameter should be an object
Oh
And its not typeId, its just type
({})
?
Yes```js
.getEntities({ type: "something" })
Also your player variable is actually an array of players
Is it type or typeId?
For that function, its type
this is pretty complex question, but if anyone knows..
how many buttons() could an ActionFormData() hold? (@minecraft/server-ui)
and how many options could a dropdown() from ModalFormData() hold?
As far as I know there is no limit for any of those components
does the getModifiers really needed?
this will work fine right?
world.afterEvents.dataDrivenEntityTrigger.subscribe(ev => {const {entity, eventId} = ev;
if (entity?.typeId === 'minecraft:bee') {if (eventId === 'angry_bee') entity?.setDynamicProperty('angry', true); else entity?.setDynamicProperty('angry', false); if (eventId === 'angry_bee' && eventId === 'has_nectar') entity?.setDynamicProperty('angry_nectar', true); else entity?.setDynamicProperty('angry_nectar', false)};
if (entity?.typeId === 'minecraft:wolf') if (eventId === 'minecraft:wolf_angry') entity?.setDynamicProperty('angry', true); else entity?.setDynamicProperty('angry', false);
});;```
Anyone have an example code for an sneak input event signal?
system.afterEvents.scriptEventReceive.subscribe((event) => {
if (event.id == "space:sign1") {
for (const entity of world.getDimension("overworld").getEntities({ type: "space:anomaly" })) {
const player = world.getAllPlayers();
const message1 = "I am always watching you,";
const message2 ="Always watch your back,";
const message3 = "Don't sleep,";
const random = Math.floor(Math.random() * 3) + 1;
const location = entity.location;
const block = entity.dimension.getBlock(location);
if (random === 1) {
block?.setType("standing_sign");
const signComponent = block?.getComponent("minecraft:sign");
signComponent?.setText(message1 + player.name,SignSide.Front);
};
if (random === 2) {
block?.setType("standing_sign");
const signComponent = block?.getComponent("minecraft:sign");
signComponent?.setText(message2 + player.name,SignSide.Front);
};
if (random === 3) {
block?.setType("standing_sign");
const signComponent = block?.getComponent("minecraft:sign");
signComponent?.setText(message3 + player.name,SignSide.Front);
};
}
}
});
This doesn't work for some reason
so this error appears from here:
[Scripting][error]-TypeError: Native type conversion failed. Function argument [0] expected type: EntityQueryOptions | undefined at <anonymous> (main.js:92)
const graveEntity = dimension.getEntities('bleach:corpse')```
const graveEntity = dimension.getEntities({ type: 'bleach:corpse' })
ty it worked
and how do I get these with it?
let { x, y, z } = deadEntity.getSpawnPoint()````
the x, y, z
that should work, but obviously only for players
or what u mean
detect the entity in these cords
if its even possible
const graveEntity = dimension.getEntities({ type: 'bleach:corpse', location: { x, y, z } });
use also the maxDistance filter
const graveEntity = dimension.getEntities({ type: 'bleach:corpse', location: { x, y, z }, maxDistance: 1 });
like that
what does it do?
it only gets the entities in a certain distance, if you want only in that coords, it could be 1 block distance
Help
this should be better by using animations
Can't I change the direction an entity is facing with a script?
const graveInventory = graveEntity.getComponent("inventory").container```
now this is saying thats its not a function
ye, get the player rotation, and then invert it, and then apply this to the entity
const rot = player.getRotation();
entity.setRotation(rot);
const graveEntity = dimension.getEntities({ type: 'bleach:corpse', location: { x, y, z }, maxDistance: 1 })[0];
whats does the [0] mean?
cause ur getting an array of entities
That means the first element in the array
first element
k ty guys
👍
function grapplingUse(player) {
const entity = player.dimension.getEntities({tags: [`Grappling:${player.name}`],})[0];
}
I'm trying to make the player jump to the location where the entity is, but it doesn't work.
I want to do it like this but it doesn't work
You are just getting the entity but you are not doing anything to launch the player in that direction
function grapplingUse(player) {
const entity = player.dimension.getEntities({ tags: [`Grappling:${player.name}`] })[0];
if (!entity) return;
const px = player.location.x, py = player.location.y, pz = player.location.z;
const ex = entity.location.x, ey = entity.location.y, ez = entity.location.z;
const dx = ex - px, dy = ey - py, dz = ez - pz;
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (distance === 0) return;
const horizontalDistance = Math.sqrt(dx * dx + dz * dz);
const fx = horizontalDistance > 0 ? (dx / horizontalDistance) : 0;
const fz = horizontalDistance > 0 ? (dz / horizontalDistance) : 0;
const fy = dy / distance;
const force = Math.min(distance * 1.2, 4);
const horizontalForce = force * 0.7;
const verticalForce = force * 0.5 + 0.3;
player.applyKnockback(fx, fz, horizontalForce, fy * verticalForce);
entity.remove();
}
I did this with AI
But it still didn't work as well as I wanted, so I deleted everything.
256 buttons but not sure, as for the dropdowns, ig enjoy?
applying a single knockback will not work if there obstacles
When you say obstacle, do you mean blocks?
system.afterEvents.scriptEventReceive.subscribe((event) => {
if (event.id == "space:sign1") {
for (const entity of world.getDimension("overworld").getEntities({ type: "space:anomaly" })) {
const player = world.getAllPlayers();
const message1 = "I am always watching you,";
const message2 ="Always watch your back,";
const message3 = "Don't sleep,";
const random = Math.floor(Math.random() * 3) + 1;
const location = entity.location;
const block = entity.dimension.getBlock(location);
if (random === 1) {
block?.setType("standing_sign");
const signComponent = block?.getComponent("minecraft:sign");
signComponent?.setText(message1 + player.name,SignSide.Front);
};
if (random === 2) {
block?.setType("standing_sign");
const signComponent = block?.getComponent("minecraft:sign");
signComponent?.setText(message2 + player.name,SignSide.Front);
};
if (random === 3) {
block?.setType("standing_sign");
const signComponent = block?.getComponent("minecraft:sign");
signComponent?.setText(message3 + player.name,SignSide.Front);
};
}
}
});
This doesn't work for some reason. The sign isn't being placed at the entity's location
getAllPlayers return an array of all players in the rowld
getPlayers?
Why does everyone use world.getAllPlayers tho
Nah they both return an array
its in plural so...
Then [0]?
And both do the exact same except you can pass params in world.getPlayers()
Ye
But actually
That would do for one player
also you dont have any reference to determinate wich player you want to target
applyImpulse not working for player?
so either:
for (const player of world.getPlayers()) {
// code with "player"
}```
no
Only for entities
I am actually not adding any multiplayer support on my addon

Use .applyKnockback (it's in vec2 instead of the vec3 so you are gonna need to do some basic math to convert it)
Alright then
[0] is the most straightforward approach but in the long run, it wouldn't hurt to use a for loop
use the getPlayers() filter to get the closest one to the sign
.getPlayers({closest: 1, location: block.location}); // assuming block is a valid block
But then I used world.getAllPlayers for my previous function and it functions properly why does this one not?
.getPlayers() allows for passing entity params, while .getAllPlayers() only returns an array, anyhow, both return an array.
I see no reason for getAllPlayers to exist
Fr
Ayo navi, listen to this man
I think they getPlayers used to return an interator instead of an array
I didn't even include [0] in the previous one or ({ closest: 1 }) and it worked
no
Anyhow i will edit your code
But you need to learn about js basics
here not, maybe your other code you iterated them or selected the first element of the array [0]
Wait but how do I fix my code
Any 1 here good at coding
Dont ask to ask.
const messages = [
'I am always watching you..',
'Always watch your back..',
'Don\'t sleep..'
];
system.afterEvents.scriptEventReceive.subscribe((event) => {
if (!event.id.startsWith('space:')) return;
switch (event.id.split(':')[1]) {
case 'sign1': {
for (const entity of world.getDimension('overworld').getEntities({ type: 'space:anomaly' })) {
const player = entity.dimension.getEntities({type: 'player', closest: 1, location: entity.location})[0];
const random = Math.ceil(Math.random() * messages.length) - 1;
const block = entity.dimension.getBlock(entity.location);
block?.setType('standing_sign');
block?.getComponent('minecraft:sign')?.setText(`${messages[random]}, ${player.name}`, SignSide.Front);
}
break;
}
default:
console.error('Invalid Event Requested.');
break;
}
});```
@ivory bough
But you must learn js basics
I just saved your time a bit
Ok
Or actually alot, but again, you must absolutely learn js basics no matter what
But there are a ton of websites lien w3 schools mozilla and javascript.info but I don't know which one is best
import { world } from "@minecraft/server";
const COMMAND_PREFIX = '/';
const overworld = world.getDimension("overworld");
function runCommandAsync(command: string) {
overworld.runCommandAsync(command);
}
world.beforeEvents.chatSend.subscribe(event => {
const player = event.sender;
const message = event.message;
if (!message.startsWith(COMMAND_PREFIX)) {
const command = message.replace(COMMAND_PREFIX, '');
event.cancel = true;
switch(command) {
// command: checkblock
case 'checkblock': {
const playerPosition = player.location;
try {
const blockBelow = player.dimension.getBlockBelow(playerPosition);
const blockToCheck = "minecraft:end_portal_frame";
if (blockBelow && blockBelow.typeId === blockToCheck) {
runCommandAsync(`/function locationID`);
} else {
// no block have been found
}
} catch (err) {
console.error(err);
}
break;
}
case 'test': {
// test
break;
}
default: {
player.sendMessage(`No such command: ${command}`);
}
}
}
});;```
world.getAllPlayers().forEach(players => {
players.playSound(`random.fuse`,)
})
This should play a sound for all players right?
Not my code.
Watch a bro code js tutorial, it taught me how to start and with lots of trials and reading stuff, i came to be the man i am right now.
But bro code talks mostly about Web development and html in his js courses which I dont know and is not needed
Search up a youtube tut for MINECRAFT
You can't exactly check for messages with "/", also that's pretty ai lookin'
Again NOT MY CODE
Yeah, but he talks about all the basics of js first, like arrays and etc. After that you can watch another tutorial, scripting api.
runCommandAsync(`function locationID`);```
Again, providing feedback
I don't know anything about html and css tho
Yup correct
You don't need them tho
Only watch until about hour 6 or smth
But he uses them through the series
2024 version?
Still you can't listen to mc commands, it won't exactly trigger the event
So use a different syntax other than "/"
Yeah
Ok
Also even if he uses web apis, you only need to look after the stuff like "+=" and other pure js stuff
Instead of
import { world } from "@minecraft/server";
const COMMAND_PREFIX = '/';
const overworld = world.getDimension("overworld");```
Would it be
```JS
import { world } from "@minecraft/server";
const overworld = world.getDimension("overworld");```
Sorry!
import { world } from "@minecraft/server";
const COMMAND_PREFIX = '!'; // fine tune to your liking
const overworld = world.getDimension("overworld");```
Hm no.
The code is suppose to run a function command when someone is standing on the block.
But it's way too chopped
I gotta bounce
Bye
Is it possible to make applyImpluse work for the player?
Is it true that if we use return Inside a loop, it stops running for everyone?
ty
world.afterEvents.playerInteractWithBlock.subscribe((event) => {
if (event.block.typeId == "jay4x:gold_block") {
let player = event.player;
event.player?.runCommand(`say interact`);
}
})```
why does this only work when I place a black on it
If you want empty hand use before event.
How whould i go about making it if someone walked or stood on a block a command would run
Why player.dimension.getBlockBelow() not detecting water?
no
cause getBlockBelow needs an argument
getBlockBelow(location: Vector3);
-# includeLiquidBlocks
yup
that just causes errors
world.beforeEvents.playerInteractWithBlock.subscribe((event) => {
if (event.block.typeId == "jay4x:monitor") {
let player = event.player;
event.player?.runCommand(`say interact`); *LINE 62*
}})```
#1067535608660107284 message
world.beforeEvents.itemUse.subscribe((data) => {
const player = data.source;
switch (data.itemStack) {
event.player?.runCommandAsync(`scoreboard players add @s MoneyStolen 150`);
}});```
wait thats itemUse im trying to interact with a block
You need to wrap it around system.run.
import { world, system } from "@minecraft/server";
console.log("loaded")
system.runInterval(() => {
for (const player of world.getPlayers()) {
const blockLocation = player.location;
blockLocation.y -= 1;
const block = player.dimension.getBlock(blockLocation);
if (block && block.typeId === "skygen:plotp") {// change this to the block eg minecraft:gold_block
player.runCommandAsync("function locationID")// anything you put in here it will run eg a console.log or in you case the CommandRunning
}
}
}, 20);// the '20' is the tick delay```
No work
I think it's the block location.y-=1 because you're trying to reassign something that can't be reassigned
How to give a player a dynamic property every 15 ticks if they stand at a certain location without causing lag?
that should not cause lag
well how could i make it
Reassigning blockLocation is not allowed, but they are changing a value inside blockLocation, wich is an object
That should not be the problem
Change console.log for console.warn and reopen the world or do /reload
If nothing appears on the screen, that means your script is not even being used
@knotty plaza Wdym can i change that pack while i am in game?
Not exactly, but you can edit the script and it will be applied in game after /reload
But your pack has to be inside development_behavior_packs
just funcions and scripts will be reloaded if they are in the development folder
i got it dw
try this
world.beforeEvents.playerInteractWithBlock.subscribe(({player, block}) => {
if (block?.typeId === 'jay4x:monitor') {
// interaction event;
system.run(() => {player.runCommand('say Player just interacted with a Monitor block!')});
};
});;```
the function isn't working cuz it may have an issue somewhere in the commands it has
How to give a player a dynamic property every 15 ticks if they stand at a certain location?
inside of a runInterval, u can give it a timer that will make it works every 15 ticks
example: system.runInterval(() => { *** }, 15);
i dont want 4 different system intervals though
alright lemme show u another way to do it using only one interval
i want 3 different gens with different times
but id have to do multiple intervals for that
Yao
u need only one
let count = 0;
system.runInterval(() => {
count++;
if (count %100 === 0) { }; // 1s & 20 ticks
if (count %50 === 0) { }; // 0.5s & 10 ticks, do %75 if u want to make it works every 15 ticks
});;```
Wouldn't it be easier to create a channel that's just a general?
We went over our chocies and decided removing members is the way to go.
what in the skibidi toilet are you griffin about?
These sigmas are giving ratio L's to other beacuse there are too many alphas associated with this thread
This picture is on the bedrock wiki. What app is is? Seems like it might be useful
NBT Editor if I remember right
how do I get an authtoken to send HTTP requests with?
universal minecraft editor/tool
wdym?
in general you dont need tokens to make requests
in HTTP Docs they show an example of sending data locally and storing it with an auth included in the header
there we go
Thats just an example
You can build a http server that doenst require auth
😭 well that's definitely useful to know
this is my first time dipping into server-net and HTTP so it's very new to me
well not first but first beyond just copy-pasting
You should read about how web servers work before that
this was in fact very helpful. Thank you!
How whould i do something like :
/scoreboard players operation ${selectedplayer} locationID1 = ${mainplayer} locationID
why do i get a not a function error with if (block.isValid())?
.isValid.
its a method
isValidmethods on various classes have been changed to read only properties
If the content log is throwing that function one can assume they're using Preview then 🙂
-# https://feedback.minecraft.net/hc/en-us/articles/33873681034637-Minecraft-Beta-Preview-1-21-70-20
gotcha 🙂
how to get passable block at a location
its been saying trying to access location ... which is not in a chunk currently loading or ticking i only want the function to run when its in simulation distance
try {
// block code
} catch {
// block is unloaded or another error
}```
Be like: **Am i a joke to you?**
try {
const block = (dimension).getBlock({x: 0, y: 0, z: 0});
if (!block.isValid) return; // assuming it is used in a function & you are on preview, however if you are not on preview use .isValid()
if (!block.isAir || !block.isLiquid) return;
// block is passable probably.
} catch {
console.log('Block is unloaded or minecraft is smoking crack or you are coding at 3am and forgor to edit the script accordingly.');
}```
what about tall grass and others?
closeAllForms is beta?
Probably
just edit the if statement to:
if ((!block.isAir || !block.isLiquid) && !passableBlocks.includes(block.typeId)) return;
And define an array named passableBlocks and add all typeIds of passable blocks.
dont think so
its in server-ui 1.3.0
so it isn't
import { system, world } from '@minecraft/server';
import { ChestFormData } from './extensions/forms.js';
world.beforeEvents.playerInteractWithBlock.subscribe((event) => {
const { player, block } = event;
if (block.typeId === 'minecraft:iron_block') {
testGui(player);
}
});
function testGui(player) {
new ChestFormData('9')
.title('Test Gui')
.button(0, 'Back', ['', 'Back Button', ''], 'minecraft:arrow')
.button(8, 'Next', ['', 'Next Button', ''], 'minecraft:arrow')
.show(player).then(response => {
if (response.canceled) return;
});
}```
@valid ice When I click on the block, the GUI does not open, what is the problem?
I think it's not your addon but I couldn't find it.