mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
physics: bed bouncing, BrewingStandBlock (particles)
This commit is contained in:
parent
83bc3593d1
commit
a27df8f91e
@ -24,7 +24,7 @@ class EntityObjectType(
|
||||
) : RegistryItem {
|
||||
|
||||
companion object : ResourceLocationDeserializer<EntityObjectType> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): EntityObjectType {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): EntityObjectType {
|
||||
return EntityObjectType(resourceLocation)
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class BlockEntityMetaType(
|
||||
) : RegistryItem {
|
||||
|
||||
companion object : ResourceLocationDeserializer<BlockEntityMetaType> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): BlockEntityMetaType {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): BlockEntityMetaType {
|
||||
return BlockEntityMetaType(resourceLocation)
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ data class Dimension(
|
||||
)
|
||||
}
|
||||
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Dimension {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Dimension {
|
||||
return Dimension(
|
||||
resourceLocation = resourceLocation,
|
||||
piglinSafe = data.get("piglin_safe")?.asBoolean == true,
|
||||
|
@ -28,7 +28,7 @@ data class Motive(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<Motive> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Motive {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Motive {
|
||||
return Motive(
|
||||
resourceLocation = resourceLocation,
|
||||
width = data["width"].asInt,
|
||||
|
@ -28,7 +28,7 @@ data class PluginChannel(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<PluginChannel> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): PluginChannel {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): PluginChannel {
|
||||
return PluginChannel(
|
||||
resourceLocation = resourceLocation,
|
||||
name = LegacyResourceLocation(data["name"].asString)
|
||||
|
@ -59,8 +59,8 @@ data class Biome(
|
||||
|
||||
companion object : ResourceLocationDeserializer<Biome> {
|
||||
private val TODO_SWAMP_COLOR = "#6A7039".asColor()
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Biome {
|
||||
check(mappings != null) { "Registries is null!" }
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Biome {
|
||||
check(registries != null) { "Registries is null!" }
|
||||
return Biome(
|
||||
resourceLocation = resourceLocation,
|
||||
depth = data["depth"]?.asFloat ?: 0.0f,
|
||||
@ -69,8 +69,8 @@ data class Biome(
|
||||
downfall = data["downfall"]?.asFloat ?: 0.0f,
|
||||
waterColor = TintColorCalculator.getJsonColor(data["water_color"]?.asInt ?: 0),
|
||||
waterFogColor = TintColorCalculator.getJsonColor(data["water_fog_color"]?.asInt ?: 0),
|
||||
category = mappings.biomeCategoryRegistry[data["category"]?.asInt ?: -1] ?: DEFAULT_CATEGORY,
|
||||
precipitation = mappings.biomePrecipitationRegistry[data["precipitation"]?.asInt ?: -1] ?: DEFAULT_PRECIPITATION,
|
||||
category = registries.biomeCategoryRegistry[data["category"]?.asInt ?: -1] ?: DEFAULT_CATEGORY,
|
||||
precipitation = registries.biomePrecipitationRegistry[data["precipitation"]?.asInt ?: -1] ?: DEFAULT_PRECIPITATION,
|
||||
skyColor = data["sky_color"]?.asInt?.asRGBColor() ?: RenderConstants.GRASS_FAILOVER_COLOR,
|
||||
foliageColorOverride = TintColorCalculator.getJsonColor(data["foliage_color_override"]?.asInt ?: 0),
|
||||
grassColorOverride = TintColorCalculator.getJsonColor(data["grass_color_override"]?.asInt ?: 0),
|
||||
|
@ -48,7 +48,7 @@ data class BlockEntityType(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<BlockEntityType> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): BlockEntityType? {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): BlockEntityType? {
|
||||
val factory = DefaultBlockEntityMetaDataFactory[resourceLocation] ?: return null // ToDo
|
||||
|
||||
val blockIds: MutableSet<Int> = mutableSetOf()
|
||||
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.blocks.types
|
||||
|
||||
import com.google.gson.JsonObject
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||
import de.bixilon.minosoft.data.mappings.blocks.BlockState
|
||||
import de.bixilon.minosoft.data.mappings.versions.Registries
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import glm_.vec3.Vec3i
|
||||
|
||||
open class BedBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : Block(resourceLocation, registries, data) {
|
||||
|
||||
override fun onEntityLand(connection: PlayConnection, entity: Entity, blockPosition: Vec3i, blockState: BlockState) {
|
||||
super.onEntityLand(connection, entity, blockPosition, blockState)
|
||||
|
||||
if (entity.isSneaking) {
|
||||
return
|
||||
}
|
||||
|
||||
bounce(entity)
|
||||
}
|
||||
|
||||
private fun bounce(entity: Entity) {
|
||||
if (entity.velocity.y < 0.0) {
|
||||
entity.velocity.y = -entity.velocity.y * 0.66f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,29 +109,32 @@ open class Block(
|
||||
open fun onEntityLand(connection: PlayConnection, entity: Entity, blockPosition: Vec3i, blockState: BlockState) {}
|
||||
|
||||
companion object : ResourceLocationDeserializer<Block> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Block {
|
||||
check(mappings != null) { "Registries is null!" }
|
||||
private val CONSTRUCTORS: Map<String, (resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) -> Block> = mapOf(
|
||||
"FluidBlock" to { resourceLocation, registries, data -> FluidBlock(resourceLocation, registries, data) },
|
||||
"DoorBlock" to { resourceLocation, registries, data -> DoorBlock(resourceLocation, registries, data) },
|
||||
"LeverBlock" to { resourceLocation, registries, data -> LeverBlock(resourceLocation, registries, data) },
|
||||
"NoteBlock" to { resourceLocation, registries, data -> NoteBlock(resourceLocation, registries, data) },
|
||||
"RepeaterBlock" to { resourceLocation, registries, data -> RepeaterBlock(resourceLocation, registries, data) },
|
||||
"ComparatorBlock" to { resourceLocation, registries, data -> ComparatorBlock(resourceLocation, registries, data) },
|
||||
"CampfireBlock" to { resourceLocation, registries, data -> CampfireBlock(resourceLocation, registries, data) },
|
||||
"TorchBlock" to { resourceLocation, registries, data -> TorchBlock(resourceLocation, registries, data) },
|
||||
"SlimeBlock" to { resourceLocation, registries, data -> SlimeBlock(resourceLocation, registries, data) },
|
||||
"BedBlock" to { resourceLocation, registries, data -> BedBlock(resourceLocation, registries, data) },
|
||||
"BrewingStandBlock" to { resourceLocation, registries, data -> BrewingStandBlock(resourceLocation, registries, data) },
|
||||
)
|
||||
|
||||
val block = when (data["class"].asString) {
|
||||
"FluidBlock" -> FluidBlock(resourceLocation, mappings, data)
|
||||
"DoorBlock" -> DoorBlock(resourceLocation, mappings, data)
|
||||
"LeverBlock" -> LeverBlock(resourceLocation, mappings, data)
|
||||
"NoteBlock" -> NoteBlock(resourceLocation, mappings, data)
|
||||
"RepeaterBlock" -> RepeaterBlock(resourceLocation, mappings, data)
|
||||
"ComparatorBlock" -> ComparatorBlock(resourceLocation, mappings, data)
|
||||
"CampfireBlock" -> CampfireBlock(resourceLocation, mappings, data)
|
||||
"TorchBlock" -> TorchBlock(resourceLocation, mappings, data)
|
||||
"SlimeBlock" -> SlimeBlock(resourceLocation, mappings, data)
|
||||
else -> Block(resourceLocation, mappings, data)
|
||||
}
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Block {
|
||||
check(registries != null) { "Registries is null!" }
|
||||
|
||||
val block = CONSTRUCTORS[data["class"].asString]?.invoke(resourceLocation, registries, data) ?: Block(resourceLocation, registries, data)
|
||||
|
||||
val properties: MutableMap<BlockProperties, MutableSet<Any>> = mutableMapOf()
|
||||
|
||||
val states: MutableSet<BlockState> = mutableSetOf()
|
||||
for ((stateId, stateJson) in data["states"].asJsonObject.entrySet()) {
|
||||
check(stateJson is JsonObject) { "Not a state element!" }
|
||||
val state = BlockState.deserialize(block, mappings, stateJson, mappings.models)
|
||||
mappings.blockStateIdMap[stateId.toInt()] = state
|
||||
val state = BlockState.deserialize(block, registries, stateJson, registries.models)
|
||||
registries.blockStateIdMap[stateId.toInt()] = state
|
||||
states.add(state)
|
||||
for ((property, value) in state.properties) {
|
||||
properties.getOrPut(property) { mutableSetOf() } += value
|
||||
@ -145,7 +148,7 @@ open class Block(
|
||||
}
|
||||
|
||||
block.states = states.toSet()
|
||||
block.defaultState = mappings.blockStateIdMap[data["default_state"].asInt]!!
|
||||
block.defaultState = registries.blockStateIdMap[data["default_state"].asInt]!!
|
||||
block.properties = propertiesOut.toMap()
|
||||
return block
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.blocks.types
|
||||
|
||||
import com.google.gson.JsonObject
|
||||
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||
import de.bixilon.minosoft.data.mappings.blocks.BlockState
|
||||
import de.bixilon.minosoft.data.mappings.versions.Registries
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.fire.SmokeParticle
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.EMPTY
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.horizontal
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.toVec3d
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import glm_.vec3.Vec3d
|
||||
import glm_.vec3.Vec3i
|
||||
import kotlin.random.Random
|
||||
|
||||
open class BrewingStandBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : Block(resourceLocation, registries, data) {
|
||||
private val smokeParticle = registries.particleTypeRegistry[SmokeParticle]
|
||||
|
||||
override fun randomTick(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, random: Random) {
|
||||
super.randomTick(connection, blockState, blockPosition, random)
|
||||
|
||||
smokeParticle?.let {
|
||||
connection.world += SmokeParticle(
|
||||
connection,
|
||||
blockPosition.toVec3d + Vec3d(0.4, 0.7, 0.4) + Vec3d.horizontal({ random.nextDouble() * 0.2 }, random.nextDouble() * 0.3),
|
||||
Vec3d.EMPTY,
|
||||
it.default(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import de.bixilon.minosoft.gui.rendering.input.camera.RaycastHit
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import glm_.vec3.Vec3i
|
||||
|
||||
open class DoorBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : DoubleSizeBlock(resourceLocation, mappings, data) {
|
||||
open class DoorBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : DoubleSizeBlock(resourceLocation, registries, data) {
|
||||
|
||||
override fun getPlacementState(connection: PlayConnection, raycastHit: RaycastHit): BlockState? {
|
||||
TODO()
|
||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.gui.rendering.util.VecUtil.plus
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import glm_.vec3.Vec3i
|
||||
|
||||
abstract class DoubleSizeBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : Block(resourceLocation, mappings, data) {
|
||||
abstract class DoubleSizeBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : Block(resourceLocation, registries, data) {
|
||||
|
||||
override fun onBreak(connection: PlayConnection, blockPosition: Vec3i, blockState: BlockState, blockEntity: BlockEntity?) {
|
||||
if (blockState.properties[BlockProperties.STAIR_HALF] == Halves.LOWER) {
|
||||
|
@ -20,9 +20,9 @@ import de.bixilon.minosoft.data.mappings.versions.Registries
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.models.renderable.BlockLikeRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.models.renderable.FluidRenderer
|
||||
|
||||
open class FluidBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : Block(resourceLocation, mappings, data) {
|
||||
open val stillFluid: Fluid = mappings.fluidRegistry[data["still_fluid"].asInt]
|
||||
open val flowingFluid: Fluid = mappings.fluidRegistry[data["flow_fluid"].asInt]
|
||||
open class FluidBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : Block(resourceLocation, registries, data) {
|
||||
open val stillFluid: Fluid = registries.fluidRegistry[data["still_fluid"].asInt]
|
||||
open val flowingFluid: Fluid = registries.fluidRegistry[data["flow_fluid"].asInt]
|
||||
|
||||
val fluidRenderer: FluidRenderer
|
||||
|
||||
|
@ -4,4 +4,4 @@ import com.google.gson.JsonObject
|
||||
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||
import de.bixilon.minosoft.data.mappings.versions.Registries
|
||||
|
||||
abstract class HorizontalFacingBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) :Block(resourceLocation, mappings, data)
|
||||
abstract class HorizontalFacingBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : Block(resourceLocation, registries, data)
|
||||
|
@ -24,7 +24,7 @@ import de.bixilon.minosoft.gui.rendering.input.camera.RaycastHit
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import glm_.vec3.Vec3i
|
||||
|
||||
open class NoteBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : Block(resourceLocation, mappings, data) {
|
||||
open class NoteBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : Block(resourceLocation, registries, data) {
|
||||
|
||||
override fun onUse(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, raycastHit: RaycastHit, hands: Hands, itemStack: ItemStack?): BlockUsages {
|
||||
return BlockUsages.SUCCESS
|
||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.data.mappings.versions.Registries
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import glm_.vec3.Vec3i
|
||||
|
||||
open class SlimeBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : Block(resourceLocation, mappings, data) {
|
||||
open class SlimeBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : Block(resourceLocation, registries, data) {
|
||||
|
||||
override fun onEntityLand(connection: PlayConnection, entity: Entity, blockPosition: Vec3i, blockState: BlockState) {
|
||||
super.onEntityLand(connection, entity, blockPosition, blockState)
|
||||
|
@ -38,7 +38,7 @@ data class StatusEffect(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<StatusEffect> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): StatusEffect {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): StatusEffect {
|
||||
val attributes: MutableMap<ResourceLocation, StatusEffectAttribute> = mutableMapOf()
|
||||
val uuidAttributes: MutableMap<UUID, StatusEffectAttribute> = mutableMapOf()
|
||||
|
||||
|
@ -28,7 +28,7 @@ data class Enchantment(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<Enchantment> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Enchantment {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Enchantment {
|
||||
return Enchantment(resourceLocation)
|
||||
}
|
||||
}
|
||||
|
@ -45,13 +45,13 @@ data class EntityType(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<EntityType> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): EntityType? {
|
||||
check(mappings != null) { "Registries is null!" }
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): EntityType? {
|
||||
check(registries != null) { "Registries is null!" }
|
||||
|
||||
data["meta"]?.asJsonObject?.let {
|
||||
for ((minosoftFieldName, index) in it.entrySet()) {
|
||||
val minosoftField = EntityMetaDataFields[minosoftFieldName.lowercase(Locale.getDefault())]
|
||||
mappings.entityMetaIndexMap[minosoftField] = index.asInt
|
||||
registries.entityMetaIndexMap[minosoftField] = index.asInt
|
||||
}
|
||||
}
|
||||
if (data["width"] == null) {
|
||||
|
@ -29,7 +29,7 @@ data class VillagerProfession(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<VillagerProfession> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): VillagerProfession {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): VillagerProfession {
|
||||
return VillagerProfession(
|
||||
resourceLocation = resourceLocation,
|
||||
)
|
||||
|
@ -38,12 +38,12 @@ data class Fluid(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<Fluid> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Fluid {
|
||||
check(mappings != null) { "Registries is null!" }
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Fluid {
|
||||
check(registries != null) { "Registries is null!" }
|
||||
return Fluid(
|
||||
resourceLocation = resourceLocation,
|
||||
bucketItemId = data["bucket"]?.asInt,
|
||||
dripParticle = data["drip_particle_type"]?.asInt?.let { mappings.particleTypeRegistry[it] },
|
||||
dripParticle = data["drip_particle_type"]?.asInt?.let { registries.particleTypeRegistry[it] },
|
||||
renderTexture = data["render"]?.asJsonObject?.get("texture")?.asString?.let { ResourceLocation(it) },
|
||||
)
|
||||
}
|
||||
|
@ -58,25 +58,25 @@ open class Item(
|
||||
companion object : ResourceLocationDeserializer<Item> {
|
||||
const val INFINITE_MINING_SPEED_MULTIPLIER = -1.0f
|
||||
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Item {
|
||||
check(mappings != null) { "Registries is null!" }
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Item {
|
||||
check(registries != null) { "Registries is null!" }
|
||||
return when (data["class"].asString) {
|
||||
"BlockItem" -> BlockItem(resourceLocation, mappings, data)
|
||||
"ArmorItem" -> ArmorItem(resourceLocation, mappings, data)
|
||||
"SwordItem" -> SwordItem(resourceLocation, mappings, data)
|
||||
"ToolItem" -> ToolItem(resourceLocation, mappings, data)
|
||||
"AxeItem" -> AxeItem(resourceLocation, mappings, data)
|
||||
"BucketItem" -> BucketItem(resourceLocation, mappings, data)
|
||||
"DyeItem" -> DyeItem(resourceLocation, mappings, data)
|
||||
"HorseArmorItem" -> HorseArmorItem(resourceLocation, mappings, data)
|
||||
"SpawnEggItem" -> SpawnEggItem(resourceLocation, mappings, data)
|
||||
"MusicDiscItem" -> MusicDiscItem(resourceLocation, mappings, data)
|
||||
"ShovelItem" -> ShovelItem(resourceLocation, mappings, data)
|
||||
"PickaxeItem" -> PickaxeItem(resourceLocation, mappings, data)
|
||||
"HoeItem" -> HoeItem(resourceLocation, mappings, data)
|
||||
"BlockItem" -> BlockItem(resourceLocation, registries, data)
|
||||
"ArmorItem" -> ArmorItem(resourceLocation, registries, data)
|
||||
"SwordItem" -> SwordItem(resourceLocation, registries, data)
|
||||
"ToolItem" -> ToolItem(resourceLocation, registries, data)
|
||||
"AxeItem" -> AxeItem(resourceLocation, registries, data)
|
||||
"BucketItem" -> BucketItem(resourceLocation, registries, data)
|
||||
"DyeItem" -> DyeItem(resourceLocation, registries, data)
|
||||
"HorseArmorItem" -> HorseArmorItem(resourceLocation, registries, data)
|
||||
"SpawnEggItem" -> SpawnEggItem(resourceLocation, registries, data)
|
||||
"MusicDiscItem" -> MusicDiscItem(resourceLocation, registries, data)
|
||||
"ShovelItem" -> ShovelItem(resourceLocation, registries, data)
|
||||
"PickaxeItem" -> PickaxeItem(resourceLocation, registries, data)
|
||||
"HoeItem" -> HoeItem(resourceLocation, registries, data)
|
||||
// "Item" -> Item(resourceLocation, data)
|
||||
// else -> TODO("Can not find item class: ${data["class"].asString}")
|
||||
else -> Item(resourceLocation, mappings, data)
|
||||
else -> Item(resourceLocation, registries, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ data class Material(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<Material> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Material {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Material {
|
||||
return Material(
|
||||
resourceLocation = resourceLocation,
|
||||
color = TintColorCalculator.getJsonColor(data["color"]?.asInt ?: 0),
|
||||
|
@ -27,7 +27,7 @@ data class ContainerType(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<ContainerType> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): ContainerType {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): ContainerType {
|
||||
return ContainerType(
|
||||
resourceLocation = resourceLocation,
|
||||
)
|
||||
|
@ -27,7 +27,7 @@ data class GameEvent(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<GameEvent> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): GameEvent {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): GameEvent {
|
||||
return GameEvent(
|
||||
resourceLocation = resourceLocation,
|
||||
)
|
||||
|
@ -39,7 +39,7 @@ data class ParticleType(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<ParticleType> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): ParticleType {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): ParticleType {
|
||||
val textures: MutableList<ResourceLocation> = mutableListOf()
|
||||
data["render"]?.asJsonObject?.get("textures")?.asJsonArray?.let {
|
||||
for (texture in it) {
|
||||
|
@ -18,5 +18,5 @@ import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||
import de.bixilon.minosoft.data.mappings.versions.Registries
|
||||
|
||||
interface ResourceLocationDeserializer<T> {
|
||||
fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): T?
|
||||
fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): T?
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ data class SoundEvent(
|
||||
) : RegistryItem {
|
||||
|
||||
companion object : ResourceLocationDeserializer<SoundEvent> {
|
||||
override fun deserialize(mappings: Registries?, resourceLocation: ResourceLocation, data: JsonObject): SoundEvent {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): SoundEvent {
|
||||
return SoundEvent(
|
||||
resourceLocation = resourceLocation,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user