Skip to content

Commit

Permalink
feat: Add config option to unlink wormhole when destroyed
Browse files Browse the repository at this point in the history
Closes #1023
  • Loading branch information
klikli-dev committed Jan 3, 2024
1 parent 69062a0 commit 895851d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.klikli_dev.occultism.Occultism;
import com.klikli_dev.occultism.common.blockentity.StableWormholeBlockEntity;
import com.klikli_dev.occultism.common.container.storage.StorageControllerContainerBase;
import com.klikli_dev.occultism.registry.OccultismTiles;
Expand Down Expand Up @@ -210,6 +211,14 @@ public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, Block
@Override
@SuppressWarnings("deprecation")
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
if(Occultism.SERVER_CONFIG.storage.unlinkWormholeOnBreak.get()){
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (blockEntity instanceof StableWormholeBlockEntity wormhole) {
if (wormhole.getLinkedStorageController() != null) {
wormhole.setLinkedStorageControllerPosition(null);
}
}
}
BlockEntityUtil.onBlockChangeDropWithNbt(this, state, worldIn, pos, newState);
super.onRemove(state, worldIn, pos, newState, isMoving);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ public static class StorageSettings {
public final ConfigValue<Integer> controllerBaseSlots;
public final ConfigValue<Integer> controllerStackSize;
public final BooleanValue overrideItemStackSizes;
public final BooleanValue unlinkWormholeOnBreak;

public StorageSettings(ForgeConfigSpec.Builder builder) {
builder.comment("Storage Settings").push("storage");
Expand Down Expand Up @@ -282,6 +283,12 @@ public StorageSettings(ForgeConfigSpec.Builder builder) {
"item type (such as 16 for ender pearls, 64 for iron ingot). WARNING: Setting this to " +
"false may have a negative impact on performance.")
.define("overrideItemStackSizes", true);
this.unlinkWormholeOnBreak =
builder.comment(
"True to use the configured controllerStackSize for all items, instead of the stack sizes provided by " +
"item type (such as 16 for ender pearls, 64 for iron ingot). WARNING: Setting this to " +
"false may have a negative impact on performance.")
.define("unlinkWormholeOnBreak", false);
builder.pop();
}
}
Expand Down

0 comments on commit 895851d

Please sign in to comment.