ddevault / Craft.Net

(Unmaintained, see TrueCraft) Minecraft server, client, and etc for .NET
MIT License
228 stars 65 forks source link

Blocks placed turn grass into dirt. #160

Open MoBaT opened 11 years ago

MoBaT commented 11 years ago

Any block placed such as a rail block will turn the grass into dirt. This is due to the lightreduction being a value of 15 on default for blocks and this code in the grassblock.cs in Craft.Net.Data

public override void OnScheduledUpdate(World world, Vector3 position) { var block = world.GetBlock(position + Vector3.Up); if (block.LightReduction > 2) world.SetBlock(position, new DirtBlock()); else Grow(world, position, false); base.OnScheduledUpdate(world, position); }

Where (block.LightReduction > 2) is always going to be true for classes inheriting the block class.

At the moment I don't understand what's the point of having an integer for the light reduction code for blocks. I can see it being easier to just use a boolean. That's my understanding from looking at the code but you might have something in mind fore the future.

ddevault commented 11 years ago

Water, for example, has a light reduction value somewhere in the middle. I'll look into that, though.

lancepioch commented 11 years ago

In Minecraft each block is inherits a light value. This determines how much light the block "naturally gives off" or reflects. Certain blocks may reduce the light by more than one.