27
27
import appeng .api .storage .data .IAEItemStack ;
28
28
import appeng .api .storage .data .IItemList ;
29
29
import appeng .core .features .AEFeature ;
30
+ import appeng .core .localization .GuiText ;
30
31
import appeng .items .AEBaseItem ;
31
32
import appeng .items .contents .CellConfig ;
32
33
import appeng .items .contents .CellUpgrades ;
33
34
import appeng .util .Platform ;
34
35
import appeng .util .item .AEItemStack ;
35
- import appeng .util .prioitylist .FuzzyPriorityList ;
36
- import appeng .util .prioitylist .IPartitionList ;
37
- import appeng .util .prioitylist .MergedPriorityList ;
38
- import appeng .util .prioitylist .PrecisePriorityList ;
36
+ import appeng .util .prioitylist .*;
37
+ import net .minecraft .entity .player .EntityPlayer ;
39
38
import net .minecraft .inventory .IInventory ;
40
39
import net .minecraft .item .ItemStack ;
41
40
42
41
import java .util .EnumSet ;
42
+ import java .util .List ;
43
43
44
44
45
45
public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
@@ -65,60 +65,58 @@ public static IPartitionList<IAEItemStack> createFilter( final ItemStack[] list
65
65
66
66
if ( ( currentViewCell .getItem () instanceof ItemViewCell ) )
67
67
{
68
- final IItemList <IAEItemStack > priorityList = AEApi .instance ().storage ().createItemList ();
69
-
70
68
final ICellWorkbenchItem vc = (ICellWorkbenchItem ) currentViewCell .getItem ();
71
69
final IInventory upgrades = vc .getUpgradesInventory ( currentViewCell );
72
70
final IInventory config = vc .getConfigInventory ( currentViewCell );
73
71
final FuzzyMode fzMode = vc .getFuzzyMode ( currentViewCell );
72
+ final String filter = vc .getOreFilter (currentViewCell );
74
73
75
74
boolean hasInverter = false ;
76
75
boolean hasFuzzy = false ;
77
-
78
- for ( int x = 0 ; x < upgrades .getSizeInventory (); x ++ )
79
- {
80
- final ItemStack is = upgrades .getStackInSlot ( x );
81
- if ( is != null && is .getItem () instanceof IUpgradeModule )
82
- {
83
- final Upgrades u = ( (IUpgradeModule ) is .getItem () ).getType ( is );
84
- if ( u != null )
85
- {
86
- switch ( u )
87
- {
76
+ boolean hasOreFilter = false ;
77
+ for (int x = 0 ; x < upgrades .getSizeInventory (); x ++) {
78
+ final ItemStack is = upgrades .getStackInSlot (x );
79
+ if (is != null && is .getItem () instanceof IUpgradeModule ) {
80
+ final Upgrades u = ((IUpgradeModule ) is .getItem ()).getType (is );
81
+ if (u != null ) {
82
+ switch (u ) {
88
83
case FUZZY :
89
84
hasFuzzy = true ;
90
85
break ;
91
86
case INVERTER :
92
87
hasInverter = true ;
93
88
break ;
89
+ case ORE_FILTER :
90
+ hasOreFilter = true ;
91
+ break ;
94
92
default :
95
93
}
96
94
}
97
95
}
98
96
}
99
97
100
- for ( int x = 0 ; x < config .getSizeInventory (); x ++ )
101
- {
102
- final ItemStack is = config .getStackInSlot ( x );
103
- if ( is != null )
104
- {
105
- priorityList .add ( AEItemStack .create ( is ) );
106
- }
98
+ if (hasOreFilter && !filter .isEmpty ()) {
99
+ myMergedList .addNewList (new OreFilteredList (filter ), !hasInverter );
107
100
}
101
+ else {
102
+ final IItemList <IAEItemStack > priorityList = AEApi .instance ().storage ().createItemList ();
108
103
109
- if ( !priorityList .isEmpty () )
110
- {
111
- if ( hasFuzzy )
112
- {
113
- myMergedList .addNewList ( new FuzzyPriorityList <IAEItemStack >( priorityList , fzMode ), !hasInverter );
114
- }
115
- else
116
- {
117
- myMergedList .addNewList ( new PrecisePriorityList <IAEItemStack >( priorityList ), !hasInverter );
104
+ for (int x = 0 ; x < config .getSizeInventory (); x ++) {
105
+ final ItemStack is = config .getStackInSlot (x );
106
+ if (is != null ) {
107
+ priorityList .add (AEItemStack .create (is ));
108
+ }
118
109
}
119
110
120
- myPartitionList = myMergedList ;
111
+ if (!priorityList .isEmpty ()) {
112
+ if (hasFuzzy ) {
113
+ myMergedList .addNewList (new FuzzyPriorityList <IAEItemStack >(priorityList , fzMode ), !hasInverter );
114
+ } else {
115
+ myMergedList .addNewList (new PrecisePriorityList <IAEItemStack >(priorityList ), !hasInverter );
116
+ }
117
+ }
121
118
}
119
+ myPartitionList = myMergedList ;
122
120
}
123
121
}
124
122
@@ -162,4 +160,21 @@ public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode )
162
160
{
163
161
Platform .openNbtData ( is ).setString ( "FuzzyMode" , fzMode .name () );
164
162
}
163
+
164
+ @ Override
165
+ public String getOreFilter (ItemStack is ) {
166
+ return Platform .openNbtData ( is ).getString ( "OreFilter" );
167
+ }
168
+
169
+ @ Override
170
+ public void setOreFilter (ItemStack is , String filter ) {
171
+ Platform .openNbtData ( is ).setString ("OreFilter" , filter );
172
+ }
173
+ @ Override
174
+ public void addCheckedInformation (final ItemStack stack , final EntityPlayer player , final List <String > lines , final boolean displayMoreInfo )
175
+ {
176
+ String filter = getOreFilter (stack );
177
+ if (!filter .isEmpty ())
178
+ lines .add (GuiText .PartitionedOre .getLocal () + " : " + filter );
179
+ }
165
180
}
0 commit comments