aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/nei/GT_NEI_multiCentriElectroFreezer.java
blob: 3f22b15f3bfd3b26155898794d32239b4e2e3da8 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package gtPlusPlus.nei;

import java.util.HashMap;

import codechicken.nei.recipe.TemplateRecipeHandler;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.api.objects.data.Pair;

public class GT_NEI_multiCentriElectroFreezer extends GTPP_NEI_DefaultHandler {

	public GT_NEI_multiCentriElectroFreezer(GT_Recipe_Map aMap) {
		super(aMap);
	}

	@Override
	public TemplateRecipeHandler newInstance() {
		return new GT_NEI_multiCentriElectroFreezer(mRecipeMap);
	}

	@Override
    public CachedDefaultRecipe createCachedRecipe(GT_Recipe aRecipe) {
    	return new NoCellMultiDefaultRecipe(aRecipe);
    }
	
	private static final HashMap<Integer, Pair<Integer, Integer>> mInputSlotMap = new HashMap<Integer, Pair<Integer, Integer>>();
	private static final HashMap<Integer, Pair<Integer, Integer>> mOutputSlotMap = new HashMap<Integer, Pair<Integer, Integer>>();
	
	static {
		int aSlotX_1 = 12;
		int aSlotX_2 = 30;
		int aSlotX_3 = 48;
		int aSlotY_1 = 5;
		int aSlotY_2 = 23;
		int aSlotY_3 = 41;
		int aSlotY_10 = 65; // Only if 9 input items and a FLuid
		mInputSlotMap.put(0, new Pair<Integer, Integer>(aSlotX_1, aSlotY_1));
		mInputSlotMap.put(1, new Pair<Integer, Integer>(aSlotX_2, aSlotY_1));
		mInputSlotMap.put(2, new Pair<Integer, Integer>(aSlotX_3, aSlotY_1));
		mInputSlotMap.put(3, new Pair<Integer, Integer>(aSlotX_1, aSlotY_2));
		mInputSlotMap.put(4, new Pair<Integer, Integer>(aSlotX_2, aSlotY_2));
		mInputSlotMap.put(5, new Pair<Integer, Integer>(aSlotX_3, aSlotY_2));
		mInputSlotMap.put(6, new Pair<Integer, Integer>(aSlotX_1, aSlotY_3));
		mInputSlotMap.put(7, new Pair<Integer, Integer>(aSlotX_2, aSlotY_3));
		mInputSlotMap.put(8, new Pair<Integer, Integer>(aSlotX_3, aSlotY_3));
		mInputSlotMap.put(9, new Pair<Integer, Integer>(aSlotX_1, aSlotY_10));
		mInputSlotMap.put(10, new Pair<Integer, Integer>(aSlotX_2, aSlotY_10));
		mInputSlotMap.put(11, new Pair<Integer, Integer>(aSlotX_3, aSlotY_10));
		aSlotX_1 = 102;
		aSlotX_2 = 120;
		aSlotX_3 = 138;
		mOutputSlotMap.put(0, new Pair<Integer, Integer>(aSlotX_1, aSlotY_1));
		mOutputSlotMap.put(1, new Pair<Integer, Integer>(aSlotX_2, aSlotY_1));
		mOutputSlotMap.put(2, new Pair<Integer, Integer>(aSlotX_3, aSlotY_1));
		mOutputSlotMap.put(3, new Pair<Integer, Integer>(aSlotX_1, aSlotY_2));
		mOutputSlotMap.put(4, new Pair<Integer, Integer>(aSlotX_2, aSlotY_2));
		mOutputSlotMap.put(5, new Pair<Integer, Integer>(aSlotX_3, aSlotY_2));
		mOutputSlotMap.put(6, new Pair<Integer, Integer>(aSlotX_1, aSlotY_3));
		mOutputSlotMap.put(7, new Pair<Integer, Integer>(aSlotX_2, aSlotY_3));
		mOutputSlotMap.put(8, new Pair<Integer, Integer>(aSlotX_3, aSlotY_3));
		mOutputSlotMap.put(9, new Pair<Integer, Integer>(aSlotX_1, aSlotY_10));
		mOutputSlotMap.put(10, new Pair<Integer, Integer>(aSlotX_2, aSlotY_10));
		mOutputSlotMap.put(11, new Pair<Integer, Integer>(aSlotX_3, aSlotY_10));
	}

	public class NoCellMultiDefaultRecipe extends CachedDefaultRecipe {

		public NoCellMultiDefaultRecipe(final GT_Recipe aRecipe) {
			super(aRecipe);
			
		}

		@Override
		public void handleSlots() {

			int aInputItemsCount = this.mRecipe.mInputs.length;
			int aInputFluidsCount = this.mRecipe.mFluidInputs.length;			
			int aOutputItemsCount = this.mRecipe.mOutputs.length;
			int aOutputFluidsCount = this.mRecipe.mFluidOutputs.length;
			int aInputSlotsUsed = 0;
			int aOutputSlotsUsed = 0;			
			int aSlotToCheck = 0;	

			// Special Slot
			if (mRecipe.mSpecialItems != null) {
				this.mInputs.add(new FixedPositionedStack(mRecipe.mSpecialItems, 120, 52));
			}
			
			/*
			 * Items
			 */
			
			// Upto 9 Inputs Slots
			if (aInputItemsCount > 0) {				
				if (aInputItemsCount > 9) {
					aInputItemsCount = 9;
				}				
				for (int i=0;i<aInputItemsCount;i++) {
					int x = mInputSlotMap.get(aSlotToCheck).getKey();
					int y = mInputSlotMap.get(aSlotToCheck).getValue();
					this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(aSlotToCheck), x, y));	
					aSlotToCheck++;
					aInputSlotsUsed++;
				}
			}
			aSlotToCheck = 0;	
			// Upto 9 Output Slots
			if (aOutputItemsCount > 0) {			
				if (aOutputItemsCount > 9) {
					aOutputItemsCount = 9;
				}		
				for (int i=0;i<aOutputItemsCount;i++) {
					int x = mOutputSlotMap.get(aSlotToCheck).getKey();
					int y = mOutputSlotMap.get(aSlotToCheck).getValue();
					this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(aSlotToCheck), x, y, mRecipe.getOutputChance(aSlotToCheck)));	
					aSlotToCheck++;
					aOutputSlotsUsed++;
				}
			}					
			
			/*
			 * Fluids
			 */

			// Upto 9 Fluid Inputs Slots
			aSlotToCheck = aInputSlotsUsed;	
			if (aInputFluidsCount > 0) {				
				for (int i=0;i<aInputFluidsCount;i++) {
					int x = mInputSlotMap.get(aSlotToCheck).getKey();
					int y = mInputSlotMap.get(aSlotToCheck).getValue();
					this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[i], true), x, y));
					aSlotToCheck++;
					aInputSlotsUsed++;
				}
			}
			// Upto 9 Fluid Outputs Slots
			aSlotToCheck = aOutputSlotsUsed;	
			if (aOutputFluidsCount > 0) {				
				for (int i=0;i<aOutputFluidsCount;i++) {
					int x = mOutputSlotMap.get(aSlotToCheck).getKey();
					int y = mOutputSlotMap.get(aSlotToCheck).getValue();
					this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[i], true), x, y));
					aSlotToCheck++;
					aOutputSlotsUsed++;
				}
			}
		}
	}
}