One Spatial Dimension (#4570)

* Ported the "one spatial dimension" concept from pre-1.15

* Apply lighting updates after moving chunks.
Mark world data as dirty when changing it.

* Consolidated naming of spatial storage world/dimension.
Use server light manager to update lighting info in chunk.

* Save last transition information,
and add ae2 spatial command to interact with spatial storage.

* Formatting fixes.

* Improved docs for the origin generation.

Inverted condition on when the x/z axis are flipped.
Also added a helper to map a plot to a region file

* Remove TransitionResult since it's only used in lieu of a boolean.
Rework transition to make the checks BEFORE allocating a new cell.

* Removed unused imports.

Co-authored-by: yueh <yueh@users.noreply.github.com>
This commit is contained in:
shartte
2020-08-10 11:29:07 +02:00
committed by GitHub
parent 8733c2c11f
commit d1ba26311b
36 changed files with 1073 additions and 610 deletions
@@ -0,0 +1,69 @@
package appeng.spatial;
import java.time.Instant;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
/**
* Defines the source world and area of a transition into the spatial storage
* plot.
*/
public final class TransitionInfo {
public static final String TAG_WORLD_ID = "world_id";
public static final String TAG_MIN = "min";
public static final String TAG_MAX = "max";
public static final String TAG_TIMESTAMP = "timestamp";
private final ResourceLocation worldId;
private final BlockPos min;
private final BlockPos max;
private final Instant timestamp;
public TransitionInfo(ResourceLocation worldId, BlockPos min, BlockPos max, Instant timestamp) {
this.worldId = worldId;
this.min = min.toImmutable();
this.max = max.toImmutable();
this.timestamp = timestamp;
}
public ResourceLocation getWorldId() {
return worldId;
}
public BlockPos getMin() {
return min;
}
public BlockPos getMax() {
return max;
}
public Instant getTimestamp() {
return timestamp;
}
public CompoundNBT toTag() {
CompoundNBT tag = new CompoundNBT();
tag.putString(TAG_WORLD_ID, worldId.toString());
tag.put(TAG_MIN, NBTUtil.writeBlockPos(min));
tag.put(TAG_MAX, NBTUtil.writeBlockPos(max));
tag.putLong(TAG_TIMESTAMP, timestamp.toEpochMilli());
return tag;
}
public static TransitionInfo fromTag(CompoundNBT tag) {
ResourceLocation worldId = new ResourceLocation(tag.getString(TAG_WORLD_ID));
BlockPos min = NBTUtil.readBlockPos(tag.getCompound(TAG_MIN));
BlockPos max = NBTUtil.readBlockPos(tag.getCompound(TAG_MAX));
Instant timestamp = Instant.ofEpochMilli(tag.getLong(TAG_TIMESTAMP));
return new TransitionInfo(worldId, min, max, timestamp);
}
}