diff --git a/src/main/java/gregtech/api/capability/IMiner.java b/src/main/java/gregtech/api/capability/IMiner.java index 4b82046f399..837ee9fd161 100644 --- a/src/main/java/gregtech/api/capability/IMiner.java +++ b/src/main/java/gregtech/api/capability/IMiner.java @@ -1,6 +1,22 @@ package gregtech.api.capability; +import gregtech.common.mui.widget.ScrollableTextWidget; + +import net.minecraftforge.items.IItemHandlerModifiable; + import codechicken.lib.vec.Cuboid6; +import com.cleanroommc.modularui.drawable.UITexture; +import com.cleanroommc.modularui.drawable.text.RichText; +import com.cleanroommc.modularui.utils.Alignment; +import com.cleanroommc.modularui.value.sync.PanelSyncManager; +import com.cleanroommc.modularui.value.sync.SyncHandlers; +import com.cleanroommc.modularui.widget.Widget; +import com.cleanroommc.modularui.widgets.layout.Flow; +import com.cleanroommc.modularui.widgets.layout.Grid; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; public interface IMiner { @@ -19,4 +35,31 @@ default boolean drainFluid(boolean simulate) { default int getWorkingArea(int maximumRadius) { return maximumRadius * 2 + 1; } + + default Widget createMinerWidgets(@NotNull PanelSyncManager panelSyncManager, + @NotNull IItemHandlerModifiable inventory, int inventorySize, + @NotNull UITexture textDisplayBackground, + @NotNull Consumer textBuilder) { + int rowSize = (int) Math.sqrt(inventorySize); + panelSyncManager.registerSlotGroup("export_items", rowSize); + + return Flow.row() + .coverChildren() + .child(new ScrollableTextWidget() + .size(105 - 3 * 2, 75 - 3 * 2) + .autoUpdate(true) + .alignment(Alignment.TopLeft) + .textBuilder(textBuilder) + .background(textDisplayBackground.asIcon() + .margin(-3))) + .child(new Grid() + .marginLeft(6) + .minElementMargin(0) + .minColWidth(18) + .minRowHeight(18) + .mapTo(rowSize, inventorySize, index -> new ItemSlot() + .slot(SyncHandlers.itemSlot(inventory, index) + .slotGroup("export_items") + .accessibility(false, true)))); + } } diff --git a/src/main/java/gregtech/api/mui/GTGuiTheme.java b/src/main/java/gregtech/api/mui/GTGuiTheme.java index aa7b579797f..01b5084ec2c 100644 --- a/src/main/java/gregtech/api/mui/GTGuiTheme.java +++ b/src/main/java/gregtech/api/mui/GTGuiTheme.java @@ -71,8 +71,7 @@ private static String gregtech(String s) { public static final GTGuiTheme BRONZE = templateBuilder(Names.BRONZE) .parent(Names.STANDARD) .panel(IDs.BRONZE_BACKGROUND) - // .itemSlot(GTGuiTextures.IDs.BRONZE_SLOT) - // .fluidSlot(GTGuiTextures.IDs.BRONZE_SLOT) + .itemSlot(GTGuiTextures.IDs.BRONZE_SLOT) .displayBackground(IDs.DISPLAY_BRONZE) .button(IDs.BRONZE_BUTTON) .color(Colors.BRONZE) @@ -84,8 +83,7 @@ private static String gregtech(String s) { .parent(Names.STANDARD) .panel(IDs.STEEL_BACKGROUND) .textColor(Color.WHITE.darker(1)) - // .itemSlot(GTGuiTextures.IDs.STEEL_SLOT) - // .fluidSlot(GTGuiTextures.IDs.STEEL_SLOT) + .itemSlot(GTGuiTextures.IDs.STEEL_SLOT) .displayBackground(IDs.DISPLAY_STEEL) .button(IDs.STEEL_BUTTON) .simpleToggleButton(IDs.STEEL_BUTTON, IDs.STEEL_BUTTON_SELECTED, @@ -98,8 +96,7 @@ private static String gregtech(String s) { .panel(IDs.PRIMITIVE_BACKGROUND) .textColor(Color.WHITE.darker(1)) .color(Colors.PRIMITIVE) - // .itemSlot(GTGuiTextures.IDs.PRIMITIVE_SLOT) - // .fluidSlot(GTGuiTextures.IDs.PRIMITIVE_SLOT) + .itemSlot(GTGuiTextures.IDs.PRIMITIVE_SLOT) .build(); protected final String themeId; diff --git a/src/main/java/gregtech/api/mui/TextStandards.java b/src/main/java/gregtech/api/mui/TextStandards.java new file mode 100644 index 00000000000..02aef97140d --- /dev/null +++ b/src/main/java/gregtech/api/mui/TextStandards.java @@ -0,0 +1,26 @@ +package gregtech.api.mui; + +import gregtech.api.util.KeyUtil; + +import net.minecraft.util.text.TextFormatting; + +import com.cleanroommc.modularui.api.drawable.IKey; + +public final class TextStandards { + + public static class Colors { + + public static final TextFormatting MACHINE_WORKING = TextFormatting.GREEN; + public static final TextFormatting MACHINE_DONE = TextFormatting.GREEN; + public static final TextFormatting MACHINE_PAUSED = TextFormatting.GOLD; + public static final TextFormatting NO_OUTPUT_SPACE = TextFormatting.RED; + public static final TextFormatting STEAM_VENT_BLOCKED = TextFormatting.RED; + public static final TextFormatting NO_POWER = TextFormatting.RED; + } + + public static class Keys { + + public static final IKey MACHINE_PAUSED = KeyUtil.lang(Colors.MACHINE_PAUSED, + "gregtech.multiblock.work_paused"); + } +} diff --git a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityMiner.java b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityMiner.java index 78603f145d1..53656efac23 100644 --- a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityMiner.java +++ b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityMiner.java @@ -7,15 +7,15 @@ import gregtech.api.capability.impl.EnergyContainerHandler; import gregtech.api.capability.impl.NotifiableItemStackHandler; import gregtech.api.capability.impl.miner.MinerLogic; -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.ModularUI; -import gregtech.api.gui.widgets.AdvancedTextWidget; -import gregtech.api.gui.widgets.SlotWidget; import gregtech.api.items.itemhandlers.GTItemStackHandler; import gregtech.api.metatileentity.IDataInfoProvider; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.TieredMetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtech.api.mui.GTGuiTextures; +import gregtech.api.mui.GTGuis; +import gregtech.api.mui.TextStandards; +import gregtech.api.util.KeyUtil; import gregtech.client.renderer.texture.Textures; import gregtech.core.sound.GTSoundEvents; @@ -26,7 +26,6 @@ import net.minecraft.network.PacketBuffer; import net.minecraft.util.*; import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.Style; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; @@ -40,6 +39,15 @@ import codechicken.lib.render.CCRenderState; import codechicken.lib.render.pipeline.IVertexOperation; import codechicken.lib.vec.Matrix4; +import com.cleanroommc.modularui.api.drawable.IKey; +import com.cleanroommc.modularui.factory.PosGuiData; +import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; +import com.cleanroommc.modularui.value.sync.BooleanSyncValue; +import com.cleanroommc.modularui.value.sync.IntSyncValue; +import com.cleanroommc.modularui.value.sync.PanelSyncManager; +import com.cleanroommc.modularui.widgets.SlotGroupWidget; +import com.cleanroommc.modularui.widgets.slot.ItemSlot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -96,69 +104,85 @@ public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, } @Override - protected ModularUI createUI(@NotNull EntityPlayer entityPlayer) { - int rowSize = (int) Math.sqrt(inventorySize); - ModularUI.Builder builder = new ModularUI.Builder(GuiTextures.BACKGROUND, 195, 176); - builder.bindPlayerInventory(entityPlayer.inventory, 94); - - if (getTier() == GTValues.HV) { - for (int y = 0; y < rowSize; y++) { - for (int x = 0; x < rowSize; x++) { - int index = y * rowSize + x; - builder.widget( - new SlotWidget(exportItems, index, 151 - rowSize * 9 + x * 18, 18 + y * 18, true, false) - .setBackgroundTexture(GuiTextures.SLOT)); - } - } - } else { - for (int y = 0; y < rowSize; y++) { - for (int x = 0; x < rowSize; x++) { - int index = y * rowSize + x; - builder.widget( - new SlotWidget(exportItems, index, 142 - rowSize * 9 + x * 18, 18 + y * 18, true, false) - .setBackgroundTexture(GuiTextures.SLOT)); - } - } - } - - builder.image(7, 16, 105, 75, GuiTextures.DISPLAY) - .label(6, 6, getMetaFullName()); - builder.widget(new AdvancedTextWidget(10, 19, this::addDisplayText, 0xFFFFFF) - .setMaxWidthLimit(84)); - builder.widget(new AdvancedTextWidget(70, 19, this::addDisplayText2, 0xFFFFFF) - .setMaxWidthLimit(84)); - builder.widget(new SlotWidget(chargerInventory, 0, 171, 152) - .setBackgroundTexture(GuiTextures.SLOT, GuiTextures.CHARGER_OVERLAY)); - - return builder.build(getHolder(), entityPlayer); - } - - private void addDisplayText(@NotNull List textList) { - int workingArea = getWorkingArea(minerLogic.getCurrentRadius()); - textList.add(new TextComponentTranslation("gregtech.machine.miner.startx", this.minerLogic.getX().get())); - textList.add(new TextComponentTranslation("gregtech.machine.miner.starty", this.minerLogic.getY().get())); - textList.add(new TextComponentTranslation("gregtech.machine.miner.startz", this.minerLogic.getZ().get())); - textList.add(new TextComponentTranslation("gregtech.machine.miner.working_area", workingArea, workingArea)); - if (this.minerLogic.isDone()) - textList.add(new TextComponentTranslation("gregtech.machine.miner.done") - .setStyle(new Style().setColor(TextFormatting.GREEN))); - else if (this.minerLogic.isWorking()) - textList.add(new TextComponentTranslation("gregtech.machine.miner.working") - .setStyle(new Style().setColor(TextFormatting.GOLD))); - else if (!this.isWorkingEnabled()) - textList.add(new TextComponentTranslation("gregtech.multiblock.work_paused")); - if (isInventoryFull) - textList.add(new TextComponentTranslation("gregtech.machine.miner.invfull") - .setStyle(new Style().setColor(TextFormatting.RED))); - if (!drainEnergy(true)) - textList.add(new TextComponentTranslation("gregtech.machine.miner.needspower") - .setStyle(new Style().setColor(TextFormatting.RED))); + public boolean usesMui2() { + return true; } - private void addDisplayText2(@NotNull List textList) { - textList.add(new TextComponentTranslation("gregtech.machine.miner.minex", this.minerLogic.getMineX().get())); - textList.add(new TextComponentTranslation("gregtech.machine.miner.miney", this.minerLogic.getMineY().get())); - textList.add(new TextComponentTranslation("gregtech.machine.miner.minez", this.minerLogic.getMineZ().get())); + @SuppressWarnings("DuplicatedCode") + @Override + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager, UISettings settings) { + IntSyncValue radiusSync = new IntSyncValue(() -> getWorkingArea(minerLogic.getCurrentRadius())); + BooleanSyncValue isDoneSync = new BooleanSyncValue(minerLogic::isDone); + BooleanSyncValue isWorkingSync = new BooleanSyncValue(minerLogic::isWorking); + BooleanSyncValue isWorkingEnabledSync = new BooleanSyncValue(minerLogic::isWorkingEnabled); + BooleanSyncValue isInventoryFullSync = new BooleanSyncValue(() -> isInventoryFull); + BooleanSyncValue hasEnoughEnergySync = new BooleanSyncValue(() -> drainEnergy(true)); + panelSyncManager.syncValue("radius", 0, radiusSync); + panelSyncManager.syncValue("done", 0, isDoneSync); + panelSyncManager.syncValue("working", 0, isWorkingSync); + panelSyncManager.syncValue("workingEnabled", 0, isWorkingEnabledSync); + panelSyncManager.syncValue("inventoryFull", 0, isInventoryFullSync); + panelSyncManager.syncValue("enoughEnergy", 0, hasEnoughEnergySync); + + IntSyncValue xPosSync = new IntSyncValue(() -> minerLogic.getMineX().get()); + IntSyncValue yPosSync = new IntSyncValue(() -> minerLogic.getMineY().get()); + IntSyncValue zPosSync = new IntSyncValue(() -> minerLogic.getMineZ().get()); + panelSyncManager.syncValue("xPos", 0, xPosSync); + panelSyncManager.syncValue("yPos", 0, yPosSync); + panelSyncManager.syncValue("zPos", 0, zPosSync); + + return GTGuis.createPanel(this, 197, 176) + .child(IKey.lang(getMetaFullName()) + .asWidget() + .pos(5, 5)) + .child(createMinerWidgets(panelSyncManager, exportItems, inventorySize, GTGuiTextures.DISPLAY, text -> { + boolean isDone = isDoneSync.getBoolValue(); + boolean isWorking = isWorkingSync.getBoolValue(); + boolean isWorkingEnabled = isWorkingEnabledSync.getBoolValue(); + boolean isInventoryFull = isInventoryFullSync.getBoolValue(); + boolean hasEnoughEnergy = hasEnoughEnergySync.getBoolValue(); + + if (isWorking) { + text.addLine(KeyUtil.lang(TextFormatting.WHITE, "gregtech.machine.miner.mining_at")); + text.addLine(KeyUtil.lang(TextFormatting.WHITE, "gregtech.machine.miner.mining_pos_x", + xPosSync.getIntValue())); + text.addLine(KeyUtil.lang(TextFormatting.WHITE, "gregtech.machine.miner.mining_pos_y", + yPosSync.getIntValue())); + text.addLine(KeyUtil.lang(TextFormatting.WHITE, "gregtech.machine.miner.mining_pos_z", + zPosSync.getIntValue())); + } + + text.addLine(KeyUtil.lang(TextFormatting.WHITE, "gregtech.machine.miner.working_area", + radiusSync.getIntValue(), radiusSync.getIntValue())); + + if (isDone) { + text.addLine(KeyUtil.lang(TextStandards.Colors.MACHINE_DONE, "gregtech.machine.miner.done")); + } else if (isWorking) { + text.addLine(KeyUtil.lang(TextStandards.Colors.MACHINE_WORKING, + "gregtech.machine.miner.working")); + } else if (!isWorkingEnabled) { + text.addLine(TextStandards.Keys.MACHINE_PAUSED); + } + + if (isInventoryFull) { + text.addLine(KeyUtil.lang(TextStandards.Colors.NO_OUTPUT_SPACE, + "gregtech.machine.miner.invfull")); + } + + if (!hasEnoughEnergy) { + text.addLine(KeyUtil.lang(TextStandards.Colors.NO_POWER, "gregtech.machine.miner.needspower")); + } + }) + .left(10) + .top(18)) + .child(SlotGroupWidget.playerInventory(false) + .left(7) + .bottom(7)) + .child(new ItemSlot() + .right(7) + .bottom(7) + .slot(chargerInventory, 0) + .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY)); } @Override diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityLargeMiner.java b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityLargeMiner.java index 8128e1fa525..7436c7eafd2 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityLargeMiner.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityLargeMiner.java @@ -270,9 +270,11 @@ protected void configureDisplayText(MultiblockUIBuilder builder) { int workingArea = syncer.syncInt(getWorkingArea(minerLogic.getCurrentRadius())); list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.machine.miner.mining_at")); - list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.machine.miner.mining_pos", - syncer.syncInt(minerLogic.getMineX().get()), - syncer.syncInt(minerLogic.getMineY().get()), + list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.machine.miner.mining_pos_x", + syncer.syncInt(minerLogic.getMineX().get()))); + list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.machine.miner.mining_pos_y", + syncer.syncInt(minerLogic.getMineY().get()))); + list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.machine.miner.mining_pos_z", syncer.syncInt(minerLogic.getMineZ().get()))); if (syncer.syncBoolean(minerLogic.isChunkMode())) { diff --git a/src/main/java/gregtech/common/metatileentities/steam/SteamMiner.java b/src/main/java/gregtech/common/metatileentities/steam/SteamMiner.java index 3f70bf75aaf..cbe9ae2aa7a 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/SteamMiner.java +++ b/src/main/java/gregtech/common/metatileentities/steam/SteamMiner.java @@ -8,14 +8,15 @@ import gregtech.api.capability.impl.miner.MinerLogic; import gregtech.api.capability.impl.miner.SteamMinerLogic; import gregtech.api.damagesources.DamageSources; -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.ModularUI; -import gregtech.api.gui.widgets.AdvancedTextWidget; -import gregtech.api.gui.widgets.SlotWidget; import gregtech.api.metatileentity.IDataInfoProvider; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtech.api.mui.GTGuiTextures; +import gregtech.api.mui.GTGuiTheme; +import gregtech.api.mui.GTGuis; +import gregtech.api.mui.TextStandards; import gregtech.api.util.GTUtility; +import gregtech.api.util.KeyUtil; import gregtech.client.renderer.texture.Textures; import gregtech.client.renderer.texture.cube.SimpleSidedCubeRenderer; import gregtech.common.ConfigHolder; @@ -25,7 +26,6 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.I18n; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -34,7 +34,6 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.Style; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; @@ -48,6 +47,14 @@ import codechicken.lib.render.pipeline.ColourMultiplier; import codechicken.lib.render.pipeline.IVertexOperation; import codechicken.lib.vec.Matrix4; +import com.cleanroommc.modularui.api.drawable.IKey; +import com.cleanroommc.modularui.factory.PosGuiData; +import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.UISettings; +import com.cleanroommc.modularui.value.sync.BooleanSyncValue; +import com.cleanroommc.modularui.value.sync.IntSyncValue; +import com.cleanroommc.modularui.value.sync.PanelSyncManager; +import com.cleanroommc.modularui.widgets.SlotGroupWidget; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; @@ -114,60 +121,105 @@ public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, } @Override - protected ModularUI createUI(EntityPlayer entityPlayer) { - int rowSize = (int) Math.sqrt(inventorySize); - - ModularUI.Builder builder = ModularUI.builder(GuiTextures.BACKGROUND_STEAM.get(false), 175, 176); - builder.bindPlayerInventory(entityPlayer.inventory, 94); - - for (int y = 0; y < rowSize; y++) { - for (int x = 0; x < rowSize; x++) { - int index = y * rowSize + x; - builder.widget(new SlotWidget(exportItems, index, 142 - rowSize * 9 + x * 18, 18 + y * 18, true, false) - .setBackgroundTexture(GuiTextures.SLOT_STEAM.get(false))); - } - } - builder.bindPlayerInventory(entityPlayer.inventory, GuiTextures.SLOT_STEAM.get(false), 10); - - builder.image(7, 16, 105, 75, GuiTextures.DISPLAY_STEAM.get(false)) - .label(6, 6, getMetaFullName()); - builder.widget(new AdvancedTextWidget(10, 19, this::addDisplayText, 0xFFFFFF) - .setMaxWidthLimit(84)); - builder.widget(new AdvancedTextWidget(70, 19, this::addDisplayText2, 0xFFFFFF) - .setMaxWidthLimit(84)); - - return builder.build(getHolder(), entityPlayer); + public boolean usesMui2() { + return true; } - void addDisplayText(List textList) { - int workingArea = getWorkingArea(minerLogic.getCurrentRadius()); - textList.add(new TextComponentTranslation("gregtech.machine.miner.startx", this.minerLogic.getX().get())); - textList.add(new TextComponentTranslation("gregtech.machine.miner.starty", this.minerLogic.getY().get())); - textList.add(new TextComponentTranslation("gregtech.machine.miner.startz", this.minerLogic.getZ().get())); - textList.add(new TextComponentTranslation("gregtech.machine.miner.working_area", workingArea, workingArea)); - if (this.minerLogic.isDone()) - textList.add(new TextComponentTranslation("gregtech.machine.miner.done") - .setStyle(new Style().setColor(TextFormatting.GREEN))); - else if (this.minerLogic.isWorking()) - textList.add(new TextComponentTranslation("gregtech.machine.miner.working") - .setStyle(new Style().setColor(TextFormatting.GOLD))); - else if (!this.isWorkingEnabled()) - textList.add(new TextComponentTranslation("gregtech.multiblock.work_paused")); - if (this.isInventoryFull) - textList.add(new TextComponentTranslation("gregtech.machine.miner.invfull") - .setStyle(new Style().setColor(TextFormatting.RED))); - if (ventingStuck) - textList.add(new TextComponentTranslation("gregtech.machine.steam_miner.vent") - .setStyle(new Style().setColor(TextFormatting.RED))); - else if (!drainEnergy(true)) - textList.add(new TextComponentTranslation("gregtech.machine.steam_miner.steam") - .setStyle(new Style().setColor(TextFormatting.RED))); + @Override + public GTGuiTheme getUITheme() { + return GTGuiTheme.BRONZE; } - void addDisplayText2(List textList) { - textList.add(new TextComponentTranslation("gregtech.machine.miner.minex", this.minerLogic.getMineX().get())); - textList.add(new TextComponentTranslation("gregtech.machine.miner.miney", this.minerLogic.getMineY().get())); - textList.add(new TextComponentTranslation("gregtech.machine.miner.minez", this.minerLogic.getMineZ().get())); + @SuppressWarnings("DuplicatedCode") + @Override + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager, UISettings settings) { + IntSyncValue radiusSync = new IntSyncValue(() -> getWorkingArea(minerLogic.getCurrentRadius())); + BooleanSyncValue isDoneSync = new BooleanSyncValue(minerLogic::isDone); + BooleanSyncValue isWorkingSync = new BooleanSyncValue(minerLogic::isWorking); + BooleanSyncValue isWorkingEnabledSync = new BooleanSyncValue(minerLogic::isWorkingEnabled); + BooleanSyncValue isInventoryFullSync = new BooleanSyncValue(() -> isInventoryFull); + BooleanSyncValue isVentBlockedSync = new BooleanSyncValue(this::isVentingStuck); + BooleanSyncValue hasEnoughEnergySync = new BooleanSyncValue(() -> drainEnergy(true)); + panelSyncManager.syncValue("radius", 0, radiusSync); + panelSyncManager.syncValue("done", 0, isDoneSync); + panelSyncManager.syncValue("working", 0, isWorkingSync); + panelSyncManager.syncValue("workingEnabled", 0, isWorkingEnabledSync); + panelSyncManager.syncValue("inventoryFull", 0, isInventoryFullSync); + panelSyncManager.syncValue("ventBlocked", 0, isVentBlockedSync); + panelSyncManager.syncValue("enoughEnergy", 0, hasEnoughEnergySync); + + IntSyncValue xPosSync = new IntSyncValue(() -> minerLogic.getMineX().get()); + IntSyncValue yPosSync = new IntSyncValue(() -> minerLogic.getMineY().get()); + IntSyncValue zPosSync = new IntSyncValue(() -> minerLogic.getMineZ().get()); + panelSyncManager.syncValue("xPos", 0, xPosSync); + panelSyncManager.syncValue("yPos", 0, yPosSync); + panelSyncManager.syncValue("zPos", 0, zPosSync); + + return GTGuis.createPanel(this, 175, 176) + .child(IKey.lang(getMetaFullName()) + .asWidget() + .pos(5, 5)) + .child(createMinerWidgets(panelSyncManager, exportItems, inventorySize, GTGuiTextures.DISPLAY_BRONZE, + text -> { + boolean isDone = isDoneSync.getBoolValue(); + boolean isWorking = isWorkingSync.getBoolValue(); + boolean isWorkingEnabled = isWorkingEnabledSync.getBoolValue(); + boolean isInventoryFull = isInventoryFullSync.getBoolValue(); + boolean hasEnoughEnergy = hasEnoughEnergySync.getBoolValue(); + boolean isVentBlocked = isVentBlockedSync.getBoolValue(); + + int xPos = xPosSync.getIntValue(); + int yPos = yPosSync.getIntValue(); + int zPos = zPosSync.getIntValue(); + int radius = radiusSync.getIntValue(); + + if (isWorking) { + text.addLine(KeyUtil.lang(TextFormatting.WHITE, "gregtech.machine.miner.mining_at")); + text.addLine(KeyUtil.lang(TextFormatting.WHITE, "gregtech.machine.miner.mining_pos_x", + xPos)); + text.addLine(KeyUtil.lang(TextFormatting.WHITE, "gregtech.machine.miner.mining_pos_y", + yPos)); + text.addLine(KeyUtil.lang(TextFormatting.WHITE, "gregtech.machine.miner.mining_pos_z", + zPos)); + } + + text.addLine(KeyUtil.lang(TextFormatting.WHITE, "gregtech.machine.miner.working_area", + radius, radius)); + + if (isDone) { + text.addLine(KeyUtil.lang(TextStandards.Colors.MACHINE_DONE, + "gregtech.machine.miner.done")); + } else if (isWorking) { + text.addLine(KeyUtil.lang(TextStandards.Colors.MACHINE_WORKING, + "gregtech.machine.miner.working")); + } else if (!isWorkingEnabled) { + text.addLine(TextStandards.Keys.MACHINE_PAUSED); + } + + if (isInventoryFull) { + text.addLine(KeyUtil.lang(TextStandards.Colors.NO_OUTPUT_SPACE, + "gregtech.machine.miner.invfull")); + } + + if (isVentBlocked) { + text.addLine(KeyUtil.lang(TextStandards.Colors.STEAM_VENT_BLOCKED, + "gregtech.machine.steam_miner.vent")); + } + + // Drain energy always returns false when the vent is blocked, so check that it isn't + // blocked. + // It should be fine since I don't think it can even enter the vent blocked state without + // having steam. + if (!hasEnoughEnergy && !isVentBlocked) { + text.addLine(KeyUtil.lang(TextStandards.Colors.NO_POWER, + "gregtech.machine.steam_miner.steam")); + } + }) + .left(10) + .top(18)) + .child(SlotGroupWidget.playerInventory(false) + .left(7) + .bottom(7)); } @Override diff --git a/src/main/resources/assets/gregtech/lang/en_us.lang b/src/main/resources/assets/gregtech/lang/en_us.lang index ea6df5b60b1..d9a27bc991f 100644 --- a/src/main/resources/assets/gregtech/lang/en_us.lang +++ b/src/main/resources/assets/gregtech/lang/en_us.lang @@ -4883,6 +4883,7 @@ gregtech.machine.miner.hv.name=Advanced Miner II gregtech.machine.miner.tooltip=Mines ores below the Miner! Starts as §f%sx%s §7area gregtech.machine.miner.per_block=§7takes §f%,ds §7per Block + gregtech.machine.large_miner.ev.name=Basic Ore Drilling Plant gregtech.machine.large_miner.iv.name=Advanced Ore Drilling Plant gregtech.machine.large_miner.luv.name=Advanced Ore Drilling Plant II @@ -4891,8 +4892,17 @@ gregtech.machine.miner.multi.production=Produces §f3x§7 more crushed ore than gregtech.machine.miner.fluid_usage=Uses §f%,d L/t §7of §f%s§7, doubled per overclock. gregtech.machine.miner.multi.description=A multiblock mining machine that covers a large area and produces huge quantity of ore. gregtech.machine.miner.multi.needsfluid=No Drilling Fluid! +gregtech.machine.miner.done=Done! +gregtech.machine.miner.working=Mining... +gregtech.machine.miner.invfull=Inventory Full! +gregtech.machine.miner.needspower=Needs Power! +gregtech.machine.steam_miner.vent=Venting Blocked! +gregtech.machine.steam_miner.steam=Needs Steam! +gregtech.machine.miner.errorradius=§cCannot change radius while working! gregtech.machine.miner.mining_at=Currently mining at: -gregtech.machine.miner.mining_pos=X: %s Y: %s Z: %s +gregtech.machine.miner.mining_pos_x=§bX§r: §a%s§r +gregtech.machine.miner.mining_pos_y=§bY§r: §a%s§r +gregtech.machine.miner.mining_pos_z=§bZ§r: §a%s§r gregtech.machine.miner.radius=Radius: %d gregtech.machine.miner.working_area=Working Area: %dx%d blocks gregtech.machine.miner.working_area_chunks=Working Area: %dx%d chunks @@ -5908,14 +5918,6 @@ gregtech.multiblock.large_boiler.explosion_tooltip=Will explode if provided Fuel gregtech.multiblock.large_boiler.water_bar_hover=§7Water: §9%,d / %,d L gregtech.multiblock.large_boiler.no_water=§eNo Water! -gregtech.machine.miner.done=Done! -gregtech.machine.miner.working=Working... -gregtech.machine.miner.invfull=Inventory Full! -gregtech.machine.miner.needspower=Needs Power! -gregtech.machine.steam_miner.vent=Venting Blocked! -gregtech.machine.steam_miner.steam=Needs Steam! -gregtech.machine.miner.errorradius=§cCannot change radius while working! - gregtech.multiblock.miner.neither_mode=Chunk Mode: §cDisabled§r/nSilk Touch Mode: §cDisabled§r/n§7Switching requires an idle machine. gregtech.multiblock.miner.chunk_mode=Chunk Mode: §aEnabled§r/nSilk Touch Mode: §cDisabled§r/n§7Switching requires an idle machine. gregtech.multiblock.miner.silk_touch_mode=Chunk Mode: §cDisabled§r/nSilk Touch Mode: §aEnabled§r/n§7Switching requires an idle machine.