Made the api usefull
This commit is contained in:
parent
b44cdd4064
commit
7e7fcf2ad9
18 changed files with 162 additions and 133 deletions
|
@ -4,26 +4,26 @@ import net.minecraft.item.Item.ToolMaterial;
|
|||
import net.minecraft.item.ItemArmor.ArmorMaterial;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
/**
|
||||
* This contains some static stuff used in recipes and other things
|
||||
*/
|
||||
//TODO move this out of the api, and make it nicer
|
||||
public class Reference {
|
||||
public static ToolMaterial BRONZE = EnumHelper.addToolMaterial("BRONZE", 2, 375, 6.0F, 2.25F, 8);
|
||||
public static ArmorMaterial BRONZE_ARMOUR = EnumHelper.addArmorMaterial("BRONZE", ModInfo.MOD_ID + ":bronze", 17,
|
||||
public static ArmorMaterial BRONZE_ARMOUR = EnumHelper.addArmorMaterial("BRONZE", "techreborn:bronze", 17,
|
||||
new int[]{3, 6, 5, 2}, 8, null/* TODO: SoundEvent */);
|
||||
|
||||
public static ToolMaterial RUBY = EnumHelper.addToolMaterial("RUBY", 2, 320, 6.2F, 2.7F, 10);
|
||||
public static ArmorMaterial RUBY_ARMOUR = EnumHelper.addArmorMaterial("RUBY", ModInfo.MOD_ID + ":ruby", 16,
|
||||
public static ArmorMaterial RUBY_ARMOUR = EnumHelper.addArmorMaterial("RUBY", "techreborn:ruby", 16,
|
||||
new int[]{2, 7, 5, 2}, 10, null/* TODO: SoundEvent */);
|
||||
|
||||
public static ToolMaterial SAPPHIRE = EnumHelper.addToolMaterial("SAPPHIRE", 2, 620, 5.0F, 2F, 8);
|
||||
public static ArmorMaterial SAPPHIRE_ARMOUR = EnumHelper.addArmorMaterial("SAPPHIRE", ModInfo.MOD_ID + ":sapphire",
|
||||
public static ArmorMaterial SAPPHIRE_ARMOUR = EnumHelper.addArmorMaterial("SAPPHIRE", "techreborn:sapphire",
|
||||
19, new int[]{4, 4, 4, 4}, 8, null/* TODO: SoundEvent */);
|
||||
|
||||
public static ToolMaterial PERIDOT = EnumHelper.addToolMaterial("PERIDOT", 2, 400, 7.0F, 2.4F, 16);
|
||||
public static ArmorMaterial PERIDOT_ARMOUR = EnumHelper.addArmorMaterial("PERIDOT", ModInfo.MOD_ID + ":peridot", 17,
|
||||
public static ArmorMaterial PERIDOT_ARMOUR = EnumHelper.addArmorMaterial("PERIDOT", "techreborn:peridot", 17,
|
||||
new int[]{3, 8, 3, 2}, 16, null/* TODO: SoundEvent */);
|
||||
|
||||
public static String alloySmelteRecipe = I18n.translateToLocal("techreborn.recipe.alloysmelter");
|
||||
|
|
|
@ -3,7 +3,7 @@ package techreborn.api.gui;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.api.upgrade.IMachineUpgrade;
|
||||
import techreborn.utils.upgrade.IMachineUpgrade;
|
||||
|
||||
public class SlotUpgrade extends Slot {
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
12
src/main/java/techreborn/api/recipe/ITileRecipeHandler.java
Normal file
12
src/main/java/techreborn/api/recipe/ITileRecipeHandler.java
Normal 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);
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package techreborn.api.upgrade;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.utils.RecipeCrafter;
|
||||
|
||||
public interface IMachineUpgrade {
|
||||
|
||||
public void processUpgrade(RecipeCrafter crafter, ItemStack stack);
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package techreborn.api.upgrade;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.utils.RecipeCrafter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class UpgradeHandler {
|
||||
|
||||
RecipeCrafter crafter;
|
||||
|
||||
Inventory inventory;
|
||||
|
||||
ArrayList<Integer> slots = new ArrayList<Integer>();
|
||||
|
||||
public UpgradeHandler(RecipeCrafter crafter, Inventory inventory, int... slots) {
|
||||
this.crafter = crafter;
|
||||
this.inventory = inventory;
|
||||
for (int slot : slots) {
|
||||
this.slots.add(slot);
|
||||
}
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (crafter.parentTile.getWorld().isRemote)
|
||||
return;
|
||||
crafter.resetPowerMulti();
|
||||
crafter.resetSpeedMulti();
|
||||
for (int slot : this.slots) {
|
||||
ItemStack stack = inventory.getStackInSlot(slot);
|
||||
if (stack != null && stack.getItem() instanceof IMachineUpgrade) {
|
||||
((IMachineUpgrade) stack.getItem()).processUpgrade(crafter, stack);
|
||||
}
|
||||
}
|
||||
if (crafter.currentRecipe != null)
|
||||
crafter.currentNeededTicks = (int) (crafter.currentRecipe.tickTime()
|
||||
* (1.0 - crafter.getSpeedMultiplier()));
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
|
||||
package techreborn.api.upgrade;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
Loading…
Add table
Add a link
Reference in a new issue