Générer des minerais
-
j’ai réussi pour les minerais, j’ai nommé une fonction random et l’autre random2 pour la différenciation.
-
Merci de ne pas dériver du sujet original. Comme ton problème ne concerne pas le tutoriel, tu dois ouvrir une discussion dans la section support pour les moddeurs.
-
Bonjours, j,ai essayer de faire un minerais de rubis, mais il se génere mal dans la map, j’ai mit 3 pour la taille des fillons et 4 pour la rareté, mais le probleme, c’est qu’il est beaucoup trop rare! Si le diam est a 1, logiquement mon minerais devrai etre 4 fois moin rare que le diam! J’ai pris 2 heures pour trouver un fillon de 1… j’ai essayé de monter la raretée a 300, ca a donner une rareté plus au moin equivalente a l’or, mais il y avait que des fillons de 1…
Bref voici les codes:
Classe principale:
package fr.teraforge.teracraft.common; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import cpw.mods.fml.common.IWorldGenerator; 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.registry.GameRegistry; import fr.teraforge.teracraft.proxy.CommonProxy; @Mod(modid = "tc", name = "TeraCraft", version = "1.0.0") public class ModTeraCraft { public static final String MODID = "tc"; @Instance("tc") public static ModTeraCraft instance; @SidedProxy(clientSide = "fr.teraforge.teracraft.proxy.ClientProxy", serverSide = "fr.teraforge.teracraft.proxy.CommonProxy") public static CommonProxy proxy; public static Item itemTc; public static Block blockRubis; public static Block mineraisRubis; public static final IWorldGenerator worldgeneration = new WorldGeneration(); @EventHandler public void preInit(FMLPreInitializationEvent event) { itemTc = new ItemTc().setUnlocalizedName("Rubis").setTextureName(ModTeraCraft.MODID + ":Rubis").setCreativeTab(CreativeTabs.tabMaterials); GameRegistry.registerItem(itemTc, "Rubis"); blockRubis = new BlockRubis(Material.rock).setBlockName("blockrubis").setBlockTextureName(MODID + ":block_rubis").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(blockRubis, "block_rubis"); mineraisRubis = new MineraisRubis(Material.rock).setBlockName("mineraisrubis").setBlockTextureName(MODID + ":minerais_rubis").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(mineraisRubis, "minerais_rubis"); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRender(); GameRegistry.registerWorldGenerator(worldgeneration, 0); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
WorldGeneration.java:
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId) { case -1: generateNether(world, random, chunkX * 16, chunkZ * 16); break; case 0: generateSurface(world, random, chunkX * 16, chunkZ * 16); break; case 1: generateEnd(world, random, chunkX * 16, chunkZ * 16); break; } } private void generateEnd(World world, Random random, int x, int z) { } private void generateSurface(World world, Random random, int x, int z) { this.addOreSpawn(ModTeraCraft.mineraisRubis, 0, Blocks.stone, world, random, x, z, 16, 16, 3, 4, 1, 16); } private void generateNether(World world, Random random, int x, int z) { } public void addOreSpawn(Block block, int metadata, Block target, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY) { assert maxY > minY : "La position Y maximum doit être supérieure à la position Y minimum."; assert maxX > 0 && maxX <= 16 : "X doit se trouver entre 0 et 16."; assert minY > 0 : "La position Y minimum doit être supérieure à 0."; assert maxY < 256 && maxY > 0 : "La position Y maximum doit se trouver entre 0 et 256."; assert maxZ > 0 && maxZ <= 16 : "Z doit se trouver entre 0 et 16."; for(int i = 0; i < chancesToSpawn; i++) { int posY = random.nextInt(128); if((posY <= maxY) && (posY >= minY)) { (new WorldGenMinable(block, metadata, maxVeinSize, target)).generate(world, random, blockXPos + random.nextInt(16), posY, blockZPos + random.nextInt(16)); } } } }
et les logs de la console:
[15:12:46] [main/INFO] [GradleStart]: Extra: [] [15:12:46] [main/INFO] [GradleStart]: Running with arguments: [–userProperties, {}, --assetsDir, C:/Users/uniik/.gradle/caches/minecraft/assets, --assetIndex, 1.7.10, --accessToken, {REDACTED}, --version, 1.7.10, --tweakClass, cpw.mods.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker] [15:12:46] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker [15:12:46] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker [15:12:46] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker [15:12:46] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker [15:12:46] [main/INFO] [FML]: Forge Mod Loader version 7.99.29.1490 for Minecraft 1.7.10 loading [15:12:46] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_45, running on Windows 8.1:amd64:6.3, installed at C:\Program Files\Java\jdk1.8.0_45\jre [15:12:46] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [15:12:46] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker [15:12:46] [main/INFO] [GradleStart]: Injecting location in coremod cpw.mods.fml.relauncher.FMLCorePlugin [15:12:46] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin [15:12:46] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [15:12:46] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker [15:12:46] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [15:12:46] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [15:12:46] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [15:12:46] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [15:12:46] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [15:12:48] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [15:12:48] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [15:12:48] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker [15:12:49] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [15:12:49] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.TerminalTweaker [15:12:49] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.TerminalTweaker [15:12:49] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [15:12:50] [main/INFO]: Setting user: Player400 [15:12:51] [Client thread/INFO]: LWJGL Version: 2.9.1 [15:12:52] [Client thread/INFO] [STDOUT]: [cpw.mods.fml.client.SplashProgress:start:188]: –-- Minecraft Crash Report ---- // Ooh. Shiny. Time: 15-07-15 15:12 Description: Loading screen debug info This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 8.1 (amd64) version 6.3 Java Version: 1.8.0_45, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 798260816 bytes (761 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.3.12618 Compatibility Profile Context 13.251.9001.1001' Renderer: 'AMD Radeon R7 200 Series' [15:12:52] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [15:12:52] [Client thread/INFO] [FML]: MinecraftForge v10.13.4.1490 Initialized [15:12:52] [Client thread/INFO] [FML]: Replaced 183 ore recipies [15:12:52] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [15:12:52] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer [15:12:52] [Client thread/INFO] [FML]: Searching C:\Users\uniik\Desktop\Test\forge-1.7.10-10.13.4.1490-1.7.10-src\eclipse\mods for mods [15:12:55] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load [15:12:55] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, tc] at CLIENT [15:12:55] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, tc] at SERVER [15:12:56] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:TeraCraft [15:12:56] [Client thread/INFO] [FML]: Processing ObjectHolder annotations [15:12:56] [Client thread/INFO] [FML]: Found 341 ObjectHolder annotations [15:12:56] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations [15:12:56] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations [15:12:56] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0 [15:12:56] [Client thread/INFO] [FML]: Applying holder lookups [15:12:56] [Client thread/INFO] [FML]: Holder lookups applied [15:12:56] [Client thread/INFO] [FML]: Injecting itemstacks [15:12:56] [Client thread/INFO] [FML]: Itemstack injection complete [15:12:56] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [15:12:56] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Starting up SoundSystem… [15:12:56] [Thread-8/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Initializing LWJGL OpenAL [15:12:56] [Thread-8/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [15:12:56] [Thread-8/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: OpenAL initialized. [15:12:57] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [15:12:57] [Sound Library Loader/INFO]: Sound engine started [15:12:59] [Client thread/INFO]: Created: 16x16 textures/blocks-atlas [15:12:59] [Client thread/INFO]: Created: 16x16 textures/items-atlas [15:12:59] [Client thread/INFO] [STDOUT]: [fr.teraforge.teracraft.proxy.ClientProxy:registerRender:8]: méthode côté client [15:12:59] [Client thread/INFO] [FML]: Injecting itemstacks [15:12:59] [Client thread/INFO] [FML]: Itemstack injection complete [15:12:59] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods [15:12:59] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:TeraCraft [15:12:59] [Client thread/INFO]: Created: 512x256 textures/blocks-atlas [15:12:59] [Client thread/INFO]: Created: 256x256 textures/items-atlas [15:12:59] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [15:12:59] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: SoundSystem shutting down… [15:13:00] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:importantMessage:90]: Author: Paul Lamb, www.paulscode.com [15:13:00] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [15:13:00] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [15:13:00] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Starting up SoundSystem… [15:13:00] [Thread-10/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Initializing LWJGL OpenAL [15:13:00] [Thread-10/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [15:13:00] [Thread-10/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: OpenAL initialized. [15:13:00] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [15:13:00] [Sound Library Loader/INFO]: Sound engine started [15:13:08] [Server thread/INFO]: Starting integrated minecraft server version 1.7.10 [15:13:08] [Server thread/INFO]: Generating keypair [15:13:08] [Server thread/INFO]: Converting map! [15:13:08] [Server thread/INFO]: Scanning folders… [15:13:08] [Server thread/INFO]: Total conversion count is 0 [15:13:08] [Server thread/INFO] [FML]: Injecting existing block and item data into this server instance [15:13:08] [Server thread/INFO] [FML]: Applying holder lookups [15:13:08] [Server thread/INFO] [FML]: Holder lookups applied [15:13:08] [Server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@9af2d95) [15:13:08] [Server thread/INFO] [FML]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@9af2d95) [15:13:08] [Server thread/INFO] [FML]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@9af2d95) [15:13:08] [Server thread/INFO]: Preparing start region for level 0 [15:13:09] [Server thread/INFO]: Preparing spawn area: 9% [15:13:10] [Server thread/INFO]: Preparing spawn area: 26% [15:13:11] [Server thread/INFO]: Preparing spawn area: 44% [15:13:12] [Server thread/INFO]: Preparing spawn area: 58% [15:13:13] [Server thread/INFO]: Preparing spawn area: 73% [15:13:14] [Server thread/INFO]: Preparing spawn area: 84% [15:13:15] [Server thread/INFO]: Preparing spawn area: 95% [15:13:16] [Server thread/INFO]: Changing view distance to 12, from 10 [15:13:16] [Netty Client IO #0/INFO] [FML]: Server protocol version 2 [15:13:16] [Netty IO #1/INFO] [FML]: Client protocol version 2 [15:13:16] [Netty IO #1/INFO] [FML]: Client attempting to join with 4 mods : FML@7.10.99.99,Forge@10.13.4.1490,mcp@9.05,tc@1.0.0 [15:13:16] [Netty IO #1/INFO] [FML]: Attempting connection with missing mods [] at CLIENT [15:13:16] [Netty Client IO #0/INFO] [FML]: Attempting connection with missing mods [] at SERVER [15:13:16] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established [15:13:16] [Server thread/INFO]: Player400[local:E:47116045] logged in with entity id 218 at (83.5, 64.0, 241.5) [15:13:16] [Client thread/INFO] [FML]: [Client thread] Client side modded connection established [15:13:16] [Server thread/INFO]: Player400 joined the game [15:13:19] [Server thread/INFO]: Saving and pausing game… [15:13:19] [Server thread/INFO]: Saving chunks for level 'New World'/Overworld [15:13:20] [Client thread/INFO]: Stopping! [15:13:20] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [15:13:20] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: SoundSystem shutting down… [15:13:21] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:importantMessage:90]: Author: Paul Lamb, www.paulscode.com [15:13:21] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [15:13:21] [Client Shutdown Thread/INFO]: Stopping server Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
Je remerci d’avance la personne qui aura la pacience de m’aider
-
Je veux bien avoir la “pacience” comme tu dis .
Tu ne fais pas spawner ton minerai plus souvent que le diamant, voici le code pour le diamant :
this.diamondGen = new WorldGenMinable(Blocks.diamond_ore, 7); et la génération : this.genStandardOre1(1, this.diamondGen, 0, 16); qui appelle cette fonction : /** * Standard ore generation helper. Generates most ores. */ protected void genStandardOre1(int p_76795_1_, WorldGenerator p_76795_2_, int p_76795_3_, int p_76795_4_) { for (int l = 0; l < p_76795_1_; ++l) { int i1 = this.chunk_X + this.randomGenerator.nextInt(16); int j1 = this.randomGenerator.nextInt(p_76795_4_ - p_76795_3_) + p_76795_3_; int k1 = this.chunk_Z + this.randomGenerator.nextInt(16); p_76795_2_.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); } }
-
Ducou, ques que je doit changer dans mes codes pour qu’il sois 2 foit moin rare que le diaman par exemple?
Edit: j’ai suivi le bonus d tuto, mais bien que je veut que mon minerais de rubis donne une gemme, je voudrais que, a la pioche fortune, toute en gardant une norme de un drop sans celle-ci, puisse dropper plus d’une gemme lorsqu’elle est minée a l’aide d’une pioche fortune.
Bref, j’espere que quelqu’un poura m’aider
-
Salut, j’ai suivi le tuto et il marche très bien, par contre ça ne supporte pas l’enchant Fortune je pense?
Silk Touch marche mais en testant avec une pioche normale et une pioche Fortune sur un minerai droppant un nombre aléatoire d’items entre 3 et 7, je ne vois pas de différence flagrante contrairement au Lapis par exemple où là ça se voit qu’on a fortune.
Et je n’ai pas réussi à trouver comment adapter le drop à l’enchant en fouillant dans les classes de l’enchant et des blocs ore…Quelqu’un a une idée pour ça?
Tu devrais aussi rajouter le code de l’XP que NicoKing60 a donné sur la page 2.
-
L’effet de fortune ne se gère pas dans la génération mais dans la fonction quantityDropped de ton bloc.
-
Ok j’ai trouvé la solution. Il y a une méthode “quantityDroppedWithBonus” dans la classe OreBlock mais ça ne marchait pas (pas compris pourquoi) du coup j’ai fait comme Galacticraft, j’ai renommé en “quantityDropped” et ajouté un @Override avant et là ça marche:
@Override public int quantityDropped(int meta, int fortune, Random random) { if (fortune > 0 && Item.getItemFromBlock(this) != this.getItemDropped(meta, random, fortune)) { int j = random.nextInt(fortune + 2) - 1; if (j < 0) { j = 0; } return this.quantityDropped(random) * (j + 1); } else { return this.quantityDropped(random); } }
Cette fonction peut multiplier au maximum le rendement par 5, comme dans Minecraft. Je pigeais pas au début pourquoi ils enlevaient 1 avant de le rajouter après, mais c’est pour éviter d’avoir une multiplication par 0 vu que nextInt() peut renvoyer un 0…
-
Et comment faire pour un random ore ? ( Un minerais aléatoire qui drop parmi 3 créer)
-
Bonsoir,
Avec la fonction getItemDropped.
-
@robin4002 Nickel Merci
-
@agabou salut je voudrais savoir comment faire pour que le minerais spawn genre 2 fois tous les 5chunk
-
@lothbrock Tu est en 1.7 ? Sache que cette version n’est plus supportée par le forum, si tu es en 1.7 change plutôt en 1.16 où je modde.
-
@Krafty oui je suis en 1.7.10 mais j’ai bien avance sur mon mod et j’ai pas envie de le recodé en 1.16
-
@lothbrock Bah alors désolé pour toi mais tu as une chance sur 10000 d’avoir une réponse