Jump to content

Recommended Posts

Posted

Hello guys, I am here to ask you for help about my mod.

Ok, so I tried to create a flower who spawn in the biome Forest per exemple.

 

That is my code :

package fr.troox.nezylia.init;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.common.BiomeManager.BiomeType;

public class FlowerMod 
{
    public static void init()
    {
        BiomeManager.getBiomes(BiomeType.COOL);
        
    }
    
    public void generate(Random random, int chunkX, int chunkZ, World world,
    IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
    {
        int x = chunkX * 16;
        int z = chunkZ * 16;
        
        BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
        
        if(BiomeDictionary.isBiomeOfType(biome, Type.FOREST))
        {
            
        }
    }
    
}

Im not sure but I think is not that. And I don't know what I should to do for a generation of already existing biome exist.

 

Thank you in advance for your help.

Posted

Well, what you probably actually want is if(biome == Biomes.FOREST)

The code you have now will spawn your flower in any forest: forest, birch forest, tiaga, etc.

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
12 hours ago, Draco18s said:

Well, what you probably actually want is if(biome == Biomes.FOREST)

The code you have now will spawn your flower in any forest: forest, birch forest, tiaga, etc.

Sorry for my late message, I didn't see ... So If I understand what you say, I just need to to make if(biome == Biomes.FOREST) for one biome ?

 

But How I generate flower on minecraft (map) please ?

 

Thank you in advance !

Posted

It will match only the forest biome, yes.

As for generating flowers, world.setBlockState(...) does amazing things.

 

If you're asking how to spawn flowers the way vanilla spawns flowers, I suggest looking for the code vanilla uses to spawn flowers.

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
13 minutes ago, Draco18s said:

It will match only the forest biome, yes.

As for generating flowers, world.setBlockState(...) does amazing things.

 

If you're asking how to spawn flowers the way vanilla spawns flowers, I suggest looking for the code vanilla uses to spawn flowers.

Ok, I will try this method, thank you ;)

Posted (edited)

Humm world.setBlockState does not exist, can you make me an exemple please ?

 

That is my code : 

package fr.troox.nezylia.world;

import java.util.Random;

import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.common.BiomeManager.BiomeType;

public class WorldFlowers 
{
    public static void init()
    {
        
    }
    
    public void generate(Random random, int chunkX, int chunkZ, World world,
    IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
    {
        int x = chunkX * 16;
        int z = chunkZ * 16;
        
        BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
        
        if(biome == biome.forest)
        {
            world.setBlock(p_147449_1_, p_147449_2_, p_147449_3_, p_147449_4_);
        }
    }
    
}

Thank you !

@Draco18s

Edited by Trooox
Posted

setBlockState doesn't exist because you're using an older version of Minecraft.

You should probably update.

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

But I prefer to play in 1.7.10, I found : 

 

 public void generate(Random random, int chunkX, int chunkZ, World world,
    IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
    {
        for(int i = 0; i < 2; i++)
        {
         int randPosX = chunkX + random.nextInt(16) + 8;
         int randPosY = random.nextInt(256);
         int randPosZ = chunkZ + random.nextInt(16) + 8;
         (new WorldGenFlowers(BlockMod.flowertest)).generate(world, random, randPosX, randPosY, randPosZ);
        }
    }

That can work no ?

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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