use of forestry.api.recipes.IFabricatorSmeltingRecipe in project ForestryMC by ForestryMC.
the class FabricatorRecipeCategory method getSmeltingInputs.
private static Map<Fluid, List<IFabricatorSmeltingRecipe>> getSmeltingInputs() {
Map<Fluid, List<IFabricatorSmeltingRecipe>> smeltingInputs = new HashMap<>();
for (IFabricatorSmeltingRecipe smelting : FabricatorSmeltingRecipeManager.recipes) {
Fluid fluid = smelting.getProduct().getFluid();
if (!smeltingInputs.containsKey(fluid)) {
smeltingInputs.put(fluid, new ArrayList<>());
}
smeltingInputs.get(fluid).add(smelting);
}
return smeltingInputs;
}
use of forestry.api.recipes.IFabricatorSmeltingRecipe in project ForestryMC by ForestryMC.
the class FabricatorRecipeCategory method setRecipe.
@Override
public void setRecipe(IRecipeLayout recipeLayout, FabricatorRecipeWrapper recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
guiItemStacks.init(planSlot, true, 118, 0);
guiItemStacks.init(smeltingInputSlot, true, 5, 4);
guiItemStacks.init(craftOutputSlot, false, 118, 36);
for (int y = 0; y < 3; ++y) {
for (int x = 0; x < 3; ++x) {
int index = craftInputSlot + x + y * 3;
guiItemStacks.init(index, true, 46 + x * 18, y * 18);
}
}
guiFluidStacks.init(inputTank, true, 6, 32, 16, 16, 2000, false, null);
IFabricatorRecipe recipe = recipeWrapper.getRecipe();
ItemStack plan = recipe.getPlan();
if (!plan.isEmpty()) {
guiItemStacks.set(planSlot, plan);
}
List<ItemStack> smeltingInput = new ArrayList<>();
Fluid recipeFluid = recipe.getLiquid().getFluid();
for (IFabricatorSmeltingRecipe s : getSmeltingInputs().get(recipeFluid)) {
smeltingInput.add(s.getResource());
}
if (!smeltingInput.isEmpty()) {
guiItemStacks.set(smeltingInputSlot, smeltingInput);
}
List<List<ItemStack>> itemOutputs = ingredients.getOutputs(ItemStack.class);
guiItemStacks.set(craftOutputSlot, itemOutputs.get(0));
List<List<ItemStack>> itemStackInputs = ingredients.getInputs(ItemStack.class);
craftingGridHelper.setInputs(guiItemStacks, itemStackInputs, recipe.getWidth(), recipe.getHeight());
List<List<FluidStack>> fluidInputs = ingredients.getInputs(FluidStack.class);
if (!fluidInputs.isEmpty()) {
guiFluidStacks.set(inputTank, fluidInputs.get(0));
}
}
use of forestry.api.recipes.IFabricatorSmeltingRecipe in project ForestryMC by ForestryMC.
the class TileFabricator method trySmelting.
private void trySmelting() {
IInventoryAdapter inventory = getInternalInventory();
ItemStack smeltResource = inventory.getStackInSlot(InventoryFabricator.SLOT_METAL);
if (smeltResource.isEmpty()) {
return;
}
IFabricatorSmeltingRecipe smelt = FabricatorSmeltingRecipeManager.findMatchingSmelting(smeltResource);
if (smelt == null || smelt.getMeltingPoint() > heat) {
return;
}
FluidStack smeltFluid = smelt.getProduct();
if (moltenTank.fillInternal(smeltFluid, false) == smeltFluid.amount) {
this.decrStackSize(InventoryFabricator.SLOT_METAL, 1);
moltenTank.fillInternal(smeltFluid, true);
meltingPoint = smelt.getMeltingPoint();
}
}
Aggregations