Added the broken blocks to the repo for the sake of it

This commit is contained in:
Adubbz 2013-12-25 18:10:47 +11:00
parent f0e5ce3a6c
commit c0ea750d1b
67 changed files with 10213 additions and 0 deletions

View file

@ -0,0 +1,186 @@
package biomesoplenty.common.blocks;
import java.util.List;
import java.util.Random;
import javax.swing.Icon;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
public class BlockBOPAmethyst extends Block
{
public static final String[] types = new String[] {"amethystore", "amethystblock", "rubyore", "rubyblock", "peridotore", "peridotblock", "topazore", "topazblock", "tanzaniteore", "tanzaniteblock", "malachiteore", "malachiteblock", "sapphireore", "sapphireblock"};
private Icon[] textures;
public BlockBOPAmethyst()
{
super(Material.);
setStepSound(Block.soundStoneFootstep);
//TODO: this.setCreativeTab()
this.func_149647_a(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[types.length];
for (int i = 0; i < types.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:"+types[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
public int getDamageValue(World world, int x, int y, int z) {
return world.getBlockMetadata(x, y, z);
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list)
{
for (int i = 0; i < types.length; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public float getBlockHardness(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
return (meta % 2 == 0) ? 3.0F : 5.0F;
}
@Override
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
{
int meta = world.getBlockMetadata(x, y, z);
return (meta % 2 == 0) ? 1.0F : 2.0F;
}
@Override
public int idDropped(int meta, Random par2Random, int par3)
{
return (meta % 2 == 0) ? Items.gems.get().itemID : this.blockID;
}
@Override
public int damageDropped(int meta)
{
if (meta == 0)
{
return 0;
}
if (meta == 1)
{
return meta;
}
if (meta == 2)
{
return 1;
}
if (meta == 3)
{
return meta;
}
if (meta == 4)
{
return 2;
}
if (meta == 5)
{
return meta;
}
if (meta == 6)
{
return 3;
}
if (meta == 7)
{
return meta;
}
if (meta == 8)
{
return 4;
}
if (meta == 9)
{
return meta;
}
if (meta == 10)
{
return 5;
}
if (meta == 11)
{
return meta;
}
if (meta == 12)
{
return 6;
}
if (meta == 13)
{
return meta;
}
return meta;
}
@Override
public int quantityDropped(int meta, int fortune, Random random)
{
return (meta % 2 == 0) ? quantityDroppedWithBonus(fortune, random) : 1;
}
@Override
public int quantityDroppedWithBonus(int bonus, Random par2Random)
{
if (bonus > 0 && blockID != this.idDropped(0, par2Random, bonus))
{
int rnd = par2Random.nextInt(bonus + 2) - 1;
if (rnd < 0) {
rnd = 0;
}
return this.quantityDropped(par2Random) * (rnd + 1);
}
else
return this.quantityDropped(par2Random);
}
@Override
public void dropBlockAsItemWithChance(World world, int par2, int par3, int par4, int par5, float par6, int par7)
{
super.dropBlockAsItemWithChance(world, par2, par3, par4, par5, par6, par7);
if (this.idDropped(par5, world.rand, par7) != blockID)
{
int var8 = MathHelper.getRandomIntegerInRange(world.rand, 3, 7);
this.dropXpOnBlockBreak(world, par2, par3, par4, var8);
}
}
}

View file

@ -0,0 +1,355 @@
package biomesoplenty.common.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.FakePlayer;
import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPAppleLeaves extends BlockLeavesBase implements IShearable
{
private Icon[][] textures;
private Icon[] betterTextures;
int[] adjacentTreeBlocks;
public BlockBOPAppleLeaves(int blockID)
{
super(blockID, Material.leaves, false);
setBurnProperties(this.blockID, 30, 60);
this.setTickRandomly(true);
setHardness(0.2F);
setLightOpacity(1);
setStepSound(Block.soundGrassFootstep);
//TODO: this.setCreativeTab()
this.func_149647_a(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[3][4];
if(Loader.isModLoaded("BetterGrassAndLeavesMod"))
for (int i = 0; i < 4; ++i)
{
textures[0][i] = iconRegister.registerIcon("biomesoplenty:leaves_apple" + i + "_round");
textures[1][i] = iconRegister.registerIcon("biomesoplenty:leaves_apple" + i + "_fast");
textures[2][i] = iconRegister.registerIcon("biomesoplenty:better_leaves_apple" + i);
}
else
for (int i = 0; i < 4; ++i)
{
textures[0][i] = iconRegister.registerIcon("biomesoplenty:leaves_apple" + i + "_fancy");
textures[1][i] = iconRegister.registerIcon("biomesoplenty:leaves_apple" + i + "_fast");
}
}
public Icon getIconBetterLeaves(int metadata, float randomIndex)
{
return textures[2][metadata & 3];
}
public Icon getIconFallingLeaves(int metadata)
{
return textures[1][metadata & 3];
}
@Override
public Icon getIcon(int side, int meta)
{
return textures[(!isOpaqueCube() ? 0 : 1)][meta & 3];
}
@Override
public boolean isOpaqueCube()
{
return Block.leaves.isOpaqueCube();
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
list.add(new ItemStack(blockID, 1, 0));
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
if (world.canLightningStrikeAt(x, y + 1, z) && !world.doesBlockHaveSolidTopSurface(x, y - 1, z) && random.nextInt(15) == 1)
{
double d0 = x + random.nextFloat();
double d1 = y - 0.05D;
double d2 = z + random.nextFloat();
world.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
super.randomDisplayTick(world, x, y, z, random);
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
byte radius = 1;
int bounds = radius + 1;
if (world.checkChunksExist(x - bounds, y - bounds, z - bounds, x + bounds, y + bounds, z + bounds)) {
for (int i = -radius; i <= radius; ++i) {
for (int j = -radius; j <= radius; ++j) {
for (int k = -radius; k <= radius; ++k)
{
int blockID = world.getBlockId(x + i, y + j, z + k);
if (Block.blocksList[blockID] != null) {
Block.blocksList[blockID].beginLeavesDecay(world, x + i, y + j, z + k);
}
}
}
}
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
if (world.isRemote)
return;
int meta = world.getBlockMetadata(x, y, z);
if (random.nextInt(25) == 0)
if (meta > 0)
if ((meta & 3) < 3) {
world.setBlock(x, y, z, blockID, ++meta, 3);
}
if ((meta & 8) != 0/* && (meta & 4) == 0*/)
{
byte b0 = 4;
int i1 = b0 + 1;
byte b1 = 32;
int j1 = b1 * b1;
int k1 = b1 / 2;
if (adjacentTreeBlocks == null)
{
adjacentTreeBlocks = new int[b1 * b1 * b1];
}
int l1;
if (world.checkChunksExist(x - i1, y - i1, z - i1, x + i1, y + i1, z + i1))
{
int i2;
int j2;
int k2;
for (l1 = -b0; l1 <= b0; ++l1)
{
for (i2 = -b0; i2 <= b0; ++i2)
{
for (j2 = -b0; j2 <= b0; ++j2)
{
k2 = world.getBlockId(x + l1, y + i2, z + j2);
Block block = Block.blocksList[k2];
if (block != null && block.canSustainLeaves(world, x + l1, y + i2, z + j2))
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
}
else if (block != null && block.isLeaves(world, x + l1, y + i2, z + j2))
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
}
else
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
}
}
}
}
for (l1 = 1; l1 <= 4; ++l1)
{
for (i2 = -b0; i2 <= b0; ++i2)
{
for (j2 = -b0; j2 <= b0; ++j2)
{
for (k2 = -b0; k2 <= b0; ++k2)
{
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1)
{
if (adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
}
}
}
}
}
}
}
l1 = adjacentTreeBlocks[k1 * j1 + k1 * b1 + k1];
if (l1 >= 0)
{
world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4);
}
else
{
this.removeLeaves(world, x, y, z);
}
}
}
private void removeLeaves(World world, int x, int y, int z)
{
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
}
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
int meta = world.getBlockMetadata(x, y, z);
if ((meta & 3) == 3)
{
world.setBlock(x, y, z, blockID, meta - 3, 3);
EntityItem entityitem = new EntityItem(world, x, y, z, new ItemStack(Item.appleRed, 1, 0));
if (!world.isRemote) {
world.spawnEntityInWorld(entityitem);
if (!(player instanceof FakePlayer))
entityitem.onCollideWithPlayer(player);
}
return true;
}
else
return false;
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return Blocks.saplings.get().blockID;
}
@Override
public int damageDropped(int meta)
{
return 0;
}
@Override
public int quantityDropped(Random random)
{
return random.nextInt(20) == 0 ? 1 : 0;
}
@Override
public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int par7)
{
if (world.isRemote)
return;
if (world.rand.nextInt(20) == 0)
{
int var9 = this.idDropped(meta, world.rand, par7);
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(var9, 1, this.damageDropped(meta)));
}
if ((meta & 3) == 3) {
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Item.appleRed, 1, 0));
} else if ((meta & 3) == 2 && world.rand.nextInt(16) == 0) {
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Item.appleRed, 1, 0));
} else if ((meta & 3) == 1 && world.rand.nextInt(48) == 0) {
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Item.appleRed, 1, 0));
} else if ((meta & 3) == 0 && world.rand.nextInt(80) == 0) {
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Item.appleRed, 1, 0));
}
}
@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, 0));
return ret;
}
@SideOnly(Side.CLIENT)
public void setGraphicsLevel(boolean par1)
{
graphicsLevel = par1;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return true;
}
@Override
public void beginLeavesDecay(World world, int x, int y, int z)
{
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4);
}
@Override
public boolean isLeaves(World world, int x, int y, int z)
{
return true;
}
}

View file

@ -0,0 +1,415 @@
package biomesoplenty.common.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.swing.Icon;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.ColorizerFoliage;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearable
{
public static enum ColourizedLeafCategory
{
CAT1, CAT2, CAT3, CAT4;
}
//colorizedLeaves1
//Acacia (0)
//Mangrove (1)
//Palm (2)
//Redwood (3)
//colorizedLeaves2
//Willow (0)
//Pine (1)
private static final String[] leaves = new String[] {"acacia", "mangrove", "palm", "redwood", "willow", "pine"};
private IIcon[][] textures;
private final ColourizedLeafCategory category;
int[] adjacentTreeBlocks;
public BlockBOPColorizedLeaves(ColourizedLeafCategory cat)
{
//TODO: Material.leaves
super(Material.field_151584_j, false);
this.category = cat;
this.setTickRandomly(true);
this.setBurnProperties(this, 30, 60);
//TODO: this.setHardness
this.func_149711_c(0.2F);
setLightOpacity(1);
setStepSound(Block.soundGrassFootstep);
//TODO: this.setCreativeTab()
this.func_149647_a(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
//TODO: registerIcons()
public void func_149651_a(IIconRegister iconRegister)
{
textures = new IIcon[3][leaves.length];
if(Loader.isModLoaded("BetterGrassAndLeavesMod"))
{
for (int i = 0; i < leaves.length; ++i)
{
textures[0][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_round");
textures[1][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_fast");
textures[2][i] = iconRegister.registerIcon("biomesoplenty:better_leaves_" + leaves[i]);
}
}
else
{
for (int i = 0; i < leaves.length; ++i)
{
textures[0][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_fancy");
textures[1][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_fast");
}
}
}
public IIcon getIconBetterLeaves(int metadata, float randomIndex)
{
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return textures[2][type >= leaves.length ? 0 : type];
}
public IIcon getIconFallingLeaves(int metadata)
{
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return textures[1][type >= leaves.length ? 0 : type];
}
@Override
public int getBlockColor()
{
double temperature = 0.5D;
double humidity = 1.0D;
return ColorizerFoliage.getFoliageColor(temperature, humidity);
}
@Override
public int getRenderColor(int par1)
{
switch (par1)
{
case 0:
return ColorizerFoliage.getFoliageColorBirch();
case 3:
return ColorizerFoliage.getFoliageColorPine();
default:
return ColorizerFoliage.getFoliageColorBasic();
}
}
@Override
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
int var6 = 0;
int var7 = 0;
int var8 = 0;
for (int var9 = -1; var9 <= 1; ++var9)
{
for (int var10 = -1; var10 <= 1; ++var10)
{
int var11 = par1IBlockAccess.getBiomeGenForCoords(par2 + var10, par4 + var9).getBiomeFoliageColor();
var6 += (var11 & 16711680) >> 16;
var7 += (var11 & 65280) >> 8;
var8 += var11 & 255;
}
}
return (var6 / 9 & 255) << 16 | (var7 / 9 & 255) << 8 | var8 / 9 & 255;
}
@Override
//TODO: getIcon()
public IIcon func_149691_a(int side, int metadata)
{
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
//TODO: isOpaqueCube()
return textures[(!func_149662_c() ? 0 : 1)][type >= leaves.length ? 0 : type];
}
@Override
//TODO: isOpaqueCube()
public boolean func_149662_c()
{
//TODO: isOpaqueCube()
return Blocks.leaves.func_149662_c();
}
@Override
//TODO: getSubBlocks()
public void func_149666_a(Item block, CreativeTabs creativeTabs, List list)
{
for (int i = 0; i < 4; ++i)
{
if (category != ColourizedLeafCategory.CAT2 || i < 2)
{
list.add(new ItemStack(block, 1, i));
}
}
}
@Override
//TODO: randomDisplayTick()
public void func_149734_b(World world, int x, int y, int z, Random random)
{
//TODO: doesBlockHaveSolidTopSurface
if (world.canLightningStrikeAt(x, y + 1, z) && !World.func_147466_a(world, x, y - 1, z) && random.nextInt(15) == 1)
{
double d0 = x + random.nextFloat();
double d1 = y - 0.05D;
double d2 = z + random.nextFloat();
world.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
//TODO: randomDisplayTick()
super.func_149734_b(world, x, y, z, random);
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
byte radius = 1;
int bounds = radius + 1;
if (world.checkChunksExist(x - bounds, y - bounds, z - bounds, x + bounds, y + bounds, z + bounds)) {
for (int i = -radius; i <= radius; ++i) {
for (int j = -radius; j <= radius; ++j) {
for (int k = -radius; k <= radius; ++k)
{
int blockID = world.getBlockId(x + i, y + j, z + k);
if (Block.blocksList[blockID] != null) {
Block.blocksList[blockID].beginLeavesDecay(world, x + i, y + j, z + k);
}
}
}
}
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
if (world.isRemote)
return;
int meta = world.getBlockMetadata(x, y, z);
if ((meta & 8) != 0 && (meta & 4) == 0)
{
byte b0 = 4;
int i1 = b0 + 1;
byte b1 = 32;
int j1 = b1 * b1;
int k1 = b1 / 2;
if (adjacentTreeBlocks == null)
{
adjacentTreeBlocks = new int[b1 * b1 * b1];
}
int l1;
if (world.checkChunksExist(x - i1, y - i1, z - i1, x + i1, y + i1, z + i1))
{
int i2;
int j2;
int k2;
for (l1 = -b0; l1 <= b0; ++l1)
{
for (i2 = -b0; i2 <= b0; ++i2)
{
for (j2 = -b0; j2 <= b0; ++j2)
{
k2 = world.getBlockId(x + l1, y + i2, z + j2);
Block block = Block.blocksList[k2];
if (block != null && block.canSustainLeaves(world, x + l1, y + i2, z + j2))
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
}
else if (block != null && block.isLeaves(world, x + l1, y + i2, z + j2))
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
}
else
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
}
}
}
}
for (l1 = 1; l1 <= 4; ++l1)
{
for (i2 = -b0; i2 <= b0; ++i2)
{
for (j2 = -b0; j2 <= b0; ++j2)
{
for (k2 = -b0; k2 <= b0; ++k2)
{
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1)
{
if (adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
}
}
}
}
}
}
}
l1 = adjacentTreeBlocks[k1 * j1 + k1 * b1 + k1];
if (l1 >= 0)
{
world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4);
}
else
{
this.removeLeaves(world, x, y, z);
}
}
}
private void removeLeaves(World world, int x, int y, int z)
{
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return Blocks.colorizedSaplings.get().blockID;
}
@Override
public int damageDropped(int meta)
{
return getTypeFromMeta(meta) + category.ordinal() * 4;
}
@Override
public int getDamageValue(World par1World, int par2, int par3, int par4)
{
return getTypeFromMeta(par1World.getBlockMetadata(par2, par3, par4));
}
@Override
public int quantityDropped(Random random)
{
return random.nextInt(20) == 0 ? 1 : 0;
}
@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, getTypeFromMeta(world.getBlockMetadata(x, y, z))));
return ret;
}
public String getLeafType(int metadata)
{
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return leaves[type >= leaves.length ? 0 : type];
}
private static int getTypeFromMeta(int meta)
{
meta = meta & 3;
if (meta < 0 || meta >= leaves.length) {
meta = 0;
}
return meta;
}
@SideOnly(Side.CLIENT)
public void setGraphicsLevel(boolean par1)
{
graphicsLevel = par1;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return true;
}
@Override
public void beginLeavesDecay(World world, int x, int y, int z)
{
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4);
}
@Override
public boolean isLeaves(World world, int x, int y, int z)
{
return true;
}
}

View file

@ -0,0 +1,210 @@
package biomesoplenty.common.blocks;
import java.util.List;
import java.util.Random;
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.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPCoral extends BlockFlower
{
private static final String[] coral = new String[] {"kelpbottom", "kelpmiddle", "kelptop", "kelpsingle", "pinkcoral", "orangecoral", "bluecoral", "glowcoral"};
private Icon[] textures;
public BlockBOPCoral(int blockID)
{
super(blockID, Material.water);
this.setTickRandomly(true);
float f = 0.4F;
setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
//TODO: this.setCreativeTab()
this.func_149647_a(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[coral.length];
for (int i = 0; i < coral.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:" + coral[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
public int getRenderType()
{
return 1;
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < coral.length; ++i)
{
if (i > 2)
{
list.add(new ItemStack(blockID, 1, i));
}
}
}
@Override
protected boolean canThisPlantGrowOnThisBlockID(int id)
{
return id == Block.dirt.blockID || id == Block.sand.blockID || id == Block.sponge.blockID || id == Block.stone.blockID || id == Block.blockClay.blockID || id == blockID;
}
protected boolean canThisPlantGrowOnThisBlockID(int id, int metadata)
{
if (metadata == 1)
return id == blockID;
if (metadata == 2)
return id == blockID;
else
return id == Block.dirt.blockID || id == Block.sand.blockID || id == Block.sponge.blockID || id == Block.stone.blockID || id == Block.blockClay.blockID;
}
@Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack)
{
int id = world.getBlockId(x, y - 1, z);
int meta = itemStack.getItemDamage();
if (itemStack.itemID == blockID) {
switch (meta)
{
case 1: // Kelp Middle
return id == blockID;
case 2: // Kelp Top
return id == blockID;
default:
return id == Block.dirt.blockID || id == Block.sand.blockID || id == Block.sponge.blockID || id == Block.stone.blockID || id == Block.blockClay.blockID;
}
} else
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);
if (world.getBlockMetadata(x, y, z) == 0 && world.getBlockId(x, y + 1, z) != blockID)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if (world.getBlockMetadata(x, y, z) == 1 && world.getBlockId(x, y + 1, z) != blockID)
{
if (world.getBlockId(x, y - 1, z) == blockID)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
}
if (world.getBlockMetadata(x, y, z) == 0 || world.getBlockMetadata(x, y, z) == 1 || world.getBlockMetadata(x, y, z) == 2)
{
this.checkBlockCoordValid(world, x, y, z);
}
if (world.getBlockId(x, y, z) != this.blockID)
{
world.setBlock(x, y, z, Block.waterMoving.blockID, 0, 2);
}
}
protected final void checkBlockCoordValid(World world, int x, int y, int z)
{
for (int i = 1; world.getBlockId(x, y + i, z) == blockID; i++)
{
if (!this.canBlockStay(world, x, y + i, z))
{
this.dropBlockAsItem(world, x, y + i, z, world.getBlockMetadata(x, y + i, z), 0);
world.setBlock(x, y + i, z, Block.waterMoving.blockID, 0, 2);
}
}
}
@Override
public int damageDropped(int meta)
{
if (meta < 3)
{
return 3;
}
return meta;
}
@Override
public int quantityDropped(int meta, int fortune, Random random)
{
return 1;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 7)
return 10;
else
return 0;
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta < 3) {
meta = 3;
}
return meta;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
if (world.getBlockId(x, y, z) != blockID)
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
else
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z));
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
//ItemStack itemstack = new ItemStack(Blocks.flowers.get(), 1, 10);
if (world.getBlockMetadata(x, y, z) == 10)
//if (!world.isRemote)
//world.spawnEntityInWorld(new EntityItem(world, x, y, z, itemstack));
return true;
return false;
}
}

View file

@ -0,0 +1,346 @@
package biomesoplenty.common.blocks;
import java.util.List;
import java.util.Random;
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.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import biomesoplenty.blocks.renderers.RenderUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPFlower extends BlockFlower
{
private static final String[] plants = new String[] {"clover", "swampflower", "deadbloom", "glowflower", "hydrangea", "cosmos", "daffodil", "wildflower", "violet", "anemone", "lilyflower", "rainbowflower", "bromeliad", "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);
this.setTickRandomly(true);
float var4 = 0.2F;
this.setBlockBounds(0.5F - var4, 0.0F, 0.5F - var4, 0.5F + var4, var4 * 3.0F, 0.5F + var4);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
public BlockBOPFlower(int blockID)
{
this(blockID, Material.plants);
}
@Override
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
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
public int getRenderType()
{
return RenderUtils.foliageModel;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 3)
return 9;
else if (meta == 11)
return 5;
else
return 0;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4)
{
int meta = world.getBlockMetadata(par2, par3, par4);
switch (meta)
{
case 0:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.015625F, 1.0F);
break;
case 5:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.8F, 0.7F);
break;
case 6:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F);
break;
case 9:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.5F, 0.7F);
break;
case 10:
this.setBlockBounds(0.3F, -0.97F, 0.3F, 0.7F, -0.7F, 0.7F);
//this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
break;
case 11:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.4F, 0.7F);
break;
case 15:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F);
break;
default:
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
break;
}
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{
int meta = world.getBlockMetadata(x, y, z);
if (!world.isRemote && meta == 2 && entity instanceof EntityLivingBase)
{
if (entity instanceof EntityPlayer)
{
InventoryPlayer inventory = ((EntityPlayer)entity).inventory;
if (!((inventory.armorInventory[0] != null && inventory.armorInventory[0].itemID == Item.bootsLeather.itemID) && (inventory.armorInventory[1] != null && inventory.armorInventory[1].itemID == Item.legsLeather.itemID)))
{
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(Potion.wither.id, 200));
}
}
else
{
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(Potion.wither.id, 200));
}
}
}
/**
* A randomly called display update to be able to add particles or other items for display
*/
@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
super.randomDisplayTick(par1World, par2, par3, par4, par5Random);
int meta = par1World.getBlockMetadata(par2, par3, par4);
if (meta == 2)
{
if (par5Random.nextInt(4) != 0)
{
par1World.spawnParticle("townaura", par2 + par5Random.nextFloat(), par3 + par5Random.nextFloat(), par4 + par5Random.nextFloat(), 0.0D, 0.0D, 0.0D);
}
if (par5Random.nextInt(4) == 0)
{
par1World.spawnParticle("smoke", par2 + par5Random.nextFloat(), (par3), par4 + par5Random.nextFloat(), 0.0D, 0.0D, 0.0D);
}
}
}
@Override
@SideOnly(Side.CLIENT)
@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));
}
}
}
@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 || id == Blocks.longGrass.get().blockID || id == Blocks.overgrownNetherrack.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 || id == Blocks.longGrass.get().blockID || id == Blocks.overgrownNetherrack.get().blockID;
if (metadata == 10) //Lily Flower
return id == Block.waterlily.blockID;
if (metadata == 11) //Rainbow Flower
return id == Blocks.holyGrass.get().blockID || id == Blocks.holyDirt.get().blockID || id == Block.grass.blockID || id == Block.dirt.blockID;
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 == blockID;
else
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.longGrass.get().blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
@Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack)
{
int id = world.getBlockId(x, y - 1, z);
int meta = itemStack.getItemDamage();
//boolean sky = world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z);
if (itemStack.itemID == blockID) {
switch (meta)
{
case 6: // Tulip
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.holyGrass.get().blockID || id == Blocks.longGrass.get().blockID || id == Blocks.overgrownNetherrack.get().blockID;
case 10: // Lily Flower
return id == Block.waterlily.blockID;
case 11: // Rainbow Flower
return id == Blocks.holyGrass.get().blockID || id == Blocks.holyDirt.get().blockID || id == Block.grass.blockID || id == Block.dirt.blockID;
case 12: // Aloe
return id == Blocks.hardDirt.get().blockID || id == Blocks.redRock.get().blockID || id == Block.sand.blockID;
case 14: // Sunflower Top
return id == blockID;
default:
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.longGrass.get().blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
} else
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) == blockID && world.getBlockMetadata(x, y - 1, z) != SUNFLOWERBOTTOM) {
world.setBlockToAir(x, y, z);
}
if (world.getBlockMetadata(x, y, z) == SUNFLOWERBOTTOM && world.getBlockId(x, y + 1, z) != blockID) {
world.setBlockToAir(x, y, z);
}
}
@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)
{
int meta = world.getBlockMetadata(x, y, z);
if (world.getBlockId(x, y, z) != blockID)
{
if (meta == 11)
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
else
return (world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z)) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
}
else
{
if (meta == 11)
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z));
else
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 harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta)
{
super.harvestBlock(world, player, x, y, z, meta);
ItemStack equippedItem = player.getCurrentEquippedItem();
if (equippedItem != null)
{
if (equippedItem.itemID != Item.shears.itemID)
{
if (meta == 2)
{
if (!world.isRemote)
{
player.addPotionEffect(new PotionEffect(Potion.wither.id, 300));
}
}
}
}
else
{
if (meta == 2)
{
if (!world.isRemote)
{
player.addPotionEffect(new PotionEffect(Potion.wither.id, 300));
}
}
}
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
//ItemStack itemstack = new ItemStack(Blocks.flowers.get(), 1, 10);
if (world.getBlockMetadata(x, y, z) == 10)
//if (!world.isRemote)
//world.spawnEntityInWorld(new EntityItem(world, x, y, z, itemstack));
return true;
return false;
}
}

View file

@ -0,0 +1,262 @@
package biomesoplenty.common.blocks;
import java.util.List;
import java.util.Random;
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.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPFlower2 extends BlockFlower
{
private static final String[] plants2 = new String[] {"hibiscus", "lilyofthevalley", "burningblossom", "lavender", "goldenrod", "bluebells", "minersdelight", "icyiris"};
private Icon[] textures;
protected BlockBOPFlower2(int blockID, Material material)
{
super(blockID, material);
this.setTickRandomly(true);
float var4 = 0.2F;
this.setBlockBounds(0.5F - var4, 0.0F, 0.5F - var4, 0.5F + var4, var4 * 3.0F, 0.5F + var4);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
public BlockBOPFlower2(int blockID)
{
this(blockID, Material.plants);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[plants2.length];
for (int i = 0; i < plants2.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:" + plants2[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
public int getRenderType()
{
return 1;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 2)
return 9;
else
return 0;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4)
{
int meta = world.getBlockMetadata(par2, par3, par4);
switch (meta)
{
default:
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
break;
}
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{
if (world.getBlockMetadata(x, y, z) == 2)
{
if (entity instanceof EntityPlayer)
{
InventoryPlayer inventory = ((EntityPlayer)entity).inventory;
if (!((inventory.armorInventory[0] != null && inventory.armorInventory[0].itemID == Item.bootsLeather.itemID) && (inventory.armorInventory[1] != null && inventory.armorInventory[1].itemID == Item.legsLeather.itemID)))
{
entity.setFire(1);
}
}
else
{
entity.setFire(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);
ItemStack equippedItem = player.getCurrentEquippedItem();
if (equippedItem != null)
{
if (equippedItem.itemID != Item.shears.itemID)
{
if (meta == 2)
{
player.setFire(5);
}
}
}
else
{
if (meta == 2)
{
player.setFire(5);
}
}
}
/**
* A randomly called display update to be able to add particles or other items for display
*/
@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
super.randomDisplayTick(par1World, par2, par3, par4, par5Random);
int meta = par1World.getBlockMetadata(par2, par3, par4);
if (meta == 2)
{
if (par5Random.nextInt(2) == 0)
{
par1World.spawnParticle("smoke", par2 + par5Random.nextFloat(), par3 + par5Random.nextFloat(), par4 + par5Random.nextFloat(), 0.0D, 0.0D, 0.0D);
}
if (par5Random.nextInt(4) == 0)
{
par1World.spawnParticle("flame", par2 + par5Random.nextFloat(), par3 + par5Random.nextFloat(), par4 + par5Random.nextFloat(), 0.0D, 0.0D, 0.0D);
}
}
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < plants2.length; ++i)
{
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
protected boolean canThisPlantGrowOnThisBlockID(int id)
{
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Block.netherrack.blockID || id == Blocks.longGrass.get().blockID || id == Block.stone.blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
protected boolean canThisPlantGrowOnThisBlockID(int id, int metadata)
{
if (metadata == 2) // Burning Blossom
return id == Block.netherrack.blockID || id == Blocks.overgrownNetherrack.get().blockID;
else if (metadata == 6) // Burning Blossom
return id == Block.stone.blockID;
else
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.longGrass.get().blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
@Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack)
{
int id = world.getBlockId(x, y - 1, z);
int meta = itemStack.getItemDamage();
//boolean sky = world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z);
if (itemStack.itemID == blockID) {
switch (meta)
{
case 2: // Burning Blossom
return id == Block.netherrack.blockID || id == Blocks.overgrownNetherrack.get().blockID;
case 6: // Miner's Delight
return id == Block.stone.blockID;
default:
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.longGrass.get().blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
} else
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);
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
return meta;
}
@Override
public int damageDropped(int meta)
{
return meta & 15;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (world.getBlockId(x, y, z) != blockID)
{
if (meta == 2 || meta == 6)
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
else
return (world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z)) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
}
else
{
if (meta == 2 || meta == 6)
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z));
else
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 boolean isBlockReplaceable(World world, int x, int y, int z)
{
//ItemStack itemstack = new ItemStack(Blocks.flowers.get(), 1, 10);
if (world.getBlockMetadata(x, y, z) == 10)
//if (!world.isRemote)
//world.spawnEntityInWorld(new EntityItem(world, x, y, z, itemstack));
return true;
return false;
}
}

View file

@ -0,0 +1,427 @@
package biomesoplenty.common.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTallGrass;
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.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.ColorizerFoliage;
import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.FakePlayer;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import biomesoplenty.api.Items;
import biomesoplenty.blocks.renderers.RenderUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPFoliage extends BlockTallGrass implements IShearable
{
private static final String[] foliageTypes = new String[] {"algae", "shortgrass", "mediumgrass", "highgrassbottom", "bush", "sprout", "highgrasstop", "poisonivy", "berrybush", "shrub", "wheatgrass", "dampgrass", "koru", "cloverpatch"};
private Icon[] textures;
public Icon shrubBranch;
public Icon berryBushBerry;
private static final int GRASSTOP = 6;
private static final int ALGAE = 0;
private static final int GRASSBOTTOM = 3;
public BlockBOPFoliage(int blockID)
{
super(blockID);
float f = 0.4F;
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(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
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]);
}
shrubBranch = iconRegister.registerIcon("biomesoplenty:" + "shrub_branch");
berryBushBerry = iconRegister.registerIcon("biomesoplenty:" + "berrybush_berry");
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs par2CreativeTabs, List list)
{
for (int i = 0; i < foliageTypes.length; ++i)
if (i != GRASSTOP) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int meta, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
switch (meta)
{
case 1:
case 2:
case 3:
case 10:
case 11:
if (world.rand.nextInt(8) != 0)
return ret;
ItemStack item = ForgeHooks.getGrassSeed(world);
if (item != null) {
ret.add(item);
}
break;
case 5:
if (world.rand.nextInt(50) != 0)
return ret;
if (world.rand.nextInt(2) == 0) {
ret.add(new ItemStack(Item.carrot,1));
} else {
ret.add(new ItemStack(Item.potato,1));
}
break;
case 12:
if (world.rand.nextInt(32) != 0)
return ret;
if (world.rand.nextInt(2) == 0) {
ret.add(new ItemStack(Items.turnipseeds.get(),1));
}
break;
case 8:
ret.add(new ItemStack(Items.food.get(), 1, 0));
break;
}
return ret;
}
@Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack)
{
int id = world.getBlockId(x, y - 1, z);
int meta = itemStack.getItemDamage();
if (itemStack.itemID == blockID) {
switch (meta)
{
case ALGAE: // Dead Grass
return id == Block.waterStill.blockID;
default:
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.longGrass.get().blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
} else
return this.canPlaceBlockOnSide(world, x, y, z, side);
}
@Override
protected boolean canThisPlantGrowOnThisBlockID(int id)
{
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.longGrass.get().blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
protected boolean canThisPlantGrowOnThisBlockID(int blockID, int metadata)
{
if (metadata == GRASSTOP)
return blockID == this.blockID;
else if (metadata == ALGAE)
return blockID == Block.waterStill.blockID;
else
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID || blockID == Blocks.longGrass.get().blockID || blockID == Blocks.overgrownNetherrack.get().blockID;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
if (world.getBlockId(x, y, z) != blockID)
{
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
public void onNeighborBlockChange(World world, int x, int y, int z, int neighbourID)
{
int metadata = world.getBlockMetadata(x, y, z);
if (world.getBlockMetadata(x, y, z) == GRASSBOTTOM)
{
if (world.getBlockId(x, y + 1, z) != blockID)
{
world.setBlock(x, y, z, Block.tallGrass.blockID, 1, 2);
}
else if (!canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z)))
{
this.dropBlockAsItem(world, x, y + 1, z, world.getBlockMetadata(x, y + 1, z), 0);
world.setBlockToAir(x, y + 1, z);
}
}
super.onNeighborBlockChange(world, x, y, z, neighbourID);
this.checkFlowerChange(world, x, y, z);
}
@Override
public void onEntityCollidedWithBlock(World par1World, int x, int y, int z, Entity par5Entity)
{
int meta = par1World.getBlockMetadata(x, y, z);
if (!par1World.isRemote && meta == 7)
{
if (par5Entity instanceof EntityLivingBase)
{
if (par5Entity instanceof EntityPlayer)
{
InventoryPlayer inventory = ((EntityPlayer)par5Entity).inventory;
if (!((inventory.armorInventory[0] != null && inventory.armorInventory[0].itemID == Item.bootsLeather.itemID) && (inventory.armorInventory[1] != null && inventory.armorInventory[1].itemID == Item.legsLeather.itemID)))
{
((EntityLivingBase)par5Entity).addPotionEffect(new PotionEffect(Potion.poison.id, 100));
}
}
else
{
((EntityLivingBase)par5Entity).addPotionEffect(new PotionEffect(Potion.poison.id, 100));
}
}
}
}
@Override
@SideOnly(Side.CLIENT)
public int getBlockColor()
{
double var1 = 0.5D;
double var3 = 1.0D;
return ColorizerGrass.getGrassColor(var1, var3);
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int par1)
{
return ColorizerFoliage.getFoliageColorBasic();
}
@Override
public int getRenderType()
{
return RenderUtils.foliageModel;
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
if (par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 9)
{
return par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeFoliageColor();
}
return par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeGrassColor();
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == GRASSTOP) {
meta = GRASSBOTTOM;
}
return meta;
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return -1;
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
switch (meta)
{
case ALGAE:
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1.0D, y + 0.015625D, z + 1.0D);
case 1: // Short Grass
return AxisAlignedBB.getBoundingBox(x + 0.1D, y, z + 0.1D, x + 0.9D, y + 0.25D, z + 0.9D);
case 2: // Medium Grass
return AxisAlignedBB.getBoundingBox(x + 0.1D, y, z + 0.1D, x + 0.9D, y + 0.6D, z + 0.9D);
case 13: //Clover Patch
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1.0D, y + 0.015625D, z + 1.0D);
default:
return AxisAlignedBB.getBoundingBox(x + 0.1D, y, z + 0.1D, x + 0.9D, y + 0.8D, z + 0.9D);
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int x, int y, int z)
{
int meta = iblockaccess.getBlockMetadata(x, y, z);
float minX;
float minY;
float minZ;
float maxX;
float maxY;
float maxZ;
switch (meta)
{
case ALGAE:
minX = minY = minZ = 0F;
maxX = maxZ = 1.0F;
maxY = 0.015625F;
break;
case 1: // Short grass
minX = minZ = 0.1F;
minY = 0.0F;
maxX = maxZ = 0.9F;
maxY = 0.25F;
break;
case 2: // Medium grass
minX = minZ = 0.1F;
minY = 0.0F;
maxX = maxZ = 0.9F;
maxY = 0.6F;
break;
case 13:
minX = minY = minZ = 0F;
maxX = maxZ = 1.0F;
maxY = 0.015625F;
break;
default:
minX = minZ = 0.1F;
minY = 0.0F;
maxX = maxZ = 0.9F;
maxY = 0.8F;
break;
}
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
@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 onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 8)
{
world.setBlock(x, y, z, blockID, 4, 3);
EntityItem entityitem = new EntityItem(world, x, y, z, new ItemStack(Items.food.get(), 1, 0));
if (!world.isRemote) {
world.spawnEntityInWorld(entityitem);
if (!(player instanceof FakePlayer))
entityitem.onCollideWithPlayer(player);
}
return true;
}
else
return false;
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
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>();
if (world.getBlockMetadata(x, y, z) == GRASSTOP)
{
ret.add(new ItemStack(Block.tallGrass, 1, 1));
}
else if (world.getBlockMetadata(x, y, z) == 8)
{
ret.add(new ItemStack(Blocks.foliage.get(), 1, 4));
}
else
{
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

@ -0,0 +1,167 @@
package biomesoplenty.common.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.util.Icon;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Items;
public class BlockBOPGeneric extends Block
{
public enum BlockType
{
ASH_STONE, HARD_SAND, HARD_DIRT, HARD_ICE, DRIED_DIRT, CRAG_ROCK, MUD_BRICK, HOLY_DIRT, CRYSTAL;
}
private Icon texture;
private BlockType type;
public BlockBOPGeneric(int id, Material material, BlockType type)
{
super(id, material);
this.type = type;
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
switch (type)
{
case ASH_STONE:
setHardness(1.0F).setStepSound(Block.soundStoneFootstep);
break;
case CRAG_ROCK:
setHardness(1.0F).setStepSound(Block.soundGravelFootstep);
break;
case DRIED_DIRT:
setHardness(0.1F).setStepSound(Block.soundStoneFootstep);
break;
case HARD_DIRT:
setHardness(0.9F).setStepSound(Block.soundStoneFootstep);
break;
case HARD_ICE:
setHardness(0.75F).setStepSound(Block.soundStoneFootstep);
break;
case HARD_SAND:
setHardness(0.7F).setStepSound(Block.soundSandFootstep);
break;
case MUD_BRICK:
setHardness(1.0F).setResistance(2.0F).setStepSound(Block.soundStoneFootstep);
break;
case HOLY_DIRT:
setHardness(0.6F).setStepSound(Block.soundGravelFootstep);
break;
case CRYSTAL:
setHardness(0.15F).setResistance(5.0F).setLightValue(1.0F).setStepSound(Block.soundGlassFootstep);
break;
default:
break;
}
}
@Override
public String getUnlocalizedName()
{
return "tile.bop.generic" + "." + type.toString().toLowerCase();
}
@Override
public void registerIcons(IconRegister iconRegister)
{
switch (type)
{
case ASH_STONE:
texture = iconRegister.registerIcon("biomesoplenty:ashstone");
break;
case CRAG_ROCK:
texture = iconRegister.registerIcon("biomesoplenty:cragrock");
break;
case DRIED_DIRT:
texture = iconRegister.registerIcon("biomesoplenty:drieddirt");
break;
case HARD_DIRT:
texture = iconRegister.registerIcon("biomesoplenty:harddirt");
break;
case HARD_ICE:
texture = iconRegister.registerIcon("biomesoplenty:hardice");
break;
case HARD_SAND:
texture = iconRegister.registerIcon("biomesoplenty:hardsand");
break;
case MUD_BRICK:
texture = iconRegister.registerIcon("biomesoplenty:mudbrick");
break;
case HOLY_DIRT:
texture = iconRegister.registerIcon("biomesoplenty:holydirt");
break;
case CRYSTAL:
texture = iconRegister.registerIcon("biomesoplenty:crystal");
break;
default:
break;
}
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
switch (type)
{
case CRYSTAL:
return Items.miscItems.get().itemID;
default:
return blockID;
}
}
@Override
public int damageDropped(int meta)
{
switch (type)
{
case CRYSTAL:
return 4;
default:
return meta;
}
}
@Override
public int quantityDropped(int meta, int fortune, Random random)
{
switch (type)
{
case CRYSTAL:
return 4;
default:
return 1;
}
}
@Override
public Icon getIcon(int side, int meta)
{
return texture;
}
}

View file

@ -0,0 +1,191 @@
package biomesoplenty.common.blocks;
import static net.minecraftforge.common.ForgeDirection.UP;
import java.util.List;
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.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderEnd;
import net.minecraftforge.common.ForgeDirection;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
public class BlockBOPGrass extends Block
{
private Icon[][] blockIcon = new Icon[2][6];
public BlockBOPGrass(int par1)
{
super(par1, Material.grass);
this.setTickRandomly(true);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
setStepSound(Block.soundGrassFootstep);
setHardness(0.6F);
//setLightValue(0.25F);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
blockIcon[0][0] = iconRegister.registerIcon("biomesoplenty:holydirt");
blockIcon[0][1] = iconRegister.registerIcon("biomesoplenty:holygrass_top");
blockIcon[0][2] = iconRegister.registerIcon("biomesoplenty:holygrass_side");
blockIcon[0][3] = iconRegister.registerIcon("biomesoplenty:holygrass_side");
blockIcon[0][4] = iconRegister.registerIcon("biomesoplenty:holygrass_side");
blockIcon[0][5] = iconRegister.registerIcon("biomesoplenty:holygrass_side");
blockIcon[1][0] = iconRegister.registerIcon("biomesoplenty:smolderinggrass_bottom");
blockIcon[1][1] = iconRegister.registerIcon("biomesoplenty:smolderinggrass_top");
blockIcon[1][2] = iconRegister.registerIcon("biomesoplenty:smolderinggrass_side");
blockIcon[1][3] = iconRegister.registerIcon("biomesoplenty:smolderinggrass_side");
blockIcon[1][4] = iconRegister.registerIcon("biomesoplenty:smolderinggrass_side");
blockIcon[1][5] = iconRegister.registerIcon("biomesoplenty:smolderinggrass_side");
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= blockIcon.length)
meta = 1;
if (side < 0 || side >= blockIcon[meta].length)
side = 1;
return blockIcon[meta][side];
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < 2; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public int damageDropped(int meta)
{
return meta;
}
@Override
public boolean isFireSource(World world, int x, int y, int z, int metadata, ForgeDirection side)
{
int blockId = world.getBlockId(x, y, z);
if (metadata == 0)
{
if (blockId == this.blockID && side == UP && world.provider.dimensionId == -1)
return true;
}
else if (metadata == 1) return true;
return super.isFireSource(world, x, y, z, metadata, side);
}
@Override
public int onBlockPlaced(World world, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int meta)
{
if (meta == 0)
if (world.provider.isHellWorld)
{
world.playSound(par2, par3, par4, "mob.ghast.death", 20.0F, 0.95F + (float)Math.random() * 0.1F, true);
for (int l = 0; l < 8; ++l)
{
world.spawnParticle("flame", par2 + Math.random(), par3 + Math.random(), par4 + Math.random(), 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", par2 + Math.random(), par3 + Math.random(), par4 + Math.random(), 0.0D, 0.0D, 0.0D);
}
}
return meta;
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
if (!world.isRemote)
return;
if (world.getBlockMetadata(x, y, z) == 1)
{
if (random.nextInt(4) == 0) {
world.spawnParticle("smoke", x + random.nextFloat(), y + 1.1F, z + random.nextFloat(), 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(6) == 0) {
world.spawnParticle("flame", x + random.nextFloat(), y + 1.1F, z + random.nextFloat(), 0.0D, 0.0D, 0.0D);
}
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
if (world.getBlockMetadata(x, y, z) == 0)
{
if (world.provider.isHellWorld)
{
world.setBlock(x, y + 1, z, Block.fire.blockID);
world.setBlock(x, y, z, Blocks.holyGrass.get().blockID, 1, 2);
}
if (!world.isRemote)
{
if (world.getBlockLightValue(x, y + 1, z) < 4 && Block.lightOpacity[world.getBlockId(x, y + 1, z)] > 2)
{
world.setBlock(x, y, z, Blocks.holyDirt.get().blockID);
}
else if (world.getBlockLightValue(x, y + 1, z) >= 9)
{
for (int var6 = 0; var6 < 4; ++var6)
{
int var7 = x + random.nextInt(3) - 1;
int var8 = y + random.nextInt(5) - 3;
int var9 = z + random.nextInt(3) - 1;
int var10 = world.getBlockId(var7, var8 + 1, var9);
if (world.getBlockId(var7, var8, var9) == Blocks.holyDirt.get().blockID && world.getBlockLightValue(var7, var8 + 1, var9) >= 4 && Block.lightOpacity[var10] <= 2)
{
world.setBlock(var7, var8, var9, Blocks.holyGrass.get().blockID, 0, 2);
}
}
}
}
}
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
if (world.getBlockMetadata(x, y, z) == 1)
{
float f = 0.02F;
return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1 - f, z + 1);
}
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{
if (world.getBlockMetadata(x, y, z) == 1) {
entity.setFire(2);
}
}
@Override
public int idDropped(int meta, Random par2Random, int par3)
{
return meta == 0 ? Blocks.holyDirt.get().blockID : Block.dirt.blockID;
}
}

View file

@ -0,0 +1,429 @@
package biomesoplenty.common.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import biomesoplenty.api.Items;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPLeaves extends BlockLeavesBase implements IShearable
{
public static enum LeafCategory
{
CAT1, CAT2, CAT3, CAT4;
}
//leaves1
//Yellow Autumn (0)
//Bamboo (1)
//Magic (2)
//Dark (3)
//leaves2
//Dead (0)
//Fir (1)
//Loftwood (2)
//Orange Autumn (3)
//leaves3
//Origin (0)
//Pink Cherry (1)
//Maple (2)
//White Cherry (3)
//leaves4
//Hellbark (0)
//Jacaranda (1)
private static final String[] leaves = new String[] {"yellowautumn", "bamboo", "magic", "dark", "dead", "fir", "holy", "orangeautumn", "origin", "pinkcherry", "maple", "whitecherry", "hellbark", "jacaranda"};
private static final float[] fallingLeavesChance = new float[] {0.1F, 0.008F, 0.016F, 0.008F, 0.0F, 0.008F, 0.016F, 0.1F, 0.008F, 0.1F, 0.008F, 0.1F, 0.008F, 0.008F};
private Icon[][] textures;
private final LeafCategory category;
int[] adjacentTreeBlocks;
public BlockBOPLeaves(int blockID, LeafCategory cat)
{
super(blockID, Material.leaves, false);
category = cat;
this.setTickRandomly(true);
setHardness(0.2F);
setLightOpacity(1);
setStepSound(Block.soundGrassFootstep);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[3][leaves.length];
if(Loader.isModLoaded("BetterGrassAndLeavesMod"))
for (int i = 0; i < leaves.length; ++i)
{
textures[0][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_round");
textures[1][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_fast");
textures[2][i] = iconRegister.registerIcon("biomesoplenty:better_leaves_" + leaves[i]);
}
else
for (int i = 0; i < leaves.length; ++i)
{
textures[0][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_fancy");
textures[1][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_fast");
}
}
public Icon getIconBetterLeaves(int metadata, float randomIndex)
{
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return textures[2][type >= leaves.length ? 0 : type];
}
public Icon getIconFallingLeaves(int metadata)
{
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return textures[1][type >= leaves.length ? 0 : type];
}
public float getSpawnChanceFallingLeaves(int metadata)
{
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return fallingLeavesChance[type >= leaves.length ? 0 : type];
}
@Override
public Icon getIcon(int side, int metadata)
{
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return textures[(!isOpaqueCube() ? 0 : 1)][type >= leaves.length ? 0 : type];
}
@Override
public boolean isOpaqueCube()
{
return Block.leaves.isOpaqueCube();
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list)
{
for (int i = 0; i < 4; ++i)
{
if (category != LeafCategory.CAT4 || i < 2)
{
list.add(new ItemStack(blockID, 1, i));
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
if (world.canLightningStrikeAt(x, y + 1, z) && !world.doesBlockHaveSolidTopSurface(x, y - 1, z) && random.nextInt(15) == 1)
{
double d0 = x + random.nextFloat();
double d1 = y - 0.05D;
double d2 = z + random.nextFloat();
world.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
if (world.getBlockId(x, y, z) == Blocks.leaves1.get().blockID && world.getBlockMetadata(x, y, z) == 2)
{
if (!(world.getBlockId(x, y - 1, z) == Blocks.leaves1.get().blockID && world.getBlockMetadata(x, y - 1, z) == 2))
{
if (random.nextInt(5) == 0)
{
BiomesOPlenty.proxy.spawnParticle("magictree", x + random.nextFloat(), y + 0.9F, z + random.nextFloat());
}
}
}
super.randomDisplayTick(world, x, y, z, random);
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
byte radius = 1;
int bounds = radius + 1;
if (world.checkChunksExist(x - bounds, y - bounds, z - bounds, x + bounds, y + bounds, z + bounds)) {
for (int i = -radius; i <= radius; ++i) {
for (int j = -radius; j <= radius; ++j) {
for (int k = -radius; k <= radius; ++k)
{
int blockID = world.getBlockId(x + i, y + j, z + k);
if (Block.blocksList[blockID] != null) {
Block.blocksList[blockID].beginLeavesDecay(world, x + i, y + j, z + k);
}
}
}
}
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
if (world.isRemote)
return;
int meta = world.getBlockMetadata(x, y, z);
if ((meta & 8) != 0 && (meta & 4) == 0)
{
byte b0 = 4;
int i1 = b0 + 1;
byte b1 = 32;
int j1 = b1 * b1;
int k1 = b1 / 2;
if (adjacentTreeBlocks == null)
{
adjacentTreeBlocks = new int[b1 * b1 * b1];
}
int l1;
if (world.checkChunksExist(x - i1, y - i1, z - i1, x + i1, y + i1, z + i1))
{
int i2;
int j2;
int k2;
for (l1 = -b0; l1 <= b0; ++l1)
{
for (i2 = -b0; i2 <= b0; ++i2)
{
for (j2 = -b0; j2 <= b0; ++j2)
{
k2 = world.getBlockId(x + l1, y + i2, z + j2);
Block block = Block.blocksList[k2];
if (block != null && block.canSustainLeaves(world, x + l1, y + i2, z + j2))
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
}
else if (block != null && block.isLeaves(world, x + l1, y + i2, z + j2))
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
}
else
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
}
}
}
}
for (l1 = 1; l1 <= 4; ++l1)
{
for (i2 = -b0; i2 <= b0; ++i2)
{
for (j2 = -b0; j2 <= b0; ++j2)
{
for (k2 = -b0; k2 <= b0; ++k2)
{
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1)
{
if (adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
}
}
}
}
}
}
}
l1 = adjacentTreeBlocks[k1 * j1 + k1 * b1 + k1];
if (l1 >= 0)
{
world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4);
}
else
{
this.removeLeaves(world, x, y, z);
}
}
}
private void removeLeaves(World world, int x, int y, int z)
{
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
}
@Override
public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
if (category == LeafCategory.CAT4 && metadata == 0)
return 0;
else
{
super.setBurnProperties(blockID, 30, 60);
return blockFlammability[blockID];
}
}
@Override
public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face)
{
if (category == LeafCategory.CAT4 && metadata == 0)
return 0;
else
return blockFireSpreadSpeed[blockID];
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
if (category == LeafCategory.CAT4 && metadata == 0)
return false;
else
return getFlammability(world, x, y, z, metadata, face) > 0;
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return Blocks.saplings.get().blockID;
}
@Override
public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int par7)
{
if (world.isRemote)
return;
if (world.rand.nextInt(20) == 0)
{
int var9 = this.idDropped(meta, world.rand, par7);
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(var9, 1, this.damageDropped(meta)));
}
if (((meta & 3) == 0 || (meta & 3) == 4 || (meta & 3) == 7) && (world.rand.nextInt(50) == 0)) {
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Items.food.get(), 1, 8));
}
}
@Override
public int damageDropped(int meta)
{
return (getTypeFromMeta(meta) + category.ordinal() * 4) + 1;
}
@Override
public int getDamageValue(World par1World, int par2, int par3, int par4)
{
return getTypeFromMeta(par1World.getBlockMetadata(par2, par3, par4));
}
@Override
public int quantityDropped(Random random)
{
return random.nextInt(20) == 0 ? 1 : 0;
}
@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, getTypeFromMeta(world.getBlockMetadata(x, y, z))));
return ret;
}
public String getLeafType(int metadata)
{
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return leaves[type >= leaves.length ? 0 : type];
}
private static int getTypeFromMeta(int meta)
{
meta = meta & 3;
if (meta < 0 || meta >= leaves.length) {
meta = 0;
}
return meta;
}
@SideOnly(Side.CLIENT)
public void setGraphicsLevel(boolean par1)
{
graphicsLevel = par1;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return true;
}
@Override
public void beginLeavesDecay(World world, int x, int y, int z)
{
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4);
}
@Override
public boolean isLeaves(World world, int x, int y, int z)
{
return true;
}
}

View file

@ -0,0 +1,224 @@
package biomesoplenty.common.blocks;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import biomesoplenty.BiomesOPlenty;
public class BlockBOPLog extends Block
{
public static enum LogCategory
{
CAT1, CAT2, CAT3, CAT4;
}
//logs1
//Acacia (0)
//Cherry (1)
//Dark (2)
//Fir (3)
//logs2
//Loftwood (0)
//Magic (1)
//Mangrove (2)
//Palm (3)
//logs3
//Redwood (0)
//Willow (1)
//Dead (2)
//Giant Flower Stem (3)
//logs4
//Pine (0)
//Hellbark (1)
//Jacaranda (2)
private static final String[] types = new String[] {"acacia", "cherry", "dark", "fir", "holy", "magic", "mangrove", "palm", "redwood", "willow", "dead", "bigflowerstem", "pine", "hellbark", "jacaranda"};
private Icon[] textures;
private Icon[] logHearts;
private final LogCategory category;
public BlockBOPLog(int blockID, LogCategory cat)
{
super(blockID, Material.wood);
category = cat;
setHardness(2.0F);
setResistance(5.0F);
setStepSound(Block.soundWoodFootstep);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[types.length];
logHearts = new Icon[types.length];
for (int i = 0; i < types.length; ++i)
{
if (i != 11)
{
textures[i] = iconRegister.registerIcon("biomesoplenty:log_"+types[i]+"_side");
logHearts[i] = iconRegister.registerIcon("biomesoplenty:log_"+types[i]+"_heart");
}
}
textures[11] = iconRegister.registerIcon("biomesoplenty:bigflowerstem_side");
logHearts[11] = iconRegister.registerIcon("biomesoplenty:bigflowerstem_heart");
}
@Override
public Icon getIcon(int side, int meta)
{
int pos = meta & 12;
if (pos == 0 && (side == 1 || side == 0) || pos == 4 && (side == 5 || side == 4) || pos == 8 && (side == 2 || side == 3))
return logHearts[(getTypeFromMeta(meta) + category.ordinal() * 4)];
else
return textures[(getTypeFromMeta(meta) + category.ordinal() * 4)];
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
if (category != LogCategory.CAT4)
{
for (int i = 0; i < 4; ++i) {
list.add(new ItemStack(this, 1, i));
}
}
else
{
for (int i = 0; i < 3; ++i) {
list.add(new ItemStack(this, 1, i));
}
}
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
byte radius = 4;
int bounds = radius + 1;
if (world.checkChunksExist(x - bounds, y - bounds, z - bounds, x + bounds, y + bounds, z + bounds)) {
for (int i = -radius; i <= radius; ++i) {
for (int j = -radius; j <= radius; ++j) {
for (int k = -radius; k <= radius; ++k)
{
int blockID = world.getBlockId(x + i, y + j, z + k);
if (Block.blocksList[blockID] != null) {
Block.blocksList[blockID].beginLeavesDecay(world, x + i, y + j, z + k);
}
}
}
}
}
}
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta)
{
int type = getTypeFromMeta(meta);
byte orientation = 0;
switch (side)
{
case 0:
case 1:
orientation = 0;
break;
case 2:
case 3:
orientation = 8;
break;
case 4:
case 5:
orientation = 4;
}
return type | orientation;
}
@Override
public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
if (category == LogCategory.CAT4 && metadata == 1)
return 0;
else
{
super.setBurnProperties(blockID, 5, 5);
return blockFlammability[blockID];
}
}
@Override
public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face)
{
if (category == LogCategory.CAT4 && metadata == 1)
return 0;
else
return blockFireSpreadSpeed[blockID];
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
if (category == LogCategory.CAT4 && metadata == 1)
return false;
else
return getFlammability(world, x, y, z, metadata, face) > 0;
}
@Override
public int damageDropped(int meta)
{
return getTypeFromMeta(meta);
}
@Override
protected ItemStack createStackedBlock(int meta)
{
return new ItemStack(blockID, 1, getTypeFromMeta(meta));
}
@Override
public int getRenderType()
{
return 31;
}
@Override
public boolean canSustainLeaves(World world, int x, int y, int z)
{
return true;
}
@Override
public boolean isWood(World world, int x, int y, int z)
{
return true;
}
public String getWoodType(int meta)
{
return types[getTypeFromMeta(meta) + category.ordinal() * 4];
}
private static int getTypeFromMeta(int meta)
{
return meta & 3;
}
}

View file

@ -0,0 +1,160 @@
package biomesoplenty.common.blocks;
import java.util.List;
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.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPMushroom extends BlockFlower
{
private static final String[] plants = new String[] {"toadstool", "portobello", "bluemilk", "glowshroom", "flatmushroom"};
private Icon[] textures;
protected BlockBOPMushroom(int blockID, Material material)
{
super(blockID, material);
this.setTickRandomly(true);
float var4 = 0.2F;
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.4F, 0.7F);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
public BlockBOPMushroom(int blockID)
{
this(blockID, Material.plants);
}
@Override
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
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
public int getRenderType ()
{
return 1;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 3)
return 6;
else
return 0;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4)
{
int meta = world.getBlockMetadata(par2, par3, par4);
switch (meta)
{
case 0:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.4F, 0.7F);
break;
default:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.4F, 0.7F);
break;
}
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "rawtypes", "unchecked" })
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
protected boolean canThisPlantGrowOnThisBlockID(int id)
{
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.mycelium.blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
protected boolean canThisPlantGrowOnThisBlockID(int id, int metadata)
{
if (metadata == 0) //Toadstool
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.mycelium.blockID || id == Blocks.holyGrass.get().blockID || id == Block.netherrack.blockID || id == Blocks.overgrownNetherrack.get().blockID;
if (metadata == 1) //Portobello
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.mycelium.blockID | id == Blocks.holyGrass.get().blockID;
if (metadata == 2) //Blue Milk Cap
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.mycelium.blockID || id == Blocks.holyGrass.get().blockID;
if (metadata == 3) //Glowshroom
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.mycelium.blockID || id == Block.stone.blockID || id == Block.netherrack.blockID || id == Blocks.overgrownNetherrack.get().blockID;
else
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.mycelium.blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
@Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack)
{
int id = world.getBlockId(x, y - 1, z);
int meta = itemStack.getItemDamage();
//boolean sky = world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z);
if (itemStack.itemID == blockID) {
switch (meta)
{
case 0: // Toadstool
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.mycelium.blockID || id == Blocks.holyGrass.get().blockID || id == Block.netherrack.blockID || id == Blocks.overgrownNetherrack.get().blockID;
case 1: // Portobello
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.mycelium.blockID || id == Blocks.holyGrass.get().blockID;
case 2: // Blue Milk Cap
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.mycelium.blockID || id == Blocks.holyGrass.get().blockID;
case 3: // Glowshroom
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.mycelium.blockID || id == Block.stone.blockID || id == Block.netherrack.blockID || id == Blocks.overgrownNetherrack.get().blockID;
default:
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.mycelium.blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
} else
return this.canPlaceBlockOnSide(world, x, y, z, side);
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z));
}
@Override
public int damageDropped(int meta)
{
return meta & 15;
}
}

View file

@ -0,0 +1,353 @@
package biomesoplenty.common.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.FakePlayer;
import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import biomesoplenty.api.Items;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPPersimmonLeaves extends BlockLeavesBase implements IShearable
{
private Icon[][] textures;
private Icon[] betterTextures;
int[] adjacentTreeBlocks;
public BlockBOPPersimmonLeaves(int blockID)
{
super(blockID, Material.leaves, false);
setBurnProperties(this.blockID, 30, 60);
this.setTickRandomly(true);
setHardness(0.2F);
setLightOpacity(1);
setStepSound(Block.soundGrassFootstep);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[3][4];
if(Loader.isModLoaded("BetterGrassAndLeavesMod"))
for (int i = 0; i < 4; ++i)
{
textures[0][i] = iconRegister.registerIcon("biomesoplenty:leaves_persimmon" + i + "_round");
textures[1][i] = iconRegister.registerIcon("biomesoplenty:leaves_persimmon" + i + "_fast");
textures[2][i] = iconRegister.registerIcon("biomesoplenty:better_leaves_persimmon" + i);
}
else
for (int i = 0; i < 4; ++i)
{
textures[0][i] = iconRegister.registerIcon("biomesoplenty:leaves_persimmon" + i + "_fancy");
textures[1][i] = iconRegister.registerIcon("biomesoplenty:leaves_persimmon" + i + "_fast");
}
}
public Icon getIconBetterLeaves(int metadata, float randomIndex)
{
return textures[2][metadata & 3];
}
public Icon getIconFallingLeaves(int metadata)
{
return textures[1][metadata & 3];
}
@Override
public Icon getIcon(int side, int meta)
{
return textures[(!isOpaqueCube() ? 0 : 1)][meta & 3];
}
@Override
public boolean isOpaqueCube()
{
return Block.leaves.isOpaqueCube();
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
list.add(new ItemStack(blockID, 1, 0));
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
if (world.canLightningStrikeAt(x, y + 1, z) && !world.doesBlockHaveSolidTopSurface(x, y - 1, z) && random.nextInt(15) == 1)
{
double d0 = x + random.nextFloat();
double d1 = y - 0.05D;
double d2 = z + random.nextFloat();
world.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
super.randomDisplayTick(world, x, y, z, random);
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
byte radius = 1;
int bounds = radius + 1;
if (world.checkChunksExist(x - bounds, y - bounds, z - bounds, x + bounds, y + bounds, z + bounds)) {
for (int i = -radius; i <= radius; ++i) {
for (int j = -radius; j <= radius; ++j) {
for (int k = -radius; k <= radius; ++k)
{
int blockID = world.getBlockId(x + i, y + j, z + k);
if (Block.blocksList[blockID] != null) {
Block.blocksList[blockID].beginLeavesDecay(world, x + i, y + j, z + k);
}
}
}
}
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
if (world.isRemote)
return;
int meta = world.getBlockMetadata(x, y, z);
if (random.nextInt(25) == 0)
if (meta > 0)
if ((meta & 3) < 3) {
world.setBlock(x, y, z, blockID, ++meta, 3);
}
if ((meta & 8) != 0/* && (meta & 4) == 0*/)
{
byte b0 = 4;
int i1 = b0 + 1;
byte b1 = 32;
int j1 = b1 * b1;
int k1 = b1 / 2;
if (adjacentTreeBlocks == null)
{
adjacentTreeBlocks = new int[b1 * b1 * b1];
}
int l1;
if (world.checkChunksExist(x - i1, y - i1, z - i1, x + i1, y + i1, z + i1))
{
int i2;
int j2;
int k2;
for (l1 = -b0; l1 <= b0; ++l1)
{
for (i2 = -b0; i2 <= b0; ++i2)
{
for (j2 = -b0; j2 <= b0; ++j2)
{
k2 = world.getBlockId(x + l1, y + i2, z + j2);
Block block = Block.blocksList[k2];
if (block != null && block.canSustainLeaves(world, x + l1, y + i2, z + j2))
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
}
else if (block != null && block.isLeaves(world, x + l1, y + i2, z + j2))
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
}
else
{
adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
}
}
}
}
for (l1 = 1; l1 <= 4; ++l1)
{
for (i2 = -b0; i2 <= b0; ++i2)
{
for (j2 = -b0; j2 <= b0; ++j2)
{
for (k2 = -b0; k2 <= b0; ++k2)
{
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1)
{
if (adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
}
if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2)
{
adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
}
}
}
}
}
}
}
l1 = adjacentTreeBlocks[k1 * j1 + k1 * b1 + k1];
if (l1 >= 0)
{
world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4);
}
else
{
this.removeLeaves(world, x, y, z);
}
}
}
private void removeLeaves(World world, int x, int y, int z)
{
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
}
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
int meta = world.getBlockMetadata(x, y, z);
if ((meta & 3) == 3)
{
world.setBlock(x, y, z, blockID, meta - 3, 3);
EntityItem entityitem = new EntityItem(world, x, y, z, new ItemStack(Items.food.get(), 1, 8));
if (!world.isRemote) {
world.spawnEntityInWorld(entityitem);
if (!(player instanceof FakePlayer))
entityitem.onCollideWithPlayer(player);
}
return true;
}
else
return false;
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return Blocks.saplings.get().blockID;
}
@Override
public int damageDropped(int meta)
{
return 15;
}
@Override
public int quantityDropped(Random random)
{
return random.nextInt(20) == 0 ? 1 : 0;
}
@Override
public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int par7)
{
if (world.isRemote)
return;
if (world.rand.nextInt(20) == 0)
{
int var9 = this.idDropped(meta, world.rand, par7);
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(var9, 1, this.damageDropped(meta)));
}
if ((meta & 3) == 3) {
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Items.food.get(), 1, 8));
} else if ((meta & 3) == 2 && world.rand.nextInt(8) == 0) {
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Items.food.get(), 1, 8));
} else if ((meta & 3) == 1 && world.rand.nextInt(16) == 0) {
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Items.food.get(), 1, 8));
} else if ((meta & 3) == 0 && world.rand.nextInt(32) == 0) {
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Items.food.get(), 1, 8));
}
}
@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, 0));
return ret;
}
@SideOnly(Side.CLIENT)
public void setGraphicsLevel(boolean par1)
{
graphicsLevel = par1;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return true;
}
@Override
public void beginLeavesDecay(World world, int x, int y, int z)
{
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4);
}
@Override
public boolean isLeaves(World world, int x, int y, int z)
{
return true;
}
}

View file

@ -0,0 +1,98 @@
package biomesoplenty.common.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty;
public class BlockBOPPetals extends BlockLeavesBase implements IShearable
{
private static final String[] petals = new String[] {"bigflowerred", "bigfloweryellow"};
private Icon[][] textures;
public BlockBOPPetals(int blockID)
{
super(blockID, Material.leaves, false);
setBurnProperties(this.blockID, 30, 60);
this.setTickRandomly(true);
setHardness(0.2F);
setLightOpacity(1);
setStepSound(Block.soundGrassFootstep);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[petals.length][2];
for (int i = 0; i < petals.length; ++i) {
textures[i][0] = iconRegister.registerIcon("biomesoplenty:" + petals[i]);
textures[i][1] = iconRegister.registerIcon("biomesoplenty:better_" + petals[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
return textures[meta < 0 || meta >= textures.length ? 0 : meta][0];
}
public Icon getIconBetterLeaves(int meta, float randomIndex)
{
return textures[meta < 0 || meta >= textures.length ? 0 : meta][1];
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < textures.length; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
if (par1 == 0)
return Block.plantRed.blockID;
else
return Block.plantYellow.blockID;
}
@Override
public int damageDropped(int meta)
{
return meta & 15;
}
@Override
public int quantityDropped(Random random)
{
return random.nextInt(20) == 0 ? 1 : 0;
}
@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) & 15));
return ret;
}
}

View file

@ -0,0 +1,59 @@
package biomesoplenty.common.blocks;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import biomesoplenty.BiomesOPlenty;
public class BlockBOPPlank extends Block
{
private static final String[] woodTypes = new String[] {"plank_acacia", "plank_cherry", "plank_dark", "plank_fir", "plank_holy", "plank_magic", "plank_mangrove", "plank_palm", "plank_redwood", "plank_willow", "bamboothatching", "plank_pine", "plank_hell_bark", "plank_jacaranda"};
private Icon[] textures;
public BlockBOPPlank(int blockID)
{
super(blockID, Material.wood);
setBurnProperties(this.blockID, 5, 20);
setHardness(2.0F);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[woodTypes.length];
for (int i = 0; i < woodTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:"+woodTypes[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < woodTypes.length; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public int damageDropped(int meta)
{
return meta;
}
}

View file

@ -0,0 +1,475 @@
package biomesoplenty.common.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
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.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import biomesoplenty.api.Items;
import biomesoplenty.blocks.renderers.RenderUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPPlant extends BlockFlower implements IShearable
{
private static final String[] plants = new String[] {"deadgrass", "desertgrass", "desertsprouts", "dunegrass", "holytallgrass", "thorn", "barley", "cattail", "rivercane", "cattailtop", "cattailbottom", "wildcarrot", "cactus", "witherwart", "reed", "root"};
private Icon[] textures;
public Icon reedbottom;
private static final int CATTAILTOP = 9;
private static final int CATTAILBOTTOM = 10;
public BlockBOPPlant(int par1)
{
super(par1, Material.vine);
setTickRandomly(true);
float var3 = 0.4F;
setBurnProperties(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(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
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]);
}
reedbottom = iconRegister.registerIcon("biomesoplenty:" + "reedbottom");
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
public int getRenderType ()
{
return RenderUtils.plantsModel;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4)
{
int meta = world.getBlockMetadata(par2, par3, par4);
switch (meta)
{
case 6:
case 7:
this.setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 1.00F, 0.875F);
break;
default:
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
break;
}
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list)
{
for (int i = 0; i < plants.length; ++i) {
if (i != CATTAILTOP && i!= CATTAILBOTTOM && i!= 11)
{
list.add(new ItemStack(blockID, 1, i));
}
}
}
protected boolean canThisPlantGrowOnThisBlockID(int blockID, int metadata)
{
//case 2: // Desert Sprouts
if (metadata == 0) //Dead Grass
return blockID == Blocks.driedDirt.get().blockID || blockID == Block.sand.blockID;
else if (metadata == 1) //Desert Grass
return blockID == Blocks.redRock.get().blockID;
else if (metadata == 3) //Dune Grass
return blockID == Block.sand.blockID;
else if (metadata == 4) //Holy Tall Grass
return blockID == Blocks.holyGrass.get().blockID || blockID == Blocks.holyDirt.get().blockID;
else if (metadata == 5)
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.slowSand.blockID;
else if (metadata == 6)
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID;
else if (metadata == 7)
return blockID == Block.grass.blockID;
else if (metadata == 8)
return blockID == this.blockID || blockID == Block.grass.blockID;
else if (metadata == 9)
return blockID == this.blockID;
else if (metadata == 12)
return blockID == Block.sand.blockID || blockID == Blocks.redRock.get().blockID || blockID == Block.slowSand.blockID;
else if (metadata == 13)
return blockID == Block.slowSand.blockID;
else if (metadata == 14)
return blockID == Block.waterStill.blockID;
else if (metadata == 15)
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID || blockID == Blocks.longGrass.get().blockID || blockID == Blocks.holyGrass.get().blockID || blockID == Blocks.holyDirt.get().blockID;
else
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID || blockID == Blocks.longGrass.get().blockID || blockID == Blocks.overgrownNetherrack.get().blockID;
}
@Override
protected boolean canThisPlantGrowOnThisBlockID(int id)
{
return id == Blocks.driedDirt.get().blockID || id == Block.sand.blockID || id == Blocks.redRock.get().blockID || id == Blocks.holyGrass.get().blockID
|| id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.holyDirt.get().blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
@Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack)
{
int id = world.getBlockId(x, y - 1, z);
int idRoot = world.getBlockId(x, y + 1, z);
int meta = itemStack.getItemDamage();
if (itemStack.itemID == blockID) {
switch (meta)
{
case 0: // Dead Grass
return id == Blocks.driedDirt.get().blockID || id == Block.sand.blockID;
case 1: // Desert Grass
return id == Blocks.redRock.get().blockID;
case 2: // Desert Sprouts
case 3: // Dune Grass
return id == Block.sand.blockID;
case 4: // Holy Tall Grass
return id == Blocks.holyGrass.get().blockID;
case 5: // Thorns
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.slowSand.blockID;
case 6: // Barley
return id == Block.grass.blockID || id == Block.dirt.blockID;
case 7: // Cattail
return id != Block.grass.blockID ? false : (world.getBlockMaterial(x - 1, y - 1, z) == Material.water ? true : (world.getBlockMaterial(x + 1, y - 1, z) == Material.water ? true : (world.getBlockMaterial(x, y - 1, z - 1) == Material.water ? true : world.getBlockMaterial(x, y - 1, z + 1) == Material.water)));
case 8: // River Cane
return id == blockID || id == Block.grass.blockID;
case 10: // High Cattail Bottom
return id != Block.grass.blockID ? false : (world.getBlockMaterial(x - 1, y - 1, z) == Material.water ? true : (world.getBlockMaterial(x + 1, y - 1, z) == Material.water ? true : (world.getBlockMaterial(x, y - 1, z - 1) == Material.water ? true : world.getBlockMaterial(x, y - 1, z + 1) == Material.water)));
case 12: // Tiny Cactus
return id == Block.sand.blockID || id == Blocks.redRock.get().blockID || id == Block.slowSand.blockID;
case 13: // Wither Wart
return id == Block.slowSand.blockID;
case 14: // Reed
return id == Block.waterStill.blockID;
case 15: // Reed
return idRoot == Block.grass.blockID || idRoot == Block.dirt.blockID || idRoot == Block.tilledField.blockID || idRoot == Blocks.longGrass.get().blockID || idRoot == Blocks.holyGrass.get().blockID || idRoot == Blocks.holyDirt.get().blockID;
default:
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || id == Blocks.overgrownNetherrack.get().blockID;
}
} else
return this.canPlaceBlockOnSide(world, x, y, z, side);
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
int id = world.getBlockId(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
Block block = Block.blocksList[id];
if (world.getBlockId(x, y, z) != blockID)
{
if (meta == 5 || meta == 13)
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
else if (meta == 8)
return block == null || block.isBlockReplaceable(world, x, y, z);
else if (meta == 15)
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y + 1, z));
else
return (world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z)) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
}
else
{
if (meta == 5 || meta == 13)
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z));
else if (meta == 15)
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y + 1, z), world.getBlockMetadata(x, y, z));
else
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 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) == CATTAILTOP && world.getBlockId(x, y - 1, z) == blockID && world.getBlockMetadata(x, y - 1, z) != CATTAILBOTTOM)
{
world.setBlockToAir(x, y, z);
}
else if (world.getBlockMetadata(x, y, z) == CATTAILBOTTOM && world.getBlockId(x, y + 1, z) != blockID)
{
world.setBlockToAir(x, y, z);
}
else if (world.getBlockId(x, y, z) != blockID || world.getBlockMetadata(x, y, z) != 8)
{
this.checkBlockCoordValid(world, x, y, z);
}
}
protected final void checkBlockCoordValid(World world, int x, int y, int z)
{
for (int i = 1; world.getBlockId(x, y + i, z) == blockID; i++)
{
if (!this.canBlockStay(world, x, y + i, z))
{
this.dropBlockAsItem(world, x, y + i, z, world.getBlockMetadata(x, y + i, z), 0);
world.setBlock(x, y + i, z, 0);
}
}
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 5)
{
if (entity instanceof EntityPlayer)
{
InventoryPlayer inventory = ((EntityPlayer)entity).inventory;
if (!((inventory.armorInventory[0] != null && inventory.armorInventory[0].itemID == Item.bootsLeather.itemID) && (inventory.armorInventory[1] != null && inventory.armorInventory[1].itemID == Item.legsLeather.itemID)))
{
entity.attackEntityFrom(DamageSource.cactus, 1);
}
}
else
{
entity.attackEntityFrom(DamageSource.cactus, 1);
}
}
if (meta == 12)
{
if (entity instanceof EntityPlayer)
{
InventoryPlayer inventory = ((EntityPlayer)entity).inventory;
if (!((inventory.armorInventory[0] != null && inventory.armorInventory[0].itemID == Item.bootsLeather.itemID) && (inventory.armorInventory[1] != null && inventory.armorInventory[1].itemID == Item.legsLeather.itemID)))
{
entity.attackEntityFrom(DamageSource.cactus, 1);
}
}
else
{
entity.attackEntityFrom(DamageSource.cactus, 1);
}
}
}
@Override
public int idPicked(World world, int x, int y, int z)
{
int blockID = world.getBlockId(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (meta == 11)
{
return Items.food.get().itemID;
}
return this.blockID;
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == CATTAILTOP || meta == CATTAILBOTTOM)
{
meta = 7;
}
else if (meta == 11)
{
meta = 2;
}
return meta;
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
if (par1 > 5 && par1 != 11)
{
return blockID;
}
else if (par1 == 11)
{
return Items.food.get().itemID;
}
else
{
return -1;
}
}
@Override
public int damageDropped(int meta)
{
if (meta == 9)
{
return 7;
}
else if (meta == 11)
{
return 2;
}
else
{
return meta;
}
}
@Override
public int quantityDropped(int meta, int fortune, Random random)
{
if (meta == 6)
return random.nextInt(5) == 0 ? 1 : 0;
else if (meta == 7 || meta == 8 || meta == 9)
return 1;
else if (meta == 11)
return random.nextInt(7) == 0 ? 2 : 1;
else if (meta == 13)
return 1;
else
return 0;
}
@Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta)
{
super.harvestBlock(world, player, x, y, z, meta);
if (meta == 13)
{
player.addPotionEffect(new PotionEffect(Potion.wither.id, 250, 1));
}
ItemStack equippedItem = player.getCurrentEquippedItem();
if (equippedItem != null)
{
if (equippedItem.itemID != Item.shears.itemID)
{
if (meta == 5)
{
player.attackEntityFrom(DamageSource.cactus, 2);
}
}
}
else
{
if (meta == 5)
{
player.attackEntityFrom(DamageSource.cactus, 2);
}
}
}
@Override
@SideOnly(Side.CLIENT)
public boolean addBlockDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer)
{
if (meta == 13)
{
byte b0 = 3;
for (int j1 = 0; j1 < b0; ++j1)
{
for (int k1 = 0; k1 < b0; ++k1)
{
for (int l1 = 0; l1 < b0; ++l1)
{
double d0 = (double)x + ((double)j1 + 0.5D) / (double)b0;
double d1 = (double)y + ((double)k1 + 0.5D) / (double)b0;
double d2 = (double)z + ((double)l1 + 0.5D) / (double)b0;
world.spawnParticle("smoke", d0, d1, d2, d0 - (double)x - 0.5D, d1 - (double)y - 0.5D, d2 - (double)z - 0.5D);
}
}
}
}
return false;
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 5 || meta == 8)
return false;
return true;
}
@Override
public boolean isShearable(ItemStack item, World world, int x, int y, int z)
{
if (world.getBlockMetadata(x, y, z) == 7 || world.getBlockMetadata(x, y, z) == 8 || world.getBlockMetadata(x, y, z) == 9)
return false;
else
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

@ -0,0 +1,110 @@
package biomesoplenty.common.blocks;
import java.util.List;
import net.minecraft.block.Block;
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.Icon;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
public class BlockBOPRedRock extends Block
{
private static final String[] types = new String[] {"redrock", "redcobble", "redbrick"};
private Icon[] textures = {null, null, null};
public BlockBOPRedRock(int par1)
{
super(par1, Material.rock);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
setStepSound(Block.soundStoneFootstep);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[types.length];
for (int i = 0; i < types.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:"+types[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length)
{
meta = 0;
}
return textures[meta];
}
@Override
public int getDamageValue(World world, int x, int y, int z) {
return world.getBlockMetadata(x, y, z);
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < types.length; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public int damageDropped(int meta)
{
return meta == 0 ? 1 : meta;
}
@Override
public float getBlockHardness(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
float hardness = blockHardness;
switch (meta)
{
case 0:
hardness = 1.0F;
break;
case 1:
hardness = 1.6F;
break;
case 2:
hardness = 1.1F;
break;
}
return hardness;
}
@Override
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
{
int meta = world.getBlockMetadata(x, y, z);
float resistance = blockResistance;
switch (meta)
{
case 1:
resistance = 7.5F;
break;
case 2:
resistance = 7.0F;
break;
}
return resistance / 5.0F;
}
}

View file

@ -0,0 +1,241 @@
package biomesoplenty.common.blocks;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.ForgeDirection;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import biomesoplenty.worldgen.WorldGenNetherBush;
import biomesoplenty.worldgen.tree.WorldGenApple;
import biomesoplenty.worldgen.tree.WorldGenAutumn;
import biomesoplenty.worldgen.tree.WorldGenAutumn2;
import biomesoplenty.worldgen.tree.WorldGenBambooTree;
import biomesoplenty.worldgen.tree.WorldGenBambooTree2;
import biomesoplenty.worldgen.tree.WorldGenCherry1;
import biomesoplenty.worldgen.tree.WorldGenCherry2;
import biomesoplenty.worldgen.tree.WorldGenDeadTree2;
import biomesoplenty.worldgen.tree.WorldGenJacaranda;
import biomesoplenty.worldgen.tree.WorldGenMaple;
import biomesoplenty.worldgen.tree.WorldGenMystic2;
import biomesoplenty.worldgen.tree.WorldGenOminous1;
import biomesoplenty.worldgen.tree.WorldGenOminous2;
import biomesoplenty.worldgen.tree.WorldGenOriginTree;
import biomesoplenty.worldgen.tree.WorldGenPersimmon;
import biomesoplenty.worldgen.tree.WorldGenPromisedTree;
import biomesoplenty.worldgen.tree.WorldGenTaiga9;
public class BlockBOPSapling extends BlockSapling
{
private static final String[] saplings = new String[] {"apple", "yellowautumn", "bamboo", "magic", "dark", "dead", "fir", "holy", "orangeautumn", "origin", "pinkcherry", "maple", "whitecherry", "hellbark", "jacaranda", "persimmon"};
private Icon[] textures;
private static final int TYPES = 15;
public BlockBOPSapling(int par1)
{
super(par1);
setHardness(0.0F);
setStepSound(Block.soundGrassFootstep);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[saplings.length];
for (int i = 0; i < saplings.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:sapling_" + saplings[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= saplings.length) {
meta = 0;
}
return textures[meta];
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < saplings.length; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack)
{
int id = world.getBlockId(x, y - 1, z);
int meta = itemStack.getItemDamage();
if (itemStack.itemID == blockID && id != 0) {
switch (meta)
{
case 7: // Loftwood
return id == Blocks.holyGrass.get().blockID || id == Blocks.holyDirt.get().blockID;
default:
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID || blocksList[id].canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, this);
}
} else
return this.canPlaceBlockOnSide(world, x, y, z, side);
}
protected boolean canThisPlantGrowOnThisBlockID(int blockID, int metadata)
{
if (metadata == 7) //Loftwood
return blockID == Blocks.holyGrass.get().blockID || blockID == Blocks.holyDirt.get().blockID;
else
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID;
}
@Override
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
{
Block soil = blocksList[par1World.getBlockId(par2, par3 - 1, par4)];
if (par1World.getBlockMetadata(par2, par3, par4) != 7)
return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) &&
(soil != null && soil.canSustainPlant(par1World, par2, par3 - 1, par4, ForgeDirection.UP, this));
else
return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) &&
(soil != null && (soil.canSustainPlant(par1World, par2, par3 - 1, par4, ForgeDirection.UP, this) || soil.blockID == Blocks.holyGrass.get().blockID));
}
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
if (world.isRemote)
return;
this.checkFlowerChange(world, x, y, z);
if (world.getBlockLightValue(x, y + 1, z) >= 9 && random.nextInt(7) == 0) {
this.growTree(world, x, y, z, random);
}
}
@Override
public void growTree(World world, int x, int y, int z, Random random)
{
int meta = world.getBlockMetadata(x, y, z) & TYPES;
Object obj = null;
int rnd = random.nextInt(8);
if (obj == null)
{
switch (meta)
{
case 0: // Apple Tree
obj = new WorldGenApple(false);
break;
case 1: // Autumn Tree
obj = new WorldGenAutumn(false);
break;
case 2: // Bamboo Tree
rnd = random.nextInt(8);
if (rnd == 0) {
obj = new WorldGenBambooTree(false);
} else {
obj = new WorldGenBambooTree2(false);
}
break;
case 3: // Magic Tree
obj = new WorldGenMystic2(false);
break;
case 4: // Dark Tree
rnd = random.nextInt(8);
if (rnd == 0) {
obj = new WorldGenOminous2();
} else {
obj = new WorldGenOminous1(false);
}
break;
case 5: // Dead Tree
obj = new WorldGenDeadTree2(false);
break;
case 6: // Fir Tree
obj = new WorldGenTaiga9(false);
break;
case 7: // Holy Tree
obj = new WorldGenPromisedTree(false);
break;
case 8: // Autumn Tree
obj = new WorldGenAutumn2(false);
break;
case 9: // Origin Tree
obj = new WorldGenOriginTree(false);
break;
case 10: // Pink Cherry Tree
obj = new WorldGenCherry1(false);
break;
case 11: // Maple Tree
obj = new WorldGenMaple(false);
break;
case 12: // White Cherry Tree
obj = new WorldGenCherry2(false);
break;
case 13: // Hellbark
obj = new WorldGenNetherBush();
break;
case 14: // Jacaranda
obj = new WorldGenJacaranda(false);
break;
case 15: // Persimmon
obj = new WorldGenPersimmon(false);
break;
}
}
if (obj != null)
{
world.setBlockToAir(x, y, z);
if (!((WorldGenerator)obj).generate(world, random, x, y, z)) {
world.setBlock(x, y, z, blockID, meta, 2);
}
}
}
@Override
public int damageDropped(int meta)
{
return meta & TYPES;
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
return world.getBlockMetadata(x, y, z) & TYPES;
}
}

View file

@ -0,0 +1,122 @@
package biomesoplenty.common.blocks;
import java.util.List;
import net.minecraft.block.Block;
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.Icon;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
public class BlockBOPSkystone extends Block
{
private static final String[] types = new String[] {"holystone", "holycobble", "holybrick", "holystonemossy"};
private Icon[] textures = {null, null, null};
public BlockBOPSkystone(int par1)
{
super(par1, Material.rock);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
setStepSound(Block.soundStoneFootstep);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[types.length];
for (int i = 0; i < types.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:"+types[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
public int getDamageValue(World world, int x, int y, int z) {
return world.getBlockMetadata(x, y, z);
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < types.length; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public int damageDropped(int meta)
{
if (meta == 0)
{
return 1;
}
if (meta == 3)
{
return 1;
}
return meta;
}
@Override
public float getBlockHardness(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
float hardness = blockHardness;
switch (meta)
{
case 0:
hardness = 1.0F;
break;
case 1:
hardness = 1.6F;
break;
case 2:
hardness = 1.1F;
break;
case 3:
hardness = 1.0F;
break;
}
return hardness;
}
@Override
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
{
int meta = world.getBlockMetadata(x, y, z);
float resistance = blockResistance;
switch (meta)
{
case 1:
resistance = 7.5F;
break;
case 2:
resistance = 7.0F;
break;
}
return resistance / 5.0F;
}
}

View file

@ -0,0 +1,216 @@
package biomesoplenty.common.blocks;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHalfSlab;
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.Icon;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
public class BlockBOPSlab extends BlockHalfSlab
{
public static enum SlabCategory
{
WOOD1, WOOD2, STONE;
}
private static final String[] woodTypes = new String[] {"acacia", "cherry", "dark", "fir", "holy", "magic", "mangrove", "palm", "redwood", "willow", "pine", "hell_bark", "jacaranda"};
private static final String[] rockTypes = new String[] {"redcobble", "redbrick", "mudbrick", "holycobble", "holybrick"};
private Icon[] textures;
protected final boolean isDoubleSlab;
private final SlabCategory category;
public BlockBOPSlab(int par1, boolean par2, Material material, SlabCategory cat)
{
super(par1, par2, material);
isDoubleSlab = par2;
category = cat;
if (material == Material.wood)
{
setBurnProperties(blockID, 5, 20);
setHardness(2.0F);
setResistance(5.0F);
setStepSound(Block.soundWoodFootstep);
}
else if (material == Material.rock) {
setStepSound(Block.soundStoneFootstep);
}
if (!par2) {
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
useNeighborBrightness[blockID] = true;
}
@Override
public void registerIcons(IconRegister iconRegister)
{
if (category == SlabCategory.STONE)
{
textures = new Icon[rockTypes.length];
for (int i = 0; i < rockTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:"+rockTypes[i]);
}
}
else
{
textures = new Icon[woodTypes.length];
for (int i = 0; i < woodTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:plank_"+woodTypes[i]);
}
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (category == SlabCategory.STONE)
return textures[getTypeFromMeta(meta)];
else
return textures[(getTypeFromMeta(meta) + category.ordinal() * 8)];
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
int max = 0;
if (category == SlabCategory.WOOD1) {
max = 8;
} else if (category == SlabCategory.WOOD2) {
max = 5;
} else if (category == SlabCategory.STONE) {
max = 5;
}
for (int i = 0; i < max; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public String getFullSlabName(int meta)
{
if (category == SlabCategory.STONE)
return (new StringBuilder()).append(rockTypes[getTypeFromMeta(meta)]).append("Slab").toString();
else
return (new StringBuilder()).append(woodTypes[getWoodType(meta)]).append("Slab").toString();
}
@Override
public int damageDropped(int meta)
{
return meta & 7;
}
@Override
public int idDropped(int meta, Random par2Random, int par3)
{
if (isDoubleSlab)
{
if (blockID == Blocks.woodenDoubleSlab1.get().blockID)
return Blocks.woodenSingleSlab1.get().blockID;
if (blockID == Blocks.woodenDoubleSlab2.get().blockID)
return Blocks.woodenSingleSlab2.get().blockID;
else
return Blocks.stoneSingleSlab.get().blockID;
}
else
return blockID;
}
@Override
public float getBlockHardness(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
float hardness = blockHardness;
if (category == SlabCategory.STONE)
{
switch (getTypeFromMeta(meta))
{
case 0:
case 3:
hardness = 1.6F;
break;
case 1:
case 4:
hardness = 1.1F;
break;
case 2:
hardness = 1.0F;
break;
}
}
return hardness;
}
@Override
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
{
int meta = world.getBlockMetadata(x, y, z);
float resistance = blockHardness;
if (category == SlabCategory.STONE)
{
switch (getTypeFromMeta(meta))
{
case 0:
case 3:
resistance = 7.0F;
break;
case 1:
case 4:
resistance = 7.5F;
break;
case 2:
resistance = 2.0F;
break;
}
}
return resistance / 5.0F;
}
@Override
public int idPicked(World par1World, int par2, int par3, int par4)
{
return !isDoubleSlab ? blockID : (blockID == Blocks.woodenDoubleSlab1.get().blockID ? Blocks.woodenSingleSlab1.get().blockID : (blockID == Blocks.woodenDoubleSlab2.get().blockID ? Blocks.woodenSingleSlab2.get().blockID : Blocks.stoneSingleSlab.get().blockID));
}
@Override
protected ItemStack createStackedBlock(int par1)
{
return new ItemStack(blockID, 2, par1);
}
private int getWoodType(int meta)
{
meta = getTypeFromMeta(meta) + category.ordinal() * 8;
if (meta < woodTypes.length)
return meta;
return 0;
}
private static int getTypeFromMeta(int meta)
{
return meta & 7;
}
}

View file

@ -0,0 +1,128 @@
package biomesoplenty.common.blocks;
import java.util.Arrays;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import biomesoplenty.BiomesOPlenty;
public class BlockBOPStairs extends BlockStairs
{
public static enum Category
{
ACACIA ("wood"), CHERRY ("wood"), DARK ("wood"), FIR ("wood"), HOLY ("wood"), MAGIC ("wood"), MANGROVE ("wood"), PALM ("wood"), REDWOOD ("wood"), WILLOW ("wood"), PINE ("wood"), HELL_BARK ("wood"), JACARANDA ("wood"), RED_COBBLE ("stone"), RED_BRICKS ("stone"), MUD_BRICKS ("stone"), HOLY_COBBLE ("stone"), HOLY_BRICKS ("stone");
private final List<String> values;
private String type;
private Category(String type)
{
this.type = type;
values = Arrays.asList(type);
}
}
private static final String[] woodTypes = new String[] {"acacia", "cherry", "dark", "fir", "holy", "magic", "mangrove", "palm", "redwood", "willow", "pine", "hell_bark", "jacaranda"};
private static final String[] stoneTypes = new String[] {"redcobble", "redbrick", "mudbrick", "holycobble", "holybrick"};
private Icon[] textures;
private final Category category;
public BlockBOPStairs(int blockID, Block model, Category cat)
{
super(blockID, model, 0);
category = cat;
setBurnProperties(this.blockID, 5, 20);
this.setLightOpacity(0);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
this.setHardness(model.blockHardness);
this.setResistance(model.blockResistance / 3.0F);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
if (isStoneCategory(category.toString()))
{
textures = new Icon[stoneTypes.length];
for (int i = 0; i < stoneTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:"+stoneTypes[i]);
}
}
else
{
textures = new Icon[woodTypes.length];
for (int i = 0; i < woodTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:plank_"+woodTypes[i]);
}
}
}
public boolean isWoodCategory(String block)
{
String type = Category.valueOf(block).type;
if (type == "wood")
return true;
else
return false;
}
public boolean isStoneCategory(String block)
{
String type = Category.valueOf(block).type;
if (type == "stone")
return true;
else
return false;
}
public static int getWoodCategoryAmount()
{
int woodCatNo = 0;
for (Category cat : Category.values())
{
if (cat.values.contains("wood"))
{
++woodCatNo;
}
}
return woodCatNo;
}
public static int getStoneCategoryAmount()
{
int woodCatNo = 0;
for (Category cat : Category.values())
{
if (cat.values.contains("stone"))
{
++woodCatNo;
}
}
return woodCatNo;
}
@Override
public Icon getIcon(int side, int meta)
{
int adjCat = category.ordinal();
if (isStoneCategory(category.toString()))
{
adjCat = adjCat - getWoodCategoryAmount();
}
return textures[adjCat];
}
}

View file

@ -0,0 +1,163 @@
package biomesoplenty.common.blocks;
import java.util.List;
import java.util.Random;
import javax.swing.Icon;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
public class BlockBamboo extends Block
{
private IIcon bambooSide;
private IIcon bambooTop;
public BlockBamboo()
{
super(Material.plants);
setBurnProperties(blockID, 5, 5);
this.setTickRandomly(true);
//TODO: this.setCreativeTab()
this.func_149647_a(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
blockIcon = iconRegister.registerIcon("biomesoplenty:bamboo");
bambooTop = iconRegister.registerIcon("biomesoplenty:bambootop");
}
@Override
public Icon getIcon(int side, int meta)
{
if (side > 1)
return blockIcon;
else
return bambooTop;
}
@Override
public void updateTick(World world, int x, int y, int z, Random par5Random)
{
if (world.isAirBlock(x, y + 1, z))
{
int var6;
for (var6 = 1; world.getBlockId(x, y - var6, z) == blockID; ++var6)
{
;
}
if (var6 < 3)
{
int var7 = world.getBlockMetadata(x, y, z);
if (var7 == 15)
{
world.setBlock(x, y + 1, z, blockID);
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
}
else
{
world.setBlockMetadataWithNotify(x, y, z, var7 + 1, 2);
}
}
}
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
{
float pixel = 0.0625F;
return AxisAlignedBB.getAABBPool().getAABB((double)x + (1.0F - (pixel * 4)), (double)y, (double)z + (1.0F - (pixel * 4)), (double)x + (pixel * 4), (double)y + 1.0F, (double)z + (pixel * 4));
}
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, List list, Entity entity)
{
float pixel = 0.0625F;
this.setBlockBounds((pixel * 4), 0.0F, (pixel * 4), 1.0F - (pixel * 4), 1.0F, 1.0F - (pixel * 4));
super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity);
this.setBlockBoundsForItemRender();
}
@Override
public void setBlockBoundsForItemRender()
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@Override
public boolean canBeReplacedByLeaves(World world, int x, int y, int z)
{
return false;
}
@Override
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockId(par2, par3 - 1, par4);
if (var5 == blockID)
return true;
else if (var5 == Block.grass.blockID)
return true;
else
return false;
}
@Override
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
this.checkBlockCoordValid(par1World, par2, par3, par4);
}
protected final void checkBlockCoordValid(World par1World, int par2, int par3, int par4)
{
if (!this.canBlockStay(par1World, par2, par3, par4))
{
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlock(par2, par3, par4, 0);
}
}
@Override
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
{
return this.canPlaceBlockAt(par1World, par2, par3, par4);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return RenderUtils.bambooModel;
}
@Override
public boolean canSustainLeaves(World world, int x, int y, int z)
{
return true;
}
}

View file

@ -0,0 +1,239 @@
package biomesoplenty.common.blocks;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.blocks.renderers.RenderUtils;
public class BlockBones extends Block {
//Meta 3 & 4 used by alternate small bone rotations, 5 & 6 are used by alternate medium bone rotations
private static final String[] boneTypes = new String[] {"bones_small", "bones_medium", "bones_large"};
private Icon[] textures;
public BlockBones(int blockID)
{
super(blockID, Material.rock);
setHardness(3.0F);
setResistance(5.0F);
//TODO: this.setCreativeTab()
this.func_149647_a(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[boneTypes.length];
for (int i = 0; i < boneTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:"+boneTypes[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
if (meta == 4 || meta == 5) {
meta = 1;
}
return textures[meta];
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
switch (meta)
{
case 0:
return AxisAlignedBB.getBoundingBox(x + 0.374D, y, z + 0.374D, x + 0.626D, y + 1.0D, z + 0.626D);
case 1:
return AxisAlignedBB.getBoundingBox(x + 0.187D, y, z + 0.187D, x + 0.813D, y + 1.0D, z + 0.813D);
case 3:
return AxisAlignedBB.getBoundingBox(x + 0.374D, y + 0.374D, z, x + 0.626D, y + 0.626D, z + 1.00D);
case 4:
return AxisAlignedBB.getBoundingBox(x, y + 0.374D, z + 0.374D, x + 1.00D, y + 0.626D, z + 0.626D);
case 5:
return AxisAlignedBB.getBoundingBox(x + 0.187D, y + 0.187D, z, x + 0.813D, y + 0.813D, z + 1.00D);
case 6:
return AxisAlignedBB.getBoundingBox(x, y + 0.187D, z + 0.187D, x + 1.00D, y + 0.813D, z + 0.813D);
default:
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D);
}
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
switch (meta)
{
case 0:
return AxisAlignedBB.getBoundingBox(x + 0.374D, y, z + 0.374D, x + 0.626D, y + 1.0D, z + 0.626D);
case 1:
return AxisAlignedBB.getBoundingBox(x + 0.187D, y, z + 0.187D, x + 0.813D, y + 1.0D, z + 0.813D);
case 3:
return AxisAlignedBB.getBoundingBox(x + 0.374D, y + 0.374D, z, x + 0.626D, y + 0.626D, z + 1.00D);
case 4:
return AxisAlignedBB.getBoundingBox(x, y + 0.374D, z + 0.374D, x + 1.00D, y + 0.626D, z + 0.626D);
case 5:
return AxisAlignedBB.getBoundingBox(x + 0.187D, y + 0.187D, z, x + 0.813D, y + 0.813D, z + 1.00D);
case 6:
return AxisAlignedBB.getBoundingBox(x, y + 0.187D, z + 0.187D, x + 1.00D, y + 0.813D, z + 0.813D);
default:
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D);
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int x, int y, int z)
{
int meta = iblockaccess.getBlockMetadata(x, y, z);
float minX;
float minY;
float minZ;
float maxX;
float maxY;
float maxZ;
switch (meta)
{
case 0:
minY = 0F;
minX = minZ = 0.374F;
maxX = maxZ = 0.626F;
maxY = 1.0F;
break;
case 1:
minY = 0F;
minX = minZ = 0.187F;
maxX = maxZ = 0.813F;
maxY = 1.00F;
break;
case 3:
minX = minY = 0.374F;
minZ = 0F;
maxX = maxY = 0.626F;
maxZ = 1.00F;
break;
case 4:
minX = 0F;
minY = minZ = 0.374F;
maxX = 1.00F;
maxY = maxZ = 0.626F;
break;
case 5:
minX = minY = 0.187F;
minZ = 0F;
maxX = maxY = 0.813F;
maxZ = 1.00F;
break;
case 6:
minX = 0F;
minY = minZ = 0.187F;
maxX = 1.00F;
maxY = maxZ = 0.813F;
break;
default:
minY = 0F;
minX = minZ = 0.0F;
maxX = maxZ = 1.0F;
maxY = 1.0F;
break;
}
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 3 || meta == 4) {
meta = 0;
}
if (meta == 5 || meta == 6) {
meta = 1;
}
return meta;
}
@Override
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list)
{
for (int i = 0; i < boneTypes.length; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return RenderUtils.bonesModel;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
return true;
}
@Override
public int damageDropped(int meta)
{
if (meta == 3 || meta == 4) {
meta = 0;
}
if (meta == 5 || meta == 6) {
meta = 1;
}
return meta;
}
}

View file

@ -0,0 +1,104 @@
package biomesoplenty.common.blocks;
import static net.minecraftforge.common.ForgeDirection.UP;
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.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import biomesoplenty.api.Items;
public class BlockFlesh extends Block
{
public BlockFlesh(int par1)
{
super(par1, Material.sponge);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
blockIcon = par1IconRegister.registerIcon("biomesoplenty:flesh");
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
float var5 = 0.125F;
return AxisAlignedBB.getAABBPool().getAABB(par2, par3, par4, par2 + 1, par3 + 1 - var5, par4 + 1);
}
/**
* A randomly called display update to be able to add particles or other items for display
*/
@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
super.randomDisplayTick(par1World, par2, par3, par4, par5Random);
if (par5Random.nextInt(4) == 0)
{
par1World.spawnParticle("tilecrack_" + String.valueOf(Blocks.flesh.get().blockID) + "_0", par2 + par5Random.nextFloat(), par3 - 0.4F, par4 + par5Random.nextFloat(), 0.0D, 0.0D, 0.0D);
}
if (par5Random.nextInt(12) == 0)
{
par1World.spawnParticle("tilecrack_" + String.valueOf(Blocks.flesh.get().blockID) + "_0", par2 + par5Random.nextFloat(), par3 + 1.0F, par4 + par5Random.nextFloat(), 0.0D, 0.0D, 0.0D);
}
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{
if (entity instanceof EntityPlayer)
{
InventoryPlayer inventory = ((EntityPlayer)entity).inventory;
if (inventory.armorInventory[0] != null && inventory.armorInventory[0].itemID == Items.wadingBoots.get().itemID)
{
return;
}
}
entity.motionX *= 0.9D;
entity.motionZ *= 0.9D;
}
/**
* Returns the ID of the items to drop on destruction.
*/
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return Items.miscItems.get().itemID;
}
@Override
public int damageDropped(int meta)
{
return 3;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random)
{
return par1Random.nextInt(5);
}
}

View file

@ -0,0 +1,112 @@
package biomesoplenty.common.blocks;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import biomesoplenty.blocks.renderers.RenderUtils;
public class BlockGrave extends Block
{
public BlockGrave(int id)
{
super(id, Material.rock);
setHardness(5f);
setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
blockIcon = iconRegister.registerIcon("biomesoplenty:grave");
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4)
{
int meta = world.getBlockMetadata(par2, par3, par4);
switch (meta)
{
case 0:
this.setBlockBounds(0.0F, 0.0F, 0.31F, 1.0F, 1.6875F, 0.69F);
break;
case 1:
this.setBlockBounds(0.0F, -1.0F, 0.31F, 1.0F, 0.6875F, 0.69F);
break;
case 2:
this.setBlockBounds(0.31F, 0.0F, 0.0F, 0.69F, 1.6875F, 1.0F);
break;
case 3:
this.setBlockBounds(0.31F, -1.0F, 0.0F, 0.69F, 0.6875F, 1.0F);
break;
}
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int neighbourID)
{
if (neighbourID == Blocks.grave.get().blockID)
{
if (world.getBlockMetadata(x, y, z) == 0 || world.getBlockMetadata(x, y, z) == 2)
{
if (world.getBlockId(x, y + 1, z) != Blocks.grave.get().blockID)
{
world.destroyBlock(x, y, z, true);
}
}
else
{
if (world.getBlockId(x, y - 1, z) != Blocks.grave.get().blockID)
{
world.destroyBlock(x, y, z, true);
}
}
}
}
@Override
public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int meta, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
if (meta == 0) ret.add(new ItemStack(Blocks.grave.get(), 1));
else if (meta == 2) ret.add(new ItemStack(Blocks.grave.get(), 1));
return ret;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public int getRenderType()
{
return RenderUtils.graveModel;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
return true;
}
}

View file

@ -0,0 +1,121 @@
package biomesoplenty.common.blocks;
import java.util.List;
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.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Items;
import biomesoplenty.entities.EntityWasp;
public class BlockHive extends Block
{
private static final String[] hiveTypes = new String[] {"honeycomb", "hive", "honeycombempty", "honeycombfilled"};
private Icon[] textures;
public BlockHive(int par1)
{
super(par1, Material.wood);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
if (world.getBlockMetadata(x, y, z) == 2)
{
EntityWasp wasp = new EntityWasp(world);
wasp.setLocationAndAngles((double)x + 0.6, (double)y, (double)z + 0.3, 0.0F, 0.0F);
world.spawnEntityInWorld(wasp);
}
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[hiveTypes.length];
for (int i = 0; i < hiveTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:"+hiveTypes[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= hiveTypes.length) {
meta = 0;
}
return textures[meta];
}
@Override
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list)
{
for (int i = 0; i < hiveTypes.length; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public int idDropped(int meta, Random par2Random, int par3)
{
if (meta == 0)
{
return Items.miscItems.get().itemID;
}
if (meta == 3)
{
return Items.food.get().itemID;
}
return this.blockID;
}
@Override
public int damageDropped(int meta)
{
if (meta == 0)
{
return 2;
}
if (meta == 2)
{
return 0;
}
if (meta == 3)
{
return 9;
}
return meta;
}
@Override
public int quantityDropped(int meta, int fortune, Random random)
{
if (meta == 0)
{
return (random.nextInt(3) + 1);
}
if (meta == 2)
{
return 0;
}
if (meta == 3)
{
return random.nextInt(2);
}
return 1;
}
}

View file

@ -0,0 +1,47 @@
package biomesoplenty.common.blocks;
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.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Fluids;
import biomesoplenty.core.BOPAchievements;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockHoney extends Block
{
public BlockHoney(int par1)
{
super(par1, Material.glass);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
blockIcon = par1IconRegister.registerIcon("biomesoplenty:honeyblock");
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass()
{
return 1;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, 1 - par5);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
}

View file

@ -0,0 +1,383 @@
package biomesoplenty.common.blocks;
import java.util.ArrayList;
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.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Direction;
import net.minecraft.world.ColorizerFoliage;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty;
public class BlockIvy extends Block implements IShearable
{
public BlockIvy(int par1)
{
super(par1, Material.vine);
this.setTickRandomly(true);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
blockIcon = par1IconRegister.registerIcon("biomesoplenty:ivy");
}
/**
* Sets the block's bounds for rendering it as an item
*/
@Override
public void setBlockBoundsForItemRender()
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
* The type of render function that is called for this block
*/
@Override
public int getRenderType()
{
return 20;
}
/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
@Override
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
@Override
public boolean renderAsNormalBlock()
{
return false;
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
@Override
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
float var7 = 1.0F;
float var8 = 1.0F;
float var9 = 1.0F;
float var10 = 0.0F;
float var11 = 0.0F;
float var12 = 0.0F;
boolean var13 = var6 > 0;
if ((var6 & 2) != 0)
{
var10 = Math.max(var10, 0.0625F);
var7 = 0.0F;
var8 = 0.0F;
var11 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
var13 = true;
}
if ((var6 & 8) != 0)
{
var7 = Math.min(var7, 0.9375F);
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
var13 = true;
}
if ((var6 & 4) != 0)
{
var12 = Math.max(var12, 0.0625F);
var9 = 0.0F;
var7 = 0.0F;
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var13 = true;
}
if ((var6 & 1) != 0)
{
var9 = Math.min(var9, 0.9375F);
var12 = 1.0F;
var7 = 0.0F;
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var13 = true;
}
if (!var13 && this.canBePlacedOn(par1IBlockAccess.getBlockId(par2, par3 + 1, par4)))
{
var8 = Math.min(var8, 0.9375F);
var11 = 1.0F;
var7 = 0.0F;
var10 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
}
this.setBlockBounds(var7, var8, var9, var10, var11, var12);
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
/**
* checks to see if you can place this block can be placed on that side of a block: BlockLever overrides
*/
@Override
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
{
switch (par5)
{
case 1:
return this.canBePlacedOn(par1World.getBlockId(par2, par3 + 1, par4));
case 2:
return this.canBePlacedOn(par1World.getBlockId(par2, par3, par4 + 1));
case 3:
return this.canBePlacedOn(par1World.getBlockId(par2, par3, par4 - 1));
case 4:
return this.canBePlacedOn(par1World.getBlockId(par2 + 1, par3, par4));
case 5:
return this.canBePlacedOn(par1World.getBlockId(par2 - 1, par3, par4));
default:
return false;
}
}
/**
* returns true if a vine can be placed on that block (checks for render as normal block and if it is solid)
*/
private boolean canBePlacedOn(int par1)
{
if (par1 == 0)
return false;
else
{
Block var2 = Block.blocksList[par1];
return var2.renderAsNormalBlock() && var2.blockMaterial.blocksMovement();
}
}
/**
* Returns if the vine can stay in the world. It also changes the metadata according to neighboring blocks.
*/
private boolean canVineStay(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockMetadata(par2, par3, par4);
int var6 = var5;
if (var5 > 0)
{
for (int var7 = 0; var7 <= 3; ++var7)
{
int var8 = 1 << var7;
if ((var5 & var8) != 0 && !this.canBePlacedOn(par1World.getBlockId(par2 + Direction.offsetX[var7], par3, par4 + Direction.offsetZ[var7])) && (par1World.getBlockId(par2, par3 + 1, par4) != blockID || (par1World.getBlockMetadata(par2, par3 + 1, par4) & var8) == 0))
{
var6 &= ~var8;
}
}
}
if (var6 == 0 && !this.canBePlacedOn(par1World.getBlockId(par2, par3 + 1, par4)))
return false;
else
{
if (var6 != var5)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6, 2);
}
return true;
}
}
@Override
public int getBlockColor()
{
return ColorizerFoliage.getFoliageColorBasic();
}
/**
* Returns the color this block should be rendered. Used by leaves.
*/
@Override
public int getRenderColor(int par1)
{
return ColorizerFoliage.getFoliageColorBasic();
}
@Override
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
return par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeFoliageColor();
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
@Override
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
if (!par1World.isRemote && !this.canVineStay(par1World, par2, par3, par4))
{
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlock(par2, par3, par4, 0);
}
}
/**
* Ticks the block if it's been scheduled
*/
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
}
/**
* called before onBlockPlacedBy by ItemBlock and ItemReed
*/
public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8)
{
byte var9 = 0;
switch (par5)
{
case 2:
var9 = 1;
break;
case 3:
var9 = 4;
break;
case 4:
var9 = 8;
break;
case 5:
var9 = 2;
}
if (var9 != 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var9, 2);
}
}
/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
*/
@Override
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
{
byte b0 = 0;
switch (par5)
{
case 2:
b0 = 1;
break;
case 3:
b0 = 4;
break;
case 4:
b0 = 8;
break;
case 5:
b0 = 2;
}
return b0 != 0 ? b0 : par9;
}
/**
* Returns the ID of the items to drop on destruction.
*/
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return 0;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
/**
* Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
* block and l is the block's subtype/damage.
*/
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
{
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
}
@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, 0));
return ret;
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
return true;
}
@Override
public boolean isLadder(World world, int x, int y, int z, EntityLivingBase entity)
{
return true;
}
}

View file

@ -0,0 +1,139 @@
package biomesoplenty.common.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

@ -0,0 +1,335 @@
package biomesoplenty.common.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.util.AxisAlignedBB;
import net.minecraft.util.Direction;
import net.minecraft.world.ColorizerFoliage;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
public class BlockMoss extends Block
{
public BlockMoss(int par1)
{
super(par1, Material.vine);
setBurnProperties(blockID, 15, 100);
this.setTickRandomly(true);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
blockIcon = par1IconRegister.registerIcon("biomesoplenty:moss");
}
/**
* Sets the block's bounds for rendering it as an item
*/
@Override
public void setBlockBoundsForItemRender()
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
* The type of render function that is called for this block
*/
@Override
public int getRenderType()
{
return 20;
}
/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
@Override
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
@Override
public boolean renderAsNormalBlock()
{
return false;
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
@Override
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
float var7 = 1.0F;
float var8 = 1.0F;
float var9 = 1.0F;
float var10 = 0.0F;
float var11 = 0.0F;
float var12 = 0.0F;
boolean var13 = var6 > 0;
if ((var6 & 2) != 0)
{
var10 = Math.max(var10, 0.0625F);
var7 = 0.0F;
var8 = 0.0F;
var11 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
var13 = true;
}
if ((var6 & 8) != 0)
{
var7 = Math.min(var7, 0.9375F);
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
var13 = true;
}
if ((var6 & 4) != 0)
{
var12 = Math.max(var12, 0.0625F);
var9 = 0.0F;
var7 = 0.0F;
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var13 = true;
}
if ((var6 & 1) != 0)
{
var9 = Math.min(var9, 0.9375F);
var12 = 1.0F;
var7 = 0.0F;
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var13 = true;
}
if (!var13 && this.canBePlacedOn(par1IBlockAccess.getBlockId(par2, par3 + 1, par4)))
{
var8 = Math.min(var8, 0.9375F);
var11 = 1.0F;
var7 = 0.0F;
var10 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
}
this.setBlockBounds(var7, var8, var9, var10, var11, var12);
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
/**
* checks to see if you can place this block can be placed on that side of a block: BlockLever overrides
*/
@Override
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
{
switch (par5)
{
case 1:
return this.canBePlacedOn(par1World.getBlockId(par2, par3 + 1, par4));
case 2:
return this.canBePlacedOn(par1World.getBlockId(par2, par3, par4 + 1));
case 3:
return this.canBePlacedOn(par1World.getBlockId(par2, par3, par4 - 1));
case 4:
return this.canBePlacedOn(par1World.getBlockId(par2 + 1, par3, par4));
case 5:
return this.canBePlacedOn(par1World.getBlockId(par2 - 1, par3, par4));
default:
return false;
}
}
/**
* returns true if a vine can be placed on that block (checks for render as normal block and if it is solid)
*/
private boolean canBePlacedOn(int par1)
{
if (par1 != Block.wood.blockID && par1 != Blocks.logs3.get().blockID && par1 != Block.stone.blockID)
return false;
else
return true;
}
/**
* Returns if the vine can stay in the world. It also changes the metadata according to neighboring blocks.
*/
private boolean canVineStay(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockMetadata(par2, par3, par4);
int var6 = var5;
if (var5 > 0)
{
for (int var7 = 0; var7 <= 3; ++var7)
{
int var8 = 1 << var7;
if ((var5 & var8) != 0 && !this.canBePlacedOn(par1World.getBlockId(par2 + Direction.offsetX[var7], par3, par4 + Direction.offsetZ[var7])) && (par1World.getBlockId(par2, par3 + 1, par4) != blockID || (par1World.getBlockMetadata(par2, par3 + 1, par4) & var8) == 0))
{
var6 &= ~var8;
}
}
}
if (var6 == 0 && !this.canBePlacedOn(par1World.getBlockId(par2, par3 + 1, par4)))
return false;
else
{
if (var6 != var5)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6, 2);
}
return true;
}
}
@Override
public int getBlockColor()
{
return ColorizerFoliage.getFoliageColorBasic();
}
/**
* Returns the color this block should be rendered. Used by leaves.
*/
@Override
public int getRenderColor(int par1)
{
return ColorizerFoliage.getFoliageColorBasic();
}
@Override
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
return par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeFoliageColor();
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
@Override
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
if (!par1World.isRemote && !this.canVineStay(par1World, par2, par3, par4))
{
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlock(par2, par3, par4, 0);
}
}
/**
* Ticks the block if it's been scheduled
*/
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
}
/**
* called before onBlockPlacedBy by ItemBlock and ItemReed
*/
public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8)
{
byte var9 = 0;
switch (par5)
{
case 2:
var9 = 1;
break;
case 3:
var9 = 4;
break;
case 4:
var9 = 8;
break;
case 5:
var9 = 2;
}
if (var9 != 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var9, 2);
}
}
/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
*/
@Override
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
{
byte b0 = 0;
switch (par5)
{
case 2:
b0 = 1;
break;
case 3:
b0 = 4;
break;
case 4:
b0 = 8;
break;
case 5:
b0 = 2;
}
return b0 != 0 ? b0 : par9;
}
@Override
public int quantityDropped(Random par1Random)
{
return 1;
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
return true;
}
}

View file

@ -0,0 +1,139 @@
package biomesoplenty.common.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 BlockOriginGrass extends Block
{
private Icon[] blockIcon = new Icon[6];
public BlockOriginGrass(int par1)
{
super(par1, Material.grass);
this.setTickRandomly(true);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
blockIcon[0] = par1IconRegister.registerIcon("biomesoplenty:origingrass3");
blockIcon[1] = par1IconRegister.registerIcon("biomesoplenty:origingrass1");
blockIcon[2] = par1IconRegister.registerIcon("biomesoplenty:origingrass2");
blockIcon[3] = par1IconRegister.registerIcon("biomesoplenty:origingrass2");
blockIcon[4] = par1IconRegister.registerIcon("biomesoplenty:origingrass2");
blockIcon[5] = par1IconRegister.registerIcon("biomesoplenty:origingrass2");
}
/**
* 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.originGrass.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

@ -0,0 +1,84 @@
package biomesoplenty.common.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 BlockOvergrownNetherrack extends Block
{
private Icon[] blockIcon = new Icon[6];
public BlockOvergrownNetherrack(int par1)
{
super(par1, Material.rock);
this.setTickRandomly(true);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
blockIcon[0] = par1IconRegister.registerIcon("biomesoplenty:overgrownnetherrack3");
blockIcon[1] = par1IconRegister.registerIcon("biomesoplenty:overgrownnetherrack1");
blockIcon[2] = par1IconRegister.registerIcon("biomesoplenty:overgrownnetherrack2");
blockIcon[3] = par1IconRegister.registerIcon("biomesoplenty:overgrownnetherrack2");
blockIcon[4] = par1IconRegister.registerIcon("biomesoplenty:overgrownnetherrack2");
blockIcon[5] = par1IconRegister.registerIcon("biomesoplenty:overgrownnetherrack2");
}
/**
* 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;
}
/**
* Returns the ID of the items to drop on destruction.
*/
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return Block.netherrack.idDropped(0, par2Random, par3);
}
}

View file

@ -0,0 +1,91 @@
package biomesoplenty.common.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.configuration.BOPConfigurationIDs;
import biomesoplenty.helpers.TeleporterPromised;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockPromisedPortal extends Block
{
public BlockPromisedPortal(int par1)
{
super(par1, Material.portal);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
blockIcon = par1IconRegister.registerIcon("biomesoplenty:portal");
}
@Override
@SideOnly(Side.CLIENT)
/**
* Returns which pass should this block be rendered on. 0 for solids and 1 for alpha
*/
public int getRenderBlockPass()
{
return 1;
}
@Override
@SideOnly(Side.CLIENT)
/**
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
* coordinates. Args: blockAccess, x, y, z, side
*/
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, 1 - par5);
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
{
if (par5Entity.ridingEntity == null && par5Entity.riddenByEntity == null)
{
if (par5Entity instanceof EntityPlayerMP)
{
EntityPlayerMP thePlayer = (EntityPlayerMP) par5Entity;
if (par5Entity.dimension != BOPConfigurationIDs.promisedLandDimID)
{
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, BOPConfigurationIDs.promisedLandDimID, new TeleporterPromised(thePlayer.mcServer.worldServerForDimension(BOPConfigurationIDs.promisedLandDimID)));
}
else
{
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 0, new TeleporterPromised(thePlayer.mcServer.worldServerForDimension(0)));
}
}
}
}
}

View file

@ -0,0 +1,109 @@
package biomesoplenty.common.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.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import biomesoplenty.ClientProxy;
import biomesoplenty.blocks.renderers.RenderUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockPuddle extends Block
{
@SideOnly(Side.CLIENT)
private Icon field_94441_a;
@SideOnly(Side.CLIENT)
private Icon field_94440_b;
public BlockPuddle(int par1)
{
super(par1, Material.ground);
this.setTickRandomly(true);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8135F, 1.0F);
this.setLightOpacity(0);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return AxisAlignedBB.getAABBPool().getAABB((double)(par2 + 0), (double)(par3 + 0), (double)(par4 + 0), (double)(par2 + 1), (double)(par3 + 0.8135F), (double)(par4 + 1));
}
@Override
public boolean isBlockNormalCube(World world, int x, int y, int z)
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public void updateTick(World world, int x, int y, int z, Random par5Random)
{
if (!world.isRaining() && world.rand.nextInt(2) == 0)
{
world.setBlock(x, y, z, Block.dirt.blockID);
}
}
@Override
public int getRenderBlockPass()
{
return 1;
}
@Override
public boolean canRenderInPass(int pass)
{
ClientProxy.puddleRenderPass = pass;
return true;
}
@Override
public int getRenderType()
{
return RenderUtils.puddleModel;
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2)
{
return Block.dirt.getBlockTextureFromSide(par1);
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return Block.dirt.idDropped(0, par2Random, par3);
}
@Override
@SideOnly(Side.CLIENT)
public int idPicked(World par1World, int par2, int par3, int par4)
{
return Block.dirt.blockID;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
}
}

View file

@ -0,0 +1,50 @@
package biomesoplenty.common.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
public class BlockQuicksand extends Block
{
public BlockQuicksand(int par1)
{
super(par1, Material.sand);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
blockIcon = par1IconRegister.registerIcon("biomesoplenty:quicksand");
}
@Override
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return true;
}
/**
* Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
*/
@Override
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
{
par5Entity.setInWeb();
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
}

View file

@ -0,0 +1,174 @@
package biomesoplenty.common.blocks;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.BlockStone;
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.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockStoneFormations extends BlockFlower
{
private static final String[] forms = new String[] {"stalagmite", "stalactite"};
private Icon[] textures;
protected BlockStoneFormations(int blockID, Material material)
{
super(blockID, material);
this.setTickRandomly(true);
float var4 = 0.2F;
this.setBlockBounds(0.5F - var4, 0.0F, 0.5F - var4, 0.5F + var4, var4 * 3.0F, 0.5F + var4);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
public BlockStoneFormations(int blockID)
{
this(blockID, Material.vine);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[forms.length];
for (int i = 0; i < forms.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:" + forms[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
public int getRenderType()
{
return 1;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4)
{
int meta = world.getBlockMetadata(par2, par3, par4);
switch (meta)
{
default:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
}
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < forms.length; ++i)
{
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
protected boolean canThisPlantGrowOnThisBlockID(int id)
{
return Block.blocksList[id] instanceof BlockStone;
}
protected boolean canThisPlantGrowOnThisBlockID(int id, int metadata)
{
return Block.blocksList[id] instanceof BlockStone;
}
@Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack)
{
int idbottom = world.getBlockId(x, y - 1, z);
int idtop = world.getBlockId(x, y + 1, z);
int meta = itemStack.getItemDamage();
//boolean sky = world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z);
if (itemStack.itemID == blockID) {
switch (meta)
{
case 0: // Stalagmite
return Block.blocksList[idbottom] instanceof BlockStone;
case 1: // Stalactite
return Block.blocksList[idtop] instanceof BlockStone;
default:
return Block.blocksList[idbottom] instanceof BlockStone;
}
} else
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);
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
return meta;
}
@Override
public int damageDropped(int meta)
{
return meta & 15;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (world.getBlockId(x, y, z) != blockID)
{
if (meta == 1)
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y + 1, z));
else
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
}
else
{
if (meta == 1)
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y + 1, z), world.getBlockMetadata(x, y, z));
else
return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z));
}
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
return true;
}
}

View file

@ -0,0 +1,355 @@
package biomesoplenty.common.blocks;
import java.util.ArrayList;
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.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Direction;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty;
public class BlockTreeMoss extends Block implements IShearable
{
public BlockTreeMoss(int par1)
{
super(par1, Material.vine);
this.setTickRandomly(true);
setBurnProperties(blockID, 15, 100);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
blockIcon = par1IconRegister.registerIcon("biomesoplenty:treemoss");
}
/**
* Sets the block's bounds for rendering it as an item
*/
@Override
public void setBlockBoundsForItemRender()
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
* The type of render function that is called for this block
*/
@Override
public int getRenderType()
{
return 20;
}
/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
@Override
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
@Override
public boolean renderAsNormalBlock()
{
return false;
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
@Override
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
float var7 = 1.0F;
float var8 = 1.0F;
float var9 = 1.0F;
float var10 = 0.0F;
float var11 = 0.0F;
float var12 = 0.0F;
boolean var13 = var6 > 0;
if ((var6 & 2) != 0)
{
var10 = Math.max(var10, 0.0625F);
var7 = 0.0F;
var8 = 0.0F;
var11 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
var13 = true;
}
if ((var6 & 8) != 0)
{
var7 = Math.min(var7, 0.9375F);
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
var13 = true;
}
if ((var6 & 4) != 0)
{
var12 = Math.max(var12, 0.0625F);
var9 = 0.0F;
var7 = 0.0F;
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var13 = true;
}
if ((var6 & 1) != 0)
{
var9 = Math.min(var9, 0.9375F);
var12 = 1.0F;
var7 = 0.0F;
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var13 = true;
}
if (!var13 && this.canBePlacedOn(par1IBlockAccess.getBlockId(par2, par3 + 1, par4)))
{
var8 = Math.min(var8, 0.9375F);
var11 = 1.0F;
var7 = 0.0F;
var10 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
}
this.setBlockBounds(var7, var8, var9, var10, var11, var12);
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
/**
* checks to see if you can place this block can be placed on that side of a block: BlockLever overrides
*/
@Override
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
{
switch (par5)
{
case 1:
return this.canBePlacedOn(par1World.getBlockId(par2, par3 + 1, par4));
case 2:
return this.canBePlacedOn(par1World.getBlockId(par2, par3, par4 + 1));
case 3:
return this.canBePlacedOn(par1World.getBlockId(par2, par3, par4 - 1));
case 4:
return this.canBePlacedOn(par1World.getBlockId(par2 + 1, par3, par4));
case 5:
return this.canBePlacedOn(par1World.getBlockId(par2 - 1, par3, par4));
default:
return false;
}
}
/**
* returns true if a vine can be placed on that block (checks for render as normal block and if it is solid)
*/
private boolean canBePlacedOn(int par1)
{
if (par1 == 0)
return false;
else
{
Block var2 = Block.blocksList[par1];
return var2.renderAsNormalBlock() && var2.blockMaterial.blocksMovement();
}
}
/**
* Returns if the vine can stay in the world. It also changes the metadata according to neighboring blocks.
*/
private boolean canVineStay(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockMetadata(par2, par3, par4);
int var6 = var5;
if (var5 > 0)
{
for (int var7 = 0; var7 <= 3; ++var7)
{
int var8 = 1 << var7;
if ((var5 & var8) != 0 && !this.canBePlacedOn(par1World.getBlockId(par2 + Direction.offsetX[var7], par3, par4 + Direction.offsetZ[var7])) && (par1World.getBlockId(par2, par3 + 1, par4) != blockID || (par1World.getBlockMetadata(par2, par3 + 1, par4) & var8) == 0))
{
var6 &= ~var8;
}
}
}
if (var6 == 0 && !this.canBePlacedOn(par1World.getBlockId(par2, par3 + 1, par4)))
return false;
else
{
if (var6 != var5)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6, 2);
}
return true;
}
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
@Override
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
if (!par1World.isRemote && !this.canVineStay(par1World, par2, par3, par4))
{
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockToAir(par2, par3, par4);
}
}
/**
* Ticks the block if it's been scheduled
*/
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
}
/**
* called before onBlockPlacedBy by ItemBlock and ItemReed
*/
public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8)
{
byte var9 = 0;
switch (par5)
{
case 2:
var9 = 1;
break;
case 3:
var9 = 4;
break;
case 4:
var9 = 8;
break;
case 5:
var9 = 2;
}
if (var9 != 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var9, 2);
}
}
/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
*/
@Override
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
{
byte b0 = 0;
switch (par5)
{
case 2:
b0 = 1;
break;
case 3:
b0 = 4;
break;
case 4:
b0 = 8;
break;
case 5:
b0 = 2;
}
return b0 != 0 ? b0 : par9;
}
/**
* Returns the ID of the items to drop on destruction.
*/
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return 0;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
/**
* Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
* block and l is the block's subtype/damage.
*/
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
{
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
}
@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, 0));
return ret;
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
return true;
}
}

View file

@ -0,0 +1,87 @@
package biomesoplenty.common.blocks;
import java.util.Random;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Items;
import net.minecraft.block.BlockCrops;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockTurnip extends BlockCrops
{
@SideOnly(Side.CLIENT)
private Icon[] iconArray;
public BlockTurnip(int par1)
{
super(par1);
}
@SideOnly(Side.CLIENT)
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
@Override
public Icon getIcon(int par1, int par2)
{
if (par2 < 7)
{
if (par2 == 6)
{
par2 = 5;
}
return this.iconArray[par2 >> 1];
}
else
{
return this.iconArray[3];
}
}
/**
* Generate a seed ItemStack for this crop.
*/
@Override
protected int getSeedItem()
{
return Items.turnipseeds.get().itemID;
}
/**
* Generate a crop produce ItemStack for this crop.
*/
@Override
protected int getCropItem()
{
return Items.food.get().itemID;
}
@Override
public int damageDropped(int meta)
{
return meta == 7 ? 11 : 0;
}
@SideOnly(Side.CLIENT)
/**
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
* is the only chance you get to register icons.
*/
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.iconArray = new Icon[4];
for (int i = 0; i < this.iconArray.length; ++i)
{
this.iconArray[i] = par1IconRegister.registerIcon("biomesoplenty:" + this.getTextureName() + "_stage_" + i);
}
}
}

View file

@ -0,0 +1,381 @@
package biomesoplenty.common.blocks;
import java.util.ArrayList;
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.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Direction;
import net.minecraft.world.ColorizerFoliage;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty;
public class BlockWillow extends Block implements IShearable
{
public BlockWillow(int par1)
{
super(par1, Material.vine);
setBurnProperties(blockID, 15, 100);
this.setTickRandomly(true);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
blockIcon = par1IconRegister.registerIcon("biomesoplenty:willow");
}
/**
* Sets the block's bounds for rendering it as an item
*/
@Override
public void setBlockBoundsForItemRender()
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
* The type of render function that is called for this block
*/
@Override
public int getRenderType()
{
return 20;
}
/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
@Override
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
@Override
public boolean renderAsNormalBlock()
{
return false;
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
@Override
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
float var7 = 1.0F;
float var8 = 1.0F;
float var9 = 1.0F;
float var10 = 0.0F;
float var11 = 0.0F;
float var12 = 0.0F;
boolean var13 = var6 > 0;
if ((var6 & 2) != 0)
{
var10 = Math.max(var10, 0.0625F);
var7 = 0.0F;
var8 = 0.0F;
var11 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
var13 = true;
}
if ((var6 & 8) != 0)
{
var7 = Math.min(var7, 0.9375F);
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
var13 = true;
}
if ((var6 & 4) != 0)
{
var12 = Math.max(var12, 0.0625F);
var9 = 0.0F;
var7 = 0.0F;
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var13 = true;
}
if ((var6 & 1) != 0)
{
var9 = Math.min(var9, 0.9375F);
var12 = 1.0F;
var7 = 0.0F;
var10 = 1.0F;
var8 = 0.0F;
var11 = 1.0F;
var13 = true;
}
if (!var13 && this.canBePlacedOn(par1IBlockAccess.getBlockId(par2, par3 + 1, par4)))
{
var8 = Math.min(var8, 0.9375F);
var11 = 1.0F;
var7 = 0.0F;
var10 = 1.0F;
var9 = 0.0F;
var12 = 1.0F;
}
this.setBlockBounds(var7, var8, var9, var10, var11, var12);
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
/**
* checks to see if you can place this block can be placed on that side of a block: BlockLever overrides
*/
@Override
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
{
switch (par5)
{
case 1:
return this.canBePlacedOn(par1World.getBlockId(par2, par3 + 1, par4));
case 2:
return this.canBePlacedOn(par1World.getBlockId(par2, par3, par4 + 1));
case 3:
return this.canBePlacedOn(par1World.getBlockId(par2, par3, par4 - 1));
case 4:
return this.canBePlacedOn(par1World.getBlockId(par2 + 1, par3, par4));
case 5:
return this.canBePlacedOn(par1World.getBlockId(par2 - 1, par3, par4));
default:
return false;
}
}
/**
* returns true if a vine can be placed on that block (checks for render as normal block and if it is solid)
*/
private boolean canBePlacedOn(int par1)
{
if (par1 == 0)
return false;
else
{
Block var2 = Block.blocksList[par1];
return var2.renderAsNormalBlock() && var2.blockMaterial.blocksMovement();
}
}
/**
* Returns if the vine can stay in the world. It also changes the metadata according to neighboring blocks.
*/
private boolean canVineStay(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockMetadata(par2, par3, par4);
int var6 = var5;
if (var5 > 0)
{
for (int var7 = 0; var7 <= 3; ++var7)
{
int var8 = 1 << var7;
if ((var5 & var8) != 0 && !this.canBePlacedOn(par1World.getBlockId(par2 + Direction.offsetX[var7], par3, par4 + Direction.offsetZ[var7])) && (par1World.getBlockId(par2, par3 + 1, par4) != blockID || (par1World.getBlockMetadata(par2, par3 + 1, par4) & var8) == 0))
{
var6 &= ~var8;
}
}
}
if (var6 == 0 && !this.canBePlacedOn(par1World.getBlockId(par2, par3 + 1, par4)))
return false;
else
{
if (var6 != var5)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6, 2);
}
return true;
}
}
@Override
public int getBlockColor()
{
return ColorizerFoliage.getFoliageColorBasic();
}
/**
* Returns the color this block should be rendered. Used by leaves.
*/
@Override
public int getRenderColor(int par1)
{
return ColorizerFoliage.getFoliageColorBasic();
}
/**
* Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called
* when first determining what to render.
*/
@Override
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
return par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeFoliageColor();
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
@Override
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
if (!par1World.isRemote && !this.canVineStay(par1World, par2, par3, par4))
{
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlock(par2, par3, par4, 0);
}
}
/**
* Ticks the block if it's been scheduled
*/
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
}
/**
* called before onBlockPlacedBy by ItemBlock and ItemReed
*/
public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8)
{
byte var9 = 0;
switch (par5)
{
case 2:
var9 = 1;
break;
case 3:
var9 = 4;
break;
case 4:
var9 = 8;
break;
case 5:
var9 = 2;
}
if (var9 != 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var9, 2);
}
}
/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
*/
@Override
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
{
byte b0 = 0;
switch (par5)
{
case 2:
b0 = 1;
break;
case 3:
b0 = 4;
break;
case 4:
b0 = 8;
break;
case 5:
b0 = 2;
}
return b0 != 0 ? b0 : par9;
}
/**
* Returns the ID of the items to drop on destruction.
*/
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return 0;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
/**
* Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
* block and l is the block's subtype/damage.
*/
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
{
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
}
@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, 0));
return ret;
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
return true;
}
}

View file

@ -0,0 +1,37 @@
package biomesoplenty.common.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockAmethyst extends ItemBlock
{
private static final String[] types = new String[] {"amethystore", "amethystblock", "rubyore", "rubyblock", "peridotore", "peridotblock", "topazore", "topazblock", "tanzaniteore", "tanzaniteblock", "malachiteore", "malachiteblock", "sapphireore", "sapphireblock"};
public ItemBlockAmethyst(Block block)
{
super(block);
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta;
}
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
int meta = itemstack.getItemDamage();
if (meta < 0 || meta >= types.length)
{
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta];
}
}

View file

@ -0,0 +1,21 @@
package biomesoplenty.common.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
public class ItemBlockAppleLeaves extends ItemBlock
{
public ItemBlockAppleLeaves(Block block)
{
super(block);
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta;
}
}

View file

@ -0,0 +1,26 @@
package biomesoplenty.common.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.IIcon;
public class ItemBlockBamboo extends ItemBlock
{
public ItemBlockBamboo(Block block)
{
super(block);
}
@Override
public void registerIcons(IIconRegister iconRegister)
{
itemIcon = iconRegister.registerIcon("biomesoplenty:item_bamboo");
}
@Override
public IIcon getIconFromDamage(int meta)
{
return itemIcon;
}
}

View file

@ -0,0 +1,128 @@
package biomesoplenty.common.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemBlockBones extends ItemBlock
{
private static final String[] types = new String[] {"bones_small", "bones_medium", "bones_large", "bones_small_side_1", "bones_small_side_2", "bones_medium_side_1", "bones_medium_side_2"};
public ItemBlockBones(Block block)
{
super(block);
this.setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
int meta = itemstack.getItemDamage();
if (meta < 0 || meta >= types.length)
{
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta];
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitVecX, float hitVecY, float hitVecZ)
{
//TODO: getBlock()
Block block = world.func_147439_a(x, y, z);
if (block == Blocks.snow && (world.getBlockMetadata(x, y, z) & 7) < 1)
{
side = 1;
}
else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(world, x, y, z))
{
if (side == 0)
{
--y;
}
if (side == 1)
{
++y;
}
if (side == 2)
{
--z;
}
if (side == 3)
{
++z;
}
if (side == 4)
{
--x;
}
if (side == 5)
{
++x;
}
}
if (itemstack.stackSize == 0)
return false;
else if (!player.canPlayerEdit(x, y, z, side, itemstack))
return false;
//TODO: getBlockMaterial()
else if (y == 255 && block.func_149688_o().isSolid())
return false;
//TODO: canPlaceEntityOnSide()?
else if (world.func_147472_a(block, x, y, z, false, side, player, itemstack))
{
int j1 = this.getMetadata(itemstack.getItemDamage());
if (side == 2 || side == 3)
{
if (itemstack.getItemDamage() == 0) {
j1 = 3;
} else if (itemstack.getItemDamage() == 1) {
j1 = 5;
}
}
if (side == 4 || side == 5)
{
if (itemstack.getItemDamage() == 0) {
j1 = 4;
} else if (itemstack.getItemDamage() == 1) {
j1 = 6;
}
}
//TODO: onBlockPlaced()
int k1 = block.func_149660_a(world, x, y, z, side, hitVecX, hitVecY, hitVecZ, j1);
if (placeBlockAt(itemstack, player, world, x, y, z, side, hitVecX, hitVecY, hitVecZ, k1))
{
//TODO: stepSound.getPlaceSound() stepSound.getVolume() stepSound.getPitch()
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.field_149762_H.func_150496_b(), (block.field_149762_H.func_150497_c() + 1.0F) / 2.0F, block.field_149762_H.func_150494_d() * 0.8F);
--itemstack.stackSize;
}
return true;
} else
return false;
}
}

View file

@ -0,0 +1,31 @@
package biomesoplenty.common.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import biomesoplenty.common.blocks.BlockBOPColorizedLeaves;
public class ItemBlockColorizedLeaves extends ItemBlock
{
public ItemBlockColorizedLeaves(Block block)
{
super(block);
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta | 4;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
//TODO: block
BlockBOPColorizedLeaves block = (BlockBOPColorizedLeaves)field_150939_a;
return super.getUnlocalizedName() + "." + block.getLeafType(itemStack.getItemDamage());
}
}

View file

@ -0,0 +1,158 @@
package biomesoplenty.common.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockCoral extends ItemBlock
{
private static final String[] coral = new String[] {"kelpbottom", "kelpmiddle", "kelptop", "kelpsingle", "pinkcoral", "orangecoral", "bluecoral", "glowcoral"};
@SideOnly(Side.CLIENT)
private IIcon[] textures;
public ItemBlockCoral(Block block)
{
super(block);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
textures = new IIcon[1];
textures[0] = iconRegister.registerIcon("biomesoplenty:item_kelp");
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= coral.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + coral[meta];
}
@Override
public IIcon getIconFromDamage(int meta)
{
if (meta == 3)
return textures[0];
else
//TODO: block getIcon()
return field_150939_a.func_149691_a(0, meta);
}
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return null;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 20;
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
//TODO: getBlock()
Block block = world.func_147439_a(x, y, z);
if (block == Blocks.snow && (world.getBlockMetadata(x, y, z) & 7) < 1)
{
side = 1;
}
else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(world, x, y, z))
{
if (side == 0)
{
--y;
}
if (side == 1)
{
++y;
}
if (side == 2)
{
--z;
}
if (side == 3)
{
++z;
}
if (side == 4)
{
--x;
}
if (side == 5)
{
++x;
}
}
if (itemstack.stackSize == 0)
return false;
else if (!player.canPlayerEdit(x, y, z, side, itemstack))
return false;
//TODO: getBlockMaterial()
else if (y == 255 && block.func_149688_o().isSolid())
return false;
//TODO: canPlaceEntityOnSide()?
else if (world.func_147472_a(block, x, y, z, false, side, player, itemstack))
{
//TODO: getBlock() getBlock()
if (world.func_147439_a(x, y + 1, z) == Blocks.water)
{
onItemUsePlaceBlock(itemstack, player, world, x, y, z, side, hitX, hitY, hitZ);
return true;
}
}
return false;
}
public void onItemUsePlaceBlock(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitVecX, float hitVecY, float hitVecZ)
{
//TODO: block
Block block = field_150939_a;
int j1 = this.getMetadata(itemstack.getItemDamage());
//TODO: onBlockPlaced()
int k1 = block.func_149660_a(world, x, y, z, side, hitVecX, hitVecY, hitVecZ, j1);
if (placeBlockAt(itemstack, player, world, x, y, z, side, hitVecX, hitVecY, hitVecZ, k1))
{
//TODO: stepSound.getPlaceSound() stepSound.getVolume() stepSound.getPitch()
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.field_149762_H.func_150496_b(), (block.field_149762_H.func_150497_c() + 1.0F) / 2.0F, block.field_149762_H.func_150494_d() * 0.8F);
--itemstack.stackSize;
}
}
}

View file

@ -0,0 +1,196 @@
package biomesoplenty.itemblocks;
import java.util.Random;
import javax.swing.IIcon;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockFlower extends ItemBlock
{
private static final String[] plants = new String[] {"clover", "swampflower", "deadbloom", "glowflower", "hydrangea", "cosmos", "daffodil", "wildflower", "violet", "anemone", "lilyflower", "rainbowflower", "bromeliad", "sunflowerbottom", "sunflowertop", "dandelion"};
@SideOnly(Side.CLIENT)
private IIcon[] textures;
private static final int SUNFLOWERTOP = 14;
public ItemBlockFlower(Block block)
{
super(block);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIIcons(IIconRegister IIconRegister)
{
textures = new IIcon[2];
textures[0] = IIconRegister.registerIIcon("biomesoplenty:item_sunflower");
textures[1] = IIconRegister.registerIIcon("biomesoplenty:item_rainbowflower");
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= plants.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + plants[meta];
}
@Override
public IIcon getIIconFromDamage(int meta)
{
if (meta == 11)
return textures[1];
else if (meta == 13)
return textures[0];
else
return Block.blocksList[itemID].getIIcon(0, meta);
}
@Override
@SideOnly(Side.CLIENT)
public boolean isFull3D()
{
return true;
}
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
if (par1ItemStack.getItemDamage() == 15)
return EnumAction.block;
else
return null;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 20;
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (par1ItemStack.getItemDamage() == 15)
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
--par1ItemStack.stackSize;
}
return par1ItemStack;
}
@Override
public void onUsingItemTick(ItemStack stack, EntityPlayer player, int count)
{
Vec3 vec = player.getLook(0.5F);
Random rnd = player.getRNG();
for (int p = 0; p < 4; ++p)
{
float pos = (rnd.nextFloat() - 0.5F) / 8;
BiomesOPlenty.proxy.spawnParticle("dandelion", player.posX + vec.xCoord + pos, player.posY + vec.yCoord + player.getEyeHeight() + pos, player.posZ + vec.zCoord + pos);
}
if (count < 10) {
player.stopUsingItem();
}
}
@Override
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
{
if (!par3EntityPlayer.capabilities.isCreativeMode && !par2World.isRemote) {
--par1ItemStack.stackSize;
}
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
int id = world.getBlockId(x, y, z);
if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1) {
side = 1;
} else if (!Block.blocksList[id].isBlockReplaceable(world, x, y, z))
{
if (side == 0) {
--y;
}
if (side == 1) {
++y;
}
if (side == 2) {
--z;
}
if (side == 3) {
++z;
}
if (side == 4) {
--x;
}
if (side == 5) {
++x;
}
}
if (!player.canPlayerEdit(x, y, z, side, itemStack))
return false;
else if (itemStack.stackSize == 0)
return false;
else
{
if (world.canPlaceEntityOnSide(this.getBlockID(), x, y, z, false, side, (Entity)null, itemStack))
{
Block block = Block.blocksList[this.getBlockID()];
int j1 = block.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, 0);
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);
Block.blocksList[this.getBlockID()].onPostBlockPlaced(world, x, y, z, j1);
}
world.playSoundEffect(x + 0.5F, y + 0.5F, 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,113 @@
package biomesoplenty.itemblocks;
import javax.swing.Icon;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockFlower2 extends ItemBlock
{
private static final String[] plants = new String[] {"hibiscus", "lilyofthevalley", "burningblossom", "lavender", "goldenrod", "bluebells", "minersdelight", "icyiris"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
public ItemBlockFlower2(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= plants.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + plants[meta];
}
@Override
public Icon getIconFromDamage(int meta)
{
return Block.blocksList[itemID].getIcon(0, meta);
}
@Override
@SideOnly(Side.CLIENT)
public boolean isFull3D()
{
return true;
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
int id = world.getBlockId(x, y, z);
if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1) {
side = 1;
} else if (!Block.blocksList[id].isBlockReplaceable(world, x, y, z))
{
if (side == 0) {
--y;
}
if (side == 1) {
++y;
}
if (side == 2) {
--z;
}
if (side == 3) {
++z;
}
if (side == 4) {
--x;
}
if (side == 5) {
++x;
}
}
if (!player.canPlayerEdit(x, y, z, side, itemStack))
return false;
else if (itemStack.stackSize == 0)
return false;
else
{
if (world.canPlaceEntityOnSide(this.getBlockID(), x, y, z, false, side, (Entity)null, itemStack))
{
Block block = Block.blocksList[this.getBlockID()];
int j1 = block.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, 0);
if (world.setBlock(x, y, z, this.getBlockID(), itemStack.getItemDamage(), 3))
{
if (world.getBlockId(x, y, z) == this.getBlockID())
{
Block.blocksList[this.getBlockID()].onBlockPlacedBy(world, x, y, z, player, itemStack);
Block.blocksList[this.getBlockID()].onPostBlockPlaced(world, x, y, z, j1);
}
world.playSoundEffect(x + 0.5F, y + 0.5F, 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,189 @@
package biomesoplenty.itemblocks;
import javax.swing.Icon;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemColored;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockFoliage extends ItemColored
{
private static final String[] foliageTypes = new String[] {"algae", "shortgrass", "mediumgrass", "highgrassbottom", "bush", "sprout", "highgrasstop", "poisonivy", "berrybush", "shrub", "wheatgrass", "dampgrass", "koru", "cloverpatch"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
private static final int GRASSTOP = 6;
public ItemBlockFoliage(int par1)
{
super(par1, true);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[foliageTypes.length];
for (int i = 0; i < foliageTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:" + foliageTypes[i]);
}
textures[3] = iconRegister.registerIcon("biomesoplenty:item_highgrass");
textures[8] = iconRegister.registerIcon("biomesoplenty:item_berrybush");
textures[9] = iconRegister.registerIcon("biomesoplenty:item_shrub");
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack itemStack, int par2)
{
if (itemStack.getItemDamage() == 3 || itemStack.getItemDamage() == 8 || itemStack.getItemDamage() == 9)
return 16777215;
else
return Blocks.foliage.get().getRenderColor(itemStack.getItemDamage());
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= foliageTypes.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + foliageTypes[meta];
}
@Override
public Icon getIconFromDamage(int meta)
{
if (meta == GRASSTOP) {
meta = 3;
}
return textures[meta];
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
if (itemStack.getItemDamage() != 0)
return super.onItemRightClick(itemStack, world, player);
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
if (movingobjectposition == null)
return itemStack;
else
{
if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
{
int i = movingobjectposition.blockX;
int j = movingobjectposition.blockY;
int k = movingobjectposition.blockZ;
if (!world.canMineBlock(player, i, j, k))
return itemStack;
if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack))
return itemStack;
if (world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0 && world.isAirBlock(i, j + 1, k))
{
world.setBlock(i, j + 1, k, itemStack.itemID, 0, 2);
if (!player.capabilities.isCreativeMode)
{
--itemStack.stackSize;
}
}
}
return itemStack;
}
}
@Override
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() == 0)
return super.onItemUse(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ);
int id = world.getBlockId(x, y, z);
if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1) {
side = 1;
} else if (!Block.blocksList[id].isBlockReplaceable(world, x, y, z))
{
if (side == 0) {
--y;
}
if (side == 1) {
++y;
}
if (side == 2) {
--z;
}
if (side == 3) {
++z;
}
if (side == 4) {
--x;
}
if (side == 5) {
++x;
}
}
if (!player.canPlayerEdit(x, y, z, side, itemStack))
return false;
else if (itemStack.stackSize == 0)
return false;
else
{
if (world.canPlaceEntityOnSide(this.getBlockID(), x, y, z, false, side, (Entity)null, itemStack))
{
Block block = Block.blocksList[this.getBlockID()];
int j1 = block.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, 0);
if (world.setBlock(x, y, z, this.getBlockID(), itemStack.getItemDamage(), 3))
{
if (itemStack.getItemDamage() == 3 && world.getBlockMaterial(x, y + 1, z).isReplaceable()) {
world.setBlock(x, y + 1, z, this.getBlockID(), GRASSTOP, 2);
}
if (world.getBlockId(x, y, z) == this.getBlockID())
{
Block.blocksList[this.getBlockID()].onBlockPlacedBy(world, x, y, z, player, itemStack);
Block.blocksList[this.getBlockID()].onPostBlockPlaced(world, x, y, z, j1);
}
world.playSoundEffect(x + 0.5F, y + 0.5F, 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,32 @@
package biomesoplenty.itemblocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockGrass extends ItemBlock
{
private static final String[] types = new String[] {"holygrass", "smolderinggrass"};
public ItemBlockGrass(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta;
}
@Override
public String getUnlocalizedName(ItemStack itemstack) {
int meta = itemstack.getItemDamage();
if (meta < 0 || meta >= types.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta];
}
}

View file

@ -0,0 +1,132 @@
package biomesoplenty.common.itemblocks;
import javax.swing.Icon;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockGrave extends ItemBlock
{
private Icon grave;
public ItemBlockGrave(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
grave = iconRegister.registerIcon("biomesoplenty:item_grave");
}
@Override
public Icon getIconFromDamage(int meta)
{
return grave;
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10)
{
int id = world.getBlockId(x, y, z);
if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1)
{
side = 1;
}
else if (id != Block.vine.blockID && id != Block.tallGrass.blockID && id != Block.deadBush.blockID
&& (Block.blocksList[id] == null || !Block.blocksList[id].isBlockReplaceable(world, x, y, z)))
{
if (side == 0)
{
--y;
}
if (side == 1)
{
++y;
}
if (side == 2)
{
--z;
}
if (side == 3)
{
++z;
}
if (side == 4)
{
--x;
}
if (side == 5)
{
++x;
}
}
if (itemstack.stackSize == 0)
return false;
else if (!player.canPlayerEdit(x, y, z, side, itemstack))
return false;
else if (y == 255 && Block.blocksList[itemID].blockMaterial.isSolid())
return false;
else if (world.canPlaceEntityOnSide(itemID, x, y, z, false, side, player, itemstack))
{
Block block = Block.blocksList[itemID];
int o = ((MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4;
int fO;
if (o == 0 || o == 2)
{
fO = 0;
}
else
{
fO = 2;
}
if (placeGrave(itemstack, player, block, world, x, y, z, fO, side, par8, par9, par10)) return true;
}
return false;
}
private boolean placeGrave(ItemStack itemstack, EntityPlayer player, Block block, World world, int x, int y, int z, int meta, int side, float par8, float par9, float par10)
{
if (world.isAirBlock(x, y + 1, z))
{
int k1 = Block.blocksList[itemID].onBlockPlaced(world, x, y, z, side, par8, par9, par10, meta);
int k2 = Block.blocksList[itemID].onBlockPlaced(world, x, y, z, side, par8, par9, par10, meta + 1);
if (placeBlockAt(itemstack, player, world, x, y, z, side, par8, par9, par10, k1) && placeBlockAt(itemstack, player, world, x, y + 1, z, side, par8, par9, par10, k2))
{
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
--itemstack.stackSize;
}
return true;
}
return false;
}
}

View file

@ -0,0 +1,37 @@
package biomesoplenty.common.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockHive extends ItemBlock
{
private static final String[] types = new String[] {"honeycomb", "hive", "honeycombempty", "honeycombfilled"};
public ItemBlockHive(Block block)
{
super(block);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
int meta = itemstack.getItemDamage();
if (meta < 0 || meta >= types.length)
{
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta];
}
}

View file

@ -0,0 +1,40 @@
package biomesoplenty.common.itemblocks;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.ItemColored;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import biomesoplenty.api.Blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockIvy extends ItemColored
{
@SideOnly(Side.CLIENT)
private Icon texture;
public ItemBlockIvy(int par1)
{
super(par1, false);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
texture = iconRegister.registerIcon("biomesoplenty:ivy");
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack itemStack, int par2)
{
return Blocks.ivy.get().getRenderColor(itemStack.getItemDamage());
}
@Override
public Icon getIconFromDamage(int meta)
{
return texture;
}
}

View file

@ -0,0 +1,29 @@
package biomesoplenty.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import biomesoplenty.common.blocks.BlockBOPLeaves;
public class ItemBlockLeaves extends ItemBlock
{
public ItemBlockLeaves(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta | 4;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
BlockBOPLeaves block = (BlockBOPLeaves)Block.blocksList[itemStack.itemID];
return super.getUnlocalizedName() + "." + block.getLeafType(itemStack.getItemDamage());
}
}

View file

@ -0,0 +1,29 @@
package biomesoplenty.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import biomesoplenty.common.blocks.BlockBOPLog;
public class ItemBlockLog extends ItemBlock
{
public ItemBlockLog(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 3;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
BlockBOPLog block = (BlockBOPLog)Block.blocksList[itemStack.itemID];
return super.getUnlocalizedName() + "." + block.getWoodType(itemStack.getItemDamage()) + "Wood";
}
}

View file

@ -0,0 +1,31 @@
package biomesoplenty.itemblocks;
import javax.swing.Icon;
import net.minecraft.item.ItemBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockMoss extends ItemBlock
{
@SideOnly(Side.CLIENT)
private Icon texture;
public ItemBlockMoss(int par1)
{
super(par1);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
texture = iconRegister.registerIcon("biomesoplenty:item_moss");
}
@Override
public Icon getIconFromDamage(int meta)
{
return texture;
}
}

View file

@ -0,0 +1,107 @@
package biomesoplenty.itemblocks;
import javax.swing.Icon;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemBlockMushroom extends ItemBlock
{
private static final String[] plants = new String[] {"toadstool", "portobello", "bluemilk", "glowshroom", "flatmushroom"};
public ItemBlockMushroom(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= plants.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + plants[meta];
}
@Override
public Icon getIconFromDamage(int meta)
{
return Block.blocksList[itemID].getIcon(0, meta);
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
int id = world.getBlockId(x, y, z);
if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1) {
side = 1;
} else if (!Block.blocksList[id].isBlockReplaceable(world, x, y, z))
{
if (side == 0) {
--y;
}
if (side == 1) {
++y;
}
if (side == 2) {
--z;
}
if (side == 3) {
++z;
}
if (side == 4) {
--x;
}
if (side == 5) {
++x;
}
}
if (!player.canPlayerEdit(x, y, z, side, itemStack))
return false;
else if (itemStack.stackSize == 0)
return false;
else
{
if (world.canPlaceEntityOnSide(this.getBlockID(), x, y, z, false, side, (Entity)null, itemStack))
{
Block block = Block.blocksList[this.getBlockID()];
int j1 = block.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, 0);
if (world.setBlock(x, y, z, this.getBlockID(), itemStack.getItemDamage(), 3))
{
if (world.getBlockId(x, y, z) == this.getBlockID())
{
Block.blocksList[this.getBlockID()].onBlockPlacedBy(world, x, y, z, player, itemStack);
Block.blocksList[this.getBlockID()].onPostBlockPlaced(world, x, y, z, j1);
}
world.playSoundEffect(x + 0.5F, y + 0.5F, 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,26 @@
package biomesoplenty.itemblocks;
import javax.swing.Icon;
import net.minecraft.item.ItemBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockPersimmonLeaves extends ItemBlock
{
@SideOnly(Side.CLIENT)
private Icon texture;
public ItemBlockPersimmonLeaves(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta;
}
}

View file

@ -0,0 +1,33 @@
package biomesoplenty.itemblocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockPetals extends ItemBlock
{
private static final String[] petals = new String[] {"bigflowerred", "bigfloweryellow"};
public ItemBlockPetals(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= petals.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + petals[meta];
}
}

View file

@ -0,0 +1,33 @@
package biomesoplenty.itemblocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockPlank extends ItemBlock
{
private static final String[] woodTypes = new String[] {"acaciaPlank", "cherryPlank", "darkPlank", "firPlank", "holyPlank", "magicPlank", "mangrovePlank", "palmPlank", "redwoodPlank", "willowPlank", "bambooThatching", "pinePlank", "hellBarkPlank", "jacarandaPlank"};
public ItemBlockPlank(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= woodTypes.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + woodTypes[meta];
}
}

View file

@ -0,0 +1,179 @@
package biomesoplenty.itemblocks;
import javax.swing.Icon;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockPlant extends ItemBlock
{
private static final String[] plants = new String[] {"deadgrass", "desertgrass", "desertsprouts", "dunegrass", "holytallgrass", "thorn", "barley", "cattail", "rivercane", "cattailtop", "cattailbottom", "wildcarrot", "cactus", "witherwart", "reed", "root"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
public ItemBlockPlant(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[6];
textures[0] = iconRegister.registerIcon("biomesoplenty:item_barley");
textures[1] = iconRegister.registerIcon("biomesoplenty:item_cattail");
textures[2] = iconRegister.registerIcon("biomesoplenty:item_rivercane");
textures[3] = iconRegister.registerIcon("biomesoplenty:item_witherwart");
textures[4] = iconRegister.registerIcon("biomesoplenty:item_reed");
textures[5] = iconRegister.registerIcon("biomesoplenty:item_root");
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= plants.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + plants[itemStack.getItemDamage()];
}
@Override
public Icon getIconFromDamage(int meta)
{
if (meta == 6)
return textures[0];
else if (meta == 7)
return textures[1];
else if (meta == 8)
return textures[2];
else if (meta == 13)
return textures[3];
else if (meta == 14)
return textures[4];
else if (meta == 15)
return textures[5];
else
return Block.blocksList[itemID].getIcon(0, meta);
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
if (itemStack.getItemDamage() != 14)
return super.onItemRightClick(itemStack, world, player);
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
if (movingobjectposition == null)
return itemStack;
else
{
if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
{
int i = movingobjectposition.blockX;
int j = movingobjectposition.blockY;
int k = movingobjectposition.blockZ;
if (!world.canMineBlock(player, i, j, k))
return itemStack;
if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack))
return itemStack;
if (world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0 && world.isAirBlock(i, j + 1, k))
{
world.setBlock(i, j + 1, k, itemStack.itemID, 14, 2);
if (!player.capabilities.isCreativeMode)
{
--itemStack.stackSize;
}
}
}
return itemStack;
}
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
int id = world.getBlockId(x, y, z);
if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1) {
side = 1;
} else if (Block.blocksList[id] != null && !Block.blocksList[id].isBlockReplaceable(world, x, y, z))
{
if (side == 0) {
--y;
}
if (side == 1) {
++y;
}
if (side == 2) {
--z;
}
if (side == 3) {
++z;
}
if (side == 4) {
--x;
}
if (side == 5) {
++x;
}
}
if (!player.canPlayerEdit(x, y, z, side, itemStack))
return false;
else if (itemStack.stackSize == 0)
return false;
else
{
if (world.canPlaceEntityOnSide(this.getBlockID(), x, y, z, false, side, (Entity)null, itemStack))
{
Block block = Block.blocksList[this.getBlockID()];
int j1 = block.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, 0);
if (world.setBlock(x, y, z, this.getBlockID(), itemStack.getItemDamage(), 3))
{
if (world.getBlockId(x, y, z) == this.getBlockID())
{
Block.blocksList[this.getBlockID()].onBlockPlacedBy(world, x, y, z, player, itemStack);
Block.blocksList[this.getBlockID()].onPostBlockPlaced(world, x, y, z, j1);
}
world.playSoundEffect(x + 0.5F, y + 0.5F, 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,32 @@
package biomesoplenty.itemblocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockRedRock extends ItemBlock
{
private static final String[] types = new String[] {"redrock", "redcobble", "redbrick"};
public ItemBlockRedRock(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
public String getUnlocalizedName(ItemStack itemstack) {
int meta = itemstack.getItemDamage();
if (meta < 0 || meta >= types.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta];
}
}

View file

@ -0,0 +1,41 @@
package biomesoplenty.itemblocks;
import javax.swing.Icon;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockSapling extends ItemBlock
{
private static final String[] saplings = new String[] {"apple", "yellowautumn", "bamboo", "magic", "dark", "dead", "fir", "holy", "orangeautumn", "origin", "pinkcherry", "maple", "whitecherry", "hellbark", "jacaranda", "persimmon"};
private static final int MAX = 15;
public ItemBlockSapling(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamageForDisplay() > MAX ? 0 : itemStack.getItemDamageForDisplay();
return super.getUnlocalizedName() + "." + (new StringBuilder()).append(saplings[meta]).append("Sapling").toString();
}
@Override
public Icon getIconFromDamage(int meta)
{
return Block.blocksList[itemID].getIcon(0, meta);
}
}

View file

@ -0,0 +1,32 @@
package biomesoplenty.itemblocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockSkystone extends ItemBlock
{
private static final String[] types = new String[] {"holystone", "holycobble", "holybrick", "holystonemossy"};
public ItemBlockSkystone(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
public String getUnlocalizedName(ItemStack itemstack) {
int meta = itemstack.getItemDamage();
if (meta < 0 || meta >= types.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta];
}
}

View file

@ -0,0 +1,37 @@
package biomesoplenty.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemSlab;
import net.minecraft.item.ItemStack;
import biomesoplenty.common.blocks.BlockBOPSlab;
import com.google.common.base.Optional;
public class ItemBlockSlab extends ItemSlab
{
private static Optional<BlockHalfSlab> singleSlab = Optional.absent();
private static Optional<BlockHalfSlab> doubleSlab = Optional.absent();
static public void setSlabs(BlockHalfSlab singleSlab, BlockHalfSlab doubleSlab)
{
ItemBlockSlab.singleSlab = Optional.of(singleSlab);
ItemBlockSlab.doubleSlab = Optional.of(doubleSlab);
}
public ItemBlockSlab(int id) {
super(id, singleSlab.get(), doubleSlab.get(), id == doubleSlab.get().blockID);
}
@Override
public int getMetadata(int meta)
{
return meta & 7;
}
@Override
public String getUnlocalizedName(ItemStack itemStack) {
BlockBOPSlab slab = (BlockBOPSlab)Block.blocksList[itemStack.itemID];
return super.getUnlocalizedName() + "." + (new StringBuilder()).append(slab.getFullSlabName(itemStack.getItemDamage())).toString();
}
}

View file

@ -0,0 +1,113 @@
package biomesoplenty.itemblocks;
import javax.swing.Icon;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockStoneFormations extends ItemBlock
{
private static final String[] forms = new String[] {"stalagmite", "stalactite"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
public ItemBlockStoneFormations(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= forms.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + forms[meta];
}
@Override
public Icon getIconFromDamage(int meta)
{
return Block.blocksList[itemID].getIcon(0, meta);
}
@Override
@SideOnly(Side.CLIENT)
public boolean isFull3D()
{
return true;
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
int id = world.getBlockId(x, y, z);
if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1) {
side = 1;
} else if (!Block.blocksList[id].isBlockReplaceable(world, x, y, z))
{
if (side == 0) {
--y;
}
if (side == 1) {
++y;
}
if (side == 2) {
--z;
}
if (side == 3) {
++z;
}
if (side == 4) {
--x;
}
if (side == 5) {
++x;
}
}
if (!player.canPlayerEdit(x, y, z, side, itemStack))
return false;
else if (itemStack.stackSize == 0)
return false;
else
{
if (world.canPlaceEntityOnSide(this.getBlockID(), x, y, z, false, side, (Entity)null, itemStack))
{
Block block = Block.blocksList[this.getBlockID()];
int j1 = block.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, 0);
if (world.setBlock(x, y, z, this.getBlockID(), itemStack.getItemDamage(), 3))
{
if (world.getBlockId(x, y, z) == this.getBlockID())
{
Block.blocksList[this.getBlockID()].onBlockPlacedBy(world, x, y, z, player, itemStack);
Block.blocksList[this.getBlockID()].onPostBlockPlaced(world, x, y, z, j1);
}
world.playSoundEffect(x + 0.5F, y + 0.5F, 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,24 @@
package biomesoplenty.itemblocks;
import javax.swing.Icon;
import net.minecraft.item.ItemBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockTurnip extends ItemBlock
{
@SideOnly(Side.CLIENT)
private Icon texture;
public ItemBlockTurnip(int par1)
{
super(par1);
}
@Override
public Icon getIconFromDamage(int meta)
{
return texture;
}
}

View file

@ -0,0 +1,40 @@
package biomesoplenty.common.itemblocks;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.ItemColored;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import biomesoplenty.api.Blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockWillow extends ItemColored
{
@SideOnly(Side.CLIENT)
private Icon texture;
public ItemBlockWillow(int par1)
{
super(par1, false);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
texture = iconRegister.registerIcon("biomesoplenty:willow");
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack itemStack, int par2)
{
return Blocks.willow.get().getRenderColor(itemStack.getItemDamage());
}
@Override
public Icon getIconFromDamage(int meta)
{
return texture;
}
}