Package logisticspipes.recipes

Source Code of logisticspipes.recipes.LPShapelessOreRecipe

package logisticspipes.recipes;

import logisticspipes.Configs;
import logisticspipes.proxy.MainProxy;
import logisticspipes.proxy.SimpleServiceLocator;
import logisticspipes.utils.PlayerIdentifier;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.oredict.ShapelessOreRecipe;

public class LPShapelessOreRecipe extends ShapelessOreRecipe {

  private final CraftingDependency dependent;
 
  public LPShapelessOreRecipe(ItemStack result, CraftingDependency dependent, Object[] recipe) {
    super(result, recipe);
    this.dependent = dependent;
    dependent.addStack(result);
  }

  @Override
  public ItemStack getCraftingResult(InventoryCrafting inv) {
    if(Configs.ENABLE_RESEARCH_SYSTEM) {
      PlayerIdentifier name = SimpleServiceLocator.craftingPermissionManager.getPlayerID(inv);
      if(name == null || name.equals("")) return null;
      if(!SimpleServiceLocator.craftingPermissionManager.isAllowedFor(dependent, name)) {
        return null;
      }
    }
    return super.getCraftingResult(inv);
  }

  @Override
  public boolean matches(InventoryCrafting inv, World world) {
    if(Configs.ENABLE_RESEARCH_SYSTEM) {
      PlayerIdentifier name = SimpleServiceLocator.craftingPermissionManager.getPlayerID(inv);
      if(name == null || name.equals("")) return false;
      if(!SimpleServiceLocator.craftingPermissionManager.isAllowedFor(dependent, name)) {
        return false;
      }
    }
    return super.matches(inv, world);
  }

  @Override
  public ItemStack getRecipeOutput() {
    if(MainProxy.isClient() && Configs.ENABLE_RESEARCH_SYSTEM) {
      if(!SimpleServiceLocator.craftingPermissionManager.clientSidePermission.contains(dependent)) {
        return null;
      }
    }
    return super.getRecipeOutput();
  }
}
TOP

Related Classes of logisticspipes.recipes.LPShapelessOreRecipe

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.