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:
@@ -27,8 +27,8 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.cells.ICellWorkbenchItem;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,8 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.storage.ICellContainer;
|
||||
import appeng.api.storage.cells.CellState;
|
||||
import appeng.api.storage.cells.ICellContainer;
|
||||
import appeng.api.util.IOrientable;
|
||||
|
||||
public interface IChestOrDrive extends ICellContainer, IGridHost, IOrientable {
|
||||
@@ -39,19 +40,11 @@ public interface IChestOrDrive extends ICellContainer, IGridHost, IOrientable {
|
||||
int getCellCount();
|
||||
|
||||
/**
|
||||
* 0 - cell is missing.
|
||||
*
|
||||
* 1 - green,
|
||||
*
|
||||
* 2 - orange,
|
||||
*
|
||||
* 3 - red
|
||||
*
|
||||
* @param slot slot index
|
||||
*
|
||||
* @return status of the slot, one of the above indices.
|
||||
*/
|
||||
int getCellStatus(int slot);
|
||||
CellState getCellStatus(int slot);
|
||||
|
||||
/**
|
||||
* @return if the device is online you should check this before providing any
|
||||
|
||||
@@ -26,10 +26,10 @@ package appeng.api.networking.storage;
|
||||
import appeng.api.networking.IGridCache;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.ICellContainer;
|
||||
import appeng.api.storage.ICellProvider;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.cells.ICellContainer;
|
||||
import appeng.api.storage.cells.ICellProvider;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,10 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.IAppEngApi;
|
||||
import appeng.api.storage.cells.ICellGuiHandler;
|
||||
import appeng.api.storage.cells.ICellHandler;
|
||||
import appeng.api.storage.cells.ICellInventoryHandler;
|
||||
import appeng.api.storage.cells.ISaveProvider;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
package appeng.api.storage;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.storage.cells.ICellContainer;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.storage.cells;
|
||||
|
||||
/**
|
||||
* @author yueh
|
||||
*/
|
||||
public enum CellState {
|
||||
/**
|
||||
* No cell at all
|
||||
*/
|
||||
ABSENT,
|
||||
|
||||
/**
|
||||
* A cell without anything stored
|
||||
*/
|
||||
EMPTY,
|
||||
|
||||
/**
|
||||
* Stored something, but neither types nor totally full
|
||||
*/
|
||||
NOT_EMPTY,
|
||||
|
||||
/**
|
||||
* Available types exhausted
|
||||
*/
|
||||
TYPES_FULL,
|
||||
|
||||
/**
|
||||
* Full cell, technically could have free types
|
||||
*/
|
||||
FULL,
|
||||
}
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.storage;
|
||||
package appeng.api.storage.cells;
|
||||
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
|
||||
+3
-1
@@ -1,10 +1,12 @@
|
||||
|
||||
package appeng.api.storage;
|
||||
package appeng.api.storage.cells;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public interface ICellGuiHandler {
|
||||
+8
-6
@@ -21,10 +21,12 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.storage;
|
||||
package appeng.api.storage.cells;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ICellRegistry;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
/**
|
||||
@@ -72,17 +74,17 @@ public interface ICellHandler {
|
||||
*
|
||||
* @return get the status of the cell based on its contents.
|
||||
*/
|
||||
default <T extends IAEStack<T>> int getStatusForCell(ItemStack is, ICellInventoryHandler<T> handler) {
|
||||
default <T extends IAEStack<T>> CellState getStatusForCell(ItemStack is, ICellInventoryHandler<T> handler) {
|
||||
if (handler.getCellInv() != null) {
|
||||
int val = handler.getCellInv().getStatusForCell();
|
||||
CellState val = handler.getCellInv().getStatusForCell();
|
||||
|
||||
if (val == 1 && handler.isPreformatted()) {
|
||||
val = 2;
|
||||
if (val == CellState.EMPTY && handler.isPreformatted()) {
|
||||
val = CellState.TYPES_FULL;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
return 0;
|
||||
return CellState.ABSENT;
|
||||
}
|
||||
|
||||
/**
|
||||
+3
-10
@@ -21,12 +21,13 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.storage;
|
||||
package appeng.api.storage.cells;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public interface ICellInventory<T extends IAEStack<T>> extends IMEInventory<T> {
|
||||
@@ -112,17 +113,9 @@ public interface ICellInventory<T extends IAEStack<T>> extends IMEInventory<T> {
|
||||
int getUnusedItemCount();
|
||||
|
||||
/**
|
||||
* 0 - cell is missing.
|
||||
*
|
||||
* 1 - green, ( usually means available room for types or items. )
|
||||
*
|
||||
* 2 - orange, ( usually means available room for items, but not types. )
|
||||
*
|
||||
* 3 - red, ( usually means the cell is 100% full )
|
||||
*
|
||||
* @return get the status of the cell based on its contents.
|
||||
*/
|
||||
int getStatusForCell();
|
||||
CellState getStatusForCell();
|
||||
|
||||
/**
|
||||
* Tells the cell to persist to NBT
|
||||
+2
-1
@@ -21,11 +21,12 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.storage;
|
||||
package appeng.api.storage.cells;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public interface ICellInventoryHandler<T extends IAEStack<T>> extends IMEInventoryHandler<T> {
|
||||
+4
-1
@@ -21,10 +21,13 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.storage;
|
||||
package appeng.api.storage.cells;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
|
||||
/**
|
||||
* Allows you to provide cells via non IGridHosts directly to the storage
|
||||
* system, drives, and similar features should go though {@link ICellContainer}
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.storage;
|
||||
package appeng.api.storage.cells;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.storage;
|
||||
package appeng.api.storage.cells;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.util;
|
||||
|
||||
@@ -5,7 +27,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.cells.ICellInventoryHandler;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public interface IClientHelper {
|
||||
|
||||
Reference in New Issue
Block a user