Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.11.2] Ore Gen specific to the different stone variants


Recommended Posts

I have 3 different ores I am trying to have only spawn in a certain stone variant each. I have set up predicates for each stone variant, the ores are spawning but in all variants of stone


this is my OreGen class:

package hazmatik.sonictech.worldgen;

import java.util.Random;

import hazmatik.sonictech.blocks.BlockAntimonyOre;
import hazmatik.sonictech.init.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStone;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.block.state.pattern.BlockStateMatcher;
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.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;

public class OreGen implements IWorldGenerator {
	private WorldGenerator antimony_ore;
	private WorldGenerator chromite_ore;
	private WorldGenerator copper_ore;
	private WorldGenerator molybdenum_ore;
	private WorldGenerator tin_ore;
	private WorldGenerator zinc_ore;
	public OreGen() {
		antimony_ore = new WorldGenMinable(ModBlocks.oreAntimony.getDefaultState(), 8, new DioritePredicate());
		chromite_ore = new WorldGenMinable(ModBlocks.oreChromite.getDefaultState(), 4, new NetherPredicate());
		copper_ore = new WorldGenMinable(ModBlocks.oreCopper.getDefaultState(), 6);
		molybdenum_ore = new WorldGenMinable(ModBlocks.oreMolybdenum.getDefaultState(), 8, new GranitePredicate());
		tin_ore = new WorldGenMinable(ModBlocks.oreTin.getDefaultState(), 6);
		zinc_ore= new WorldGenMinable(ModBlocks.oreZinc.getDefaultState(), 8, new AndesitePredicate());
	private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
		if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
			throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");

		int heightDiff = maxHeight - minHeight + 1;
		for (int i = 0; i < chancesToSpawn; i ++) {
			int x = chunk_X * 16 + rand.nextInt(16);
		    int y = minHeight + rand.nextInt(heightDiff);
		    int z = chunk_Z * 16 + rand.nextInt(16);
		    generator.generate(world, rand, new BlockPos(x, y, z));

	public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
			IChunkProvider chunkProvider) {	
		switch(world.provider.getDimension()) {
		case 0://Overworld
			this.runGenerator(zinc_ore, world, random, chunkX, chunkZ, 20, 0, 75);
			this.runGenerator(antimony_ore, world, random, chunkX, chunkZ, 20, 0, 75);
			this.runGenerator(molybdenum_ore, world, random, chunkX, chunkZ, 20, 0, 75);
			this.runGenerator(copper_ore, world, random, chunkX, chunkZ, 20, 0, 64);
			this.runGenerator(tin_ore, world, random, chunkX, chunkZ, 20, 0, 64);
		case 1://End
		case -1://Nether
			this.runGenerator(chromite_ore, world, random, chunkX, chunkZ, 20, 0, 126);


And this is the Predicate classes (same code just different names and meta for each variant of stone):

package hazmatik.sonictech.worldgen;

import com.google.common.base.Predicate;

import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;

public class GranitePredicate implements Predicate<IBlockState> {

	public boolean apply(IBlockState input) {
		return input != null && input.getBlock() == Blocks.STONE.getStateFromMeta(1);


Any help would be appreciated.

Edited by Hazmatik
Link to comment
Share on other sites

Well....a Block will never equal an IBlockState...

Also, you shouldn't use getStateFromMeta, use getDefaultState().withProperty(...)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.


Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.


DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Im trying to make a moddes server with my friends but every single time we get same error https://pastebin.com/UP6P6YSd Is there a way to fix it? Thanks for solutions
    • Take a break, go for a walk. Then try again. 🙂
    • Where did you see that? Sorry if I am being a bother, it's just that I have been staring at this mod for a long time and I'm probably looking over a lot of things
    • Taking a look at AbstractContainerScreen.renderSlot() I got the following code: Method created in my AbstractContainerScreen class: private void renderCustomSlot(PoseStack poseStack,ItemStack itemstack,int x, int y) { boolean visible = true; boolean hover = false; this.setBlitOffset(100); this.itemRenderer.blitOffset = 100.0F; if (visible) { if (hover) { //Draw a rectangle behind the item fill(poseStack, x, y, x + 16, y + 16, -2130706433); } //Render item icon RenderSystem.enableDepthTest(); this.itemRenderer.renderAndDecorateItem(this.minecraft.player, itemstack, x, y, x + y * this.imageWidth); //Render item string count PoseStack posestack = new PoseStack(); if (itemstack.getCount() != 1) { String s = String.valueOf(itemstack.getCount()); posestack.translate(0.0D, 0.0D, itemRenderer.blitOffset + 200.0F); MultiBufferSource.BufferSource multibuffersource$buffersource = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); /* float scale; if (s.length()<3){ scale=1f; }else if (s.length()<4){ scale = 0.75f; }else { scale=0.5f; s = s.substring(0,s.length()-3)+"k"; } float compensatingScale = 1/scale; float stringX = (x + 19f - 2 - font.width(s)*scale)*compensatingScale; float stringY =(y + 6f + 3)*compensatingScale; posestack.scale(scale,scale,scale); */ float stringX = (x + 19f - 2 - font.width(s)); float stringY =(y + 6f + 3); font.drawInBatch(s,stringX,stringY,16777215, true, posestack.last().pose(), multibuffersource$buffersource, false, 0, 15728880); //posestack.scale(compensatingScale,compensatingScale,compensatingScale); multibuffersource$buffersource.endBatch(); } } this.itemRenderer.blitOffset = 0.0F; this.setBlitOffset(0); } Now it works correctly: Thanks to warjort for the tip!
    • Hello, I am currently trying to get a forge server setup so I can play the Pixelmon mod with some friends on a private server and have run into some issues with launching my forge server file, I downloaded the forge 12.2.2- installer, downloaded it into a folder on my desktop, ran the Mc server file, agreed to Eula, made a run.bat file to launch the forge server at 6GBs, and when I try launching I get this issue: Pixelmon Server>java -Xmx6144M -Xms6144M -jar forge-1.12.2- --nogui We appear to be missing one or more essential library files. You will need to add them to your server before FML and Forge will run successfully.java.lang.ClassNotFoundException: org.objectweb.asm.Type         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)         at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)         at java.base/java.lang.Class.forName0(Native Method)         at java.base/java.lang.Class.forName(Class.java:466)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:53)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34)   I've tried using another minecraft server jar file from a different source to see if that would solve anything but its still coming up with this issue. Any help is greatly appreciated, thanks for your help in advance.
  • Topics

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.