Revert "генерация colomposed текстур и автотрек текстур для датагена"
This reverts commit cc8a149c25
.
@ -118,7 +118,10 @@ class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(eve
|
|||||||
val model = withExistingParent(modelName + "_${color.name.lowercase()}$suffix", modLocation(modelName + suffix))
|
val model = withExistingParent(modelName + "_${color.name.lowercase()}$suffix", modLocation(modelName + suffix))
|
||||||
|
|
||||||
for ((key, value) in textureKeys) {
|
for ((key, value) in textureKeys) {
|
||||||
model.texture(key, modLocation("block/$value/${color.name.lowercase()}"))
|
val loc = modLocation("block/$value/${color.name.lowercase()}")
|
||||||
|
|
||||||
|
existingFileHelper.trackGenerated(loc, TEXTURE)
|
||||||
|
model.texture(key, loc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ru.dbotthepony.mc.otm.datagen.textures
|
package ru.dbotthepony.mc.otm.datagen.textures
|
||||||
|
|
||||||
|
import net.minecraft.resources.ResourceLocation
|
||||||
import net.neoforged.neoforge.common.data.SpriteSourceProvider
|
import net.neoforged.neoforge.common.data.SpriteSourceProvider
|
||||||
import net.neoforged.neoforge.data.event.GatherDataEvent
|
import net.neoforged.neoforge.data.event.GatherDataEvent
|
||||||
import ru.dbotthepony.mc.otm.client.render.ColorizedSpriteSource
|
import ru.dbotthepony.mc.otm.client.render.ColorizedSpriteSource
|
||||||
@ -7,57 +8,54 @@ import ru.dbotthepony.mc.otm.datagen.DataGen
|
|||||||
import ru.dbotthepony.mc.otm.datagen.modLocation
|
import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||||
|
|
||||||
class ColorizedSpritesProvider(event: GatherDataEvent) : SpriteSourceProvider(event.generator.packOutput, event.lookupProvider, DataGen.MOD_ID, event.existingFileHelper) {
|
class ColorizedSpritesProvider(event: GatherDataEvent) : SpriteSourceProvider(event.generator.packOutput, event.lookupProvider, DataGen.MOD_ID, event.existingFileHelper) {
|
||||||
override fun gather() {
|
fun getMaskedTextureMap(paths: List<String>) : Map<ResourceLocation, ResourceLocation> {
|
||||||
listOf(
|
val map: MutableMap<ResourceLocation, ResourceLocation> = mutableMapOf()
|
||||||
"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 {
|
|
||||||
atlas(BLOCKS_ATLAS).addSource(
|
|
||||||
ColorizedSpriteSource(modLocation(it), modLocation(it).withSuffix("_mask"), modLocation(it)).trackGeneratedTextures(existingFileHelper)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
paths.forEach { map[modLocation(it)] = modLocation(it + "_mask") }
|
||||||
|
|
||||||
|
return map
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun gather() {
|
||||||
atlas(BLOCKS_ATLAS).addSource(
|
atlas(BLOCKS_ATLAS).addSource(
|
||||||
ColorizedSpriteSource(
|
ColorizedSpriteSource(getMaskedTextureMap(listOf(
|
||||||
modLocation("block/decorative/tritanium_striped_block_colorless_base"),
|
"block/android_charger",
|
||||||
modLocation("block/decorative/tritanium_striped_block_colorless_stripe"),
|
"block/android_station_base",
|
||||||
modLocation("block/decorative/stripe/tritanium_striped_block"),
|
"block/batterybank_frame",
|
||||||
"_", true, true
|
"block/chemical_generator",
|
||||||
).trackGeneratedTextures(existingFileHelper)
|
"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"
|
||||||
|
)))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,34 +15,26 @@ import net.minecraft.server.packs.resources.ResourceManager
|
|||||||
import net.minecraft.server.packs.resources.ResourceMetadata
|
import net.minecraft.server.packs.resources.ResourceMetadata
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
import net.neoforged.neoforge.client.event.RegisterSpriteSourceTypesEvent
|
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.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters.loc
|
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 {
|
class ColorizedSpriteSource(val textures: Map<ResourceLocation, ResourceLocation>) : SpriteSource {
|
||||||
override fun run(
|
override fun run(
|
||||||
manager: ResourceManager,
|
manager: ResourceManager,
|
||||||
output: SpriteSource.Output
|
output: SpriteSource.Output
|
||||||
) {
|
) {
|
||||||
val baseRes = manager.getResource(TEXTURE_ID_CONVERTER.idToFile(base)).get()
|
for (entry in textures) {
|
||||||
val maskRes = manager.getResource(TEXTURE_ID_CONVERTER.idToFile(overlay)).get()
|
val baseRes = manager.getResource(TEXTURE_ID_CONVERTER.idToFile(entry.key)).get()
|
||||||
|
val maskRes = manager.getResource(TEXTURE_ID_CONVERTER.idToFile(entry.value)).get()
|
||||||
|
|
||||||
for (baseTint in DyeColor.entries) {
|
DyeColor.entries.forEach {
|
||||||
for (overlayTint in DyeColor.entries) {
|
val outputLocation = entry.key.withSuffix("/" + it.serializedName)
|
||||||
if (tintBase && baseTint == overlayTint) continue
|
|
||||||
|
|
||||||
var outputLocation = outputPathBase
|
val baseImage = LazyLoadedImage(entry.key, baseRes, 1)
|
||||||
if (tintBase) outputLocation = outputLocation.withSuffix(outputPathSuffix + baseTint.serializedName)
|
val maskImage = LazyLoadedImage(entry.value, maskRes, 1)
|
||||||
if (tintOverlay) outputLocation = outputLocation.withSuffix(outputPathSuffix + overlayTint.serializedName)
|
|
||||||
|
|
||||||
val baseImage = LazyLoadedImage(base, baseRes, 1)
|
output.add(outputLocation, Supplier(baseImage, maskImage, it, outputLocation))
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,25 +42,7 @@ class ColorizedSpriteSource(val base: ResourceLocation, val overlay: ResourceLoc
|
|||||||
return SPRITE_SOURCE!!
|
return SPRITE_SOURCE!!
|
||||||
}
|
}
|
||||||
|
|
||||||
fun trackGeneratedTextures(efh: ExistingFileHelper) : ColorizedSpriteSource {
|
class Supplier(val baseImage: LazyLoadedImage, val maskImage: LazyLoadedImage, val color: DyeColor, val outputLocation: ResourceLocation) : SpriteSource.SpriteSupplier {
|
||||||
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? {
|
override fun apply(t: SpriteResourceLoader?): SpriteContents? {
|
||||||
val base = baseImage.get()
|
val base = baseImage.get()
|
||||||
val mask = maskImage.get()
|
val mask = maskImage.get()
|
||||||
@ -77,28 +51,14 @@ class ColorizedSpriteSource(val base: ResourceLocation, val overlay: ResourceLoc
|
|||||||
throw IllegalArgumentException("Base image doesn't match mask in texture size")
|
throw IllegalArgumentException("Base image doesn't match mask in texture size")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseTint != null) {
|
val diffCol = RGBAColor.argb(color.textureDiffuseColor)
|
||||||
val baseDiffCol = RGBAColor.argb(baseTint.textureDiffuseColor)
|
mask.applyToAllPixels {
|
||||||
base.applyToAllPixels {
|
val a = (it and -0x1000000 ushr 24) / 255f
|
||||||
val a = (it and -0x1000000 ushr 24) / 255f
|
val b = (it and 0xFF0000 ushr 16) / 255f
|
||||||
val b = (it and 0xFF0000 ushr 16) / 255f
|
val g = (it and 0xFF00 ushr 8) / 255f
|
||||||
val g = (it and 0xFF00 ushr 8) / 255f
|
val r = (it and 0xFF) / 255f
|
||||||
val r = (it and 0xFF) / 255f
|
|
||||||
|
|
||||||
RGBAColor(r * baseDiffCol.red, g * baseDiffCol.green, b * baseDiffCol.blue, a).toRGBA()
|
RGBAColor(r * diffCol.red, g * diffCol.green, b * diffCol.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 (i in 0 until base.width) {
|
||||||
@ -119,13 +79,7 @@ class ColorizedSpriteSource(val base: ResourceLocation, val overlay: ResourceLoc
|
|||||||
|
|
||||||
private val CODEC: MapCodec<ColorizedSpriteSource> = RecordCodecBuilder.mapCodec {
|
private val CODEC: MapCodec<ColorizedSpriteSource> = RecordCodecBuilder.mapCodec {
|
||||||
it.group(
|
it.group(
|
||||||
ResourceLocation.CODEC.fieldOf("base").forGetter { it.base },
|
Codec.unboundedMap(ResourceLocation.CODEC, ResourceLocation.CODEC).fieldOf("textures").forGetter { it.textures }
|
||||||
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)
|
).apply(it, ::ColorizedSpriteSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 463 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 439 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 463 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 439 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 463 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 439 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 463 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 439 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 463 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 439 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 463 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 439 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 458 B |