2013-04-16 08:19:59 +00:00
|
|
|
package biomesoplenty.blocks;
|
2013-03-28 19:03:53 +00:00
|
|
|
|
2013-04-01 10:05:04 +00:00
|
|
|
import static net.minecraftforge.common.ForgeDirection.UP;
|
|
|
|
|
2013-03-28 19:03:53 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
2013-04-19 09:35:26 +00:00
|
|
|
import biomesoplenty.BiomesOPlenty;
|
2013-04-20 01:26:09 +00:00
|
|
|
import biomesoplenty.api.Blocks;
|
2013-04-16 08:19:59 +00:00
|
|
|
import biomesoplenty.configuration.BOPBlocks;
|
2013-04-16 06:43:45 +00:00
|
|
|
|
2013-03-28 19:03:53 +00:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
2013-03-30 17:14:03 +00:00
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
2013-03-31 07:44:08 +00:00
|
|
|
import net.minecraft.util.Icon;
|
2013-03-28 19:03:53 +00:00
|
|
|
import net.minecraft.world.World;
|
2013-04-01 10:05:04 +00:00
|
|
|
import net.minecraft.world.WorldProviderEnd;
|
|
|
|
import net.minecraftforge.common.ForgeDirection;
|
2013-03-28 19:03:53 +00:00
|
|
|
|
2013-03-30 17:14:03 +00:00
|
|
|
//=========================================
|
|
|
|
|
2013-03-28 19:03:53 +00:00
|
|
|
public class BlockHolyGrass extends Block
|
|
|
|
{
|
2013-03-31 07:44:08 +00:00
|
|
|
private Icon[] blockIcon = new Icon[6];
|
|
|
|
|
2013-03-28 19:03:53 +00:00
|
|
|
public BlockHolyGrass(int par1)
|
|
|
|
{
|
|
|
|
super(par1, Material.grass);
|
|
|
|
this.setTickRandomly(true);
|
2013-04-19 09:35:26 +00:00
|
|
|
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
2013-03-28 19:03:53 +00:00
|
|
|
}
|
2013-03-30 17:14:03 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerIcons(IconRegister par1IconRegister)
|
|
|
|
{
|
2013-03-31 07:44:08 +00:00
|
|
|
this.blockIcon[0] = par1IconRegister.registerIcon("BiomesOPlenty:holystone");
|
|
|
|
this.blockIcon[1] = par1IconRegister.registerIcon("BiomesOPlenty:holygrass1");
|
|
|
|
this.blockIcon[2] = par1IconRegister.registerIcon("BiomesOPlenty:holygrass2");
|
|
|
|
this.blockIcon[3] = par1IconRegister.registerIcon("BiomesOPlenty:holygrass2");
|
|
|
|
this.blockIcon[4] = par1IconRegister.registerIcon("BiomesOPlenty:holygrass2");
|
|
|
|
this.blockIcon[5] = par1IconRegister.registerIcon("BiomesOPlenty:holygrass2");
|
2013-03-30 17:14:03 +00:00
|
|
|
}
|
|
|
|
|
2013-03-28 19:03:53 +00:00
|
|
|
/**
|
|
|
|
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
|
|
|
*/
|
2013-04-17 00:09:59 +00:00
|
|
|
@Override
|
|
|
|
public Icon getIcon(int par1, int par2)
|
2013-03-28 19:03:53 +00:00
|
|
|
{
|
2013-03-31 07:44:08 +00:00
|
|
|
return blockIcon[par1];
|
|
|
|
}
|
2013-04-01 10:05:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Currently only called by fire when it is on top of this block.
|
|
|
|
* Returning true will prevent the fire from naturally dying during updating.
|
|
|
|
* Also prevents firing from dying from rain.
|
|
|
|
*
|
|
|
|
* @param world The current world
|
|
|
|
* @param x The blocks X position
|
|
|
|
* @param y The blocks Y position
|
|
|
|
* @param z The blocks Z position
|
|
|
|
* @param metadata The blocks current metadata
|
|
|
|
* @param side The face that the fire is coming from
|
|
|
|
* @return True if this block sustains fire, meaning it will never go out.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean isFireSource(World world, int x, int y, int z, int metadata, ForgeDirection side)
|
|
|
|
{
|
|
|
|
if (blockID == Block.netherrack.blockID && side == UP)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (blockID == this.blockID && side == UP)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if ((world.provider instanceof WorldProviderEnd) && blockID == Block.bedrock.blockID && side == UP)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
|
|
|
|
*/
|
|
|
|
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
|
|
|
|
{
|
|
|
|
if (par1World.provider.isHellWorld)
|
|
|
|
{
|
|
|
|
par1World.playSound(par2, par3, par4, "mob.ghast.death", 20.0F, 0.95F + (float)Math.random() * 0.1F, true);
|
|
|
|
|
|
|
|
for (int l = 0; l < 8; ++l)
|
|
|
|
{
|
|
|
|
par1World.spawnParticle("flame", (double)par2 + Math.random(), (double)par3 + Math.random(), (double)par4 + Math.random(), 0.0D, 0.0D, 0.0D);
|
|
|
|
par1World.spawnParticle("smoke", (double)par2 + Math.random(), (double)par3 + Math.random(), (double)par4 + Math.random(), 0.0D, 0.0D, 0.0D);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return par9;
|
|
|
|
}
|
2013-03-28 19:03:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
|
|
|
*/
|
2013-03-30 17:14:03 +00:00
|
|
|
/*public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
2013-03-28 19:03:53 +00:00
|
|
|
{
|
|
|
|
if (par5 == 1)
|
|
|
|
{
|
|
|
|
return 29;
|
|
|
|
}
|
|
|
|
else if (par5 == 0)
|
|
|
|
{
|
|
|
|
return 27;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Material var6 = par1IBlockAccess.getBlockMaterial(par2, par3 + 1, par4);
|
|
|
|
return var6 != Material.snow && var6 != Material.craftedSnow ? 28 : 28;
|
|
|
|
}
|
2013-03-30 17:14:03 +00:00
|
|
|
}*/
|
2013-03-28 19:03:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Ticks the block if it's been scheduled
|
|
|
|
*/
|
|
|
|
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
|
|
|
{
|
2013-04-01 10:05:04 +00:00
|
|
|
if (par1World.provider.isHellWorld)
|
|
|
|
{
|
|
|
|
par1World.setBlock(par2, par3 + 1, par4, Block.fire.blockID);
|
2013-04-20 01:26:09 +00:00
|
|
|
par1World.setBlock(par2, par3, par4, Blocks.smolderingGrass.get().blockID);
|
2013-04-01 10:05:04 +00:00
|
|
|
}
|
|
|
|
|
2013-03-28 19:03:53 +00:00
|
|
|
if (!par1World.isRemote)
|
|
|
|
{
|
|
|
|
if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && Block.lightOpacity[par1World.getBlockId(par2, par3 + 1, par4)] > 2)
|
|
|
|
{
|
2013-04-20 01:26:09 +00:00
|
|
|
par1World.setBlock(par2, par3, par4, Blocks.holyStone.get().blockID);
|
2013-03-28 19:03:53 +00:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
|
2013-04-20 01:26:09 +00:00
|
|
|
if (par1World.getBlockId(var7, var8, var9) == Blocks.holyStone.get().blockID && par1World.getBlockLightValue(var7, var8 + 1, var9) >= 4 && Block.lightOpacity[var10] <= 2)
|
2013-03-28 19:03:53 +00:00
|
|
|
{
|
2013-04-20 01:26:09 +00:00
|
|
|
par1World.setBlock(var7, var8, var9, Blocks.holyGrass.get().blockID);
|
2013-03-28 19:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the ID of the items to drop on destruction.
|
|
|
|
*/
|
|
|
|
public int idDropped(int par1, Random par2Random, int par3)
|
|
|
|
{
|
2013-04-20 01:26:09 +00:00
|
|
|
return Blocks.holyStone.get().idDropped(0, par2Random, par3);
|
2013-03-28 19:03:53 +00:00
|
|
|
}
|
|
|
|
}
|