GT5-Unofficial/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java
2015-10-14 22:33:33 -04:00

140 lines
3.7 KiB
Java

package gregtech.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.GregTech_API;
import gregtech.api.items.GT_Generic_Block;
import gregtech.api.util.GT_LanguageManager;
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.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public abstract class GT_Block_Casings_Abstract
extends GT_Generic_Block
{
public GT_Block_Casings_Abstract(Class<? extends ItemBlock> aItemClass, String aName, Material aMaterial)
{
super(aItemClass, aName, aMaterial);
setStepSound(soundTypeMetal);
setCreativeTab(GregTech_API.TAB_GREGTECH);
GregTech_API.registerMachineBlock(this, -1);
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this");
}
public String getHarvestTool(int aMeta)
{
return "wrench";
}
public int getHarvestLevel(int aMeta)
{
return 2;
}
public float getBlockHardness(World aWorld, int aX, int aY, int aZ)
{
return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ);
}
public float getExplosionResistance(Entity aTNT)
{
return Blocks.iron_block.getExplosionResistance(aTNT);
}
protected boolean canSilkHarvest()
{
return false;
}
public void onBlockAdded(World aWorld, int aX, int aY, int aZ)
{
if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
}
}
public String getUnlocalizedName()
{
return this.mUnlocalizedName;
}
public String getLocalizedName()
{
return StatCollector.translateToLocal(this.mUnlocalizedName + ".name");
}
public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ)
{
return false;
}
public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ)
{
return true;
}
public boolean renderAsNormalBlock()
{
return true;
}
public boolean isOpaqueCube()
{
return true;
}
public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData)
{
if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
}
}
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z)
{
return false;
}
public int damageDropped(int par1)
{
return par1;
}
public int getDamageValue(World par1World, int par2, int par3, int par4)
{
return par1World.getBlockMetadata(par2, par3, par4);
}
public int quantityDropped(Random par1Random)
{
return 1;
}
public Item getItemDropped(int par1, Random par2Random, int par3)
{
return Item.getItemFromBlock(this);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister aIconRegister) {}
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList)
{
for (int i = 0; i < 16; i++) {
aList.add(new ItemStack(aItem, 1, i));
}
}
}