Guest User

Untitled

a guest
Mar 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.42 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.client.Minecraft;
  6.  
  7. public class FurnaceWhite extends BlockContainer
  8. {
  9.  
  10.         protected FurnaceWhite(int i, int j, boolean flag)
  11.     {
  12.         super(i, j, Material.rock);
  13.         repairRand = new Random();
  14.         isActive = flag;          
  15.         blockIndexInTexture = j;
  16.     }
  17.     public int getBlockTextureFromSideAndMetadata(int i, int j)
  18.     {
  19.         if(i == 1)
  20.         {
  21.             return blockIndexInTexture;
  22.         }
  23.         if(i == 0)
  24.         {
  25.             return blockIndexInTexture;
  26.         }
  27.  
  28.         int k = mod_WhiteFurnace.WhitestoneFront;
  29.        
  30.         if(j == 2 && i == 2)
  31.         {
  32.             return k;
  33.         }
  34.         if(j == 3 && i == 5)
  35.         {
  36.             return k;
  37.         }
  38.         if(j == 0 && i == 3)
  39.         {
  40.             return k;
  41.         }
  42.         if(j == 1 && i == 4)
  43.         {
  44.             return k;
  45.         } else
  46.         {
  47.             return mod_WhiteFurnace.WhitestoneSide;
  48.         }
  49.     }
  50.  
  51.     public int getBlockTextureFromSide(int i)  
  52.     {
  53.         if(i == 1)
  54.         {
  55.             return blockIndexInTexture;
  56.         }
  57.         if(i == 0)
  58.         {
  59.             return blockIndexInTexture;
  60.         }
  61.         if(i == 3)
  62.         {
  63.           return mod_WhiteFurnace.WhitestoneFront;
  64.            
  65.         } else
  66.         {
  67.             return mod_WhiteFurnace.WhitestoneSide;
  68.         }
  69.     }
  70.    
  71.      public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
  72.     {
  73.         int l = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 2.5D) & 3;
  74.         world.setBlockMetadataWithNotify(i, j, k, l);
  75.     }
  76.    
  77.     protected FurnaceWhite(int i, boolean flag)
  78.     {
  79.         super(i, Material.rock);
  80.         repairRand = new Random();
  81.         isActive = flag;          
  82.     }
  83.  
  84.     public int idDropped(int i, Random random)
  85.     {
  86.         return mod_WhiteFurnace.whitefurnace.blockID;
  87.     }
  88.  
  89.     public void onBlockAdded(World world, int i, int j, int k)
  90.     {
  91.         super.onBlockAdded(world, i, j, k);
  92.        
  93.     }
  94.  
  95.     public void randomDisplayTick(World world, int i, int j, int k, Random random) // for some reason this doesn't work
  96.     {
  97.         if(!isActive)
  98.         {
  99.             return;
  100.         }
  101.         int l = world.getBlockMetadata(i, j, k);
  102.         float f = (float)i + 0.5F;
  103.         float f1 = (float)j + 0.0F + (random.nextFloat() * 6F) / 16F;
  104.         float f2 = (float)k + 0.5F;
  105.         float f3 = 0.52F;
  106.         float f4 = random.nextFloat() * 0.6F - 0.3F;
  107.         if(l == 4)
  108.         {
  109.             world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
  110.             world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
  111.         } else
  112.         if(l == 5)
  113.         {
  114.             world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
  115.             world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
  116.         } else
  117.         if(l == 2)
  118.         {
  119.             world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
  120.             world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
  121.         } else
  122.         if(l == 3)
  123.         {
  124.             world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
  125.             world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
  126.         }
  127.     }
  128.  
  129.    
  130.  
  131.     public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
  132.     {
  133.         if(world.multiplayerWorld)
  134.         {
  135.             return true;
  136.         } else
  137.         {
  138.             TileEntityWhiteFurnace tileentitywhitefurnace = (TileEntityWhiteFurnace)world.getBlockTileEntity(i, j, k);          
  139.          ModLoader.OpenGUI(ModLoader.getMinecraftInstance().thePlayer, new Guiwhite(ModLoader.getMinecraftInstance().thePlayer.inventory, tileentitywhitefurnace));
  140.            
  141.             return true;
  142.         }
  143.     }
  144.  
  145.     public static void updateRepairBlockState(boolean flag, World world, int i, int j, int k)
  146.     {
  147.         int l = world.getBlockMetadata(i, j, k);
  148.         TileEntity tileentity = world.getBlockTileEntity(i, j, k);
  149.         keepRepairInventory = true;        
  150.         keepRepairInventory = false;
  151.         world.setBlockMetadataWithNotify(i, j, k, l);
  152.         tileentity.validate();
  153.         world.setBlockTileEntity(i, j, k, tileentity);
  154.     }
  155.  
  156. public TileEntity getBlockEntity()
  157.     {
  158.         return new TileEntityWhiteFurnace();
  159.     }
  160.  
  161.    
  162.  
  163.     public void onBlockRemoval(World world, int i, int j, int k)
  164.     {
  165.         if(!keepRepairInventory)
  166.         {
  167.             TileEntityWhiteFurnace tileentitywhitefurnace = (TileEntityWhiteFurnace)world.getBlockTileEntity(i, j, k);
  168. label0:
  169.             for(int l = 0; l < tileentitywhitefurnace.getSizeInventory(); l++)
  170.             {
  171.                 ItemStack itemstack = tileentitywhitefurnace.getStackInSlot(l);
  172.                 if(itemstack == null)
  173.                 {
  174.                     continue;
  175.                 }
  176.                 float f = repairRand.nextFloat() * 0.8F + 0.1F;
  177.                 float f1 = repairRand.nextFloat() * 0.8F + 0.1F;
  178.                 float f2 = repairRand.nextFloat() * 0.8F + 0.1F;
  179.                 do
  180.                 {
  181.                     if(itemstack.stackSize <= 0)
  182.                     {
  183.                         continue label0;
  184.                     }
  185.                     int i1 = repairRand.nextInt(21) + 10;
  186.                     if(i1 > itemstack.stackSize)
  187.                     {
  188.                         i1 = itemstack.stackSize;
  189.                     }
  190.                     itemstack.stackSize -= i1;
  191.                     EntityItem entityitem = new EntityItem(world, (float)i + f, (float)j + f1, (float)k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getItemDamage()));
  192.                     float f3 = 0.05F;
  193.                     entityitem.motionX = (float)repairRand.nextGaussian() * f3;
  194.                     entityitem.motionY = (float)repairRand.nextGaussian() * f3 + 0.2F;
  195.                     entityitem.motionZ = (float)repairRand.nextGaussian() * f3;
  196.                     world.entityJoinedWorld(entityitem);
  197.                 } while(true);
  198.             }
  199.  
  200.         }
  201.         super.onBlockRemoval(world, i, j, k);
  202.     }
  203.  
  204.     private Random repairRand;
  205.     private final boolean isActive;
  206.     public EntityPlayer entityplayer;
  207.     private static boolean keepRepairInventory = false;
  208.  
  209. }
Add Comment
Please, Sign In to add comment