tModLoader How do I make ore spawn in a specific biome? (And other questions)

Hallam_9K

Empress of Light
Help, how do I make my ore to generate only in the Underground Jungle?
Also, how do I make it shine when I use a spelunker potion?
Also, also, how do I make the ore show up on the mini-map?

Code:
Code:
using System.IO;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.World.Generation;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Generation;

namespace ModOfRandomness
{
    public class ModWord : ModWorld
    {
        private const int saveVersion = 0;
        public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));
            if (ShiniesIndex == -1)
            {
                return;
            }
            tasks.Insert(ShiniesIndex + 1, new PassLegacy("Custom Mod Ores", delegate (GenerationProgress progress)
            {
                progress.Message = "Custom Mod Ores";
                                                                                                                                                                                                                                         //Put your custom tile block name
                for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)                                                                                                                                      //      |
                {                                                                                                                                                                                                                      //       |
                    WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("NoobiteFossilBlock"), false, 0f, 0f, false, true);
                }
            }));
        }

    }
}

Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModOfRandomness.Items.Placeable
{
    public class NoobiteFossil : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Noobite Fossil";
            item.width = 16;
            item.height = 16;
            item.maxStack = 999;
            AddTooltip("The remains of an extinct race.");
            item.useTurn = true;
            item.autoReuse = true;
            item.useAnimation = 15;
            item.useTime = 10;
            item.useStyle = 1;
            item.consumable = true;
            item.createTile = mod.TileType("NoobiteFossilBlock"); //put your CustomBlock Tile name
        }
    }
}

Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace ModOfRandomness.Tiles
{
    public class NoobiteFossilBlock : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileSolid[Type] = true;
            Main.tileMergeDirt[Type] = true;
            drop = mod.ItemType("NoobiteFossil");   //put your CustomBlock name
            minPick = 60;
            mineResist = 3f;
        }
    }
}
 
Okay, first one is what I want to do too. Second one, I think the game makes it glow when it's recognized as treasure and third, you need to have a seperate (block).cs file with a tilesheet that will be the ore block in game, in that .cs file (read below) will be a line called AddMapEntry (and then the rgb values), that will be the color shown on the map of that block


Like this (it's from an ore I made and want to generate):

Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace things.Tiles.Floran
{
    public class FloranOre : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileSolid[Type] = true;
            Main.tileMergeDirt[Type] = true;
            Main.tileLighted[Type] = true;
            Main.tileBlockLight[Type] = true;

            drop = mod.ItemType("FloranOre");
            ModTranslation name = CreateMapEntryName();
            name.SetDefault("Floran Ore");
            AddMapEntry(new Color(81, 178, 105), name);
            minPick = 40;
        }

        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            r = 0.25f;
            g = 0.75f;
            b = 0.3f;
        }
    }
}
 

Attachments

  • FloranOre.png
    FloranOre.png
    9.4 KB · Views: 233
Code:
Tile tile = Framing.GetTileSafely(x, y);
                 if (tile.active() && tile.type == TileID.MudBlock)
                {
                   WorldGen.TileRunner(.....);
                 }
This should work.
Note:This makes the ore generate in mud blocks, not the jungle itself.
But that shouldnt be a problem since about 80% of all the mud is in the jungle.
Tell me if you need help with sth.
Edit:Or look at the example mod file called: Example World
 
Back
Top Bottom