mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 23:13:21 +00:00
Added vanilla smelting to alloy furnace.
This commit is contained in:
1 parent
1f87d0aacb
commit
485ef1733b
5 files changed
+125
-8
No files matched your search
@@ -96,13 +96,16 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
protected void taskComplete() {
|
||||
int outputIndex = inventory.length - 2;
|
||||
if (currentTask != null) {
|
||||
ItemStack result = currentTask.getCompletedResult()[0];
|
||||
if (inventory[outputIndex] == null) {
|
||||
inventory[outputIndex] = result.copy();
|
||||
} else {
|
||||
int newStackSize = inventory[outputIndex].stackSize += result.stackSize;
|
||||
inventory[outputIndex] = result.copy();
|
||||
inventory[outputIndex].stackSize = newStackSize;
|
||||
ItemStack[] output = currentTask.getCompletedResult();
|
||||
if (output != null && output.length > 0) {
|
||||
ItemStack result = currentTask.getCompletedResult()[0];
|
||||
if (inventory[outputIndex] == null) {
|
||||
inventory[outputIndex] = result.copy();
|
||||
} else {
|
||||
int newStackSize = inventory[outputIndex].stackSize += result.stackSize;
|
||||
inventory[outputIndex] = result.copy();
|
||||
inventory[outputIndex].stackSize = newStackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
currentTask = null;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PoweredTask {
|
||||
int index = 0;
|
||||
for (int i = 0; i < inputsIn.length; i++) {
|
||||
if (inputsIn[i] != null && inputsIn[i].item != null) {
|
||||
inputs[index] = inputsIn[i];
|
||||
inputs[index] = new RecipeInput(inputsIn[i].slotNumber, inputsIn[i].item.copy());
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package crazypants.enderio.machine.alloy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.IMachineRecipe;
|
||||
import crazypants.enderio.machine.RecipeInput;
|
||||
|
||||
public class VanillaSmeltingRecipe implements IMachineRecipe {
|
||||
|
||||
// We will use the same energy as per a standard furnace.
|
||||
// To do the conversion between fuel burning and MJ, use the Stirling Gen
|
||||
// which produces one MJ per tick of burn time
|
||||
private static float MJ_PER_ITEM = TileEntityFurnace.getItemBurnTime(new ItemStack(Item.coal)) / 8;
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return "VanillaSmeltingRecipe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnergyRequired(RecipeInput... inputs) {
|
||||
int numInputs = getNumInputs(inputs);
|
||||
return numInputs * MJ_PER_ITEM;
|
||||
}
|
||||
|
||||
private int getNumInputs(RecipeInput[] inputs) {
|
||||
int numInputs = 0;
|
||||
for (RecipeInput input : inputs) {
|
||||
if (input != null && isValidInput(input.slotNumber, input.item)) {
|
||||
numInputs += input.item.stackSize;
|
||||
}
|
||||
}
|
||||
return Math.min(numInputs, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipe(RecipeInput... inputs) {
|
||||
ItemStack output = null;
|
||||
for (RecipeInput ri : inputs) {
|
||||
if (ri != null && ri.item != null) {
|
||||
if (output == null) {
|
||||
output = FurnaceRecipes.smelting().getSmeltingResult(ri.item);
|
||||
} else {
|
||||
ItemStack newOutput = FurnaceRecipes.smelting().getSmeltingResult(ri.item);
|
||||
if (newOutput != null && !newOutput.isItemEqual(output)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return output != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(RecipeInput... inputs) {
|
||||
ItemStack output = null;
|
||||
int inputCount = 0;
|
||||
for (RecipeInput ri : inputs) {
|
||||
if (ri != null && ri.item != null && output == null) {
|
||||
output = FurnaceRecipes.smelting().getSmeltingResult(ri.item);
|
||||
}
|
||||
}
|
||||
if (output == null) {
|
||||
return new ItemStack[0];
|
||||
}
|
||||
ItemStack result = output.copy();
|
||||
result.stackSize = result.stackSize * getNumInputs(inputs);
|
||||
return new ItemStack[] { result };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(int slotNumber, ItemStack item) {
|
||||
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(item);
|
||||
return itemstack != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMachineName() {
|
||||
return ModObject.blockAlloySmelter.unlocalisedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeInput[] getQuantitiesConsumed(RecipeInput[] inputs) {
|
||||
int consumed = 0;
|
||||
List<RecipeInput> result = new ArrayList<RecipeInput>();
|
||||
for (RecipeInput ri : inputs) {
|
||||
if (consumed < 3 && ri != null && ri.item != null) {
|
||||
int available = ri.item.stackSize;
|
||||
int canUse = 3 - consumed;
|
||||
int use = Math.min(canUse, available);
|
||||
if (use > 0) {
|
||||
ItemStack st = ri.item.copy();
|
||||
st.stackSize = use;
|
||||
result.add(new RecipeInput(ri.slotNumber, st));
|
||||
consumed += use;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toArray(new RecipeInput[result.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -152,6 +152,9 @@ public class BlockCustomStair extends BlockStairs implements ITileEntityProvider
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(RecipeInput... inputs) {
|
||||
ItemStack paintSource = RecipeInput.getInputForSlot(1, inputs);
|
||||
if(paintSource == null) {
|
||||
return new ItemStack[0];
|
||||
}
|
||||
return new ItemStack[] {createItemStackForSourceBlock(paintSource.itemID, paintSource.getItemDamage())};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.IMachineRecipe;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.alloy.BasicAlloyRecipe;
|
||||
import crazypants.enderio.machine.alloy.VanillaSmeltingRecipe;
|
||||
|
||||
public class MaterialRecipes {
|
||||
|
||||
@@ -53,6 +54,7 @@ public class MaterialRecipes {
|
||||
}
|
||||
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockAlloySmelter.unlocalisedName, new FusedQuartzRecipe());
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockAlloySmelter.unlocalisedName, new VanillaSmeltingRecipe());
|
||||
|
||||
ItemStack fusedQuartzFrame = new ItemStack(ModObject.itemFusedQuartzFrame.actualId,1,0);
|
||||
GameRegistry.addShapedRecipe(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', industialBinder, 's', new ItemStack(Item.stick));
|
||||
|
||||
Reference in new issue
Block a user