mirror of
https://github.com/GTNewHorizons/FindIt.git
synced 2026-11-24 18:24:21 +00:00
Add support for Aspect Recipe Index and remove requirement of TCNEIPlugin to load ThaumcraftProvider (#28)
This commit is contained in:
1 parent
ab6c722369
commit
f34980692b
10 files changed
+98
-37
No files matched your search
@@ -86,7 +86,7 @@ public class FindIt {
|
||||
this.pluginsList.add(new BackpackProvider());
|
||||
}
|
||||
|
||||
if (Loader.isModLoaded("thaumcraftneiplugin") && Loader.isModLoaded("Thaumcraft")) {
|
||||
if (Loader.isModLoaded("Thaumcraft")) {
|
||||
this.pluginsList.add(new ThaumcraftProvider());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,12 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect;
|
||||
import com.gtnewhorizons.aspectrecipeindex.common.items.ItemAspect;
|
||||
import com.gtnh.findit.IStackFilter;
|
||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
||||
import com.gtnh.findit.service.itemfinder.FindItemRequest;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.aspects.IAspectContainer;
|
||||
@@ -17,6 +18,9 @@ import thaumcraft.api.aspects.IEssentiaContainerItem;
|
||||
|
||||
public class ThaumcraftProvider implements IStackFilterProvider {
|
||||
|
||||
public static final boolean ASPECTRECIPEINDEX = Loader.isModLoaded("aspectrecipeindex");
|
||||
public static final boolean TCNEIPLUGIN = Loader.isModLoaded("thaumcraftneiplugin");
|
||||
|
||||
static class AspectStackFilter implements IStackFilter {
|
||||
|
||||
AspectList filterAspects;
|
||||
@@ -29,14 +33,26 @@ public class ThaumcraftProvider implements IStackFilterProvider {
|
||||
public boolean matches(FindItemRequest request) {
|
||||
ItemStack stack = request.getStackToFind();
|
||||
Item item = stack.getItem();
|
||||
if (!(item instanceof ItemAspect || item instanceof IEssentiaContainerItem)) return false;
|
||||
if (item instanceof IEssentiaContainerItem container) {
|
||||
AspectList stackAspects = container.getAspects(stack);
|
||||
if (stackAspects == null || stackAspects.aspects.isEmpty()) return false;
|
||||
for (Aspect a : stackAspects.getAspects()) {
|
||||
if (filterAspects.getAmount(a) > 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Aspect aspect;
|
||||
if (ASPECTRECIPEINDEX && item instanceof ItemAspect) {
|
||||
aspect = ItemAspect.getAspect(stack);
|
||||
} else if (TCNEIPLUGIN && item instanceof com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect) {
|
||||
AspectList stackAspects = com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect.getAspects(stack);
|
||||
if (stackAspects == null || stackAspects.aspects.isEmpty()) return false;
|
||||
aspect = stackAspects.getAspects()[0];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
AspectList stackAspects = ItemAspect.getAspects(stack);
|
||||
if (stackAspects == null || stackAspects.size() != 1) return false;
|
||||
|
||||
Aspect stackAspect = stackAspects.getAspects()[0];
|
||||
|
||||
return filterAspects.getAmount(stackAspect) > 0;
|
||||
return filterAspects.getAmount(aspect) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user