Compare commits
10 Commits
1be974006f
...
28c7459b82
Author | SHA1 | Date | |
---|---|---|---|
28c7459b82 | |||
a93d754a68 | |||
ad729221f3 | |||
980f09471a | |||
ec68b7ee9c | |||
b4fc02b14e | |||
4712cf4b35 | |||
f9159f61ec | |||
bde57e69cf | |||
47364de172 |
68
color datagen/base_with_mask.js
Normal file
@ -0,0 +1,68 @@
|
||||
|
||||
const args = process.argv.slice(2)
|
||||
|
||||
if (args.length < 2) {
|
||||
console.error('Usage: node base_with_mask.js <base_name> <mask_name> [subfolder]\n')
|
||||
console.error('If subfolder specified, resulting file name will contain only color name\n')
|
||||
console.error('Subfolder is relative to base texture path\n')
|
||||
process.exit(2)
|
||||
}
|
||||
|
||||
const fs = require('fs')
|
||||
const {colorsWithWhite, rootFolder, splitName, getSize} = require('./include.js')
|
||||
const child_process = require('child_process');
|
||||
|
||||
(async function() {
|
||||
const baseTexture = args[0]
|
||||
const maskTexture = args[1]
|
||||
const subfolder = args[2] ?? ''
|
||||
|
||||
const fBase = `${rootFolder}${baseTexture}.png`
|
||||
const fMask = `${rootFolder}${maskTexture}.png`
|
||||
|
||||
if (!fs.existsSync(fBase)) {
|
||||
process.stderr.write(`${fBase} does not exist\n`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (!fs.existsSync(fMask)) {
|
||||
process.stderr.write(`${fMask} does not exist\n`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const [fileName, _, fullBaseFolder] = splitName(baseTexture)
|
||||
const bSize = (await getSize(fBase))[2]
|
||||
const mSize = (await getSize(fMask))[2]
|
||||
|
||||
if (bSize != mSize) {
|
||||
process.stderr.write(`${fBase} has size of ${bSize}, ${fMask} has size of ${mSize}!\n`)
|
||||
process.exit(3)
|
||||
}
|
||||
|
||||
for (const [name, _, xc] of colorsWithWhite) {
|
||||
const outputFilename = subfolder === '' ? `${fullBaseFolder}/${fileName}_${name}.png` : `${fullBaseFolder}/${subfolder}/${name}.png`
|
||||
|
||||
const magick = child_process.spawn('magick', [
|
||||
'convert',
|
||||
|
||||
fBase,
|
||||
|
||||
'(',
|
||||
fMask,
|
||||
'-size', bSize,
|
||||
xc,
|
||||
'-channel', 'rgb',
|
||||
'-compose', 'Multiply',
|
||||
'-composite',
|
||||
')',
|
||||
|
||||
'-compose', 'Over',
|
||||
'-composite',
|
||||
|
||||
outputFilename])
|
||||
|
||||
magick.stdout.pipe(process.stdout)
|
||||
magick.stderr.pipe(process.stderr)
|
||||
}
|
||||
})();
|
||||
|
4
color datagen/computer_block.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
node ./base_with_mask.js block/decorative/computer_base block/decorative/computer_base_mask computer_base
|
||||
node ./base_with_mask.js block/decorative/computer_screen block/decorative/computer_screen_mask computer_screen
|
76
color datagen/include.js
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
const colors = [
|
||||
['orange', [245, 116, 16]],
|
||||
['magenta', [186, 63, 175]],
|
||||
['light_blue', [59, 180, 219]],
|
||||
['yellow', [252, 199, 36]],
|
||||
['lime', [111, 187, 24]],
|
||||
['pink', [243, 139, 170]],
|
||||
['gray', [62, 66, 70]],
|
||||
['light_gray', [140, 140, 131]],
|
||||
['cyan', [22, 134, 145]],
|
||||
['purple', [116, 38, 169]],
|
||||
['blue', [51, 53, 155]],
|
||||
['brown', [114, 71, 40]],
|
||||
['green', [84, 109, 28]],
|
||||
['red', [156, 37, 34]],
|
||||
['black', [31, 31, 35]],
|
||||
]
|
||||
|
||||
const white = ['white', [235, 235, 235]]
|
||||
const colorsWithWhite = [...colors]
|
||||
colorsWithWhite.push(white)
|
||||
|
||||
function addRgbString(values) {
|
||||
for (const row of values) {
|
||||
const rgb = row[1]
|
||||
row.push(`xc:rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`)
|
||||
}
|
||||
}
|
||||
|
||||
addRgbString(colors)
|
||||
addRgbString(colorsWithWhite)
|
||||
|
||||
const rootFolder = '../src/main/resources/assets/overdrive_that_matters/textures/'
|
||||
const child_process = require('child_process')
|
||||
|
||||
process.stdout.setMaxListeners(900)
|
||||
process.stderr.setMaxListeners(900)
|
||||
|
||||
async function getSize(path) {
|
||||
const identify = child_process.spawn('magick', [
|
||||
'identify',
|
||||
path,
|
||||
])
|
||||
|
||||
identify.stderr.pipe(process.stderr)
|
||||
|
||||
const chunks = []
|
||||
identify.stdout.on('data', (a) => chunks.push(a))
|
||||
|
||||
await new Promise((resolve) => {
|
||||
identify.on('close', () => resolve())
|
||||
})
|
||||
|
||||
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])
|
||||
|
||||
return [width, height, `${width}x${height}`]
|
||||
}
|
||||
|
||||
function splitName(name) {
|
||||
const splitted = name.split('/')
|
||||
const fileName = splitted.pop()
|
||||
const baseFolder = splitted.join('/')
|
||||
const fullBaseFolder = `${rootFolder}${baseFolder}`
|
||||
|
||||
return [fileName, baseFolder, fullBaseFolder, fileName.indexOf('_white') == -1 ? colorsWithWhite : colors]
|
||||
}
|
||||
|
||||
exports.colors = colors
|
||||
exports.colorsWithWhite = colorsWithWhite
|
||||
exports.rootFolder = rootFolder
|
||||
exports.splitName = splitName
|
||||
exports.getSize = getSize
|
5
color datagen/tritanium_door.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
node ./base_with_mask.js block/decorative/tritanium_door_top block/decorative/tritanium_door_color_top
|
||||
node ./base_with_mask.js block/decorative/tritanium_door_bottom block/decorative/tritanium_door_color_bottom
|
||||
|
@ -1,56 +0,0 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs')
|
||||
const root_main = './src/main/resources/assets/overdrive_that_matters/textures/block/decorative/'
|
||||
const child_process = require('child_process')
|
||||
|
||||
const colors = [
|
||||
['orange', [245, 116, 16]],
|
||||
['magenta', [186, 63, 175]],
|
||||
['light_blue', [59, 180, 219]],
|
||||
['yellow', [252, 199, 36]],
|
||||
['lime', [111, 187, 24]],
|
||||
['pink', [243, 139, 170]],
|
||||
['gray', [62, 66, 70]],
|
||||
['light_gray', [140, 140, 131]],
|
||||
['cyan', [22, 134, 145]],
|
||||
['purple', [116, 38, 169]],
|
||||
['blue', [51, 53, 155]],
|
||||
['brown', [114, 71, 40]],
|
||||
['green', [84, 109, 28]],
|
||||
['red', [156, 37, 34]],
|
||||
['black', [31, 31, 35]],
|
||||
['white', [235, 235, 235]],
|
||||
]
|
||||
|
||||
process.stderr.setMaxListeners(40)
|
||||
process.stdout.setMaxListeners(40);
|
||||
|
||||
(async function() {
|
||||
for (const [base, overlay, nameBase] of [['tritanium_door_base_top', 'tritanium_door_color_top', 'tritanium_door_top'], ['tritanium_door_base_bottom', 'tritanium_door_color_bottom', 'tritanium_door_bottom']]) {
|
||||
for (const [name, rgb] of colors) {
|
||||
const magick = child_process.spawn('magick', [
|
||||
'convert',
|
||||
|
||||
`${root_main}${base}.png`,
|
||||
|
||||
'(',
|
||||
`${root_main}${overlay}.png`,
|
||||
'-size', '16x16',
|
||||
`xc:rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`,
|
||||
'-channel', 'rgb',
|
||||
'-compose', 'Multiply',
|
||||
'-composite',
|
||||
')',
|
||||
|
||||
'-compose', 'Over',
|
||||
'-composite',
|
||||
|
||||
`${root_main}/${nameBase}_${name}.png`])
|
||||
|
||||
magick.stdout.pipe(process.stdout)
|
||||
magick.stderr.pipe(process.stderr)
|
||||
}
|
||||
}
|
||||
})()
|
@ -54,7 +54,6 @@ import ru.dbotthepony.mc.otm.datagen.tags.addMineableTags
|
||||
import ru.dbotthepony.mc.otm.datagen.tags.addResourceTags
|
||||
import ru.dbotthepony.mc.otm.datagen.tags.addSuspiciousTags
|
||||
import ru.dbotthepony.mc.otm.datagen.tags.addTags
|
||||
import ru.dbotthepony.mc.otm.datagen.textures.ColorizedSpritesProvider
|
||||
import ru.dbotthepony.mc.otm.matter.MatterDataProvider
|
||||
import ru.dbotthepony.mc.otm.registry.game.MBlocks
|
||||
import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock
|
||||
@ -493,7 +492,6 @@ object DataGen {
|
||||
@SubscribeEvent
|
||||
@Suppress("unused")
|
||||
fun onGatherData(event: GatherDataEvent) {
|
||||
val colorizedSpritesProvider = ColorizedSpritesProvider(event)
|
||||
val blockModelProvider = MatteryBlockModelProvider(event)
|
||||
val blockStateProvider = MatteryBlockStateProvider(event)
|
||||
val itemModelProvider = MatteryItemModelProvider(event)
|
||||
@ -531,7 +529,6 @@ object DataGen {
|
||||
addMineableTags(tagsProvider)
|
||||
addDyeTags(tagsProvider)
|
||||
|
||||
event.generator.addProvider(event.includeClient(), colorizedSpritesProvider)
|
||||
event.generator.addProvider(event.includeClient(), blockModelProvider)
|
||||
event.generator.addProvider(event.includeServer(), blockStateProvider)
|
||||
event.generator.addProvider(event.includeClient(), itemModelProvider)
|
||||
|
@ -1,150 +0,0 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.textures
|
||||
|
||||
import net.neoforged.neoforge.common.data.SpriteSourceProvider
|
||||
import net.neoforged.neoforge.data.event.GatherDataEvent
|
||||
import ru.dbotthepony.mc.otm.client.render.ColorizedSpriteSource
|
||||
import ru.dbotthepony.mc.otm.datagen.DataGen
|
||||
import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||
|
||||
class ColorizedSpritesProvider(event: GatherDataEvent) : SpriteSourceProvider(event.generator.packOutput, event.lookupProvider, DataGen.MOD_ID, event.existingFileHelper) {
|
||||
override fun gather() {
|
||||
with(atlas(BLOCKS_ATLAS)) {
|
||||
listOf(
|
||||
"block/android_charger",
|
||||
"block/android_station_base",
|
||||
"block/batterybank_frame",
|
||||
"block/chemical_generator",
|
||||
"block/cobblestone_generator",
|
||||
"block/decorative/computer_base",
|
||||
"block/decorative/computer_screen",
|
||||
"block/drive_viewer",
|
||||
"block/electric_furnace",
|
||||
"block/electric_furnace_offline",
|
||||
"block/energy_counter",
|
||||
"block/energy_servo",
|
||||
"block/essence_storage",
|
||||
"block/induction_furnace",
|
||||
"block/induction_furnace_offline",
|
||||
"block/item_monitor",
|
||||
"block/matter_bottler",
|
||||
"block/matter_decomposer",
|
||||
"block/matter_panel",
|
||||
"block/matter_reconstructor",
|
||||
"block/matter_recycler",
|
||||
"block/matter_replicator_base",
|
||||
"block/matter_replicator_halted",
|
||||
"block/matter_replicator",
|
||||
"block/matter_replicator_offline",
|
||||
"block/matter_scanner",
|
||||
"block/mattercapacitorbank_frame",
|
||||
"block/plate_press",
|
||||
"block/plate_press2",
|
||||
"block/powered_smoker_base",
|
||||
"block/powered_smoker_interior_0",
|
||||
"block/powered_smoker_interior_1",
|
||||
"block/powered_smoker_interior_2",
|
||||
"block/decorative/star_chair",
|
||||
"block/storage_power_supplier",
|
||||
"block/water_source"
|
||||
).forEach {
|
||||
addSource(
|
||||
ColorizedSpriteSource(modLocation(it), modLocation(it).withSuffix("_mask"), modLocation(it)).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
}
|
||||
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("block/decorative/crates/crate_borderless_colorless"),
|
||||
modLocation("block/decorative/crates/crate_frame"),
|
||||
modLocation("block/decorative/crates/crate"), "_", true, false
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("block/decorative/crates/crate_borderless_colorless"),
|
||||
modLocation("block/decorative/crates/crate_borderless_colorless"),
|
||||
modLocation("block/decorative/crates/crate_borderless"), "_"
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("block/decorative/tritanium_block"),
|
||||
modLocation("block/decorative/tritanium_block_colorless"),
|
||||
modLocation("block/decorative/tritanium_block"), "_"
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("block/decorative/tritanium_pillar"),
|
||||
modLocation("block/decorative/tritanium_pillar_colorless"),
|
||||
modLocation("block/decorative/tritanium_pillar"), "_"
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("block/decorative/tritanium_striped_block_base"),
|
||||
modLocation("block/decorative/tritanium_striped_block_colorless_stripe"),
|
||||
modLocation("block/decorative/stripe/tritanium_striped_block"), "_"
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("block/decorative/tritanium_striped_block_colorless_base"),
|
||||
modLocation("block/decorative/tritanium_striped_block_colorless_stripe"),
|
||||
modLocation("block/decorative/stripe/tritanium_striped_block"), "_", true, true
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("block/decorative/tritanium_door_base_top"),
|
||||
modLocation("block/decorative/tritanium_door_color_top"),
|
||||
modLocation("block/decorative/tritanium_door_top"), "_"
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("block/decorative/tritanium_door_base_bottom"),
|
||||
modLocation("block/decorative/tritanium_door_color_bottom"),
|
||||
modLocation("block/decorative/tritanium_door_bottom"), "_"
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("block/decorative/tritanium_trapdoor_overlay"),
|
||||
modLocation("block/decorative/tritanium_trapdoor_colorless"),
|
||||
modLocation("block/decorative/tritanium_trapdoor"), "_"
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("block/decorative/vent_colorless"),
|
||||
modLocation("block/decorative/vent_overlay"),
|
||||
modLocation("block/decorative/vent"), "_", true, false
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("block/decorative/vent_alternative_colorless"),
|
||||
modLocation("block/decorative/vent_alternative_overlay"),
|
||||
modLocation("block/decorative/vent_alternative"), "_", true, false
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("item/minecart_cargo_crate_colorless"),
|
||||
modLocation("item/minecart_cargo_crate_nopaint"),
|
||||
modLocation("item/minecart_cargo_crate"), "_", true, false
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
addSource(
|
||||
ColorizedSpriteSource(
|
||||
modLocation("item/tritanium_door_colorless"),
|
||||
modLocation("item/tritanium_door_overlay"),
|
||||
modLocation("item/tritanium_door"), "_", true, false
|
||||
).trackGeneratedTextures(existingFileHelper)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -36,7 +36,6 @@ import ru.dbotthepony.mc.otm.client.onClientDisconnected
|
||||
import ru.dbotthepony.mc.otm.client.onClientPostRender
|
||||
import ru.dbotthepony.mc.otm.client.tooltipEvent
|
||||
import ru.dbotthepony.mc.otm.client.render.ChartTooltipElement
|
||||
import ru.dbotthepony.mc.otm.client.render.ColorizedSpriteSource
|
||||
import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer
|
||||
import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer
|
||||
import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer
|
||||
@ -159,8 +158,6 @@ object OverdriveThatMatters {
|
||||
MOD_BUS.addListener(EventPriority.NORMAL, ChartTooltipElement.Companion::register)
|
||||
MOD_BUS.addListener(EventPriority.NORMAL, MatteryTooltipComponents::registerComponents)
|
||||
|
||||
MOD_BUS.addListener(EventPriority.NORMAL, ColorizedSpriteSource::register)
|
||||
|
||||
MOD_BUS.addListener(EventPriority.HIGH, MatteryGUI::registerGuiLayers)
|
||||
|
||||
MBlockColors.register(MOD_BUS)
|
||||
|
@ -1,138 +0,0 @@
|
||||
package ru.dbotthepony.mc.otm.client.render
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.MapCodec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.client.renderer.texture.SpriteContents
|
||||
import net.minecraft.client.renderer.texture.atlas.SpriteResourceLoader
|
||||
import net.minecraft.client.renderer.texture.atlas.SpriteSource
|
||||
import net.minecraft.client.renderer.texture.atlas.SpriteSource.TEXTURE_ID_CONVERTER
|
||||
import net.minecraft.client.renderer.texture.atlas.SpriteSourceType
|
||||
import net.minecraft.client.renderer.texture.atlas.sources.LazyLoadedImage
|
||||
import net.minecraft.client.resources.metadata.animation.FrameSize
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.packs.resources.ResourceManager
|
||||
import net.minecraft.server.packs.resources.ResourceMetadata
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.neoforged.neoforge.client.event.RegisterSpriteSourceTypesEvent
|
||||
import net.neoforged.neoforge.client.model.generators.ModelProvider
|
||||
import net.neoforged.neoforge.common.data.ExistingFileHelper
|
||||
import ru.dbotthepony.kommons.math.RGBAColor
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters.loc
|
||||
|
||||
class ColorizedSpriteSource(val base: ResourceLocation, val overlay: ResourceLocation, val outputPathBase: ResourceLocation, val outputPathSuffix: String = "/", val tintBase: Boolean = false, val tintOverlay: Boolean = true) : SpriteSource {
|
||||
override fun run(
|
||||
manager: ResourceManager,
|
||||
output: SpriteSource.Output
|
||||
) {
|
||||
val baseRes = manager.getResource(TEXTURE_ID_CONVERTER.idToFile(base)).get()
|
||||
val maskRes = manager.getResource(TEXTURE_ID_CONVERTER.idToFile(overlay)).get()
|
||||
|
||||
for (baseTint in DyeColor.entries) {
|
||||
for (overlayTint in DyeColor.entries) {
|
||||
if (tintBase && baseTint == overlayTint) continue
|
||||
|
||||
var outputLocation = outputPathBase
|
||||
if (tintBase) outputLocation = outputLocation.withSuffix(outputPathSuffix + baseTint.serializedName)
|
||||
if (tintOverlay) outputLocation = outputLocation.withSuffix(outputPathSuffix + overlayTint.serializedName)
|
||||
|
||||
val baseImage = LazyLoadedImage(base, baseRes, 1)
|
||||
val maskImage = LazyLoadedImage(overlay, maskRes, 1)
|
||||
|
||||
output.add(outputLocation, Supplier(baseImage, if (tintBase) baseTint else null, maskImage, if (tintOverlay) overlayTint else null, outputLocation))
|
||||
}
|
||||
|
||||
if (!tintBase) return
|
||||
}
|
||||
}
|
||||
|
||||
override fun type(): SpriteSourceType {
|
||||
return SPRITE_SOURCE!!
|
||||
}
|
||||
|
||||
fun trackGeneratedTextures(efh: ExistingFileHelper) : ColorizedSpriteSource {
|
||||
for (baseTint in DyeColor.entries) {
|
||||
for (overlayTint in DyeColor.entries) {
|
||||
if (tintBase && baseTint == overlayTint) continue
|
||||
|
||||
var outputLocation = outputPathBase
|
||||
if (tintBase) outputLocation = outputLocation.withSuffix(outputPathSuffix + baseTint.serializedName)
|
||||
if (tintOverlay) outputLocation = outputLocation.withSuffix(outputPathSuffix + overlayTint.serializedName)
|
||||
|
||||
efh.trackGenerated(outputLocation, ModelProvider.TEXTURE)
|
||||
}
|
||||
|
||||
if (!tintBase) return this
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
class Supplier(val baseImage: LazyLoadedImage, val baseTint: DyeColor?, val maskImage: LazyLoadedImage, val maskTint: DyeColor?, val outputLocation: ResourceLocation) : SpriteSource.SpriteSupplier {
|
||||
override fun apply(t: SpriteResourceLoader?): SpriteContents? {
|
||||
val base = baseImage.get()
|
||||
val mask = maskImage.get()
|
||||
|
||||
if (base.width != mask.width || base.height != mask.height) {
|
||||
throw IllegalArgumentException("Base image doesn't match mask in texture size")
|
||||
}
|
||||
|
||||
if (baseTint != null) {
|
||||
val baseDiffCol = RGBAColor.argb(baseTint.textureDiffuseColor)
|
||||
base.applyToAllPixels {
|
||||
val a = (it and -0x1000000 ushr 24) / 255f
|
||||
val b = (it and 0xFF0000 ushr 16) / 255f
|
||||
val g = (it and 0xFF00 ushr 8) / 255f
|
||||
val r = (it and 0xFF) / 255f
|
||||
|
||||
RGBAColor(r * baseDiffCol.red, g * baseDiffCol.green, b * baseDiffCol.blue, a).toRGBA()
|
||||
}
|
||||
}
|
||||
|
||||
if (maskTint != null) {
|
||||
val maskDiffCol = RGBAColor.argb(maskTint.textureDiffuseColor)
|
||||
mask.applyToAllPixels {
|
||||
val a = (it and -0x1000000 ushr 24) / 255f
|
||||
val b = (it and 0xFF0000 ushr 16) / 255f
|
||||
val g = (it and 0xFF00 ushr 8) / 255f
|
||||
val r = (it and 0xFF) / 255f
|
||||
|
||||
RGBAColor(r * maskDiffCol.red, g * maskDiffCol.green, b * maskDiffCol.blue, a).toRGBA()
|
||||
}
|
||||
}
|
||||
|
||||
for (i in 0 until base.width) {
|
||||
for (j in 0 until base.height) {
|
||||
base.blendPixel(i, j, mask.getPixelRGBA(i, j))
|
||||
}
|
||||
}
|
||||
|
||||
maskImage.release()
|
||||
|
||||
return SpriteContents(outputLocation, FrameSize(base.width, base.height), base, ResourceMetadata.EMPTY)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
val LOCATION = loc("colorized")
|
||||
|
||||
private val CODEC: MapCodec<ColorizedSpriteSource> = RecordCodecBuilder.mapCodec {
|
||||
it.group(
|
||||
ResourceLocation.CODEC.fieldOf("base").forGetter { it.base },
|
||||
ResourceLocation.CODEC.fieldOf("overlay").forGetter { it.overlay },
|
||||
ResourceLocation.CODEC.fieldOf("output_path_base").forGetter { it.outputPathBase },
|
||||
Codec.STRING.optionalFieldOf("output_path_suffix", "/").forGetter { it.outputPathSuffix },
|
||||
Codec.BOOL.optionalFieldOf("base_tint", false).forGetter { it.tintBase },
|
||||
Codec.BOOL.optionalFieldOf("overlay_tint", true).forGetter{ it.tintOverlay }
|
||||
|
||||
).apply(it, ::ColorizedSpriteSource)
|
||||
}
|
||||
|
||||
var SPRITE_SOURCE: SpriteSourceType? = null
|
||||
|
||||
fun register(event: RegisterSpriteSourceTypesEvent) {
|
||||
SPRITE_SOURCE = event.register(LOCATION, CODEC)
|
||||
}
|
||||
}
|
||||
}
|
@ -21,12 +21,18 @@ class UpgradeContainer(
|
||||
get() = setOf()
|
||||
|
||||
private fun positiveDecimals(fn: (IMatteryUpgrade) -> Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal {
|
||||
if (isEmpty)
|
||||
return Decimal.ZERO
|
||||
|
||||
return iterator()
|
||||
.map { (it.getCapability(MatteryCapability.UPGRADE)?.let(fn) ?: Decimal.ZERO).moreThanZero() * it.count }
|
||||
.reduce(Decimal.ZERO, reducer)
|
||||
}
|
||||
|
||||
private fun anyDecimals(fn: (IMatteryUpgrade) -> Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal {
|
||||
if (isEmpty)
|
||||
return Decimal.ZERO
|
||||
|
||||
return iterator()
|
||||
.map { (it.getCapability(MatteryCapability.UPGRADE)?.let(fn) ?: Decimal.ZERO) * it.count }
|
||||
.reduce(Decimal.ZERO, reducer)
|
||||
|
@ -75,7 +75,8 @@ class MatterEntanglerMenu(
|
||||
|
||||
private fun rescan() {
|
||||
if (player is ServerPlayer && entangling[0].item is IQuantumLinked && entangling[1].item == entangling[0].item && entangling[0].isNotEmpty && entangling[1].isNotEmpty) {
|
||||
entanglingC.container[0] = (entangling[0].item as IQuantumLinked).merge(entangling[0], entangling[1])
|
||||
val result = (entangling[0].item as IQuantumLinked).merge(entangling[0], entangling[1])
|
||||
entanglingC.container[0] = result
|
||||
} else if (player is ServerPlayer) {
|
||||
entanglingC.container[0] = ItemStack.EMPTY
|
||||
}
|
||||
@ -89,7 +90,7 @@ class MatterEntanglerMenu(
|
||||
|
||||
val entanglingA: MatterySlot = EntanglingInputSlot(0)
|
||||
val entanglingB: MatterySlot = EntanglingInputSlot(1)
|
||||
val entanglingC: MatterySlot = object : MatterySlot(SimpleContainer(1), 0) {
|
||||
val entanglingC: MatterySlot = object : MatterySlot(MatteryContainer(1), 0) {
|
||||
override fun mayPlace(itemStack: ItemStack): Boolean {
|
||||
return false
|
||||
}
|
||||
|
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 607 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 732 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 793 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 787 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |