mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
Universal GUI (#340)
Co-authored-by: Kogepan229 <[email protected]> Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
213 files changed
+1859
-19432
No files matched your search
@@ -11,14 +11,12 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import com.glodblock.github.client.render.RenderBlockFluidInterface;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
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 appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -50,12 +48,7 @@ public class BlockFluidInterface extends FCBaseBlock {
|
||||
final TileInterface tg = this.getTileEntity(world, x, y, z);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.DUAL_INTERFACE);
|
||||
Platform.openGUI(player, tg, ForgeDirection.getOrientation(facing), GuiBridge.GUI_INTERFACE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,70 +1,33 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
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;
|
||||
|
||||
import com.glodblock.github.api.FluidCraftAPI;
|
||||
import com.glodblock.github.common.storage.CellType;
|
||||
import com.glodblock.github.common.storage.FluidCellInventory;
|
||||
import com.glodblock.github.common.storage.FluidCellInventoryHandler;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.inventory.FluidCellConfig;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.ICellRestriction;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.IterationCounter;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
import appeng.items.AEBaseCell;
|
||||
|
||||
public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluidCell, ICellRestriction {
|
||||
public abstract class FCBaseItemCell extends AEBaseCell {
|
||||
|
||||
protected CellType component;
|
||||
protected long totalBytes;
|
||||
protected int perType;
|
||||
protected double idleDrain;
|
||||
protected int maxType = 1;
|
||||
private final ReadableNumberConverter format = ReadableNumberConverter.INSTANCE;
|
||||
|
||||
@SuppressWarnings("Guava")
|
||||
public FCBaseItemCell(long bytes, int perType, int totalType, double drain) {
|
||||
super(Optional.of(bytes / 1024 + "k"));
|
||||
this.setFeature(EnumSet.of(AEFeature.StorageCells));
|
||||
this.setMaxStackSize(1);
|
||||
this.totalBytes = bytes;
|
||||
this.perType = perType;
|
||||
this.idleDrain = drain;
|
||||
this.maxType = totalType;
|
||||
this.totalTypes = totalType;
|
||||
this.component = null;
|
||||
}
|
||||
|
||||
public FCBaseItemCell(final Optional<String> subName) {
|
||||
@Override
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
public FCBaseItemCell(Optional subName) {
|
||||
super(subName);
|
||||
}
|
||||
|
||||
@@ -76,226 +39,6 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
|
||||
return component.stack(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytes(ItemStack cellItem) {
|
||||
return this.totalBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType(ItemStack cellItem) {
|
||||
return this.perType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
|
||||
return requestedAddition == null || requestedAddition.getFluid() == null
|
||||
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
|
||||
}
|
||||
|
||||
@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 final FluidCellInventoryHandler handler) {
|
||||
final FluidCellInventory cellInventory = (FluidCellInventory) handler.getCellInv();
|
||||
|
||||
if (cellInventory != null) {
|
||||
lines.add(
|
||||
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getUsedBytes())
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ " "
|
||||
+ GuiText.Of.getLocal()
|
||||
+ " "
|
||||
+ EnumChatFormatting.DARK_GREEN
|
||||
+ NumberFormat.getInstance().format(cellInventory.getTotalBytes())
|
||||
+ " "
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ GuiText.BytesUsed.getLocal());
|
||||
lines.add(
|
||||
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getStoredFluidTypes())
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ " "
|
||||
+ GuiText.Of.getLocal()
|
||||
+ " "
|
||||
+ EnumChatFormatting.DARK_GREEN
|
||||
+ cellInventory.getMaxFluidTypes()
|
||||
+ " "
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ GuiText.Types.getLocal());
|
||||
|
||||
if (GuiScreen.isCtrlKeyDown()) {
|
||||
if (cellInventory.getStoredFluidTypes() > 0) {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
|
||||
for (IAEFluidStack fluid : cellInventory.getContents()) {
|
||||
if (fluid != null) {
|
||||
lines.add(
|
||||
String.format(
|
||||
" %s x%s mB",
|
||||
fluid.getFluidStack().getLocalizedName(),
|
||||
format.toWideReadableForm(fluid.getStackSize())));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
|
||||
}
|
||||
|
||||
if (handler.isPreformatted()) {
|
||||
final String list = (handler.getWhitelist() == IncludeExclude.WHITELIST ? GuiText.Included
|
||||
: GuiText.Excluded).getLocal();
|
||||
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal());
|
||||
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
lines.add(GuiText.Filter.getLocal() + ": ");
|
||||
for (IAEFluidStack aeFluidStack : handler.getPartitionInv()) {
|
||||
if (aeFluidStack != null) lines.add(" " + aeFluidStack.getFluidStack().getLocalizedName());
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_SHIFT_FOR_MORE));
|
||||
}
|
||||
if (handler.getSticky()) {
|
||||
lines.add(GuiText.Sticky.getLocal());
|
||||
}
|
||||
}
|
||||
List<Object> restricted = handler.getRestricted();
|
||||
if (restricted != null && ((long) restricted.get(0) != 0 || (byte) restricted.get(1) != 0)) {
|
||||
lines.add(GuiText.Restricted.getLocal());
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
if ((long) restricted.get(0) != 0)
|
||||
lines.add(GuiText.MaxFluid.getLocal() + " " + nf.format((long) restricted.get(0)) + " mB");
|
||||
if ((byte) restricted.get(1) != 0)
|
||||
lines.add(GuiText.MaxTypes.getLocal() + " " + restricted.get(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell(ItemStack i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain(ItemStack is) {
|
||||
return this.idleDrain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes(final ItemStack cellItem) {
|
||||
return this.maxType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(ItemStack is) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory(ItemStack is) {
|
||||
return new CellUpgrades(is, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory(ItemStack is) {
|
||||
return new FluidCellConfig(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) {
|
||||
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCellData(ItemStack is) {
|
||||
return totalBytes + ","
|
||||
+ this.getTotalTypes(null)
|
||||
+ ","
|
||||
+ this.getBytesPerType(null)
|
||||
+ ","
|
||||
+ 256 * 8
|
||||
+ ","
|
||||
+ Platform.openNbtData(is).getByte("cellRestrictionTypes")
|
||||
+ ","
|
||||
+ Platform.openNbtData(is).getLong("cellRestrictionAmount")
|
||||
+ ","
|
||||
+ "fluid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCellRestriction(ItemStack is, String newData) {
|
||||
List<String> data = Arrays.asList(newData.split(",", 2));
|
||||
Platform.openNbtData(is).setByte("cellRestrictionTypes", Byte.parseByte(data.get(0)));
|
||||
Platform.openNbtData(is).setLong("cellRestrictionAmount", Long.parseLong(data.get(1)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
|
||||
if (player.isSneaking()) {
|
||||
if (Platform.isClient()) {
|
||||
return false;
|
||||
}
|
||||
final InventoryPlayer playerInventory = player.inventory;
|
||||
final IMEInventoryHandler<?> inv = AEApi.instance().registries().cell()
|
||||
.getCellInventory(stack, null, StorageChannel.FLUIDS);
|
||||
if (inv != null && playerInventory.getCurrentItem() == stack) {
|
||||
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
final IItemList<IAEFluidStack> list = inv
|
||||
.getAvailableItems(StorageChannel.FLUIDS.createList(), IterationCounter.fetchNewId());
|
||||
if (list.isEmpty() && ia != null) {
|
||||
playerInventory.setInventorySlotContents(playerInventory.currentItem, null);
|
||||
|
||||
// drop core
|
||||
final ItemStack extraB = ia.addItems(this.component.stack(1));
|
||||
if (extraB != null) {
|
||||
player.dropPlayerItemWithRandomChoice(extraB, false);
|
||||
}
|
||||
|
||||
// drop upgrades
|
||||
final IInventory upgradesInventory = this.getUpgradesInventory(stack);
|
||||
for (int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSizeInventory(); upgradeIndex++) {
|
||||
final ItemStack upgradeStack = upgradesInventory.getStackInSlot(upgradeIndex);
|
||||
final ItemStack leftStack = ia.addItems(upgradeStack);
|
||||
if (leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule) {
|
||||
player.dropPlayerItemWithRandomChoice(upgradeStack, false);
|
||||
}
|
||||
}
|
||||
|
||||
// drop empty storage cell case
|
||||
final ItemStack extraA = ia.addItems(this.getHousing());
|
||||
if (extraA != null) {
|
||||
player.dropPlayerItemWithRandomChoice(this.getHousing(), false);
|
||||
}
|
||||
if (player.inventoryContainer != null) {
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
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 com.glodblock.github.api.FluidCraftAPI;
|
||||
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.util.NameConst;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
|
||||
public abstract class ItemBaseInfinityStorageCell extends AEBaseItem implements IStorageFluidCell {
|
||||
|
||||
@Override
|
||||
public long getBytes(ItemStack cellItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType(ItemStack cellItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
|
||||
return requestedAddition == null || requestedAddition.getFluid() == null
|
||||
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell(ItemStack i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain(ItemStack is) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes(ItemStack cellItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory(ItemStack is) {
|
||||
return new CellUpgrades(is, 0);
|
||||
}
|
||||
|
||||
@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 final IFluidCellInventoryHandler handler) {
|
||||
final IFluidCellInventory cellInventory = handler.getCellInv();
|
||||
|
||||
if (GuiScreen.isCtrlKeyDown()) {
|
||||
if (!cellInventory.getContents().isEmpty()) {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
|
||||
for (IAEFluidStack fluid : cellInventory.getContents()) {
|
||||
if (fluid != null) {
|
||||
lines.add(String.format(" %s %s", StatCollector.translateToLocal(NameConst.TT_INFINITY_FLUID_STORAGE_TIPS), fluid.getFluidStack().getLocalizedName()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.MODE;
|
||||
import static com.glodblock.github.loader.recipe.WirelessTerminalEnergyRecipe.getEnergyCard;
|
||||
import static com.glodblock.github.loader.recipe.WirelessTerminalRecipe.getInfinityBoosterCard;
|
||||
import static com.glodblock.github.util.Util.DimensionalCoordSide.hasEnergyCard;
|
||||
@@ -9,37 +10,38 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IItemInventory;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.UltraTerminalModes;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.features.IWirelessTermRegistry;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements IItemInventory {
|
||||
public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements IItemInventory, IGuiItem {
|
||||
|
||||
protected GuiType type;
|
||||
protected Object type;
|
||||
public static String infinityBoosterCard = "infinityBoosterCard";
|
||||
public static String infinityEnergyCard = "InfinityEnergyCard";
|
||||
public static String restockItems = "restock";
|
||||
|
||||
public ItemBaseWirelessTerminal(GuiType t) {
|
||||
public ItemBaseWirelessTerminal(Object t) {
|
||||
super();
|
||||
this.type = t;
|
||||
}
|
||||
@@ -48,40 +50,7 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
|
||||
if (player.isSneaking()) return removeInfinityBoosterCard(player, item); // todo: doesn't work in universal
|
||||
// terminal
|
||||
if (ForgeEventFactory.onItemUseStart(player, item, 1) > 0) {
|
||||
if (Platform.isClient()) {
|
||||
return item;
|
||||
}
|
||||
IWirelessTermRegistry term = AEApi.instance().registries().wireless();
|
||||
if (!term.isWirelessTerminal(item)) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotWirelessTerminal.toChat());
|
||||
return item;
|
||||
}
|
||||
final IWirelessTermHandler handler = term.getWirelessTerminalHandler(item);
|
||||
final String unparsedKey = handler.getEncryptionKey(item);
|
||||
if (unparsedKey.isEmpty()) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotLinked.toChat());
|
||||
return item;
|
||||
}
|
||||
final long parsedKey = Long.parseLong(unparsedKey);
|
||||
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
|
||||
if (securityStation == null) {
|
||||
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.toChat());
|
||||
return item;
|
||||
}
|
||||
if (handler.hasPower(player, 0.5, item)) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
w,
|
||||
new BlockPos(player.inventory.currentItem, 0, 0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
this.guiGuiType(item));
|
||||
} else {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotPowered.toChat());
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
return super.onItemRightClick(item, w, player);
|
||||
}
|
||||
|
||||
private ItemStack removeInfinityBoosterCard(final EntityPlayer player, ItemStack is) {
|
||||
@@ -117,7 +86,7 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
if (is == null) {
|
||||
return false;
|
||||
}
|
||||
return is.getItem() instanceof ItemBaseWirelessTerminal;
|
||||
return is.getItem() == this;
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
@@ -129,12 +98,64 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
return null;
|
||||
}
|
||||
|
||||
public GuiType guiGuiType(ItemStack stack) {
|
||||
return this.type;
|
||||
public static UltraTerminalModes getMode(ItemStack is) {
|
||||
Item item = is.getItem();
|
||||
if (item instanceof ItemWirelessUltraTerminal) {
|
||||
if (!is.hasTagCompound()) is.setTagCompound(new NBTTagCompound());
|
||||
return UltraTerminalModes.values()[is.getTagCompound().getInteger(MODE)];
|
||||
} else if (item instanceof ItemWirelessPatternTerminal) {
|
||||
return UltraTerminalModes.PATTERN;
|
||||
} else if (item instanceof ItemWirelessInterfaceTerminal) {
|
||||
return UltraTerminalModes.INTERFACE;
|
||||
} else if (item instanceof ItemWirelessLevelTerminal) {
|
||||
return UltraTerminalModes.LEVEL;
|
||||
} else {
|
||||
return UltraTerminalModes.INTERFACE; // any wireless gui object will fit
|
||||
}
|
||||
}
|
||||
|
||||
public static void toggleRestockItemsMode(ItemStack is, boolean state) {
|
||||
NBTTagCompound data = Platform.openNbtData(is);
|
||||
data.setBoolean(restockItems, state);
|
||||
public static void setMode(ItemStack is, UltraTerminalModes utm) {
|
||||
is.getTagCompound().setInteger(MODE, utm.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGui(final ItemStack is, final World w, final EntityPlayer player, final Object mode) {
|
||||
final GuiBridge aeGui;
|
||||
Item item = is.getItem();
|
||||
if (item instanceof ItemWirelessPatternTerminal) {
|
||||
aeGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
} else if (item instanceof ItemWirelessInterfaceTerminal) {
|
||||
aeGui = GuiBridge.GUI_INTERFACE_TERMINAL;
|
||||
} else if (item instanceof ItemWirelessLevelTerminal) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
w,
|
||||
new BlockPos(player.inventory.currentItem, 0, 0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
return;
|
||||
} else {
|
||||
aeGui = GuiBridge.GUI_INTERFACE_TERMINAL; // any wireless gui object will fit
|
||||
}
|
||||
Platform.openGUI(player, null, null, aeGui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(ItemStack is, World world, EntityPlayer p, int x, int y, int z) {
|
||||
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler(is);
|
||||
if (wh == null) return null;
|
||||
return new WirelessTerminalGuiObject(wh, is, p, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasInfinityPower(ItemStack is) {
|
||||
NBTTagCompound data = is.getTagCompound();
|
||||
return data != null && data.hasKey(infinityEnergyCard) && data.getBoolean(infinityEnergyCard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasInfinityRange(ItemStack is) {
|
||||
NBTTagCompound data = is.getTagCompound();
|
||||
return data != null && data.hasKey(infinityBoosterCard) && data.getBoolean(infinityBoosterCard);
|
||||
}
|
||||
}
|
||||
@@ -4,18 +4,14 @@ import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.storage.CellType;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
@@ -23,14 +19,12 @@ import com.glodblock.github.util.NameConst;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.exceptions.MissingDefinition;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBasicFluidStorageCell extends FCBaseItemCell
|
||||
implements IStorageFluidCell, IRegister<ItemBasicFluidStorageCell> {
|
||||
public class ItemBasicFluidStorageCell extends FCBaseItemCell implements IRegister<ItemBasicFluidStorageCell> {
|
||||
|
||||
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
|
||||
private final int housingValue;
|
||||
@@ -114,19 +108,6 @@ public class ItemBasicFluidStorageCell extends FCBaseItemCell
|
||||
return icon.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) {
|
||||
this.disassembleDrive(stack, world, player);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(final ItemStack stack, final EntityPlayer player, final World world, final int x,
|
||||
final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ) {
|
||||
if (ForgeEventFactory.onItemUseStart(player, stack, 1) <= 0) return true;
|
||||
return this.disassembleDrive(stack, world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(final ItemStack itemStack) {
|
||||
if (this.getHousing() != null) {
|
||||
@@ -135,11 +116,6 @@ public class ItemBasicFluidStorageCell extends FCBaseItemCell
|
||||
throw new MissingDefinition("Tried to use empty storage cells while basic storage cells are defined.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(final ItemStack stack) {
|
||||
return AEConfig.instance.isFeatureEnabled(AEFeature.EnableDisassemblyCrafting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBasicFluidStorageCell register() {
|
||||
if (!Config.fluidCells) return null;
|
||||
|
||||
@@ -2,61 +2,47 @@ package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.FluidCellConfig;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
import appeng.items.AEBaseInfiniteCell;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemCreativeFluidStorageCell extends ItemBaseInfinityStorageCell
|
||||
implements IStorageFluidCell, IRegister<ItemCreativeFluidStorageCell> {
|
||||
public class ItemCreativeFluidStorageCell extends AEBaseInfiniteCell
|
||||
implements 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 IInventory getConfigInventory(ItemStack is) {
|
||||
return new FluidCellConfig(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 boolean isEditable(ItemStack is) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(ItemStack is) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes(ItemStack cellItem) {
|
||||
return 63;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,27 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemFluidExtremeStorageCell extends FCBaseItemCell
|
||||
implements IStorageFluidCell, IRegister<ItemFluidExtremeStorageCell> {
|
||||
public class ItemFluidExtremeStorageCell extends FCBaseItemCell implements IRegister<ItemFluidExtremeStorageCell> {
|
||||
|
||||
private final String name;
|
||||
|
||||
public ItemFluidExtremeStorageCell(String name, long bytes, int perType, int totalTypes, double drain) {
|
||||
super(bytes, perType, totalTypes, drain);
|
||||
this.setFeature(EnumSet.of(AEFeature.StorageCells));
|
||||
this.setMaxStackSize(1);
|
||||
setUnlocalizedName(name);
|
||||
this.name = name;
|
||||
setTextureName(FluidCraft.resource(name).toString());
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -57,4 +59,11 @@ public class ItemFluidLevelEmitter extends FCBaseItem implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
|
||||
final boolean displayMoreInfo) {
|
||||
lines.add("Deprecated, use regular level emitter, hold CTRL for get fluid of container.");
|
||||
super.addInformation(stack, player, lines, displayMoreInfo);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,20 @@
|
||||
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 com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.api.FluidCraftAPI;
|
||||
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.FluidCellConfig;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
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.AEBaseItem;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.util.Platform;
|
||||
import appeng.items.storage.ItemVoidStorageCell;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemFluidVoidStorageCell extends AEBaseItem
|
||||
implements IStorageFluidCell, IRegister<ItemFluidVoidStorageCell> {
|
||||
public class ItemFluidVoidStorageCell extends ItemVoidStorageCell implements IRegister<ItemFluidVoidStorageCell> {
|
||||
|
||||
public ItemFluidVoidStorageCell() {
|
||||
super();
|
||||
setUnlocalizedName(NameConst.ITEM_FLUID_VOID_CELL);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_FLUID_VOID_CELL).toString());
|
||||
this.setFeature(EnumSet.of(AEFeature.StorageCells));
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,88 +25,7 @@ public class ItemFluidVoidStorageCell extends AEBaseItem
|
||||
}
|
||||
|
||||
@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 final IFluidCellInventoryHandler handler) {
|
||||
lines.add(NameConst.i18n(NameConst.TT_ITEM_FLUID_VOID_CELL));
|
||||
lines.add(GuiText.VoidCellTooltip.getLocal());
|
||||
lines.add(0 + " " + GuiText.Of.getLocal() + " \u00A7k9999\u00A77 " + GuiText.BytesUsed.getLocal());
|
||||
final IFluidCellInventory inv = handler.getCellInv();
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
lines.add(GuiText.Filter.getLocal() + ": ");
|
||||
for (int i = 0; i < inv.getConfigInventory().getSizeInventory(); ++i) {
|
||||
ItemStack s = inv.getConfigInventory().getStackInSlot(i);
|
||||
if (s != null) lines.add(s.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytes(ItemStack cellItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType(ItemStack cellItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
|
||||
return requestedAddition == null || requestedAddition.getFluid() == null
|
||||
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell(ItemStack i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain(ItemStack is) {
|
||||
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, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory(ItemStack is) {
|
||||
return new FluidCellConfig(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) {
|
||||
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
}
|
||||
@@ -4,33 +4,28 @@ import static com.glodblock.github.util.Util.FluidUtil.water_bucket;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
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.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.items.AEBaseInfiniteCell;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemInfinityWaterStorageCell extends ItemBaseInfinityStorageCell
|
||||
implements IStorageFluidCell, IRegister<ItemInfinityWaterStorageCell> {
|
||||
public class ItemInfinityWaterStorageCell extends AEBaseInfiniteCell
|
||||
implements IRegister<ItemInfinityWaterStorageCell> {
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory(ItemStack is) {
|
||||
return new InfinityConfig(water_bucket);
|
||||
}
|
||||
|
||||
public static class InfinityConfig extends AppEngInternalInventory {
|
||||
public static class InfinityConfig extends IAEStackInventory {
|
||||
|
||||
public InfinityConfig(final ItemStack is) {
|
||||
super(null, 1);
|
||||
this.setInventorySlotContents(0, is);
|
||||
this.putAEStackInSlot(0, Util.getAEFluidFromItem(is));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,7 +33,6 @@ public class ItemInfinityWaterStorageCell extends ItemBaseInfinityStorageCell
|
||||
}
|
||||
|
||||
public ItemInfinityWaterStorageCell() {
|
||||
super();
|
||||
setUnlocalizedName(NameConst.ITEM_INFINITY_WATER_FLUID_STORAGE);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_INFINITY_FLUID_STORAGE).toString());
|
||||
this.setFeature(EnumSet.of(AEFeature.StorageCells));
|
||||
@@ -52,17 +46,23 @@ public class ItemInfinityWaterStorageCell extends ItemBaseInfinityStorageCell
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStackInventory getConfigAEInventory(ItemStack is) {
|
||||
return new InfinityConfig(water_bucket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(ItemStack is) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode(ItemStack is) {
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
public int getTotalTypes(ItemStack cellItem) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {}
|
||||
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
}
|
||||
@@ -4,18 +4,14 @@ import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.storage.CellType;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
@@ -23,14 +19,12 @@ import com.glodblock.github.util.NameConst;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.exceptions.MissingDefinition;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemMultiFluidStorageCell extends FCBaseItemCell
|
||||
implements IStorageFluidCell, IRegister<ItemMultiFluidStorageCell> {
|
||||
public class ItemMultiFluidStorageCell extends FCBaseItemCell implements IRegister<ItemMultiFluidStorageCell> {
|
||||
|
||||
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
|
||||
private final int housingValue;
|
||||
@@ -43,7 +37,7 @@ public class ItemMultiFluidStorageCell extends FCBaseItemCell
|
||||
this.totalBytes = kilobytes * 1024;
|
||||
this.component = whichCell;
|
||||
this.housingValue = housingValue;
|
||||
this.maxType = 5;
|
||||
this.totalTypes = 5;
|
||||
setUnlocalizedName(NameConst.ITEM_MULTI_FLUID_STORAGE + "." + kilobytes);
|
||||
|
||||
switch (this.component) {
|
||||
@@ -115,24 +109,6 @@ public class ItemMultiFluidStorageCell extends FCBaseItemCell
|
||||
return icon.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) {
|
||||
this.disassembleDrive(stack, world, player);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(final ItemStack stack, final EntityPlayer player, final World world, final int x,
|
||||
final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ) {
|
||||
if (ForgeEventFactory.onItemUseStart(player, stack, 1) <= 0) return true;
|
||||
return this.disassembleDrive(stack, world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(final ItemStack stack) {
|
||||
return AEConfig.instance.isFeatureEnabled(AEFeature.EnableDisassemblyCrafting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(final ItemStack itemStack) {
|
||||
if (this.getHousing() != null) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.glodblock.github.common.item;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
@@ -46,7 +45,9 @@ public class ItemPartFluidInterface extends FCBaseItem implements IPartItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister _iconRegister) {}
|
||||
protected String getIconString() {
|
||||
return NameConst.RES_KEY + "fluid_interface";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -53,4 +55,10 @@ public class ItemPartFluidPatternTerminal extends FCBaseItem implements IPartIte
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> toolTip, boolean flag) {
|
||||
toolTip.add("DEPRECATED!");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -53,4 +55,10 @@ public class ItemPartFluidPatternTerminalEx extends FCBaseItem implements IPartI
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> toolTip, boolean flag) {
|
||||
toolTip.add("DEPRECATED!");
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.glodblock.github.common.item;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
@@ -46,7 +45,9 @@ public class ItemPartFluidStorageBus extends FCBaseItem implements IPartItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister _iconRegister) {}
|
||||
protected String getIconString() {
|
||||
return NameConst.RES_KEY + "fluid_storage_bus";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -45,6 +45,7 @@ public class ItemPartFluidTerminal extends FCBaseItem implements IPartItem {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> toolTip, boolean flag) {
|
||||
toolTip.add("DEPRECATED!");
|
||||
if (isShiftKeyDown()) {
|
||||
toolTip.add(NameConst.i18n(NameConst.TT_FLUID_TERMINAL));
|
||||
} else {
|
||||
@@ -67,4 +68,5 @@ public class ItemPartFluidTerminal extends FCBaseItem implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +1,38 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
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;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.api.FluidCraftAPI;
|
||||
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.FluidCellConfig;
|
||||
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.NameConst;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.items.AEBasePortableCell;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.Platform;
|
||||
import appeng.items.contents.PortableCellViewer;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemPortableFluidCell extends AEBasePoweredItem
|
||||
implements IStorageFluidCell, IItemInventory, IRegister<ItemPortableFluidCell> {
|
||||
public class ItemPortableFluidCell extends AEBasePortableCell implements IRegister<ItemPortableFluidCell> {
|
||||
|
||||
public ItemPortableFluidCell() {
|
||||
super(Config.portableCellBattery, Optional.absent());
|
||||
super();
|
||||
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)
|
||||
@@ -77,35 +40,6 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
|
||||
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 final IFluidCellInventoryHandler handler) {
|
||||
final IFluidCellInventory cellInventory = handler.getCellInv();
|
||||
if (cellInventory != null) {
|
||||
lines.add(
|
||||
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getUsedBytes())
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ " "
|
||||
+ GuiText.Of.getLocal()
|
||||
+ " "
|
||||
+ EnumChatFormatting.DARK_GREEN
|
||||
+ cellInventory.getTotalBytes()
|
||||
+ " "
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ GuiText.BytesUsed.getLocal());
|
||||
lines.add(
|
||||
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getStoredFluidTypes())
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ " "
|
||||
+ GuiText.Of.getLocal()
|
||||
+ " "
|
||||
+ EnumChatFormatting.DARK_GREEN
|
||||
+ cellInventory.getTotalFluidTypes()
|
||||
+ " "
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ GuiText.Types.getLocal());
|
||||
}
|
||||
}
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
lines.addAll(
|
||||
RenderUtil.listFormattedStringToWidth(
|
||||
@@ -116,34 +50,20 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytes(final ItemStack cellItem) {
|
||||
public long getBytesLong(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) {
|
||||
return requestedAddition == null || requestedAddition.getFluid() == null
|
||||
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
|
||||
}
|
||||
public boolean isBlackListed(IAEStack<?> requestedAddition) {
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell(final ItemStack i) {
|
||||
return true;
|
||||
return requestedAddition instanceof IAEFluidStack ifs && (ifs.getFluid() == null
|
||||
|| FluidCraftAPI.instance().isBlacklistedInStorage(ifs.getFluid().getClass()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,34 +71,20 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
|
||||
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 FluidCellConfig(is);
|
||||
public IGuiItemObject getGuiObject(final ItemStack is, final World w, final EntityPlayer p, final int x,
|
||||
final int y, final int z) {
|
||||
return new PortableCellViewer<IAEFluidStack>(is, x, StorageChannel.FLUIDS);
|
||||
}
|
||||
|
||||
@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());
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,11 +94,6 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
return new PortableFluidCellInventory(stack, x);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
@@ -8,23 +8,18 @@ import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemWirelessFluidTerminal extends ItemBaseWirelessTerminal
|
||||
implements IRegister<ItemWirelessFluidTerminal> {
|
||||
|
||||
public ItemWirelessFluidTerminal() {
|
||||
super(GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
super(null);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler(this);
|
||||
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_FLUID_TERMINAL);
|
||||
@@ -40,12 +35,6 @@ public class ItemWirelessFluidTerminal extends ItemBaseWirelessTerminal
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
|
||||
} catch (Exception e) {
|
||||
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,23 +8,22 @@ import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.contents.WirelessInterfaceTerminalGuiObject;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemWirelessInterfaceTerminal extends ItemBaseWirelessTerminal
|
||||
implements IRegister<ItemWirelessInterfaceTerminal> {
|
||||
|
||||
public ItemWirelessInterfaceTerminal() {
|
||||
super(GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
super(GuiBridge.GUI_INTERFACE_TERMINAL);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler(this);
|
||||
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_INTERFACE_TERMINAL);
|
||||
@@ -39,13 +38,9 @@ public class ItemWirelessInterfaceTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
|
||||
} catch (Exception e) {
|
||||
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
|
||||
}
|
||||
return null;
|
||||
public IGuiItemObject getGuiObject(ItemStack is, World world, EntityPlayer p, int x, int y, int z) {
|
||||
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler(is);
|
||||
if (wh == null) return null;
|
||||
return new WirelessInterfaceTerminalGuiObject(wh, is, x);
|
||||
}
|
||||
}
|
||||
@@ -8,23 +8,22 @@ import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.contents.WirelessPatternTerminalGuiObject;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemWirelessPatternTerminal extends ItemBaseWirelessTerminal
|
||||
implements IRegister<ItemWirelessPatternTerminal> {
|
||||
|
||||
public ItemWirelessPatternTerminal() {
|
||||
super(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
super(GuiBridge.GUI_PATTERN_TERMINAL);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler(this);
|
||||
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
@@ -39,13 +38,9 @@ public class ItemWirelessPatternTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
|
||||
} catch (Exception e) {
|
||||
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
|
||||
}
|
||||
return null;
|
||||
public IGuiItemObject getGuiObject(ItemStack is, World world, EntityPlayer p, int x, int y, int z) {
|
||||
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler(is);
|
||||
if (wh == null) return null;
|
||||
return new WirelessPatternTerminalGuiObject(wh, is, p, world, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static appeng.util.Platform.baublesSlotsOffset;
|
||||
import static appeng.util.Platform.nextEnum;
|
||||
import static com.glodblock.github.util.Util.GuiHelper.decodeInvType;
|
||||
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
@@ -12,7 +14,6 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -20,43 +21,44 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.UltraTerminalButtons;
|
||||
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.WirelessCraftingTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnet;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnetCardFilterInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalExInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.UltraTerminalModes;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.ICustomButtonDataObject;
|
||||
import appeng.helpers.ICustomButtonProvider;
|
||||
import appeng.helpers.ICustomButtonSource;
|
||||
import appeng.items.contents.WirelessCraftingTerminalGuiObject;
|
||||
import appeng.items.contents.WirelessInterfaceTerminalGuiObject;
|
||||
import appeng.items.contents.WirelessPatternTerminalGuiObject;
|
||||
import appeng.util.Platform;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.BaublesApi;
|
||||
import baubles.api.IBauble;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles")
|
||||
public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
implements IBauble, IRegister<ItemWirelessUltraTerminal> {
|
||||
implements IRegister<ItemWirelessUltraTerminal>, IGuiItem, ICustomButtonSource {
|
||||
|
||||
public final static String MODE = "mode_main";
|
||||
private final static List<GuiType> guis = new ArrayList<>();
|
||||
public final static String MODE = "mode";
|
||||
|
||||
public ItemWirelessUltraTerminal() {
|
||||
super(null);
|
||||
@@ -64,15 +66,6 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_ULTRA_TERMINAL);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_ULTRA_TERMINAL).toString());
|
||||
guis.add(GuiType.WIRELESS_CRAFTING_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
|
||||
guis.add(GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
if (ModAndClassUtil.ThE) {
|
||||
guis.add(GuiType.WIRELESS_ESSENTIA_TERMINAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +82,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
super.addCheckedInformation(stack, player, lines, displayMoreInfo);
|
||||
if (isShiftKeyDown()) {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL));
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL + "." + guiGuiType(stack)));
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL + "." + getMode(stack)));
|
||||
lines.add(NameConst.i18n(NameConst.TT_ULTRA_TERMINAL_TIPS));
|
||||
lines.addAll(Arrays.asList(NameConst.i18n(NameConst.TT_ULTRA_TERMINAL_TIPS_DESC).split("\\\\n")));
|
||||
} else {
|
||||
@@ -99,40 +92,21 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return StatCollector.translateToLocalFormatted("item.wireless_ultra_terminal." + guiGuiType(stack) + ".name");
|
||||
return StatCollector.translateToLocalFormatted("item.wireless_ultra_terminal." + getMode(stack) + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
final GuiType gui;
|
||||
final IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
|
||||
// wireless magnet
|
||||
if (Util.GuiHelper.decodeType(y).getLeft() == Util.GuiHelper.GuiType.ITEM && z == -1) {
|
||||
gui = GuiType.WIRELESS_MAGNET_FILTER;
|
||||
} else if (Util.GuiHelper.decodeType(y).getLeft() == Util.GuiHelper.GuiType.ITEM && z > 0) {
|
||||
gui = getGuis().get(Util.GuiHelper.decodeType(y).getRight());
|
||||
} else {
|
||||
gui = readMode(stack);
|
||||
}
|
||||
if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL) {
|
||||
return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
|
||||
} else if (gui == GuiType.WIRELESS_CRAFTING_TERMINAL) {
|
||||
return new WirelessCraftingTerminalInventory(stack, x, gridNode, player);
|
||||
} else if (ModAndClassUtil.ThE && gui == GuiType.WIRELESS_ESSENTIA_TERMINAL) {
|
||||
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
|
||||
} else if (gui == GuiType.WIRELESS_FLUID_TERMINAL) {
|
||||
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
|
||||
} else if (gui == GuiType.WIRELESS_INTERFACE_TERMINAL) {
|
||||
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
|
||||
} else if (gui == GuiType.WIRELESS_LEVEL_TERMINAL) {
|
||||
return new WirelessLevelTerminalInventory(stack, x, gridNode, player);
|
||||
} else if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX) {
|
||||
return new WirelessPatternTerminalExInventory(stack, x, gridNode, player);
|
||||
} else if (gui == GuiType.WIRELESS_MAGNET_FILTER) {
|
||||
return new WirelessMagnetCardFilterInventory(stack, x, gridNode, player);
|
||||
} else {
|
||||
this.setMode(GuiType.WIRELESS_FLUID_TERMINAL, stack); // set as default mode
|
||||
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
|
||||
}
|
||||
|
||||
if (z != 0 ? z == UltraTerminalModes.LEVEL.ordinal() : getMode(stack) == UltraTerminalModes.LEVEL) {
|
||||
return new WirelessLevelTerminalInventory(stack, x, gridNode, player);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
|
||||
@@ -141,73 +115,64 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
|
||||
public ItemStack onItemRightClick(final ItemStack is, final World w, final EntityPlayer player) {
|
||||
if (player.isSneaking()) {
|
||||
setNext(readMode(item), item);
|
||||
return item;
|
||||
setMode(is, nextEnum(getMode(is)));
|
||||
return is;
|
||||
}
|
||||
readMode(item);
|
||||
return super.onItemRightClick(item, w, player);
|
||||
return super.onItemRightClick(is, w, player);
|
||||
}
|
||||
|
||||
public static GuiType readMode(ItemStack stack) {
|
||||
NBTTagCompound data = Platform.openNbtData(stack);
|
||||
if (data.hasKey(MODE)) {
|
||||
String GUI = data.getString(MODE);
|
||||
try {
|
||||
return GuiType.valueOf(GUI);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return GuiType.WIRELESS_CRAFTING_TERMINAL;
|
||||
}
|
||||
} else {
|
||||
return GuiType.WIRELESS_CRAFTING_TERMINAL;
|
||||
public void switchTerminal(EntityPlayer player, ImmutablePair<Integer, ItemStack> term, UltraTerminalModes mode) {
|
||||
if (term != null) {
|
||||
final ItemStack terminal = term.getRight();
|
||||
if (terminal == null) return;
|
||||
if (mode != null) setMode(terminal, mode);
|
||||
else mode = getMode(terminal);
|
||||
|
||||
if (AEApi.instance().registries().wireless().performCheck(terminal, player))
|
||||
openGui(terminal, player.worldObj, player, mode, term.getLeft());
|
||||
}
|
||||
}
|
||||
|
||||
public void setNext(GuiType type, ItemStack stack) {
|
||||
boolean f = false;
|
||||
for (GuiType g : guis) {
|
||||
if (f) {
|
||||
setMode(g.toString(), stack);
|
||||
private void openGui(final ItemStack is, final World w, final EntityPlayer player, final Object mode,
|
||||
final int slotIndex) {
|
||||
final GuiBridge aeGui;
|
||||
final int slot = slotIndex == Integer.MIN_VALUE ? player.inventory.currentItem : slotIndex;
|
||||
final ImmutablePair<Util.GuiHelper.InvType, Integer> invSlotPair = decodeInvType(slotIndex);
|
||||
|
||||
switch (mode instanceof UltraTerminalModes utm ? utm : getMode(is)) {
|
||||
case CRAFTING -> aeGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
case PATTERN -> aeGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
case PATTERN_EX -> aeGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
case INTERFACE -> aeGui = GuiBridge.GUI_INTERFACE_TERMINAL;
|
||||
case LEVEL -> {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
w,
|
||||
new BlockPos(
|
||||
slot,
|
||||
0,
|
||||
player.openContainer instanceof AEBaseContainer abc ? abc.getSwitchAbleGuiNext() : 0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
return;
|
||||
}
|
||||
if (g == type) {
|
||||
f = true;
|
||||
}
|
||||
default -> aeGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
setMode(guis.get(0).toString(), stack);
|
||||
|
||||
Platform.openGUI(
|
||||
player,
|
||||
null,
|
||||
null,
|
||||
aeGui,
|
||||
invSlotPair.getLeft() == Util.GuiHelper.InvType.PLAYER_INV ? slotIndex
|
||||
: invSlotPair.getRight() + baublesSlotsOffset);
|
||||
}
|
||||
|
||||
public void setMode(String mode, ItemStack stack) {
|
||||
NBTTagCompound data = Platform.openNbtData(stack);
|
||||
data.setString(MODE, mode);
|
||||
}
|
||||
|
||||
public void setMode(GuiType mode, ItemStack stack) {
|
||||
this.setMode(mode.toString(), stack);
|
||||
}
|
||||
|
||||
public static void switchTerminal(EntityPlayer player, GuiType guiType) {
|
||||
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
|
||||
if (term == null) return;
|
||||
if (term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
((ItemWirelessUltraTerminal) term.getRight().getItem()).setMode(guiType, term.getRight());
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(guiType, true));
|
||||
} else {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(
|
||||
term.getLeft(),
|
||||
Util.GuiHelper.encodeType(
|
||||
guis.indexOf(GuiType.valueOf(guiType.toString())),
|
||||
Util.GuiHelper.GuiType.ITEM),
|
||||
1),
|
||||
ForgeDirection.UNKNOWN,
|
||||
guiType);
|
||||
}
|
||||
@Override
|
||||
public void openGui(final ItemStack is, final World w, final EntityPlayer player, final Object mode) {
|
||||
this.openGui(is, w, player, mode, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
public static boolean hasInfinityBoosterCard(EntityPlayer player) {
|
||||
@@ -219,20 +184,6 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<GuiType> getGuis() {
|
||||
return guis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiType guiGuiType(ItemStack stack) {
|
||||
return readMode(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack itemStack) {
|
||||
return BaubleType.RING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
if (Platform.isServer() && entityLivingBase instanceof EntityPlayer player) {
|
||||
@@ -252,26 +203,6 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEquipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEquip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnequip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int slot, boolean p_77663_5_) {
|
||||
if (entityIn instanceof EntityPlayer player) {
|
||||
@@ -280,4 +211,21 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(ItemStack is, World world, EntityPlayer p, int x, int y, int z) {
|
||||
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler(is);
|
||||
if (wh == null) return null;
|
||||
return switch (y != Integer.MIN_VALUE ? UltraTerminalModes.values()[y] : getMode(is)) {
|
||||
case CRAFTING -> new WirelessCraftingTerminalGuiObject(wh, is, p, world, x, y, z);
|
||||
case PATTERN, PATTERN_EX -> new WirelessPatternTerminalGuiObject(wh, is, p, world, x, y, z);
|
||||
case INTERFACE -> new WirelessInterfaceTerminalGuiObject(wh, is, x);
|
||||
default -> super.getGuiObject(is, world, p, x, y, z);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICustomButtonDataObject getCustomDataObject(ICustomButtonProvider provider) {
|
||||
return new UltraTerminalButtons();
|
||||
}
|
||||
}
|
||||
@@ -1,69 +1,29 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import static appeng.util.Platform.convertStack;
|
||||
import static appeng.util.Platform.stackConvert;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.InsertionMode;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingRequester;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.AELog;
|
||||
import appeng.helpers.MultiCraftingTracker;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.PartBaseExportBus;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingRequester {
|
||||
|
||||
private final BaseActionSource source;
|
||||
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker(this, 9);
|
||||
private int nextSlot = 0;
|
||||
private long fluidToSend = 1000;
|
||||
private boolean didSomething;
|
||||
public class PartFluidExportBus extends PartBaseExportBus<IAEFluidStack> {
|
||||
|
||||
public PartFluidExportBus(ItemStack is) {
|
||||
super(is);
|
||||
this.getConfigManager().registerSetting(Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
|
||||
this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
|
||||
this.getConfigManager().registerSetting(Settings.CRAFT_ONLY, YesNo.NO);
|
||||
this.getConfigManager().registerSetting(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT);
|
||||
this.source = new MachineSource(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,238 +32,63 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node) {
|
||||
return new TickingRequest(5, 40, this.isSleeping(), false);
|
||||
protected int getAdaptorFlags() {
|
||||
return InventoryAdaptor.DEFAULT & ~InventoryAdaptor.ALLOW_ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
|
||||
return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canDoBusWork() {
|
||||
return this.getProxy().isActive();
|
||||
}
|
||||
|
||||
private int getStartingSlot(final SchedulingMode schedulingMode, final int x) {
|
||||
if (schedulingMode == SchedulingMode.RANDOM) {
|
||||
return Platform.getRandom().nextInt(this.availableSlots());
|
||||
public int calculateAmountToSend() {
|
||||
double amount = 1000D;
|
||||
switch (this.getInstalledUpgrades(Upgrades.SPEED)) {
|
||||
case 4:
|
||||
amount = amount * 1.5;
|
||||
case 3:
|
||||
amount = amount * 2;
|
||||
case 2:
|
||||
amount = amount * 4;
|
||||
case 1:
|
||||
amount = amount * 8;
|
||||
}
|
||||
|
||||
if (schedulingMode == SchedulingMode.ROUNDROBIN) {
|
||||
return (this.nextSlot + x) % this.availableSlots();
|
||||
switch (this.getInstalledUpgrades(Upgrades.SUPERSPEED)) {
|
||||
case 4:
|
||||
amount = amount * 8;
|
||||
case 3:
|
||||
amount = amount * 12;
|
||||
case 2:
|
||||
amount = amount * 16;
|
||||
case 1:
|
||||
amount = amount * 32;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
private int availableSlots() {
|
||||
return Math.min(1 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 4, this.getInv().getSizeInventory());
|
||||
}
|
||||
|
||||
private IInventory getInv() {
|
||||
return this.getInventoryByName("config");
|
||||
return (int) Math.floor(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TickRateModulation doBusWork() {
|
||||
if (!this.canDoBusWork()) {
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
this.didSomething = false;
|
||||
this.fluidToSend = this.calculateAmountToSend();
|
||||
final TileEntity te = this.getConnectedTE();
|
||||
InventoryAdaptor destination;
|
||||
if (te instanceof IFluidHandler && (destination = this.getHandler(te)) != null) {
|
||||
try {
|
||||
final ICraftingGrid cg = this.getProxy().getCrafting();
|
||||
final IFluidHandler fh = (IFluidHandler) te;
|
||||
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
|
||||
int i;
|
||||
for (i = 0; i < this.availableSlots() && this.fluidToSend > 0; i++) {
|
||||
final int slotToExport = this.getStartingSlot(this.getSchedulingMode(), i);
|
||||
IAEFluidStack fluid = AEFluidStack
|
||||
.create(ItemFluidPacket.getFluidStack(getInv().getStackInSlot(slotToExport)));
|
||||
if (fluid != null) {
|
||||
fluid.setStackSize(this.calculateAmountToSend());
|
||||
if (this.craftOnly()) {
|
||||
this.didSomething = this.craftingTracker.handleCrafting(
|
||||
i,
|
||||
fluid.getStackSize(),
|
||||
ItemFluidDrop.newAeStack(fluid),
|
||||
destination,
|
||||
this.getTile().getWorldObj(),
|
||||
this.getProxy().getGrid(),
|
||||
cg,
|
||||
this.source);
|
||||
continue;
|
||||
}
|
||||
// Find out how much to push
|
||||
final IAEFluidStack toPush = fluid.copy();
|
||||
final int amtToInsert = fh.fill(this.getSide().getOpposite(), toPush.getFluidStack(), false);
|
||||
toPush.setStackSize(amtToInsert);
|
||||
// Extract from the ME system. This might not be the same amount we actually send...
|
||||
final IAEFluidStack real = inv.extractItems(toPush, Actionable.MODULATE, this.source);
|
||||
if (real != null) {
|
||||
int realInserted = fh.fill(this.getSide().getOpposite(), real.getFluidStack(), true);
|
||||
if (realInserted < real.getStackSize()) {
|
||||
// Could not use the entirety of the amount we extracted, so put it back.
|
||||
// This can result in voiding fluids if there's nowhere for the fluids to go.
|
||||
fluid.setStackSize(real.getStackSize() - realInserted);
|
||||
inv.injectItems(fluid, Actionable.MODULATE, this.source);
|
||||
}
|
||||
this.fluidToSend -= realInserted;
|
||||
didSomething = true;
|
||||
} else if (this.isCraftingEnabled()) {
|
||||
// If we didn't send anything, try crafting it if we can.
|
||||
this.didSomething = this.craftingTracker.handleCrafting(
|
||||
i,
|
||||
fluid.getStackSize(),
|
||||
ItemFluidDrop.newAeStack(fluid),
|
||||
destination,
|
||||
this.getTile().getWorldObj(),
|
||||
this.getProxy().getGrid(),
|
||||
cg,
|
||||
this.source);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updateSchedulingMode(this.getSchedulingMode(), i);
|
||||
return didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
} catch (GridAccessException ignored) {}
|
||||
}
|
||||
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
private void updateSchedulingMode(final SchedulingMode schedulingMode, final int x) {
|
||||
if (schedulingMode == SchedulingMode.ROUNDROBIN) {
|
||||
this.nextSlot = (this.nextSlot + x) % this.availableSlots();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
bch.addBox(4, 4, 12, 12, 12, 14);
|
||||
bch.addBox(5, 5, 14, 11, 11, 15);
|
||||
bch.addBox(6, 6, 15, 10, 10, 16);
|
||||
bch.addBox(6, 6, 11, 10, 10, 12);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartExportSides.getIcon(),
|
||||
CableBusTextures.PartExportSides.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.getFaceIcon(),
|
||||
CableBusTextures.PartExportSides.getIcon(),
|
||||
CableBusTextures.PartExportSides.getIcon());
|
||||
|
||||
rh.setBounds(4, 4, 12, 12, 12, 14);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(5, 5, 14, 11, 11, 15);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(6, 6, 15, 10, 10, 16);
|
||||
rh.renderInventoryBox(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer) {
|
||||
this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache()));
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartExportSides.getIcon(),
|
||||
CableBusTextures.PartExportSides.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.getFaceIcon(),
|
||||
CableBusTextures.PartExportSides.getIcon(),
|
||||
CableBusTextures.PartExportSides.getIcon());
|
||||
|
||||
rh.setBounds(4, 4, 12, 12, 12, 14);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setBounds(5, 5, 14, 11, 11, 15);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setBounds(6, 6, 15, 10, 10, 16);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.getFaceIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon());
|
||||
|
||||
rh.setBounds(6, 6, 11, 10, 10, 12);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
this.renderLights(x, y, z, rh, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode() {
|
||||
return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED);
|
||||
}
|
||||
|
||||
public SchedulingMode getSchedulingMode() {
|
||||
return (SchedulingMode) this.getConfigManager().getSetting(Settings.SCHEDULING_MODE);
|
||||
}
|
||||
|
||||
private boolean craftOnly() {
|
||||
return this.getConfigManager().getSetting(Settings.CRAFT_ONLY) == YesNo.YES;
|
||||
}
|
||||
|
||||
private boolean isCraftingEnabled() {
|
||||
return this.getInstalledUpgrades(Upgrades.CRAFTING) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableSet<ICraftingLink> getRequestedJobs() {
|
||||
return this.craftingTracker.getRequestedJobs();
|
||||
}
|
||||
|
||||
protected InventoryAdaptor getHandler(TileEntity target) {
|
||||
return target != null ? InventoryAdaptor.getAdaptor(target, getSide().getOpposite()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) {
|
||||
final InventoryAdaptor d = this.getHandler(getConnectedTE());
|
||||
|
||||
protected IMEMonitor<IAEFluidStack> getMonitor() {
|
||||
try {
|
||||
if (d != null && this.getProxy().isActive()) {
|
||||
final IEnergyGrid energy = this.getProxy().getEnergy();
|
||||
final double power = Math.ceil(items.getStackSize() / 1000D);
|
||||
|
||||
if (energy.extractAEPower(power, mode, PowerMultiplier.CONFIG) > power - 0.01) {
|
||||
IAEItemStack remaining;
|
||||
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
remaining = stackConvert(d.simulateAddStack(convertStack(items), InsertionMode.DEFAULT));
|
||||
} else {
|
||||
remaining = stackConvert(d.addStack(convertStack(items), InsertionMode.DEFAULT));
|
||||
}
|
||||
|
||||
return remaining;
|
||||
}
|
||||
}
|
||||
return this.getProxy().getStorage().getFluidInventory();
|
||||
} catch (final GridAccessException e) {
|
||||
AELog.debug(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobStateChange(ICraftingLink link) {
|
||||
this.craftingTracker.jobStateChange(link);
|
||||
protected void doFuzzy(IAEFluidStack aes, FuzzyMode fzMode, InventoryAdaptor destination, IEnergyGrid energy,
|
||||
IMEMonitor<IAEFluidStack> gridInv) {}
|
||||
|
||||
@Override
|
||||
protected void doOreDict(InventoryAdaptor destination, IEnergyGrid energy, IMEMonitor<IAEFluidStack> gridInv) {}
|
||||
|
||||
// legacy
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound extra) {
|
||||
super.readFromNBT(extra);
|
||||
|
||||
final IAEStackInventory config = this.getAEInventoryByName(StorageName.NONE);
|
||||
for (int i = 0; i < config.getSizeInventory(); i++) {
|
||||
final IAEStack<?> stack = config.getAEStackInSlot(i);
|
||||
if (stack instanceof IAEItemStack ais) {
|
||||
config.putAEStackInSlot(i, Util.getAEFluidFromItem(ais.getItemStack()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,37 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.PartBaseImportBus;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartFluidImportBus extends FCSharedFluidBus {
|
||||
|
||||
private final BaseActionSource source;
|
||||
public class PartFluidImportBus extends PartBaseImportBus<IAEFluidStack> {
|
||||
|
||||
public PartFluidImportBus(ItemStack is) {
|
||||
super(is);
|
||||
this.getConfigManager().registerSetting(Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
|
||||
this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
|
||||
this.getConfigManager().registerSetting(Settings.CRAFT_ONLY, YesNo.NO);
|
||||
this.getConfigManager().registerSetting(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT);
|
||||
this.source = new MachineSource(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,79 +40,108 @@ public class PartFluidImportBus extends FCSharedFluidBus {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node) {
|
||||
return new TickingRequest(5, 40, this.isSleeping(), false);
|
||||
protected Object getTarget() {
|
||||
TileEntity self = this.getHost().getTile();
|
||||
return this.getTileEntity(self, (new BlockPos(self)).getOffSet(this.getSide()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
|
||||
return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE;
|
||||
}
|
||||
private TileEntity getTileEntity(final TileEntity self, final BlockPos pos) {
|
||||
final World w = self.getWorldObj();
|
||||
|
||||
@Override
|
||||
protected TickRateModulation doBusWork() {
|
||||
if (!this.canDoBusWork()) {
|
||||
return TickRateModulation.IDLE;
|
||||
if (w.getChunkProvider().chunkExists(pos.getX() >> 4, pos.getZ() >> 4)) {
|
||||
return w.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
final TileEntity te = this.getConnectedTE();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (te instanceof IFluidHandler) {
|
||||
try {
|
||||
final IFluidHandler fh = (IFluidHandler) te;
|
||||
FluidTankInfo[] tanksInfo = fh.getTankInfo(this.getSide().getOpposite());
|
||||
if (tanksInfo == null) {
|
||||
return TickRateModulation.SLOWER;
|
||||
@Override
|
||||
public int calculateAmountToSend() {
|
||||
double amount = 1000D;
|
||||
switch (this.getInstalledUpgrades(Upgrades.SPEED)) {
|
||||
case 4:
|
||||
amount = amount * 1.5;
|
||||
case 3:
|
||||
amount = amount * 2;
|
||||
case 2:
|
||||
amount = amount * 4;
|
||||
case 1:
|
||||
amount = amount * 8;
|
||||
}
|
||||
switch (this.getInstalledUpgrades(Upgrades.SUPERSPEED)) {
|
||||
case 4:
|
||||
amount = amount * 8;
|
||||
case 3:
|
||||
amount = amount * 12;
|
||||
case 2:
|
||||
amount = amount * 16;
|
||||
case 1:
|
||||
amount = amount * 32;
|
||||
}
|
||||
return (int) Math.floor(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IMEMonitor<IAEFluidStack> getMonitor() {
|
||||
try {
|
||||
return this.getProxy().getStorage().getFluidInventory();
|
||||
} catch (final GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean importStuff(final Object myTarget, final IAEFluidStack whatToImport,
|
||||
final IMEMonitor<IAEFluidStack> inv, final IEnergySource energy, final FuzzyMode fzMode) {
|
||||
if (myTarget instanceof IFluidHandler fh) {
|
||||
FluidTankInfo[] tanksInfo = fh.getTankInfo(this.getSide().getOpposite());
|
||||
if (tanksInfo == null) return true;
|
||||
|
||||
int maxDrain = this.calculateAmountToSend();
|
||||
boolean doBreak = true;
|
||||
|
||||
for (FluidTankInfo tankInfo : tanksInfo) {
|
||||
if (tankInfo.fluid == null) continue;
|
||||
|
||||
FluidStack fluidStack = new FluidStack(tankInfo.fluid, Math.min(tankInfo.fluid.amount, maxDrain));
|
||||
fluidStack = fh.drain(this.getSide().getOpposite(), fluidStack, false);
|
||||
if (this.filterEnabled() && !this.isInFilter(fluidStack)) continue;
|
||||
|
||||
final AEFluidStack aeFluidStack = AEFluidStack.create(fluidStack);
|
||||
if (aeFluidStack != null) {
|
||||
final IAEFluidStack notInserted = inv.injectItems(aeFluidStack, Actionable.MODULATE, this.mySrc);
|
||||
|
||||
if (notInserted != null && notInserted.getStackSize() > 0) {
|
||||
aeFluidStack.decStackSize(notInserted.getStackSize());
|
||||
}
|
||||
|
||||
fh.drain(this.getSide().getOpposite(), aeFluidStack.getFluidStack(), true);
|
||||
maxDrain -= aeFluidStack.getFluidStack().amount;
|
||||
doBreak = false;
|
||||
}
|
||||
|
||||
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
|
||||
int maxDrain = this.calculateAmountToSend();
|
||||
boolean drained = false;
|
||||
|
||||
for (FluidTankInfo tankInfo : tanksInfo) {
|
||||
if (tankInfo.fluid == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FluidStack fluidStack = new FluidStack(tankInfo.fluid, Math.min(tankInfo.fluid.amount, maxDrain));
|
||||
fluidStack = fh.drain(this.getSide().getOpposite(), fluidStack, false);
|
||||
if (this.filterEnabled() && !this.isInFilter(fluidStack)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final AEFluidStack aeFluidStack = AEFluidStack.create(fluidStack);
|
||||
if (aeFluidStack != null) {
|
||||
final IAEFluidStack notInserted = inv
|
||||
.injectItems(aeFluidStack, Actionable.MODULATE, this.source);
|
||||
|
||||
if (notInserted != null && notInserted.getStackSize() > 0) {
|
||||
aeFluidStack.decStackSize(notInserted.getStackSize());
|
||||
}
|
||||
|
||||
fh.drain(this.getSide().getOpposite(), aeFluidStack.getFluidStack(), true);
|
||||
maxDrain -= aeFluidStack.getFluidStack().amount;
|
||||
drained = true;
|
||||
}
|
||||
}
|
||||
|
||||
return drained ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
} catch (GridAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return doBreak;
|
||||
}
|
||||
|
||||
return TickRateModulation.SLEEP;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canDoBusWork() {
|
||||
return this.getProxy().isActive();
|
||||
protected boolean doOreDict(final Object myTarget, IMEMonitor<IAEFluidStack> inv, IEnergyGrid energy,
|
||||
FuzzyMode fzMode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPowerMultiplier() {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
private boolean isInFilter(FluidStack fluid) {
|
||||
for (int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++) {
|
||||
final IAEFluidStack stack = AEFluidStack
|
||||
.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
|
||||
final IAEStackInventory inv = this.getAEInventoryByName(StorageName.NONE);
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
final IAEFluidStack stack = (IAEFluidStack) inv.getAEStackInSlot(i);
|
||||
if (stack != null && stack.getFluidStack().equals(fluid)) {
|
||||
return true;
|
||||
}
|
||||
@@ -133,9 +150,9 @@ public class PartFluidImportBus extends FCSharedFluidBus {
|
||||
}
|
||||
|
||||
private boolean filterEnabled() {
|
||||
for (int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++) {
|
||||
final IAEFluidStack stack = AEFluidStack
|
||||
.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
|
||||
final IAEStackInventory inv = this.getAEInventoryByName(StorageName.NONE);
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
final IAEFluidStack stack = (IAEFluidStack) inv.getAEStackInSlot(i);
|
||||
if (stack != null) {
|
||||
return true;
|
||||
}
|
||||
@@ -143,71 +160,17 @@ public class PartFluidImportBus extends FCSharedFluidBus {
|
||||
return false;
|
||||
}
|
||||
|
||||
// legacy
|
||||
@Override
|
||||
public RedstoneMode getRSMode() {
|
||||
return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED);
|
||||
}
|
||||
public void readFromNBT(NBTTagCompound extra) {
|
||||
super.readFromNBT(extra);
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
bch.addBox(6, 6, 11, 10, 10, 13);
|
||||
bch.addBox(5, 5, 13, 11, 11, 14);
|
||||
bch.addBox(4, 4, 14, 12, 12, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartImportSides.getIcon(),
|
||||
CableBusTextures.PartImportSides.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.getFaceIcon(),
|
||||
CableBusTextures.PartImportSides.getIcon(),
|
||||
CableBusTextures.PartImportSides.getIcon());
|
||||
|
||||
rh.setBounds(3, 3, 15, 13, 13, 16);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(4, 4, 14, 12, 12, 15);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(5, 5, 13, 11, 11, 14);
|
||||
rh.renderInventoryBox(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer) {
|
||||
this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache()));
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartImportSides.getIcon(),
|
||||
CableBusTextures.PartImportSides.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.getFaceIcon(),
|
||||
CableBusTextures.PartImportSides.getIcon(),
|
||||
CableBusTextures.PartImportSides.getIcon());
|
||||
|
||||
rh.setBounds(4, 4, 14, 12, 12, 16);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setBounds(5, 5, 13, 11, 11, 14);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setBounds(6, 6, 12, 10, 10, 13);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.getFaceIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon());
|
||||
|
||||
rh.setBounds(6, 6, 11, 10, 10, 12);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
this.renderLights(x, y, z, rh, renderer);
|
||||
final IAEStackInventory config = this.getAEInventoryByName(StorageName.NONE);
|
||||
for (int i = 0; i < config.getSizeInventory(); i++) {
|
||||
final IAEStack<?> stack = config.getAEStackInSlot(i);
|
||||
if (stack instanceof IAEItemStack ais) {
|
||||
config.putAEStackInSlot(i, Util.getAEFluidFromItem(ais.getItemStack()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,22 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.client.FluidInterfaceButtons;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.AEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.inventory.IDualHost;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.DualityFluidInterface;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
@@ -31,86 +27,27 @@ import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.helpers.ICustomButtonDataObject;
|
||||
import appeng.helpers.ICustomButtonProvider;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
public class PartFluidInterface extends PartInterface implements IDualHost, ICustomButtonProvider {
|
||||
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
|
||||
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this);
|
||||
|
||||
private ICustomButtonDataObject customButtonDataObject;
|
||||
|
||||
public PartFluidInterface(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer) {
|
||||
this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache()));
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(),
|
||||
FCPartsTexture.BlockInterface_Face.getIcon(),
|
||||
CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartMonitorSides.getIcon());
|
||||
|
||||
rh.setBounds(2, 2, 14, 14, 14, 16);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(),
|
||||
FCPartsTexture.BlockInterface_Face.getIcon(),
|
||||
CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartMonitorSides.getIcon());
|
||||
|
||||
rh.setBounds(5, 5, 12, 11, 11, 13);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(),
|
||||
FCPartsTexture.BlockInterface_Face.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon());
|
||||
|
||||
rh.setBounds(5, 5, 13, 11, 11, 14);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
this.renderLights(x, y, z, rh, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(),
|
||||
FCPartsTexture.BlockInterface_Face.getIcon(),
|
||||
CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartMonitorSides.getIcon());
|
||||
|
||||
rh.setBounds(2, 2, 14, 14, 14, 16);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(5, 5, 12, 11, 11, 13);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(5, 5, 13, 11, 11, 14);
|
||||
rh.renderInventoryBox(renderer);
|
||||
this.customButtonDataObject = new FluidInterfaceButtons(false);
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
@@ -222,22 +159,6 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
return fluidDuality.getTankInfo(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
if (player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.DUAL_INTERFACE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
|
||||
saveChanges();
|
||||
@@ -283,4 +204,38 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
return fluid;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPrimaryGuiIcon() {
|
||||
return ItemAndBlockHolder.FLUID_INTERFACE.stack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomButtonData() {}
|
||||
|
||||
@Override
|
||||
public void readCustomButtonData() {}
|
||||
|
||||
@Override
|
||||
public void initCustomButtons(int guiLeft, int guiTop, int xSize, int ySize, int xOffset, int yOffset,
|
||||
List<GuiButton> buttonList) {
|
||||
if (customButtonDataObject != null)
|
||||
customButtonDataObject.initCustomButtons(guiLeft, guiTop, xSize, ySize, xOffset, yOffset, buttonList);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean actionPerformedCustomButtons(final GuiButton btn) {
|
||||
return customButtonDataObject != null && customButtonDataObject.actionPerformedCustomButtons(btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICustomButtonDataObject getDataObject() {
|
||||
return customButtonDataObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataObject(ICustomButtonDataObject dataObject) {
|
||||
customButtonDataObject = dataObject;
|
||||
}
|
||||
}
|
||||
@@ -1,603 +1,14 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import com.glodblock.github.api.registries.ILevelViewable;
|
||||
import com.glodblock.github.api.registries.LevelItemInfo;
|
||||
import com.glodblock.github.api.registries.LevelState;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingWatcher;
|
||||
import appeng.api.networking.crafting.ICraftingWatcherHost;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.networking.storage.IStackWatcher;
|
||||
import appeng.api.networking.storage.IStackWatcherHost;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
|
||||
public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatcherHost, ICraftingWatcherHost,
|
||||
IMEMonitorHandlerReceiver<IAEFluidStack>, IGridTickable, ILevelViewable {
|
||||
|
||||
private static final int FLAG_ON = 8;
|
||||
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 1);
|
||||
|
||||
private boolean prevState = false;
|
||||
|
||||
private long lastReportedValue = 0;
|
||||
private long reportingValue = 0;
|
||||
|
||||
private IStackWatcher myWatcher;
|
||||
private double centerX;
|
||||
private double centerY;
|
||||
private double centerZ;
|
||||
|
||||
private int lastWorkingTick = 0;
|
||||
private boolean delayedUpdatesQueued = false;
|
||||
public class PartFluidLevelEmitter extends PartLevelEmitter {
|
||||
|
||||
@Reflected
|
||||
public PartFluidLevelEmitter(final ItemStack is) {
|
||||
super(is);
|
||||
|
||||
this.getConfigManager().registerSetting(Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL);
|
||||
|
||||
// Workaround the emitter randomly breaking on world load
|
||||
if (MinecraftServer.getServer() != null) {
|
||||
delayedUpdatesQueued = true;
|
||||
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
|
||||
}
|
||||
}
|
||||
|
||||
public long getReportingValue() {
|
||||
return this.reportingValue;
|
||||
}
|
||||
|
||||
public void setReportingValue(final long v) {
|
||||
this.reportingValue = v;
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerChanged(final MENetworkPowerStatusChange c) {
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
final boolean isOn = this.isLevelEmitterOn();
|
||||
if (this.prevState != isOn) {
|
||||
this.getHost().markForUpdate();
|
||||
final TileEntity te = this.getHost().getTile();
|
||||
this.prevState = isOn;
|
||||
Platform.notifyBlocksOfNeighbors(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
|
||||
Platform.notifyBlocksOfNeighbors(
|
||||
te.getWorldObj(),
|
||||
te.xCoord + this.getSide().offsetX,
|
||||
te.yCoord + this.getSide().offsetY,
|
||||
te.zCoord + this.getSide().offsetZ);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLevelEmitterOn() {
|
||||
if (Platform.isClient()) {
|
||||
return (this.getClientFlags() & FLAG_ON) == FLAG_ON;
|
||||
}
|
||||
|
||||
if (!this.getProxy().isActive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Enum<?> redstoneEmitterSetting = this.getConfigManager().getSetting(Settings.REDSTONE_EMITTER);
|
||||
final boolean result;
|
||||
|
||||
if (redstoneEmitterSetting == RedstoneMode.LOW_SIGNAL) {
|
||||
result = this.reportingValue >= this.lastReportedValue + 1;
|
||||
} else {
|
||||
result = this.reportingValue < this.lastReportedValue + 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void channelChanged(final MENetworkChannelsChanged c) {
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int populateFlags(final int cf) {
|
||||
return cf | (this.prevState ? FLAG_ON : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getBreakingTexture() {
|
||||
return this.getItemStack().getIconIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWatcher(final ICraftingWatcher newWatcher) {
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestChange(final ICraftingGrid craftingGrid, final IAEItemStack what) {
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
private IAEFluidStack getIAEFluidStack() {
|
||||
final FluidStack fs = ItemFluidPacket.getFluidStack(this.config.getAEStackInSlot(0));
|
||||
if (fs != null) return Util.FluidUtil.createAEFluidStack(fs);
|
||||
return null;
|
||||
}
|
||||
|
||||
// update the system...
|
||||
private void configureWatchers() {
|
||||
final IAEFluidStack myStack = this.getIAEFluidStack();
|
||||
|
||||
if (this.myWatcher != null) {
|
||||
this.myWatcher.clear();
|
||||
}
|
||||
|
||||
try {
|
||||
this.getProxy().getStorage().getFluidInventory().removeListener(this);
|
||||
if (this.myWatcher != null && myStack != null) {
|
||||
this.myWatcher.add(myStack);
|
||||
}
|
||||
|
||||
if (myStack == null) {
|
||||
this.getProxy().getStorage().getFluidInventory().addListener(this, this.getProxy().getGrid());
|
||||
}
|
||||
|
||||
this.updateReportingValue(this.getProxy().getStorage().getFluidInventory());
|
||||
} catch (final GridAccessException ignored) {}
|
||||
}
|
||||
|
||||
private void updateReportingValue(final IMEMonitor<IAEFluidStack> monitor) {
|
||||
final IAEFluidStack myStack = this.getIAEFluidStack();
|
||||
|
||||
if (myStack == null) {
|
||||
this.lastReportedValue = 0;
|
||||
for (final IAEFluidStack st : monitor.getStorageList()) {
|
||||
this.lastReportedValue += st.getStackSize();
|
||||
}
|
||||
} else {
|
||||
final IAEFluidStack r = monitor.getStorageList().findPrecise(myStack);
|
||||
if (r == null) {
|
||||
this.lastReportedValue = 0;
|
||||
} else {
|
||||
this.lastReportedValue = r.getStackSize();
|
||||
}
|
||||
}
|
||||
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWatcher(final IStackWatcher newWatcher) {
|
||||
this.myWatcher = newWatcher;
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStackChange(@SuppressWarnings("rawtypes") final IItemList o,
|
||||
@SuppressWarnings("rawtypes") final IAEStack fullStack,
|
||||
@SuppressWarnings("rawtypes") final IAEStack diffStack, final BaseActionSource src,
|
||||
final StorageChannel chan) {
|
||||
if (chan == StorageChannel.FLUIDS && fullStack.equals(this.getIAEFluidStack())) {
|
||||
this.lastReportedValue = fullStack.getStackSize();
|
||||
this.updateState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final Object effectiveGrid) {
|
||||
try {
|
||||
return this.getProxy().getGrid() == effectiveGrid;
|
||||
} catch (final GridAccessException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node) {
|
||||
return new TickingRequest(
|
||||
AEConfig.instance.levelEmitterDelay / 2,
|
||||
AEConfig.instance.levelEmitterDelay,
|
||||
!delayedUpdatesQueued,
|
||||
true);
|
||||
}
|
||||
|
||||
private boolean canDoWork() {
|
||||
int currentTick = MinecraftServer.getServer().getTickCounter();
|
||||
return (currentTick - lastWorkingTick) > AEConfig.instance.levelEmitterDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) {
|
||||
if (delayedUpdatesQueued && canDoWork()) {
|
||||
delayedUpdatesQueued = false;
|
||||
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
|
||||
this.onListUpdate();
|
||||
}
|
||||
return delayedUpdatesQueued ? TickRateModulation.IDLE : TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change,
|
||||
final BaseActionSource actionSource) {
|
||||
if (canDoWork()) {
|
||||
if (delayedUpdatesQueued) {
|
||||
delayedUpdatesQueued = false;
|
||||
try {
|
||||
this.getProxy().getTick().sleepDevice(this.getProxy().getNode());
|
||||
} catch (GridAccessException e) {
|
||||
AELog.error(e, "Couldn't put level emitter to sleep after cancelling delayed updates");
|
||||
}
|
||||
}
|
||||
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
|
||||
this.updateReportingValue((IMEMonitor<IAEFluidStack>) monitor);
|
||||
} else if (!delayedUpdatesQueued) {
|
||||
delayedUpdatesQueued = true;
|
||||
try {
|
||||
this.getProxy().getTick().alertDevice(this.getProxy().getNode());
|
||||
} catch (GridAccessException e) {
|
||||
AELog.error(e, "Couldn't wake up level emitter for delayed updates");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate() {
|
||||
try {
|
||||
this.updateReportingValue(this.getProxy().getStorage().getFluidInventory());
|
||||
} catch (final GridAccessException ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final ForgeDirection dir) {
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
bch.addBox(7, 7, 11, 9, 9, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
rh.setTexture(this.getItemStack().getIconIndex());
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawingQuads();
|
||||
this.renderTorchAtAngle(0, -0.5, 0);
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
private void renderTorchAtAngle(double baseX, double baseY, double baseZ) {
|
||||
final boolean isOn = this.isLevelEmitterOn();
|
||||
final IIcon offTexture = this.getItemStack().getIconIndex();
|
||||
final IIcon IIcon = (isOn ? CableBusTextures.LevelEmitterTorchOn.getIcon() : offTexture);
|
||||
this.centerX = baseX + 0.5;
|
||||
this.centerY = baseY + 0.5;
|
||||
this.centerZ = baseZ + 0.5;
|
||||
|
||||
baseY += 7.0 / 16.0;
|
||||
|
||||
final float var16 = IIcon.getMinU();
|
||||
final float var17 = IIcon.getMaxU();
|
||||
final float var18 = IIcon.getMinV();
|
||||
final float var19 = IIcon.getMaxV();
|
||||
|
||||
final double var20b = offTexture.getInterpolatedU(7.0D);
|
||||
final double var24b = offTexture.getInterpolatedU(9.0D);
|
||||
|
||||
final double var20 = IIcon.getInterpolatedU(7.0D);
|
||||
final double var24 = IIcon.getInterpolatedU(9.0D);
|
||||
final double var22 = IIcon.getInterpolatedV(6.0D + (isOn ? 0 : 1.0D));
|
||||
final double var26 = IIcon.getInterpolatedV(8.0D + (isOn ? 0 : 1.0D));
|
||||
final double var28 = IIcon.getInterpolatedU(7.0D);
|
||||
final double var30 = IIcon.getInterpolatedV(13.0D);
|
||||
final double var32 = IIcon.getInterpolatedU(9.0D);
|
||||
final double var34 = IIcon.getInterpolatedV(15.0D);
|
||||
|
||||
final double var22b = IIcon.getInterpolatedV(9.0D);
|
||||
final double var26b = IIcon.getInterpolatedV(11.0D);
|
||||
|
||||
baseX += 0.5D;
|
||||
baseZ += 0.5D;
|
||||
final double var36 = baseX - 0.5D;
|
||||
final double var38 = baseX + 0.5D;
|
||||
final double var40 = baseZ - 0.5D;
|
||||
final double var42 = baseZ + 0.5D;
|
||||
|
||||
double toff = 0.0d;
|
||||
|
||||
if (!isOn) {
|
||||
toff = 1.0d / 16.0d;
|
||||
}
|
||||
|
||||
final Tessellator var12 = Tessellator.instance;
|
||||
if (isOn) {
|
||||
var12.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
var12.setBrightness(11 << 20 | 11 << 4);
|
||||
}
|
||||
|
||||
final double TorchLen = 0.625D;
|
||||
final double var44 = 0.0625D;
|
||||
final double Zero = 0;
|
||||
final double par10 = 0;
|
||||
|
||||
final double x = baseX + Zero * (1.0D - TorchLen) - var44;
|
||||
final double x1 = baseX + Zero * (1.0D - TorchLen) + var44;
|
||||
|
||||
final double y = baseY + TorchLen - toff;
|
||||
final double var422 = 0.1915D + 1.0 / 16.0;
|
||||
final double y1 = baseY + var422;
|
||||
|
||||
final double z = baseZ + par10 * (1.0D - TorchLen) - var44;
|
||||
final double z1 = baseZ + par10 * (1.0D - TorchLen) + var44;
|
||||
|
||||
this.addVertexWithUV(x, y, z, var20, var22);
|
||||
this.addVertexWithUV(x, y, z1, var20, var26);
|
||||
this.addVertexWithUV(x1, y, z1, var24, var26);
|
||||
this.addVertexWithUV(x1, y, z, var24, var22);
|
||||
|
||||
this.addVertexWithUV(x1, y1, z, var24b, var22b);
|
||||
this.addVertexWithUV(x1, y1, z1, var24b, var26b);
|
||||
this.addVertexWithUV(x, y1, z1, var20b, var26b);
|
||||
this.addVertexWithUV(x, y1, z, var20b, var22b);
|
||||
|
||||
this.addVertexWithUV(baseX + var44 + Zero, baseY, baseZ - var44 + par10, var32, var30);
|
||||
this.addVertexWithUV(baseX + var44 + Zero, baseY, baseZ + var44 + par10, var32, var34);
|
||||
this.addVertexWithUV(baseX - var44 + Zero, baseY, baseZ + var44 + par10, var28, var34);
|
||||
this.addVertexWithUV(baseX - var44 + Zero, baseY, baseZ - var44 + par10, var28, var30);
|
||||
|
||||
this.addVertexWithUV(baseX - var44, baseY + 1.0D, var40, var16, var18);
|
||||
this.addVertexWithUV(baseX - var44 + Zero, baseY + 0.0D, var40 + par10, var16, var19);
|
||||
this.addVertexWithUV(baseX - var44 + Zero, baseY + 0.0D, var42 + par10, var17, var19);
|
||||
this.addVertexWithUV(baseX - var44, baseY + 1.0D, var42, var17, var18);
|
||||
|
||||
this.addVertexWithUV(baseX + var44, baseY + 1.0D, var42, var16, var18);
|
||||
this.addVertexWithUV(baseX + Zero + var44, baseY + 0.0D, var42 + par10, var16, var19);
|
||||
this.addVertexWithUV(baseX + Zero + var44, baseY + 0.0D, var40 + par10, var17, var19);
|
||||
this.addVertexWithUV(baseX + var44, baseY + 1.0D, var40, var17, var18);
|
||||
|
||||
this.addVertexWithUV(var36, baseY + 1.0D, baseZ + var44, var16, var18);
|
||||
this.addVertexWithUV(var36 + Zero, baseY + 0.0D, baseZ + var44 + par10, var16, var19);
|
||||
this.addVertexWithUV(var38 + Zero, baseY + 0.0D, baseZ + var44 + par10, var17, var19);
|
||||
this.addVertexWithUV(var38, baseY + 1.0D, baseZ + var44, var17, var18);
|
||||
|
||||
this.addVertexWithUV(var38, baseY + 1.0D, baseZ - var44, var16, var18);
|
||||
this.addVertexWithUV(var38 + Zero, baseY + 0.0D, baseZ - var44 + par10, var16, var19);
|
||||
this.addVertexWithUV(var36 + Zero, baseY + 0.0D, baseZ - var44 + par10, var17, var19);
|
||||
this.addVertexWithUV(var36, baseY + 1.0D, baseZ - var44, var17, var18);
|
||||
}
|
||||
|
||||
private void addVertexWithUV(double x, double y, double z, final double u, final double v) {
|
||||
final Tessellator var12 = Tessellator.instance;
|
||||
|
||||
x -= this.centerX;
|
||||
y -= this.centerY;
|
||||
z -= this.centerZ;
|
||||
|
||||
if (this.getSide() == ForgeDirection.DOWN) {
|
||||
y = -y;
|
||||
z = -z;
|
||||
}
|
||||
|
||||
if (this.getSide() == ForgeDirection.EAST) {
|
||||
final double m = x;
|
||||
x = y;
|
||||
y = m;
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if (this.getSide() == ForgeDirection.WEST) {
|
||||
final double m = x;
|
||||
x = -y;
|
||||
y = m;
|
||||
}
|
||||
|
||||
if (this.getSide() == ForgeDirection.SOUTH) {
|
||||
final double m = z;
|
||||
z = y;
|
||||
y = m;
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if (this.getSide() == ForgeDirection.NORTH) {
|
||||
final double m = z;
|
||||
z = -y;
|
||||
y = m;
|
||||
}
|
||||
|
||||
x += this.centerX; // + orientation.offsetX * 0.4;
|
||||
y += this.centerY; // + orientation.offsetY * 0.4;
|
||||
z += this.centerZ; // + orientation.offsetZ * 0.4;
|
||||
|
||||
var12.addVertexWithUV(x, y, z, u, v);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer) {
|
||||
rh.setTexture(this.getItemStack().getIconIndex());
|
||||
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
tess.setBrightness(rh.getBlock().getMixedBrightnessForBlock(this.getHost().getTile().getWorldObj(), x, y, z));
|
||||
tess.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
|
||||
this.renderTorchAtAngle(x, y, z);
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
|
||||
rh.setBounds(7, 7, 11, 9, 9, 12);
|
||||
this.renderLights(x, y, z, rh, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower() {
|
||||
return this.prevState ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower() {
|
||||
return this.prevState ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random r) {
|
||||
if (this.isLevelEmitterOn()) {
|
||||
final ForgeDirection d = this.getSide();
|
||||
|
||||
final double d0 = d.offsetX * 0.45F + (r.nextFloat() - 0.5F) * 0.2D;
|
||||
final double d1 = d.offsetY * 0.45F + (r.nextFloat() - 0.5F) * 0.2D;
|
||||
final double d2 = d.offsetZ * 0.45F + (r.nextFloat() - 0.5F) * 0.2D;
|
||||
|
||||
world.spawnParticle("reddust", 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
if (!player.isSneaking()) {
|
||||
if (Platform.isClient()) {
|
||||
return true;
|
||||
}
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(getSide()),
|
||||
GuiType.FLUID_LEVEL_EMITTER);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, @SuppressWarnings("rawtypes") final Enum settingName,
|
||||
@SuppressWarnings("rawtypes") final Enum newValue) {
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
if (inv == this.config) {
|
||||
this.configureWatchers();
|
||||
}
|
||||
super.onChangeInventory(inv, slot, mc, removedStack, newStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged() {
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.lastReportedValue = data.getLong("lastReportedValue");
|
||||
this.reportingValue = data.getLong("reportingValue");
|
||||
this.prevState = data.getBoolean("prevState");
|
||||
this.config.readFromNBT(data, "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
data.setLong("lastReportedValue", this.lastReportedValue);
|
||||
data.setLong("reportingValue", this.reportingValue);
|
||||
data.setBoolean("prevState", this.prevState);
|
||||
this.config.writeToNBT(data, "config");
|
||||
}
|
||||
|
||||
public void setFluidInSlot(int id, IAEFluidStack fluid) {
|
||||
ItemStack tmp = ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack());
|
||||
this.config.setInventorySlotContents(id, tmp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(final String name) {
|
||||
if (name.equals("config")) {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
return super.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LevelItemInfo[] getLevelItemInfoList() {
|
||||
ItemStack stack = this.config.getStackInSlot(0);
|
||||
if (stack == null) return new LevelItemInfo[] { null };
|
||||
return new LevelItemInfo[] { new LevelItemInfo(
|
||||
stack,
|
||||
this.getReportingValue(),
|
||||
-1,
|
||||
this.isProvidingStrongPower() > 0 ? LevelState.Craft : LevelState.Idle) };
|
||||
}
|
||||
}
|
||||
@@ -1,279 +1,53 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import static appeng.helpers.DualityInterface.NUMBER_OF_STORAGE_SLOTS;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import com.glodblock.github.client.FluidInterfaceButtons;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.AEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.inventory.IDualHost;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.DualityFluidInterface;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.helpers.ICustomButtonDataObject;
|
||||
import appeng.helpers.ICustomButtonProvider;
|
||||
import appeng.parts.p2p.PartP2PInterface;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.parts.p2p.PartP2PTunnelStatic;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorIInventory;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.inv.WrapperInvSlot;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInterface>
|
||||
implements IGridTickable, IStorageMonitorable, IInventoryDestination, IDualHost, ISidedInventory,
|
||||
IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost, IInterfaceHost {
|
||||
public class PartFluidP2PInterface extends PartP2PInterface implements IDualHost, ICustomButtonProvider {
|
||||
|
||||
boolean needUpdateOnNetworkBooted = false;
|
||||
boolean lastPowerStart = false;
|
||||
|
||||
public PartFluidP2PInterface(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
private final DualityInterface duality = new DualityInterface(this.getProxy(), this) {
|
||||
|
||||
@Override
|
||||
public void updateCraftingList() {
|
||||
if (!isOutput()) {
|
||||
CraftingGridCache.pauseRebuilds();
|
||||
|
||||
super.updateCraftingList();
|
||||
|
||||
try {
|
||||
for (PartFluidP2PInterface p2p : getOutputs()) {
|
||||
p2p.duality.updateCraftingList();
|
||||
}
|
||||
} catch (GridAccessException e) {
|
||||
// ?
|
||||
}
|
||||
|
||||
CraftingGridCache.unpauseRebuilds();
|
||||
} else {
|
||||
PartFluidP2PInterface p2p = getInput();
|
||||
if (p2p != null) {
|
||||
this.craftingList = p2p.duality.craftingList;
|
||||
try {
|
||||
this.gridProxy.getGrid()
|
||||
.postEvent(new MENetworkCraftingPatternChange(this, this.gridProxy.getNode()));
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
|
||||
final boolean powerState = proxy.isActive();
|
||||
if (needUpdateOnNetworkBooted || lastPowerStart != powerState) {
|
||||
needUpdateOnNetworkBooted = false;
|
||||
lastPowerStart = powerState;
|
||||
updateSharingInventory();
|
||||
}
|
||||
return super.tickingRequest(node, ticksSinceLastCall);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasWorkToDo() {
|
||||
if (isOutput()) {
|
||||
return hasItemsToSend() || hasConfig() || !getStorage().isEmpty();
|
||||
} else return super.hasWorkToDo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfig() {
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface p2p = getInput();
|
||||
boolean alertDevice = false;
|
||||
|
||||
if (p2p != null) {
|
||||
this.setHasConfig(p2p.duality.hasConfig());
|
||||
|
||||
alertDevice = hasWorkToDo();
|
||||
|
||||
} else {
|
||||
this.setHasConfig(false);
|
||||
}
|
||||
|
||||
if (alertDevice) {
|
||||
try {
|
||||
this.gridProxy.getTick().alertDevice(this.gridProxy.getNode());
|
||||
} catch (final GridAccessException ignored) {}
|
||||
} else {
|
||||
try {
|
||||
this.gridProxy.getTick().sleepDevice(this.gridProxy.getNode());
|
||||
} catch (final GridAccessException ignored) {}
|
||||
}
|
||||
|
||||
this.notifyNeighbors();
|
||||
} else {
|
||||
super.readConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDrops(final List<ItemStack> drops) {
|
||||
if (!isOutput()) {
|
||||
super.addDrops(drops);
|
||||
try {
|
||||
for (PartFluidP2PInterface p2p : getOutputs()) p2p.duality.addDrops(drops);
|
||||
} catch (GridAccessException ignored) {}
|
||||
} else {
|
||||
List<IAEStack<?>> waitingList = this.getWaitingToSend();
|
||||
if (waitingList != null) {
|
||||
for (final IAEStack<?> as : waitingList) {
|
||||
if (as instanceof IAEItemStack ais) {
|
||||
drops.add(ais.getItemStack());
|
||||
} else if (as instanceof IAEFluidStack afs) {
|
||||
drops.add(ItemFluidPacket.newStack(afs));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final ItemStack is : this.getUpgrades()) {
|
||||
if (is != null) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
for (final ItemStack is : this.getPatterns()) {
|
||||
if (is != null) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(Upgrades u) {
|
||||
if (isOutput() && u == Upgrades.PATTERN_CAPACITY) return -1;
|
||||
return super.getInstalledUpgrades(u);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConfigSize() {
|
||||
if (isOutput()) return -1;
|
||||
return super.getConfigSize();
|
||||
}
|
||||
};
|
||||
private final DualityFluidInterface dualityFluid = new DualityFluidInterface(this.getProxy(), this);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
|
||||
|
||||
private void updateSharingInventory() {
|
||||
duality.readConfig();
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface p2p = getInput();
|
||||
if (proxy.isActive() && p2p != null) {
|
||||
if (!duality.sharedInventory && !duality.getStorage().isEmpty()) {
|
||||
ArrayList<ItemStack> drops = new ArrayList<>();
|
||||
AppEngInternalInventory storageAppEng = this.duality.getStorage();
|
||||
AdaptorIInventory p2pInv = new AdaptorIInventory(p2p.duality.getStorage());
|
||||
for (ItemStack itemStack : storageAppEng) {
|
||||
if (itemStack == null) continue;
|
||||
ItemStack drop = p2pInv.addItems(itemStack);
|
||||
if (drop != null && drop.stackSize > 0) {
|
||||
drops.add(drop);
|
||||
}
|
||||
}
|
||||
TileEntity te = getTileEntity();
|
||||
Platform.spawnDrops(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, drops);
|
||||
}
|
||||
duality.setStorage(p2p.duality.getStorage());
|
||||
duality.setSlotInv(p2p.duality.getSlotInv());
|
||||
duality.sharedInventory = true;
|
||||
} else {
|
||||
if (duality.sharedInventory) {
|
||||
duality.setStorage(new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS));
|
||||
duality.setSlotInv(new WrapperInvSlot(duality.getStorage()));
|
||||
duality.sharedInventory = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (duality.sharedInventory) {
|
||||
duality.setStorage(new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS));
|
||||
duality.setSlotInv(new WrapperInvSlot(duality.getStorage()));
|
||||
duality.sharedInventory = false;
|
||||
}
|
||||
try {
|
||||
for (PartFluidP2PInterface p2p : getOutputs()) {
|
||||
p2p.duality.readConfig();
|
||||
}
|
||||
} catch (GridAccessException ignored) {}
|
||||
}
|
||||
}
|
||||
private ICustomButtonDataObject customButtonDataObject;
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(final MENetworkChannelsChanged c) {
|
||||
this.duality.notifyNeighbors();
|
||||
updateSharingInventory();
|
||||
needUpdateOnNetworkBooted = true;
|
||||
}
|
||||
public PartFluidP2PInterface(ItemStack is) {
|
||||
super(is);
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(final MENetworkPowerStatusChange c) {
|
||||
this.duality.notifyNeighbors();
|
||||
updateSharingInventory();
|
||||
needUpdateOnNetworkBooted = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(final Upgrades u) {
|
||||
return this.duality.getInstalledUpgrades(u);
|
||||
this.customButtonDataObject = new FluidInterfaceButtons(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -282,31 +56,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
return ItemAndBlockHolder.INTERFACE.getBlockTextureFromSide(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged() {
|
||||
super.gridChanged();
|
||||
dualityFluid.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.duality.readFromNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
this.duality.writeToNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getMemoryCardData() {
|
||||
final NBTTagCompound output = super.getMemoryCardData();
|
||||
this.duality.getConfigManager().writeToNBT(output);
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PartP2PTunnel<?> applyMemoryCard(EntityPlayer player, IMemoryCard memoryCard, ItemStack is) {
|
||||
PartP2PTunnel<?> newTunnel = super.applyMemoryCard(player, memoryCard, is);
|
||||
@@ -318,112 +67,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
return newTunnel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld() {
|
||||
super.addToWorld();
|
||||
this.duality.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
|
||||
this.duality.addDrops(drops);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
return this.duality.getConfigManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(final String name) {
|
||||
return this.duality.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged() {
|
||||
this.duality.updateRedstoneState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer p, final Vec3 pos) {
|
||||
if (super.onPartActivate(p, pos)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (p.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Platform.isServer()) {
|
||||
InventoryHandler.openGui(
|
||||
p,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.DUAL_INTERFACE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dropPatterns(final PartFluidP2PInterface p2p) {
|
||||
final AppEngInternalInventory patterns = p2p.duality.getPatterns();
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
for (int i = 0; i < patterns.getSizeInventory(); i++) {
|
||||
if (patterns.getStackInSlot(i) == null) continue;
|
||||
drops.add(patterns.getStackInSlot(i));
|
||||
}
|
||||
if (!drops.isEmpty()) {
|
||||
final TileEntity te = p2p.getTileEntity();
|
||||
Platform.spawnDrops(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, drops);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void copyContents(final PartP2PTunnel<?> from) {
|
||||
if (from instanceof PartFluidP2PInterface fromInterface) {
|
||||
DualityInterface newDuality = this.duality;
|
||||
// Copy interface storage, upgrades, and settings over
|
||||
UpgradeInventory upgrades = (UpgradeInventory) fromInterface.duality.getInventoryByName("upgrades");
|
||||
UpgradeInventory newUpgrade = (UpgradeInventory) newDuality.getInventoryByName("upgrades");
|
||||
for (int i = 0; i < upgrades.getSizeInventory(); ++i) {
|
||||
newUpgrade.setInventorySlotContents(i, upgrades.getStackInSlot(i));
|
||||
}
|
||||
|
||||
if (!fromInterface.duality.sharedInventory) {
|
||||
IInventory storage = fromInterface.duality.getStorage();
|
||||
IInventory newStorage = newDuality.getStorage();
|
||||
for (int i = 0; i < storage.getSizeInventory(); ++i) {
|
||||
newStorage.setInventorySlotContents(i, storage.getStackInSlot(i));
|
||||
}
|
||||
|
||||
IInventory config = fromInterface.duality.getInventoryByName("config");
|
||||
IInventory newConfig = newDuality.getInventoryByName("config");
|
||||
for (int i = 0; i < config.getSizeInventory(); ++i) {
|
||||
newConfig.setInventorySlotContents(i, config.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
|
||||
AppEngInternalInventory patterns = fromInterface.duality.getPatterns();
|
||||
boolean drop = true;
|
||||
if (!from.isOutput() && !this.isOutput()) { // input to input
|
||||
for (int i = 0; i < patterns.getSizeInventory(); i++) {
|
||||
newDuality.getPatterns().setInventorySlotContents(i, patterns.getStackInSlot(i));
|
||||
}
|
||||
drop = false;
|
||||
}
|
||||
|
||||
if (drop) {
|
||||
this.dropPatterns(fromInterface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void copySettings(final PartP2PTunnel<?> from) {
|
||||
if (from instanceof PartFluidP2PInterface fromInterface) {
|
||||
@@ -435,26 +78,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getBreakingTexture() {
|
||||
return this.getItemStack().getIconIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(final ItemStack stack) {
|
||||
return this.duality.canInsert(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return this.duality.getItemInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return this.duality.getFluidInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node) {
|
||||
TickingRequest item = duality.getTickingRequest(node);
|
||||
@@ -477,216 +100,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return this.duality.getStorage().getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(final int i) {
|
||||
return this.duality.getStorage().getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int i, final int j) {
|
||||
return this.duality.getStorage().decrStackSize(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(final int i) {
|
||||
return this.duality.getStorage().getStackInSlotOnClosing(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(final int i, final ItemStack itemstack) {
|
||||
this.duality.getStorage().setInventorySlotContents(i, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return this.duality.getStorage().getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return this.duality.getStorage().hasCustomInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return this.duality.getStorage().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
this.duality.getStorage().markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
|
||||
return this.duality.getStorage().isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
this.duality.getStorage().openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
this.duality.getStorage().closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(final int i, final ItemStack itemstack) {
|
||||
return this.duality.getStorage().isItemValidForSlot(i, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(final int s) {
|
||||
return this.duality.getAccessibleSlotsFromSide(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int i, final ItemStack itemstack, final int j) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int i, final ItemStack itemstack, final int j) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
this.duality.onChangeInventory(inv, slot, mc, removedStack, newStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DualityInterface getInterfaceDuality() {
|
||||
return this.duality;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getTargets() {
|
||||
return EnumSet.of(this.getSide());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return super.getHost().getTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageMonitorable getMonitorable(final ForgeDirection side, final BaseActionSource src) {
|
||||
return this.duality.getMonitorable(side, src, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushPattern(final ICraftingPatternDetails patternDetails, final InventoryCrafting table) {
|
||||
return this.duality.pushPattern(patternDetails, table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBusy() {
|
||||
return this.duality.isBusy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideCrafting(final ICraftingProviderHelper craftingTracker) {
|
||||
this.duality.provideCrafting(craftingTracker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableSet<ICraftingLink> getRequestedJobs() {
|
||||
return this.duality.getRequestedJobs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems(final ICraftingLink link, final IAEItemStack items, final Actionable mode) {
|
||||
return this.duality.injectCraftedItems(link, items, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobStateChange(final ICraftingLink link) {
|
||||
this.duality.jobStateChange(link);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return this.duality.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(final int newValue) {
|
||||
this.duality.setPriority(newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange() {
|
||||
this.duality.updateCraftingList();
|
||||
updateSharingInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelConfigChange() {
|
||||
updateSharingInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getPatterns() {
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface input = getInput();
|
||||
if (input != null) {
|
||||
return input.getPatterns();
|
||||
}
|
||||
return IInterfaceHost.super.getPatterns();
|
||||
}
|
||||
return IInterfaceHost.super.getPatterns();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int rows() {
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface input = getInput();
|
||||
if (input != null) {
|
||||
return input.rows();
|
||||
}
|
||||
return IInterfaceHost.super.rows();
|
||||
}
|
||||
return IInterfaceHost.super.rows();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int rowSize() {
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface input = getInput();
|
||||
if (input != null) {
|
||||
return input.rowSize();
|
||||
}
|
||||
return IInterfaceHost.super.rowSize();
|
||||
}
|
||||
return IInterfaceHost.super.rowSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface input = getInput();
|
||||
if (input != null) {
|
||||
return input.getName();
|
||||
}
|
||||
return IInterfaceHost.super.getName();
|
||||
}
|
||||
return IInterfaceHost.super.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSelfRep() {
|
||||
return this.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return dualityFluid.fill(from, resource, doFill);
|
||||
@@ -758,8 +171,36 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDisplay() {
|
||||
return IInterfaceHost.super.shouldDisplay();
|
||||
public ItemStack getPrimaryGuiIcon() {
|
||||
return ItemAndBlockHolder.FLUID_INTERFACE.stack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomButtonData() {}
|
||||
|
||||
@Override
|
||||
public void readCustomButtonData() {}
|
||||
|
||||
@Override
|
||||
public void initCustomButtons(int guiLeft, int guiTop, int xSize, int ySize, int xOffset, int yOffset,
|
||||
List<GuiButton> buttonList) {
|
||||
if (customButtonDataObject != null)
|
||||
customButtonDataObject.initCustomButtons(guiLeft, guiTop, xSize, ySize, xOffset, yOffset, buttonList);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean actionPerformedCustomButtons(final GuiButton btn) {
|
||||
return customButtonDataObject != null && customButtonDataObject.actionPerformedCustomButtons(btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICustomButtonDataObject getDataObject() {
|
||||
return customButtonDataObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataObject(ICustomButtonDataObject dataObject) {
|
||||
customButtonDataObject = dataObject;
|
||||
}
|
||||
}
|
||||
@@ -1,161 +1,13 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.tile.inventory.BiggerAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
public class PartFluidPatternTerminal extends FCFluidEncodeTerminal {
|
||||
|
||||
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright;
|
||||
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
|
||||
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark;
|
||||
public class PartFluidPatternTerminal extends PartPatternTerminal {
|
||||
|
||||
public PartFluidPatternTerminal(ItemStack is) {
|
||||
super(is);
|
||||
this.crafting = new BiggerAppEngInventory(this, 9);
|
||||
this.output = new BiggerAppEngInventory(this, 3);
|
||||
this.prioritize = false;
|
||||
this.inverted = false;
|
||||
this.activePage = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiType getGui() {
|
||||
return GuiType.FLUID_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
if (inv == this.pattern && slot == 1) {
|
||||
final ItemStack is = inv.getStackInSlot(1);
|
||||
if (is != null && is.getItem() instanceof final ICraftingPatternItem craftingPatternItem) {
|
||||
final ICraftingPatternDetails details = craftingPatternItem
|
||||
.getPatternForItem(is, this.getHost().getTile().getWorldObj());
|
||||
if (details != null) {
|
||||
final IAEItemStack[] inItems = details.getInputs();
|
||||
final IAEItemStack[] outItems = details.getOutputs();
|
||||
|
||||
this.setCraftingRecipe(details.isCraftable());
|
||||
this.setSubstitution(details.canSubstitute());
|
||||
if (newStack != null) {
|
||||
NBTTagCompound data = newStack.getTagCompound();
|
||||
this.setCombineMode(data.getInteger("combine") == 1);
|
||||
this.setBeSubstitute(details.canBeSubstitute());
|
||||
}
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
this.crafting.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.output.getSizeInventory(); i++) {
|
||||
this.output.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
|
||||
if (inItems[i] != null) {
|
||||
final IAEItemStack item = inItems[i];
|
||||
if (item != null && item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.crafting.setInventorySlotContents(i, packet);
|
||||
} else this.crafting.setInventorySlotContents(i, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
|
||||
if (outItems[i] != null) {
|
||||
final IAEItemStack item = outItems[i];
|
||||
if (item != null && item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.output.setInventorySlotContents(i, packet);
|
||||
} else this.output.setInventorySlotContents(i, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inv == this.crafting) {
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
private void fixCraftingRecipes() {
|
||||
if (this.craftingMode) {
|
||||
for (int x = 0; x < this.crafting.getSizeInventory(); x++) {
|
||||
final ItemStack is = this.crafting.getStackInSlot(x);
|
||||
if (is != null) {
|
||||
is.stackSize = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
super.setCraftingRecipe(craftingMode);
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrioritization(boolean canPrioritize) {
|
||||
this.prioritize = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritize() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInverted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInverted(boolean inverted) {
|
||||
this.inverted = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActivePage() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivePage(int activePage) {
|
||||
this.activePage = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontBright() {
|
||||
return FRONT_BRIGHT_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontColored() {
|
||||
return FRONT_COLORED_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontDark() {
|
||||
return FRONT_DARK_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLightSource() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,149 +1,12 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import appeng.parts.reporting.PartPatternTerminalEx;
|
||||
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.tile.inventory.BiggerAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
public class PartFluidPatternTerminalEx extends FCFluidEncodeTerminal {
|
||||
|
||||
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright;
|
||||
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
|
||||
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark;
|
||||
public class PartFluidPatternTerminalEx extends PartPatternTerminalEx {
|
||||
|
||||
public PartFluidPatternTerminalEx(ItemStack is) {
|
||||
super(is);
|
||||
this.crafting = new BiggerAppEngInventory(this, 32);
|
||||
this.output = new BiggerAppEngInventory(this, 32);
|
||||
this.craftingMode = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiType getGui() {
|
||||
return GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
if (inv == this.pattern && slot == 1) {
|
||||
final ItemStack is = inv.getStackInSlot(1);
|
||||
|
||||
if (is != null && is.getItem() instanceof final ICraftingPatternItem craftingPatternItem) {
|
||||
final ICraftingPatternDetails details = craftingPatternItem
|
||||
.getPatternForItem(is, this.getHost().getTile().getWorldObj());
|
||||
|
||||
if (details != null) {
|
||||
final IAEItemStack[] inItems = details.getInputs();
|
||||
final IAEItemStack[] outItems = details.getOutputs();
|
||||
int inputsCount = 0;
|
||||
int outputCount = 0;
|
||||
for (IAEItemStack inItem : inItems) {
|
||||
if (inItem != null) {
|
||||
inputsCount++;
|
||||
}
|
||||
}
|
||||
for (IAEItemStack outItem : outItems) {
|
||||
if (outItem != null) {
|
||||
outputCount++;
|
||||
}
|
||||
}
|
||||
|
||||
this.setSubstitution(details.canSubstitute());
|
||||
if (newStack != null) {
|
||||
NBTTagCompound data = newStack.getTagCompound();
|
||||
this.setCombineMode(data.getInteger("combine") == 1);
|
||||
this.setBeSubstitute(details.canBeSubstitute());
|
||||
}
|
||||
this.setInverted(inputsCount <= 8 && outputCount > 8);
|
||||
this.setActivePage(0);
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
this.crafting.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.output.getSizeInventory(); i++) {
|
||||
this.output.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
|
||||
final IAEItemStack item = inItems[i];
|
||||
if (item != null) {
|
||||
if (item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.crafting.setInventorySlotContents(i, packet);
|
||||
} else this.crafting.setInventorySlotContents(i, item.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
if (inverted) {
|
||||
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
|
||||
final IAEItemStack item = outItems[i];
|
||||
if (item != null) {
|
||||
if (item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.output.setInventorySlotContents(i, packet);
|
||||
} else this.output.setInventorySlotContents(i, item.getItemStack());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < outItems.length && i < 8; i++) {
|
||||
final IAEItemStack item = outItems[i];
|
||||
if (item != null) {
|
||||
if (item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket
|
||||
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, packet);
|
||||
} else this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
this.craftingMode = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftingRecipe() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontBright() {
|
||||
return FRONT_BRIGHT_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontColored() {
|
||||
return FRONT_COLORED_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontDark() {
|
||||
return FRONT_DARK_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLightSource() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,529 +1,18 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.MEMonitorIFluidHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.ITickManager;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.storage.ICellContainer;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.GridStorageCache;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.me.storage.StorageBusInventoryHandler;
|
||||
import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.IterationCounter;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.prioitylist.PrecisePriorityList;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
|
||||
public class PartFluidStorageBus extends PartUpgradeable
|
||||
implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEFluidStack>, IPriorityHost {
|
||||
|
||||
private final BaseActionSource source;
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 63);
|
||||
private int priority = 0;
|
||||
private boolean cached = false;
|
||||
private MEMonitorIFluidHandler monitor = null;
|
||||
private MEInventoryHandler<IAEFluidStack> handler = null;
|
||||
private int handlerHash = 0;
|
||||
private boolean wasActive = false;
|
||||
private byte resetCacheLogic = 0;
|
||||
/**
|
||||
* used to read changes once when the list of extractable items was changed
|
||||
*/
|
||||
private boolean readOncePass = false;
|
||||
public class PartFluidStorageBus extends PartStorageBus {
|
||||
|
||||
public PartFluidStorageBus(ItemStack is) {
|
||||
super(is);
|
||||
this.getConfigManager().registerSetting(Settings.ACCESS, AccessRestriction.READ_WRITE);
|
||||
this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
|
||||
this.getConfigManager().registerSetting(Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
|
||||
this.getConfigManager().registerSetting(Settings.STICKY_MODE, YesNo.NO);
|
||||
this.source = new MachineSource(this);
|
||||
if (is.getTagCompound() != null) {
|
||||
NBTTagCompound tag = is.getTagCompound();
|
||||
if (tag.hasKey("priority")) {
|
||||
priority = tag.getInteger("priority");
|
||||
// if we don't do this, the tag will stick forever to the storage bus, as it's never cleaned up,
|
||||
// even when the item is broken with a pickaxe
|
||||
this.is.setTagCompound(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(final PartItemStack type) {
|
||||
if (type == PartItemStack.Wrench) {
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("priority", priority);
|
||||
final ItemStack copy = this.is.copy();
|
||||
copy.setTagCompound(tag);
|
||||
return copy;
|
||||
}
|
||||
return super.getItemStack(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(final MENetworkPowerStatusChange c) {
|
||||
this.updateStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void chanRender(final MENetworkChannelsChanged changedChannels) {
|
||||
this.updateStatus();
|
||||
}
|
||||
|
||||
protected void updateStatus() {
|
||||
final boolean currentActive = this.getProxy().isActive();
|
||||
if (this.wasActive != currentActive) {
|
||||
this.wasActive = currentActive;
|
||||
try {
|
||||
this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate());
|
||||
this.getHost().markForUpdate();
|
||||
} catch (final GridAccessException e) {
|
||||
// NO-OP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getUpgradeSlots() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, @SuppressWarnings("rawtypes") final Enum settingName,
|
||||
@SuppressWarnings("rawtypes") final Enum newValue) {
|
||||
this.resetCache(true);
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged() {
|
||||
super.upgradesChanged();
|
||||
this.resetCache(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.config.readFromNBT(data, "config");
|
||||
this.priority = data.getInteger("priority");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
this.config.writeToNBT(data, "config");
|
||||
data.setInteger("priority", this.priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(final String name) {
|
||||
if (name.equals("config")) {
|
||||
return this.config;
|
||||
}
|
||||
return super.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
super.onChangeInventory(inv, slot, mc, removedStack, newStack);
|
||||
|
||||
if (inv == this.config) {
|
||||
this.resetCache(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void resetCache(final boolean fullReset) {
|
||||
if (this.getHost() == null || this.getHost().getTile() == null
|
||||
|| this.getHost().getTile().getWorldObj() == null
|
||||
|| this.getHost().getTile().getWorldObj().isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fullReset) {
|
||||
this.resetCacheLogic = 2;
|
||||
} else if (this.resetCacheLogic < 2) {
|
||||
this.resetCacheLogic = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
this.getProxy().getTick().alertDevice(this.getProxy().getNode());
|
||||
} catch (final GridAccessException ignore) {}
|
||||
}
|
||||
|
||||
protected void resetCache() {
|
||||
final boolean fullReset = this.resetCacheLogic == 2;
|
||||
this.resetCacheLogic = 0;
|
||||
|
||||
final MEInventoryHandler<IAEFluidStack> in = this.getInternalHandler();
|
||||
IItemList<IAEFluidStack> before = AEApi.instance().storage().createFluidList();
|
||||
if (in != null) {
|
||||
before = in.getAvailableItems(before, IterationCounter.fetchNewId());
|
||||
}
|
||||
|
||||
this.cached = false;
|
||||
if (fullReset) {
|
||||
this.handlerHash = 0;
|
||||
}
|
||||
|
||||
final MEInventoryHandler<IAEFluidStack> out = this.getInternalHandler();
|
||||
if (this.monitor != null) {
|
||||
this.monitor.onTick();
|
||||
}
|
||||
|
||||
IItemList<IAEFluidStack> after = AEApi.instance().storage().createFluidList();
|
||||
|
||||
if (in != out) {
|
||||
if (out != null) {
|
||||
after = out.getAvailableItems(after, IterationCounter.fetchNewId());
|
||||
}
|
||||
Platform.postListChanges(before, after, this, this.source);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final Object verificationToken) {
|
||||
return this.handler == verificationToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change,
|
||||
final BaseActionSource source) {
|
||||
try {
|
||||
if (this.getProxy().isActive()) {
|
||||
if (!this.readOncePass) {
|
||||
AccessRestriction currentAccess = (AccessRestriction) this.getConfigManager()
|
||||
.getSetting(Settings.ACCESS);
|
||||
if (!currentAccess.hasPermission(AccessRestriction.READ)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Iterable<IAEFluidStack> filteredChanges = this.filterChanges(change, this.readOncePass);
|
||||
this.readOncePass = false;
|
||||
if (filteredChanges == null) return;
|
||||
this.getProxy().getStorage()
|
||||
.postAlterationOfStoredItems(StorageChannel.FLUIDS, filteredChanges, this.source);
|
||||
}
|
||||
} catch (final GridAccessException ignore) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the changes to only include fluids that pass the handlers extract filter. Will return null if none of the
|
||||
* changes match the filter.
|
||||
*/
|
||||
@Nullable
|
||||
private Iterable<IAEFluidStack> filterChanges(final Iterable<IAEFluidStack> change, final boolean readOncePass) {
|
||||
if (readOncePass) {
|
||||
return change;
|
||||
}
|
||||
|
||||
if (this.handler != null && this.handler.isExtractFilterActive()
|
||||
&& !this.handler.getExtractPartitionList().isEmpty()) {
|
||||
List<IAEFluidStack> filteredChanges = new ArrayList<>();
|
||||
Predicate<IAEFluidStack> extractFilterCondition = this.handler.getExtractFilterCondition();
|
||||
for (final IAEFluidStack changedFluid : change) {
|
||||
if (extractFilterCondition.test(changedFluid)) {
|
||||
filteredChanges.add(changedFluid);
|
||||
}
|
||||
}
|
||||
return filteredChanges.isEmpty() ? null : Collections.unmodifiableList(filteredChanges);
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
bch.addBox(3, 3, 15, 13, 13, 16);
|
||||
bch.addBox(2, 2, 14, 14, 14, 15);
|
||||
bch.addBox(5, 5, 12, 11, 11, 14);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged() {
|
||||
this.resetCache(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
if (player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.FLUID_STORAGE_BUS);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node) {
|
||||
return new TickingRequest(TickRates.StorageBus.getMin(), TickRates.StorageBus.getMax(), monitor == null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
|
||||
if (this.resetCacheLogic != 0) {
|
||||
this.resetCache();
|
||||
}
|
||||
if (this.monitor != null) {
|
||||
return this.monitor.onTick();
|
||||
}
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public MEInventoryHandler<IAEFluidStack> getInternalHandler() {
|
||||
if (this.cached) {
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
final boolean wasSleeping = this.monitor == null;
|
||||
|
||||
this.cached = true;
|
||||
final TileEntity self = this.getHost().getTile();
|
||||
final TileEntity target = new BlockPos(self).getOffSet(this.getSide()).getTileEntity();
|
||||
final int newHandlerHash = Platform.generateTileHash(target);
|
||||
if (newHandlerHash != 0 && newHandlerHash == this.handlerHash) {
|
||||
return this.handler;
|
||||
}
|
||||
this.handlerHash = newHandlerHash;
|
||||
this.handler = null;
|
||||
this.monitor = null;
|
||||
this.readOncePass = true;
|
||||
if (target != null) {
|
||||
final IExternalStorageHandler esh = AEApi.instance().registries().externalStorage()
|
||||
.getHandler(target, this.getSide().getOpposite(), StorageChannel.FLUIDS, this.source);
|
||||
if (esh != null) {
|
||||
final IMEInventory<?> inv = esh
|
||||
.getInventory(target, this.getSide().getOpposite(), StorageChannel.FLUIDS, this.source);
|
||||
if (inv instanceof final MEMonitorIFluidHandler h) {
|
||||
h.setMode((StorageFilter) this.getConfigManager().getSetting(Settings.STORAGE_FILTER));
|
||||
h.setActionSource(new MachineSource(this));
|
||||
this.monitor = h;
|
||||
}
|
||||
if (inv != null) {
|
||||
this.handler = new StorageBusInventoryHandler(inv, StorageChannel.FLUIDS);
|
||||
AccessRestriction currentAccess = (AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS);
|
||||
this.handler.setBaseAccess(currentAccess);
|
||||
this.handler.setWhitelist(
|
||||
this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST
|
||||
: IncludeExclude.WHITELIST);
|
||||
this.handler.setSticky(this.getInstalledUpgrades(Upgrades.STICKY) > 0);
|
||||
this.handler.setPriority(this.priority);
|
||||
// only READ since READ_WRITE would break compat of existing storage buses
|
||||
// could use a new setting that is applied via button or a card too
|
||||
this.handler.setIsExtractFilterActive(currentAccess == AccessRestriction.READ);
|
||||
|
||||
if (inv instanceof IMEMonitor) {
|
||||
((IBaseMonitor) inv).addListener(this, this.handler);
|
||||
}
|
||||
final IItemList<IAEFluidStack> priorityList = AEApi.instance().storage().createFluidList();
|
||||
|
||||
final int slotsToUse = 18 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 9;
|
||||
for (int x = 0; x < this.config.getSizeInventory() && x < slotsToUse; x++) {
|
||||
final IAEItemStack is = this.config.getAEStackInSlot(x);
|
||||
if (is != null) priorityList.add(AEFluidStack.create(ItemFluidPacket.getFluidStack(is)));
|
||||
}
|
||||
PrecisePriorityList partitionList = new PrecisePriorityList(priorityList);
|
||||
this.handler.setPartitionList(partitionList);
|
||||
this.handler.setExtractPartitionList(partitionList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update sleep state...
|
||||
if (wasSleeping != (this.monitor == null)) {
|
||||
try {
|
||||
final ITickManager tm = this.getProxy().getTick();
|
||||
if (this.monitor == null) {
|
||||
tm.sleepDevice(this.getProxy().getNode());
|
||||
} else {
|
||||
tm.wakeDevice(this.getProxy().getNode());
|
||||
}
|
||||
} catch (final GridAccessException ignore) {}
|
||||
}
|
||||
|
||||
try {
|
||||
// force grid to update handlers...
|
||||
((GridStorageCache) this.getProxy().getGrid().getCache(IStorageGrid.class)).cellUpdate(null);
|
||||
} catch (final GridAccessException ignore) {}
|
||||
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public List<IMEInventoryHandler> getCellArray(final StorageChannel channel) {
|
||||
if (channel == StorageChannel.FLUIDS) {
|
||||
final IMEInventoryHandler<IAEFluidStack> out = this.getInternalHandler();
|
||||
if (out != null) {
|
||||
return Collections.singletonList(out);
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue) {
|
||||
this.priority = newValue;
|
||||
this.getHost().markForSave();
|
||||
this.resetCache(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges(@SuppressWarnings("rawtypes") final IMEInventory cellInventory) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public AppEngInternalAEInventory getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
public void setFluidInSlot(int id, IAEFluidStack fluid) {
|
||||
ItemStack tmp = ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack());
|
||||
this.config.setInventorySlotContents(id, tmp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartStorageSides.getIcon(),
|
||||
CableBusTextures.PartStorageSides.getIcon(),
|
||||
CableBusTextures.PartStorageBack.getIcon(),
|
||||
FCPartsTexture.PartFluidStorageBus.getIcon(),
|
||||
CableBusTextures.PartStorageSides.getIcon(),
|
||||
CableBusTextures.PartStorageSides.getIcon());
|
||||
|
||||
rh.setBounds(3, 3, 15, 13, 13, 16);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(2, 2, 14, 14, 14, 15);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(5, 5, 12, 11, 11, 14);
|
||||
rh.renderInventoryBox(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer) {
|
||||
this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache()));
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartStorageSides.getIcon(),
|
||||
CableBusTextures.PartStorageSides.getIcon(),
|
||||
CableBusTextures.PartStorageBack.getIcon(),
|
||||
FCPartsTexture.PartFluidStorageBus.getIcon(),
|
||||
CableBusTextures.PartStorageSides.getIcon(),
|
||||
CableBusTextures.PartStorageSides.getIcon());
|
||||
|
||||
rh.setBounds(3, 3, 15, 13, 13, 16);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setBounds(2, 2, 14, 14, 14, 15);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartStorageSides.getIcon(),
|
||||
CableBusTextures.PartStorageSides.getIcon(),
|
||||
CableBusTextures.PartStorageBack.getIcon(),
|
||||
FCPartsTexture.PartFluidStorageBus.getIcon(),
|
||||
CableBusTextures.PartStorageSides.getIcon(),
|
||||
CableBusTextures.PartStorageSides.getIcon());
|
||||
|
||||
rh.setBounds(5, 5, 12, 11, 11, 13);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(),
|
||||
FCPartsTexture.PartFluidStorageBus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon());
|
||||
|
||||
rh.setBounds(5, 5, 13, 11, 11, 14);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
this.renderLights(x, y, z, rh, renderer);
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,8 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.parts.base.FCPart;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
public class PartFluidTerminal extends FCPart {
|
||||
|
||||
@@ -42,7 +43,7 @@ public class PartFluidTerminal extends FCPart {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiType getGui() {
|
||||
return GuiType.FLUID_TERMINAL;
|
||||
public GuiBridge getGui() {
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,21 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.parts.base.FCPart;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IClickableInTerminal;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
public class PartLevelTerminal extends FCPart implements IClickableInTerminal {
|
||||
|
||||
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartLevelTerminal_Bright;
|
||||
@@ -66,8 +73,8 @@ public class PartLevelTerminal extends FCPart implements IClickableInTerminal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiType getGui() {
|
||||
return GuiType.LEVEL_TERMINAL;
|
||||
public GuiBridge getGui() {
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,4 +87,14 @@ public class PartLevelTerminal extends FCPart implements IClickableInTerminal {
|
||||
public Util.DimensionalCoordSide getClickedInterface() {
|
||||
return this.tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void openGui(EntityPlayer player) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.LEVEL_TERMINAL);
|
||||
}
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
package com.glodblock.github.common.parts.base;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.item.IItemPatternTerminal;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.storage.ITerminalPins;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.items.contents.PinsHandler;
|
||||
import appeng.items.contents.PinsHolder;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
||||
public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatternTerminal, ITerminalPins {
|
||||
|
||||
protected AppEngInternalInventory crafting;
|
||||
protected AppEngInternalInventory output;
|
||||
protected final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
|
||||
private final PinsHolder pinsInv = new PinsHolder(this);
|
||||
|
||||
protected boolean craftingMode = true;
|
||||
protected boolean substitute = false;
|
||||
protected boolean combine = false;
|
||||
protected boolean prioritize = false;
|
||||
protected boolean inverted = false;
|
||||
protected boolean beSubstitute = false;
|
||||
protected boolean autoFillPattern = false;
|
||||
protected int activePage = 0;
|
||||
|
||||
public FCFluidEncodeTerminal(ItemStack is) {
|
||||
super(is, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
|
||||
super.getDrops(drops, wrenched);
|
||||
for (final ItemStack is : this.pattern) {
|
||||
if (is != null) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.setCraftingRecipe(data.getBoolean("craftingMode"));
|
||||
this.setSubstitution(data.getBoolean("substitute"));
|
||||
this.setCombineMode(data.getBoolean("combine"));
|
||||
this.setBeSubstitute(data.getBoolean("beSubstitute"));
|
||||
this.setPrioritization(data.getBoolean("priorization"));
|
||||
this.setInverted(data.getBoolean("inverted"));
|
||||
this.setActivePage(data.getInteger("activePage"));
|
||||
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
|
||||
this.pattern.readFromNBT(data, "pattern");
|
||||
this.output.readFromNBT(data, "outputList");
|
||||
this.crafting.readFromNBT(data, "craftingGrid");
|
||||
pinsInv.readFromNBT(data, "pins");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
data.setBoolean("craftingMode", this.craftingMode);
|
||||
data.setBoolean("combine", this.combine);
|
||||
data.setBoolean("beSubstitute", this.beSubstitute);
|
||||
data.setBoolean("priorization", this.prioritize);
|
||||
data.setBoolean("substitute", this.substitute);
|
||||
data.setBoolean("inverted", this.inverted);
|
||||
data.setInteger("activePage", this.activePage);
|
||||
data.setBoolean("autoFillPattern", this.autoFillPattern);
|
||||
this.pattern.writeToNBT(data, "pattern");
|
||||
this.output.writeToNBT(data, "outputList");
|
||||
this.crafting.writeToNBT(data, "craftingGrid");
|
||||
pinsInv.writeToNBT(data, "pins");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombine() {
|
||||
return this.combine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCombineMode(boolean shouldCombine) {
|
||||
this.combine = shouldCombine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubstitution() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritize() {
|
||||
return this.prioritize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeSubstitute(boolean canBeSubstitute) {
|
||||
this.beSubstitute = canBeSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeSubstitute() {
|
||||
return this.beSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubstitution(boolean canSubstitute) {
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrioritization(boolean canPrioritize) {
|
||||
this.prioritize = canPrioritize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInverted() {
|
||||
return inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInverted(boolean inverted) {
|
||||
this.inverted = inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActivePage() {
|
||||
return this.activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivePage(int activePage) {
|
||||
this.activePage = activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftingRecipe() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
|
||||
IInventory crafting = this.getInventoryByName("crafting");
|
||||
IInventory output = this.getInventoryByName("output");
|
||||
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
|
||||
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
|
||||
final IAEItemStack item = newCrafting[x];
|
||||
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
|
||||
final IAEItemStack item = newOutput[x];
|
||||
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(final String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
return super.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortCraftingItems() {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
List<ItemStack> fluids = new ArrayList<>();
|
||||
for (ItemStack is : this.crafting) {
|
||||
if (is == null) continue;
|
||||
if (is.getItem() instanceof ItemFluidPacket) {
|
||||
fluids.add(is);
|
||||
} else {
|
||||
items.add(is);
|
||||
}
|
||||
}
|
||||
if (this.prioritize) {
|
||||
fluids.addAll(items);
|
||||
items.clear();
|
||||
} else {
|
||||
items.addAll(fluids);
|
||||
fluids.clear();
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
if (this.crafting.getStackInSlot(i) == null) break;
|
||||
if (items.isEmpty()) {
|
||||
this.crafting.setInventorySlotContents(i, fluids.get(i));
|
||||
} else {
|
||||
this.crafting.setInventorySlotContents(i, items.get(i));
|
||||
}
|
||||
}
|
||||
saveChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoFillPattern() {
|
||||
return this.autoFillPattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoFillPattern(boolean canFill) {
|
||||
this.autoFillPattern = canFill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PinsHandler getPinsHandler(EntityPlayer player) {
|
||||
return pinsInv.getHandler(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrid getGrid() {
|
||||
return getGridNode().getGrid();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.glodblock.github.common.parts.base;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -18,8 +17,6 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
@@ -44,6 +41,7 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
@@ -149,7 +147,7 @@ public abstract class FCPart extends AEBasePart
|
||||
this.viewCell.writeToNBT(data, "viewCell");
|
||||
}
|
||||
|
||||
public abstract GuiType getGui();
|
||||
public abstract GuiBridge getGui();
|
||||
|
||||
@Override
|
||||
public void writeToStream(final ByteBuf data) throws IOException {
|
||||
@@ -223,7 +221,7 @@ public abstract class FCPart extends AEBasePart
|
||||
if (Platform.isServer()) {
|
||||
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this)
|
||||
|| Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
|
||||
InventoryHandler.openGui(player, te.getWorldObj(), tePos, Objects.requireNonNull(getSide()), getGui());
|
||||
openGui(player);
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
}
|
||||
@@ -231,6 +229,10 @@ public abstract class FCPart extends AEBasePart
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void openGui(EntityPlayer player) {
|
||||
Platform.openGUI(player, this.getHost().getTile(), this.getSide(), this.getGui());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPlacement(final EntityPlayer player, final ItemStack held, final ForgeDirection side) {
|
||||
super.onPlacement(player, held, side);
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
package com.glodblock.github.common.parts.base;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public abstract class FCSharedFluidBus extends PartUpgradeable implements IGridTickable {
|
||||
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 9);
|
||||
private boolean lastRedstone;
|
||||
|
||||
public FCSharedFluidBus(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
public abstract IIcon getFaceIcon();
|
||||
|
||||
@Override
|
||||
public void upgradesChanged() {
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged() {
|
||||
this.updateState();
|
||||
if (this.lastRedstone != this.getHost().hasRedstone(this.getSide())) {
|
||||
this.lastRedstone = !this.lastRedstone;
|
||||
if (this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE) {
|
||||
this.doBusWork();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
try {
|
||||
if (!this.isSleeping()) {
|
||||
this.getProxy().getTick().wakeDevice(this.getProxy().getNode());
|
||||
} else {
|
||||
this.getProxy().getTick().sleepDevice(this.getProxy().getNode());
|
||||
}
|
||||
} catch (final GridAccessException ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
if (player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.FLUID_BUS_IO);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch) {
|
||||
bch.addBox(6, 6, 11, 10, 10, 13);
|
||||
bch.addBox(5, 5, 13, 11, 11, 14);
|
||||
bch.addBox(4, 4, 14, 12, 12, 16);
|
||||
}
|
||||
|
||||
protected TileEntity getConnectedTE() {
|
||||
TileEntity self = this.getHost().getTile();
|
||||
return this.getTileEntity(self, (new BlockPos(self)).getOffSet(this.getSide()));
|
||||
}
|
||||
|
||||
private TileEntity getTileEntity(final TileEntity self, final BlockPos pos) {
|
||||
final World w = self.getWorldObj();
|
||||
|
||||
if (w.getChunkProvider().chunkExists(pos.getX() >> 4, pos.getZ() >> 4)) {
|
||||
return w.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int calculateAmountToSend() {
|
||||
double amount = 1000D;
|
||||
switch (this.getInstalledUpgrades(Upgrades.SPEED)) {
|
||||
case 4:
|
||||
amount = amount * 1.5;
|
||||
case 3:
|
||||
amount = amount * 2;
|
||||
case 2:
|
||||
amount = amount * 4;
|
||||
case 1:
|
||||
amount = amount * 8;
|
||||
}
|
||||
switch (this.getInstalledUpgrades(Upgrades.SUPERSPEED)) {
|
||||
case 4:
|
||||
amount = amount * 8;
|
||||
case 3:
|
||||
amount = amount * 12;
|
||||
case 2:
|
||||
amount = amount * 16;
|
||||
case 1:
|
||||
amount = amount * 32;
|
||||
}
|
||||
return (int) Math.floor(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound extra) {
|
||||
super.readFromNBT(extra);
|
||||
this.config.readFromNBT(extra, "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound extra) {
|
||||
super.writeToNBT(extra);
|
||||
this.config.writeToNBT(extra, "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name) {
|
||||
if (name.equals("config")) {
|
||||
return this.config;
|
||||
}
|
||||
return super.getInventoryByName(name);
|
||||
}
|
||||
|
||||
public void setFluidInSlot(int id, IAEFluidStack fluid) {
|
||||
ItemStack tmp = ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack());
|
||||
this.config.setInventorySlotContents(id, tmp);
|
||||
}
|
||||
|
||||
protected StorageChannel getChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
protected abstract TickRateModulation doBusWork();
|
||||
|
||||
protected abstract boolean canDoBusWork();
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo() {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.glodblock.github.common.storage;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
FluidStack fs = Util.getFluidFromItem(is);
|
||||
if (fs == null) continue;
|
||||
IAEFluidStack iaeFluidStack = Util.FluidUtil.createAEFluidStack(fs);
|
||||
if (this.cellFluids.findPrecise(iaeFluidStack) == null) {
|
||||
iaeFluidStack.setStackSize((long) (Math.pow(2, 52) - 1));
|
||||
this.cellFluids.add(iaeFluidStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.glodblock.github.common.storage;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
|
||||
public class FluidCellHandler implements ICellHandler {
|
||||
|
||||
@Override
|
||||
public boolean isCell(final ItemStack is) {
|
||||
return FluidCellInventory.isCell(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public IMEInventoryHandler getCellInventory(final ItemStack is, final ISaveProvider container,
|
||||
final StorageChannel channel) {
|
||||
if (channel == StorageChannel.FLUIDS) {
|
||||
return FluidCellInventory.getCell(is, container);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Light() {
|
||||
return ExtraBlockTextures.BlockMEChestItems_Light.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Medium() {
|
||||
return ExtraBlockTextures.BlockMEChestItems_Medium.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Dark() {
|
||||
return ExtraBlockTextures.BlockMEChestItems_Dark.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChestGui(final EntityPlayer player, final IChestOrDrive chest, final ICellHandler cellHandler,
|
||||
@SuppressWarnings("rawtypes") final IMEInventoryHandler inv, final ItemStack is,
|
||||
final StorageChannel chan) {
|
||||
if (chan == StorageChannel.FLUIDS) {
|
||||
if (chest instanceof TileEntity te) {
|
||||
InventoryHandler
|
||||
.openGui(player, te.getWorldObj(), new BlockPos(te), chest.getUp(), GuiType.FLUID_TERMINAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell(final ItemStack is, @SuppressWarnings("rawtypes") final IMEInventory handler) {
|
||||
if (handler instanceof final FluidCellInventoryHandler ci) {
|
||||
return ci.getStatusForCell();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double cellIdleDrain(final ItemStack is, @SuppressWarnings("rawtypes") final IMEInventory handler) {
|
||||
final IFluidCellInventory inv = ((IFluidCellInventoryHandler) handler).getCellInv();
|
||||
return inv.getIdleDrain(is);
|
||||
}
|
||||
}
|
||||
@@ -1,505 +0,0 @@
|
||||
package com.glodblock.github.common.storage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.glodblock.github.common.item.ItemBaseInfinityStorageCell;
|
||||
import com.glodblock.github.common.item.ItemFluidVoidStorageCell;
|
||||
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInventory;
|
||||
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.exceptions.AppEngException;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
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.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
protected static final String FLUID_TYPE_TAG = "ft";
|
||||
protected static final String FLUID_COUNT_TAG = "fc";
|
||||
protected static final String FLUID_SLOT = "#";
|
||||
protected static final String FLUID_SLOT_COUNT = "@";
|
||||
protected IStorageFluidCell cellType;
|
||||
protected static String[] fluidSlots;
|
||||
protected static String[] fluidSlotCount;
|
||||
protected final ItemStack cellItem;
|
||||
private final ISaveProvider container;
|
||||
private final int MAX_TYPE = 63;
|
||||
protected long storedFluidCount;
|
||||
protected short storedFluids;
|
||||
protected IItemList<IAEFluidStack> cellFluids;
|
||||
protected final NBTTagCompound tagCompound;
|
||||
public static final int singleByteAmount = 256 * 8;
|
||||
private boolean cardVoidOverflow = false;
|
||||
private boolean cardDistribution = false;
|
||||
private byte restrictionTypes = 0;
|
||||
private long restrictionLong = 0;
|
||||
|
||||
public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
|
||||
if (o == null) {
|
||||
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
|
||||
}
|
||||
this.cellType = null;
|
||||
this.cellItem = o;
|
||||
final Item type = this.cellItem.getItem();
|
||||
if (type instanceof IStorageFluidCell) {
|
||||
this.cellType = (IStorageFluidCell) this.cellItem.getItem();
|
||||
}
|
||||
if (this.cellType == null) {
|
||||
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
|
||||
}
|
||||
if (!this.cellType.isStorageCell(this.cellItem)) {
|
||||
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
|
||||
}
|
||||
|
||||
if (fluidSlots == null) {
|
||||
fluidSlots = new String[MAX_TYPE];
|
||||
fluidSlotCount = new String[MAX_TYPE];
|
||||
|
||||
for (int x = 0; x < MAX_TYPE; x++) {
|
||||
fluidSlots[x] = FLUID_SLOT + x;
|
||||
fluidSlotCount[x] = FLUID_SLOT_COUNT + x;
|
||||
}
|
||||
}
|
||||
|
||||
final IInventory upgrades = this.getUpgradesInventory();
|
||||
Upgrades u;
|
||||
for (int x = 0; x < upgrades.getSizeInventory(); x++) {
|
||||
final ItemStack is = upgrades.getStackInSlot(x);
|
||||
if (is == null) continue;
|
||||
if (is.getItem() instanceof IUpgradeModule upgradeItem && (u = upgradeItem.getType(is)) != null) {
|
||||
switch (u) {
|
||||
case VOID_OVERFLOW -> cardVoidOverflow = true;
|
||||
case DISTRIBUTION -> cardDistribution = true;
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.container = container;
|
||||
this.tagCompound = Platform.openNbtData(o);
|
||||
this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG);
|
||||
this.storedFluidCount = this.tagCompound.getLong(FLUID_COUNT_TAG);
|
||||
this.restrictionTypes = this.tagCompound.getByte("cellRestrictionTypes");
|
||||
this.restrictionLong = this.tagCompound.getLong("cellRestrictionAmount");
|
||||
this.cellFluids = null;
|
||||
}
|
||||
|
||||
public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, final ISaveProvider container2) {
|
||||
try {
|
||||
if (o.getItem() instanceof ItemBaseInfinityStorageCell) {
|
||||
return new FluidCellInventoryHandler(new CreativeFluidCellInventory(o, container2));
|
||||
} else if (o.getItem() instanceof ProxyFluidStorageCell) {
|
||||
return new FluidCellInventoryHandler(new ProxyFluidCellInventory(o, container2));
|
||||
} else if (o.getItem() instanceof ItemFluidVoidStorageCell) {
|
||||
return new FluidCellInventoryHandler(new FluidVoidStorageCellInventory(o, container2));
|
||||
} else {
|
||||
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
|
||||
}
|
||||
} catch (final AppEngException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isCell(final ItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
final Item type = itemStack.getItem();
|
||||
if (type instanceof IStorageFluidCell) {
|
||||
return ((IStorageFluidCell) type).isStorageCell(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.cellItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain(ItemStack is) {
|
||||
return this.cellType.getIdleDrain(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory() {
|
||||
return this.cellType.getConfigInventory(this.cellItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType() {
|
||||
return this.cellType.getBytesPerType(this.cellItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHoldNewFluid() {
|
||||
final long bytesFree = this.getFreeBytes();
|
||||
return (bytesFree > this.getBytesPerType()
|
||||
|| (bytesFree == this.getBytesPerType() && this.getUnusedFluidCount() > 0))
|
||||
&& this.getRemainingFluidTypes() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalBytes() {
|
||||
return this.cellType.getBytes(this.cellItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeBytes() {
|
||||
return this.getTotalBytes() - this.getUsedBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUsedBytes() {
|
||||
final long bytesForFluidCount = (this.getStoredFluidCount() + this.getUnusedFluidCount()) / singleByteAmount;
|
||||
return this.getStoredFluidTypes() * this.getBytesPerType() + bytesForFluidCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalFluidTypes() {
|
||||
if (restrictionTypes > 0) return restrictionTypes;
|
||||
return this.cellType.getTotalTypes(this.cellItem);
|
||||
}
|
||||
|
||||
public long getMaxFluidTypes() {
|
||||
return this.cellType.getTotalTypes(this.cellItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoredFluidCount() {
|
||||
return this.storedFluidCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoredFluidTypes() {
|
||||
return this.storedFluids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingFluidTypes() {
|
||||
final long basedOnStorage = this.getFreeBytes() / Math.max(1, this.getBytesPerType());
|
||||
final long baseOnTotal = this.getTotalFluidTypes() - this.getStoredFluidTypes();
|
||||
return Math.min(basedOnStorage, baseOnTotal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingFluidCount() {
|
||||
if (restrictionLong > 0) {
|
||||
return Math.min(
|
||||
restrictionLong - this.getStoredFluidCount(),
|
||||
this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount());
|
||||
}
|
||||
final long remaining = this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount();
|
||||
return remaining > 0 ? remaining : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingFluidCountDist(IAEFluidStack l) {
|
||||
long remaining;
|
||||
long types = 0;
|
||||
long maxFluidTypes = this.getTotalFluidTypes();
|
||||
IInventory configInventory = this.getConfigInventory();
|
||||
for (int i = 0; i < configInventory.getSizeInventory(); i++) {
|
||||
// Check all partition slots to determine min distribution behaviour until max fluid types is reached
|
||||
if (types >= maxFluidTypes) break;
|
||||
if (configInventory.getStackInSlot(i) != null) {
|
||||
types++;
|
||||
}
|
||||
}
|
||||
if (types == 0) types = maxFluidTypes;
|
||||
if (l != null) {
|
||||
if (restrictionLong > 0) {
|
||||
remaining = Math.min((restrictionLong / types) - l.getStackSize(), getRemainingFluidCount());
|
||||
} else {
|
||||
remaining = (((getTotalBytes() / types) - getBytesPerType()) * singleByteAmount) - l.getStackSize();
|
||||
}
|
||||
} else {
|
||||
if (restrictionLong > 0) {
|
||||
remaining = Math.min(
|
||||
restrictionLong / types,
|
||||
((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount);
|
||||
} else {
|
||||
remaining = ((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount;
|
||||
}
|
||||
}
|
||||
return remaining > 0 ? remaining : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnusedFluidCount() {
|
||||
final int div = (int) (this.getStoredFluidCount() % singleByteAmount);
|
||||
if (div == 0) {
|
||||
return 0;
|
||||
}
|
||||
return singleByteAmount - div;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell() {
|
||||
if (this.getUsedBytes() == 0) {
|
||||
return 1;
|
||||
}
|
||||
if (this.canHoldNewFluid()) {
|
||||
return 2;
|
||||
}
|
||||
if (this.getRemainingFluidCount() > 0) {
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
protected void loadCellFluids() {
|
||||
if (this.cellFluids == null) {
|
||||
this.cellFluids = AEApi.instance().storage().createFluidList();
|
||||
}
|
||||
this.cellFluids.resetStatus(); // clears totals and stuff.
|
||||
final int types = (int) this.getStoredFluidTypes();
|
||||
for (int x = 0; x < types; x++) {
|
||||
final FluidStack t = FluidStack.loadFluidStackFromNBT(this.tagCompound.getCompoundTag(fluidSlots[x]));
|
||||
final AEFluidStack aet = AEFluidStack.create(t);
|
||||
if (aet != null) {
|
||||
aet.setStackSize(this.tagCompound.getLong(fluidSlotCount[x]));
|
||||
if (aet.getStackSize() > 0) {
|
||||
this.cellFluids.add(aet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected IItemList<IAEFluidStack> getCellFluids() {
|
||||
if (this.cellFluids == null) {
|
||||
this.loadCellFluids();
|
||||
}
|
||||
return this.cellFluids;
|
||||
}
|
||||
|
||||
private void updateFluidCount(final long delta) {
|
||||
this.storedFluidCount += delta;
|
||||
this.tagCompound.setLong(FLUID_COUNT_TAG, this.storedFluidCount);
|
||||
}
|
||||
|
||||
private void saveChanges() {
|
||||
long fluidCount = 0;
|
||||
int x = 0;
|
||||
|
||||
for (final IAEFluidStack v : this.cellFluids) {
|
||||
fluidCount += v.getStackSize();
|
||||
final NBTBase c = this.tagCompound.getTag(fluidSlots[x]);
|
||||
if (c instanceof NBTTagCompound) {
|
||||
v.writeToNBT((NBTTagCompound) c);
|
||||
} else {
|
||||
final NBTTagCompound g = new NBTTagCompound();
|
||||
v.writeToNBT(g);
|
||||
this.tagCompound.setTag(fluidSlots[x], g);
|
||||
}
|
||||
this.tagCompound.setLong(fluidSlotCount[x], v.getStackSize());
|
||||
x++;
|
||||
}
|
||||
|
||||
final short oldStoredFluids = this.storedFluids;
|
||||
this.storedFluids = (short) this.cellFluids.size();
|
||||
|
||||
if (this.cellFluids.isEmpty()) {
|
||||
this.tagCompound.removeTag(FLUID_TYPE_TAG);
|
||||
} else {
|
||||
this.tagCompound.setShort(FLUID_TYPE_TAG, this.storedFluids);
|
||||
}
|
||||
|
||||
this.storedFluidCount = fluidCount;
|
||||
|
||||
if (fluidCount == 0) {
|
||||
this.tagCompound.removeTag(FLUID_COUNT_TAG);
|
||||
} else {
|
||||
this.tagCompound.setLong(FLUID_COUNT_TAG, fluidCount);
|
||||
}
|
||||
|
||||
// clean any old crusty stuff...
|
||||
for (; x < oldStoredFluids && x < MAX_TYPE; x++) {
|
||||
this.tagCompound.removeTag(fluidSlots[x]);
|
||||
this.tagCompound.removeTag(fluidSlotCount[x]);
|
||||
}
|
||||
|
||||
if (this.container != null) {
|
||||
this.container.saveChanges(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActionSource src) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (input.getStackSize() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (this.cellType.isBlackListed(this.cellItem, input)) {
|
||||
return input;
|
||||
}
|
||||
final IAEFluidStack l = this.getCellFluids().findPrecise(input);
|
||||
|
||||
if (l != null) {
|
||||
long remainingFluidSlots;
|
||||
if (cardDistribution) {
|
||||
remainingFluidSlots = this.getRemainingFluidCountDist(l);
|
||||
} else {
|
||||
remainingFluidSlots = this.getRemainingFluidCount();
|
||||
}
|
||||
|
||||
if (remainingFluidSlots <= 0) {
|
||||
if (cardVoidOverflow) {
|
||||
return null;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
if (input.getStackSize() > remainingFluidSlots) {
|
||||
final IAEFluidStack r = input.copy();
|
||||
r.setStackSize(r.getStackSize() - remainingFluidSlots);
|
||||
if (mode == Actionable.MODULATE) {
|
||||
l.setStackSize(l.getStackSize() + remainingFluidSlots);
|
||||
this.updateFluidCount(remainingFluidSlots);
|
||||
this.saveChanges();
|
||||
}
|
||||
return r;
|
||||
} else {
|
||||
if (mode == Actionable.MODULATE) {
|
||||
l.setStackSize(l.getStackSize() + input.getStackSize());
|
||||
this.updateFluidCount(input.getStackSize());
|
||||
this.saveChanges();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.canHoldNewFluid()) // room for new type, and for at least one item!
|
||||
{
|
||||
long remainingFluidCount;
|
||||
if (cardDistribution) {
|
||||
remainingFluidCount = this.getRemainingFluidCountDist(null);
|
||||
} else {
|
||||
remainingFluidCount = Math.min(
|
||||
getRemainingFluidCount(),
|
||||
getFreeBytes() * singleByteAmount + getUnusedFluidCount()
|
||||
- (long) getBytesPerType() * singleByteAmount);
|
||||
}
|
||||
|
||||
if (remainingFluidCount > 0) {
|
||||
if (input.getStackSize() > remainingFluidCount) {
|
||||
final IAEFluidStack toReturn = input.copy();
|
||||
toReturn.decStackSize(remainingFluidCount);
|
||||
if (mode == Actionable.MODULATE) {
|
||||
IAEFluidStack toWrite = input.copy();
|
||||
toWrite.setStackSize(remainingFluidCount);
|
||||
this.cellFluids.add(toWrite);
|
||||
this.updateFluidCount(toWrite.getStackSize());
|
||||
this.saveChanges();
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
if (mode == Actionable.MODULATE) {
|
||||
this.updateFluidCount(input.getStackSize());
|
||||
this.cellFluids.add(input);
|
||||
this.saveChanges();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src) {
|
||||
if (request == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final long size = request.getStackSize();
|
||||
|
||||
IAEFluidStack results = null;
|
||||
|
||||
final IAEFluidStack l = this.getCellFluids().findPrecise(request);
|
||||
|
||||
if (l != null) {
|
||||
results = l.copy();
|
||||
|
||||
if (l.getStackSize() <= size) {
|
||||
results.setStackSize(l.getStackSize());
|
||||
|
||||
if (mode == Actionable.MODULATE) {
|
||||
this.updateFluidCount(-l.getStackSize());
|
||||
l.setStackSize(0);
|
||||
this.saveChanges();
|
||||
}
|
||||
} else {
|
||||
results.setStackSize(size);
|
||||
|
||||
if (mode == Actionable.MODULATE) {
|
||||
l.setStackSize(l.getStackSize() - size);
|
||||
this.updateFluidCount(-size);
|
||||
this.saveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> getAvailableItems(IItemList<IAEFluidStack> out, int iteration) {
|
||||
for (final IAEFluidStack i : this.getCellFluids()) {
|
||||
out.add(i);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack getAvailableItem(@Nonnull IAEFluidStack request, int iteration) {
|
||||
return this.getCellFluids().findPrecise(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<IAEFluidStack> getContents() {
|
||||
List<IAEFluidStack> ret = new ArrayList<>();
|
||||
for (IAEFluidStack fluid : this.getCellFluids()) {
|
||||
ret.add(fluid);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory() {
|
||||
return this.cellType.getUpgradesInventory(this.cellItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
public List<Object> getRestriction() {
|
||||
return Arrays.asList(restrictionLong, restrictionTypes);
|
||||
}
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
package com.glodblock.github.common.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.storage.ICellCacheRegistry;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.me.storage.MEPassThrough;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.prioitylist.PrecisePriorityList;
|
||||
|
||||
public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
|
||||
implements IFluidCellInventoryHandler, ICellCacheRegistry {
|
||||
|
||||
protected FluidCellInventoryHandler(final IMEInventory<IAEFluidStack> c) {
|
||||
super(c, StorageChannel.FLUIDS);
|
||||
|
||||
final IFluidCellInventory ci = this.getCellInv();
|
||||
|
||||
if (ci != null) {
|
||||
final IInventory config = ci.getConfigInventory();
|
||||
|
||||
final IItemList<IAEFluidStack> priorityList = AEApi.instance().storage().createFluidList();
|
||||
for (int x = 0; x < config.getSizeInventory(); x++) {
|
||||
final ItemStack is = config.getStackInSlot(x);
|
||||
final FluidStack fluid = Util.getFluidFromItem(is);
|
||||
if (fluid != null) {
|
||||
AEFluidStack stack = AEFluidStack.create(fluid);
|
||||
stack.setStackSize(1);
|
||||
priorityList.add(stack);
|
||||
|
||||
// convert partition on cells in network
|
||||
if (!(is.getItem() instanceof ItemFluidPacket)) {
|
||||
config.setInventorySlotContents(x, ItemFluidPacket.newDisplayStack(fluid));
|
||||
config.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!priorityList.isEmpty()) {
|
||||
this.setPartitionList(new PrecisePriorityList<>(priorityList));
|
||||
}
|
||||
|
||||
final IInventory upgrades = ci.getUpgradesInventory();
|
||||
boolean hasSticky = false;
|
||||
|
||||
for (int x = 0; x < upgrades.getSizeInventory(); x++) {
|
||||
final ItemStack is = upgrades.getStackInSlot(x);
|
||||
if (is != null && is.getItem() instanceof IUpgradeModule) {
|
||||
final Upgrades u = ((IUpgradeModule) is.getItem()).getType(is);
|
||||
if (u == Upgrades.STICKY) {
|
||||
hasSticky = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSticky) {
|
||||
setSticky(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidCellInventory getCellInv() {
|
||||
Object o = this.getInternal();
|
||||
if (o instanceof MEPassThrough<?>pt) {
|
||||
o = pt.getInternal();
|
||||
}
|
||||
return (IFluidCellInventory) (o instanceof IFluidCellInventory ? o : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Iterable<IAEFluidStack> getPartitionInv() {
|
||||
return getPartitionList().getItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPreformatted() {
|
||||
return !getPartitionList().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public IncludeExclude getIncludeExcludeMode() {
|
||||
return getWhitelist();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IncludeExclude getWhitelist() {
|
||||
return IncludeExclude.WHITELIST;
|
||||
}
|
||||
|
||||
public int getStatusForCell() {
|
||||
int val = this.getCellInv().getStatusForCell();
|
||||
|
||||
if ((val == 1 || val == 2) && this.isPreformatted()) {
|
||||
val = 3;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGetInv() {
|
||||
IFluidCellInventory cellInv = this.getCellInv();
|
||||
return !(cellInv instanceof CreativeFluidCellInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalBytes() {
|
||||
return this.getCellInv().getTotalBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeBytes() {
|
||||
return this.getCellInv().getFreeBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUsedBytes() {
|
||||
return this.getCellInv().getUsedBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalTypes() {
|
||||
return this.getCellInv().getTotalFluidTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeTypes() {
|
||||
return this.getCellInv().getRemainingFluidTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUsedTypes() {
|
||||
return this.getCellInv().getStoredFluidTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellStatus() {
|
||||
return this.getStatusForCell();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TYPE getCellType() {
|
||||
return TYPE.FLUID;
|
||||
}
|
||||
|
||||
public List<Object> getRestricted() {
|
||||
IFluidCellInventory cellInventory = this.getCellInv();
|
||||
if (cellInventory instanceof FluidCellInventory ci) {
|
||||
return ci.getRestriction();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package com.glodblock.github.common.storage;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
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 appeng.api.storage.data.IItemList;
|
||||
|
||||
public class FluidVoidStorageCellInventory extends FluidCellInventory {
|
||||
|
||||
public FluidVoidStorageCellInventory(ItemStack o, ISaveProvider container) throws AppEngException {
|
||||
super(o, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHoldNewFluid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalBytes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeBytes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUsedBytes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalFluidTypes() {
|
||||
return 63;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoredFluidCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoredFluidTypes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingFluidTypes() {
|
||||
return 63;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingFluidCount() {
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnusedFluidCount() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadCellFluids() {}
|
||||
|
||||
@Override
|
||||
protected IItemList<IAEFluidStack> getCellFluids() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> getAvailableItems(IItemList<IAEFluidStack> out, int iteration) {
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack getAvailableItem(@Nonnull IAEFluidStack request, int iteration) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<IAEFluidStack> getContents() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package com.glodblock.github.common.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
|
||||
public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
|
||||
|
||||
/**
|
||||
* @return the item stack of this storage cell.
|
||||
*/
|
||||
ItemStack getItemStack();
|
||||
|
||||
/**
|
||||
* @return idle cost for this Storage Cell
|
||||
*/
|
||||
double getIdleDrain(ItemStack is);
|
||||
|
||||
/**
|
||||
* @return access configured list
|
||||
*/
|
||||
IInventory getConfigInventory();
|
||||
|
||||
/**
|
||||
* @return How many bytes are used for each type?
|
||||
*/
|
||||
int getBytesPerType();
|
||||
|
||||
/**
|
||||
* @return true if a new fluid type can be added.
|
||||
*/
|
||||
boolean canHoldNewFluid();
|
||||
|
||||
/**
|
||||
* @return total byte storage.
|
||||
*/
|
||||
long getTotalBytes();
|
||||
|
||||
/**
|
||||
* @return how many bytes are free.
|
||||
*/
|
||||
long getFreeBytes();
|
||||
|
||||
/**
|
||||
* @return how many bytes are in use.
|
||||
*/
|
||||
long getUsedBytes();
|
||||
|
||||
/**
|
||||
* @return how many fluids are stored.
|
||||
*/
|
||||
long getStoredFluidCount();
|
||||
|
||||
/**
|
||||
* @return how many more fluids can be stored.
|
||||
*/
|
||||
long getRemainingFluidCount();
|
||||
|
||||
/**
|
||||
* @return how many more fluids can be stored with Distribution card.
|
||||
*/
|
||||
long getRemainingFluidCountDist(IAEFluidStack l);
|
||||
|
||||
/**
|
||||
* @return how many fluid types remain.
|
||||
*/
|
||||
long getRemainingFluidTypes();
|
||||
|
||||
/**
|
||||
* @return how many fluids can be added without consuming another byte.
|
||||
*/
|
||||
int getUnusedFluidCount();
|
||||
|
||||
/**
|
||||
* @return the status number for this drive.
|
||||
*/
|
||||
int getStatusForCell();
|
||||
|
||||
/**
|
||||
* @return how many items types are currently stored.
|
||||
*/
|
||||
long getStoredFluidTypes();
|
||||
|
||||
/**
|
||||
* @return max number of types.
|
||||
*/
|
||||
long getTotalFluidTypes();
|
||||
|
||||
@NotNull
|
||||
List<IAEFluidStack> getContents();
|
||||
|
||||
/**
|
||||
* @return access installed upgrades.
|
||||
*/
|
||||
IInventory getUpgradesInventory();
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.glodblock.github.common.storage;
|
||||
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
|
||||
public interface IFluidCellInventoryHandler {
|
||||
|
||||
IFluidCellInventory getCellInv();
|
||||
|
||||
Iterable<IAEFluidStack> getPartitionInv();
|
||||
|
||||
boolean isPreformatted();
|
||||
|
||||
/** use {@link IFluidCellInventoryHandler#getWhitelist} instead */
|
||||
@Deprecated
|
||||
IncludeExclude getIncludeExcludeMode();
|
||||
|
||||
IncludeExclude getWhitelist();
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.glodblock.github.common.storage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
|
||||
public interface IStorageFluidCell extends ICellWorkbenchItem {
|
||||
|
||||
long getBytes(ItemStack cellItem);
|
||||
|
||||
int getBytesPerType(ItemStack cellItem);
|
||||
|
||||
boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition);
|
||||
|
||||
boolean storableInStorageCell();
|
||||
|
||||
boolean isStorageCell(ItemStack i);
|
||||
|
||||
double getIdleDrain(ItemStack is);
|
||||
|
||||
int getTotalTypes(ItemStack cellItem);
|
||||
}
|
||||
@@ -45,6 +45,7 @@ import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
@@ -59,7 +60,7 @@ import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class TileFluidAutoFiller extends AENetworkInvTile
|
||||
implements ICraftingProvider, IMEMonitorHandlerReceiver<IAEFluidStack>, IGridTickable {
|
||||
implements ICraftingProvider, IMEMonitorHandlerReceiver<IAEStack<?>>, IGridTickable {
|
||||
|
||||
private final AppEngInternalInventory inventory = new AppEngInternalInventory(this, 1);
|
||||
private final BaseActionSource source = new MachineSource(this);
|
||||
@@ -214,14 +215,13 @@ public class TileFluidAutoFiller extends AENetworkInvTile
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change,
|
||||
BaseActionSource source) {
|
||||
public void postChange(IBaseMonitor<IAEStack<?>> monitor, Iterable<IAEStack<?>> change, BaseActionSource source) {
|
||||
if (this.getProxy().isActive() && this.getStorageGrid() != null) {
|
||||
boolean hasChanged = false;
|
||||
for (IAEFluidStack tmp : change) {
|
||||
if (this.fluids.findPrecise(tmp) == null) {
|
||||
for (IAEStack<?> tmp : change) {
|
||||
if (this.fluids.findPrecise((IAEFluidStack) tmp) == null) {
|
||||
hasChanged = true;
|
||||
this.fluids.add(tmp);
|
||||
this.fluids.add((IAEFluidStack) tmp);
|
||||
}
|
||||
}
|
||||
if (hasChanged) postEvent();
|
||||
|
||||
@@ -1,258 +1,10 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.glodblock.github.api.FluidCraftAPI;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.events.MENetworkStorageEvent;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.ICellContainer;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
|
||||
public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost, ICellContainer {
|
||||
|
||||
private final BaseActionSource ownActionSource = new MachineSource(this);
|
||||
private final FluidDiscretizingInventory fluidDropInv = new FluidDiscretizingInventory();
|
||||
private boolean prevActiveState = false;
|
||||
public class TileFluidDiscretizer extends AENetworkTile {
|
||||
|
||||
public TileFluidDiscretizer() {
|
||||
super();
|
||||
getProxy().setIdlePowerUsage(3D);
|
||||
getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public List<IMEInventoryHandler> getCellArray(StorageChannel channel) {
|
||||
if (channel == StorageChannel.ITEMS && getProxy().isActive()) {
|
||||
return Collections.singletonList(fluidDropInv.invHandler);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged() {
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid != null) {
|
||||
fluidGrid.addListener(fluidDropInv, fluidGrid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges(@SuppressWarnings("rawtypes") IMEInventory cellInventory) {
|
||||
markDirty();
|
||||
}
|
||||
|
||||
private IMEMonitor<IAEFluidStack> getFluidGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnergyGrid getEnergyGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().getCache(IEnergyGrid.class);
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
boolean isActive = getProxy().isActive();
|
||||
if (isActive != prevActiveState) {
|
||||
prevActiveState = isActive;
|
||||
try {
|
||||
getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate());
|
||||
} catch (GridAccessException e) {
|
||||
// NO-OP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onPowerUpdate(MENetworkPowerStatusChange event) {
|
||||
updateState();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onChannelUpdate(MENetworkChannelsChanged event) {
|
||||
updateState();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onStorageUpdate(MENetworkStorageEvent event) {
|
||||
updateState();
|
||||
}
|
||||
|
||||
private class FluidDiscretizingInventory
|
||||
implements IMEInventory<IAEItemStack>, IMEMonitorHandlerReceiver<IAEFluidStack> {
|
||||
|
||||
private final MEInventoryHandler<IAEItemStack> invHandler = new MEInventoryHandler<>(this, getChannel());
|
||||
private IItemList<IAEItemStack> itemCache = null;
|
||||
|
||||
FluidDiscretizingInventory() {
|
||||
invHandler.setPriority(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack request, Actionable type, BaseActionSource src) {
|
||||
IAEFluidStack fluidStack = ItemFluidDrop.getAeFluidStack(request);
|
||||
if (fluidStack == null) {
|
||||
return request;
|
||||
}
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid == null) {
|
||||
return request;
|
||||
}
|
||||
IEnergyGrid energyGrid = getEnergyGrid();
|
||||
if (energyGrid == null) {
|
||||
return request;
|
||||
}
|
||||
if (type == Actionable.SIMULATE) {
|
||||
return ItemFluidDrop.newAeStack(fluidGrid.injectItems(fluidStack.copy(), Actionable.SIMULATE, src));
|
||||
} else {
|
||||
return ItemFluidDrop.newAeStack(fluidGrid.injectItems(fluidStack.copy(), Actionable.MODULATE, src));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src) {
|
||||
IAEFluidStack fluidStack = ItemFluidDrop.getAeFluidStack(request);
|
||||
if (fluidStack == null) {
|
||||
return null;
|
||||
}
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid == null) {
|
||||
return null;
|
||||
}
|
||||
IEnergyGrid energyGrid = getEnergyGrid();
|
||||
if (energyGrid == null) {
|
||||
return null;
|
||||
}
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return ItemFluidDrop.newAeStack(fluidGrid.extractItems(fluidStack.copy(), Actionable.SIMULATE, src));
|
||||
} else {
|
||||
return ItemFluidDrop.newAeStack(fluidGrid.extractItems(fluidStack.copy(), Actionable.MODULATE, src));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out, int iteration) {
|
||||
if (itemCache == null) {
|
||||
itemCache = AEApi.instance().storage().createItemList();
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid != null) {
|
||||
for (IAEFluidStack fluid : fluidGrid.getStorageList()) {
|
||||
IAEItemStack stack = ItemFluidDrop.newAeStack(fluid);
|
||||
if (stack != null
|
||||
&& !FluidCraftAPI.instance().isBlacklistedInDisplay(fluid.getFluid().getClass())) {
|
||||
itemCache.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (IAEItemStack stack : itemCache) {
|
||||
out.addStorage(stack);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack getAvailableItem(@Nonnull IAEItemStack request, int iteration) {
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid == null) {
|
||||
return null;
|
||||
}
|
||||
IAEFluidStack fluidRequest = ItemFluidDrop.getAeFluidStack(request);
|
||||
if (fluidRequest == null) {
|
||||
return null;
|
||||
}
|
||||
IAEFluidStack availableFluid = fluidGrid.getAvailableItem(fluidRequest, iteration);
|
||||
if (availableFluid == null || availableFluid.getFluid() == null
|
||||
|| FluidCraftAPI.instance().isBlacklistedInDisplay(availableFluid.getFluid().getClass())) {
|
||||
return null;
|
||||
}
|
||||
return ItemFluidDrop.newAeStack(availableFluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel() {
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object verificationToken) {
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
return fluidGrid != null && fluidGrid == verificationToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change,
|
||||
BaseActionSource actionSource) {
|
||||
itemCache = null;
|
||||
try {
|
||||
List<IAEItemStack> mappedChanges = new ArrayList<>();
|
||||
for (IAEFluidStack fluidStack : change) {
|
||||
IAEItemStack itemStack = ItemFluidDrop.newAeStack(fluidStack);
|
||||
if (itemStack != null
|
||||
&& !FluidCraftAPI.instance().isBlacklistedInDisplay(fluidStack.getFluid().getClass())) {
|
||||
mappedChanges.add(itemStack);
|
||||
}
|
||||
}
|
||||
getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class)
|
||||
.postAlterationOfStoredItems(getChannel(), mappedChanges, ownActionSource);
|
||||
} catch (GridAccessException e) {
|
||||
// NO-OP
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate() {
|
||||
// NO-OP
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
@@ -13,6 +14,7 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import com.glodblock.github.client.FluidInterfaceButtons;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.AEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
@@ -32,17 +34,23 @@ import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.helpers.ICustomButtonDataObject;
|
||||
import appeng.helpers.ICustomButtonProvider;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileFluidInterface extends TileInterface implements IDualHost {
|
||||
public class TileFluidInterface extends TileInterface implements IDualHost, ICustomButtonProvider {
|
||||
|
||||
private final IConfigManager dualityConfigManager = getInterfaceDuality().getConfigManager();
|
||||
|
||||
private ICustomButtonDataObject customButtonDataObject;
|
||||
|
||||
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) {
|
||||
|
||||
@Override
|
||||
@@ -59,6 +67,7 @@ public class TileFluidInterface extends TileInterface implements IDualHost {
|
||||
|
||||
public TileFluidInterface() {
|
||||
super.getInterfaceDuality().getConfigManager().registerSetting(Settings.SIDELESS_MODE, SidelessMode.SIDELESS);
|
||||
this.customButtonDataObject = new FluidInterfaceButtons(true);
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
@@ -226,4 +235,39 @@ public class TileFluidInterface extends TileInterface implements IDualHost {
|
||||
this.fluidDuality.addDrops(drops);
|
||||
super.getDrops(w, x, y, z, drops);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPrimaryGuiIcon() {
|
||||
return ItemAndBlockHolder.INTERFACE.stack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomButtonData() {}
|
||||
|
||||
@Override
|
||||
public void readCustomButtonData() {}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void initCustomButtons(int guiLeft, int guiTop, int xSize, int ySize, int xOffset, int yOffset,
|
||||
List<GuiButton> buttonList) {
|
||||
if (customButtonDataObject != null)
|
||||
customButtonDataObject.initCustomButtons(guiLeft, guiTop, xSize, ySize, xOffset, yOffset, buttonList);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean actionPerformedCustomButtons(final GuiButton btn) {
|
||||
return customButtonDataObject != null && customButtonDataObject.actionPerformedCustomButtons(btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICustomButtonDataObject getDataObject() {
|
||||
return customButtonDataObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataObject(ICustomButtonDataObject dataObject) {
|
||||
customButtonDataObject = dataObject;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -17,20 +15,18 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.glodblock.github.api.registries.ILevelViewable;
|
||||
import com.glodblock.github.api.registries.LevelItemInfo;
|
||||
import com.glodblock.github.api.registries.LevelState;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.crossmod.thaumcraft.ThaumicEnergisticsCrafting;
|
||||
import com.glodblock.github.inventory.AeItemStackHandler;
|
||||
import com.glodblock.github.inventory.AeStackInventory;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.features.ILevelViewable;
|
||||
import appeng.api.features.LevelItemInfo;
|
||||
import appeng.api.features.LevelState;
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGrid;
|
||||
@@ -49,8 +45,10 @@ import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.core.AELog;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -58,7 +56,9 @@ import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -76,10 +76,9 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
public static final String NBT_LINK = "link";
|
||||
|
||||
public final RequestInfo[] requests = new RequestInfo[REQ_COUNT];
|
||||
private final LevelMaintainerInventory inventory = new LevelMaintainerInventory(requests, this);
|
||||
private final LevelMaintainerInventory inventory = new LevelMaintainerInventory(requests);
|
||||
private int firstRequest = 0;
|
||||
private final BaseActionSource source;
|
||||
private final IInventory inv = new AeItemStackHandler(inventory);
|
||||
private boolean isPowered = false;
|
||||
|
||||
public TileLevelMaintainer() {
|
||||
@@ -88,7 +87,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
source = new MachineSource(this);
|
||||
}
|
||||
|
||||
public AeStackInventory<IAEItemStack> getRequestSlots() {
|
||||
public IAEStackInventory getAEStackInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@@ -181,7 +180,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
// If there is none, find the next request we can begin calculating.
|
||||
ICraftingJob jobToSubmit = null;
|
||||
int jobToSubmitIdx = -1;
|
||||
IAEItemStack itemToBegin = null;
|
||||
IAEStack<?> itemToBegin = null;
|
||||
int itemToBeginIdx = -1;
|
||||
|
||||
for (int j = 0; j < REQ_COUNT; ++j) {
|
||||
@@ -197,29 +196,27 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
continue;
|
||||
}
|
||||
|
||||
IAEItemStack craftItem = requests[i].itemStack.copy();
|
||||
IAEStack<?> aeItem = null;
|
||||
|
||||
IAEStack<?> craftItem = requests[i].stack.copy();
|
||||
craftItem.setStackSize(batchSize);
|
||||
|
||||
if (ModAndClassUtil.ThE) {
|
||||
if (ThaumicEnergisticsCrafting.isAspectStack(craftItem.getItemStack())) {
|
||||
craftItem = ThaumicEnergisticsCrafting.convertAspectStack(craftItem);
|
||||
if (craftItem instanceof IAEItemStack ais) {
|
||||
if (ModAndClassUtil.ThE && ThaumicEnergisticsCrafting.isAspectStack(ais.getItemStack())) {
|
||||
aeItem = ThaumicEnergisticsCrafting.convertAspectStack(ais);
|
||||
} else {
|
||||
aeItem = invItems.findPrecise(ais);
|
||||
}
|
||||
} else if (craftItem instanceof IAEFluidStack afs) {
|
||||
aeItem = invFluid.findPrecise(afs);
|
||||
}
|
||||
|
||||
IAEItemStack aeItem = invItems.findPrecise(craftItem);
|
||||
|
||||
long stackSize;
|
||||
|
||||
if (craftItem.getItem() instanceof ItemFluidDrop) {
|
||||
IAEFluidStack ifs = invFluid.findPrecise(ItemFluidDrop.getAeFluidStack(craftItem));
|
||||
stackSize = ifs == null ? 0 : ifs.getStackSize();
|
||||
} else {
|
||||
stackSize = aeItem == null ? 0 : aeItem.getStackSize();
|
||||
}
|
||||
long stackSize = aeItem == null ? 0 : aeItem.getStackSize();
|
||||
|
||||
if (ModAndClassUtil.ThE) {
|
||||
if (aeItem != null && ThaumicEnergisticsCrafting.isAspectStack(aeItem.getItemStack())) {
|
||||
stackSize = ThaumicEnergisticsCrafting.getEssentiaAmount(aeItem, grid);
|
||||
if (aeItem instanceof IAEItemStack ais
|
||||
&& ThaumicEnergisticsCrafting.isAspectStack(ais.getItemStack())) {
|
||||
stackSize = ThaumicEnergisticsCrafting.getEssentiaAmount(ais, grid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,11 +240,11 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
continue;
|
||||
}
|
||||
|
||||
if (craftingGrid.canEmitFor(craftItem)) {
|
||||
if (craftingGrid.canEmitFor(aeItem)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (craftingGrid.isRequesting(craftItem)) {
|
||||
if (craftingGrid.isRequesting(aeItem)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -338,22 +335,12 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
return isPowered;
|
||||
}
|
||||
|
||||
public IInventory getInventory() {
|
||||
return inv;
|
||||
}
|
||||
|
||||
public IInventory getInventoryByName(String name) {
|
||||
if (Objects.equals(name, "config")) return new AeItemStackHandler(this.inventory);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LevelItemInfo[] getLevelItemInfoList() {
|
||||
return Arrays.stream(this.requests).map(request -> {
|
||||
if (request == null) return null;
|
||||
return new LevelItemInfo(
|
||||
request.itemStack.getItemStack(),
|
||||
request.getAEStack(),
|
||||
request.getQuantity(),
|
||||
request.getBatchSize(),
|
||||
request.getState());
|
||||
@@ -387,11 +374,10 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
public void updateStack(int idx, @Nullable ItemStack stack) {
|
||||
public void updateStack(int idx, @Nullable IAEStack<?> stack) {
|
||||
if (stack == null) {
|
||||
requests[idx] = null;
|
||||
} else {
|
||||
stack = this.removeRecursion(stack);
|
||||
requests[idx] = new RequestInfo(stack, this);
|
||||
}
|
||||
this.saveChanges();
|
||||
@@ -481,7 +467,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
ItemStack craftStack = ItemStack.loadItemStackFromNBT(itemTag.getCompoundTag("Stack"));
|
||||
craftStack = removeRecursion(craftStack);
|
||||
if (craftStack == null) continue;
|
||||
requests[i] = new RequestInfo(craftStack, this);
|
||||
requests[i] = new RequestInfo(Platform.convertStack(AEItemStack.create(craftStack)), this);
|
||||
if (itemTag.hasKey("Enable")) {
|
||||
requests[i].enable = itemTag.getBoolean("Enable");
|
||||
}
|
||||
@@ -522,7 +508,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
|
||||
for (int i = 0; i < REQ_COUNT; i++) {
|
||||
if (stacks[i] == null) continue;
|
||||
this.requests[i] = new RequestInfo(stacks[i], this);
|
||||
this.requests[i] = new RequestInfo(Platform.convertStack(AEItemStack.create(stacks[i])), this);
|
||||
this.requests[i].batchSize = batches[i];
|
||||
this.requests[i].quantity = quantyties[i];
|
||||
}
|
||||
@@ -631,7 +617,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
public static class RequestInfo {
|
||||
|
||||
private final TileLevelMaintainer tile;
|
||||
private @NotNull IAEItemStack itemStack;
|
||||
private @NotNull IAEStack<?> stack;
|
||||
private long quantity;
|
||||
private long batchSize;
|
||||
private boolean enable;
|
||||
@@ -641,9 +627,9 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
@Nullable
|
||||
private ICraftingLink link;
|
||||
|
||||
public RequestInfo(@NotNull ItemStack stack, TileLevelMaintainer tile) {
|
||||
public RequestInfo(@NotNull IAEStack<?> stack, TileLevelMaintainer tile) {
|
||||
this.tile = tile;
|
||||
itemStack = AEItemStack.create(stack);
|
||||
this.stack = stack.copy();
|
||||
quantity = 0;
|
||||
batchSize = 0;
|
||||
enable = false;
|
||||
@@ -654,8 +640,8 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
|
||||
public RequestInfo(NBTTagCompound tag, TileLevelMaintainer tile) throws IllegalArgumentException {
|
||||
this.tile = tile;
|
||||
itemStack = AEItemStack.loadItemStackFromNBT(tag.getCompoundTag(NBT_STACK));
|
||||
if (itemStack == null) {
|
||||
stack = Platform.readStackNBT(tag.getCompoundTag(NBT_STACK), true);
|
||||
if (stack == null) {
|
||||
throw new IllegalArgumentException("ItemStack cannot be null!");
|
||||
}
|
||||
quantity = tag.getLong(NBT_QUANTITY);
|
||||
@@ -673,7 +659,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
|
||||
public void loadFromNBT(NBTTagCompound tag) {
|
||||
itemStack = AEItemStack.loadItemStackFromNBT(tag.getCompoundTag(NBT_STACK));
|
||||
stack = Platform.readStackNBT(tag.getCompoundTag(NBT_STACK), true);
|
||||
quantity = tag.getLong(NBT_QUANTITY);
|
||||
batchSize = tag.getLong(NBT_BATCH);
|
||||
enable = tag.getBoolean(NBT_ENABLE);
|
||||
@@ -690,7 +676,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
public NBTTagCompound writeToNBT(boolean includeLink) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
NBTTagCompound stackTag = new NBTTagCompound();
|
||||
itemStack.writeToNBT(stackTag);
|
||||
Platform.writeStackNBT(stack, stackTag, true);
|
||||
tag.setTag(NBT_STACK, stackTag);
|
||||
tag.setLong(NBT_QUANTITY, quantity);
|
||||
tag.setLong(NBT_BATCH, batchSize);
|
||||
@@ -704,8 +690,9 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
return tag;
|
||||
}
|
||||
|
||||
public IAEItemStack getAEItemStack() {
|
||||
return this.itemStack;
|
||||
@NotNull
|
||||
public IAEStack<?> getAEStack() {
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
public long getQuantity() {
|
||||
@@ -725,43 +712,34 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
}
|
||||
|
||||
private static class LevelMaintainerInventory implements AeStackInventory<IAEItemStack> {
|
||||
private class LevelMaintainerInventory extends IAEStackInventory {
|
||||
|
||||
private final RequestInfo[] requests;
|
||||
private final TileLevelMaintainer tile;
|
||||
|
||||
private LevelMaintainerInventory(RequestInfo[] requests, TileLevelMaintainer tile) {
|
||||
this.requests = requests;
|
||||
this.tile = tile;
|
||||
public LevelMaintainerInventory(RequestInfo[] requests) {
|
||||
super(null, requests.length, StorageName.NONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Iterator<IAEItemStack> iterator() {
|
||||
return Arrays.stream(requests).map(info -> info != null ? info.itemStack : null).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotCount() {
|
||||
public int getSizeInventory() {
|
||||
return requests.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IAEItemStack getStack(int slot) {
|
||||
return requests[slot] != null ? requests[slot].itemStack : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(int slot, @Nullable IAEItemStack stack) {
|
||||
if (stack == null) {
|
||||
this.tile.updateStack(slot, null);
|
||||
} else {
|
||||
this.tile.updateStack(slot, stack.getItemStack());
|
||||
public IAEStack<?> getAEStackInSlot(int n) {
|
||||
if (requests[n] != null) {
|
||||
return requests[n].stack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<IAEItemStack> stream() {
|
||||
return Arrays.stream(requests).map(info -> info != null ? info.itemStack : null);
|
||||
public void putAEStackInSlot(int slot, IAEStack<?> aes) {
|
||||
updateStack(slot, aes);
|
||||
super.putAEStackInSlot(slot, aes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,10 +34,13 @@ import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AELog;
|
||||
import appeng.items.storage.ItemBasicStorageCell;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -52,7 +55,7 @@ import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileSuperStockReplenisher extends AENetworkInvTile
|
||||
implements IAEFluidInventory, IFluidHandler, IPowerChannelState, IGridTickable {
|
||||
implements IAEFluidInventory, IFluidHandler, IPowerChannelState, IGridTickable, ITerminalHost {
|
||||
|
||||
private final AppEngInternalInventory cell = new AppEngInternalInventory(this, 1);
|
||||
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 63);
|
||||
@@ -461,4 +464,19 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) {
|
||||
return doWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user