Advertisement
Guest User

Untitled

a guest
May 30th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.57 KB | None | 0 0
  1. package com.github.wolfiewaffle.hardcoretorches.blocks;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Random;
  5.  
  6. import net.minecraft.block.BlockTorch;
  7. import net.minecraft.block.ITileEntityProvider;
  8. import net.minecraft.creativetab.CreativeTabs;
  9. import net.minecraft.entity.EntityLivingBase;
  10. import net.minecraft.entity.player.EntityPlayer;
  11. import net.minecraft.item.Item;
  12. import net.minecraft.item.ItemStack;
  13. import net.minecraft.tileentity.TileEntity;
  14. import net.minecraft.world.World;
  15.  
  16. import com.github.wolfiewaffle.hardcoretorches.help.Reference;
  17. import com.github.wolfiewaffle.hardcoretorches.init.ModBlocks;
  18. import com.github.wolfiewaffle.hardcoretorches.tileentities.TileEntityTorchLit;
  19.  
  20. import cpw.mods.fml.relauncher.Side;
  21. import cpw.mods.fml.relauncher.SideOnly;
  22.  
  23. public class BlockTorchLit extends BlockTorch implements ITileEntityProvider
  24. {
  25.     public BlockTorchLit()
  26.     {
  27.         super();
  28.         this.setCreativeTab(CreativeTabs.tabBlock);
  29.         this.setStepSound(soundTypeStone);
  30.         this.setBlockName("torchLit");
  31.         this.setLightLevel(0.8f);
  32.         this.setBlockTextureName(Reference.MODID + ":" + getUnlocalizedName().substring(5));
  33.     }
  34.    
  35.     public void updateTick(World world, int i, int j, int k, Random rand)
  36.     {
  37.         if((world.isRaining() && world.canBlockSeeTheSky(i, j, k)))
  38.         {
  39.             world.spawnParticle("smoke", i, j, k, 0.5D, 0.7D, 0.5D);
  40.            
  41.             world.playSoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
  42.            
  43.             world.setBlock(i, j, k, ModBlocks.torchUnlit, world.getBlockMetadata(i, j, k), 3);
  44.            
  45.             int l = world.getBlockMetadata(i, j, k);
  46.             double d0 = (double)((float)i + 0.5F);
  47.             double d1 = (double)((float)j + 0.7F);
  48.             double d2 = (double)((float)k + 0.5F);
  49.             double d3 = 0.2199999988079071D;
  50.             double d4 = 0.27000001072883606D;
  51.            
  52.             if      (l == 1)
  53.             {
  54.                 for(int c = 1; c < 10+1; c++) {
  55.                     world.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);  
  56.                 }
  57.             }
  58.             else if (l == 2)
  59.             {
  60.                 for(int c = 1; c < 10+1; c++) {
  61.                     world.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
  62.                 }
  63.             }
  64.             else if (l == 3)
  65.             {
  66.                 for(int c = 1; c < 10+1; c++) {
  67.                     world.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
  68.                 }
  69.             }
  70.             else if (l == 4)
  71.             {
  72.                 for(int c = 1; c < 10+1; c++) {
  73.                     world.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
  74.                 }
  75.             }
  76.             else
  77.             {
  78.                 for(int c = 1; c < 10+1; c++) {
  79.                     world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
  80.                 }
  81.             };
  82.            
  83.             return;
  84.         }
  85.     }
  86.    
  87.     @SideOnly(Side.CLIENT)
  88.     public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_)
  89.     {
  90.        
  91.     }
  92.    
  93.     @Override
  94.     public TileEntity createNewTileEntity(World world, int meta) {
  95.         return new TileEntityTorchLit();
  96.     }
  97.    
  98.     public boolean hasTileEntity(int metadata) {
  99.         return true;
  100.     }
  101.    
  102.     @Override
  103.     public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int meta, float par7, float par8, float par9) {
  104.         TileEntity te = world.getTileEntity(i, j, k);
  105.        
  106.         if(te instanceof TileEntityTorchLit) {
  107.             System.out.println(((TileEntityTorchLit)te).getFuelAmount());
  108.         }
  109.        
  110.         return true;
  111.     }
  112.    
  113.     @Override
  114.     public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase player, ItemStack itemstack) {
  115.         TileEntity te = world.getTileEntity(i, j, k);
  116.         int meta = itemstack.getItemDamage();
  117.        
  118.         ((TileEntityTorchLit)te).setFuel(meta);
  119.     }
  120.    
  121.     public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
  122.     {
  123.         return Item.getItemFromBlock(ModBlocks.torchLit);
  124.     }
  125.    
  126.    
  127.     @Override
  128.     public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
  129.     {
  130.         ArrayList<ItemStack> drop = new ArrayList<ItemStack>();
  131.        
  132.         TileEntity te = world.getTileEntity(x, y, z);
  133.         int count = quantityDropped(metadata, fortune, world.rand);
  134.         for(int i = 0; i < count; i++)
  135.         {
  136.             Item item = getItemDropped(((TileEntityTorchLit)te).getFuelAmount(), world.rand, fortune);
  137.             if (item != null)
  138.             {
  139.                 drop.add(new ItemStack(item, 2, ((TileEntityTorchLit)te).getFuelAmount()));
  140.             }
  141.         }
  142.         return drop;
  143.     }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement