#Script API General
1 messages · Page 124 of 1
i really liked the slash commands
but very sad they dont fix such things like this
but wouldnt string also work instead of player selector
this map addon had the command without needing to activate cheasts
this is for owner
in this for normal player
cant you just add string parameter and check if it equals to any players name?
idk i didnt give it enough time
why is there no bds related channel?
editor mode but no bds 🗣️
bds related: Can you make a player be the "host" of the server? Essentially, I want to use reload all.
import { world, system, ItemStack } from "@minecraft/server";
system.runInterval(() => {
console.log("Running")
world.getAllPlayers().forEach(player => {
console.log("Player")
let inventory = player.getComponent("minecraft:inventory")
let container = inventory.container
for (let i = 0; i < container.size; i++) {
console.log(${i} Slot)
let item = container.getItem(i)
console.log(${item})
if (item) continue;
if (item.typeId === "minecraft:stick") {
let nitem = new ItemStack("minecraft:stick", item.amount)
console.log(${nitem})
nitem.setLore(["Isso e um Graveto", "Nossa que ligal!"])
container.setItem(i, nitem)
}
}
})
}, 100)
Why this code is not working? Only on reload
continue can only be used in loops (for, while, do while). Even if you had a loop, it wouldn't work, because if Boolean(item), the iteration fails and the second condition can't be satisfied (and sometimes there might be an error, because Item might be undefined). Also, instead of creating a new ItemStack, you could use setLore on the current ItemStack to save other properties
Oh
How to make a dash that makes the player move 6 blocks forward and up simultaneously? I tried but it doesn't work.
guys is it possible to add lore to any items ?
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]
Is this preview only?
Aye
next update release?

Can you show what you tried so we can correct mistakes if you still have it
i know how to fix
{
"binding_type": "view",
"source_property_name": "((#form_button_texture - (#form_button_texture % 65536)) / 65536)",
"target_property_name": "#item_id_aux"
}
search for aux and find something in the chest-server_form.json that say what i have below
{
"binding_type": "view",
"source_property_name": "(#form_button_texture * 1)",
"target_property_name": "#item_id_aux"
}
should be in the array aux_id
just replace that with this
is there any better way to store data on realms/worlds than dynamic properties
cause i only have 33k bytes used yet it already lags a ton
I just learned that u cannot make any fish mobs ride any entity even custom ones, cuz it's hardcoded.
not really
Is it true that updating any key on a world's dynamic properties means it also re-indexes the rest in the process
it has to resave every dynamic property when you update one yes
Yes but it only matters for large data sets
is this why my world lags for like 10sec when i save my shit
How am i meant to combat this
How many DPs do you have and how big are they?
How often are you updating?
Every 60s
I dont know how many but tgheyre big
What are you saving every 60s? Any reason?
Up to 32k bytes big
Everything basically
Thats not helpful
What data are you saving? Does ot have to be every 60s
I dont know else id avoid massive data loss
So yes i think every 60s is reasonable
I dont know why it matters
What data I'm saving I mean
Player data
Market data
Staff audits
Player activity logs
And more
Because some things dont need to be saved every 60s depending on the situation.
how to make onUse not fire when onUseOn fire for custom item components?
maybe check if there's no block in the player's view direction in a distance
that's what i was using
until i tested my addon with mobile today and realized how bad raycast is for touch screens
maybe dont do this and use sneak interactions instead for your alt use
...
idk what you are doing
anyway, now i am putting the player id in a set if the onUseOn event is called, call the the onUse event one tick layer if the player id isn't in the set and remove it from it 2 ticks later
i was hoping for a native way
..
the item does something different when used on a lodestone compared to when used in the air or any other block
maybe try this, when the player interacts with the lodestone set a property on the player.
and in itemUse beforeEvent check for this property and cancel the event.
literally what i am doing but worse
my suggestion is worse?
because it writes data on the player file that might get stuck if something unexpected happen
thats possible?
yes.
damn
by using a set it's only saved in memory and if anything were to happen it will fix itself by relogging
javascript ❤️🩹
what about it
nothing, its peak javascript behavior
i know, but i not calling the onUse function from the onUseOn function and passing the player instance to it so that property won't exist
im willing to bet this is a problem to people
somehow
me too, but no one is gonna bet against us so we wont make any money out of our bets
lol
yes it will.
oh you meant this
..?
and also make sure to get rid of it after a tick or 2
no, because it only be saved on that instance of Player, so unless i pass that instance to the onUse function, the property won't exist on it, i have tested that before
not true
ive tested aswell
i am almost willing to bet on it, let me test that again real quick
make sure not to reload the script in between testing.
because that would get rid of the property
ik
you were right
yeah I assumed you did it wrong somehow, its fine
but yeah try what i suggested
I believe it would work
Player.prototype.randomProperty = true;
?
pipol
how do I get the data in a custom component?
I registered it in the item so doing item.getComponents() it shows up but me doing item.getComponent('<id>') returns undefined
Why?
The other one is more simple
NVM got it, I'm fuckin stupid
idk
they are trolling
are they now
they are indeed
I'm still new to scripting and trying to figure it out. I'm trying to get a block to emit particles using onTick but this just breaks it:
const EmitParticleComponent = {
onTick() {
runCommand("particle ser:chem_smoke ~~~")
}
};
I am confused on what to do and where I am going wrong
I am also using itemComponentRegistry.registerCustomComponent("ser:emit_particle", EmitParticleComponent); in the system.beforeEvents.startup.subscribe(({ itemComponentRegistry }) => {} and have "ser:emit_particle": {} in my block components
const EmitParticleComponent = { onTick: ({ dimension, block }) => {
dimension.spawnParticle("ser:chem_smoke", block.location)
}};
try that
but why are you using itemComponentRegistry if this is for a block?
I might be stupid
is there a blockComponentRegistry?
That is exactly what was happening. Thank you
Is it possible to check if the sprint key is pressed? like when movement is disabled
Hmmm , not directly
no but you can detect sneaking or jumping with playerButtonInput afterEvent
hb using the movement component
can't believe I can do OOP now
Oop ?
I dont think that really give much. Or anything really
not with movement locked
hmm, ye thats fair
anybody knew why my dynamic property wont work?
world.afterEvents.playerSpawn.subscribe((data) => {
const { player, initialSpawn } = data;
if (!initialSpawn) return;
const inv = player.getComponent('inventory')?.container;
if (!inv) return;
const itemStack = new ItemStack("vdg:akm");
itemStack.setDynamicProperty('vd:akammo', 30);
});
world.afterEvents.itemUse.subscribe(ev => {
const { source: player, itemStack } = ev
if (itemStack.typeId !== gun) return
const ammo = itemStack.getDynamicProperty('vd:akammo');
const dpshoot = system.runInterval(() => {
if (typeof ammo === 'number') {
itemStack.setDynamicProperty('vd:akammo', ammo - 1);
}
}, 1)
system.runInterval(() => {
if (itemStack.getDynamicProperty('vd:akammo') <= 0) empty = true
if (itemStack.getDynamicProperty('vd:akammo') > 0) empty = false
})
const container = player.getComponent("minecraft:inventory")?.container
if (!container) return
container.setItem(player.selectedSlotIndex, itemStack)
})
world.afterEvents.itemUse.subscribe(ev => {
const { source: player, itemStack } = ev
if (itemStack.typeId !== mag) return
itemStack.setDynamicProperty('vd:akammo', 30);
const container = player.getComponent("minecraft:inventory")?.container
if (!container) return
container.setItem(player.selectedSlotIndex, itemStack)
}) ```
i removed the null part alr
so for the systemruninterval on the if part idk why it wont set empty var to either to true or false
anybody knew why?
How do I set the value of can_fly component
scripting can't change the value of components, you have to set the value of components in the entity JSON
you could add an event to your entity that adds a component group with the can_fly component and then trigger that event with scripts
Can fly is not a client entity json component, and it does can change just like minecraft:health
health is different since it's an attribute component where the JSON definition sets a max, min and default value
Yeah I think for some components, we can set and read values. Idk if can_fly can set
because using the command /ability we can change it
So I think there might be an api for it also
mayfly is separate from the can_fly component
only players have abilities
can_fly is just for pathfinding afaik
no but you can use the isSprinting property
Why does getDefaultSpawn always have maximum height level
the game tries to spawn the player at the highest position in the world
otherwise when you make a new world you'd probably start in a cave
I see, thanks a lot
Again this doesn't work with movement disabled
how can I get the potion type of the potion ENTITY.. in the EntityDieAfterEvent? (posting in entities general as well)
Ok, I am actually switching to the EntityRemovedBeforeEvent so I can get the location.. but still am wondering this..

there is no way to do this at in this event. if you want to do this you will have to add a dynamic property or a tag to the potion entity you can use. for example if the potion is always from a player create a itemUse event that gets the potion type and add the tags to the potion spawned either with a separate entitySpawn event or an area around the player. if its from a dispenser or witch i dont think you can do anything
same applies to entityRemove event
maybe you can do some magic with https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entityprojectilecomponent?view=minecraft-bedrock-experimental to match
No, It's in stable api, been using in in quite sometime
Thanks for letting me know, just found out I’m stupid and I’m not defining things properly
What’s the best method to learn scriptAPI if I already have some experience with JS or Java
I think the common answer is building projects, but looking at some large projects is also great, that's what i have been doing
Ah sweet okay. I’ll try and start simpler then
Any good recommendations for projects to check out?
It depends really what you are interested in, before i just started with simple tree capitators and like auto plant crops
Most of the time, i learned by porting some small mods from java to bedrock
p
guys how does onRedstoneUpdate works? Do I need to give the block a component? if yes which one and does it work like a tick intervall? when powered
someone? Please
bruh I'm dumb it literally says onRedstoneUpdate
can i get component a shulker box that is inside the inventory?
This is good advice, thank you
scripting can only access to components that are actually supported
since a component can be anything else other than "value"
what youre probably thinking of is attribute components, which includes health
although i wish we could freely edit attribute values...
Anyone know a way to store a data to a block (no entity involved) cuz eith states u can only store like 16 bits, mine used 24 bits (i am using hex per state to store some data) , i know some ways but i wanna know what you guys have done, cuz mine is probably more work.
Yeah that'll be useful, has a lot of potential uses
toJSON() is crazy
just some random free food ;-; ```js
getPlayerPlots() {
const data = JSON.parse(world.getDynamicProperty("playerPlots"));
const convert = (allowBlocks) => {
if (typeof allowBlocks === "number") {
return [
{
chest: (allowBlocks & (1 << 0)) !== 0,
barrel: (allowBlocks & (1 << 1)) !== 0,
undyedShulkerBox: (allowBlocks & (1 << 2)) !== 0,
enderChest: (allowBlocks & (1 << 3)) !== 0,
dropper: (allowBlocks & (1 << 4)) !== 0,
hopper: (allowBlocks & (1 << 5)) !== 0,
},
];
}
if (typeof allowBlocks === "object") {
let ab = 0;
if (allowBlocks.chest) ab |= 1 << 0;
if (allowBlocks.barrel) ab |= 1 << 1;
if (allowBlocks.undyedShulkerBox) ab |= 1 << 2;
if (allowBlocks.enderChest) ab |= 1 << 3;
if (allowBlocks.dropper) ab |= 1 << 4;
if (allowBlocks.hopper) ab |= 1 << 5;
return ab;
}
};
data.forEach((p) => {
if ("ab" in p) {
p.allowBlocks = convert(p.ab);
delete p.ab;
}
});
// should trigger when JSON.stringify(data)
Object.defineProperty(data, "toJSON", {
enumerable: false,
value() {
return this.map((p) => {
const copy = { ...p };
if ("allowBlocks" in copy) {
copy.ab = convert(copy.allowBlocks[0]);
delete copy.allowBlocks;
}
return copy;
});
},
});
return data;
}```
abcd
oh no, a bitwise operator is used, the complexity
Is initialSpawn in playerSpawn a first time join, or first time spawn in the world so it resets on joining again
it's before each "<player> joined the game" message in chat
Alright thanks again
copilot's help, im not fluent with bitwise, just have base understanding
Bitwise are very easy
They are made to shift the numbers binary numbers
Like
1 << 2
0000.0001 << 2
0000.0100
= 4
@subtle cove
Those bitwise turning the both right and left value to binary then compare each bit of both like : | , & , !
welp, not a language I wana learn for now, i just let ai speak it's own lang ;-;
It s easy to not to learn
U will need it to optimize your code trust me
Betwise just turns numbers to binary form and compare each position that s all :
Like
2 & 1
0010 & 0001
= 0 0 0 0
= 0
in any length, right?
They give you a binary result not true or false like the regular one
like the (allowBlocks & (1 << 45678))
Yes they are compare the positions in integers after turning the to binary :
Like
1 & 1 = 1
1 & 0 = 0
It will turn 1 to binary and shift it 45678 position to the left
And then it will give you very big number in return ._.
well, exchanging readability for optimization isn't really worth it on small cases like these. Especially since bitwise operators are uncommon(if not rare) in high level languages like JS
Hmm there are something called :
// Comments
Anyways what the problem with this code?_.
the db on our server was reaching limits so had to come up with anything necessary
What the problem so i can help you ._.
Can u tell me what the problem :-: ?
on nxt one we'll use separate objects for specific data use like one object dyprop per plot etc
the '[]' was abt 31k length
._.
data was lota this in the array
Oh i guess i want to save data in the most optimized way righr ?
i didnt have time to make changes on it's setup before, that's why
i wana avoid looping, and just use one object for specific use on the nxt season
🤦♂️ can u tell me what you are trying to do , and what s your problem instead of explaining me how it works ? @subtle cove
Oh you want to avoid looping and use one object for all players data ?
it's not a problem... ;-; dont solve it, it's already handled
Sure ? :-: because i have an idea that make it better than using 999 object
do tell
So u use one object that have multiple keys that uses arrays
And then using
name , members , from to , center , tp extra
Use Plural words
And make the key an array
So when u want a player data u use
playersPlots[1][1][1] etc...
It will be more optimized
U can bring all datas in one object in one dynamic array by looping only the players names
const DB = new Database("PLOT");// dprop of IGNkeys[]
const plot = DB.get(player.name);// dprop plotData
Then after getting the index , u use it for the rest thing , because each player's data are having the same index
I think it s better to use a code so u understand me
that's likely gona use more enums, right?
Hmmm no just using arrays
that's how i'd name em instead of plain numbers
const playerPlots = {
names : [],
memberes : [[]],
froms : [] ,
tos : [],
center : [] ,
tps : [],
allowBlocks : [[]],
playerTages : [[]]
}
So instead of using multiple objects u use only one
is it like a 2d table?

matching their indexes...
And use a loop to search The concerned player index
And use that index to reach the rest of its data
Hmmm yes u can say so
const DB = new
Database("PLOTS") ;
const plot = DB.set(playerPlots) ;
And just for your knowledge, if u a big array instead of of keys u will get better results
const playerPlots = [ [] , [[]] , .... , [[]] ]
thx for the offer btw
i had this idea yrs ago, but setting up enums for readability got me stuck, and just left it
._. u are using js or ts ?
storage for now since it's using []
Oh ._.
changing the data w/o testing in-game ;-;
Are u sure memory is a big deal ?
I mean storage*
Like will you store 1 TB of datas ;-;
no, not that storage, it's the 32k limit per property i dont wana reach
🗿
I actually don't store players locas as raw objects
I omit everything and let only numbers
Like instead of
{ X : 8272 , y : 8272 , z : -9282 }
I turn them into string and :
Let locString = "8272:8727:-9282/"
And do concatenation to the rest ._.
yup, same thing ig
And i got a little string like this instead:
Let locsString "x1:y1:z1/x2:y2:z2/etc../"
was thinking if there's other way than vectors
And i made a function to make them into objects again
Huh ☠️
What do u mean , u just turn numbers into string then put commas between each location, and by that you are getting much bigger storage
i mean compacting the vectors collected
oh well it's too much to think of anyway
was just an idea to the bin
:-: ._.
how long has it been recording 👀
☠️ i made its code
ohw
As i remember it recorded 97K char last time
But i can compact it more by using @subtle cove hexadecimal format
It s size will be nearly - 50%
hmm, idk abt using hex yet. im not entering any multiple big numbers yet
i could only take note if it for now 'til i need it soon, thx
i mean yeh
why is it that after taming the nautilus, then calling that nautilus entity with script api then checking if it's tamed by EntityTameableComponent and EntityTameMountComponent returns undefined instead of something that has value? i cannot seem to get who's owner of this entity or even the tamedMob.getComponent(EntityTameMountComponent.componentId)?.isTamed and tamedMob.getComponent(EntityTameableComponent.componentId)?.isTamed doesn't return any value. I mean it should be cuz it's tamed i think.. is this a bug?
Tame mount? i never seen that component
It's a "bug" / WAI for vanilla mobs as once tamed they remove that component.
You are completely misreading what they're asking.
They even stated they used both TameMount and Tameable
i didnt read the whole convo
You should read the whole thing next time.
you re right
ah okay, hope they fix this. Thanks for letting me know, i thought i was crazy.
Is there a way to make players fly faster? cause I can't set the value of the custom component called "flying_speed"
Speed effect while in flying state
the getPing sometimes errors
where can i find this endstone
ahhh
Creative Flight dampens the effect of movement outside of flight itself
A really high level of speed coukd do something, can't remember if flight cancels the effects of speed or not
Either way, I believe both applyImpulse and applyKnockback can be used to increase flight speed but would need to be constantly run in a runInterval
Alr thanks
No problem
How would I go about making it run commands off a player being hit by 2 different entities?
Im trying to make it so when hit by jay:zombie it runs a set of commands then hit by jay:boss_zombie it runs a different set
rn im using
"events": {
"jay:player_hit": {
"queue_command": {
"command": [
"scoreboard players operation @s Health -= ZomDamage Settings",
"execute @s[scores={Health=..0}] ~~~ kill @s"
]
}
},```
in the player.json but thats j when the player is hit at all so its very inaccurate
Can server-admin transferplayer be used in realms?
It could in the past but I'm unaware if that has since changed. It was mentioned a while back that if it were abused they would revisit it but I haven't heard any complaints so you should be good.
nice, i just wanted to know before buying a realm to transfer players easier to my server.
If by some chance you know someone with a realm, you might be able to convince them to let you do a quick test to verify.
it can
if not they must've changed it, however ive seen no updates on that
Y'know basic scripts or nah??
ehh not really
How do you do anything with getAllStates()?
It's a record so you loop through it.
Oke
how long have u been testing with endstone
like a day
dang is that like plugin or script api but only for endstone
ah
so u can do just script api and access like
xuid
os
ip
boss bars
client sided nametags
question would endstone be good for a smp
i mean yeah
only thing that really matters is performance
so vps
im using ovhcloud right now
just the vps1 server
$4.90 USD for pretty crazy things
are you batman and a silver surfer??
yes
Ok so I've gotten it to print out the keys and values into s console.error but im currently struggling on how to get it into setPermutation
Just do setPemutation(getAllStates())
No Blockpermutation.resolve?
Well, yeah, setPermutation(BP.resolve(getAllStates()))
I'm quite confused tbh.
This is all ovee complicated.
Why don't you just setPermutation(block.permutation)
because im trying to copy a block from a specific location
and any states it may have
What does that have to do with anything?
If you have access to the block you have access to its permutation. So just use that permuation and pass it into setPermutation.
I'm lost
wait you can just use e.block.permutation in setPermutation and it will just use the permutations found?
damn
Yes.
thanks
Ooooo
can u send link never seen it but heard of it
nvm found it
I mean the cpu is not the best but their prices are ❤️
300 entities in 1 spot with a $4.90 server and the tps only drops to 19 and stats consistantly at 19
also 36 ping and the server is 12 hours away in a different country
const volume = new BlockVolume({ x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0 });
for (const eachb of volume.getBlockLocationIterator()) {
const blockt = block.dimension.getBlock(eachb);
console.error(`${blockt.typeId}`)
}
Anyone know what I'm doing wrong. It doesn't return the typeId. Says it's undefined, but it's clearly a block I'm looking at.
Oooooh aparently it gives the coords relative to the block, but not the global coords so I just had to add those into it:
const volume = new BlockVolume({ x: -9, y: 1, z: -9 }, { x: 9, y: 11, z: 9 });
for (const eb of volume.getBlockLocationIterator()) {
const blockt = block.dimension.getBlock({x:loc.x+eb.x,y:loc.y+eb.y,z:loc.z+eb.z});
console.error(`${eb.x},${eb.y},${eb.z},${blockt.typeId}`)
}```
umm, how can i detect when an entity explode?
world.afterEvents.explosion.subscribe(({source: entity}) => {}) or something?
don't use that
oh afterEvents.... what are you gonna do with that?
i always use beforeEvents to prevent specific entity from exploding
🗣️ 🔥 🔥
world.beforeEvents.explosion.subscribe((E)=>{
if(E.source?.typeId=="minecraft:creeper")E.setImpactedBlocks([])
})
it used whenever a creeper explode, any impacted block still remain untouched
ill spawn an entity at the location of the exploded entity, so i think it has to be done using beforeEvents, right?
haven't tried using that method
try it then, mostly beforeEvents used if the following entity removed where you cannot execute some component with afterEvents
i have to extract the entity location and spawn it using dimension, bec it doesnt work with the explosion source
yup, that works
are there any script equivalent to /say or /tell
smth that sends message using scripts basically
Can any mob apart from players use the eqquipable component?
player.sendMessage
When the player is looking straight, what is the x rotation value in player.getRotation()
0. x-rotation is around the x-axis, which involves looking up and down. Minecraft defines straight forward as 0 rotation
Thank you!
can we trigger the minecraft:ageable event on the animal to simulate eating/breeding?
Use entity.triggerEvent
This is my gui script how do I make it so you need a tag to see a button and where would I put it
world.afterEvents.itemUse.subscribe(async (data) => {
const player = data.source;
if (data.itemStack.typeId === 'minecraft:apple') {
await test(player);
}
})
function test(player) {
const menu = new ActionFormData()
.title("title")
.button("1")
.button("2")
.button("3");
menu.show(player).then(result => {
if (result.canceled) return;
switch (result.selection) {
case 0:
// response for first button
break;
case 1:
// response for second button
break;
case 2:
// response for third button
break;
}
});
} ```
Make different uis
Or make if statement between button and other
Like this
....
.title("title");
if ( player.TagsMethod = "your Name tag" ) menu.button("1") ;
And so on
Sorry i don't remember the exact method to get players tag or tags
So it must be pussting if statement and use if else too
@midnight crane
Okay thanks

player.hasTag("");
if (player.hasTag("tag") {
menu.button("1")
}
Where is ")"?!??!?!?!?!?
cleary I made a mistake!!!!!!
How dare you still not fix it?!
Js wanna ask if ItemStack or ItemStack.clone() returns an object that consists also all method functions, so that it can be stored and return again
Nvm, it returns {} or error if I stringify it
Does anyone know if we can use getBlockFromViewDirection and or getEntityFromViewDirection to get blocks/entities from BEHIND the view direction?
Its "View Direction" for a reason
But I think math can make it
Reversing the facingLocation I think (BlockRaycastHit)
And reversing the entity.location (EntityRaycastHit)
do we not have any getPlayer method that uses a players id? Only thing I'm seeing is to do world.getPlayers(); and going through each one and checking it
We dont
Needs to check all players first
You can make your own Prototype or Function as a shortcut instead
yeah, all just to send the player a message that they left a party
damn, id isn't even an entity filter
maybe I should be saving players in a party as just their player name
or include both ig
If it's about player leave event, they also have playerName
nope, making a party system
Why id if the player exist in the world
Its part of Entity class
So that they persist in the party if they leave the world
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entityfilter?view=minecraft-bedrock-stable It is in the Entity class, it is not in the EntityFilter interface
That was used for certain function such as raycast hit, idk why you need that, what code did you use
It's used for world.getPlayers(), player leave event isn't remotely what I'm trying to do right now
So you want to get the player's name that didn't exist anytime
Yeah I think make database to save the names would be right
all good, already solved it. I just needed to know if there was a native getPlayer(entityId) call anywhere. It's for a party system and I'm building out the commands for it
It worked thank you so much
Generally what's the point of unsubscribing from an event like afterPlayerInteractWithBlock?
There isn't one unless you're embedding one event inside of another for whatever reason
But there are usually better alternatives then having to do that
What
Seems like you can use world.getEntity() to get players as well.
import { Player } from "@minecraft/server";
import { system } from "@minecraft/server";
import { world } from "@minecraft/server";
world.afterEvents.playerJoin.subscribe(e => {
const { playerId } = e
system.runInterval(() => {
const entity = world.getEntity(playerId)
if (!entity) {
world.sendMessage("nothing found")
return
}
world.sendMessage(entity.id)
if (entity instanceof Player) {
world.sendMessage("found a player!!")
world.sendMessage(`player has slot ${entity.selectedSlotIndex} selected`)
}
}, 100)
})
It only says Entity in the docs. I guess it includes players too though.
/**
* @remarks
* Returns an entity based on the provided id.
*
* @param id
* The id of the entity.
* @returns
* The requested entity object.
* @throws
* Throws if the given entity id is invalid.
*/
getEntity(id: string): Entity | undefined;
a player is an entity
woops, that completely slipped my mind, I was only searching by player. Thanks!
Although I just realized I should also be storing player names
I wonder which is more efficient to do, I'd assume several world.getEntity calls vs a world.getPlayers with a name filter
I'd say it depends on how many players you're planning to get.
You could always do a filter afterwards using JavaScript's .filter() method on .getAllPlayers() if EntityQueryOptions doesn't provide enough options.
world.getAllPlayers().filter(player => player.name === "player1")
getPlayers has entityQueryOptions
could use that instead
I guess the flow is either A) js players = world.getPlayers(filter by name if included in list of players in party) -> for loop of players -> send message or B) ```js
for loop of players in the party that I stored -> player = world.getEntity(id) -> send message
A makes more sense
I think B makes more sense lol
how come
easier to read, I don't know about the runtime, it's likely negligible
also why store the names
I wasn't going to store names originally but I figured people might want some sort of /plist to show players in their party
Won't really be helpful if it's just a bunch of entity Id's
just use tags or dynamic properties
and make a custom command that lists the players
That's what I'm doing
I'm going to look at both ways to see which ones actually easier to read now lol
okay now that I visualized it more, maybe B is better
lol
I'd like to highlight the off-chance that a player might change their username, and if something would break as a result of that.
Were you planning on storing both ids and name?
It was originally just going to be player Id but now it's this js const partyInfo = { partyId: playerId, players: [{ name: player.name, id: playerId, online: true }] }
use ids instead
I'm using ids for everything, name is display purposes only
makes sense
this pretty much disqualifies option A then anyways
It's a very rare chance for that to occur anyways since the party would have to be persisting long enough for a player to leave, change their username, then rejoin
export function partyDisband(source) {
const player = source.sourceEntity;
const playerId = player.id;
let parsedPartyListInfo = JSON.parse(world.getDynamicProperty('party_list') ?? '[]');
const index = parsedPartyListInfo.findIndex(entry => entry.partyId === playerId);
const listedParty = parsedPartyListInfo[index];
if(index != -1) {
for(const entry of listedParty.players) {
const playerInParty = world.getEntity(entry.id);
if(playerInParty.id === listedParty.partyId) continue;
playerInParty.sendMessage(`The party you were in has disbanded.`)
}
parsedPartyListInfo.splice(index, 1);
world.setDynamicProperty('party_list', JSON.stringify(parsedPartyListInfo));
player.sendMessage(`Party disbanded.`)
}
else {
player.sendMessage(`You are not in a party or are a party leader.`);
}
}``` this seems easy enough to read through though
why are you not just giving them a dynamic property or tag to make them part of the party
doing this seems like extra work, and worse because you need to stringify/parse
players can stay in a party after they leave the world
as long as one player is still active
This way I can just access all of the relevant data in one place
I really need to set up a dual gameplay system so I can test these out though
just create functions to get the relevant data?
But I'm pretty sure I wouldn't be able to read if a player was in a party after they had left the world
I don't know though, I can't test this stuff out
hm.
I see now
Though this does have a potential limit compared to storing this data per player
Doesn't world.getPlayers return all players, offline and online?
then why does getAllPlayers specify that they are all active players
that would essentially make getAllPlayers and getPlayers pretty much identical minus not having filter options on getPlayers
active as in, online
Who even uses getPlayers
people who need entityQueryOptions for players.
honestly idk why getAllPlayers exists
Actually, I don't think I would ever have to worry about reaching the limit
Kinda same as getEntities, so does that means getPlayers is better
if you need entityQueryOptions.
Yeah I think getAllPlayers would be useless
It's just a long typing clone that doesn't have better filtering
yeah.
mk.. so this method can store around 400-450 players
I don't think I'd ever run into issues unless something weird happened
they would also all have to be concurrent players in active parties
-# I mostly trust the getAllPlayers as its name says its purpose
{"partyId":"playerId","players":[{"name":"player.name","id":"playerId","online":true},{"name":"player.name.2","id":"playerId","online":true},{"name":"player.name.3","id":"playerId","online":true},{"name":"player.name.4","id":"playerId","online":true}]} is around 250 characters, or 500 bytes (assuming UTF-16 string encoding).
String dynamic properties have a limit of around 32Kb the last time I checked. That makes it so you can have something along the lines of 50 parties at maximum. Does that seem like something that might be hit?
Unless something weird happens and my add-on explodes into popularity out of nowhere and gets put in a giant server with thousands of people, there's no way it's ever hitting that limit
I could alternatively build it out by having each party by a separateId and just referencing all active parties in another dynamic property by an Id
Maybe put an easter egg if someone ever does hit that limit 😆
this would support ~12k players
I mean I can try and lock parties down to be present on the player, but last time I tried it it was a total mess
dream big right?
My add-on will be played by 60k + on a single server
oh boy
You'd probably get a user messaging you if they ever did hit that limit. That's when I'd start to worry about it.
I would be ecstatic if that were ever a problem
But we love future proofing for scenario's that will almost never happen
so I guess I'll try and redo this tomorrow, I only built out a create, leave, and disband command anyways
I think if per player parties doesn't work, the only other option is to just scale it up, create multiple party Id lists, and simplify the id's down to be incremental starting from 0 -> whatever
so like, maybe make a new dynamic property for extra space each time it goes past its limit?
is that the only option?
because of how many properties you can have
What do I do if I my server has 10 million players on it active concurrently?!?!?
I will
I'll look into it more I guess tomorrow. If I store it on per player, it really is infinite
how would get the offline then
I think getPlayers does return offline?
I mean, you could just make them leave the party when they leave
probably not a good option
no
I wanted to let them be able to leave and come back and be in the same party
without needing to be reinvited
This creates a whole bungle of annoying extra work imo
I have to now update the party info on every single player in the world each time
anytime I want to do anything with a party, I need to get all players in the world and then filter them based on if they have a specific property
yeah
If a server ever got so large where the other methods would break the runtime on something like this would be painful
at least I think it would, I don't really know 🤷♂️
im not an expert here clearly, I wish you luck
Neither am I, I just do things
This would probably be a bigger issue whenever I add in guilds since that would store a lot more information
so I probably should come up with a better sorting method now that I can just paste later
but yeah this should not return offline players
if it does, thats news to me
i cant test it rn
I'm too lazy to make a simulated player
because like, how would it return offline players?
they dont exist anymore when they leave
doesnt make sense
well, now I'm curious enough hold on 😭
lmk
I've actually never used gametest, no clue what I'm doing
lmao
-# thats why I said I cant
okay, I can't make a simulated player leave the game
so this won't work lol
maybe?
and now my game crashed :]
I'm assuming I would need to use bot.disconnect();
couldnt you just get a player to test it for you
It would certainly be much easier lol
i can be your tester
I really just need to get a 2nd version of minecraft running
but that's a little tedious in itself
are you able to join preview worlds?
I think it works on same platform, just not on cross platform
I have preview downloaded
pc?
im on pc
yeah
we're good then.
can you test now?
what's your gt
ill dm you it
can we uae afterEvents.playerInteractWithBlock to move the interacted block into our equipmentSlot? and the following block still with it's data?
like how setEquipment
You can, but why not pick block feature
Does player interact with block still works like clicking any block, I think in the new update it's only detectable when interacting a block like chest, furnace, crafting table, anything that has interactions
i wanted to interacy with vanilla_block, this:
- Cactus
- Cake
- Hay Bale
- Jack'O Lantern
Purpose to make them moved to Head.Armor.Slot
Yes you can
nice
is there any better way to detect if a player is sneaking than to check for the value of the isSneaking property every tick
Nope
There is no event to check
Not sure why you would need a different way tho
There is a way to check every packet sent if it’s crouching it loops trough every player
i don't but i mean checking every tick is obviously more costly than an event listener
not like it matters much tho
im assuming the effect is negligible
anyway is this a game bug or what
sneaking is meant to clear the velocity of enderbutt which it does
but why do i fall down so slop
slow
Yeah, true. I know someone had a code with like 100s of thousands of iterations per tick if not millions but yeah
lol first time seeing that
it happens every time too not rng
i guess this means i was right about spamming sneak making you fall slower then
LMAO
Haha thanks for the tip 💀
i feel like this is a result of the recent movement cheat prevention measures theyve been pushing out
ive had a lot of issues with movement but this is probably the most apparent if it is caused by it
You got server authoritive movement on? It’s pretty bugged on Linux iirc
this is a world not a server
so i can't configure that
Oh.
Didn’t know they pushed it onto worlds
But that’s kinda good
💀
I’m in so mood for coding rn bro
Gotta install mcpe on my pc asap
is there any downsides for allowing achivements in an addon ?
like does it disable triggering commands or block anything else
That's not scripting, but it doesn't do anything else
nvm LMAO this was caused by my scripts
AntiCheat?
@last latch yoo is it possible to make a hud_screen.json where I can add a button that shows on every player screen and when you press the button it opens the menu from the bp
Oh shoot wrong channel my bad
I ment to say it in Json ui general
nah the logic for the enderbutt was just stupid
i wanted sneaking to act as like a dismount button basically which meant it cleared player velocity
but it fired multiple times so if you kept sneaking itd just repeatedly clear and clear it
is it possible to close an action/modal form for a player
Yes but only mobile players can touch buttons in hud
How do I make it where PC people can press it too @last latch
Is it possible to spawn an entity with a dye color?
for example, a red sheep?
@last latch is this a thing in scripting
EntityEquippableComponent
For import { EntityEquippableComponent } @minecraft/server;
yea
What about EquipmentSlot
I just trying to learn here okay @last latch so sorry if I asking too many questions
you have all the info there
It's an enumeration, more useful for TypeScript users
Also, try pinging other people less
hmm, is it possible to detect the target of my entity? aka if the zombie is targetting a villager,
I'm sure someone has already asked this. Try searching this channel
I can't really remember the answer and I am currently on my phone, so that's the best thing I can tell you right now :/
i think its entity.target or something
Check documentation maybe
Are you in stable or preview?
Guys, I want to create a system that will have several codes stored within the addon itself, and if you use, for example, `?item ABCDE, it will delete the command from the chat and give you a compass only once, then this code would be set as used
2.0.0-stable, as always
wdym "as always" 😭
i never use beta api, bec im god damn lazy (u can see it next to my name) i just dont want to update my addon every time the api gets updated
It’s not like it’s beta 1.3.0 where 90% gets changed
Nowadays old things rarely change
You can use „beta” as version and it’ll auto-update in most cases
oh, thats a nice script! now remake the whole thing just bec we decided to change how it works.
also, entity.target works, its stable
im using the 2.0.0-stable, no experimental toggles, and it works.
havent you read what i sent?
reading is for nerds.
-# jk
Is there any way to detect a chest the player interacted after the player closing it? To possibly detect what items player put in there
My friends and I managed to expand the player's inventory using serenity + json ui.
hehhehe
share your secrets 🙏🏻
Is there a way to make that we prioritize onUseOn over onUse?
onUse is prioritize over onUseOn that's why I'm asking for solution
nvm, found it.
It was supposed to turn into a swap shelf when I hit the shelf with the stick.
Era para quando eu bater com o graveto na prateleira era para virar uma prateleira de troca
Is it possible to ".replace" A RawMessage?
wdym
Like, let's say u have a lang file containing your custom item that has an additional string something like "\nSomethingFancy", then inside the script, i want to erase or remove that "\nSomethingFancy", cuz i just used it for Creative Inventory and i don't want it to be displayed when i am calling it's name.
Wait, i think my message is confusing, even I am confused
Imma send an image
i don't want to include the whole thing
i don't want to create a hardcoded names for each items just for this cause that's not maintainable if you have many items
object oriented programming
Is it possible to subscribe to console logs and warns from scripting API to /connect websocket just like "PlayerMessage" event?
Yes, but it causes problems
Do you know what event I need to subscribe?
That's a showcase not help.
Guys im doing a system that gives a shulker box full of items
How can i do It?
I know i cant make it drop, and i need to use structure blocks
But idk how to put structure loads in scriptinf
use a chest placed in a chunk that's always loaded
Loaded with tickingarea?
yeah
But how would that help me?
example of my implementation but for kits
static fetchKitItems(kitId: KitId): ItemStack[] {
const dimId = cfg.kitChests.dimensionId as string;
const dim = world.getDimension(dimId as any);
const pos = this.getKitChestLocation(kitId);
const block = dim.getBlock(pos as any);
const container = (block as any)?.getComponent?.("inventory")?.container;
if (!container) return [];
const slots: number[] = ((cfg.kitChests.kitSlots as any)[kitId] as number[]) ?? [];
const out: ItemStack[] = [];
for (const slot of slots) {
try {
const it = container.getItem(slot);
if (!it) continue;
out.push(it.clone());
} catch {}
}
return out;
}
place the filled shulker in a chest
then load it from there
Ohhhhhhhhhhh
get the coordinates the chest is at
Makes much more sense
and know the slot (just place it on the first slot , index 0)
then get the item from the chest's container
chest.getItem(0)
then you have the shulker stored in memory simple as that
very clean way to do it
Wowwwww so cool
you can do whatever with it that you can with a normal itemstack in script api
My system looks a bit like the kit system
clone, delete, edit, add to inventory etc.
The only diff is im trying to like
Create several codes and save them set to false; when they are used, they will be set to true.
similar to gift codes?
or
like codes that you can redeem to receive a shulker
or what do you mean by a code
yes
When i use It i got the pvp kit
and the code becomes unusable ?
Yes
okay
do you want it to persist between sessions ? (e.g. world/server leave -> its still unusable)
I tried using gpt but he is so dumb i gave up and started trying looking myself in wikis
Its a BDS but probably yes
okay you can use dynamic properties for this
do you want self-configured codes or do you want like a list of procedural, random-generated codes
i have a system similar to what you want but used for redeeming gift cards to receive gems
I was going to make random ones from websites and put them in the addon lol
example of self-configured codes, you make your own list of codes, like using code catdog123 -> give kit #1
yeah dont do that it's tedious
Yea
My code already has the / working, but the give part isn't working yet.
Oh cool
but it's predictable, meaning you can generate the same random sequence again whenever
I don't think it can happen easily, there will be 50 codes per kit, and there are 6
that's not difficult
the amount doesn't really matter
Bro is you an angel 😭😭😭😭😭😭
the only information you need to really 'know' yourself is a static seed configured in your code
you can for example make a form that generates a valid gift code later
Okay okay
so you can distribute them to players
example of mine
but instead of what i have like GEMS_100 GEMS_50, you could have KIT_1, KIT_2 and so on
Ohhhhh cool
static generateCode(seed: string, table: string, index: number): string {
const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let state = this.hash32(`${seed}:${table}:${index}`) || 0x6d2b79f5;
const nextU32 = () => {
// xorshift32
state ^= state << 13;
state ^= state >>> 17;
state ^= state << 5;
return state >>> 0;
};
const chars: string[] = [];
for (let i = 0; i < 16; i++) {
const r = nextU32();
chars.push(charset[r % charset.length]);
}
const groups = [chars.slice(0, 4), chars.slice(4, 8), chars.slice(8, 12), chars.slice(12, 16)].map((g) =>
g.join("")
);
return groups.join("-");
}
private static hash32(input: string): number {
// FNV-1a 32-bit
let h = 0x811c9dc5;
for (let i = 0; i < input.length; i++) {
h ^= input.charCodeAt(i);
h = Math.imul(h, 0x01000193);
}
return h >>> 0;
}
this is what i use to generate codes
Wow
generateCode will always output the same code as long as you input the same values used to generate the state
which here are seed, table (for me this is like GEMS_100, GEMS_5) and the index
that seems like a nice way for generating random codes
it is
Im impressed
the key is in using predictable RNG
the codes are meant to be predictable
the seed is meant to be kept secret
ok to be honest theres practically going to be no one whos gonna predict this just for something
so yeah ig it works
with these values
seed = "abc123"
table = "GEMS_50"
index = 0
generateCode() might output e.g. "123" (obviously my formaat isn't the same but i cba to type it out), but if i switch any of these values (key value here is the seed since it's the only one that only the server only has authority to access), it could output "321"
the list of gift codes is predictable and that's why it works
you dont need to have them all stored individually somewhere
predicting it requires you to know the seed and it'll be tedious to bruteforce
it is nice
as long as they dont have additional intel that reduce the pool
the worst are knowing the charset and length of the seed
which is why its useful to use a mix of symbols and make it long
yeah it doesnt matter what it is as long as its not guessable
but bruteforcing a 20-char seed using any possible unicode will take astronomically long
@jolly citrus But like, how would I link the code to the main command? Would I create a codes.js file, store it there, set its values to true/false, and then import it into main.js?
what main command
and what values to true/false
Can beforeEvents.entityRemove REALLY not check the removed entitys tag..? its a before event... wth
Are you using system.run?
In beforeEvents, nothing has actually happened and it can't run (almost) anything cause it's in read-only mode
I’ll try it out
The problem is that I’m getting an ‘entity no longer exists’ error
You could cancel the event and then kill them afterwards
Ahhhhh good idea!
Nvm.. it has no event cancel method..
"Anything" is anything that changes the world, while anything that simply reads information can be run. Although, for example setDP can also be used in beforeEvents
what do u need?
or did u already solve it?
Why do i get such low fps on my world
With scripts
Theres not rlly any tps issues its just that im stuck playing on like 5 fps
scripts do not affect fps at all
Sometimes it can jump up to like 80-90 but other than that i get 5-15
What is it then LMAO
if i remove the pack completely i get 200
Well, the most it could be is because of particles that are spawned by a script or something like that
I’m trying to make renewable deepslate by converting stone splashed by a thick potion into deepslate, I currently am getting the itemUse before event to add a tag to the player who threw the potion, getting the entity spawn after event to check if the projectile owner has the tag, removing the owners tag and applying a new tag to the projectile, and then I wanted to use beforeentityremove to get the tag and then convert the blocks at the location if the projectile had the tag, but that’s giving me an invalid entity error. I just need a good way to do this, idc how.
You make a great point
When I said anything I was referring to all the things we can do through scripting and more often than not, I've found that these methods don't tend to work when in read-only.
As for the lack of an event cancel in this scenario, it should've been something I should've assumed, given its name and definition, but I tend to assume and find out the hard way with these things 😅
entity.playAnimation("animation.cnb_crp_sg1_l1.attack", {controller: "variable.gh=48;"})
Any ideas why this variable isn't transferring to the animation?
Feel like it's something with my formatting.
I have it working right now where I am using the projectileHitBlock hook and just checking the owners tags for a "threwThickPotion" tag, then removing it and doing the conversion. But I feel like this is not a good way to do it. I think the projectile should have the tag, because if there are multiple it might break, but you cant get the potion type from the ENTITY, so i have to get it from the owner in a before event, then apply it to the entity when its created by the owner if its of type splash potion and the owner has the tags. if anyone has any recs or suggestions id credit them with the help when i release my addon. Im so burnt out from this one stupid problemXD
Interesting
Throwing random ideas out now:
Use the projectileHitBlock event to spawn an invisible dummy entity on the block the projectile hit, transfer the tags over, and then do the detection with the dummy entity?
Then have the other dummy entity runTimeout itself into a .remove()
Oh my GOD bruh
this is genius.. ill have to make a dummy entity but that shouldnt be too hard at this pointXD
🤣
Dummy entities are unfathomablely easy to create
They have like 5 components at most
So you're in luck
Why did you make it the name of your controller?
Because I don't know how to read this 😂
agh dang, i have to make it into an addon then huh? Its currently just a BP.
Form.slider(translate, 3, distlimiter, {valueStep: 1, defaultValue: oldsavefollow})
Was thinking it worked similar to a slider, but guess I was wrong.
You might
Unless not adding resource pack file for an entity makes it invisible
I can give you an explanation of what the parts do if you'd like
If you're really trying to just keep it to a bp you could edit the armor_stand and make a component group where gravity and damage is turned off.
Yes please, that would be awesome.
Cool
I will keep this in mind, thank you
am i not thinking of a better way to do this though? it makes sense right?
could i add an event/ component group to the splash potion that the script activates when the entity is created/removed??
Are you able to target the potion type and name with:
world.afterEvents.entityDie
```?
You should even be able to store the location of the place where it "died".
Nope, doesn't count as dying, just tested it.
player.camera.fade({
fadeColor: { red: 1.0, green: 0.0, blue: 0.0, alpha: 0.1 },
fadeTime: {
fadeInTime: 1.0, // 1 second fade in
holdTime: 10.0, // Hold for 10 seconds (max allowed)
fadeOutTime: 1.0 // 1 second fade out
}
});
why is the alpha setting not working?
fadeColor only accepts RGB.
Documentation for @minecraft/server
The only other ways I can think of require more load on the system, I think that's probably one of the best.
Been thinking for the last 20 mins.
Oh wait, this could be ANY thick splash potion, or a perticular type?
Wait, @devout sandal is the issue just that you can't get the location of the splash potion?
Because I think I know what happened here, the location is within the event itself so you have to grab it a different way than entity.location
Am I missing something:
world.afterEvents.projectileHitBlock.subscribe((e) => {
const { projectile, location } = e
console.error(projectile.typeId)
console.error(location.x)
})
You should still be able to run the command from the script though?
@jolly citrus what the diff between the Typescript and the javascript and if i use js instead of ts the code will break?
BlendOutTime?:
- defines the amount of time taken for the last frame of the animation to transition into the entities base geometry, or into the next frame of the animation currently playing. The default value is
0
Controller?: - defines the identifier of the animation controller. This matching an existing animation controller in the resource pack will cause it to override the controllers animations. This being a different value to another playAnimation controller will cause the 2 animations to play simultaneously. This being the same value as another playAnimation controller will stop the first animation from playing and cancel it, with animation the second playing normally, the default value is
__runtime_controller
nextState?: - defines an animation identifier or shortname (found in an entity's resource pack file) to immediately transition into playing upon the prior animation finishing or it's
stopExpressionbeing met. The default value isnone
Players?: - passes a player object defining all the players capable of seeing the animation play. The default is all players
StopExpression?: - a string molang expression value made up of molang queries and/or variables defined in an entity's resource pack file. When the defined conditions are met, the animation will immediately stop playing or gradually transition from for the duration of time stated in the
blendOutTimeto the animation innextState. The default value isquery.any_animation_finished
Someone knows?
ye just no transparancy
Oh wow, thank you for all that work! That's sad, I was hoping variables could be transferred to an animation then from script, but doesn't seem to be able to.
Yeah, scripts not being able to manipulate animations is a bit of a bummer to me too
What your doing does sound like a situation that might work with a property but I'm not fully sure
I thought about it, but my properties are super full right now, at like 29 so trying to spare them and not sure I wanted to route all the attacks through properties either.
Oh... wait I think I could just run it from a command 🤦♂️ . Thank you for explaining all that though!
Absolutely no problem 👍
It's such a tiny thing, but when the entity that's attacking get's knocked back there's a little jump they do because the entity gets thrown up. I was trying to neutralize that so the attack animation doesn't get muddled by all the jumping. Thankfully I was able to do this:
const eloc = damagingEntity.location
const topb = entity.dimension.getTopmostBlock(ploc)
const gh = topb.y - ploc.y
entity.runCommand(`playanimation @s "animation.cnb_crp_sg1_l1.attack" none 0 "variable.gh=${gh};"`);
I thought it did.. because the cause for its removal in the entityRemove hook logs as 'contact' damage.\
the issue is differentiating between what potion type it was when it died, I can get location pretty easily with any of the above mentioned hooks, but the splash potion ENTITY, type id is just "minecraft:splash_potion" and its localization key is similarly non specific, so I am having to use tag/dynamicProperties. A
nything that is an after event throws the invalidentityerror, and the only before event I could find that was relevant "entityRemove" throws it as well..
There is no logical difference
Just rempve all the ts specific features
Type declarations annotations etc
pauseNotification.title.onePlayer=%s joined your game!
player.sendMessage({
translate: "pauseNotification.title.onePlayer",
with: [player.name],
})```this kind of .replace() in lang
Ahh thank you so much! Forgot that this exists
Anyone know the best way to plan/make a route for a camera cutscene?
how do I check for this?
entity.isValid
wait it's an attribute? not a method?
thanks
I thought it's isValid()
what's the amount limit of dynamicProperty? and does it share with other addons too?
Each dynamic property is stored in the world file and is linked to the specific behavior pack (via its manifest UUID) that created it. While there's no hard technical limit on how many you can create, excessive use will cause the world file size to grow significantly.
In the manifest uuid?
sorry, I phrased it wrong...
Get it, thanks
I see, thank you for the info
legacy
how do i get value of component from an item or entity?
Why does block.above().location always on the very corner, or something wrong
i do know if it uses getComponent
getComponent(id)
Or if dp getDynamicProperty(id)
check the docs for it's readable and writable properties
block.above() is a vector 3 already
I tried to spawn an entity in that location but it's always on the corner of the block
world.beforeEvents.playerInteractWithBlock.subscribe(data=>{
const {faceLocation,block,player,itemStack: item} = data;
player.dimension.spawnEntity("minecraft:allay",block.above().location)
Like that
I mean it did spawn, just not centered
block.center()?
Centered at the top of the block
I'll try that
Thanks
It can be like block.above().center() right
hmmm
yeh sorry for not answering why it does that, since .location is just an integer location of the block and that's in the corner since there's no decimal and the center is 0.5 0.5 0.5
import {EntityComponentTypes as ect} from "minecraft/server";
for(const Target of world.getAllPlayers(){
const A = Target.getComponent(ect.Health);
const B = A.currentValue;
const C = A.effectiveMax;
if(A){if(B<C){A.setCurrentValue(B+1,C)}}
})
wait
is it correct?
i mean how player.Health component works? and if player has Health_Boost effect, will it affect it's max value in the json? and how to detect if the player's health is full before make the script stops detecting it?
also saturation.component
Oops misunderstood
does script api supports write and read the data of this thing or not yet
The setCurrentValue only asks 1 argument, the number/amount of hearts to be filled
Yes the health boost affects effectiveMax
It does yes.
its by detecting if currentValue is equal to effectiveMax, idk if I'm right
maybe, may i have to check other example
In your example, you use alias A,B,C so:
if(A === B){
player.sendMessage("Im full health") //or something
}
can we create a function inside a function? i hope so
why not?? lol
wait... ur shadowgamer??
understandable, and if i create it inside the function, will the other type can detect the function that is inside the function?
no, it's only accessible inside that scope.
nice, then i can relax now
you need to expose it if you want to access it outside that scope...
understandable, have a good night
yea
finally
U saw the sign and words I wrote there?
was that u?
yes, that was me lol
i was AFK then when i get back i saw it

yes lol
I also said something in chat
I guess it didn't load?
I played around there for like 20 minutes then dip
Kodi, you might understand this
how would you connect two entity each other?
example
I have Entity A that is connected to Entity B I want Entity A to always follow Entity B via applyImpulse() or teleporting to it's direction however the issue is that if there are multiple Entity A and B it's hard to have a unique identifier on where to connect it
bro #off-topic
is it like how RLCraft Bedrock's Sand Worm mob?
i guess yes
like worms yeah
Entity A to Z depending on the length
or duplicates
following each other
a worm system
yeah
maybe not me can answer this, i haven't understand how this thing works
Bruh... but yes I do
use entitySpawn event listener, add a unique tag in it's DP
Are properties of Player.inputInfo easy to spoof ? should i not rely on it
how so?
I'd like to use it to make matching touch players with other touch players, KBM players with other KBM players etc. in duels more likely
but i presume its not the hardest of tasks for a hacked client to spoof this information
yea it could be spoofed but its very unlikely in theory lot of information could be just spoofed by a bots
yeah i guess you can spoof your input and device
only thing you can trust is that xuid is actual xuid of the account haha
say i do rely on inputInfo to know their input type. if i combine this with some basic heuristics (e.g. client replicates input that isn't meant to be possible on specific type), and server staff discretion would it even be close enough to being accurate for something like this or is it still likely to get cheated
idk if it's worth trying to implement it or if it'll just cause more hassle
just go for it
you wouldn't get anywhere trying to avoid spoofing
