Skip to content

Commit faea245

Browse files
committed
🔁 Added Loop Delay property to animations
1 parent 5f77e26 commit faea245

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

src/components/animationProperties.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
1414
export let animationName: Valuable<string>
1515
export let loopMode: Valuable<string>
16+
export let loopDelay: Valuable<number>
1617
export let excludedBones: Valuable<Array<{ name: string; value: string }>>
1718
1819
const availableBones = Group.all.map(group => {
@@ -62,6 +63,13 @@
6263
bind:value={loopMode}
6364
/>
6465

66+
<NumberSlider
67+
label={translate('dialog.animation_properties.loop_delay.title')}
68+
tooltip={translate('dialog.animation_properties.loop_delay.description')}
69+
min={0}
70+
bind:value={loopDelay}
71+
/>
72+
6573
<Collection
6674
label={translate('dialog.animation_properties.excluded_bones.title')}
6775
tooltip={translate('dialog.animation_properties.bone_lists.description')}

src/interface/animationPropertiesDialog.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { translate } from '../util/translation'
77
export function openAnimationPropertiesDialog(animation: _Animation) {
88
const animationName = new Valuable(animation.name)
99
const loopMode = new Valuable(animation.loop)
10+
const loopDelay = new Valuable(Number(animation.loop_delay) || 0)
1011
const excludedBones = new Valuable(animation.excluded_bones)
1112

1213
new SvelteDialog({
@@ -17,24 +18,16 @@ export function openAnimationPropertiesDialog(animation: _Animation) {
1718
svelteComponentProperties: {
1819
animationName,
1920
loopMode,
21+
loopDelay,
2022
excludedBones,
2123
},
2224
preventKeybinds: true,
2325
onConfirm() {
2426
animation.name = animationName.get()
2527
animation.createUniqueName(Blockbench.Animation.all)
2628
animation.loop = loopMode.get()
29+
animation.loop_delay = loopDelay.get().toString()
2730
animation.excluded_bones = excludedBones.get()
2831
},
2932
}).show()
3033
}
31-
32-
// export const ANIMATION_PROPERTIES_ACTION = createAction(`${PACKAGE.name}:bone_config`, {
33-
// icon: 'settings',
34-
// name: translate('action.open_bone_config.name'),
35-
// condition: () => Format === BLUEPRINT_FORMAT,
36-
// click: () => {
37-
// if (!Blockbench.Animation.selected) return
38-
// openBoneConfigDialog(Blockbench.Animation.selected)
39-
// },
40-
// })

src/lang/en.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ animated_java.dialog.animation_properties.loop_mode.options.loop: Loop
294294
animated_java.dialog.animation_properties.animation_name.error.empty: The animation name cannot be empty!
295295
animated_java.dialog.animation_properties.animation_name.error.invalid_characters: The animation name contains invalid characters! Animation names should only contain letters, numbers, underscores, and periods.
296296

297+
animated_java.dialog.animation_properties.loop_delay.title: Loop Delay
298+
animated_java.dialog.animation_properties.loop_delay.description: The delay between loops. This is the time the animation will pause before starting again. This is only used when the Loop Mode is set to Loop.
299+
297300
animated_java.dialog.animation_properties.bone_lists.description: A list of bones to include or exclude from the animation. Only bones in the included list will be modified by the animation, and bones in the excluded list will be ignored.
298301
animated_java.dialog.animation_properties.excluded_bones.title: Excluded Bones
299302
animated_java.dialog.animation_properties.excluded_bones.description: A list of bones to exclude from the animation. These bones will not be modified by the animation.

src/systems/animated_java.mcb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ dir <%export_namespace%> {
298298
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 0 on passengers run data modify entity @s interpolation_duration set value <%interpolation_duration%>
299299
# Animation logic
300300
execute store result storage aj:temp frame int 1 run scoreboard players get @s <%OBJECTIVES.FRAME()%>
301-
IF (animation.loopMode === 'loop') {
301+
IF (animation.loopMode === 'loop' && animation.loopDelay === 0) {
302302
# Makes sure commands in the last frame of the animation is run.
303303
execute if score @s <%OBJECTIVES.FRAME()%> matches -1 run {
304304
function ./apply_frame {frame: <%animation.duration-1%>}
@@ -307,8 +307,8 @@ dir <%export_namespace%> {
307307
}
308308
function ./apply_frame with storage aj:temp
309309
IF (animation.loopMode === 'loop') {
310-
execute if score @s <%OBJECTIVES.FRAME()%> matches <%animation.duration-2%>.. run return run {
311-
scoreboard players set @s <%OBJECTIVES.FRAME()%> -1
310+
execute if score @s <%OBJECTIVES.FRAME()%> matches <%animation.duration-2 + animation.loopDelay%>.. run return run {
311+
scoreboard players set @s <%OBJECTIVES.FRAME()%> <%animation.loopDelay === 0 ? -1 : 0%>
312312
}
313313
} ELSE IF (animation.loopMode === 'hold') {
314314
execute if score @s <%OBJECTIVES.FRAME()%> matches <%animation.duration-1%>.. run return run function ../pause

src/systems/animationRenderer.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export interface IRenderedFrame {
7474

7575
export interface IRenderedAnimation {
7676
name: string
77-
startDelay: number
7877
loopDelay: number
7978
frames: IRenderedFrame[]
8079
/**
@@ -251,8 +250,7 @@ export function updatePreview(animation: _Animation, time: number) {
251250
export function renderAnimation(animation: _Animation, rig: IRenderedRig) {
252251
const rendered = {
253252
name: animation.name,
254-
startDelay: Number(animation.start_delay),
255-
loopDelay: Number(animation.loop_delay),
253+
loopDelay: Number(animation.loop_delay) || 0,
256254
frames: [],
257255
duration: 0,
258256
loopMode: animation.loop,

0 commit comments

Comments
 (0)