2013-07-01 07:33:41 +00:00
|
|
|
package biomesoplenty.blocks;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
2013-07-01 09:27:31 +00:00
|
|
|
import net.minecraft.client.particle.EffectRenderer;
|
|
|
|
import net.minecraft.client.particle.EntityDiggingFX;
|
2013-07-02 03:57:49 +00:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2013-07-01 09:27:31 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2013-07-01 07:33:41 +00:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2013-07-01 09:27:31 +00:00
|
|
|
import net.minecraft.util.MathHelper;
|
2013-07-03 02:33:15 +00:00
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
2013-07-01 09:27:31 +00:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2013-07-01 07:33:41 +00:00
|
|
|
import net.minecraft.world.World;
|
2013-07-01 09:27:31 +00:00
|
|
|
import biomesoplenty.BiomesOPlenty;
|
2013-07-01 07:33:41 +00:00
|
|
|
import biomesoplenty.tileentity.TileEntityGrave;
|
|
|
|
|
|
|
|
public class BlockGrave extends Block
|
|
|
|
{
|
|
|
|
public BlockGrave(int id)
|
|
|
|
{
|
|
|
|
super(id, Material.rock);
|
|
|
|
|
|
|
|
setHardness(5f);
|
2013-07-01 09:27:31 +00:00
|
|
|
setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
|
|
|
}
|
|
|
|
|
2013-07-02 03:57:49 +00:00
|
|
|
|
2013-07-01 09:27:31 +00:00
|
|
|
@Override
|
2013-07-02 03:57:49 +00:00
|
|
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack)
|
2013-07-01 09:27:31 +00:00
|
|
|
{
|
|
|
|
int o = ((MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4;
|
|
|
|
int fO;
|
|
|
|
|
|
|
|
if (o == 0 || o == 2)
|
|
|
|
{
|
|
|
|
fO = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fO = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!world.isRemote)
|
|
|
|
{
|
|
|
|
world.setBlockMetadataWithNotify(x, y, z, fO, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-03 02:33:15 +00:00
|
|
|
@Override
|
|
|
|
public boolean addBlockHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer)
|
|
|
|
{
|
|
|
|
int i1 = worldObj.getBlockId(target.blockX, target.blockY, target.blockZ);
|
|
|
|
|
|
|
|
if (i1 != 0)
|
|
|
|
{
|
|
|
|
Block block = Block.stone;
|
|
|
|
float f = 0.1F;
|
|
|
|
double d0 = (double)target.blockX + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinX();
|
|
|
|
double d1 = (double)target.blockY + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinY();
|
|
|
|
double d2 = (double)target.blockZ + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinZ();
|
|
|
|
|
|
|
|
if (target.sideHit == 0)
|
|
|
|
{
|
|
|
|
d1 = (double)target.blockY + block.getBlockBoundsMinY() - (double)f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target.sideHit == 1)
|
|
|
|
{
|
|
|
|
d1 = (double)target.blockY + block.getBlockBoundsMaxY() + (double)f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target.sideHit == 2)
|
|
|
|
{
|
|
|
|
d2 = (double)target.blockZ + block.getBlockBoundsMinZ() - (double)f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target.sideHit == 3)
|
|
|
|
{
|
|
|
|
d2 = (double)target.blockZ + block.getBlockBoundsMaxZ() + (double)f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target.sideHit == 4)
|
|
|
|
{
|
|
|
|
d0 = (double)target.blockX + block.getBlockBoundsMinX() - (double)f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target.sideHit == 5)
|
|
|
|
{
|
|
|
|
d0 = (double)target.blockX + block.getBlockBoundsMaxX() + (double)f;
|
|
|
|
}
|
|
|
|
|
|
|
|
effectRenderer.addEffect((new EntityDiggingFX(worldObj, d0, d1, d2, 0.0D, 0.0D, 0.0D, block, 0)).func_70596_a(target.blockX, target.blockY, target.blockZ).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-01 09:27:31 +00:00
|
|
|
@Override
|
|
|
|
public boolean addBlockDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer)
|
|
|
|
{
|
|
|
|
byte b0 = 4;
|
|
|
|
|
|
|
|
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;
|
|
|
|
int i2 = world.rand.nextInt(6);
|
2013-07-02 03:57:49 +00:00
|
|
|
effectRenderer.addEffect(new EntityDiggingFX(world, d0, d1, d2, d0 - (double)x - 0.5D, d1 - (double)y - 0.5D, d2 - (double)z - 0.5D, Block.stone, i2, meta).func_70596_a(x, y, z));
|
2013-07-01 09:27:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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.5F, 0.69F);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
this.setBlockBounds(0.31F, 0.0F, 0.0F, 0.69F, 1.5F, 1.0F);
|
|
|
|
break;
|
|
|
|
}
|
2013-07-01 07:33:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasTileEntity(int metadata)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean renderAsNormalBlock()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TileEntity createTileEntity(World world, int metadata)
|
|
|
|
{
|
|
|
|
return new TileEntityGrave();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRenderType()
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|