#Can you use player.location as a coordinate?

1 messages · Page 1 of 1 (latest)

swift yacht
#

yes

vapid ore
#

you can, but for this case it would be better to just use StructureManager

wheat thunder
vapid ore
#

world.structureManager.place("structureId", world.getDimension("overworld"), player.location)

wheat thunder
#

But I don't know how to use structureManager... I looked in the documentation, but I didn't understand

vapid ore
wheat thunder
vapid ore
wheat thunder
#

For example
world.structureManager.save()

wheat thunder
vapid ore
#
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

swift yacht
vapid ore
#

so you want to save the area before tnt explodes and then place it back later to regenerate the area?

vapid ore
#

this might not be the best solution for that

#

it would have issues if multiple tnts go off in that area

swift yacht
#

yeah this will cause lags

vapid ore
#

lag isn;t the problem

#

it wouldn't be that bad for performance

wheat thunder
wheat thunder
swift yacht
#

it will load the same structure for the other place

wheat thunder
#

I would do everything by several commands in one function 😔

vapid ore
wheat thunder
wheat thunder
vapid ore
#

which one

wheat thunder
#

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

vapid ore
#

are you using 1.11.0 or 1.12.0-beta

wheat thunder
swift yacht
swift yacht
wheat thunder
#

A structure is placed in player location

#

And when the structure disappears, the area it destroyed must return to the way it was before

vapid ore
#

so the blocks don't explode, you're just making a fake explosion in its place?

wheat thunder
swift yacht
#

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

wheat thunder
vapid ore
#

oh it's not an explosion at all

wheat thunder
#

I want to save the area, so when this structure disappears, it goes back to how it was before

wheat thunder
swift yacht
#

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()

wheat thunder
#

It seems difficult, but it's not

#

Could you explain to me how structureManager works?

#

So I could try to do it, I guess

vapid ore
#
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

wheat thunder
#

WOOOOOW

vapid ore
#

this creates a backup and then places it back into the world after 3 seconds

wheat thunder
vapid ore
wheat thunder
swift yacht
#

you'll have problems if both players execute the skill at the same location consecutively

vapid ore
#

yeah, you'll need to handle that situation since I didn't write anything for that

wheat thunder
#

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