Advertisement
Guest User

adc

a guest
Nov 29th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. package net.EternIsles.item.staff;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraft.item.Item;
  5. import net.minecraft.item.ItemStack;
  6. import net.minecraft.world.World;
  7.  
  8. public abstract class BaseStaff extends Item {
  9.  
  10. private Item[] runes;
  11. private int[] runeCounts;
  12.  
  13. public BaseStaff(Item[] runestouse, int[] runeNumbers) {
  14. this.runes = runestouse;
  15. this.runeCounts = runeNumbers;
  16. }
  17.  
  18. // both arrays should have a length of 4 and null for the ones you dont
  19. // need.
  20. public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
  21.  
  22. int rune1Count = 0;
  23. int rune1Slot = (Integer) null;
  24. int rune2Count = 0;
  25. int rune2Slot = (Integer) null;
  26. int rune3Count = 0;
  27. int rune3Slot = (Integer) null;
  28. int rune4Count = 0;
  29. int rune4Slot = (Integer) null;
  30.  
  31. for (int i = 0; i < 35; i++) {
  32. for (int j = 0; j < 4; j++) {
  33. if (player.inventory.getStackInSlot(i) != null && this.runes[j] != null
  34. && player.inventory.getStackInSlot(i).getItem() == this.runes[j]
  35. && player.inventory.getStackInSlot(i).stackSize >= this.runeCounts[j]) {
  36. switch (j) {
  37. case 0:
  38. rune1Count += player.inventory.getStackInSlot(i).stackSize;
  39. rune1Slot = i;
  40. break;
  41. case 1:
  42. rune2Count += player.inventory.getStackInSlot(i).stackSize;
  43. rune2Slot = i;
  44. break;
  45. case 2:
  46. rune3Count += player.inventory.getStackInSlot(i).stackSize;
  47. rune3Slot = i;
  48. break;
  49. case 3:
  50. rune4Count += player.inventory.getStackInSlot(i).stackSize;
  51. rune4Slot = i;
  52. break;
  53. default:
  54. break;
  55. }
  56. }
  57. }
  58. }
  59.  
  60. if (((this.runeCounts[0] != 0 && rune1Count >= this.runeCounts[0]) || this.runeCounts[0] == 0)
  61. && ((this.runeCounts[1] != 0 && rune2Count >= this.runeCounts[1]) || this.runeCounts[1] == 0)
  62. && ((this.runeCounts[2] != 0 && rune3Count >= this.runeCounts[2]) || this.runeCounts[2] == 0)) {
  63. if (this.runeCounts[0] != 0)
  64. player.inventory.getStackInSlot(rune1Slot).stackSize -= runeCounts[0];
  65. if (this.runeCounts[1] != 0)
  66. player.inventory.getStackInSlot(rune2Slot).stackSize -= runeCounts[1];
  67. if (this.runeCounts[2] != 0)
  68. player.inventory.getStackInSlot(rune3Slot).stackSize -= runeCounts[2];
  69. if (this.runeCounts[3] != 0)
  70. player.inventory.getStackInSlot(rune4Slot).stackSize -= runeCounts[3];
  71.  
  72. fireStaff(stack, player);
  73. }
  74.  
  75. return stack;
  76. }
  77.  
  78. public abstract void fireStaff(ItemStack stack, EntityPlayer player);
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement