Added a way to grow tiny cacti and cattails with bonemeal
This commit is contained in:
parent
e3d49e1698
commit
f750b9d445
3 changed files with 100 additions and 36 deletions
|
@ -7,8 +7,10 @@ import net.minecraftforge.event.entity.player.BonemealEvent;
|
||||||
import biomesoplenty.api.Blocks;
|
import biomesoplenty.api.Blocks;
|
||||||
import biomesoplenty.blocks.BlockBOPColorizedSapling;
|
import biomesoplenty.blocks.BlockBOPColorizedSapling;
|
||||||
import biomesoplenty.blocks.BlockBOPSapling;
|
import biomesoplenty.blocks.BlockBOPSapling;
|
||||||
|
import biomesoplenty.worldgen.WorldGenDesertCactus;
|
||||||
import biomesoplenty.worldgen.WorldGenGiantFlowerRed;
|
import biomesoplenty.worldgen.WorldGenGiantFlowerRed;
|
||||||
import biomesoplenty.worldgen.WorldGenGiantFlowerYellow;
|
import biomesoplenty.worldgen.WorldGenGiantFlowerYellow;
|
||||||
|
import biomesoplenty.worldgen.WorldGenCattailBonemeal;
|
||||||
import biomesoplenty.worldgen.WorldGenKelp;
|
import biomesoplenty.worldgen.WorldGenKelp;
|
||||||
|
|
||||||
public class BonemealHandler
|
public class BonemealHandler
|
||||||
|
@ -79,6 +81,32 @@ public class BonemealHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (event.ID == Blocks.plants.get().blockID && event.world.getBlockMetadata(event.X, event.Y, event.Z) == 12)
|
||||||
|
{
|
||||||
|
event.setResult(Result.ALLOW);
|
||||||
|
|
||||||
|
if (!event.world.isRemote)
|
||||||
|
{
|
||||||
|
if (event.world.rand.nextFloat() < 0.45D)
|
||||||
|
{
|
||||||
|
WorldGenDesertCactus worldgendesertcactus = new WorldGenDesertCactus();
|
||||||
|
worldgendesertcactus.generate(event.world, event.world.rand, event.X, event.Y, event.Z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event.ID == Blocks.plants.get().blockID && event.world.getBlockMetadata(event.X, event.Y, event.Z) == 7)
|
||||||
|
{
|
||||||
|
event.setResult(Result.ALLOW);
|
||||||
|
|
||||||
|
if (!event.world.isRemote)
|
||||||
|
{
|
||||||
|
if (event.world.rand.nextFloat() < 0.45D)
|
||||||
|
{
|
||||||
|
WorldGenCattailBonemeal worldgencattailbonemeal = new WorldGenCattailBonemeal(Blocks.plants.get().blockID, 9);
|
||||||
|
worldgencattailbonemeal.generate(event.world, event.world.rand, event.X, event.Y, event.Z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (event.ID == Block.plantRed.blockID)
|
else if (event.ID == Block.plantRed.blockID)
|
||||||
{
|
{
|
||||||
event.setResult(Result.ALLOW);
|
event.setResult(Result.ALLOW);
|
||||||
|
|
54
common/biomesoplenty/worldgen/WorldGenCattailBonemeal.java
Normal file
54
common/biomesoplenty/worldgen/WorldGenCattailBonemeal.java
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
package biomesoplenty.worldgen;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||||
|
import biomesoplenty.api.Blocks;
|
||||||
|
|
||||||
|
public class WorldGenCattailBonemeal extends WorldGenerator
|
||||||
|
{
|
||||||
|
/** Stores ID for WorldGenHighCattail */
|
||||||
|
private int highCattailID;
|
||||||
|
private int highCattailMetadata;
|
||||||
|
|
||||||
|
public WorldGenCattailBonemeal(int par1, int par2)
|
||||||
|
{
|
||||||
|
highCattailID = par1;
|
||||||
|
highCattailMetadata = par2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
|
||||||
|
{
|
||||||
|
int var11;
|
||||||
|
|
||||||
|
for (boolean var6 = false; ((var11 = par1World.getBlockId(par3, par4, par5)) == 0 || var11 == Block.leaves.blockID) && par4 > 0; --par4)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int var7 = 0; var7 < 128; ++var7)
|
||||||
|
{
|
||||||
|
int var8 = par3;
|
||||||
|
int var9 = par4;
|
||||||
|
int var10 = par5;
|
||||||
|
|
||||||
|
int var999 = par1World.getBlockId(par3, par4, par5);
|
||||||
|
int var998 = par1World.getBlockMetadata(par3, par4, par5);
|
||||||
|
|
||||||
|
if (var999 == Blocks.plants.get().blockID && var998 == 7 && Block.blocksList[highCattailID].canBlockStay(par1World, var8, var9, var10))
|
||||||
|
{
|
||||||
|
if (par1World.getBlockMaterial(var8 - 1, var9 - 1, var10) == Material.water ? true : (par1World.getBlockMaterial(var8 + 1, var9 - 1, var10) == Material.water ? true : (par1World.getBlockMaterial(var8, var9 - 1, var10 - 1) == Material.water ? true : par1World.getBlockMaterial(var8, var9 - 1, var10 + 1) == Material.water)))
|
||||||
|
{
|
||||||
|
par1World.setBlock(var8, var9, var10, Blocks.plants.get().blockID, 10, 2);
|
||||||
|
par1World.setBlock(var8, var9 + 1, var10, Blocks.plants.get().blockID, 9, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,45 +2,27 @@ package biomesoplenty.worldgen;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import biomesoplenty.api.Blocks;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||||
import biomesoplenty.api.Blocks;
|
|
||||||
|
|
||||||
public class WorldGenDesertCactus extends WorldGenerator
|
public class WorldGenDesertCactus extends WorldGenerator
|
||||||
{
|
{
|
||||||
@Override
|
|
||||||
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
|
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
|
||||||
{
|
{
|
||||||
for (int var6 = 0; var6 < 10; ++var6)
|
int var999 = par1World.getBlockId(par3, par4, par5);
|
||||||
{
|
int var998 = par1World.getBlockMetadata(par3, par4, par5);
|
||||||
int var7 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8);
|
|
||||||
int var8 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4);
|
|
||||||
int var9 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8);
|
|
||||||
|
|
||||||
if (par1World.isAirBlock(var7, var8, var9))
|
if (var999 == Blocks.plants.get().blockID && var998 == 12)
|
||||||
{
|
{
|
||||||
if (!par1World.isAirBlock(var7 - 1, var8 - 1, var9))
|
int l1 = 1 + par2Random.nextInt(par2Random.nextInt(3) + 1);
|
||||||
{
|
|
||||||
if (!par1World.isAirBlock(var7 + 1, var8 - 1, var9))
|
|
||||||
{
|
|
||||||
if (!par1World.isAirBlock(var7, var8 - 1, var9 - 1))
|
|
||||||
{
|
|
||||||
if (!par1World.isAirBlock(var7, var8 - 1, var9 + 1))
|
|
||||||
{
|
|
||||||
int var10 = 2 + par2Random.nextInt(par2Random.nextInt(2) + 2);
|
|
||||||
|
|
||||||
for (int var11 = 0; var11 < var10; ++var11)
|
for (int i2 = 0; i2 < l1; ++i2)
|
||||||
{
|
{
|
||||||
if (Blocks.plants.get().canBlockStay(par1World, var7, var8 + var11, var9))
|
if (Block.cactus.canBlockStay(par1World, par3, par4 + i2, par5))
|
||||||
{
|
{
|
||||||
par1World.setBlock(var7, var8 - 1, var9, Block.sand.blockID);
|
par1World.setBlock(par3, par4 + i2, par5, Block.cactus.blockID, 0, 2);
|
||||||
par1World.setBlock(var7, var8 + var11, var9, Block.cactus.blockID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue