Plants and grass.

This commit is contained in:
Amnet 2013-04-16 01:55:45 +02:00
parent ecb6faaf8f
commit 82a2579b61
27 changed files with 357 additions and 42 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

View file

@ -31,4 +31,6 @@ public class Blocks
public static Optional<? extends Block> logs1 = Optional.absent();
public static Optional<? extends Block> logs2 = Optional.absent();
public static Optional<? extends Block> logs3 = Optional.absent();
public static Optional<? extends Block> foliage = Optional.absent();
public static Optional<? extends Block> plants = Optional.absent();
}

View file

@ -7,7 +7,9 @@ import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@ -17,7 +19,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPFlower extends BlockFlower
{
private static final String[] plants = new String[] {"swampflower", "deadbloom", "glowflower", "hydrangea", "orangeflower", "pinkflower", "purpleflower", "violet", "whiteflower"};
private static final String[] plants = new String[] {"swampflower", "deadbloom", "glowflower", "hydrangea", "orangeflower", "pinkflower", "purpleflower", "violet", "whiteflower", "toadstool", "cactus"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
@ -55,6 +57,7 @@ public class BlockBOPFlower extends BlockFlower
return textures[meta];
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
@ -64,6 +67,14 @@ public class BlockBOPFlower extends BlockFlower
return 0;
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 10)
entity.attackEntityFrom(DamageSource.cactus, 1);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {

View file

@ -17,34 +17,34 @@ import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import tdwp_ftw.biomesop.configuration.BOPBlocks;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPFoliage extends BlockFlower implements IShearable
{
private static final String[] foliageTypes = new String[] {"shortgrass", "mediumgrass", "highgrassbottom", "highgrasstop"};
private static final String[] foliageTypes = new String[] {"shortgrass", "mediumgrass", "highgrassbottom", "bush", "sprout", "highgrasstop"};
@SideOnly(Side.CLIENT)
private Icon[] textures = {null, null, null, null};
private final int metadata;
private Icon[] textures;
public BlockBOPFoliage(int blockID, int index)
public BlockBOPFoliage(int blockID)
{
super(blockID, Material.vine);
float f = 0.4F;
BlockBOPFoliage.setBurnProperties(this.blockID, 60, 100);
metadata = index;
if (metadata == 3)
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
else
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
setBurnProperties(this.blockID, 60, 100);
setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
setHardness(0.0F);
setStepSound(Block.soundGrassFootstep);
this.setCreativeTab(mod_BiomesOPlenty.tabBiomesOPlenty);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[foliageTypes.length];
for (int i = 0; i < textures.length; ++i)
textures[i] = iconRegister.registerIcon("BiomesOPlenty:"+foliageTypes[i]);
}
@ -65,31 +65,28 @@ public class BlockBOPFoliage extends BlockFlower implements IShearable
@SideOnly(Side.CLIENT)
public void getSubBlocks(int blockID, CreativeTabs par2CreativeTabs, List list)
{
list.add(new ItemStack(blockID, 1, 0));
list.add(new ItemStack(blockID, 1, 1));
list.add(new ItemStack(blockID, 1, 2));
list.add(new ItemStack(blockID, 1, 3));
for (int i = 0; i < textures.length-1; ++i)
list.add(new ItemStack(blockID, 1, i));
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
return super.canPlaceBlockAt(world, x, y, z) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
return super.canPlaceBlockAt(world, x, y, z) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z));
}
@Override
protected boolean canThisPlantGrowOnThisBlockID(int blockID)
protected boolean canThisPlantGrowOnThisBlockID(int blockID, int metadata)
{
if (metadata == 3)
return blockID == BOPBlocks.highGrassBottom.blockID;
if (metadata == 5)
return blockID == this.blockID;
else
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
return (world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z)) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
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
@ -112,21 +109,23 @@ public class BlockBOPFoliage extends BlockFlower implements IShearable
@SideOnly(Side.CLIENT)
public int getRenderColor(int par1)
{
return par1 == 0 ? 16777215 : ColorizerFoliage.getFoliageColorBasic();
return ColorizerFoliage.getFoliageColorBasic();
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
return var5 == 0 ? 16777215 : par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeGrassColor();
return par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeGrassColor();
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
return world.getBlockMetadata(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (meta == 5)
meta = 2;
return meta;
}
@Override
@ -141,14 +140,6 @@ public class BlockBOPFoliage extends BlockFlower implements IShearable
super.harvestBlock(world, player, x, y, z, meta);
}
@Override
public int idPicked(World par1World, int par2, int par3, int par4)
{
// TODO
return -1;
// return BOPItems.shortGrassItem.itemID;
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
@ -158,9 +149,11 @@ public class BlockBOPFoliage extends BlockFlower implements IShearable
@Override
public boolean isShearable(ItemStack item, World world, int x, int y, int z)
{
if (world.getBlockMetadata(x, y, z) == 5)
return false;
return true;
}
@Override
public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{

View file

@ -0,0 +1,154 @@
package tdwp_ftw.biomesop.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import tdwp_ftw.biomesop.configuration.BOPBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
public class BlockBOPPlant extends BlockFlower implements IShearable
{
private static final String[] plants = new String[] {"deadgrass", "desertgrass", "desertsprouts", "dunegrass", "holytallgrass", "thorn"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
public BlockBOPPlant(int par1)
{
super(par1, Material.vine);
setTickRandomly(true);
float var3 = 0.4F;
setBurnProperties(this.blockID, 60, 100);
setHardness(0.0F);
setStepSound(Block.soundGrassFootstep);
setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 0.8F, 0.5F + var3);
setCreativeTab(mod_BiomesOPlenty.tabBiomesOPlenty);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[plants.length];
for (int i = 0; i < plants.length; ++i)
textures[i] = iconRegister.registerIcon("BiomesOPlenty:" + plants[i]);
}
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTextureFromSideAndMetadata(int side, int meta)
{
if (meta < 0 || meta >= textures.length)
meta = 0;
return textures[meta];
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < plants.length; ++i)
list.add(new ItemStack(blockID, 1, i));
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
return super.canPlaceBlockAt(world, x, y, z) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z));
}
protected boolean canThisPlantGrowOnThisBlockID(int id, int meta)
{
// TODO
if (meta == 0)
return id == BOPBlocks.driedDirt.blockID || id == Block.sand.blockID;
else if (meta == 1)
return id == BOPBlocks.redRock.blockID;
else if (meta == 2 || meta == 3)
return id == Block.sand.blockID;
else if (meta == 4)
return id == BOPBlocks.holyGrass.blockID;
else
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
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 void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 5)
entity.attackEntityFrom(DamageSource.cactus, 1);
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
return meta;
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return -1;
}
@Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta)
{
super.harvestBlock(world, player, x, y, z, meta);
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 5)
return false;
return true;
}
@Override
public boolean isShearable(ItemStack item, World world, int x, int y, int z)
{
return true;
}
@Override
public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z)));
return ret;
}
@Override
public boolean isBlockFoliage(World world, int x, int y, int z)
{
return true;
}
}

View file

@ -18,6 +18,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import tdwp_ftw.biomesop.configuration.BOPItems;
@Deprecated
public class BlockBush extends BlockFlower implements IShearable
{
public BlockBush(int par1)

View file

@ -16,6 +16,7 @@ import net.minecraftforge.common.IShearable;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import tdwp_ftw.biomesop.configuration.BOPBlocks;
@Deprecated
public class BlockDeadGrass extends Block implements IShearable
{
protected BlockDeadGrass(int par1, Material par3Material)

View file

@ -14,6 +14,7 @@ import net.minecraftforge.common.IShearable;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import tdwp_ftw.biomesop.configuration.BOPBlocks;
@Deprecated
public class BlockDesertGrass extends Block implements IShearable
{
protected BlockDesertGrass(int par1, Material par3Material)

View file

@ -9,6 +9,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockDesertSprouts extends Block
{
protected BlockDesertSprouts(int par1, Material par3Material)

View file

@ -9,6 +9,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockDuneGrass extends Block
{
protected BlockDuneGrass(int par1, Material par3Material)

View file

@ -13,6 +13,7 @@ import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@Deprecated
public class BlockHighGrassBottom extends BlockFlower
{
public BlockHighGrassBottom(int par1)

View file

@ -10,6 +10,7 @@ import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import tdwp_ftw.biomesop.configuration.BOPBlocks;
@Deprecated
public class BlockHighGrassTop extends BlockFlower
{
public BlockHighGrassTop(int par1)

View file

@ -13,6 +13,7 @@ import net.minecraftforge.common.IShearable;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import tdwp_ftw.biomesop.configuration.BOPBlocks;
@Deprecated
public class BlockHolyTallGrass extends Block implements IShearable
{
protected BlockHolyTallGrass(int par1, Material par3Material)

View file

@ -18,6 +18,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import tdwp_ftw.biomesop.configuration.BOPItems;
@Deprecated
public class BlockMediumGrass extends BlockFlower implements IShearable
{
public BlockMediumGrass(int par1)

View file

@ -16,6 +16,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import tdwp_ftw.biomesop.configuration.BOPItems;
@Deprecated
public class BlockShortGrass extends BlockFlower implements IShearable
{
public BlockShortGrass(int par1)

View file

@ -18,6 +18,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import tdwp_ftw.biomesop.configuration.BOPItems;
@Deprecated
public class BlockSprout extends BlockFlower implements IShearable
{
public BlockSprout(int par1)

View file

@ -18,6 +18,7 @@ import net.minecraftforge.common.IShearable;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import tdwp_ftw.biomesop.configuration.BOPBlocks;
@Deprecated
public class BlockThorn extends Block implements IShearable
{
protected BlockThorn(int par1, Material par3Material)

View file

@ -11,6 +11,7 @@ import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockTinyCactus extends Block
{
protected BlockTinyCactus(int par1, Material par3Material)

View file

@ -9,6 +9,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockToadstool extends Block
{
protected BlockToadstool(int par1, Material par3Material)

View file

@ -15,10 +15,12 @@ import tdwp_ftw.biomesop.blocks.BlockBOPLog.LogCategory;
import tdwp_ftw.biomesop.blocks.BlockBOPSlab.SlabCategory;
import tdwp_ftw.biomesop.blocks.BlockBOPStairs.WoodCategory;
import tdwp_ftw.biomesop.items.ItemBOPFlower;
import tdwp_ftw.biomesop.items.ItemBOPFoliage;
import tdwp_ftw.biomesop.items.ItemBOPPlank;
import tdwp_ftw.biomesop.items.ItemBOPSlab;
import tdwp_ftw.biomesop.items.ItemBOPLeaves;
import tdwp_ftw.biomesop.items.ItemBOPLog;
import tdwp_ftw.biomesop.items.ItemBOPPlant;
import tdwp_ftw.biomesop.items.ItemBOPColorizedLeaves;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@ -478,8 +480,8 @@ public class BOPBlocks {
LanguageRegistry.addName(new ItemStack(Blocks.stoneSingleSlab.get(),1,0), "Red Rock Bricks Slab");
LanguageRegistry.addName(new ItemStack(Blocks.stoneSingleSlab.get(),1,1), "Red Rock Cobblestone Slab");
LanguageRegistry.addName(new ItemStack(Blocks.stoneSingleSlab.get(),1,2), "Mud Bricks Slab");
// Flowers - WORKING!
// Flowers - WORKING! - need a fix for tiny cactus
Blocks.flowers = Optional.of((new BlockBOPFlower(2002)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("flowers"));
GameRegistry.registerBlock(Blocks.flowers.get(), ItemBOPFlower.class, "flowers");
@ -492,8 +494,9 @@ public class BOPBlocks {
LanguageRegistry.addName(new ItemStack(Blocks.flowers.get(),1,6), "Wildflower");
LanguageRegistry.addName(new ItemStack(Blocks.flowers.get(),1,7), "Violet");
LanguageRegistry.addName(new ItemStack(Blocks.flowers.get(),1,8), "Anemone");
LanguageRegistry.addName(new ItemStack(Blocks.flowers.get(),1,9), "Toadstool");
LanguageRegistry.addName(new ItemStack(Blocks.flowers.get(),1,10), "Tiny Cactus");
// Leaves - Almost working, will have to fix drops
Blocks.leaves = Optional.of((new BlockBOPLeaves(2000)).setHardness(0.2F).setLightOpacity(1).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("leaves"));
GameRegistry.registerBlock(Blocks.leaves.get(), ItemBOPLeaves.class, "leaves");
@ -541,8 +544,29 @@ public class BOPBlocks {
LanguageRegistry.addName(new ItemStack(Blocks.logs3.get(),1,0), "Redwood Wood");
LanguageRegistry.addName(new ItemStack(Blocks.logs3.get(),1,1), "Willow Wood");
LanguageRegistry.addName(new ItemStack(Blocks.logs3.get(),1,2), "Dead Wood");
*/
// Foliage - WORKIMG!
Blocks.foliage = Optional.of((new BlockBOPFoliage(1988)).setUnlocalizedName("foliage"));
GameRegistry.registerBlock(Blocks.foliage.get(), ItemBOPFoliage.class, "foliage");
LanguageRegistry.addName(new ItemStack(Blocks.foliage.get(),1,0), "Short Grass");
LanguageRegistry.addName(new ItemStack(Blocks.foliage.get(),1,1), "Medium Grass");
LanguageRegistry.addName(new ItemStack(Blocks.foliage.get(),1,2), "High Grass");
LanguageRegistry.addName(new ItemStack(Blocks.foliage.get(),1,3), "Bush");
LanguageRegistry.addName(new ItemStack(Blocks.foliage.get(),1,4), "Sprout");
// Plants - Semi working
Blocks.plants = Optional.of((new BlockBOPPlant(1987)).setUnlocalizedName("plants"));
GameRegistry.registerBlock(Blocks.plants.get(), ItemBOPPlant.class, "plants");
LanguageRegistry.addName(new ItemStack(Blocks.plants.get(),1,0), "Dead Grass");
LanguageRegistry.addName(new ItemStack(Blocks.plants.get(),1,1), "Desert Grass");
LanguageRegistry.addName(new ItemStack(Blocks.plants.get(),1,2), "Desert Sprouts");
LanguageRegistry.addName(new ItemStack(Blocks.plants.get(),1,3), "Dune Grass");
LanguageRegistry.addName(new ItemStack(Blocks.plants.get(),1,4), "Holy Tall Grass");
LanguageRegistry.addName(new ItemStack(Blocks.plants.get(),1,5), "Thorns");
*/
// Add block registration
GameRegistry.registerBlock(mud, "mud");
GameRegistry.registerBlock(driedDirt, "driedDirt");

View file

@ -7,7 +7,7 @@ import net.minecraft.util.Icon;
public class ItemBOPFlower extends ItemBlock
{
private static final String[] plants = new String[] {"swampflower", "deadbloom", "glowflower", "hydrangea", "orangeflower", "pinkflower", "purpleflower", "violet", "whiteflower"};
private static final String[] plants = new String[] {"swampflower", "deadbloom", "glowflower", "hydrangea", "orangeflower", "pinkflower", "purpleflower", "violet", "whiteflower", "toadstool", "cactus"};
public ItemBOPFlower(int par1)
{

View file

@ -0,0 +1,81 @@
package tdwp_ftw.biomesop.items;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBOPFoliage extends ItemBlock
{
private static final String[] foliageTypes = new String[] {"shortgrass", "mediumgrass", "highgrass", "bush", "sprout", "highgrasstop"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
public ItemBOPFoliage(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@SideOnly(Side.CLIENT)
public void updateIcons(IconRegister iconRegister)
{
textures = new Icon[foliageTypes.length - 1];
for (int i = 0; i < foliageTypes.length - 1; ++i)
textures[i] = iconRegister.registerIcon("BiomesOPlenty:item" + foliageTypes[i]);
}
@Override
public int getMetadata(int meta)
{
return meta;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
return (new StringBuilder()).append(foliageTypes[itemStack.getItemDamage()]).toString();
}
@Override
public Icon getIconFromDamage(int meta)
{
if (meta == 5)
meta = 2;
return textures[meta];
}
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
if (itemStack.getItemDamage() != 2)
{
return super.onItemUse(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ);
}
else
{
++y;
if (!(player.canPlayerEdit(x, y, z, side, itemStack) || player.canPlayerEdit(x, y + 1, z, side, itemStack)))
return false;
else if (world.getBlockMaterial(x, y, z).isReplaceable() && world.getBlockMaterial(x, y + 1, z).isReplaceable())
{
world.setBlock(x, y, z, itemStack.itemID, 2, 2);
world.setBlock(x, y + 1, z, itemStack.itemID, 5, 2);
world.notifyBlocksOfNeighborChange(x, y, z, itemStack.itemID);
world.notifyBlocksOfNeighborChange(x, y + 1, z, itemStack.itemID);
Block block = Block.blocksList[itemStack.itemID];
world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
--itemStack.stackSize;
}
return true;
}
}
}

View file

@ -0,0 +1,36 @@
package tdwp_ftw.biomesop.items;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
public class ItemBOPPlant extends ItemBlock
{
private static final String[] plants = new String[] {"deadgrass", "desertgrass", "desertsprouts", "dunegrass", "holytallgrass", "thorn"};
public ItemBOPPlant(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
return (new StringBuilder()).append(plants[itemStack.getItemDamage()]).toString();
}
@Override
public Icon getIconFromDamage(int meta)
{
return Block.blocksList[this.itemID].getBlockTextureFromSideAndMetadata(0, meta);
}
}