Exemplo n.º 1
0
        public void OpenDialog(IClientWorldAccessor world, BlockPos pos, ItemStack baseMaterial)
        {
            List <ItemStack> stacks = world.KnappingRecipes
                                      .Where(r => r.Ingredient.SatisfiesAsIngredient(baseMaterial))
                                      .OrderBy(r => r.Output.ResolvedItemstack.GetName())
                                      .Select(r => r.Output.ResolvedItemstack)
                                      .ToList()
            ;

            GuiDialog dlg = new GuiDialogBlockEntityRecipeSelector("Select recipe", stacks.ToArray(), pos, api as ICoreClientAPI);

            dlg.TryOpen();
        }
Exemplo n.º 2
0
        public void OpenDialog(IClientWorldAccessor world, BlockPos pos, ItemStack ingredient)
        {
            if (ingredient.Collectible is ItemWorkItem)
            {
                ingredient = new ItemStack(world.GetItem(new AssetLocation("clay-" + ingredient.Collectible.LastCodePart())));
            }

            List <ItemStack> stacks = world.ClayFormingRecipes
                                      .Where(r => r.Ingredient.SatisfiesAsIngredient(ingredient))
                                      .OrderBy(r => r.Output.ResolvedItemstack.GetName())
                                      .Select(r => r.Output.ResolvedItemstack)
                                      .ToList()
            ;

            GuiDialog dlg = new GuiDialogBlockEntityRecipeSelector("Select recipe", stacks.ToArray(), pos, api as ICoreClientAPI);

            dlg.TryOpen();
        }
Exemplo n.º 3
0
        internal void OpenDialog(ItemStack ingredient)
        {
            if (ingredient.Collectible is ItemWorkItem)
            {
                ingredient = new ItemStack(api.World.GetItem(new AssetLocation("ingot-" + ingredient.Collectible.LastCodePart())));
            }

            List <ItemStack> stacks = api.World.SmithingRecipes
                                      .Where(r => r.Ingredient.SatisfiesAsIngredient(ingredient))
                                      .OrderBy(r => r.Output.ResolvedItemstack.GetName())
                                      .Select(r => r.Output.ResolvedItemstack)
                                      .ToList()
            ;

            IClientWorldAccessor clientWorld = (IClientWorldAccessor)api.World;

            GuiDialog dlg = new GuiDialogBlockEntityRecipeSelector("Select smithing recipe", stacks.ToArray(), pos, api as ICoreClientAPI);

            dlg.TryOpen();
        }
Exemplo n.º 4
0
        public void OpenDialog(IClientWorldAccessor world, BlockPos pos, ItemStack ingredient)
        {
            if (ingredient.Collectible is ItemWorkItem)
            {
                ingredient = new ItemStack(world.GetItem(new AssetLocation("clay-" + ingredient.Collectible.LastCodePart())));
            }

            List <ClayFormingRecipe> recipes = world.ClayFormingRecipes
                                               .Where(r => r.Ingredient.SatisfiesAsIngredient(ingredient))
                                               .OrderBy(r => r.Output.ResolvedItemstack.Collectible.Code) // Cannot sort by name, thats language dependent!
                                               .ToList();

            ;


            List <ItemStack> stacks = recipes
                                      .Select(r => r.Output.ResolvedItemstack)
                                      .ToList()
            ;

            ICoreClientAPI capi = api as ICoreClientAPI;

            GuiDialog dlg = new GuiDialogBlockEntityRecipeSelector(
                Lang.Get("Select recipe"),
                stacks.ToArray(),
                (selectedIndex) => {
                capi.Logger.VerboseDebug("Select clay from recipe {0}, have {1} recipes.", selectedIndex, recipes.Count);

                selectedRecipeId = recipes[selectedIndex].RecipeId;
                capi.Network.SendBlockEntityPacket(pos.X, pos.Y, pos.Z, (int)EnumClayFormingPacket.SelectRecipe, SerializerUtil.Serialize(recipes[selectedIndex].RecipeId));
            },
                () => {
                capi.Network.SendBlockEntityPacket(pos.X, pos.Y, pos.Z, (int)EnumClayFormingPacket.CancelSelect);
            },
                pos,
                api as ICoreClientAPI
                );

            dlg.TryOpen();
        }
Exemplo n.º 5
0
        internal void OpenDialog(ItemStack ingredient)
        {
            if (ingredient.Collectible is ItemWorkItem)
            {
                ingredient = new ItemStack(api.World.GetItem(new AssetLocation("ingot-" + ingredient.Collectible.LastCodePart())));
            }

            List <SmithingRecipe> recipes = api.World.SmithingRecipes
                                            .Where(r => r.Ingredient.SatisfiesAsIngredient(ingredient))
                                            .OrderBy(r => r.Output.ResolvedItemstack.Collectible.Code) // Cannot sort by name, thats language dependent!
                                            .ToList()
            ;

            List <ItemStack> stacks = recipes
                                      .Select(r => r.Output.ResolvedItemstack)
                                      .ToList()
            ;

            IClientWorldAccessor clientWorld = (IClientWorldAccessor)api.World;
            ICoreClientAPI       capi        = api as ICoreClientAPI;

            GuiDialog dlg = new GuiDialogBlockEntityRecipeSelector(
                Lang.Get("Select smithing recipe"),
                stacks.ToArray(),
                (selectedIndex) => {
                selectedRecipeId = recipes[selectedIndex].RecipeId;
                capi.Network.SendBlockEntityPacket(pos.X, pos.Y, pos.Z, (int)EnumClayFormingPacket.SelectRecipe, SerializerUtil.Serialize(recipes[selectedIndex].RecipeId));
            },
                () => {
                capi.Network.SendBlockEntityPacket(pos.X, pos.Y, pos.Z, (int)EnumClayFormingPacket.CancelSelect);
            },
                pos,
                api as ICoreClientAPI
                );

            dlg.TryOpen();
        }