mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 15:46:01 +00:00
Port ToMe25's PR for sawing factories (#5383)
* Port remainder of #5327 implementing #5236 sawing factories * Add missing blockstate files for sawing factories * Inline helper method * Revert a bit of minor formatting changes to make dif easier to read * remove redundant mcmeta for sawing front textures * de-dupe sawmill factory textures (left+right are the same)
This commit is contained in:
1 parent
0eb455b882
commit
da71637053
49 files changed
+408
-17
No files matched your search
@@ -15,6 +15,7 @@ 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.ChanceMachineRecipe;
|
||||
import mekanism.common.recipe.machines.DoubleMachineRecipe;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
||||
@@ -54,7 +55,8 @@ public interface IFactory {
|
||||
enum MachineFuelType {
|
||||
BASIC,
|
||||
ADVANCED,
|
||||
DOUBLE
|
||||
DOUBLE,
|
||||
CHANCE
|
||||
}
|
||||
|
||||
enum RecipeType implements IStringSerializable {
|
||||
@@ -71,7 +73,9 @@ public interface IFactory {
|
||||
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);
|
||||
Recipe.METALLURGIC_INFUSER),
|
||||
SAWING("Sawing", "sawmill", MachineType.PRECISION_SAWMILL, MachineFuelType.CHANCE, false,
|
||||
Recipe.PRECISION_SAWMILL);
|
||||
|
||||
private String name;
|
||||
private SoundEvent sound;
|
||||
@@ -129,6 +133,14 @@ public interface IFactory {
|
||||
return getRecipe(new DoubleMachineInput(input, extra));
|
||||
}
|
||||
|
||||
public ChanceMachineRecipe getChanceRecipe(ItemStackInput input) {
|
||||
return RecipeHandler.getChanceRecipe(input, recipe.get());
|
||||
}
|
||||
|
||||
public ChanceMachineRecipe getChanceRecipe(ItemStack input) {
|
||||
return getChanceRecipe(new ItemStackInput(input));
|
||||
}
|
||||
|
||||
public MetallurgicInfuserRecipe getRecipe(InfusionInput input) {
|
||||
return RecipeHandler.getMetallurgicInfuserRecipe(input);
|
||||
}
|
||||
@@ -143,6 +155,8 @@ public interface IFactory {
|
||||
return getRecipe(slotStack, gasType);
|
||||
} else if (fuelType == MachineFuelType.DOUBLE) {
|
||||
return getRecipe(slotStack, extraStack);
|
||||
} else if (fuelType == MachineFuelType.CHANCE) {
|
||||
return getChanceRecipe(slotStack);
|
||||
} else if (this == INFUSING) {
|
||||
if (infuse.type != null) {
|
||||
return RecipeHandler.getMetallurgicInfuserRecipe(new InfusionInput(infuse, slotStack));
|
||||
|
||||
@@ -12,14 +12,18 @@ public abstract class ChanceMachineRecipe<RECIPE extends ChanceMachineRecipe<REC
|
||||
super(input, output);
|
||||
}
|
||||
|
||||
public boolean inputMatches(NonNullList<ItemStack> inventory, int inputIndex) {
|
||||
return getInput().useItemStackFromInventory(inventory, inputIndex, false);
|
||||
}
|
||||
|
||||
public boolean canOperate(NonNullList<ItemStack> inventory, int inputIndex, int primaryIndex, int secondaryIndex) {
|
||||
return getInput().useItemStackFromInventory(inventory, inputIndex, false) && getOutput()
|
||||
return inputMatches(inventory, inputIndex) && getOutput()
|
||||
.applyOutputs(inventory, primaryIndex, secondaryIndex, false);
|
||||
}
|
||||
|
||||
public void operate(NonNullList<ItemStack> inventory) {
|
||||
if (getInput().useItemStackFromInventory(inventory, 0, true)) {
|
||||
getOutput().applyOutputs(inventory, 2, 4, true);
|
||||
public void operate(NonNullList<ItemStack> inventory, int inputIndex, int primaryIndex, int secondaryIndex) {
|
||||
if (getInput().useItemStackFromInventory(inventory, inputIndex, true)) {
|
||||
getOutput().applyOutputs(inventory, primaryIndex, secondaryIndex, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import mekanism.common.recipe.machines.ChanceMachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ChanceOutput;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.prefab.TileEntityBasicMachine;
|
||||
import mekanism.common.tile.prefab.TileEntityUpgradeableMachine;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe<RECIPE>> extends
|
||||
TileEntityBasicMachine<ItemStackInput, ChanceOutput, RECIPE> {
|
||||
TileEntityUpgradeableMachine<ItemStackInput, ChanceOutput, RECIPE> {
|
||||
|
||||
private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate",
|
||||
"getMaxEnergy", "getEnergyNeeded"};
|
||||
@@ -47,6 +47,17 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void upgradeInventory(TileEntityFactory factory) {
|
||||
//Chance Machine
|
||||
factory.configComponent.getOutputs(TransmissionType.ITEM).get(2).availableSlots = new int[]{4, 8, 9, 10};
|
||||
|
||||
factory.inventory.set(5, inventory.get(0));
|
||||
factory.inventory.set(1, inventory.get(1));
|
||||
factory.inventory.set(5 + 3, inventory.get(2));
|
||||
factory.inventory.set(0, inventory.get(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
@@ -103,7 +114,7 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
|
||||
@Override
|
||||
public void operate(RECIPE recipe) {
|
||||
recipe.operate(inventory);
|
||||
recipe.operate(inventory, 0, 2, 4);
|
||||
|
||||
markDirty();
|
||||
ejectorComponent.outputItems();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Arrays;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
@@ -36,6 +37,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.ChanceMachineRecipe;
|
||||
import mekanism.common.recipe.machines.DoubleMachineRecipe;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
||||
@@ -358,6 +360,16 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades());
|
||||
secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType);
|
||||
|
||||
if (type.getFuelType() == MachineFuelType.CHANCE) {
|
||||
SideData data = configComponent.getOutputs(TransmissionType.ITEM).get(2);
|
||||
//Append the "extra" slot to the available slots
|
||||
data.availableSlots = Arrays.copyOf(data.availableSlots, data.availableSlots.length + 1);
|
||||
data.availableSlots[data.availableSlots.length - 1] = 4;
|
||||
|
||||
ejectorComponent.trackers.put(TransmissionType.ITEM,
|
||||
Arrays.copyOf(ejectorComponent.trackers.get(TransmissionType.ITEM), data.availableSlots.length));
|
||||
}
|
||||
|
||||
for (Upgrade upgrade : upgradeComponent.getSupportedTypes()) {
|
||||
recalculateUpgradables(upgrade);
|
||||
}
|
||||
@@ -491,10 +503,12 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
return true;
|
||||
} else if (tier == FactoryTier.ADVANCED && slotID >= 10 && slotID <= 14) {
|
||||
return true;
|
||||
} else {
|
||||
return tier == FactoryTier.ELITE && slotID >= 12 && slotID <= 18;
|
||||
} else if (tier == FactoryTier.ELITE && slotID >= 12 && slotID <= 18) {
|
||||
return true;
|
||||
} else if (recipeType.getFuelType() == MachineFuelType.CHANCE && slotID == 4) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -600,6 +614,15 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
cachedRecipe[process] = recipe;
|
||||
|
||||
return recipe != null && recipe.canOperate(inventory, inputSlot, 4, outputSlot);
|
||||
} else if (recipeType.getFuelType() == MachineFuelType.CHANCE) {
|
||||
if (cachedRecipe[process] instanceof ChanceMachineRecipe && ((ChanceMachineRecipe) cachedRecipe[process])
|
||||
.inputMatches(inventory, inputSlot)) {
|
||||
return ((ChanceMachineRecipe) cachedRecipe[process]).canOperate(inventory, inputSlot, outputSlot, 4);
|
||||
}
|
||||
ChanceMachineRecipe<?> recipe = recipeType.getChanceRecipe(inventory.get(inputSlot));
|
||||
cachedRecipe[process] = recipe;
|
||||
|
||||
return recipe != null && recipe.canOperate(inventory, inputSlot, outputSlot, 4);
|
||||
}
|
||||
|
||||
if (recipeType == RecipeType.INFUSING) {
|
||||
@@ -654,6 +677,11 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
DoubleMachineRecipe<?> recipe = (DoubleMachineRecipe<?>) cachedRecipe[process];
|
||||
|
||||
recipe.operate(inventory, inputSlot, 4, outputSlot);
|
||||
} else if (recipeType.getFuelType() == MachineFuelType.CHANCE
|
||||
&& cachedRecipe[process] instanceof ChanceMachineRecipe) {
|
||||
ChanceMachineRecipe<?> recipe = (ChanceMachineRecipe<?>) cachedRecipe[process];
|
||||
|
||||
recipe.operate(inventory, inputSlot, outputSlot, 4);
|
||||
} else if (recipeType == RecipeType.INFUSING && cachedRecipe[process] instanceof MetallurgicInfuserRecipe) {
|
||||
MetallurgicInfuserRecipe recipe = (MetallurgicInfuserRecipe) cachedRecipe[process];
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package mekanism.common.tile.prefab;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.base.ITierUpgradeable;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
@@ -39,7 +39,7 @@ public abstract class TileEntityUpgradeableMachine<INPUT extends MachineInput<IN
|
||||
world.setBlockState(getPos(), MekanismBlocks.MachineBlock.getStateFromMeta(5), 3);
|
||||
|
||||
TileEntityFactory factory = (TileEntityFactory) world.getTileEntity(getPos());
|
||||
IFactory.RecipeType type = IFactory.RecipeType.getFromMachine(getBlockType(), getBlockMetadata());
|
||||
RecipeType type = RecipeType.getFromMachine(getBlockType(), getBlockMetadata());
|
||||
|
||||
//Basic
|
||||
factory.facing = facing;
|
||||
|
||||
Reference in new issue
Block a user