I'm not 100% sure as it's been a while since I've worked with the factory code and i think you might've deleted some stuff that matters but try
if (set.item.megaStone || set.item.zMove) continue;
if (set.item.megaStone || set.item.zMove) continue;