Files
TinkersConstruct/src/main/java/tconstruct/blocks/MultiBrick.java
T

159 lines
5.8 KiB
Java
Raw Normal View History

package tconstruct.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
2013-12-31 11:26:08 -05:00
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
2013-12-31 15:30:34 -05:00
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
2013-12-31 11:26:08 -05:00
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class MultiBrick extends TConstructBlock
{
static String blockTextures[] = { "brick_obsidian", "brick_sandstone", "brick_netherrack", "brick_stone_refined", "brick_iron", "brick_gold", "brick_lapis", "brick_diamond", "brick_redstone",
"brick_bone", "brick_slime", "brick_blueslime", "brick_endstone", "brick_obsidian_ingot" };
public MultiBrick(int id)
{
super(id, Material.rock, 3f, blockTextures);
}
@Override
public float getBlockHardness (World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
switch (meta)
{
case 0:
2013-12-31 15:30:34 -05:00
return Blocks.obsidian.getBlockHardness(world, x, y, z);
case 1:
2013-12-31 15:30:34 -05:00
return Blocks.sandstone.getBlockHardness(world, x, y, z);
case 2:
2013-12-31 15:30:34 -05:00
return Blocks.netherrack.getBlockHardness(world, x, y, z);
case 3:
2013-12-31 15:30:34 -05:00
return Blocks.stone.getBlockHardness(world, x, y, z);
case 4:
2013-12-31 15:30:34 -05:00
return Blocks.iron_block.getBlockHardness(world, x, y, z);
case 5:
2013-12-31 15:30:34 -05:00
return Blocks.gold_block.getBlockHardness(world, x, y, z);
case 6:
2013-12-31 15:30:34 -05:00
return Blocks.lapis_block.getBlockHardness(world, x, y, z);
case 7:
2013-12-31 15:30:34 -05:00
return Blocks.diamond_block.getBlockHardness(world, x, y, z);
case 8:
2013-12-31 15:30:34 -05:00
return Blocks.redstone_block.getBlockHardness(world, x, y, z);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
2013-12-31 15:30:34 -05:00
return Blocks.end_stone.getBlockHardness(world, x, y, z);
case 13:
2013-12-31 15:30:34 -05:00
return Blocks.obsidian.getBlockHardness(world, x, y, z);
default:
return blockHardness;
}
}
public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
{
int meta = world.getBlockMetadata(x, y, z);
switch (meta)
{
case 0:
2013-12-31 15:30:34 -05:00
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 1:
2013-12-31 15:30:34 -05:00
return Blocks.sandstone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 2:
2013-12-31 15:30:34 -05:00
return Blocks.netherrack.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 3:
2013-12-31 15:30:34 -05:00
return Blocks.stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 4:
2013-12-31 15:30:34 -05:00
return Blocks.iron_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 5:
2013-12-31 15:30:34 -05:00
return Blocks.gold_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 6:
2013-12-31 15:30:34 -05:00
return Blocks.lapis_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 7:
2013-12-31 15:30:34 -05:00
return Blocks.diamond_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 8:
2013-12-31 15:30:34 -05:00
return Blocks.redstone_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
2013-12-31 15:30:34 -05:00
return Blocks.end_stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 13:
2013-12-31 15:30:34 -05:00
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
default:
2013-12-31 15:30:34 -05:00
return getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
}
}
@Override
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 10 || meta == 11)
{
if (entity.motionY < 0)
entity.motionY *= -1.2F;
entity.fallDistance = 0;
}
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 10 || meta == 11)
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D);
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
/*@Override
public int getRenderType ()
{
return BrickRender.model;
}*/
@Override
public boolean isBlockNormalCube (World world, int x, int y, int z)
{
return world.getBlockMetadata(x, y, z) != 8;
}
@Override
{
return true;
}
@Override
public int isProvidingWeakPower (IBlockAccess world, int x, int y, int z, int side)
{
if (world.getBlockMetadata(x, y, z) == 8)
return 4;
return 0;
}
@Override
@SideOnly(Side.CLIENT)
2013-12-31 11:26:08 -05:00
public void registerIcons (IIconRegister iconRegister)
{
2013-12-31 11:26:08 -05:00
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
}
}
}