Fixed crashing the game when a network block was removed in a bad way. Fixes #3326
This commit is contained in:
@@ -14,6 +14,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
- Fixed Storage Monitor not showing all matching items in non-exact mode
|
||||
- Fixed items getting lost on Creative Disk when more than 2,147,483,647 of one type is stored
|
||||
- Fixed incorrect autocrafting keybind prompt on macOS
|
||||
- Fixed crashing the game when a network block was removed in a bad way
|
||||
|
||||
### Changed
|
||||
|
||||
|
@@ -6,10 +6,10 @@ import com.refinedmods.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.refinedmods.refinedstorage.api.util.Action;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||
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.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -18,6 +18,8 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -28,6 +30,8 @@ public abstract class NetworkNodeBlockEntity<N extends NetworkNode> extends Base
|
||||
private N clientNode;
|
||||
private N removedNode;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
protected NetworkNodeBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
|
||||
@@ -61,7 +65,10 @@ public abstract class NetworkNodeBlockEntity<N extends NetworkNode> extends Base
|
||||
INetworkNode node = manager.getNode(worldPosition);
|
||||
|
||||
if (node == null) {
|
||||
throw new IllegalStateException("No network node present at " + worldPosition.toString() + ", consider removing the block at this position");
|
||||
LOGGER.warn("Expected a node @ {} but couldn't find it, creating a new one...", worldPosition);
|
||||
node = createNode(level, worldPosition);
|
||||
manager.setNode(worldPosition, node);
|
||||
manager.markForSaving();
|
||||
}
|
||||
|
||||
return (N) node;
|
||||
|
Reference in New Issue
Block a user