aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2022-08-02 17:34:54 +0900
committerGitHub <noreply@github.com>2022-08-02 10:34:54 +0200
commit50a5f9f5df5fc7d3690d9c8b3bfff67e69f4df73 (patch)
treefed6ac3684989ef619876e99159e5467caece595 /src/main
parent89bf9ba2b6fe2e7c8217f78389318ec5140be0c5 (diff)
downloadGT5-Unofficial-50a5f9f5df5fc7d3690d9c8b3bfff67e69f4df73.tar.gz
GT5-Unofficial-50a5f9f5df5fc7d3690d9c8b3bfff67e69f4df73.tar.bz2
GT5-Unofficial-50a5f9f5df5fc7d3690d9c8b3bfff67e69f4df73.zip
Fusion fixes (#1181)
* Allow storing `long` energy * Fix hardcoded voltage limit for searching recipe * Fix reactor might run without consuming energy * Fix weird charging rate limit
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java26
-rw-r--r--src/main/java/gregtech/common/gui/GT_GUIContainer_FusionReactor.java6
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java20
3 files changed, 41 insertions, 11 deletions
diff --git a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java
index a6a6064976..c0c2863521 100644
--- a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java
+++ b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java
@@ -26,6 +26,8 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
mInput = 0,
mID = 0,
mDisplayErrorCode = 0;
+ public long mEnergyLong = 0,
+ mStorageLong = 0;
private int oActive = 0,
oMaxProgressTime = 0,
oProgressTime = 0,
@@ -37,6 +39,8 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
oInput = 0,
oID = 0,
oDisplayErrorCode = 0;
+ private long oEnergyLong = 0,
+ oStorageLong = 0;
protected int mTimer = 0;
@@ -75,7 +79,9 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null)
return;
mStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getEUCapacity());
+ mStorageLong = mTileEntity.getEUCapacity();
mEnergy = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredEU());
+ mEnergyLong = mTileEntity.getStoredEU();
mSteamStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getSteamCapacity());
mSteam = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredSteam());
mOutput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getOutputVoltage());
@@ -127,6 +133,14 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
player.sendProgressBarUpdate(this, 19, mSteamStorage & 65535);
player.sendProgressBarUpdate(this, 20, mSteamStorage >>> 16);
}
+ if (mTimer % 500 == 10 || oEnergyLong != mEnergyLong) {
+ player.sendProgressBarUpdate(this, 21, (int) mEnergyLong);
+ player.sendProgressBarUpdate(this, 22, (int) (mEnergyLong >>> 32));
+ }
+ if (mTimer % 500 == 10 || oStorageLong != mStorageLong) {
+ player.sendProgressBarUpdate(this, 23, (int) mStorageLong);
+ player.sendProgressBarUpdate(this, 24, (int) (mStorageLong >>> 32));
+ }
}
oID = mID;
@@ -198,6 +212,18 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
case 20:
mSteamStorage = mSteamStorage & 0x0000ffff | value << 16;
break;
+ case 21:
+ mEnergyLong = mEnergyLong & 0xffffffff00000000L | value & 0x00000000ffffffffL;
+ break;
+ case 22:
+ mEnergyLong = mEnergyLong & 0x00000000ffffffffL | (long) value << 32;
+ break;
+ case 23:
+ mStorageLong = mStorageLong & 0xffffffff00000000L | value & 0x00000000ffffffffL;
+ break;
+ case 24:
+ mStorageLong = mStorageLong & 0x00000000ffffffffL | (long) value << 32;
+ break;
}
}
diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_FusionReactor.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_FusionReactor.java
index d6fd5da3ce..55c144356a 100644
--- a/src/main/java/gregtech/common/gui/GT_GUIContainer_FusionReactor.java
+++ b/src/main/java/gregtech/common/gui/GT_GUIContainer_FusionReactor.java
@@ -43,8 +43,10 @@ public class GT_GUIContainer_FusionReactor extends GT_GUIContainerMetaTile_Machi
fontRendererObj.drawString("320,000,000 EU", 50, 155, 0x00ff0000);
else if(this.mContainer.mEnergy > 640000000 && this.mContainer.mEnergy < 640010000)
fontRendererObj.drawString("640,000,000 EU", 50, 155, 0x00ff0000);
+ else if(this.mContainer.mEnergyLong > 5120000000L && this.mContainer.mEnergyLong < 5120080000L)
+ fontRendererObj.drawString("5,120,000,000 EU", 50, 155, 0x00ff0000);
else
- fontRendererObj.drawString(GT_Utility.formatNumbers(this.mContainer.mEnergy) + " EU", 50, 155, 0x00ff0000);
+ fontRendererObj.drawString(GT_Utility.formatNumbers(this.mContainer.mEnergyLong) + " EU", 50, 155, 0x00ff0000);
}
}
@@ -55,7 +57,7 @@ public class GT_GUIContainer_FusionReactor extends GT_GUIContainerMetaTile_Machi
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
if (this.mContainer != null) {
- double tScale = (double) this.mContainer.mEnergy / (double) this.mContainer.mStorage;
+ double tScale = (double) this.mContainer.mEnergyLong / (double) this.mContainer.mStorageLong;
drawTexturedModalRect(x + 5, y + 156, 0, 251, Math.min(147, (int) (tScale * 148)), 5);
}
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java
index c203e49346..e917f7b1a6 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java
@@ -106,7 +106,7 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity
}
};
public GT_Recipe mLastRecipe;
- public int mEUStore;
+ public long mEUStore;
static {
Textures.BlockIcons.setCasingTextureForId(52,
@@ -280,9 +280,9 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity
FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]);
GT_Recipe tRecipe;
- tRecipe = GT_Recipe.GT_Recipe_Map.sFusionRecipes.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, GT_Values.V[8], tFluids);
+ tRecipe = GT_Recipe.GT_Recipe_Map.sFusionRecipes.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, GT_Values.V[tier()], tFluids);
if (tRecipe == null) {
- tRecipe = GT_Recipe.GT_Recipe_Map.sComplexFusionRecipes.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, GT_Values.V[8], tFluids);
+ tRecipe = GT_Recipe.GT_Recipe_Map.sComplexFusionRecipes.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, GT_Values.V[tier()], tFluids);
}
if ((tRecipe == null && !mRunningOnLoad) || (maxEUStore() < tRecipe.mSpecialValue)) {
@@ -331,7 +331,7 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity
if (mEfficiency < 0)
mEfficiency = 0;
if (mRunningOnLoad && checkMachine(aBaseMetaTileEntity, mInventory[1])) {
- this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU();
+ this.mEUStore = aBaseMetaTileEntity.getStoredEU();
checkRecipe(mInventory[1]);
}
if (--mUpdate == 0 || --mStartUpCheck == 0) {
@@ -339,12 +339,14 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity
}
if (mStartUpCheck < 0) {
if (mMachine) {
+ this.mEUStore = aBaseMetaTileEntity.getStoredEU();
if (this.mEnergyHatches != null) {
for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches)
if (isValidMetaTileEntity(tHatch)) {
- if (aBaseMetaTileEntity.getStoredEU() + (2048 * tierOverclock()) < maxEUStore()
- && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(2048 * tierOverclock(), false)) {
- aBaseMetaTileEntity.increaseStoredEnergyUnits(2048 * tierOverclock(), true);
+ long energyToMove = GT_Values.V[tier()] / 16;
+ if (aBaseMetaTileEntity.getStoredEU() + energyToMove < maxEUStore()
+ && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(energyToMove, false)) {
+ aBaseMetaTileEntity.increaseStoredEnergyUnits(energyToMove, true);
}
}
}
@@ -369,7 +371,7 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity
} catch (Exception ignored) {
}
}
- this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU();
+ this.mEUStore = aBaseMetaTileEntity.getStoredEU();
if (aBaseMetaTileEntity.isAllowedToWork())
checkRecipe(mInventory[1]);
}
@@ -377,7 +379,7 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity
if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) {
turnCasingActive(mMaxProgresstime > 0);
if (aBaseMetaTileEntity.isAllowedToWork()) {
- this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU();
+ this.mEUStore = aBaseMetaTileEntity.getStoredEU();
if (checkRecipe(mInventory[1])) {
if (this.mEUStore < this.mLastRecipe.mSpecialValue - this.mEUt) {
criticalStopMachine();