Skip to content

Commit 0dc5de9

Browse files
committed
✨ On Remove commands and bug fixes
- Implemented #400 - Fixed #398 - Fixed several issues causing locators and cameras to not move correctly - Fixed inconsistant data pack structure between versions - Added on-remove commands
1 parent c6d4cbc commit 0dc5de9

File tree

20 files changed

+5939
-1486
lines changed

20 files changed

+5939
-1486
lines changed

src/blockbenchTypeMods.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import { blueprintSettingErrors, defaultValues } from './blueprintSettings'
88
import { openExportProgressDialog } from './interface/dialog/exportProgress'
99
import { openUnexpectedErrorDialog } from './interface/dialog/unexpectedError'
1010
import { TextDisplay } from './outliner/textDisplay'
11+
import { VanillaBlockDisplay } from './outliner/vanillaBlockDisplay'
12+
import { VanillaItemDisplay } from './outliner/vanillaItemDisplay'
1113
import datapackCompiler from './systems/datapackCompiler'
12-
import resourcepackCompiler from './systems/resourcepackCompiler'
1314
import { MINECRAFT_REGISTRY } from './systems/minecraft/registryManager'
15+
import resourcepackCompiler from './systems/resourcepackCompiler'
16+
import { EasingKey } from './util/easing'
1417
import { isDataPackPath, isResourcePackPath } from './util/minecraftUtil'
1518
import { Valuable } from './util/stores'
1619
import { type Variant } from './variants'
17-
import { VanillaItemDisplay } from './outliner/vanillaItemDisplay'
18-
import { VanillaBlockDisplay } from './outliner/vanillaBlockDisplay'
19-
import { EasingKey } from './util/easing'
2020

2121
declare module 'three' {
2222
interface Object3D {

src/blueprintSettings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const defaultValues = {
2222
enable_advanced_data_pack_settings: false,
2323
data_pack: '',
2424
summon_commands: '',
25+
remove_commands: '',
2526
ticking_commands: '',
2627
interpolation_duration: 1,
2728
teleportation_duration: 1,

src/components/blueprintSettingsDialog.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
// export let enableAdvancedDataPackSettings: Valuable<boolean>
6060
export let dataPack: Valuable<string>
6161
export let summonCommands: Valuable<string>
62+
export let removeCommands: Valuable<string>
6263
export let tickingCommands: Valuable<string>
6364
export let interpolationDuration: Valuable<number>
6465
export let teleportationDuration: Valuable<number>
@@ -678,6 +679,13 @@
678679
defaultValue={defaultValues.summon_commands}
679680
/>
680681

682+
<CodeInput
683+
label={translate('dialog.blueprint_settings.remove_commands.title')}
684+
tooltip={translate('dialog.blueprint_settings.remove_commands.description')}
685+
bind:value={removeCommands}
686+
defaultValue={defaultValues.remove_commands}
687+
/>
688+
681689
<CodeInput
682690
label={translate('dialog.blueprint_settings.ticking_commands.title')}
683691
tooltip={translate('dialog.blueprint_settings.ticking_commands.description')}

src/interface/dialog/blueprintSettings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function getSettings() {
5353
),
5454
dataPack: new Valuable(Project!.animated_java.data_pack),
5555
summonCommands: new Valuable(Project!.animated_java.summon_commands),
56+
removeCommands: new Valuable(Project!.animated_java.remove_commands),
5657
tickingCommands: new Valuable(Project!.animated_java.ticking_commands),
5758
interpolationDuration: new Valuable(Project!.animated_java.interpolation_duration),
5859
teleportationDuration: new Valuable(Project!.animated_java.teleportation_duration),
@@ -95,6 +96,7 @@ function setSettings(settings: ReturnType<typeof getSettings>) {
9596
settings.enableAdvancedDataPackSettings.get()
9697
Project.animated_java.data_pack = settings.dataPack.get()
9798
Project.animated_java.summon_commands = settings.summonCommands.get()
99+
Project.animated_java.remove_commands = settings.removeCommands.get()
98100
Project.animated_java.ticking_commands = settings.tickingCommands.get()
99101
Project.animated_java.interpolation_duration = settings.interpolationDuration.get()
100102
Project.animated_java.teleportation_duration = settings.teleportationDuration.get()

src/lang/en.yml

Lines changed: 71 additions & 66 deletions
Large diffs are not rendered by default.

src/systems/animationRenderer.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ export function getFrame(
174174
case 'block_display':
175175
case 'bone': {
176176
matrix = getNodeMatrix(outlinerNode, node.base_scale)
177-
// Only add the frame if the matrix has changed.
178-
if (lastFrame && lastFrame.matrix.equals(matrix)) continue
179177
// Inherit instant interpolation from parent
180178
if (node.parent && node.parent !== 'root') {
181179
const parentKeyframes = keyframeCache.get(node.parent)
@@ -187,6 +185,9 @@ export function getFrame(
187185
interpolation = 'pre-post'
188186
}
189187
}
188+
// Only add the frame if the matrix has changed, this is the first frame, or there is an interpolation change.
189+
if (lastFrame && lastFrame.matrix.equals(matrix) && interpolation == undefined)
190+
continue
190191
// Instant interpolation
191192
if (keyframe?.interpolation === 'step') {
192193
interpolation = 'step'
@@ -204,6 +205,8 @@ export function getFrame(
204205
}
205206
case 'locator': {
206207
matrix = getNodeMatrix(outlinerNode, 1)
208+
// // Only add the frame if the matrix has changed, or this is the first frame
209+
// if (lastFrame && lastFrame.matrix.equals(matrix)) continue
207210
if (keyframe) {
208211
commands = getKeyframeCommands(keyframe)
209212
executeCondition = getKeyframeExecuteCondition(keyframe)
@@ -220,11 +223,15 @@ export function getFrame(
220223
executeCondition = getKeyframeExecuteCondition(lastFrame.keyframe)
221224
}
222225
}
226+
// lastFrameCache.set(uuid, { matrix, keyframe })
223227
break
224228
}
225229
case 'camera':
226230
case 'struct': {
227231
matrix = getNodeMatrix(outlinerNode, 1)
232+
// Only add the frame if the matrix has changed, or this is the first frame
233+
if (lastFrame && lastFrame.matrix.equals(matrix)) continue
234+
lastFrameCache.set(uuid, { matrix, keyframe })
228235
break
229236
}
230237
}
@@ -235,6 +242,10 @@ export function getFrame(
235242
matrix.decompose(pos, rot, scale)
236243
const decomposed = getDecomposedTransformation(matrix)
237244

245+
if (node.type === 'locator' || node.type === 'camera') {
246+
node.max_distance = Math.max(node.max_distance, pos.length())
247+
}
248+
238249
frame.node_transforms[uuid] = {
239250
matrix,
240251
decomposed,

0 commit comments

Comments
 (0)