package landmaster.plustic.util;

import net.minecraft.entity.player.*;
import net.minecraftforge.fml.common.*;
import vazkii.psi.common.core.handler.*;

public class PsiUtils {
	public static int extractPsi(EntityPlayer player, int maxExtract) {
		if (Loader.isModLoaded("Psi") && PlayerDataHandler.get(player) != null && PlayerDataHandler.get(player).getCAD() != null) {
			int amount = PlayerDataHandler.get(player).getAvailablePsi();
			PlayerDataHandler.get(player).deductPsi(Math.min(maxExtract, amount), 20, true);
			return Math.min(maxExtract, amount);
		}
		return 0;
	}
	
	public static int extractPsiExact(EntityPlayer player, int extract) {
		if (Loader.isModLoaded("Psi") && PlayerDataHandler.get(player) != null && PlayerDataHandler.get(player).getCAD() != null) {
			int amount = PlayerDataHandler.get(player).getAvailablePsi();
			if (amount >= extract) {
				PlayerDataHandler.get(player).deductPsi(extract, 20, true);
				return Math.min(extract, amount);
			}
		}
		return 0;
	}
}

@@ -237,32 +237,33 @@
 Extract) %7B%0A%09%09if 
+(
 (Loader.isModLoa
@@ -264,32 +264,62 @@
 ModLoaded(%22Psi%22)
+ %7C%7C Loader.isModLoaded(%22psi%22))
  && PlayerDataHa
@@ -683,16 +683,17 @@
  %7B%0A%09%09if 
+(
 (Loader.
@@ -710,16 +710,46 @@
 d(%22Psi%22)
+ %7C%7C Loader.isModLoaded(%22psi%22))
  && Play

Fix #64