XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

MyDimension

【Java】我的维度模组

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/MyDimension

批量建造/拆除仅播放一次音效,新增复制选区

为筑境权杖批量操作增加“每次仅播放一个代表方块音效”特性,避免重复叠加。实现 OperationSoundKind 枚举及音效选择方法,并补充单元测试。蓝图轮盘新增“复制选区”操作,支持本地快速恢复与超时自动请求,完善图标、本地化及 UI 渲染。README.md 已同步更新,相关控制器与测试覆盖新行为。

6531305
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

11 个文件 +231 -15
Modified README.md +2 -2
@@ -97,10 +97,10 @@ F F F F F
97 97
98 98 - 建造按“绑定锚点 → 主背包 → 快捷栏 → 副手”取材;材料不足的位置保留黄色虚影,右键聚焦任一虚影继续补齐。准星射线进入黄色方格或蓝色选区/部署框的边线与内部体积都会取得唯一焦点并加粗;相连缺料格按 26 邻接视为一组并整体加粗,焦点粗框宽度以约 160 毫秒平滑过渡到普通框的四倍。部署框优先,其余对象按入射距离选择最近者;左键只取消当前焦点,取消部署不会清除源选区。普通建造预览仅显示绿色框,不渲染具体方块;黄色缺料与蓝图投影使用更实的半透明模型,并通过轻微内缩避免相邻投影面共面闪烁。大型预览按 16³ 分区缓存实体 QUADS 线框和投影模型,六面蓝紫裂罅波纹只用于黄色缺料投影;预览距离至少 160 格并随客户端渲染距离提高到最多 512 格,128 格外自动保留完整框架与缺料波纹 LOD,避免近中距离缺块及大型蓝图瞬时烘焙卡顿。
99 99 - 手动铺层/拆层在一次交互中立即执行本次设定上限,不再拆成跨 tick 的施工队列。作业页提供每把权杖独立的“历史记录”开关,默认关闭;关闭时不会创建撤销事务、方块实体前后镜像或物资账,从而避开批量施工最重的序列化开销,此时新操作不可撤销/重做。开启后才保留完整事务语义。入口仍会合并拒绝同一时刻的重复快速点击,避免重复射线、BFS 与供材扫描;蓝图自动施工继续使用自身的队列与建造上限。
100 - 拆除只有在副手工具类型和等级均合格时才保留正常掉落;每个成功拆除的方块消耗一次工具耐久,不生成经验。副手为空或工具类型不匹配时直接无粒子删除,不走原版 `2001` 破坏特效,也不创建掉落列表。
100 - 拆除只有在副手工具类型和等级均合格时才保留正常掉落;每个成功拆除的方块消耗一次工具耐久,不生成经验。副手为空或工具类型不匹配时直接无粒子删除,不走原版 `2001` 破坏特效,也不创建掉落列表。每次批量操作只播放一个代表方块音效:建造使用该方块的放置音效,拆除使用拆前方块的破坏音效。
101 101 - 共鸣供材锚潜行贴附在容器面上使用。它优先访问目标面的 Forge 物品 Capability,并兼容 `WorldlyContainer`、普通 `Container` 和可配置的无侧面 Capability 回退;普通非容器表面会拒绝放置且不扣物品,容器消失或第三方旁路产生非法锚时会正常掉落并保留 UUID/ACL。跨区块重验使用目标区块反向索引唤醒,不扫描方块、不强制加载区块也不常驻 tick。锚点默认私有,可设置公开或白名单。主手持权杖时,只为当前这把权杖有序绑定、且位于当前维度的供材锚绘制紫色方框;客户端用权杖绑定 UUID 与服务端轻量索引快照求交,不扫描附近区块。换物品、换权杖、解绑、换维度或退出世界都会立即清理或重算缓存。
102 102 - 蓝图保存在客户端全局目录 `<游戏目录>/mydimension/blueprints/`,文件扩展名为 `.mindbp`,可跨存档和服务器导入、导出。自动施工每 tick 使用权杖当前“建造上限”作为处理预算;已加载目标跨区块合并成一次供材扫描与历史提交,未加载目标按区块稳定分组并临时租赁,避免以旧的 64 格节流或在区块间逐行往返。服务器会重新验证尺寸、权限、材料、目标方块及完整方块实体 NBT。
103 - 按住 `Alt` 会立即显示裂罅风格的暗紫径向轮盘;九项操作全部使用独立图标(翻转轴、旋转、偏移、重置和保存),选中扇区使用青紫辉光,中央只放大当前图标,不显示动作文本。松开后按原状态机关闭或确认调整。完整源选区存在时始终保留保存图标;服务端选区不再按空闲时间过期,只在重新框选、明确取消、换权杖/维度、退出或停服时清理。保存弹窗将方块状态策略独占第一行、保存与取消并排放在第二行;保存后在同一弹窗等待服务端捕获并直接写入本地蓝图库,不再跳转到第二个保存界面。
103 - 按住 `Alt` 会立即显示裂罅风格的暗紫径向轮盘;十项操作全部使用独立图标(翻转轴、旋转、偏移、重置、复制选区和保存),选中扇区使用青紫辉光,中央只放大当前图标,并在轮盘外显示当前动作提示。松开后按原状态机关闭或确认调整。完整源选区存在时始终保留复制与保存图标;取消移动中的复制预览后,可直接用“复制选区”从保留的蓝色源选区重新生成预览。服务端选区不再按空闲时间过期,只在重新框选、明确取消、换权杖/维度、退出或停服时清理。保存弹窗将方块状态策略独占第一行、保存与取消并排放在第二行;保存后在同一弹窗等待服务端捕获并直接写入本地蓝图库,不再跳转到第二个保存界面。
104 104 - 服务端配置位于 `[builder]`;`enabled=false` 会停用配方、创造栏入口、增距、施工、绑定、远程容器访问和临时区块加载,但不会删除物品、NBT、历史或客户端蓝图库。
105 105 - 权杖与供材锚均使用裂罅风格的原生 3D 模型。权杖采用黑灰虚空石、紫蓝裂晶、扭曲杖身和断裂晶簇,不再使用黄铜、齿轮或扳手机械造型;物品栏以约 45° 斜向展示,第一人称模型缩小并右移以保留视野。模式切换只替换悬浮核心的青蓝/紫蓝反向漩涡动画,本体几何和材质不会整体刷新。供材锚的物品视图为 3D 侧视图,世界模型使用非遮挡几何,避免内缩模型裁掉相邻方块表面。
106 106
Modified src/main/java/com/xfestudio/mydimension/builder/BuilderGameTests.java +71 -0
@@ -11,11 +11,15 @@ import com.xfestudio.mydimension.builder.blueprint.BlueprintSaveMode;
11 11 import com.xfestudio.mydimension.builder.blueprint.BlueprintTransform;
12 12 import com.xfestudio.mydimension.builder.history.BuilderTransaction;
13 13 import com.xfestudio.mydimension.builder.history.WorldDelta;
14 import com.xfestudio.mydimension.registry.ModItems;
14 15 import net.minecraft.core.BlockPos;
15 16 import net.minecraft.core.Direction;
16 17 import net.minecraft.gametest.framework.GameTest;
17 18 import net.minecraft.gametest.framework.GameTestHelper;
18 19 import net.minecraft.server.level.ServerPlayer;
20 import net.minecraft.sounds.SoundEvent;
21 import net.minecraft.sounds.SoundSource;
22 import net.minecraft.world.InteractionHand;
19 23 import net.minecraft.world.level.block.Blocks;
20 24 import net.minecraft.world.Container;
21 25 import net.minecraft.world.entity.item.ItemEntity;
@@ -28,13 +32,19 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
28 32 import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
29 33 import net.minecraft.world.level.material.Fluids;
30 34 import net.minecraft.world.phys.AABB;
35 import net.minecraft.world.phys.BlockHitResult;
36 import net.minecraft.world.phys.Vec3;
31 37 import net.minecraftforge.common.MinecraftForge;
38 import net.minecraftforge.common.util.FakePlayerFactory;
39 import net.minecraftforge.event.PlayLevelSoundEvent;
32 40 import net.minecraftforge.event.level.BlockEvent;
33 41 import net.minecraftforge.eventbus.api.EventPriority;
34 42 import net.minecraftforge.gametest.GameTestHolder;
35 43 import net.minecraftforge.gametest.PrefixGameTestTemplate;
36 44
45 import java.util.ArrayList;
37 46 import java.util.List;
47 import java.util.Set;
38 48 import java.util.UUID;
39 49 import java.util.concurrent.atomic.AtomicBoolean;
40 50 import java.util.function.Consumer;
@@ -395,6 +405,67 @@ public final class BuilderGameTests {
395 405 helper.succeed();
396 406 }
397 407
408 @GameTest(template = "empty")
409 public static void surfaceBatchesUseOneModeSpecificBlockSound(GameTestHelper helper) {
410 BlockPos firstBase = helper.absolutePos(new BlockPos(1, 1, 1));
411 BlockPos secondBase = firstBase.east();
412 BlockPos firstTarget = firstBase.above();
413 BlockPos secondTarget = secondBase.above();
414 helper.getLevel().setBlock(firstBase, Blocks.STONE.defaultBlockState(), Block.UPDATE_ALL);
415 helper.getLevel().setBlock(secondBase, Blocks.STONE.defaultBlockState(), Block.UPDATE_ALL);
416
417 ServerPlayer player = FakePlayerFactory.get(helper.getLevel(),
418 new GameProfile(UUID.randomUUID(), "builder-sound-test-player"));
419 ItemStack scepter = new ItemStack(ModItems.REALMWRIGHT_SCEPTER.get());
420 player.setItemInHand(InteractionHand.MAIN_HAND, scepter);
421 RealmwrightData.setBuildLimit(scepter, 2, BuilderRuntime.settings().maxBuildLimit());
422 RealmwrightData.setDemolishLimit(scepter, 2, BuilderRuntime.settings().maxDemolishLimit());
423
424 Set<BlockPos> soundPositions = Set.of(firstTarget, secondTarget);
425 List<SoundEvent> sounds = new ArrayList<>();
426 Consumer<PlayLevelSoundEvent.AtPosition> listener = event -> {
427 if (event.getLevel() == helper.getLevel()
428 && event.getSource() == SoundSource.BLOCKS
429 && soundPositions.contains(BlockPos.containing(event.getPosition()))) {
430 sounds.add(event.getSound().value());
431 }
432 };
433
434 try {
435 MinecraftForge.EVENT_BUS.addListener(EventPriority.NORMAL, false,
436 PlayLevelSoundEvent.AtPosition.class, listener);
437
438 player.setItemInHand(InteractionHand.OFF_HAND, new ItemStack(Items.STONE, 2));
439 BlockHitResult buildHit = new BlockHitResult(Vec3.atCenterOf(firstBase).add(0.0D, 0.5D, 0.0D),
440 Direction.UP, firstBase, false);
441 BuilderOperationManager.Result build = BuilderOperationManager.executeValidatedSurface(
442 player, scepter, buildHit);
443 helper.assertTrue(build.changed() == 2,
444 "Two-block build changed " + build.changed() + " blocks instead of two");
445 helper.assertTrue(sounds.equals(List.of(Blocks.STONE.defaultBlockState().getSoundType(
446 helper.getLevel(), firstTarget, player).getPlaceSound())),
447 "Two-block build did not emit exactly one stone placement sound: " + sounds);
448
449 sounds.clear();
450 RealmwrightData.setMode(scepter, BuilderMode.DEMOLISH);
451 player.setItemInHand(InteractionHand.OFF_HAND, new ItemStack(Items.DIAMOND_PICKAXE));
452 BlockHitResult demolishHit = new BlockHitResult(Vec3.atCenterOf(firstTarget).add(0.0D, 0.5D, 0.0D),
453 Direction.UP, firstTarget, false);
454 BuilderOperationManager.Result demolish = BuilderOperationManager.executeValidatedSurface(
455 player, scepter, demolishHit);
456 helper.assertTrue(demolish.changed() == 2,
457 "Two-block demolition changed " + demolish.changed() + " blocks instead of two");
458 helper.assertTrue(sounds.equals(List.of(Blocks.STONE.defaultBlockState().getSoundType(
459 helper.getLevel(), firstTarget, player).getBreakSound())),
460 "Two-block demolition did not emit exactly one stone break sound: " + sounds);
461 helper.succeed();
462 } catch (RuntimeException exception) {
463 helper.fail(exception.getMessage());
464 } finally {
465 MinecraftForge.EVENT_BUS.unregister(listener);
466 }
467 }
468
398 469 private record TestPlacement(BlockPos pos, BlockState state) {
399 470 }
400 471 }
Modified src/main/java/com/xfestudio/mydimension/builder/BuilderOperationManager.java +24 -6
@@ -269,7 +269,8 @@ public final class BuilderOperationManager {
269 269 Map<BlockPos, net.minecraft.nbt.CompoundTag> blockEntityTags,
270 270 boolean captureHistory) {
271 271 ServerLevel level = player.serverLevel();
272 Execution result = new Execution(player.getOffhandItem().copy(), captureHistory);
272 Execution result = new Execution(player.getOffhandItem().copy(), captureHistory,
273 OperationSoundKind.PLACE);
273 274 List<BuildAttempt> attempts = new ArrayList<>();
274 275 ItemStack placementSource = player.getOffhandItem().copy();
275 276 boolean free = isFree(player);
@@ -706,7 +707,8 @@ public final class BuilderOperationManager {
706 707 List<SurfacePlanner.Candidate> candidates, UUID transactionId,
707 708 boolean captureHistory) {
708 709 ServerLevel level = player.serverLevel();
709 Execution result = new Execution(player.getOffhandItem().copy(), captureHistory);
710 Execution result = new Execution(player.getOffhandItem().copy(), captureHistory,
711 OperationSoundKind.BREAK);
710 712 List<PositionedDrop> deferredDrops = captureHistory ? List.of() : new ArrayList<>();
711 713 try {
712 714 for (SurfacePlanner.Candidate candidate : candidates) {
@@ -1359,7 +1361,9 @@ public final class BuilderOperationManager {
1359 1361 try {
1360 1362 var soundType = operationSound.state.getSoundType(
1361 1363 player.serverLevel(), operationSound.pos, player);
1362 player.serverLevel().playSound(null, operationSound.pos, soundType.getBreakSound(),
1364 player.serverLevel().playSound(null, operationSound.pos,
1365 selectOperationSound(soundType.getPlaceSound(), soundType.getBreakSound(),
1366 operationSound.kind),
1363 1367 SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) * 0.5F,
1364 1368 soundType.getPitch() * 0.8F);
1365 1369 } catch (Throwable throwable) {
@@ -1368,6 +1372,13 @@ public final class BuilderOperationManager {
1368 1372 }
1369 1373 }
1370 1374
1375 static <T> T selectOperationSound(T placeSound, T breakSound, OperationSoundKind kind) {
1376 return switch (kind) {
1377 case PLACE -> placeSound;
1378 case BREAK -> breakSound;
1379 };
1380 }
1381
1371 1382 public record Result(int changed, int missing, int blocked, boolean truncated, String rejectionKey,
1372 1383 boolean shouldSynchronize) {
1373 1384 public static Result disabled() { return rejected("message.mydimension.builder.disabled"); }
@@ -1387,18 +1398,20 @@ public final class BuilderOperationManager {
1387 1398 new java.util.LinkedHashSet<>();
1388 1399 private final ItemStack offhandBefore;
1389 1400 private final boolean captureHistory;
1401 private final OperationSoundKind soundKind;
1390 1402 private ItemStack offhandAfter = ItemStack.EMPTY;
1391 1403 private int changedCount;
1392 1404 private int blocked;
1393 1405 @javax.annotation.Nullable private OperationSound sound;
1394 1406
1395 private Execution(ItemStack offhandBefore, boolean captureHistory) {
1407 private Execution(ItemStack offhandBefore, boolean captureHistory, OperationSoundKind soundKind) {
1396 1408 this.offhandBefore = offhandBefore;
1397 1409 this.captureHistory = captureHistory;
1410 this.soundKind = soundKind;
1398 1411 }
1399 1412
1400 1413 private void captureSound(BlockPos pos, BlockState state) {
1401 if (sound == null) sound = new OperationSound(pos, state);
1414 if (sound == null) sound = new OperationSound(pos, state, soundKind);
1402 1415 }
1403 1416 }
1404 1417
@@ -1406,12 +1419,17 @@ public final class BuilderOperationManager {
1406 1419 boolean committed, @javax.annotation.Nullable OperationSound sound) {
1407 1420 }
1408 1421
1409 public record OperationSound(BlockPos pos, BlockState state) {
1422 public record OperationSound(BlockPos pos, BlockState state, OperationSoundKind kind) {
1410 1423 public OperationSound {
1411 1424 pos = pos.immutable();
1412 1425 }
1413 1426 }
1414 1427
1428 public enum OperationSoundKind {
1429 PLACE,
1430 BREAK
1431 }
1432
1415 1433 record NeighborNotification(BlockPos target, BlockPos source) {
1416 1434 NeighborNotification {
1417 1435 target = target.immutable();
Modified src/main/java/com/xfestudio/mydimension/client/builder/BlueprintAltActionController.java +1 -0
@@ -18,6 +18,7 @@ public final class BlueprintAltActionController {
18 18 OFFSET_Y(true),
19 19 OFFSET_Z(true),
20 20 RESET(false),
21 COPY_SELECTION(false),
21 22 SAVE(false);
22 23
23 24 private final boolean repeatable;
Modified src/main/java/com/xfestudio/mydimension/client/builder/BuilderClientNetworkBridge.java +68 -6
@@ -51,6 +51,9 @@ public final class BuilderClientNetworkBridge implements BuilderClientBridge,
51 51 @Nullable private UUID pendingCapture;
52 52 @Nullable private UUID pendingSelectionCapture;
53 53 @Nullable private UUID pendingPlacement;
54 @Nullable private BlueprintData cachedSelectionBlueprint;
55 @Nullable private UUID cachedSelectionToken;
56 private long cachedSelectionAtNanos;
54 57 private BlueprintTransform transform = BlueprintTransform.NONE;
55 58 private BlockPos offset = BlockPos.ZERO;
56 59 @Nullable private BlockPos lastPreviewAnchor;
@@ -229,6 +232,8 @@ public final class BuilderClientNetworkBridge implements BuilderClientBridge,
229 232 selection = new BuilderPreviewState.Selection(dimension,
230 233 current.selection().first(), target.blockPos());
231 234 } else {
235 INSTANCE.clearCachedSelectionCopy();
236 INSTANCE.pendingSelectionCapture = null;
232 237 selection = new BuilderPreviewState.Selection(dimension, target.blockPos(), null);
233 238 ModNetwork.CHANNEL.sendToServer(new BlueprintSelectionStartPacket(target.blockPos()));
234 239 }
@@ -237,13 +242,33 @@ public final class BuilderClientNetworkBridge implements BuilderClientBridge,
237 242 BuilderPreviewState.get().accept(new BuilderPreviewState.Snapshot(dimension, List.of(), selection,
238 243 null, complete, true, revision));
239 244 if (complete) {
240 UUID request = UUID.randomUUID();
241 INSTANCE.pendingSelectionCapture = request;
242 ModNetwork.CHANNEL.sendToServer(new BlueprintCaptureRequestPacket(request, selection.first(),
243 selection.second(), BlueprintSaveMode.BLOCKS_ONLY, "Unsaved Selection", false));
245 requestSelectionCopy();
244 246 }
245 247 }
246 248
249 /**
250 * Rebuilds a movable deployment preview from the persistent, server-validated source cuboid.
251 * This is also used by the wheel after a player cancels only the copied preview: the blue
252 * source selection remains intact and can therefore be copied again without reselecting it.
253 */
254 public static boolean requestSelectionCopy() {
255 BuilderPreviewState.Snapshot preview = BuilderPreviewState.get().snapshot();
256 if (preview == null || preview.selection() == null || !preview.selection().complete()
257 || INSTANCE.pendingSelectionCapture != null) return false;
258 // A source-selection capture supersedes any library upload that may still be in flight.
259 // Otherwise that late upload could pair this selection's BlueprintData with an unrelated
260 // cache token and make the visible preview differ from the eventual placement.
261 INSTANCE.selectedBlueprintId = null;
262 INSTANCE.pendingUpload = null;
263 if (INSTANCE.restoreFreshSelectionCopy()) return true;
264 UUID request = UUID.randomUUID();
265 INSTANCE.pendingSelectionCapture = request;
266 ModNetwork.CHANNEL.sendToServer(new BlueprintCaptureRequestPacket(request,
267 preview.selection().first(), preview.selection().second(), BlueprintSaveMode.BLOCKS_ONLY,
268 "Unsaved Selection", false));
269 return true;
270 }
271
247 272 public static boolean requestCapture(String name, BlueprintSaveMode mode) {
248 273 BuilderPreviewState.Snapshot preview = BuilderPreviewState.get().snapshot();
249 274 if (preview == null || preview.selection().first() == null
@@ -280,6 +305,7 @@ public final class BuilderClientNetworkBridge implements BuilderClientBridge,
280 305 INSTANCE.pendingCapture = null;
281 306 INSTANCE.pendingSelectionCapture = null;
282 307 INSTANCE.pendingPlacement = null;
308 INSTANCE.clearCachedSelectionCopy();
283 309 INSTANCE.lastPreviewAnchor = null;
284 310 INSTANCE.previewDirty = false;
285 311 INSTANCE.blueprintTargetMissTicks = 0;
@@ -313,6 +339,7 @@ public final class BuilderClientNetworkBridge implements BuilderClientBridge,
313 339 public static void cancelSourceSelection() {
314 340 ModNetwork.CHANNEL.sendToServer(new BlueprintSelectionCancelPacket());
315 341 INSTANCE.pendingSelectionCapture = null;
342 INSTANCE.clearCachedSelectionCopy();
316 343 BuilderPreviewState.get().clearSelection();
317 344 }
318 345
@@ -371,8 +398,11 @@ public final class BuilderClientNetworkBridge implements BuilderClientBridge,
371 398 BLUEPRINT_TRANSFERS.takeDownload(selectionId);
372 399 if (download.isPresent()) {
373 400 pendingSelectionCapture = null;
374 selectedBlueprint = download.get().blueprint();
375 blueprintToken = download.get().cacheToken();
401 cachedSelectionBlueprint = download.get().blueprint();
402 cachedSelectionToken = download.get().cacheToken();
403 cachedSelectionAtNanos = System.nanoTime();
404 selectedBlueprint = cachedSelectionBlueprint;
405 blueprintToken = cachedSelectionToken;
376 406 transform = BlueprintTransform.NONE;
377 407 offset = BlockPos.ZERO;
378 408 lastPreviewAnchor = null;
@@ -392,6 +422,34 @@ public final class BuilderClientNetworkBridge implements BuilderClientBridge,
392 422 }
393 423 }
394 424
425 /**
426 * Covers the brief interval in which the server's anti-spam capture cooldown is still active.
427 * A just-cancelled deployment can be restored locally from the capture that produced it; after
428 * two seconds we recapture normally so later source-world edits and cache eviction are respected.
429 */
430 private boolean restoreFreshSelectionCopy() {
431 long age = System.nanoTime() - cachedSelectionAtNanos;
432 if (cachedSelectionBlueprint == null || cachedSelectionToken == null
433 || cachedSelectionAtNanos == 0L || age < 0L || age > 2_000_000_000L) {
434 clearCachedSelectionCopy();
435 return false;
436 }
437 selectedBlueprint = cachedSelectionBlueprint;
438 blueprintToken = cachedSelectionToken;
439 transform = BlueprintTransform.NONE;
440 offset = BlockPos.ZERO;
441 lastPreviewAnchor = null;
442 blueprintTargetMissTicks = 0;
443 previewDirty = true;
444 return true;
445 }
446
447 private void clearCachedSelectionCopy() {
448 cachedSelectionBlueprint = null;
449 cachedSelectionToken = null;
450 cachedSelectionAtNanos = 0L;
451 }
452
395 453 private static void showBlueprintMessage(String message) {
396 454 Minecraft minecraft = Minecraft.getInstance();
397 455 if (minecraft.player != null && message != null && !message.isBlank()) {
@@ -400,6 +458,10 @@ public final class BuilderClientNetworkBridge implements BuilderClientBridge,
400 458 }
401 459
402 460 private void executeBlueprintAction(BlueprintAltActionController.Action action) {
461 if (action == BlueprintAltActionController.Action.COPY_SELECTION) {
462 requestSelectionCopy();
463 return;
464 }
403 465 if (action == BlueprintAltActionController.Action.SAVE) {
404 466 BuilderPreviewState.Snapshot preview = BuilderPreviewState.get().snapshot();
405 467 if (preview != null && preview.selection() != null && preview.selection().complete()) {
Modified src/main/java/com/xfestudio/mydimension/client/builder/BuilderHudRenderer.java +1 -1
@@ -116,7 +116,7 @@ public final class BuilderHudRenderer {
116 116 drawChevron(graphics, centerX + innerRadius - 7, centerY - 2, true, 0xFF73EAD7);
117 117 }
118 118
119 // Nine dots preserve position feedback without reintroducing textual page numbers.
119 // One dot per action preserves position feedback without textual page numbers.
120 120 int indicatorY = centerY + innerRadius - 9;
121 121 int indicatorSpacing = 3;
122 122 int indicatorStart = centerX - (actions.size() - 1) * indicatorSpacing / 2;
Modified src/main/java/com/xfestudio/mydimension/client/builder/BuilderWheelIconPainter.java +11 -0
@@ -28,6 +28,7 @@ final class BuilderWheelIconPainter {
28 28 case OFFSET_Y -> drawOffset(graphics, Axis.Y, color, accentColor);
29 29 case OFFSET_Z -> drawOffset(graphics, Axis.Z, color, accentColor);
30 30 case RESET -> drawReset(graphics, color, accentColor);
31 case COPY_SELECTION -> drawCopySelection(graphics, color, accentColor);
31 32 case SAVE -> drawSave(graphics, color, accentColor);
32 33 }
33 34 graphics.pose().popPose();
@@ -100,6 +101,16 @@ final class BuilderWheelIconPainter {
100 101 line(graphics, -2, 5, -4, 3, color);
101 102 }
102 103
104 /** Two overlapping selection frames with a small transfer arrow. */
105 private static void drawCopySelection(GuiGraphics graphics, int color, int accentColor) {
106 outline(graphics, -5, -5, 2, 2, accentColor);
107 outline(graphics, -2, -2, 5, 5, color);
108
109 line(graphics, -4, 5, 0, 5, accentColor);
110 line(graphics, 0, 5, -2, 3, accentColor);
111 line(graphics, 0, 5, -2, 6, accentColor);
112 }
113
103 114 /** Classic floppy-disk silhouette without relying on a texture atlas. */
104 115 private static void drawSave(GuiGraphics graphics, int color, int accentColor) {
105 116 line(graphics, -5, -6, 3, -6, color);
Modified src/main/resources/assets/mydimension/lang/en_us.json +1 -0
@@ -221,5 +221,6 @@
221 221 "action.mydimension.realmwright.blueprint.offset_y": "Offset Y",
222 222 "action.mydimension.realmwright.blueprint.offset_z": "Offset Z",
223 223 "action.mydimension.realmwright.blueprint.reset": "Reset transform",
224 "action.mydimension.realmwright.blueprint.copy_selection": "Copy selection",
224 225 "action.mydimension.realmwright.blueprint.save": "Save blueprint"
225 226 }
Modified src/main/resources/assets/mydimension/lang/zh_cn.json +1 -0
@@ -222,5 +222,6 @@
222 222 "action.mydimension.realmwright.blueprint.offset_y": "Y 轴偏移",
223 223 "action.mydimension.realmwright.blueprint.offset_z": "Z 轴偏移",
224 224 "action.mydimension.realmwright.blueprint.reset": "重置变换",
225 "action.mydimension.realmwright.blueprint.copy_selection": "复制选区",
225 226 "action.mydimension.realmwright.blueprint.save": "保存蓝图"
226 227 }
Added src/test/java/com/xfestudio/mydimension/builder/BuilderOperationSoundTest.java +19 -0
@@ -0,0 +1,19 @@
1 package com.xfestudio.mydimension.builder;
2
3 import org.junit.jupiter.api.Test;
4
5 import static org.junit.jupiter.api.Assertions.assertEquals;
6
7 final class BuilderOperationSoundTest {
8 @Test
9 void buildUsesTheBlocksPlacementSound() {
10 assertEquals("place", BuilderOperationManager.selectOperationSound(
11 "place", "break", BuilderOperationManager.OperationSoundKind.PLACE));
12 }
13
14 @Test
15 void demolitionUsesTheBlocksBreakSound() {
16 assertEquals("break", BuilderOperationManager.selectOperationSound(
17 "place", "break", BuilderOperationManager.OperationSoundKind.BREAK));
18 }
19 }
Modified src/test/java/com/xfestudio/mydimension/client/builder/BlueprintAltActionControllerTest.java +32 -0
@@ -4,10 +4,12 @@ import net.minecraft.core.BlockPos;
4 4 import org.junit.jupiter.api.AfterEach;
5 5 import org.junit.jupiter.api.Test;
6 6
7 import java.util.List;
7 8 import java.util.concurrent.atomic.AtomicReference;
8 9
9 10 import static org.junit.jupiter.api.Assertions.assertEquals;
10 11 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
12 import static org.junit.jupiter.api.Assertions.assertFalse;
11 13 import static org.junit.jupiter.api.Assertions.assertTrue;
12 14
13 15 final class BlueprintAltActionControllerTest {
@@ -48,4 +50,34 @@ final class BlueprintAltActionControllerTest {
48 50 assertTrue(!new BuilderPreviewState.Selection(null, first, null).complete());
49 51 assertTrue(new BuilderPreviewState.Selection(null, first, first.offset(4, 5, 6)).complete());
50 52 }
53
54 @Test
55 void copySelectionIsAOneShotWheelActionBeforeSave() {
56 AtomicReference<BuilderClientCommand> sent = new AtomicReference<>();
57 BuilderClientServices.install(new BuilderClientBridge() {
58 @Override
59 public void send(BuilderClientCommand command) {
60 sent.set(command);
61 }
62 });
63 BlueprintAltActionController controller = new BlueprintAltActionController();
64
65 // SAVE remains the final sector; a second upward step reaches the new action before it.
66 assertTrue(controller.scroll(1.0D));
67 assertEquals(BlueprintAltActionController.Action.SAVE, controller.highlighted());
68 assertTrue(controller.scroll(1.0D));
69 assertEquals(BlueprintAltActionController.Action.COPY_SELECTION, controller.highlighted());
70 assertFalse(controller.highlighted().repeatable());
71 assertEquals("action.mydimension.realmwright.blueprint.copy_selection",
72 controller.highlighted().translationKey());
73
74 assertTrue(controller.activateOrConfirm());
75 assertEquals(BlueprintAltActionController.Action.COPY_SELECTION,
76 assertInstanceOf(BuilderClientCommand.ExecuteBlueprintAction.class, sent.get()).action());
77 assertEquals(BlueprintAltActionController.Phase.NAVIGATION, controller.phase());
78 assertEquals(List.of(BlueprintAltActionController.Action.RESET,
79 BlueprintAltActionController.Action.COPY_SELECTION,
80 BlueprintAltActionController.Action.SAVE),
81 controller.actions().subList(controller.actions().size() - 3, controller.actions().size()));
82 }
51 83 }