Skip to content

Commit f54f807

Browse files
committed
🚧 Improved version handling
1 parent 02b1860 commit f54f807

File tree

4 files changed

+46
-7
lines changed

4 files changed

+46
-7
lines changed

src/systems/datapackCompiler/index.ts

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ export default async function compileDataPack(options: {
794794
})
795795
)
796796

797+
type Formats = number | number[] | { min_inclusive: number; max_inclusive: number }
797798
interface IPackMeta {
798799
pack?: {
799800
pack_format?: number
@@ -802,7 +803,7 @@ export default async function compileDataPack(options: {
802803
overlays?: {
803804
entries?: Array<{
804805
directory?: string
805-
formats?: number | number[] | { min_inclusive: number; max_inclusive: number }
806+
formats?: Formats
806807
}>
807808
}
808809
}
@@ -823,14 +824,46 @@ export default async function compileDataPack(options: {
823824
packMeta.pack.description ??= `Animated Java Data Pack for ${aj.target_minecraft_version}`
824825
packMeta.overlays ??= {}
825826
packMeta.overlays.entries ??= []
827+
let formats: Formats
828+
switch (aj.target_minecraft_version) {
829+
case '1.20.5': {
830+
formats = {
831+
min_inclusive: getDataPackFormat('1.20.5'),
832+
max_inclusive: getDataPackFormat('1.21.0') - 1,
833+
}
834+
break
835+
}
836+
case '1.21.0': {
837+
formats = {
838+
min_inclusive: getDataPackFormat('1.21.0'),
839+
max_inclusive: getDataPackFormat('1.21.2') - 1,
840+
}
841+
break
842+
}
843+
case '1.21.2': {
844+
formats = {
845+
min_inclusive: getDataPackFormat('1.21.2'),
846+
max_inclusive: getDataPackFormat('1.21.4') - 1,
847+
}
848+
break
849+
}
850+
case '1.21.4': {
851+
formats = getDataPackFormat('1.21.4')
852+
break
853+
}
854+
default: {
855+
formats = getDataPackFormat(aj.target_minecraft_version)
856+
break
857+
}
858+
}
826859
const overlay = packMeta.overlays.entries.find(e => e.directory === 'animated_java')
827860
if (!overlay) {
828861
packMeta.overlays.entries.push({
829862
directory: 'animated_java',
830-
formats: getDataPackFormat(aj.target_minecraft_version),
863+
formats,
831864
})
832865
} else {
833-
overlay.formats = getDataPackFormat(aj.target_minecraft_version)
866+
overlay.formats = formats
834867
}
835868

836869
exportedFiles.set(PathModule.join(dataPackFolder, 'pack.mcmeta'), autoStringify(packMeta))

src/systems/resourcepackCompiler/1.21.4.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,5 +286,9 @@ function createMultiVariantItemDefinition(
286286
} as (typeof itemDefinition.model.cases)[0])
287287
}
288288

289+
if (itemDefinition.model.cases.length === 0) {
290+
return createSingleVariantItemDefinition(model)
291+
}
292+
289293
return itemDefinition
290294
}

src/util/minecraftUtil.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ export function getDataPackFormat(version: MinecraftVersion): number {
228228
return 48
229229
case '1.21.2':
230230
return 57
231+
case '1.21.4':
232+
return 61
231233
default:
232234
return Infinity
233235
}

test_blueprints/armor_stand.ajblueprint

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
"enable_plugin_mode": false,
1515
"resource_pack_export_mode": "raw",
1616
"data_pack_export_mode": "raw",
17-
"target_minecraft_version": "1.20.4",
17+
"target_minecraft_version": "1.21.4",
1818
"display_item": "minecraft:white_dye",
1919
"custom_model_data_offset": 0,
2020
"enable_advanced_resource_pack_settings": false,
2121
"enable_advanced_resource_pack_folders": false,
22-
"resource_pack": "C:\\Users\\SnaveSutit\\AppData\\Roaming\\.modrinth\\profiles\\AJ Tests 1.20.4\\resourcepacks\\resourcepack",
22+
"resource_pack": "C:\\Users\\SnaveSutit\\AppData\\Roaming\\.modrinth\\profiles\\Animated Java Dev\\resourcepacks\\resourcepack",
2323
"display_item_path": "",
2424
"model_folder": "",
2525
"texture_folder": "",
2626
"enable_advanced_data_pack_settings": false,
27-
"data_pack": "C:\\Users\\SnaveSutit\\AppData\\Roaming\\.modrinth\\profiles\\AJ Tests 1.20.4\\saves\\AJ Tests 1_21_4\\datapacks\\datapack",
27+
"data_pack": "C:\\Users\\SnaveSutit\\AppData\\Roaming\\.modrinth\\profiles\\Animated Java Dev\\saves\\Animated Java Dev\\datapacks\\datapack",
2828
"summon_commands": "",
2929
"ticking_commands": "",
3030
"interpolation_duration": 1,
@@ -1502,7 +1502,7 @@
15021502
"default": {
15031503
"name": "default",
15041504
"display_name": "Default",
1505-
"uuid": "b3c20335-1d42-762c-f9a7-2d7abaec2ece",
1505+
"uuid": "d08528a6-bb3d-0203-485d-1727f5ff2ff7",
15061506
"texture_map": {},
15071507
"excluded_nodes": [],
15081508
"is_default": true

0 commit comments

Comments
 (0)