tModLoader Loot table tweaks - What IItemDropRule subtype is used to control/remove the dev items drop rule in HM Boss Bags?

Glasia 森の魔王🌳

The Destroyer
Good evening,

I have a question about tweaking boss bag loot via TML:

What IItemDropRule is used for the Dev items in the hardmode expert boss bags (except QS)?
I try to replace the dev items drops with that blueprints are dropped that are used to craft the dev items,
the blueprint giveout works but however the dev items are not removed out of the loot table:

Item drop tweaks
C#:
using DeveloperItemBlueprintMod.Content.Items;
using System;
using System.Linq;
using Terraria;
using Terraria.GameContent.ItemDropRules;
using Terraria.ID;
using Terraria.ModLoader;

namespace DeveloperItemBlueprintMod.Common.CommonItems
{
    public class BossBagLoot : GlobalItem
    {

        static int[] bossBagsWithDeveloperItems = new int[] {
            ItemID.DestroyerBossBag, ItemID.TwinsBossBag, ItemID.SkeletronPrimeBossBag,
            ItemID.PlanteraBossBag, ItemID.GolemBossBag,
            ItemID.MoonLordBossBag, ItemID.BossBagBetsy,
            ItemID.FairyQueenBossBag, ItemID.FishronBossBag
        };
        public override void ModifyItemLoot(Item item, ItemLoot itemLoot)
        {

            if (bossBagsWithDeveloperItems.Contains(item.type))
            {
                foreach (var rule in itemLoot.Get())
                {
                    /* Here it is supposed that the replacement happens: The dev item rule is removed, then replaced by the item drop*/
                    if (rule is OneFromOptionsDropRule oneFromOptionsDrop oneFromOptionsDrop.dropIds.Contains(ItemID.RedsHelmet))
                    {
                        itemLoot.Remove(rule);
                    }
                }
                /*Chance is 100% for test/debug purposes*/
                itemLoot.Add(new CommonDrop(ModContent.ItemType<DeveloperBlueprint>(), 1, 8, 13, 1));

            }
        }
    }
}

Here the code of the blueprint item itself
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace DeveloperItemBlueprintMod.Content.Items
{
    public class DeveloperBlueprint : ModItem
    {
        public override void SetStaticDefaults()
        {
             Item.ResearchUnlockCount = 100;

        }

        public override void SetDefaults()
        {
            Item.width = 24;
            Item.height = 24;
            Item.rare = ItemRarityID.Cyan;
            Item.maxStack = Item.CommonMaxStack;
            Item.value = Item.buyPrice(silver: 25);
        }

        
    }
}

If you need more info, do not hesitate to let me know.

I thank you for your answer.

Glasia🌳
 
Check this out, you can simply disable the dev set drops and then add your own drops in.

Minion Boss Bag
 
I thank you for your answer, and the changed code worked:

C#:
using DeveloperItemBlueprintMod.Content.Items;
using System;
using System.Linq;
using Terraria;
using Terraria.GameContent.ItemDropRules;
using Terraria.ID;
using Terraria.ModLoader;

namespace DeveloperItemBlueprintMod.Common.CommonItems
{
    public class BossBagLoot : GlobalItem
    {

        static int[] bossBagsWithDeveloperItems = new int[] {
            ItemID.DestroyerBossBag, ItemID.TwinsBossBag, ItemID.SkeletronPrimeBossBag,
            ItemID.PlanteraBossBag, ItemID.GolemBossBag,
            ItemID.MoonLordBossBag, ItemID.BossBagBetsy,
            ItemID.FairyQueenBossBag, ItemID.FishronBossBag
        };
        public override void ModifyItemLoot(Item item, ItemLoot itemLoot)
        {

            if (bossBagsWithDeveloperItems.Contains(item.type))
            {
                ItemID.Sets.PreHardmodeLikeBossBag[item.type] = true;
                itemLoot.Add(new CommonDrop(ModContent.ItemType<DeveloperBlueprint>(),
                    (Main.tenthAnniversaryWorld ? 8 : 16), 8, 13, 1));
                
            }
        }
    }
}

I enter that incase in the future people have a similar problem and are googling the problem.
 
Back
Top Bottom