From: fredboy Date: Tue, 7 May 2024 14:16:11 +0000 (+0700) Subject: Add spruce and snow to winter biome X-Git-Tag: alpha0.7.1~3 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=179ecd2d5af6349fe6a7812419c6d7818afb3b38;p=cavedroid.git Add spruce and snow to winter biome --- diff --git a/android/assets/json/crafting.json b/android/assets/json/crafting.json index 6f651bb..94cbe47 100644 --- a/android/assets/json/crafting.json +++ b/android/assets/json/crafting.json @@ -38,5 +38,9 @@ "stone_shovel": { "input": ["none", "cobblestone", "none", "none", "stick", "none", "none", "stick", "none"], "count": 131 + }, + "snow_block": { + "input": ["snowball", "snowball", "none", "snowball", "snowball", "none", "none", "none", "none"], + "count": 1 } } \ No newline at end of file diff --git a/android/assets/json/game_items.json b/android/assets/json/game_items.json index d6c3b44..f6bfb63 100644 --- a/android/assets/json/game_items.json +++ b/android/assets/json/game_items.json @@ -49,6 +49,13 @@ "tool_level": 0, "tool_type": "axe" }, + "planks_spruce": { + "hp": 180, + "drop": "planks_spruce", + "texture": "planks_spruce", + "tool_level": 0, + "tool_type": "axe" + }, "sapling_oak": { "collision": false, "transparent": true, @@ -57,6 +64,14 @@ "texture": "sapling_oak", "hp": 0 }, + "sapling_spruce": { + "collision": false, + "transparent": true, + "block_required": true, + "drop": "sapling_spruce", + "texture": "sapling_spruce", + "hp": 0 + }, "bedrock": { "drop": "bedrock", "texture": "bedrock" @@ -145,6 +160,21 @@ "tool_type": "shears", "tint": "#5AC557" }, + "log_spruce": { + "hp": 180, + "drop": "log_spruce", + "texture": "log_spruce", + "tool_level": 0, + "tool_type": "axe" + }, + "leaves_spruce": { + "hp": 21, + "drop": "leaves_spruce", + "texture": "leaves_spruce", + "tool_level": 1, + "tool_type": "shears", + "tint": "#486D4E" + }, "sponge": { "hp": 54, "drop": "sponge", @@ -487,6 +517,32 @@ "tool_level": 0, "tool_type": "axe" }, + "spruce_slab_bottom": { + "top": 8, + "sprite_top": 8, + "hp": 180, + "transparent": true, + "drop": "spruce_slab", + "meta": "slab", + "texture": "planks_spruce", + "full_block": "planks_spruce", + "other_part": "spruce_slab_top", + "tool_level": 0, + "tool_type": "axe" + }, + "spruce_slab_top": { + "bottom": 8, + "sprite_bottom": 8, + "hp": 180, + "transparent": true, + "drop": "spruce_slab", + "meta": "slab", + "texture": "planks_spruce", + "full_block": "planks_spruce", + "other_part": "spruce_slab_bottom", + "tool_level": 0, + "tool_type": "axe" + }, "cobblestone_slab_bottom": { "top": 8, "sprite_top": 8, @@ -683,6 +739,28 @@ "texture": "obsidian", "tool_level": 4, "tool_type": "pickaxe" + }, + "snow": { + "top": 14, + "sprite_top": 14, + "collision": false, + "transparent": true, + "drop": "snowball", + "texture": "snow", + "hp": 6, + "tool_level": 1, + "tool_type": "shovel", + "block_required": true + }, + "snow_block": { + "collision": true, + "transparent": true, + "drop": "snowball", + "drop_count": 4, + "texture": "snow", + "hp": 60, + "tool_level": 1, + "tool_type": "shovel" } }, "items": { @@ -721,20 +799,20 @@ "type": "block", "texture": "sapling_oak" }, - "bedrock": { - "name": "Bedrock", + "planks_spruce": { + "name": "Spruce Planks", "type": "block", - "texture": "bedrock" + "texture": "planks_spruce" }, - "water": { - "name": "Water", + "sapling_spruce": { + "name": "Spruce Sapling", "type": "block", - "texture": "water" + "texture": "sapling_spruce" }, - "lava": { - "name": "Lava", + "bedrock": { + "name": "Bedrock", "type": "block", - "texture": "lava" + "texture": "bedrock" }, "sand": { "name": "Sand", @@ -776,6 +854,16 @@ "type": "block", "texture": "leaves_oak" }, + "log_spruce": { + "name": "Spruce", + "type": "block", + "texture": "log_spruce" + }, + "leaves_spruce": { + "name": "Spruce Leaves", + "type": "block", + "texture": "leaves_spruce" + }, "glass": { "name": "Glass", "type": "block", @@ -958,6 +1046,13 @@ "top_slab_block": "oak_slab_top", "bottom_slab_block": "oak_slab_bottom" }, + "spruce_slab": { + "name": "Spruce Slab", + "type": "slab", + "texture": "spruce_slab", + "top_slab_block": "spruce_slab_top", + "bottom_slab_block": "spruce_slab_bottom" + }, "cobblestone_slab": { "name": "Cobblestone Slab", "type": "slab", @@ -994,6 +1089,11 @@ "type": "block", "texture": "obsidian" }, + "snow_block": { + "name": "Snow Block", + "type": "block", + "texture": "snow" + }, "stick": { "name": "Stick", "texture": "stick" @@ -1192,6 +1292,11 @@ "origin_x": 0.25, "action_key": "use_lava_bucket", "max_stack": 1 + }, + "snowball": { + "name": "Snowball", + "texture": "snowball", + "max_stack": 16 } } } diff --git a/android/assets/textures/blocks/leaves_spruce.png b/android/assets/textures/blocks/leaves_spruce.png new file mode 100644 index 0000000..0be1897 Binary files /dev/null and b/android/assets/textures/blocks/leaves_spruce.png differ diff --git a/android/assets/textures/blocks/snow.png b/android/assets/textures/blocks/snow.png new file mode 100644 index 0000000..20a836e Binary files /dev/null and b/android/assets/textures/blocks/snow.png differ diff --git a/android/assets/textures/items/snowball.png b/android/assets/textures/items/snowball.png new file mode 100644 index 0000000..56a11e9 Binary files /dev/null and b/android/assets/textures/items/snowball.png differ diff --git a/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateGrassAction.kt b/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateGrassAction.kt index 27005b8..d5ca3b1 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateGrassAction.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateGrassAction.kt @@ -13,8 +13,12 @@ class UpdateGrassAction @Inject constructor( override fun update(x: Int, y: Int) { val blockOnTop = gameWorld.getForeMap(x, y - 1) - if (blockOnTop.collision || blockOnTop.isFluid()) { - gameWorld.setForeMap(x, y, mGameItemsHolder.getBlock("dirt")) + + val makesDirt = blockOnTop.params.hasCollision || blockOnTop.isFluid() + + when { + makesDirt -> gameWorld.setForeMap(x, y, mGameItemsHolder.getBlock("dirt")) + blockOnTop.params.key == "snow" -> gameWorld.setForeMap(x, y, mGameItemsHolder.getBlock("grass_snowed")) } } diff --git a/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateSnowedGrassAction.kt b/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateSnowedGrassAction.kt index 8b7f0e3..0aa5c90 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateSnowedGrassAction.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateSnowedGrassAction.kt @@ -13,8 +13,11 @@ class UpdateSnowedGrassAction @Inject constructor( override fun update(x: Int, y: Int) { val blockOnTop = gameWorld.getForeMap(x, y - 1) - if (blockOnTop.collision || blockOnTop.isFluid()) { - gameWorld.setForeMap(x, y, mGameItemsHolder.getBlock("dirt")) + val makesDirt = blockOnTop.params.hasCollision || blockOnTop.isFluid() + + when { + makesDirt -> gameWorld.setForeMap(x, y, mGameItemsHolder.getBlock("dirt")) + blockOnTop.params.key != "snow" -> gameWorld.setForeMap(x, y, mGameItemsHolder.getBlock("grass")) } } diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Inventory.kt b/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Inventory.kt index 31f4c78..4469038 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Inventory.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Inventory.kt @@ -80,6 +80,6 @@ class Inventory( endIndex = size - 1 ) - _items[0] = item.toInventoryItem() + _items[0] = item.toInventoryItem(item.params.maxStack) } } \ No newline at end of file diff --git a/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt b/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt index e00a0ea..004a56b 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt @@ -72,12 +72,17 @@ class GameWorldGenerator( val bedrock = gameItemsHolder.getBlock("bedrock") val dirt = gameItemsHolder.getBlock("dirt") val stone = gameItemsHolder.getBlock("stone") + val snow = gameItemsHolder.getBlock("snow") foreMap[x][surfaceHeight] = grass foreMap[x][config.height - 1] = bedrock backMap[x][surfaceHeight] = grass backMap[x][config.height - 1] = bedrock + if (surfaceHeight - 1 < config.seaLevel) { + foreMap[x][surfaceHeight - 1] = snow + } + for (y in min(surfaceHeight + 1, config.seaLevel) ..< config.height - 1) { if (y <= surfaceHeight) { backMap[x][y] = dirt @@ -90,6 +95,13 @@ class GameWorldGenerator( } backMap[x][y] = foreMap[x][y] } + + val plant = random.nextInt(100) + if (surfaceHeight < config.seaLevel) { + if (plant < 10) { + generateSpruce(x) + } + } } private fun plainsBiome(x: Int) { @@ -222,6 +234,37 @@ class GameWorldGenerator( } } + private fun generateSpruce(x: Int) { + val log = gameItemsHolder.getBlock("log_spruce") + val leaves = gameItemsHolder.getBlock("leaves_spruce") + val h = heights[x] - 1 + val treeH = random.nextInt(7, 9) + val height = max(0, h - treeH) + + val top = height - 1 + if (top >= 0) { + foreMap[x][top] = leaves + backMap[x][top] = leaves + } + + for (x1 in max(0, x - 1) .. min(config.width - 1, x + 1)) { + val y = height + foreMap[x1][y] = leaves + backMap[x1][y] = leaves + } + + for (y in 1..2) { + for (x1 in max(0, x - y) .. min(config.width - 1, x + y)) { + foreMap[x1][height + 1 + y] = leaves + backMap[x1][height + 1 + y] = leaves + } + } + + for (y in h downTo height) { + backMap[x][y] = log + } + } + private fun generateTallGrass(x: Int) { val tallGrass = gameItemsHolder.getBlock(plainsPlants.random(random)) val h = heights[x] - 1