Skip to content

Commit cc364a7

Browse files
committed
🎉 Versioned Exporting
Allow the user to select a specific Minecraft version to target when exporting. # Changes - Created versioned data pack and resource pack compilers. - Added a Target Minecraft Version blueprint setting. - Added support for Minecraft 1.20.4. - Added support for Minecraft 1.20.5. - Added support for Minecraft 1.21.2. # Fixes - Fixed "default is not defined" error when attempting to export a newly converted blueprint. - Disabled broken zip export modes (will re-enable when fixed). - Fixed missing default values in locator config UI. - Fixed bone config types to ensure they're considered optional. - Updated the packager ESBuild plugin to only copy over prod builds.
1 parent e8d74d3 commit cc364a7

25 files changed

+2798
-118
lines changed

src/blockbenchTypeMods.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { blueprintSettingErrors, defaultValues } from './blueprintSettings'
88
import { openExportProgressDialog } from './interface/exportProgressDialog'
99
import { openUnexpectedErrorDialog } from './interface/unexpectedErrorDialog'
1010
import { TextDisplay } from './outliner/textDisplay'
11-
import { compileDataPack } from './systems/datapackCompiler'
12-
import { compileResourcePack } from './systems/resourcepackCompiler'
11+
import datapackCompiler from './systems/datapackCompiler'
12+
import resourcepackCompiler from './systems/resourcepackCompiler'
1313
import { MINECRAFT_REGISTRY } from './systems/minecraft/registryManager'
1414
import { isDataPackPath, isResourcePackPath } from './util/minecraftUtil'
1515
import { Valuable } from './util/stores'
@@ -87,8 +87,8 @@ declare global {
8787

8888
const AnimatedJava: {
8989
API: {
90-
compileDataPack: typeof compileDataPack
91-
compileResourcePack: typeof compileResourcePack
90+
compileDataPack: typeof datapackCompiler
91+
compileResourcePack: typeof resourcepackCompiler
9292
Variant: typeof Variant
9393
MINECRAFT_REGISTRY: typeof MINECRAFT_REGISTRY
9494
openExportProgressDialog: typeof openExportProgressDialog

src/blueprintSettings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { type MinecraftVersion } from './systems/datapackCompiler/mcbFiles'
12
import { Valuable } from './util/stores'
23

34
export type ExportMode = 'raw' | 'zip' | 'none'
@@ -11,6 +12,7 @@ export const defaultValues = {
1112
enable_plugin_mode: false,
1213
resource_pack_export_mode: 'raw' as ExportMode,
1314
data_pack_export_mode: 'raw' as ExportMode,
15+
target_minecraft_version: '1.21.2' as MinecraftVersion,
1416
// Resource Pack Settings
1517
display_item: 'minecraft:white_dye',
1618
custom_model_data_offset: 0,

src/components/blueprintSettingsDialog.svelte

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
<script lang="ts">
3535
import { defaultValues } from '../blueprintSettings'
36+
import mcbFiles from '../systems/datapackCompiler/mcbFiles'
3637
3738
export let blueprintName: Valuable<string>
3839
export let textureSizeX: Valuable<number>
@@ -42,6 +43,7 @@
4243
export let enablePluginMode: Valuable<boolean>
4344
export let resourcePackExportMode: Valuable<string>
4445
export let dataPackExportMode: Valuable<string>
46+
export let targetMinecraftVersion: Valuable<string>
4547
// Bounding Box
4648
export let showBoundingBox: Valuable<boolean>
4749
export let autoBoundingBox: Valuable<boolean>
@@ -560,12 +562,20 @@
560562
valueChecker={jsonFileChecker}
561563
/>
562564
{:else}
565+
<Select
566+
label={translate('dialog.blueprint_settings.target_minecraft_version.title')}
567+
tooltip={translate('dialog.blueprint_settings.target_minecraft_version.description')}
568+
options={Object.fromEntries(Object.keys(mcbFiles).map(v => [v, v]))}
569+
defaultOption={Object.keys(mcbFiles).at(-1) || '1.21.1'}
570+
bind:value={targetMinecraftVersion}
571+
/>
572+
563573
<Select
564574
label={translate('dialog.blueprint_settings.resource_pack_export_mode.title')}
565575
tooltip={translate('dialog.blueprint_settings.resource_pack_export_mode.description')}
566576
options={{
567577
raw: translate('dialog.blueprint_settings.resource_pack_export_mode.options.raw'),
568-
zip: translate('dialog.blueprint_settings.resource_pack_export_mode.options.zip'),
578+
// zip: translate('dialog.blueprint_settings.resource_pack_export_mode.options.zip'),
569579
none: translate('dialog.blueprint_settings.resource_pack_export_mode.options.none'),
570580
}}
571581
defaultOption={'raw'}
@@ -577,7 +587,7 @@
577587
tooltip={translate('dialog.blueprint_settings.data_pack_export_mode.description')}
578588
options={{
579589
raw: translate('dialog.blueprint_settings.data_pack_export_mode.options.raw'),
580-
zip: translate('dialog.blueprint_settings.data_pack_export_mode.options.zip'),
590+
// zip: translate('dialog.blueprint_settings.data_pack_export_mode.options.zip'),
581591
none: translate('dialog.blueprint_settings.data_pack_export_mode.options.none'),
582592
}}
583593
defaultOption={'raw'}

src/components/locatorConfigDialog.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
label={translate('dialog.locator_config.use_entity.title')}
4848
tooltip={translate('dialog.locator_config.use_entity.description')}
4949
bind:checked={useEntity}
50+
defaultValue={false}
5051
/>
5152

5253
{#if $useEntity}
@@ -55,19 +56,22 @@
5556
tooltip={translate('dialog.locator_config.entity_type.description')}
5657
bind:value={entityType}
5758
valueChecker={entityTypeValidator}
59+
defaultValue="minecraft:item_display"
5860
/>
5961

6062
<CodeInput
6163
label={translate('dialog.locator_config.summon_commands.title')}
6264
tooltip={translate('dialog.locator_config.summon_commands.description')}
6365
bind:value={summonCommands}
66+
defaultValue=""
6467
/>
6568
{/if}
6669

6770
<CodeInput
6871
label={translate('dialog.locator_config.ticking_commands.title')}
6972
tooltip={translate('dialog.locator_config.ticking_commands.description')}
7073
bind:value={tickingCommands}
74+
defaultValue=""
7175
/>
7276
{/if}
7377
</div>

src/index.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import './outliner/textDisplay'
1212
import './outliner/vanillaItemDisplay'
1313
import './outliner/vanillaBlockDisplay'
1414
// Compilers
15-
import { compileDataPack } from './systems/datapackCompiler'
15+
import datapackCompiler from './systems/datapackCompiler'
1616
// Minecraft Systems
1717
import './systems/minecraft/versionManager'
1818
import './systems/minecraft/registryManager'
@@ -23,19 +23,14 @@ import './systems/minecraft/fontManager'
2323
import { TRANSPARENT_TEXTURE, Variant } from './variants'
2424
import './systems/minecraft/registryManager'
2525
import { MINECRAFT_REGISTRY } from './systems/minecraft/registryManager'
26-
import { compileResourcePack } from './systems/resourcepackCompiler'
26+
import resourcepackCompiler from './systems/resourcepackCompiler'
2727
import { openExportProgressDialog } from './interface/exportProgressDialog'
28-
import { isDataPackPath, isResourcePackPath } from './util/minecraftUtil'
28+
import { isDataPackPath, isResourcePackPath, parseResourcePackPath } from './util/minecraftUtil'
2929
import { blueprintSettingErrors } from './blueprintSettings'
3030
import { openUnexpectedErrorDialog } from './interface/unexpectedErrorDialog'
3131
import { BLUEPRINT_CODEC, BLUEPRINT_FORMAT } from './blueprintFormat'
3232
import { TextDisplay } from './outliner/textDisplay'
3333
import { getLatestVersionClientDownloadUrl } from './systems/minecraft/assetManager'
34-
import {
35-
hideLoadingPopup,
36-
showLoadingPopup,
37-
showOfflineError,
38-
} from './interface/animatedJavaLoadingPopup'
3934
import { getVanillaFont } from './systems/minecraft/fontManager'
4035
import * as assetManager from './systems/minecraft/assetManager'
4136
import * as itemModelManager from './systems/minecraft/itemModelManager'
@@ -46,13 +41,13 @@ import { BLOCKSTATE_REGISTRY } from './systems/minecraft/blockstateManager'
4641
import { exportProject } from './systems/exporter'
4742
import { openBlueprintLoadingDialog } from './interface/blueprintLoadingPopup'
4843
import { openInstallPopup } from './interface/installedPopup'
49-
import { createBlockbenchMod } from './util/moddingTools'
5044

5145
// @ts-ignore
5246
globalThis.AnimatedJava = {
5347
API: {
54-
compileDataPack,
55-
compileResourcePack,
48+
parseResourcePackPath,
49+
datapackCompiler,
50+
resourcepackCompiler,
5651
Variant,
5752
MINECRAFT_REGISTRY,
5853
openExportProgressDialog,

src/interface/blueprintSettingsDialog.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { toSafeFuntionName } from '../util/minecraftUtil'
66
import { defaultValues, ExportMode } from '../blueprintSettings'
77
import { translate } from '../util/translation'
88
import { updateBoundingBox } from '../blueprintFormat'
9+
import { MinecraftVersion } from '../systems/datapackCompiler/mcbFiles'
910

1011
function getSettings() {
1112
return {
@@ -33,6 +34,9 @@ function getSettings() {
3334
Project!.animated_java.resource_pack_export_mode as string
3435
),
3536
dataPackExportMode: new Valuable(Project!.animated_java.data_pack_export_mode as string),
37+
targetMinecraftVersion: new Valuable(
38+
Project!.animated_java.target_minecraft_version as string
39+
),
3640
// Resource Pack Settings
3741
displayItem: new Valuable(Project!.animated_java.display_item, value => {
3842
if (!value) {
@@ -86,6 +90,8 @@ function setSettings(settings: ReturnType<typeof getSettings>) {
8690
Project.animated_java.resource_pack_export_mode =
8791
settings.resourcePackExportMode.get() as ExportMode
8892
Project.animated_java.data_pack_export_mode = settings.dataPackExportMode.get() as ExportMode
93+
Project.animated_java.target_minecraft_version =
94+
settings.targetMinecraftVersion.get() as MinecraftVersion
8995
// Resource Pack Settings
9096
Project.animated_java.display_item = settings.displayItem.get()
9197
Project.animated_java.custom_model_data_offset = settings.customModelDataOffset.get()

src/lang/en.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ animated_java.dialog.blueprint_settings.auto_bounding_box.description: |-
9191
animated_java.dialog.blueprint_settings.bounding_box.title: Bounding Box
9292
animated_java.dialog.blueprint_settings.bounding_box.description: Determines the culling box of the model. The model will stop rendering when this box is off-screen.
9393

94+
animated_java.dialog.blueprint_settings.target_minecraft_version.title: Target Minecraft Version
95+
animated_java.dialog.blueprint_settings.target_minecraft_version.description: The version of Minecraft to target when exporting the project. This will determine the format of the exported Resource Pack and Data Pack.
96+
9497
# Resource Pack Settings
9598
animated_java.dialog.blueprint_settings.resource_pack_settings.title: Resource Pack Settings
9699

0 commit comments

Comments
 (0)