Skip to content

Commit

Permalink
fix: šŸ› Fixed storage IO blocks to properly unlink their location fromā€¦
Browse files Browse the repository at this point in the history
ā€¦ controller when broken
  • Loading branch information
P3pp3rF1y committed Sep 21, 2024
1 parent baec963 commit 2a5ffdb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ loader_version_range=[4,)
mod_id=sophisticatedstorage
mod_name=Sophisticated Storage
mod_license=GNU General Public License v3.0
mod_version=0.10.34
mod_version=0.10.35
mod_group_id=sophisticatedstorage
mod_authors=P3pp3rF1y, Ridanisaurus
mod_description=Fancy and functional storage containers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class StorageIOBlockEntity extends BlockEntity implements IControllerBoun
@Nullable
private BlockPos controllerPos = null;
private boolean isLinkedToController = false;
private boolean chunkBeingUnloaded = false;

@Nullable
private BlockCapabilityCache<IItemHandler, Direction> controllerItemHandlerCache;

Expand Down Expand Up @@ -179,4 +181,19 @@ public IItemHandler getExternalItemHandler(@Nullable Direction side) {
return WorldHelper.getBlockEntity(getLevel(), getControllerPos().get(), ControllerBlockEntity.class).map(c -> c.getExternalItemHandler(side)).orElse(null);
}
}

@Override
public void onChunkUnloaded() {
super.onChunkUnloaded();
chunkBeingUnloaded = true;
}

@Override
public void setRemoved() {
if (!chunkBeingUnloaded && level != null) {
unlinkFromController();
}

super.setRemoved();
}
}

0 comments on commit 2a5ffdb

Please sign in to comment.