#Can you use player.location as a coordinate?
1 messages · Page 1 of 1 (latest)
you can, but for this case it would be better to just use StructureManager
I wanted to copy an area before it was deleted and then replace it
world.structureManager.place("structureId", world.getDimension("overworld"), player.location)
But I don't know how to use structureManager... I looked in the documentation, but I didn't understand
player.dimension
yeah, that's better, slipped my mind
Is there a way to copy an area using this?
createFromWorld is how you'd save a structure
For example
world.structureManager.save()
Could you give me an example of how to copy an area/radius?
const newStructure = world.structureManager.createFromWorld("newStructure", player.dimension, {x: 0, y: 0, z: 0}, {x: 32, y: 32, z: 32});
world.structureManager.place(newStructure, player.dimension, player.location)
that would save an area from 0 0 0 to 32 32 32 and then place it again at the player's location
where are you using it for exactly? before tnt explode or something?
Yea
so you want to save the area before tnt explodes and then place it back later to regenerate the area?
Yeeees
this might not be the best solution for that
it would have issues if multiple tnts go off in that area
yeah this will cause lags
It's not a problem, because I did something to hide this lag
How could I do this in an easier way?
it will load the same structure for the other place
I would do everything by several commands in one function 😔
are you using stable APIs or beta APIs?
Load the structure in the same place
Yea
which one
I'll summarize... Where the player destroys the structure, a mob is spawned that takes the player's name
This mob will save the structure around it and after a while, rebuild
are you using 1.11.0 or 1.12.0-beta
1.12.0-beta
i think iterate each block that is affected inside ExplosionBeforeEvent, with
getImpactedBlocks()
Blocks do not explode
oh
A structure is placed in player location
And when the structure disappears, the area it destroyed must return to the way it was before
so the blocks don't explode, you're just making a fake explosion in its place?
I'll show you, just a minute
oh so you want to spawn a structure without losing the previous environment? then retrive back the environment right after the player breaks a block
or im getting it wrong
@swift yacht @vapid ore
oh it's not an explosion at all
This structure will break surrounding blocks within a 28 block radius
I want to save the area, so when this structure disappears, it goes back to how it was before
This structure weighs 42kb
skill activate -> save structure for whatever the size of that is, offset it rightly -> wait for structure despawn/remove -> reload the original environment
basically thats it, just experiment the offsets on structureManager.createFromWorld()
Yea
It seems difficult, but it's not
Could you explain to me how structureManager works?
So I could try to do it, I guess
const { x, y, z } = player.location;
// get the minimum and maximum coordinates of the affected area
const areaMin = { x: x - 28, y: y - 28, z: z - 28 };
const areaMax = { x: x + 28, y: y + 28, z: z + 28 };
// create a backup of the affected area
const areaBackup = world.structureManager.createFromWorld(`areaBackup:${player.name}`, player.dimension, areaMin, areaMax, { includeEntities: false });
system.runTimeout(() => {
// place the backup back into the world to restore the area
world.structureManager.place(areaBackup, player.dimension, areaMin);
// delete the structure so it's no longer taking up space in the world
world.structureManager.delete(areaBackup);
}, 60);
something like that should work
WOOOOOW
this creates a backup and then places it back into the world after 3 seconds
Bro, I don't even know how to thank you for this
details on the structureManager can be found here
https://jaylydev.github.io/scriptapi-docs/1.21.0/classes/_minecraft_server_1_11_0.StructureManager.html
Very thanks
you'll have problems if both players execute the skill at the same location consecutively
yeah, you'll need to handle that situation since I didn't write anything for that
I already solved this
The entity that is in the middle of the structure creates an area property... It is only possible to create another structure outside this area