Ejemplo n.º 1
0
        void LoadBlocks()
        {
            List <Block> blocks = new List <Block>();

            foreach (var val in blockTypes)
            {
                if (!val.Value.Enabled)
                {
                    continue;
                }
                GatherBlocks(val.Value.Code, val.Value, blocks);
            }

            foreach (Block block in blocks)
            {
                try
                {
                    api.RegisterBlock(block);
                }
                catch (Exception e)
                {
                    api.Server.LogError("Failed registering block {0}: {1}", block.Code, e);
                }
            }
        }
Ejemplo n.º 2
0
        public override void StartServerSide(ICoreServerAPI manager)
        {
            api = manager;

            noSound = new BlockSounds();

            #region Block types

            api.RegisterBlock(new Block()
            {
                Code     = new AssetLocation("mantle"),
                Textures = new Dictionary <string, CompositeTexture> {
                    { "all", new CompositeTexture(new AssetLocation("block/mantle")) },
                },
                DrawType              = EnumDrawType.Cube,
                MatterState           = EnumMatterState.Solid,
                BlockMaterial         = EnumBlockMaterial.Stone,
                Replaceable           = 0,
                Resistance            = 31337,
                Sounds                = noSound,
                CreativeInventoryTabs = new string[] { "general" }
            });

            #endregion
        }
Ejemplo n.º 3
0
        void LoadBlocks(List <RegistryObjectType>[] variantLists)
        {
            // Step2: create all the blocks from the blocktypes, and register them: this has to be on the main thread as the registry is not thread-safe
            LoadFromVariants(variantLists, "block", (variants) =>
            {
                foreach (BlockType type in variants)
                {
                    Block block = type.CreateBlock(api);

                    try
                    {
                        api.RegisterBlock(block);
                    }
                    catch (Exception e)
                    {
                        api.Server.LogError("Failed registering block {0}: {1}", block.Code, e);
                    }
                }
            });
        }
Ejemplo n.º 4
0
        public override void StartServerSide(ICoreServerAPI manager)
        {
            api = manager;

            noSound = new BlockSounds();

            #region Block types
            Block block = new Block()
            {
                Code     = new AssetLocation("mantle"),
                Textures = new Dictionary <string, CompositeTexture> {
                    { "all", new CompositeTexture(new AssetLocation("block/mantle")) },
                },
                DrawType           = EnumDrawType.Cube,
                MatterState        = EnumMatterState.Solid,
                BlockMaterial      = EnumBlockMaterial.Stone,
                Replaceable        = 0,
                Resistance         = 31337,
                RequiredMiningTier = 196,
                Sounds             = new BlockSounds()
                {
                    Walk   = new AssetLocation("sounds/walk/stone"),
                    ByTool = new Dictionary <EnumTool, BlockSounds>()
                    {
                        { EnumTool.Pickaxe, new BlockSounds()
                          {
                              Hit = new AssetLocation("sounds/block/rock-hit-pickaxe"), Break = new AssetLocation("sounds/block/rock-hit-pickaxe")
                          } }
                    }
                },
                CreativeInventoryTabs = new string[] { "general" }
            };

            api.RegisterBlock(block);

            #endregion
        }