Skip to content

Commit 5482374

Browse files
committed
🛠️ Improved issue in #222
1 parent 127d0a7 commit 5482374

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/mods/bonePropertiesMod.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,29 @@ import { PACKAGE } from '../constants'
33
import { roundToNth } from '../util/misc'
44
import { type ContextProperty, createBlockbenchMod } from '../util/moddingTools'
55

6+
class DeepClonedObjectProperty extends Property<'object'> {
7+
constructor(targetClass: any, name: string, options?: PropertyOptions) {
8+
super(targetClass, 'object', name, options)
9+
}
10+
merge(instance: any, data: any) {
11+
if (typeof data[this.name] === 'object') {
12+
instance[this.name] = JSON.parse(JSON.stringify(data[this.name]))
13+
}
14+
}
15+
copy(instance: any, target: any) {
16+
if (typeof instance[this.name] === 'object') {
17+
target[this.name] = JSON.parse(JSON.stringify(instance[this.name]))
18+
}
19+
}
20+
}
21+
622
createBlockbenchMod(
723
`${PACKAGE.name}:boneProperties`,
824
{
9-
configs: undefined as ContextProperty<'instance'>,
25+
configs: undefined as ContextProperty<'object'>,
1026
},
1127
context => {
12-
context.configs = new Property(Group, 'instance', 'configs', {
28+
context.configs = new DeepClonedObjectProperty(Group, 'configs', {
1329
condition,
1430
default: { default: undefined, variants: {} },
1531
})

0 commit comments

Comments
 (0)