Added a new Long Grass block which generates in the Garden biome.

This commit is contained in:
Matt Caughey 2013-07-21 22:01:24 -04:00
parent 527778691c
commit b723e47ebd
18 changed files with 233 additions and 14 deletions

View file

@ -99,6 +99,7 @@
<entry key="tile.bop.bamboo.name">Bamboo</entry>
<entry key="tile.bop.mudBricksStairs.name">Mud Bricks Stairs</entry>
<entry key="tile.bop.originGrass.name">Origin Grass</entry>
<entry key="tile.bop.longGrass.name">Long Grass</entry>
<entry key="tile.bop.treeMoss.name">Tree Moss</entry>
<entry key="tile.bop.coral.kelp.name">Kelp</entry>

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

View file

@ -104,6 +104,7 @@ public class BlockReferences {
ashStone (Blocks.ashStone, 0),
hardIce (Blocks.hardIce, 0),
originGrass (Blocks.originGrass, 0),
longGrass (Blocks.longGrass, 0),
hardSand (Blocks.hardSand, 0),
hardDirt (Blocks.hardDirt, 0),
holyGrass (Blocks.holyGrass, 0),

View file

@ -23,6 +23,7 @@ public class Blocks
public static Optional<? extends Block> holyStone = Optional.absent();
public static Optional<? extends Block> mud = Optional.absent();
public static Optional<? extends Block> originGrass = Optional.absent();
public static Optional<? extends Block> longGrass = Optional.absent();
public static Optional<? extends Block> redRock = Optional.absent();
public static Optional<? extends Block> crystal = Optional.absent();

View file

@ -11,6 +11,7 @@ import net.minecraft.world.gen.feature.WorldGenTallGrass;
import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.api.Blocks;
import biomesoplenty.entities.EntityRosester;
import biomesoplenty.worldgen.WorldGenBOPShrub;
import biomesoplenty.worldgen.WorldGenGiantFlowerRed;
import biomesoplenty.worldgen.WorldGenGiantFlowerYellow;
@ -22,6 +23,8 @@ public class BiomeGenGarden extends BiomeGenBase
public BiomeGenGarden(int par1)
{
super(par1);
topBlock = (byte)Blocks.longGrass.get().blockID;
fillerBlock = (byte)Block.dirt.blockID;
theBiomeDecorator = new BiomeDecoratorBOP(this);
customBiomeDecorator = (BiomeDecoratorBOP)theBiomeDecorator;
customBiomeDecorator.treesPerChunk = 2;
@ -37,7 +40,6 @@ public class BiomeGenGarden extends BiomeGenBase
customBiomeDecorator.sandPerChunk2 = -999;
customBiomeDecorator.bushesPerChunk = 10;
customBiomeDecorator.lilyflowersPerChunk = 4;
customBiomeDecorator.carrotsPerChunk = 1;
customBiomeDecorator.generatePumpkins = true;
customBiomeDecorator.generateMelons = true;
spawnableCreatureList.clear();
@ -70,7 +72,7 @@ public class BiomeGenGarden extends BiomeGenBase
@Override
public WorldGenerator getRandomWorldGenForGrass(Random par1Random)
{
return new WorldGenTallGrass(Block.tallGrass.blockID, 1);
return (par1Random.nextInt(4) == 0 ? new WorldGenTallGrass(Block.tallGrass.blockID, 1) : (par1Random.nextInt(2) == 0 ? new WorldGenTallGrass(Blocks.foliage.get().blockID, 1) : new WorldGenTallGrass(Blocks.foliage.get().blockID, 2)));
}
/**
@ -79,7 +81,7 @@ public class BiomeGenGarden extends BiomeGenBase
@Override
public WorldGenerator getRandomWorldGenForTrees(Random par1Random)
{
return par1Random.nextInt(6) == 0 ? new WorldGenGiantFlowerRed() : (par1Random.nextInt(6) == 0 ? new WorldGenGiantFlowerYellow() : new WorldGenShrub(0,0));
return par1Random.nextInt(6) == 0 ? new WorldGenGiantFlowerRed() : (par1Random.nextInt(6) == 0 ? new WorldGenGiantFlowerYellow() : new WorldGenBOPShrub(0,0));
}
/**

View file

@ -175,13 +175,13 @@ public class BlockBOPFlower extends BlockFlower
@Override
protected boolean canThisPlantGrowOnThisBlockID(int id)
{
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Block.sand.blockID || id == Blocks.hardDirt.get().blockID || id == Blocks.redRock.get().blockID;
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Block.sand.blockID || id == Blocks.hardDirt.get().blockID || id == Blocks.redRock.get().blockID || id == Blocks.longGrass.get().blockID;
}
protected boolean canThisPlantGrowOnThisBlockID(int id, int metadata)
{
if (metadata == 6) //Tulip
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.holyGrass.get().blockID;
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.holyGrass.get().blockID || id == Blocks.longGrass.get().blockID;
if (metadata == 10) //Lily Flower
return id == Block.waterlily.blockID;
if (metadata == 11) //Cactus
@ -191,7 +191,7 @@ public class BlockBOPFlower extends BlockFlower
if (metadata == 14) //Sunflower Top
return id == blockID;
else
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID;
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.longGrass.get().blockID;
}
@Override
@ -205,7 +205,7 @@ public class BlockBOPFlower extends BlockFlower
switch (meta)
{
case 6: // Tulip
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.holyGrass.get().blockID;
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.holyGrass.get().blockID || id == Blocks.longGrass.get().blockID;
case 10: // Lily Flower
return id == Block.waterlily.blockID;
@ -220,7 +220,7 @@ public class BlockBOPFlower extends BlockFlower
return id == blockID;
default:
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID;
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.longGrass.get().blockID;
}
} else
return this.canPlaceBlockOnSide(world, x, y, z, side);

View file

@ -136,7 +136,7 @@ public class BlockBOPFoliage extends BlockFlower implements IShearable
return id == Block.waterStill.blockID;
default:
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID;
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.longGrass.get().blockID;
}
} else
return this.canPlaceBlockOnSide(world, x, y, z, side);
@ -145,7 +145,7 @@ public class BlockBOPFoliage extends BlockFlower implements IShearable
@Override
protected boolean canThisPlantGrowOnThisBlockID(int id)
{
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID;
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.longGrass.get().blockID;
}
protected boolean canThisPlantGrowOnThisBlockID(int blockID, int metadata)
@ -155,7 +155,7 @@ public class BlockBOPFoliage extends BlockFlower implements IShearable
else if (metadata == ALGAE)
return blockID == Block.waterStill.blockID;
else
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID;
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID || blockID == Blocks.longGrass.get().blockID;
}
@Override

View file

@ -118,7 +118,7 @@ public class BlockBOPPlant extends BlockFlower implements IShearable
else if (metadata == 9)
return blockID == this.blockID;
else
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID;
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID || blockID == Blocks.longGrass.get().blockID;
}
@Override

View file

@ -0,0 +1,139 @@
package biomesoplenty.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.IPlantable;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
public class BlockLongGrass extends Block
{
private Icon[] blockIcon = new Icon[6];
public BlockLongGrass(int par1)
{
super(par1, Material.grass);
this.setTickRandomly(true);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
blockIcon[0] = par1IconRegister.registerIcon("biomesoplenty:longgrass3");
blockIcon[1] = par1IconRegister.registerIcon("biomesoplenty:longgrass1");
blockIcon[2] = par1IconRegister.registerIcon("biomesoplenty:longgrass2");
blockIcon[3] = par1IconRegister.registerIcon("biomesoplenty:longgrass2");
blockIcon[4] = par1IconRegister.registerIcon("biomesoplenty:longgrass2");
blockIcon[5] = par1IconRegister.registerIcon("biomesoplenty:longgrass2");
}
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
@Override
public Icon getIcon(int par1, int par2)
{
if (par1 < 0 || par1 >= blockIcon.length)
par1 = 1;
return blockIcon[par1];
}
/**
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
*/
/*public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
if (par5 == 1)
{
return 32;
}
else if (par5 == 0)
{
return 34;
}
else
{
Material var6 = par1IBlockAccess.getBlockMaterial(par2, par3 + 1, par4);
return var6 != Material.snow && var6 != Material.craftedSnow ? 33 : 33;
}
}*/
@Override
public boolean canSustainPlant(World world, int x, int y, int z, ForgeDirection direction, IPlantable plant)
{
return true;
}
/**
* Called upon block activation (right click on the block.)
*/
@Override
public boolean onBlockActivated(World world, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
if (par5EntityPlayer.getCurrentEquippedItem() != null)
{
if (par5EntityPlayer.getCurrentEquippedItem().getDisplayName().toLowerCase().contains(" hoe"))
{
Block block = Block.tilledField;
world.playSoundEffect(par2 + 0.5F, par3 + 0.5F, par4 + 0.5F, block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
if (!world.isRemote)
{
world.setBlock(par2, par3, par4, block.blockID);
}
return true;
} else
return false;
} else
return false;
}
/**
* Ticks the block if it's been scheduled
*/
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (!par1World.isRemote)
{
if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && Block.lightOpacity[par1World.getBlockId(par2, par3 + 1, par4)] > 2)
{
par1World.setBlock(par2, par3, par4, Block.dirt.blockID);
}
else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
{
for (int var6 = 0; var6 < 4; ++var6)
{
int var7 = par2 + par5Random.nextInt(3) - 1;
int var8 = par3 + par5Random.nextInt(5) - 3;
int var9 = par4 + par5Random.nextInt(3) - 1;
int var10 = par1World.getBlockId(var7, var8 + 1, var9);
if (par1World.getBlockId(var7, var8, var9) == Block.dirt.blockID && par1World.getBlockLightValue(var7, var8 + 1, var9) >= 4 && Block.lightOpacity[var10] <= 2)
{
par1World.setBlock(var7, var8, var9, Blocks.longGrass.get().blockID);
}
}
}
}
}
/**
* Returns the ID of the items to drop on destruction.
*/
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return Block.dirt.idDropped(0, par2Random, par3);
}
}

View file

@ -38,6 +38,7 @@ import biomesoplenty.blocks.BlockBones;
import biomesoplenty.blocks.BlockCloud;
import biomesoplenty.blocks.BlockGrave;
import biomesoplenty.blocks.BlockIvy;
import biomesoplenty.blocks.BlockLongGrass;
import biomesoplenty.blocks.BlockMoss;
import biomesoplenty.blocks.BlockMud;
import biomesoplenty.blocks.BlockOriginGrass;
@ -97,6 +98,7 @@ public class BOPBlocks
MinecraftForge.setBlockHarvestLevel(Blocks.mud.get(), "shovel", 0);
MinecraftForge.setBlockHarvestLevel(Blocks.ash.get(), "shovel", 0);
MinecraftForge.setBlockHarvestLevel(Blocks.originGrass.get(), "shovel", 0);
MinecraftForge.setBlockHarvestLevel(Blocks.longGrass.get(), "shovel", 0);
MinecraftForge.setBlockHarvestLevel(Blocks.hardSand.get(), "shovel", 0);
MinecraftForge.setBlockHarvestLevel(Blocks.holyGrass.get(), 0, "pickaxe", 0);
@ -138,6 +140,7 @@ public class BOPBlocks
Blocks.stoneDoubleSlab = Optional.of((BlockHalfSlab)(new BlockBOPSlab(BOPConfiguration.stoneDoubleSlabID, true, Material.rock, SlabCategory.STONE)).setUnlocalizedName("bop.stoneDoubleSlab"));
Blocks.stoneSingleSlab = Optional.of((BlockHalfSlab)(new BlockBOPSlab(BOPConfiguration.stoneSingleSlabID, false, Material.rock, SlabCategory.STONE)).setUnlocalizedName("bop.stoneSingleSlab"));
Blocks.originGrass = Optional.of((new BlockOriginGrass(BOPConfiguration.originGrassID)).setHardness(0.6F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("bop.originGrass"));
Blocks.longGrass = Optional.of((new BlockLongGrass(BOPConfiguration.longGrassID)).setHardness(0.6F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("bop.longGrass"));
Blocks.treeMoss = Optional.of((new BlockTreeMoss(BOPConfiguration.treeMossID)).setHardness(0.2F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("bop.treeMoss"));
Blocks.logs1 = Optional.of((new BlockBOPLog(BOPConfiguration.logs1ID,LogCategory.CAT1)).setUnlocalizedName("bop.wood1"));
Blocks.logs2 = Optional.of((new BlockBOPLog(BOPConfiguration.logs2ID,LogCategory.CAT2)).setUnlocalizedName("bop.wood2"));
@ -221,6 +224,7 @@ public class BOPBlocks
GameRegistry.registerBlock(Blocks.mudBrick.get(), "bop.mudBrick");
GameRegistry.registerBlock(Blocks.mudBricksStairs.get(), "bop.mudBricksStairs");
GameRegistry.registerBlock(Blocks.originGrass.get(), "bop.originGrass");
GameRegistry.registerBlock(Blocks.longGrass.get(), "bop.longGrass");
GameRegistry.registerBlock(Blocks.treeMoss.get(), "bop.treeMoss");
GameRegistry.registerBlock(Blocks.logs1.get(), ItemBlockLog.class, "bop.wood1");
GameRegistry.registerBlock(Blocks.logs2.get(), ItemBlockLog.class, "bop.wood2");

View file

@ -134,6 +134,7 @@ public class BOPConfiguration {
public static int ashStoneID;
public static int hardIceID;
public static int originGrassID;
public static int longGrassID;
public static int hardSandID;
public static int hardDirtID;
public static int holyGrassID;
@ -706,6 +707,7 @@ public class BOPConfiguration {
holyDirtID = config.getTerrainBlock("Terrain Block IDs - MUST BE BELOW 255", "Holy Dirt ID", 170, null).getInt();
holyStoneID = config.getTerrainBlock("Terrain Block IDs - MUST BE BELOW 255", "Skystone ID", 171, null).getInt();
cragRockID = config.getTerrainBlock("Terrain Block IDs - MUST BE BELOW 255", "Crag Rock ID", 172, null).getInt();
longGrassID = config.getTerrainBlock("Terrain Block IDs - MUST BE BELOW 255", "Long Grass ID", 173, null).getInt();
// Get Crafted Block ID's
plantsID = config.getBlock("Plant ID", 1920, null).getInt();

View file

@ -0,0 +1,69 @@
package biomesoplenty.worldgen;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.api.Blocks;
public class WorldGenBOPShrub extends WorldGenerator
{
private int field_76527_a;
private int field_76526_b;
public WorldGenBOPShrub(int par1, int par2)
{
this.field_76526_b = par1;
this.field_76527_a = par2;
}
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
{
int l;
Block block = null;
do
{
block = Block.blocksList[par1World.getBlockId(par3, par4, par5)];
if (block != null && !block.isLeaves(par1World, par3, par4, par5))
{
break;
}
par4--;
} while (par4 > 0);
int i1 = par1World.getBlockId(par3, par4, par5);
if (i1 == Block.dirt.blockID || i1 == Blocks.longGrass.get().blockID)
{
++par4;
this.setBlockAndMetadata(par1World, par3, par4, par5, Block.wood.blockID, this.field_76526_b);
for (int j1 = par4; j1 <= par4 + 2; ++j1)
{
int k1 = j1 - par4;
int l1 = 2 - k1;
for (int i2 = par3 - l1; i2 <= par3 + l1; ++i2)
{
int j2 = i2 - par3;
for (int k2 = par5 - l1; k2 <= par5 + l1; ++k2)
{
int l2 = k2 - par5;
block = Block.blocksList[par1World.getBlockId(i2, j1, k2)];
if ((Math.abs(j2) != l1 || Math.abs(l2) != l1 || par2Random.nextInt(2) != 0) &&
(block == null || block.canBeReplacedByLeaves(par1World, i2, j1, k2)))
{
this.setBlockAndMetadata(par1World, i2, j1, k2, Block.leaves.blockID, this.field_76527_a);
}
}
}
}
}
return true;
}
}

View file

@ -19,7 +19,7 @@ public class WorldGenGiantFlowerRed extends WorldGenerator
int var6 = var1.getBlockId(var3, var4, var5);
if (var6 != Block.grass.blockID)
if (var6 != Blocks.longGrass.get().blockID)
return false;
else
{

View file

@ -19,7 +19,7 @@ public class WorldGenGiantFlowerYellow extends WorldGenerator
int var6 = var1.getBlockId(var3, var4, var5);
if (var6 != Block.grass.blockID)
if (var6 != Blocks.longGrass.get().blockID)
return false;
else
{