Skip to content

Commit 179e8ec

Browse files
committed
Data Pack Exporter fixes
1 parent 5b47ad0 commit 179e8ec

File tree

6 files changed

+50
-25
lines changed

6 files changed

+50
-25
lines changed

exporters/datapackExporter/exporter/datapackGen/animatedJavaFolderGen.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { type ExportData } from '../datapackGen'
21
import { loadAnimationTreeGenerator } from './animationTreeGen'
32
import { Globals as G } from './globals'
43

@@ -50,7 +49,6 @@ export function generateAnimatedJavaFolder() {
5049
G.OUTDATED_RIG_WARNING_ENABLED
5150
? `execute unless score @s ${G.SCOREBOARD.exportVersion} = ${G.SCOREBOARD.exportVersion} ${G.SCOREBOARD.i} at @s run function ${G.AJ_NAMESPACE}:upgrade_rig`
5251
: undefined,
53-
`function #${G.NAMESPACE}:on_load`,
5452
])
5553
// ANCHOR - func AJ_NAMESPACE:tick
5654
.chainNewFile('tick.mcfunction', [

exporters/datapackExporter/exporter/datapackGen/globals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class Globals {
4141
Object.keys(rig.nodeMap).length === 1 && renderedAnimations.length === 0
4242
Globals.DEFAULT_INTERPOLATION_DURATION = exporterSettings.interpolation_duration.value
4343

44-
Globals.DATAPACK = new VirtualFileSystem.VirtualFolder(Globals.NAMESPACE)
44+
Globals.DATAPACK = new VirtualFileSystem.VirtualFolder('virtual_datapack')
4545
Globals.DATA_FOLDER = Globals.DATAPACK.newFolder('data')
4646
Globals.MINECRAFT_FOLDER = Globals.DATA_FOLDER.newFolder('minecraft')
4747

src/exporter/resourcePackExporter.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,23 @@ export async function exportResources(
7272
rigs: {},
7373
},
7474
}
75-
const predicateItemFile = minecraftFolder.newFile(`${rigItemName}.json`, content)
75+
const predicateItemFile = minecraftFolder.newFile(
76+
`${rigItemName}.json`,
77+
content,
78+
// TODO
79+
(oldContent, newContent) => {
80+
console.log('Merging predicate file...', oldContent, newContent)
81+
if (!oldContent.animated_java) {
82+
showPredicateFileOverwriteConfirmation(predicateItemFilePath)
83+
oldContent.animated_java = {
84+
rigs: {
85+
[projectNamespace]: { used_ids: [] },
86+
},
87+
}
88+
}
89+
return newContent as unknown
90+
}
91+
)
7692
let successfullyReadPredicateItemFile = false
7793
if (fs.existsSync(predicateItemFilePath)) {
7894
const stringContent = await fs.promises.readFile(predicateItemFilePath, 'utf8')

src/projectSettings.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,15 @@ export const projectSettingStructure: GUIStructure = [
428428
],
429429
},
430430
{
431-
type: 'setting',
432-
settingId: _.exporter.id,
431+
type: 'group',
432+
title: translate('animated_java.project_settings.exporter_group'),
433+
openByDefault: true,
434+
children: [
435+
{
436+
type: 'setting',
437+
settingId: _.exporter.id,
438+
},
439+
],
433440
},
434441
]
435442

src/rendering/animationRenderer.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export function restoreSceneAngle() {
1616
function getNodeMatrix(node: OutlinerElement, scale: number) {
1717
const matrixWorld = node.mesh.matrixWorld.clone()
1818
matrixWorld.setPosition(
19-
new THREE.Vector3().setFromMatrixPosition(matrixWorld).multiplyScalar(1 / 16)
19+
new THREE.Vector3()
20+
.setFromMatrixPosition(matrixWorld)
21+
.multiplyScalar(1 / 16)
22+
.multiply(new THREE.Vector3(-1, 1, -1))
2023
)
2124
matrixWorld.scale(new THREE.Vector3().setScalar(scale))
2225
return matrixWorld
@@ -34,24 +37,26 @@ export interface IAnimationNode {
3437
interpolation?: 'instant' | 'default'
3538
}
3639

40+
export interface IRenderedFrame {
41+
time: number
42+
nodes: IAnimationNode[]
43+
variant?: {
44+
uuid: string
45+
executeCondition: string
46+
}
47+
commands?: {
48+
commands: string
49+
executeCondition: string
50+
}
51+
animationState?: {
52+
animation: string
53+
executeCondition: string
54+
}
55+
}
56+
3757
export interface IRenderedAnimation {
3858
name: string
39-
frames: Array<{
40-
time: number
41-
nodes: IAnimationNode[]
42-
variant?: {
43-
uuid: string
44-
executeCondition: string
45-
}
46-
commands?: {
47-
commands: string
48-
executeCondition: string
49-
}
50-
animationState?: {
51-
animation: string
52-
executeCondition: string
53-
}
54-
}>
59+
frames: IRenderedFrame[]
5560
/**
5661
* Duration of the animation in ticks (AKA frames). Same as animation.frames.length
5762
*/
@@ -111,7 +116,7 @@ export function getAnimationNodes(
111116
const parentRotation = new THREE.Quaternion().setFromRotationMatrix(
112117
parentMatrix
113118
)
114-
console.log(matrix, parentRotation)
119+
// console.log(matrix, parentRotation)
115120
matrix.makeRotationFromQuaternion(parentRotation)
116121
}
117122
break

src/rendering/modelRenderer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ function renderCube(cube: Cube, rig: IRenderedRig, model: IRenderedModel) {
199199
rescale: true,
200200
}
201201
}
202-
console.log(cube.rotation, element)
203202

204203
if (cube.parent instanceof Group) {
205204
const parent = cube.parent

0 commit comments

Comments
 (0)