mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
* First pass reformatting code to be more readable (common still not done) * Replace google common collect calls with Java calls where possible * Remove a bunch of unnecessary parenthesis leaving clarifying ones * Add some missing @Nonnull annotations * Fix checking wrong type * Remove unnecessary continue/return statements and simplify comparision check * Pass exception instead of directly printing stack trace * Work on cleaning up common, through config so far * Work on cleaning up common, through integration so far * Work on cleaning up common, through network so far * Work on cleaning up common, through tier so far * Remove empty constructors that get created by default anyways * Work on cleaning up common, through transmitters so far * Work on cleaning up common, through utils so far * Finish cleaning up spacing for common
69 lines
2.3 KiB
Java
69 lines
2.3 KiB
Java
package mekanism.common.tile;
|
|
|
|
import java.util.Map;
|
|
import mekanism.api.gas.Gas;
|
|
import mekanism.api.gas.GasStack;
|
|
import mekanism.api.gas.IGasItem;
|
|
import mekanism.common.block.states.BlockStateMachine.MachineType;
|
|
import mekanism.common.recipe.RecipeHandler.Recipe;
|
|
import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
|
import mekanism.common.recipe.machines.PurificationRecipe;
|
|
import mekanism.common.tile.prefab.TileEntityAdvancedElectricMachine;
|
|
import mekanism.common.util.GasUtils;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMachine<PurificationRecipe> {
|
|
|
|
public TileEntityPurificationChamber() {
|
|
super("purification", "PurificationChamber", MachineType.PURIFICATION_CHAMBER.getStorage(), MachineType.PURIFICATION_CHAMBER.getUsage(),
|
|
BASE_TICKS_REQUIRED, BASE_GAS_PER_TICK);
|
|
}
|
|
|
|
@Override
|
|
public Map<AdvancedMachineInput, PurificationRecipe> getRecipes() {
|
|
return Recipe.PURIFICATION_CHAMBER.get();
|
|
}
|
|
|
|
@Override
|
|
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer) {
|
|
if (canReceiveGas(side, stack.getGas())) {
|
|
return gasTank.receive(stack, doTransfer);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public boolean canReceiveGas(EnumFacing side, Gas type) {
|
|
return gasTank.canReceive(type) && isValidGas(type);
|
|
}
|
|
|
|
@Override
|
|
public void handleSecondaryFuel() {
|
|
ItemStack itemStack = inventory.get(1);
|
|
if (!itemStack.isEmpty() && gasTank.getNeeded() > 0 && itemStack.getItem() instanceof IGasItem) {
|
|
GasStack gas = ((IGasItem) itemStack.getItem()).getGas(itemStack);
|
|
if (gas != null) {
|
|
GasStack removed = GasUtils.removeGas(itemStack, gas.getGas(), gasTank.getNeeded());
|
|
gasTank.receive(removed, true);
|
|
return;
|
|
}
|
|
}
|
|
super.handleSecondaryFuel();
|
|
}
|
|
|
|
@Override
|
|
public boolean isValidGas(Gas gas) {
|
|
return Recipe.PURIFICATION_CHAMBER.containsRecipe(gas);
|
|
}
|
|
|
|
@Override
|
|
public boolean upgradeableSecondaryEfficiency() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean useStatisticalMechanics() {
|
|
return true;
|
|
}
|
|
} |