Jump to content

Modding question.


Vies

Recommended Posts

I am trying to follow the guide (seems like multiple ways to set up a mod) and things seem like they are not loading.

I can see my mod in the list, (only the name and description from my modinfo file) but my test item isn't showing up in the world. I even tried to put a write line statement in but it never goes off. Any help is appreciated. I have my .cs files set up below (tried to make the test pickaxe from the wiki):


Main.cs

Spoiler

namespace ViesCraft.src
{
    public class Main : ModSystem
    {
        public override void Start(ICoreAPI api)
        {
            System.Diagnostics.Debug.WriteLine("GOT TO HERE");
            base.Start(api);
            api.RegisterItemClass("testitem", typeof(TestItem));
        }
    }
}

 

TestItem.cs

Spoiler

namespace ViesCraft
{
    internal class TestItem : Item
    {
        public void destroyBlocks(IWorldAccessor world, BlockPos min, BlockPos max, IPlayer player)
        {
            BlockPos tempPos = new BlockPos();
            for (int x = min.X; x <= max.X; x++)
            {
                for (int y = min.Y; y <= max.Y; y++)
                {
                    for (int z = min.Z; z <= max.Z; z++)
                    {
                        tempPos.Set(x, y, z);
                        if (player.WorldData.CurrentGameMode == EnumGameMode.Creative)
                            world.BlockAccessor.SetBlock(0, tempPos);
                        else
                            world.BlockAccessor.BreakBlock(tempPos, player);
                    }
                }
            }
        }

        public override bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel)
        {
            if (base.OnBlockBrokenWith(world, byEntity, itemslot, blockSel))
            {
                if (byEntity is EntityPlayer)
                {
                    IPlayer player = world.PlayerByUid((byEntity as EntityPlayer).PlayerUID);
                    switch (blockSel.Face.Axis)
                    {
                        case EnumAxis.X:
                            destroyBlocks(world, blockSel.Position.AddCopy(0, -1, -1), blockSel.Position.AddCopy(0, 1, 1), player);
                            break;
                        case EnumAxis.Y:
                            destroyBlocks(world, blockSel.Position.AddCopy(-1, 0, -1), blockSel.Position.AddCopy(1, 0, 1), player);
                            break;
                        case EnumAxis.Z:
                            destroyBlocks(world, blockSel.Position.AddCopy(-1, -1, 0), blockSel.Position.AddCopy(1, 1, 0), player);
                            break;
                    }
                }
                return true;
            }
            return false;
        }
    }
}

 

Edit: just to add, there are no compiler errors in either file. I can supply the assets -> itemtype/lang/texture info if needed.

Edited by Vies
Link to comment
Share on other sites

Alright, I think I figured it out. In my csproj, I had to add the following:
 

Spoiler

<Target Name="Copy" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Debug'">
        <Copy SourceFiles="$(TargetPath)" DestinationFolder="$(VINTAGE_STORY_DATA)/Mods" />
        <Copy SourceFiles="$(TargetDir)/$(TargetName).pdb" DestinationFolder="$(VINTAGE_STORY_DATA)/Mods" />
    </Target>

 

I am new to how visual Studio works and did some digging. I don't remember seeing having to have this in any of the modding stuff in the wiki. it should be added to help ease others coming for the Minecraft/forge world. Thanks!

  • Cookie time 1
Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.