Skip to content

Commit f3e3a0c

Browse files
committed
Merge branch 'experimental' of https://github.com/Animated-Java/animated-java into experimental
2 parents 8491c2d + 88adb3e commit f3e3a0c

File tree

6 files changed

+54
-48
lines changed

6 files changed

+54
-48
lines changed

debug_resourcepack/armor_stand.ajmodel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"meta": {
33
"format_version": "0.0",
4-
"creation_time": 1641766217,
4+
"creation_time": 1641769747,
55
"model_format": "animated_java/ajmodel",
66
"box_uv": false,
77
"settings": {
88
"animatedJava": {
99
"projectName": "armor_stand",
10-
"exporter": "animationExporter",
10+
"exporter": "vanillaAnimationExporter",
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",
@@ -33,7 +33,7 @@
3333
"vanillaAnimationExporter": {
3434
"rootEntityType": "minecraft:marker",
3535
"rootEntityNbt": "{}",
36-
"markerArmorStands": true,
36+
"markerArmorStands": false,
3737
"autoDistance": true,
3838
"autoDistanceMovementThreshold": 1,
3939
"manualDistance": 10,

src/exporters/animationExporter.ts

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import { CustomError } from '../util/customError'
1212
import { JsonText } from '../util/minecraft/jsonText'
1313
import { Entities } from '../util/minecraft/entities'
1414
import { SNBT, SNBTTag, SNBTTagType } from '../util/SNBT'
15-
import { safeFunctionName, format, fixIndent } from '../util/replace'
15+
import {
16+
safeFunctionName,
17+
format,
18+
fixIndent,
19+
safeEntityTag,
20+
} from '../util/replace'
1621

1722
interface vanillaAnimationExporterSettings {
1823
allBonesTag: string
@@ -1260,8 +1265,14 @@ function validateFormattedStringSetting(required: string[]) {
12601265
notFound,
12611266
}
12621267
)
1268+
return d
12631269
}
12641270
}
1271+
const formattedValue = format(d.value, Object.fromEntries(required.map(v => [v.replace('%', ''),'replaced'])))
1272+
if (formattedValue !== safeEntityTag(formattedValue)) {
1273+
d.isValid = false
1274+
d.error = tl('animatedJava.settings.generic.errors.invalidEntityTag')
1275+
}
12651276
return d
12661277
}
12671278
}
@@ -1361,18 +1372,15 @@ const Exporter = (AJ: any) => {
13611372
if (!(d.value >= 0)) {
13621373
d.isValid = false
13631374
d.error = tl(
1364-
'animatedJava.exporters.generic.settings.autoDistanceThreshold.errors.valueOutOfRange'
1375+
'animatedJava.exporters.vanillaAnimation.settings.autoDistanceMovementThreshold.errors.valueOutOfRange'
13651376
)
13661377
}
13671378
return d
13681379
},
13691380
isVisible(settings: any) {
1370-
return settings.vanillaAnimationExporter
1371-
.autoDistance
1381+
return settings.vanillaAnimationExporter.autoDistance
13721382
},
1373-
dependencies: [
1374-
'vanillaAnimationExporter.autoDistance',
1375-
],
1383+
dependencies: ['vanillaAnimationExporter.autoDistance'],
13761384
},
13771385
manualDistance: {
13781386
title: tl(
@@ -1387,18 +1395,15 @@ const Exporter = (AJ: any) => {
13871395
if (!(d.value >= 0)) {
13881396
d.isValid = false
13891397
d.error = tl(
1390-
'animatedJava.exporters.generic.settings.manualDistance.errors.valueOutOfRange'
1398+
'animatedJava.exporters.vanillaAnimation.settings.manualDistance.errors.valueOutOfRange'
13911399
)
13921400
}
13931401
return d
13941402
},
13951403
isVisible(settings: any) {
1396-
return !settings.vanillaAnimationExporter
1397-
.autoDistance
1404+
return !settings.vanillaAnimationExporter.autoDistance
13981405
},
1399-
dependencies: [
1400-
'vanillaAnimationExporter.autoDistance',
1401-
],
1406+
dependencies: ['vanillaAnimationExporter.autoDistance'],
14021407
},
14031408
modelTag: {
14041409
title: tl(
@@ -1587,8 +1592,7 @@ const Exporter = (AJ: any) => {
15871592
},
15881593
isVisible(settings: any) {
15891594
return (
1590-
settings.vanillaAnimationExporter
1591-
.exportMode === 'mcb'
1595+
settings.vanillaAnimationExporter.exportMode === 'mcb'
15921596
)
15931597
},
15941598
dependencies: [
@@ -1623,13 +1627,10 @@ const Exporter = (AJ: any) => {
16231627
},
16241628
isVisible(settings: any) {
16251629
return (
1626-
settings.vanillaAnimationExporter
1627-
.exportMode === 'mcb'
1630+
settings.vanillaAnimationExporter.exportMode === 'mcb'
16281631
)
16291632
},
1630-
dependencies: [
1631-
'vanillaAnimationExporter.exportMode',
1632-
],
1633+
dependencies: ['vanillaAnimationExporter.exportMode'],
16331634
},
16341635
dataPackPath: {
16351636
title: tl(
@@ -1659,17 +1660,15 @@ const Exporter = (AJ: any) => {
16591660
},
16601661
isVisible(settings: any) {
16611662
return (
1662-
settings.vanillaAnimationExporter
1663-
.exportMode === 'vanilla'
1663+
settings.vanillaAnimationExporter.exportMode ===
1664+
'vanilla'
16641665
)
16651666
},
1666-
dependencies: [
1667-
'vanillaAnimationExporter.exportMode',
1668-
],
1667+
dependencies: ['vanillaAnimationExporter.exportMode'],
16691668
},
16701669
}
16711670
)
1672-
AJ.registerExportFunc('animationExporter', function () {
1671+
AJ.registerExportFunc('vanillaAnimationExporter', function () {
16731672
AJ.build(
16741673
(data: any) => {
16751674
console.log('Input Data:', data)

src/exporters/statueExporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ const Exporter = (AJ: any) => {
886886
},
887887
}
888888
)
889-
AJ.registerExportFunc('statueExporter', function () {
889+
AJ.registerExportFunc('vanillaStatueExporter', function () {
890890
AJ.build(
891891
(data: any) => {
892892
console.log('Input Data:', data)

src/lang/en.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,25 @@ animatedJava:
3535
generic:
3636
errors:
3737
invalid: If you're seeing this message Animated Java broke. (Uh Oh)
38-
emptyValue: Setting cannot be empty
39-
mustBeBoolean: Setting value must be a boolean
40-
mustBeString: Setting value must be a string
41-
missingFormatString: Setting value missing required %notFound formatting string
38+
emptyValue: Value cannot be empty
39+
mustBeBoolean: Value must be a boolean
40+
mustBeString: Value must be a string
41+
missingFormatString: Value missing required %notFound formatting string
42+
invalidEntityTag: Value is not a valid entity tag
4243

4344
projectName:
4445
title: Project Name
4546
description:
4647
- The unique ID of your project. Make sure you set this!
4748
errors:
48-
invalidFunctionName: TL:animatedJava.settings.projectName.errors.invalidFunctionName
49+
invalidFunctionName: Project name must be a valid function name!
4950

5051
exporter:
5152
title: Exporter
5253
description:
5354
- Which export format to use for this project
5455
errors:
55-
mustBeValidExporter: TL:animatedJava.settings.exporter.errors.mustBeValidExporter
56+
mustBeValidExporter: Selected exporter does not exist in the registered exporters!
5657

5758
verbose:
5859
title: Verbose
@@ -65,28 +66,28 @@ animatedJava:
6566
description:
6667
- The item that will be used to display the models on the armor_stands
6768
errors:
68-
invalidMinecraftItem: TL:animatedJava.settings.rigItem.errors.invalidItem
69+
invalidMinecraftItem: Chosen item does not exist!
6970

7071
rigModelsExportFolder:
7172
title: Rig Models Export Folder
7273
description:
7374
- The folder that all of the rig's models will be dumped into
7475
errors:
75-
invalidPath: TL:animatedJava.settings.rigModelsExportFolder.errors.invalidPath
76+
invalidPath: Chosen path is not a valid location to export models to!
7677

7778
predicateFilePath:
7879
title: Rig Item Predicate Model
7980
description:
8081
- The item model file of the rig item
8182
errors:
82-
notEqualToRigItem: TL:animatedJava.settings.predicateFilePath.errors.notEqualToRigItem
83+
notEqualToRigItem: Path must end on a file named %rigItem.json
8384

8485
transparentTexturePath:
8586
title: Transparent Texture Path
8687
description:
8788
- A transparent texture for adding transparency to variants. Only needed if you're using transparency in your variants.
8889
errors:
89-
undefinedWhenNeeded: TL:animatedJava.settings.transparentTexturePath.errors.undefinedWhenNeeded
90+
undefinedWhenNeeded: Path must be defined if you're using the transparency feature of variants!
9091

9192
useCache:
9293
title: Use Animation Cache
@@ -275,14 +276,14 @@ animatedJava:
275276
description:
276277
- The entity type to use as the root entity for the model
277278
errors:
278-
invalidEntity: TL:animatedJava.exporters.generic.settings.rootEntityType.errors.invalidEntity
279+
invalidEntity: Chosen entity does not exist!
279280

280281
rootEntityNbt:
281282
title: Root Entity NBT
282283
description:
283284
- The NBT data of the root entity
284285
errors:
285-
invalidNbt: TL:animatedJava.exporters.generic.settings.rootEntityType.errors.invalidNbt
286+
invalidNbt: Invalid NBT!
286287

287288
markerArmorStands:
288289
title: Marker Armor Stands
@@ -345,7 +346,7 @@ animatedJava:
345346
- Exports the default MCB config for Animated Java
346347
- WARNING! Will overwrite existing config.json
347348
errors:
348-
mustBeNamedAfterProject: TL:animatedJava.exporters.generic.settings.mcbFilePath.errors.mustBeNamedAfterProject
349+
mustBeNamedAfterProject: Path must end on a file named %projectName.mc!
349350

350351
dataPackPath:
351352
title: Data Pack
@@ -384,15 +385,15 @@ animatedJava:
384385
- How much distance to add to the calculated animation distance.
385386
- The more distance you add the farther you can move the rig in a single tick without dropping bones
386387
errors:
387-
valueOutOfRange: TL:animatedJava.exporters.generic.settings.autoDistanceThreshold.errors.valueOutOfRange
388+
valueOutOfRange: Setting value must be at least 0
388389

389390
manualDistance:
390391
title: Manual Animation Distance
391392
description:
392393
- How far away a bone can be from the root entity before it stops animating.
393394
- This setting is intended for advanced users.
394395
errors:
395-
valueOutOfRange: TL:animatedJava.exporters.generic.settings.manualDistance.errors.valueOutOfRange
396+
valueOutOfRange: Setting value must be at least 0
396397

397398
frameScoreboardObjective:
398399
title: Frame Scoreboard

src/settings.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const DefaultSettings = {
5151
return Object.fromEntries(
5252
[...store.getStore('exporters').keys()].map((v) => [
5353
v,
54-
`animatedJava.exporters.${v}.title`,
54+
ForeignSettingTranslationKeys[v],
5555
])
5656
)
5757
},
@@ -185,7 +185,9 @@ export const DefaultSettings = {
185185
if (`${rigItem}.json` !== b.base) {
186186
d.isValid = false
187187
d.error = tl(
188-
'animatedJava.settings.predicateFilePath.errors.notEqualToRigItem'
188+
'animatedJava.settings.predicateFilePath.errors.notEqualToRigItem',{
189+
rigItem
190+
}
189191
)
190192
}
191193
} else {

src/util/replace.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ export function format(str: string, dict: FormatObject = {}) {
1010
}
1111

1212
export function safeFunctionName(s: string) {
13-
return s.toLowerCase().replace(/[^a-z0-9\._]/g, '_')
13+
return s.toLowerCase().replace(/[^\w\d\._]+/g, '_')
14+
}
15+
16+
export function safeEntityTag(s: string) {
17+
return s.replace(/[^\w\.\-+]+/g, '_')
1418
}
1519

1620
export function fixIndent(str: string[]) {

0 commit comments

Comments
 (0)