Advertisement
Eragonn14900

Untitled

Nov 21st, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. package com.reactioncraft.core.common.craftinghandlers;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.reactioncraft.integration.instances.*;
  6.  
  7. import net.minecraft.entity.player.EntityPlayer;
  8. import net.minecraft.entity.player.EntityPlayerMP;
  9. import net.minecraft.entity.player.InventoryPlayer;
  10. import net.minecraft.init.*;
  11. import net.minecraft.item.*;
  12. import net.minecraftforge.fml.common.eventhandler.*;
  13. import net.minecraftforge.fml.common.gameevent.PlayerEvent.*;
  14. import net.minecraftforge.oredict.*;
  15. import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
  16.  
  17. /**
  18. * @author Ordinastie && Eragonn1490
  19. *
  20. */
  21. public class HammerCraftingHandler
  22. {
  23. Random random = new Random();
  24. @SubscribeEvent
  25. public void onCrafting(ItemCraftedEvent event)
  26. {
  27. if (event.crafting.getItem() != Items.IRON_AXE)
  28. return;
  29.  
  30. for (int i = 0; i < event.player.inventory.getSizeInventory(); i++)
  31. {
  32. ItemStack slotStack = event.player.inventory.getStackInSlot(i);
  33.  
  34. if (slotStack != null && (slotStack.getItem() == IntegratedItems.Hammer))// || slotStack.getItem() == IntegratedItems.bloodstoneHammer))
  35. {
  36.  
  37. if (slotStack.getMaxStackSize() >= 1) //If Greater then 0 change to item -durbaility
  38. {
  39. System.out.println("Reset Item?");
  40. slotStack.attemptDamageItem(1, random);
  41. }
  42. if (slotStack.getMaxStackSize() == 0) //if == 0 delete item (it works now, due to its durability always being 0)
  43. {
  44. System.out.println("Deleted Item");
  45. event.player.inventory.setInventorySlotContents(i, null);
  46. }
  47. event.player.inventory.setInventorySlotContents(i, slotStack);
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement