Skip to content

Commit b57ec76

Browse files
committed
Raw Animation Exporter
- Added raw animation exporter - Updated Linting
1 parent 9c7aafb commit b57ec76

File tree

20 files changed

+1462
-1325
lines changed

20 files changed

+1462
-1325
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
22
name: Bug report
33
about: Report an issue you encountered while using Animated Java
4-
title: "[BUG]"
4+
title: '[BUG]'
55
labels: bug
66
assignees: ''
7-
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'
@@ -21,6 +21,7 @@ Steps to reproduce the behavior:
2121
A clear and concise description of what you expected to happen.
2222

2323
**Error Message**
24+
2425
```
2526
Paste the message the error displayed when it occurred (if applicable)
2627
```
@@ -29,8 +30,9 @@ Paste the message the error displayed when it occurred (if applicable)
2930
If applicable, add screenshots to help explain your problem.
3031

3132
**Desktop (please complete the following information):**
32-
- OS: [e.g. iOS]
33-
- Version [e.g. v0.2.0]
33+
34+
- OS: [e.g. iOS]
35+
- Version [e.g. v0.2.0]
3436

3537
**Additional context**
3638
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
title: "[FR]"
4+
title: '[FR]'
55
labels: ''
66
assignees: SnaveSutit
7-
87
---
98

109
**Is your feature request related to a problem? Please describe.**

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
Welcome to Animated Java, A tool for mapmakers to create smooth, and detailed animations for Minecraft Java Edition.
88

99
# Installing
10-
- Open Blockbench and navigate to the plugin list
11-
- Click on the "Available" tab, then search for `Animated Java`
12-
- Click `install`
13-
- Congratulations! You've installed Animated Java!
10+
11+
- Open Blockbench and navigate to the plugin list
12+
- Click on the "Available" tab, then search for `Animated Java`
13+
- Click `install`
14+
- Congratulations! You've installed Animated Java!
1415

1516
# Contributing to Animated Java
1617

1718
### Setting up a Development Enviornment
19+
1820
You will need to install `nodejs` and `yarn` before you get started.
1921

2022
1. Clone the repo
@@ -24,6 +26,7 @@ You will need to install `nodejs` and `yarn` before you get started.
2426
To make a production build, run `yarn build` inside your development enviornment.
2527

2628
### Adding Localizations
29+
2730
Note: Translations should use formal language
2831

2932
1. Fork the animated-java repo.
@@ -34,6 +37,7 @@ Note: Translations should use formal language
3437

3538
To edit an existing language follow the above steps; but instead of overwriting the file just edit it as is.
3639
You can check what translation keys are missing using the following code inside of blockbench's dev tools (Opened with Ctrl+shift+i)
40+
3741
```js
3842
ANIMATED_JAVA.logging = true
3943
ANIMATED_JAVA.logIntlDifferences()

debug_resourcepack/armor_stand.ajmodel

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"meta": {
33
"format_version": "0.0",
4-
"creation_time": 1643574489,
4+
"creation_time": 1644081457,
55
"model_format": "animated_java/ajmodel",
66
"box_uv": false,
77
"settings": {
88
"animatedJava": {
99
"projectName": "armor_stand",
10-
"exporter": "vanillaAnimationExporter",
10+
"exporter": "rawAnimationExporter",
1111
"verbose": true,
1212
"rigItem": "minecraft:leather_horse_armor",
1313
"rigModelsExportFolder": "C:\\Users\\Snave\\AppData\\Roaming\\.minecraft\\resourcepacks\\Animated Java Testing\\assets\\animated_java\\models\\rigs\\armor_stand",
@@ -53,6 +53,9 @@
5353
"mcbFilePath": "C:\\Users\\Snave\\AppData\\Roaming\\.minecraft\\saves\\Performance Tool 2_0\\datapacks\\performance_tool_2.0\\src\\armor_stand.mc",
5454
"mcbConfigPath": "",
5555
"dataPackPath": ""
56+
},
57+
"rawAnimationExporter": {
58+
"outputJsonPath": "C:\\Users\\Snave\\Downloads\\output.json"
5659
}
5760
},
5861
"variants": {

src/animatedJava.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import { settings } from './settings'
99
import { registerSettingRenderer } from './ui/dialogs/settings'
1010
import './ui/mods/boneConfig'
1111
import './compileLangMC'
12-
import './exporters/statueExporter'
13-
import './exporters/animationExporter'
12+
import './exporters/vanillaStatue'
13+
import './exporters/vanillaAnimation'
14+
import './exporters/rawAnimation'
1415
import './bbmods/modelFormatMod'
1516
import './bbmods/faceTint'
1617
import './util/minecraft/items'
@@ -146,6 +147,17 @@ export interface Settings {
146147
verbose: boolean
147148
}
148149

150+
export interface ExportData {
151+
settings: GlobalSettings
152+
cubeData: CubeData
153+
bones: BoneObject
154+
models: ModelObject
155+
variantTextureOverrides: VariantTextureOverrides
156+
variantModels: VariantModels
157+
variantTouchedModels: variantTouchedModels
158+
animations: Animations
159+
}
160+
149161
export interface GlobalSettings {
150162
animatedJava: Settings
151163
[index: string]: any

src/bbmods/modelFormatMod.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ ModelFormat.prototype.convertTo = function convertTo() {
154154
Canvas.updateAllBones()
155155
Canvas.updateAllFaces()
156156
updateSelection()
157-
157+
158158
// Mark the project as unsaved, so the user can save it and preserve the conversion
159-
Project.saved = false;
160-
159+
Project.saved = false
160+
161161
// Hacky method to refresh the top bar and make the custom tab menu appear without reopening the project
162162
Interface.tab_bar.openNewTab()
163163
ModelProject.all[0].select()

src/exporters/rawAnimation.ts

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import type * as aj from '../animatedJava'
2+
import { CustomError } from '../util/customError'
3+
import { store } from '../util/store'
4+
5+
interface rawAnimationExporterSettings {
6+
outputJsonPath: string
7+
}
8+
9+
function rawExport(exportData: aj.ExportData) {
10+
const ajSettings = exportData.settings.animatedJava
11+
const exporterSettings = exportData.settings
12+
.rawAnimationExporter as rawAnimationExporterSettings
13+
14+
const FILE = {
15+
meta: {
16+
head_item: ajSettings.rigItem,
17+
},
18+
animations: exportData.animations,
19+
}
20+
21+
if (!exporterSettings.outputJsonPath) {
22+
throw new CustomError(
23+
'animatedJava.exporters.rawAnimation.dialogs.errors.outputJsonPath.title',
24+
{
25+
intentional: true,
26+
dialog: {
27+
id: 'animatedJava.exporters.rawAnimation.dialogs.errors.outputJsonPath',
28+
title: tl(
29+
'animatedJava.exporters.rawAnimation.dialogs.errors.outputJsonPath.title'
30+
),
31+
lines: [
32+
tl(
33+
'animatedJava.exporters.rawAnimation.dialogs.errors.outputJsonPath.body'
34+
),
35+
],
36+
width: 512,
37+
singleButton: true,
38+
},
39+
}
40+
)
41+
}
42+
43+
Blockbench.writeFile(exporterSettings.outputJsonPath, {
44+
content: JSON.stringify(FILE, null, '\t'),
45+
custom_writer: null,
46+
})
47+
}
48+
49+
const genericEmptySettingText = tl(
50+
'animatedJava.settings.generic.errors.emptyValue'
51+
)
52+
53+
const Exporter = (AJ: any) => {
54+
AJ.settings.registerPluginSettings(
55+
'animatedJava.exporters.rawAnimation', // Exporter ID
56+
'rawAnimationExporter', // Exporter Settings Key
57+
{
58+
outputJsonPath: {
59+
title: tl(
60+
'animatedJava.exporters.rawAnimation.settings.outputJson.title'
61+
),
62+
description: tl(
63+
'animatedJava.exporters.rawAnimations.settings.outputJson.description'
64+
),
65+
type: 'filepath',
66+
default: '',
67+
optional: true,
68+
props: {
69+
dialogOpts: {
70+
get defaultPath() {
71+
return `output.json`
72+
},
73+
promptToCreate: true,
74+
properties: ['openFile'],
75+
},
76+
},
77+
onUpdate(d: aj.SettingDescriptor) {
78+
if (d.value === '') {
79+
d.isValid = false
80+
d.error = genericEmptySettingText
81+
}
82+
return d
83+
},
84+
},
85+
}
86+
)
87+
AJ.registerExportFunc('rawAnimationExporter', function () {
88+
AJ.build(
89+
(exportData: aj.ExportData) => {
90+
console.log('Input Data:', exportData)
91+
rawExport(exportData)
92+
},
93+
{
94+
generate_static_animation: true,
95+
}
96+
)
97+
})
98+
}
99+
100+
if (Reflect.has(window, 'ANIMATED_JAVA')) {
101+
Exporter(window['ANIMATED_JAVA'])
102+
} else {
103+
// @ts-ignore
104+
Blockbench.on('animated-java-ready', Exporter)
105+
}

src/exporters/animationExporter.ts renamed to src/exporters/vanillaAnimation.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -983,11 +983,17 @@ async function createMCFile(
983983
}
984984
case 'leaf':
985985
const pos = getPos(boneName, item)
986-
const nextFrame = getFrame(boneName, item.index+1)
986+
const nextFrame = getFrame(
987+
boneName,
988+
item.index + 1
989+
)
987990
if (isEqualVector(pos, lastPos)) {
988991
// Ignore deduplication if next frame is different value
989-
if (nextFrame && isEqualVector(pos, nextFrame.pos))
990-
return { v: '', trimmed: true }
992+
if (
993+
nextFrame &&
994+
isEqualVector(pos, nextFrame.pos)
995+
)
996+
return { v: '', trimmed: true }
991997
}
992998
lastPos = pos
993999
return {
@@ -1037,11 +1043,17 @@ async function createMCFile(
10371043
}
10381044
case 'leaf':
10391045
const rot = getRot(boneName, item)
1040-
const nextFrame = getFrame(boneName, item.index+1)
1046+
const nextFrame = getFrame(
1047+
boneName,
1048+
item.index + 1
1049+
)
10411050
if (isEqualVector(rot, lastRot)) {
10421051
// Ignore deduplication if next frame is different value
1043-
if (nextFrame && isEqualVector(rot, nextFrame.rot))
1044-
return { v: '', trimmed: true }
1052+
if (
1053+
nextFrame &&
1054+
isEqualVector(rot, nextFrame.rot)
1055+
)
1056+
return { v: '', trimmed: true }
10451057
}
10461058
lastRot = rot
10471059
return {

src/exporters/statueExporter.ts renamed to src/exporters/vanillaStatue.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,7 @@ const Exporter = (AJ: any) => {
813813
return d
814814
},
815815
isVisible(settings: any) {
816-
return (
817-
settings.vanillaStatueExporter
818-
.exportMode === 'mcb'
819-
)
816+
return settings.vanillaStatueExporter.exportMode === 'mcb'
820817
},
821818
dependencies: [
822819
'vanillaStatueExporter.exportMode',
@@ -849,14 +846,9 @@ const Exporter = (AJ: any) => {
849846
return value == '' || value.endsWith('config.json')
850847
},
851848
isVisible(settings: any) {
852-
return (
853-
settings.vanillaStatueExporter
854-
.exportMode === 'mcb'
855-
)
849+
return settings.vanillaStatueExporter.exportMode === 'mcb'
856850
},
857-
dependencies: [
858-
'vanillaStatueExporter.exportMode',
859-
],
851+
dependencies: ['vanillaStatueExporter.exportMode'],
860852
},
861853
dataPackPath: {
862854
title: tl(
@@ -886,13 +878,10 @@ const Exporter = (AJ: any) => {
886878
},
887879
isVisible(settings: any) {
888880
return (
889-
settings.vanillaStatueExporter
890-
.exportMode === 'vanilla'
881+
settings.vanillaStatueExporter.exportMode === 'vanilla'
891882
)
892883
},
893-
dependencies: [
894-
'vanillaStatueExporter.exportMode',
895-
],
884+
dependencies: ['vanillaStatueExporter.exportMode'],
896885
},
897886
}
898887
)

0 commit comments

Comments
 (0)