Hey, I need some help. I'm doing a modding course for my last year of High school, and I have run into a problem. I have created a custom Ore in my mod, Acuatic Ore, and no matter how many times I code it into the game, It will NOT generate. I have tried erasing code and then rewriting it, I've even asked my teacher about it, but when HE tired the mod, all the blocks, including mine, generated. I cannot for the life of me figure this out. IT WILL NOT generate on my pc. Heres the block
To debug problems in your code you should always "trace" the execution. There are all sorts of tools for that (like debug mode in Eclipse) but I find it simplest to just add console statements (System.out.println() method) at all the key points in your code. In those statements you can print out the values of any key fields.
So if you added the statements in your code you could see whether your method is being executed at all, and you can follow the execution of the loop and see whether or not it is placing the blocks -- for example, maybe your ore is generating but in a different location than you expect (you can see this directly by printing out the position of each ore block as it generates).
No professional programmer just guesses, instead the trace the execution and then it is very clear at what point the code starts behaving differently than expected.
Hey, I need some help. I'm doing a modding course for my last year of High school, and I have run into a problem. I have created a custom Ore in my mod, Acuatic Ore, and no matter how many times I code it into the game, It will NOT generate. I have tried erasing code and then rewriting it, I've even asked my teacher about it, but when HE tired the mod, all the blocks, including mine, generated. I cannot for the life of me figure this out. IT WILL NOT generate on my pc. Heres the block
Could you post your code?
Also, in the future, posts asking for help with modding should go in modification development.
Uncrafting Table (1.15.2): https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/wip-mods/3032965-uncrafting-table
Ruins of Humanity (mod, no longer being developed): https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/wip-mods/2898701-1-12-2-wip-early-alpha-ruins-of-humanity
Sure, how?
Here is the generation code;
package generators;package generators;
import java.util.Random;
import net.minecraft.block.Block;import net.minecraft.util.BlockPos;import net.minecraft.world.World;import net.minecraft.world.chunk.IChunkProvider;import net.minecraft.world.gen.feature.WorldGenMinable;import net.minecraftforge.fml.common.IWorldGenerator;
public class Acuatic_Ore_Block_Gen implements IWorldGenerator {
private Block block;
public Acuatic_Ore_Block_Gen(Block _block) { this.block = _block; } //end constructor
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { for(int i=0; i < 450; i++){ int x = chunkX * 16 + random.nextInt(16); int y = 15 + random.nextInt(145); int z = chunkZ * 16 + random.nextInt(16); WorldGenMinable wgm = new WorldGenMinable(block.getDefaultState(),7); wgm.generate(world, random, new BlockPos(x,y,z));
} //end for loop
}
}
To debug problems in your code you should always "trace" the execution. There are all sorts of tools for that (like debug mode in Eclipse) but I find it simplest to just add console statements (System.out.println() method) at all the key points in your code. In those statements you can print out the values of any key fields.
So if you added the statements in your code you could see whether your method is being executed at all, and you can follow the execution of the loop and see whether or not it is placing the blocks -- for example, maybe your ore is generating but in a different location than you expect (you can see this directly by printing out the position of each ore block as it generates).
No professional programmer just guesses, instead the trace the execution and then it is very clear at what point the code starts behaving differently than expected.
Ok, thank you.