Skip to content

Commit c6c98da

Browse files
PrunoideaeIThundxr
andauthored
Add config option to prevent block dropping when contraption is replacing blocks (#8456)
Co-authored-by: IThundxr <me@ithundxr.dev>
1 parent a73ce94 commit c6c98da

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/main/java/com/simibubi/create/content/contraptions/Contraption.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,8 @@ public void addBlocksToWorld(Level world, StructureTransform transform) {
11461146
return;
11471147
disassembled = true;
11481148

1149+
boolean shouldDropBlocks = !AllConfigs.server().kinetics.noDropWhenContraptionReplaceBlocks.get();
1150+
11491151
translateMultiblockControllers(transform);
11501152

11511153
for (boolean nonBrittles : Iterate.trueAndFalse) {
@@ -1172,7 +1174,9 @@ public void addBlocksToWorld(Level world, StructureTransform transform) {
11721174
if (targetPos.getY() == world.getMinBuildHeight())
11731175
targetPos = targetPos.above();
11741176
world.levelEvent(2001, targetPos, Block.getId(state));
1175-
Block.dropResources(state, world, targetPos, null);
1177+
if (shouldDropBlocks) {
1178+
Block.dropResources(state, world, targetPos, null);
1179+
}
11761180
continue;
11771181
}
11781182
if (state.getBlock() instanceof SimpleWaterloggedBlock
@@ -1181,7 +1185,7 @@ public void addBlocksToWorld(Level world, StructureTransform transform) {
11811185
state = state.setValue(BlockStateProperties.WATERLOGGED, FluidState.getType() == Fluids.WATER);
11821186
}
11831187

1184-
world.destroyBlock(targetPos, true);
1188+
world.destroyBlock(targetPos, shouldDropBlocks);
11851189

11861190
if (AllBlocks.SHAFT.has(state))
11871191
state = ShaftBlock.pickCorrectShaftType(state, world, targetPos);
@@ -1200,7 +1204,7 @@ public void addBlocksToWorld(Level world, StructureTransform transform) {
12001204
if (verticalRotation) {
12011205
if (state.getBlock() instanceof RopeBlock || state.getBlock() instanceof MagnetBlock
12021206
|| state.getBlock() instanceof DoorBlock)
1203-
world.destroyBlock(targetPos, true);
1207+
world.destroyBlock(targetPos, shouldDropBlocks);
12041208
}
12051209

12061210
BlockEntity blockEntity = world.getBlockEntity(targetPos);

src/main/java/com/simibubi/create/infrastructure/config/CKinetics.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class CKinetics extends ConfigBase {
5252
b(false, "minecartContraptionInContainers", Comments.minecartContraptionInContainers);
5353
public final ConfigBool stabiliseStableContraptions = b(false, "stabiliseStableContraptions", Comments.stabiliseStableContraptions, "[Technical]");
5454
public final ConfigBool syncPlayerPickupHitboxWithContraptionHitbox = b(false, "syncPlayerPickupHitboxWithContraptionHitbox", Comments.syncPlayerPickupHitboxWithContraptionHitbox, "[Technical]");
55+
public final ConfigBool noDropWhenContraptionReplaceBlocks = b(false, "noDropWhenContraptionReplaceBlocks", Comments.noDropWhenContraptionReplaceBlocks);
5556

5657
public final ConfigGroup stats = group(1, "stats", Comments.stats);
5758
public final ConfigFloat mediumSpeed = f(30, 0, 4096, "mediumSpeed", Comments.rpm, Comments.mediumSpeed);
@@ -122,6 +123,8 @@ private static class Comments {
122123
static String minecartContraptionInContainers = "Whether minecart contraptions can be placed into container items.";
123124
static String stabiliseStableContraptions = "Whether stabilised bearings create a separated entity even on non-rotating contraptions.";
124125
static String syncPlayerPickupHitboxWithContraptionHitbox = "Whether the players hitbox should be expanded to the size of the contraption hitbox.";
126+
static String noDropWhenContraptionReplaceBlocks = "Whether to prevent block dropping when contraption is placed inside in-world blocks.";
127+
125128
}
126129

127130
public enum DeployerAggroSetting {

0 commit comments

Comments
 (0)