Big improvements on the compression handler.

This commit is contained in:
WayofTime 2015-03-02 20:51:24 -05:00
parent a2a25626d4
commit ff3e2685ff
3 changed files with 120 additions and 30 deletions

View file

@ -1,22 +1,37 @@
package WayofTime.alchemicalWizardry.common.routing;
import WayofTime.alchemicalWizardry.api.RoutingFocusLogic;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
import WayofTime.alchemicalWizardry.api.RoutingFocusLogic;
import cpw.mods.fml.common.registry.GameData;
public class RoutingFocusLogicModItems extends RoutingFocusLogic
{
@Override
public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack)
{
if(keyStack != null && checkedStack != null)
if(keyStack != null && checkedStack != null && keyStack.getItem() != null && checkedStack.getItem() != null)
{
UniqueIdentifier keyId = GameRegistry.findUniqueIdentifierFor(keyStack.getItem());
UniqueIdentifier checkedId = GameRegistry.findUniqueIdentifierFor(checkedStack.getItem());
return keyId.modId.equals(checkedId.modId);
String keyId = getModID(keyStack.getItem());
String checkedId = getModID(checkedStack.getItem());
return keyId.equals(checkedId);
}
return false;
}
public String getModID(Item itm)
{
String str = GameData.getItemRegistry().getNameForObject(itm);
if(!str.isEmpty())
{
String[] strs = str.split(":");
if(strs != null && strs.length >= 1)
{
return strs[0];
}
}
return "";
}
}