From 316ffebe1ff25618a109bdaecd04f969f116b582 Mon Sep 17 00:00:00 2001 From: trunksbomb Date: Mon, 23 Mar 2026 12:34:02 -0400 Subject: [PATCH] captured cards are now flipped in groups instead of one at a time. --- .../blockentity/DuelTableBlockEntity.java | 36 +++++++++++++------ .../render/DuelTableBlockEntityRenderer.java | 2 +- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/trunksbomb/minetriad/blockentity/DuelTableBlockEntity.java b/src/main/java/com/trunksbomb/minetriad/blockentity/DuelTableBlockEntity.java index 6027c1f..3ea1a19 100644 --- a/src/main/java/com/trunksbomb/minetriad/blockentity/DuelTableBlockEntity.java +++ b/src/main/java/com/trunksbomb/minetriad/blockentity/DuelTableBlockEntity.java @@ -45,7 +45,7 @@ public class DuelTableBlockEntity extends BlockEntity { private UUID firstParticipantId; private UUID secondParticipantId; private AnimationType animationType = AnimationType.NONE; - private int animationSlot = -1; + private int[] animationSlots = new int[0]; private int animationTargetOwner = OWNER_NONE; private int animationAge; private int animationDuration; @@ -95,7 +95,16 @@ public class DuelTableBlockEntity extends BlockEntity { } public int animationSlot() { - return animationSlot; + return animationSlots.length > 0 ? animationSlots[0] : -1; + } + + public boolean isAnimatingSlot(int slot) { + for (int animatedSlot : animationSlots) { + if (animatedSlot == slot) { + return true; + } + } + return false; } public float animationProgress(float partialTick) { @@ -188,9 +197,12 @@ public class DuelTableBlockEntity extends BlockEntity { return; } - pendingAnimations.addLast(new AnimationStep(AnimationType.PLACEMENT, moveResult.playedCell().index(), owner)); - for (BoardCell capturedCell : moveResult.capturedCells()) { - pendingAnimations.addLast(new AnimationStep(AnimationType.CAPTURE, capturedCell.index(), owner)); + pendingAnimations.addLast(new AnimationStep(AnimationType.PLACEMENT, new int[] {moveResult.playedCell().index()}, owner)); + if (!moveResult.capturedCells().isEmpty()) { + int[] captureSlots = moveResult.capturedCells().stream() + .mapToInt(BoardCell::index) + .toArray(); + pendingAnimations.addLast(new AnimationStep(AnimationType.CAPTURE, captureSlots, owner)); } advanceAnimationStep(); } @@ -219,7 +231,9 @@ public class DuelTableBlockEntity extends BlockEntity { && blockEntity.animationType == AnimationType.CAPTURE && !blockEntity.animationOwnerApplied && blockEntity.animationAge >= Math.max(1, blockEntity.animationDuration / 2)) { - blockEntity.setOwner(blockEntity.animationSlot, blockEntity.animationTargetOwner); + for (int slot : blockEntity.animationSlots) { + blockEntity.setOwner(slot, blockEntity.animationTargetOwner); + } blockEntity.animationOwnerApplied = true; blockEntity.sync(); } @@ -349,7 +363,7 @@ public class DuelTableBlockEntity extends BlockEntity { private void saveAnimation(CompoundTag tag) { tag.putString("AnimationType", animationType.name()); - tag.putInt("AnimationSlot", animationSlot); + tag.putIntArray("AnimationSlots", animationSlots); tag.putInt("AnimationTargetOwner", animationTargetOwner); tag.putInt("AnimationAge", animationAge); tag.putInt("AnimationDuration", animationDuration); @@ -358,7 +372,7 @@ public class DuelTableBlockEntity extends BlockEntity { private void loadAnimation(CompoundTag tag) { animationType = AnimationType.valueOf(tag.getString("AnimationType").isEmpty() ? AnimationType.NONE.name() : tag.getString("AnimationType")); - animationSlot = tag.getInt("AnimationSlot"); + animationSlots = tag.getIntArray("AnimationSlots"); animationTargetOwner = tag.getInt("AnimationTargetOwner"); animationAge = tag.getInt("AnimationAge"); animationDuration = tag.getInt("AnimationDuration"); @@ -386,7 +400,7 @@ public class DuelTableBlockEntity extends BlockEntity { } animationType = nextStep.type(); - animationSlot = nextStep.slot(); + animationSlots = nextStep.slots(); animationTargetOwner = nextStep.targetOwner(); animationAge = 0; animationDuration = nextStep.type() == AnimationType.PLACEMENT ? PLACEMENT_DURATION : CAPTURE_DURATION; @@ -396,7 +410,7 @@ public class DuelTableBlockEntity extends BlockEntity { private void clearAnimationState() { animationType = AnimationType.NONE; - animationSlot = -1; + animationSlots = new int[0]; animationTargetOwner = OWNER_NONE; animationAge = 0; animationDuration = 0; @@ -486,6 +500,6 @@ public class DuelTableBlockEntity extends BlockEntity { CLEARING } - private record AnimationStep(AnimationType type, int slot, int targetOwner) { + private record AnimationStep(AnimationType type, int[] slots, int targetOwner) { } } diff --git a/src/main/java/com/trunksbomb/minetriad/client/render/DuelTableBlockEntityRenderer.java b/src/main/java/com/trunksbomb/minetriad/client/render/DuelTableBlockEntityRenderer.java index 42eb528..d223235 100644 --- a/src/main/java/com/trunksbomb/minetriad/client/render/DuelTableBlockEntityRenderer.java +++ b/src/main/java/com/trunksbomb/minetriad/client/render/DuelTableBlockEntityRenderer.java @@ -35,7 +35,7 @@ public class DuelTableBlockEntityRenderer implements BlockEntityRenderer