diff options
| author | Foghrye4 <foghrye4@gmail.com> | 2017-01-27 11:32:28 +0300 |
|---|---|---|
| committer | Foghrye4 <foghrye4@gmail.com> | 2017-01-27 11:32:28 +0300 |
| commit | 2db8e30b1d2151fdde5d08a6c06aef55f0c397d2 (patch) | |
| tree | e8cd0022f3a30a5c952092e0ea4c7ffdafcdf7bb /ihl/explosion/PileBlock.java | |
| parent | ffe23313fb7421b0a1849b420baf708999023f7b (diff) | |
License, readme and stuff
Diffstat (limited to 'ihl/explosion/PileBlock.java')
| -rw-r--r-- | ihl/explosion/PileBlock.java | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/ihl/explosion/PileBlock.java b/ihl/explosion/PileBlock.java new file mode 100644 index 0000000..a2c56c3 --- /dev/null +++ b/ihl/explosion/PileBlock.java @@ -0,0 +1,125 @@ +package ihl.explosion; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.IHLModInfo; +import ihl.items_blocks.IHLItemBlock; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class PileBlock extends Block implements ITileEntityProvider +{ + public static PileBlock instance; + public static int id; + protected PileBlock(Material material) { + super(material); + this.setBlockName("pileBlock"); + this.setBlockTextureName("tubBronzeIcon"); + instance = this; + this.setBlockBounds(0f, 0f, 0f, 1f, 0.5f, 1f); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) + { + if(!world.isRemote) + { + PileTileEntity pte = (PileTileEntity)world.getTileEntity(x, y, z); + pte.checkAndFall(); + } + } + + @Override + public int getRenderType() + { + return PileBlockRender.renderId; + } + + @Override + public TileEntity createNewTileEntity(World word, int metadata) { + return new PileTileEntity(); + } + + public static void init() + { + GameRegistry.registerBlock(new PileBlock(Material.sand), IHLItemBlock.class,"pileBlock"); + GameRegistry.registerTileEntity(PileTileEntity.class, "pileBlockTileEntity"); + id = Block.getIdFromBlock(instance); + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fluidAcetyleneFlowing"); + } + + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z) + { + if(!world.isRemote && world.getTileEntity(x,y,z) instanceof PileTileEntity) + { + PileTileEntity te = (PileTileEntity)world.getTileEntity(x,y,z); + if(entityPlayer.inventory.addItemStackToInventory(te.content)) + { + te.content=null; + world.setBlockToAir(x, y, z); + entityPlayer.inventoryContainer.detectAndSendChanges(); + return true; + } + } + return false; + } + + @Override + public void onBlockHarvested(World world,int x,int y,int z,int meta, EntityPlayer entityPlayer) + { + if(!world.isRemote && world.getTileEntity(x,y,z) instanceof PileTileEntity) + { + PileTileEntity te = (PileTileEntity)world.getTileEntity(x,y,z); + if(entityPlayer.inventory.addItemStackToInventory(te.content)) + { + te.content=null; + entityPlayer.inventoryContainer.detectAndSendChanges(); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x,int y,int z,int meta) + { + if(world.getTileEntity(x,y,z) instanceof PileTileEntity) + { + PileTileEntity te = (PileTileEntity)world.getTileEntity(x,y,z); + if(te.content!=null) + { + return te.content.getIconIndex(); + } + } + return this.blockIcon; + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag){} +} |
