Example #1
0
        public Item GetItem(short id, short metadata = 0, int count = 1)
        {
            Item item = null;

            if (id == 280)
            {
                item = new ItemStick();
            }
            else if (id == 332)
            {
                item = new ItemSnowball();
            }
            else if (id == 333)
            {
                item = new ItemBoat(metadata);
            }
            else if (id == 340)
            {
                item = new ItemBook();
            }
            else if (id == 344)
            {
                item = new ItemEgg();
            }

            else if (id == 401)
            {
                item = new ItemFireworks();
            }

            item.Metadata = metadata;
            item.Count    = (byte)count;

            return(item);
        }
Example #2
0
        private void GameRegistry()
        {
            _blockRegistry  = new BlockRegistry();
            _itemRegistry   = new ItemRegistry();
            _recipeRegistry = new RecipeRegistry();

            for (int i = 1; i < 6; i++)
            {
                //SoundEngine.RegisterSound($"block/grass/walk{i}");
            }

            //register materails
            Material.RegisterMaterial(new Material("air", true));
            Material.RegisterMaterial(new Material("tallgrass", true));
            Material.RegisterMaterial(new Material("grass", false));
            Material.RegisterMaterial(new Material("dirt", false));
            Material.RegisterMaterial(new Material("stone", false));
            Material.RegisterMaterial(new Material("wood", false));

            _blockRegistry.Put(new BlockAir());
            _blockRegistry.Put(new BlockStone());
            _blockRegistry.Put(new BlockGrass());
            _blockRegistry.Put(new BlockDirt());
            _blockRegistry.Put(new BlockCobbleStone());
            _blockRegistry.Put(new BlockPlanks());
            _blockRegistry.Put(new BlockBedrock());
            _blockRegistry.Put(new BlockLog());
            _blockRegistry.Put(new BlockLeaves());
            _blockRegistry.Put(new BlockGlass());
            _blockRegistry.Put(new BlockCraftingTable());
            _blockRegistry.Put(new BlockFurnace());
            //_blockRegistry.Put(new BlockSlab());
            _blockRegistry.Put(new BlockRare());
            _blockRegistry.Put(new BlockLadder());
            _blockRegistry.Put(new BlockTallGrass());
            _blockRegistry.Put(new BlockTulipRed());
            _blockRegistry.Put(new BlockTulipOrange());
            _blockRegistry.Put(new BlockTNT());

            //POST - MOD Blocks and Items
            //foreach (ModMain mod in _installedMods)
            //{
            //mod.OnItemsAndBlocksRegistry(new RegistryEventArgs(_blockRegistry, _itemRegistry, _recipeRegistry));
            //}

            foreach (var block in BlockRegistry.AllBlocks())
            {
                _itemRegistry.Put(new ItemBlock(block));
            }

            Item stick = new ItemStick();

            _itemRegistry.Put(new ItemPickaxe("wood"));
            _itemRegistry.Put(new ItemPickaxe("stone"));
            _itemRegistry.Put(new ItemPickaxe("rare"));
            _itemRegistry.Put(stick);

            var log    = ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockLog>());
            var wood   = ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockPlanks>());
            var cobble = ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockCobbleStone>());
            var rare   = ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockRare>());

            Item[] recipe =
            {
                cobble, cobble, cobble,
                null,   stick,  null,
                null,   stick,  null
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem("sharpcraft", "pick_stone"));

            recipe = new[]
            {
                rare, rare, rare,
                null, stick, null,
                null, stick, null
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem("sharpcraft", "pick_rare"));

            recipe = new[]
            {
                wood, wood, wood,
                null, stick, null,
                null, stick, null
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem("sharpcraft", "pick_wood"));

            recipe = new[]
            {
                cobble, cobble, cobble,
                cobble, null, cobble,
                cobble, cobble, cobble
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockFurnace>()));

            recipe = new[]
            {
                wood, wood, null,
                wood, wood, null,
                null, null, null
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockCraftingTable>()));

            recipe = new[]
            {
                log, null, null,
                null, null, null,
                null, null, null
            };
            _recipeRegistry.RegisterRecipe(recipe, new ItemStack(wood, 4), true);

            recipe = new[]
            {
                wood, null, null,
                wood, null, null,
                null, null, null
            };
            _recipeRegistry.RegisterRecipe(recipe, new ItemStack(stick, 4));

            recipe = new[]
            {
                wood, wood, wood,
                null, wood, null,
                wood, wood, wood
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem("sharpcraft", "ladder"));

            //foreach (ModMain mod in _installedMods)
            //{
            //mod.OnRecipeRegistry(new RecipeRegistryEventArgs(_recipeRegistry));
            //}

            //LangUtil.LoadLang(SettingsManager.GetString("lang"));//TODO - find a proper placement for this line
        }