Made the api usefull

This commit is contained in:
modmuss50 2016-04-03 14:25:46 +01:00
parent b44cdd4064
commit 7e7fcf2ad9
18 changed files with 162 additions and 133 deletions

View file

@ -62,11 +62,17 @@ public abstract class BaseRecipe implements IBaseRecipeType, Cloneable {
@Override
public boolean canCraft(TileEntity tile) {
if(tile instanceof ITileRecipeHandler){
return ((ITileRecipeHandler) tile).canCraft(tile, this);
}
return true;
}
@Override
public boolean onCraft(TileEntity tile) {
if(tile instanceof ITileRecipeHandler){
return ((ITileRecipeHandler) tile).onCraft(tile, this);
}
return true;
}

View file

@ -0,0 +1,12 @@
package techreborn.api.recipe;
import net.minecraft.tileentity.TileEntity;
/**
* Created by Mark on 03/04/2016.
*/
public interface ITileRecipeHandler<T extends BaseRecipe> {
boolean canCraft(TileEntity tile, T recipe);
boolean onCraft(TileEntity tile, T recipe);
}

View file

@ -2,7 +2,7 @@ package techreborn.api.recipe;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
import techreborn.items.ItemParts;
import techreborn.api.TechRebornAPI;
//THIS is only here to trick JEI into showing recipes for the recycler
public class RecyclerRecipe extends BaseRecipe {
@ -10,7 +10,7 @@ public class RecyclerRecipe extends BaseRecipe {
public RecyclerRecipe(ItemStack input) {
super(Reference.recyclerRecipe, 0, 0);
inputs.add(input);
addOutput(ItemParts.getPartByName("scrap"));
addOutput(TechRebornAPI.subItemRetriever.getPartByName("scrap"));
}
@Override

View file

@ -4,7 +4,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import techreborn.api.Reference;
import techreborn.api.recipe.BaseRecipe;
import techreborn.tiles.TileBlastFurnace;
public class BlastFurnaceRecipe extends BaseRecipe {
@ -29,18 +28,4 @@ public class BlastFurnaceRecipe extends BaseRecipe {
public String getUserFreindlyName() {
return "Blast Furnace";
}
@Override
public boolean canCraft(TileEntity tile) {
if (tile instanceof TileBlastFurnace) {
TileBlastFurnace blastFurnace = (TileBlastFurnace) tile;
return blastFurnace.getHeat() >= neededHeat;
}
return false;
}
@Override
public boolean onCraft(TileEntity tile) {
return super.onCraft(tile);
}
}

View file

@ -5,7 +5,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
import techreborn.api.Reference;
import techreborn.api.recipe.BaseRecipe;
import techreborn.tiles.TileIndustrialGrinder;
public class IndustrialGrinderRecipe extends BaseRecipe {
@ -33,48 +32,4 @@ public class IndustrialGrinderRecipe extends BaseRecipe {
public String getUserFreindlyName() {
return "IndustrialGrinder";
}
@Override
public boolean canCraft(TileEntity tile) {
if (fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialGrinder) {
TileIndustrialGrinder grinder = (TileIndustrialGrinder) tile;
if (grinder.tank.getFluid() == null) {
return false;
}
if (grinder.tank.getFluid() == fluidStack) {
if (grinder.tank.getFluidAmount() >= fluidStack.amount) {
return true;
}
}
}
return false;
}
@Override
public boolean onCraft(TileEntity tile) {
if (fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialGrinder) {
TileIndustrialGrinder grinder = (TileIndustrialGrinder) tile;
if (grinder.tank.getFluid() == null) {
return false;
}
if (grinder.tank.getFluid() == fluidStack) {
if (grinder.tank.getFluidAmount() >= fluidStack.amount) {
if (grinder.tank.getFluidAmount() > 0) {
grinder.tank.setFluid(new FluidStack(fluidStack.getFluid(),
grinder.tank.getFluidAmount() - fluidStack.amount));
} else {
grinder.tank.setFluid(null);
}
return true;
}
}
}
return false;
}
}

View file

@ -5,7 +5,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
import techreborn.api.Reference;
import techreborn.api.recipe.BaseRecipe;
import techreborn.tiles.TileIndustrialSawmill;
public class IndustrialSawmillRecipe extends BaseRecipe {
@ -51,50 +50,6 @@ public class IndustrialSawmillRecipe extends BaseRecipe {
return "Industrial Sawmill";
}
@Override
public boolean canCraft(TileEntity tile) {
if (fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialSawmill) {
TileIndustrialSawmill sawmill = (TileIndustrialSawmill) tile;
if (sawmill.tank.getFluid() == null) {
return false;
}
if (sawmill.tank.getFluid() == fluidStack) {
if (sawmill.tank.getFluidAmount() >= fluidStack.amount) {
return true;
}
}
}
return false;
}
@Override
public boolean onCraft(TileEntity tile) {
if (fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialSawmill) {
TileIndustrialSawmill sawmill = (TileIndustrialSawmill) tile;
if (sawmill.tank.getFluid() == null) {
return false;
}
if (sawmill.tank.getFluid() == fluidStack) {
if (sawmill.tank.getFluidAmount() >= fluidStack.amount) {
if (sawmill.tank.getFluidAmount() > 0) {
sawmill.tank.setFluid(new FluidStack(fluidStack.getFluid(),
sawmill.tank.getFluidAmount() - fluidStack.amount));
} else {
sawmill.tank.setFluid(null);
}
return true;
}
}
}
return false;
}
@Override
public boolean useOreDic() {
return canUseOreDict;

View file

@ -4,7 +4,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import techreborn.api.Reference;
import techreborn.api.recipe.BaseRecipe;
import techreborn.tiles.TileVacuumFreezer;
public class VacuumFreezerRecipe extends BaseRecipe {
@ -20,14 +19,4 @@ public class VacuumFreezerRecipe extends BaseRecipe {
public String getUserFreindlyName() {
return "Vacuum Freezer";
}
@Override
public boolean canCraft(TileEntity tile) {
if (tile instanceof TileVacuumFreezer) {
if (((TileVacuumFreezer) tile).multiBlockStatus == 1) {
return true;
}
}
return false;
}
}