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) const args = process.argv.slice(2)
if (args.length == 0) { 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) process.exit(2)
} }
@ -33,39 +36,46 @@ const colors = [
process.stderr.setMaxListeners(40) process.stderr.setMaxListeners(40)
process.stdout.setMaxListeners(40) process.stdout.setMaxListeners(40)
for (const texture of args) { async function size(path) {
if (!fs.existsSync(`${root_main}${texture}.png`)) { const identify = child_process.spawn('magick', [
process.stderr.write(`${texture}.png does not exist\n`) 'identify',
continue path,
} ])
const splitted = texture.split('/') identify.stderr.pipe(process.stderr)
const last = splitted.pop()
const combined = splitted.join('/')
const basedir = `${root_main}${combined}` const chunks = []
identify.stdout.on('data', (a) => chunks.push(a))
for (const color of colors) { await new Promise((resolve) => {
(async function() { identify.on('close', () => resolve())
const identify = child_process.spawn('magick', [ })
'identify',
`${root_main}${texture}.png`,
])
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 = [] return [width, height]
identify.stdout.on('data', (a) => chunks.push(a)) }
await new Promise((resolve) => { (async function() {
identify.on('close', () => resolve()) if (args.length == 1) {
}) const texture = args[1]
const chunk = chunks[0].toString('utf-8') if (!fs.existsSync(`${root_main}${texture}.png`)) {
const size = chunk.match(/PNG ([0-9]+)x([0-9]+)/) process.stderr.write(`${texture}.png does not exist\n`)
const width = parseInt(size[1]) process.exit(1)
const height = parseInt(size[2]) }
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 name = color[0]
const rgb = color[1] const rgb = color[1]
const magick = child_process.spawn('magick', [ const magick = child_process.spawn('magick', [
@ -75,11 +85,62 @@ for (const texture of args) {
`xc:rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`, `xc:rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`,
'-compose', 'Multiply', '-compose', 'Multiply',
'-composite', '-composite',
//'-layers', 'merge',
`${basedir}/${last.replace(/_colorless/, '').replace(/_white/, '')}_${name}.png`]) `${basedir}/${last.replace(/_colorless/, '').replace(/_white/, '')}_${name}.png`])
magick.stdout.pipe(process.stdout) magick.stdout.pipe(process.stdout)
magick.stderr.pipe(process.stderr) 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.TRITANIUM_BLOCK)
decoratives(MRegistry.FLOOR_TILES) decoratives(MRegistry.FLOOR_TILES)
decoratives(MRegistry.VENT)
decoratives(MRegistry.VENT_ALTERNATIVE)
for (glass in MBlocks.INDUSTRIAL_GLASS_LIST) { for (glass in MBlocks.INDUSTRIAL_GLASS_LIST) {
decorativeCubeAll(glass) decorativeCubeAll(glass)

View File

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

View File

@ -308,6 +308,8 @@ object MItems {
init { init {
MRegistry.FLOOR_TILES.registerItems(registry) 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) } 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) .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) { val FLOOR_TILES = ColoredDecorativeBlock(MNames.FLOOR_TILES) {
BlockBehaviour.Properties.of(Material.STONE, it.materialColor) BlockBehaviour.Properties.of(Material.STONE, it.materialColor)
.sound(SoundType.STONE) .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