Skip to content

Commit 5e7ae6d

Browse files
committed
✨ Add Sync Passenger Rotation Locator config option
This commit only contains UI and internal changes. The MCB file changes will be in a future commit
1 parent d6cd930 commit 5e7ae6d

File tree

5 files changed

+37
-10
lines changed

5 files changed

+37
-10
lines changed

src/blueprintFormat.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface IBlueprintBoneConfigJSON {
4444
export interface IBlueprintLocatorConfigJSON {
4545
use_entity?: LocatorConfig['useEntity']
4646
entity_type?: LocatorConfig['entityType']
47+
sync_passenger_rotation?: LocatorConfig['syncPassengerRotation']
4748
summon_commands?: LocatorConfig['_summonCommands']
4849
ticking_commands?: LocatorConfig['tickingCommands']
4950
}

src/components/locatorConfigDialog.svelte

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
<script lang="ts" , context="module">
2-
import CodeInput from './dialogItems/codeInput.svelte'
3-
import CheckBox from './dialogItems/checkbox.svelte'
4-
import LineInput from './dialogItems/lineInput.svelte'
1+
<script lang="ts">
2+
const pluginModeEnabled = !!Project?.animated_java?.enable_plugin_mode
53
4+
import { MINECRAFT_REGISTRY } from '../systems/minecraft/registryManager'
65
import { Valuable } from '../util/stores'
76
import { translate } from '../util/translation'
8-
import { MINECRAFT_REGISTRY } from '../systems/minecraft/registryManager'
9-
</script>
10-
11-
<script lang="ts">
12-
const pluginModeEnabled = !!Project?.animated_java?.enable_plugin_mode
7+
import CheckBox from './dialogItems/checkbox.svelte'
8+
import CodeInput from './dialogItems/codeInput.svelte'
9+
import LineInput from './dialogItems/lineInput.svelte'
1310
1411
export let useEntity: Valuable<boolean>
1512
export let entityType: Valuable<string>
13+
export let syncPassengerRotation: Valuable<boolean>
1614
export let summonCommands: Valuable<string>
1715
export let tickingCommands: Valuable<string>
1816
@@ -59,6 +57,13 @@
5957
defaultValue="minecraft:item_display"
6058
/>
6159

60+
<CheckBox
61+
label={translate('dialog.locator_config.sync_passenger_rotation.title')}
62+
tooltip={translate('dialog.locator_config.sync_passenger_rotation.description')}
63+
bind:checked={syncPassengerRotation}
64+
defaultValue={false}
65+
/>
66+
6267
<CodeInput
6368
label={translate('dialog.locator_config.summon_commands.title')}
6469
tooltip={translate('dialog.locator_config.summon_commands.description')}

src/interface/dialog/locatorConfig.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BLUEPRINT_FORMAT } from '../../blueprintFormat'
2-
import { LocatorConfig } from '../../nodeConfigs'
32
import LocatorConfigDialog from '../../components/locatorConfigDialog.svelte'
43
import { PACKAGE } from '../../constants'
4+
import { LocatorConfig } from '../../nodeConfigs'
55
import { createAction } from '../../util/moddingTools'
66
import { Valuable } from '../../util/stores'
77
import { SvelteDialog } from '../../util/svelteDialog'
@@ -13,6 +13,7 @@ export function openLocatorConfigDialog(locator: Locator) {
1313

1414
const useEntity = new Valuable(locatorConfig.useEntity)
1515
const entityType = new Valuable(locatorConfig.entityType)
16+
const syncPassengerRotation = new Valuable(locatorConfig.syncPassengerRotation)
1617
const summonCommands = new Valuable(locatorConfig.summonCommands)
1718
const tickingCommands = new Valuable(locatorConfig.tickingCommands)
1819

@@ -24,13 +25,15 @@ export function openLocatorConfigDialog(locator: Locator) {
2425
props: {
2526
useEntity,
2627
entityType,
28+
syncPassengerRotation,
2729
summonCommands,
2830
tickingCommands,
2931
},
3032
preventKeybinds: true,
3133
onConfirm() {
3234
locatorConfig.useEntity = useEntity.get()
3335
locatorConfig.entityType = entityType.get()
36+
locatorConfig.syncPassengerRotation = syncPassengerRotation.get()
3437
locatorConfig.summonCommands = summonCommands.get()
3538
locatorConfig.tickingCommands = tickingCommands.get()
3639

src/lang/en.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ animated_java.dialog.locator_config.entity_type.description: The type of entity
303303
animated_java.dialog.locator_config.entity_type.error.empty: Entity Type cannot be empty!
304304
animated_java.dialog.locator_config.entity_type.warning.invalid: The selected entity type doesn't exist in Minecraft {0}
305305

306+
animated_java.dialog.locator_config.sync_passenger_rotation.title: Sync Passenger Rotation
307+
animated_java.dialog.locator_config.sync_passenger_rotation.description: Automatically sync the rotation of the Locator's passenger entities.
308+
306309
animated_java.dialog.locator_config.summon_commands.title: On-Summon Commands
307310
animated_java.dialog.locator_config.summon_commands.description: |-
308311
Commands to run as the Locator's entity when summoned.

src/nodeConfigs.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,15 @@ export class BoneConfig {
346346
export class LocatorConfig {
347347
private _useEntity?: boolean
348348
private _entityType?: string
349+
private _syncPassengerRotation?: boolean
349350
private _summonCommands?: string
350351
private _tickingCommands?: string
351352

352353
getDefault(): LocatorConfig {
353354
return LocatorConfig.fromJSON({
354355
use_entity: false,
355356
entity_type: 'minecraft:pig',
357+
sync_passenger_rotation: false,
356358
summon_commands: '',
357359
ticking_commands: '',
358360
})
@@ -376,6 +378,15 @@ export class LocatorConfig {
376378
this._entityType = value
377379
}
378380

381+
get syncPassengerRotation(): NonNullable<LocatorConfig['_syncPassengerRotation']> {
382+
if (this._syncPassengerRotation !== undefined) return this._syncPassengerRotation
383+
const defaultConfig = this.getDefault()
384+
return defaultConfig.syncPassengerRotation
385+
}
386+
set syncPassengerRotation(value: NonNullable<LocatorConfig['_syncPassengerRotation']>) {
387+
this._syncPassengerRotation = value
388+
}
389+
379390
get summonCommands(): NonNullable<LocatorConfig['_summonCommands']> {
380391
if (this._summonCommands !== undefined) return this._summonCommands
381392
const defaultConfig = this.getDefault()
@@ -398,6 +409,7 @@ export class LocatorConfig {
398409
return {
399410
use_entity: this._useEntity,
400411
entity_type: this._entityType,
412+
sync_passenger_rotation: this._syncPassengerRotation,
401413
summon_commands: this._summonCommands,
402414
ticking_commands: this._tickingCommands,
403415
}
@@ -407,6 +419,8 @@ export class LocatorConfig {
407419
const config = new LocatorConfig()
408420
if (json.use_entity !== undefined) config._useEntity = json.use_entity
409421
if (json.entity_type !== undefined) config._entityType = json.entity_type
422+
if (json.sync_passenger_rotation !== undefined)
423+
config._syncPassengerRotation = json.sync_passenger_rotation
410424
if (json.summon_commands !== undefined) config._summonCommands = json.summon_commands
411425
if (json.ticking_commands !== undefined) config._tickingCommands = json.ticking_commands
412426
return config
@@ -420,6 +434,7 @@ export class LocatorConfig {
420434
return (
421435
this.useEntity === other.useEntity &&
422436
this.entityType === other.entityType &&
437+
this.syncPassengerRotation === other.syncPassengerRotation &&
423438
this.summonCommands === other.summonCommands &&
424439
this.tickingCommands === other.tickingCommands
425440
)

0 commit comments

Comments
 (0)