I Probelm With C# (MinePackage Used)

Hello, I am making a Minecraft-Clone game caled BuildWorld, and the game uses MinePackage. I have some code from the wiki for a building function, and here it is.

public class MyCoolNewDecoration : IDecoration
{
private readonly WorldData m_WorldData;

public MyCoolNewDecoration(WorldData worldData)
{
m_WorldData = worldData;
}

public bool Decorate(int blockX, int blockY, int blockZ, Random random)
{
if (IsAValidLocationforDecoration(blockX, blockY, blockZ, random))
{
CreateDecorationAt(blockX, blockY, blockZ, random);
return true;
}

return false;
}

private void CreateDecorationAt(int blockX, int blockY, int blockZ, Random random)
{
m_WorldData.SetBlockType(blockX, blockY, blockZ, BlockType.Stone);
}

private bool IsAValidLocationforDecoration(int blockX, int blockY, int blockZ, Random random)
{
if (random.RandomRange(1, 100) < 90)
{
return false;
}

return m_WorldData.GetBlock(blockX, blockY, blockZ).Type == BlockType.Air;
}
}

The thing keeps saying The type or namespace “IDecorator” could not be found.
Here is the code for IDecoration

using System;

public interface IDecoration
{
void Decorate(int blockX, int blockY, int blockZ, Random random);}

I know it is not a namespace probelm, but can anyone help? :slight_smile:

Hi! First, when you post code, click on “Go Advanced”, highlight your code, and press the # button. It wraps it in code tags, is much easier for others to read, and you are more likely to get assistance.

public class MyCoolNewDecoration : IDecoration
{
    private readonly WorldData m_WorldData;

    public MyCoolNewDecoration(WorldData worldData)
    {
        m_WorldData = worldData;
    }

    public bool Decorate(int blockX, int blockY, int blockZ, Random random)
    {
        if (IsAValidLocationforDecoration(blockX, blockY, blockZ, random))
        {
            CreateDecorationAt(blockX, blockY, blockZ, random);
            return true;
        }

        return false;
    }

    private void CreateDecorationAt(int blockX, int blockY, int blockZ, Random random)
    {
        m_WorldData.SetBlockType(blockX, blockY, blockZ, BlockType.Stone);
    }

    private bool IsAValidLocationforDecoration(int blockX, int blockY, int blockZ, Random random)
    {
        if (random.RandomRange(1, 100) < 90)
        {
            return false;
        }

        return m_WorldData.GetBlock(blockX, blockY, blockZ).Type == BlockType.Air;
    }

}

using System;

public interface IDecoration
{
    void Decorate(int blockX, int blockY, int blockZ, Random random);
}

Ok, so the code in the wiki is more of a guideline. But…I don’t see why it’s not seeing the IDecoration interface.

You new decoration class that implements the IDecoration interface…can you post the entire class? Also, can you show part of a screenshot that shows your new class and the interface in the project view? I’m trying to get an idea of how your files are laid out. I don’t need to see the entire project, just where the files are and such.

What are you using for an IDE? If you are using Visual Studio (not express), I would highly recommend you purchase a R# (Resharper) license. It is magic at identifying and fixing many issues.

Both files are in the same folder. I am using Visual Studio, but I do not have the money to purchase such a license. The decorator file would usaully go in the scripts\WorldDecorations folder, I did not put it there because of the bug that made game unplayable.

1036136--38429--$Help.png

So, is anyone going to help?

I was planning on looking at it this weekend, but got sidetracked. I’ll try to remember to check it out tonight.
My first thought is that it -must- be a namespace issue, but I’ll need to load up the project to know for sure.

I had another developer on the BuildWorld team check it out, and to see what the issue was, he at first claimed it was a namepsace issue until I showed him the code for IDecoration, and now hes sure it is not a namespace issue, but something he does not understand, I probably will not pester him anymore, as he is working on improving the graphics.