Skip to content

Commit

Permalink
Change the interface and finish the whole function. (#427)
Browse files Browse the repository at this point in the history
* Add network bytes infomation for network status gui

* Add network bytes infomation for network status gui

* Update src/main/java/appeng/me/cache/GridStorageCache.java

Co-authored-by: Andrei Antropov <q.laiff@gmail.com>

* swap some of Class.forName to instanceof

* make cache update delay

* make cache update delay

* Change error conditions

* Change delay from 1000t(50s) to 100t(5s)

* Let cache update data at the beginning

* Add a cfg that can change the cache update rate

* Add fluid bytes information

* Add essentia status and change gui form

* Apply the spotlessApply

* Delete useless rows

* Delete useless rows

* Revert "Merge branch 'GTNewHorizons:master' into master"

This reverts commit 01dde62, reversing
changes made to d09184e.

* Revert "Revert "Merge branch 'GTNewHorizons:master' into master""

This reverts commit 864bbd4.

* back roll some commits

* delete incorrect import and depends

delete non compliant  depends

* Change interface's name

* Remove wrong annotations

* Add new AdvancedNetworkTool

only text and texture, wait to implement the actual functions.

* Add the Advanced Network Tool gui

* Add the advanced toolbox for other Gui

* Update Build Script

* Add recipe into AE and fix some issue

* Fix the wrong info when cell in ME chest

* Add external buttons for advanced network status

Actual function still working on it

* merge with main branch

Update Settings.java

* Apply spotless

* Add external Gui for advanced network tool

* Add more info to new Gui

* Apply spotless

* Replace some class to interface

* Add chinese lang for #426

* Change the trans to better version

* Fix some problem and finish some function

Finish the data statistics, Change the interface function, Add depends for testing.

* Change variables  to constants, and change depends

---------

Co-authored-by: Andrei Antropov <q.laiff@gmail.com>
  • Loading branch information
MCTBL and Laiff authored Nov 19, 2023
1 parent 0a3ce69 commit c709bd1
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 25 deletions.
4 changes: 4 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
dependencies {
implementation('com.github.GTNewHorizons:NotEnoughItems:2.4.12-GTNH:dev')
implementation('curse.maven:cofh-core-69162:2388751')

compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.36:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.4.0:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.79:dev') {transitive = false}
Expand Down Expand Up @@ -32,4 +33,7 @@ dependencies {
}

runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.1.7:dev")
runtimeOnlyNonPublishable('com.github.GTNewHorizons:Baubles:1.0.1.16:dev')
runtimeOnlyNonPublishable('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
runtimeOnlyNonPublishable('com.github.GTNewHorizons:ThaumicEnergistics:1.5.0-GTNH:dev') { transitive = false }
}
8 changes: 7 additions & 1 deletion src/main/java/appeng/api/storage/ICellCacheRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public interface ICellCacheRegistry {

int getCellStatus();

StorageChannel getCellType();
TYPE getCellType();

enum TYPE {
ITEM,
FLUID,
ESSENTIA
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ private void drawItemInfo() {
13,
26,
GuiColors.DefaultBlack.getColor());

// Item byte status
tempDouble = ns.getItemBytesUsed() * 100d / ns.getItemBytesTotal();
tempStr = ns.getItemBytesTotal() == 0 ? "(0%)" : " (" + df.format(tempDouble) + "%)";
Expand Down Expand Up @@ -489,6 +490,7 @@ private void drawFluidInfo() {
13,
26,
GuiColors.DefaultBlack.getColor());

// Fluid byte status
tempDouble = ns.getFluidBytesUsed() * 100d / ns.getFluidBytesTotal();
tempStr = ns.getFluidBytesTotal() == 0 ? "(0%)" : " (" + df.format(tempDouble) + "%)";
Expand Down Expand Up @@ -546,6 +548,7 @@ private void drawEssentiaInfo() {
13,
26,
GuiColors.DefaultBlack.getColor());

// Essentia byte status
tempDouble = ns.getEssentiaBytesUsed() * 100d / ns.getEssentiaBytesTotal();
tempStr = ns.getEssentiaBytesTotal() == 0 ? "(0%)" : " (" + df.format(tempDouble) + "%)";
Expand Down
100 changes: 78 additions & 22 deletions src/main/java/appeng/me/cache/GridStorageCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@
import appeng.api.storage.data.IItemList;
import appeng.core.AEConfig;
import appeng.me.helpers.GenericInterestManager;
import appeng.me.storage.CellInventoryHandler;
import appeng.me.storage.DriveWatcher;
import appeng.me.storage.ItemWatcher;
import appeng.me.storage.MEInventoryHandler;
import appeng.me.storage.NetworkInventoryHandler;
import appeng.me.storage.VoidCellInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.storage.TileChest;
import appeng.tile.storage.TileDrive;
Expand Down Expand Up @@ -94,6 +92,9 @@ public class GridStorageCache implements IStorageGrid {
private long essentiaCellCount;
private int ticksCount;
private int networkBytesUpdateFrequency;
private static final int CELL_RED = 3;
private static final int CELL_ORANGE = 2;
private static final int CELL_GREEN = 1;

public GridStorageCache(final IGrid g) {
this.myGrid = g;
Expand Down Expand Up @@ -383,7 +384,7 @@ private void updateBytesInfo() {
try {
for (ICellProvider icp : this.activeCellProviders) {
if (icp instanceof TileDrive) {
// All Item Cell
// Item cells
for (IMEInventoryHandler<?> meih : icp.getCellArray(StorageChannel.ITEMS)) {
// exclude void cell
if (((DriveWatcher<IAEItemStack>) meih).getInternal() instanceof ICellCacheRegistry iccr) {
Expand All @@ -392,18 +393,47 @@ private void updateBytesInfo() {
itemBytesTotal += iccr.getTotalBytes();
itemBytesUsed += iccr.getUsedBytes();
switch (iccr.getCellStatus()) {
case 1 -> itemCellG++;
case 2 -> itemCellO++;
case 3 -> itemCellR++;
case CELL_GREEN -> itemCellG++;
case CELL_ORANGE -> itemCellO++;
case CELL_RED -> itemCellR++;
}
itemTypesTotal += iccr.getTotalTypes();
itemTypesUsed += iccr.getUsedTypes();
itemCellCount++;
}
}
itemCellCount++;
}
// TODO
// Essentia and Fluid cells
for (IMEInventoryHandler<?> meih : icp.getCellArray(StorageChannel.FLUIDS)) {
// exclude void cell
if (((DriveWatcher<IAEItemStack>) meih).getInternal() instanceof ICellCacheRegistry iccr) {
// exclude creative cell
if (iccr.canGetInv()) {
if (iccr.getCellType() == ICellCacheRegistry.TYPE.FLUID) {
fluidBytesTotal += iccr.getTotalBytes();
fluidBytesUsed += iccr.getUsedBytes();
switch (iccr.getCellStatus()) {
case CELL_GREEN -> fluidCellG++;
case CELL_ORANGE -> fluidCellO++;
case CELL_RED -> fluidCellR++;
}
fluidTypesTotal += iccr.getTotalTypes();
fluidTypesUsed += iccr.getUsedTypes();
fluidCellCount++;
} else if (iccr.getCellType() == ICellCacheRegistry.TYPE.ESSENTIA) {
essentiaBytesTotal += iccr.getTotalBytes();
essentiaBytesUsed += iccr.getUsedBytes();
switch (iccr.getCellStatus()) {
case CELL_GREEN -> essentiaCellG++;
case CELL_ORANGE -> essentiaCellO++;
case CELL_RED -> essentiaCellR++;
}
essentiaTypesTotal += iccr.getTotalTypes();
essentiaTypesUsed += iccr.getUsedTypes();
essentiaCellCount++;
}
}
}

}
} else if (icp instanceof TileChest tc) {
Expand All @@ -412,26 +442,52 @@ private void updateBytesInfo() {
MEInventoryHandler<IAEItemStack> meih = (MEInventoryHandler<IAEItemStack>) AEApi.instance()
.registries().cell().getCellInventory(cell, tc, StorageChannel.ITEMS);
// exclude void cell
if (meih instanceof VoidCellInventory) {
continue;
} else if (meih instanceof CellInventoryHandler handler) {
if (meih instanceof ICellCacheRegistry iccr) {
// exclude creative cell
if (handler.getCellInv() != null) {
itemBytesTotal += handler.getTotalBytes();
itemBytesUsed += handler.getUsedBytes();
switch (handler.getStatusForCell()) {
case 1 -> itemCellG++;
case 2 -> itemCellO++;
case 3 -> itemCellR++;
if (iccr.canGetInv()) {
itemBytesTotal += iccr.getTotalBytes();
itemBytesUsed += iccr.getUsedBytes();
switch (iccr.getCellStatus()) {
case CELL_GREEN -> itemCellG++;
case CELL_ORANGE -> itemCellO++;
case CELL_RED -> itemCellR++;
}
itemTypesTotal += handler.getTotalTypes();
itemTypesUsed += handler.getUsedTypes();
itemTypesTotal += iccr.getTotalTypes();
itemTypesUsed += iccr.getUsedTypes();
itemCellCount++;
}
itemCellCount++;
} else {
// TODO
meih = (MEInventoryHandler<IAEItemStack>) AEApi.instance().registries().cell()
.getCellInventory(cell, tc, StorageChannel.FLUIDS);
// exclude void cell
if (meih instanceof ICellCacheRegistry iccr) {
// exclude creative cell
if (iccr.canGetInv()) {
if (iccr.getCellType() == ICellCacheRegistry.TYPE.FLUID) {
fluidBytesTotal += iccr.getTotalBytes();
fluidBytesUsed += iccr.getUsedBytes();
switch (iccr.getCellStatus()) {
case CELL_GREEN -> fluidCellG++;
case CELL_ORANGE -> fluidCellO++;
case CELL_RED -> fluidCellR++;
}
fluidTypesTotal += iccr.getTotalTypes();
fluidTypesUsed += iccr.getUsedTypes();
fluidCellCount++;
} else if (iccr.getCellType() == ICellCacheRegistry.TYPE.ESSENTIA) {
essentiaBytesTotal += iccr.getTotalBytes();
essentiaBytesUsed += iccr.getUsedBytes();
switch (iccr.getCellStatus()) {
case CELL_GREEN -> essentiaCellG++;
case CELL_ORANGE -> essentiaCellO++;
case CELL_RED -> essentiaCellR++;
}
essentiaTypesTotal += iccr.getTotalTypes();
essentiaTypesUsed += iccr.getUsedTypes();
essentiaCellCount++;
}
}
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/appeng/me/storage/CellInventoryHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public int getCellStatus() {
}

@Override
public StorageChannel getCellType() {
return StorageChannel.ITEMS;
public TYPE getCellType() {
return TYPE.ITEM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ gui.appliedenergistics2.CraftingStatus=合成状态
gui.appliedenergistics2.RemainingOperations=空闲处理器
gui.appliedenergistics2.FromStorage=可用数量
gui.appliedenergistics2.ToCraft=合成数量
gui.appliedenergistics2.ToCraftRequests=合成次数
gui.appliedenergistics2.CraftingPlan=合成计划
gui.appliedenergistics2.Automatic=自动分配
gui.appliedenergistics2.Start=开始
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ gui.appliedenergistics2.Scheduled=計劃合成
gui.appliedenergistics2.CraftingStatus=合成狀態
gui.appliedenergistics2.FromStorage=可用數量
gui.appliedenergistics2.ToCraft=合成數量
gui.appliedenergistics2.ToCraftRequests=合成次數
gui.appliedenergistics2.CraftingPlan=合成計劃
gui.appliedenergistics2.Automatic=自動分配
gui.appliedenergistics2.Start=開始
Expand Down

0 comments on commit c709bd1

Please sign in to comment.