Guest User

Untitled

a guest
Apr 29th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.41 KB | None | 0 0
  1. package neg2013.acsension.machine;
  2.  
  3. import cofh.api.energy.EnergyStorage;
  4. import cofh.api.energy.IEnergyHandler;
  5. import cpw.mods.fml.relauncher.Side;
  6. import cpw.mods.fml.relauncher.SideOnly;
  7. import neg2013.acsension.Acsension;
  8. import neg2013.acsension.reference.GuiID;
  9. import neg2013.acsension.tile_entity.TECrusher;
  10. import neg2013.acsension.tile_entity.TEDecomp;
  11. import net.minecraft.block.Block;
  12. import net.minecraft.block.ITileEntityProvider;
  13. import net.minecraft.block.material.Material;
  14. import net.minecraft.client.renderer.texture.IIconRegister;
  15. import net.minecraft.entity.item.EntityItem;
  16. import net.minecraft.entity.player.EntityPlayer;
  17. import net.minecraft.inventory.IInventory;
  18. import net.minecraft.item.ItemStack;
  19. import net.minecraft.tileentity.TileEntity;
  20. import net.minecraft.util.IIcon;
  21. import net.minecraft.world.World;
  22. import net.minecraftforge.common.util.ForgeDirection;
  23.  
  24. public class BlockDecomposer extends Block implements ITileEntityProvider, IEnergyHandler{
  25.  
  26.    
  27.     public BlockDecomposer(Material material) {
  28.         super(material);
  29.         // TODO Auto-generated constructor stub
  30.     }
  31.  
  32.     @SideOnly(Side.CLIENT)
  33.     private IIcon field_150035_a;
  34.     @SideOnly(Side.CLIENT)
  35.     private IIcon field_150034_b;
  36.     @SideOnly(Side.CLIENT)
  37.     private IIcon field_150034_c;
  38.  
  39.     protected EnergyStorage energyStorage = new EnergyStorage(512);
  40.     //protected List<ForgeDirection> recieveSides = new ArrayList<ForgeDirection>();
  41.    // protected List<ForgeDirection> extractSides = new ArrayList<Object>();
  42.    
  43.  
  44.  
  45.     @SideOnly(Side.CLIENT)
  46.     public IIcon getIcon(int side, int met)
  47.     {
  48.         return side == 1 ? this.field_150035_a : (side == 0 ? field_150034_c : (side != 2 && side != 4 ? this.blockIcon : this.field_150034_b));
  49.     }
  50.  
  51.     @SideOnly(Side.CLIENT)
  52.     public void registerBlockIcons(IIconRegister p_149651_1_)
  53.     {
  54.         this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_decomposer_side");
  55.         this.field_150035_a = p_149651_1_.registerIcon(this.getTextureName() + "_top");
  56.         this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_decomposer_side");
  57.         this.field_150034_c = p_149651_1_.registerIcon(this.getTextureName() + "_bottum");
  58.        // this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_crusher_front");
  59.        
  60.     }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. @Override
  69. public TileEntity createNewTileEntity(World world, int i) {
  70.  
  71.     return new TEDecomp();
  72. }
  73.  
  74.  @Override
  75. public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float subx, float suby, float subz) {
  76.  
  77.      if(world.isRemote){
  78.  
  79.         if(player.isSneaking()){
  80.             return false;
  81.         }
  82.         else{
  83.             player.openGui(Acsension.instance, GuiID.DECOMP_BASED_ID, world, x, y, z);
  84.             return true;
  85.         }
  86.      }
  87.      
  88.      
  89.     return true;
  90. }
  91.  
  92. @Override
  93. public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
  94.  
  95.     TileEntity entity = world.getTileEntity(x, y, z);
  96.     if(entity != null && entity instanceof IInventory){
  97.         IInventory inventory = (IInventory) entity;
  98.         for(int i = 0; i > inventory.getSizeInventory(); i++){
  99.             ItemStack itemstack = inventory.getStackInSlotOnClosing(i);
  100.             if(itemstack != null){
  101.                 float spawnX = x + world.rand.nextFloat();
  102.                 float spawnY = y + world.rand.nextFloat();
  103.                 float spawnZ = z + world.rand.nextFloat();
  104.                 EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, itemstack);
  105.                 float multi = 0.05f;
  106.                 droppedItem.motionX = -0.5f + world.rand.nextFloat() * multi;
  107.                 droppedItem.motionY = -0.5f + world.rand.nextFloat() * multi;
  108.                 droppedItem.motionZ = -0.5f + world.rand.nextFloat() * multi;
  109.                 world.spawnEntityInWorld(droppedItem);
  110.            
  111.            
  112.             }
  113.         }
  114.     }
  115.        
  116.    
  117.     super.breakBlock(world, x, y, z, block, meta);
  118. }
  119.  
  120. @Override
  121. public boolean canConnectEnergy(ForgeDirection from) {
  122.     // TODO Auto-generated method stub
  123.     return false;
  124. }
  125.  
  126. @Override
  127. public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
  128.     // TODO Auto-generated method stub
  129.     return 0;
  130. }
  131.  
  132. @Override
  133. public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
  134.     // TODO Auto-generated method stub
  135.     return 0;
  136. }
  137.  
  138. @Override
  139. public int getEnergyStored(ForgeDirection from) {
  140.     // TODO Auto-generated method stub
  141.     return 0;
  142. }
  143.  
  144. @Override
  145. public int getMaxEnergyStored(ForgeDirection from) {
  146.     // TODO Auto-generated method stub
  147.     return 0;
  148. }
  149.  
  150.  
  151. }
Advertisement
Add Comment
Please, Sign In to add comment