List a pack's unread fields once and draw plugin blocks in the palette view

Unknown fields used to log one warning per field per file, with a snippet,
every time a pack loaded. A pack without modules logged about 2200 of them at
startup. Now they are gathered per pack and stated as one list a few seconds
after the first, one line per field with its first file and how many others
hold it. Each file's field is stated once per server start. The header says
when the pack loads no modules, which is why layers, wall and decorators
were unread here.

The Bukkit warning path stripped colours. It now keeps section-sign codes
and still reads nothing else as markup.

The palette view drew CraftEngine blocks by their server-only state, such as
craftengine:custom_7, which has no assets. The pattern header now names a
plugin block as the pack does and adds the vanilla state players see, which
the studio draws. Asset reads check plugin resource packs before the client
jar for minecraft paths too, since those packs replace vanilla blockstates.
This commit is contained in:
piexel committed 2026-11-11 14:34:45 +01:00
1 parent f98b6dc548
commit a71b27ce31
21 files changed
+326 -55

No files matched your search

@@ -15,11 +15,18 @@ function encodedPattern(header: object, picks: number[]): ArrayBuffer {
describe('decodePattern', () => {
it('reads the picks after the padded header, row by row, with no block as -1', () => {
const header = { columns: 2, blocksPerColumn: 4, blocks: ['minecraft:grass_block[snowy=false]', 'minecraft:dirt'], noBlock: -1 }
const header = {
columns: 2,
blocksPerColumn: 4,
blocks: ['minecraft:grass_block[snowy=false]', 'etopia:grass_block'],
drawnAs: ['minecraft:grass_block[snowy=false]', 'minecraft:note_block[note=7]'],
noBlock: -1
}
const pattern = decodePattern(encodedPattern(header, [0, -1, 1, 0]))
expect(pattern.columns).toBe(2)
expect(pattern.blocksPerColumn).toBe(4)
expect(pattern.blocks).toEqual(header.blocks)
expect(pattern.drawnAs).toEqual(header.drawnAs)
expect([...pattern.picks]).toEqual([0, NO_PATTERN_BLOCK, 1, 0])
})
})
@@ -6,6 +6,7 @@ interface PatternHeader {
columns: number
blocksPerColumn: number
blocks: string[]
drawnAs: string[]
}
/**
@@ -20,6 +21,7 @@ export function decodePattern(buffer: ArrayBuffer): PatternTile {
columns: header.columns,
blocksPerColumn: header.blocksPerColumn,
blocks: header.blocks,
drawnAs: header.drawnAs,
picks: new Int16Array(buffer, picksAt, header.columns * header.columns)
}
}
+3 -1
View File
@@ -150,8 +150,10 @@ export interface PatternEntry {
export interface PatternTile {
columns: number
blocksPerColumn: number
/** The block states the picks index, as BlockState keys. */
/** The block states the picks index, as BlockState keys; a plugin's block by the name the pack gives it. */
blocks: string[]
/** Per block, the state players see and the studio draws: the block itself, or the vanilla state a plugin block borrows. */
drawnAs: string[]
/** Each column's block, or NO_PATTERN_BLOCK where the pattern places none. */
picks: Int16Array
}
@@ -35,9 +35,9 @@ export interface PatternStatus extends TiledFrame {
spot: PatternSpot
}
/** The blocks a tile placed with their colours, and whether it left some columns without a block. */
/** The blocks a tile placed, each with the state it is drawn as, and whether it left some columns without a block. */
export interface PatternBlocks {
colors: Map<string, number>
drawnAs: Map<string, string>
someNone: boolean
}
@@ -89,7 +89,7 @@ function patternTileSource(client: BridgeClient, blockColors: BlockColors, liste
fetch: async (address, layer, signal) => {
const picture = await fetchPicture(client, blockColors, address, layer, signal)
listener.onBlocks(layer, {
colors: new Map(picture.pattern.blocks.map((block, index) => [block, picture.colors[index]])),
drawnAs: new Map(picture.pattern.blocks.map((block, index) => [block, picture.pattern.drawnAs[index]])),
someNone: picture.pattern.picks.includes(NO_PATTERN_BLOCK)
})
return picture
@@ -109,8 +109,8 @@ async function fetchPicture(client: BridgeClient, blockColors: BlockColors, addr
const pixelsPerColumn = Math.round(blocksPerColumn / address.blocksPerPixel)
const columns = PATTERN_TILE_PIXELS / pixelsPerColumn
const pattern = await client.pattern({ ...layer, tileX: address.tileX, tileZ: address.tileZ, blocksPerColumn, columns }, signal)
const colors = await Promise.all(pattern.blocks.map((block) => blockColors.colorOf(block)))
const textures = pixelsPerColumn > 1 ? await Promise.all(pattern.blocks.map((block) => blockColors.topTexture(block))) : []
const colors = await Promise.all(pattern.drawnAs.map((block) => blockColors.colorOf(block)))
const textures = pixelsPerColumn > 1 ? await Promise.all(pattern.drawnAs.map((block) => blockColors.topTexture(block))) : []
return { pattern, colors, textures, pixelsPerColumn }
}
@@ -18,7 +18,7 @@ const DEFAULT_NAMESPACE_PREFIX = 'minecraft:'
// A layer thinner than the depth shown, or a palette with no block for the spot.
const NONE_LABEL = 'nothing at this depth'
/** The blocks the shown layer's tiles placed so far by name, each with one full state for its icon, and whether some spots got none. */
/** The blocks the shown layer's tiles placed so far by name, each with one state to draw its icon as, and whether some spots got none. */
interface LegendBlocks {
examples: Map<string, string>
someNone: boolean
@@ -153,7 +153,7 @@ function usePatternView(
/** The legend with the tile's blocks added, one row per block whatever its state; unchanged when it had them all. */
function withBlocks(shown: LegendBlocks, tile: PatternBlocks): LegendBlocks {
const added = [...tile.colors.keys()].map((block) => [shortName(block), block] as const).filter(([name]) => !shown.examples.has(name))
const added = [...tile.drawnAs].map(([block, drawnAs]) => [shortName(block), drawnAs] as const).filter(([name]) => !shown.examples.has(name))
const someNone = shown.someNone || tile.someNone
if (added.length === 0 && someNone === shown.someNone) {
return shown