Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.EternIsles.item.staff;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.world.World;
- public abstract class BaseStaff extends Item {
- private Item[] runes;
- private int[] runeCounts;
- public BaseStaff(Item[] runestouse, int[] runeNumbers) {
- this.runes = runestouse;
- this.runeCounts = runeNumbers;
- }
- // both arrays should have a length of 4 and null for the ones you dont
- // need.
- public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
- int rune1Count = 0;
- int rune1Slot = (Integer) null;
- int rune2Count = 0;
- int rune2Slot = (Integer) null;
- int rune3Count = 0;
- int rune3Slot = (Integer) null;
- int rune4Count = 0;
- int rune4Slot = (Integer) null;
- for (int i = 0; i < 35; i++) {
- for (int j = 0; j < 4; j++) {
- if (player.inventory.getStackInSlot(i) != null && this.runes[j] != null
- && player.inventory.getStackInSlot(i).getItem() == this.runes[j]
- && player.inventory.getStackInSlot(i).stackSize >= this.runeCounts[j]) {
- switch (j) {
- case 0:
- rune1Count += player.inventory.getStackInSlot(i).stackSize;
- rune1Slot = i;
- break;
- case 1:
- rune2Count += player.inventory.getStackInSlot(i).stackSize;
- rune2Slot = i;
- break;
- case 2:
- rune3Count += player.inventory.getStackInSlot(i).stackSize;
- rune3Slot = i;
- break;
- case 3:
- rune4Count += player.inventory.getStackInSlot(i).stackSize;
- rune4Slot = i;
- break;
- default:
- break;
- }
- }
- }
- }
- if (((this.runeCounts[0] != 0 && rune1Count >= this.runeCounts[0]) || this.runeCounts[0] == 0)
- && ((this.runeCounts[1] != 0 && rune2Count >= this.runeCounts[1]) || this.runeCounts[1] == 0)
- && ((this.runeCounts[2] != 0 && rune3Count >= this.runeCounts[2]) || this.runeCounts[2] == 0)) {
- if (this.runeCounts[0] != 0)
- player.inventory.getStackInSlot(rune1Slot).stackSize -= runeCounts[0];
- if (this.runeCounts[1] != 0)
- player.inventory.getStackInSlot(rune2Slot).stackSize -= runeCounts[1];
- if (this.runeCounts[2] != 0)
- player.inventory.getStackInSlot(rune3Slot).stackSize -= runeCounts[2];
- if (this.runeCounts[3] != 0)
- player.inventory.getStackInSlot(rune4Slot).stackSize -= runeCounts[3];
- fireStaff(stack, player);
- }
- return stack;
- }
- public abstract void fireStaff(ItemStack stack, EntityPlayer player);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement