Only create entities during a restore if they are contained by the region and the editsession's mask (#1800)

This commit is contained in:
Jordan 2022-06-15 12:37:20 +01:00 committed by GitHub
parent 5b2f8502fb
commit ea434163c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,6 +55,7 @@ public class SnapshotRestore {
//FAWE start - biome and entity restore //FAWE start - biome and entity restore
private final boolean restoreBiomes; private final boolean restoreBiomes;
private final boolean restoreEntities; private final boolean restoreEntities;
private final Region region;
//FAWE end //FAWE end
private ArrayList<BlockVector2> missingChunks; private ArrayList<BlockVector2> missingChunks;
private ArrayList<BlockVector2> errorChunks; private ArrayList<BlockVector2> errorChunks;
@ -92,6 +93,7 @@ public class SnapshotRestore {
this.editSession = editSession; this.editSession = editSession;
this.restoreBiomes = restoreBiomes; this.restoreBiomes = restoreBiomes;
this.restoreEntities = restoreEntities; this.restoreEntities = restoreEntities;
this.region = region;
if (region instanceof CuboidRegion) { if (region instanceof CuboidRegion) {
findNeededCuboidChunks(region); findNeededCuboidChunks(region);
@ -204,7 +206,11 @@ public class SnapshotRestore {
float yRot = rotation.getFloat(0); float yRot = rotation.getFloat(0);
float xRot = rotation.getFloat(1); float xRot = rotation.getFloat(1);
Location location = new Location(editSession.getWorld(), x, y, z, yRot, xRot); Location location = new Location(editSession.getWorld(), x, y, z, yRot, xRot);
editSession.createEntity(location, entity); BlockVector3 blockVector3 = BlockVector3.at(x, y, z);
if (region.contains(blockVector3) && (editSession.getMask() == null
|| editSession.getMask().test(blockVector3))) {
editSession.createEntity(location, entity);
}
} }
} catch (DataException e) { } catch (DataException e) {
// this is a workaround: just ignore for now // this is a workaround: just ignore for now