Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2021-2022, Valaphee.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.valaphee.netcode.mcbe.world.block
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonTypeName
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.core.JsonToken
import com.fasterxml.jackson.databind.JsonSerializer
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.databind.jsontype.TypeSerializer
import com.valaphee.jackson.dataformat.nbt.NbtGenerator
import com.valaphee.netcode.mcbe.latestProtocolVersion
import com.valaphee.netcode.mcbe.pack.Data
/**
* @author Kevin Ludwig
*/
@JsonTypeName("minecraft:block")
@JsonSerialize(using = Block.Serializer::class)
class Block : Data {
class Description(
@JsonProperty("identifier") val key: String,
@JsonProperty("properties") val properties: Map>? = null
)
class Permutation(
@JsonProperty("condition") val condition: String,
@JsonProperty("components") val components: Map
)
val description: Description
val events: Map>?
val components: Map?
val permutations: List?
@JsonIgnore val states: List
@JsonCreator
constructor(
@JsonProperty("description") description: Description,
@JsonProperty("events") events: Map>? = null,
@JsonProperty("components") components: Map? = null,
@JsonProperty("permutations") permutations: List? = null
) {
this.description = description
this.events = events
this.components = components
this.permutations = permutations
this.states = description.properties?.values?.reversed()?.fold(listOf(listOf())) { acc, set -> acc.flatMap { list -> set.map { list + it } } }?.map { BlockState(description.key, description.properties.keys.zip(it.reversed()).toMap()) } ?: listOf(BlockState(description.key, emptyMap()))
}
constructor(key: String, states: List