mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
add Creative ME Fluid Storage Cell
This commit is contained in:
1 parent
8d14239c53
commit
879993cf22
8 files changed
+232
-6
No files matched your search
@@ -0,0 +1,146 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.storage.IFluidCellInventory;
|
||||
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemCreativeFluidStorageCell extends AEBaseItem
|
||||
implements IStorageFluidCell, IRegister<ItemCreativeFluidStorageCell> {
|
||||
|
||||
public ItemCreativeFluidStorageCell() {
|
||||
super();
|
||||
setUnlocalizedName(NameConst.ITEM_CREATIVE_FLUID_STORAGE);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_CREATIVE_FLUID_STORAGE).toString());
|
||||
this.setFeature(EnumSet.of(AEFeature.StorageCells));
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(ItemStack cellItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType(ItemStack cellItem) {
|
||||
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() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes(ItemStack cellItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@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 addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
|
||||
final boolean displayMoreInfo) {
|
||||
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
|
||||
.getCellInventory(stack, null, StorageChannel.FLUIDS);
|
||||
|
||||
if (inventory instanceof IFluidCellInventoryHandler) {
|
||||
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
|
||||
final IFluidCellInventory cellInventory = handler.getCellInv();
|
||||
|
||||
if (GuiScreen.isCtrlKeyDown()) {
|
||||
if (cellInventory.getContents().size() > 0) {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
|
||||
for (IAEFluidStack fluid : cellInventory.getContents()) {
|
||||
if (fluid != null) {
|
||||
lines.add(String.format(" %s", fluid.getFluidStack().getLocalizedName()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {
|
||||
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCreativeFluidStorageCell register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_CREATIVE_FLUID_STORAGE, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.glodblock.github.common.storage;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
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.data.IAEFluidStack;
|
||||
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public class CreativeFluidCellInventory extends FluidCellInventory {
|
||||
|
||||
public CreativeFluidCellInventory(ItemStack o, ISaveProvider container) throws AppEngException {
|
||||
super(o, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActionSource src) {
|
||||
if (input == null || input.getStackSize() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (this.cellType.isBlackListed(this.cellItem, input)) {
|
||||
return input;
|
||||
}
|
||||
if (this.getCellFluids().findPrecise(input) != null) {
|
||||
return null;
|
||||
} else {
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src) {
|
||||
if (request == null) {
|
||||
return null;
|
||||
}
|
||||
if (this.getCellFluids().findPrecise(request) != null) {
|
||||
return request.copy();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadCellFluids() {
|
||||
if (this.cellFluids == null) {
|
||||
this.cellFluids = AEApi.instance().storage().createFluidList();
|
||||
}
|
||||
this.cellFluids.resetStatus(); // clears totals and stuff.
|
||||
IInventory inv = this.cellType.getConfigInventory(this.cellItem);
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack is = inv.getStackInSlot(i);
|
||||
if (Util.FluidUtil.isFluidContainer(is)) {
|
||||
FluidStack fs = Util.getFluidFromItem(is);
|
||||
if (fs == null) continue;
|
||||
IAEFluidStack iaeFluidStack = Util.FluidUtil.createAEFluidStack(fs);
|
||||
if (this.cellFluids.findPrecise(iaeFluidStack) == null) {
|
||||
iaeFluidStack.setStackSize(Integer.MAX_VALUE);
|
||||
this.cellFluids.add(iaeFluidStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,21 +22,23 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
import com.glodblock.github.common.item.ItemCreativeFluidStorageCell;
|
||||
|
||||
public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
private static final String FLUID_TYPE_TAG = "ft";
|
||||
private static final String FLUID_COUNT_TAG = "fc";
|
||||
private static final String FLUID_SLOT = "#";
|
||||
private static final String FLUID_SLOT_COUNT = "@";
|
||||
private IStorageFluidCell cellType;
|
||||
protected IStorageFluidCell cellType;
|
||||
private static String[] fluidSlots;
|
||||
private static String[] fluidSlotCount;
|
||||
private final ItemStack cellItem;
|
||||
protected final ItemStack cellItem;
|
||||
private final ISaveProvider container;
|
||||
private final int MAX_TYPE = 63;
|
||||
private long storedFluidCount;
|
||||
private short storedFluids;
|
||||
private IItemList<IAEFluidStack> cellFluids;
|
||||
protected IItemList<IAEFluidStack> cellFluids;
|
||||
private final NBTTagCompound tagCompound;
|
||||
public static final int singleByteAmount = 256 * 8;
|
||||
|
||||
@@ -76,7 +78,11 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, final ISaveProvider container2) {
|
||||
try {
|
||||
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
|
||||
if (o.getItem() instanceof ItemCreativeFluidStorageCell) {
|
||||
return new FluidCellInventoryHandler(new CreativeFluidCellInventory(o, container2));
|
||||
} else {
|
||||
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
|
||||
}
|
||||
} catch (final AppEngException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -185,7 +191,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
return 3;
|
||||
}
|
||||
|
||||
private void loadCellFluids() {
|
||||
protected void loadCellFluids() {
|
||||
if (this.cellFluids == null) {
|
||||
this.cellFluids = AEApi.instance().storage().createFluidList();
|
||||
}
|
||||
@@ -203,7 +209,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
}
|
||||
}
|
||||
|
||||
private IItemList<IAEFluidStack> getCellFluids() {
|
||||
protected IItemList<IAEFluidStack> getCellFluids() {
|
||||
if (this.cellFluids == null) {
|
||||
this.loadCellFluids();
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public class ItemAndBlockHolder {
|
||||
.register();
|
||||
public static ItemBasicFluidStorageCell CELL16384K = new ItemBasicFluidStorageCell(CellType.Cell16384kPart, 16384)
|
||||
.register();
|
||||
public static ItemCreativeFluidStorageCell CREATIVE_CELL = new ItemCreativeFluidStorageCell().register();
|
||||
public static ItemBasicFluidStoragePart CELL_PART = new ItemBasicFluidStoragePart().register();
|
||||
|
||||
public static void loadSetting() {
|
||||
|
||||
@@ -35,6 +35,7 @@ public class NameConst {
|
||||
public static final String ITEM_PART_FLUID_LEVEL_EMITTER = "part_fluid_level_emitter";
|
||||
public static final String ITEM_FLUID_PACKET = "fluid_packet";
|
||||
public static final String ITEM_FLUID_STORAGE = "fluid_storage";
|
||||
public static final String ITEM_CREATIVE_FLUID_STORAGE = "creative_" + ITEM_FLUID_STORAGE;
|
||||
public static final String ITEM_FLUID_PORTABLE_CELL = "portable_fluid_cell";
|
||||
public static final String ITEM_WIRELESS_FLUID_TERMINAL = "wireless_fluid_terminal";
|
||||
public static final String ITEM_WIRELESS_INTERFACE_TERMINAL = "wireless_interface_terminal";
|
||||
|
||||
@@ -21,6 +21,7 @@ item.wireless_ultra_terminal.WIRELESS_ESSENTIA_TERMINAL.name=Universal Wireless
|
||||
item.wireless_ultra_terminal.WIRELESS_INTERFACE_TERMINAL.name=Universal Wireless Terminal - Interface
|
||||
item.wireless_ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL_EX.name=Universal Wireless Terminal - Processing Pattern
|
||||
item.fluid_packet.name=Fluid Packet
|
||||
item.creative_fluid_storage.name=Creative ME Fluid Storage Cell
|
||||
item.fluid_storage.1.name=%s1k%s ME Fluid Storage Cell
|
||||
item.fluid_storage.4.name=%s4k%s ME Fluid Storage Cell
|
||||
item.fluid_storage.16.name=%s16k%s ME Fluid Storage Cell
|
||||
|
||||
@@ -21,6 +21,7 @@ item.wireless_ultra_terminal.WIRELESS_ESSENTIA_TERMINAL.name=无线ME通用终
|
||||
item.wireless_ultra_terminal.WIRELESS_INTERFACE_TERMINAL.name=无线ME通用终端 - 接口
|
||||
item.wireless_ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL_EX.name=无线ME通用终端 - 增广样板
|
||||
item.fluid_packet.name=流体封包
|
||||
item.creative_fluid_storage.name=创造ME流体存储元件
|
||||
item.fluid_storage.1.name=%s1k%s-ME流体存储元件
|
||||
item.fluid_storage.4.name=%s4k%s-ME流体存储元件
|
||||
item.fluid_storage.16.name=%s16k%s-ME流体存储元件
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 366 B |
Reference in new issue
Block a user