Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
Rocket engine pollution fix (#885)
Browse files Browse the repository at this point in the history
* fix pollution amount

* slight code cleanup
  • Loading branch information
chochem authored May 21, 2024
1 parent 65f1647 commit 846c083
Showing 1 changed file with 6 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_BasicTank implements RecipeMapWorkable {

private boolean useFuel = false;
protected int pollMin, pollMax;

public GregtechRocketFuelGeneratorBase(final int aID, final String aName, final String aNameRegional,
Expand Down Expand Up @@ -210,36 +209,6 @@ public boolean isFluidInputAllowed(final FluidStack aFluid) {
@Override
public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {

// super.onPostTick(aBaseMetaTileEntity, aTick);

/*
* if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { int
* tFuelValue; if (this.mFluid == null) { if (aBaseMetaTileEntity.getUniversalEnergyStored() <
* this.maxEUOutput() + this.getMinimumStoredEU()) { this.mInventory[this.getStackDisplaySlot()] = null; } else
* { if (this.mInventory[this.getStackDisplaySlot()] == null) { this.mInventory[this.getStackDisplaySlot()] =
* new ItemStack(Blocks.fire, 1); }
* this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " +
* (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); } } else { tFuelValue
* = this.getFuelValue(this.mFluid); int tConsumed = this.consumedFluidPerOperation(this.mFluid); if (tFuelValue
* > 0 && tConsumed > 0 && this.mFluid.amount > tConsumed) { long tFluidAmountToUse = Math.min((long)
* (this.mFluid.amount / tConsumed), (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) /
* (long) tFuelValue); if (tFluidAmountToUse > 0L && aBaseMetaTileEntity
* .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) {
* PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); this.mFluid.amount =
* (int) ((long) this.mFluid.amount - tFluidAmountToUse * (long) tConsumed); } } } if
* (this.mInventory[this.getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() <
* this.maxEUOutput() * 20L + this.getMinimumStoredEU() &&
* GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) { tFuelValue =
* this.getFuelValue(this.mInventory[this.getInputSlot()]); if (tFuelValue > 0) { ItemStack tEmptyContainer =
* this.getEmptyContainer(this.mInventory[this.getInputSlot()]); if
* (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) {
* aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true);
* aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1);
* PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); } } } } if
* (aBaseMetaTileEntity.isServerSide()) { aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() &&
* aBaseMetaTileEntity .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU()); }
*/

if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && ((aTick % 10) == 0)) {
if (this.mFluid == null) {
if (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + this.getMinimumStoredEU())) {
Expand Down Expand Up @@ -279,7 +248,7 @@ public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long
if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) {
aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true);
aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1);
PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution());
PollutionUtils.addPollution(getBaseMetaTileEntity(), getPollution() / 2);
}
}
}
Expand Down Expand Up @@ -311,22 +280,14 @@ public int getFuelValue(final FluidStack aLiquid) {
}
FluidStack tLiquid;
final Collection<GT_Recipe> tRecipeList = this.getRecipeMap().getAllRecipes();
if (tRecipeList != null) {
// Logger.INFO("Step A");
for (final GT_Recipe tFuel : tRecipeList) {
// Logger.INFO("Step B");
if ((tLiquid = tFuel.mFluidInputs[0]) != null) {
// Logger.INFO("Step C");
if (aLiquid.isFluidEqual(tLiquid)) {
// Logger.INFO("Found some fuel?");
int aperOp = this.consumedFluidPerOperation(tLiquid);
int aConsume = (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * aperOp) / 100);
return aConsume;
}
for (final GT_Recipe tFuel : tRecipeList) {
if ((tLiquid = tFuel.mFluidInputs[0]) != null) {
if (aLiquid.isFluidEqual(tLiquid)) {
int aperOp = this.consumedFluidPerOperation(tLiquid);
return (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * aperOp) / 100);
}
}
}
// Logger.INFO("No Fuel Value | Valid? "+(aLiquid != null));
return 0;
}

Expand Down

0 comments on commit 846c083

Please sign in to comment.