Générations de minerais
-
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 !

-
Je suis vraiment désolé

Je suis parti faire des tests sur eclipse, et je viens de me rendre compte qu’il y a une grosse faute dans le tutoriel.
-1 = Nether et 1 = end, et non l’inverse :/. Je viens d’éditer le tutoriel.On a donc :
switch(world.provider.dimensionId) { case -1: this.generateNether(world, chunkX * 16, chunkZ * 16, random); case 0: this.generateSurface(world, chunkX * 16, chunkZ * 16, random); case 1: this.generateEnd(world, chunkX * 16, chunkZ * 16, random); }Ensuite pour la génération seulement en surface, le problème du code que je t’ai donné, c’est qu’il va que générer si le random tombe sur un cas où le bloc juste au dessus est de l’air, ce qui est très rare.
Donc je te propose une meilleur solution, si le bloc au dessus du minerai n’est pas de l’air, il monte de 1 la coordonné y où il doit se générer. Ainsi les minerais ne se génèrent que en surface.
private void generateEnd(World world, int x, int z, Random rand) { for(int i = 0; i < 4; i++) { (new WorldGenSurfaceMinable(ModTutoriel.BlockTutorial.blockID, 0, 12, Block.whiteStone.blockID)).generate(world, rand, x + rand.nextInt(16), rand.nextInt(128), z + rand.nextInt(16)); } }Et la classe WorldGenSurfaceMinable :
package tutoriel.common; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; public class WorldGenSurfaceMinable extends WorldGenerator { private int minableBlockId; private int minableBlockMeta = 0; private int numberOfBlocks; private int blockToReplace; public WorldGenSurfaceMinable(int id, int number) { this(id, number, Block.whiteStone.blockID); } public WorldGenSurfaceMinable(int id, int number, int target) { this.minableBlockId = id; this.numberOfBlocks = number; this.blockToReplace = target; } public WorldGenSurfaceMinable(int id, int meta, int number, int target) { this(id, number, target); this.minableBlockMeta = meta; } public boolean generate(World world, Random rand, int x, int y, int z) { float f = rand.nextFloat() * (float)Math.PI; double d0 = (double)((float)(x + 8) + MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F); double d1 = (double)((float)(x + 8) - MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F); double d2 = (double)((float)(z + 8) + MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F); double d3 = (double)((float)(z + 8) - MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F); double d4 = (double)(y + rand.nextInt(3) - 2); double d5 = (double)(y + rand.nextInt(3) - 2); for (int l = 0; l <= this.numberOfBlocks; ++l) { double d6 = d0 + (d1 - d0) * (double)l / (double)this.numberOfBlocks; double d7 = d4 + (d5 - d4) * (double)l / (double)this.numberOfBlocks; double d8 = d2 + (d3 - d2) * (double)l / (double)this.numberOfBlocks; double d9 = rand.nextDouble() * (double)this.numberOfBlocks / 16.0D; double d10 = (double)(MathHelper.sin((float)l * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D; double d11 = (double)(MathHelper.sin((float)l * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D; int i1 = MathHelper.floor_double(d6 - d10 / 2.0D); int j1 = MathHelper.floor_double(d7 - d11 / 2.0D); int k1 = MathHelper.floor_double(d8 - d10 / 2.0D); int l1 = MathHelper.floor_double(d6 + d10 / 2.0D); int i2 = MathHelper.floor_double(d7 + d11 / 2.0D); int j2 = MathHelper.floor_double(d8 + d10 / 2.0D); while(!world.isAirBlock(i1, j1 + 2, k1)) { j1++; } for (int k2 = i1; k2 <= l1; ++k2) { double d12 = ((double)k2 + 0.5D - d6) / (d10 / 2.0D); if (d12 * d12 < 1.0D) { for (int l2 = j1; l2 <= i2; ++l2) { double d13 = ((double)l2 + 0.5D - d7) / (d11 / 2.0D); if (d12 * d12 + d13 * d13 < 1.0D) { for (int i3 = k1; i3 <= j2; ++i3) { double d14 = ((double)i3 + 0.5D - d8) / (d10 / 2.0D); Block block = Block.blocksList[world.getBlockId(k2, l2, i3)]; if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && (block != null && block.isGenMineableReplaceable(world, k2, l2, i3, this.blockToReplace))) { world.setBlock(k2, l2, i3, this.minableBlockId, minableBlockMeta, 2); } } } } } } } return true; } }
