So I tried to setup ore generation for an ore that I created but I keep receiving this error:
---- Minecraft Crash Report ----
// Ooh. Shiny.
Time: 7/11/16 10:33 AM
Description: Exception in server tick loop
java.lang.ClassCastException: quplet.moreMaterials.mod.blocks.BlockBronzeOre cannot be cast to net.minecraft.block.state.IBlockState
at quplet.moreMaterials.mod.init.OreGeneration.generateOre(OreGeneration.java:37)
at quplet.moreMaterials.mod.init.OreGeneration.generateOverworld(OreGeneration.java:31)
at quplet.moreMaterials.mod.init.OreGeneration.generate(OreGeneration.java:24)
at net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:120)
at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1070)
at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1052)
at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:163)
at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:336)
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:107)
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:124)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:496)
at java.lang.Thread.run(Thread.java:745)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- System Details --
Details:
Minecraft Version: 1.10.2
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_92, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 728712072 bytes (694 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 1, tcache: 1, allocated: 12, tallocated: 94
FML: MCP 9.32 Powered by Forge 12.18.0.2010 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)
UCHIJAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.0.2010.jar)
UCHIJAA Forge{12.18.0.2010} [Minecraft Forge] (forgeSrc-1.10.2-12.18.0.2010.jar)
UCHIJAA mmm{0.3 Alpha} [More Materials Mod] (bin)
Loaded coremods (and transformers):
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Player Count: 0 / 8; []
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
This is my Ore Gen code:
package quplet.moreMaterials.mod.init;
import java.util.Random;
import com.google.common.base.Predicate;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraftforge.fml.common.IWorldGenerator;
public class OreGeneration implements IWorldGenerator {
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
IChunkProvider chunkProvider) {
switch (world.provider.getDimension()) {
case 0:
generateOverworld(world, random, chunkX, chunkZ);
break;
}
}
public void generateOverworld(World world, Random rand, int x, int z) {
generateOre(ModBlocks.bronze_ore, world, rand, x, z, 2, 6, 4, 5, 68, Blocks.STONE);
}
public void generateOre(Block block, World world, Random random, int chunkX, int chunkZ, int minVienSize, int maxVienSize, int chance, int minY, int maxY, Block generateIn) {
int vienSize = minVienSize + random.nextInt(maxVienSize - minVienSize);
int heightRange = maxY - minY;
WorldGenMinable gen = new WorldGenMinable((IBlockState) block, vienSize, (Predicate<IBlockState>) generateIn);
for(int i = 0; i < chance; i++) {
int xRand = chunkX * 16 + random.nextInt(16);
int yRand = random.nextInt(heightRange) + minY;
int zRand = chunkZ * 16 + random.nextInt(16);
gen.generate(world, random, new BlockPos(xRand, yRand, zRand));
}
}
}
The crash log is telling you that you can't cast a block into a state, and that it is happening on line 37 of your ore generation class. In order to get the default block state of a block, you need to call "block.getDefaultState();".
The crash log is telling you that you can't cast a block into a state, and that it is happening on line 37 of your ore generation class. In order to get the default block state of a block, you need to call "block.getDefaultState();".
So I tried to setup ore generation for an ore that I created but I keep receiving this error:
---- Minecraft Crash Report ----
// Ooh. Shiny.
Time: 7/11/16 10:33 AM
Description: Exception in server tick loop
java.lang.ClassCastException: quplet.moreMaterials.mod.blocks.BlockBronzeOre cannot be cast to net.minecraft.block.state.IBlockState
at quplet.moreMaterials.mod.init.OreGeneration.generateOre(OreGeneration.java:37)
at quplet.moreMaterials.mod.init.OreGeneration.generateOverworld(OreGeneration.java:31)
at quplet.moreMaterials.mod.init.OreGeneration.generate(OreGeneration.java:24)
at net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:120)
at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1070)
at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1052)
at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:163)
at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:336)
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:107)
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:124)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:496)
at java.lang.Thread.run(Thread.java:745)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- System Details --
Details:
Minecraft Version: 1.10.2
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_92, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 728712072 bytes (694 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 1, tcache: 1, allocated: 12, tallocated: 94
FML: MCP 9.32 Powered by Forge 12.18.0.2010 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)
UCHIJAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.0.2010.jar)
UCHIJAA Forge{12.18.0.2010} [Minecraft Forge] (forgeSrc-1.10.2-12.18.0.2010.jar)
UCHIJAA mmm{0.3 Alpha} [More Materials Mod] (bin)
Loaded coremods (and transformers):
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Player Count: 0 / 8; []
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
This is my Ore Gen code:
And this is my Ore registation code line:
Can anyone help me with this?
The crash log is telling you that you can't cast a block into a state, and that it is happening on line 37 of your ore generation class. In order to get the default block state of a block, you need to call "block.getDefaultState();".
Thank you for your help, sir.