#Script API General
1 messages · Page 107 of 1
Only one way to find out. Fire up a fresh world and do it lol. Then verify with an NBT Editor.
Does anyone have a link to a custom slash command example in javascript?
Oh wait the wiki has one
Ty
looking at the game dp, they are stored in the entity itself, it get removed when the entity die or despawn (unless player) so yeah it does get removed
i see, thanks!
does anyone know a good way to simulate an elastic movement with applyKnockback/Impulse for entities?, i want to simulate a Black hole and when entities go through its center they do some elastic-like movement
LOL HE ASKED YOU 4 TIMES, you gotta be so confused after asked thrice
i was
uhh... Math...
Is there an easy way to detect when a block is placed and what block is was placed on including if it was placed on the side of said block?
Documentation for @minecraft/server
yeah i know, but I was hoping there was an easier way...
Sup, how do you like make teleporting instant
What am actually trying to do is like a system where left click activates something ,even on air especially for mobile players,
so I made it when you hold an item a mob spawns on your head that if you click it activates the stuff, and I made the mob always to to your head
But it's bad when the player is moving so I calculated the velocity of the player and accounted for drag and stuff to get the location of the player the next tick
But the entity like still lags behind when the player is moving
Sorry for the yap
wdym by "instant"
Like when mobs teleport it takes like half a sec or more to get there
it doesnt, it might appear that way because its smoothed by the client side
Then my maths prolly wrong then
I dont see any way to get the block that the player placed. I can use the itemStartUseOn after event and that seems to work tho
The permutationToPlace
you might have better luck trying to attach your entity to the player, but i think that requires editing the player.json
learn conic sectiona make an ellipse iterate every step of the ellipse's location
Ok bye making the entity ride the player right,tnx
You cant make entities ride players.
Because things are hardcoded. Just because vanilla can doesnt mean addons can.
thats not true, i have made an addon that lets players ride other players, so you can get anything to ride players
Modifying player.json?
yeah
Yeah not recommended. Good luck though then.
make a custom entity with the parrot_tame family
Sup can you hit stuff that are riding you
It works without it tnx
It seems you can't
you modified player.json?
Yh,but it seems you can't hit the entity when it's riding you
just in case you don't want to edit player.json
goodluck with compatibility though
Oh
Compatibility is a dream long forgotten for my add-on,too many limitations without editing player json
basically an entity that have the parrot_tame and every entity can ride it
so you make it ride the player and make any other mob ride it
even if the player have a parrot you can just make it ride that entity instead
I thought about that , I was scared I'd try it and it wouldn't work + am already having burn out, any way tnx,I'd continue tomorrow
so entities with parrot_tame comp would allow it to ride the player?
family
I see, thanks
Can you click it?
is Entity.getDynamicProperties not a method?
Like hurt it?
Documentation for @minecraft/server
😭
script API be making no sense sometimes man
there's a Entity.setDynamicProperties method, which I feel like infers that there's also an accessor to go with it but okay I guess
day 4 learning ScriptAPI💦
the inconsistency
at least you haven't triggered watchdog
exactly!
It's not really inconsistent.
It's just how and what would it return. We had a previous convo about this either here or in OSS.
#879773489601585244 message
oh yeah it's ids, there's really no getDynamicProperties() so yeah
what do you mean?
this exists, but there's no getDynamicProperties to go with it
which yes I can filter and map the dynamic property ids to get what I want from them, but that's not the point of it
though I do see the argument against it for the reasons that smokey said above
but i dont think it should exist, what exactly do you expect getting from it?
if that existed
because for me a way of batching dynamic properties is enough
How to detect a player head with event entityHurt?
player.getHeadLocation();
How to detect when a player shoots an entity with a specific projectile then plays a command on the player who shot the projectile?
use projectileHitEntity afterEvent
Documentation for @minecraft/server
I'll tryy thankss
it works!! but how do I check for the entity's health that got hit?
const projectile = event.projectile;
const gotHit = event.getEntityHit;
const player = event.source;
player.addTag("shoot");
});```
entity.getComponent("health").currentValue
Also check if gotHit is still valid
How do I define this?
tried this but it says undefined
const projectile = event.projectile;
const gotHit = event.getEntityHit();
const health = gotHit.getComponent('health').currentValue;
const player = event.source;
player.addTag("shoot");
});
Maybe gotHit is already dead
.
Try it again on an entity that survives the shot
It says not a function
For what?
this line is not a function
const health = gotHit.getComponent('health').currentValue;
Is the entity your shooting dying?
No
Right your get entity hit is wrong
add an .entity at the end
Now it works. Thank you so much!
Hello everyone! I updated my game to version 1.21.100 yesterday, and all my scripts in my addons stopped working. Does anyone know what's going on?
is there any errors in console when you join the world?
A simple solution for holes. Contribute to mcbe-mods/Hole-Filler development by creating an account on GitHub.
Woah woah woah dude ☠️ a reply to very very old message from 2024
Lmao
I was looking for a way to fit the custom throws in line with the snowball throw trajectory, but never got around to it!
manifest, files, versions, a lot could happen
I think it's still easier to recreate PVP system rather than modifying it
entity hit entity event -> clear velocity
does it really clear velocity? I tried jumping verically then clearvelocity then applyKnockback but the knockback seems to vary and not fixed
applyKnockback behave differently if you are in air, ground, falling or rising
also, not sure about the player
Welp I guess I'll just research more of it
Does applyDamage ignore armors?
no
Okay nice
Knockback
So? What do you need?
what values?
...
You ask for values for applyKnockback, but there could be any values, so I don't understand what you mean.
Horizontal force
VerticalStrength
aand?
you can put a number there, like, from 0 to however many you want
I know
I need beforeEvents for entityHitEntity, i removed vanilla PvP, now I need a knockback replica of vanilla pvp
applyKnockback({ x: 0, z: 0 }, 0):``` its used like that read documentation
Wha
Well, you just need to experiment.
I tried everything, it feels weird lol, that's why I came if someone did it
Oh you mean vanilla entity hit replica values?
😭 yes
let horizontalKB = 0.2789
let verticalKB = 0.1023
let knockbackX = victimLocation.x - attackerLocation.x;
let knockbackZ = victimLocation.z - attackerLocation.z;
const magnitude = Math.sqrt(knockbackX * knockbackX + knockbackZ * knockbackZ);
if (magnitude !== 0) {
knockbackX /= magnitude;
knockbackZ /= magnitude;
}
entity.applyKnockback(knockbackX, knockbackZ, horizontalKB, verticalKB);
here, i have it here
TYSM
let horizontalKB = 0.2789;
let verticalKB = 0.1023;
let knockbackX = victimLocation.x - attackerLocation.x;
let knockbackZ = victimLocation.z - attackerLocation.z;
const magnitude = Math.sqrt(knockbackX * knockbackX + knockbackZ * knockbackZ);
if (magnitude !== 0) {
knockbackX /= magnitude;
knockbackZ /= magnitude;
}
const horizontalForce = {
x: knockbackX * horizontalKB,
y: knockbackZ * horizontalKB
};
entity.applyKnockback(horizontalForce, verticalKB);
here's the fixed one
@stark kestrel
Tysm
Hey any scripters here if you're willing to, i'd love some critical feedback on this project 🙂
https://discord.com/channels/523663022053392405/1406740973421330492
let victimLocation = hitEntity.location;
let attackerLocation = damagingEntity.location;
let horizontalKB = 0.2789;
let verticalKB = 0.1023;
let knockbackX = victimLocation.x - attackerLocation.x;
let knockbackZ = victimLocation.z - attackerLocation.z;
const magnitude = Math.sqrt(knockbackX * knockbackX + knockbackZ * knockbackZ);
if (magnitude !== 0) {
knockbackX /= magnitude;
knockbackZ /= magnitude;
}
const horizontalForce = {
x: knockbackX * horizontalKB,
y: knockbackZ * horizontalKB
};
hitEntity.applyKnockback(horizontalForce, verticalKB);```
let victimLocation = hitEntity.location;
let attackerLocation = damagingEntity.location;
let horizontalKB = 0.2789;
let verticalKB = 0.1023;
let knockbackX = victimLocation.x - attackerLocation.x;
let knockbackZ = victimLocation.z - attackerLocation.z;
const magnitude = Math.sqrt(knockbackX * knockbackX + knockbackZ * knockbackZ);
if (magnitude !== 0) {
knockbackX /= magnitude;
knockbackZ /= magnitude;
}
const horizontalForce = {
x: knockbackX * horizontalKB,
z: knockbackZ * horizontalKB
};
hitEntity.applyKnockback(horizontalForce, verticalKB);```
ty
What wld be an efficnet way to despawn a mob with script
Entitiy.remove()
Cheers
Why when I run player.playSound while in camera does it not work.
is it still locational if I just have player.playSound(sound)?
sound play at the player location but sound are heard from the camera location
wait, player.playSound should do that
entity.kill() 😈
entity.getComponent('health').setCurrentValue(0) 😈😈
breh
I don't make the rules
I need to test this.
Doesn't seem to be. I've debugged it and it all seems fine it's just not working could it be due to server load that it wouldn't work?
yeah, unfortunately sounds have to be played from the camera location
Your information is incorrect
Sounds have never been able to move with the player aside from whatever biome music is doing
try defining the sound as music instead, that might work
That's weird considering they recently made it so you can't set the values to anything greater than the max value
I think the way it works is that it just gets you close to the edge and 0 is in range so you can kill an entity that way
nah didn't work
Does anyone have an addon that lets items stack past 64 on the ground? Thought I should ask before I go reinventing something
Mainly for lag preventative reasons
is it possible to get the item damage value?
dont think that is posible
Hmm. I know I could get it to work with players picking it up, but getting hoppers and things like that to work is a struggle
i mean the attack damage
Not possible.
okay, thanks!
you can't directly change max stack sizes in scripts but you might be able to do something jank I huess
What do you need it for? There may be alternatives
for my custom crit damage, but i already found another way, i made a list of my custom weapons with their damage values and used it for my crit damage logic
I'm concerned about why we don't have access to something basic as the item damage component yet
Priority.
Whar use case do you have?
I don't have one, but there will be people who need it at some point
At some point yes, but right now I don't see anyone advocating that it's a must thus it's not a priority.
Can I define more than one ““function”” on custom components? Like, I can define a component with onStepOn and onEntityFallOn?
(I called it as ‘function’ bcs I idk how it is called lol. Ik it’s not a function)
Yes.
Nice
Also, how can I detect if the block has an optional param(it won’t be on every block with this component)?
if (params.(my_param)) {
…
}```
^
Like this?
onUse(event, {parms}) {
if (my_param in params) ...
}```
world.setDynamicProperty(entity.id, total amount)
get dynamicProperty on entity remove to dupe the stack by the total amount
yeah, that's what I was thinking, but it doesn't really work with hoppers which I still want to be able to use
Hrmmm indeed 
do you remove dynamic properties with null or undefined? someone said a while back undefined still keeps it stored
setDynamicProperty('prop')
ye I know it's optional but I like doing null / undefined so it makes intent clearer
yeah you can just leave it empty
undefined
Make a wrapper out of it, ig...
undefined actually deletes it?
yes
alr
does anyone know how to get the biome at a location? theres no func in stable, but there is dimension.getBiome() but my game keeps saying it doesnt exist (im on 1.21.101, using script api 2.2.0-beta). i even went as far as to use the alpha version but its just gaslighting me at this point
thats in preview.
there's findClosestBiome but it takes time to complete
Documentation for @minecraft/server
pretty sure findClosestBiome searches for a specific biomes location, not the biome at a location
I know what it does
people have used it for this though.
however, I dont recommend it
essentially im making a heat system:
export function getSurfaceCondition(player) {
let heat = 5;
let weather = sv.world.getDynamicProperty(consts.DPK_WEATHER);
if (weather == null) weather == "Clear";
let biome = player.dimension.getBiome(player.location).id;
if (weather == "Rain") heat--;
if (weather == "Thunder") heat--;
if (!isDay()) heat--;
if (biome.includes("desert")) heat++;
if (biome.includes("frozen") || biome.includes("ice")) heat--;
if (biome.includes("jungle")) heat--;
if (biome.includes("cave")) heat--;
if (biome.includes("ocean")) heat--;
if (biome == "hell") heat = 10;
return HEATLEVELS[heat];
}
and it should be colder in caves oceans and frozen places
yeah ive made a temp system too, just not with numbers.
first thing I did when getBiome dropped in preview
oh i just have an array that turns it into a string
const HEATLEVELS = [
"§b§lFrigid", // 0
"§bFrosty", // 1
"§9Chilly", // 2
"§3Cold", // 3
"§2Neutral", // 4
"§6Warm", // 5
"§6Hot", // 6
"§eBoiling", // 7
"§cSearing", // 8
"§4Furnace", // 9
"§4§lHELL" // 10
]
I like simple
im making a mod where the sun hurts you
the hotter it is, the more damage it does
so you have to stay under shade
or underground or wear helmets that degrade
so what, a vampire addon?
lol
cool, I just created a system, its not part of anything yet
ill think of something
i got the heat system working
it shows whenever its the first time surfacing that day
is there a way to change the player's seat position through script?
how do you make a wrapper?
not afaik
im using component groups unfortunately...
How does this work?
world.afterEvents.itemReleaseUse.subscribe((data) => {
console.warn(data.useDuration / 20 / 60);
})
I can't seem to get it to format into seconds
Why are you dividing by 60?
I assumed it is on miliseconds, it is not though
wait isn't it suppose to be 1000
its in ticks
20 ticks = 1 second
I don't think script api uses miliseconds anywhere
It's returning arbitrary numbers, but nevermind, I was going to track how charged the arrow is but I'll just use the velocity of the arrow
basically categorizing functions/methods/snippets in simple ones so it's faster to understand the logic of the code
no
In the .setDynamicProperty() function, trying to set undefined doesn't actually remove the value. It works and actually removes the Key, only when, setting it to null OR you can just leave the parameter and don't fill it up, like world.setDynamicProperty("key") and the value will be deleted.
in Date.now ...
cool
-# that's a javascript function not script api one.
xdxd
actually, no it does remove it
I was got this info by a friend
you can confirm with nbt
I need to confirm that
Whats going on
so you didnt confirm it yourself
yeah
how about you go do that
im curious
discussing if setting dp to undefined remove the property
Oh
since you are scripting leader you should know right /j
xd fr
the doc itself says undefined remove it
it doesn't
hmm lets check the changelogs
- Removed function removeDynamicProperty - Please use setDynamicProperty with a value of undefined to remove a property
Yeah, I'm sorry guys
I was wrong, I wanna test though with a NBT editor, It's interesting
better to do these things before correcting someone
so both work
yeah, even
p.setDynamicProperty('test3')
yeah.
Can we spawn simulated players directly in the stable version?
using the same logic I should've confirmed myself before answering, because clearly I needed clarification as well.
like OOP?
thanks for checking.
np
more likely, yeah
wait so you no longer need a structure block or whatever
yeah
I might use this now
same
is there anyway to teleport a entity to player location and follow player direction view?
stable api or beta api
entity.teleport(player.location, {facingLocation: player.getViewDirection()})
or if you mean make them face towards the player, just change facingLocation to the player's location.
this is stable.
that will make the entity look at 0 0 (near it) sense getViewDirection() return a normalized vector of the length 1
facingLocation: look at this place in the world
Entity does not follow the player's view
so just use rotation instead, and get the player's rotation.
wdym by this
make the entity look where the player is looking?
yeah
you have to spam the method.
it wont magically follow after 1 teleport.
entity.teleport(player.location, {rotation: player.getRotation()})
ofc this will make the entity unable to move
thask
is it possible to spawn a block break particle with a chosen texture?
or it'll be better to create a custom emiter that mimics that behavior instead?
Nope afaik
what are you using for this?
MCC Tool Chest PE
U can also use old Universal Minecraft Editor
okay, thanks!
is it this one?
https://mcctoolchest.weebly.com/download.html
Ye
how do i get a 2nd script file to run that's not the main.js?
make the file then put this in your main.js
import './fileName.js'
also you need to restart your world for it to work
ty
wait u don't need to restart ur world?
no but i meant u said u need to restart ur world which implies that sometimes u don't need to
it says "import not found"
do /reload all in chat or simply exit the world and rejoin it
you have to do this everytime you create a new file
still says not found :/
Hello, how to return launched projectile like trident's loyalty, anybody can give me a script?
You dont have to restart the game if the behaviour pack is in development folder
What s new in script api ?
its a bug then, I thought I was the only one having that issue
a lot
bro see the changelogs ;-; u ask that like every month lmao
:-:
2.0?
Please help 🙏
do I need to remind you?
what projectile are you trying to return?
you can just use projectileHitEntity and projectileHitBlock
Yes
you should check the microsoft page for that
Thank you, thank you sir 🔥🔥
Is it possible to fetch the texture of a block using scripts?
Is the texture of an item/block accessible via script?
no
No.
hmmmmm thx :]
Closest thing you can do it by using prebuilds, but it depends what do you mean by a texture
A path to a texture, or blob of a texture?
a blob
Yes.
They were added in 1.21.80 or 1.21.90, I might be incorrect; but still, it's 1.21.100 already.
ok thx :)
No problem.
How to know the recipe of an item via script? Especially items from other add-ons
you can't
hm?
you know, the thing that containers like chests and furnaces are
last time I checked we didn't have support for this
ah, you mean something like a custom chest? If yes, there are still no improvements in this direction :/
You can get a block to get their container?
🛌 
New preview btw.
And we have to wait for 2 months to use it in stable Minecraft.
Is it possible to keep a chuck updated via script?
No cross posting please
why player.playSound() never works for me? No errors but still doesn’t play the sound
show code
@merry cove
Have you tried using player.playMusic?
is there a way to have multiple threads in the Script API?
It's like telling Mojang to not go against their own terms of service
Closest thing you can achieve is by using async and jobs.
CPU threads
this cannot be configured
I'm sure the user already had a valid answer
-# note: this is a javascript issue, not minecraft
does anyone know of anywhere i can get a movement detection script? just need a basic one and wondering if there is a resource with a template
Use clustering and multi-instancing inside Script API.
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]
check player velocity
check #1067535712372654091 for template, I doubt it exists
so what's the utility for .getBlockStandingOn()?
i mean, isn't it like
Dimension.getBlock(Entity.location).below()?
ig it would be for entites with big hitboxes, that's the reason for .getBlocksStandingOn() afaik
or if you stand between 2 blocks.
also its getAllBlocksStandingOn()
its not
the block will return undefined if you are flying above it when using getBlockStandingOn() unless you are sneaking
and when it comes to paths, using getBlock(Entity.location).below() will return the block under the path.
You could just do {x: pl.x, y: pl.y - 0.1, z: pl.z} instead to fix the path issue.
either way, I rather use the method that tells you when the game recognizes you actually standing on a block.
QQ, are entity custom components a thing yet?
no
Sad times, any update on when it’s coming?
nope
😔, thanks anyway
QQ?
entityHitEntity isn't even out yet :<
what?
quick question
I meant entityHitEntity before event
what does this have to do with entity custom components
they are some of the things that alot of us want
entityHurt beforeEvent would be better.
yeah
but you know boyh would be nice
allgoods
shame on you for not reading my message
👀
discord didn't show the "x new messages" thing
ummm, what is this used for exactly? PlayerSwingEventOptions
detecting when the player swing its arms?
left click detection I guess
Added class PlayerSwingStartAfterEvent to beta. This contains information regarding a player starting to swing their arm
it detect every swing, left or right click, it doesn't matter
Added class PlayerSwingStartAfterEventSignal to beta. This event is fired at the start of a player's swing (e.g. attacking, using an item, interacting). It can be subscribed/unsubscribed via world.afterEvents.playerSwingStart and optionally filtered by passing in PlayerSwingEventOptions.
jeez, thats extremely useful, that will make my ||""""""|| addon way better
how to filter left
filter out using other events, player interact with block, player place block and so on
Only thing I could think of was for more exact timing with combat type addons. Curious to see how it gets used and why
Custom form or Message Form 😜🙏
const menu = new ModalFormData();
menu.button('test1');
menu.label('text');
menu.button('test2');
Ty
is there a way to stop player from sprinting?
yes..
how?
Well, in theory you need to change the value of movement component
player.getComponent('movement').setCurrentValue(1);
but you need to calculate the speed yourself, which will be without sprinting
Hello, can someone tell me how to scale player at 0.01 when it riding any mob?
wait, you can change component values, or only for some components?
as i remember sprint gives +20% to speed so... try ```js
const movement = player.getComponent('movement');
movement.setCurrentValue(movement.currentValue / 1.2);
@livid elk sir, did you find any method to attach particle in attachables?
if it is an Attribute component yes. And for some values of other components
no, i stopped using particles in attachables
Oooo 😔
Please help 🙏
try scale component
I tried but it's not working 😭
other vvalues woeking fine ?
Not catching the event and scale
You don't need to calculate anything, just log the current value when not sprinting and re use that
the formula is not so complicated that you have to choose the option where you need to save something + it does not take into account the speed changes during the sprint
Why do yon need to take into account the sprinting speed when you are disabling it
and if after sprint starts, the player gets speed effect? hm? dividing by 1.2 seems like an easier solution
That just slow the player down even with speed effects
do we need something else? Your version would do the same thing
No, i know my version does the same.
If speed effects is that important you will have to figure out the formula the player speed increase when speed effect increases
Hopefully it is lineare
Well, we need to see how it will work. For example, I have the speed set every tick taking into account the effects, sprint + my additional modifiers
how can i detect if the player move left/right? like if the player moves right - run something, if left - run something
system.runInterval + player.inputInfo
const vector = player.inputInfo.getMovementVector();
thanks
Can I check when a player opens and closes an entity inventory?
Oof
wouldn't that just be interactWithEntity?
then spam a form for when player closed the inventory ui...
its good approach, but it has its bugs. the choice is on the scripter
is it a vanilla entity? or a custom entity
Custom entity
Why can't you use the interactWith event then?
How can I test when the inventory is closed after the first interaction with that?
good point. We don't have a player.isInUi option lol
you could check for the player not moving, but that might not be great
I have an idea, let me try something
Okay let me know!
Testing the form method, but is not working as I wish
I have a moment to test my idea hold on
unfortunate
these were finger crossed copium tests
I tried checking whether the player input controls are disabled when going into a ui and whether the hud ui elements are changed to true for onScreenDisplay.isForcedHidden();
unfortunately neither of these are effected when going into ui or doing anything else
it depends on what you're using it for
what
I have one more thing to check
isn't that for when the client entity is rendered in a ui
it is
darn
Yeah I think you either have to do that or check for player movement
Tried to see if I could "open" a form for the player and just have it returned as true/false
it did not work
that possible, but you will have to call closeAllForms after
Yeah but it's not going to return a true or false
it's just always going to open up
you can use useBusy to confirm it didn't open, and if it did open close it
not the best thing tho
hmmm,
@distant tulip u great at math?
tryin' to make a temperature system, but apparently it requires alot of math for some reason,
i wouldn't say great but i am alright
if you know what to ask and how to ask
it is not
not for everyoe i assume
nah my math is just built different, chatGPT cant handle it
-# bec i already tried, the answer was somehow more stupid than my question
I am running the event 3 seconds after interaction with the entity, this is the event:
"kai:poll_container": {
"sequence": [
{
"filters": {
"test": "has_container_open",
"subject": "player",
"operator": "equals",
"value": true
},
"sequence": [
{ "set_property": { "kai:open": true } },
{ "queue_command": { "command": ["playanimation @s open", "say open"] } }
]
},
{
"filters": {
"test": "has_container_open",
"subject": "player",
"operator": "equals",
"value": false
},
"queue_command": {
"command": ["say closed"]
},
"trigger": {
"event": "kai:chest_close",
"target": "self"
}
}
]
}
And even though the event is being ran successfully(console warns says), the debug say commands are not triggered. Any ideas?
Script:
import { world, system } from "@minecraft/server";
const POLL_EVENT = "kai:poll_container";
world.beforeEvents.playerInteractWithEntity.subscribe((event) => {
const { player, target } = event;
if (target.typeId === "kai:dead_chest") {
console.warn(`${player.name} interacted with a chest. Event will trigger in 3 seconds.`);
system.runTimeout(() => {
try {
target.triggerEvent(POLL_EVENT);
console.warn(`Event '${POLL_EVENT}' triggered on ${target.id} after delay.`);
} catch (error) {
console.error("Failed to trigger event due to a script error.", error);
}
}, 60);
}
});
What is the debug command?
say open and say closed
Ah Wait hang on. You're trying to make a pseudo chest yeah?
Yeah
I didn't have the closing animation but
world.beforeEvents.playerInteractWithEntity.subscribe((eventData) => {
if (eventData.target.typeId != 'toycat:fake_chest') return;
system.run(() => {
eventData.target.playAnimation('animation.fake_chest.open');
system.runTimeout(() => {
eventData.target.playAnimation('animation.fake_chest.close');
}, 100);
});
});
``` I had this.
But that will make it close after 5 seconds no?
Ideally I wanted it to close after the container was closed
it will
i dont think u can do that using scripts directly, but there must be a workaround somehow somewhere sometime
does the "kai:chest_close" event "set_property": { "kai:open": false }?
yeah
i thought u are missing that, anyways
Ah I see it now. I reckon the event is being triggered way before it detects if you have the container open.
I tried doing it even after 15 seconds but nothing
I feel like the problem is on the event
And even though, if it checks it before it should say in chat the word closes
yeah the script are fine
Ah ok I see it now, I believe the issue is the subject player.
Try putting that check inside the interact component instead.
I'm not using the interact component, if I do, I would need to interact twice with the chest for it to open the inventory
btw, "minecraft:timer":{"time":0,"looping":true} will cause lag right? like it will work the same as onTIck for blocks?
Yes
I also did tried running the event through timer and is not saying none of the say commands
what about triggering an entity event using scripts? 20x per second
will it has the same lag as the timer?
I think whathever problem is on the event needs to be fixed first
hmmm
What why?
Youre approaching this wrong Kai.
Did you read the last part?
Use the interact component to set the property to true and play animation and use entity sensor to close itself.
try using environment_sensor for the filter (has_container_open) and make it triggering the events that will run the commands
that would work too
like:
"minecraft:environment_sensor":{
"triggers":[
{
"filters":{
"test":"has_container_open",
"subject":"player",
"operator":"==",
"value":true
},
"event":"open:event"
}
]
},
that might keep spamming the commands tho, so u only need it for the close thing
Using the minecraft:interact component makes the inventory not open till second interaction, so is not a feasible option.
Regarding the entity sensor, I tried this:
"minecraft:entity_sensor": {
"subsensors": [
{
"event_filters": {
"test": "has_container_open",
"subject": "player",
"operator": "equals",
"value": false
},
"event": "kai:chest_close"
}
]
}
And nothing happens.
You need others not player.
Check the piglin code.
I made it! Thanks
Works perfectly
Still, dont use minecraft:interact + minecraft:inventory
Requires double interact
at least for a good reason?
if it works, it works.
anyways, d u have any suggestions about how am i going to make a temperature system?
cuz idk from where i should start,
Do you already know how you want it to work?
yeah, hot biomes will increase the player temperature, cold biomes will decrease it,
light armor (leather, chain) will make u cooler
heavy armor (iron, gold, etc) will make u hotter
heavy armor with fire resistance will make u feel somewhere cooler, depending on the enchantment level
and standing nearby lava/fire/magma will increase the temperature,
standing inside water will decrease the temperature
hot biomes are hot during daytime and cold during nighttime,
overall, complicated asf, and im completely lost idk from where i should start
I think a script for checking player surroundings would be a good start
yeah that wont be that hard,
ibstoycat jumpscare
When before hurt event 🗿
-# after the end update
Never gonna happen 💀
Yo how can I display a scoreboard on sidebar
is there an efficient way to detect the armor enchantments without using loops? or i just have to get 4 itemStacks and try getting the enchantments for each part?
Unfortunately not, afaik
then ill use 4 itemStakcs for each part, and get the enchantments of each one
afaik, loops will slow the interval at somepoint, so im trying to avoid using it
- i already have to detect each part individually so i can do better math
Excuse me, how are you getting the enchantments so far?
const helmetEnchantments = Helmet?.getComponent('minecraft:enchantable')?.getEnchantment(enchantmentType)?.level;
referring to the loop you mentioned
im not using any loops
100.000 TH MESSAGE
1067th 100,000th message
Is there any recreations of vanilla boss bar?
is there a way to detect players hitting entities like "world.afterEvents.entityHurt", but doesn't have the delay between registering hits?
world.afterEvents.entityHitEntity
idk why I didn't see that before 😭
thx!
Is there any way to fix this error?
make the M capital in mainhand like this Mainhand
Wow Thank you
What would be the best way to detect a block update?
you cant
not yet anyway
Does anyone have a better suggestion for my code or modification.
ohboi
oh boi indeed
😅
w8, ima send a function
ohh thanks
world.afterEvents.playerInteractWithBlock.subscribe(e => {
const { player, block, dimension } = e;
const variant = block.permutation.getState("goobli:variant");
if (variant === undefined) return;
const toolComp = player.getComponent("equippable");
if (!toolComp) return;
const tool = toolComp.getEquipment("mainhand");
if (!tool) return;
if (tool.typeId === "gooblideco:goobli_screw") {
let newVariant = variant === 0 ? 1 : 0;
block.setPermutation(block.permutation.withState("goobli:variant", newVariant));
dimension.spawnParticle("goobli:place_effect", block.center());
dimension.playSound("item.bone_meal.use", block.center());
}
});
come on
not the biggest spoon full
was about to fix the whole thing, but it is basically the same
edible enuf ;-;
I am just trying to grasp something in the coding thing in js script cause the structure thing is kinda i guess a bad thing
it is
because you are subscribing to an event listener multiple times when you do not need to.
the only really bad thing was using switch for one case switch
just use if statement. also you are repeating codes a lot
🍿 👀
smacks popcorn out of serty's hand
i am trying to be nice lol
we all do some questionable things
and im not being nice I guess
so rude for me discouraging bad practices
you guys are both nice,and I learn something new from what you said
#spoonHolder
im just joking with minato
you are telling me, you did smacks popcorn out of serty hands
that was indeed not nice of me
serty deserves it though
lets be real
he roles his eyes because its the truth
I'm just drinking tea with cookies and I'm lazy to type
what kind of cookies
are you lazy to type the cookie type
import { BlockStates, system } from "@minecraft/server";
function clockVariantPermutation(permutation, stateId) {
const newState = (permutation.getState(stateId) + 1) % BlockStates.get(stateId).validValues.length;
return permutation.withState(stateId, newState);
};
system.beforeEvents.startup.subscribe(eventData => {
const customComponents = Array.from({ length: 15 }, (_, i) => `goobli:change${i + 2}`);
for (const componentId of customComponents) {
eventData.blockComponentRegistry.registerCustomComponent(componentId, {
onPlayerInteract: e => {
const { player, block, dimension } = e;
const tool = player.getComponent('equippable').getEquipment('Mainhand');
if (tool && tool.typeId === 'gooblideco:goobli_screw') {
const newVariant = clockVariantPermutation(block.permutation, "goobli:variant");
block.setPermutation(newVariant);
dimension.spawnParticle("goobli:place_effect", block.center());
dimension.playSound("item.bone_meal.use", block.center());
}
}
});
}
});```
i guess ill never know
yooo, remember m9 with the superior spoonfeed
@distant tulip you got a competitor
.
w8, so whos chef
you are the chefs that hold the spoon and feed the people
😭
oh hell no
special iNgRiDiEnT
never ask m9 to help with script ever again
he is the one who taught me
did he also teach you how to do this
freaky ass scripting
won't work
yeah you gotta use setVector3
so viewDir....
also, you don't need to add variable to the name
lol, he did say not tested
Calm down with the damn reaction spam.
lmao
1 button away from a 1000 year ban
@strong oar also remember that BlockStates is like a library of state values
ngl, for the clockVariantPermutation function I was abt to get the last value from validValues as reference of max, but ai suggested % values.length
ai?
you used ai?
auto completion bot...
ah.
It works fine, and I tweak it a few so that it works properly. Overall thanks again for your effort and your coding inspire me to learn more about it same goes for the people who help me previously about this matter. Thanks again guys, I learned a lot ❤️
is it possible to add dynamicproperty to item?
yes
thank you
wtf?!
Debug result for [code](#1067535608660107284 message)
Compiler found 2 errors:
[36mvanillaItemsDynamicPropertyEligibles.js[0m:[33m1[0m:[33m1[0m - [31merror[0m[30m TS2304: [0mCannot find name 'mc'.
[7m1[0m mc.ItemTypes.getAll().filter(t => {
[7m [0m [31m~~[0m
``````ansi
[36mvanillaItemsDynamicPropertyEligibles.js[0m:[33m3[0m:[33m13[0m - [31merror[0m[30m TS2304: [0mCannot find name 'mc'.
[7m3[0m new mc.ItemStack(t).setDynamicProperty(t.id, 1);
[7m [0m [31m ~~[0m
There are no errors from ESLint.
as long as it is not stackable
.
best code
setDynamicProperty on uneligibles throws error, thats why
LMAO
Yes, but only for non-stackable.
can't you just get max amount
straight to setDynamicProperty is more accurate
import { ItemTypes, ItemStack } from "@minecraft/server"
const canSetDynamicPropertyOn: Readonly<Set<string>> = new Set<string>(
ItemTypes.getAll().filter(({ id: typeId }) => !(new ItemStack(typeId, 1).isStackable))
)
Hey @shy leaf, thought that you're the right person to ask-have you made a custom damage system for projectiles before?
I do not understand this at all, what does this do?
Creates a set of unique item identifiers that can have dynamic properties.
custom damage system, yeah, but not for projectiles
Okay that works, just wondering other than weapon base damage, enchant, player effects, and critical damage what else factors that can affect player's damage?
Okay, it is not a searchable term. Can you elaborate more?
ill get back to you in a few minutes
Okay nice, no rush
Basically rebuilding vanilla damage system but combining my own stuff
i see
so basically, when an entity takes damage, theres a short period (500ms) where theyre immune to damage
you can refer to the wiki, though its slightly different in bedrock edition (and its somehow not noted in the page)
Okay nice thanks, although, referring to what you said earlier, this seems it will only need some runTimeouts before dealing damage. Am I missing something?
nah, runTimeout is not reliable for this
for whatever reason, script environment doesnt 100% sync with ingame environment
especially when it comes to ticks/time
So I need to use realtime?
thats even worse
instead, try storing currentTick in the entity whether by writing in memory or DP
and then compare ticks
oh wait
now that i think about it
if youre using applyDamage for this, it probably doesnt matter
Yeah I am using that
i see
then yeah, those should be everything
Okay thanks for the advice. Although dealing with another problem with projectiles because there isn't beforeEvent for projectileHit 😬 Mojang when 🙏
😔
Can't u use projectileComponent.owner on spawn...
Hm?
this is what I was talking about: https://discordapp.com/channels/523663022053392405/1354973333216563200/1408089071678521517
U can modify the projectile before it hits anything
There's only a few properties tho
Can I get the ItemStack though? I want to get the enchants of the projectile before it is thrown. No problems with arrows as they don't get removed unlike tridents
I don't think it has access to item, so u gota make a map for it ig
Okay interesting, how would that work though? What would I store?
I would use itemstartuse to track the trident being charged.
I used that to track bows.
You can also use this, though not sure how accurate it be, you probably need to trigger both events.
Documentation for @minecraft/server
Oh wait yeah, gosh, thank you, this will surely work
umm, is it possible to setLore for items? or i have to spawn a new item and then use setLore on it?
You can
just itemStack?.setLore(['test']);?
bec this Boots?.setLore(['Test']); doesnt work (setting lore for specific boots)
Yeah, and give the player/container the item back
ohh i see
its not possible to setLore above the item enchantments right?
Nope
changing the item name and use \n will make lore-like string under the item name, but it will be visible always, right?
-# making sure.
Yeah but players can change the name
then ill stick with setLore
what if i check if the name doesnt have my strings so it will automatically add them back?
meh, it will make the naming thing messy
Players shouldn't have to deal with that
This script is nothing working. Does absolutely nothing. I suspect it is the is_shifting…
import { world, system, EquipmentSlot, ItemStack, GameMode } from "@minecraft/server";
world.afterEvents.playerInteractWithBlock.subscribe((e) => {
const { player, block } = e;
const {x, y, z} = block.location;
const chance = Math.random();
const grassBlocks = [
"minecraft:short_grass",
"minecraft:tall_grass",
"minecraft:fern",
"minecraft:large_fern"
];
const vineBlocks = [
"minecraft:vine",
"minecraft:twisting_vines",
"minecraft:weeping_vines"
];
if ( grassBlocks.includes(block.typeId) && player.isSneaking) {
let fiberCount = 0;
if (chance < 0.1) {
fiberCount = 3;
} else if (chance < 0.3) {
fiberCount = 2;
} else if (chance < 0.65) fiberCount = 1;
if (fiberCount != 0) block.dimension.spawnItem(new ItemStack("sca:small_fiber",fiberCount), block.location);
block.dimension.runCommand(`setblock ${x} ${y} ${z} air destroy`);
} else if (vineBlocks.includes(block.typeId) && player.isSneaking) {
let fiberCount = 0;
if (chance < 0.3) {
fiberCount = 2;
} else if (chance < 0.75) fiberCount = 1;
if (fiberCount != 0) block.dimension.spawnItem(new ItemStack("aca:big_fiber", fiberCount), block.location);
block.dimension.runCommand(`setblock ${x} ${y} ${z} air destroy`);
}
return;
});```
Is it the is_shifting?
I don't see an is_shifting
Yh, that's what i thought
Did content logs say anything?
there is no shifting
No errors in [code](#1067535608660107284 message)
Can you even get an entity's collision box? I can't find anything in the docs.
Nope.
Not directly, but technically you can.
Find a fixed point offset from the entity, then cast an axis-aligned ray towards the entity. The hitbox width is approximately offset - distance
Similar deal with the height; find a fixed vertical offset from the entity, then cast a ray downward.
You may want to fiddle with the difference some, I think it can be 0.1 meters off
You may find this interesting @small cloak @wary edge
I wish add-ons had more freedom with what they can do.
That can work, though for a sue case of mine for [REDACTED] that would not have worked as our entity used custom hit test and raycast doesnt detect that.
Thanks. I was thinking about doing that, but I wasn't sure if it would work.
I suppose it wouldn't. Then again, hurt boxes and collision boxes are different.
I just wish there was a better way to do this. Doing a couple raycasts is a bit jank.
Allegedly, the mob spawning experiment comes with an api to get an entitys aabb. Allegedly.
There's a mob spawning experiment?
Eventually.
Theres been a qna where they want to rework the mob spawning and whrn v2 first released there were a bunch of scripting stuff related to mob spawning.
https://x.com/SmokeyStack_/status/1885413419890700698?t=6MRINZF_gGD9JK1v2uVWGA&s=19
https://x.com/SmokeyStack_/status/1885415697963958406?t=XZMB3yxxohf8Ig_tR-vbxw&s=19
Interesting.
I guess I'll just have to deal with raycasts for now.
I had to make my own AABB class too because BlockBoundingBox didn't work as expected.
Is there a way to do a forEach after using getBlocks for a volume area?
anyone remember what hte difference between healthComponent.defaultValue and .effectiveMax were?
assuming it just gives you an array of block locations, you should just be able to do
for(const location of locations) {const block = dimension.getBlock(location)}``` ?
close, it returns a blockVolume, and then you need to use getBlockLocationIterator()
yeah, I think everytime I've looked at it I straight up avoided using that call because it just looked like a convoluted mess
const blocks = player.dimension.getBlocks( area, { includeTypes: [ `cnb_inb:essence_block` ] })
console.error(blocks.location)
if (blocks == undefined) return;
blocks.forEach((block) => {
const loc = block.location
player.runCommandAsync(`fill ${loc.x} ${loc.y} ${loc.z} ${loc.x} ${loc.y} ${loc.z} cnb_inb:essence_block["cnb_inb:invis"= 2]`)
});
Here's what I have so far if it helps.
Documentation for @minecraft/server
Oh ok I'll look up how to use that one.
const blocks = dimension.getBlocks(area, { includeTypes: [ `cnb_inb:essence_block` ] })
for (const location of blocks.getBlockLocationIterator()) {
const block = dimension.getBlock(location)
}
Very nice, thank you!
lol
I'm going to have to think about this one for a while too XD. Might try it tomorrow when I'm more awake.
@sharp elbow @subtle cove Thanks for the help. I got it working.
As you mentioned, the size is a bit off, but I don't really need perfect accuracy.
nothing
the player.isSneaking
Nothing is wrong with that
then I have no idea whats wrong
maybe the after event?
yes.
the afterEvent wont trigger because the grass blocks are not interactable.
use beforeEvents.
.
watchy doin? those particles look trippy
Working on portals.
Is there a way to spawn a is_summonable false entity via scriptAPI?
maybe with a structure
How do i make my entity spin
Entity.setRotation
Thx
Run a interval and change entity's rotation
Hey devlopers, can we make hold release use button event like bow? If anybody know how to do, can you help please? 🙏
we can't use rawtext for custom command descriptions?
No
I am not really sure why they dont automatically support that
been like that for setLore until recent changes
does anyone have bedrock documentation for the 1.18.0 module in minecraft/server?
Documentation for @minecraft/server
" %your.translation.key"
space or something is needed before %
if u dont mind me asking, why u need that module? nvm
that works?
was, not sure if it still do
i thought it didn't work, why is the space before % needed
really? i will try it right now
could u please tell me if it works?
@warped blaze @distant tulip It works!
nice
It adds a little awkward whitespace before the command description tho
maybe try
"§r%key"
minato said "space or something is needed"
§r makes the description non italic
so u can font-format the translated key there...
§o?
§. works fine
how do you know about this? what else do you know about?
king
whats the difference between usingblock.setPermuation(block.permutation.withState()) and using BlockPermutation.resolve()
current.with & default.resolve
ohh
it makes sense the first one didnt work on permutationToPlace in beforeOnPlayerPlace
thanks
i am having the same concerns, thanks for that answer
Ok, ty
have u ever tried ```js
const prm = data.permutationToPlace;
data.permutationToPlace = prm.withState("cs:variant", false);
i didt but now i see my mistake was the **block.**permutation
e.permutationToPlace = block.permutation.withState(
"custom_vine:hanging", true
);
your variant works fine though :D
thats great then
May I ask because I also have the same topic (super duper identical)
you forgot to add "super duper"
fine...
Good M9
should that behave like tall grass, vines, pillar or what?
like tall grass
onPlayerBreak could work, but not when the block gets moved/destroyed by piston/explosion
i tried to use it before but nothing happens still the same, maybe because it is for 2.0.0? Because i am using 1.18.0 module version
where can i do this type of thing, so that i can figure it out for myself if you dont mind.
in vs code?
add a package.json file containing {}
thanks I am going, to try it out
then choose any package
That seems to work, but content log now says this:
at <anonymous> (sca/onBreakBlock.js:27)```
use system.run
Has anyone ever ran into an issue where when the player alive, it's meant to do one thing, and when the player dies, it's meant to stop that thing, but instead of stopping that thing, it pauses it until the player has respawned?
I have a stamina system that only drains stamina when the player is sprinting, when the player dies, it should stop. However, it pauses it entirely and the second the player respawns it drains their stamina. What's even weirder is that whether this happens or not depends on the time that the player had paused their game or not. Pausing the game and unpausing affects all of the tick intervals and can throw them off.
if (player.isSprinting && !player.isGliding && !player.__staminaDraining && currentHealth > 0) {
if (currentStamina > 0) {
player.__staminaDraining = true;
world.sendMessage(`${player.__staminaDraining} ${currentHealth} ${player.isSprinting}`)
drainStamina(player, currentStamina, staminaDrainAmount);
system.runTimeout(() => {
player.__staminaDraining = false
}, 5);
player.__staminaGainTimer = 20;
}
else {
player.addEffect('slowness', 60, { showParticles: false, amplifier: 1 });
}
}```
you are doing it wrong then
Send the code
make it:
system.run(() => {
//code
})
Here is the code:
import { world, system, EquipmentSlot, ItemStack, GameMode } from "@minecraft/server";
world.beforeEvents.playerBreakBlock.subscribe((e) => {
const { player, block } = e;
const {x, y, z} = block.location;
const chance = Math.random();
const grassBlocks = [
"minecraft:short_grass"
];
const vineBlocks = [
"minecraft:vine"
];
const isCreative = player.matches({gameMode:GameMode.Creative});
if ( grassBlocks.includes(block.typeId) && player.isSneaking) {
let fiberCount = 0;
if (chance < 0.1) {
fiberCount = 3;
} else if (chance < 0.3) {
fiberCount = 2;
} else if (chance < 0.65) fiberCount = 1;
system.run(() => {
block.dimension.spawnItem(new ItemStack("sca:small_fiber",fiberCount), block.location);
});
block.dimension.runCommand(`setblock ${x} ${y} ${z} air`);
} else if (vineBlocks.includes(block.typeId) && player.isSneaking) {
let fiberCount = 0;
if (chance < 0.3) {
fiberCount = 2;
} else if (chance < 0.75) fiberCount = 1;
system.run(() => {
block.dimension.spawnItem(new ItemStack("sca:big_fiber", fiberCount), block.location);
});
block.dimension.runCommand(`setblock ${x} ${y} ${z} air`);
}
return;
});```
runCommand cant be called in read only mode.
import { world, system, EquipmentSlot, ItemStack, GameMode } from "@minecraft/server";
world.beforeEvents.playerBreakBlock.subscribe((e) => {
const { player, block } = e;
const {x, y, z} = block.location;
const chance = Math.random();
const grassBlocks = [
"minecraft:short_grass"
];
const vineBlocks = [
"minecraft:vine"
];
const isCreative = player.matches({gameMode:GameMode.Creative});
if ( grassBlocks.includes(block.typeId) && player.isSneaking) {
let fiberCount = 0;
if (chance < 0.1) {
fiberCount = 3;
} else if (chance < 0.3) {
fiberCount = 2;
} else if (chance < 0.65) fiberCount = 1;
system.run(() => {
block.dimension.spawnItem(new ItemStack("sca:small_fiber",fiberCount), block.location);
block.dimension.runCommand(`setblock ${x} ${y} ${z} air`);
});
} else if (vineBlocks.includes(block.typeId) && player.isSneaking) {
let fiberCount = 0;
if (chance < 0.3) {
fiberCount = 2;
} else if (chance < 0.75) fiberCount = 1;
system.run(() => {
block.dimension.spawnItem(new ItemStack("sca:big_fiber", fiberCount), block.location);
block.dimension.runCommand(`setblock ${x} ${y} ${z} air`);
});
}
return;
});
You should also put runCommand in system.run.
Ok
I said that
I’ll test
Yes
something might be off with your logic.
The error was mine
I thought I gave the file with onInteractWithBlock, but it was onPlayerBreakBlock
ah
Use Entity.id and continue task after.
Or add return statement that checks if player's health is below or equal zero.
Can someone help me in https://discord.com/channels/523663022053392405/1408526130914398301 ? please?
Clear interval?
System.clearRun(interval: number)
clearRun*
Btw guys, did setProperty change in 2.0.0 or something?
I am asking this because for some reason it doesn't work correctly
For some reason this increases its value
var final = (open_count - 1)
garage_door[i].setProperty("bd:open_count", final)
Meanwhile, this decreases it
var final = (open_count + 1)
garage_door[i].setProperty("bd:open_count", final)
(One is minus and the other is plus)
That won't work. There is no way to discern the difference between a player that just died and respawned and a player that didn't
on death stop the draining system and resume it when player spawn
Thank you for saying what I'm trying to do
🗿
I think I fixed it, I was trying to avoid making a new property just for this but I needed one
It's hard to tell if I actually fixed it though since it's being caused by whatever pausing the game does to interval timers
why do you need property for that
to disable it
I can't use health directly, because it pauses whatever is running and resumes it when the player spawns
so I have to set a property when health is 0 so when it runs back through when the player spawns it checks that and just exits
dynamic property?
ah, alright
i thought you meant entity property
I try to avoid entity properties since they're so limited
We don't have any limits on dynamic properties right?
You want to stop code after player dies and resume it on his spawn?
there we go, finally got the weird interval timing difference from pausing/unpausing so it would trigger
fixed it with the temp property
while riding an entity and both jump and dismount are disabled playerButtonInput event trigger for jump but not for sneak, any work around?
can i get the entity that’s doing the raycast instead of the entity getting detected by one or am i stupid
nevermind i just used the player
in a function that was in it
execute in scripts uses old version, that's silly
I am going to lose my mind. Why doesn't setProperty work properly anymore???
It work fine for me
I literally wrote zero in this code, but somehow it sets as one
garage_door[i].setProperty("bd:open_count", 0)
was setProperty changed somehow after 1.17.0?
How are you checking the value
by console.warn(garagedoor[i].getProperty("bd:open_count"))
And it displays it as one
For some reason this increases its value
var final = (open_count - 1)
garage_door[i].setProperty("bd:open_count", final)
Meanwhile, this decreases it
var final = (open_count + 1)
garage_door[i].setProperty("bd:open_count", final)
Yeah
Did you wait 1 tick before calling this?
@distant tulipDid you seem to figure out something? (sorry about the ping)
I tried system.runTimeout(() => {garage_door[i].setProperty("bd:open_count", 0)}, 20)
which didn't work