Colored vents

This commit is contained in:
DBotThePony 2022-05-21 11:11:44 +07:00
parent 69b3f723e6
commit d0c1a7ec5a
Signed by: DBot
GPG Key ID: DCC23B5715498507
39 changed files with 116 additions and 33 deletions

View File

@ -8,7 +8,10 @@ const child_process = require('child_process')
const args = process.argv.slice(2)
if (args.length == 0) {
console.error('No texture(s) names specified.')
console.error('No texture(s) names specified. Valid arguments are: <texture> [mask over]')
process.exit(2)
} else if (args.length > 2) {
console.error('Too many textures specified! Valid arguments are: <texture> [mask over]')
process.exit(2)
}
@ -33,39 +36,46 @@ const colors = [
process.stderr.setMaxListeners(40)
process.stdout.setMaxListeners(40)
for (const texture of args) {
if (!fs.existsSync(`${root_main}${texture}.png`)) {
process.stderr.write(`${texture}.png does not exist\n`)
continue
}
async function size(path) {
const identify = child_process.spawn('magick', [
'identify',
path,
])
const splitted = texture.split('/')
const last = splitted.pop()
const combined = splitted.join('/')
identify.stderr.pipe(process.stderr)
const basedir = `${root_main}${combined}`
const chunks = []
identify.stdout.on('data', (a) => chunks.push(a))
for (const color of colors) {
(async function() {
const identify = child_process.spawn('magick', [
'identify',
`${root_main}${texture}.png`,
])
await new Promise((resolve) => {
identify.on('close', () => resolve())
})
identify.stderr.pipe(process.stderr)
const chunk = chunks[0].toString('utf-8')
const size = chunk.match(/PNG ([0-9]+)x([0-9]+)/)
const width = parseInt(size[1])
const height = parseInt(size[2])
const chunks = []
identify.stdout.on('data', (a) => chunks.push(a))
return [width, height]
}
await new Promise((resolve) => {
identify.on('close', () => resolve())
})
(async function() {
if (args.length == 1) {
const texture = args[1]
const chunk = chunks[0].toString('utf-8')
const size = chunk.match(/PNG ([0-9]+)x([0-9]+)/)
const width = parseInt(size[1])
const height = parseInt(size[2])
if (!fs.existsSync(`${root_main}${texture}.png`)) {
process.stderr.write(`${texture}.png does not exist\n`)
process.exit(1)
}
const splitted = texture.split('/')
const last = splitted.pop()
const combined = splitted.join('/')
const basedir = `${root_main}${combined}`
const [width, height] = await size(`${root_main}${texture}.png`)
for (const color of colors) {
const name = color[0]
const rgb = color[1]
const magick = child_process.spawn('magick', [
@ -75,11 +85,62 @@ for (const texture of args) {
`xc:rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`,
'-compose', 'Multiply',
'-composite',
//'-layers', 'merge',
`${basedir}/${last.replace(/_colorless/, '').replace(/_white/, '')}_${name}.png`])
magick.stdout.pipe(process.stdout)
magick.stderr.pipe(process.stderr)
})()
}
} else {
const textureColor = args[0]
const textureOverlay = args[1]
if (!fs.existsSync(`${root_main}${textureColor}.png`)) {
process.stderr.write(`${textureColor}.png does not exist\n`)
process.exit(1)
}
if (!fs.existsSync(`${root_main}${textureOverlay}.png`)) {
process.stderr.write(`${textureOverlay}.png does not exist\n`)
process.exit(1)
}
const splitted = textureColor.split('/')
const last = splitted.pop()
const combined = splitted.join('/')
const basedir = `${root_main}${combined}`
const [widthOverlay, heightOverlay] = await size(`${root_main}${textureOverlay}.png`)
const [width, height] = await size(`${root_main}${textureColor}.png`)
if (widthOverlay != width || heightOverlay != height) {
process.stderr.write(`${textureColor}.png has size of ${width}x${height}, overlay has size of ${widthOverlay}x${heightOverlay}!\n`)
process.exit(3)
}
for (const color of colors) {
const name = color[0]
const rgb = color[1]
const magick = child_process.spawn('magick', [
'convert',
'(',
`${root_main}${textureColor}.png`,
'-size', `${width}x${height}`,
`xc:rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`,
'-compose', 'Multiply',
'-composite',
')',
`${root_main}${textureOverlay}.png`,
'-compose', 'Over',
'-composite',
`${basedir}/${last.replace(/_colorless/, '').replace(/_white/, '')}_${name}.png`])
magick.stdout.pipe(process.stdout)
magick.stderr.pipe(process.stderr)
}
}
}
})()

View File

@ -149,6 +149,8 @@ object DataGen {
decoratives(MRegistry.TRITANIUM_BLOCK)
decoratives(MRegistry.FLOOR_TILES)
decoratives(MRegistry.VENT)
decoratives(MRegistry.VENT_ALTERNATIVE)
for (glass in MBlocks.INDUSTRIAL_GLASS_LIST) {
decorativeCubeAll(glass)

View File

@ -123,20 +123,22 @@ object MBlocks {
BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_LIGHT_BLUE)
.sound(SoundType.BASALT)
.requiresCorrectToolForDrops()
.explosionResistance(80f)
.strength(4f)
.explosionResistance(20f)
.strength(1.5f)
) }
val VENT_ALTERNATIVE: Block by registry.register(MNames.VENT_ALTERNATIVE) { Block(
BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_LIGHT_BLUE)
.sound(SoundType.BASALT)
.requiresCorrectToolForDrops()
.explosionResistance(80f)
.strength(4f)
.explosionResistance(20f)
.strength(1.5f)
) }
init {
MRegistry.FLOOR_TILES.registerBlocks(registry)
MRegistry.VENT.registerBlocks(registry)
MRegistry.VENT_ALTERNATIVE.registerBlocks(registry)
}
val CARGO_CRATE: Block by registry.register(MNames.CARGO_CRATE) { CargoCrateBlock(null) }

View File

@ -308,6 +308,8 @@ object MItems {
init {
MRegistry.FLOOR_TILES.registerItems(registry)
MRegistry.VENT.registerItems(registry)
MRegistry.VENT_ALTERNATIVE.registerItems(registry)
}
val INDUSTRIAL_GLASS: Item by registry.register(MRegistry.INDUSTRIAL_GLASS.name) { BlockItem(MBlocks.INDUSTRIAL_GLASS, DEFAULT_PROPERTIES_DECORATIVE) }

View File

@ -271,6 +271,22 @@ object MRegistry {
.strength(4f)
}
val VENT = ColoredDecorativeBlock(MNames.VENT) {
BlockBehaviour.Properties.of(Material.METAL, it.materialColor)
.sound(SoundType.BASALT)
.requiresCorrectToolForDrops()
.explosionResistance(20f)
.strength(1.5f)
}
val VENT_ALTERNATIVE = ColoredDecorativeBlock(MNames.VENT_ALTERNATIVE) {
BlockBehaviour.Properties.of(Material.METAL, it.materialColor)
.sound(SoundType.BASALT)
.requiresCorrectToolForDrops()
.explosionResistance(20f)
.strength(1.5f)
}
val FLOOR_TILES = ColoredDecorativeBlock(MNames.FLOOR_TILES) {
BlockBehaviour.Properties.of(Material.STONE, it.materialColor)
.sound(SoundType.STONE)

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B