Advertisement
Guest User

SlotReactor

a guest
Feb 10th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.23 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. public class SlotReactor extends Slot
  4. {
  5.     /** The player that is using the GUI where this slot resides. */
  6.     private EntityPlayer thePlayer;
  7.     private int field_75228_b;
  8.  
  9.     public SlotReactor(EntityPlayer par1EntityPlayer, IInventory par2IInventory, int par3, int par4, int par5)
  10.     {
  11.         super(par2IInventory, par3, par4, par5);
  12.         this.thePlayer = par1EntityPlayer;
  13.     }
  14.  
  15.     /**
  16.      * Check if the stack is a valid item for this slot. Always true beside for the armor slots.
  17.      */
  18.     public boolean isItemValid(ItemStack par1ItemStack)
  19.     {
  20.         return false;
  21.     }
  22.  
  23.     /**
  24.      * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
  25.      * stack.
  26.      */
  27.     public ItemStack decrStackSize(int par1)
  28.     {
  29.         if (this.getHasStack())
  30.         {
  31.             this.field_75228_b += Math.min(par1, this.getStack().stackSize);
  32.         }
  33.  
  34.         return super.decrStackSize(par1);
  35.     }
  36.  
  37.     public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
  38.     {
  39.         this.onCrafting(par2ItemStack);
  40.         super.onPickupFromSlot(par1EntityPlayer, par2ItemStack);
  41.     }
  42.  
  43.     /**
  44.      * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
  45.      * internal count then calls onCrafting(item).
  46.      */
  47.     protected void onCrafting(ItemStack par1ItemStack, int par2)
  48.     {
  49.         this.field_75228_b += par2;
  50.         this.onCrafting(par1ItemStack);
  51.     }
  52.  
  53.     /**
  54.      * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
  55.      */
  56.     protected void onCrafting(ItemStack par1ItemStack)
  57.     {
  58.         par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b);
  59.         ModLoader.takenFromFurnace(this.thePlayer, par1ItemStack);
  60.  
  61.         if (!this.thePlayer.worldObj.isRemote)
  62.         {
  63.             int var2 = this.field_75228_b;
  64.             float var3 = FurnaceRecipes.smelting().getExperience(par1ItemStack.itemID);
  65.             int var4;
  66.  
  67.             if (var3 == 0.0F)
  68.             {
  69.                 var2 = 0;
  70.             }
  71.             else if (var3 < 1.0F)
  72.             {
  73.                 var4 = MathHelper.floor_float((float)var2 * var3);
  74.  
  75.                 if (var4 < MathHelper.ceiling_float_int((float)var2 * var3) && (float)Math.random() < (float)var2 * var3 - (float)var4)
  76.                 {
  77.                     ++var4;
  78.                 }
  79.  
  80.                 var2 = var4;
  81.             }
  82.  
  83.             while (var2 > 0)
  84.             {
  85.                 var4 = EntityXPOrb.getXPSplit(var2);
  86.                 var2 -= var4;
  87.                 this.thePlayer.worldObj.spawnEntityInWorld(new EntityXPOrb(this.thePlayer.worldObj, this.thePlayer.posX, this.thePlayer.posY + 0.5D, this.thePlayer.posZ + 0.5D, var4));
  88.             }
  89.         }
  90.  
  91.         this.field_75228_b = 0;
  92.  
  93.         if (par1ItemStack.itemID == Item.ingotIron.itemID)
  94.         {
  95.             this.thePlayer.addStat(AchievementList.acquireIron, 1);
  96.         }
  97.  
  98.         if (par1ItemStack.itemID == Item.fishCooked.itemID)
  99.         {
  100.             this.thePlayer.addStat(AchievementList.cookFish, 1);
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement