mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 17:37:58 -04:00
abstract tinted block
This commit is contained in:
parent
4f36e4d8b1
commit
7ad5ba2a11
@ -30,7 +30,6 @@ import de.bixilon.minosoft.data.registries.blocks.types.properties.physics.Pushi
|
|||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||||
import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender
|
import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender
|
||||||
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
|
||||||
import kotlin.reflect.jvm.javaField
|
import kotlin.reflect.jvm.javaField
|
||||||
|
|
||||||
abstract class Block(
|
abstract class Block(
|
||||||
@ -44,9 +43,6 @@ abstract class Block(
|
|||||||
|
|
||||||
override val translationKey: ResourceLocation = settings.translationKey ?: identifier.translation("block")
|
override val translationKey: ResourceLocation = settings.translationKey ?: identifier.translation("block")
|
||||||
|
|
||||||
@Deprecated("Interface")
|
|
||||||
var tintProvider: TintProvider? = null
|
|
||||||
|
|
||||||
val soundGroup = settings.soundGroup
|
val soundGroup = settings.soundGroup
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
@ -23,11 +23,14 @@ import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
|||||||
import de.bixilon.minosoft.data.registries.item.items.Item
|
import de.bixilon.minosoft.data.registries.item.items.Item
|
||||||
import de.bixilon.minosoft.data.registries.item.items.tool.shovel.ShovelRequirement
|
import de.bixilon.minosoft.data.registries.item.items.tool.shovel.ShovelRequirement
|
||||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.grass.GrassTinted
|
||||||
|
|
||||||
open class GrassBlock(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : SnowyBlock(identifier, settings), FullOpaqueBlock, FlatteningRenamedModel, ShovelRequirement, BlockWithItem<Item> {
|
open class GrassBlock(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : SnowyBlock(identifier, settings), FullOpaqueBlock, FlatteningRenamedModel, ShovelRequirement, BlockWithItem<Item>, GrassTinted {
|
||||||
override val item: Item = this::item.inject(identifier)
|
override val item: Item = this::item.inject(identifier)
|
||||||
override val hardness get() = 0.6f
|
override val hardness get() = 0.6f
|
||||||
override val legacyModelName get() = minecraft("grass")
|
override val legacyModelName get() = minecraft("grass")
|
||||||
|
override val tintProvider: TintProvider? = null
|
||||||
|
|
||||||
|
|
||||||
companion object : BlockFactory<GrassBlock> {
|
companion object : BlockFactory<GrassBlock> {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
package de.bixilon.minosoft.data.registries.blocks.types.building.plants
|
package de.bixilon.minosoft.data.registries.blocks.types.building.plants
|
||||||
|
|
||||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||||
|
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||||
import de.bixilon.minosoft.data.direction.Directions
|
import de.bixilon.minosoft.data.direction.Directions
|
||||||
import de.bixilon.minosoft.data.registries.blocks.factory.BlockFactory
|
import de.bixilon.minosoft.data.registries.blocks.factory.BlockFactory
|
||||||
import de.bixilon.minosoft.data.registries.blocks.properties.EnumProperty
|
import de.bixilon.minosoft.data.registries.blocks.properties.EnumProperty
|
||||||
@ -39,6 +40,10 @@ import de.bixilon.minosoft.gui.rendering.models.block.state.DirectBlockModel
|
|||||||
import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender
|
import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender
|
||||||
import de.bixilon.minosoft.gui.rendering.models.block.state.render.PickedBlockRender
|
import de.bixilon.minosoft.gui.rendering.models.block.state.render.PickedBlockRender
|
||||||
import de.bixilon.minosoft.gui.rendering.models.loader.legacy.ModelChooser
|
import de.bixilon.minosoft.gui.rendering.models.loader.legacy.ModelChooser
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintManager
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintedBlock
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.grass.TallGrassTintCalculator
|
||||||
import de.bixilon.minosoft.protocol.versions.Version
|
import de.bixilon.minosoft.protocol.versions.Version
|
||||||
|
|
||||||
abstract class DoublePlant(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), ShearsRequirement, BlockWithItem<Item>, FullOutlinedBlock, RandomOffsetBlock, InstantBreakableBlock, ModelChooser, DoubleSizeBlock {
|
abstract class DoublePlant(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), ShearsRequirement, BlockWithItem<Item>, FullOutlinedBlock, RandomOffsetBlock, InstantBreakableBlock, ModelChooser, DoubleSizeBlock {
|
||||||
@ -93,7 +98,12 @@ abstract class DoublePlant(identifier: ResourceLocation, settings: BlockSettings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open class TallGrass(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : DoublePlant(identifier, settings) {
|
open class TallGrass(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : DoublePlant(identifier, settings), TintedBlock {
|
||||||
|
override val tintProvider: TintProvider? = null
|
||||||
|
|
||||||
|
override fun initTint(manager: TintManager) {
|
||||||
|
this::tintProvider.forceSet(TallGrassTintCalculator(manager.grassTintCalculator))
|
||||||
|
}
|
||||||
|
|
||||||
companion object : BlockFactory<TallGrass> {
|
companion object : BlockFactory<TallGrass> {
|
||||||
override val identifier = minecraft("tall_grass")
|
override val identifier = minecraft("tall_grass")
|
||||||
@ -102,8 +112,13 @@ abstract class DoublePlant(identifier: ResourceLocation, settings: BlockSettings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open class LargeFern(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : DoublePlant(identifier, settings), FlatteningRenamedModel {
|
open class LargeFern(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : DoublePlant(identifier, settings), FlatteningRenamedModel, TintedBlock {
|
||||||
override val legacyModelName get() = minecraft("double_fern")
|
override val legacyModelName get() = minecraft("double_fern")
|
||||||
|
override val tintProvider: TintProvider? = null
|
||||||
|
|
||||||
|
override fun initTint(manager: TintManager) {
|
||||||
|
this::tintProvider.forceSet(TallGrassTintCalculator(manager.grassTintCalculator))
|
||||||
|
}
|
||||||
|
|
||||||
companion object : BlockFactory<LargeFern> {
|
companion object : BlockFactory<LargeFern> {
|
||||||
override val identifier = minecraft("large_fern")
|
override val identifier = minecraft("large_fern")
|
||||||
@ -132,12 +147,17 @@ abstract class DoublePlant(identifier: ResourceLocation, settings: BlockSettings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UpperFlowerBlock(settings: BlockSettings) : DoublePlant(Companion.identifier, settings) {
|
class UpperFlowerBlock(settings: BlockSettings) : DoublePlant(Companion.identifier, settings), TintedBlock {
|
||||||
|
override val tintProvider: TintProvider? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
model = Model()
|
model = Model()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun initTint(manager: TintManager) {
|
||||||
|
this::tintProvider.forceSet(TallGrassTintCalculator(manager.grassTintCalculator)) // TODO: only tint if lower block is tinted
|
||||||
|
}
|
||||||
|
|
||||||
private class Model : PickedBlockRender {
|
private class Model : PickedBlockRender {
|
||||||
override val default get() = null // TODO
|
override val default get() = null // TODO
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ import de.bixilon.minosoft.data.registries.item.items.Item
|
|||||||
import de.bixilon.minosoft.data.registries.item.items.tool.shears.ShearsRequirement
|
import de.bixilon.minosoft.data.registries.item.items.tool.shears.ShearsRequirement
|
||||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||||
import de.bixilon.minosoft.data.registries.shapes.voxel.VoxelShape
|
import de.bixilon.minosoft.data.registries.shapes.voxel.VoxelShape
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.grass.GrassTinted
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
|
||||||
abstract class FernBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), ShearsRequirement, BlockWithItem<Item>, OutlinedBlock, RandomOffsetBlock, InstantBreakableBlock {
|
abstract class FernBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), ShearsRequirement, BlockWithItem<Item>, OutlinedBlock, RandomOffsetBlock, InstantBreakableBlock {
|
||||||
@ -50,8 +52,9 @@ abstract class FernBlock(identifier: ResourceLocation, settings: BlockSettings)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open class Grass(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : FernBlock(identifier, settings), FlatteningRenamedModel {
|
open class Grass(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : FernBlock(identifier, settings), FlatteningRenamedModel, GrassTinted {
|
||||||
override val legacyModelName get() = minecraft("tall_grass")
|
override val legacyModelName get() = minecraft("tall_grass")
|
||||||
|
override val tintProvider: TintProvider? = null
|
||||||
|
|
||||||
companion object : BlockFactory<Grass> {
|
companion object : BlockFactory<Grass> {
|
||||||
override val identifier = minecraft("grass")
|
override val identifier = minecraft("grass")
|
||||||
@ -60,7 +63,8 @@ abstract class FernBlock(identifier: ResourceLocation, settings: BlockSettings)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open class Fern(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : FernBlock(identifier, settings) {
|
open class Fern(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : FernBlock(identifier, settings), GrassTinted {
|
||||||
|
override val tintProvider: TintProvider? = null
|
||||||
|
|
||||||
companion object : BlockFactory<Fern> {
|
companion object : BlockFactory<Fern> {
|
||||||
override val identifier = minecraft("fern")
|
override val identifier = minecraft("fern")
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
package de.bixilon.minosoft.data.registries.blocks.types.fluid
|
package de.bixilon.minosoft.data.registries.blocks.types.fluid
|
||||||
|
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3
|
import de.bixilon.kotlinglm.vec3.Vec3
|
||||||
|
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||||
import de.bixilon.kutil.exception.Broken
|
import de.bixilon.kutil.exception.Broken
|
||||||
import de.bixilon.minosoft.data.registries.blocks.light.CustomLightProperties
|
import de.bixilon.minosoft.data.registries.blocks.light.CustomLightProperties
|
||||||
import de.bixilon.minosoft.data.registries.blocks.properties.list.MapPropertyList
|
import de.bixilon.minosoft.data.registries.blocks.properties.list.MapPropertyList
|
||||||
@ -29,15 +30,25 @@ import de.bixilon.minosoft.data.registries.shapes.aabb.AABB
|
|||||||
import de.bixilon.minosoft.data.registries.shapes.voxel.VoxelShape
|
import de.bixilon.minosoft.data.registries.shapes.voxel.VoxelShape
|
||||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||||
import de.bixilon.minosoft.gui.rendering.models.loader.legacy.CustomModel
|
import de.bixilon.minosoft.gui.rendering.models.loader.legacy.CustomModel
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintManager
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintedBlock
|
||||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.EMPTY
|
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.EMPTY
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.versions.Version
|
import de.bixilon.minosoft.protocol.versions.Version
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
abstract class FluidBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), FluidHolder, OutlinedBlock, LightedBlock, RandomDisplayTickable, CustomModel {
|
abstract class FluidBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), FluidHolder, OutlinedBlock, LightedBlock, RandomDisplayTickable, CustomModel, TintedBlock {
|
||||||
override val hardness: Float get() = Broken("Fluid is kind of unbreakable?")
|
override val hardness: Float get() = Broken("Fluid is kind of unbreakable?")
|
||||||
override val modelName: ResourceLocation? get() = null
|
override val modelName: ResourceLocation? get() = null
|
||||||
|
|
||||||
|
override val tintProvider: TintProvider?
|
||||||
|
get() = fluid.nullCast<TintedBlock>()?.tintProvider
|
||||||
|
|
||||||
|
override fun initTint(manager: TintManager) {
|
||||||
|
fluid.nullCast<TintedBlock>()?.initTint(manager)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getOutlineShape(connection: PlayConnection, blockState: BlockState): VoxelShape {
|
override fun getOutlineShape(connection: PlayConnection, blockState: BlockState): VoxelShape {
|
||||||
return VoxelShape(AABB(Vec3.EMPTY, Vec3(1.0f, fluid.getHeight(blockState), 1.0f)))
|
return VoxelShape(AABB(Vec3.EMPTY, Vec3(1.0f, fluid.getHeight(blockState), 1.0f)))
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ import de.bixilon.minosoft.data.registries.blocks.types.properties.shape.special
|
|||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||||
import de.bixilon.minosoft.gui.rendering.models.loader.legacy.CustomModel
|
import de.bixilon.minosoft.gui.rendering.models.loader.legacy.CustomModel
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintedBlock
|
||||||
import de.bixilon.minosoft.protocol.versions.Version
|
import de.bixilon.minosoft.protocol.versions.Version
|
||||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
|
|
||||||
@ -30,8 +32,9 @@ open class LegacyBlock(
|
|||||||
version: Version,
|
version: Version,
|
||||||
registries: Registries,
|
registries: Registries,
|
||||||
data: Map<String, Any>,
|
data: Map<String, Any>,
|
||||||
) : Block(identifier, BlockSettings(version)), FullBlock, BlockStateBuilder, CustomModel {
|
) : Block(identifier, BlockSettings(version)), FullBlock, BlockStateBuilder, CustomModel, TintedBlock {
|
||||||
override var hardness: Float = 0.0f
|
override var hardness: Float = 0.0f
|
||||||
|
override var tintProvider: TintProvider? = null
|
||||||
|
|
||||||
override val modelName: ResourceLocation? = data["model"]?.toResourceLocation() ?: identifier
|
override val modelName: ResourceLocation? = data["model"]?.toResourceLocation() ?: identifier
|
||||||
|
|
||||||
|
@ -48,6 +48,8 @@ import de.bixilon.minosoft.data.registries.registries.Registries
|
|||||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||||
import de.bixilon.minosoft.data.registries.registries.registry.codec.ResourceLocationCodec
|
import de.bixilon.minosoft.data.registries.registries.registry.codec.ResourceLocationCodec
|
||||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintedBlock
|
||||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.getWorldOffset
|
import de.bixilon.minosoft.gui.rendering.util.VecUtil.getWorldOffset
|
||||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.EMPTY
|
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.EMPTY
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
@ -61,13 +63,14 @@ open class PixLyzerBlock(
|
|||||||
identifier: ResourceLocation,
|
identifier: ResourceLocation,
|
||||||
registries: Registries,
|
registries: Registries,
|
||||||
data: Map<String, Any>,
|
data: Map<String, Any>,
|
||||||
) : Block(identifier, BlockSettings(Versions.AUTOMATIC, soundGroup = data["sound_group"]?.toInt()?.let { registries.soundGroup[it] })), FrictionBlock, JumpBlock, VelocityBlock, RandomOffsetBlock, OutlinedBlock, BlockStateBuilder, ReplaceableBlock, PotentialFullOpaqueBlock, WaterloggableBlock, CollidableBlock, ToolRequirement, BlockWithItem<Item> {
|
) : Block(identifier, BlockSettings(Versions.AUTOMATIC, soundGroup = data["sound_group"]?.toInt()?.let { registries.soundGroup[it] })), FrictionBlock, JumpBlock, VelocityBlock, RandomOffsetBlock, OutlinedBlock, BlockStateBuilder, ReplaceableBlock, PotentialFullOpaqueBlock, WaterloggableBlock, CollidableBlock, ToolRequirement, BlockWithItem<Item>, TintedBlock {
|
||||||
override val randomOffset: RandomOffsetTypes? = data["offset_type"].nullCast<String>()?.let { RandomOffsetTypes[it] }
|
override val randomOffset: RandomOffsetTypes? = data["offset_type"].nullCast<String>()?.let { RandomOffsetTypes[it] }
|
||||||
|
|
||||||
override val friction = data["friction"]?.toFloat() ?: FrictionBlock.DEFAULT_FRICTION
|
override val friction = data["friction"]?.toFloat() ?: FrictionBlock.DEFAULT_FRICTION
|
||||||
override val velocity = data["velocity_multiplier"]?.toFloat() ?: 1.0f // ToDo: They exist since ~1.15
|
override val velocity = data["velocity_multiplier"]?.toFloat() ?: 1.0f // ToDo: They exist since ~1.15
|
||||||
|
|
||||||
override val jumpBoost = data["jump_velocity_multiplier"]?.toFloat() ?: 1.0f
|
override val jumpBoost = data["jump_velocity_multiplier"]?.toFloat() ?: 1.0f
|
||||||
|
override var tintProvider: TintProvider? = null
|
||||||
|
|
||||||
override var hardness: Float = 0.0f
|
override var hardness: Float = 0.0f
|
||||||
val requiresTool: Boolean
|
val requiresTool: Boolean
|
||||||
|
@ -18,10 +18,15 @@ import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
|
|||||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintManager
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.StaticTintProvider
|
||||||
|
|
||||||
interface Birch {
|
interface Birch {
|
||||||
|
|
||||||
class Leaves(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : LeavesBlock(identifier, settings), Birch {
|
class Leaves(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : LeavesBlock(identifier, settings), Birch {
|
||||||
|
override val tintProvider = StaticTintProvider(0x80A755)
|
||||||
|
|
||||||
|
override fun initTint(manager: TintManager) = Unit
|
||||||
|
|
||||||
companion object : BlockFactory<Leaves> {
|
companion object : BlockFactory<Leaves> {
|
||||||
override val identifier = minecraft("birch_leaves")
|
override val identifier = minecraft("birch_leaves")
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.registries.blocks.types.wood
|
package de.bixilon.minosoft.data.registries.blocks.types.wood
|
||||||
|
|
||||||
|
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||||
import de.bixilon.minosoft.data.direction.Directions
|
import de.bixilon.minosoft.data.direction.Directions
|
||||||
import de.bixilon.minosoft.data.registries.blocks.light.CustomLightProperties
|
import de.bixilon.minosoft.data.registries.blocks.light.CustomLightProperties
|
||||||
@ -34,11 +35,19 @@ import de.bixilon.minosoft.data.registries.item.items.tool.shears.ShearsItem
|
|||||||
import de.bixilon.minosoft.data.registries.item.items.tool.sword.SwordItem
|
import de.bixilon.minosoft.data.registries.item.items.tool.sword.SwordItem
|
||||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.CustomBlockCulling
|
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.CustomBlockCulling
|
||||||
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.side.FaceProperties
|
import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.side.FaceProperties
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintManager
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintedBlock
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
|
||||||
abstract class LeavesBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), CustomBlockCulling, FullBlock, BlockStateBuilder, ToolRequirement, CustomDiggingBlock, WaterloggableBlock, BlockWithItem<Item>, LightedBlock {
|
abstract class LeavesBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), CustomBlockCulling, FullBlock, BlockStateBuilder, ToolRequirement, CustomDiggingBlock, WaterloggableBlock, BlockWithItem<Item>, LightedBlock, TintedBlock {
|
||||||
override val hardness get() = 0.2f
|
override val hardness get() = 0.2f
|
||||||
override val item: Item = this::item.inject(identifier)
|
override val item: Item = this::item.inject(identifier)
|
||||||
|
override val tintProvider: TintProvider? = null
|
||||||
|
|
||||||
|
override fun initTint(manager: TintManager) {
|
||||||
|
this::tintProvider.forceSet(manager.foliageTintCalculator)
|
||||||
|
}
|
||||||
|
|
||||||
override fun buildState(settings: BlockStateSettings): BlockState {
|
override fun buildState(settings: BlockStateSettings): BlockState {
|
||||||
return PropertyBlockState(this, settings)
|
return PropertyBlockState(this, settings)
|
||||||
|
@ -18,10 +18,15 @@ import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
|
|||||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintManager
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.StaticTintProvider
|
||||||
|
|
||||||
interface Spruce {
|
interface Spruce {
|
||||||
|
|
||||||
class Leaves(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : LeavesBlock(identifier, settings), Spruce {
|
class Leaves(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : LeavesBlock(identifier, settings), Spruce {
|
||||||
|
override val tintProvider = StaticTintProvider(0x619961)
|
||||||
|
|
||||||
|
override fun initTint(manager: TintManager) = Unit
|
||||||
|
|
||||||
companion object : BlockFactory<Leaves> {
|
companion object : BlockFactory<Leaves> {
|
||||||
override val identifier = minecraft("spruce_leaves")
|
override val identifier = minecraft("spruce_leaves")
|
||||||
|
@ -33,6 +33,8 @@ import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
|||||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||||
import de.bixilon.minosoft.gui.rendering.models.fluid.fluids.WaterFluidModel
|
import de.bixilon.minosoft.gui.rendering.models.fluid.fluids.WaterFluidModel
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.water.UnderwaterParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.water.UnderwaterParticle
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintedBlock
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.fluid.WaterTintProvider
|
||||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.plus
|
import de.bixilon.minosoft.gui.rendering.util.VecUtil.plus
|
||||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.toVec3d
|
import de.bixilon.minosoft.gui.rendering.util.VecUtil.toVec3d
|
||||||
import de.bixilon.minosoft.physics.entities.EntityPhysics
|
import de.bixilon.minosoft.physics.entities.EntityPhysics
|
||||||
@ -44,8 +46,9 @@ import de.bixilon.minosoft.physics.parts.input.InputPhysics.applyMovementInput
|
|||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class WaterFluid(resourceLocation: ResourceLocation = identifier) : Fluid(resourceLocation), FluidEnterHandler, FluidCollisionHandler {
|
class WaterFluid(resourceLocation: ResourceLocation = identifier) : Fluid(resourceLocation), FluidEnterHandler, FluidCollisionHandler, TintedBlock {
|
||||||
override val priority: Int get() = 0
|
override val priority: Int get() = 0
|
||||||
|
override val tintProvider get() = WaterTintProvider
|
||||||
|
|
||||||
override fun getVelocityMultiplier(connection: PlayConnection) = 0.014
|
override fun getVelocityMultiplier(connection: PlayConnection) = 0.014
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import de.bixilon.minosoft.data.language.translate.Translatable
|
|||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||||
import de.bixilon.minosoft.gui.rendering.models.item.ItemRender
|
import de.bixilon.minosoft.gui.rendering.models.item.ItemRender
|
||||||
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
@ -33,7 +32,6 @@ abstract class Item(
|
|||||||
override val translationKey: ResourceLocation = identifier.translation("item")
|
override val translationKey: ResourceLocation = identifier.translation("item")
|
||||||
|
|
||||||
open var model: ItemRender? = null
|
open var model: ItemRender? = null
|
||||||
var tintProvider: TintProvider? = null
|
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return identifier.toString()
|
return identifier.toString()
|
||||||
|
@ -25,17 +25,20 @@ import de.bixilon.minosoft.data.registries.item.items.Item
|
|||||||
import de.bixilon.minosoft.data.registries.item.stack.StackableItem
|
import de.bixilon.minosoft.data.registries.item.stack.StackableItem
|
||||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||||
import de.bixilon.minosoft.data.registries.registries.registry.codec.ResourceLocationCodec
|
import de.bixilon.minosoft.data.registries.registries.registry.codec.ResourceLocationCodec
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintedBlock
|
||||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
open class PixLyzerItem(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>) : Item(resourceLocation), DurableItem, StackableItem {
|
open class PixLyzerItem(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>) : Item(resourceLocation), DurableItem, StackableItem, TintedBlock {
|
||||||
override val rarity: Rarities = data["rarity"]?.toInt()?.let { Rarities[it] } ?: Rarities.COMMON
|
override val rarity: Rarities = data["rarity"]?.toInt()?.let { Rarities[it] } ?: Rarities.COMMON
|
||||||
override val maxStackSize: Int = data["max_stack_size"]?.toInt() ?: 64
|
override val maxStackSize: Int = data["max_stack_size"]?.toInt() ?: 64
|
||||||
override val maxDurability: Int = data["max_damage"]?.toInt() ?: 1
|
override val maxDurability: Int = data["max_damage"]?.toInt() ?: 1
|
||||||
val isFireResistant: Boolean = data["is_fire_resistant"]?.toBoolean() ?: false
|
val isFireResistant: Boolean = data["is_fire_resistant"]?.toBoolean() ?: false
|
||||||
override val translationKey: ResourceLocation = data["translation_key"]?.toResourceLocation() ?: super.translationKey
|
override val translationKey: ResourceLocation = data["translation_key"]?.toResourceLocation() ?: super.translationKey
|
||||||
|
override var tintProvider: TintProvider? = null
|
||||||
|
|
||||||
|
|
||||||
companion object : ResourceLocationCodec<Item>, PixLyzerItemFactory<Item>, MultiClassFactory<Item> {
|
companion object : ResourceLocationCodec<Item>, PixLyzerItemFactory<Item>, MultiClassFactory<Item> {
|
||||||
|
@ -22,6 +22,7 @@ import de.bixilon.kutil.primitive.BooleanUtil.decide
|
|||||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||||
import de.bixilon.kutil.unit.UnitFormatter.formatNanos
|
import de.bixilon.kutil.unit.UnitFormatter.formatNanos
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderUtil.pause
|
import de.bixilon.minosoft.gui.rendering.RenderUtil.pause
|
||||||
|
import de.bixilon.minosoft.gui.rendering.RenderUtil.runAsync
|
||||||
import de.bixilon.minosoft.gui.rendering.font.manager.FontManager
|
import de.bixilon.minosoft.gui.rendering.font.manager.FontManager
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.input.key.DebugKeyBindings
|
import de.bixilon.minosoft.gui.rendering.input.key.DebugKeyBindings
|
||||||
@ -62,8 +63,6 @@ object RenderLoader {
|
|||||||
|
|
||||||
camera.init()
|
camera.init()
|
||||||
|
|
||||||
tints.init(connection.assetsManager)
|
|
||||||
|
|
||||||
|
|
||||||
Log.log(LogMessageType.RENDERING, LogLevels.VERBOSE) { "Creating context (after ${stopwatch.labTime()})..." }
|
Log.log(LogMessageType.RENDERING, LogLevels.VERBOSE) { "Creating context (after ${stopwatch.labTime()})..." }
|
||||||
|
|
||||||
@ -73,6 +72,7 @@ object RenderLoader {
|
|||||||
// Init stage
|
// Init stage
|
||||||
val initLatch = ParentLatch(1, renderLatch)
|
val initLatch = ParentLatch(1, renderLatch)
|
||||||
Log.log(LogMessageType.RENDERING, LogLevels.VERBOSE) { "Generating font, gathering textures and loading models (after ${stopwatch.labTime()})..." }
|
Log.log(LogMessageType.RENDERING, LogLevels.VERBOSE) { "Generating font, gathering textures and loading models (after ${stopwatch.labTime()})..." }
|
||||||
|
initLatch.inc(); runAsync { tints.init(connection.assetsManager); initLatch.dec() }
|
||||||
textures.dynamicTextures.upload(initLatch)
|
textures.dynamicTextures.upload(initLatch)
|
||||||
textures.initializeSkins(connection)
|
textures.initializeSkins(connection)
|
||||||
textures.loadDefaultTextures()
|
textures.loadDefaultTextures()
|
||||||
|
@ -146,7 +146,7 @@ class SolidSectionMesher(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val tints = tints.getAverageBlockTint(chunk, neighbourChunks, state, x, y, z)
|
val tints = tints.getBlockTint(state, chunk.getBiome(position.x and 0x0F, y, position.z and 0x0F), x, y, z)
|
||||||
var rendered = model.render(position, floatOffset, mesh, random, state, neighbourBlocks, light, tints)
|
var rendered = model.render(position, floatOffset, mesh, random, state, neighbourBlocks, light, tints)
|
||||||
|
|
||||||
if (entity is BlockRender) {
|
if (entity is BlockRender) {
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparenci
|
|||||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
|
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
|
||||||
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
||||||
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||||
import de.bixilon.minosoft.gui.rendering.tint.tints.WaterTintProvider
|
import de.bixilon.minosoft.gui.rendering.tint.tints.fluid.WaterTintProvider
|
||||||
|
|
||||||
class WaterFluidModel : FluidModel {
|
class WaterFluidModel : FluidModel {
|
||||||
override val tint: TintProvider = WaterTintProvider
|
override val tint: TintProvider = WaterTintProvider
|
||||||
|
@ -14,21 +14,23 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.tint
|
package de.bixilon.minosoft.gui.rendering.tint
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.registries.blocks.MinecraftBlocks
|
import de.bixilon.minosoft.data.registries.blocks.MinecraftBlocks
|
||||||
import de.bixilon.minosoft.data.registries.blocks.types.building.plants.DoublePlant
|
import de.bixilon.minosoft.data.registries.blocks.types.legacy.LegacyBlock
|
||||||
|
import de.bixilon.minosoft.data.registries.blocks.types.pixlyzer.PixLyzerBlock
|
||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
import de.bixilon.minosoft.gui.rendering.tint.tints.*
|
import de.bixilon.minosoft.data.registries.item.items.pixlyzer.PixLyzerItem
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.StaticTintProvider
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.fluid.WaterTintProvider
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.plants.StemTintCalculator
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.plants.SugarCaneTintCalculator
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.redstone.RedstoneWireTintCalculator
|
||||||
|
|
||||||
@Deprecated("directly in integrated registries")
|
@Deprecated("directly in integrated registries")
|
||||||
object DefaultTints {
|
object DefaultTints {
|
||||||
|
|
||||||
fun init(manager: TintManager) {
|
fun init(manager: TintManager) {
|
||||||
manager.applyTo(setOf(MinecraftBlocks.GRASS_BLOCK, MinecraftBlocks.FERN, MinecraftBlocks.GRASS, MinecraftBlocks.POTTED_FERN), manager.grassTintCalculator)
|
manager.applyTo(setOf(MinecraftBlocks.POTTED_FERN), manager.grassTintCalculator)
|
||||||
manager.applyTo(setOf(MinecraftBlocks.LARGE_FERN, MinecraftBlocks.TALL_GRASS, DoublePlant.UpperFlowerBlock.identifier), TallGrassTintCalculator(manager.grassTintCalculator)) // TODO: upper flower block should only tint if using grass or fern
|
|
||||||
manager.applyTo(setOf(MinecraftBlocks.SPRUCE_LEAVES), StaticTintProvider(0x619961))
|
|
||||||
manager.applyTo(setOf(MinecraftBlocks.BIRCH_LEAVES), StaticTintProvider(0x80A755))
|
|
||||||
manager.applyTo(setOf(MinecraftBlocks.OAK_LEAVES, MinecraftBlocks.JUNGLE_LEAVES, MinecraftBlocks.ACACIA_LEAVES, MinecraftBlocks.DARK_OAK_LEAVES, MinecraftBlocks.VINE), manager.foliageTintCalculator)
|
|
||||||
manager.applyTo(setOf(MinecraftBlocks.REDSTONE_WIRE), RedstoneWireTintCalculator)
|
manager.applyTo(setOf(MinecraftBlocks.REDSTONE_WIRE), RedstoneWireTintCalculator)
|
||||||
manager.applyTo(setOf(MinecraftBlocks.WATER_CAULDRON, MinecraftBlocks.CAULDRON, MinecraftBlocks.WATER), WaterTintProvider)
|
manager.applyTo(setOf(MinecraftBlocks.WATER_CAULDRON, MinecraftBlocks.CAULDRON), WaterTintProvider)
|
||||||
manager.applyTo(setOf(MinecraftBlocks.SUGAR_CANE), SugarCaneTintCalculator(manager.grassTintCalculator))
|
manager.applyTo(setOf(MinecraftBlocks.SUGAR_CANE), SugarCaneTintCalculator(manager.grassTintCalculator))
|
||||||
manager.applyTo(setOf(MinecraftBlocks.ATTACHED_MELON_STEM, MinecraftBlocks.ATTACHED_PUMPKIN_STEM), StaticTintProvider(0xE0C71C))
|
manager.applyTo(setOf(MinecraftBlocks.ATTACHED_MELON_STEM, MinecraftBlocks.ATTACHED_PUMPKIN_STEM), StaticTintProvider(0xE0C71C))
|
||||||
manager.applyTo(setOf(MinecraftBlocks.MELON_STEM, MinecraftBlocks.PUMPKIN_STEM), StemTintCalculator)
|
manager.applyTo(setOf(MinecraftBlocks.MELON_STEM, MinecraftBlocks.PUMPKIN_STEM), StemTintCalculator)
|
||||||
@ -37,8 +39,17 @@ object DefaultTints {
|
|||||||
|
|
||||||
private fun TintManager.applyTo(names: Set<ResourceLocation>, provider: TintProvider) {
|
private fun TintManager.applyTo(names: Set<ResourceLocation>, provider: TintProvider) {
|
||||||
for (name in names) {
|
for (name in names) {
|
||||||
connection.registries.block[name]?.tintProvider = provider
|
when (val block = connection.registries.block[name]) {
|
||||||
connection.registries.item[name]?.tintProvider = provider
|
is LegacyBlock -> block.tintProvider = provider
|
||||||
|
is PixLyzerBlock -> block.tintProvider = provider
|
||||||
|
null -> Unit
|
||||||
|
else -> throw IllegalArgumentException("$name should set its tint itself!")
|
||||||
|
}
|
||||||
|
when (val item = connection.registries.item[name]) {
|
||||||
|
is PixLyzerItem -> item.tintProvider = provider
|
||||||
|
null -> Unit
|
||||||
|
else -> throw IllegalArgumentException("$name should set its tint itself!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ import de.bixilon.minosoft.data.registries.fluid.Fluid
|
|||||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor.Companion.asRGBColor
|
import de.bixilon.minosoft.data.text.formatting.color.RGBColor.Companion.asRGBColor
|
||||||
import de.bixilon.minosoft.data.world.chunk.chunk.Chunk
|
import de.bixilon.minosoft.data.world.chunk.chunk.Chunk
|
||||||
import de.bixilon.minosoft.gui.rendering.tint.tints.FoliageTintCalculator
|
import de.bixilon.minosoft.gui.rendering.tint.tints.grass.GrassTintCalculator
|
||||||
import de.bixilon.minosoft.gui.rendering.tint.tints.GrassTintCalculator
|
import de.bixilon.minosoft.gui.rendering.tint.tints.plants.FoliageTintCalculator
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
|
||||||
class TintManager(val connection: PlayConnection) {
|
class TintManager(val connection: PlayConnection) {
|
||||||
@ -35,44 +35,34 @@ class TintManager(val connection: PlayConnection) {
|
|||||||
grassTintCalculator.init(assetsManager)
|
grassTintCalculator.init(assetsManager)
|
||||||
foliageTintCalculator.init(assetsManager)
|
foliageTintCalculator.init(assetsManager)
|
||||||
|
|
||||||
|
for (block in connection.registries.block) {
|
||||||
|
if (block !is TintedBlock) continue
|
||||||
|
block.initTint(this)
|
||||||
|
}
|
||||||
|
for (item in connection.registries.item) {
|
||||||
|
if (item !is TintedBlock) continue
|
||||||
|
item.initTint(this)
|
||||||
|
}
|
||||||
|
|
||||||
DefaultTints.init(this)
|
DefaultTints.init(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAverageBlockTint(chunk: Chunk, neighbours: Array<Chunk>, blockState: BlockState, tintProvider: TintProvider, x: Int, y: Int, z: Int): IntArray {
|
fun getBlockTint(state: BlockState, biome: Biome?, x: Int, y: Int, z: Int): IntArray? {
|
||||||
// ToDo: biome blending?
|
if (state.block !is TintedBlock) return null
|
||||||
val inChunkX = x and 0x0F
|
val tintProvider = state.block.tintProvider ?: return null
|
||||||
val inChunkZ = z and 0x0F
|
|
||||||
val biome = chunk.getBiome(inChunkX, y, inChunkZ)
|
|
||||||
val tints = IntArray(if (tintProvider is MultiTintProvider) tintProvider.tints else 1)
|
val tints = IntArray(if (tintProvider is MultiTintProvider) tintProvider.tints else 1)
|
||||||
|
|
||||||
for (tintIndex in tints.indices) {
|
for (tintIndex in tints.indices) {
|
||||||
tints[tintIndex] = tintProvider.getBlockColor(blockState, biome, x, y, z, tintIndex)
|
tints[tintIndex] = tintProvider.getBlockColor(state, biome, x, y, z, tintIndex)
|
||||||
}
|
}
|
||||||
return tints
|
return tints
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAverageBlockTint(chunk: Chunk, neighbours: Array<Chunk>, blockState: BlockState, x: Int, y: Int, z: Int): IntArray? {
|
fun getParticleTint(state: BlockState, x: Int, y: Int, z: Int): Int? {
|
||||||
return getAverageBlockTint(chunk, neighbours, blockState, blockState.block.tintProvider ?: return null, x, y, z)
|
if (state.block !is TintedBlock) return null
|
||||||
}
|
val tintProvider = state.block.tintProvider ?: return null
|
||||||
|
|
||||||
fun getAverageBlockTint(chunk: Chunk, neighbours: Array<Chunk>, blockState: BlockState, fluid: Fluid, x: Int, y: Int, z: Int): IntArray? {
|
|
||||||
return getAverageBlockTint(chunk, neighbours, blockState, fluid.model?.tint ?: return null, x, y, z)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getBlockTint(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int): IntArray? {
|
|
||||||
val tintProvider = blockState.block.tintProvider ?: return null
|
|
||||||
val tints = IntArray(if (tintProvider is MultiTintProvider) tintProvider.tints else 1)
|
|
||||||
|
|
||||||
for (tintIndex in tints.indices) {
|
|
||||||
tints[tintIndex] = tintProvider.getBlockColor(blockState, biome, x, y, z, tintIndex)
|
|
||||||
}
|
|
||||||
return tints
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getParticleTint(blockState: BlockState, x: Int, y: Int, z: Int): Int? {
|
|
||||||
val tintProvider = blockState.block.tintProvider ?: return null
|
|
||||||
val biome = connection.world.getBiome(x, y, z)
|
val biome = connection.world.getBiome(x, y, z)
|
||||||
return tintProvider.getParticleColor(blockState, biome, x, y, z)
|
return tintProvider.getParticleColor(state, biome, x, y, z)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getParticleTint(blockState: BlockState, position: Vec3i): Int? {
|
fun getParticleTint(blockState: BlockState, position: Vec3i): Int? {
|
||||||
@ -89,6 +79,7 @@ class TintManager(val connection: PlayConnection) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getItemTint(stack: ItemStack): IntArray? {
|
fun getItemTint(stack: ItemStack): IntArray? {
|
||||||
|
if (stack.item.item !is TintedBlock) return null
|
||||||
val tintProvider = stack.item.item.tintProvider ?: return null
|
val tintProvider = stack.item.item.tintProvider ?: return null
|
||||||
val tints = IntArray(if (tintProvider is MultiTintProvider) tintProvider.tints else 1)
|
val tints = IntArray(if (tintProvider is MultiTintProvider) tintProvider.tints else 1)
|
||||||
|
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2023 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.gui.rendering.tint
|
||||||
|
|
||||||
|
interface TintedBlock {
|
||||||
|
val tintProvider: TintProvider?
|
||||||
|
|
||||||
|
fun initTint(manager: TintManager) = Unit
|
||||||
|
}
|
@ -11,7 +11,7 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.tint.tints
|
package de.bixilon.minosoft.gui.rendering.tint.tints.fluid
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
@ -11,15 +11,15 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.tint.tints
|
package de.bixilon.minosoft.gui.rendering.tint.tints.grass
|
||||||
|
|
||||||
import de.bixilon.kutil.exception.ExceptionUtil.ignoreAll
|
import de.bixilon.kutil.exception.ExceptionUtil.ignoreAll
|
||||||
import de.bixilon.minosoft.assets.AssetsManager
|
import de.bixilon.minosoft.assets.AssetsManager
|
||||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readRGBArray
|
import de.bixilon.minosoft.assets.util.InputStreamUtil.readRGBArray
|
||||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||||
import de.bixilon.minosoft.data.registries.biomes.GrassColorModifiers
|
import de.bixilon.minosoft.data.registries.biomes.GrassColorModifiers
|
||||||
import de.bixilon.minosoft.data.registries.blocks.MinecraftBlocks
|
|
||||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||||
|
import de.bixilon.minosoft.data.registries.blocks.types.building.dirt.GrassBlock
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
||||||
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
||||||
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||||
@ -66,7 +66,7 @@ class GrassTintCalculator : TintProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getParticleColor(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int): Int {
|
override fun getParticleColor(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int): Int {
|
||||||
if (blockState.block.identifier == MinecraftBlocks.GRASS_BLOCK) {
|
if (blockState.block is GrassBlock) { // dirt particles
|
||||||
return Colors.WHITE
|
return Colors.WHITE
|
||||||
}
|
}
|
||||||
return getBlockColor(biome)
|
return getBlockColor(biome)
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2023 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.gui.rendering.tint.tints.grass
|
||||||
|
|
||||||
|
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintManager
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.TintedBlock
|
||||||
|
|
||||||
|
interface GrassTinted : TintedBlock {
|
||||||
|
|
||||||
|
override fun initTint(manager: TintManager) {
|
||||||
|
this::class.java.getDeclaredField("tintProvider").forceSet(this, manager.grassTintCalculator)
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,7 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.tint.tints
|
package de.bixilon.minosoft.gui.rendering.tint.tints.grass
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
@ -11,7 +11,7 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.tint.tints
|
package de.bixilon.minosoft.gui.rendering.tint.tints.plants
|
||||||
|
|
||||||
import de.bixilon.kutil.exception.ExceptionUtil.ignoreAll
|
import de.bixilon.kutil.exception.ExceptionUtil.ignoreAll
|
||||||
import de.bixilon.minosoft.assets.AssetsManager
|
import de.bixilon.minosoft.assets.AssetsManager
|
@ -11,7 +11,7 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.tint.tints
|
package de.bixilon.minosoft.gui.rendering.tint.tints.plants
|
||||||
|
|
||||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
import de.bixilon.minosoft.data.registries.biomes.Biome
|
@ -11,13 +11,14 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.tint.tints
|
package de.bixilon.minosoft.gui.rendering.tint.tints.plants
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
||||||
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||||
|
import de.bixilon.minosoft.gui.rendering.tint.tints.grass.GrassTintCalculator
|
||||||
|
|
||||||
class SugarCaneTintCalculator(val grassTintCalculator: GrassTintCalculator) : TintProvider {
|
class SugarCaneTintCalculator(val grassTintCalculator: GrassTintCalculator) : TintProvider {
|
||||||
|
|
@ -11,7 +11,7 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.tint.tints
|
package de.bixilon.minosoft.gui.rendering.tint.tints.redstone
|
||||||
|
|
||||||
import de.bixilon.kotlinglm.func.common.clamp
|
import de.bixilon.kotlinglm.func.common.clamp
|
||||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
import de.bixilon.kutil.primitive.IntUtil.toInt
|
Loading…
x
Reference in New Issue
Block a user