Fixed external storage using an out of date block entity for getting handler
This commit is contained in:
@@ -10,6 +10,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
### Fixed
|
||||
|
||||
- Fixed external storage cache being de-synced from the network cache.
|
||||
- Fixed external storage using an out of date block entity for getting handler.
|
||||
|
||||
## [v1.11.2] - 2022-12-17
|
||||
|
||||
|
@@ -5,7 +5,9 @@ import com.refinedmods.refinedstorage.api.storage.externalstorage.IExternalStora
|
||||
import com.refinedmods.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
|
||||
import com.refinedmods.refinedstorage.blockentity.FluidInterfaceBlockEntity;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -21,11 +23,21 @@ public class FluidExternalStorageProvider implements IExternalStorageProvider<Fl
|
||||
@Override
|
||||
public IExternalStorage<FluidStack> provide(IExternalStorageContext context, BlockEntity blockEntity, Direction direction) {
|
||||
return new FluidExternalStorage(context, () -> {
|
||||
if (!blockEntity.getLevel().isLoaded(blockEntity.getBlockPos())) {
|
||||
Level level = blockEntity.getLevel();
|
||||
|
||||
if (level == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return LevelUtils.getFluidHandler(blockEntity, direction.getOpposite());
|
||||
BlockPos blockPos = blockEntity.getBlockPos();
|
||||
|
||||
if (!level.isLoaded(blockPos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockEntity currentBlockEntity = level.getBlockEntity(blockPos);
|
||||
|
||||
return LevelUtils.getFluidHandler(currentBlockEntity, direction.getOpposite());
|
||||
}, blockEntity instanceof FluidInterfaceBlockEntity);
|
||||
}
|
||||
|
||||
|
@@ -6,10 +6,12 @@ import com.refinedmods.refinedstorage.api.storage.externalstorage.IExternalStora
|
||||
import com.refinedmods.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
|
||||
import com.refinedmods.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
|
||||
import com.refinedmods.refinedstorage.blockentity.InterfaceBlockEntity;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -30,11 +32,21 @@ public class ItemExternalStorageProvider implements IExternalStorageProvider<Ite
|
||||
@Override
|
||||
public IExternalStorage<ItemStack> provide(IExternalStorageContext context, BlockEntity blockEntity, Direction direction) {
|
||||
return new ItemExternalStorage(context, () -> {
|
||||
if (!blockEntity.getLevel().isLoaded(blockEntity.getBlockPos())) {
|
||||
Level level = blockEntity.getLevel();
|
||||
|
||||
if (level == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return LevelUtils.getItemHandler(blockEntity, direction.getOpposite());
|
||||
BlockPos blockPos = blockEntity.getBlockPos();
|
||||
|
||||
if (!level.isLoaded(blockPos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockEntity currentBlockEntity = level.getBlockEntity(blockPos);
|
||||
|
||||
return LevelUtils.getItemHandler(currentBlockEntity, direction.getOpposite());
|
||||
}, blockEntity instanceof InterfaceBlockEntity);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user