Jump to content

[1.10.2] World Gen... AND now blockstates too!


EscapeMC

Recommended Posts

Ok, so I am on the last thing I need. I am working on world_gen currently, and I for some reason cannot get it to work!

 

world_gen class:

package com.escapemc.teammadnessmod.world;

import java.util.Random;

import com.escapemc.teammadnessmod.init.ModBlocks;

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 world_gen implements IWorldGenerator {

@Override
    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {   
    switch (world.provider.getDimension()) {
    case 0: //Overworld
        this.runGenerator(this.gen_escapemc_ore, world, random, chunkX, chunkZ, 8, 0, 64);
        this.runGenerator(this.gen_mushrromstew_ore, world, random, chunkX, chunkZ, 8, 0, 64);
        this.runGenerator(this.gen_epicbudder22_ore, world, random, chunkX, chunkZ, 8, 0, 64);
        this.runGenerator(this.gen_jonahjoe2002_ore, world, random, chunkX, chunkZ, 8, 0, 64);
        this.runGenerator(this.gen_ms, world, random, chunkX, chunkZ, 6, 0, 40);
        this.runGenerator(this.gen_madness_ore, world, random, chunkX, chunkZ, 6, 0, 64);
        
        break;
    case -1: //Nether

        break;
    case 1: //End

        break;
    	}
    }
    private WorldGenerator gen_escapemc_ore;
    private WorldGenerator gen_mushrromstew_ore;
    private WorldGenerator gen_epicbudder22_ore;
    private WorldGenerator gen_jonahjoe2002_ore;
    private WorldGenerator gen_ms;
    private WorldGenerator gen_madness_ore;


    public world_gen() {
        this.gen_escapemc_ore = new WorldGenMinable(ModBlocks.escapemc_ore.getDefaultState(), ;
        this.gen_mushrromstew_ore = new WorldGenMinable(ModBlocks.mushrromstew_ore.getDefaultState(), ;
        this.gen_epicbudder22_ore = new WorldGenMinable(ModBlocks.epicbudder22_ore.getDefaultState(), ;
        this.gen_jonahjoe2002_ore = new WorldGenMinable(ModBlocks.jonahjoe2002_ore.getDefaultState(), ;
        this.gen_ms = new WorldGenMinable(ModBlocks.ms.getDefaultState(), 4);
        this.gen_madness_ore = new WorldGenMinable(ModBlocks.madness_ore.getDefaultState(), 4);

    }

    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));
        }
    }

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
		IChunkProvider chunkProvider) {

}
}

 

Do note, eclipse tells me to remove the @Override annotation at the top-area. Without it anyway, world gen does not take place for my ores.

 

 

I registered it in the init method as well with

	    GameRegistry.registerWorldGenerator(new world_gen(), 0);

 

What am I missing?

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

The generate method you are using has got the param IChunkGenerator put as an IChunkProvider, change it and it should work, and also remove the bottom generate method

 

Oh goodness thank you! I cannot believe I looked over that xD

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Whelp I changed that, and now where ever the ores should be, there are empty air blocks, and i cannot go through them, but they are destroyed...

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Alright, so I might have found the problem?

 

I noticed whenever I place a block, it has the purple-black texture. Might this be the problem?

The item itself in my hand is normal, so is it the blockstate?

Example of my blockstate:

{
    "variants": {
        "normal": { "model": "tmm:madness_ore" }
    }
}

 

This is for all blocks too by the way.

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Do note, eclipse tells me to remove the @Override annotation at the top-area. Without it anyway, world gen does not take place for my ores.
In 99% of cases the fix is not to remove the annotation.

 

This is because Eclipse cannot determine what the correct method signature is.

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

As for your model thing, post your Block code and the console log.

 

Block code:

package com.escapemc.teammadnessmod.blocks;

import com.escapemc.teammadnessmod.Reference;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

public class madness_ore extends Block {

public madness_ore(Material materialIn) {
	super(materialIn);
	this.setHardness(0.6F);
	this.setHarvestLevel("pickaxe", 3);
	this.setResistance(15);

	setUnlocalizedName(Reference.ModItems.MADNESS_ORE.getUnlocalizedName());
	setRegistryName(Reference.ModItems.MADNESS_ORE.getRegistryName());

}

}

 

Model Block:

{
    "variants": {
        "normal": { "model": "tmm:madness_ore" }
    }
}

Model Item:

{
    "parent": "block/cube_all",
    "textures": {
        "all": "tmm:blocks/madness_ore"
    }
}

 

Blockstate:

{
    "variants": {
        "normal": { "model": "tmm:madness_ore" }
    }
}

 

ModBlock.java class:

package com.escapemc.teammadnessmod.init;

import com.escapemc.teammadnessmod.Main;
import com.escapemc.teammadnessmod.blocks.cdm;
import com.escapemc.teammadnessmod.blocks.epicbudder22_ore;
import com.escapemc.teammadnessmod.blocks.escapemc_ore;
import com.escapemc.teammadnessmod.blocks.jonahjoe2002_ore;
import com.escapemc.teammadnessmod.blocks.madness_ore;
import com.escapemc.teammadnessmod.blocks.ms;
import com.escapemc.teammadnessmod.blocks.mushrromstew_ore;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ModBlocks {


public static Block escapemc_ore;
public static Block mushrromstew_ore;
public static Block epicbudder22_ore;
public static Block jonahjoe2002_ore;


public static Block ms;
public static Block cdm;
public static Block madness_ore;


public static void init() {


	escapemc_ore = new escapemc_ore(Material.IRON).setCreativeTab(Main.TeamMadnessModMaterialsTab);
	mushrromstew_ore = new mushrromstew_ore(Material.IRON).setCreativeTab(Main.TeamMadnessModMaterialsTab);
	epicbudder22_ore = new epicbudder22_ore(Material.IRON).setCreativeTab(Main.TeamMadnessModMaterialsTab);
	jonahjoe2002_ore = new jonahjoe2002_ore(Material.IRON).setCreativeTab(Main.TeamMadnessModMaterialsTab);

	ms = new ms(Material.IRON).setCreativeTab(Main.TeamMadnessModMaterialsTab);
	cdm = new cdm(Material.IRON).setCreativeTab(Main.TeamMadnessModMaterialsTab);
	madness_ore = new madness_ore(Material.IRON).setCreativeTab(Main.TeamMadnessModMaterialsTab);


}

public static void registry() {

	GameRegistry.register(new ItemBlock(escapemc_ore), escapemc_ore.getRegistryName());
	GameRegistry.register(new ItemBlock (mushrromstew_ore), mushrromstew_ore.getRegistryName());
	GameRegistry.register(new ItemBlock(epicbudder22_ore), epicbudder22_ore.getRegistryName());
	GameRegistry.register(new ItemBlock(jonahjoe2002_ore), jonahjoe2002_ore.getRegistryName());

	GameRegistry.register(new ItemBlock(ms), ms.getRegistryName());		
	GameRegistry.register(new ItemBlock(cdm), cdm.getRegistryName());
	GameRegistry.register(new ItemBlock(madness_ore), madness_ore.getRegistryName());


}


public static void registerBlock(Block block) {

	GameRegistry.register(block);
	ItemBlock item = new ItemBlock(block);
	item.setRegistryName(block.getRegistryName());
	GameRegistry.register(item);



}



public static void registerRenders() {

	registerRender(escapemc_ore);
	registerRender(mushrromstew_ore);
	registerRender(epicbudder22_ore);
	registerRender(jonahjoe2002_ore);

	registerRender(ms);
	registerRender(cdm);
	registerRender(madness_ore);

}

@SideOnly(Side.CLIENT)
public static void registerRender(Block block) {

    ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
    
    
}




}

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

 

package com.escapemc
You do not own that domain.

 

Then what exactly should I make it? I really have no idea... It just seemed to be the default thing that people do.

 

EDIT: Should I just get rid of com.?

 

public class madness_ore extends Block {
Please follow the Java naming conventions.

 

What should I make these then? I have used these all my coding time, and no one has said anything... also, doesn't 1.11 force you to use lowerCase?

 

 

And as to the blockstate thing, whelp, *facepalm* thanks

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

What should I make these then? I have used these all my coding time, and no one has said anything...
Java suggests UpperCamelCase for class names, so in your case it would be
MadnessOre

.

 

Also called TitleCase.

 

OreMadness, BlockMadnessOre, BlockOreMadness would also be good names ("Block" to match the existing naming convention of Minecraft, BlockStone, BlockDoor, etc.) as well as if you'd like to denote your ores by calling them "BlockOre[x]" or "Block[x]Ore"

 

I favor the former (it puts all ore blocks near each other when sorted alphabetically) whereas the latter reads more naturally.

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.

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.



×
×
  • Create New...

Important Information

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