[WIP] beginning port to 1.16.5

+most of the stuff is working
This commit is contained in:
octarine-noise
2021-05-14 22:40:04 +02:00
parent 79ef6cfaa9
commit 81d3a2eba4
30 changed files with 89 additions and 85 deletions
@@ -66,7 +66,7 @@ interface ModelBakingKey {
object BakeWrapperManager : HasLogger(), Invalidator, ModelLoadingCallback, ClientSpriteRegistryCallback, BlockModelsReloadCallback {
init {
ModelLoadingCallback.EVENT.register(this)
ClientSpriteRegistryCallback.event(SpriteAtlasTexture.BLOCK_ATLAS_TEX).register(this)
ClientSpriteRegistryCallback.event(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE).register(this)
}
val discoverers = mutableListOf<ModelDiscovery>()
override val callbacks = mutableListOf<WeakReference<()->Unit>>()
@@ -4,6 +4,7 @@ import com.google.common.base.Joiner
import mods.betterfoliage.util.HasLogger
import mods.betterfoliage.util.YarnHelper
import mods.betterfoliage.util.get
import net.minecraft.block.Block
import net.minecraft.client.render.block.BlockModels
import net.minecraft.client.render.model.ModelLoader
import net.minecraft.client.render.model.json.JsonUnbakedModel
@@ -19,7 +20,7 @@ abstract class AbstractModelDiscovery : HasLogger(), ModelDiscovery {
sprites: MutableSet<Identifier>,
replacements: MutableMap<Identifier, ModelBakingKey>
) {
Registry.BLOCK
(Registry.BLOCK as Iterable<Block>)
.flatMap { block -> block.stateManager.states }
.forEach { state ->
val location = BlockModels.getModelId(state)
@@ -3,24 +3,20 @@ package mods.betterfoliage.resource.generated
import mods.betterfoliage.util.Atlas
import mods.betterfoliage.util.HasLogger
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener
import net.minecraft.client.resource.ClientResourcePackProfile
import net.minecraft.resource.*
import net.minecraft.resource.ResourceType.CLIENT_RESOURCES
import net.minecraft.resource.metadata.ResourceMetadataReader
import net.minecraft.text.LiteralText
import net.minecraft.util.Identifier
import net.minecraft.util.profiler.Profiler
import org.apache.logging.log4j.Level
import org.apache.logging.log4j.Level.INFO
import org.apache.logging.log4j.Logger
import java.io.IOException
import java.lang.IllegalStateException
import java.util.*
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ExecutionException
import java.util.concurrent.Executor
import java.util.function.Consumer
import java.util.function.Predicate
import java.util.function.Supplier
/**
* [ResourcePack] containing generated block textures
@@ -69,21 +65,18 @@ class GeneratedBlockTexturePack(
type == CLIENT_RESOURCES && resources.containsKey(id)
/**
* Supplier for this resource pack. Adds pack as always-on and hidden.
* Provider for this resource pack. Adds pack as always-on and hidden.
*/
val finder = object : ResourcePackProvider {
val packInfo = ClientResourcePackProfile(
packName, true, Supplier { this@GeneratedBlockTexturePack },
val packInfo = ResourcePackProfile(
packName, true, { this@GeneratedBlockTexturePack },
LiteralText(packName),
LiteralText(packDesc),
ResourcePackCompatibility.COMPATIBLE, ResourcePackProfile.InsertionPosition.TOP, true, null
)
override fun <T : ResourcePackProfile> register(
registry: MutableMap<String, T>,
factory: ResourcePackProfile.Factory<T>
) {
(registry as MutableMap<String, ResourcePackProfile>)[reloadId.toString()] = packInfo
override fun register(consumer: Consumer<ResourcePackProfile>, factory: ResourcePackProfile.Factory) {
consumer.accept(packInfo)
}
}