Package electricexpansion.common.blocks

Source Code of electricexpansion.common.blocks.BlockSwitchWireBlock

package electricexpansion.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.item.ItemBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.ElectricExpansion;
import electricexpansion.common.cables.TileEntitySwitchWireBlock;
import electricexpansion.common.helpers.BlockWireBase;
import electricexpansion.common.helpers.TileEntityConductorBase;
import electricexpansion.common.misc.EETab;

public class BlockSwitchWireBlock extends BlockWireBase
{
    public BlockSwitchWireBlock(int id)
    {
        super(id, Material.rock);
        this.setUnlocalizedName("SwitchWireBlock");
        this.setStepSound(soundStoneFootstep);
        this.setResistance(0.2F);
        this.setHardness(1.5F);
        this.setResistance(10.0F);
        this.setCreativeTab(EETab.INSTANCE);
    }
   
    @Override
    public boolean isOpaqueCube()
    {
        return false;
    }
   
    @Override
    @SideOnly(Side.CLIENT)
    public int getRenderBlockPass()
    {
        return 0;
    }
   
    @Override
    public boolean renderAsNormalBlock()
    {
        return true;
    }
   
    @Override
    public int damageDropped(int i)
    {
        return i;
    }
   
    @Override
    public TileEntity createNewTileEntity(World var1)
    {
        return new TileEntitySwitchWireBlock();
    }
   
    @Override
    public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
    {
        return true;
    }
   
    @Override
    @SideOnly(Side.CLIENT)
    public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int x, int y, int z, int side)
    {
        return ((TileEntityConductorBase) par1IBlockAccess.getBlockTileEntity(x, y, z)).textureItemStack == null ? this.blockIcon : ((TileEntityConductorBase) par1IBlockAccess.getBlockTileEntity(x,
                y, z)).textureItemStack.getIconIndex();
    }
   
    @Override
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
    {
        if (super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9))
            return true;
       
        TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
        if (tileEntity instanceof TileEntityConductorBase)
        {
            TileEntityConductorBase te = (TileEntityConductorBase) tileEntity;
            if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemBlock)
            {
                if (!te.mode && player.inventory.getCurrentItem().itemID != this.blockID && Block.isNormalCube(player.inventory.getCurrentItem().itemID))
                {
                    ((TileEntityConductorBase) world.getBlockTileEntity(x, y, z)).textureItemStack = player.inventory.getCurrentItem();
                    world.markBlockForRenderUpdate(x, y, z);
                    return true;
                }
                else
                {
                    ((TileEntityConductorBase) world.getBlockTileEntity(x, y, z)).textureItemStack = null;
                    world.markBlockForRenderUpdate(x, y, z);
                    return true;
                }
            }
            else
            {
                if (player.isSneaking())
                {
                    te.mode = !te.mode;
                    return true;
                }
            }
        }
       
        return false;
    }
   
    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons(IconRegister par1IconRegister)
    {
        this.blockIcon = par1IconRegister.registerIcon(ElectricExpansion.PREFIX + "CamoWire");
    }
}
TOP

Related Classes of electricexpansion.common.blocks.BlockSwitchWireBlock

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.