Jump to content

[1.7.10] generate seaweed underwater instead of clay using BiomeDecorator


Glistre

Recommended Posts

Trying to make my custom seaweedgenerate in place of the clay block in my custom Glistering  biome.

 

I created a new WorldGenSeaweed class for seaweed modeled after WorldGenClay class.  I created a new BiomeDecorator class called BiomeDecoratorGlistre, and trying to generate my Seaweed block instead of Blocks.clay.

 

Cannot seem to get it to work

 

WorldGenSeaweed:

 

package com.glistre.glistremod.biome;

import java.util.Random;

import com.glistre.glistremod.BlockRegistry;
import com.glistre.glistremod.MyBlock;
import com.glistre.glistremod.atlantis.BlockSeaweed;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenClay;
import net.minecraft.world.gen.feature.WorldGenerator;

public class WorldGenSeaweed extends WorldGenClay
{
    public BlockSeaweed fieldseaweed;
    /** The number of blocks to generate. */
    private int numberOfBlocks;
//   private static final String __OBFID = "CL_00000405";

    public WorldGenSeaweed(int p_i2011_1_)
    {
    	super(p_i2011_1_);
        this.fieldseaweed = (BlockSeaweed) BlockRegistry.blockSeaweed;
        this.numberOfBlocks = p_i2011_1_;
//        this.numberOfBlocks = 16;
    }

    public boolean generate(World world, Random random, int par2, int par3, int par4)
    {
        if (world.getBlock(par2, par3, par4).getMaterial() != Material.water)
        {
            return false;
        }
        else
        {
            int l = random.nextInt(this.numberOfBlocks - 2) + 2;
            byte b0 = 1;

            for (int i1 = par2 - l; i1 <= par2 + l; ++i1)
            {
                for (int j1 = par4 - l; j1 <= par4 + l; ++j1)
                {
                    int k1 = i1 - par2;
                    int l1 = j1 - par4;

                    if (k1 * k1 + l1 * l1 <= l * l)
                    {
                        for (int i2 = par3 - b0; i2 <= par3 + b0; ++i2)
                        {
                            Block block = world.getBlock(i1, i2, j1);

                            if (block == Blocks.dirt || block == Blocks.sand || block == Blocks.gravel || block == Blocks.clay)
                            {
                                world.setBlock(i1, i2, j1, this.fieldseaweed, 0, 2);
                            }
                        }
                    }
                }
            }

            return true;
        }
    }
}

 

BiomeDecoratorGlistre:

 

package com.glistre.glistremod.biome;

import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.CLAY;

import java.util.Random;

import com.glistre.glistremod.BlockRegistry;
import com.glistre.glistremod.GlistreBiome;

import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenClay;
import net.minecraft.world.gen.feature.WorldGenLiquids;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
import net.minecraftforge.event.terraingen.TerrainGen;

public class BiomeDecoratorGlistre extends BiomeDecorator
{
 /** The world the BiomeDecorator is currently decorating */
    public World currentWorld;
    /** The Biome Decorator's random number generator. */
    public Random randomGenerator;
    /** The X-coordinate of the chunk currently being decorated */
    public int chunk_X;
    /** The Z-coordinate of the chunk currently being decorated */
    public int chunk_Z;
    public int seaweedPerChunk;
    /** The clay/seaweed generator. */
//    public WorldGenerator clayGen = new WorldGenClay(4);
   //added next two lines no idea if will work 
    public WorldGenerator seaweedGen = new WorldGenSeaweed(2);


public BiomeDecoratorGlistre()
{
	super();
//		seaweedPerChunk = new WorldGenSeaweed(16);
	seaweedGen = new WorldGenSeaweed(2);
	this.seaweedPerChunk = 1600;

}

@Override
public void decorateChunk(World p_150512_1_, Random p_150512_2_, BiomeGenBase p_150512_3_, int p_150512_4_,
		int p_150512_5_) {
	super.decorateChunk(p_150512_1_, p_150512_2_, p_150512_3_, p_150512_4_, p_150512_5_);
	 if (this.currentWorld != null)
        {
            throw new RuntimeException("Already decorating!!");
        }
        else
        {
            this.currentWorld = p_150512_1_;
            this.randomGenerator = p_150512_2_;
            this.chunk_X = p_150512_4_;
            this.chunk_Z = p_150512_5_;
            this.genDecorations(p_150512_3_);
            this.currentWorld = null;
            this.randomGenerator = null;
        }
}

@Override
protected void genDecorations(BiomeGenBase p_150513_1_) {
	super.genDecorations(p_150513_1_);
	MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z));
        this.generateOres();
        int i;
        int j;
        int k;
        int i1;
        int l;

//       boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND);
       boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CLAY);
        for (j = 0; doGen && j < this.seaweedPerChunk; ++j)
//        	for (j = 0; doGen && j < this.deadBushPerChunk; ++j)
        	{
        	k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
        	l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
        	i1 = this.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
//           (new WorldGenSeaweed()).generate(this.currentWorld, this.randomGenerator, k, l, i1);
        	(new WorldGenSeaweed(2)).generate(this.currentWorld, this.randomGenerator, k, i1, l);
        	
//         this.seaweedGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(k, i1), l);
        	MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z));

        	
        	}
        	}
        
        private int nextInt(int i) {
        	if (i <= 1)
        	return 0;
        	return this.randomGenerator.nextInt(i);

}

}

 

CustomBiome  glistering Biome:

 

package com.glistre.glistremod;

import java.util.Random;

import com.glistre.glistremod.biome.BiomeDecoratorGlistre;
import com.glistre.glistremod.biome.WaterGeneration;
import com.glistre.glistremod.biome.WorldGenSeaweed;
import com.glistre.glistremod.entities.EntityTobieSkel;

import net.minecraft.block.Block;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenClay;
import net.minecraft.world.gen.feature.WorldGenHugeTrees;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenTaiga2;
import net.minecraft.world.gen.feature.WorldGenTallGrass;
import net.minecraft.world.gen.feature.WorldGenerator;

public class GlistreBiome extends BiomeGenBase
{
BiomeDecoratorGlistre customBiomeDecorator;
    public GlistreBiome(int id)
    {
        super(id);
        
        this.setBiomeName("Glistering Biome");
        this.topBlock = Blocks.grass;
	this.fillerBlock = Blocks.dirt;
	this.theBiomeDecorator = new BiomeDecoratorGlistre();
	customBiomeDecorator = new BiomeDecoratorGlistre();
	customBiomeDecorator =(BiomeDecoratorGlistre)theBiomeDecorator;
	this.theBiomeDecorator = this.createBiomeDecorator();
	this.customBiomeDecorator.seaweedPerChunk = 1600;
	this.customBiomeDecorator.seaweedGen = new WorldGenSeaweed(2);
	this.theBiomeDecorator.clayPerChunk = 2;

	//		customBiomeDecorator.seaweedGen = 2;
        
/*        this.theBiomeDecorator.treesPerChunk = 2;
        this.theBiomeDecorator.waterlilyPerChunk = 300;
        this.theBiomeDecorator.bigMushroomsPerChunk = 1;
        this.theBiomeDecorator.reedsPerChunk = 10;
        this.theBiomeDecorator.grassPerChunk = 10;*/
//        this.customBiomeDecorator.seaweedGen = new WorldGenSeaweed(16);



       
        

        this.spawnableCreatureList.add(new SpawnListEntry(EntityOcelot.class, 2, 1, 1));      
        this.spawnableCreatureList.add(new SpawnListEntry(EntityHorse.class, 2, 5, 7));
        this.spawnableCreatureList.add(new SpawnListEntry(EntityPig.class, 1, 2, 7));     
        this.spawnableMonsterList.add(new SpawnListEntry(EntitySkeleton.class, 1, 1, 1));
        this.spawnableMonsterList.add(new SpawnListEntry(EntityZombie.class, 2, 1, 2));
        this.spawnableCreatureList.add(new SpawnListEntry(EntityGlistreWolf.class, 1, 1, 5));
        this.spawnableCreatureList.add(new SpawnListEntry(EntityTobieSkel.class, 10, 3, 7));
        this.spawnableCreatureList.clear();
        this.spawnableWaterCreatureList.clear();
        this.spawnableMonsterList.clear();        
//this.spawnableMonsterList.add(new SpawnListEntry(EntityWitch.class, 200, 1, 1));
    
        this.addFlower(Blocks.red_flower, 4, 3);
        this.addFlower(Blocks.pumpkin, 7, 20);
//       this.addFlower(Blocks.red_flower, 5, 3);       
//        this.addFlower(Blocks.red_flower, 7, 3);       
//       this.addFlower(Blocks.red_flower, 0, 20);       
//      this.addFlower(Blocks.yellow_flower, 0, 30);

        
//       this.setColor(0x7F007F);
//        this.setColor(0x443333);
        this.setColor(0x003000);
        this.setEnableSnow();
        this.setMinMaxHeight(0.7F, 1.1F);
        this.setTemperatureRainfall(0.75F, .25F);
       
    }
    
/*   public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_)
    {
        super.genTerrainBlocks(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_);
    } */
/*	@Override
public BiomeGenBase.TempCategory getTempCategory()
{
	return TempCategory.COLD;
}*/



private void setMinMaxHeight(float f, float g) 
{

}
//    @SideOnly(Side.CLIENT)
/*   public int getBiomeGrassColor()
    {
    	return 0x443333;
    }
//   @SideOnly(Side.CLIENT)
    public int getBiomeFoliageColor()
    {
    	return 0x443333;
    }*/
//   @SideOnly(Side.CLIENT)
    public int getSkyColorByTemp(float par1)
    {
    	return 0x443333;
    }

    /**
     * Gets a WorldGen appropriate for this biome.
    */ 
/*this is supposed to have WorldGenTallGrass not Water Generation block.seaweed{
BiomeGenBase b = world.getBiomeGenForCoords(i, j);
if(b.biomeName.equals("biomeGlistre")) {*/
    
    public WorldGenerator getRandomWorldGenForGrass(Random random){
        return random.nextInt(2) == 0 ? new WaterGeneration(BlockRegistry.blockSeaweed, 1) : new WorldGenTallGrass(BlockRegistry.blockSeaweed, 2);
        
    }
    public WorldGenerator getRandomWorldGenForTrees(Random par1Random){
    	return(WorldGenerator)(par1Random.nextInt(1) == 0 ? this.worldGeneratorBigTree : (par1Random.nextInt(6) == 0 ? this.worldGeneratorSwamp : par1Random.nextInt(20) == 0 ? this.worldGeneratorTrees : this.worldGeneratorTrees));
    }

    public void generateSurface (World world, Random random, int i, int j){
    
    	for(int f = 0; f <20; f++);{
    	int x = i + random.nextInt(16);
    	int y = random.nextInt(128);
    	int z = j + random.nextInt(16);
    	new WaterGeneration(BlockRegistry.blockSeaweed, 20).generate(world, random, x, y, z);
    	}
    	}

             
       

}
    /** Adds Huge Trees to your Biome */
/*   public WorldGenerator getRandomWorldGenForTrees(Random random)
   {
        return (WorldGenerator)
        new WorldGenHugeTrees(false, 20 + random.nextInt(10), 1, 3, 3);
        }
      /*   Wood/Leaf Metadata: 0=Oak, 1=Spruce, 2=Birch, 3=Jungle Wood */
    

 

Any ideas? Would I have to create a new event instead of using the CLAY event?  Or is there something really obvious I am missing?

Link to comment
Share on other sites

I changed

  public WorldGenerator getRandomWorldGenForGrass(Random random){
        return random.nextInt(2) == 0 ? new WaterGeneration(BlockRegistry.blockSeaweed, 1) : new WorldGenTallGrass(BlockRegistry.blockSeaweed, 2); 

 

to

    public WorldGenerator getRandomWorldGenForGrass(Random random){
        return random.nextInt(2) == 0 ? new WaterGeneration(BlockRegistry.blockSeaweed, 2) : new WorldGenSeaweed(3);

 

and it did generate a small amount of seaweed but only like five blocks.  I am not sure why. . . it looks like it was already working but just very, very, very small amount of seaweed .

 

So, I know I do not need to add a "SEAWEED" event and the CLAY event might be okay. .

 

I still need way more seaweed though

 

UPDATE:  increased the frequency of the seaweed substantially --changed the "number of blocks of my WaterGen class from 10 to 2000 :  my code now looks like this :

    public WorldGenerator getRandomWorldGenForGrass(Random random){
       return random.nextInt(2) == 0 ?  new WorldGenSeaweed(3) : new WorldGenSeaweed(10);
        
   }
    public WorldGenerator getRandomWorldGenForTrees(Random par1Random){
    	return(WorldGenerator)(par1Random.nextInt(1) == 0 ? this.worldGeneratorBigTree : (par1Random.nextInt(6) == 0 ? this.worldGeneratorSwamp : par1Random.nextInt(20) == 0 ? this.worldGeneratorTrees : this.worldGeneratorTrees));
    }

    public void generateSurface (World world, Random random, int i, int j){
    
    	for(int f = 0; f <200; f++);{
    	int x = i + random.nextInt(16);
    	int y = random.nextInt(128);
    	int z = j + random.nextInt(16);
    	new WaterGeneration(BlockRegistry.blockSeaweed, 2000).generate(world, random, x, y, z);
    	}
    	}

 

I still don't have this right though I have not connected all the dots on how its working

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Run jarfix https://johann.loefflmann.net/en/software/jarfix/index.html
    • Ich entschuldige mich schonmal im Voraus, falls es zu Kommunikationsproblemen  kommen sollte. Ich bin deutscher, etwas gestresst und habe gerade nicht wirklich die Nerven dafür, das alles ins englische zu übersetzen.   Ich habe mir in der Curseforge App 2 Mod-Profile für die Java Minecraft-Version 1.20.1 erstellt. eines für Forge-Mods und eines Für Fabric-Mods. Allerdings bekomme ich bei beiden eine Fehlermeldung, wenn ich Minecraft spielen will. Was kann ich tun? (Wenn es gebraucht wird, werde ich mir die Zeit nehmen und die Versionen und Ersteller der Mods und Recources raussuchen.)   Alle Mods, Resources und Modloader-packs sind auf der neusten Version Standpunkt 29.02.2024   - Forge: Meine Zusammenstellung besteht aus 121 Mods und 6 Resources. Was passiert: Wenn ich Spielen will, komm ich zwar in den Launcher und der Ladebildschirm taucht auf, bricht allerdings ab und bekomme eine Fehlermeldung. Fehlermeldung: The game crashed whilst initializing game Error: net.minecraftforge.fml.loading.EarlyLoadingException: Could not execute entrypoint stage 'main' due to errors, provided by 'eldritch_end'! Exitcode: -1 Wenn ich allerdings Eldrich End aus schalte, kommt ebenfalls eine. Fehlermeldung: The game crashed whilst initializing game Error: java.lang.NoClassDefFoundError: Could not initialize class net.minecraft.client.renderer.RenderType Exitcode: -1 Liste der Mods: A.V.A-Alliance of  Valiant Arms Guns Ad Astra Additional Lanterns Additional Structures Alex's Mobs Aquacolture 2 Aquamirae (Forge) Architectury API (Fabric/Forge/NeoForge) Armore Statues [Forge & Fabric] Armored Redstone AzurLib Balm (Forge Editon) Better Villages - Fabric BetterF3 Biomes O' Plenty Blue Skies Botarium CalamityMusicDisc Camera Mod Charm of Undying (Fabric/Forge/Quilt) Citadel Clasic musical discs Cloth Config API (Fabric/Forge/NeoForge) Config API [Fabric/Forge/NeoForge/Quilt] Connected Glass Connector Extras Cristel Lib Curios API (Forge/NeoForge) Curious Armor Stands Denki's Music Disc DivineRPG (Official) Dragon Mounts: Legacy Eldrich End Energized Power Eureka! Ships! for Valkyrien Skies (Forge/Fabric) Fish Tanks Forgified Fabric API Fussion (Connected Textures) Gamma Creatures GeckoLib Handcrafted HorkLord's Musik Discs Ice and Fire: Dragons Immersiv Melodies (Fabric/Forge) Immersiv Paintings (Fabric/Forge) Immersiv Structures Infinit Abyss Just Enough Items (JEI) Kotlin for Forge L_Enders Catalysm Library Ferret - Forge Macaw's Bridges Macaw's Doors Many More Music Discs [FORGE] MCEF (Minecraft Chromium Embedded  Framework) Mobs Head Modonomicon Monster Plus More Bows CJ (Fabric/Forge/Quilt) More Crossbows CJ (Fabric/Forge/Quilt) Morer Music Discs (Records) More Music Discs (Fabric/Forge/NeoForge) Moving Elevators MrCrayfish's Furniture Mod Multipart Machines: Mining Music Discs Galore Musical Instrument Minecraft Interface (MIMI) Musical Lib Mythic Mounts (Forge) Necronomicon API Nether Exorcism Netherrite Horse Armor CJ [Fabric/Forge/Quilt] Nullscape Nyctophobia (FABRIC) Obscure API (Fabric) Obscure Tooltips Occultism Ore Tree:Reeborn Patchouli Puzzles Lib [Forge & Fabric] Redstone engineering Redstone Lamp Plus Regions Unexplored (forge/fabric) Resourceful Config Resourceful Lib Scuffy Music Disc Pack Securety Craft Shadowlands Sinytra Connector SmartBrainLib (Forge/Fabric/Quilt) Spawn Structory Structory: Towers Structure Gel API  SuperMartijn642's Config Lib SuperMartijn642's Core Lib TerraBlender (Forge) The Ather The Graveyard (FORGE/NEOFORGE) The Twilight Forrest Towns and Towers Trash Cans Traveler' Backpack Valhelsia Core Valhelsia Structures Valkyrien Skies (Forge/Fabric) Waddles Waystones DebDisplays Wireles_Redstone Wither's Wepons YUNG'S API (Forge) YUNG'S Better Desert Temples (Forge) YUNG'S Better Dungeons (Forge) YUNG'S Better End Island (Forge) YUNG'S Better Jungle Temples (Forge) YUNG'S Better Mineshafts (Forge) YUNG'S Better Nether Fortresses (Forge) YUNG'S Better Ocean Monuments (Forge) YUNG'S Better Sreongholds (Forge) YUNG'S Better Witch Huts (Forge)   Liste der Resources: Better Cats Better Dogs Boss Refreshed Enhanced Boss Bars Visible Ores Zerotekz's Mythic Weapons     - Fabric: Meine Zusammenstellung besteht aus 61 Mods und 6 Resources. Was passiert: Wenn ich Spielen will, komm ich zwar in den Launcher, aber ich komme noch nicht einmal in den Ladebildschirm und drückt mir direkt eine Fehlermeldung rein. Fehlermeldung: The game crashed whilst initializing game Error: java.lang.NoSuchMethodError: 'java.lang.Object[] org.apache.commons.lang3.ArrayUtils.addFirst(java.lang.Object[], java.lang.Object)' Exitcode: -1 Liste der Mods: Ad Astra Additional Lanterns Aquamirae (Fabric) Architectury API (Fabric/Forge/NeoForge) AzurLib Better Villages - Fabric BetterF3 Bosses Of Mass Destruction Botarium Cardinal Components API Cloth Config API (Fabric/Forge/NeoForge) Clutter Config API [Fabric/Forge/NeoForge/Quilt] Cristel Lib Eldrich End Energized Power Eureka! Ships! for Valkyrien Skies (Forge/Fabric) Fabric API Fabric Language Kotlin GeckoLib Handcrafted Immersiv Armors (Fabric/Forge) Immersiv Melodies (Fabric/Forge) Immersiv Paintings (Fabric/Forge) Immersiv Structures Library Ferret - Fabric Macaw's Bridges Macaw's Doors More Bows CJ (Fabric/Forge/Quilt) More Crossbows CJ (Fabric/Forge/Quilt) More Music Discs (Fabric/Forge/NeoForge) Moving Elevators Mythic Mounts Necronomicon API Nullscape Nyctophobia (FABRIC) Obscure API (Fabric) Patchouli (Fabric) Regions Unexplored (forge/fabric) Resourceful Config Resourceful Lib Spawn Structory Structory: Towers SuperMartijn642's Config Lib SuperMartijn642's Core Lib TerraBlender (Fabric) The Graveyard (FABRIC) Towns and Towers Trash Cans Valkyrien Skies (Forge/Fabric) YUNG'S API (Fabric) YUNG'S Better Desert Temples (Fabric) YUNG'S Better Dungeons (Fabric) YUNG'S Better End Island (Fabric) YUNG'S Better Jungle Temples (Fabric) YUNG'S Better Mineshafts (Fabric) YUNG'S Better Nether Fortresses (Fabric) YUNG'S Better Ocean Monuments (Fabric) YUNG'S Better Sreongholds (Fabric) YUNG'S Better Witch Huts (Fabric)   Liste der Resources: Better Cats Better Dogs Boss Refreshed Enhanced Boss Bars Visible Ores Zerotekz's Mythic Weapons
    • When i click a jar file there's a black window popping out for a second then closing i don't know what to do, it's been happening for 2 days already
    • Hello, I don't have much experience with forge but I have some java knowledge, I want to add a button that says "Explore New Packs" to the Pause Screen that opens when we enter a world in the game and press the "esc" button, but I couldn't understand it (or I don't know how to use it), although I did research from artificial intelligence or different places. I was told that I can do it using mixins but I have no idea how to do it, can you explain step by step
    • We need the crash report or debug.log, as explained in the FAQ
  • Topics

×
×
  • Create New...

Important Information

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