add portable fluid cell

This commit is contained in:
GlodBlock committed 2023-01-28 23:15:33 +08:00
1 parent fc9893ac32
commit 80340dbd75
29 files changed
+523 -98

No files matched your search

@@ -125,19 +125,11 @@ public class GuiDualInterface extends GuiUpgradeable {
return;
}
if (btn == this.priority) {
if (isTile()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY_TILE));
} else if (isPart()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY_PART));
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
}
if (btn == this.switcher) {
if (isTile()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
} else if (isPart()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID_PART));
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
}
if (btn == this.interfaceMode) {
@@ -9,9 +9,8 @@ import appeng.helpers.IPriorityHost;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import java.io.IOException;
@@ -59,12 +58,9 @@ public class GuiFCPriority extends FCGuiAmount {
@Override
protected void setOriginGUI(Object target) {
if (target instanceof TileFluidInterface) {
if (target instanceof IDualHost) {
this.myIcon = ItemAndBlockHolder.INTERFACE.stack();
this.originalGui = GuiType.DUAL_INTERFACE;
} else if (target instanceof PartFluidInterface) {
this.myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack();
this.originalGui = GuiType.DUAL_INTERFACE_PART;
} else if (target instanceof PartFluidStorageBus) {
this.myIcon = ItemAndBlockHolder.FLUID_STORAGE_BUS.stack();
this.originalGui = GuiType.FLUID_STORAGE_BUS;
@@ -117,8 +117,7 @@ public class GuiFluidInterface extends AEBaseGui {
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.switcher) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketSwitchGuis(isPart() ? GuiType.DUAL_INTERFACE_PART : GuiType.DUAL_INTERFACE));
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE));
}
}
@@ -0,0 +1,23 @@
package com.glodblock.github.client.gui;
import appeng.container.slot.AppEngSlot;
import com.glodblock.github.client.gui.container.ContainerFluidPortableCell;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiFluidPortableCell extends GuiFluidTerminal {
public GuiFluidPortableCell(final InventoryPlayer inventoryPlayer, final IFluidPortableCell te) {
super(inventoryPlayer, te, new ContainerFluidPortableCell(inventoryPlayer, te));
}
@Override
protected void repositionSlot(final AppEngSlot s) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
@Override
protected int getMaxRows() {
return 3;
}
}
@@ -80,7 +80,7 @@ public class GuiFluidStorageBus extends GuiUpgradeable {
} else if (btn == this.clear) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
} else if (btn == this.priority) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY_PART));
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
} else if (btn == this.rwMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
}
@@ -39,6 +39,14 @@ public class GuiFluidTerminal extends GuiFluidMonitor {
this.showViewBtn = false;
}
public GuiFluidTerminal(
final InventoryPlayer inventoryPlayer, final ITerminalHost te, final ContainerFluidMonitor c) {
super(inventoryPlayer, te, c);
this.container = c;
this.player = inventoryPlayer.player;
this.showViewBtn = false;
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
@@ -25,6 +25,7 @@ import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
@@ -58,7 +59,9 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
this.monitor = monitorable.getFluidInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
if (monitorable instanceof IPortableCell) {
if (monitorable instanceof IFluidPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
@@ -0,0 +1,68 @@
package com.glodblock.github.client.gui.container;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.util.Platform;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class ContainerFluidPortableCell extends ContainerFluidMonitor {
private double powerMultiplier = 0.5;
private final IFluidPortableCell civ;
private int ticks = 0;
private final int slot;
public ContainerFluidPortableCell(final InventoryPlayer ip, final IFluidPortableCell monitorable) {
super(ip, monitorable, false);
if (monitorable != null) {
final int slotIndex = monitorable.getInventorySlot();
this.lockPlayerInventorySlot(slotIndex);
this.slot = slotIndex;
} else {
this.slot = -1;
this.lockPlayerInventorySlot(ip.currentItem);
}
this.civ = monitorable;
this.bindPlayerInventory(ip, 0, 0);
}
@Override
public void detectAndSendChanges() {
final ItemStack currentItem = this.slot < 0
? this.getPlayerInv().getCurrentItem()
: this.getPlayerInv().getStackInSlot(this.slot);
if (this.civ != null) {
if (currentItem != this.civ.getItemStack()) {
if (currentItem != null) {
if (Platform.isSameItem(this.civ.getItemStack(), currentItem)) {
this.getPlayerInv()
.setInventorySlotContents(this.getPlayerInv().currentItem, this.civ.getItemStack());
} else {
this.setValidContainer(false);
}
} else {
this.setValidContainer(false);
}
}
} else {
this.setValidContainer(false);
}
this.ticks++;
if (this.ticks > 10 && this.civ != null) {
this.civ.extractAEPower(
this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
this.ticks = 0;
}
super.detectAndSendChanges();
}
private double getPowerMultiplier() {
return this.powerMultiplier;
}
void setPowerMultiplier(final double powerMultiplier) {
this.powerMultiplier = powerMultiplier;
}
}
@@ -14,6 +14,7 @@ public class Config {
public static boolean fluidIOBus;
public static boolean removeRecipe;
public static boolean blacklistEssentiaGas;
public static double portableCellBattery;
public static void run() {
loadCategory();
@@ -43,6 +44,8 @@ public class Config {
"Fluid Craft for AE2",
true,
"Blacklist Essentia Gas from Thaumic Energistics, so they won't be stored in Fluid Storage Cells.");
portableCellBattery = Config.get("Fluid Craft for AE2", "Portable Fluid Cell Battery Capacity", 20000D)
.getDouble();
if (Config.hasChanged()) Config.save();
}
@@ -6,6 +6,7 @@ import com.glodblock.github.common.item.FCBaseItemBlock;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileFluidDiscretizer;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -40,7 +41,7 @@ public class BlockFluidDiscretizer extends FCBaseBlock {
final boolean advancedToolTips) {
if (isShiftKeyDown()) {
toolTip.addAll(this.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_FLUID_DISCRETIZER_DESC)));
toolTip.addAll(RenderUtil.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_FLUID_DISCRETIZER_DESC)));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
@@ -9,6 +9,7 @@ import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -65,7 +66,8 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
final List<String> toolTip,
final boolean advancedToolTips) {
if (isShiftKeyDown()) {
toolTip.addAll(this.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_FLUID_PACKET_DECODER_DESC)));
toolTip.addAll(
RenderUtil.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_FLUID_PACKET_DECODER_DESC)));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
@@ -13,6 +13,7 @@ import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -83,7 +84,7 @@ public class BlockLevelMaintainer extends FCBaseBlock {
if (isShiftKeyDown() && isCtrlKeyDown()) {
toolTip.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_WHO_AM_I));
} else if (isShiftKeyDown()) {
toolTip.addAll(this.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_DESC)));
toolTip.addAll(RenderUtil.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_DESC)));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
@@ -9,7 +9,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -47,11 +46,6 @@ public abstract class FCBaseBlock extends AEBaseTileBlock implements IRegister<F
final List<String> toolTip,
final boolean advancedToolTips) {}
@SuppressWarnings("unchecked")
protected final List<String> listFormattedStringToWidth(String str) {
return Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(str, 150);
}
public void addCheckedInformation(
ItemStack itemStack, EntityPlayer player, List<String> toolTip, boolean advancedToolTips) {
this.addInformation(itemStack, player, toolTip, advancedToolTips);
@@ -260,14 +260,6 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
public String getOreFilter(ItemStack is) {
return Platform.openNbtData(is).getString("OreFilter");
}
public void setOreFilter(ItemStack is, String filter) {
Platform.openNbtData(is).setString("OreFilter", filter);
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) {
this.disassembleDrive(stack, world, player);
@@ -0,0 +1,183 @@
package com.glodblock.github.common.item;
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.core.localization.GuiText;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
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.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IItemInventory;
import com.glodblock.github.inventory.item.PortableFluidCellInventory;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import com.google.common.base.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class ItemPortableFluidCell extends AEBasePoweredItem
implements IStorageFluidCell, IItemInventory, IRegister<ItemPortableFluidCell> {
public ItemPortableFluidCell() {
super(Config.portableCellBattery, Optional.absent());
setUnlocalizedName(NameConst.ITEM_FLUID_PORTABLE_CELL);
setTextureName(FluidCraft.resource(NameConst.ITEM_FLUID_PORTABLE_CELL).toString());
this.setFeature(EnumSet.of(AEFeature.PortableCell, AEFeature.StorageCells, AEFeature.PoweredTools));
}
@Override
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
InventoryHandler.openGui(
player,
w,
new BlockPos(player.inventory.currentItem, 0, 0),
ForgeDirection.UNKNOWN,
GuiType.PORTABLE_FLUID_CELL);
return item;
}
@SideOnly(Side.CLIENT)
@Override
public boolean isFull3D() {
return false;
}
@SideOnly(Side.CLIENT)
@Override
public void addCheckedInformation(
final ItemStack stack, final EntityPlayer player, final List<String> lines, final boolean displayMoreInfo) {
super.addCheckedInformation(stack, player, lines, 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 (cellInventory != null) {
lines.add(EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY + " " + GuiText.Of.getLocal() + " "
+ EnumChatFormatting.DARK_GREEN + cellInventory.getTotalBytes() + " "
+ EnumChatFormatting.GRAY + GuiText.BytesUsed.getLocal());
lines.add(EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY + " " + GuiText.Of.getLocal() + " "
+ EnumChatFormatting.DARK_GREEN + cellInventory.getTotalFluidTypes() + " "
+ EnumChatFormatting.GRAY + GuiText.Types.getLocal());
}
}
if (GuiScreen.isShiftKeyDown()) {
lines.addAll(RenderUtil.listFormattedStringToWidth(
StatCollector.translateToLocalFormatted(NameConst.TT_CELL_PORTABLE)));
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_SHIFT_FOR_MORE));
}
}
@Override
public int getBytes(final ItemStack cellItem) {
return 256;
}
@Override
public int getBytesPerType(final ItemStack cellItem) {
return 8;
}
@Override
public int getTotalTypes(final ItemStack cellItem) {
return 5;
}
@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(final ItemStack i) {
return true;
}
@Override
public double getIdleDrain() {
return 0.5;
}
@Override
public boolean isEditable(final ItemStack is) {
return true;
}
@Override
public IInventory getUpgradesInventory(final ItemStack is) {
return new CellUpgrades(is, 0);
}
@Override
public IInventory getConfigInventory(final ItemStack is) {
return new CellConfig(is);
}
@Override
public FuzzyMode getFuzzyMode(final 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(final ItemStack is, final FuzzyMode fzMode) {
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
@Override
public ItemPortableFluidCell register() {
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_PORTABLE_CELL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public Object getInventory(ItemStack stack, World world, int x, int y, int z) {
return new PortableFluidCellInventory(stack, x);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -268,7 +268,7 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
this.getHost().getTile().getWorldObj(),
new BlockPos(this.getHost().getTile()),
Objects.requireNonNull(this.getSide()),
GuiType.DUAL_INTERFACE_PART);
GuiType.DUAL_INTERFACE);
}
return true;
}
@@ -1,16 +1,15 @@
package com.glodblock.github.common.storage;
import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.networking.security.PlayerSource;
import appeng.api.storage.*;
import appeng.client.texture.ExtraBlockTextures;
import com.glodblock.github.util.ModAndClassUtil;
import extracells.network.GuiHandler;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
public class FluidCellHandler implements ICellHandler {
@@ -52,17 +51,11 @@ public class FluidCellHandler implements ICellHandler {
final IMEInventoryHandler inv,
final ItemStack is,
final StorageChannel chan) {
if (ModAndClassUtil.EC2) {
if (chan == StorageChannel.FLUIDS) {
IStorageMonitorable monitorable = null;
if (chest != null) {
monitorable =
((IMEChest) chest).getMonitorable(ForgeDirection.UNKNOWN, new PlayerSource(player, chest));
}
if (monitorable != null) {
GuiHandler.launchGui(
GuiHandler.getGuiId(0), player, new Object[] {monitorable.getFluidInventory()});
}
if (chan == StorageChannel.FLUIDS) {
if (chest instanceof TileEntity) {
TileEntity te = (TileEntity) chest;
InventoryHandler.openGui(
player, te.getWorldObj(), new BlockPos(te), chest.getUp(), GuiType.FLUID_TERMINAL);
}
}
}
@@ -31,7 +31,7 @@ public class FluidCellInventory implements IFluidCellInventory {
private static String[] fluidSlotCount;
private final ItemStack cellItem;
private final ISaveProvider container;
private final int MAX_TYPE = 1;
private final int MAX_TYPE = 63;
private long storedFluidCount;
private short storedFluids;
private IItemList<IAEFluidStack> cellFluids;
@@ -137,7 +137,7 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public long getTotalFluidTypes() {
return MAX_TYPE;
return this.cellType.getTotalTypes(this.cellItem);
}
@Override
@@ -3,17 +3,16 @@ package com.glodblock.github.inventory.gui;
import appeng.api.storage.ITerminalHost;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.container.implementations.ContainerCraftingStatus;
import appeng.container.implementations.ContainerInterface;
import appeng.container.implementations.ContainerPriority;
import appeng.helpers.IPriorityHost;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.*;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.common.parts.base.FCPart;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.common.tile.*;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.google.common.collect.ImmutableList;
import java.util.List;
import javax.annotation.Nullable;
@@ -31,6 +30,7 @@ public enum GuiType {
return new GuiFluidLevelEmitter(player.inventory, inv);
}
}),
LEVEL_MAINTAINER(new TileGuiFactory<TileLevelMaintainer>(TileLevelMaintainer.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileLevelMaintainer inv) {
@@ -42,6 +42,7 @@ public enum GuiType {
return new GuiLevelMaintainer(player.inventory, inv);
}
}),
OC_PATTERN_EDITOR(new TileGuiFactory<TileOCPatternEditor>(TileOCPatternEditor.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileOCPatternEditor inv) {
@@ -54,31 +55,7 @@ public enum GuiType {
}
}),
DUAL_INTERFACE_PART(new PartGuiFactory<PartFluidInterface>(PartFluidInterface.class) {
@Override
protected Object createServerGui(EntityPlayer player, PartFluidInterface inv) {
return new ContainerInterface(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, PartFluidInterface inv) {
return new GuiDualInterface(player.inventory, inv);
}
}),
DUAL_INTERFACE_FLUID_PART(new PartGuiFactory<PartFluidInterface>(PartFluidInterface.class) {
@Override
protected Object createServerGui(EntityPlayer player, PartFluidInterface inv) {
return new ContainerFluidInterface(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, PartFluidInterface inv) {
return new GuiFluidInterface(player.inventory, inv);
}
}),
DUAL_INTERFACE(new TileGuiFactory<TileFluidInterface>(TileFluidInterface.class) {
DUAL_INTERFACE(new TileOrPartGuiFactory<TileFluidInterface>(TileFluidInterface.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileFluidInterface inv) {
return new ContainerDualInterface(player.inventory, inv);
@@ -90,7 +67,7 @@ public enum GuiType {
}
}),
DUAL_INTERFACE_FLUID(new TileGuiFactory<TileFluidInterface>(TileFluidInterface.class) {
DUAL_INTERFACE_FLUID(new TileOrPartGuiFactory<TileFluidInterface>(TileFluidInterface.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileFluidInterface inv) {
return new ContainerFluidInterface(player.inventory, inv);
@@ -102,19 +79,7 @@ public enum GuiType {
}
}),
PRIORITY_PART(new PartGuiFactory<IPriorityHost>(IPriorityHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, IPriorityHost inv) {
return new ContainerPriority(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IPriorityHost inv) {
return new GuiFCPriority(player.inventory, inv);
}
}),
PRIORITY_TILE(new TileGuiFactory<IPriorityHost>(IPriorityHost.class) {
PRIORITY(new TileOrPartGuiFactory<IPriorityHost>(IPriorityHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, IPriorityHost inv) {
return new ContainerPriority(player.inventory, inv);
@@ -186,7 +151,7 @@ public enum GuiType {
}
}),
FLUID_TERMINAL(new PartGuiFactory<ITerminalHost>(ITerminalHost.class) {
FLUID_TERMINAL(new TileOrPartGuiFactory<ITerminalHost>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
return new ContainerFluidMonitor(player.inventory, inv);
@@ -198,6 +163,18 @@ public enum GuiType {
}
}),
PORTABLE_FLUID_CELL(new ItemGuiFactory<IFluidPortableCell>(IFluidPortableCell.class) {
@Override
protected Object createServerGui(EntityPlayer player, IFluidPortableCell inv) {
return new ContainerFluidPortableCell(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IFluidPortableCell inv) {
return new GuiFluidPortableCell(player.inventory, inv);
}
}),
FLUID_PATTERN_TERMINAL(new PartGuiFactory<ITerminalHost>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
@@ -0,0 +1,65 @@
package com.glodblock.github.inventory.gui;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerOpenContext;
import com.glodblock.github.inventory.item.IItemInventory;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public abstract class ItemGuiFactory<T> implements IGuiFactory {
protected final Class<T> invClass;
ItemGuiFactory(Class<T> invClass) {
this.invClass = invClass;
}
@Nullable
protected T getInventory(Object inv) {
return invClass.isInstance(inv) ? invClass.cast(inv) : null;
}
@Nullable
@Override
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ItemStack item = player.getHeldItem();
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
T inv = getInventory(((IItemInventory) item.getItem()).getInventory(item, world, x, y, z));
if (inv == null) {
return null;
}
Object gui = createServerGui(player, inv);
if (gui instanceof AEBaseContainer) {
ContainerOpenContext ctx = new ContainerOpenContext(inv);
ctx.setWorld(world);
ctx.setX(x);
ctx.setY(y);
ctx.setZ(z);
ctx.setSide(face);
((AEBaseContainer) gui).setOpenContext(ctx);
}
return gui;
}
@Nullable
protected abstract Object createServerGui(EntityPlayer player, T inv);
@Nullable
@Override
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ItemStack item = player.getHeldItem();
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
T inv = getInventory(((IItemInventory) item.getItem()).getInventory(item, world, x, y, z));
return inv != null ? createClientGui(player, inv) : null;
}
@Nullable
protected abstract Object createClientGui(EntityPlayer player, T inv);
}
@@ -0,0 +1,26 @@
package com.glodblock.github.inventory.gui;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import javax.annotation.Nullable;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public abstract class TileOrPartGuiFactory<T> extends TileGuiFactory<T> {
TileOrPartGuiFactory(Class<T> invClass) {
super(invClass);
}
@Nullable
@Override
protected T getInventory(TileEntity tile, ForgeDirection face) {
if (tile instanceof IPartHost) {
IPart part = ((IPartHost) tile).getPart(face);
if (invClass.isInstance(part)) {
return invClass.cast(part);
}
}
return super.getInventory(tile, face);
}
}
@@ -0,0 +1,8 @@
package com.glodblock.github.inventory.item;
import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.storage.ITerminalHost;
import appeng.container.interfaces.IInventorySlotAware;
public interface IFluidPortableCell extends ITerminalHost, IInventorySlotAware, IEnergySource, IGuiItemObject {}
@@ -0,0 +1,9 @@
package com.glodblock.github.inventory.item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IItemInventory {
Object getInventory(ItemStack stack, World world, int x, int y, int z);
}
@@ -0,0 +1,71 @@
package com.glodblock.github.inventory.item;
import appeng.api.config.*;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.MEMonitorHandler;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.IConfigManager;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import com.glodblock.github.common.storage.FluidCellInventory;
import java.util.Objects;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class PortableFluidCellInventory extends MEMonitorHandler<IAEFluidStack> implements IFluidPortableCell {
private final ItemStack target;
private final IAEItemPowerStorage ips;
private final int inventorySlot;
public PortableFluidCellInventory(final ItemStack is, final int slot) {
super(Objects.requireNonNull(FluidCellInventory.getCell(is, null)));
this.ips = (IAEItemPowerStorage) is.getItem();
this.target = is;
this.inventorySlot = slot;
}
@Override
public int getInventorySlot() {
return this.inventorySlot;
}
@Override
public ItemStack getItemStack() {
return this.target;
}
@Override
public double extractAEPower(double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier) {
amt = usePowerMultiplier.multiply(amt);
if (mode == Actionable.SIMULATE) {
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
}
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory() {
return null;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory() {
return this;
}
@Override
public IConfigManager getConfigManager() {
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
final NBTTagCompound data = Platform.openNbtData(PortableFluidCellInventory.this.target);
manager.writeToNBT(data);
});
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
return out;
}
}
@@ -29,6 +29,7 @@ public class ItemAndBlockHolder {
public static ItemFluidLevelEmitter FLUID_LEVEL_EMITTER = new ItemFluidLevelEmitter().register();
public static ItemFluidStorageMonitor FLUID_STORAGE_MONITOR = new ItemFluidStorageMonitor().register();
public static ItemFluidConversionMonitor FLUID_CONVERSION_MONITOR = new ItemFluidConversionMonitor().register();
public static ItemPortableFluidCell PORTABLE_FLUID_CELL = new ItemPortableFluidCell().register();
public static ItemFluidPacket PACKET = new ItemFluidPacket().register();
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 1).register();
public static ItemBasicFluidStorageCell CELL4K = new ItemBasicFluidStorageCell(CellType.Cell4kPart, 4).register();
@@ -31,6 +31,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_FLUID_PORTABLE_CELL = "portable_fluid_cell";
public static final String ITEM_FLUID_PART = "fluid_part";
public static final String TT_KEY = FluidCraft.MODID + ".tooltip.";
@@ -66,6 +67,7 @@ public class NameConst {
public static final String TT_LEVEL_MAINTAINER_EXPORT_DESC = TT_LEVEL_MAINTAINER + "export_desc";
public static final String TT_CELL_CONTENTS = TT_KEY + "cell_contents";
public static final String TT_CELL_EMPTY = TT_KEY + "cell_empty";
public static final String TT_CELL_PORTABLE = TT_KEY + "cell_portable";
public static final String WAILA_KEY = FluidCraft.MODID + ".waila.";
public static final String WAILA_ENABLE = WAILA_KEY + "enable";
@@ -1,6 +1,7 @@
package com.glodblock.github.util;
import appeng.api.storage.data.IAEFluidStack;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
@@ -66,4 +67,9 @@ public final class RenderUtil {
}
}
}
@SuppressWarnings("unchecked")
public static List<String> listFormattedStringToWidth(String str) {
return Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(str, 150);
}
}
@@ -10,6 +10,7 @@ item.part_fluid_storage_bus.name=ME Fluid Storage Bus
item.part_fluid_level_emitter.name=ME Fluid Level Emitter
item.part_fluid_storage_monitor.name=ME Fluid Storage Monitor
item.part_fluid_conversion_monitor.name=ME Fluid Conversion Monitor
item.portable_fluid_cell.name=Portable Fluid Cell
item.fluid_packet.name=Fluid Packet
item.fluid_storage.1.name=%s1k%s ME Fluid Storage Cell
item.fluid_storage.4.name=%s4k%s ME Fluid Storage Cell
@@ -67,6 +68,7 @@ ae2fc.tooltip.level_maintainer.request_size.hint=The count defines how many item
ae2fc.tooltip.cell_contents=Contains Fluid:
ae2fc.tooltip.cell_empty=Cell is empty
ae2fc.tooltip.cell_portable=Right click to open its GUI. It works like a backpack, but you need to charge it before using.
ae2fc.tooltip.fluid_terminal=uh So we don't need EC2 anymore?
ae2fc.tooltip.invalid_fluid=Invalid fluid!
ae2fc.tooltip.encode_pattern=Encode Patter
Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B