Marlin Posted August 10, 2021 Report Share Posted August 10, 2021 If I mown the lawn of my yard it will one day grow back...but that doesn't happen in the game. My suggestion is that the grass grows over time, Stardew Valley or Terraria style, in spring, after the winter and snow. 1 Link to comment Share on other sites More sharing options...
LuuBluum Posted August 11, 2021 Report Share Posted August 11, 2021 It does. The wiki is wrong in this regard; grass grows and regrows over time just fine. Link to comment Share on other sites More sharing options...
Marlin Posted August 11, 2021 Author Report Share Posted August 11, 2021 12 hours ago, LuuBluum said: It does. The wiki is wrong in this regard; grass grows and regrows over time just fine. How does it grow? Link to comment Share on other sites More sharing options...
LuuBluum Posted August 11, 2021 Report Share Posted August 11, 2021 39 minutes ago, Marlin said: How does it grow? Simple. public override void OnServerGameTick(IWorldAccessor world, BlockPos pos, object extra = null) { base.OnServerGameTick(world, pos, extra); GrassTick tick = extra as GrassTick; world.BlockAccessor.SetBlock(tick.Grass.BlockId, pos); if (tick.TallGrass != null && world.BlockAccessor.GetBlock(pos.UpCopy()).BlockId == 0) { world.BlockAccessor.SetBlock(tick.TallGrass.BlockId, pos.UpCopy()); } } Whenever it receives a server game tick, and specifically is told to grow grass in that tick, then it grows grass. Of course, that begs the question: when should it receive a server game tick? public override bool ShouldReceiveServerGameTicks(IWorldAccessor world, BlockPos pos, Random offThreadRandom, out object extra) { extra = null; if (offThreadRandom.NextDouble() > growthChanceOnTick) return false; if (growOnlyWhereRainfallExposed && world.BlockAccessor.GetRainMapHeightAt(pos) > pos.Y + 1) { return false; } bool isGrowing = false; Block grass; BlockPos upPos = pos.UpCopy(); bool lowLightLevel = world.BlockAccessor.GetLightLevel(pos, EnumLightLevelType.MaxLight) < growthLightLevel; if (lowLightLevel || isSmotheringBlock(world, upPos)) { grass = tryGetBlockForDying(world); } else { isGrowing = true; grass = tryGetBlockForGrowing(world, pos); } if (grass != null) { extra = new GrassTick() { Grass = grass, TallGrass = isGrowing ? getTallGrassBlock(world, upPos, offThreadRandom) : null }; } return extra != null; } Which is to say, first it rolls a die to see whether it should even grow, based on growth chance. Then it checks whether it should be getting rain and, if it should, whether it does. If all of that is met, it then checks whether or not the grass should grow or die (die if smothered or in darkness, grow otherwise). If in fact it should, then it does. So, if you want grass to grow, make sure it is exposed to rain and not smothered, and is in good lighting. Then wait. Link to comment Share on other sites More sharing options...
Streetwind Posted August 11, 2021 Report Share Posted August 11, 2021 (edited) Grass plants have a chance to spawn whenever the texture of a dirt block changes. Freshly placed dirt blocks have no grass texture at all. Then, over time, their texture can go from patchy to sparse to full. Sometimes it skips a step, sometimes it does every step. Sometimes it happens quickly, sometimes it takes a while. Everytime the texture changes, it has a chance (but not a guarantee) to spawn a grass plant on top of it. If there already is one, the block texture can still continue to change, but it will obviously not spawn new grass, as it is already there. But if the grass plant is harvested, a new one might spawn at the next texture change. Once the dirt block has reached its final, full grass texture, it will never change again, and therefore, never spawn grass again. Unless you dig it up and place it back down so it starts texture-less again. Also, fallow farmland has a small chance of spawning grass over time. If you want a steady supply of grass without having to regularly dig up dirt, make a giant field, and don't plant anything on it. Doing the dirt thing generates grass much faster, though. Edited August 11, 2021 by Streetwind Link to comment Share on other sites More sharing options...
LuuBluum Posted August 11, 2021 Report Share Posted August 11, 2021 3 minutes ago, Streetwind said: Grass plants have a chance to spawn whenever the texture of a dirt block changes. Freshly placed dirt blocks have no grass texture at all. Then, over time, their texture can go from patchy to sparse to full. Sometimes it skips a step, sometimes it does every step. Sometimes it happens quickly, sometimes it takes a while. Everytime the texture changes, it has a chance (but not a guarantee) to spawn a grass plant on top of it. If there already is one, the black texture can still continue to change, but it will obviously not spawn new grass, as it is already there. But if the grass plant is harvested, a new one might spawn at the next texture change. Once the dirt block has reached its final, full grass texture, it will never change again, and therefore, never spawn grass again. Unless you dig it up and place it back down so it starts texture-less again. Also, fallow farmland has a small chance of spawning grass over time. If you want a steady supply of grass without having to regularly dig up dirt, make a giant field, and don't plant anything on it. Doing the dirt thing generates gradd much faster, though. Ah, you are actually right on that. I guess that's to prevent tall grass spam, since otherwise over time fields of grass would become completely overgrown with tall grass. Perhaps that really means that we just need more wildlife to eat the ever-growing tall grass? 2 Link to comment Share on other sites More sharing options...
Maelstrom Posted August 11, 2021 Report Share Posted August 11, 2021 (edited) 1 hour ago, Streetwind said: Also, fallow farmland has a small chance of spawning grass over time. If you want a steady supply of grass without having to regularly dig up dirt, make a giant field, and don't plant anything on it. Doing the dirt thing generates grass much faster, though. Or find a plain that is littered with tall grass. Dropped my permanent home in the middle of a massive field of tall grass. Literally every single block in a hundred block radius has tall grass unless there's a tree, water, or reed on it. I wonder how long my iron scythe will take to break harvesting only grass and how much grass will I have on my hands when it does. Edited August 11, 2021 by Maelstrom Link to comment Share on other sites More sharing options...
Recommended Posts