mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
API changes to make room for Extra Cells fluid placeholder
This commit is contained in:
1 parent
93d4a7745e
commit
a0454d0e6b
11 files changed
+190
-12
No files matched your search
@@ -175,7 +175,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain() {
|
||||
public double getIdleDrain(ItemStack is) {
|
||||
return this.idleDrain;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class ItemCreativeFluidStorageCell extends AEBaseItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain() {
|
||||
public double getIdleDrain(ItemStack is) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain() {
|
||||
public double getIdleDrain(ItemStack is) {
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,6 @@ public class FluidCellHandler implements ICellHandler {
|
||||
@Override
|
||||
public double cellIdleDrain(final ItemStack is, final IMEInventory handler) {
|
||||
final IFluidCellInventory inv = ((IFluidCellInventoryHandler) handler).getCellInv();
|
||||
return inv.getIdleDrain();
|
||||
return inv.getIdleDrain(is);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package com.glodblock.github.common.storage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInvHandler;
|
||||
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInventory;
|
||||
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -31,15 +34,15 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
private static final String FLUID_SLOT = "#";
|
||||
private static final String FLUID_SLOT_COUNT = "@";
|
||||
protected IStorageFluidCell cellType;
|
||||
private static String[] fluidSlots;
|
||||
private static String[] fluidSlotCount;
|
||||
protected static String[] fluidSlots;
|
||||
protected static String[] fluidSlotCount;
|
||||
protected final ItemStack cellItem;
|
||||
private final ISaveProvider container;
|
||||
private final int MAX_TYPE = 63;
|
||||
private long storedFluidCount;
|
||||
private short storedFluids;
|
||||
protected IItemList<IAEFluidStack> cellFluids;
|
||||
private final NBTTagCompound tagCompound;
|
||||
protected final NBTTagCompound tagCompound;
|
||||
public static final int singleByteAmount = 256 * 8;
|
||||
|
||||
public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
|
||||
@@ -80,6 +83,8 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
try {
|
||||
if (o.getItem() instanceof ItemCreativeFluidStorageCell) {
|
||||
return new FluidCellInventoryHandler(new CreativeFluidCellInventory(o, container2));
|
||||
} else if (o.getItem() instanceof ProxyFluidStorageCell) {
|
||||
return new FluidCellInventoryHandler(new ProxyFluidCellInventory(o, container2));
|
||||
} else {
|
||||
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
|
||||
}
|
||||
@@ -105,8 +110,8 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain() {
|
||||
return this.cellType.getIdleDrain();
|
||||
public double getIdleDrain(ItemStack is) {
|
||||
return this.cellType.getIdleDrain(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.glodblock.github.util.Util;
|
||||
|
||||
public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack> implements IFluidCellInventoryHandler {
|
||||
|
||||
FluidCellInventoryHandler(final IMEInventory<IAEFluidStack> c) {
|
||||
protected FluidCellInventoryHandler(final IMEInventory<IAEFluidStack> c) {
|
||||
super(c, StorageChannel.FLUIDS);
|
||||
|
||||
final IFluidCellInventory ci = this.getCellInv();
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
|
||||
/**
|
||||
* @return idle cost for this Storage Cell
|
||||
*/
|
||||
double getIdleDrain();
|
||||
double getIdleDrain(ItemStack is);
|
||||
|
||||
/**
|
||||
* @return access configured list
|
||||
|
||||
@@ -17,7 +17,7 @@ public interface IStorageFluidCell extends ICellWorkbenchItem {
|
||||
|
||||
boolean isStorageCell(ItemStack i);
|
||||
|
||||
double getIdleDrain();
|
||||
double getIdleDrain(ItemStack is);
|
||||
|
||||
int getTotalTypes(ItemStack cellItem);
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.glodblock.github.crossmod.extracells.storage;
|
||||
|
||||
import com.glodblock.github.common.storage.*;
|
||||
|
||||
|
||||
public class ProxyFluidCellInvHandler extends FluidCellInventoryHandler {
|
||||
|
||||
public ProxyFluidCellInvHandler(FluidCellInventory inv) {
|
||||
super(inv);
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.glodblock.github.crossmod.extracells.storage;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.exceptions.AppEngException;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.common.storage.FluidCellInventory;
|
||||
import com.glodblock.github.common.storage.IFluidCellInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProxyFluidCellInventory extends FluidCellInventory {
|
||||
private static final String EC_CONVERTED = "ec_converted";
|
||||
public ProxyFluidCellInventory(ItemStack o, ISaveProvider container) throws AppEngException {
|
||||
super(o, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadCellFluids() {
|
||||
// If we've already converted the tag to AE2FC, just go to super.
|
||||
// Else, proceed with conversion
|
||||
if (!this.tagCompound.hasKey(EC_CONVERTED)) {
|
||||
if (this.cellFluids == null) {
|
||||
this.cellFluids = AEApi.instance().storage().createFluidList();
|
||||
}
|
||||
this.cellFluids.resetStatus(); // clears totals and stuff.
|
||||
// Load using Extra Cell's NBT format
|
||||
for (int i = 0; i < this.cellType.getTotalTypes(this.cellItem); i++) {
|
||||
FluidStack fs = FluidStack.loadFluidStackFromNBT(tagCompound.getCompoundTag("Fluid#" + i));
|
||||
final AEFluidStack aet = AEFluidStack.create(fs);
|
||||
if (aet != null) {
|
||||
if (aet.getStackSize() > 0) {
|
||||
this.cellFluids.add(aet);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.tagCompound.setBoolean(EC_CONVERTED, true);
|
||||
} else {
|
||||
super.loadCellFluids();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
package com.glodblock.github.crossmod.extracells.storage;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.item.ItemMultiFluidStorageCell;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.crossmod.extracells.ProxyItem;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCell {
|
||||
|
||||
public ProxyFluidStorageCell(String ec2itemName) {
|
||||
super(ec2itemName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytes(ItemStack cellItem) {
|
||||
int meta = cellItem.getItemDamage();
|
||||
if (replacements.containsKey(meta)) {
|
||||
ProxyItemEntry entry = replacements.get(meta);
|
||||
if (entry instanceof ProxyFluidStorageEntry) {
|
||||
return ((ProxyFluidStorageEntry) entry).maxBytes;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType(ItemStack cellItem) {
|
||||
int meta = cellItem.getItemDamage();
|
||||
if (replacements.containsKey(meta)) {
|
||||
ProxyItemEntry entry = replacements.get(meta);
|
||||
if (entry instanceof ProxyFluidStorageEntry) {
|
||||
return ((ProxyFluidStorageEntry) entry).bytesPerType;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
|
||||
if (Config.blacklistEssentiaGas && ModAndClassUtil.ThE && requestedAddition != null) {
|
||||
return ModAndClassUtil.essentiaGas.isInstance(requestedAddition.getFluid());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell(ItemStack i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain(ItemStack is) {
|
||||
int meta = is.getItemDamage();
|
||||
if (replacements.containsKey(meta)) {
|
||||
ProxyItemEntry entry = replacements.get(meta);
|
||||
if (entry instanceof ProxyFluidStorageEntry) {
|
||||
return ((ProxyFluidStorageEntry) entry).idleDrain;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes(ItemStack cellItem) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(ItemStack is) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory(ItemStack is) {
|
||||
return new CellUpgrades(is, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory(ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode(ItemStack is) {
|
||||
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
|
||||
try {
|
||||
return FuzzyMode.valueOf(fz);
|
||||
} catch (final Throwable t) {
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user