making a system that will set a dynamic property for a specific entity;
after the player places a block, there's an entity that will spawn with the block, that entity will get a dynamic property number { 0 } but when the player places another block it will spawn another entity and it will get a dynamic property number { 1 };
so each time the player places a block it will set a dynamic property number to that entity, like theres 5 entities each one will have a different property number { 0, 1, 2, 3, 4 };
and when one of those entities died the property number of it will disappear;
for example, there are 6 entities and one of them despawned or has been killed, the number will go from { 0, 1, 2, 3, 4, 5 } to { 0, 1, 2, 3, 4 };
#Dynamic Properties;
1 messages · Page 1 of 1 (latest)
instead of setting numbers for every single entities, you can do
const array = [ "value1", "value2", "value3" ]
console.warn(`${array.length}`) // 3
how exactly?
what do you use to track the entities?
im using playerPlaceBlock component, that will spawn an entity with placing the block, and block.dimension.getEntities()
getEntities() returns an array
so this can be used simply
without using dynamic properties
you dont need to track for entities death or anything
just getEntities() and length check
whats the filter option did you use for getEntities
nothing, just getEntities()
getEntities().filter(arrawThing)?
no
im so stupid
you can do filter by types or tags
its in EntityQueryOptions
if you want to make it track per player, you can give the entities a tag with player's id
nah i dont have to
and then filter out the entities using EntityQueryOptions by tag w/ player id
then youd want typeId
getEntities().filter(EntityQueryOptions?) ?
bridge doesn't show me how to write it correctly

bookmark that website
also check that
first time enjoying while seeing a docs link
const options: EntityQueryOptions = {
"type" or "excludeTypes" ?
}
also for some reason bridge telling me it's wrong
"type" is for one specific entity type
im literally lost, especially with a random chest pain
What are you trying to do? Tracking how many specific entities are there?
kinda,
the script will spawn an entity after placing a specific block
that entity will get a dynamic property of 0
after placing another block and spawning another entity, the entity will get a dynamic property of 1
similar to this;
playerPlaceBlock.sub(({ block }) => {
block.dimension.spawnEntity('my:entity', block.center())
const entity = block.dimension.getEntities({ type: 'my:entity' }).?```but idk how to complete it
ive posted it before but
const entities = player.dimension.getEntities({
type: "namespace:typeId"
});
console.warn(`${entities.length}`);
playerPlaceBlock.sub(({ block }) => {
const entity = block.dimension.getEntities({ type: 'my:entity' })
if (entity.length < 50) block.dimension.spawnEntity('my:entity', block.center())
});```
that will count how many entities are in the world, but how about giving them properties? or tags?
you dont need em if you only need the amount of entities in the dimension
if you do want to give em tags or dp, give me a second
i had to give them a property or a tag for making the block system,
pushing the block using a piston will move up the block but not the entity, i can mske the entity pushable but it will be kicked out of the block, so i had to make a syetem that will always teleporting the entity inside the block matter how far is it
even teleporting the entity somehow outside the block will make it disappear without breaking the block, i had to make a system that will give the entity a property or a tag so the entity will be attached to the block,
do you need only one tag
no, if multiple entities has the same tag they will be teleported to the same block
now i get it
i mean if u place 2 of the same block, both of those entities will get the same tag and start glitching up
ill check something
so i have to make a syetem that will give a different tag or property for each entity, max entities 50.
the only problem is im new at tags or properties things, so im always lost
just making sure, is this custom component?
i cant find it in jayly docs
oh wait nvm it was because of a typo
ok so
i just found a way, and youd need dynamic property instead of tags
you can get the location of the block and then set that for the entity's dynamic property
since dynamic property accepts Vector3
but if the block has been pushed? is it will works the same
i think so
oh yeah thats an issue
entity.setDynamicProperty(block.location)?
nvm
giving a dynamic property of the block location for the entity,
entity.setDynamicProperty(${block.location}) will give the entity a dynamic property of the block location right?
@half shale does each entity do something different? Or do they have the same function other than the location?
they're all storage entities, like custom chests thing
u dont want to put ur stuff on one of them and they randomly disappear
maybe, MAYBE, you can get the id of the entity and apply that to the block's dynamic property
this will work perfectly
blocks have dynamic properties?
You can effectively store dynamic properties for blocks using world dynamic properties with a key derived from the block location ${dimension.id}_${x}_${y}_${z}
the only clear way to do it is by setting a dynamic property for the entity that will be different than other entities, by putting the block location as a property name
pistons are kinda an issue
unless you only make it to check for matching dp and nothing else
You just need to not allow the blocks to be pushed by pistons. Not sure if there's a way to do that with custom blocks
guys if i give the entity a dynamic property, i can teleport it into the block
const prop = entity.getDynamicProperty('ash')
if (prop) entity.teleport(block.center())
idfk
onTick
the entity will always be teleported inside the block
trying to teleport it outside the block will not be a thing,
pushing it with a piston will be completely fine
Oh wait. You can listen for when your block moves from a piston
Well once the block moves you won't actually know which dynamic property is associated anymore
lemme try to explain
const arrays = ["0", "1"] // the property name
placing the block will set that property name to the entity
to teleport the entity only
and some mechanics for the blocks later on
if property name 0 has been used, the script will put the second property name (1) to the second entity
and the onTick script will detect the entity by its property name and teleport it inside the block
wait a minute
i should do something really really really really smart, making the block unpushable
java barrel moment
but how tho
i think by canceling the piston using this method
but wait
canceling the piston will not be a thing bec u still can push it by placing blocks in front of the piston
It's an afterEvent so you can't cancel. But you can respond to it by adjusting the block location of the dynamic property.
one thing is that its an afterevent, so it can be hard to track the world dp before the event
making a system that will break the block while pushing it
that sounds stupid
or,
you can just overwrite the world dp
hmm
making the block pushable, but the entity will die after pushing the block

i know thats a bug, but what else should i do?
beforeOnPlayerPlace: e => {
e.permutationToPlace = e.permutationToPlace.withState('pog:playerPlaced', true);
},
took this from Poggy's leaves decay script
if (e.block.permutation.getState('pog:playerPlaced') === false) {
e.block.setType('air');
e.block.dimension.runCommand(`loot spawn ${loc.x} ${loc.y} ${loc.z} loot ${loottable}`);
}
what is it for?
that script? its for checking whether the player placed the block or not
and if it isnt, allow leaves decay
you can set the permutation on Block class by doing that on BlockPermutation class (permutationToPlace returns BlockPermutation)
and inside the onTick, you can do a check for block permutation state's value instead of DP or tags
i think that will not be useful for those entities,
isn't it?
hmm
for entities, you can use DP
get some rest first 
i think im getting that pain bec of the irritable bowel syndrome
it feels like it is
oof
dont worry, i will finish my addon even if i am dying, i am already dying tho
cya, I'll think about the script tomorrow
rest well
