Refactored how cell state is exposed (#4422)

Replaced fuzzy ints with a well defined enum
Moved API related cell interfaces to a new subpackage
Introduced a new client helper method to register a cell texture for a storage channel
Added a method to obtain the storage channel for a drive or chest slot
Added a new cell state for cells with stored items but neither types nor completely full
This commit is contained in:
yueh
2020-06-22 22:18:41 +02:00
committed by GitHub
parent adf1bd0191
commit cb62d3a706
45 changed files with 224 additions and 118 deletions
@@ -20,6 +20,8 @@ package appeng.block.storage;
import net.minecraft.util.IStringSerializable;
import appeng.api.storage.cells.CellState;
/**
* Describes the different states a single slot of a BlockDrive can be in in
* terms of rendering.
@@ -52,16 +54,17 @@ public enum DriveSlotState implements IStringSerializable {
return this.name;
}
public static DriveSlotState fromCellStatus(int cellStatus) {
public static DriveSlotState fromCellStatus(CellState cellStatus) {
switch (cellStatus) {
default:
case 0:
case ABSENT:
return DriveSlotState.EMPTY;
case 1:
case EMPTY:
case NOT_EMPTY:
return DriveSlotState.ONLINE;
case 2:
case TYPES_FULL:
return DriveSlotState.TYPES_FULL;
case 3:
case FULL:
return DriveSlotState.FULL;
}
}
@@ -23,6 +23,7 @@ import com.google.common.base.Preconditions;
import net.minecraft.item.Item;
import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.storage.cells.CellState;
/**
* Contains the full information about what the state of the slots in a
@@ -69,7 +70,7 @@ public class DriveSlotsState {
cells[i] = chestOrDrive.getCellItem(i);
if (!chestOrDrive.isPowered()) {
if (chestOrDrive.getCellStatus(i) != 0) {
if (chestOrDrive.getCellStatus(i) != CellState.EMPTY) {
states[i] = DriveSlotState.OFFLINE;
} else {
states[i] = DriveSlotState.EMPTY;