From a4ebfe190d506d5490a440ba93064c195d900a6f Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Thu, 16 Dec 2021 02:42:09 +0100 Subject: [PATCH 1/2] Bump to 1.10.0-beta.3. --- CHANGELOG.md | 3 +++ build.gradle | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e753a2f7b..49e47da35 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [v1.10.0-beta.2] - 2021-12-16 + ### Fixed - Fixed all Refined Storage advancements being granted when joining a world. @@ -27,3 +29,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). diff --git a/build.gradle b/build.gradle index b67c4d55d..6c540f740 100755 --- a/build.gradle +++ b/build.gradle @@ -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) From a522edea083d57c14c3309af88018618ee3ed92c Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Fri, 17 Dec 2021 12:06:04 +0100 Subject: [PATCH 2/2] Fix networks and network devices being removed when a chunk unloads. Fixes #3178 --- CHANGELOG.md | 3 +++ .../blockentity/BaseBlockEntity.java | 24 +++++++++++++++++++ .../blockentity/ControllerBlockEntity.java | 8 +++---- .../blockentity/NetworkNodeBlockEntity.java | 4 ++-- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49e47da35..ddb1f9743 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ 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 diff --git a/src/main/java/com/refinedmods/refinedstorage/blockentity/BaseBlockEntity.java b/src/main/java/com/refinedmods/refinedstorage/blockentity/BaseBlockEntity.java index 325eac9df..3752ad65b 100644 --- a/src/main/java/com/refinedmods/refinedstorage/blockentity/BaseBlockEntity.java +++ b/src/main/java/com/refinedmods/refinedstorage/blockentity/BaseBlockEntity.java @@ -12,6 +12,8 @@ import net.minecraft.world.level.block.state.BlockState; 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); } @@ -48,6 +50,28 @@ public abstract class BaseBlockEntity extends BlockEntity { 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() { diff --git a/src/main/java/com/refinedmods/refinedstorage/blockentity/ControllerBlockEntity.java b/src/main/java/com/refinedmods/refinedstorage/blockentity/ControllerBlockEntity.java index 0d2c129b7..fbd0773f7 100644 --- a/src/main/java/com/refinedmods/refinedstorage/blockentity/ControllerBlockEntity.java +++ b/src/main/java/com/refinedmods/refinedstorage/blockentity/ControllerBlockEntity.java @@ -9,11 +9,11 @@ import com.refinedmods.refinedstorage.api.network.node.INetworkNodeProxy; 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; @@ -116,8 +116,8 @@ public class ControllerBlockEntity extends BaseBlockEntity implements INetworkNo } @Override - public void setRemoved() { - super.setRemoved(); + public void onRemovedNotDueToChunkUnload() { + super.onRemovedNotDueToChunkUnload(); if (!level.isClientSide) { INetworkManager manager = API.instance().getNetworkManager((ServerLevel) level); diff --git a/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkNodeBlockEntity.java b/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkNodeBlockEntity.java index f5b06bfb2..207c21a2c 100644 --- a/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkNodeBlockEntity.java +++ b/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkNodeBlockEntity.java @@ -82,8 +82,8 @@ public abstract class NetworkNodeBlockEntity extends Base } @Override - public void setRemoved() { - super.setRemoved(); + public void onRemovedNotDueToChunkUnload() { + super.onRemovedNotDueToChunkUnload(); if (!level.isClientSide) { INetworkNodeManager manager = API.instance().getNetworkNodeManager((ServerLevel) level);