Added sunflowers

This commit is contained in:
Matt Caughey 2013-05-14 10:17:00 -04:00
parent e938cdbda6
commit 231cde7958
14 changed files with 145 additions and 15 deletions

View file

@ -58,6 +58,7 @@ import biomesoplenty.worldgen.WorldGenShield;
import biomesoplenty.worldgen.WorldGenSmolderingGrass;
import biomesoplenty.worldgen.WorldGenSprout;
import biomesoplenty.worldgen.WorldGenSteppe;
import biomesoplenty.worldgen.WorldGenSunflower;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
@ -186,6 +187,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator
protected WorldGenerator quicksandGen;
protected WorldGenerator quicksand2Gen;
protected WorldGenerator poisonIvyGen;
protected WorldGenerator sunflowerGen;
protected WorldGenerator crystalGen;
protected WorldGenerator crystalGen2;
@ -259,6 +261,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator
protected int quicksandPerChunk;
protected int quicksand2PerChunk;
protected int poisonIvyPerChunk;
protected int sunflowersPerChunk;
/** The amount of tall grass to generate per chunk. */
protected int grassPerChunk;
@ -393,6 +396,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator
this.holyTallGrassGen = new WorldGenBOPFlowers(Blocks.plants.get().blockID, 4);
this.desertSproutsGen = new WorldGenBOPFlowers(Blocks.plants.get().blockID, 2);
this.poisonIvyGen = new WorldGenBush(Blocks.foliage.get().blockID, 7);
this.sunflowerGen = new WorldGenSunflower(Blocks.flowers.get().blockID, 13);
this.promisedWillowGen = new WorldGenPromisedWillow();
this.quicksandGen = new WorldGenQuicksand();
this.quicksand2Gen = new WorldGenQuicksand2();
@ -459,6 +463,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator
this.portobellosPerChunk = 0;
this.blueMilksPerChunk = 0;
this.glowshroomsPerChunk = 0;
this.sunflowersPerChunk = 0;
this.sproutsPerChunk = 0;
this.bushesPerChunk = 0;
this.tinyCactiPerChunk = 0;
@ -775,6 +780,14 @@ public class BiomeDecoratorBOP extends BiomeDecorator
this.plantRedGen.generate(this.currentWorld, this.randomGenerator, var3, var4, var5);
}
for (var2 = 0; var2 < this.sunflowersPerChunk; ++var2)
{
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
var4 = this.randomGenerator.nextInt(128);
var5 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
this.sunflowerGen.generate(this.currentWorld, this.randomGenerator, var3, var4, var5);
}
for (var2 = 0; var2 < this.crystalsPerChunk; ++var2)
{
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;

View file

@ -27,6 +27,7 @@ public class BiomeGenForestNew extends BiomeGenBase
this.customBiomeDecorator.whiteFlowersPerChunk = 1;
this.customBiomeDecorator.reedsBOPPerChunk = 5;
this.customBiomeDecorator.poisonIvyPerChunk = 2;
this.customBiomeDecorator.sunflowersPerChunk = 1;
}
/**

View file

@ -30,8 +30,9 @@ public class BiomeGenGarden extends BiomeGenBase
this.customBiomeDecorator.flowersPerChunk = 20;
this.customBiomeDecorator.whiteFlowersPerChunk = 25;
this.customBiomeDecorator.tinyFlowersPerChunk = 15;
this.customBiomeDecorator.hydrangeasPerChunk = 10;
this.customBiomeDecorator.sproutsPerChunk = 5;
this.customBiomeDecorator.hydrangeasPerChunk = 3;
this.customBiomeDecorator.sproutsPerChunk = 2;
this.customBiomeDecorator.sunflowersPerChunk = 4;
this.customBiomeDecorator.rosesPerChunk = 20;
this.customBiomeDecorator.grassPerChunk = 25;
this.customBiomeDecorator.sandPerChunk = -999;
@ -48,7 +49,7 @@ public class BiomeGenGarden extends BiomeGenBase
*/
public WorldGenerator getRandomWorldGenForGrass(Random par1Random)
{
return (par1Random.nextInt(3) == 0 ? new WorldGenTallGrass(Block.tallGrass.blockID, 1) : (par1Random.nextInt(4) == 0 ? new WorldGenTallGrass(Block.tallGrass.blockID, 2) : (par1Random.nextInt(2) == 0 ? new WorldGenTallGrass(Blocks.foliage.get().blockID, 2) : new WorldGenTallGrass(Blocks.foliage.get().blockID, 1))));
return new WorldGenTallGrass(Block.tallGrass.blockID, 1);
}
/**

View file

@ -26,6 +26,7 @@ public class BiomeGenMeadow extends BiomeGenBase
this.customBiomeDecorator.sandPerChunk = -999;
this.customBiomeDecorator.sandPerChunk2 = -999;
this.customBiomeDecorator.hydrangeasPerChunk = 3;
this.customBiomeDecorator.sunflowersPerChunk = 1;
this.customBiomeDecorator.generatePumpkins = false;
}

View file

@ -22,6 +22,7 @@ public class BiomeGenOrchard extends BiomeGenBase
this.customBiomeDecorator.tinyFlowersPerChunk = 20;
this.customBiomeDecorator.grassPerChunk = 15;
this.customBiomeDecorator.portobellosPerChunk = 2;
this.customBiomeDecorator.sunflowersPerChunk = 1;
}
/**

View file

@ -24,6 +24,7 @@ public class BiomeGenPlainsNew extends BiomeGenBase
this.customBiomeDecorator.grassPerChunk = 10;
this.customBiomeDecorator.tinyFlowersPerChunk = 1;
this.customBiomeDecorator.portobellosPerChunk = 1;
this.customBiomeDecorator.sunflowersPerChunk = 2;
}
/**

View file

@ -29,6 +29,7 @@ public class BiomeGenTropics extends BiomeGenBase
this.customBiomeDecorator.sandPerChunk2 = 50;
this.customBiomeDecorator.orangeFlowersPerChunk = 10;
this.customBiomeDecorator.whiteFlowersPerChunk = 4;
this.customBiomeDecorator.sunflowersPerChunk = 2;
this.customBiomeDecorator.generatePumpkins = false;
this.spawnableMonsterList.add(new SpawnListEntry(EntityJungleSpider.class, 12, 6, 6));
this.spawnableCreatureList.clear();

View file

@ -1,5 +1,6 @@
package biomesoplenty.blocks;
import java.util.Random;
import java.util.List;
import net.minecraft.block.Block;
@ -25,6 +26,9 @@ public class BlockBOPFlower extends BlockFlower
private static final String[] plants = new String[] {"clover", "swampflower", "deadbloom", "glowflower", "hydrangea", "daisy", "tulip", "wildflower", "violet", "anemone", "lilyflower", "cactus", "aloe", "sunflowerbottom", "sunflowertop", "dandelion"};
private Icon[] textures;
private static final int SUNFLOWERTOP = 14;
private static final int SUNFLOWERBOTTOM = 13;
protected BlockBOPFlower(int blockID, Material material)
{
super(blockID, material);
@ -117,8 +121,13 @@ public class BlockBOPFlower extends BlockFlower
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < plants.length; ++i)
{
if (i != 14)
{
list.add(new ItemStack(blockID, 1, i));
}
}
}
protected boolean canThisPlantGrowOnThisBlockID(int id)
{
@ -133,8 +142,10 @@ public class BlockBOPFlower extends BlockFlower
return id == Block.waterlily.blockID;
if (metadata == 11) //Cactus
return id == Block.sand.blockID || id == Blocks.redRock.get().blockID;
if (metadata == 12) //Yucca
if (metadata == 12) //Aloe
return id == Blocks.hardDirt.get().blockID || id == Blocks.redRock.get().blockID || id == Block.sand.blockID;
if (metadata == 14) //Sunflower Top
return id == this.blockID;
else
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID;
}
@ -158,9 +169,12 @@ public class BlockBOPFlower extends BlockFlower
case 11: // Cactus
return id == Blocks.redRock.get().blockID || id == Block.sand.blockID;
case 12: // Yucca
case 12: // Aloe
return id == Blocks.hardDirt.get().blockID || id == Blocks.redRock.get().blockID || id == Block.sand.blockID;
case 14: // Sunflower Top
return id == this.blockID;
default:
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID;
}
@ -168,6 +182,48 @@ public class BlockBOPFlower extends BlockFlower
return this.canPlaceBlockOnSide(world, x, y, z, side);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID)
{
super.onNeighborBlockChange(world, x, y, z, neighborID);
this.checkFlowerChange(world, x, y, z);
if (world.getBlockMetadata(x, y, z) == SUNFLOWERTOP && world.getBlockId(x, y - 1, z) == this.blockID && world.getBlockMetadata(x, y - 1, z) != SUNFLOWERBOTTOM)
world.setBlockToAir(x, y, z);
//if (world.getBlockMetadata(x, y, z) == CATTAILBOTTOM && world.getBlockId(x, y + 1, z) != this.blockID)
// world.setBlock(x, y, z, this.blockID, 7, 2);
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == SUNFLOWERTOP)
meta = 13;
return meta;
}
@Override
public int damageDropped(int meta)
{
if (meta == 14)
{
return 13 & 15;
}
else
{
return meta & 15;
}
}
@Override
public int quantityDropped(int meta, int fortune, Random random)
{
if (meta == 13)
return 0;
else
return 1;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
@ -178,10 +234,4 @@ public class BlockBOPFlower extends BlockFlower
return (world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z))
&& this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z));
}
@Override
public int damageDropped(int meta)
{
return meta & 15;
}
}

View file

@ -4,6 +4,7 @@ import biomesoplenty.BiomesOPlenty;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
@ -15,6 +16,9 @@ import net.minecraft.world.World;
public class ItemBOPFlower extends ItemBlock
{
private static final String[] plants = new String[] {"clover", "swampflower", "deadbloom", "glowflower", "hydrangea", "daisy", "tulip", "wildflower", "violet", "anemone", "lilyflower", "cactus", "aloe", "sunflowerbottom", "sunflowertop", "dandelion"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
private static final int SUNFLOWERTOP = 14;
public ItemBOPFlower(int par1)
{
@ -29,6 +33,14 @@ public class ItemBOPFlower extends ItemBlock
return meta & 15;
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[1];
textures[0] = iconRegister.registerIcon("BiomesOPlenty:item_sunflower");
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
@ -38,6 +50,9 @@ public class ItemBOPFlower extends ItemBlock
@Override
public Icon getIconFromDamage(int meta)
{
if (meta == 13)
return textures[0];
else
return Block.blocksList[this.itemID].getIcon(0, meta);
}
@ -126,6 +141,9 @@ public class ItemBOPFlower extends ItemBlock
if (world.setBlock(x, y, z, this.getBlockID(), itemStack.getItemDamage(), 3))
{
if (itemStack.getItemDamage() == 13 && world.getBlockMaterial(x, y + 1, z).isReplaceable())
world.setBlock(x, y + 1, z, this.getBlockID(), SUNFLOWERTOP, 2);
if (world.getBlockId(x, y, z) == this.getBlockID())
{
Block.blocksList[this.getBlockID()].onBlockPlacedBy(world, x, y, z, player, itemStack);

View file

@ -0,0 +1,43 @@
package biomesoplenty.worldgen;
import java.util.Random;
import biomesoplenty.api.Blocks;
import biomesoplenty.configuration.BOPBlocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
public class WorldGenSunflower extends WorldGenerator
{
/** The ID of the plant block used in this plant generator. */
private int plantBlockId;
private int plantBlockMeta;
public WorldGenSunflower(int par1, int meta)
{
this.plantBlockId = par1;
this.plantBlockMeta = meta;
}
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
{
for (int l = 0; l < 64; ++l)
{
int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8);
int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4);
int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8);
if (par1World.isAirBlock(i1, j1, k1) && (!par1World.provider.hasNoSky || j1 < 127) && (par1World.getFullBlockLightValue(i1, j1, k1) >= 8 || par1World.canBlockSeeTheSky(i1, j1, k1))
&& Block.blocksList[this.plantBlockId].canPlaceBlockOnSide(par1World, i1, j1, k1, 1, new ItemStack(this.plantBlockId, 1, this.plantBlockMeta)))
{
par1World.setBlock(i1, j1, k1, Blocks.flowers.get().blockID, 13, 2);
par1World.setBlock(i1, j1 + 1, k1, Blocks.flowers.get().blockID, 14, 2);
}
}
return true;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B