Compare commits
2 Commits
1.16.5-Fab
...
1.14.4-For
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa91aed58e | ||
|
|
802862f151 |
@@ -15,20 +15,13 @@ dependencies {
|
|||||||
"minecraft"("net.minecraftforge:forge:${properties["mcVersion"]}-${properties["forgeVersion"]}")
|
"minecraft"("net.minecraftforge:forge:${properties["mcVersion"]}-${properties["forgeVersion"]}")
|
||||||
|
|
||||||
"implementation"("kottle:Kottle:${properties["kottleVersion"]}")
|
"implementation"("kottle:Kottle:${properties["kottleVersion"]}")
|
||||||
|
|
||||||
"implementation"("org.spongepowered:mixin:0.8-SNAPSHOT")
|
"implementation"("org.spongepowered:mixin:0.8-SNAPSHOT")
|
||||||
annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configurations["annotationProcessor"].extendsFrom(configurations["implementation"])
|
||||||
sourceSets {
|
sourceSets {
|
||||||
get("main").ext["refMap"] = "betterfoliage.refmap.json"
|
get("main").ext["refMap"] = "betterfoliage.refmap.json"
|
||||||
get("main").resources.srcDir("src/forge/resources")
|
|
||||||
get("main").java.srcDir("src/forge/java")
|
|
||||||
}
|
}
|
||||||
kotlin.sourceSets {
|
|
||||||
get("main").kotlin.srcDir("src/forge/kotlin")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings(properties["mappingsChannel"] as String, properties["mappingsVersion"] as String)
|
mappings(properties["mappingsChannel"] as String, properties["mappingsVersion"] as String)
|
||||||
@@ -62,4 +55,5 @@ tasks.getByName<Jar>("jar") {
|
|||||||
attributes["Implementation-Version"] = project.version
|
attributes["Implementation-Version"] = project.version
|
||||||
}
|
}
|
||||||
exclude("net")
|
exclude("net")
|
||||||
|
filesMatching("META-INF/mods.toml") { expand(project.properties) }
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ org.gradle.daemon=false
|
|||||||
group = com.github.octarine-noise
|
group = com.github.octarine-noise
|
||||||
jarName = BetterFoliage-Forge
|
jarName = BetterFoliage-Forge
|
||||||
|
|
||||||
version = 2.3.1
|
version = 2.5.0
|
||||||
|
|
||||||
mcVersion = 1.14.4
|
mcVersion = 1.14.4
|
||||||
forgeVersion = 28.1.109
|
forgeVersion = 28.1.109
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package mods.betterfoliage.mixin;
|
package mods.betterfoliage.mixin;
|
||||||
|
|
||||||
import mods.betterfoliage.BetterFoliage;
|
import mods.betterfoliage.BetterFoliage;
|
||||||
import mods.octarinecore.client.resource.AsnycSpriteProviderManager;
|
|
||||||
import net.minecraft.client.renderer.model.ModelBakery;
|
import net.minecraft.client.renderer.model.ModelBakery;
|
||||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||||
import net.minecraft.profiler.IProfiler;
|
import net.minecraft.profiler.IProfiler;
|
||||||
@@ -19,9 +18,12 @@ abstract public class MixinModelBakery {
|
|||||||
|
|
||||||
@Redirect(method = processLoading, at = @At(value = "INVOKE", target = stitch))
|
@Redirect(method = processLoading, at = @At(value = "INVOKE", target = stitch))
|
||||||
AtlasTexture.SheetData onStitchModelTextures(AtlasTexture atlas, IResourceManager manager, Iterable<ResourceLocation> idList, IProfiler profiler) {
|
AtlasTexture.SheetData onStitchModelTextures(AtlasTexture atlas, IResourceManager manager, Iterable<ResourceLocation> idList, IProfiler profiler) {
|
||||||
AsnycSpriteProviderManager.StitchWrapper wrapper = BetterFoliage.INSTANCE.getBlockSprites().prepare(this, atlas, manager, idList, profiler);
|
return BetterFoliage.INSTANCE.getBlockSprites().finish(
|
||||||
AtlasTexture.SheetData sheet = atlas.stitch(manager, wrapper.getIdList(), profiler);
|
atlas.stitch(
|
||||||
wrapper.complete(sheet);
|
manager,
|
||||||
return sheet;
|
BetterFoliage.INSTANCE.getBlockSprites().prepare(this, manager, idList, profiler),
|
||||||
|
profiler
|
||||||
|
), profiler
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,13 @@ public class MixinParticleManager {
|
|||||||
@SuppressWarnings("UnresolvedMixinReference")
|
@SuppressWarnings("UnresolvedMixinReference")
|
||||||
@Redirect(method = "*", at = @At(value = "INVOKE", target = stitch))
|
@Redirect(method = "*", at = @At(value = "INVOKE", target = stitch))
|
||||||
AtlasTexture.SheetData onStitchModelTextures(AtlasTexture atlas, IResourceManager manager, Iterable<ResourceLocation> idList, IProfiler profiler) {
|
AtlasTexture.SheetData onStitchModelTextures(AtlasTexture atlas, IResourceManager manager, Iterable<ResourceLocation> idList, IProfiler profiler) {
|
||||||
AsnycSpriteProviderManager.StitchWrapper wrapper = BetterFoliage.INSTANCE.getParticleSprites().prepare(this, atlas, manager, idList, profiler);
|
return BetterFoliage.INSTANCE.getParticleSprites().finish(
|
||||||
AtlasTexture.SheetData sheet = atlas.stitch(manager, wrapper.getIdList(), profiler);
|
atlas.stitch(
|
||||||
wrapper.complete(sheet);
|
manager,
|
||||||
return sheet;
|
BetterFoliage.INSTANCE.getParticleSprites().prepare(this, manager, idList, profiler),
|
||||||
|
profiler
|
||||||
|
), profiler
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ object Client {
|
|||||||
// init mod integrations
|
// init mod integrations
|
||||||
val integrations = listOf(
|
val integrations = listOf(
|
||||||
ShadersModIntegration,
|
ShadersModIntegration,
|
||||||
OptifineCustomColors,
|
OptifineCustomColors
|
||||||
ForestryIntegration,
|
// ForestryIntegration,
|
||||||
IC2RubberIntegration,
|
// IC2RubberIntegration,
|
||||||
TechRebornRubberIntegration
|
// TechRebornRubberIntegration
|
||||||
)
|
)
|
||||||
|
|
||||||
LeafParticleRegistry.init()
|
LeafParticleRegistry.init()
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ object Config : DelegatingConfig(BetterFoliageMod.MOD_ID, BetterFoliageMod.MOD_I
|
|||||||
val windStrength by double(min=0.1, max=2.0, default=0.5)
|
val windStrength by double(min=0.1, max=2.0, default=0.5)
|
||||||
val stormStrength by double(min=0.1, max=2.0, default=0.8)
|
val stormStrength by double(min=0.1, max=2.0, default=0.8)
|
||||||
val size by double(min=0.25, max=1.5, default=0.75).lang("size")
|
val size by double(min=0.25, max=1.5, default=0.75).lang("size")
|
||||||
val chance by double(min=0.001, max=1.0, default=0.05)
|
val chance by double(min=0.001, max=1.0, default=0.02)
|
||||||
val perturb by double(min=0.01, max=1.0, default=0.25)
|
val perturb by double(min=0.01, max=1.0, default=0.25)
|
||||||
val lifetime by double(min=1.0, max=15.0, default=5.0)
|
val lifetime by double(min=1.0, max=15.0, default=5.0)
|
||||||
val opacityHack by boolean(true)
|
val opacityHack by boolean(true)
|
||||||
@@ -153,10 +153,7 @@ object BlockConfig {
|
|||||||
val crops = blocks("crop_default.cfg")
|
val crops = blocks("crop_default.cfg")
|
||||||
val logBlocks = blocks("log_blocks_default.cfg")
|
val logBlocks = blocks("log_blocks_default.cfg")
|
||||||
val logModels = models("log_models_default.cfg")
|
val logModels = models("log_models_default.cfg")
|
||||||
val sand = blocks("sand_default.cfg")
|
|
||||||
val lilypad = blocks("lilypad_default.cfg")
|
val lilypad = blocks("lilypad_default.cfg")
|
||||||
val cactus = blocks("cactus_default.cfg")
|
|
||||||
val netherrack = blocks("netherrack_blocks_default.cfg")
|
|
||||||
|
|
||||||
init { BetterFoliageMod.bus.register(this) }
|
init { BetterFoliageMod.bus.register(this) }
|
||||||
private fun blocks(cfgName: String) = ConfigurableBlockMatcher(BetterFoliage.logDetail, ResourceLocation(BetterFoliageMod.MOD_ID, cfgName)).apply { list.add(this) }
|
private fun blocks(cfgName: String) = ConfigurableBlockMatcher(BetterFoliage.logDetail, ResourceLocation(BetterFoliageMod.MOD_ID, cfgName)).apply { list.add(this) }
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ val ILeafSpriteProvider_getSprite = MethodRef(ILeafSpriteProvider, "getSprite",
|
|||||||
object ForestryIntegration {
|
object ForestryIntegration {
|
||||||
init {
|
init {
|
||||||
if (ModList.get().isLoaded("forestry") && allAvailable(TileLeaves_getLeaveSprite, IAlleleTreeSpecies_getLeafSpriteProvider, ILeafSpriteProvider_getSprite)) {
|
if (ModList.get().isLoaded("forestry") && allAvailable(TileLeaves_getLeaveSprite, IAlleleTreeSpecies_getLeafSpriteProvider, ILeafSpriteProvider_getSprite)) {
|
||||||
|
// Just keep it inactive for now until Forestry updates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import mods.betterfoliage.BetterFoliage
|
|||||||
import mods.betterfoliage.client.render.LogRegistry
|
import mods.betterfoliage.client.render.LogRegistry
|
||||||
import mods.betterfoliage.client.render.column.ColumnTextureInfo
|
import mods.betterfoliage.client.render.column.ColumnTextureInfo
|
||||||
import mods.betterfoliage.client.render.column.SimpleColumnInfo
|
import mods.betterfoliage.client.render.column.SimpleColumnInfo
|
||||||
|
import mods.betterfoliage.client.resource.Sprite
|
||||||
import mods.octarinecore.client.render.CombinedContext
|
import mods.octarinecore.client.render.CombinedContext
|
||||||
import mods.octarinecore.client.render.Quad
|
import mods.octarinecore.client.render.Quad
|
||||||
import mods.octarinecore.client.render.lighting.QuadIconResolver
|
import mods.octarinecore.client.render.lighting.QuadIconResolver
|
||||||
@@ -12,7 +13,6 @@ import mods.octarinecore.common.rotate
|
|||||||
import mods.octarinecore.metaprog.ClassRef
|
import mods.octarinecore.metaprog.ClassRef
|
||||||
import mods.octarinecore.metaprog.allAvailable
|
import mods.octarinecore.metaprog.allAvailable
|
||||||
import net.minecraft.client.renderer.model.BlockModel
|
import net.minecraft.client.renderer.model.BlockModel
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
|
||||||
import net.minecraft.util.Direction
|
import net.minecraft.util.Direction
|
||||||
import net.minecraft.util.Direction.*
|
import net.minecraft.util.Direction.*
|
||||||
import net.minecraft.util.ResourceLocation
|
import net.minecraft.util.ResourceLocation
|
||||||
@@ -20,19 +20,23 @@ import net.minecraftforge.fml.ModList
|
|||||||
import org.apache.logging.log4j.Level
|
import org.apache.logging.log4j.Level
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
|
|
||||||
|
|
||||||
object IC2RubberIntegration {
|
object IC2RubberIntegration {
|
||||||
|
|
||||||
val BlockRubWood = ClassRef<Any>("ic2.core.block.BlockRubWood")
|
val BlockRubWood = ClassRef<Any>("ic2.core.block.BlockRubWood")
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (ModList.get().isLoaded("ic2") && allAvailable(BlockRubWood)) {
|
if (ModList.get().isLoaded("ic2") && allAvailable(BlockRubWood)) {
|
||||||
BetterFoliage.log(Level.INFO, "IC2 rubber support initialized")
|
// keep it inactive for now until IC2 updates
|
||||||
LogRegistry.registries.add(IC2LogDiscovery)
|
// BetterFoliage.log(Level.INFO, "IC2 rubber support initialized")
|
||||||
BetterFoliage.blockSprites.providers.add(IC2LogDiscovery)
|
// LogRegistry.registries.add(IC2LogDiscovery)
|
||||||
|
// BetterFoliage.blockSprites.providers.add(IC2LogDiscovery)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Probably unneeded, as TechReborn went Fabric-only
|
||||||
|
/*
|
||||||
object TechRebornRubberIntegration {
|
object TechRebornRubberIntegration {
|
||||||
|
|
||||||
val BlockRubberLog = ClassRef<Any>("techreborn.blocks.BlockRubberLog")
|
val BlockRubberLog = ClassRef<Any>("techreborn.blocks.BlockRubberLog")
|
||||||
@@ -45,14 +49,15 @@ object TechRebornRubberIntegration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
class RubberLogInfo(
|
class RubberLogInfo(
|
||||||
axis: Axis?,
|
axis: Axis?,
|
||||||
val spotDir: Direction,
|
val spotDir: Direction,
|
||||||
topTexture: TextureAtlasSprite,
|
topTexture: Sprite,
|
||||||
bottomTexture: TextureAtlasSprite,
|
bottomTexture: Sprite,
|
||||||
val spotTexture: TextureAtlasSprite,
|
val spotTexture: Sprite,
|
||||||
sideTextures: List<TextureAtlasSprite>
|
sideTextures: List<Sprite>
|
||||||
) : SimpleColumnInfo(axis, topTexture, bottomTexture, sideTextures) {
|
) : SimpleColumnInfo(axis, topTexture, bottomTexture, sideTextures) {
|
||||||
|
|
||||||
override val side: QuadIconResolver = { ctx: CombinedContext, idx: Int, quad: Quad ->
|
override val side: QuadIconResolver = { ctx: CombinedContext, idx: Int, quad: Quad ->
|
||||||
@@ -116,6 +121,7 @@ object IC2LogDiscovery : ModelDiscovery<ColumnTextureInfo>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
object TechRebornLogDiscovery : ModelDiscovery<ColumnTextureInfo>() {
|
object TechRebornLogDiscovery : ModelDiscovery<ColumnTextureInfo>() {
|
||||||
override val logger = BetterFoliage.logDetail
|
override val logger = BetterFoliage.logDetail
|
||||||
|
|
||||||
@@ -153,3 +159,4 @@ object TechRebornLogDiscovery : ModelDiscovery<ColumnTextureInfo>() {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ object ShadersModIntegration {
|
|||||||
@JvmStatic val isAvailable = allAvailable(SVertexBuilder, SVertexBuilder.pushState, SVertexBuilder.pushNum, SVertexBuilder.pop)
|
@JvmStatic val isAvailable = allAvailable(SVertexBuilder, SVertexBuilder.pushState, SVertexBuilder.pushNum, SVertexBuilder.pop)
|
||||||
|
|
||||||
val defaultLeaves = Blocks.OAK_LEAVES.defaultState
|
val defaultLeaves = Blocks.OAK_LEAVES.defaultState
|
||||||
val defaultGrass = Blocks.TALL_GRASS.defaultState
|
val defaultGrass = Blocks.GRASS.defaultState
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from transformed ShadersMod code.
|
* Called from transformed ShadersMod code.
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import mods.octarinecore.client.render.lighting.*
|
|||||||
import mods.octarinecore.common.allDirections
|
import mods.octarinecore.common.allDirections
|
||||||
import mods.octarinecore.random
|
import mods.octarinecore.random
|
||||||
import net.minecraft.block.material.Material
|
import net.minecraft.block.material.Material
|
||||||
|
import net.minecraft.tags.BlockTags
|
||||||
import net.minecraft.util.Direction.Axis
|
import net.minecraft.util.Direction.Axis
|
||||||
import net.minecraft.util.Direction.UP
|
import net.minecraft.util.Direction.UP
|
||||||
import net.minecraft.util.ResourceLocation
|
import net.minecraft.util.ResourceLocation
|
||||||
@@ -41,7 +42,7 @@ class RenderCoral : RenderDecorator(BetterFoliageMod.MOD_ID, BetterFoliageMod.bu
|
|||||||
Config.enabled && Config.coral.enabled &&
|
Config.enabled && Config.coral.enabled &&
|
||||||
(ctx.state(up2).material == Material.WATER || Config.coral.shallowWater) &&
|
(ctx.state(up2).material == Material.WATER || Config.coral.shallowWater) &&
|
||||||
ctx.state(up1).material == Material.WATER &&
|
ctx.state(up1).material == Material.WATER &&
|
||||||
BlockConfig.sand.matchesClass(ctx.state.block) &&
|
BlockTags.SAND.contains(ctx.state.block) &&
|
||||||
ctx.biome.category.let { it == Biome.Category.OCEAN || it == Biome.Category.BEACH } &&
|
ctx.biome.category.let { it == Biome.Category.OCEAN || it == Biome.Category.BEACH } &&
|
||||||
noise[ctx.pos] < Config.coral.population
|
noise[ctx.pos] < Config.coral.population
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ class RenderGrass : RenderDecorator(BetterFoliageMod.MOD_ID, BetterFoliageMod.bu
|
|||||||
|
|
||||||
val normalIcons = spriteSet { idx -> Identifier(BetterFoliageMod.MOD_ID, "blocks/better_grass_long_$idx") }
|
val normalIcons = spriteSet { idx -> Identifier(BetterFoliageMod.MOD_ID, "blocks/better_grass_long_$idx") }
|
||||||
val snowedIcons = spriteSet { idx -> Identifier(BetterFoliageMod.MOD_ID, "blocks/better_grass_snowed_$idx") }
|
val snowedIcons = spriteSet { idx -> Identifier(BetterFoliageMod.MOD_ID, "blocks/better_grass_snowed_$idx") }
|
||||||
val normalGenIcon by sprite { GeneratedGrass(sprite = "minecraft:blocks/tallgrass", isSnowed = false).register(BetterFoliage.asyncPack) }
|
val normalGenIcon by sprite { GeneratedGrass(sprite = "minecraft:blocks/tall_grass_top", isSnowed = false).register(BetterFoliage.asyncPack) }
|
||||||
val snowedGenIcon by sprite { GeneratedGrass(sprite = "minecraft:blocks/tallgrass", isSnowed = true).register(BetterFoliage.asyncPack) }
|
val snowedGenIcon by sprite { GeneratedGrass(sprite = "minecraft:blocks/tall_grass_top", isSnowed = true).register(BetterFoliage.asyncPack) }
|
||||||
|
|
||||||
val grassModels = modelSet(64) { idx -> grassTopQuads(Config.shortGrass.heightMin, Config.shortGrass.heightMax)(idx) }
|
val grassModels = modelSet(64) { idx -> grassTopQuads(Config.shortGrass.heightMin, Config.shortGrass.heightMax)(idx) }
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import mods.betterfoliage.client.resource.Identifier
|
|||||||
import mods.octarinecore.client.render.*
|
import mods.octarinecore.client.render.*
|
||||||
import mods.octarinecore.client.render.lighting.*
|
import mods.octarinecore.client.render.lighting.*
|
||||||
import mods.octarinecore.random
|
import mods.octarinecore.random
|
||||||
|
import net.minecraft.block.Blocks
|
||||||
import net.minecraft.util.Direction.Axis
|
import net.minecraft.util.Direction.Axis
|
||||||
import net.minecraft.util.Direction.*
|
import net.minecraft.util.Direction.*
|
||||||
import org.apache.logging.log4j.Level.DEBUG
|
import org.apache.logging.log4j.Level.DEBUG
|
||||||
@@ -25,10 +26,8 @@ class RenderNetherrack : RenderDecorator(BetterFoliageMod.MOD_ID, BetterFoliageM
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isEligible(ctx: CombinedContext): Boolean {
|
override fun isEligible(ctx: CombinedContext) =
|
||||||
if (!Config.enabled || !Config.netherrack.enabled) return false
|
Config.enabled && Config.netherrack.enabled && ctx.state.block == Blocks.NETHERRACK
|
||||||
return BlockConfig.netherrack.matchesClass(ctx.state.block)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun render(ctx: CombinedContext) {
|
override fun render(ctx: CombinedContext) {
|
||||||
ctx.render()
|
ctx.render()
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import mods.octarinecore.client.resource.Atlas
|
|||||||
import mods.octarinecore.common.sinkAsync
|
import mods.octarinecore.common.sinkAsync
|
||||||
import net.minecraft.client.particle.ParticleManager
|
import net.minecraft.client.particle.ParticleManager
|
||||||
import net.minecraft.resources.IResourceManager
|
import net.minecraft.resources.IResourceManager
|
||||||
import net.minecraft.util.ResourceLocation
|
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
|
|
||||||
class FixedSpriteSet(val sprites: List<Sprite>) : SpriteSet {
|
class FixedSpriteSet(val sprites: List<Sprite>) : SpriteSet {
|
||||||
@@ -58,7 +57,7 @@ object LeafParticleRegistry : AsyncSpriteProvider<ParticleManager> {
|
|||||||
class TextureMatcher {
|
class TextureMatcher {
|
||||||
|
|
||||||
data class Mapping(val domain: String?, val path: String, val type: String) {
|
data class Mapping(val domain: String?, val path: String, val type: String) {
|
||||||
fun matches(iconLocation: ResourceLocation): Boolean {
|
fun matches(iconLocation: Identifier): Boolean {
|
||||||
return (domain == null || domain == iconLocation.namespace) &&
|
return (domain == null || domain == iconLocation.namespace) &&
|
||||||
iconLocation.path.stripStart("blocks/").contains(path, ignoreCase = true)
|
iconLocation.path.stripStart("blocks/").contains(path, ignoreCase = true)
|
||||||
}
|
}
|
||||||
@@ -66,10 +65,10 @@ class TextureMatcher {
|
|||||||
|
|
||||||
val mappings: MutableList<Mapping> = mutableListOf()
|
val mappings: MutableList<Mapping> = mutableListOf()
|
||||||
|
|
||||||
fun getType(resource: ResourceLocation) = mappings.filter { it.matches(resource) }.map { it.type }.firstOrNull()
|
fun getType(resource: Identifier) = mappings.filter { it.matches(resource) }.map { it.type }.firstOrNull()
|
||||||
fun getType(iconName: String) = ResourceLocation(iconName).let { getType(it) }
|
fun getType(iconName: String) = Identifier(iconName).let { getType(it) }
|
||||||
|
|
||||||
fun loadMappings(mappingLocation: ResourceLocation) {
|
fun loadMappings(mappingLocation: Identifier) {
|
||||||
mappings.clear()
|
mappings.clear()
|
||||||
resourceManager[mappingLocation]?.getLines()?.let { lines ->
|
resourceManager[mappingLocation]?.getLines()?.let { lines ->
|
||||||
lines.filter { !it.startsWith("//") }.filter { !it.isEmpty() }.forEach { line ->
|
lines.filter { !it.startsWith("//") }.filter { !it.isEmpty() }.forEach { line ->
|
||||||
|
|||||||
@@ -34,22 +34,30 @@ class AsnycSpriteProviderManager<SOURCE: Any>(val profilerSection: String) {
|
|||||||
fun complete(sheet: AtlasTexture.SheetData) = onComplete(sheet)
|
fun complete(sheet: AtlasTexture.SheetData) = onComplete(sheet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var currentAtlas: AtlasFuture? = null
|
||||||
|
var currentPhases: List<StitchPhases> = emptyList()
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun prepare(sourceObj: Any, atlas: AtlasTexture, manager: IResourceManager, idList: Iterable<Identifier>, profiler: IProfiler): StitchWrapper {
|
fun prepare(sourceObj: Any, manager: IResourceManager, idList: Iterable<Identifier>, profiler: IProfiler): Set<Identifier> {
|
||||||
profiler.startSection(profilerSection)
|
profiler.startSection(profilerSection)
|
||||||
|
|
||||||
val source = CompletableFuture<SOURCE>()
|
val source = CompletableFuture<SOURCE>()
|
||||||
val atlasFuture = AtlasFuture(idList)
|
currentAtlas = AtlasFuture(idList)
|
||||||
|
|
||||||
val phases = providers.map { it.setup(manager, source, atlasFuture) }
|
currentPhases = providers.map { it.setup(manager, source, currentAtlas!!) }
|
||||||
source.complete(sourceObj as SOURCE)
|
source.complete(sourceObj as SOURCE)
|
||||||
phases.forEach { it.discovery.get() }
|
currentPhases.forEach { it.discovery.get() }
|
||||||
|
|
||||||
return StitchWrapper(atlasFuture.idSet) { sheet ->
|
return currentAtlas!!.idSet
|
||||||
atlasFuture.complete(sheet)
|
|
||||||
phases.forEach { it.cleanup.get() }
|
|
||||||
profiler.endSection()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun finish(sheetData: AtlasTexture.SheetData, profiler: IProfiler): AtlasTexture.SheetData {
|
||||||
|
currentAtlas!!.complete(sheetData)
|
||||||
|
currentPhases.forEach { it.cleanup.get() }
|
||||||
|
currentAtlas = null
|
||||||
|
currentPhases = emptyList()
|
||||||
|
profiler.endSection()
|
||||||
|
return sheetData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,9 +64,9 @@ open class ResourceHandler(
|
|||||||
// ============================
|
// ============================
|
||||||
fun sprite(id: Identifier) = sprite { id }
|
fun sprite(id: Identifier) = sprite { id }
|
||||||
fun sprite(idFunc: ()->Identifier) = AsyncSpriteDelegate(idFunc).apply { BetterFoliage.getSpriteManager(targetAtlas).providers.add(this) }
|
fun sprite(idFunc: ()->Identifier) = AsyncSpriteDelegate(idFunc).apply { BetterFoliage.getSpriteManager(targetAtlas).providers.add(this) }
|
||||||
fun spriteSet(idFunc: (Int)->Identifier) = AsyncSpriteSet(idFunc).apply { BetterFoliage.getSpriteManager(targetAtlas).providers.add(this) }
|
fun spriteSet(idFunc: (Int)->Identifier) = AsyncSpriteSet(targetAtlas, idFunc).apply { BetterFoliage.getSpriteManager(targetAtlas).providers.add(this) }
|
||||||
fun spriteSetTransformed(check: (Int)->Identifier, register: (Identifier)->Identifier) =
|
fun spriteSetTransformed(check: (Int)->Identifier, register: (Identifier)->Identifier) =
|
||||||
AsyncSpriteSet(check, register).apply { BetterFoliage.getSpriteManager(targetAtlas).providers.add(this) }
|
AsyncSpriteSet(targetAtlas, check, register).apply { BetterFoliage.getSpriteManager(targetAtlas).providers.add(this) }
|
||||||
fun model(init: Model.()->Unit) = ModelHolder(init).apply { resources.add(this) }
|
fun model(init: Model.()->Unit) = ModelHolder(init).apply { resources.add(this) }
|
||||||
fun modelSet(num: Int, init: Model.(Int)->Unit) = ModelSet(num, init).apply { resources.add(this) }
|
fun modelSet(num: Int, init: Model.(Int)->Unit) = ModelSet(num, init).apply { resources.add(this) }
|
||||||
fun vectorSet(num: Int, init: (Int)-> Double3) = VectorSet(num, init).apply { resources.add(this) }
|
fun vectorSet(num: Int, init: (Int)-> Double3) = VectorSet(num, init).apply { resources.add(this) }
|
||||||
@@ -108,7 +108,7 @@ interface SpriteSet {
|
|||||||
operator fun get(idx: Int): Sprite
|
operator fun get(idx: Int): Sprite
|
||||||
}
|
}
|
||||||
|
|
||||||
class AsyncSpriteSet(val idFunc: (Int)->Identifier, val transform: (Identifier)->Identifier = { it }) : AsyncSpriteProvider<Any> {
|
class AsyncSpriteSet(val targetAtlas: Atlas = Atlas.BLOCKS, val idFunc: (Int)->Identifier, val transform: (Identifier)->Identifier = { it }) : AsyncSpriteProvider<Any> {
|
||||||
var num = 0
|
var num = 0
|
||||||
protected set
|
protected set
|
||||||
protected var sprites: List<Sprite> = emptyList()
|
protected var sprites: List<Sprite> = emptyList()
|
||||||
@@ -119,7 +119,7 @@ class AsyncSpriteSet(val idFunc: (Int)->Identifier, val transform: (Identifier)-
|
|||||||
return StitchPhases(
|
return StitchPhases(
|
||||||
discovery = sourceF.sink {
|
discovery = sourceF.sink {
|
||||||
list = (0 until 16).map { idFunc(it) }
|
list = (0 until 16).map { idFunc(it) }
|
||||||
.filter { manager.hasResource( Atlas.BLOCKS.wrap(it)) }
|
.filter { manager.hasResource( targetAtlas.wrap(it)) }
|
||||||
.map { transform(it) }
|
.map { transform(it) }
|
||||||
.map { atlas.sprite(it) }
|
.map { atlas.sprite(it) }
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
// Vanilla
|
|
||||||
net.minecraft.block.CactusBlock
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
// Vanilla
|
|
||||||
net.minecraft.block.NetherrackBlock
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
// Vanilla
|
|
||||||
net.minecraft.block.BlockSand
|
|
||||||
|
|
||||||
// TerraFirmaCraft
|
|
||||||
com.bioxx.tfc.Blocks.Terrain.BlockSand
|
|
||||||
Reference in New Issue
Block a user