Skip to content

Commit 557ada7

Browse files
committed
Fixes and features
- Fixed #35, #32, and #20 - Added features from #41
1 parent acffc4c commit 557ada7

File tree

4 files changed

+61
-7
lines changed

4 files changed

+61
-7
lines changed

src/animationRenderer.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,29 @@ async function renderAnimation(options) {
276276
console.log('Rendered Groups:', renderedGroups)
277277

278278
for (const animation of Animator.animations.sort()) {
279+
if (animation.snapping != 20) {
280+
throw new CustomError('Invalid Snapping Value Error', {
281+
intentional: true,
282+
dialog: {
283+
id: 'animatedJava_exporter_animationExporter.popup.warning.invalidSnappingValue',
284+
title: tl(
285+
'animatedJava_exporter_animationExporter.popup.warning.invalidSnappingValue.title'
286+
),
287+
lines: format(
288+
tl(
289+
'animatedJava_exporter_animationExporter.popup.warning.invalidSnappingValue.body'
290+
),
291+
{
292+
animationName: animation.name,
293+
snapping: animation.snapping
294+
}
295+
)
296+
.split('\n')
297+
.map((line) => `<p>${line}</p>`),
298+
},
299+
})
300+
}
301+
279302
const value = Cache.hit(animation)
280303
if (!value) {
281304
let maxDistance = -Infinity

src/exporters/animationExporter.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ async function createMCFile(
184184
.join('\n')}
185185
scoreboard players add .aj.animation ${scoreboards.animatingFlag} 0
186186
scoreboard players add .aj.anim_loop ${scoreboards.animatingFlag} 0
187+
scoreboard players set .noScripts ${scoreboards.internal} 0
187188
}
188189
`)
189190
// prettier-ignore
@@ -534,6 +535,24 @@ async function createMCFile(
534535
}
535536

536537
{
538+
if (!Object.keys(animations).length) {
539+
throw new CustomError('No Animations Error', {
540+
intentional: true,
541+
dialog: {
542+
id: 'animatedJava_exporter_animationExporter.popup.warning.noAnimations',
543+
title: tl(
544+
'animatedJava_exporter_animationExporter.popup.warning.noAnimations.title'
545+
),
546+
lines:
547+
tl(
548+
'animatedJava_exporter_animationExporter.popup.warning.noAnimations.body'
549+
)
550+
.split('\n')
551+
.map((line: string) => `<p>${line}</p>`),
552+
},
553+
})
554+
}
555+
537556
//? Animation Dir
538557
FILE.push(`dir animations {`)
539558

@@ -681,9 +700,10 @@ async function createMCFile(
681700
# Reset animation time
682701
scoreboard players set @s ${scoreboards.frame} 0
683702
# load initial animation frame without running scripts
703+
scoreboard players operation .oldValue ${scoreboards.internal} = .noScripts ${scoreboards.internal}
684704
scoreboard players set .noScripts ${scoreboards.internal} 1
685705
function ${projectName}:animations/${animation.name}/next_frame
686-
scoreboard players set .noScripts ${scoreboards.internal} 0
706+
scoreboard players operation .noScripts ${scoreboards.internal} = .oldValue ${scoreboards.internal}
687707
# Reset animation time
688708
scoreboard players set @s ${scoreboards.frame} 0
689709
# If this entity is not the root

src/exporters/statueExporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ const Exporter = (AJ: any) => {
686686
AJ.settings.animatedJava_exporter_statueExporter
687687
.exportMode === 'mcb' &&
688688
(value === '' ||
689-
b.base !== `${AJ.settings.animatedJava.projectName}.mc`)
689+
b.base === `${AJ.settings.animatedJava.projectName}.mc`)
690690
)
691691
},
692692
isVisible(settings: any) {

src/lang/en.yaml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,19 @@ animatedJava.customErrorReport.titleUndefined: Unknown Error
6868

6969
animatedJava.popup.error.unableToGenerateTexturePath.title: Invalid texture path
7070
animatedJava.popup.error.unableToGenerateTexturePath.body: |-
71-
The texture '%textureName' has an invalid location inside a resource pack
72-
Please make sure it is properly saved inside of a valid resource pack in a sub folder of 'assets/namespace/textures/'
71+
The texture '%textureName' has an invalid location inside a Resource Pack
72+
Please make sure it is properly saved inside of a valid Resource Pack in a sub folder of 'assets/namespace/textures/'
73+
eg. 'resources/assets/minecraft/textures/item/diamond.png'
7374
7475
animatedJava.popup.error.invalidCubeRotations.title: Invalid Element Rotations
7576
animatedJava.popup.error.invalidCubeRotations.body: |-
7677
The rotations of some cubes are invalid for the java model format.
77-
Please all invalid rotations before exporting
78+
Please fix all invalid rotations before exporting.
79+
80+
animatedJava_exporter_animationExporter.popup.warning.invalidSnappingValue.title: Invalid Animation Snapping Value
81+
animatedJava_exporter_animationExporter.popup.warning.invalidSnappingValue.body: |-
82+
The animation '%animationName' has a snapping value of %snapping!
83+
Due to how fast Minecraft ticks, Animated Java only supports a snapping value of 20.
7884
7985
animatedJava.popup.error.unsavedTexture.title: Unsaved Texture
8086
animatedJava.popup.error.unsavedTexture.body: |-
@@ -196,7 +202,7 @@ animatedJava_exporter_statueExporter.setting.exportMode.vanilla.name: Vanilla
196202
animatedJava_exporter_statueExporter.setting.exportMode.mcb.name: MCB
197203

198204
animatedJava_exporter_statueExporter.setting.mcbFilePath.name: Lang-mc file
199-
animatedJava_exporter_statueExporter.setting.mcbFilePath.description: The path to export the .mc file to
205+
animatedJava_exporter_statueExporter.setting.mcbFilePath.description: The path to export the .mc file to\nYou will need to install mc-extra into your MCB workspace in order to build the exported data pack
200206

201207
animatedJava_exporter_statueExporter.setting.mcbConfigPath.name: Lang-mc config.json Path
202208
animatedJava_exporter_statueExporter.setting.mcbConfigPath.description: |-
@@ -268,14 +274,19 @@ animatedJava_exporter_animationExporter.setting.exportMode.vanilla.name: Vanilla
268274
animatedJava_exporter_animationExporter.setting.exportMode.mcb.name: MCB
269275

270276
animatedJava_exporter_animationExporter.setting.mcbFilePath.name: Lang-mc File Path
271-
animatedJava_exporter_animationExporter.setting.mcbFilePath.description: The path to export the .mc file to
277+
animatedJava_exporter_animationExporter.setting.mcbFilePath.description: The path to export the .mc file to\nYou will need to install mc-extra into your MCB workspace in order to build the exported data pack
272278
animatedJava_exporter_animationExporter.setting.mcbFilePath.invalidPopup.text: Invalid MCB File Path! The MCB file must be called %projectName.mc (project_name.mc)
273279

274280
animatedJava_exporter_animationExporter.setting.mcbConfigPath.name: Lang-mc config.json Path
275281
animatedJava_exporter_animationExporter.setting.mcbConfigPath.description: |-
276282
Exports the default MCB config for Animated Java
277283
WARNING! Will overwrite existing config.json
278284
285+
animatedJava_exporter_animationExporter.popup.warning.noAnimations.title: No Animations
286+
animatedJava_exporter_animationExporter.popup.warning.noAnimations.body: |-
287+
You haven't made any animations!
288+
You'll need to create some animations in the animation tab before you can export using the animation exporter.
289+
279290
animatedJava_exporter_animationExporter.setting.dataPackPath.name: Data Pack
280291
animatedJava_exporter_animationExporter.setting.dataPackPath.description: The path to export the generated Data Pack to.
281292
animatedJava_exporter_animationExporter.popup.error.dataPackPathNotDefined.title: Data Pack file path undefined

0 commit comments

Comments
 (0)