Skip to content

Commit

Permalink
implement fern blocks (dead_bush, grass, fern)
Browse files Browse the repository at this point in the history
That makes walking through biomes soooo much easier and better.
  • Loading branch information
Bixilon committed Oct 8, 2023
1 parent d68f2b0 commit 4faadaf
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ import de.bixilon.minosoft.data.registries.blocks.types.Block
import de.bixilon.minosoft.data.registries.blocks.types.air.AirBlock
import de.bixilon.minosoft.data.registries.blocks.types.bee.HoneyBlock
import de.bixilon.minosoft.data.registries.blocks.types.building.WoolBlock
import de.bixilon.minosoft.data.registries.blocks.types.building.dirt.GrassBlock
import de.bixilon.minosoft.data.registries.blocks.types.building.plants.FernBlock
import de.bixilon.minosoft.data.registries.blocks.types.building.snow.SnowBlock
import de.bixilon.minosoft.data.registries.blocks.types.building.snow.SnowLayerBlock
import de.bixilon.minosoft.data.registries.blocks.types.climbing.ScaffoldingBlock
import de.bixilon.minosoft.data.registries.blocks.types.dirt.GrassBlock
import de.bixilon.minosoft.data.registries.blocks.types.fluid.LavaFluidBlock
import de.bixilon.minosoft.data.registries.blocks.types.fluid.water.BubbleColumnBlock
import de.bixilon.minosoft.data.registries.blocks.types.fluid.water.WaterFluidBlock
import de.bixilon.minosoft.data.registries.blocks.types.pixlyzer.SlimeBlock
import de.bixilon.minosoft.data.registries.blocks.types.pixlyzer.snow.PowderSnowBlock
import de.bixilon.minosoft.data.registries.blocks.types.pvp.CobwebBlock
import de.bixilon.minosoft.data.registries.blocks.types.snow.SnowBlock
import de.bixilon.minosoft.data.registries.blocks.types.snow.SnowLayerBlock
import de.bixilon.minosoft.data.registries.blocks.types.stone.RockBlock
import de.bixilon.minosoft.data.registries.blocks.types.wood.*
import de.bixilon.minosoft.data.registries.factory.DefaultFactory
Expand Down Expand Up @@ -72,6 +73,7 @@ object BlockFactories : DefaultFactory<BlockFactory<*>>(
FloweringAzalea.Leaves,

SnowBlock, SnowLayerBlock,
FernBlock.DeadBush, FernBlock.Grass, FernBlock.Fern,
) {

fun build(name: ResourceLocation, registries: Registries, settings: BlockSettings): Block? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import de.bixilon.minosoft.data.registries.blocks.properties.primitives.BooleanP
import de.bixilon.minosoft.data.registries.blocks.properties.primitives.IntProperty
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
import de.bixilon.minosoft.data.registries.blocks.types.Block
import de.bixilon.minosoft.data.registries.blocks.types.dirt.SnowyBlock
import de.bixilon.minosoft.data.registries.blocks.types.building.dirt.SnowyBlock
import de.bixilon.minosoft.data.registries.blocks.types.building.snow.SnowLayerBlock
import de.bixilon.minosoft.data.registries.blocks.types.fluid.FluidBlock
import de.bixilon.minosoft.data.registries.blocks.types.snow.SnowLayerBlock

@Deprecated("Fallback data")
object BlockProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
return 1.0f
}

open class White(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class White(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.WHITE

companion object : BlockFactory<White> {
Expand All @@ -57,7 +57,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Orange(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Orange(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.ORANGE

companion object : BlockFactory<Orange> {
Expand All @@ -67,7 +67,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Magenta(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Magenta(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.MAGENTA

companion object : BlockFactory<Magenta> {
Expand All @@ -77,7 +77,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class LightBlue(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class LightBlue(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.LIGHT_BLUE

companion object : BlockFactory<LightBlue> {
Expand All @@ -87,7 +87,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Yellow(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Yellow(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.YELLOW

companion object : BlockFactory<Yellow> {
Expand All @@ -97,7 +97,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Lime(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Lime(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.LIME

companion object : BlockFactory<Lime> {
Expand All @@ -107,7 +107,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Pink(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Pink(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.PINK

companion object : BlockFactory<Pink> {
Expand All @@ -117,7 +117,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Gray(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Gray(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.GRAY

companion object : BlockFactory<Gray> {
Expand All @@ -127,7 +127,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class LightGray(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class LightGray(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.LIGHT_GRAY

companion object : BlockFactory<LightGray> {
Expand All @@ -137,7 +137,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Cyan(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Cyan(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.CYAN

companion object : BlockFactory<Cyan> {
Expand All @@ -147,7 +147,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Purple(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Purple(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.PURPLE

companion object : BlockFactory<Purple> {
Expand All @@ -157,7 +157,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Blue(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Blue(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.BLUE

companion object : BlockFactory<Blue> {
Expand All @@ -167,7 +167,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Brown(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Brown(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.BROWN

companion object : BlockFactory<Brown> {
Expand All @@ -177,7 +177,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Green(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Green(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.GREEN

companion object : BlockFactory<Green> {
Expand All @@ -187,7 +187,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Red(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Red(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.RED

companion object : BlockFactory<Red> {
Expand All @@ -197,7 +197,7 @@ abstract class WoolBlock(identifier: ResourceLocation, settings: BlockSettings)
}
}

open class Black(identifier: ResourceLocation = this.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
open class Black(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : WoolBlock(identifier, settings) {
override val color: DyeColors get() = DyeColors.BLACK

companion object : BlockFactory<Black> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/

package de.bixilon.minosoft.data.registries.blocks.types.dirt
package de.bixilon.minosoft.data.registries.blocks.types.building.dirt

import de.bixilon.minosoft.data.registries.blocks.factory.BlockFactory
import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/

package de.bixilon.minosoft.data.registries.blocks.types.dirt
package de.bixilon.minosoft.data.registries.blocks.types.building.dirt

import de.bixilon.minosoft.data.direction.Directions
import de.bixilon.minosoft.data.registries.blocks.properties.list.MapPropertyList
import de.bixilon.minosoft.data.registries.blocks.properties.primitives.BooleanProperty
import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
import de.bixilon.minosoft.data.registries.blocks.types.Block
import de.bixilon.minosoft.data.registries.blocks.types.snow.AbstractSnowBlock
import de.bixilon.minosoft.data.registries.blocks.types.building.snow.AbstractSnowBlock
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.models.block.state.DirectBlockModel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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.data.registries.blocks.types.building.plants

import de.bixilon.minosoft.data.registries.blocks.factory.BlockFactory
import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
import de.bixilon.minosoft.data.registries.blocks.types.Block
import de.bixilon.minosoft.data.registries.blocks.types.legacy.FlatteningRenamedModel
import de.bixilon.minosoft.data.registries.blocks.types.properties.hardness.InstantBreakableBlock
import de.bixilon.minosoft.data.registries.blocks.types.properties.item.BlockWithItem
import de.bixilon.minosoft.data.registries.blocks.types.properties.offset.RandomOffsetBlock
import de.bixilon.minosoft.data.registries.blocks.types.properties.offset.RandomOffsetTypes
import de.bixilon.minosoft.data.registries.blocks.types.properties.shape.outline.FullOutlinedBlock
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
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.tool.shears.ShearsRequirement
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.data.registries.shapes.voxel.VoxelShape
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection

abstract class FernBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), ShearsRequirement, BlockWithItem<Item>, FullOutlinedBlock, RandomOffsetBlock, InstantBreakableBlock {
override val randomOffset get() = RandomOffsetTypes.XYZ
override val item: Item = this::item.inject(identifier)

override fun getOutlineShape(connection: PlayConnection, blockState: BlockState) = SHAPE

companion object {
private val SHAPE = VoxelShape(0.125, 0.0, 0.125, 0.875, 0.8125, 0.875)

}

open class DeadBush(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : FernBlock(identifier, settings) {

companion object : BlockFactory<DeadBush> {
override val identifier = minecraft("dead_bush")

override fun build(registries: Registries, settings: BlockSettings) = DeadBush(settings = settings)
}
}

open class Grass(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : FernBlock(identifier, settings), FlatteningRenamedModel {
override val legacyModelName get() = minecraft("tall_grass")

companion object : BlockFactory<Grass> {
override val identifier = minecraft("grass")

override fun build(registries: Registries, settings: BlockSettings) = Grass(settings = settings)
}
}

open class Fern(identifier: ResourceLocation = Companion.identifier, settings: BlockSettings) : FernBlock(identifier, settings) {

companion object : BlockFactory<Fern> {
override val identifier = minecraft("fern")

override fun build(registries: Registries, settings: BlockSettings) = Fern(settings = settings)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/

package de.bixilon.minosoft.data.registries.blocks.types.snow
package de.bixilon.minosoft.data.registries.blocks.types.building.snow

interface AbstractSnowBlock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/

package de.bixilon.minosoft.data.registries.blocks.types.snow
package de.bixilon.minosoft.data.registries.blocks.types.building.snow

import de.bixilon.minosoft.data.registries.blocks.factory.BlockFactory
import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/

package de.bixilon.minosoft.data.registries.blocks.types.snow
package de.bixilon.minosoft.data.registries.blocks.types.building.snow

import de.bixilon.kutil.primitive.IntUtil.toInt
import de.bixilon.minosoft.data.registries.blocks.factory.BlockFactory
Expand Down

0 comments on commit 4faadaf

Please sign in to comment.