Générations de minerais
-
Car ils n’ont pas de nom non localisé :
.setUnlocalizedName(“nom non localisé”);Et non c’est pas un problème de texture, mais un NPE, car les objets de tes blocs sont null.
public static Block monBloc; @EventHandler public void preInit(FMLPreInitializationEvent event) { Block monBloc = new BlockQuelqueChose(1700).setUnlocalizedName("monBloc"); }Je sais pas où vous avez vu ça, j’ai déjà vu plusieurs personnes faire ça, et c’est completement faux.
Dans cette exemple, je déclare un bloc nommé monBloc qui est public et static, donc accessible de partout sans instance. En dessus, je créer une variable local à la fonction preInit nommé monBloc. Et donc la variable de la classe (qui est utilisé dans les autres classes) reste null, d’où le NPE ( = NullPointerException).Le bon code c’est ça :
public static Block monBloc; @EventHandler public void preInit(FMLPreInitializationEvent event) { monBloc = new BlockQuelqueChose(1700).setUnlocalizedName("monBloc"); }Ici je déclare la variable, puis je l’initialise dans la fonction preInit, donc pas de NPE puisque mon bloc à une valeur.
Même chose pour tout tes items, dans la fonction load enlève tout les Item, sinon tu créés une variable local à la place d’initialisé l’item.
En passant, les blocs et items se preinit, sinon tu vas avoir des problèmes le jour où tu vas faire des achievements.
-
D’accord je ferais comme cela dé maintenant mais je ne vois pas ou est le problème en fait car je le met dans “public void load” ?
Au fait une idée pour la génération du monde ?

-
D’après ce que j’ai compris c’est que dans le preInit(), tu recrées un block en écrivant le “Block” devant “oretopaze = new oretopaze(2002).setTextureName(“rm:oretopaze”).setHardness(10.0F).setStepSound(Block.soundStoneFootstep);”. Donc quand le jeu se lance, il utilise la variable déclarée précédemment (“public static Block oretopaze”) qui n’a pas subit de modification. Voilà j’espère que tu as compris.

-
Ah d’accord j’ai compris donc j’ai modifier tout mes codes , comme cela est-ce correcte y a t-il toujours des erreurs ?

package chinesemod; import net.minecraft.block.Block; import net.minecraft.block.BlockOre; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraftforge.common.EnumHelper; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @Mod(modid="CM", name="Prehistocraft", version="1.0.0") @NetworkMod(clientSideRequired=true, serverSideRequired=false) // NE PAS MODIFIER CETTE LIGNE public class chinesemodmain { @Instance("CM") public static chinesemodmain instance; @SidedProxy(clientSide="chinesemod.ClientProxy", serverSide="chinesemod.CommonProxy") public static CommonProxy proxy; static EnumToolMaterial TOPAZE = EnumHelper.addToolMaterial("TOPAZE", 3/*miner obsi*/, 200/*durabilite*/, 10.0F/*Vitesse minage*/, 10/*coeur de degats*/,25 ); static EnumToolMaterial TOPAZEPICKAXE = EnumHelper.addToolMaterial("TOPAZEPICKAXE", 3/*miner obsi*/, 200/*durabilite*/, 21.0F/*Vitesse minage*/, 5/*coeur de degats*/,25 ); public static Item topaze; public static Item topazesword; public static Item topazepickaxe; public static Item topazeaxe; public static Item topazeshovel; public static Item topazehoe; public static Block boue; public static Block topazeblock; public static Block oretopaze; @EventHandler public void preInit(FMLPreInitializationEvent event) { topaze = new topaze(865).setTextureName("rm:topaze"); topazesword = (new ItemSword(866, TOPAZE)).setUnlocalizedName("topazeSword").setTextureName("rm:topazesword"); topazepickaxe = (new ItemPickaxe(867, TOPAZEPICKAXE)).setUnlocalizedName("topazePickaxe").setTextureName("rm:topazepickaxe"); topazeaxe= (new ItemAxe(868, TOPAZEPICKAXE)).setUnlocalizedName("topazeAxe").setTextureName("rm:topazeaxe"); topazeshovel= (new ItemSpade(869, TOPAZEPICKAXE)).setUnlocalizedName("topazeShovel").setTextureName("rm:topazeshovel"); topazehoe= (new ItemHoe(870, TOPAZEPICKAXE)).setUnlocalizedName("topazeHoe").setTextureName("rm:topazehoe"); boue = new boue(2000).setTextureName("rm:boue").setHardness(0.1F).setStepSound(Block.soundGravelFootstep); oretopaze = new oretopaze(2001).setTextureName("rm:oretopaze").setHardness(10.0F).setStepSound(Block.soundStoneFootstep); topazeblock = new Blocktopaze(2002).setUnlocalizedName("topazeb").setTextureName("rm:topazeblock").setHardness(10.0F).setStepSound(Block.soundStoneFootstep); } @EventHandler public void load(FMLInitializationEvent event) { proxy.registerRenderers(); GameRegistry.registerItem(topaze, "Topaze"); GameRegistry.registerItem(topazesword, "Topaze Sword"); GameRegistry.registerItem(topazepickaxe, "Topaze Pickaxe"); GameRegistry.registerItem(topazeaxe, "Topaze Axe"); GameRegistry.registerItem(topazeshovel, "Topaze Shovel"); GameRegistry.registerItem(topazehoe, "Topaze Hoe"); LanguageRegistry.addName(topaze, "Topaze"); LanguageRegistry.addName(topazesword, "Topaze Sword"); LanguageRegistry.addName(topazepickaxe, "Topaze Pickaxe"); LanguageRegistry.addName(topazeaxe, "Topaze Axe"); LanguageRegistry.addName(topazeshovel, "Topaze Shovel"); LanguageRegistry.addName(topazehoe, "Topaze Hoe"); GameRegistry.registerBlock(boue, "Boue"); GameRegistry.registerBlock(topazeblock, "TopazeBlock"); GameRegistry.registerBlock(oretopaze, "Topaze Ore"); LanguageRegistry.addName(boue, "Boue"); LanguageRegistry.addName(topazeblock, "TopazeBlock"); LanguageRegistry.addName(oretopaze, "Topaze Ore"); //*CRAFTS*// //GameRegistry.addRecipe(new ItemStack(topazeblock), new Object[]{"XXX", "XXX", "XXX", 'X', chinesemodmain.topaze}); //*FURNACE*// GameRegistry.addSmelting(oretopaze.blockID, new ItemStack(topaze), 1.0F); //GameRegistry.registerWorldGenerator(new WorldGeneratorTutoriel()); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } -
Normalement c’est bon, mais pour le nom des Items et des blocs tu devrais utiliser les fichiers lang, c’est plus efficace et ça permet de clarifier le code.
-
@‘gagoi’:
Normalement c’est bon, mais pour le nom des Items et des blocs tu devrais utiliser les fichiers lang, c’est plus efficace et ça permet de clarifier le code.
Oké je retiens
Merci , tout marche les crafts sont devenu opérationnel par la suite ainsi que le génération de monde maintenant je mine en créa a la couche 16 et je n’ai pas vu mon minerai , qu’est-ce qui pourrait causer sa ?EDIT : Je n’ai riens dit mon minerai est générer MERCI BEAUCOUP !

-
De rien.

-
Salut j’aimerais générer dans l’end mon minerai mais sur la surface de l’end donc la ou on marche si vous préférer , mais comment faire ?
-
Tu fait une condition pour vérifier si il y a un bloc d’air au-dessus du bloc de pierre de l’end.
-
for(int i = 0; i < probabilité; i++) { int targetX = x + rand.nextInt(16); int targetY = rand.nextInt(192); int targetZ = z + rand.nextInt(16); if(world.isAirBlock(targetZ, targetY, targetZ) { (new WorldGenMinable(id du bloc à générer, metadata du bloc à générer, taille maximum d un filon, Block.whiteStone.blockID)).generate(world, rand, targetX, targetY, targetZ); } }Parcontre monte bien la prob, sinon il se généra que très rarement.
-
Merci beaucoup à vous deux !

-
A croire que je ne suis pas très intelligent j’ai une question à chaque fois que je veut génerger un minerai je dois refaire un classe ou je l’ajoute simplement dans la case correspondant ? Car le minerai de néphrite ne se génère pas dans l’end ! Sad
-
Il faut mettre dans la même classe. Envoie ton code.
-
Voici mon code : j’ai un deuxième soucis mon generateNether se souligne en rouge comme si il avais été supprimer normal ?
package chinesemod; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import cpw.mods.fml.common.IWorldGenerator; public class WorldGeneratorTutoriel implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId) { case -1: this.generateEnd(world, chunkX * 16, chunkZ * 16, random); case 0: this.generateSurface(world, chunkX * 16, chunkZ * 16, random); case 1: //*this.generateNether(world, chunkX * 16, chunkZ * 16, random);*// } } private void generateSurface(World world, int x, int z, Random rand) { for(int i = 0; i < 14; i++) { (new WorldGenMinable(chinesemodmain.oretopaze.blockID, 0, 6, Block.stone.blockID)).generate(world, rand, x + rand.nextInt(16), rand.nextInt(16), z + rand.nextInt(16)); } } private void generateEnd(World world, int x, int z, Random rand) { for(int i = 0; i < 100; i++) { int targetX = x + rand.nextInt(16); int targetY = rand.nextInt(192); int targetZ = z + rand.nextInt(16); if(world.isAirBlock(targetZ, targetY, targetZ)) { (new WorldGenMinable(chinesemodmain.orenephrite.blockID, 0, 6, Block.whiteStone.blockID)).generate(world, rand, targetX, targetY, targetZ); } } } } -
Faut pas @Override ?
Vérifie tes params aussi
-
Le @Override y est , mes paramètres sont bon normalement . . .

-
Screen l’erreur eclipse et envoie le
-
Voici -
Il créer une méthode generateNether comme pour l’end et l’overworld :
private void generateNether(World world, int x, int z, Random rand) { } -
Super sa à régler le problème mais mon minerai dans l’end n’est toujours pas génerer !

