diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/storage/chest/DoubleChestRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/storage/chest/DoubleChestRenderer.kt index 1b2625760..1d2c11752 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/storage/chest/DoubleChestRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/storage/chest/DoubleChestRenderer.kt @@ -22,7 +22,7 @@ import de.bixilon.minosoft.data.registries.identified.ResourceLocation import de.bixilon.minosoft.gui.rendering.RenderContext import de.bixilon.minosoft.gui.rendering.chunk.entities.EntityRendererRegister import de.bixilon.minosoft.gui.rendering.models.loader.ModelLoader -import de.bixilon.minosoft.gui.rendering.models.loader.SkeletalLoader.Companion.bbModel +import de.bixilon.minosoft.gui.rendering.models.loader.SkeletalLoader.Companion.sModel import de.bixilon.minosoft.gui.rendering.skeletal.baked.BakedSkeletalModel import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture @@ -36,36 +36,58 @@ class DoubleChestRenderer( ) : ChestRenderer(state, model.createInstance(context), position, light) { companion object { - val DOUBLE_MODEL = minecraft("block/entities/double_chest").bbModel() - private val named = arrayOf(minecraft("left"), minecraft("right")) + private val MODEL = minecraft("block/entities/chest/double").sModel() + private val MODEL_5 = minecraft("block/entities/chest/double_5").sModel() - private fun register(loader: ModelLoader, name: ResourceLocation, textures: Array) { + private val TEXTURE = minecraft("chest") + private val TEXTURE_5 = arrayOf(minecraft("left"), minecraft("right")) + + private fun register(loader: ModelLoader, name: ResourceLocation, texture: ResourceLocation) { + val static = loader.context.textures.staticTextures + val override = mapOf(TEXTURE to static.createTexture(texture)) + loader.skeletal.register(name, MODEL, override) + } + + private fun register5(loader: ModelLoader, name: ResourceLocation, textures: Array) { if (textures.size != 2) throw IllegalStateException("Textures must be left and right!") val static = loader.context.textures.staticTextures val override = mapOf( - named[0] to static.createTexture(textures[0]), - named[1] to static.createTexture(textures[1]), + TEXTURE_5[0] to static.createTexture(textures[0]), + TEXTURE_5[1] to static.createTexture(textures[1]), ) - loader.skeletal.register(name, DOUBLE_MODEL, override) + loader.skeletal.register(name, MODEL_5, override) } } object NormalChest : EntityRendererRegister { - val NAME = minecraft("block/entities/double_chest") - private val textures = arrayOf(minecraft("entity/chest/normal_left").texture(), minecraft("entity/chest/normal_right").texture()) - private val christmas = arrayOf(minecraft("entity/chest/christmas_left").texture(), minecraft("entity/chest/christmas_right").texture()) + val NAME = minecraft("block/entities/chest/double") + private val TEXTURE = minecraft("entity/chest/normal_double").texture() + private val TEXTURE_5 = arrayOf(minecraft("entity/chest/normal_left").texture(), minecraft("entity/chest/normal_right").texture()) + private val CHRISTMAS = minecraft("entity/chest/christmas_double").texture() + private val CHRISTMAS_5 = arrayOf(minecraft("entity/chest/christmas_left").texture(), minecraft("entity/chest/christmas_right").texture()) override fun register(loader: ModelLoader) { - register(loader, NAME, if (DateUtil.christmas) christmas else textures) + val christmas = DateUtil.christmas + + if (loader.packFormat < 5) { + register(loader, NAME, if (christmas) CHRISTMAS else TEXTURE) + } else { + register5(loader, NAME, if (christmas) CHRISTMAS_5 else TEXTURE_5) + } } } object TrappedChest : EntityRendererRegister { - val NAME = minecraft("block/entities/double_trapped_chest") - private val textures = arrayOf(minecraft("entity/chest/trapped_left").texture(), minecraft("entity/chest/trapped_right").texture()) + val NAME = minecraft("block/entities/chest/double_trapped") + private val TEXTURE = minecraft("entity/chest/trapped_double").texture() + private val TEXTURE_5 = arrayOf(minecraft("entity/chest/trapped_left").texture(), minecraft("entity/chest/trapped_right").texture()) override fun register(loader: ModelLoader) { - register(loader, NAME, textures) + if (loader.packFormat < 5) { + register(loader, NAME, TEXTURE) + } else { + register5(loader, NAME, TEXTURE_5) + } } } } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/storage/chest/SingleChestRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/storage/chest/SingleChestRenderer.kt index 8470d2aed..1a97e3cc7 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/storage/chest/SingleChestRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/storage/chest/SingleChestRenderer.kt @@ -36,7 +36,7 @@ class SingleChestRenderer( ) : ChestRenderer(state, model.createInstance(context), position, light) { companion object { - val SINGLE_MODEL = minecraft("block/entities/single_chest").sModel() + val SINGLE_MODEL = minecraft("block/entities/chest/single").sModel() private val named = minecraft("chest") fun register(loader: ModelLoader, name: ResourceLocation, texture: ResourceLocation) { @@ -46,7 +46,7 @@ class SingleChestRenderer( } object NormalChest : EntityRendererRegister { - val NAME = minecraft("block/entities/single_chest") + val NAME = minecraft("block/entities/chest/single") val TEXTURE = minecraft("entity/chest/normal").texture() val TEXTURE_CHRISTMAS = minecraft("entity/chest/christmas").texture() @@ -56,7 +56,7 @@ class SingleChestRenderer( } object TrappedChest : EntityRendererRegister { - val NAME = minecraft("block/entities/trapped_chest") + val NAME = minecraft("block/entities/chest/trapped") val TEXTURE = minecraft("entity/chest/trapped").texture() override fun register(loader: ModelLoader) { @@ -65,7 +65,7 @@ class SingleChestRenderer( } object EnderChest : EntityRendererRegister { - val NAME = minecraft("block/entities/ender_chest") + val NAME = minecraft("block/entities/chest/ender") val TEXTURE = minecraft("entity/chest/ender").texture() override fun register(loader: ModelLoader) { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/loader/SkeletalLoader.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/loader/SkeletalLoader.kt index 4141ffb47..94dd5ee29 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/loader/SkeletalLoader.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/loader/SkeletalLoader.kt @@ -23,9 +23,6 @@ import de.bixilon.minosoft.data.registries.identified.ResourceLocationUtil.exten import de.bixilon.minosoft.gui.rendering.skeletal.baked.BakedSkeletalModel import de.bixilon.minosoft.gui.rendering.skeletal.model.SkeletalModel import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture -import de.bixilon.minosoft.util.logging.Log -import de.bixilon.minosoft.util.logging.LogLevels -import de.bixilon.minosoft.util.logging.LogMessageType class SkeletalLoader(private val loader: ModelLoader) { private val registered: SynchronizedMap = synchronizedMapOf() @@ -64,10 +61,6 @@ class SkeletalLoader(private val loader: ModelLoader) { } fun register(name: ResourceLocation, template: ResourceLocation = name, override: Map = emptyMap()) { - if (template.path.endsWith(".bbmodel")) { - Log.log(LogMessageType.LOADING, LogLevels.WARN) { "Trying to load bbmodel $template!" } - return // TODO: port double chest renderer to smodel - } val previous = this.registered.put(name, RegisteredModel(template, override)) if (previous != null) throw IllegalArgumentException("A model with the name $name was already registered!") } @@ -80,11 +73,6 @@ class SkeletalLoader(private val loader: ModelLoader) { companion object { - @Deprecated(".sModel()") - fun ResourceLocation.bbModel(): ResourceLocation { - return this.extend(prefix = "models/", suffix = ".bbmodel") - } - fun ResourceLocation.sModel(): ResourceLocation { return this.extend(prefix = "models/", suffix = ".smodel") } diff --git a/src/main/resources/assets/minecraft/models/block/entities/chest/double_5.smodel b/src/main/resources/assets/minecraft/models/block/entities/chest/double_5.smodel new file mode 100644 index 000000000..a83141e72 --- /dev/null +++ b/src/main/resources/assets/minecraft/models/block/entities/chest/double_5.smodel @@ -0,0 +1,105 @@ +{ + "elements": { + "left": { + "from": [-7, 0, -7], + "to": [8, 10, 7], + "texture": "minecraft:left", + "uv": [0, 19], + "faces": { + "down": {}, + "up": {}, + "north": {}, + "south": {}, + "west": {} + }, + "children": { + "lid": { + "offset": [0, 9, 0], + "transform": "lid", + "from": [-7, 0, -7], + "to": [8, 5, 7], + "uv": [0, 0], + "faces": { + "down": {}, + "up": {}, + "north": {}, + "south": {}, + "west": {} + }, + "children": { + "lock": { + "offset": [7, -2, -8], + "from": [0, 0, 0], + "to": [1, 4, 1], + "uv": [0, 0], + "faces": { + "down": {}, + "up": {}, + "north": {}, + "south": {}, + "west": {} + } + } + } + } + } + }, + "right": { + "from": [8, 0, -7], + "to": [23, 10, 7], + "texture": "minecraft:right", + "uv": [0, 19], + "faces": { + "down": {}, + "up": {}, + "north": {}, + "south": {}, + "east": {} + }, + "children": { + "lid": { + "offset": [0, 9, 0], + "transform": "lid", + "from": [8, 0, -7], + "to": [23, 5, 7], + "uv": [0, 0], + "faces": { + "down": {}, + "up": {}, + "north": {}, + "south": {}, + "east": {} + }, + "children": { + "lock": { + "offset": [8, -2, -8], + "from": [0, 0, 0], + "to": [1, 4, 1], + "uv": [0, 0], + "faces": { + "down": {}, + "up": {}, + "north": {}, + "south": {}, + "east": {} + } + } + } + } + } + } + }, + "transforms": { + "lid": { + "pivot": [0, 9, 7] + } + }, + "textures": { + "minecraft:left": { + "resolution": [64, 64] + }, + "minecraft:right": { + "resolution": [64, 64] + } + } +} diff --git a/src/main/resources/assets/minecraft/models/block/entities/chest/single.smodel b/src/main/resources/assets/minecraft/models/block/entities/chest/single.smodel new file mode 100644 index 000000000..0b21ae1d7 --- /dev/null +++ b/src/main/resources/assets/minecraft/models/block/entities/chest/single.smodel @@ -0,0 +1,61 @@ +{ + "elements": { + "body": { + "from": [-7, 0, -7], + "to": [7, 10, 7], + "texture": "minecraft:chest", + "uv": [0, 19], + "faces": { + "down": {}, + "up": {}, + "north": {}, + "south": {}, + "west": {}, + "east": {} + }, + "children": { + "lid": { + "offset": [0, 9, 0], + "transform": "lid", + "from": [-7, 0, -7], + "to": [7, 5, 7], + "uv": [0, 0], + "faces": { + "down": {}, + "up": {}, + "north": {}, + "south": {}, + "west": {}, + "east": {} + }, + "children": { + "lock": { + "offset": [0, -2, -8], + "from": [-1, 0, 0], + "to": [1, 4, 1], + "uv": [0, 0], + "faces": { + "down": {}, + "up": {}, + "north": {}, + "south": {}, + "west": {}, + "east": {} + } + } + } + } + } + } + }, + "transforms": { + "lid": { + "pivot": [0, 9, 7] + } + }, + "textures": { + "minecraft:chest": { + "resolution": [64, 64] + } + } +} diff --git a/src/main/resources/assets/minecraft/models/block/entities/double_chest.bbmodel b/src/main/resources/assets/minecraft/models/block/entities/double_chest.bbmodel deleted file mode 100644 index 2a0c489f4..000000000 --- a/src/main/resources/assets/minecraft/models/block/entities/double_chest.bbmodel +++ /dev/null @@ -1,332 +0,0 @@ -{ - "meta": { - "format_version": "4.0", - "model_format": "free", - "box_uv": true - }, - "name": "double_chest", - "geometry_name": "chest", - "visible_box": [1, 1, 0], - "resolution": { - "width": 64, - "height": 64 - }, - "elements": [ - { - "name": "bottom_left", - "from": [8, -10, -7], - "to": [23, 0, 7], - "rotation": [-180, 0, 0], - "uv_offset": [0, 19], - "faces": { - "north": { - "uv": [14, 33, 29, 43], - "texture": 1 - }, - "east": { - "uv": [0, 33, 14, 43], - "texture": 1 - }, - "south": { - "uv": [43, 33, 58, 43], - "texture": 1 - }, - "west": { - "uv": [29, 33, 43, 43], - "texture": 1 - }, - "up": { - "uv": [29, 33, 14, 19], - "texture": 1 - }, - "down": { - "uv": [44, 19, 29, 33], - "texture": 1 - } - }, - "uuid": "76801e5b-8a1b-0a5d-c258-beef5dbc79ee" - }, - { - "name": "lid_left", - "from": [8, -14, -7], - "to": [23, -9, 7], - "rotation": [-180, 0, 0], - "faces": { - "north": { - "uv": [14, 14, 29, 19], - "texture": 1 - }, - "east": { - "uv": [0, 14, 14, 19], - "texture": 1 - }, - "south": { - "uv": [43, 14, 58, 19], - "texture": 1 - }, - "west": { - "uv": [29, 14, 43, 19], - "texture": 1 - }, - "up": { - "uv": [29, 14, 14, 0], - "texture": 1 - }, - "down": { - "uv": [44, 0, 29, 14], - "texture": 1 - } - }, - "uuid": "01d53de6-eeef-3c77-dd07-6f6d52b0527b" - }, - { - "name": "lock_left", - "from": [-9, -11, -8], - "to": [-8, -7, -7], - "rotation": [0, 0, -180], - "faces": { - "north": { - "uv": [1, 1, 2, 5], - "texture": 0 - }, - "east": { - "uv": [0, 1, 1, 5], - "texture": 0 - }, - "south": { - "uv": [3, 1, 4, 5], - "texture": 0 - }, - "west": { - "uv": [2, 1, 3, 5], - "texture": 0 - }, - "up": { - "uv": [2, 1, 1, 0], - "texture": 0 - }, - "down": { - "uv": [3, 0, 2, 1], - "texture": 0 - } - }, - "uuid": "3cc1a7d6-4cf0-42bc-032f-1b3a602ca1f6" - }, - { - "name": "bottom_right", - "from": [-7, -10, -7], - "to": [8, 0, 7], - "rotation": [-180, 0, 0], - "uv_offset": [0, 19], - "faces": { - "north": { - "uv": [14, 33, 29, 43], - "texture": 0 - }, - "east": { - "uv": [0, 33, 14, 43], - "texture": 0 - }, - "south": { - "uv": [43, 33, 58, 43], - "texture": 0 - }, - "west": { - "uv": [29, 33, 43, 43], - "texture": 0 - }, - "up": { - "uv": [29, 33, 14, 19], - "texture": 0 - }, - "down": { - "uv": [44, 19, 29, 33], - "texture": 0 - } - }, - "uuid": "803e6dc7-ed11-6324-fd9f-3f22b1d809e8" - }, - { - "name": "lid_right", - "from": [-7, -14, -7], - "to": [8, -9, 7], - "rotation": [-180, 0, 0], - "faces": { - "north": { - "uv": [14, 14, 29, 19], - "texture": 0 - }, - "east": { - "uv": [0, 14, 14, 19], - "texture": 0 - }, - "south": { - "uv": [43, 14, 58, 19], - "texture": 0 - }, - "west": { - "uv": [29, 14, 43, 19], - "texture": 0 - }, - "up": { - "uv": [29, 14, 14, 0], - "texture": 0 - }, - "down": { - "uv": [44, 0, 29, 14], - "texture": 0 - } - }, - "uuid": "5fdcaa6f-15bd-6696-9e45-a7a4143b40d6" - }, - { - "name": "lock_right", - "from": [-8, -11, -8], - "to": [-7, -7, -7], - "rotation": [0, 0, -180], - "faces": { - "north": { - "uv": [1, 1, 2, 5], - "texture": 0 - }, - "east": { - "uv": [0, 1, 1, 5], - "texture": 0 - }, - "south": { - "uv": [3, 1, 4, 5], - "texture": 0 - }, - "west": { - "uv": [2, 1, 3, 5], - "texture": 0 - }, - "up": { - "uv": [2, 1, 1, 0], - "texture": 0 - }, - "down": { - "uv": [3, 0, 2, 1], - "texture": 0 - } - }, - "uuid": "1fdffae9-b046-1951-ff2a-fd3f30db2514" - } - ], - "outliner": [ - { - "name": "root", - "origin": [8, 8, 8], - "uuid": "17d8814a-c29f-abdc-4f4a-c9b07cd032df", - "children": [ - "76801e5b-8a1b-0a5d-c258-beef5dbc79ee", - "803e6dc7-ed11-6324-fd9f-3f22b1d809e8", - { - "name": "lid", - "origin": [0, 10, 7], - "uuid": "c9b45550-2e8b-af52-a981-4aedc81fb456", - "children": ["01d53de6-eeef-3c77-dd07-6f6d52b0527b", "5fdcaa6f-15bd-6696-9e45-a7a4143b40d6", "3cc1a7d6-4cf0-42bc-032f-1b3a602ca1f6", "1fdffae9-b046-1951-ff2a-fd3f30db2514"] - } - ] - } - ], - "textures": [ - { - "path": "entity/chest/normal_left", - "name": "normal_left", - "namespace": "minecraft", - "id": 0, - "uuid": "9038a773-2512-f607-b2da-58c3649228ad" - }, - { - "path": "entity/chest/normal_right", - "name": "normal_right", - "namespace": "minecraft", - "id": 1, - "uuid": "dbef04c5-267c-2d45-5fcb-190a93892a20" - } - ], - "animations": [ - { - "uuid": "d951b58f-d87c-519b-c3a7-22db3d46871c", - "name": "animation.chest.opening", - "loop": "hold", - "length": 0.3, - "animators": { - "c9b45550-2e8b-af52-a981-4aedc81fb456": { - "name": "lid", - "type": "bone", - "keyframes": [ - { - "channel": "rotation", - "data_points": [ - { - "x": 0, - "y": 0, - "z": 0 - } - ], - "uuid": "d595c66b-58da-743a-223e-baff1a2910f1", - "time": 0, - "color": -1, - "interpolation": "sine" - }, - { - "channel": "rotation", - "data_points": [ - { - "x": -90, - "y": 0, - "z": 0 - } - ], - "uuid": "ac945fe7-65b4-1f09-dc05-782860c4aa7c", - "time": 0.3, - "interpolation": "sine" - } - ] - } - } - }, - { - "uuid": "581b97d7-b54c-456f-e91e-7b619572a530", - "name": "animation.chest.closing", - "loop": "hold", - "length": 0.5, - "animators": { - "c9b45550-2e8b-af52-a981-4aedc81fb456": { - "name": "lid", - "type": "bone", - "keyframes": [ - { - "channel": "rotation", - "data_points": [ - { - "x": -90, - "y": 0, - "z": 0 - } - ], - "uuid": "ac945fe7-65b4-1f09-dc05-782860c4aa7c", - "time": 0, - "interpolation": "sine" - }, - { - "channel": "rotation", - "data_points": [ - { - "x": 0, - "y": 0, - "z": 0 - } - ], - "uuid": "8ef02eb5-7b0c-462d-42ab-cce77b9a4497", - "time": 0.5, - "interpolation": "sine" - } - ] - } - } - } - ] -} diff --git a/src/main/resources/assets/minecraft/models/block/entities/single_chest.smodel b/src/main/resources/assets/minecraft/models/block/entities/single_chest.smodel deleted file mode 100644 index 138676a92..000000000 --- a/src/main/resources/assets/minecraft/models/block/entities/single_chest.smodel +++ /dev/null @@ -1,58 +0,0 @@ -{ - "elements": { - "body": { - "from": [-7, 0, -7], - "to": [7, 10, 7], - "texture": "minecraft:chest", - "faces": { - "down": {"uv": [14, 19, 28, 33]}, - "up": {"uv": [28, 33, 42, 19]}, - "north": {"uv": [42, 33, 56, 43]}, - "south": {"uv": [14, 33, 28, 43]}, - "west": {"uv": [28, 33, 42, 43]}, - "east": {"uv": [0, 33, 14, 43]} - }, - "children": { - "lid": { - "offset": [0, 9, 0], - "transform": "lid", - "from": [-7, 0, -7], - "to": [7, 5, 7], - "faces": { - "down": {"uv": [14, 0, 28, 14]}, - "up": {"uv": [28, 14, 42, 0]}, - "north": {"uv": [42, 14, 56, 19]}, - "south": {"uv": [14, 14, 28, 19]}, - "west": {"uv": [28, 14, 42, 19]}, - "east": {"uv": [0, 14, 14, 19]} - }, - "children": { - "lock": { - "offset": [0, -2, -8], - "from": [-1, 0, 0], - "to": [1, 4, 1], - "faces": { - "down": {"uv": [1, 1, 3, 0]}, - "up": {"uv": [3, 0, 5, 1]}, - "north": {"uv": [4, 1, 6, 5]}, - "south": {"uv": [1, 1, 3, 5]}, - "west": {"uv": [3, 1, 4, 5]}, - "east": {"uv": [0, 1, 1, 5]} - } - } - } - } - } - } - }, - "transforms": { - "lid": { - "pivot": [0, 9, 7] - } - }, - "textures": { - "minecraft:chest": { - "resolution": [64, 64] - } - } -}