Skip to content

Commit 0080d33

Browse files
committed
Fix Data Pack Exporter refactor bugs
1 parent 638df19 commit 0080d33

File tree

6 files changed

+9
-11
lines changed

6 files changed

+9
-11
lines changed

exporters/datapackExporter/datapackExporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,6 @@ export function loadExporter() {
112112
settingId: 'animated_java:datapack_exporter/root_entity_nbt',
113113
},
114114
],
115-
export() {},
115+
export: loadDataPackGenerator() as any,
116116
})
117117
}

exporters/datapackExporter/exporter/datapackGen.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ import { Globals as G } from './datapackGen/globals'
88
type ExporterSettings = ReturnType<ReturnType<typeof loadExporter>['getSettings']>
99
export type ExportData = AnimatedJava.IAnimatedJavaExportData<ExporterSettings>
1010

11-
export interface DataPackContext {
12-
scoreboards: {}
13-
}
14-
1511
export function loadDataPackGenerator() {
1612
const { formatStr, ProgressBarController, ExpectedError, LimitClock } = AnimatedJava.API
1713
const { NbtTag, NbtCompound, NbtString, NbtList, NbtInt } = AnimatedJava.API.deepslate

exporters/datapackExporter/exporter/datapackGen/globals.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ExportData } from '../datapackGen'
22
import { getEntityTypes, getScoreboard, getTags, loopModes } from './data'
3+
import { loadTellrawMessages } from './tellrawMessages'
34

45
export class Globals {
56
static exportData: ExportData

exporters/datapackExporter/exporter/datapackGen/namespaceFolderGen.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ export function generateNamespaceFolder() {
165165
summonTags.add(new NbtString(G.TAGS.rootEntity))
166166
summonNbt.set('Tags', summonTags)
167167

168-
const variantSummonFolder = namespaceFolder
169-
.accessFolder('functions')
168+
const variantSummonFolder = functionsFolder
170169
// ANCHOR - function NAMESPACE:summon
171170
.chainNewFile('summon.mcfunction', [
172171
`summon minecraft:item_display ~ ~ ~ ${summonNbt.toString()}`,

exporters/datapackExporter/exporter/datapackGen/tellrawMessages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function loadTellrawMessages() {
1+
export function loadTellrawMessages() {
22
const { JsonText } = AnimatedJava.API
33

44
const errorMustBeRunAsRoot = new JsonText([

src/util/virtualFileSystem.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,15 @@ export class VirtualFolder extends VirtualNode {
164164
const parts = path.split('/')
165165
const name = parts[0]
166166
const child = this.children.find(
167-
child => child instanceof VirtualFile && child.fileName === name
167+
child =>
168+
(child instanceof VirtualFile && child.fileName === name) ||
169+
(child instanceof VirtualFolder && child.name === name)
168170
)
171+
if (!child) throw new Error(`No child named ${name} in ${this.path}`)
172+
if (child instanceof VirtualFolder) return child.accessFile(parts.slice(1).join('/'))
169173
if (!(child instanceof VirtualFile))
170174
throw new Error(`No file named ${name} in ${this.path}`)
171-
if (!child) throw new Error(`No child named ${name} in ${this.path}`)
172175
if (parts.length === 1) return child
173-
if (child instanceof VirtualFolder) return child.accessFile(parts.slice(1).join('/'))
174176
throw new Error(`Cannot access child of file ${this.path}/${name}`)
175177
}
176178

0 commit comments

Comments
 (0)