Skip to content

Commit c9cdb13

Browse files
committed
🛠️ Fix #218
Block displays should not respect the `facing` state.
1 parent bde8fe3 commit c9cdb13

File tree

5 files changed

+51
-889
lines changed

5 files changed

+51
-889
lines changed

src/outliner/vanillaBlockDisplay.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ export const PREVIEW_CONTROLLER = new NodePreviewController(VanillaBlockDisplay,
240240
el.preview_controller.updateTransform(el)
241241
el.mesh.visible = el.visibility
242242
TickUpdates.selection = true
243-
244-
el.ready = true
245243
})
246244
.catch(err => {
247245
console.error(err)
@@ -254,6 +252,7 @@ export const PREVIEW_CONTROLLER = new NodePreviewController(VanillaBlockDisplay,
254252
if (el.error.get()) el.mesh.outline.material = ERROR_OUTLINE_MATERIAL
255253
else el.mesh.outline.material = Canvas.outlineMaterial
256254
}
255+
el.ready = true
257256
})
258257
},
259258
updateTransform(el: VanillaBlockDisplay) {

src/outliner/vanillaItemDisplay.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import { ResizableOutlinerElement } from './resizableOutlinerElement'
1414
import { TextDisplay } from './textDisplay'
1515
import { VanillaBlockDisplay } from './vanillaBlockDisplay'
1616

17+
const ERROR_OUTLINE_MATERIAL = Canvas.outlineMaterial.clone()
18+
ERROR_OUTLINE_MATERIAL.color.set('#ff0000')
19+
1720
interface VanillaItemDisplayOptions {
1821
name?: string
1922
item?: string
@@ -237,14 +240,19 @@ export const PREVIEW_CONTROLLER = new NodePreviewController(VanillaItemDisplay,
237240
el.preview_controller.updateTransform(el)
238241
el.mesh.visible = el.visibility
239242
TickUpdates.selection = true
240-
241-
el.ready = true
242243
})
243244
.catch(err => {
244245
if (typeof err.message === 'string') {
245246
el.error.set(err.message as string)
246247
}
247248
})
249+
.finally(() => {
250+
if (el.mesh?.outline instanceof THREE.LineSegments) {
251+
if (el.error.get()) el.mesh.outline.material = ERROR_OUTLINE_MATERIAL
252+
else el.mesh.outline.material = Canvas.outlineMaterial
253+
}
254+
el.ready = true
255+
})
248256
},
249257
updateTransform(el: VanillaItemDisplay) {
250258
ResizableOutlinerElement.prototype.preview_controller.updateTransform(el)

src/systems/minecraft/blockModelManager.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ const BLACKLISTED_BLOCKS = new Map([
4242
['piglin_wall_head', translate('block_model_manager.mob_head_warning')],
4343
])
4444

45+
const BLACKLISTED_BLOCKSTATES = new Map([
46+
['facing', translate('block_model_manager.facing_warning')],
47+
])
48+
4549
export async function getBlockModel(block: string): Promise<BlockModelMesh | undefined> {
4650
await assetsLoaded()
4751
let result = BLOCK_MODEL_CACHE.get(block)
4852
if (!result) {
49-
// console.warn(`Found no cached item model mesh for '${block}'`)
5053
const parsed = await parseBlock(block)
5154
if (!parsed) return undefined
5255
if (BLACKLISTED_BLOCKS.has(block)) {
@@ -383,6 +386,9 @@ export async function parseBlockState(block: IParsedBlock): Promise<BlockModelMe
383386
} else if (!block.blockStateRegistryEntry.stateValues[k].includes(v)) {
384387
throw new Error(`Invalid block state value '${v.toString()}' for '${k}'`)
385388
}
389+
if (BLACKLISTED_BLOCKSTATES.has(k)) {
390+
block.states[k] = block.blockStateRegistryEntry.defaultStates[k]
391+
}
386392
}
387393

388394
if (blockstate.variants) {

test_blueprints/armor_stand.ajblueprint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3006,7 +3006,7 @@
30063006
"override": false,
30073007
"length": 0.8,
30083008
"snapping": 20,
3009-
"selected": true,
3009+
"selected": false,
30103010
"saved": false,
30113011
"path": "",
30123012
"anim_time_update": "",

0 commit comments

Comments
 (0)