aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/slots/SlotPollutionScrubber.java
blob: 6dd3745d09631f53dd79d5e45d3457995b3c0206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package gtPlusPlus.core.slots;

import java.util.HashMap;

import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.item.general.ItemAirFilter;
import gtPlusPlus.core.item.general.ItemBasicScrubberTurbine;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.recipe.common.CI;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

public class SlotPollutionScrubber extends Slot {

	private final int mType;
	private final int mTier;
	
	private static HashMap<Integer, ItemStack> mConveyorMap = new HashMap<Integer, ItemStack>();
	
	static {
		for (int i=0; i<(CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? 9 : 5); i++) {
			mConveyorMap.put(i, CI.getConveyor(i, 1));			
		}
	}

	public SlotPollutionScrubber(final int aType, final int aTier, final IInventory inventory, final int slot, final int x, final int y) {
		super(inventory, slot, x, y);
		mType = aType;
		mTier = aTier;
	}

	@Override
	public synchronized boolean isItemValid(final ItemStack itemstack) {
		return isItemValidForSlot(this, itemstack);
	}

	public static synchronized boolean isItemValidForSlot(final SlotPollutionScrubber aSlot, final ItemStack itemstack) {
		if (aSlot.mType == 0) {
			if (itemstack.getItem() instanceof ItemBasicScrubberTurbine) {
				return true;
			}			
			if (itemstack.getItem() instanceof GT_MetaGenerated_Tool  && itemstack.getItemDamage() >= 170 && itemstack.getItemDamage() <= 179){
				return true;
			}
		}
		else if (aSlot.mType == 1) {
			if (itemstack.getItem() instanceof ItemAirFilter) {
				return true;
			}		
		}
		else if (aSlot.mType == 2) {
			ItemStack aConveyorStack = mConveyorMap.get(aSlot.mTier);
			if (GT_Utility.areStacksEqual(itemstack, aConveyorStack, true)) {
				return true;
			}
		}
		return false;
	}

	@Override
	public int getSlotStackLimit() {
		return 1;
	}
}