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
-1
View File
@@ -84,5 +84,4 @@ public final class Api implements IAppEngApi {
public IClientHelper client() {
return this.client;
}
}
@@ -1,3 +1,20 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2020, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.api;
@@ -7,8 +24,8 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import appeng.api.config.IncludeExclude;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.IClientHelper;
import appeng.core.localization.GuiText;
@@ -48,4 +65,4 @@ public class ApiClientHelper implements IClientHelper {
}
}
}
@@ -20,11 +20,11 @@ package appeng.core.features.registries.cell;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ICellHandler;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.ISaveProvider;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.cells.ISaveProvider;
import appeng.api.storage.data.IAEStack;
import appeng.me.storage.BasicCellInventory;
import appeng.me.storage.BasicCellInventoryHandler;
@@ -7,10 +7,10 @@ import net.minecraft.tileentity.TileEntity;
import appeng.api.AEApi;
import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.storage.ICellGuiHandler;
import appeng.api.storage.ICellHandler;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.ICellGuiHandler;
import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.container.ContainerLocator;
@@ -26,12 +26,12 @@ import com.google.common.base.Verify;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ICellGuiHandler;
import appeng.api.storage.ICellHandler;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.ICellRegistry;
import appeng.api.storage.ISaveProvider;
import appeng.api.storage.IStorageChannel;
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;
public class CellRegistry implements ICellRegistry {
@@ -21,10 +21,11 @@ package appeng.core.features.registries.cell;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.storage.ICellHandler;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.ISaveProvider;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.CellState;
import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.cells.ISaveProvider;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.items.storage.CreativeStorageCellItem;
import appeng.me.storage.CreativeCellInventory;
@@ -47,12 +48,13 @@ public final class CreativeCellHandler implements ICellHandler {
}
@Override
public int getStatusForCell(final ItemStack is, final ICellInventoryHandler handler) {
return 2;
public CellState getStatusForCell(final ItemStack is, final ICellInventoryHandler handler) {
return CellState.TYPES_FULL;
}
@Override
public double cellIdleDrain(final ItemStack is, final ICellInventoryHandler handler) {
return 0;
}
}