From a4735d48f871571354b72355b704777caea63cbf Mon Sep 17 00:00:00 2001 From: Bixilon Date: Sun, 1 May 2022 19:34:44 +0200 Subject: [PATCH] bed models --- .../bixilon/minosoft/data/colors/DyeColors.kt | 42 ++++++++ .../data/entities/block/BedBlockEntity.kt | 8 +- .../bixilon/minosoft/data/text/ChatColors.kt | 4 - .../unbaked/block/UnbakedBlockStateModel.kt | 17 +++- .../minecraft/blockstates/orange_bed.json | 34 +++++++ .../models/block/orange_bed_foot.json | 7 ++ .../models/block/orange_bed_head.json | 7 ++ .../models/block/template_bed_foot.json | 98 ++++++++++++++++++ .../models/block/template_bed_head.json | 99 +++++++++++++++++++ 9 files changed, 305 insertions(+), 11 deletions(-) create mode 100644 src/main/java/de/bixilon/minosoft/data/colors/DyeColors.kt create mode 100644 src/main/resources/assets_override/minecraft/blockstates/orange_bed.json create mode 100644 src/main/resources/assets_override/minecraft/models/block/orange_bed_foot.json create mode 100644 src/main/resources/assets_override/minecraft/models/block/orange_bed_head.json create mode 100644 src/main/resources/assets_override/minecraft/models/block/template_bed_foot.json create mode 100644 src/main/resources/assets_override/minecraft/models/block/template_bed_head.json diff --git a/src/main/java/de/bixilon/minosoft/data/colors/DyeColors.kt b/src/main/java/de/bixilon/minosoft/data/colors/DyeColors.kt new file mode 100644 index 000000000..6f1b5cd2a --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/data/colors/DyeColors.kt @@ -0,0 +1,42 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.data.colors + +import de.bixilon.kutil.enums.EnumUtil +import de.bixilon.kutil.enums.ValuesEnum + +enum class DyeColors { + WHITE, + ORANGE, + MAGENTA, + LIGHT_BLUE, + YELLOW, + LIME, + PINK, + GRAY, + LIGHT_GRAY, + CYAN, + PURPLE, + BLUE, + BROWN, + GREEN, + RED, + BLACK, + ; + + companion object : ValuesEnum { + override val VALUES: Array = values() + override val NAME_MAP: Map = EnumUtil.getEnumValues(VALUES) + } +} diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/BedBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/BedBlockEntity.kt index dca59f048..bb9ce8d35 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/BedBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/BedBlockEntity.kt @@ -1,6 +1,6 @@ /* * Minosoft - * Copyright (C) 2021 Moritz Zwerger + * Copyright (C) 2020-2022 Moritz Zwerger * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -13,17 +13,17 @@ package de.bixilon.minosoft.data.entities.block +import de.bixilon.minosoft.data.colors.DyeColors import de.bixilon.minosoft.data.registries.ResourceLocation -import de.bixilon.minosoft.data.text.ChatColors import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection class BedBlockEntity(connection: PlayConnection) : BlockEntity(connection) { - var color = ChatColors.RED + var color = DyeColors.RED private set override fun updateNBT(nbt: Map) { - color = ChatColors.RED // ToDo + color = DyeColors.RED // ToDo } companion object : BlockEntityFactory { diff --git a/src/main/java/de/bixilon/minosoft/data/text/ChatColors.kt b/src/main/java/de/bixilon/minosoft/data/text/ChatColors.kt index c8ebcecbb..8059188b1 100644 --- a/src/main/java/de/bixilon/minosoft/data/text/ChatColors.kt +++ b/src/main/java/de/bixilon/minosoft/data/text/ChatColors.kt @@ -81,10 +81,6 @@ object ChatColors { nameMap[field.name.lowercase()] = color } - - - - this.VALUES = values.toTypedArray() this.NAME_MAP = nameMap.toMap() } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/unbaked/block/UnbakedBlockStateModel.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/unbaked/block/UnbakedBlockStateModel.kt index 18862889f..c176bcbc3 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/unbaked/block/UnbakedBlockStateModel.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/unbaked/block/UnbakedBlockStateModel.kt @@ -39,15 +39,25 @@ import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.get import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.rotateAssign import de.bixilon.minosoft.util.KUtil.toResourceLocation -data class UnbakedBlockStateModel( +class UnbakedBlockStateModel( val model: UnbakedBlockModel, val rotation: Vec2i?, val uvLock: Boolean, val weight: Int, + textures: Map?, ) : AbstractUnbakedBlockModel { var baked: BakedBlockModel? = null - override val textures: Map - get() = model.textures + override var textures: Map = model.textures + private set + + + init { + if (textures != null && textures.isNotEmpty()) { + val textureCopy = model.textures.toMutableMap() + textureCopy.putAll(textures) + this.textures = textureCopy + } + } @Synchronized override fun bake(renderWindow: RenderWindow): BakedBlockModel { @@ -167,6 +177,7 @@ data class UnbakedBlockStateModel( rotation = data.toVec2iN(), uvLock = data["uvlock"]?.toBoolean() ?: false, weight = data["weight"]?.toInt() ?: 1, + textures = data["textures"]?.unsafeCast(), ) } diff --git a/src/main/resources/assets_override/minecraft/blockstates/orange_bed.json b/src/main/resources/assets_override/minecraft/blockstates/orange_bed.json new file mode 100644 index 000000000..358482250 --- /dev/null +++ b/src/main/resources/assets_override/minecraft/blockstates/orange_bed.json @@ -0,0 +1,34 @@ +{ + "variants": { + "part=head,facing=north": { + "model": "minecraft:block/orange_bed_head" + }, + "part=head,facing=east": { + "model": "minecraft:block/orange_bed_head", + "y": 90 + }, + "part=head,facing=south": { + "model": "minecraft:block/orange_bed_head", + "y": 180 + }, + "part=head,facing=west": { + "model": "minecraft:block/orange_bed_head", + "y": 270 + }, + "part=foot,facing=north": { + "model": "minecraft:block/orange_bed_foot" + }, + "part=foot,facing=east": { + "model": "minecraft:block/orange_bed_foot", + "y": 90 + }, + "part=foot,facing=south": { + "model": "minecraft:block/orange_bed_foot", + "y": 180 + }, + "part=foot,facing=west": { + "model": "minecraft:block/orange_bed_foot", + "y": 270 + } + } +} diff --git a/src/main/resources/assets_override/minecraft/models/block/orange_bed_foot.json b/src/main/resources/assets_override/minecraft/models/block/orange_bed_foot.json new file mode 100644 index 000000000..161feb9b4 --- /dev/null +++ b/src/main/resources/assets_override/minecraft/models/block/orange_bed_foot.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/template_bed_foot", + "textures": { + "particle": "minecraft:block/oak_planks", + "bed": "minecraft:entity/bed/orange" + } +} diff --git a/src/main/resources/assets_override/minecraft/models/block/orange_bed_head.json b/src/main/resources/assets_override/minecraft/models/block/orange_bed_head.json new file mode 100644 index 000000000..6d19b7e45 --- /dev/null +++ b/src/main/resources/assets_override/minecraft/models/block/orange_bed_head.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/template_bed_head", + "textures": { + "particle": "minecraft:block/oak_planks", + "bed": "minecraft:entity/bed/orange" + } +} diff --git a/src/main/resources/assets_override/minecraft/models/block/template_bed_foot.json b/src/main/resources/assets_override/minecraft/models/block/template_bed_foot.json new file mode 100644 index 000000000..de02d6531 --- /dev/null +++ b/src/main/resources/assets_override/minecraft/models/block/template_bed_foot.json @@ -0,0 +1,98 @@ +{ + "elements": [ + { + "__comment": "Base", + "from": [0, 3, 0], + "to": [16, 9, 16], + "faces": { + "up": { + "uv": [1.5, 7, 5.5, 11], + "texture": "#bed" + }, + "down": { + "uv": [7, 7, 11, 11], + "texture": "#bed" + }, + "east": { + "uv": [5.5, 7, 7, 11], + "texture": "#bed", + "rotation": 90, + "cullface": "east" + }, + "south": { + "uv": [5.5, 5.5, 9.5, 7], + "texture": "#bed", + "rotation": 180, + "cullface": "south" + }, + "west": { + "uv": [0.0, 7, 1.5, 11], + "texture": "#bed", + "rotation": 270, + "cullface": "west" + } + } + }, + { + "__comment": "left", + "from": [0, 0, 13], + "to": [3, 3, 16], + "faces": { + "down": { + "uv": [14, 3.0, 14.75, 3.75], + "texture": "#bed", + "cullface": "down" + }, + "north": { + "uv": [14.75, 3.75, 15.5, 4.5], + "texture": "#bed", + "cullface": "north" + }, + "west": { + "uv": [12.5, 3.75, 13.25, 4.5], + "texture": "#bed", + "cullface": "west" + }, + "south": { + "uv": [13.25, 3.75, 14, 4.5], + "texture": "#bed" + }, + "east": { + "uv": [14, 3.75, 14.75, 4.5], + "texture": "#bed" + } + } + }, + { + "__comment": "right", + "from": [13, 0, 13], + "to": [16, 3, 16], + "faces": { + "down": { + "uv": [14, 4.5, 14.75, 5.25], + "texture": "#bed", + "rotation": 90, + "cullface": "down" + }, + "north": { + "uv": [14, 5.25, 14.75, 6], + "texture": "#bed", + "cullface": "north" + }, + "west": { + "uv": [14.75, 5.25, 15.5, 6], + "texture": "#bed" + }, + "south": { + "uv": [12.5, 5.25, 13.25, 6], + "texture": "#bed" + }, + "east": { + "uv": [13.25, 5.25, 14, 6], + "texture": "#bed", + "cullface": "east" + } + } + } + ] +} diff --git a/src/main/resources/assets_override/minecraft/models/block/template_bed_head.json b/src/main/resources/assets_override/minecraft/models/block/template_bed_head.json new file mode 100644 index 000000000..5ed9e7f60 --- /dev/null +++ b/src/main/resources/assets_override/minecraft/models/block/template_bed_head.json @@ -0,0 +1,99 @@ +{ + "elements": [ + { + "__comment": "Base", + "from": [0, 3, 0], + "to": [16, 9, 16], + "faces": { + "up": { + "uv": [1.5, 1.5, 5.5, 5.5], + "texture": "#bed" + }, + "down": { + "uv": [7, 1.5, 11, 5.5], + "texture": "#bed" + }, + "east": { + "uv": [5.5, 1.5, 7, 5.5], + "texture": "#bed", + "rotation": 90, + "cullface": "east" + }, + "north": { + "uv": [1.5, 0.0, 5.5, 1.5], + "texture": "#bed", + "rotation": 180, + "cullface": "north" + }, + "west": { + "uv": [0.0, 1.5, 1.5, 5.5], + "texture": "#bed", + "rotation": 270, + "cullface": "west" + } + } + }, + { + "__comment": "left", + "from": [0, 0, 0], + "to": [3, 3, 3], + "faces": { + "down": { + "uv": [14, 0, 14.75, 0.75], + "texture": "#bed", + "rotation": 270, + "cullface": "down" + }, + "north": { + "uv": [12.5, 0.75, 13.25, 1.5], + "texture": "#bed", + "cullface": "north" + }, + "west": { + "uv": [13.25, 0.75, 14, 1.5], + "texture": "#bed", + "cullface": "west" + }, + "south": { + "uv": [14, 0.75, 14.75, 1.5], + "texture": "#bed" + }, + "east": { + "uv": [14.75, 0.75, 15.5, 1.5], + "texture": "#bed" + } + } + }, + { + "__comment": "right", + "from": [13, 0, 0], + "to": [16, 3, 3], + "faces": { + "down": { + "uv": [14, 1.5, 14.75, 2.25], + "texture": "#bed", + "rotation": 180, + "cullface": "down" + }, + "north": { + "uv": [13.25, 2.25, 14, 3.0], + "texture": "#bed", + "cullface": "north" + }, + "west": { + "uv": [14, 2.25, 14.75, 3.0], + "texture": "#bed" + }, + "south": { + "uv": [14.75, 2.25, 15.5, 3.0], + "texture": "#bed" + }, + "east": { + "uv": [12.5, 2.25, 13.25, 3.0], + "texture": "#bed", + "cullface": "east" + } + } + } + ] +}