From c709bd14e7dec1c3e4a7897c6a8ac949f2d3ce5d Mon Sep 17 00:00:00 2001 From: MCTBL <30978504+MCTBL@users.noreply.github.com> Date: Sun, 19 Nov 2023 23:42:03 +0800 Subject: [PATCH] Change the interface and finish the whole function. (#427) * 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 * 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 01dde621b8a40ea870c3d61a8e9f2dc8c18475f9, reversing changes made to d09184e8a376448f637df87eb0d490eb0fb4607a. * Revert "Revert "Merge branch 'GTNewHorizons:master' into master"" This reverts commit 864bbd494c9f9f46ef5f30648fe6663701da1be8. * 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 --- dependencies.gradle | 4 + .../api/storage/ICellCacheRegistry.java | 8 +- .../gui/implementations/GuiNetworkStatus.java | 3 + .../appeng/me/cache/GridStorageCache.java | 100 ++++++++++++++---- .../me/storage/CellInventoryHandler.java | 4 +- .../appliedenergistics2/lang/zh_CN.lang | 1 + .../appliedenergistics2/lang/zh_TW.lang | 1 + 7 files changed, 96 insertions(+), 25 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index e2e772fad2d..430305be42c 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -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} @@ -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 } } diff --git a/src/main/java/appeng/api/storage/ICellCacheRegistry.java b/src/main/java/appeng/api/storage/ICellCacheRegistry.java index b6a87cb6feb..23d83d09453 100644 --- a/src/main/java/appeng/api/storage/ICellCacheRegistry.java +++ b/src/main/java/appeng/api/storage/ICellCacheRegistry.java @@ -22,6 +22,12 @@ public interface ICellCacheRegistry { int getCellStatus(); - StorageChannel getCellType(); + TYPE getCellType(); + + enum TYPE { + ITEM, + FLUID, + ESSENTIA + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java b/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java index 3547f0690e7..0d8d1e2e87d 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java +++ b/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java @@ -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) + "%)"; @@ -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) + "%)"; @@ -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) + "%)"; diff --git a/src/main/java/appeng/me/cache/GridStorageCache.java b/src/main/java/appeng/me/cache/GridStorageCache.java index 33c68310d66..9c48b5eacd8 100644 --- a/src/main/java/appeng/me/cache/GridStorageCache.java +++ b/src/main/java/appeng/me/cache/GridStorageCache.java @@ -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; @@ -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; @@ -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) meih).getInternal() instanceof ICellCacheRegistry iccr) { @@ -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) 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) { @@ -412,26 +442,52 @@ private void updateBytesInfo() { MEInventoryHandler meih = (MEInventoryHandler) 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) 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++; + } + } + } } } } diff --git a/src/main/java/appeng/me/storage/CellInventoryHandler.java b/src/main/java/appeng/me/storage/CellInventoryHandler.java index d6b2146bfd2..9f03c7d3fac 100644 --- a/src/main/java/appeng/me/storage/CellInventoryHandler.java +++ b/src/main/java/appeng/me/storage/CellInventoryHandler.java @@ -166,7 +166,7 @@ public int getCellStatus() { } @Override - public StorageChannel getCellType() { - return StorageChannel.ITEMS; + public TYPE getCellType() { + return TYPE.ITEM; } } diff --git a/src/main/resources/assets/appliedenergistics2/lang/zh_CN.lang b/src/main/resources/assets/appliedenergistics2/lang/zh_CN.lang index 608fdf84178..de4aaf9c609 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/zh_CN.lang +++ b/src/main/resources/assets/appliedenergistics2/lang/zh_CN.lang @@ -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=开始 diff --git a/src/main/resources/assets/appliedenergistics2/lang/zh_TW.lang b/src/main/resources/assets/appliedenergistics2/lang/zh_TW.lang index 178106d9262..e200397124b 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/zh_TW.lang +++ b/src/main/resources/assets/appliedenergistics2/lang/zh_TW.lang @@ -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=開始