diff --git a/gradle.properties b/gradle.properties index d9c7c5fe..75c4bfa0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false mod_id=sophisticatedstorage mod_group_id=sophisticatedstorage -mod_version=0.10.35 +mod_version=0.10.36 sonar_project_key=sophisticatedstorage:SophisticatedStorage github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedStorage diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedstorage/upgrades/hopper/HopperUpgradeWrapper.java b/src/main/java/net/p3pp3rf1y/sophisticatedstorage/upgrades/hopper/HopperUpgradeWrapper.java index af15602e..09d9a0af 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedstorage/upgrades/hopper/HopperUpgradeWrapper.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedstorage/upgrades/hopper/HopperUpgradeWrapper.java @@ -214,11 +214,27 @@ private boolean moveItems(IItemHandler fromHandler, IItemHandler toHandler, Filt @Override public void onNeighborChange(Level level, BlockPos pos, Direction direction) { - if (pushDirections.contains(direction) || pullDirections.contains(direction)) { + if (!level.isClientSide() && (pushDirections.contains(direction) || pullDirections.contains(direction)) + && needsCacheUpdate(level, pos, direction)) { updateCacheOnSide(level, pos, direction); } } + private boolean needsCacheUpdate(Level level, BlockPos pos, Direction direction) { + List> handlers = handlerCache.get(direction); + if (handlers == null || handlers.isEmpty()) { + return !level.getBlockState(pos).isAir(); + } + + for (LazyOptional handler : handlers) { + if (!handler.isPresent()) { + return true; + } + } + + return false; + } + public void updateCacheOnSide(Level level, BlockPos pos, Direction direction) { if (!level.isLoaded(pos) || !level.isLoaded(pos.relative(direction))) { handlerCache.remove(direction);