Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented throttleable Large turbine #1604

Closed
wants to merge 13 commits into from
69 changes: 57 additions & 12 deletions src/main/java/gregtech/api/capability/impl/FuelRecipeLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public Collection<IFuelInfo> getFuels() {
if (fuelInfo == null) {
fuelInfo = new FluidFuelInfo(tankContents, fuelRemaining, fuelCapacity, amountPerRecipe, fuelBurnTime);
fuels.put(tankContents.getUnlocalizedName(), fuelInfo);
}
else {
} else {
fuelInfo.addFuelRemaining(fuelRemaining);
fuelInfo.addFuelBurnTime(fuelBurnTime);
}
Expand All @@ -99,10 +98,10 @@ public Collection<IFuelInfo> getFuels() {

@Override
public <T> T getCapability(Capability<T> capability) {
if(capability == GregtechTileCapabilities.CAPABILITY_CONTROLLABLE) {
if (capability == GregtechTileCapabilities.CAPABILITY_CONTROLLABLE) {
return GregtechTileCapabilities.CAPABILITY_CONTROLLABLE.cast(this);
}
if(capability == GregtechCapabilities.CAPABILITY_FUELABLE) {
if (capability == GregtechCapabilities.CAPABILITY_FUELABLE) {
return GregtechCapabilities.CAPABILITY_FUELABLE.cast(this);
}
return null;
Expand All @@ -114,10 +113,14 @@ public void update() {
if (workingEnabled) {
if (recipeDurationLeft > 0) {
if (energyContainer.get().getEnergyCanBeInserted() >=
recipeOutputVoltage || shouldVoidExcessiveEnergy()) {
energyContainer.get().addEnergy(recipeOutputVoltage);
if (--this.recipeDurationLeft == 0) {
this.wasActiveAndNeedsUpdate = true;
recipeOutputVoltage || shouldVoidExcessiveEnergy()) {
if (canProduceEnergy()) {
energyContainer.get().addEnergy(recipeOutputVoltage);
}
if (canConsumeFuel()) {
if (--this.recipeDurationLeft == 0) {
this.wasActiveAndNeedsUpdate = true;
}
}
}
}
Expand All @@ -132,7 +135,7 @@ public void update() {
}

protected boolean isReadyForRecipes() {
return true;
return true;
}

protected boolean shouldVoidExcessiveEnergy() {
Expand Down Expand Up @@ -208,11 +211,53 @@ public long getMaxVoltage() {
}

protected int calculateFuelAmount(FuelRecipe currentRecipe) {
return currentRecipe.getRecipeFluid().amount * getVoltageMultiplier(getMaxVoltage(), currentRecipe.getMinVoltage());
return (int) (currentRecipe.getRecipeFluid().amount *
getVoltageMultiplier(getMaxVoltage(), currentRecipe.getMinVoltage()) *
getFuelConsumptionMultiplier());
}

protected int calculateRecipeDuration(FuelRecipe currentRecipe) {
return currentRecipe.getDuration();
return (int) (currentRecipe.getDuration() * getRecipeDurationMultiplier());
}

public FuelRecipe getCurrentRecipe() {
return this.previousRecipe;
}

/**
* @return if the recipe duration should get decreased during the current tick does not effect energy production.
*/

public Boolean canConsumeFuel() {
return true;
}

/**
* @return if energy should be produced during the current tick does not effect fuel consumption.
*/
public Boolean canProduceEnergy() {
return true;
}

/**
* @return the multiplier applied to fuel consumption
*/
public double getFuelConsumptionMultiplier() {
return 1.0;
}

/**
* @return the multiplier applied to recipe duration
*/
public double getRecipeDurationMultiplier() {
return 1.0f;
}

/**
* @return the multiplier applied to voltage
*/
public double getEnergyEfficiency() {
return 1.0f;
}

/**
Expand All @@ -221,7 +266,7 @@ protected int calculateRecipeDuration(FuelRecipe currentRecipe) {
* @return recipe's output voltage
*/
protected long startRecipe(FuelRecipe currentRecipe, int fuelAmountUsed, int recipeDuration) {
return getMaxVoltage();
return (long) (getMaxVoltage() * getEnergyEfficiency());
}

public static int getVoltageMultiplier(long maxVoltage, long minVoltage) {
Expand Down
Loading