mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
Add necessary GUI implementation for new mod ID filters
This commit is contained in:
1 parent
1a0821c727
commit
31dd643259
7 files changed
+296
-410
No files matched your search
@@ -8,12 +8,15 @@ import java.util.Map;
|
||||
import mekanism.api.ItemInfo;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.StackUtils;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class OreDictCache
|
||||
public final class OreDictCache
|
||||
{
|
||||
public static HashMap<ItemInfo, List<String>> cachedKeys = new HashMap<ItemInfo, List<String>>();
|
||||
public static HashMap<String, List<ItemStack>> oreDictStacks = new HashMap<String, List<ItemStack>>();
|
||||
public static HashMap<String, List<ItemStack>> modIDStacks = new HashMap<String, List<ItemStack>>();
|
||||
|
||||
public static List<String> getOreDictName(ItemStack check)
|
||||
{
|
||||
@@ -51,4 +54,114 @@ public class OreDictCache
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getOreDictStacks(String oreName, boolean forceBlock)
|
||||
{
|
||||
if(oreDictStacks.get(oreName) != null)
|
||||
{
|
||||
return oreDictStacks.get(oreName);
|
||||
}
|
||||
|
||||
List<String> keys = new ArrayList<String>();
|
||||
|
||||
for(String s : OreDictionary.getOreNames())
|
||||
{
|
||||
if(oreName.equals(s) || oreName.equals("*"))
|
||||
{
|
||||
keys.add(s);
|
||||
}
|
||||
else if(oreName.endsWith("*") && !oreName.startsWith("*"))
|
||||
{
|
||||
if(s.startsWith(oreName.substring(0, oreName.length()-1)))
|
||||
{
|
||||
keys.add(s);
|
||||
}
|
||||
}
|
||||
else if(oreName.startsWith("*") && !oreName.endsWith("*"))
|
||||
{
|
||||
if(s.endsWith(oreName.substring(1)))
|
||||
{
|
||||
keys.add(s);
|
||||
}
|
||||
}
|
||||
else if(oreName.startsWith("*") && oreName.endsWith("*"))
|
||||
{
|
||||
if(s.contains(oreName.substring(1, oreName.length()-1)))
|
||||
{
|
||||
keys.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
|
||||
for(String key : keys)
|
||||
{
|
||||
for(ItemStack stack : OreDictionary.getOres(key))
|
||||
{
|
||||
ItemStack toAdd = stack.copy();
|
||||
|
||||
if(!stacks.contains(stack) && (!forceBlock || toAdd.getItem() instanceof ItemBlock))
|
||||
{
|
||||
stacks.add(stack.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
oreDictStacks.put(oreName, stacks);
|
||||
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getModIDStacks(String modName, boolean forceBlock)
|
||||
{
|
||||
if(modIDStacks.get(modName) != null)
|
||||
{
|
||||
return modIDStacks.get(modName);
|
||||
}
|
||||
|
||||
List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
|
||||
for(String key : OreDictionary.getOreNames())
|
||||
{
|
||||
for(ItemStack stack : OreDictionary.getOres(key))
|
||||
{
|
||||
ItemStack toAdd = stack.copy();
|
||||
String s = MekanismUtils.getMod(toAdd);
|
||||
|
||||
if(!stacks.contains(stack) && toAdd.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if(modName.equals(s) || modName.equals("*"))
|
||||
{
|
||||
stacks.add(stack.copy());
|
||||
}
|
||||
else if(modName.endsWith("*") && !modName.startsWith("*"))
|
||||
{
|
||||
if(s.startsWith(modName.substring(0, modName.length()-1)))
|
||||
{
|
||||
stacks.add(stack.copy());
|
||||
}
|
||||
}
|
||||
else if(modName.startsWith("*") && !modName.endsWith("*"))
|
||||
{
|
||||
if(s.endsWith(modName.substring(1)))
|
||||
{
|
||||
stacks.add(stack.copy());
|
||||
}
|
||||
}
|
||||
else if(modName.startsWith("*") && modName.endsWith("*"))
|
||||
{
|
||||
if(s.contains(modName.substring(1, modName.length()-1)))
|
||||
{
|
||||
stacks.add(stack.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modIDStacks.put(modName, stacks);
|
||||
|
||||
return stacks;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user