aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/tileentities
diff options
context:
space:
mode:
authorquerns <33518699+querns@users.noreply.github.com>2024-07-28 20:29:35 -0500
committerGitHub <noreply@github.com>2024-07-29 08:29:35 +0700
commit278a156aae468fb79e335e535082fdb958cf7e1b (patch)
treebb1a3329ef63c48918bf68ec299eb36f687c143a /src/main/java/gregtech/common/tileentities
parenta9cea4920a7b1ef45bfe80d1b6f616c3d47884f9 (diff)
downloadGT5-Unofficial-278a156aae468fb79e335e535082fdb958cf7e1b.tar.gz
GT5-Unofficial-278a156aae468fb79e335e535082fdb958cf7e1b.tar.bz2
GT5-Unofficial-278a156aae468fb79e335e535082fdb958cf7e1b.zip
Adds vein type readout to multiblock miners (#2732)
* Adds vein type readout to multiblock miners (+metrics) * Spotless, fix weird import * Downgrades VP dep to latest non-pre version * Update dependencies.gradle * Refactor to eliminate dep on VisualProspecting --------- Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java57
1 files changed, 53 insertions, 4 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java
index 9c15d2b6eb..b60bac4f84 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java
@@ -59,6 +59,7 @@ import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.common.blocks.GT_Block_Ores_Abstract;
import gregtech.common.blocks.GT_TileEntity_Ores;
+import gregtech.crossmod.visualprospecting.GT_VisualProspecting_Database;
public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_DrillerBase
implements IMetricsExporter {
@@ -80,6 +81,9 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
/** Used to drive the drill's y-level in the UI. */
private int clientYHead = 0;
+ /** Contains the name of the currently mined vein. Used for driving metrics cover output. */
+ private String veinName = null;
+
GT_MetaTileEntity_OreDrillingPlantBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
@@ -93,6 +97,11 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
super.saveNBTData(aNBT);
aNBT.setInteger("chunkRadiusConfig", chunkRadiusConfig);
aNBT.setBoolean("replaceWithCobblestone", replaceWithCobblestone);
+ if (veinName != null) {
+ aNBT.setString("veinName", veinName);
+ } else if (aNBT.hasKey("veinName")) {
+ aNBT.removeTag("veinName");
+ }
}
@Override
@@ -104,6 +113,11 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
if (aNBT.hasKey("replaceWithCobblestone")) {
replaceWithCobblestone = aNBT.getBoolean("replaceWithCobblestone");
}
+ if (aNBT.hasKey("veinName")) {
+ veinName = aNBT.getString("veinName");
+ } else {
+ veinName = null;
+ }
}
private void adjustChunkRadius(boolean increase) {
@@ -163,6 +177,10 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
}
fillMineListIfEmpty(xDrill, yDrill, zDrill, xPipe, zPipe, yHead);
if (oreBlockPositions.isEmpty()) {
+ if (veinName == null) {
+ updateVeinNameFromVP(getDrillCoords());
+ }
+
switch (tryLowerPipeState()) {
case 2 -> {
mMaxProgresstime = 0;
@@ -285,7 +303,10 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
fillChunkMineList(yHead, yDrill);
if (oreBlockPositions.isEmpty()) {
GT_ChunkManager.releaseChunk((TileEntity) getBaseMetaTileEntity(), mCurrentChunk);
- if (!moveToNextChunk(xDrill >> 4, zDrill >> 4)) workState = STATE_UPWARD;
+ if (!moveToNextChunk(xDrill >> 4, zDrill >> 4)) {
+ workState = STATE_UPWARD;
+ updateVeinNameFromVP();
+ }
return true;
}
}
@@ -294,6 +315,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
private void createInitialWorkingChunk() {
mCurrentChunk = getTopLeftChunkCoords();
+ updateVeinNameFromVP();
if (mChunkLoadingEnabled) {
GT_ChunkManager.requestChunkLoad((TileEntity) getBaseMetaTileEntity(), mCurrentChunk);
mWorkChunkNeedsReload = false;
@@ -394,6 +416,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
GT_ChunkManager.releaseChunk((TileEntity) getBaseMetaTileEntity(), mCurrentChunk);
}
mCurrentChunk = null;
+ updateVeinNameFromVP();
}
private boolean moveToNextChunk(int centerX, int centerZ) {
@@ -425,12 +448,25 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
mCurrentChunk = null;
return false;
}
+
mCurrentChunk = new ChunkCoordIntPair(nextChunkX, nextChunkZ);
+ updateVeinNameFromVP();
+
GT_ChunkManager
.requestChunkLoad((TileEntity) getBaseMetaTileEntity(), new ChunkCoordIntPair(nextChunkX, nextChunkZ));
return true;
}
+ private void updateVeinNameFromVP() {
+ updateVeinNameFromVP(mCurrentChunk);
+ }
+
+ private void updateVeinNameFromVP(@NotNull ChunkCoordIntPair coords) {
+ veinName = GT_VisualProspecting_Database
+ .getVeinName(getBaseMetaTileEntity().getWorld().provider.dimensionId, coords)
+ .orElse(null);
+ }
+
@Override
protected boolean checkHatches() {
return !mMaintenanceHatches.isEmpty() && !mInputHatches.isEmpty()
@@ -635,11 +671,20 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
.setEnabled(
widget -> getBaseMetaTileEntity().isActive() && clientCurrentChunk > 0
&& workState == STATE_AT_BOTTOM))
+ .widget(
+ new TextWidget()
+ .setStringSupplier(
+ () -> EnumChatFormatting.GRAY
+ + StatCollector.translateToLocalFormatted("GT5U.gui.text.drill_current_vein", veinName))
+ .setTextAlignment(Alignment.CenterLeft)
+ .setEnabled(
+ widget -> veinName != null && (workState == STATE_AT_BOTTOM || workState == STATE_DOWNWARD)))
.widget(new FakeSyncWidget.IntegerSyncer(oreBlockPositions::size, (newInt) -> clientOreListSize = newInt))
.widget(new FakeSyncWidget.IntegerSyncer(this::getTotalChunkCount, (newInt) -> clientTotalChunks = newInt))
.widget(new FakeSyncWidget.IntegerSyncer(this::getChunkNumber, (newInt) -> clientCurrentChunk = newInt))
.widget(new FakeSyncWidget.IntegerSyncer(() -> workState, (newInt) -> workState = newInt))
- .widget(new FakeSyncWidget.IntegerSyncer(this::getYHead, (newInt) -> clientYHead = newInt));
+ .widget(new FakeSyncWidget.IntegerSyncer(this::getYHead, (newInt) -> clientYHead = newInt))
+ .widget(new FakeSyncWidget.StringSyncer(() -> veinName, (newString) -> veinName = newString));
}
@Override
@@ -719,12 +764,16 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
StatCollector.translateToLocalFormatted(
"GT5U.gui.text.drill_chunks_left",
GT_Utility.formatNumbers(getChunkNumber()),
- GT_Utility.formatNumbers(getTotalChunkCount())));
+ GT_Utility.formatNumbers(getTotalChunkCount())),
+ veinName == null ? ""
+ : StatCollector.translateToLocalFormatted("GT5U.gui.text.drill_current_vein", veinName));
case STATE_DOWNWARD -> ImmutableList.of(
StatCollector.translateToLocalFormatted(
"GT5U.gui.text.drill_ores_left_layer",
getYHead(),
- GT_Utility.formatNumbers(oreBlockPositions.size())));
+ GT_Utility.formatNumbers(oreBlockPositions.size())),
+ veinName == null ? ""
+ : StatCollector.translateToLocalFormatted("GT5U.gui.text.drill_current_vein", veinName));
case STATE_UPWARD, STATE_ABORT -> ImmutableList
.of(StatCollector.translateToLocal("GT5U.gui.text.retracting_pipe"));