Skip to content

Commit 127d0a7

Browse files
committed
🛠️ Fix #246
1 parent d5ce27a commit 127d0a7

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/blueprintFormat.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,16 @@ export interface IBlueprintFormatJSON {
150150

151151
export function convertToBlueprint() {
152152
// Convert the current project to a Blueprint
153-
// NOTE - Nothing needs to be done here yet. The default functionality is sufficient.
154153
Project!.save_path = ''
154+
155+
for (const group of Group.all) {
156+
group.createUniqueName(Group.all.filter(g => g !== group))
157+
group.sanitizeName()
158+
}
159+
for (const animation of Blockbench.Animation.all) {
160+
animation.createUniqueName(Blockbench.Animation.all.filter(a => a !== animation))
161+
animation.name = toSafeFuntionName(animation.name)
162+
}
155163
}
156164

157165
export function getDefaultProjectSettings(): ModelProject['animated_java'] {

src/interface/customKeyframePanel.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isCurrentFormat } from '../blueprintFormat'
12
import CustomKeyframePanelSvelteComponent from '../components/customKeyframePanel.svelte'
23
import { CUSTOM_CHANNELS } from '../mods/customKeyframesMod'
34
import { events } from '../util/events'
@@ -8,7 +9,12 @@ import { translate } from '../util/translation'
89
const CURRENT_PANEL = new Valuable<HTMLDivElement | undefined>(undefined)
910

1011
export function injectCustomKeyframePanel(selectedKeyframe: _Keyframe) {
11-
if (!CUSTOM_CHANNELS.includes(selectedKeyframe.channel)) return
12+
if (
13+
!isCurrentFormat() ||
14+
!selectedKeyframe ||
15+
!CUSTOM_CHANNELS.includes(selectedKeyframe.channel)
16+
)
17+
return
1218

1319
const element = document.querySelector(
1420
'#panel_keyframe .panel_vue_wrapper .keyframe_data_point'

src/mods/groupNameMod.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ createBlockbenchMod(
77
`${PACKAGE.name}:groupNameMod`,
88
{
99
originalRename: Group.prototype.saveName,
10+
originalSanitize: Group.prototype.sanitizeName,
1011
},
1112
context => {
1213
Group.prototype.saveName = function (this: Group, save?: boolean) {
@@ -15,6 +16,12 @@ createBlockbenchMod(
1516
}
1617
return context.originalRename.call(this, save)
1718
}
19+
Group.prototype.sanitizeName = function (this: Group) {
20+
if (isCurrentFormat()) {
21+
this.name = toSafeFuntionName(this.name)
22+
}
23+
return context.originalSanitize.call(this)
24+
}
1825
return context
1926
},
2027
context => {

0 commit comments

Comments
 (0)