I'm new to java & MC modding so I can't find problem in my code. I made ore, which is Gold Nugget ore, it drops 1 gold nugget, and spawns in a world everything is good, it's working perfectly, but I can't get my sprite map to work.
This is my code:
package net.minecraft.src;
import cpw.*;
import cpw.mods.*;
import cpw.mods.fml.*;
import cpw.mods.fml.client.*;
import cpw.mods.fml.client.modloader.*;
import cpw.mods.fml.client.registry.*;
import cpw.mods.fml.common.*;
import cpw.mods.fml.common.asm.*;
import cpw.mods.fml.common.asm.transformers.*;
import cpw.mods.fml.common.discovery.*;
import cpw.mods.fml.common.discovery.asm.*;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.functions.*;
import cpw.mods.fml.common.modloader.*;
import cpw.mods.fml.common.network.*;
import cpw.mods.fml.common.registry.*;
import cpw.mods.fml.common.toposort.*;
import cpw.mods.fml.common.versioning.*;
import cpw.mods.fml.relauncher.*;
import cpw.mods.fml.server.*;
import ibxm.*;
import net.*;
import net.minecraft.*;
import net.minecraft.block.*;
import net.minecraft.block.material.*;
import net.minecraft.client.*;
import net.minecraft.client.audio.*;
import net.minecraft.client.entity.*;
import net.minecraft.client.gui.*;
import net.minecraft.client.gui.achievement.*;
import net.minecraft.client.gui.inventory.*;
import net.minecraft.client.model.*;
import net.minecraft.client.multiplayer.*;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.culling.*;
import net.minecraft.client.renderer.entity.*;
import net.minecraft.client.renderer.texturefx.*;
import net.minecraft.client.renderer.tileentity.*;
import net.minecraft.client.settings.*;
import net.minecraft.client.texturepacks.*;
import net.minecraft.command.*;
import net.minecraft.crash.*;
import net.minecraft.creativetab.*;
import net.minecraft.dispenser.*;
import net.minecraft.enchantment.*;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.boss.*;
import net.minecraft.entity.effect.*;
import net.minecraft.entity.item.*;
import net.minecraft.entity.monster.*;
import net.minecraft.entity.passive.*;
import net.minecraft.entity.player.*;
import net.minecraft.entity.projectile.*;
import net.minecraft.inventory.*;
import net.minecraft.item.*;
import net.minecraft.item.crafting.*;
import net.minecraft.nbt.*;
import net.minecraft.network.*;
import net.minecraft.network.packet.*;
import net.minecraft.network.rcon.*;
import net.minecraft.pathfinding.*;
import net.minecraft.potion.*;
import net.minecraft.profiler.*;
import net.minecraft.server.*;
import net.minecraft.server.dedicated.*;
import net.minecraft.server.gui.*;
import net.minecraft.server.integrated.*;
import net.minecraft.server.management.*;
import net.minecraft.src.*;
import net.minecraft.stats.*;
import net.minecraft.tileentity.*;
import net.minecraft.util.*;
import net.minecraft.village.*;
import net.minecraft.world.*;
import net.minecraft.world.biome.*;
import net.minecraft.world.chunk.*;
import net.minecraft.world.chunk.storage.*;
import net.minecraft.world.demo.*;
import net.minecraft.world.gen.*;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.layer.*;
import net.minecraft.world.gen.structure.*;
import net.minecraft.world.storage.*;
import net.minecraftforge.*;
import net.minecraftforge.classloading.*;
import net.minecraftforge.client.*;
import net.minecraftforge.client.event.*;
import net.minecraftforge.client.event.sound.*;
import net.minecraftforge.common.*;
import net.minecraftforge.event.*;
import net.minecraftforge.event.entity.*;
import net.minecraftforge.event.entity.item.*;
import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.event.entity.minecart.*;
import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.terraingen.*;
import net.minecraftforge.event.world.*;
import net.minecraftforge.liquids.*;
import net.minecraftforge.oredict.*;
import net.minecraftforge.transformers.*;
import paulscode.*;
import paulscode.sound.*;
import paulscode.sound.codecs.*;import java.util.Random;
public class mod_goldNuggetOre extends BaseMod{public mod_goldNuggetOre(){}
public static BlockGoldNuggetOre block;public void load(){
ModLoader.registerBlock(block);
ModLoader.addName(block, "Gold Nugget Ore");}
public String getVersion(){
return "1.0";
}
static{block = (BlockGoldNuggetOre)(new BlockGoldNuggetOre(148, 1).setHardness(10.0F)
.setResistance(20.0F)
.setLightValue(0.0F)
.setBlockName("Gold Nugget Ore")
.setLightOpacity(0)
.setStepSound(Block.soundStoneFootstep)
.setCreativeTab(CreativeTabs.tabBlock)
.setRequiresSelfNotify()
);block.blockIndexInTexture=block.a1;
block.setBlockBounds(0.0F,0.0F,0.0F,1.0F,1.0F,1.0F);
}
public void generateSurface(World world, java.util.Random rand, int chunkX, int chunkZ){
for(int i = 0; i < 4; i++){
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(43)+0;
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(mod_goldNuggetOre.block.blockID, 3)).generate(world, rand, randPosX, randPosY, randPosZ);
}
}
static class BlockGoldNuggetOre extends Block
{int a1 = 0,a2 = 0,a3 = 0,a4 = 0,a5 = 0,a6 = 0;
boolean red = false;
protected BlockGoldNuggetOre(int i, int j)
{
super(i, j, Material.iron);
a1 = 0;
a2 = 0;
a3 = 0;
a4 = 0;
a5 = 0;
a6 = 0;
}
public boolean isPoweringTo(IBlockAccess blockAccess, int i, int j, int k, int l){
return red;
}
public int getBlockTextureFromSide(int i){if (i == 0)
return a1;
else if (i == 1)
return a2;else if (i == 2)
return a3;
else if (i == 3)
return a4;else if (i == 4)
return a5;
else if (i == 5)
return a6;else
return a1;
}public String getTextureFile(){return "/goldnugget.png";}
public int getRenderType(){
return 0;
}
public int tickRate()
{
return 10;
}
public int quantityDropped(Random par1Random){
return 1;
}public int idDropped(int par1, Random par2Random, int par3){
return Item.goldNugget.shiftedIndex;
}
}
}
And this is my sprite .png file:
It uses some weird default stonelike texture, see(one where plus pointer is at):
1. It's totally pointless to import ALL those classes.
2. You're using ModLoader in a MinecraftForge mod. NEVER, EVER do that. MinecraftForge contains a ModLoader compatibility layer ONLY to make ModLoader mods work with MinecraftForge!
3. You need proxies to preload your texture sheet.
4. Block classes are separate from the main mod class.
5. You don't need TickRate, getBlockTextureFromSide and so on, if your block isn't actually going to use it.
6. When the a texture sheet is preloaded by MinecraftForge, you only need to use the getTextureFile method in your Block class and then set the texture like you do in vanilla.
Proper answer to your issue: Learn Java and don't follow "tutorials" made by people who do not know what they're doing.
I would recommend going to the Forge wiki http://www.minecraftforge.net/wiki/Main_Page and read some of the tutorials there to get a better understanding of how Forge works and how to organise class files and use textures.
That would require a complete re-write of your entire code. Just go to the wiki and work through the tuts there, you will learn more that way.
Yes, but dude, I can't fix that error, I don't know how... Everything works perfectly, Ore spawns under ground and when I destroy it in survival mod it drops nugget, Ii just need to get texture work? Help me please?
Yes, but dude, I can't fix that error, I don't know how... Everything works perfectly, Ore spawns under ground and when I destroy it in survival mod it drops nugget, Ii just need to get texture work? Help me please?
No one's going to do that for you. Your problem is the texture is not pre-loaded, because you either don't know what you're doing at all, or you don't know what you're doing and you found a tutorial written by someone who doesn't know what they're doing.
Yes, but dude, I can't fix that error, I don't know how... Everything works perfectly, Ore spawns under ground and when I destroy it in survival mod it drops nugget, Ii just need to get texture work? Help me please?
Yes, but dude, we are trying to help you by pointing out the short comings of your code and directing you to where you can get the information you need to fix it. What you are failing to realise is that we can only fix your texture issue by re-writing your code which, as RedFoxy3 pointed out, no one is going to do that for you.
Look at his old (but updated) ModLoader tutorials, there's one for textures and it's quite detailed.You also might wanna think about cleaning up your code in the future. Not only do you have way too many imports (Ctrl+Shift+O is the magic word), but your style of coding is an entire mess, no offense.
He's obviously trying to work with MinecraftForge, why did you tell him to look at ModLoader tutorials? *sigh*
This is my code:
And this is my sprite .png file:
It uses some weird default stonelike texture, see(one where plus pointer is at):
Thank you for help and best regards, geekz!
2. You're using ModLoader in a MinecraftForge mod. NEVER, EVER do that. MinecraftForge contains a ModLoader compatibility layer ONLY to make ModLoader mods work with MinecraftForge!
3. You need proxies to preload your texture sheet.
4. Block classes are separate from the main mod class.
5. You don't need TickRate, getBlockTextureFromSide and so on, if your block isn't actually going to use it.
6. When the a texture sheet is preloaded by MinecraftForge, you only need to use the getTextureFile method in your Block class and then set the texture like you do in vanilla.
Proper answer to your issue: Learn Java and don't follow "tutorials" made by people who do not know what they're doing.
In Eclipse, you can press Ctrl+Shift+O to make it organize imports for you: it'll trim off unused ones as well.
That would require a complete re-write of your entire code. Just go to the wiki and work through the tuts there, you will learn more that way.
Yes, but dude, I can't fix that error, I don't know how... Everything works perfectly, Ore spawns under ground and when I destroy it in survival mod it drops nugget, Ii just need to get texture work? Help me please?
No one's going to do that for you. Your problem is the texture is not pre-loaded, because you either don't know what you're doing at all, or you don't know what you're doing and you found a tutorial written by someone who doesn't know what they're doing.
Ctrl+Shift+F -- Format code
Also, Ctrl+Space is auto-complete if you haven't tried it (use while typing a long name of something in your program).
Yes, but dude, we are trying to help you by pointing out the short comings of your code and directing you to where you can get the information you need to fix it. What you are failing to realise is that we can only fix your texture issue by re-writing your code which, as RedFoxy3 pointed out, no one is going to do that for you.
He's obviously trying to work with MinecraftForge, why did you tell him to look at ModLoader tutorials? *sigh*