tModLoader Help with biome specific loot drops [Solved]

Gaminator

Terrarian
So, I want to add some materials that drop when any hostile npc is killed in specific biomes, but none of the Zone options return true.
I went over all of them while killing a slime in a normal forest biome, but none of them worked.

(Yes it's for a Naruto mod)
Code:
        public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot)
        {
            if (!npc.friendly)
            {
                // LeafScroll Drops
                if (Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].ZoneForest)
                {
                    npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<LeafScroll>(), 2, 1, 3));
                }

                // SandScroll Drops
                if (Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].ZoneDesert)
                {
                    npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<SandScroll>(), 2, 1, 3));
                }

                // CloudScroll Drops
                if (Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].ZoneSkyHeight)
                {
                    npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<CloudScroll>(), 2, 1, 3));
                }

                // MistScroll Drops
                if (Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].ZoneBeach)
                {
                    npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<MistScroll>(), 2, 1, 3));
                }

                // RockScroll Drops
                if (Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].ZoneRockLayerHeight)
                {
                    npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<RockScroll>(), 2, 1, 3));
                }
            }
        }
 
Last edited:
Okay, that helps, but I only see an example with a moded biome.

Code:
	return info.player.InModBiome<ExampleUndergroundBiome>();

I need to check for vanilla biomes.

Edit:

Code:
	return info.player.InZonePurity();

This works but only for Purity and Forest biomes and there are no other functions like this that i can see

Edit 2:
Code:
    internal class ForestDropRule : IItemDropRuleCondition
    {
        public bool CanDrop(DropAttemptInfo info)
        {
            if (!info.IsInSimulation)
            {
                NPC npc = info.npc;
                if (!npc.friendly)
                {
                    return info.player.ZoneForest;
                }
            }
            return false;
        }

        public bool CanShowItemDropInUI()
        {
            return true;
        }

        public string GetConditionDescription()
        {
            return "Drops in forest biomes";
        }
    }

So, it seems like Zones now only work inside IItemDropRuleCondition classes, thank you for the help.
 
Last edited:
Back
Top Bottom