tModLoader How to fix code that adds modded loot to boss bags?

TheGrandScale

Terrarian
Hello
Can someone explain why this code ONLY works for Queen Bee? It's not giving an error, but the item won't drop from Plantera boss bags.
It's probably something obvious i'm missing

...
C#:
    public class BossBagLoot : GlobalItem

    {

        public override void ModifyItemLoot(Item item, ItemLoot itemLoot) {

            if(item.type == ItemID.PlanteraBossBag) {  //Not working

                foreach (var rule in itemLoot.Get()) {

                    if (rule is OneFromOptionsNotScaledWithLuckDropRule oneFromOptionsDrop && oneFromOptionsDrop.dropIds.Contains(ItemID.Seedler)) {

                        var original = oneFromOptionsDrop.dropIds.ToList();

                        original.Add(ModContent.ItemType<Content.Items.Material.ModItemA>());

                        oneFromOptionsDrop.dropIds = original.ToArray();

                    }

                }

            }

            if(item.type == ItemID.QueenBeeBossBag) { //Is working

                foreach (var rule in itemLoot.Get()) {

                    if (rule is OneFromOptionsNotScaledWithLuckDropRule oneFromOptionsDrop && oneFromOptionsDrop.dropIds.Contains(ItemID.BeeGun)) {

                        var original = oneFromOptionsDrop.dropIds.ToList();

                        original.Add(ModContent.ItemType<Content.Items.Material.ModItemB>());

                        oneFromOptionsDrop.dropIds = original.ToArray();

                    }

                }

            }

        }

    }

}
 
Last edited:
Is the actual loot rule for the Seedler from Plantera the oneFromOptionsDrop? Or is it just a common loot drop? You have to specify the right one.
 
Is the actual loot rule for the Seedler from Plantera the oneFromOptionsDrop? Or is it just a common loot drop? You have to specify the right one.
I've tried specifying that it's a common loot drop but it still doesn't work, i'm not sure exactly how to write it
 
You have to look through the vanilla source and see what the actual loot drop condition is to replace it
 
You have to look through the vanilla source and see what the actual loot drop condition is to replace it
I tried looking through the source and it says that it's a common loot drop, but I don't know how to write that into the code. Nothing I try works
 
C#:
// Terraria.GameContent.ItemDropRules.ItemDropDatabase::RegisterBossBags()
// ...

item = ItemID.PlanteraBossBag;
RegisterToItem(item, ItemDropRule.Common(ItemID.SporeSac));
RegisterToItem(item, ItemDropRule.NotScalingWithLuck(ItemID.PlanteraMask, 7));
RegisterToItem(item, ItemDropRule.Common(ItemID.TempleKey));
RegisterToItem(item, ItemDropRule.NotScalingWithLuck(ItemID.Seedling, 15));
RegisterToItem(item, ItemDropRule.NotScalingWithLuck(ItemID.TheAxe, 20));
RegisterToItem(item, ItemDropRule.NotScalingWithLuck(ItemID.PygmyStaff, 2));
RegisterToItem(item, ItemDropRule.NotScalingWithLuck(ItemID.ThornHook, 10));
IItemDropRule itemDropRuleGrenadeLauncher = ItemDropRule.Common(ItemID.GrenadeLauncher);
itemDropRuleGrenadeLauncher.OnSuccess(ItemDropRule.Common(ItemID.RocketI, 1, 50, 149), hideLootReport: true);
RegisterToItem(item, new OneFromRulesRule(1, itemDropRuleGrenadeLauncher, ItemDropRule.Common(ItemID.VenusMagnum), 
        ItemDropRule.Common(ItemID.NettleBurst), ItemDropRule.Common(ItemID.LeafBlower), ItemDropRule.Common(ItemID.FlowerPow),
        ItemDropRule.Common(ItemID.WaspGun), ItemDropRule.Common(ItemID.Seedler))); // !
RegisterToItem(item, ItemDropRule.CoinsBasedOnNPCValue(NPCID.Plantera));

// ...

The rule that contains the Seedler's drop rule is a OneFromRulesRule. You're checking for a OneFromOptionsNotScaledWithLuckDropRule, which isn't the same.

Once you check for the right rule, you should be able to use about the same code as you do for Queen Bee to add to Plantera's drops. You just need to add a new drop rule to the array instead of an item ID.
 
Back
Top Bottom