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:
@@ -4,8 +4,8 @@ package appeng.tile.inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.cells.ICellInventory;
|
||||
import appeng.api.storage.cells.ICellInventoryHandler;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import appeng.api.config.CopyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.api.storage.cells.ICellWorkbenchItem;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.tile.AEBaseTileEntity;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
|
||||
@@ -69,10 +69,6 @@ import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.ICellGuiHandler;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
@@ -80,6 +76,11 @@ import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.IStorageMonitorableAccessor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.cells.CellState;
|
||||
import appeng.api.storage.cells.ICellGuiHandler;
|
||||
import appeng.api.storage.cells.ICellHandler;
|
||||
import appeng.api.storage.cells.ICellInventory;
|
||||
import appeng.api.storage.cells.ICellInventoryHandler;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
@@ -162,7 +163,7 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
final int oldState = this.state;
|
||||
|
||||
for (int x = 0; x < this.getCellCount(); x++) {
|
||||
this.state |= (this.getCellStatus(x) << (3 * x));
|
||||
this.state |= (this.getCellStatus(x).ordinal() << (3 * x));
|
||||
}
|
||||
|
||||
if (this.isPowered()) {
|
||||
@@ -242,9 +243,9 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellStatus(final int slot) {
|
||||
public CellState getCellStatus(final int slot) {
|
||||
if (isRemote()) {
|
||||
return (this.state >> (slot * 3)) & 3;
|
||||
return CellState.values()[(this.state >> (slot * 3)) & 3];
|
||||
}
|
||||
|
||||
this.updateHandler();
|
||||
@@ -256,7 +257,7 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
return ch.getStatusForCell(cell, this.cellHandler.getInternalHandler());
|
||||
}
|
||||
|
||||
return 0;
|
||||
return CellState.ABSENT;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -354,7 +355,7 @@ public class ChestTileEntity extends AENetworkPowerTileEntity
|
||||
}
|
||||
|
||||
for (int x = 0; x < this.getCellCount(); x++) {
|
||||
this.state |= (this.getCellStatus(x) << (3 * x));
|
||||
this.state |= (this.getCellStatus(x).ordinal() << (3 * x));
|
||||
}
|
||||
|
||||
if (this.isPowered()) {
|
||||
|
||||
@@ -49,11 +49,12 @@ import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.cells.CellState;
|
||||
import appeng.api.storage.cells.ICellHandler;
|
||||
import appeng.api.storage.cells.ICellInventory;
|
||||
import appeng.api.storage.cells.ICellInventoryHandler;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AECableType;
|
||||
@@ -119,7 +120,7 @@ public class DriveTileEntity extends AENetworkInvTileEntity implements IChestOrD
|
||||
newState |= BIT_POWER_MASK;
|
||||
}
|
||||
for (int x = 0; x < this.getCellCount(); x++) {
|
||||
newState |= (this.getCellStatus(x) << (3 * x));
|
||||
newState |= (this.getCellStatus(x).ordinal() << (3 * x));
|
||||
}
|
||||
data.writeInt(newState);
|
||||
|
||||
@@ -213,14 +214,14 @@ public class DriveTileEntity extends AENetworkInvTileEntity implements IChestOrD
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellStatus(final int slot) {
|
||||
public CellState getCellStatus(final int slot) {
|
||||
if (Platform.isClient()) {
|
||||
return (this.state >> (slot * 3)) & 3;
|
||||
return CellState.values()[(this.state >> (slot * 3)) & 3];
|
||||
}
|
||||
|
||||
final DriveWatcher handler = this.invBySlot[slot];
|
||||
if (handler == null) {
|
||||
return 0;
|
||||
return CellState.ABSENT;
|
||||
}
|
||||
|
||||
return handler.getStatus();
|
||||
@@ -277,7 +278,7 @@ public class DriveTileEntity extends AENetworkInvTileEntity implements IChestOrD
|
||||
}
|
||||
|
||||
for (int x = 0; x < this.getCellCount(); x++) {
|
||||
newState |= (this.getCellStatus(x) << (3 * x));
|
||||
newState |= (this.getCellStatus(x).ordinal() << (3 * x));
|
||||
}
|
||||
|
||||
if (newState != this.state) {
|
||||
@@ -446,4 +447,5 @@ public class DriveTileEntity extends AENetworkInvTileEntity implements IChestOrD
|
||||
public ContainerType<?> getContainerType() {
|
||||
return DriveContainer.TYPE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user