Jump to content

Recommended Posts

Posted

I created a new flower for my mod and I can generate it in a custom biome but how do I generate it so it spawns on biomes already in the game? Also is there a forge hook that allows a custom flower to spawn when bonemeal is used on grass? I'll be thankful for any help.

Posted

Ahoj. :)

 

I was hesitant to post this at first, because, knowing my coding habits, this is probably the worst way to do something like this. You have been extremely patient though, so I'll give you something you can at least start on.

 

 

You can use this:

 

                        BiomeGenBase biomegenbase = world.getWorldChunkManager().getBiomeGenAt(chunkX, chunkZ);

                        if(biomegenbase instanceof BiomeGenPlains)

 

and then your "for loop"

 

 

I hope this helps a bit. :)

 

--Tenyar

 

Posted

I'm at a loss when it comes to fixing things in forge. Should it look like this?

                BiomeGenBase biomegenbase = world.getWorldChunkManager().getBiomeGenAt(firstBlockXCoord, firstBlockZCoord);
                if(biomegenbase instanceof BiomeGenDesert)
            	for(int l = 0; l < 10; l++){
            		int x = i + random.nextInt(16);
                	int y = random.nextInt(30);
                	int z = j + random.nextInt(16);
                	(new WorldGenMinable(PenguinMod.flowerPineapple.blockID, 4)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
            	}

Posted

Just don't check for a biome at all. Also, tweak your block so that it can spawn on anything. Unless you don't want it to spawn on everything, just make it spawn on BlockGrass. Most other mods' grass blocks will extend BlockGrass.

Kain

Posted

Make a seperate class for your flower.

 

It will look something like this...

 

http://pastebin.com/iUKqa9Lw

 

 

and then change

(new WorldGenMinable(PenguinMod.flowerPineapple.blockID, 4)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);

           

to

 

(new WorldGenYourFlower()).generate(world, random, RandPosX, RandPosY, RandPosZ);

       

Like I said, I have bad habits. I don't always do things the "best" or "most efficient" way. If it works; it works. I guess thats what happens when you are almost entirely self taught. ¯\_(ツ)_/¯

 

 

EDIT: ^ What GoTo said. Hi GoTo. :)

Posted

As far as I'm aware the code is correct an I have no errors but the pineapple won't spawn. Is anything wrong with my code? Thanks for all the help so far.

 

WorldGenPineapple

package TylerWatson.Mod;

import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;

public class WorldGenPineapple extends WorldGenerator
{
public boolean generate(World par1World, Random par2Random, int X, int Y, int Z)
{
	if (par1World.isAirBlock(X, Y, Z) && PenguinMod.flowerPineapple.canBlockStay(par1World, X, Y, Z))
	par1World.setBlock(X, Y, Z, PenguinMod.flowerPineapple.blockID);

	return true;
}
}

 

PenguinWorldGenerator:

package TylerWatson.Mod;

import java.util.Random;

import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeGenDesert;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;

public class PenguinWorldGenerator implements IWorldGenerator {

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

	switch(world.provider.dimensionId){
	case -1:
	    generateNether(world, random, chunkX * 16, chunkZ * 16);
	    break;
	case 0:
	    generateSurface(world, random, chunkX * 16, chunkZ * 16);
	    break;
	case 1:
	    generateEnd(world, random, chunkX * 16, chunkZ * 16);
	    break;
	}
}

private void generateEnd(World world, Random random, int i, int j) {

}

private void generateSurface(World world, Random random, int i, int j) {
        for(int k = 0; k < 5; k++){
        	int firstBlockXCoord = i + random.nextInt(16);
        	int firstBlockYCoord = random.nextInt(30);
        	int firstBlockZCoord = j + random.nextInt(16);
        	(new WorldGenMinable(PenguinMod.quicksilverOre.blockID, 3)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
        
        	for(int p = 0; p < 10; p++){
        		int x = i + random.nextInt(16);
            	int y = random.nextInt(30);
            	int z = j + random.nextInt(16);
            	(new WorldGenMinable(PenguinMod.copperOre.blockID, 5)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
        	}
                for(int q = 0; q < 10; q++){
                	int x = i + random.nextInt(16);
                	int y = random.nextInt(30);
                	int z = j + random.nextInt(16);
                	(new WorldGenMinable(PenguinMod.cobaltOre.blockID, 4)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
            }
            	for(int l = 0; l < 10; l++){
            		int x = i + random.nextInt(16);
                	int y = random.nextInt(30);
                	int z = j + random.nextInt(16);
                	(new WorldGenMinable(PenguinMod.rubyOre.blockID, 4)).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
            	}
            	for(int c = 0; c < 10; c++){
            		int x = i + random.nextInt(16);
                	int y = random.nextInt(30);
                	int z = j + random.nextInt(16);
                	(new WorldGenPineapple()).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
            	}
        	}
}

private void generateNether(World world, Random random, int i, int j) {

}

}

 

FlowerPineapple:

package TylerWatson.Mod;

import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;

public class FlowerPineapple extends BlockFlower{

public FlowerPineapple(int par1) {
	super(par1);
}
    public boolean canThisPlantGrowOnThisBlockID(int par1)
    {
        return par1 == Block.grass.blockID || par1 == Block.dirt.blockID || par1 == Block.sand.blockID;
    }

}

Posted

I think I have your solution.

 

First, where are you getting "firstBlockXCoord, firstBlockYCoord, firstBlockZCoord" from? How is Eclipse not screaming at you? Switch them out for "x, y, z" respectively.

 

Second, change the number in "for(int c = 0; c < 10; c++)" to something higher, like.. "for(int c = 0; c < 80; c++)"

 

 

--Tenyar

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

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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