Skip to content

Commit

Permalink
Merge pull request #3179 from refinedmods/develop
Browse files Browse the repository at this point in the history
v1.10.0-beta.3
  • Loading branch information
raoulvdberge authored Dec 17, 2021
2 parents c77ca19 + a522ede commit 01a8254
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed
- Fixed networks and network devices being removed when a chunk unloads.

## [v1.10.0-beta.2] - 2021-12-16

### Fixed

- Fixed all Refined Storage advancements being granted when joining a world.
Expand All @@ -27,3 +32,4 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Combined fluid and item view in the Pattern Grid.
- Ported to Minecraft 1.18.1.
- Focused side buttons now display their tooltip properly.
- Improved performance of retrieving patterns by [@metalshark](https://github.com/metalshark).
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ apply plugin: 'maven-publish'

group = 'com.refinedmods'
archivesBaseName = 'refinedstorage'
version = '1.10.0-beta.2'
version = '1.10.0-beta.3'

if (System.getenv('GITHUB_SHA') != null) {
version += '+' + System.getenv('GITHUB_SHA').substring(0, 7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
public abstract class BaseBlockEntity extends BlockEntity {
protected final BlockEntitySynchronizationManager dataManager = new BlockEntitySynchronizationManager(this);

private boolean unloaded;

public BaseBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
}
Expand Down Expand Up @@ -48,6 +50,28 @@ public void handleUpdateTag(CompoundTag tag) {
readUpdate(tag);
}

@Override
public void setRemoved() {
super.setRemoved();
// @Volatile: MC calls setRemoved when a chunk unloads now as well (see ServerLevel#unload -> LevelChunk#clearAllBlockEntities).
// Since we don't want to remove network node data in that case, we need to know if it was removed due to unloading.
// We can use "unloaded" for that, it's set in #onChunkUnloaded.
// Since MC first calls #onChunkUnloaded and then #setRemoved, this check keeps working.
if (!unloaded) {
onRemovedNotDueToChunkUnload();
}
}

protected void onRemovedNotDueToChunkUnload() {
// NO OP
}

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

// @Volatile: Copied with some changes from the super method (avoid sending neighbor updates, it's not needed)
@Override
public void setChanged() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.apiimpl.network.Network;
import com.refinedmods.refinedstorage.apiimpl.network.node.RootNetworkNode;
import com.refinedmods.refinedstorage.capability.NetworkNodeProxyCapability;
import com.refinedmods.refinedstorage.blockentity.config.IRedstoneConfigurable;
import com.refinedmods.refinedstorage.blockentity.config.RedstoneMode;
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
import com.refinedmods.refinedstorage.capability.NetworkNodeProxyCapability;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.syncher.EntityDataSerializers;
Expand Down Expand Up @@ -116,8 +116,8 @@ public void clearRemoved() {
}

@Override
public void setRemoved() {
super.setRemoved();
public void onRemovedNotDueToChunkUnload() {
super.onRemovedNotDueToChunkUnload();

if (!level.isClientSide) {
INetworkManager manager = API.instance().getNetworkManager((ServerLevel) level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public void clearRemoved() {
}

@Override
public void setRemoved() {
super.setRemoved();
public void onRemovedNotDueToChunkUnload() {
super.onRemovedNotDueToChunkUnload();

if (!level.isClientSide) {
INetworkNodeManager manager = API.instance().getNetworkNodeManager((ServerLevel) level);
Expand Down

0 comments on commit 01a8254

Please sign in to comment.