Skip to content

Commit

Permalink
fix: šŸ› Fixed breaking double chest with tickable upgrade to not spillā€¦
Browse files Browse the repository at this point in the history
ā€¦ items from the right side
  • Loading branch information
P3pp3rF1y committed Sep 20, 2024
1 parent f816a71 commit 6000b7a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.daemon=false

mod_id=sophisticatedstorage
mod_group_id=sophisticatedstorage
mod_version=0.10.29
mod_version=0.10.30
sonar_project_key=sophisticatedstorage:SophisticatedStorage
github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedStorage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public BlockState updateShape(BlockState state, Direction facing, BlockState fac
}
} else if (getConnectedDirection(state) == facing) {
level.getBlockEntity(currentPos, ModBlocks.CHEST_BLOCK_ENTITY_TYPE.get()).ifPresent(be -> {
if (!level.isClientSide() && !be.isBeingUpgraded()) {
if (!level.isClientSide() && !be.isBeingUpgraded() && !be.isPacked()) {
if (be.isMainChest() && state.getBlock() instanceof ChestBlock chestBlock) {
be.dropSecondPartContents(chestBlock, facingPos);
} else if (!be.isMainChest()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public ItemStack getWrappedStorageStack() {

@Override
protected void onUpgradeRefresh() {
if (!isDroppingContents && level != null && !level.isClientSide && getBlockState().getBlock() instanceof IStorageBlock storageBlock) {
if (canRefreshUpgrades() && getBlockState().getBlock() instanceof IStorageBlock storageBlock) {
storageBlock.setTicking(level, getBlockPos(), getBlockState(), !storageWrapper.getUpgradeHandler().getWrappersThatImplement(ITickableUpgrade.class).isEmpty());
}
}
Expand Down Expand Up @@ -158,6 +158,10 @@ public ITrackedContentsItemHandler getInventoryForInputOutput() {
storageWrapper.setUpgradeCachesInvalidatedHandler(this::onUpgradeCachesInvalidated);
}

protected boolean canRefreshUpgrades() {
return !isDroppingContents && level != null && !level.isClientSide;
}

@SuppressWarnings("java:S1172") //parameter used in override
protected ItemStack addWrappedStorageStackData(ItemStack cloneItemStack, BlockState state) {
return cloneItemStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,14 @@ protected void packStorage(Player player, InteractionHand hand, WoodStorageBlock
player.setItemInHand(hand, ItemStack.EMPTY);
}
}
b.setPacked(true);

BlockState blockState = b.getBlockState();
if (blockState.getBlock() instanceof StorageBlockBase storageBlock && blockState.getValue(StorageBlockBase.TICKING)) {
storageBlock.setTicking(player.level(), b.getBlockPos(), blockState, false);
}

b.setPacked(true);

b.removeFromController();

WorldHelper.notifyBlockUpdate(b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,9 @@ public boolean canBeConnected() {
public boolean canBeLinked() {
return !packed;
}

@Override
protected boolean canRefreshUpgrades() {
return super.canRefreshUpgrades() && !packed;
}
}

0 comments on commit 6000b7a

Please sign in to comment.