Skip to content

Commit 9e035a2

Browse files
committed
Merge remote-tracking branch 'origin/api-10' into api-11
2 parents 296f78f + 615f09e commit 9e035a2

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/main/java/org/spongepowered/common/event/tracking/PhaseTracker.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ public void popCauseFrame(final StackFrame oldFrame) {
664664
// Remove new values
665665
for (final Map.Entry<EventContextKey<?>, Object> entry : frame.getOriginalContextDelta().entrySet()) {
666666
this.cached_ctx = null;
667+
this.cached_cause = null;
667668
if (entry.getValue() == null) { // wasn't present before, remove
668669
this.ctx.remove(entry.getKey());
669670
} else { // was there, replace
@@ -710,6 +711,7 @@ public <T> CauseStackManager addContext(final EventContextKey<T> key, final T va
710711
Objects.requireNonNull(value, "value");
711712
this.enforceMainThread();
712713
this.cached_ctx = null;
714+
this.cached_cause = null;
713715
final @Nullable Object existing = this.ctx.put(key, value);
714716
if (!this.frames.isEmpty()) {
715717
this.frames.peek().storeOriginalContext(key, existing);
@@ -729,6 +731,7 @@ public <T> Optional<T> removeContext(final EventContextKey<T> key) {
729731
Objects.requireNonNull(key, "key");
730732
this.enforceMainThread();
731733
this.cached_ctx = null;
734+
this.cached_cause = null;
732735
final Object existing = this.ctx.remove(key);
733736
if (!this.frames.isEmpty()) {
734737
this.frames.peek().storeOriginalContext(key, existing);

src/main/java/org/spongepowered/common/world/storage/SpongeChunkLayout.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ public final class SpongeChunkLayout implements ChunkLayout {
3939
private final Vector3i spaceSize;
4040

4141
public SpongeChunkLayout(final int minY, final int height) {
42-
final var totalHeight = Math.abs(minY) + height;
43-
this.size = new Vector3i(16, totalHeight, 16);
42+
this.size = new Vector3i(16, height, 16);
4443
this.mask = this.size.sub(1, 1, 1);
45-
this.spaceMax = new Vector3i(Constants.World.BLOCK_MAX.x(), height, Constants.World.BLOCK_MAX.z()).sub(1, 1, 1);
44+
this.spaceMax = new Vector3i(Constants.World.BLOCK_MAX.x(), minY + height, Constants.World.BLOCK_MAX.z()).sub(1, 1, 1);
4645
this.spaceMin = new Vector3i(Constants.World.BLOCK_MIN.x(), minY, Constants.World.BLOCK_MIN.z());
4746
this.spaceSize = this.spaceMax.sub(this.spaceMin).add(1, 1, 1);
4847
}
@@ -88,17 +87,17 @@ public boolean isInChunk(final int x, final int y, final int z) {
8887

8988
@Override
9089
public boolean isInChunk(final int wx, final int wy, final int wz, final int cx, final int cy, final int cz) {
91-
return this.isInChunk(wx - (cx << 4), wy - (cy << 8), wz - (cz << 4));
90+
return this.isInChunk(wx - (cx << 4), wy - Math.floorDiv(cy - this.spaceMin.y(), this.size.y()), wz - (cz << 4));
9291
}
9392

9493
@Override
9594
public Vector3i forceToChunk(final int x, final int y, final int z) {
96-
return new Vector3i(x >> 4, y >> 8, z >> 4);
95+
return new Vector3i(x >> 4, Math.floorDiv(y - this.spaceMin.y(), this.size.y()), z >> 4);
9796
}
9897

9998
@Override
10099
public Vector3i forceToWorld(final int x, final int y, final int z) {
101-
return new Vector3i(x << 4, y << 8, z << 4);
100+
return new Vector3i(x << 4, (y * this.size.y()) + this.spaceMin.y(), z << 4);
102101
}
103102

104103
}

0 commit comments

Comments
 (0)