Jump to content

Recommended Posts

Posted (edited)

I'm having a serious issue with my ore generation, I'm attempting to generate certain ores in specific biomes but all I seem to get is EVERYTHING. 

nDZbIzY.png

 

Spoiler

package mikerman50.sc.worldgen;

import java.util.Random;

import mikerman50.sc.init.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockStateMatcher;
import net.minecraft.init.Biomes;
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 OreGen implements IWorldGenerator {

	public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider){
		switch (world.provider.getDimensionType())
		{
        case NETHER:
            generateNether(world, random, chunkX, chunkZ);
            break;
        case OVERWORLD:
            //Biome biome = world.getBiomeForCoordsBody(new BlockPos(chunkX * 16, 0, chunkZ * 16));
            generateOverworld(world, random, chunkX, chunkZ);
            break;

        case THE_END:
            generateEnd(world, random, chunkX, chunkZ);
            break;
            }
		}
	
	private void generateNether(World world, Random random, int worldX, int worldZ) {
    generateOre(ModBlocks.silverOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 40, 2, 8, 5);
}
//Utils.getLogger().info("added SimcraftOres");
    private void generateOverworld(World world, Random random, int worldX, int worldZ){
    
    int XX = worldX* 16;
	int ZZ = worldZ* 16;
	BlockPos pos = new BlockPos(XX, 70, ZZ);
	String biome = world.getBiomeForCoordsBody(pos).getBiomeName();//getWorldChunkManager().getBiomeGenAt(XX, ZZ);
    
    	//minY,maxY,minVein,maxVein,spawnChance
    	//Desert
    	if(Biomes.DESERT != null){//(biome, 2)){
            generateOre(ModBlocks.acanthiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 5);
            generateOre(ModBlocks.argentiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 40, 54, 2, 6, 100);
            generateOre(ModBlocks.bariteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
            generateOre(ModBlocks.cinnabarOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.corundumOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.pyrolusiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.aburstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.badalstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            generateOre(ModBlocks.carraramarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
            generateOre(ModBlocks.connemaramarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            System.out.print("Desert ores generated");
            System.out.println(pos.getX() + " " + pos.getY() + " " + pos.getZ());
        //Desert Hills
    	}
    	else if(Biomes.DESERT_HILLS != null){//.(biome, 17))
        {
        	generateOre(ModBlocks.corundumOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
        	generateOre(ModBlocks.pyrolusiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.aburstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.carraramarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
            System.out.print("Desert Hills ores generated");
        //Beach
        }
       if(Biomes.DESERT != null)
        {
        	generateOre(ModBlocks.sulfurOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
        	generateOre(ModBlocks.cinnabarOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.jasperstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.biancosivecmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            System.out.print("Beach ores generated");
        //Plains
        }
        if(Biomes.DESERT != null)
        {
        	generateOre(ModBlocks.boraxOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 55, 64, 2, 8, 100);
            generateOre(ModBlocks.bauxiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 40, 54, 2, 6, 100);
            generateOre(ModBlocks.berylOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
            generateOre(ModBlocks.leadOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.kimberliteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.manganeseOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.cahorsstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.darkverdestoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            generateOre(ModBlocks.creolemarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
            generateOre(ModBlocks.etowahmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            System.out.print("Plains ores generated");
        }

        //IcePlains
        if(Biomes.DESERT != null)
        	generateOre(ModBlocks.boraxOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 55, 64, 2, 8, 100);
        	generateOre(ModBlocks.berylOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
        	generateOre(ModBlocks.kimberliteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
        	generateOre(ModBlocks.cahorsstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
        	generateOre(ModBlocks.darkverdestoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
        	generateOre(ModBlocks.creolemarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
        	generateOre(ModBlocks.etowahmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
        	System.out.print("Ice Plains ores generated");
        //Forest
    	 }
        if(Biomes.DESERT != null)
        {
        	generateOre(ModBlocks.quartzOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 55, 64, 2, 8, 100);
            generateOre(ModBlocks.chalcociteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 40, 54, 2, 6, 100);
            generateOre(ModBlocks.chromiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
            generateOre(ModBlocks.talcOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.emeryOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.rubyOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.gabbrostoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.halifaxstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            generateOre(ModBlocks.pentelicmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
            generateOre(ModBlocks.purbeckmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);        
            System.out.print("Forest ores generated");
        }
        //ForestHills
        if(Biomes.DESERT != null)
        {
        	generateOre(ModBlocks.acanthiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 55, 64, 2, 8, 100);
            generateOre(ModBlocks.talcOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.emeryOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.rubyOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.gabbrostoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.pentelicmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
            System.out.print("Forest Hills ores generated");
        }
        //ExtremeHills
        if(Biomes.DESERT != null)
        {
        	generateOre(ModBlocks.lazuriteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 55, 64, 2, 8, 100);
            generateOre(ModBlocks.borniteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 40, 54, 2, 6, 100);
            generateOre(ModBlocks.cassiteriteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
            generateOre(ModBlocks.silverOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.malachiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.sulfideOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.elbanstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.famosastoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            generateOre(ModBlocks.murphymarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
            generateOre(ModBlocks.parianmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            System.out.print("Extreeme Hills ores generated");
        }
        //ExtremeHillsEdge
        if(Biomes.DESERT != null)
        {
            generateOre(ModBlocks.silverOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.famosastoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 8, 10, 100);
            generateOre(ModBlocks.parianmarbleOre.getDefaultState(), Blocks.DIRT, random, world, worldX, worldZ, 5, 64, 7, 12, 3);
            System.out.print("Extreme Hills Edge ores generated");
        }
        //IceMountains
        if(Biomes.DESERT != null)
        {
            generateOre(ModBlocks.molybdeniteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 55, 64, 2, 8, 100);
            generateOre(ModBlocks.seleniumOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.famosastoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 8, 10, 100);
            generateOre(ModBlocks.parianmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 7, 12, 3);
            System.out.print("Ice Mountains ores generated");
        }
        //Swampland
        if(Biomes.DESERT != null)
        {
        	generateOre(ModBlocks.sulfurOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 55, 64, 2, 8, 100);
            generateOre(ModBlocks.kyaniteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 40, 54, 2, 6, 100);
            generateOre(ModBlocks.hematiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
            generateOre(ModBlocks.limoniteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.uraniniteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.sulfideOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.kersantitestoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.languedocstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            generateOre(ModBlocks.ruskealamarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
            generateOre(ModBlocks.sylacaugamarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            System.out.print("SwampLand ores generated");
        }
        //Taiga
        if(Biomes.DESERT != null)
        {
        	generateOre(ModBlocks.bariumOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 55, 64, 2, 8, 100);
            generateOre(ModBlocks.galenaOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 40, 54, 2, 6, 100);
            generateOre(ModBlocks.cobaltiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
            generateOre(ModBlocks.ilmeniteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.ikraniteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.jadeiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.imperialstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.jasperstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            generateOre(ModBlocks.swedishgreenmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
            generateOre(ModBlocks.biancosivecmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
        }
        //TaigaHills
        if(Biomes.DESERT != null)
        {
        	generateOre(ModBlocks.bariumOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 55, 64, 2, 8, 100);
            generateOre(ModBlocks.cobaltiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
            generateOre(ModBlocks.ikraniteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.imperialstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.swedishgreenmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
        }
        //Ocean
        if(Biomes.DESERT != null)
        {
            generateOre(ModBlocks.molybdeniteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 40, 54, 2, 6, 100);
            generateOre(ModBlocks.pentlanditeOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
            generateOre(ModBlocks.apatiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.seleniumOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.azuriteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.macedonianstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.nashuastoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            generateOre(ModBlocks.tennesseemarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
            generateOre(ModBlocks.vermontmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
        }
        //FrozenOcean
        if(Biomes.DESERT != null)
        {
            generateOre(ModBlocks.pentlanditeOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
            generateOre(ModBlocks.apatiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.seleniumOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.azuriteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.macedonianstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.nashuastoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            generateOre(ModBlocks.tennesseemarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
            generateOre(ModBlocks.vermontmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
        }
        //Jungle
        if(Biomes.DESERT != null)
        {
        	generateOre(ModBlocks.scheeliteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 55, 64, 2, 8, 100);
            generateOre(ModBlocks.sphaleriteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 40, 54, 2, 6, 100);
            generateOre(ModBlocks.wolframiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 25, 39, 2, 8, 100);
            generateOre(ModBlocks.nephelineOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.coltanOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.dolomiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.oglesbystoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.painswickstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
            generateOre(ModBlocks.yulemarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 8, 100);
            generateOre(ModBlocks.wunsiedelmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
        }
        //JungleHills
        if(Biomes.DESERT != null)
        {
        	
            generateOre(ModBlocks.nephelineOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 18, 24, 2, 6, 100);
            generateOre(ModBlocks.dolomiteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 10, 17, 2, 8, 100);
            generateOre(ModBlocks.coltanOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 0, 9, 2, 6, 100);
            generateOre(ModBlocks.painswickstoneOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 60, 2, 8, 100);
            generateOre(ModBlocks.wunsiedelmarbleOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 5, 64, 2, 6, 100);
        }
        //River
        if(Biomes.DESERT != null)
        {
            generateOre(ModBlocks.rivergoldOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 40, 64, 10, 24, 100);
            generateOre(ModBlocks.rivergoldOre.getDefaultState(), Blocks.DIRT, random, world, worldX, worldZ, 50, 255, 7, 12, 100);
            generateOre(ModBlocks.rivergoldOre.getDefaultState(), Blocks.CLAY, random, world, worldX, worldZ, 50, 255, 7, 12, 100);
            
        }
        //FrozenRiver
        if(Biomes.DESERT != null)
        {
            generateOre(ModBlocks.rivergoldOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 40, 64, 10, 24, 100);
        }
        
      //HEll
        if(Biomes.DESERT != null)
        {
            generateOre(ModBlocks.cassiteriteOre.getDefaultState(), Blocks.NETHERRACK, random, world, worldX, worldZ, 40, 64, 10, 24, 100);
        }
        //Sky
        if(Biomes.DESERT != null)
        {
            generateOre(ModBlocks.cassiteriteOre.getDefaultState(), Blocks.STONE, random, world, worldX, worldZ, 40, 64, 10, 24, 100);
            
        }
        //Everywhere
        if(Biomes.DEFAULT != null)
        {
        	}
        }	
   	public void generateEnd(World world, Random rand, int worldX, int worldZ){
        generateOre(ModBlocks.cassiteriteOre.getDefaultState(), Blocks.STONE, rand, world, worldX, worldZ, 40, 64, 10, 24, 100);
   	}                                                                                 //minY,maxY,minVein,maxVein,spawnChance
		private void generateOre(IBlockState state,  Block generateIn, Random random, World world, int chunkX, int chunkZ, 
				int minY, int maxY, int minVeinSize, int maxVeinSize, int chance){
			int vienSize = minVeinSize + random.nextInt(maxVeinSize - minVeinSize);
			int heightRange = maxY - minY + 1;
            WorldGenMinable gen = new WorldGenMinable(state, vienSize, BlockStateMatcher.forBlock(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);
    			//Block testblock = world.getBlock(xRand, yRand, zRand);
    			BlockPos pos = new BlockPos(xRand, yRand, zRand);
    			
    			gen.generate(world, random, pos);
        }
    }
  }

Code here

 

 

Edited by Mikerman50
PROBLEM SOLVED.
Posted
String biome = world.getBiomeForCoordsBody(pos).getBiomeName();

And you do dick with this value.

if(Biomes.DESERT != null)

This will never be false.

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.

Posted
2 minutes ago, Differentiation said:

May I ask how in the world do you have the time to create ALL those new ores? xD

we've had all these ores since 1.2.5, last public release was in 1.6.4 main dev left, I picked up the pieces ( I can't code) 

Posted
3 hours ago, Mikerman50 said:

we've had all these ores since 1.2.5, last public release was in 1.6.4 main dev left, I picked up the pieces ( I can't code) 

Oh...

You should've made biome return Biomes, not String.

Just a small tip!

Posted
7 minutes ago, Differentiation said:

Oh...

You should've made biome return Biomes, not String.

Just a small tip!

Wrong. It should be Biome. Your advice is like saying "when you get a block, you want the variable to be Blocks."

 

Biome is the object, Biomes is where the game holds a reference to each biome.

  • Like 1

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.

Posted
Just now, Draco18s said:

Wrong. It should be Biome. Your advice is like saying "when you get a block, you want the variable to be Blocks."

 

Biome is the object, Biomes is where the game holds a reference to each biome.

Well I don't know the exact class...... but somewhere close.

Posted (edited)
On 10/21/2017 at 1:48 PM, Mikerman50 said:

I'm having a serious issue with my ore generation

Next time you get inexplicable run-time behavior, step through your code at least once in the debugger before running for help. You'd see something like a test that's always true before posting it.

 

On 10/21/2017 at 3:27 PM, Mikerman50 said:

main dev left, I picked up the pieces ( I can't code) 

You really don't want to admit that around here (see the warnings on the forum and in mods' signatures).  Find someone near you to help with programming and Eclipse (or other IDE) expertise so that the problems you bring here will be specific to the idiosyncrasies of Minecraft and Forge.

Edited by jeffryfisher

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

HI, thanks for your reply, I have spent several hours daily running through different possible causes, cant say that the debug on eclipse helps me at all.  it just runs like normal.

 

I'm not one to care what people put in their signatures, unfortunately I fall into a category a "Kinesthetic learner". so anyone that goes and says learn has no idea of how difficult it is.

 

I'm not looking for all the answers, just pointers, it's nothing new what i'm looking for, it's just rare to find anything that has been done recently. 

Posted
46 minutes ago, Mikerman50 said:

HI, thanks for your reply, I have spent several hours daily running through different possible causes, cant say that the debug on eclipse helps me at all.  it just runs like normal.

Add breakpoints.

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.

Posted
49 minutes ago, Mikerman50 said:

HI, thanks for your reply, I have spent several hours daily running through different possible causes, cant say that the debug on eclipse helps me at all.  it just runs like normal.

 

There are two types of debug. First you can use the debug mode of Eclipse (along with breakpoints as mentioned). The problem with this method is that anything that takes a long time or takes specific gameplay can be difficult to capture because if the breakpoint happens every tick you won't be able to play the game. 

 

So the alternative is to simply use console (or logger) print statements. In each of your functions put a print statement that (a) proves which code path is executing (b) prints out any important field values.

 

Both of these methods essentially "trace" the code execution. Since computers are purely logical, by careful tracing you can always debug easily. You should see right away whether it is generating different ores than you expect, you should be able to trace that back to what biome it thinks it is in, and so forth.

 

The key point is that programmers don't really debug by reading code (especially other people's code), rather they trace the execution and also create alternative versions of the code to help isolate the problem. It will really help your modding (and general programming) ability to get used to tracing your code.

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
2 minutes ago, jabelar said:

So the alternative is to simply use console (or logger) print statements. In each of your functions put a print statement that (a) proves which code path is executing (b) prints out any important field values.

 

You should see right away whether it is generating different ores than you expect, you should be able to trace that back to what biome it thinks it is in, and so forth.

Thanks for this reply Jabelar, you did some great tutorials in the past. 

 

I shall have a look into break points, I have several paperback versions on learn to program in 24 hours from Cadence but its just not my learning style annoyingly,  as I've said. I'm sure the answer is obvious for someone out there

Posted
On 10/24/2017 at 0:25 PM, Mikerman50 said:

cant say that the debug on eclipse helps me at all.  it just runs like normal.

Sorry, I've been doing this so long that I forgot how special words like "step" might have no meaning to someone who has never used a debugger before. "Step" implies setting and triggering a breakpoint, and then using the debugger's step controls to execute one line or method call at a time. You can step into or over each line of the program, and at each line, you can examine all of the currently set fields and local variables.

 

This forum teaches Minecraft and Forge. It is not a Java help desk, never mind being an intro to programming class. If I understand that correctly, it means that you should know how to use the essential tools of programming, which include the debugger, hence my signature.

 

There's lots online about Eclipse. You should be able to find several video tutorials on how to use the debugger. Fire up your own Eclipse, play an Eclipse tutorial video, and follow along.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

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