mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-21 20:52:11 +00:00
RecipeCatalyst Enhancements (#199)
* Fix serial handlers not searching catalysts
* Prevent null stack from being added
* Prevent duplicate stack from being added
* Prevent empty handlerID from being added
* Extract code to get modded items
* Use HANDLER_ID_FUNCTION to determine handler's id
This allows mods that don't implement getOverlayIdentifier to work with
* Implement priority
* Fix typo
* Allow catalysts to be loaded from csv
Add IC2 catalysts
* minor cleanup
* Add Avaritia, BM, Forestry
* Log if TransferRects fail
* Implement removing catalyst
* Add placeholder for version controlling
* Add a BUNCH of catalysts
* Add Schematics
* Add more NASA
* Add way to resolve conflict with handlerID
resolve conflict between IC2 Compressor and Mekanism Osmium Compressor
* Add more catalysts
* Add ALL GT catalysts
* Add more
* temporary "fix" for item rendering
reverts 9bbdd7b174
* enable by default
* forgot this one
* Add ability to skip search for catalysts
* resolve some todos
This commit is contained in:
1 parent
3ced04b4d3
commit
7834d72ecf
17 files changed
+1534
-118
No files matched your search
@@ -0,0 +1,70 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import com.google.common.collect.ForwardingList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
// Do not directly extend ArrayList, see Effective Java Item 16
|
||||
public class CatalystInfoList extends ForwardingList<CatalystInfo> {
|
||||
private final String handlerID;
|
||||
private final List<CatalystInfo> catalystInfoList = new ArrayList<>();
|
||||
|
||||
public CatalystInfoList(String handlerID) {
|
||||
this.handlerID = handlerID;
|
||||
}
|
||||
|
||||
public CatalystInfoList(String handlerID, CatalystInfo catalystInfo) {
|
||||
this(handlerID);
|
||||
add(catalystInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<CatalystInfo> delegate() {
|
||||
return catalystInfoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(@Nonnull CatalystInfo catalystInfo) {
|
||||
if (contains(catalystInfo)) {
|
||||
NEIClientConfig.logger.info(String.format("catalyst %s is already registered to handler %s", catalystInfo.getStack().getDisplayName(), handlerID));
|
||||
return false;
|
||||
}
|
||||
super.add(catalystInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object object) {
|
||||
if (object instanceof CatalystInfo) {
|
||||
ItemStack stack = ((CatalystInfo) object).getStack();
|
||||
return contains(stack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(ItemStack stack) {
|
||||
return catalystInfoList.stream().anyMatch(c -> NEIServerUtils.areStacksSameType(c.getStack(), stack));
|
||||
}
|
||||
|
||||
public boolean remove(ItemStack stack) {
|
||||
Iterator<CatalystInfo> iter = catalystInfoList.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ItemStack next = iter.next().getStack();
|
||||
if (NEIServerUtils.areStacksSameType(next, stack)) {
|
||||
iter.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void sort() {
|
||||
super.sort((c1, c2) -> c2.getPriority() - c1.getPriority());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user