mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-27 15:23:16 +00:00
Make combining factories work again
This commit is contained in:
1 parent
ba6634b89f
commit
6cafac7166
4 files changed
+97
-32
No files matched your search
@@ -16,6 +16,7 @@ import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Tier.FactoryTier;
|
||||
import mekanism.common.base.IFactory.MachineFuelType;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.inventory.container.ContainerFactory;
|
||||
import mekanism.common.item.ItemGaugeDropper;
|
||||
@@ -76,7 +77,7 @@ public class GuiFactory extends GuiMekanism
|
||||
|
||||
if(xAxis >= 8 && xAxis <= 168 && yAxis >= 78 && yAxis <= 83)
|
||||
{
|
||||
if(tileEntity.recipeType.usesFuel())
|
||||
if(tileEntity.recipeType.getFuelType() == MachineFuelType.ADVANCED)
|
||||
{
|
||||
drawHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : LangUtils.localize("gui.none"), xAxis, yAxis);
|
||||
}
|
||||
@@ -119,7 +120,7 @@ public class GuiFactory extends GuiMekanism
|
||||
drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt);
|
||||
}
|
||||
|
||||
if(tileEntity.recipeType.usesFuel())
|
||||
if(tileEntity.recipeType.getFuelType() == MachineFuelType.ADVANCED)
|
||||
{
|
||||
if(tileEntity.getScaledGasLevel(160) > 0)
|
||||
{
|
||||
|
||||
@@ -9,10 +9,12 @@ import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
||||
import mekanism.common.recipe.inputs.DoubleMachineInput;
|
||||
import mekanism.common.recipe.inputs.InfusionInput;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
import mekanism.common.recipe.machines.BasicMachineRecipe;
|
||||
import mekanism.common.recipe.machines.DoubleMachineRecipe;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
||||
import mekanism.common.tile.prefab.TileEntityAdvancedElectricMachine;
|
||||
@@ -45,21 +47,27 @@ public interface IFactory
|
||||
*/
|
||||
void setRecipeType(int type, ItemStack itemStack);
|
||||
|
||||
public static enum MachineFuelType {
|
||||
BASIC,
|
||||
ADVANCED,
|
||||
DOUBLE
|
||||
}
|
||||
|
||||
public static enum RecipeType implements IStringSerializable
|
||||
{
|
||||
SMELTING("Smelting", "smelter", MachineType.ENERGIZED_SMELTER, false, false, Recipe.ENERGIZED_SMELTER),
|
||||
ENRICHING("Enriching", "enrichment", MachineType.ENRICHMENT_CHAMBER, false, false, Recipe.ENRICHMENT_CHAMBER),
|
||||
CRUSHING("Crushing", "crusher", MachineType.CRUSHER, false, false, Recipe.CRUSHER),
|
||||
COMPRESSING("Compressing", "compressor", MachineType.OSMIUM_COMPRESSOR, true, false, Recipe.OSMIUM_COMPRESSOR),
|
||||
COMBINING("Combining", "combiner", MachineType.COMBINER, true, false, Recipe.COMBINER),
|
||||
PURIFYING("Purifying", "purifier", MachineType.PURIFICATION_CHAMBER, true, true, Recipe.PURIFICATION_CHAMBER),
|
||||
INJECTING("Injecting", "injection", MachineType.CHEMICAL_INJECTION_CHAMBER, true, true, Recipe.CHEMICAL_INJECTION_CHAMBER),
|
||||
INFUSING("Infusing", "metalinfuser", MachineType.METALLURGIC_INFUSER, false, false, Recipe.METALLURGIC_INFUSER);
|
||||
SMELTING("Smelting", "smelter", MachineType.ENERGIZED_SMELTER, MachineFuelType.BASIC, false, Recipe.ENERGIZED_SMELTER),
|
||||
ENRICHING("Enriching", "enrichment", MachineType.ENRICHMENT_CHAMBER, MachineFuelType.BASIC, false, Recipe.ENRICHMENT_CHAMBER),
|
||||
CRUSHING("Crushing", "crusher", MachineType.CRUSHER, MachineFuelType.BASIC, false, Recipe.CRUSHER),
|
||||
COMPRESSING("Compressing", "compressor", MachineType.OSMIUM_COMPRESSOR, MachineFuelType.ADVANCED, false, Recipe.OSMIUM_COMPRESSOR),
|
||||
COMBINING("Combining", "combiner", MachineType.COMBINER, MachineFuelType.DOUBLE, false, Recipe.COMBINER),
|
||||
PURIFYING("Purifying", "purifier", MachineType.PURIFICATION_CHAMBER, MachineFuelType.ADVANCED, true, Recipe.PURIFICATION_CHAMBER),
|
||||
INJECTING("Injecting", "injection", MachineType.CHEMICAL_INJECTION_CHAMBER, MachineFuelType.ADVANCED, true, Recipe.CHEMICAL_INJECTION_CHAMBER),
|
||||
INFUSING("Infusing", "metalinfuser", MachineType.METALLURGIC_INFUSER, MachineFuelType.BASIC, false, Recipe.METALLURGIC_INFUSER);
|
||||
|
||||
private String name;
|
||||
private ResourceLocation sound;
|
||||
private MachineType type;
|
||||
private boolean usesFuel;
|
||||
private MachineFuelType fuelType;
|
||||
private boolean fuelSpeed;
|
||||
private Recipe recipe;
|
||||
private TileEntityAdvancedElectricMachine cacheTile;
|
||||
@@ -83,7 +91,17 @@ public interface IFactory
|
||||
{
|
||||
return getRecipe(new AdvancedMachineInput(input, gas));
|
||||
}
|
||||
|
||||
|
||||
public DoubleMachineRecipe getRecipe(DoubleMachineInput input)
|
||||
{
|
||||
return RecipeHandler.getRecipe(input, recipe.get());
|
||||
}
|
||||
|
||||
public DoubleMachineRecipe getRecipe(ItemStack input, ItemStack extra)
|
||||
{
|
||||
return getRecipe(new DoubleMachineInput(input, extra));
|
||||
}
|
||||
|
||||
public MetallurgicInfuserRecipe getRecipe(InfusionInput input)
|
||||
{
|
||||
return RecipeHandler.getMetallurgicInfuserRecipe(input);
|
||||
@@ -94,12 +112,16 @@ public interface IFactory
|
||||
return getRecipe(new InfusionInput(storage, input));
|
||||
}
|
||||
|
||||
public MachineRecipe getAnyRecipe(ItemStack slotStack, Gas gasType, InfuseStorage infuse)
|
||||
public MachineRecipe getAnyRecipe(ItemStack slotStack, ItemStack extraStack, Gas gasType, InfuseStorage infuse)
|
||||
{
|
||||
if(usesFuel())
|
||||
if(fuelType == MachineFuelType.ADVANCED)
|
||||
{
|
||||
return getRecipe(slotStack, gasType);
|
||||
}
|
||||
else if(fuelType == MachineFuelType.DOUBLE)
|
||||
{
|
||||
return getRecipe(slotStack, extraStack);
|
||||
}
|
||||
else if(this == INFUSING)
|
||||
{
|
||||
if(infuse.type != null)
|
||||
@@ -125,7 +147,7 @@ public interface IFactory
|
||||
|
||||
public GasStack getItemGas(ItemStack itemstack)
|
||||
{
|
||||
if(usesFuel)
|
||||
if(fuelType == MachineFuelType.ADVANCED)
|
||||
{
|
||||
return getTile().getItemGas(itemstack);
|
||||
}
|
||||
@@ -135,7 +157,7 @@ public interface IFactory
|
||||
|
||||
public int getSecondaryEnergyPerTick()
|
||||
{
|
||||
if(usesFuel)
|
||||
if(fuelType == MachineFuelType.ADVANCED)
|
||||
{
|
||||
return getTile().BASE_SECONDARY_ENERGY_PER_TICK;
|
||||
}
|
||||
@@ -145,7 +167,7 @@ public interface IFactory
|
||||
|
||||
public boolean canReceiveGas(EnumFacing side, Gas type)
|
||||
{
|
||||
if(usesFuel)
|
||||
if(fuelType == MachineFuelType.ADVANCED)
|
||||
{
|
||||
return getTile().canReceiveGas(side, type);
|
||||
}
|
||||
@@ -155,7 +177,7 @@ public interface IFactory
|
||||
|
||||
public boolean canTubeConnect(EnumFacing side)
|
||||
{
|
||||
if(usesFuel)
|
||||
if(fuelType == MachineFuelType.ADVANCED)
|
||||
{
|
||||
return getTile().canTubeConnect(side);
|
||||
}
|
||||
@@ -165,7 +187,7 @@ public interface IFactory
|
||||
|
||||
public boolean isValidGas(Gas gas)
|
||||
{
|
||||
if(usesFuel)
|
||||
if(fuelType == MachineFuelType.ADVANCED)
|
||||
{
|
||||
return getTile().isValidGas(gas);
|
||||
}
|
||||
@@ -197,6 +219,30 @@ public interface IFactory
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasRecipeForExtra(ItemStack extraStack)
|
||||
{
|
||||
if(extraStack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for(Object obj : recipe.get().entrySet())
|
||||
{
|
||||
if(((Map.Entry)obj).getKey() instanceof DoubleMachineInput)
|
||||
{
|
||||
Map.Entry entry = (Map.Entry)obj;
|
||||
ItemStack stack = ((DoubleMachineInput)entry.getKey()).extraStack;
|
||||
|
||||
if(StackUtils.equalsWildcard(stack, extraStack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public TileEntityAdvancedElectricMachine getTile()
|
||||
{
|
||||
if(cacheTile == null)
|
||||
@@ -238,9 +284,9 @@ public interface IFactory
|
||||
return sound;
|
||||
}
|
||||
|
||||
public boolean usesFuel()
|
||||
public MachineFuelType getFuelType()
|
||||
{
|
||||
return usesFuel;
|
||||
return fuelType;
|
||||
}
|
||||
|
||||
public boolean fuelEnergyUpgrades()
|
||||
@@ -266,12 +312,12 @@ public interface IFactory
|
||||
return type;
|
||||
}
|
||||
|
||||
RecipeType(String s, String s1, MachineType t, boolean b, boolean b1, Recipe r)
|
||||
RecipeType(String s, String s1, MachineType t, MachineFuelType ft, boolean b1, Recipe r)
|
||||
{
|
||||
name = s;
|
||||
sound = new ResourceLocation("mekanism", "tile.machine." + s1);
|
||||
type = t;
|
||||
usesFuel = b;
|
||||
fuelType = ft;
|
||||
fuelSpeed = b1;
|
||||
recipe = r;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class ContainerFactory extends Container
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if(tileEntity.recipeType.getAnyRecipe(slotStack, tileEntity.gasTank.getGasType(), tileEntity.infuseStored) != null)
|
||||
else if(tileEntity.recipeType.getAnyRecipe(slotStack, inventorySlots.get(4).getStack(), tileEntity.gasTank.getGasType(), tileEntity.infuseStored) != null)
|
||||
{
|
||||
if(!isInputSlot(slotID))
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@ import mekanism.common.SideData;
|
||||
import mekanism.common.Tier.BaseTier;
|
||||
import mekanism.common.Tier.FactoryTier;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory.MachineFuelType;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.base.ITierUpgradeable;
|
||||
@@ -41,6 +42,7 @@ import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.InfusionInput;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
import mekanism.common.recipe.machines.BasicMachineRecipe;
|
||||
import mekanism.common.recipe.machines.DoubleMachineRecipe;
|
||||
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
@@ -327,7 +329,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
|
||||
if(!canOperate(getInputSlot(process), getOutputSlot(process)))
|
||||
{
|
||||
if(!(recipeType.usesFuel() && recipeType.hasRecipe(inventory.get(getInputSlot(process)))))
|
||||
if(!(recipeType.getFuelType() == MachineFuelType.ADVANCED && recipeType.hasRecipe(inventory.get(getInputSlot(process)))))
|
||||
{
|
||||
progress[process] = 0;
|
||||
}
|
||||
@@ -474,7 +476,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
{
|
||||
if(!inventory.get(4).isEmpty())
|
||||
{
|
||||
if(recipeType.usesFuel() && gasTank.getNeeded() > 0)
|
||||
if(recipeType.getFuelType() == MachineFuelType.ADVANCED && gasTank.getNeeded() > 0)
|
||||
{
|
||||
if(inventory.get(4).getItem() instanceof IGasItem)
|
||||
{
|
||||
@@ -558,7 +560,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
}
|
||||
else if(slotID >= 5 && slotID <= 7)
|
||||
{
|
||||
return recipeType.getAnyRecipe(itemstack, gasTank.getGasType(), infuseStored) != null;
|
||||
return recipeType.getAnyRecipe(itemstack, inventory.get(4), gasTank.getGasType(), infuseStored) != null;
|
||||
}
|
||||
}
|
||||
else if(tier == FactoryTier.ADVANCED)
|
||||
@@ -569,7 +571,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
}
|
||||
else if(slotID >= 5 && slotID <= 9)
|
||||
{
|
||||
return recipeType.getAnyRecipe(itemstack, gasTank.getGasType(), infuseStored) != null;
|
||||
return recipeType.getAnyRecipe(itemstack, inventory.get(4), gasTank.getGasType(), infuseStored) != null;
|
||||
}
|
||||
}
|
||||
else if(tier == FactoryTier.ELITE)
|
||||
@@ -580,7 +582,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
}
|
||||
else if(slotID >= 5 && slotID <= 11)
|
||||
{
|
||||
return recipeType.getAnyRecipe(itemstack, gasTank.getGasType(), infuseStored) != null;
|
||||
return recipeType.getAnyRecipe(itemstack, inventory.get(4), gasTank.getGasType(), infuseStored) != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,10 +596,14 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
}
|
||||
else if(slotID == 4)
|
||||
{
|
||||
if(recipeType.usesFuel())
|
||||
if(recipeType.getFuelType() == MachineFuelType.ADVANCED)
|
||||
{
|
||||
return recipeType.getItemGas(itemstack) != null;
|
||||
}
|
||||
else if(recipeType.getFuelType() == MachineFuelType.DOUBLE)
|
||||
{
|
||||
return recipeType.hasRecipeForExtra(itemstack);
|
||||
}
|
||||
else if(recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
return InfuseRegistry.getObject(itemstack) != null && (infuseStored.type == null || infuseStored.type == InfuseRegistry.getObject(itemstack).type);
|
||||
@@ -634,13 +640,19 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
return false;
|
||||
}
|
||||
|
||||
if(recipeType.usesFuel())
|
||||
if(recipeType.getFuelType() == MachineFuelType.ADVANCED)
|
||||
{
|
||||
AdvancedMachineRecipe<?> recipe = recipeType.getRecipe(inventory.get(inputSlot), gasTank.getGasType());
|
||||
|
||||
return recipe != null && recipe.canOperate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick);
|
||||
|
||||
}
|
||||
else if(recipeType.getFuelType() == MachineFuelType.DOUBLE)
|
||||
{
|
||||
DoubleMachineRecipe<?> recipe = recipeType.getRecipe(inventory.get(inputSlot), inventory.get(4));
|
||||
|
||||
return recipe != null && recipe.canOperate(inventory, inputSlot, 4, outputSlot);
|
||||
}
|
||||
|
||||
if(recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
@@ -668,12 +680,18 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
return;
|
||||
}
|
||||
|
||||
if(recipeType.usesFuel())
|
||||
if(recipeType.getFuelType() == MachineFuelType.ADVANCED)
|
||||
{
|
||||
AdvancedMachineRecipe<?> recipe = recipeType.getRecipe(inventory.get(inputSlot), gasTank.getGasType());
|
||||
|
||||
recipe.operate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick);
|
||||
}
|
||||
else if(recipeType.getFuelType() == MachineFuelType.DOUBLE)
|
||||
{
|
||||
DoubleMachineRecipe<?> recipe = recipeType.getRecipe(inventory.get(inputSlot), inventory.get(4));
|
||||
|
||||
recipe.operate(inventory, inputSlot, 4, outputSlot);
|
||||
}
|
||||
else if(recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
InfusionInput input = new InfusionInput(infuseStored, inventory.get(inputSlot));
|
||||
|
||||
Reference in new issue
Block a user