diff --git a/src/generated/resources/assets/ae2/lang/en_us.json b/src/generated/resources/assets/ae2/lang/en_us.json index 92533c56564..70c9b792844 100644 --- a/src/generated/resources/assets/ae2/lang/en_us.json +++ b/src/generated/resources/assets/ae2/lang/en_us.json @@ -344,6 +344,7 @@ "gui.ae2.Empty": "Empty", "gui.ae2.Encoded": "Encoded", "gui.ae2.EnergyDrain": "Passive Drain: %s", + "gui.ae2.EnergyGenerationCapacity": "Generation Capacity: %s", "gui.ae2.EnergyLevelEmitter": "ME Energy Level Emitter", "gui.ae2.Excluded": "Excluded", "gui.ae2.ExportBus": "ME Export Bus", diff --git a/src/main/java/appeng/api/networking/energy/IPassiveEnergyGenerator.java b/src/main/java/appeng/api/networking/energy/IPassiveEnergyGenerator.java index 4c0356f2a9b..2bf9e09085b 100644 --- a/src/main/java/appeng/api/networking/energy/IPassiveEnergyGenerator.java +++ b/src/main/java/appeng/api/networking/energy/IPassiveEnergyGenerator.java @@ -41,4 +41,10 @@ public interface IPassiveEnergyGenerator extends IGridNodeService { */ void setSuppressed(boolean suppressed); + /** + * @return Whether this generator is currently suppressed. + * @see #setSuppressed(boolean) + */ + boolean isSuppressed(); + } diff --git a/src/main/java/appeng/blockentity/networking/CrystalResonanceGeneratorBlockEntity.java b/src/main/java/appeng/blockentity/networking/CrystalResonanceGeneratorBlockEntity.java index 77a01a2f4b5..fe03b4d293a 100644 --- a/src/main/java/appeng/blockentity/networking/CrystalResonanceGeneratorBlockEntity.java +++ b/src/main/java/appeng/blockentity/networking/CrystalResonanceGeneratorBlockEntity.java @@ -50,6 +50,11 @@ public double getRate() { return AEConfig.instance().getCrystalResonanceGeneratorRate(); } + @Override + public boolean isSuppressed() { + return CrystalResonanceGeneratorBlockEntity.this.suppressed; + } + @Override public void setSuppressed(boolean suppressed) { if (suppressed != CrystalResonanceGeneratorBlockEntity.this.suppressed) { diff --git a/src/main/java/appeng/client/gui/me/networktool/NetworkStatusScreen.java b/src/main/java/appeng/client/gui/me/networktool/NetworkStatusScreen.java index b7be5c76d73..b5ea578d5f0 100644 --- a/src/main/java/appeng/client/gui/me/networktool/NetworkStatusScreen.java +++ b/src/main/java/appeng/client/gui/me/networktool/NetworkStatusScreen.java @@ -18,14 +18,6 @@ package appeng.client.gui.me.networktool; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.network.chat.Component; -import net.minecraft.world.entity.player.Inventory; - import appeng.api.client.AEKeyRendering; import appeng.client.gui.AEBaseScreen; import appeng.client.gui.style.PaletteColor; @@ -37,6 +29,14 @@ import appeng.menu.me.networktool.NetworkStatus; import appeng.menu.me.networktool.NetworkStatusMenu; import appeng.util.Platform; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.player.Inventory; + +import java.util.ArrayList; +import java.util.List; public class NetworkStatusScreen extends AEBaseScreen { @@ -56,7 +56,7 @@ public class NetworkStatusScreen extends AEBaseScreen { private final Scrollbar scrollbar; public NetworkStatusScreen(NetworkStatusMenu menu, Inventory playerInventory, - Component title, ScreenStyle style) { + Component title, ScreenStyle style) { super(menu, playerInventory, title, style); this.scrollbar = widgets.addScrollBar("scrollbar"); @@ -80,7 +80,7 @@ protected void updateBeforeRender() { @Override public void drawFG(GuiGraphics guiGraphics, int offsetX, int offsetY, int mouseX, - int mouseY) { + int mouseY) { int x = 0; int y = 0; final int viewStart = scrollbar.getCurrentScroll() * COLUMNS; @@ -112,6 +112,10 @@ public void drawFG(GuiGraphics guiGraphics, int offsetX, int offsetY, int mouseX tooltip.add(GuiText.EnergyDrain .text(Platform.formatPower(entry.getIdlePowerUsage(), true))); } + if (entry.getPowerGenerationCapacity() > 0) { + tooltip.add(GuiText.EnergyGenerationCapacity + .text(Platform.formatPower(entry.getPowerGenerationCapacity(), true))); + } } if (++x >= COLUMNS) { diff --git a/src/main/java/appeng/core/localization/GuiText.java b/src/main/java/appeng/core/localization/GuiText.java index 6d7323b6588..bfb7e3a4261 100644 --- a/src/main/java/appeng/core/localization/GuiText.java +++ b/src/main/java/appeng/core/localization/GuiText.java @@ -90,6 +90,7 @@ public enum GuiText implements LocalizationEnum { Empty("Empty"), Encoded("Encoded"), EnergyDrain("Passive Drain: %s"), + EnergyGenerationCapacity("Generation Capacity: %s"), EnergyLevelEmitter("ME Energy Level Emitter"), Excluded("Excluded"), ExportBus("ME Export Bus"), diff --git a/src/main/java/appeng/menu/me/networktool/MachineGroup.java b/src/main/java/appeng/menu/me/networktool/MachineGroup.java index 06d5c9beb26..b9e896f8461 100644 --- a/src/main/java/appeng/menu/me/networktool/MachineGroup.java +++ b/src/main/java/appeng/menu/me/networktool/MachineGroup.java @@ -18,9 +18,14 @@ package appeng.menu.me.networktool; +import appeng.api.networking.IGridNode; +import appeng.api.stacks.AEItemKey; +import net.minecraft.core.BlockPos; import net.minecraft.network.FriendlyByteBuf; -import appeng.api.stacks.AEItemKey; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Set; /** * Represents the status of machines grouped by their {@link IGridBlock#getMachineRepresentation() item representation}. @@ -38,6 +43,11 @@ public class MachineGroup { */ private double idlePowerUsage; + /** + * The sum of power this group of machines can generate in AE/t. + */ + private double powerGenerationCapacity; + /** * The number of machines in this group. */ @@ -53,6 +63,7 @@ public class MachineGroup { static MachineGroup read(FriendlyByteBuf data) { MachineGroup entry = new MachineGroup(AEItemKey.fromPacket(data)); entry.idlePowerUsage = data.readDouble(); + entry.powerGenerationCapacity = data.readDouble(); entry.count = data.readVarInt(); return entry; } @@ -60,6 +71,7 @@ static MachineGroup read(FriendlyByteBuf data) { void write(FriendlyByteBuf data) { display.writeToPacket(data); data.writeDouble(idlePowerUsage); + data.writeDouble(powerGenerationCapacity); data.writeVarInt(count); } @@ -75,6 +87,14 @@ void setIdlePowerUsage(double idlePowerUsage) { this.idlePowerUsage = idlePowerUsage; } + public double getPowerGenerationCapacity() { + return powerGenerationCapacity; + } + + public void setPowerGenerationCapacity(double powerGenerationCapacity) { + this.powerGenerationCapacity = powerGenerationCapacity; + } + public int getCount() { return count; } @@ -82,4 +102,5 @@ public int getCount() { void setCount(int count) { this.count = count; } + } diff --git a/src/main/java/appeng/menu/me/networktool/NetworkStatus.java b/src/main/java/appeng/menu/me/networktool/NetworkStatus.java index 00d2b3e5c8e..b587c5b353e 100644 --- a/src/main/java/appeng/menu/me/networktool/NetworkStatus.java +++ b/src/main/java/appeng/menu/me/networktool/NetworkStatus.java @@ -18,20 +18,24 @@ package appeng.menu.me.networktool; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.google.common.collect.ImmutableList; - -import net.minecraft.network.FriendlyByteBuf; - +import appeng.api.implementations.parts.ICablePart; import appeng.api.networking.IGrid; import appeng.api.networking.IGridNode; import appeng.api.networking.energy.IEnergyService; -import appeng.api.stacks.AEItemKey; +import appeng.api.networking.energy.IPassiveEnergyGenerator; +import appeng.blockentity.misc.VibrationChamberBlockEntity; import appeng.client.gui.me.networktool.NetworkStatusScreen; +import appeng.parts.AEBasePart; +import com.google.common.collect.ImmutableList; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.entity.BlockEntity; +import org.jetbrains.annotations.Nullable; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * Contains statistics about an ME network and the machines that form it. @@ -74,6 +78,15 @@ public static NetworkStatus fromGrid(IGrid grid) { group.setCount(group.getCount() + 1); group.setIdlePowerUsage(group.getIdlePowerUsage() + machine.getIdlePowerUsage()); + + var owner = machine.getOwner(); + var passiveEnergyGenerator =machine.getService(IPassiveEnergyGenerator.class); + if (passiveEnergyGenerator != null && !passiveEnergyGenerator.isSuppressed()) { + group.setPowerGenerationCapacity(group.getPowerGenerationCapacity() + passiveEnergyGenerator.getRate()); + } + if (owner instanceof VibrationChamberBlockEntity vibrationChamberBlockEntity) { + group.setPowerGenerationCapacity(group.getPowerGenerationCapacity() + vibrationChamberBlockEntity.getMaxEnergyRate()); + } } } } @@ -150,5 +163,4 @@ public void write(FriendlyByteBuf data) { machine.write(data); } } - } diff --git a/src/main/java/appeng/menu/me/networktool/NetworkStatusMenu.java b/src/main/java/appeng/menu/me/networktool/NetworkStatusMenu.java index 3ffc22688f8..76b0aac0c16 100644 --- a/src/main/java/appeng/menu/me/networktool/NetworkStatusMenu.java +++ b/src/main/java/appeng/menu/me/networktool/NetworkStatusMenu.java @@ -19,6 +19,7 @@ package appeng.menu.me.networktool; import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.MenuType;