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

Commit

Permalink
Merge remote-tracking branch 'HoleFish/compactFusion' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Jan 29, 2024
2 parents ed9b0f7 + 6b03fac commit f741813
Showing 1 changed file with 26 additions and 28 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 @@ -501,14 +499,12 @@ public int getChunkZ() {
private boolean addEnergyInjector(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) {
IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) {
GT_MetaTileEntity_Hatch_Energy tHatch = (GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity;
if (tHatch.mTier < hatchTier()) return false;
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy tHatch) {
if (tHatch.getTierForStructure() < hatchTier()) return false;
tHatch.updateTexture(aBaseCasingIndex);
return mEnergyHatches.add(tHatch);
} else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) {
GT_MetaTileEntity_Hatch_EnergyMulti tHatch = (GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity;
if (tHatch.mTier < hatchTier()) return false;
} else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti tHatch) {
if (tHatch.getTierForStructure() < hatchTier()) return false;
tHatch.updateTexture(aBaseCasingIndex);
return eEnergyMulti.add(tHatch);
}
Expand All @@ -518,19 +514,21 @@ private boolean addEnergyInjector(IGregTechTileEntity aBaseMetaTileEntity, int a
private boolean addFluidIO(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) {
IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch hatch) {
hatch.updateTexture(aBaseCasingIndex);
hatch.updateCraftingIcon(this.getMachineCraftingIcon());
}
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input tInput) {
if (tInput.getTierForStructure() < hatchTier()) return false;
tInput.updateTexture(aBaseCasingIndex);
tInput.mRecipeMap = getRecipeMap();
return mInputHatches.add(tInput);
}
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output tOutput) {
if (tOutput.getTierForStructure() < hatchTier()) return false;
tOutput.updateTexture(aBaseCasingIndex);
return mOutputHatches.add(tOutput);
}
if (aMetaTileEntity instanceof IDualInputHatch tInput) {
tInput.updateTexture(aBaseCasingIndex);
tInput.updateCraftingIcon(this.getMachineCraftingIcon());
return mDualInputHatches.add(tInput);
}
return false;
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 f741813

Please sign in to comment.