Jump to content

[SOLVED]Ore not generating and not accepting texture


crystalhero05

Recommended Posts

I have a problem with my ore being generated and it doesn't accept the texture code. First it was only the texture but I thought I will deal with it later. Then when I added water generation (like the clay generation code) it wouldn't generate.

 

Main class:

 

 

package first.mod;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.EnumArmorMaterial;

import net.minecraft.item.EnumToolMaterial;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.world.gen.feature.WorldGenClay;

import net.minecraft.world.gen.feature.WorldGenerator;

import net.minecraftforge.common.EnumHelper;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

import first.mod.armor.RedArmor;

import first.mod.block.BlockRedBlock;

import first.mod.block.RedOre;

import first.mod.creativetabs.CreativeTabsRed;

import first.mod.item.ItemRedThing;

import first.mod.item.ItemRedaxe;

import first.mod.item.ItemRedpick;

import first.mod.item.ItemRedshovel;

import first.mod.item.ItemRedsword;

import first.mod.placeholder.RedPlaceHolder;

import first.mod.worldgeneration.RedOreWorldGeneration;

 

 

@Mod(modid = "FirstMod", name ="FirstMod", version = "0.1")

 

public class Base{

 

//EnumToolMaterial

public static EnumToolMaterial toolRed = EnumHelper.addToolMaterial("RED", 3, 1000, 10.0F, 4.0F, 30);

public static EnumArmorMaterial armorRed = EnumHelper.addArmorMaterial("Red", 66, new int[]{6, 9, 9, 6}, 30);

 

//registration

public static Item Redpick = new ItemRedpick(2000, toolRed).setUnlocalizedName("Redpick");

public static Item Redsword = new ItemRedsword(2001, toolRed).setUnlocalizedName("Redsword");

public static Item Redshovel = new ItemRedshovel(2002, toolRed).setUnlocalizedName("Redshovel");

public static Item Redaxe = new ItemRedaxe(2003, toolRed).setUnlocalizedName("Redaxe");

public static Block RedBlock = new BlockRedBlock(1000, Material.iron).setUnlocalizedName("RedBlock");

public static Item RedThing = new ItemRedThing(2004).setUnlocalizedName("RedThing");

public static Item RedPlaceHolder = new RedPlaceHolder(3000).setUnlocalizedName("RedPlaceHolder");

public static CreativeTabs TabRed = new CreativeTabsRed(CreativeTabs.getNextID(), "Red Mod");

public static Item RedHelmet = new RedArmor(2005, armorRed, 0, 0, "red").setUnlocalizedName("Red Helmet");

public static Item RedChestplate = new RedArmor(2006, armorRed, 0 ,1, "red").setUnlocalizedName("Red Chestplate");

public static Item RedLeggings = new RedArmor(2007, armorRed, 0, 2, "red").setUnlocalizedName("Red Leggings");

public static Item RedBoots = new RedArmor(2008, armorRed, 0 ,3, "red").setUnlocalizedName("Red Boots");

public static Block RedOre = new RedOre(2009, Material.rock).setUnlocalizedName("RedOre");

 

 

//World Generation

public WorldGenerator redOreGen = new RedOreWorldGeneration(2);

 

public Base()  {

 

GameRegistry.registerBlock(RedBlock, "Red Block");

GameRegistry.registerBlock(RedOre, "Red Ore");

 

 

LanguageRegistry.addName(Redpick, "Red Pickaxe");

LanguageRegistry.addName(Redsword, "Red Sword");

LanguageRegistry.addName(Redshovel, "Red Shovel");

LanguageRegistry.addName(Redaxe, "Red Axe");

LanguageRegistry.addName(RedBlock, "Red Block");

LanguageRegistry.addName(RedThing, "Red Thing");

LanguageRegistry.addName(RedPlaceHolder, "Red Mod");

LanguageRegistry.addName(RedHelmet, "Red Helmet");

LanguageRegistry.addName(RedChestplate, "Red Chest");

LanguageRegistry.addName(RedLeggings, "Red Legs");

LanguageRegistry.addName(RedBoots, "Red Boots");

LanguageRegistry.addName(RedOre, "Red Ore");

 

GameRegistry.addRecipe(new ItemStack(Redpick, 1), new Object[]{

"XXX", " Y ", " Y ", 'X', Item.redstone, 'Y', Item.stick

});

 

GameRegistry.addRecipe(new ItemStack(Redsword, 1), new Object[]{

" X ", " X ", " Y ", 'X', Item.redstone, 'Y', Item.stick

});

 

GameRegistry.addRecipe(new ItemStack(Redshovel, 1), new Object[]{

" X ", " Y ", " Y ", 'X', Item.redstone, 'Y', Item.stick

});

 

GameRegistry.addRecipe(new ItemStack(Redaxe, 1), new Object[]{

"XX ", "XY ", " Y ", 'X', Item.redstone, 'Y', Item.stick

});

 

GameRegistry.addRecipe(new ItemStack(RedBlock, 10), new Object [] {

"XXX" , "XXX" , "XXX", 'X', RedThing

});

 

GameRegistry.addRecipe(new ItemStack(RedThing, 5), new Object[]{

"XX ", "XX ", "  ", 'X', Item.redstone

});

 

 

GameRegistry.addRecipe(new ItemStack(RedChestplate, 1), new Object [] {

"XXX" , "X X" , 'X', RedThing

});

 

GameRegistry.addRecipe(new ItemStack(RedLeggings, 1), new Object [] {

"XXX" , "X X" , "X X", 'X', RedThing

});

GameRegistry.addRecipe(new ItemStack(RedBoots, 1), new Object [] {

"X X" , "X X", 'X', RedThing

});

GameRegistry.addRecipe(new ItemStack(RedChestplate, 1), new Object [] {

"X X" , "XXX" , "XXX", 'X', RedThing

});

 

 

}

 

 

 

}

 

 

 

Ore class

 

 

package first.mod.block;

 

import java.util.Random;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.item.Item;

import first.mod.Base;

 

public class RedOre extends Block{

 

public RedOre(int par1, Material par2Material) {

super(par1, par2Material);

this.setCreativeTab(Base.TabRed);

this.setHardness(10);

this.setResistance(5);

}

 

public void RegisterIcons(IconRegister iconRegister){

blockIcon = iconRegister.registerIcon("FirstMod:RedOre");

}

 

    public int idDropped(int par1, Random par2Random, int par3)

    {

        return Base.RedThing.itemID;

    }

}

 

 

 

 

Ore generation class

 

 

package first.mod.worldgeneration;

 

import java.util.Random;

 

import first.mod.Base;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.world.World;

import net.minecraft.world.gen.feature.WorldGenerator;

 

public class RedOreWorldGeneration extends WorldGenerator{

 

private int numberOfBlocks;

 

private int RedOreId;

 

  public RedOreWorldGeneration(int i) {

  this.RedOreId = Base.RedOre.blockID;

  this.numberOfBlocks = i;

}

 

 

 

public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)

    {

        if (par1World.getBlockMaterial(par3, par4, par5) != Material.water)

        {

            return false;

        }

        else

        {

        System.out.println("Spawned");

            int l = par2Random.nextInt(this.numberOfBlocks - 2) + 2;

            byte b0 = 1;

 

            for (int i1 = par3 - l; i1 <= par3 + l; ++i1)

            {

                for (int j1 = par5 - l; j1 <= par5 + l; ++j1)

                {

                    int k1 = i1 - par3;

                    int l1 = j1 - par5;

 

                    if (k1 * k1 + l1 * l1 <= l * l)

                    {

                        for (int i2 = par4 - b0; i2 <= par4 + b0; ++i2)

                        {

                            int j2 = par1World.getBlockId(i1, i2, j1);

 

                            if (j2 == Block.dirt.blockID || j2 == Base.RedOre.blockID)

                            {

                                par1World.setBlock(i1, i2, j1, this.RedBlockId, 0, 2);

                            }

                        }

                    }

                }

            }

 

            return true;

        }

    }

 

}

 

 

 

Link to comment
Share on other sites

To fix the texture bug, instead of RegisterIcons (), add this.setTextureName("FirstMod:RedOre") under this.setResistance

The more advanced way of doing that is adding this method to your block class. It allows more control for all the sides and stuff, just for later purpose.

package first.mod.block;

// imports

public class RedOre extends Block{

   public RedOre(int par1, Material par2Material) {
      super(par1, par2Material);
      this.setCreativeTab(Base.TabRed);
      this.setHardness(10);
      this.setResistance(5);
   }
   
  @SideOnly( Side.CLIENT )
   public void RegisterIcons(IconRegister iconRegister){
      blockIcon = iconRegister.registerIcon("FirstMod:RedOre");
   }
   
   @SideOnly( Side.CLIENT )
   public Icont getIcon(int side, int meta ) {
       return this.blockIcon;
   }
   
    public int idDropped(int par1, Random par2Random, int par3)
    {
        return Base.RedThing.itemID;
    }
}

this.setTextureName does this automatically, but I still wanted to point that out.

 

And for the not generating part.. just check this really nice tutorial for that, I mean you need IWorldGenerator and you need to register it with GameRegistry.registerWorldGenerator( x.class ); in your FMLInitializationEvent.

 

Anyway, just check this tutorial out for that.

I am fairly new to Java and modding, so my answers are not always 100% correct. Sorry for that!

Link to comment
Share on other sites

OK so it is spawning and accepting texture now only 1 more thing. I set up this code so it would generate in the ocean but I didn't found it anywhere. It didn't generate. Why?

System.out.println is only for validating it spawned it prints it but I can't find it.

private void generateSurface(World world, Random rand, int chunkX, int chunkZ) {
        if (world.getBiomeGenForCoords(chunkX, chunkZ) == BiomeGenBase.ocean){
        for(int k = 0; k < 10; k++){
        	int firstBlockXCoord = chunkX + rand.nextInt(16);
        	int firstBlockYCoord = rand.nextInt(32);
        	int firstBlockZCoord = chunkZ + rand.nextInt(16);
        	
        	(new WorldGenMinable(Base.RedOre.blockID, 15)).generate(world, rand, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
        	System.out.println("spawned");
        }
	}
	}

Link to comment
Share on other sites

Would this workout?

private void generateSurface(World world, Random rand, int chunkX, int chunkZ) {
		int firstBlockXCoord = chunkX + rand.nextInt(16);
        	int firstBlockYCoord = rand.nextInt(32);
        	int firstBlockZCoord = chunkZ + rand.nextInt(16);
        	
		if (world.getBiomeGenForCoords(firstBlockXCoord, firstBlockZCoord) == BiomeGenBase.ocean){
        for(int k = 0; k < 10; k++){
        	 firstBlockXCoord = chunkX + rand.nextInt(16);
        	 firstBlockYCoord = rand.nextInt(32);
        	 firstBlockZCoord = chunkZ + rand.nextInt(16);
        	
        	(new WorldGenMinable(Base.RedOre.blockID, 15)).generate(world, rand, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
        	System.out.println("spawned");
        }
	}
	}

 

The ocean is huge so I don't know how much time would it take to find it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • As the title say, game suddenly crushed during the loading. I got this error message The game crashed whilst rendering overlay Error: java.lang.RuntimeException: null   And Here's the link of crash log bit.ly/3IcVUQG
    • Do these mods have incompatibles: Dynamic View[Forge] (by someaddon) Server Performance - Smooth Chunk Save[Forge/Fabric] (by someaddon) EdivadLib (by 3divad99) Krypton Reforged (by Anthxny) AttributeFix (by DarkhaxDev) Create Stuff & Additions (by Furti_Two) Cristel Lib (by Cristelknight) Resourceful Config (by ThatGravyBoat) Applied Cooking (by ItsSebastrn) Thermal Cultivation (by TeamCoFH) SuperMartijn642's Config Lib (by SuperMartijn642) Create: Bells & Whistles (by sudolev) Thermal Integration (by TeamCoFH) SebastrnLib (by ItsSebastrn) Farmer's Delight (by vectorwing) Right Click, Get Crops (by TeamCoFH) Observable (by tasgon) FPS optimizer (by The_TCT) Dungeons and Taverns (by Nova_Wostra) Explorify – Dungeons & Structures (by bebebea_loste) Fast Leaf Decay (by olafskiii) Create: Vintage Improvements (by Negodya1) Sophisticated Backpacks (by P3pp3rF1y) SuperMartijn642's Core Lib (by SuperMartijn642) Create Crafts & Additions (by MRHminer) Structory (by botanydev) Oculus (by Asek3) Tectonic (by Apollo) Embeddium (Rubidium) Extra (by dimadencep) Athena (by CodexAdrian) Jade 🔍 (by Snownee) Mekanism Tools (by bradyaidanc) Carry On (by Tschipp) Create: Sweets & Treats (by AstralButOnCurseForge) Extreme Reactors Create Compat (by ZeroNoRyouki) AI Improvements (by QueenOfMissiles) AE2 QoL Recipes (by Christofmeg) Create: ComputerCraft (CC: Tweaked) (by EndRage) Create Enchantment Industry (by DragonsPlus) Macaw's Fences and Walls (by sketch_macaw) Better Villages - Forge (by jtl_elisa) Puzzles Lib [Forge & Fabric] (by Fuzs) Mekanism (by bradyaidanc) Create Recycle Everything (by nocubeyt) Searchables (by Jaredlll08) Immersive Paintings [Fabric/Forge] (by Conczin) Create Deco (by talrey) Thermal Foundation (by TeamCoFH) Controlling (by Jaredlll08) Kotlin for Forge (by thedarkcolour) Lithostitched (by Apollo) Let Me Despawn (by frikinjay) MCEF (Minecraft Chromium Embedded Framework) (by ds58) FPS Boost (by The_TCT) Ad Astra (by AlexNijjar) TerraBlender (Forge) (by TheAdubbz) Falling Leaves (Forge) (by Cheaterpaul) CC:C Bridge (by Sammy_echt) Xaero's Minimap (by xaero96) CoFH Core (by TeamCoFH) Create: Applied Kinetics (by Forsteri123) AE Additions - ExtraCells2 Fork (by MasterYodAT9G) Just Enough Items (JEI) (by mezz) Biomes O' Plenty (by Forstride) Curios API (Forge/NeoForge) (by TheIllusiveC4) AE2 Network Analyser (by GlodBlock) Resourceful Lib (by ThatGravyBoat) ChoiceTheorem's Overhauled Village (by ChoiceTheorem) Clockwork: Create x Valkyrien Skies (by triode_) Architectury API (Fabric/Forge/NeoForge) (by shedaniel) Canary (by AbdElAziz333) Structure Essentials[Forge/Fabric] (by someaddon) Library Ferret - Forge (by jtl_elisa) Create Confectionery (by Furti_Two) Leaky - Farm leak detection[Forge/Fabric] (by someaddon) Game Menu Mod Option [Forge] (by morimori0317) Macaw's Bridges (by sketch_macaw) FramedBlocks (by XFactHD) Cherished Worlds (Fabric/Forge/NeoForge/Quilt) (by TheIllusiveC4) Entangled (by SuperMartijn642) Refined Storage: Requestify (by Buuz135) ME Requester (by Relentless) Inventory Sorter (by cpw) Xaero's World Map (by xaero96) William Wythers' Expanded Ecosphere (by Cristelknight) Cloth Config API (Fabric/Forge/NeoForge) (by shedaniel) FTB Library (Forge) (by FTB) Cupboard (by someaddon) Thermal Dynamics (by TeamCoFH) Patchouli (by Vazkii) Entity Culling Fabric/Forge (by tr7zw) Chipped (by terrariumearth) FTB XMod Compat (by FTB) FerriteCore ((Neo)Forge) (by malte0811) Extra Disks (by MelanX) Nature's Compass (by Chaosyr) Thermal Locomotion (by TeamCoFH) TexTrue's Embeddium Options (by TexTrue) Traveler's Backpack (by Tiviacz1337) Geophilic – Vanilla Biome Overhauls (by bebebea_loste) Create: Power Loader (by Lysine) Polymorph (Fabric/Forge/Quilt) (by TheIllusiveC4) Enlightend (by lixir) Create Central Kitchen (by DragonsPlus) Energy Meter (by Relentless) Botarium (by CodexAdrian) FTB Teams (Forge) (by FTB) Storage Drawers (by Texelsaur) Create: Extended Cogwheels (by Rabbitminers) Embeddium/Rubidium Dynamic Lights (by Anthxny) Biome Makeover (Forge) (by Lemonszz) Create Guardian Beam Defense (by ibarnstormer_) Create: The Factory Must Grow (by Dr_Mango_Tea) Create Chunkloading (by embeddedt) Balm (Forge Edition) (by BlayTheNinth) Glodium (by GlodBlock) Thermal Expansion (by TeamCoFH) Chunk-Pregenerator (by Speiger) Advanced Peripherals (by srrendi) Create: Garnished (by DakotaPrideModding) Tidal Towns (by joshieman) Easy Magic [Forge & Fabric] (by Fuzs) Extreme Reactors (by ZeroNoRyouki) Applied Energistics 2 Wireless Terminals (by Mari_023) Redstone Arsenal (by TeamCoFH) ExtraStorage (by 3divad99) Thermal Innovation (by TeamCoFH) Collective (by Serilum) Wizard's Reborn (by MaxBogomol) GraveStone Mod (by henkelmax) Mekanism Additions (by bradyaidanc) Create: New Age (by nilBlade) Refined Storage (by raoulvdberge) Embeddium/Rubidium Extras (by Anthxny) ZeroCore 2 (by ZeroNoRyouki) Mekanism Generators (by bradyaidanc) WebDisplays (by ds58) Clumps (by Jaredlll08) Vein Mining (Fabric/Forge/Quilt) (by TheIllusiveC4) Villager Names (by Serilum) Create Slice & Dice (by possible_triangle) Embeddium (by embeddedt) Create: Steam 'n' Rails (by mattentosh) Get It Together, Drops! (by bl4ckscor3) Sophisticated Core (by P3pp3rF1y) Supplementaries (by MehVahdJukaar) Jade Addons (Forge) (by Snownee) Create: Design n' Decor (by MilkyFur) Construction Wand (by ThetaDev) Create: Diesel Generators (by george8188262) Create : Misc & Things (by to0pa_fr) Valkyrien Skies (Forge/Fabric) (by triode_) Refined Storage Addons (by raoulvdberge) FTB Chunks (Forge) (by FTB) FTB Ranks (Forge) (by FTB) Moonlight Lib (by MehVahdJukaar) CC: Tweaked (by SquidDev) Waystones (by BlayTheNinth) Applied Energistics 2 (by thetechnici4n) Trowels fork (by Luciano_cz) Cooking for Blockheads (by BlayTheNinth) Create (by simibubi) Towns and Towers (by Biban_Auriu)
    • Hi, you guys are probably all tired of having to deal with the same topic everytimes. I want to play mods, but forge doesn't want me to. And after days of videos and forum, i have no choices to ask before giving up.. The classic Error code 1 ( here's my debug.log : https://paste.ee/p/0WMSP). I tryed everything. The Forge version fit the mod version. I have java jdk 17 and the path to java is set. My mods folder is empty. My Minecraft luncher path has been changed. Java, Minecraft and Forged has been reinstalled 3 times. I tryed with the curseforge luncher. The only thing i didn't do, and I think it might be the problem, is updating my graphic card drivers. For the only reason that my computer is an Ace Magician ( Tiny pc) that don't have a graphic card. But then I went with Fabric. And it works just fine.  Anyway I can't find anything so thank you for your help. Sorry for my english if there's any mistake. Razziel.  
    • I am trying to make my own modpack and at the moment it crashes before I can get to the main menu. I have been trying to google and figure it out myself but would really appreciate some help. I've been using CurseForge to install mod and think I've gotten all the dependencies but I'm not 100% sure. I hope I got the paste.ee thing right Thanks in advance! https://paste.ee/p/NXdSO
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.