Skip to content

Commit

Permalink
Implement the new interface in AE2 for network bytes information. (#52)
Browse files Browse the repository at this point in the history
* Implements the new interface

* Delete commenteds
  • Loading branch information
MCTBL authored Nov 20, 2023
1 parent d7a6578 commit 92b2b36
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 32 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependencies {
implementation("com.github.GTNewHorizons:NotEnoughItems:2.4.9-GTNH:dev")
implementation("com.github.GTNewHorizons:CodeChickenLib:1.1.8:dev")
implementation("com.github.GTNewHorizons:CodeChickenCore:1.1.11:dev")
implementation("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-279-GTNH:dev")
implementation("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-286-GTNH:dev")
implementation("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
implementation("curse.maven:thaumcraft-nei-plugin-225095:2241913") { transitive = false }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import appeng.api.config.Actionable;
import appeng.api.config.ViewItems;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.ICellCacheRegistry;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.ISaveProvider;
import appeng.api.storage.StorageChannel;
Expand All @@ -32,7 +33,7 @@
* @author Nividica
*
*/
public class HandlerItemEssentiaCell implements IMEInventoryHandler<IAEFluidStack> {
public class HandlerItemEssentiaCell implements IMEInventoryHandler<IAEFluidStack>, ICellCacheRegistry {

/**
* NBT Keys
Expand Down Expand Up @@ -546,6 +547,7 @@ public StorageChannel getChannel() {
*
* @return
*/
@Override
public long getFreeBytes() {
return this.totalBytes - this.getUsedBytes();
}
Expand Down Expand Up @@ -605,48 +607,21 @@ public List<IAspectStack> getStoredEssentia() {
*
* @return
*/
@Override
public long getTotalBytes() {
return this.totalBytes;
}

/**
* Total number of types the cell can hold.
*
* @return
*/
public int getTotalTypes() {
return this.totalTypes;
}

/**
* Returns how many bytes are used.
*
* @return
*/
@Override
public long getUsedBytes() {
return (long) Math.ceil(this.usedEssentiaStorage / (double) HandlerItemEssentiaCell.ESSENTIA_PER_BYTE);
}

/**
* Returns how many types are used.
*
* @return
*/
public int getUsedTypes() {
// Assume we are empty
int typeCount = 0;

// Count the number of valid types
for (IAspectStack stack : this.storedEssentia) {
if (stack != null) {
typeCount++;
}
}

// Return the count
return typeCount;
}

/**
* Gets the view mode.
*
Expand Down Expand Up @@ -869,4 +844,52 @@ public boolean validForPass(final int pass) {
// Valid if not partitioned and cell is empty.
return ((!isPartitioned) && (!hasStoredEssentia));
}

@Override
public boolean canGetInv() {
return (!this.isCreative());
}

@Override
public long getTotalTypes() {
return this.totalTypes;
}

@Override
public long getFreeTypes() {
return this.getTotalTypes() - this.getUsedTypes();
}

@Override
public long getUsedTypes() {
// Assume we are empty
int typeCount = 0;

// Count the number of valid types
for (IAspectStack stack : this.storedEssentia) {
if (stack != null) {
typeCount++;
}
}

// Return the count
return typeCount;
}

@Override
public int getCellStatus() {
if (this.getFreeBytes() == 0) {
return 3;
} else if (this.getFreeTypes() == 0) {
return 2;
} else {
return 1;
}
}

@Override
public TYPE getCellType() {
return TYPE.ESSENTIA;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public long getUsedBytes() {
* Used types based on partition table.
*/
@Override
public int getUsedTypes() {
public long getUsedTypes() {
return this.partitionAspects.size();
}

Expand Down

0 comments on commit 92b2b36

Please sign in to comment.