Advertisement
HalestormXV

Untitled

Aug 27th, 2017
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.38 KB | None | 0 0
  1. package halestormxv.eAngelus.slots;
  2.  
  3. import halestormxv.eAngelus.crafting.DualFurnaceRecipes;
  4. import net.minecraft.entity.item.EntityXPOrb;
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.inventory.IInventory;
  7. import net.minecraft.inventory.Slot;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.util.math.MathHelper;
  10.  
  11. /**
  12.  * Created by Blaze on 8/27/2017.
  13.  */
  14. public class SlotDualFuranceOutput extends Slot
  15. {
  16.     private final EntityPlayer player;
  17.     private int removeCount;
  18.  
  19.     public SlotDualFuranceOutput(EntityPlayer player, IInventory inventoryIn, int index, int xPosition, int yPosition)
  20.     {
  21.         super(inventoryIn, index, xPosition, yPosition);
  22.         this.player = player;
  23.     }
  24.  
  25.     @Override
  26.     public boolean isItemValid(ItemStack stack)
  27.     {
  28.         return false;
  29.     }
  30.  
  31.     @Override
  32.     public ItemStack decrStackSize(int amount)
  33.     {
  34.         if(this.getHasStack())
  35.             this.removeCount += Math.min(amount, this.getStack().getCount());
  36.         return super.decrStackSize(amount);
  37.     }
  38.  
  39.     @Override
  40.     public ItemStack onTake(EntityPlayer thePlayer, ItemStack stack)
  41.     {
  42.         this.onCrafting(stack);
  43.         super.onTake(thePlayer, stack);
  44.         return stack;
  45.     }
  46.  
  47.     @Override
  48.     protected void onCrafting(ItemStack stack, int amount)
  49.     {
  50.         this.removeCount += amount;
  51.         this.onCrafting(stack);
  52.     }
  53.  
  54.     @Override
  55.     protected void onCrafting(ItemStack stack)
  56.     {
  57.         stack.onCrafting(this.player.world, this.player, this.removeCount);
  58.  
  59.         if(!this.player.world.isRemote)
  60.         {
  61.             int i = this.removeCount;
  62.             float f = DualFurnaceRecipes.instance().getDualSmeltingExperience(stack);
  63.  
  64.             if(f == 0.0F)
  65.                 i = 0;
  66.             else if(f < 1.0F) {
  67.                 int j = MathHelper.floor((float)i * f);
  68.  
  69.                 if(j < MathHelper.ceil((float)i * f) && Math.random() < (double)((float)i * f - (float)j))
  70.                     ++j;
  71.                 i = j;
  72.             }
  73.             while (i > 0)
  74.             {
  75.                 int k = EntityXPOrb.getXPSplit(i);
  76.                 i -= k;
  77.  
  78.                 this.player.world.spawnEntity(new EntityXPOrb(this.player.world, this.player.posX, this.player.posY + 0.5D, this.player.posZ + 0.5D, k));
  79.             }
  80.         }
  81.         this.removeCount = 0;
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement