diff --git a/colorizer.js b/colorizer.js index c9f848298..7cbdf3f02 100644 --- a/colorizer.js +++ b/colorizer.js @@ -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: [mask over]') + process.exit(2) +} else if (args.length > 2) { + console.error('Too many textures specified! Valid arguments are: [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) + } } -} +})() diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index da5c28793..2aedb738a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -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) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt index 0d987ca43..65e035270 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -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) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt index f151a6415..ca3bf380d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -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) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt index 84f3a38a6..52c1e89c6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -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) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_black.png new file mode 100644 index 000000000..d07a6c1c1 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_black.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_blue.png new file mode 100644 index 000000000..87278e1f8 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_blue.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_brown.png new file mode 100644 index 000000000..fdd156265 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_brown.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_cyan.png new file mode 100644 index 000000000..3a3d3d7de Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_cyan.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_gray.png new file mode 100644 index 000000000..efe599032 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_gray.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_green.png new file mode 100644 index 000000000..72437aa8a Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_green.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_light_blue.png new file mode 100644 index 000000000..27db6aba3 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_light_blue.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_light_gray.png new file mode 100644 index 000000000..98206fda1 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_light_gray.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_lime.png new file mode 100644 index 000000000..d6e1f1076 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_lime.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_magenta.png new file mode 100644 index 000000000..95c14e251 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_magenta.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_orange.png new file mode 100644 index 000000000..3b3637fe0 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_orange.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_colorless_part.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_overlay.png similarity index 100% rename from src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_colorless_part.png rename to src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_overlay.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_pink.png new file mode 100644 index 000000000..3e5482fbc Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_pink.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_purple.png new file mode 100644 index 000000000..9119e16ac Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_purple.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_red.png new file mode 100644 index 000000000..3bf12573a Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_red.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_colorless.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_white.png similarity index 100% rename from src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_colorless.png rename to src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_white.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_yellow.png new file mode 100644 index 000000000..7f2f6a096 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_yellow.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_black.png new file mode 100644 index 000000000..96a3d194c Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_black.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_blue.png new file mode 100644 index 000000000..9dfb6238b Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_blue.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_brown.png new file mode 100644 index 000000000..79a1a3f5f Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_brown.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_cyan.png new file mode 100644 index 000000000..5505bf0a0 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_cyan.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_gray.png new file mode 100644 index 000000000..6b6335f64 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_gray.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_green.png new file mode 100644 index 000000000..a1be52895 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_green.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_light_blue.png new file mode 100644 index 000000000..478b507d5 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_light_blue.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_light_gray.png new file mode 100644 index 000000000..6e38365fb Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_light_gray.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_lime.png new file mode 100644 index 000000000..e9e892a2c Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_lime.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_magenta.png new file mode 100644 index 000000000..df71299f5 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_magenta.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_orange.png new file mode 100644 index 000000000..c83528225 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_orange.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_colorless_part.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_overlay.png similarity index 100% rename from src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_colorless_part.png rename to src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_overlay.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_pink.png new file mode 100644 index 000000000..b746081b9 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_pink.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_purple.png new file mode 100644 index 000000000..e521a3972 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_purple.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_red.png new file mode 100644 index 000000000..931f68b62 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_red.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_colorless.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_white.png similarity index 100% rename from src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_colorless.png rename to src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_white.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_yellow.png new file mode 100644 index 000000000..2d492e7ce Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_yellow.png differ