#Script API General
1 messages · Page 76 of 1
You probably need to define it as a const, then declare it in a system.run block
easy.normal.beforeEvents.chat(e => {
const message = e.player.sendMessage("You wrote: " + e.message);
system.run(()=>{
message;
});
});```
Try that
now its typeerror not a function
chat: cb => world.beforeEvents.chatSend.subscribe(e => cb(wrapEvent(e)))
const basePlayer = e.source ?? e.sender ?? e.player ?? e.entity;
return {
...e,
player: wrapPlayer(basePlayer),
item: e.itemStack?.typeId ?? e.item?.typeId ?? undefined,
raw: e
};
}```
What is the easy variable?
thats my libary
I think it's the library itself
Since if it throws an error not a function when you did system.run() then you did something wrong inside of lib.
i am having the same issue, the best thing i can think of is to pass the js code minified and compressed(yeah, first minify the js then compress it) using lzstring, and i dont know if dynamic properties on items or entities would solve, but to bypass the max of 2048 chars of scriptevent, the best thing i thought was saving data in the lore of an item specific for that
tbh, why save in lore?
i dont know if saving in a dynamic property would solve
I've been coding other projects than addons so did not test it
Solve what? Dynamic property is better than lore
i dont know if it would work
dynamic property is made for storage and why not use it?
addons are sandboxed
in my head an addon dont have acces to dynamic properties of an item set by another addon
i gotta test it
Ahhh, yes dynamic property isn't accessible outside of scripts
tho, same as lore... You can't check the lore of an item in molang or any commands.
I can't really give ideas since I don't know the context or what you are doing in the first place.
oof, then scoreboards
Or name tag...
And for scoreboards, you get how binary works?
Is there just a general event for when a block is broken?
As I need to detect when a custom crop block is broken and drop different loot depending on how it broke
nope, only playerBreakBlock
otherwise you detect the crop you placed, store the location of the to be accessed by runtInterval then so on tho not really accurate
Yeah I was perhaps thinking that but at larger scales it would be bad performance wise,
no choice :(
Yeah if I want to maintain the same way vanilla crop do drops
Is it possible to load a chunk/aside from keeping a chunk loaded, is it possible to actually load one?
eithier use a ticking area or teleport and entity with the tick_world component to that location
hey, what type of breaking do you actually need?
I pretty much was trying to replicate the vanilla crop system drops based of this https://minecraft.wiki/w/Fortune#Seeds which lead to me trying to recreate it in scripting as having to make a loot table to account for all the fortune would be a pain, but I was able to solve this though by making the base drops drop from a loot table while the fortune drops are handled in the playerBreakBlockEvent, so was able to solve it
inputInfo.getButtonState('Jump');
Is this still in beta?
WAIT IT WAS STATIC
@random flint Thanks for saying that, i did not see it, I love you
I don't think it's still beta.
its not
Are there any easy ways like a command that can trigger a modal menu to open. Or is it pretty much just methods like: check if an entity or player has a tag/family/property and if they do then open the modal?
you can use the beforeEvent "chatSend" to check if someone is writing something like !ui
Oh ok, hmmm maybe a family/tag trigger might be the best still then. I'm trying to trigger an opening if an item is used on an entity. Figure I'll just use an interact that triggers a tagging through an animation controller or something.
Either that or just use the beforeEvent, playerInteractWithEntity
Ooooh nice I didn't know there was one specifically, thanks! I'll look into the details of that one.
Nice, I didn't know there was some documentation on there too, thanks!
I found it on here too:
https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server.WorldAfterEvents-1.html#playerinteractwithentity
Perfect, it has the itemStack built in. Awesome.
yep
And you can cancel the event as well, to prevent direct "Interaction" with the entity
Oh ok, thank you! I appreciate your help and time!
Youre welcome
Hey I've tried this and while it does work in third person (albeit a bit jittery at the beginning because I likely have some animation params wrong), it doesn't seem to work in first person
Because first person and third person animation of attack is way different, and has animation patterns...
So there's another one that can be used in first person?
Did anybody figure out an animation pattern values?
world.afterEvents.playerInteractWithEntity.subscribe((eventData) => {
const { player, target, itemStack } = eventData;
if (!itemStack) return;
if (itemStack.typeId === 'cnb:cnb_ppl_gui') {
new Menu();
const targetnametag = target.nameTag
if (player.hasTag('listener')) player.sendMessage(`${targetnametag}`);
const newtarget = oldencodeString(target.nameTag)
manageemitteritem(player, newtarget)
}
});
Hmm I'm using an item to open a menu:
when used on air and also when used on an entity. Each opens a different menu
The problem is, when I open the menu from interacting with the entity it opens the regular menu after I try to click on any buttons in it.
I hope this makes sense, I can make a video if needed.
Is there any way to force a menu to close that's opened in the background?
Show all code
This is the code that opens from the item use in general:
world.beforeEvents.worldInitialize.subscribe((initEvent) => {
initEvent.itemComponentRegistry.registerCustomComponent("cnb:cnb_ppl_gui", new Menu());
});```
Essentially it's opening both menus. And I need to prevent the MainMenu The one just mentioned from opening.
about this, there's an import uiManager that can close all existing server forms...
😵💫
You need to prioritize one form to be opened and other to be ignroed
Like another api that does that?
Your name is different Aagain!??! lol This must be a part time hobby of yours.
interactWithEntity(entity: Entity)
I feel like there's a way to use this? Like, if the player is interacting with the entity then don't open the other menu?
const ITEM_ID = 'cnb:cnb_ppl_gui'
world.afterEvents.playerInteractWithEntity.subscribe(data => {
const { player, target, itemStack } = data;
if (itemStack == undefined || itemStack.typeId != ITEM_ID) return;
// Code to open menu with entity
})
world.afterEvents.itemUse.subscribe(data => {
const { source, itemStack } = data;
if (itemStack.typeId != ITEM_ID) return;
system.runTimeout(() => {
//Code to open menu without entity
}, 2)
})
In theory this should work.
@chrome gyro
How about running command part? Not just form.
?
The thing is, the itemUse one still triggers even interacting with entity especially running not just forms
In my part it still does, idk yours
Yes, but if you set system.runTimeout in itemUse before opening a regular form, it will not open if another form is opened before it
Well then you can just save the tick in which the form opened
Hmmm It's doing something weird and opening three menus now. I'll have to check it more thoroughly tomorrow, thank you both for looking into this though!
yoo I fixed it thx
I have no idea why this works, but I got it to funciton properly, thank you! I presume the delay of the few ticks is key.
Nice! What was the solution?
it's already permutation of a Block
just block.getAllStates() I think
block in Osuea's code is a BlockPermutation instance
that's a 7 hours things, imma just ignore it.
// block: BlockPermutation
const block = data.brokenBlockPermutation
12 *
xD
I just opened this chat
-# I'm sorry, I'm so fuckin sorry.
such a nice apology, short and in the topic
Did you see what I sent?
No, I send a different thing.
-# I will kiss you tonight.
bros got no one and now is in need to find someone across the internet
xd
lmao
Dude, I'm down bad but I ain't that down...
That's fuckin disgusting
i like old, like 5000 years old age gap
Lol
😳
would running this logic every 10 ticks cause a noticeable amount of lag? if so, how would i go about optimizing it?
it depends on the worst scenario
I see that you might have 48 iterations for every player, which is pretty tough already
i see
Ye, it's possible
any ideas on how to make it less laggy?
also you have some sort of m * n completixy in applyForcefield
oki
I have a BlockLootTable function that does that, but without the specifying of tools
you can use an array directly in Dimension.getEntites method
ah ok
const nearbyEntities = dimension.getEntities({
location: origin,
maxDistance: radius,
excludeEntities: Array.from(excludeEntites)
});
ty!
hey man, this isnt working
give me a second
oki
So given that attachables can only be attached to specific items, there's no way to make a first person hand swing anim for all items right?
Nor can I call some event to play it 💀
#1067869022273667152
That was an assesment more than a question
Does using the create explosion shows the particles or not cause i don't want the particles to appear when exploding?
yes, it adds the particles
Nooooooo
it's a shame, it would be nice if the explosion options had a "showParticles" option. that would be nice. maybe they can add that in the future
these are your only options though im afraid.. so you'll have to look at creating your own explosion from scratch if you wanted to have no particles
What are you trying to achieve?
Cause I'm creating an ultimate mass destruction explosion effect I already made the explosion particles so no need for that I'm trying to make the addon not too laggy
Like a 100 radius explosion
Setting blocks to air isn't hard.
It's not "random" compared to explosion.
The vanilla explosion might look round on a smaller radius, but when it's on a larger radius... not so much.
In a nutshell "Make Fancier explosion 🤪"
Is this Scratch? But messier?
Am i doing the correct way to make callback using functions?
If so, Why are typings not appearing??
@warm mason can you help
scratch for scriptapi
why not random.. get blocks under the explosion and do some math to get randomized blocks within a area
Vanilla explosions technically do janky raycast and set blocks to air. It's not truly technically random. There's also a need to check if the certain block has high blast resistance to not get blown off.
@random flint
help
/**
* @typedef {Object} detectPickupEventObject
* @property {Player} player
* @property {ItemStack} droppedItem
*/
/**
* @callback detectPickupEventCallback
* @param {detectPickupEventObject} event
*/
/**
* @param {detectPickupEventCallback} callback
*/
/**
* @returns {{ player: Player, droppedItem: ItemStack }}
*/
```\
literally tried every single JSDocs
but didn't work 😭
OH
FIXED
/**
* @param {function({player: player, droppedItem: item})} callBack
*/
this worked!!
Maybe make it into a class >:)
oh ya wrong function name it is detectPlayerDropItem
Im trying to get all the scoreboard objectives in a world and list them, but when i do JSON.stringify(world.scoreboard.getObjectives()) it returns [{}]
JSON.stringify(world.scoreboard.getObjectives().map(e=>e.id))
Ty
I use packets events to detect when player add something to the inventory, it might be better, no? search for packet type ItemStackRequestPacket (packet received) and TakeItemActorPacket (packetsend)
there is some packet InventoryTransaction
InventoryTransactionPacket
it's a bit more general, but I think it'll fit the best
Is there any way to view a player's live inventory with changes or should I just keep opening the chestUI after each edit? (or just say "inventory has changed - Refresh?")
is there a way to set an entity in love? i dont see a component for it
You could do a for loop to check a person's inventory and send each element of the loop into a UI
You could probably use Herobrine's chest UI script and change some stuff to do so
how do i get the result of a command, for example scoreboard players list @s ?
So my issue is the Live part.
I can make it keep opening after each edit, but that would get annoying quick
Just wondering if there's anything I can do with UIs that is efficient or smart
Just an issue that doesn't exist
couldnt you just force close and open it again
Yes and I do have instant opening UIs so it may be seamless if I try to make it seamless
I'll just see what I can do
is there something like world.deleteDynamicProperty(key);
how do i remove one dynamic property
Just set it undefined...
.setDynamicProperty(key, undefined)
world.beforeEvents.worldInitialize.subscribe((eventData) => {
eventData.itemComponentRegistry.registerCustomComponent("eidolon:hit", {
onHitEntity(eventData) {
const player = eventData.player;
const mob = eventData.hitEntity;
const loc = {
x: mob.location.x,
y: mob.location.y + 1,
z: mob.location.z
};
const equippable = player.getComponent("minecraft:equippable");
const item = equippable?.getEquipment(EquipmentSlot.Mainhand);
const offhand = equippable?.getEquipment(EquipmentSlot.Offhand);
if (!player) {
return;
}
if(item?.typeId === 'eidolon:sapping_sword'){
mob.dimension.spawnParticle("minecraft:critical_hit_emitter",loc);
if (offhand.typeId === "eidolon:sanguine_amulet") {
offhand.setLore(['']);
}
}
}
});
});```
Does anyone know why getEquipment is undefined?
const player = eventData.player; is wrong
should be damagingSource.damagingEntity iirc
Should I replace const player with this?
It's attackingEntity
also, since you're not setting it thru container, you need to put the item back to slot...
You good Minato?
lol, yeah
Wadahell those emojis 😭
confirming the two messages 😅
Which one is wrong? This?
it shouldn't be tho since he/she is using equipment not equipmentSlot
no one... i said confirming
sorry, I just finished eating 😬
so yeah, do const player = eventData.attackingEntity
also, you setting the lore but you're not setting the item back to slot, just do equippable.setEquipment(EquipmentSlot.Offhand, offhand)
Ok, Thanks
is their a way to encode my js and it still function? minly because im uploading it to mcpedl
by "still function" you mean "still works"?
obfuscate it
ye
not sure how
just use any online js obfuscator
that works?
"Javascript obfuscator" on Google and use any of them
yes
bet
@dawn zealot is English your native language?
script will still work on worlds tho right
cuz "still function" sounds like a mistake that a spanish speaker could do
still function sounds perfectly fine to me
oh nvm
idk, I won't discuss with someone whose native language is english, because I'm probably wrong
still function, still run all the same tbh
No. It's proper English and is in proper context
Function in this context just means work
effectively, i was wrong
ur good bro dw
how to get the loot item stack of a block that was mined?
playerbreakblock returns thee block permutation but not the loot of the block
and also how to run an event once when player reaches specific y level
Is there a way to check if cheats are enabled in a world??
runtInterval -> getPlayers() -> check location.y
Unfortunately there's no direct way, best you could do is check the very nearest mob spawned in the block using entitySpawn
js obfuscator is useless in that case just use GitHub so at least when they try to "steal" or "claim" you have proof its yours... On this day even beginners of addons or js know how to de ofuscate it...
also, why tryna to ofuscate it? Got something to hide?
Don't share it publicly if you don't want that code looked at. Deobfuscating the code is extremely simple these days. So you would be wasting your time with it.
Any way to cancel an Entity hit? or death
I tried using afterEvent and just re-spawning the entity, but is there any other way
how about adding just a bit health just before the entity dies
Tried it but Minecraft doesn't likes that- The entity will be stuck in a death-alive loop
i see
Well I can set his HP to max if he gets hit, but if you one-hit the entity.. it wont work
For canceling the entity hit, there is only way in JSON to use damage_sensor component. But i found a workaround. applying max instant health effect can make the entity invicible, just like when you hit a player who is in creative
Yes but I would need to edit EVERY minecraft entity then
I just want to cancel every damage or death on every entity
Why do you need to do so ? What are you making?
In short it's a Server Zone class, it should create zones that cant be destroyed
but players can hit entity maybe, so I want to make if hits a entity within the zone, it gets canceled
oh lol I recently made this similiar thing which i haven't completed, i made a entityHurt beforeEvent custom event. I just extended the afterEvent, and added a event.cancel property
Probably you respawned the Entity when the player kills it?
At last i've spent a lot on thinking on it. There's no other easier way than editing every single entity.json file and canceling in damage_sensor component. I think you should stop wasting your time on it just like me.
hmm
Ill just "heal" the enemy on taken damage and if it dies, I will warn the Attacker and respawn it
I didn't try making beforeEvent for death. I only made for canceling Hits
when teacher says thanks to his student
xd
im having a problem solving a problem:
[Scripting][error]-ReferenceError: Native function [Entity::remove] does not have required privileges. at removePlayer (core/HitboxSystem.js:76)
at onLeave (character/RPGPlayer.js:50)
at <anonymous> (core/PlayerManager.js:30)
basically im trying to remove some entities on world.beforeEvents.playerLeave. but it is throwing this error.
HitboxSystem.removePlayer
static removePlayer(player) {
const hitbox = HitboxSystem.#hitboxes.get(player.id);
const connector = HitboxSystem.#connectors.get(player.id);
hitbox.remove();
connector.remove();
HitboxSystem.#connectors.delete(player.id);
HitboxSystem.#hitboxes.delete(player.id);
}
const hitbox and connector return an entity
and this is ran on world.beforeEvents.playerLeave
as mentioned
static removePlayer(player) {
const hitbox = HitboxSystem.#hitboxes.get(player.id);
const connector = HitboxSystem.#connectors.get(player.id);
system.run(() => {
hitbox.remove();
connector.remove();
})
HitboxSystem.#connectors.delete(player.id);
HitboxSystem.#hitboxes.delete(player.id);
}```
try this
let me try that
Whenever you see the "required priviliges" error, just wrap the code in system.run(() => {})
It was a error with entty.remove() as always. I just put that code in system.run()
it works, thanks
Not in an add-on. You can, of course, by editing the player's animation controllers and entity definition on the client, but this bars compatibility with other packs doing the same. Should typically only be used in maps or worlds.
I don't think this should have to be said but please keep this out of this server. @round bone @dim tusk
Sorry 😔...
lol
Is there a variable you can use similar to a Float from here:
https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server.MolangVariableMap.html
But instead of floating a number it does a string?
why isnt this working?
is that even a component?
I doubt that's a component
There is no such component. You can delete all your code :)
Noo
Any alternatives to word Initialize in 1.21.70? Minecraft/Server 2.0.0-beta
worldLoad
to register custom components, use system.beforeEvents.startup.subscribe()
Example pls@unique acorn
just replace world initialize event with that...?
system.beforeEvents.startup.subscribe(data => {
data.blockComponentRegistry.registerCustomComponent('my:id', {
onRandomTick: (data => {
console.warn('Random tick')
})
})
})
It is possible to access the projectile thrown by the 'throwable' component?
like throw a trident and access it to run something
Technically yes, but you can't be sure that it's the right projectile for you.
yes
i think you need to use entitySpawn event, and then use getEntities and detect if the entity is trident
the customComponent onUse is affected by the 'use_modifiers' component?
Use modifiers are used for chargeable items (foods, shooters and throwables that are not thrown immediately such as tridents)
why instead of calculating the 48 iterations to spawn a ring, why dont you simply create a particle and spawns it?
its a simple stuff i dont think that code would be that bad, but instead of 48 operations and all fully sync, just create one ring particle and spawn it, or at least run stuff async ti nit block the thread
it works, tested
halp!
import { world, ItemStack } from "@minecraft/server";
// Function to spawn an item at a specified location
function spawnOreItem(dimension, itemType, amount, location) {
const itemEntity = dimension.spawnItem(new ItemStack(itemType, amount), location);
itemEntity.clearVelocity();
}
// Function to remove raw items at a location
function removeRawItems(dimension, blockLocation, rawItemType) {
// Convert to proper block location (integers)
const blockLoc = {
x: Math.floor(blockLocation.x),
y: Math.floor(blockLocation.y),
z: Math.floor(blockLocation.z)
};
const entities = dimension.getEntitiesAtBlockLocation(blockLoc);
for (const entity of entities) {
if (entity.typeId === rawItemType) {
entity.remove();
}
}
}
world.afterEvents.playerBreakBlock.subscribe((event) => {
const { block, dimension } = event;
const blockType = block.typeId;
const centerLocation = { x: block.x + 0.5, y: block.y + 0.5, z: block.z + 0.5 };
// Handle iron ore
if (blockType === "minecraft:iron_ore") {
removeRawItems(dimension, block.location, "minecraft:raw_iron");
spawnOreItem(dimension, "minecraft:iron_ore", 1, centerLocation);
}
// Handle gold ore
else if (blockType === "minecraft:gold_ore") {
removeRawItems(dimension, block.location, "minecraft:raw_gold");
spawnOreItem(dimension, "minecraft:gold_ore", 1, centerLocation);
}
});```
for some reason this isn't really working the way I want it to.
i'm trying to make it so the raw_ore doesn't drop, and instead is replaced by the ore block itself
but it just doesn't work at all lol
can't you edit the loot table
for a block? I dont think so
what is the current behavior of your code
It does nothing, I expect it to replace the item on the ground but the item still shows up
break ore, then raw iron shows up, on that tick its replaced with iron_ore_block
that should happen with the gold too
idk if getEntitiesAtBlockLocation would work for that
does it expect exact location or does it return all entities in that block
Doing it like that won't 100% work... It's better if you use entitySpawn.
How would you make a script that does this?
world.afterEvents.entitySpawn.subscribe((event) => {
const { entity } = event;
const dimension = entity.dimension;
const location = entity.location;
if (entity.typeId === "minecraft:raw_iron") {
// Remove the raw iron
entity.remove();
spawnOreItem(dimension, "minecraft:iron_ore", 1, location);
} else if (entity.typeId === "minecraft:raw_gold")
entity.remove();
spawnOreItem(dimension, "minecraft:gold_ore", 1, location);
}
});```
like this?
it doesn't seem to work haha
yeah because the entity typeId is "minecraft:item"
Get the component first.
const itemComponent = entity.getComponent("item").itemStack;
if (itemComponent.typeId == "minecraft:raw_iron") {}
Entity.getComponent('item').itemStack
you need the .itemStack
i forgor 💔
yippeee it works!
When registering commands, only one namespace can be used?
Or do I separate them into different startup event listener?
you can use the same event
It throws an error that the <namespace> doesn't match the existing <namespace>
code?
wait...
system.beforeEvents.startup.subscribe(({ customCommandRegistry }) => {
customCommandRegistry.registerCommand({
name: 'coddy:value',
description: 'testing1',
permissionLevel: CommandPermissionLevel.Any
}, () => {});
customCommandRegistry.registerCommand({
name: 'coddy2:value',
description: 'testing2',
permissionLevel: CommandPermissionLevel.Any
}, () => {});
});``````js
[Scripting][error]-Error: Custom Command Enum namespaces must match. Namespace 'coddy2' does not match existing namespace 'coddy'. at <anonymous> (main.js:477)```
and btw, I'm in version 1.21.80.27
try coddy:value2
I think that API has some sort of selection system for command namespaces
I hope they add permutation in the selection of blocks :)
What?
In the custom commands enumeration
Block states or?
You can override loot tables I believe
Endstone has already implemented this feature
script ay pi eye
Finally inventory events...
I can finally optimize my code
True, I still have to wait until it appears in the release
yeah
wait what- inventory events...?
where
wdym
#1019665690233405500
PlayerHotbarSelectedSlotChangeAfterEvent
PlayerInventoryItemChangeAfterEvent
also
I dont see them in preview docs..
are they just planned for future changelog
Or implemented in preview api
What is this for?
UH
???????
WO
PARTICLES REPLACEMENT
shapes
YAY
well, not in that sense
but we can use them in place of particles in some use cases
bro send code send code
how to do this
how did you
Can you tell me please how to use that DebugLine
debugDrawer
also wow, DebugText?? No more using entity nameTags !!
ah they added stopSound and it broke my function... stopSound didnt exist so i did stopsound function with commands lol no longer need of functions yay
gtg in a bit but sure
You remember you gave me a fillBlocks script that divides into two filBlocks operations when max limit of blocks reached?
yeah
I have the script
I just need to do a system.waitTicks() after each fillBlocks, But i don't know where you divided the operation..
iirc i have the function return chunks array
whats wrong with that one?
I can finally make what I want 🔥 🔥 🔥
@distant tulip
turn the function to async and remove the runjob
well, i recommend you to work with runJob, but that what you asked for
i gtg for now
@prisma shard #1364266284308631594 message
Umm, quick question... Idk how v2 custom components works but those param values are only read only and can't be changed?
ooo okay cool
do unlit campfires have a hidden block ID by any chance? Looking into making my shovels put out campfires to match vanilla, but I'm not seeing any block states or components on campfires to let me do that.
nope, just the lit block state.
I lied, extinguished
yeah woops, I was being stupid
Smh smh
nothing wrong with it
That's just the : between
i see
it is for "direction"
I thought the "" are around :
Why is there also "direction":0 tf. I just realised that
uhm, nothing wrong with it..
But why is there 2 direction states?
might be block state backwards compatibility
it doesn't use direction
Perhaps
He just printed out code like this
Cardinal is string[south,north,east,west]
and direction is number
Yes, but there's only 4 directions for a campfire, so it doesn't make sense for it to have more than just the Cardinal directions
idk
Also, is there any functions you would like for the files? @prisma shard
Wdym
What files
i did a lot commit in my repo you saw?
I have divided most of the functions into categories, maybe you can add anymore functions regarding it
each hass its own class
Yes, but I mean is there any specific functions that you would like that isn't done yet
I am currently unsure of what I want to add
How do I add an item to an allay hand? I've tried spawning one and getting it's inventory component but it doesn't show up visually nor drops it
commands
So with scripting it's bugged?
How do you even do that, there is not /data set command
you would set the item in the mainhand slot by getting the equippable component but it's disabled for non-player entities so you have to use replaceitem instead
/replaceitem entity @e[type=allay] slot.weapon.mainhand 0 emerald
Ah thanks. Ah yeah I didn't see any equippable component for that entity. The entity I have to spawn is mine actually, do you know if merely adding the equippable component would be enough for it to appear in the model (which has a rightItem bone)?
you only need to have enable_attachables set to true in the client entity file
well i do have that, allay has it too. So would i need the command for my own entity aswell right?
yes
alright, luckily entities have a runCommand so i can target that one precisely
guess its not @ s
I could swear that was for self
the command shouldn't have a / before it
it was also mising an entity. this one worked. it does support the redundant /
crazy that they added a component for this stuff and didnt bother to hook it up properly requiring workarounds like this
it used to work, but they disabled it
only reasoning I've seen is that it's weird for foxes to hold items in their mouths by using the mainhand slot
have they added infinite duration in the add effect method yet
I'm using the spawnEntity to spawn a projectile and then apply impulse to it. Is there any way to bound the projectile to the player, so it don't cause damage and show the right death message?
where can i find the list of valid biome types?
import { world, ItemStack } from '@minecraft/server';
world.afterEvents.itemUse.subscribe((event)=>{
const player = event.source
const projectile = player.dimension.spawnEntity('minecraft:arrow')
const projectileCommponent = projectile.getComponent("projectile")
projectileCommponent.owner = player
projectileCommponent.shoot(
multiplyVector3(
player.getViewDirection(),
3
)
)
})
function multiplyVector3(vector3, m){
return {
x: vector3.x * m,
y: vector3.y * m,
z: vector3.z * m,
}
}
it's stable?
no, if i didn't miss anything
should be
tysm

use runcommand
yeah ik
it worked, tysm
if I save a ItemStack in a variable, can I spawn it in the world?
const item = new ItemStack("minecraft:stick");
world.getDimension("overworld").spawnItem(item, { x: 0, y: 0, z: 0 });
yeah it'll keep data
I mean, if I get the item stack from a event like, itemUse after event, then store it in a var, can i spawn this item?
clearTimeout
Yes
What's the quick way to prevent TNT breaking blocks within a range? I can't cancel it so I'm trying to just set the block back?
world.afterEvents.blockExplode.subscribe(event => {
const block = event.block;
const claim = getClaimAtPosition(block);
// === Standard protection check ===
if (claim && !hasFlag(claim.flags, CLAIM_FLAGS.MODIFY)) {
world.sendMessage("Explosion detected in claim")
block.setType(block.type)
}
});
Detect entity spawn.
Is that the only way, because the event.block only has X Y and Z?
ai usually does worst..
I want to allow explosions, but not break blocks inside a certain range
sorry for bother, but is possible to do this storing the item in a dynamicProperty?
No you can't store an item directly in dynamic property
yeah
you can't store em
however you can save the important stuff like item name, lore, enchantments, etc... then when you need to load the item, create a new itemstack then set it's data
maybe
Yo does anyone know how to add hunger like a food item?
world.beforeEvents.explosion.subscribe((data) => {
// Force the explosion to not destroy blocks, but it can impact entities still.
data.setImpactedBlocks([]);
});
This would look like an option btw
Though idk if I can detect where the explosion is by coordinates?
Yes, since getImapactedBlocks() returns array of Blocks itslef.
Ahh right, thank you!
i think if u use something like
if (ev.entity.typeId === 'tnt') ev.entity.remove()
})```
And?
I mean yes you can use it but this works in any explosion vanilla or custom
nvmd i thought he was trying to prevent the tnt from exploding at all...
@dim tusk Do you know any behavior manifest generators?
I made one...
gimme
world.beforeEvents.explosion.subscribe(event => {
let impacted = event.getImapactedBlocks();
})
This gives me a "not a function" error which is odd
Stringifying event and logging it shows {}
hacked me
Misspelling, you just copy my message lol
event.getImpactedBlocks()
🤦♂️ Sorry my bad
You're trying to select locations to be not affected...?
Yeah! All working now, thanks!
let impacted = event.getImpactedBlocks();
for(let block in impacted) {
let claim = getClaimAtPosition({"x": block.x, "y": block.y, "z": block.z});
if (!claim || hasFlag(claim.flags, CLAIM_FLAGS.MODIFY)) {
impacted.splice(impacted.indexOf(block), 1)
}
}
event.setImpactedBlocks(impacted);
Nice but small modification... Try making another variable instead of changing/modifying the impacted variable...
I did try creating an array, but because it wanted a Block[] I wasn't too sure how that worked. I know what that is, but in plain JS I'm a little clueless
const impacted = event.getImpactedBlocks();
let filteredBlocks = [];
for (let block of impacted) {
const claim = getClaimAtPosition({"x": block.x, "y": block.y, "z": block.z});
if (!claim || hasFlag(claim.flags, CLAIM_FLAGS.MODIFY)) filteredBlocks.push(block);
}
event.setImpactedBlocks(filteredBlocks);```
Hmm I tried that and it said error converting array or something - just closed out so I don't know the exact error
@dim tusk
its a rick roll chill
I literally made it as simple as possible but I guess you made it even more harder for mobile users.
Tf you mean rickroll?
Haha. funny.
Ahh I see why mine won't work... error on my part. Thanks!
Is it possible to spawn an entity facing the same direction as the player who summoned it?
Yes.
Do I have to add minecraft:interact if I am detecting interaction using the script api?
not if you use beforeEvents
yes.
k
How do I access the afterEntityHurt event signal
world.afterEvents.entityHurt.subscribe(({ hurtEntity, damageSource: { damagingEntity, damagingProjectile, cause } }) => {
// ...
});```
im trying to recreate beta 1.7.3's armor system but I just cant get it to work right.
Basically when taking damage, it should try to heal the player back to what they should be based on the armor and durability
for some reason though, idk how to set health to the player
I wish we had beforeEntityHurt :(
we all wish
💀 aw hel naw.. It just started... Keep watching what'll happen next 😭
And he also sent me the final result 💀
That's "smell of curry"...
nope
You mean the person @smell of curry ?
or smell of a curry
I'm talking about the skin my guy...
Idk its a online skin not a private skin
jeanmajid and smell of curry ig both guys use this skin
Im not asking you.
I am not the person stealing skins
anyways
@deep quiver Why you use Smell of curry's skin
btw you know "Spyderrock"?
Yeah this conversation went from debug lines to skins Bruh
yes yes
He makes a bit weird addons, but i used to play them
How to get how much time it takes before 8th phase of moon without manual calculation?
He rarely makes addon, he mostly do showcases...
Starting to be off-topic lol
Throwback...
Yeah i used to play his "Structure expansion addon" so i told that
Yeah he makes cool showcases
what
Just a lil throwback since I have deja Vu that I have already talk with this guy lol...
And I'm not wrong...
Oh lol
He just helped me with a script a biit ago
He's a great guy
and very experienced with script api
I know him from bedrock commands community
He work for the studio you are working on, what are you talking about, lol
ok... But I mostly see him/her do showcases can't blame me about that.
dude, I have very short memory... I say hi today, I'll forget 20 minutes later what I just said oof
true
I was working on a project he worked on
studio?
Withercore
also, I was gonna going to uh make the website in github
But
It asks me to create a enterprise account
Search on YouTube
How to make GitHub pages website
You told me its free right?
It's a trial for 30 days, that doesnt mean free
Is that private repo
It is not, ignore that thing
nope
This is getting off topic, so...
cool
-# Make the website offline usable
mhm
But its for mainly downloading my addons
You cant reallly download files in offline right?
are you sure about that?
idk
you can download.
ooooh okay
if those files are local you can download them otherwise no
i see
Heya! sometimes due to lag and stuff, playSound and camera etc are not triggered which leads to player's camera being stuck forever. how can i prevent it?
That's a tough one. First see if you can determine what is causing lag. Then try to reduce it.
Hello where do I ask about setting bridge up so I can link it to Minecraft like the development addons feature
as the new minecraft bedrock beta released @minecraft/[email protected] is now released as stable version, does it mean we can use custom slash command registry in the current minecraft release version?
if its stable
Aren't the slash commands still in preview?
ye
well I thought that if the 2.0.0 was released as stable then the custom slash command would be included in the released
its stable starting from this version
I hope they will add it in the next update of the minecraft release version as beta, as long as we can use it
it will be released to stable with 1.21.90 ig
can we read the content of a bundle with scripts?
No.
¯_(ツ)_/¯
danm, i had a crazy idea of using a custom bundle item locked in a slot plus json ui to give the player extra equipment slots
How do I add auto completion to bridge in my addon development
Step 1: use VSCode
Okay I already have vs code
Step 2: install node js
Where?
on your computer preferably
No I mean the best place to download it
your Downloads folder works fine
dude... lol
just search for it
the official site is top result
u can use my redirects
https://is.gd/benpm0 - for json
https://is.gd/benpm1 - for text
how do i add an item tooltip?
Ive tried using itemstack.setLore(["some text"]) and on tooltip nothig happens
reset item
re-set
?
......
kinda, he was dragging it out tho
yeah i think you really didnt take it as fun.
it is, just got confused to why did you need to send the screenshot
made me question that i did something wrong
oh lol
AI is so shit
i told him about documentation 3 times
but he still cannot find getEntitiesFromViewDirection()
I don't use AI really often tbh
sometimes it says getEntity(), sometimes it says getEntityFromVector()..... bruh
🤖
And when i finally said you Have to use getEntitiesFromViewDirection() and he used player.getViewDirection() inside it 😭
whereas getEntitiesFromViewDirection already gets the entiy from players view direction
anywayys
.
anyone know what is the best Vector3 class among all?
i know @minecraft/math already has one
but someone know any that has most methods for vector3
how to i set an item in a bundle via scripting? i dont see a component for it
Can't.
an darn. guess i'll need to store the stuff using dynamic properties
anybody ever did something like that? storing item id an amount is easy but anything more would get lost
Nah that’s not a must, bridge is valid
Do you know the best Vector3 class?
there are a lot of vector3 script, i am unsure which is the best
check pins
I did one back then but it has simple math functions https://discord.com/channels/523663022053392405/1290669820311765042
yuh but it has simple math functions
.
as i said
Check the one from Madlad
okie
very interesting. I wonder however, wouldnt that break if somebody were to break that block it spawns way above the player to store the items?
I'm getting an error saying "cannot set dynamic properties on stackable items"
My item has a max stack size of 1
bet its another bug
no
send code
Blocks cannot have max_stack_size != 64
How it will detect if I want to click the button that's say tools shops it will open the tools shops GUI what's need to be improved
import { world } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"
const ui = new ActionFormData()
.title("Form")
.body("")
.button("button1")
.button("button2")
.button("button3");
const customUi = new ActionFormData()
.title("Custom Form")
.body("")
.button("Tools Shop", "textures/ui/Tools")
.button("Blocks Shop", "textures/ui/Blocks")
.button("Farms Shops", "textures/ui/Farms")
.button("Ores Shop", "textures/ui/Ores")
.button("Utilities Shops", "textures/ui/Utilities")
.button("Armor Shops", "textures/ui/Armors")
.button("Foods Shops", "textures/ui/Foods")
.button("Spawn Egg Shops", "textures/ui/Egg")
.button("Template Shops", "textures/ui/Template");
world.afterEvents.itemUse.subscribe(async (event) => {
const { source, itemStack } = event
switch (itemStack.typeId) {
case "minecraft:compass": ui.show(source); break;
case "minecraft:clock": {
const res = await customUi.show(source);
res.selection //This Is Number Will Be Derived From The "collection_index" property of a button in JSON UI
world.sendMessage(Button ${res.selection} Has Been Pressed!)
break
};
}
})
Please tell me how
dafuck is this
Also , its .getDynamicProperty("id")
your doing like .getDynamicProperty(id)
whwts wrong?
id can be a string variable
#1067535608660107284 message
#1067535608660107284 message
#1067535608660107284 message
#1067535608660107284 message
Oh, I mistook you for that guy.
...
xd
Ah, yeah, he sent only part of code, so i was confused
yeah as they have same id since its its block item
item is fine and its my item which has max stack of 1
item is also returning isStackable true which makes 0 sense as thats not what its documentation says
Yeah thats the only time I actively show anything, but I do way more random stuff. Nowadays I became way less active only producing for the marketplace here and there for some teams and doing random creations
Ive been using it since that skin got released lol
Short links to my repo for viewing module details, which saves me time. I can use this to find out the most recent module version from anywhere.
how cool would be if we could get the unique id of items
what are you confused about
json ui
Item.typeId ?????
Thats typeId, not id.
aux ID?
unique id !== typeId
typeId is unique
?
@wary edge can I ask something msg
yes
- https://dontasktoask.com
- dont ping mods :)
Well, you can view this manually, but it would be more convenient with a script...
they dynamically shift
I was thinking more of way to check if an itemstack in your inventory is different from another itemstack instance
?
aux id shift as you add custom items
This is bad
items don't have id related to that does they?
I wouldnt be wishing for a way if they did
@oblique mica please ask here directly
you have a bigger chance getting an answer here than dm
if it is private matter say so
Okayy
or are you not talking about the method to retrieve it, and asking if it exists overhaul?
im not sure.
i mean it could be an internal thing
that why i was asking
import { world } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"
const ui = new ActionFormData()
.title("Form")
.body("")
.button("button1")
.button("button2")
.button("button3");
const customUi = new ActionFormData()
.title("Custom Form")
.body("")
.button("Tools Shop", "textures/ui/Tools")
.button("Blocks Shop", "textures/ui/Blocks")
.button("Farms Shops", "textures/ui/Farms")
.button("Ores Shop", "textures/ui/Ores")
.button("Utilities Shops", "textures/ui/Utilities")
.button("Armor Shops", "textures/ui/Armors")
.button("Foods Shops", "textures/ui/Foods")
.button("Spawn Egg Shops", "textures/ui/Egg")
.button("Template Shops", "textures/ui/Template");
world.afterEvents.itemUse.subscribe(async (event) => {
const { source, itemStack } = event
switch (itemStack.typeId) {
case "minecraft:compass": ui.show(source); break;
case "minecraft:clock": {
const res = await customUi.show(source);
res.selection //This Is Number Will Be Derived From The "collection_index" property of a button in JSON UI
world.sendMessage(Button ${res.selection} Has Been Pressed!)
break
};
}
})
How can I make this work like if I click a form button no 1 it's open GUI I'm trying to make a shop
I tried that
If the object ID in memory is the same, it will be true
I dont think it worked.
also isnt there problems with testing if objects equal other objects?
@distant tulip?
I would say I would just stringify the objects first, but doesnt itemStack return empty {}
your question is not clear
That's why I want to ask privately
sure, lets move there
Can you help me script it so if I click the tools shops it will open the tools shop gui
Why? Just why? Make a post, let other people help and not just one private person.
I did make a post
also if you make a post, you can help other people having the same problem
But no one answer
patience
Don't you'll understand
we can't pass item component registry to other functions from 2.0.0-beta?
Wdym?
nvm
it actually isn't working wait
export function registerItemComponents(data: mc.ItemComponentRegistry) {
long_swords.register(data);
misc.register(data);
}
I have this and it stopped working
how would I make it so when a block is placed in water, the iswaterlogged is set to false after placement?
nvm I figured it out
import { world, BlockPermutation } from "@minecraft/server";
world.beforeEvents.playerPlaceBlock.subscribe((event) => {
const block = event.block;
const player = event.player;
const dimension = block.dimension;
const location = block.location;
try {
event.cancel = true;
const permutation = BlockPermutation.resolve(block.typeId).withState("minecraft:waterlogged", false);
dimension.setBlockPermutation(location, permutation);
player.sendMessage(`Placed ${block.typeId} with waterlogged=false`);
} catch (error) {
player.sendMessage(`Error: ${error.message}`);
}
});```
import { world, BlockPermutation } from "@minecraft/server";
world.beforeEvents.playerPlaceBlock.subscribe((event) => {
const { block, player } = event;
const dimension = block.dimension;
const location = block.location;
try {
// First check if target location contains water
const targetBlock = dimension.getBlock(location);
if (targetBlock.typeId !== "minecraft:water" &&
targetBlock.typeId !== "minecraft:flowing_water") {
return; // Exit early if not placing in water
}
// Only proceed if placing in water
event.cancel = true;
const permutation = BlockPermutation.resolve(block.typeId)
.withState("minecraft:waterlogged", false);
dimension.setBlockPermutation(location, permutation);
player.sendMessage(`Placed ${block.typeId} with waterlogged=false in water`);
} catch (error) {
player.sendMessage(`Error: ${error.message}`);
}
});```
I tried to do it this way, but the game returns that "minecraft:water does not have the waterlogged property"
you can do that without canceling the event
afterevent > block.setWaterlogged(false)
I wanted to optimize it by detrecting water and only running the anti-waterlog after the fact
I guess this works though
how do I prevent buckets from waterlogging blocks?
cancel itemUseOn
That would work, but if a player sneaks and places water, I want the water to still be placeable on the block, just not in it and waterlogging it
need a bit of logic but it is easy enough
which event runs after reload anyone tested ?
Wouldnt it just be the normal amordering when a world loads?
Have dought for the world load event
It's just a fact that is better than writing code in javascript.
🤮
Subjective.
i tried to say it's better to write code in typescript.
You are safe from all type errors you could have
TS is ok, but I still don't care for it. I prefer compiled languages with strict typing.
I'm safe from type errors because I literally wrote the code
Total skill issue
Don't forget your apple juice with the bendy straw
What is the most stable npm version now?
NPM itself or API?
Npm itself @minecraft/server
Stable: 1.18.0
Stable Beta: 2.0.0-beta.1.21.70-stable
https://www.npmjs.com/package/@minecraft/server?activeTab=versions
Contains many types related to manipulating a Minecraft world, including entities, blocks, dimensions, and more.. Latest version: 1.18.0, last published: a month ago. Start using @minecraft/server in your project by running npm i @minecraft/server. There are 66 other projects in the npm registry using @minecraft/server.
Thanks
What's the best way to create the impermeability of a moving world border? Knockback won't work because people could always just stand behind a block. Teleportation is the next best thing I can think of, but it is choppy and messes with player rotation. Does anyone have any other ideas? Thank you.
I installed the node.js in my device then went to visual studio code then open the integrated terminal in my BP then went to the side where you copy paste npm then I input the version in the integrated terminal but there was a red pop up issue
You can preserve player rotation with tp
You could also do both
Try and knock them back and if their location isn't changing then send them to the shadow realm
There's also the alternative method, which is to start to kill the player, that usually makes them turn around
@bronze pulsar
I’ll probably end up doing a combination of both. Knock back first then if that’s not working, teleportation.
Thank you.
It isn’t a block, it’s an entity. And the entity during an operation lasts for 6ms before getting saved into a structure, so here is no way to break the system
i believe entities yes
there are things u can do to have client sided entities
particles are easier but i dont know if they can be seen through walls
you quite literally just do player.dimension.spawnParticle instead of world.getDimension(aaaa).spawnParticle
yeah i have no clue either sadly
Nono, it's player.spawnParticle()...
player.dimension is equivalent to world.getDimension()
You just used the current dimension of the player...
whoops
nothing is causing lag, it works perfectly in single player or LAN but in multiplayer with players with high ping it doesn't works.
Is there a way to import a structure file in the behavior pack as a structure?
Export the structure via the structure block and drop the file into the structures folder in your BP
Its there already, my issue is importing said structure with the api at present.
Its saying it cant find the id.
prefix:test/ex/red1
world.structureManager.place(id, dim, origin);
I can confirm its in the "prefix" folder in the structure folder, I can also confirm its in "test" inside of "ex" folder.
the mcstructure file is named "red1.mcstructure"
Here's a better example.
<behavior_pack>/
└── structures/
└── prefix/ ← my “namespace” folder
└── test/ ← my subfolder
└── ex/ ← second subfolder
└── red1.mcstructure ← my structure
The id, I'm trying to use for the structure api is this.
prefix:test/ex/red1
My goal is to be able to place a structure file thats it.
world.structureManager.place(id, dim, origin);
Atm, its saying its missing which tells me its possibly not in the expected format?
Solved it, okay so it uses just a normal filepath.
without the extension 👍
👏
It just put me off because of how it is in actual features jsons 😮💨
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-gametest/simulatedplayer?view=minecraft-bedrock-experimental
how can i spawn this "player"?
or is it even possible in singleplayer?
import { world, system } from "@minecraft/server";
import * as GameTest from "@minecraft/server-gametest";
GameTest.register("namespace", "name", (test) => {
const player = test.spawnSimulatedPlayer({
x: 1,
y: 2,
z: 1
}, `Player-Name`, "survival").maxTicks(100).structureName("structure").tag(GameTest.Tags.suiteDefault);
});
You need a structure in your bp so it spawns, to spawn it just do /gametest run namespace:name (you can change the name)
the player will despawn after 100 ticks but you can change it
the string in .structureName("structure") should be my structure's filepath, right?
Yes
When you finally spawn it, can it leave the generated structure?
by the navigation methods for it's class
yep
alr tysm
it can't move if the location you gave it is outside it's chunk tho
that's a problem, do Entity class methods like teleport work on it?
and the moveToLocation is structure location based not world location
it is not as good as i thought
it can move to entity location which could work if you spawn an invisible entity in a location and tell it to move to it
yet if the entity is outside it's chunk, it'll just freeze and not move
hmm, it's truly for just gameTEST, I can't do anything that funny or interesting with it 😭
High ping players aren't something you can "fix" from the server side. They're always going to be out of sync, and it’s going to cause problems such as rubber banding, teleporting, missing hits, etc.
One thing you could try is to measure response times with each player in the world. A game of ping pong. Basically create a makeshift ping tool in your behavior pack to verify if a player is having extremely slow responses. Then kick them, because there isn't much that can be done beyond that in a sandbox environment.
Plsss help me😭😭😭
google the issue :D
Finally solved it I must install the npm in the window terminal not in the vs code
useful stuff
#1364625093841522779
debug utilities?
Ye
By red pop up issue, I think you mean it says "npm i" is not a command. Even if Nodejs is installed, Means this that your Nodejs is not set up in system variables, so the npm command doesnt work globally, which i had this issue before. I fixed this issue by doing:
Go " this pc " -> right click -> properties -> Advanced system settings (on right panel) -> Environmental Variables (Advanced tab) -> There is a "system variable" named Path -> click on Path text -> click edit -> click New -> paste C:\Program Files\nodejs -> Ok -> Ok -> Ok (close all) -> restart PC -> open VSCode -> open terminal -> paste npm i @minecraft/[email protected] (your command as you want your script version) -> wait until package gets added -> open a main.js script -> import { world } from '@minecraft/server' -> If it shows the properties of world class, as typings, that means it works~!
And yes, I wrote a whole youtube tutorial for you~
Well I followed a different path I actually used the command prompt in the windows to install the npm
holy essay
lol
And it works just fine
yk, why i put effort writing these for him?
I suffured 1 month for not getting to install typings
For this same issue
Uh Oh~ 💀
so i wrote this for nothing
you couldve told you've fixed it
😭 ..
I don't have YT
I am planning on to making one though
Yeah I did it
do it so I can say "drink water" in your comment
lol :)
Did anyone here created there own custom explosion effect without particles
how?
that's such a cleaver way of doing it, you spawn a bundle item entity and kill it with lava to reveal its content, but does it preserve the order of the items?
debug-utilities shapes and rays to calculate hitbox
check his post
yes, if you look at the last image of the post you can see the test i did and it does keep the same order
That's incredible, really useful for custom equipment slots
how do I open a .mcstats file from the /scrip diagnostics startcapture command?
is @minecraft/server-net and @minecraft/server-admin can be used in normal worlds like @minecraft/server
No.
you can use server-admin but only transferPlayer() function
How do I access a block's seconds_to_destroy property in scripting?
why
does anyone know why when I add loyalty 3 to a trident it gives me an out of bounds error
loyalty 2 works tho
Are enchantment levels 0-indexed? That would imply 3 is Loyalty IV
no
What does .unsubscribe do?
[Scripting][error]-Unhandled promise rejection: EnchantmentLevelOutOfBoundsError: When trying to add enchantment instance - Tyring to set enchantment level to 3, range for type loyalty is [0 - 3]. at createItem (utils/item-maker.js:14)
at giveLoot
this game gives me a headache
does anyone know what's going wrong here
stop an event listener
const id = word.afterEvents.x.sub
word.afterEvents.unsub(id)
Will need to share some code to give more insight on how you are applying it.
.addEnchentment({ type: new EnchantmentType("loyalty"), level: 3 });
and loyalty 2 is working
I give up, it doesn't matter anymore
If setting it to level 2 works but level 3 is throwing an out of bound error then that would appear to be a bug within the API. Would need to be reported so they are made aware to fix it.
I restarted my computer and it stopped erroring
no clue what that was
it just works now? lol
well it couldn't be, since I was getting that error
yeah no clue then
That's a wild issue there but at least it sorted itself out haha.
yeah I'm glad
just very weird how the error is like "trying to set level to 3" then says the range is 0-3 😂 how does that make sense
I was pretty confused myself. I could only make sense of it being an internal issue with the API.
just bedrock things
Wouldn't expect anything less.
Since when was this added
has anyone seen this error before?
[Scripting][error]-InternalError: too many closure variables
[Scripting][error]-Plugin [pack.name - 1.0.0] - [main.js] ran with error: [InternalError: too many closure variables]
huh
thats new
well thats a new one
what exactly are you doing?
how many variables did you define in the outer function lmao
7000 ish?
Thats quite a bit
Is there any way I can detect an entity after it shoots projectiles cause I want to do something after the entity shoots the projectile?
you can detect when the projectile spawns.
Documentation for @minecraft/server
I wanna do something about the shooter of the projectile anyway to trace it
get the projectile component on the entity, and get it's owner.
Documentation for @minecraft/server
i have an addon with around 120 seperate js files in it, would i gain any performance benefit by condensing all these files into a singular main.js?
Is there a ‘Forward’ ‘Back’ ‘Left’ ‘Right’ buttons in playerButtonInput event?
minimal impact in the worst case
better keep it splitted
thank you!
no
👌
import { world } from "@minecraft/server";
world.afterEvents.entitySpawn.subscribe((event) => {
const entity = event.entity;
if (entity && entity.typeId === "zombie:explosion_cast") {
const projectileComponent = entity.getComponent("minecraft:projectile");
if (projectileComponent && projectileComponent.owner) {
const owner = projectileComponent.owner;
world.sendMessage(`Projectile was shot by: ${owner.typeId}`);
} else {
world.sendMessage("Projectile has no owner.");
}
}
});```
there is no errors in the debugger but why cant i trace the owner?
OH MY GOD NODE????
how are you here online
i thought you've left scripting or what\
DIdn't expect you to be online shock
player.isOp()
it's in beta I think
ah ok
thanks!
Also it might not work on players that aren't the ones hosting the world, only world creator
in bds it will only work on players with operator level 4
And in realms it won't work
good one mojang
so i have my own entity with a projectile component and im using shoot method as soon as its spawned. Thing is it looks like its taking a second for it tostart moving for the client, more than i would expect at least since theres bound to be some communication delay
so basically it looks like you get the projectile still infronf of you for half a secondbefore it actually starts moving
Are you using system.run()
bcoz that makes somth happen after a tick
who knows could make the arrow lag
no spawning and shoot happens in the same script. same effect as using add impulse
hmm
i would expect a 1 tick delay, this noticeably longer
