Skip to content

Commit

Permalink
Replace neighbor updates on Spatial Anchor with client-side updates (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte authored Aug 24, 2024
1 parent 5af3298 commit 1383f58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/main/java/appeng/blockentity/AEBaseBlockEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,17 @@ protected void saveVisualState(CompoundTag data) {
protected void loadVisualState(CompoundTag data) {
}

/**
* Mark this block to be updated for clients.
*/
public void markForClientUpdate() {
this.requestModelDataUpdate();

if (this.level != null && !this.isRemoved() && !notLoaded()) {
this.level.sendBlockUpdated(this.worldPosition, getBlockState(), getBlockState(), Block.UPDATE_CLIENTS);
}
}

public void markForUpdate() {
// Clearing the cached model-data is always harmless regardless of status
this.requestModelDataUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,27 +338,23 @@ private boolean force(ChunkPos chunkPos) {
ServerLevel level = this.getServerLevel();
boolean forced = ChunkLoadingService.getInstance().forceChunk(level, this.getBlockPos(), chunkPos);

if (forced) {
this.chunks.add(chunkPos);
if (forced && this.chunks.add(chunkPos)) {
this.updatePowerConsumption();
markForClientUpdate();
}

this.updatePowerConsumption();
this.markForUpdate();

return forced;
}

private boolean release(ChunkPos chunkPos, boolean remove) {
ServerLevel level = this.getServerLevel();
boolean removed = ChunkLoadingService.getInstance().releaseChunk(level, this.getBlockPos(), chunkPos);

if (removed && remove) {
this.chunks.remove(chunkPos);
if (removed && remove && this.chunks.remove(chunkPos)) {
this.updatePowerConsumption();
markForClientUpdate();
}

this.updatePowerConsumption();
this.markForUpdate();

return removed;
}

Expand Down

0 comments on commit 1383f58

Please sign in to comment.