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

Commit

Permalink
fix energy consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
HoleFish committed Jan 28, 2024
1 parent 031afbb commit 1b5ef25
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import static gregtech.api.util.GT_StructureUtility.ofFrame;
import static gregtech.api.util.GT_Utility.filterValidMTEs;

import java.util.List;

import javax.annotation.Nullable;

import net.minecraft.block.Block;
Expand Down Expand Up @@ -41,6 +43,7 @@
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.interfaces.tileentity.IOverclockDescriptionProvider;
import gregtech.api.logic.ProcessingLogic;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
Expand Down Expand Up @@ -274,27 +277,22 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
}
if (mStartUpCheck < 0) {
if (mMachine) {
long mStoredEUt = aBaseMetaTileEntity.getStoredEU();
long energyToMove = getSingleHatchPower();
if (this.mEnergyHatches != null) {
for (GT_MetaTileEntity_Hatch_Energy tHatch : filterValidMTEs(mEnergyHatches)) {
if (aBaseMetaTileEntity.getStoredEU() + energyToMove < maxEUStore()
&& tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(energyToMove, false)) {
aBaseMetaTileEntity.increaseStoredEnergyUnits(energyToMove, true);
}
}
if (aBaseMetaTileEntity.getStoredEU() <= 0 && mMaxProgresstime > 0) {
criticalStopMachine();
}
if (this.eEnergyMulti != null) {
for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) {
if (aBaseMetaTileEntity.getStoredEU() + energyToMove < maxEUStore()
&& tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(energyToMove, false)) {
aBaseMetaTileEntity.increaseStoredEnergyUnits(energyToMove, true);
}

long energyLimit = getSingleHatchPower();
List<GT_MetaTileEntity_Hatch> hatches = getExoticAndNormalEnergyHatchList();
for (GT_MetaTileEntity_Hatch hatch : filterValidMTEs(hatches)) {
long consumableEnergy = Math.min(hatch.getEUVar(), energyLimit);
long receivedEnergy = Math
.min(consumableEnergy, maxEUStore() - aBaseMetaTileEntity.getStoredEU());
if (receivedEnergy > 0) {
hatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(receivedEnergy, false);
aBaseMetaTileEntity.increaseStoredEnergyUnits(receivedEnergy, true);
}
}
if (mStoredEUt <= 0 && mMaxProgresstime > 0) {
criticalStopMachine();
}

if (mMaxProgresstime > 0) {
this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(-lEUt, true);
if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) {
Expand Down Expand Up @@ -586,7 +584,7 @@ public String[] getInfoData() {
+ EnumChatFormatting.RESET,
StatCollector.translateToLocal("GT5U.fusion.req") + ": "
+ EnumChatFormatting.RED
+ GT_Utility.formatNumbers(-lEUt)
+ GT_Utility.formatNumbers(lEUt)
+ EnumChatFormatting.RESET
+ "EU/t",
StatCollector.translateToLocal("GT5U.multiblock.energy") + ": "
Expand Down

0 comments on commit 1b5ef25

Please sign in to comment.