From 179ecd2d5af6349fe6a7812419c6d7818afb3b38 Mon Sep 17 00:00:00 2001 From: fredboy Date: Tue, 7 May 2024 21:16:11 +0700 Subject: [PATCH] Add spruce and snow to winter biome --- android/assets/json/crafting.json | 4 + android/assets/json/game_items.json | 123 ++++++++++++++++-- .../assets/textures/blocks/leaves_spruce.png | Bin 0 -> 705 bytes android/assets/textures/blocks/snow.png | Bin 0 -> 315 bytes android/assets/textures/items/snowball.png | Bin 0 -> 230 bytes .../actions/updateblock/UpdateGrassAction.kt | 8 +- .../updateblock/UpdateSnowedGrassAction.kt | 7 +- .../cavedroid/game/mobs/player/Inventory.kt | 2 +- .../game/world/GameWorldGenerator.kt | 43 ++++++ 9 files changed, 173 insertions(+), 14 deletions(-) create mode 100644 android/assets/textures/blocks/leaves_spruce.png create mode 100644 android/assets/textures/blocks/snow.png create mode 100644 android/assets/textures/items/snowball.png 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 0000000000000000000000000000000000000000..0be1897b581dcbd6bc93ad9ba94c47ffa35ef1f9 GIT binary patch literal 705 zcmV;y0zUnTP)TN?a`?Y-5~4+K{l3Dv|HLTZRR z7la?78{@)-`U?zU;m!n`E=-^-bcuY_3TUBE1I@#OY$K^jywR{M`kIgNtm_>d$PbeM&K*Vkj*@>|SjqXZeD}|5} zA*HSX2q{tZI@00L_4#xL+3oesEHM`h!02ED*tA;vW*$`Bh9cME7AwR;{0+; za9=Y^T)BFgwvIM!z0ZG%^mJN3A|8!DwwrV9@p;*;Z0kc$ua97VK!>~Yv%<(|g0ssZ zrDQNMfKrNst-p*mk#1jE<0^us_fk?I}2CwE)uTHn43Qr`sTtn#DL}y_hW` ngrJZuVk^ba{aZS~rWW8oqYw)(CKYoi00000NkvXXu0mjf1DiU8 literal 0 HcmV?d00001 diff --git a/android/assets/textures/blocks/snow.png b/android/assets/textures/blocks/snow.png new file mode 100644 index 0000000000000000000000000000000000000000..20a836ef95d93e3e1ca09dd2befe6eb6df032ca5 GIT binary patch literal 315 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXY~8w@?$_XJ3U<- zLoEDrFIw{*au8q+cvo*@r4f)Z!D(V!o6!1uryLwMsrA`!mVUZn&FzmRC->OTJNUDz z`9sH@^9Ob_SY1*qeR)vFK{#ip&kR=noeV1@f_j|fZi;BQ1pdomn^L%R-s!dqod^H) zAAE^2;Bwj>bMhS5eAe%;Pu*MInkN~~q^Po?H7Rh)nf3nz)-P%@s*TaqpDD(&BPKxn zS^bA3_Pz+gd$)c|*KM>mn42KBLgnH)d)A=PZd2};sdwY1>|48f-F}OAKu<7uy85}S Ib4q9e01)(eqW}N^ literal 0 HcmV?d00001 diff --git a/android/assets/textures/items/snowball.png b/android/assets/textures/items/snowball.png new file mode 100644 index 0000000000000000000000000000000000000000..56a11e9fd1605577e9f510cf31282758a749d75d GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ydu{YLn>}$brYDxW3g) zkadctMiC=WV^>TAQ{m)TlZkFsZ~B)UnDq2&-m~7fC3p8f`W2y6y!pe=s`X4)1rCMJ z&Hw)6@>O|hCkJ7taI57>srGY{L?`qu_##(QK1a{;z}m|b9}8$Xuqhrm_r@dFdr8!r zL;NvOFZplS-e$H|IFo)q`pz9@)|D$P?2muAGiRy*=W2#lIWMNU{Ev6)svS8w&Ac;v eLF}Qu9~qgBzkV<^YrZ_t;S8RxelF{r5}E*Q9bNqZ literal 0 HcmV?d00001 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 -- 2.29.2