#Script API General
1 messages · Page 123 of 1
Sudan flag
I am alright. how about u
better, I'm slowly climbing back up...
Good to hear
i have no idea, gotta re-code it again
textField needs more than 1
write each thing in different line and look better at the error
Does anyone have previews screenshots about debug-utilities?
the error is telling you that 2-3 parameters are expected line 8 and the function was called on line 4
how can i wait for a structure to be loaded and then run code after its done?
I would just run a runTimeout or waitTicks.
but i need to like wait dynamically
i dont know how long itll take the structure to load as its dynamically changed
It shouldnt take more than 40 ticks.
64x64
from -64 to 200 loading by layer to deter lag
Layer by layer and or block by block still takes in a time
Is there snippets for debug utilities bounding box
Read the docs https://stirante.com/script/debug-utilities/1.0.0-beta.1.26.0-preview.26/classes/DebugBox.html
Documentation for @minecraft/debug-utilities
Dk how to use it, it appears invisible on mine with no error logs
import {DebugBox} from '@minecraft/debug-utilities'
world.beforeEvents.playerBreakBlock.subscribe(data => {
const {itemStack: item,player,block} = data;
if(item?.typeId === "minecraft:wooden_axe"){
data.cancel = true
const dbox = new DebugBox(block.location)
dbox.scale = 5
dbox.timeLeft = 5
}
})
You never added it.
I don't understand
Documentation for @minecraft/debug-utilities
Ohh
what is restricted execution
?
Used to be called Early Execution. Anything in beforeEvents
ahh
Thats not how args work.
Well, how can I do then?
Like this?
import {DebugBox,DebugDrawer} from '@minecraft/debug-utilities'
world.beforeEvents.playerBreakBlock.subscribe(data => {
const {itemStack: item,player,block} = data;
if(item?.typeId === "minecraft:wooden_axe"){
data.cancel = true
const dbox = new DebugBox(block.location)
dbox.scale = 5
dbox.timeLeft = 5
DebugDrawer.addShape(dbox)
}
})
Yes.
function(origin, mandatory_params, optional_params?)
I put mandarory_params or my params name?
It can be anything.
It's a callback, so for however many params you have thats how many params your function should have + 1 for the origin.
Documentation for @minecraft/server
Just for confirmation: I have to put in order origin, mandatory params (one by one), optional params (one by one)?
Dk why it just says addShape is not a function
Oh sorry, should be lowercase, debugDrawer
i had the coordinates opposite
It worked. Tysm
It worked, thankss. Just curious how to adjust it tho using 2 corners
like from vector 0,0,0 to 5,5,-5
It only give sizes
Might gonna use some math
Yes.
All you have to do is set the corner to the least coord, then set the bounds using the offset
Oh I see
I was thinking to use lines instead
I gotta study this more
Thanks again
Idk how bounding works
Like an offset of the whole box?
No its basically the size.
Her does anyone know of x == (4 || 5) sould be valid syntax for an if statement
why is there brackets
I wanted a shorter was to allow for x to by 4 or 5
remove the brackets and it works
Oh okay
js do this (x === 4 || x === 5)
How the hell can I make my script place a structure that’s saved in its structures folder.. I can’t for the life of me get it to recognise them. Even in game, I am trying to use the place command and the ids for the custom structures in the bp aren’t registering…
where are you saving the structures and what are you using as the structure name
Use runCommand
There is a bug where BP structures arent recognized after executing once.
Ok, but even in game if I type in the place command it isn’t recognized
Place is for jigsaw
You need structure load
Its correct, youll just have to do +1
Where, each value in least coord?
Yes. Because I assume youre just taking the distance from each coord. In the picture, it is cirrect since the coord is in the corner of the blocks hence it never expands past the block.
Lemme try
it the same, maybe half or something but float
const min = {
x: Math.min(p1.x, p2.x),
y: Math.min(p1.y, p2.y),
z: Math.min(p1.z, p2.z)
}
const max = {
x: Math.max(p1.x, p2.x),
y: Math.max(p1.y, p2.y),
z: Math.max(p1.z, p2.z)
}
const size = {
x: max.x - min.x,
y: max.y - min.y,
z: max.z - min.z
}
const dbox = new DebugBox({x: min.x + 1, y: min.y + 1, z: min.z + 1})
dbox.bound = size
if lazy to type both, maybe use something like:
[4,5].includes(x)
Bruh
The function no one uses
No
best for trading features or gui systems
I've been doing manual the whole time
How to detect if item stack is placable
You can only detect if it is a block
That leave out items with place block component
What are you trying to load?
The time will depend on how big the structure is
Can't find placable here
yeah how tho
I've been searching for a way
Do you think minecraft:block_placer would work
BlockTypes.getAll()
ItemTypes.getAll()
And filter shared ids
Both of those return array
is it like BlockTypes.get(id) if returns false means it's not placable
Instead of getAll
based on this
I guess..?
I mean get() should work
Was thinking more of a way to get the list, not test if an item is placeable
damn.. we can't get the food component from vanilla items, is there another way to check if a vanilla item is food?
You can
You can get it from apples apparently
Not from most of them
Isnt it ItemStack.hasComponent("minecraft:food")
Dam
yeah but that returns undefined for most of vanilla food
Map there values and use that for vanilla items
ah yeah... I need a list of food items
alright, good enough heheh, although I think I'll do some workaround
thanks! :)
place structure in runCommand isnt working?
Place command is disabled
because the native function crash my world when the structure is big
oh
any fix for this?
Yoi just have to use the native function and hope it doesnt crash.
Or make the structure smaller.
How big is it.
Yeah make it smaller or split it up.
its divided in 4 pieces and joined by jigsaw blocks
Then it should have no trouble being placed. I've had no issues.
lol
is it possible to decrease the size of this?
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
For custom block components, whats the difference in onTick, and onRandomTick
One has a timer (tick) the other is based on random tick (the mechanic)
so onTick using the tick component i add while randomTick is by the actual gamerule?
Yes.
Im adding leaf decay to custom leaves, should would it be better to do it via random tick them?
Yes.
I was trying to detect if the held item is a block type/placable, but it always goes false
const isBlock = BlockTypes.getAll().find(b => b.id === item.id)
if(isBlock){
player.runCommand(`fill ${p1} ${p2} ${item.typeId}`)
}else{
player.runCommand(`fill ${p1} ${p2} air`)
}
Even if the item is grass block
Or item.id don't exist
Works for me.
not sure what causes it, only onPlayerBreak works for me
BlockTypes.get(itemStack.typeId)```??
Suggested that too at first
.
Bith works now
u probably did something wrong then...
I never had a problem dealing with types...
You should use beta-APIs for it
Minecraft doesn't send any error or warn if you're trying to register unknown event, so..
form
does anyone know why this wont work
world.afterEvents.playerSpawn.subscribe((data) => {
const { player, initialSpawn } = data;
if (!initialSpawn) return;
const inv = player.getComponent('inventory')?.container;
if (!inv) return;
const itemStack = new ItemStack("vdg:akm");
itemStack.setDynamicProperty('vd:akammo', 30);
world.afterEvents.itemUse.subscribe(ev => {
const { source: player, itemStack } = ev
if (itemStack.typeId !== gun) return
const ammo = itemStack.getDynamicProperty('vd:akammo');
const dpshoot = system.runInterval(() => {
if (typeof ammo === 'number') {
itemStack.setDynamicProperty('vd:akammo', ammo - 1);
if (ammo <= 0) itemStack.setDynamicProperty('vd:akammo', null)
}
}, 1)
if (ammo == null) empty = true
if (ammo > 0) empty = false
})
});
world.afterEvents.itemUse.subscribe(ev => {
const { source: player, itemStack } = ev
if (itemStack.typeId !== gun) return
if (empty == true) return
const shoot = system.runInterval(() => {
shootProjectile('arrow', player.dimension, player.getHeadLocation(), player.getViewDirection(), {
power: 10,
uncertainty: 3,
owner: player
})
}, 2)
world.afterEvents.itemStopUse.subscribe(ev => {
const { source: player, itemStack } = ev
if (itemStack.typeId !== gun) return
system.clearRun(shoot)
})
})
basically if the ammo variable which is a dynamic propery reaches 0 or null it turns empty to true which on the second part if empty is true it would return
I think it's because setDynamicProperty only accepts String, Number, Boolean, and Vector3, not null
You might need to set it to something else just not null
so basically undefined
it is valid...
every empty property is undefined
no problem
I setScore to a custom named participant but it says undefined
Do I use addScore instead
I can't find other methods to add participants
Oh doesn't work too
const ConfigObj = world.scoreboard.getObjective("bbconfig")
if(ConfigObj) return;
world.scoreboard.addObjective("bbconfig", "Config")
// 1 = true, 0 = false
ConfigObj.addScore("showBoundingBox", 1)
ConfigObj.addScore("showWarning", 0)
// rgb values 0 to 10
ConfigObj.addScore("boxColorRed", 0)
ConfigObj.addScore("boxColorGreen", 0)
ConfigObj.addScore("boxColorBlue", 0)
can we prevent entity x rotation from snaping back to 0 after setRotation?
without using run interval
Nope 😔
And I've searched a lot
well, i guess i can force rotation using properties
Nvm
Is there a way to display an entity just like block/item display?
display an entity like a block?
what do you mean?
Is it possible to add a custom command parameter where if I chose the enum "add", the next param requires Integer, and if I chose ejum "remove", the next param requires String
/call <add> <number>
/call <remove> <string>
unfortunately no mojang didnt add sub commands
We really want that
I guess u can make it using scripting
I know it can, but the parameters are straight forward
It can't be custom like:
/call add <number> <string>
if I chose other enum it changes the next param:
/call remove <string> <boolean> <number>
Correct.
So this other gui thing is that a whole separate I'm making in a different .js
Display entity that displays entity, and not a block
how can i use it?
Just reached a limit on a property due to string limits. Is there anyway to decrease the number, maybe using sets? Otherwise, I was just going to use another dynamic property with a different id to save more info.
Yeah you would need to page it.
@winged gull can you please tell me what's wrong with this code and no I didn't use ai I have those notes there to help me remind me
import { world, system } from "@minecraft/server";
// Define the system interval to run every second
system.runInterval(() => {
updateTimePlayed();
updateMoney();
}, 20); // Run every tick (1 tick = 1/20 of a second)
// Function to update the Time Played scoreboard
function updateTimePlayed() {
let players = world.getPlayers();
players.forEach(player => {
// Get current time from the player's scoreboard (if it exists, otherwise set it to 0)
let currentTime = player.getScoreboard().getScore("Time") || 0;
// Update the scoreboard for time played (add 1 second)
player.getScoreboard().setScore("Time", currentTime + 1);
});
}
// Function to update the Money scoreboard
function updateMoney() {
let players = world.getPlayers();
players.forEach(player => {
let currentMoney = player.getScoreboard().getScore("Money") || 0;
// Add money every 10 seconds (if time is a multiple of 10)
let time = player.getScoreboard().getScore("Time");
if (time % 10 === 0) {
player.getScoreboard().setScore("Money", currentMoney + 1);
}
});
}
// Function to display time and money in the action bar
function displayTime() {
let players = world.getPlayers();
players.forEach(player => {
// Get the time played and format it into hours, minutes, and seconds
let timeInSeconds = player.getScoreboard().getScore("Time");
let hours = Math.floor(timeInSeconds / 3600);
let minutes = Math.floor((timeInSeconds % 3600) / 60);
let seconds = timeInSeconds % 60;
// Get the player's money
let money = player.getScoreboard().getScore("Money") || 0;
// Create a string with the formatted time and money
let formattedTime = `${hours}h ${minutes}m ${seconds}s`;
let displayText = `Time: ${formattedTime} | Money: $${money}`;
// Update the player's action bar with the time and money information
player.sendActionBar(displayText);
});
}
// Display time and money every second to all players in the action bar
system.runInterval(displayTime, 20); // Run this every tick (every second)
Hey queston how do I add a player to a scoreboard and give them a random score
wut ?
Ok so I am making a script thst creates a scoreboard objective. And when a player joins the world i wanna give them a random score
its with a command or command block
with the command scoreboard
scoreboard players random @a (objective:like money kill) (min:amount) (max:amount)
It's non shown
Then use dynamicProperties
It s better and easier to handle
Unless u are using commands
@half ivy
Yeah
Using commands right ?
Yeah
Don't know how to script right ?
I tried it with the run command and it didn't work
._.
There a whole interface for scoreboard in scripting
/scoreboard players add playerName ObjectiveName Count ```
@half ivy
Thanks
If u need how to make it in script i can make it though
there's no display entity in bedrock
but you can make an entity with no AI
What i wanted to use this is like displaying a frozen entity even from other addons. Like that
offset camera in first and third person still not working?
yeah make an entity that looks like a block of frozen ice 2x1 then apply weakness and slowness to the entity from other addons then spawn that block entity to that alother entity
is that what you meant?
Ah like riding? I think evokers can still do somethint or creepers, or not?
no
like overlay
Spawn the entity on the entity
Ah okay, but doing that, i think creepers can still explode or some entities doing their behavior
Yeah, hmmm
skeletons can still shoot too
But that can be fixed if the entity has been frozen and delete all arrows that it shoots
but the creeper, I have no idea how to disable it through script
Yeah, i just wish they have that, so there's many things you can do especially to creators.
True
you have to probably add a component to creepers
pipol...
but that's in the #1070606638525980753
yis
There is no way to check the "data" part of the item right??
data?
when you do give or replaceitem
<item> <amount> <data>
stick 1 1
something like that...
what does data return though?
here are some itemStack properties and methods
what do you mean by data though?
lmao
The best I could do rn is js const command = player.runCommand('testfor @s[hasitem={item=stick,data=2}]').successCount
That's like a damage
Probably set the durability component
Maybe just use dynamic properties
Ahh yes, us DP on stackable item.
which u can't.
It's not showing at all
what is data=2? what does it return?
is that like making a specific item liek example a stick but with different data so that its not stick?
iirc this is what used in datapacks right, pure commands
is that correct?
In old version there's no specific id for colored blocks, or other variants of blocks
We had to type something like/give concrete 1 5 in order to give ourselves a specific colored concrete
That's where data is used for
For tools it's a durability
It can be also used for other items to treat as "unique" than the other item with the same id
That's all I remember
What exactly is early/restricted execution? I'm trying to create a scoreboard objective in a world.beforeEvents.playerInteractWithBlock event and it throws an error.
hum long time
It means you can't execute the function too early, the solution would be putting all functions under system.run(void)
is applyKnockback or applyImpulse supportable for tnt?
Most likely, given that TNT can have knockback applied to it from tnt explosions
what is the best way to detect a specific entity using scripts? i don't want to call every single entity in the game to detect a specific one (detecting the zombie entity instead of every single entity)
for (const entity from world.getDimension('overworld').getEntities()) {} will return every single entity in the world, which is not good for my system,
do i have to add .getEntities({type: 'minecraft:zombie'}) or something?
Documentation for @minecraft/server
This you?
looks like it no?
i guess you could say that
Nice
always has been
even i begin to read his article recently but he haven't updsted it
I've seen many important identities here
Including zelisce
You're a former dev of a featured server right
Yeah
but I wouldnt call myself important
is it any other way to get TypeFamily of entities whenever i use afterEvents.entityDie? cuz using getComponent resulting on failure due to entity getting removed
I'm imagining it triggers if something like a projectile dies, since those despawn immediately.
Are you using an optional chaining question mark?
nah, just a normal way
deadEntity.getComponent(EntityComponentTypes.TypeFamily)?.hasTypeFamily("undead")
the only question mark is on the end of getComponent
or is it caused by (deadEntity?.getComponent) placing question mark on deadEntity ?
Well if the entity is removed, you can't get its component
then no answer for this
but how to use array for execute (deadEntity.typeId)
Wym
using forEach
Is it an array of entity type Ids you want to make forEach loop
instead of using (deadEntity.typeId==""||deadEntity.typeId=="")
Oh
@broken pawn
You can use https://stirante.com/script/server/2.6.0-beta.1.26.0-preview.26/classes/EntityRemoveBeforeEvent.html
Documentation for @minecraft/server
Oh here's the boss
nice we got the boss
If youre in the preview and can use beta.
🗣️ 🔥 🔥
i might be trying that, sounds pretty nice
i knew stirante.... he's the one who develop essentials addon
also my goat
My way would be like this:
const list = {
zombie: zombieFunc,
villager_v2: villagerFunc,
wolf: wolfFunc
}
world.afterEvents.entityDie.subscribe(data=>{
const {deadEntity: entity} = data;
Object.keys(list).forEach(mob=>{
if(entity.typeId === `minecraft:${mob}`){
list[mob]()
}
})
})
function zombieFunc(){...}
function villagerFunc(){...}
function wolfFunc(){...}
But there's a cleaner and more concise way than this
this gonna be fun
my library.js will getting extra size after this
yes, it used to store function and other array tho
for global use, once i have an addon idea, i'll just take it from there
Understandable
🗣️ 🔥 🔥
That's also efficient
But if it's a lot of code
Gotta separate it
For me in my opinion
yes, anyway thanks for the knowledge, even thought i'm not a scripter, just for casual use for my realms
it do help a lot now
You should thank Smokey 🔥🔥🔥
🗣️ 🔥 🔥
thank you! I was able tot fix it by adding a timeout for one tick
someone know if it's possible to detect when an entity wear any armor ?
use EntityEquippableComponent
let A0 =Entity.getComponent(EntityEquippableComponent.componentId).getEquipment(EquipmenSlot.Head)
if(A0.hasTag(ArmorTag)){}else{}
it detects player Equipment
make sure which slot needs to be detected
if Chestplate, the .getEquipment(EquipmentSlot.Chest)
only if the entity is a player
I kinda made my own world edit with a bounding box display, I only have cmds like:
/wfill <blockId?> - if block is empty, it uses the block in mainhand, if not placeable or empty, places air instead
/offset <x> <y> <z> - moves the blocks from selected area
/config - just a form ui to configure settings such as showBoundingBox, showWarning, showLogs, boxColor {red, green, blue}
/wand - gives an axe item with dynamic property, sets 2 positions by breaking blocks
/pos1 - sets your current position as first position
/pos2 - sets your current position as second position
what else do I make
why am i getting early execution errors???
Where?
its for my database but everything is imported properly or wrapped in a system.run
What is IslandManager
my island manager
Whats on those error lines using getAll
this.cache = Database.getAll(name, defaultValue);
Does that run after early execution...
uhhh
its just fetching dynamic properties
so i see why its erroring
but wrapping it in system.run or importing the file before system startup does nothing
i remember this error before but i forgot what i had to do
ah this
How do I use the script event command
const inst = this;
system.run(() => inst.cache = Database.getAll())
```would this work?
good to know
If u want that to work, u can do new Promise since awaition is there
new Promise for this purpose
How to use StructureManager
What are you trying to do?
I just have doubts that it might be wrong if I used it like structureManager.get(id) directly, it might have parents like world.structureManager or else
Just getting the id of structure I saved if it exists
world.structureManager.get(id)
I'm making telekinesis
To do it, should I constantly teleport an entity to the offset of the player's body or should I use applyImpulse for smoother movement of the entity
Is the smooth movement worth the larger strain on performance?
Would the strain on performance be very high?
I suggest both impulse and orbiting the body, just different methods to use
Control Entity - right click
Apply Impulse - left click/hit
Not really feasible.
Sas i thought i saw someone make them
is there currently a bug, where the custom item components just dont work? i have my custom component in the components block in my custom item json but minecraft seems to have forgotten, custom item components are a thing and gives the error message "... this member was found in the input, but is not present in the Schema" i have even copied the exact code from https://learn.microsoft.com/en-us/minecraft/creator/documents/scripting/components-tutorial?view=minecraft-bedrock-stable&viewFallbackFrom=minecraft-bedrock-preview but it does not work 🙁
guys
Are you in preview?
let fortuneLevel = 0;
try {
const heldItem = player.getComponent("equippable")?.getEquipment("mainhand");
if (heldItem?.getComponent("enchantable")) {
const ench = heldItem.getComponent("enchantable");
fortuneLevel = ench.hasEnchantment("fortune") ? ench.getEnchantment("fortune").level : 0;
}
} catch (e) {}
const fortuneBlocks = [
"minecraft:diamond_ore",
"minecraft:deepslate_diamond_ore",
"minecraft:coal_ore",
"minecraft:deepslate_coal_ore",
"minecraft:emerald_ore",
"minecraft:deepslate_emerald_ore",
"minecraft:gold_ore",
"minecraft:deepslate_gold_ore"
];
let quantity = 1;
if (dropItemId) {
if (blockId.includes("lapis")) {
quantity = 4 + Math.floor(Math.random() * 5);
if (fortuneLevel > 0) quantity *= (fortuneLevel + 1);
} else if (blockId.includes("redstone")) {
quantity = 4 + Math.floor(Math.random() * (fortuneLevel + 2));
} else if (blockId.includes("nether_gold_ore")) {
quantity = 2 + Math.floor(Math.random() * 5);
if (fortuneLevel > 0) quantity += Math.floor(Math.random() * (fortuneLevel * 2 + 1));
} else if (fortuneLevel > 0 && fortuneBlocks.includes(blockId)) {
quantity = 1 + Math.floor(Math.random() * (fortuneLevel + 1));
}
itemStack = new ItemStack(dropItemId, quantity);
} else {
itemStack = new ItemStack(blockId, 1);
}
js
Make a post please.
yessir
done
@wary edge does Minecraft api support json comments ?
Not sure how this is a scripting question tbh.
☠️ i don't know in which channel to put
Lol
But are
/* Comments */ works or they will break .json files ?
they work
if you want to make it to where they dont error just change the language model to jsonc
how to get the container component of shulkerbox in its item form
I've tried item.getComponent("inventory") it can't, also when I tried item.getComponents().length it return 0
there's no inventory component for items
only blocks and entities
ooowhh, but on the docs, there is "ItemInventoryComponent"
Thats for bundles only
owh okay okay, thx for the help
Guys is this right
world.afterEvents.playerMove.subscribe
I making a slime block launch pad
I don't see anything related to "playerMove"
that never exists, both in preview and stable Minecraft
@broken pawn then how do I make a slime block launch pad
Because I saw it in a world I was on
system.runInterval i guess? and how is it work?
It supposed to launch to any where the player is facing
Oh like if the player is facing forward it launches them forward
looks like using applyKnockback
i nailed it btw
AE.entityDie.subscribe(({deadEntity:A})=>{try{
Object.keys(Vanilla).forEach(B=>{if(A.typeId==`minecraft:${B}`){Vanilla[B]}});
}catch(Empty){}});
pretty confusing isn't it?
@broken pawn is this right also
world.beforeEvents.playerInteractWithBlock.subscribe((event) => {
const player = event.player;
const block = event.block;
if (!player || !block) return;
if (block.typeId !== "minecraft:orange_shulker_box") return;
giveStarterKit(player);
player.sendMessage("§aStarter items received.");
});
/* ================================
GIVE STARTER ITEMS
================================ */
function giveStarterKit(player) {
const inv = player.getComponent("inventory").container;
inv.addItem(new ItemStack(MinecraftItemTypes.leatherHelmet));
inv.addItem(new ItemStack(MinecraftItemTypes.leatherChestplate));
inv.addItem(new ItemStack(MinecraftItemTypes.leatherLeggings));
inv.addItem(new ItemStack(MinecraftItemTypes.leatherBoots));
inv.addItem(new ItemStack(MinecraftItemTypes.stoneSword));
inv.addItem(new ItemStack(MinecraftItemTypes.stonePickaxe));
inv.addItem(new ItemStack(MinecraftItemTypes.stoneAxe));
inv.addItem(new ItemStack(MinecraftItemTypes.shield));
inv.addItem(new ItemStack(MinecraftItemTypes.cookedBeef, 16));
inv.addItem(new ItemStack(MinecraftItemTypes.oakPlanks, 32));
}
imma diagnose this
Ok
it should be work
why didn't you add a tag to make sure it'll never duped
if(player.hasTag(""))return;
And also how do I make a leaderboard floating text system that changed every 10 seconds, from kills, to deaths, to money
I making genpvp and I want players to get starter kit when they die
understandable
Seems you typed the same except you call Vanilla[B] as an item not a function like VanillaB
@broken pawn is the applyknockback right
world.afterEvents.playerInteract.subscribe((event) => {
const player = event.player;
const loc = player.location;
// Check if the player interacts with a slime block
const block = event.block;
if (block.typeId === "minecraft:slime_block") {
// Apply knockback when the player lands or jumps on a slime block
player.applyKnockback(0, 0, 0, 1.2);
player.sendMessage("§aYou were launched by the slime block!");
}
});
I did what you said
i forgot it
i haven't used knockback, but you have to adjust the y value right?
use world.afterEvents.entityDie
then add filter
One of them doesn't work on Player type entity
I just forgot it
I mean the applyImpulse and applyKnockback
They act the same but one of them is easier to handle where to land, the other one defines the position of source knockback
Wym
AE.entityDie.subscribe(({deadEntity:A})=>{try{
Object.keys(Vanilla).forEach(B=>{if(A.typeId==`minecraft:${B}`){Vanilla[B]()}});
Object.keys(EternalEnd).forEach(B=>{if(A.typeId==`panascais_end:${B}`){EternalEnd[B]()}});
}catch(Empty){}});
like that
You can put it on one forEach actually
how
ah yes the if else
no problem, we always have a mistaken action
The conditions are the same
If you mean that you can use multiple loops from an object, you can
yes like that
yes that'll work, like the code you gave
If it's the same Object, you can put it on one forEach loop
@broken pawn getting this error even know it's in there
[Scripting][error]-SyntaxError: Could not find export 'MinecraftItemTypes' in module '@minecraft/server'
[Scripting][error]-Plugin [GenPvP - 1.0.0] - [main.js] ran with error: [SyntaxError: Could not find export 'MinecraftItemTypes' in module '@minecraft/server']
Does it also need to be in manifest.json
you have to import{MinecraftItemTypes}from"@minecraft/vanilla-data"
i guess instead of using MinecraftItemTypes, just use string ""
"minecraft:leather_helmet"
Can you give the fixed code real quick
how can i use the dyeable component?
spawnItem(new ItemStack("minecraft:dragon_egg",1),V3);
does it have to be a custom item
like this (ignore the spawnItem and V3)
@broken pawn
Or give me a line
And I can fix it
Like this @broken pawn
world.beforeEvents.playerInteractWithBlock.subscribe((event) => {
const player = event.player;
const block = event.block;
if (!player || !block) return;
if (block.typeId !== "minecraft:orange_shulker_box") return;
giveStarterKit(player);
player.sendMessage("§aStarter items received.");
});
/* ================================
GIVE STARTER ITEMS (using strings)
================================ */
function giveStarterKit(player) {
const inv = player.getComponent("inventory").container;
inv.addItem(new ItemStack("minecraft:leather_helmet"));
inv.addItem(new ItemStack("minecraft:leather_chestplate"));
inv.addItem(new ItemStack("minecraft:leather_leggings"));
inv.addItem(new ItemStack("minecraft:leather_boots"));
inv.addItem(new ItemStack("minecraft:stone_sword"));
inv.addItem(new ItemStack("minecraft:stone_pickaxe"));
inv.addItem(new ItemStack("minecraft:stone_axe"));
inv.addItem(new ItemStack("minecraft:shield"));
inv.addItem(new ItemStack("minecraft:cooked_beef", 16));
inv.addItem(new ItemStack("minecraft:oak_planks", 32));
}
exactly
function giveStarterKit(player) {
const inv = player.getComponent("inventory").container;
inv.addItem(new ItemStack("minecraft:leather_helmet",1));
inv.addItem(new ItemStack("minecraft:leather_boots",1));
inv.addItem(new ItemStack("minecraft:leather_leggings",1));
inv.addItem(new ItemStack("minecraft:leather_boots",1));
inv.addItem(new ItemStack("minecraft:stone_sword",1));
inv.addItem(new ItemStack("minecraft:stone_pickaxe",1));
inv.addItem(new ItemStack("minecraft:stone_axe",1));
inv.addItem(new ItemStack("minecraft:shield",1));
inv.addItem(new ItemStack("minecraft:cooked_beef", 16));
inv.addItem(new ItemStack("minecraft:oak_planks", 32));
}
@broken pawn got these errors
[Scripting][error]-TypeError: cannot read property 'subscribe' of undefined at <anonymous> (main.js:148)
[Scripting][error]-Plugin [GenPvP - 1.0.0] - [main.js] ran with error: [TypeError: cannot read property 'subscribe' of undefined at <anonymous> (main.js:148)
]
[Scripting][error]-TypeError: not a function at run (main.js:58)
at startSpawnCountdown (main.js:84)
at spawnCommand (main.js:45)

Or @prisma shard can you tell me what I need to fix in my code because I got this errors
uh no man sorry
@broken pawn can you tell me what I need to fix
The subscribe one is this one
world.afterEvents.playerInteract.subscribe((event) => {
const player = event.player;
const loc = player.location;
// Check if the player interacts with a slime block
const block = event.block;
if (block.typeId === "minecraft:slime_block") {
// Apply knockback when the player lands or jumps on a slime block
player.applyKnockback(0, 0, 0, 1.2);
player.sendMessage("§aYou were launched by the slime block!");
}
});
I pretty sure
Yep that the subscribe error one
For the spawn countdown error it's this one
function startSpawnCountdown(player) {
let timeLeft = 5;
let delay = 20;
const run = () => {
if (!player?.isValid()) return;
player.dimension.spawnParticle(
"minecraft:shriek_particle",
player.location
);
if (timeLeft > 0) {
player.sendMessage(`§bTeleporting in ${timeLeft}...`);
timeLeft--;
delay = Math.max(6, delay - 3);
system.runTimeout(run, delay);
} else {
const customSpawnLocation = {
x: 100,
y: 70,
z: 100
};
player.teleport(customSpawnLocation, {
dimension: player.dimension,
rotation: player.getRotation(),
});
player.sendMessage("§aTeleported to spawn.");
}
};
run();
}
@broken pawn there I gave the code of the errors
Can you tell me what I need to fix or something
I gave the full code it's the file
first of all, in this code,
change the line
if (!player?.isValid()) return;
Into
if (!player?.isValid) return;
And in this code,
change the line
world.afterEvents.playerInteract.subscribe((event) => {
Into
world.afterEvents.playerInteractWithBlock.subscribe((event) => {
since the one currently is not a valid event
player.applyKnockback(0, 0, 0, 1.2);
And this line is not valid either, That is old format of applyKnockback
verticalStrenght was uhh removed
no
maybe dont suggest
oh alr
not to be rude but it can confuse ppl yk
Ohhhh its horizontalForceXZ in curly braces
Yeah so it got changed from a number to a XZ vector
@thorn flicker it says your not replying but not to be rude or stuff I asking a question are you going give the fixed line?
player.applyKnockback({x: 0, z: 0, }, 1.2)
Just asking is it playerInteractWithBlock for launching
its fine, I just think you were excessively mentioning me lol
Srry
np
And also when I right click the shulker box the orange one with open the shulker chest menu and it doesn't actually right click and give me the starter items
both works...
now it does.
@thorn flicker [Scripting][error]-ReferenceError: Native function [Container::addItem] cannot be used in restricted execution. at giveStarterKit (main.js:182)
at <anonymous> (main.js:172)
Getting this error
holy tags...
And also the slime launch pad not working but I get no errors
you think you are getting mentioned so much?
lmao
look above
I'm not talking about me, I'm talking about U getting tagged multiple messages lol
ahhhh
[Scripting][error]-ReferenceError: Native function [Dimension::spawnParticle] cannot be used in restricted execution. at run (main.js:63)
at startSpawnCountdown (main.js:84)
at spawnCommand (main.js:45)
you'll have to find someone else to help you rn
Based on my experience, maybe they updated it
Also this too
they did
Nice
yeah
More efficient
@stray spoke can you help me with the errors
how so?
What's the problem
it's sometimes jumpy in my side lol
wdym?
probably because of the tick rate
hm
For one thinge spawn particle thingy not working which .aming the whole tp cooldown and tp thing not work andfhe starter kit not working because of the add item I think and another the slime block launch pad not working but no erros
@stray spoke
Soo umm, quick question... did you read the basics of MC script api?
May you show me the code
the way you type is so condescending
Also JavaScript
but its a good question
Sure, I'll analyze the code first
I don't even mean to do that, I just genuinely asked casue it's so common here that people don't lmao...
I respond this was too sometimes
just give them a script api doc site ig.
and if they refuse to utilize it 🤷♂️
I'm gonna abuse the player swing start now
@stray spoke
for what
I'll revise some of the code for you and see if it works, explaining it would be hard
on everything... 🌝
spam the usage of that event lol, especially there's swing source
Are you testing it on your world
Or something
Is it fixed
Did you forget to fix a code
Is it fixed
privilege error at using beforeEvents, you're modifying the world before it happens, so it's not possible, you need to make it happen next tick, that's why you need to use system.run()
that's the problem the guy is facing awhile ago...
That's what I did
world.beforeEvents.playerInteractWithBlock.subscribe((event) => {
const player = event.player;
const block = event.block;
if (!player || !block) return;
if (block.typeId !== "minecraft:orange_shulker_box") return;
giveStarterKit(player);
player.sendMessage("§aStarter items received.");
});
/* ================================
GIVE STARTER ITEMS (using strings)
================================ */
function giveStarterKit(player) {
const inv = player.getComponent("inventory").container;
inv.addItem(new ItemStack("minecraft:leather_helmet",1));
inv.addItem(new ItemStack("minecraft:leather_boots",1));
inv.addItem(new ItemStack("minecraft:leather_leggings",1));
inv.addItem(new ItemStack("minecraft:leather_boots",1));
inv.addItem(new ItemStack("minecraft:stone_sword",1));
inv.addItem(new ItemStack("minecraft:stone_pickaxe",1));
inv.addItem(new ItemStack("minecraft:stone_axe",1));
inv.addItem(new ItemStack("minecraft:shield",1));
inv.addItem(new ItemStack("minecraft:cooked_beef", 16));
inv.addItem(new ItemStack("minecraft:oak_planks", 32));
}```
where?
That's not the updated one
@stray spoke the slime block launch pad doesn't work and also the starter kit gives items but no chestplate
I was about to rename my file to send it again incase
Can you send me the error logs
There are no errors
In your code, you didn't add a function to give a chestplate
inv.addItem(new ItemStack("minecraft:leather_helmet",1));
inv.addItem(new ItemStack("minecraft:leather_boots",1));
inv.addItem(new ItemStack("minecraft:leather_leggings",1));
inv.addItem(new ItemStack("minecraft:leather_boots",1));
inv.addItem(new ItemStack("minecraft:stone_sword",1));
inv.addItem(new ItemStack("minecraft:stone_pickaxe",1));
inv.addItem(new ItemStack("minecraft:stone_axe",1));
inv.addItem(new ItemStack("minecraft:shield",1));
inv.addItem(new ItemStack("minecraft:cooked_beef", 16));
inv.addItem(new ItemStack("minecraft:oak_planks", 32));
It's just this
Can you give the line and also give the fix to the slime block not launching
Too many requests but okay
atp just open a post
it doesn't look like help anymore bro just make you do everything...
Bro I telling him to give lines
Ok
I gave you a hint, and it's a basic copy paste code, yet I still have to do it
Simply copy paste and edit the id
inv.addItem(new ItemStack("minecraft:leather_chestplate",1));
Like this
I now know what to fix
Test and see
@stray spoke I tested the slime thing and it still not launching
@stray spoke will this work with slime block if I renamed few things
import { world, system } from '@minecraft/server';
const PRESSURE_PLATES = [
"minecraft:stone_pressure_plate",
"minecraft:polished_blackstone_pressure_plate",
"minecraft:heavy_weighted_pressure_plate",
"minecraft:light_weighted_pressure_plate",
"minecraft:wooden_pressure_plate",
"minecraft:acacia_pressure_plate",
"minecraft:birch_pressure_plate",
"minecraft:cherry_pressure_plate",
"minecraft:crimson_pressure_plate",
"minecraft:dark_oak_pressure_plate",
"minecraft:jungle_pressure_plate",
"minecraft:mangrove_pressure_plate",
"minecraft:spruce_pressure_plate",
"minecraft:bamboo_pressure_plate",
"minecraft:warped_pressure_plate"
];
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
const block = player.dimension.getBlock(player.location);
if (!block) continue;
if (PRESSURE_PLATES.includes(block.typeId)) {
const direction = player.getViewDirection();
player.applyKnockback({ x: direction.x * 8, z: direction.z * 8 }, 1);
}
}
}, 1);
I found it on mcpedl
First of all its playerInteractWithBlock event so it should work only when you click the slime block, not step on it
If that was your intent
Oh then I do I do it by stepping on it I do that much Abt scripting API
⁰Idk
@stray spoke can you give me at least a code line of kt
1 line
@stray spoke like this
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
const loc = player.location;
// Offset Y by -0.1 to detect the block the player is standing ON
const blockBelow = player.dimension.getBlock({
x: loc.x,
y: loc.y - 0.1,
z: loc.z
});
if (blockBelow?.typeId === "minecraft:slime") {
// Apply knockback (vertical launch)
// x: 0, z: 0 ensures they go straight up
// The second parameter is the horizontal force, the third is vertical
player.applyKnockback(0, 0, 0, 1.2);
}
}
}, 1);
Yes but that would be repeating
So how do I remove repeating
Conditons
What about now @stray spoke okay I probably didn't need to ping you
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
// CONDITION 1: Only trigger if the player is actually touching the ground
if (!player.isOnGround) continue;
const loc = player.location;
const blockBelow = player.dimension.getBlock({
x: loc.x,
y: loc.y - 0.1,
z: loc.z
});
// CONDITION 2: Check if the block is slime
if (blockBelow?.typeId === "minecraft:slime") {
// Launch the player
player.applyKnockback(0, 0, 0, 1.2);
// Note: Because applyKnockback sends them into the air,
// 'isOnGround' immediately becomes false, stopping the loop.
}
}
}, 1);
And yes I used Gemini
But is it right
Why don't you test it first to see if it met your satisfaction
There's wrong syntax on applyKnockback
Changed it to something like this, like the old one
player.applyKnockback({x: 0, z: 0}, 1.2)
@stray spoke [Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:169)
Is that error the knock back
Did u follow this
That's optinal
Ok
It stil works without semi colon in the end
It doesn't lauch me forward only upward @stray spoke
u need to use the player's view direction to launch based on the direction they're facing
Like this
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
// Condition: Only trigger if the player is actually touching the ground
if (!player.isOnGround) continue;
const loc = player.location;
const blockBelow = player.dimension.getBlock({
x: loc.x,
y: loc.y - 0.1,
z: loc.z
});
// Condition: Check if the block directly beneath them is slime
if (blockBelow?.typeId === "minecraft:slime") {
// 1. Get the direction the player is looking
const viewDir = player.getViewDirection();
/**
* applyKnockback parameters:
* directionX: viewDir.x
* directionZ: viewDir.z
* horizontalForce: 1.5 (Adjust this for forward speed)
* verticalForce: 0.8 (Adjust this for height)
*/
player.applyKnockback(viewDir.x, viewDir.z, 1.5, 0.8);
}
}
}, 1);
Be honest Gemini probably wrong
@stray spoke got this error of that [Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2, received 4 at <anonymous> (main.js:178)
Or @jagged gazelle
Yooo I fixed it
It works
halo have anyone used getEntitiesFromRay? it doesn't seem to do anything similar to getBlockFromRay.
const raycast = dimension.getEntitiesFromRay(block.location, {x: 0, y: 1, z: 0}, {maxDistance:5})[0];
i am expecting to detect the entity above it
i mean there's volume option from getEntities, was just trying this one
@stray spoke is it possible to make a custom scoreboard in the top right corner of your screen
Nvm, I'll just use getEntities
yes, newest preview version and beta-api experiments active
Your item needs format veesion 1.26.0
That's a messy function
Anyone encountered creating a custom block that has a "onTick" Component, then placing that custom block using world generation single block placement, which doesn't trigger the onTick, only the randomTick.
Tried using 2 permutations with different timer loop interval upon interacting, still doesn't activate the onTick.
Although, if i just place it normally or using setBlock it works perfectly fine.
A known issue.
Oh, well.. 
How does randomTick works from block component? Is it based on interval declared from the block.json?
No thats onTick
Nearly all video games (including Minecraft) are driven by one big program loop. Just as every gear in a clock is synchronized with the pendulum, every task involved in advancing a game simulation is synchronized with the game loop. Appropriately, one cycle of the game loop is called a tick.
What's the range of randomTick?
Wdym range?
Read the article I sent
It's based on random ticking per chunk, just like vanilla blocks.
ah okay, thanks!
that's not mine...
I didn't mentioned that
Is there a new way to do gui's because I did my usual thing and it didn't work
world.afterEvents.itemUse.subscribe(async (data) => {
const player = data.source;
if (data.itemStack.typeId === 'minecraft:apple') {
await test(player);
}
})
function test(player) {
const menu = new ActionFormData()
.title("title")
.button("1")
.button("2")
.button("3");
menu.show(player).then(result => {
if (result.canceled) return;
switch (result.selection) {
case 0:
// response for first button
break;
case 1:
// response for second button
break;
case 2:
// response for third button
break;
}
});
}
Are u sure the event listener actually gets triggered?
playerSwingStart is so fuckin fun to use...
You mean the thing where you use the item
what is that
yes...
It's in the name itself, detects arms swinging
Yep I'm sure I've used this exact script time and time again and its always worked
there's a swing source, if it's an attack, build, drop
oh so its a new event?
afterEvent only?
hmm, try adding console.error() inside of thr function
yes, it's in the beta module version of stable MC...
Idk but maybe you have to add body? my instinct is that body is required but idk
If ur thinking about disabling damage on attack, there's also one but it's in the preview MC
omg
there's also detecting pickup...
yeah. that is something i picked up lmao
but that. omg ❤️
or just check the changelogs lol
yeah gotta start doing it again
i see they started to add something useful finally
Oh ok
Thx
@jagged gazelle are you still in need for a way to detect if item is charged or not ?
not anymore but I still accept suggestions if ever...
But will addComponent() ever be added for entities?
what exactly is the difference between the BlockCustomComponents "onRandomTick" and "onTick" ? like are there tow types of ticks? or am i dumb? i dont get it
there are two events for that
lemme guess itemCompleteUse or itemStopUse?
Is a runInterval better for performance than a behaviour animation/behaviour animation controller?
Or vice versa?
Random ticks happen at a random interval which can be sped up by increasing the world random tick speed. All blocks randomly tick by default, you should not add the minecraft:tick component to the block.
onTick triggers on "queued ticks" which can be added to a block using the minecraft:tick component to set the delay until the queued tick happens
so many events occurred here lmao
depends
runInterval is fixed while behavior animation triggers when something actived (assuming like world.afterEvents)
Ah
What I want to do is setRotation on an entity constantly until it dies or stops riding the player it's on
What would you suggest
hi guys is it possible to read enchantment by using beforeEvents.playerBreakBlock
?
as long as you can get the itemstack yes.
?
"?"
in before event player break block we can read an enchantment ?
I answered your question, yes.
W but how bc i made a script to read an enchantment but it detect nothing
Hi bro i want to make my table and entity spawn entity when the block place and it disappears when the block breaks
playerbreak block after events
and kill the entity ?
to kill the entity
Can you give me example about it
i dont have exemple sry
item start to use
share your code.
can u help me ?
what
wait
its a part of the script
i can't copy the full script
world.beforeEvents.playerBreakBlock.subscribe(ev => {
Just link to your post dude https://discord.com/channels/523663022053392405/1455707453571203115
but thx
right click on post, then click "copy link"
the type of charge I'm talking about is like a crossbow where it has an arrow on it already...
Oh
where do u use this??
Documentation for @minecraft/server
Oh sorry, I put the wrong question lol... It supposed to be how...
I get the keyframes already, except the linear spline and catmullrom spline
Idk how to put that in the first param...
You create a new Catmullrom or Linear object and define the control points and pass that object into the function.
oh, done...
I made it work now
ohh I forgot how to do this but how do I transfer value from animation to client entity...
can I get the command feedback message from "runCommand" method?
When I use getTopmostBlock() in the nether it always spawns above the bedrock, is this normal?
because it's the topmostblock?
ok, So the only way to check if that position is valid would be to tryTeleport the full height at that position?
What is top most block in the nether to you?
bedrock
But why doesn't tryTeleport still teleport me even if there are blocks?
Since there is a roof why do you need that function?
to find a valid location in the nether starting from the player's position in the overworld
Did you pass in the teleport options?
What does this mean? You said to you the top most is Bedrock, since its a flat roof the top most will always be at y127 so why not just teleport the player there.
Or are you trying to find the highest air pocket
yes this
Set it to false then. If it's true it will fail because it intersects with a block.
thanks
It's not working
It is working exactly what you wanted it to do
It teleports into the blocks. You still gotta find the highest air pocket tho.
I'm having trouble, teleporting gives me an error because chunks aren't loaded but it still teleports me, probably I can't detect the blocks and so it still teleports me?
Like you said, you still want tryTeleport to teleport you.
checkForBlocks = true means it will check for blocks, if there is a block ot wont teleport you. But you asked #1067535608660107284 message so I responded with setting that option to false.
But from what I'm seeing it doesn't recover the blocks so it doesn't recognize the block type, is there any solution?
How do I find the valid position, if I can't check the blocks, should I check it when the player enters the dimension?
You can temporary load the chunks via a ticking area.
Yes, but what do I do if 10+ consecutive players teleport?
Ticking Area manager has no limit beyond the 255 chunks as far as I know.
does someone know, if it is possible to delete an items lore? because setting it to nothing or null just creates a blank line as the lore, but does not remove it completely to look like items without a lore. and there are no methods like resetLore or clearLore. after I have used the ContainerSlot.setLore() ones on an item, the extra line seems to be unremovable
According to the docs it should remove it if you pass undefined to it.
ContainerSlot.setLore(undefined)
I'm using the ticking area system, but I'm having a problem with it. You have to wait at least 20 ticks to use the chunk check functions to find the first valid position. This could break the ticking area removal if the world is closed during the 20 ticks. So I'm wondering, should I save the ticking area names in a property so that if they aren't removed, when the next player uses the ability, it retrieves the ids in the property and removes them before creating the new ticking area?
The only problem with this system is that if a player has already created 10 ticking areas in the nether, what should I do?
You need beta api
You can load up to 300 chunks
And if the world or server is closed they get automatically removed
But you should use await, because it returns a promise
So it’s not instantly loaded, you have to wait some ticks
I understand, the system is fantastic but I would need the beta version which I can't use, can you tell me why it takes 20 ticks to load the tickingarea?
Wondering why we just have a generalized "onUse" for custom components and not an onStart/Stop use
There is onCompleteUse
That's only when the use duration is complete, not when it's no longer being used
this will only work for consumable items

But I reckon the default use duration is 1 tick and therefore done.
Class ItemComponentCompleteUseEvent
Contains information related to a chargeable item completing being charged via a component.
The shooter component has a charged property and spears have a use duration
It won't fire for bows or spears
Mojang designs them with very high use_duration values
onConsume requires the food component to be present on an item as well
Very different docs.
I am aware, I was replying to
this will only work for consumable items
It is possible to have an item with low use_duration but no food
Well yeah, but both of these fire for pretty much the same things
Have you tested with the spear?
I have custom spears fully implemented, they don't actually need any sort of scripting to function properly
The only reason scripting is needed for bows/crossbows is because they are completely broken
I could test later, but I was more so trying to see if I could move any of my custom bow stuff outside of the native event listeners
Is Date class is available in script api ?
yes
Is there any character limit for dynamic entity properties
Actually I have a much better idea for that
Im currently trying to make a block copier item and the only things Id need is how would I get the item to know many many states it would need to use
Store the permutation into a string.
I was thinking just store the location of the block I want to copy and then get all the states from there
But the issue still arises of how tf do I set the right amount of permutations and which ones to set
1 block at a time
So what's the issue?
You'd set the block by shift interacting with the block
Store the permutation into a JSON object, stringify it, then when you're copying it, parse the JSON and set the permutation to it.
Id have to get to my laptop and see what you are saying im unfamiliar with this kinda stuff
I can kinda see it tho
Actually no that was literally my 1st idea, just put into words
Yeah I get it
Actually putting into motion would be a different problem entirely
The depth of my Javascript expertise is if else and switch case
Guys suggest me something fun I can do with scripting
script using translate a lot
Huh
uh
How to make cutscenes using camera animations?
okay so basically runTimeout spam...
import { world } from "@minecraft/server";
const HelloWorld = new class {
constructor() {
this[Symbol.toPrimitive] = () => "Hello World";
}
};
world.afterEvents.playerSpawn.subscribe(
({ initialSpawn: stp, player: user }) =>
stp && user.sendMessage(+HelloWorld)
);
wow this syntax is work
that's cursed
well this is also cursed
const isntance = new class extends function (){} {
if(object) {
this.object = object;
}
};

Is this right guys
// 2. Left-Click (Attacking/Hitting)
world.afterEvents.entityHitEntity.subscribe((event) => {
const { damagingEntity, hitEntity } = event;
// Check if the attacker is a player and the target is the shopkeeper
if (damagingEntity.typeId === "minecraft:player" && hitEntity.typeId === "shop:shop_keeper") {
const player = damagingEntity;
// Use system.run to handle the UI safely outside the physics event
system.run(() => showMainMenu(player));
}
});
Is it entityhitentity
You could just...check
lol
anyone know the order of events of the world's playerLeave after event and the system's shutdown before event?
like which fires first?
i can't test rn so if anyone knows the answer, thanks!
You can use the function directly in afterEvents without using system.run, since its not an early execution
But yeah that's more safe, just to lessen the code you can remove it
I use herobrines chest ui and i havent played since 4 month now i just started playing again and the textures are bugged 4 month ago the textures worked fine does someone know why the textures are bugged?
some textures show but most of them dont
I think Herobrine UI is broken
but there have been made like 10 forks that "should" work
but i have lots of uis with herobrines chest ui i would have to recode like 50 uis
You only have to change the files from the UI not your.
could you send me the new chest ui which is working
I use my own but if you want forks click here https://github.com/Herobrine643928/Chest-UI/forks
Contribute to Herobrine643928/Chest-UI development by creating an account on GitHub.
no idea which one works
probalby the newest one does
why is it called forks
isnt this a fork
Maybe because the main stem is the Herobrine UI and there are many "little" teeth that are similar and come from one?
But thats my guess haha
okay hahahhaha nice guess
what features has yours?
It makes the empty slots unclickable, it has dynamic grid, you can hide some slots, so you got like a space between some
and it seems like mine is more optimized (less elements and bindings)
what do you mean by dynamic grid?
Like you dont have only 5, 9, 18, 27, etc slots, you can type how many you want
although I havent yet released it but I am planning on doing it
i just found out about server-graphics module, can someone tell me what this is for exactly?
i assume material stuff or some defferred rendering but idk
when do you think you will release it?
huh? what does that even do
because of the "fork in the road" saying/metaphor
Hmm, not sure. Like everything seems done. It just lacks the inventory but I find it not that useful. Have to also add comments for the methods.
the main repo is like the main road, then the "forks" are roads that go off it in another direction
so a fork is a copy of the original with maybe some changes or improvements?
exactly
so i wasnt that off afterall lol
and sometimes that fork can lead back into the main road, which in the git/source control context would be a pull request
you think that the inventory isnt that useful or smth else?
Yeah I don't it is essential. It maybe nice to have but I think that the pure container seems cleaner.
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
If someone really needs this and wants my version I could add this
i agree with ur opinion i also deactivated the inventory at the herobrines chest ui
Can anyone explain why it doesn't load chunks even though the ticking area has been added?
sometimes it loads immediately other times it doesn't even take 2 seconds, how exactly does the tickingarea work it doesn't load instantly as soon as the command is used?
But I don't understand why it is added to the list if the chunk is not loaded yet
idk but its cursed
yeah it mostly produces additional lag. if you want to use it i can try releasing it today (you will haveto rewrite your chestform codes cuz my buttons are a bit different
what are your buttons like?
const ui = new ChestForm()
ui.title = "Test"
ui.glassBorder()
ui.button(13, ["test"], "textures/items/diamond", 1, true, false, { amount: 1, max: 1 })
ui.forceShow(player)
basically what the herobrine does but a little better (havent shown the "invisible slot" becuz refuses to work for some reason will fix this now)
{ amount: 1, max: 1 } is this durability?
yes
does ur pack support custom items?
and amount is a string so you can set anything aslong as it is 3 characters
nah havent added it yet
good idea to add
oh damnn i have 300 custom items
dayum 💀
source code?
not public yet
okee im waiting
❤️
Hi everyone! I have a question. Can I create code that will detect if a player places an X block on the edge of any block (say, the up and down edges), then that block will change to a Y block while preserving all the states of the X block?
i don't git it
how to fix this custom command issue i as the owner can do the custom command but normal players cant 4 month ago it worked also for normal players
To Do (Open)
Unresolved
fixed the invisible slots.
so everyone has this problem who uses player selector in his custom command?
i guess yeah
havent touched custom commands yet
yeah same
i changed to prefix because of this problem
since 2 month this exists and minecraft doesnt fix this important thing???
thats crazy
normal mojang behavior
they dont care about players, they care about money
how does prefix work?
chat events
oh you changed back to !