package WayofTime.bloodmagic.inversion; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import WayofTime.bloodmagic.tile.TileInversionPillar; public class InversionPillarHandler { public static Map>> pillarMap = new HashMap>>(); public static boolean addPillarToMap(World world, EnumDemonWillType type, BlockPos pos) { int dim = world.provider.getDimension(); if (pillarMap.containsKey(dim)) { Map> willMap = pillarMap.get(dim); if (willMap.containsKey(type)) { if (!willMap.get(type).contains(pos)) { return willMap.get(type).add(pos); } else { return false; } } else { List posList = new ArrayList(); posList.add(pos); willMap.put(type, posList); return true; } } else { Map> willMap = new HashMap>(); List posList = new ArrayList(); posList.add(pos); willMap.put(type, posList); pillarMap.put(dim, willMap); return true; } } public static List getNearbyPillars(World world, EnumDemonWillType type, BlockPos pos) { int dim = world.provider.getDimension(); List posList = new ArrayList(); if (pillarMap.containsKey(dim)) { Map> willMap = pillarMap.get(dim); posList = willMap.get(type); } if (posList != null) { List newList = new ArrayList(); Iterator itr = posList.iterator(); while (itr.hasNext()) { BlockPos newPos = itr.next(); if (newPos.equals(pos)) { continue; } if (world.getTileEntity(newPos) instanceof TileInversionPillar) //Make this check... more efficient somehow. { newList.add(newPos); } } return newList; } else { return new ArrayList(); } } }