Skip to content

Commit 880ec94

Browse files
authored
read GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT to limit clone command (#9305)
1 parent e1b7bd7 commit 880ec94

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/com/simibubi/create/infrastructure/command/CloneCommand.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import net.minecraft.network.chat.Component;
1818
import net.minecraft.server.level.ServerLevel;
1919
import net.minecraft.world.Clearable;
20+
import net.minecraft.world.level.GameRules;
2021
import net.minecraft.world.level.block.Blocks;
2122
import net.minecraft.world.level.block.entity.BlockEntity;
2223
import net.minecraft.world.level.block.state.BlockState;
@@ -63,12 +64,13 @@ private static int doClone(CommandSourceStack source, BlockPos begin, BlockPos e
6364
BlockPos destinationEnd = destination.offset(sourceArea.getLength());
6465
BoundingBox destinationArea = BoundingBox.fromCorners(destination, destinationEnd);
6566

66-
int i = sourceArea.getXSpan() * sourceArea.getYSpan() * sourceArea.getZSpan();
67-
if (i > 32768)
68-
throw CLONE_TOO_BIG_EXCEPTION.create(32768, i);
69-
7067
ServerLevel world = source.getLevel();
7168

69+
int i = sourceArea.getXSpan() * sourceArea.getYSpan() * sourceArea.getZSpan();
70+
int limit = world.getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT);
71+
if (i > limit)
72+
throw CLONE_TOO_BIG_EXCEPTION.create(limit, i);
73+
7274
if (!world.hasChunksAt(begin, end) || !world.hasChunksAt(destination, destinationEnd))
7375
throw BlockPosArgument.ERROR_NOT_LOADED.create();
7476

0 commit comments

Comments
 (0)