data: BlockItem

This commit is contained in:
Bixilon 2021-04-02 23:00:35 +02:00
parent fca91e85b9
commit 026a2d2751
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 29 additions and 1 deletions

View File

@ -198,7 +198,7 @@ data class BlockState(
propertyJsonValue.asInt
}
else -> {
propertyJsonValue.asString.toLowerCase()
propertyJsonValue.asString.toLowerCase()
}
}
try {

View File

@ -0,0 +1,27 @@
/*
* Minosoft
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.mappings.items
import com.google.gson.JsonObject
import de.bixilon.minosoft.data.mappings.ResourceLocation
import de.bixilon.minosoft.data.mappings.blocks.Block
import de.bixilon.minosoft.data.mappings.versions.VersionMapping
open class BlockItem(
resourceLocation: ResourceLocation,
data: JsonObject,
versionMapping: VersionMapping,
) : Item(resourceLocation, data, versionMapping) {
val block: Block = versionMapping.blockRegistry.get(data["block"].asInt)
}

View File

@ -42,6 +42,7 @@ open class Item(
override fun deserialize(mappings: VersionMapping?, resourceLocation: ResourceLocation, data: JsonObject): Item {
check(mappings != null) { "VersionMapping is null!" }
return when (data["class"].asString) {
"BlockItem" -> BlockItem(resourceLocation, data, mappings)
"ArmorItem" -> ArmorItem(resourceLocation, data, mappings)
// "Item" -> Item(resourceLocation, data)
// else -> TODO("Can not find item class: ${data["class"].asString}")