Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add network bytes information for network status gui #419

Merged
merged 40 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ba686f9
Add network bytes infomation for network status gui
MCTBL Oct 31, 2023
2fdbe14
Add network bytes infomation for network status gui
MCTBL Oct 31, 2023
d31900e
Update src/main/java/appeng/me/cache/GridStorageCache.java
MCTBL Oct 31, 2023
93fc689
swap some of Class.forName to instanceof
MCTBL Oct 31, 2023
80f7e1e
Merge branch 'master' into dev
MCTBL Oct 31, 2023
c94206a
Merge pull request #1 from MCTBL/dev
MCTBL Oct 31, 2023
e4a10fd
make cache update delay
MCTBL Oct 31, 2023
1ed5568
make cache update delay
MCTBL Oct 31, 2023
0524da5
Change error conditions
MCTBL Oct 31, 2023
4869ca9
Change delay from 1000t(50s) to 100t(5s)
MCTBL Oct 31, 2023
13fe5b0
Let cache update data at the beginning
MCTBL Oct 31, 2023
d09184e
Add a cfg that can change the cache update rate
MCTBL Nov 1, 2023
01dde62
Merge branch 'GTNewHorizons:master' into master
MCTBL Nov 2, 2023
1bc8db3
Add fluid bytes information
MCTBL Nov 2, 2023
e3da6a9
Add essentia status and change gui form
MCTBL Nov 3, 2023
f13174d
Apply the spotlessApply
MCTBL Nov 3, 2023
9747e1f
Delete useless rows
MCTBL Nov 3, 2023
ff3b6ee
Delete useless rows
MCTBL Nov 3, 2023
864bbd4
Revert "Merge branch 'GTNewHorizons:master' into master"
MCTBL Nov 3, 2023
de4eaea
Revert "Revert "Merge branch 'GTNewHorizons:master' into master""
MCTBL Nov 3, 2023
597a078
back roll some commits
MCTBL Nov 3, 2023
229c3e7
Merge branch 'master' into dev
MCTBL Nov 3, 2023
fd3eda1
Merge pull request #2 from MCTBL/dev
MCTBL Nov 3, 2023
ce9efce
delete incorrect import and depends
MCTBL Nov 3, 2023
bb1f4ec
Change interface's name
MCTBL Nov 3, 2023
a8334ba
Remove wrong annotations
MCTBL Nov 4, 2023
df8b2b3
Add new AdvancedNetworkTool
MCTBL Nov 5, 2023
9a6fb39
Add the Advanced Network Tool gui
MCTBL Nov 6, 2023
4a8bb6f
Add the advanced toolbox for other Gui
MCTBL Nov 7, 2023
4697694
Update Build Script
MCTBL Nov 7, 2023
025d595
Add recipe into AE and fix some issue
MCTBL Nov 9, 2023
8369c39
Fix the wrong info when cell in ME chest
MCTBL Nov 10, 2023
781e19f
Add external buttons for advanced network status
MCTBL Nov 11, 2023
4323385
Merge branch 'master' into master
MCTBL Nov 11, 2023
8872428
merge with main branch
MCTBL Nov 11, 2023
2b999db
Apply spotless
MCTBL Nov 12, 2023
ddb9cc3
Add external Gui for advanced network tool
MCTBL Nov 12, 2023
39c01cb
Add more info to new Gui
MCTBL Nov 14, 2023
41b822b
Apply spotless
MCTBL Nov 14, 2023
f01f40c
Replace some class to interface
MCTBL Nov 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1697697256
//version: 1699290261
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -646,7 +646,7 @@ repositories {

def mixinProviderGroup = "io.github.legacymoddingmc"
def mixinProviderModule = "unimixins"
def mixinProviderVersion = "0.1.7.1"
def mixinProviderVersion = "0.1.13"
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
ext.mixinProviderSpec = mixinProviderSpec
Expand Down Expand Up @@ -1187,9 +1187,8 @@ publishing {
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
}
}

repositories {
if (usesMavenPublishing.toBoolean()) {
if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) {
maven {
url = mavenPublishUrl
allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/appeng/api/definitions/IItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public interface IItems {

IItemDefinition networkTool();

IItemDefinition advancedNetworkTool();

IItemDefinition portableCell();

IItemDefinition cellCreative();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
*/
public interface INetworkTool extends IInventory, IGuiItemObject {

int getSize();

IGridHost getGridHost(); // null for most purposes.
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ public interface IStorageGrid extends IGridCache, IStorageMonitorable {
* remove a provider added with addCellContainer
*/
void unregisterCellProvider(ICellProvider cc);

}
23 changes: 23 additions & 0 deletions src/main/java/appeng/api/storage/ICellCacheRegistry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package appeng.api.storage;

/**
* For {@link appeng.me.storage.CellInventoryHandler}(or FluidCellInventoryHandler in AE2FC) to easily get bytes
* informations
*/
public interface ICellCacheRegistry {

long getTotalBytes();

long getFreeBytes();

long getUsedBytes();

long getTotalTypes();

long getFreeTypes();

long getUsedTypes();

StorageChannel getCellType();
MCTBL marked this conversation as resolved.
Show resolved Hide resolved

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package appeng.client.gui.implementations;

import java.io.IOException;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;

import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerAdvancedNetworkTool;
import appeng.core.AELog;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;

public class GuiAdvancedNetworkTool extends AEBaseGui {

private GuiToggleButton tFacades;

public GuiAdvancedNetworkTool(final InventoryPlayer inventoryPlayer, final INetworkTool te) {
super(new ContainerAdvancedNetworkTool(inventoryPlayer, te));
this.ySize = 202;
}

@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);

try {
if (btn == this.tFacades) {
NetworkHandler.instance.sendToServer(new PacketValueConfig("AdvancedNetworkTool", "Toggle"));
}
} catch (final IOException e) {
AELog.debug(e);
}
}

@Override
public void initGui() {
super.initGui();

this.tFacades = new GuiToggleButton(
this.guiLeft - 18,
this.guiTop + 8,
23,
22,
GuiText.TransparentFacades.getLocal(),
GuiText.TransparentFacadesHint.getLocal());

this.buttonList.add(this.tFacades);
}

@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
if (this.tFacades != null) {
this.tFacades.setState(((ContainerAdvancedNetworkTool) this.inventorySlots).isFacadeMode());
}

this.fontRendererObj.drawString(
this.getGuiDisplayName(GuiText.AdvancedNetworkTool.getLocal()),
8,
6,
GuiColors.AdvancedNetworkToolTitle.getColor());
this.fontRendererObj.drawString(
GuiText.inventory.getLocal(),
8,
this.ySize - 96 + 3,
GuiColors.AdvancedNetworkToolInventory.getColor());
}

@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/advancedtoolbox.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,18 @@ public void drawBG(final int offsetX, final int offsetY, final int mouseX, final
}
}
if (this.hasToolbox()) {
this.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, 161, 68, 68);
// this.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, 161, 68, 68);
switch (this.getToolboxSize()) {
case 3 -> this
.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68);
case 5 -> {
MCTBL marked this conversation as resolved.
Show resolved Hide resolved
this.bindTexture(this.getAdvancedBackground());
// It's too big, so move it up a little bit
this.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90 - 7, 0, 0, 104, 104);
}
default -> this
.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

package appeng.client.gui.implementations;

import java.text.DecimalFormat;
import java.util.List;

import net.minecraft.client.gui.GuiButton;
Expand Down Expand Up @@ -44,14 +45,16 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
private final int rows = 4;
private GuiImgButton units;
private int tooltip = -1;
private final DecimalFormat df;

public GuiNetworkStatus(final InventoryPlayer inventoryPlayer, final INetworkTool te) {
super(new ContainerNetworkStatus(inventoryPlayer, te));
final GuiScrollbar scrollbar = new GuiScrollbar();

this.df = new DecimalFormat("#.##");
this.setScrollBar(scrollbar);
this.repo = new ItemRepo(scrollbar, this);
this.ySize = 153;
this.ySize = 183;
this.xSize = 195;
this.repo.setRowSize(5);
}
Expand Down Expand Up @@ -115,7 +118,6 @@ public void drawScreen(final int mouseX, final int mouseY, final float btn) {
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
final ContainerNetworkStatus ns = (ContainerNetworkStatus) this.inventorySlots;

this.fontRendererObj
.drawString(GuiText.NetworkDetails.getLocal(), 8, 6, GuiColors.NetworkStatusDetails.getColor());

Expand All @@ -141,6 +143,45 @@ public void drawFG(final int offsetX, final int offsetY, final int mouseX, final
143 - 20,
GuiColors.NetworkStatusPowerUsageRate.getColor());

// Item byte status
this.fontRendererObj.drawString(
GuiText.Items.getLocal() + ": "
+ Platform.formatByteLong(ns.getItemBytesUsed())
+ " / "
+ Platform.formatByteLong(ns.getItemBytesTotal())
+ " ("
+ df.format(ns.getItemBytesUsed() * 100d / ns.getItemBytesTotal())
+ "%)",
13,
143,
GuiColors.NetworkStatusPowerUsageRate.getColor());

// Fluid byte status
this.fontRendererObj.drawString(
GuiText.Fluids.getLocal() + ": "
+ Platform.formatByteLong(ns.getFluidBytesUsed())
+ " / "
+ Platform.formatByteLong(ns.getFluidBytesTotal())
+ " ("
+ df.format(ns.getFluidBytesUsed() * 100d / ns.getFluidBytesTotal())
+ "%)",
13,
143 + 10,
GuiColors.NetworkStatusPowerUsageRate.getColor());

// Essential byte status
this.fontRendererObj.drawString(
GuiText.Essentias.getLocal() + ": "
+ Platform.formatByteLong(ns.getEssentiaBytesUsed())
+ " / "
+ Platform.formatByteLong(ns.getEssentiaBytesTotal())
+ " ("
+ df.format(ns.getEssentiaBytesUsed() * 100d / ns.getEssentiaBytesTotal())
+ "%)",
13,
143 + 20,
GuiColors.NetworkStatusPowerUsageRate.getColor());

final int sectionLength = 30;

int x = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,26 @@ public GuiUpgradeable(final ContainerUpgradeable te) {
this.cvb = te;

this.bc = (IUpgradeableHost) te.getTarget();
this.xSize = this.hasToolbox() ? 246 : 211;
if (this.hasToolbox()) {
this.xSize = switch (this.getToolboxSize()) {
case 3 -> 246;
case 5 -> 290;
default -> 246;
};
} else {
this.xSize = 211;
}
this.ySize = 184;
}

protected boolean hasToolbox() {
return ((ContainerUpgradeable) this.inventorySlots).hasToolbox();
}

protected int getToolboxSize() {
return ((ContainerUpgradeable) this.inventorySlots).getToolboxSize();
}

@Override
public void initGui() {
super.initGui();
Expand Down Expand Up @@ -150,12 +162,24 @@ public void drawBG(final int offsetX, final int offsetY, final int mouseX, final
this.handleButtonVisibility();

this.bindTexture(this.getBackground());

this.drawTexturedModalRect(offsetX, offsetY, 0, 0, 211 - 34, this.ySize);
if (this.drawUpgrades()) {
this.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvb.availableUpgrades() * 18);
}
if (this.hasToolbox()) {
this.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68);
switch (this.getToolboxSize()) {
case 3 -> this
.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68);
case 5 -> {
this.bindTexture(this.getAdvancedBackground());
// It's too big, so move it up a little bit
// Why Storage Bus will use this to draw all the slot?????
this.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90 - 7, 0, 0, 104, 104);
MCTBL marked this conversation as resolved.
Show resolved Hide resolved
}
default -> this
.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68);
}
}
}

Expand Down Expand Up @@ -184,6 +208,10 @@ protected String getBackground() {
return "guis/bus.png";
}

protected String getAdvancedBackground() {
return "guis/advanced_toolbox.png";
}

protected boolean drawUpgrades() {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package appeng.container.implementations;

import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.util.Platform;

public class ContainerAdvancedNetworkTool extends AEBaseContainer {

private final INetworkTool toolInv;

@GuiSync(1)
public boolean facadeMode;

public ContainerAdvancedNetworkTool(final InventoryPlayer ip, final INetworkTool te) {
super(ip, null, null);
this.toolInv = te;

this.lockPlayerInventorySlot(ip.currentItem);

for (int y = 0; y < 5; y++) {
for (int x = 0; x < 5; x++) {
this.addSlotToContainer(
(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
te,
y * 5 + x,
62 - 18 + x * 18,
37 - 18 + y * 18,
this.getInventoryPlayer())));
}
}

this.bindPlayerInventory(ip, 0, 120);
}

public void toggleFacadeMode() {
final NBTTagCompound data = Platform.openNbtData(this.toolInv.getItemStack());
data.setBoolean("hideFacades", !data.getBoolean("hideFacades"));
this.detectAndSendChanges();
}

@Override
public void detectAndSendChanges() {
final ItemStack currentItem = this.getPlayerInv().getCurrentItem();

if (currentItem != this.toolInv.getItemStack()) {
if (currentItem != null) {
if (Platform.isSameItem(this.toolInv.getItemStack(), currentItem)) {
this.getPlayerInv()
.setInventorySlotContents(this.getPlayerInv().currentItem, this.toolInv.getItemStack());
} else {
this.setValidContainer(false);
}
} else {
this.setValidContainer(false);
}
}

if (this.isValidContainer()) {
final NBTTagCompound data = Platform.openNbtData(currentItem);
this.setFacadeMode(data.getBoolean("hideFacades"));
}

super.detectAndSendChanges();
}

public boolean isFacadeMode() {
return this.facadeMode;
}

private void setFacadeMode(final boolean facadeMode) {
this.facadeMode = facadeMode;
}
}
Loading