mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
cells
This commit is contained in:
1 parent
24d30ef078
commit
ebd42852ff
38 files changed
+211
-2351
No files matched your search
@@ -3,7 +3,6 @@ package com.glodblock.github;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.storage.FluidCellHandler;
|
||||
import com.glodblock.github.crossmod.extracells.EC2Replacer;
|
||||
import com.glodblock.github.crossmod.opencomputers.OCDriverInit;
|
||||
import com.glodblock.github.crossmod.waila.WailaInit;
|
||||
@@ -67,7 +66,6 @@ public class FluidCraft {
|
||||
public static void postInit(FMLPostInitializationEvent event) {
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(FluidCraft.INSTANCE, new InventoryHandler());
|
||||
|
||||
AEApi.instance().registries().cell().addCellHandler(new FluidCellHandler());
|
||||
ItemAndBlockHolder.loadSetting();
|
||||
|
||||
if (!Config.removeRecipe) {
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
package com.glodblock.github.client.me;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
|
||||
import com.glodblock.github.util.FluidSorters;
|
||||
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.widgets.IScrollSource;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
public class EssentiaRepo extends FluidRepo {
|
||||
|
||||
public EssentiaRepo(final IScrollSource src, final ISortSource sortSrc) {
|
||||
super(src, sortSrc);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void updateView() {
|
||||
if (this.paused) {
|
||||
// Update existing view with new data
|
||||
for (int i = 0; i < this.view.size(); i++) {}
|
||||
|
||||
// Append newly added item stacks to the end of the view
|
||||
} else {
|
||||
this.view.clear();
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
}
|
||||
|
||||
// Do not sort if paused
|
||||
if (!this.paused) {
|
||||
final Enum<?> SortBy = this.sortSrc.getSortBy();
|
||||
final Enum<?> SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
FluidSorters.init();
|
||||
|
||||
}
|
||||
|
||||
// Update the display
|
||||
this.dsp.clear();
|
||||
this.dsp.ensureCapacity(this.list.size());
|
||||
}
|
||||
|
||||
private void addEntriesToView(Iterable<IAEItemStack> entries) {
|
||||
final Enum<?> viewMode = this.sortSrc.getSortDisplay();
|
||||
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
||||
if (searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH) {
|
||||
this.updateNEI(this.searchString);
|
||||
}
|
||||
|
||||
String innerSearch = this.searchString;
|
||||
|
||||
if (innerSearch.startsWith("@")) {
|
||||
innerSearch = innerSearch.substring(1);
|
||||
}
|
||||
|
||||
Pattern m;
|
||||
try {
|
||||
m = Pattern.compile(innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable ignore) {
|
||||
try {
|
||||
m = Pattern.compile(Pattern.quote(innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable __) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (IAEItemStack is : entries) {
|
||||
if (!AspectUtil.isEssentiaGas(ItemFluidDrop.getAeFluidStack(is))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE) {
|
||||
is = is.copy();
|
||||
is.setStackSize(0);
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Fluid fluid = ItemFluidDrop.getAeFluidStack(is).getFluid();
|
||||
if (!AspectUtil.isEssentiaGas(fluid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m.matcher(fluid.getLocalizedName().toLowerCase()).find()) {
|
||||
this.view.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,289 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2. Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. Applied
|
||||
* Energistics 2 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
|
||||
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version. Applied Energistics 2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
|
||||
* Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package com.glodblock.github.client.me;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import com.glodblock.github.api.FluidCraftAPI;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.util.FluidSorters;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IDisplayRepo;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.widgets.IScrollSource;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.util.prioitylist.IPartitionList;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class FluidRepo implements IDisplayRepo {
|
||||
|
||||
protected final IItemList<IAEStack<?>> list = AEApi.instance().storage().createAEStackList();
|
||||
protected final ArrayList<IAEStack<?>> view = new ArrayList<>();
|
||||
protected final ArrayList<IAEStack<?>> dsp = new ArrayList<>();
|
||||
protected final IScrollSource src;
|
||||
protected final ISortSource sortSrc;
|
||||
|
||||
protected int rowSize = 9;
|
||||
|
||||
protected String searchString = "";
|
||||
protected IPartitionList<IAEItemStack> myPartitionList;
|
||||
protected boolean paused = false;
|
||||
private String NEIWord = null;
|
||||
private boolean hasPower;
|
||||
|
||||
public FluidRepo(final IScrollSource src, final ISortSource sortSrc) {
|
||||
this.src = src;
|
||||
this.sortSrc = sortSrc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack getReferenceItem(int idx) {
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
|
||||
if (idx >= this.view.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.view.get(idx) instanceof IAEItemStack ais ? ais : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(int idx) {
|
||||
IAEStack<?> stack = getReferenceStack(idx);
|
||||
return stack instanceof IAEItemStack ais ? ais.getItemStack() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postUpdate(IAEItemStack stack) {
|
||||
this.postUpdate((IAEStack<?>) stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postUpdate(final IAEStack<?> is) {
|
||||
final IAEStack st = this.list.findPrecise(is);
|
||||
if (st != null) {
|
||||
st.reset();
|
||||
st.add(is);
|
||||
} else {
|
||||
this.list.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViewCell(final ItemStack[] list) {
|
||||
this.myPartitionList = ItemViewCell.createFilter(list);
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void updateView() {
|
||||
if (this.paused) {
|
||||
// Update existing view with new data
|
||||
for (int i = 0; i < this.view.size(); i++) {
|
||||
IAEStack<?> entry = this.view.get(i);
|
||||
IAEStack<?> serverEntry = this.list.findPrecise(entry);
|
||||
}
|
||||
|
||||
// Append newly added item stacks to the end of the view
|
||||
Set<IAEStack<?>> viewSet = new HashSet<>(this.view);
|
||||
ArrayList<IAEStack<?>> entriesToAdd = new ArrayList<>();
|
||||
for (IAEStack<?> serverEntry : this.list) {
|
||||
if (!viewSet.contains(serverEntry)) {
|
||||
entriesToAdd.add(serverEntry);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.view.clear();
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
}
|
||||
|
||||
// Do not sort if paused
|
||||
if (!paused) {
|
||||
final Enum<?> SortBy = this.sortSrc.getSortBy();
|
||||
final Enum<?> SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
FluidSorters.init();
|
||||
|
||||
}
|
||||
|
||||
this.dsp.clear();
|
||||
this.dsp.ensureCapacity(this.list.size());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack<?> getReferenceStack(int idx) {
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
|
||||
if (idx >= this.view.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.view.get(idx);
|
||||
}
|
||||
|
||||
private void addEntriesToView(Iterable<IAEItemStack> entries) {
|
||||
final Enum<?> viewMode = this.sortSrc.getSortDisplay();
|
||||
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
||||
if (searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH) {
|
||||
this.updateNEI(this.searchString);
|
||||
}
|
||||
|
||||
String innerSearch = this.searchString;
|
||||
|
||||
boolean searchMod = false;
|
||||
if (innerSearch.startsWith("@")) {
|
||||
searchMod = true;
|
||||
innerSearch = innerSearch.substring(1);
|
||||
}
|
||||
|
||||
Pattern m;
|
||||
try {
|
||||
m = Pattern.compile(innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable ignore) {
|
||||
try {
|
||||
m = Pattern.compile(Pattern.quote(innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable __) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (IAEItemStack is : entries) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE) {
|
||||
is = is.copy();
|
||||
is.setStackSize(0);
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Fluid fluid = ItemFluidDrop.getAeFluidStack(is).getFluid();
|
||||
|
||||
if (FluidCraftAPI.instance().isBlacklistedInDisplay(fluid.getClass())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (searchMod) {
|
||||
if (m.matcher(Util.getFluidModID(fluid).toLowerCase()).find()
|
||||
|| m.matcher(Util.getFluidModName(fluid).toLowerCase()).find()) {
|
||||
this.view.add(is);
|
||||
}
|
||||
} else {
|
||||
if (m.matcher(fluid.getLocalizedName().toLowerCase()).find()) {
|
||||
this.view.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateNEI(final String filter) {
|
||||
try {
|
||||
if (this.NEIWord == null || !this.NEIWord.equals(filter)) {
|
||||
final Class<?> c = ReflectionHelper
|
||||
.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager");
|
||||
final Field fldSearchField = c.getField("searchField");
|
||||
final Object searchField = fldSearchField.get(c);
|
||||
|
||||
final Method a = searchField.getClass().getMethod("setText", String.class);
|
||||
final Method b = searchField.getClass().getMethod("onTextChange", String.class);
|
||||
|
||||
this.NEIWord = filter;
|
||||
a.invoke(searchField, filter);
|
||||
b.invoke(searchField, "");
|
||||
}
|
||||
} catch (final Throwable ignore) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return this.view.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.list.resetStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPower() {
|
||||
return this.hasPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPowered(final boolean hasPower) {
|
||||
this.hasPower = hasPower;
|
||||
}
|
||||
|
||||
public int getRowSize() {
|
||||
return this.rowSize;
|
||||
}
|
||||
|
||||
public void setRowSize(final int rowSize) {
|
||||
this.rowSize = rowSize;
|
||||
}
|
||||
|
||||
public String getSearchString() {
|
||||
return this.searchString;
|
||||
}
|
||||
|
||||
public void setSearchString(@Nonnull final String searchString) {
|
||||
this.searchString = searchString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaused() {
|
||||
return this.paused;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaused(boolean paused) {
|
||||
if (this.paused != paused) {
|
||||
this.paused = paused;
|
||||
|
||||
// Update view when un-paused
|
||||
if (!paused) {
|
||||
updateView();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +1,34 @@
|
||||
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<IAEFluidStack> {
|
||||
|
||||
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 +40,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,30 +1,20 @@
|
||||
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 com.google.common.base.Optional;
|
||||
|
||||
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 {
|
||||
public abstract class ItemBaseInfinityStorageCell extends FCBaseItemCell {
|
||||
|
||||
public ItemBaseInfinityStorageCell(Optional subName) {
|
||||
super(subName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytes(ItemStack cellItem) {
|
||||
public long getBytesLong(final ItemStack cellItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -33,22 +23,6 @@ public abstract class ItemBaseInfinityStorageCell extends AEBaseItem implements
|
||||
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;
|
||||
@@ -63,31 +37,4 @@ public abstract class ItemBaseInfinityStorageCell extends AEBaseItem implements
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,13 +2,10 @@ 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;
|
||||
|
||||
@@ -18,21 +15,16 @@ import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemCreativeFluidStorageCell extends ItemBaseInfinityStorageCell
|
||||
implements IStorageFluidCell, IRegister<ItemCreativeFluidStorageCell> {
|
||||
implements IRegister<ItemCreativeFluidStorageCell> {
|
||||
|
||||
public ItemCreativeFluidStorageCell() {
|
||||
super();
|
||||
super(com.google.common.base.Optional.absent());
|
||||
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");
|
||||
@@ -43,16 +35,6 @@ public class ItemCreativeFluidStorageCell extends ItemBaseInfinityStorageCell
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
@@ -6,14 +6,12 @@ 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 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;
|
||||
|
||||
|
||||
@@ -5,36 +5,32 @@ 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.ICellInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.AEBaseCell;
|
||||
import appeng.me.storage.FluidCellInventoryHandler;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemFluidVoidStorageCell extends AEBaseItem
|
||||
implements IStorageFluidCell, IRegister<ItemFluidVoidStorageCell> {
|
||||
public class ItemFluidVoidStorageCell extends AEBaseCell<IAEFluidStack> implements IRegister<ItemFluidVoidStorageCell> {
|
||||
|
||||
public ItemFluidVoidStorageCell() {
|
||||
super();
|
||||
super(com.google.common.base.Optional.absent());
|
||||
setUnlocalizedName(NameConst.ITEM_FLUID_VOID_CELL);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_FLUID_VOID_CELL).toString());
|
||||
this.setFeature(EnumSet.of(AEFeature.StorageCells));
|
||||
@@ -53,15 +49,15 @@ public class ItemFluidVoidStorageCell extends AEBaseItem
|
||||
final boolean displayMoreInfo) {
|
||||
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
|
||||
.getCellInventory(stack, null, StorageChannel.FLUIDS);
|
||||
if (inventory instanceof final IFluidCellInventoryHandler handler) {
|
||||
if (inventory instanceof final FluidCellInventoryHandler 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();
|
||||
final ICellInventory<IAEFluidStack> 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);
|
||||
IAEStack<?> s = inv.getConfigInventory().getAEStackInSlot(i);
|
||||
if (s != null) lines.add(s.getDisplayName());
|
||||
}
|
||||
}
|
||||
@@ -69,7 +65,7 @@ public class ItemFluidVoidStorageCell extends AEBaseItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytes(ItemStack cellItem) {
|
||||
public long getBytesLong(ItemStack cellItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -79,7 +75,7 @@ public class ItemFluidVoidStorageCell extends AEBaseItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
|
||||
public boolean isBlackListed(IAEFluidStack requestedAddition) {
|
||||
return requestedAddition == null || requestedAddition.getFluid() == null
|
||||
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
|
||||
}
|
||||
@@ -89,11 +85,6 @@ public class ItemFluidVoidStorageCell extends AEBaseItem
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell(ItemStack i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain(ItemStack is) {
|
||||
return 0;
|
||||
@@ -104,21 +95,6 @@ public class ItemFluidVoidStorageCell extends AEBaseItem
|
||||
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");
|
||||
@@ -130,7 +106,7 @@ public class ItemFluidVoidStorageCell extends AEBaseItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {
|
||||
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
}
|
||||
@@ -4,33 +4,32 @@ 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.core.features.AEFeature;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemInfinityWaterStorageCell extends ItemBaseInfinityStorageCell
|
||||
implements IStorageFluidCell, IRegister<ItemInfinityWaterStorageCell> {
|
||||
implements IRegister<ItemInfinityWaterStorageCell> {
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory(ItemStack is) {
|
||||
public IAEStackInventory 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 +37,7 @@ public class ItemInfinityWaterStorageCell extends ItemBaseInfinityStorageCell
|
||||
}
|
||||
|
||||
public ItemInfinityWaterStorageCell() {
|
||||
super();
|
||||
super(com.google.common.base.Optional.absent());
|
||||
setUnlocalizedName(NameConst.ITEM_INFINITY_WATER_FLUID_STORAGE);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_INFINITY_FLUID_STORAGE).toString());
|
||||
this.setFeature(EnumSet.of(AEFeature.StorageCells));
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,68 +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 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.item.IItemInventory;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
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.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<IAEFluidStack>
|
||||
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)
|
||||
@@ -70,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(
|
||||
@@ -109,69 +50,40 @@ 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) {
|
||||
public boolean isBlackListed(IAEFluidStack requestedAddition) {
|
||||
return requestedAddition == null || requestedAddition.getFluid() == null
|
||||
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell(final ItemStack i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain(ItemStack is) {
|
||||
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
|
||||
@@ -181,11 +93,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 null;// new PortableFluidCellInventory(stack, x);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
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.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.features.AEFeature;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemWirelessFluidTerminal extends ItemBaseWirelessTerminal
|
||||
implements IRegister<ItemWirelessFluidTerminal> {
|
||||
|
||||
public ItemWirelessFluidTerminal() {
|
||||
super(null);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler(this);
|
||||
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_FLUID_TERMINAL);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_FLUID_TERMINAL).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemWirelessFluidTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_FLUID_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,6 @@ 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.data.IAEFluidStack;
|
||||
@@ -148,13 +147,6 @@ public class PartFluidImportBus extends FCSharedFluidBus {
|
||||
return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED);
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
@@ -19,7 +19,7 @@ public class PartFluidPatternTerminal extends FCPart {
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui() {
|
||||
return null;
|
||||
return GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@ public class PartFluidPatternTerminalEx extends FCPart {
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui() {
|
||||
return GuiBridge.GUI_ME;
|
||||
return GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
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;
|
||||
@@ -81,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);
|
||||
}
|
||||
}
|
||||
@@ -221,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)) {
|
||||
Platform.openGUI(player, this.getHost().getTile(), this.getSide(), this.getGui());
|
||||
openGui(player);
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
}
|
||||
@@ -229,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,5 +1,7 @@
|
||||
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;
|
||||
@@ -10,6 +12,8 @@ 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;
|
||||
@@ -22,6 +26,7 @@ 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 {
|
||||
|
||||
@@ -64,10 +69,15 @@ public abstract class FCSharedFluidBus extends PartUpgradeable implements IGridT
|
||||
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); }
|
||||
*/
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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,73 +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 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,501 +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;
|
||||
for (int i = 0; i < this.getTotalFluidTypes(); i++) {
|
||||
if (this.getConfigInventory().getStackInSlot(i) != null) {
|
||||
types++;
|
||||
}
|
||||
}
|
||||
if (types == 0) types = this.getTotalFluidTypes();
|
||||
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);
|
||||
}
|
||||
@@ -1,259 +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 net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
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.IAEStack;
|
||||
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 {
|
||||
|
||||
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 monitor, Iterable<IAEStack<?>> change, BaseActionSource actionSource) {
|
||||
itemCache = null;
|
||||
try {
|
||||
List<IAEItemStack> mappedChanges = new ArrayList<>();
|
||||
for (IAEStack<?> fluidStack : change) {
|
||||
IAEItemStack itemStack = ItemFluidDrop.newAeStack((FluidStack) fluidStack);
|
||||
if (itemStack != null && !FluidCraftAPI.instance()
|
||||
.isBlacklistedInDisplay(((IAEFluidStack) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
-7
@@ -4,23 +4,30 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.api.FluidCraftAPI;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.crossmod.extracells.ProxyItem;
|
||||
import com.glodblock.github.inventory.FluidCellConfig;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCell {
|
||||
public class ProxyFluidStorageCell extends ProxyItem implements IStorageCell<IAEFluidStack> {
|
||||
|
||||
public ProxyFluidStorageCell(String ec2itemName) {
|
||||
super(ec2itemName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytes(ItemStack cellItem) {
|
||||
public int getBytes(ItemStack cellItem) {
|
||||
return Math.toIntExact(getBytesLong(cellItem));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytesLong(ItemStack cellItem) {
|
||||
int meta = cellItem.getItemDamage();
|
||||
if (replacements.containsKey(meta)) {
|
||||
ProxyItemEntry entry = replacements.get(meta);
|
||||
@@ -31,6 +38,11 @@ public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCel
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int BytePerType(ItemStack cellItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType(ItemStack cellItem) {
|
||||
int meta = cellItem.getItemDamage();
|
||||
@@ -44,7 +56,7 @@ public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCel
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
|
||||
public boolean isBlackListed(IAEFluidStack requestedAddition) {
|
||||
return requestedAddition == null || requestedAddition.getFluid() == null
|
||||
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
|
||||
}
|
||||
@@ -71,6 +83,16 @@ public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCel
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes(ItemStack cellItem) {
|
||||
return 5;
|
||||
@@ -87,8 +109,8 @@ public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCel
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory(ItemStack is) {
|
||||
return new FluidCellConfig(is);
|
||||
public IAEStackInventory getConfigInventory(ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-3
@@ -9,16 +9,18 @@ import com.glodblock.github.crossmod.extracells.ProxyItem;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
/**
|
||||
* Proxy Item Storage. 256K, 1024K, etc. -> AE2's version. For now its just mirroring AE2's version, will need to
|
||||
* transition to something better.
|
||||
*/
|
||||
public class ProxyItemStorageCell extends ProxyItem implements IStorageCell {
|
||||
public class ProxyItemStorageCell extends ProxyItem implements IStorageCell<IAEItemStack> {
|
||||
|
||||
public ProxyItemStorageCell(String ec2itemName) {
|
||||
super(ec2itemName);
|
||||
@@ -90,7 +92,7 @@ public class ProxyItemStorageCell extends ProxyItem implements IStorageCell {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEItemStack requestedAddition) {
|
||||
public boolean isBlackListed(IAEItemStack requestedAddition) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -124,6 +126,11 @@ public class ProxyItemStorageCell extends ProxyItem implements IStorageCell {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(ItemStack is) {
|
||||
return true;
|
||||
@@ -135,7 +142,7 @@ public class ProxyItemStorageCell extends ProxyItem implements IStorageCell {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory(ItemStack is) {
|
||||
public IAEStackInventory getConfigInventory(ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.glodblock.github.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.items.contents.CellConfig;
|
||||
|
||||
public class FluidCellConfig extends CellConfig {
|
||||
|
||||
public FluidCellConfig(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack newItemStack) {
|
||||
if (newItemStack != null && !(newItemStack.getItem() instanceof ItemFluidPacket)) {
|
||||
ItemStack fluidPacket = ItemFluidPacket.newDisplayStack(Util.getFluidFromItem(newItemStack));
|
||||
if (fluidPacket != null) {
|
||||
super.setInventorySlotContents(slot, fluidPacket);
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.setInventorySlotContents(slot, newItemStack);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.glodblock.github.loader;
|
||||
|
||||
import static com.glodblock.github.common.storage.FluidCellInventory.singleByteAmount;
|
||||
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.block.BlockCertusQuartzTank;
|
||||
import com.glodblock.github.common.block.BlockFluidAutoFiller;
|
||||
@@ -42,6 +40,7 @@ import com.glodblock.github.common.item.ItemPartFluidTerminal;
|
||||
import com.glodblock.github.common.item.ItemPartLevelTerminal;
|
||||
import com.glodblock.github.common.item.ItemPortableFluidCell;
|
||||
import com.glodblock.github.common.item.ItemQuantumBridgeCard;
|
||||
import com.glodblock.github.common.item.ItemWirelessFluidTerminal;
|
||||
import com.glodblock.github.common.item.ItemWirelessInterfaceTerminal;
|
||||
import com.glodblock.github.common.item.ItemWirelessLevelTerminal;
|
||||
import com.glodblock.github.common.item.ItemWirelessPatternTerminal;
|
||||
@@ -81,6 +80,7 @@ public class ItemAndBlockHolder {
|
||||
public static ItemFluidStorageMonitor FLUID_STORAGE_MONITOR = new ItemFluidStorageMonitor().register();
|
||||
public static ItemFluidConversionMonitor FLUID_CONVERSION_MONITOR = new ItemFluidConversionMonitor().register();
|
||||
public static ItemPortableFluidCell PORTABLE_FLUID_CELL = new ItemPortableFluidCell().register();
|
||||
public static ItemWirelessFluidTerminal WIRELESS_FLUID_TERM = new ItemWirelessFluidTerminal().register();
|
||||
public static ItemWirelessLevelTerminal WIRELESS_LEVEL_TERM = new ItemWirelessLevelTerminal().register();
|
||||
public static ItemWirelessPatternTerminal WIRELESS_PATTERN_TERM = new ItemWirelessPatternTerminal().register();
|
||||
public static ItemWirelessUltraTerminal WIRELESS_ULTRA_TERM = new ItemWirelessUltraTerminal().register();
|
||||
@@ -131,7 +131,7 @@ public class ItemAndBlockHolder {
|
||||
4.5).register();
|
||||
public static ItemFluidExtremeStorageCell SINGULARITY_CELL = new ItemFluidExtremeStorageCell(
|
||||
NameConst.ITEM_SINGULARITY_FLUID_STORAGE,
|
||||
Long.MAX_VALUE / (singleByteAmount * 2),
|
||||
Long.MAX_VALUE / (256 * 8 * 2),
|
||||
8,
|
||||
1,
|
||||
5).register();
|
||||
|
||||
@@ -22,7 +22,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.storage.FluidCellInventoryHandler;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite;
|
||||
|
||||
@@ -33,6 +32,7 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.render.StackSizeRenderer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.me.storage.FluidCellInventoryHandler;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.FluidList;
|
||||
import codechicken.nei.PositionedStack;
|
||||
|
||||
@@ -6,19 +6,17 @@ import java.util.regex.Pattern;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import com.glodblock.github.common.storage.IFluidCellInventory;
|
||||
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
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.items.AEBaseCell;
|
||||
import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.me.storage.FluidCellInventoryHandler;
|
||||
import appeng.util.IterationCounter;
|
||||
import codechicken.nei.SearchField;
|
||||
import codechicken.nei.SearchTokenParser;
|
||||
@@ -57,15 +55,15 @@ public class NEISearchFilter implements SearchTokenParser.ISearchParserProvider
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack itemStack) {
|
||||
if (itemStack.getItem() instanceof IStorageFluidCell) {
|
||||
if (itemStack.getItem() instanceof AEBaseCell<?>) {
|
||||
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
|
||||
.getCellInventory(itemStack, null, StorageChannel.FLUIDS);
|
||||
if (inventory instanceof final IFluidCellInventoryHandler handler) {
|
||||
final IFluidCellInventory cellInventory = handler.getCellInv();
|
||||
if (inventory instanceof final FluidCellInventoryHandler handler) {
|
||||
final ICellInventory<IAEFluidStack> cellInventory = handler.getCellInv();
|
||||
if (cellInventory != null) {
|
||||
final ArrayList<IAEFluidStack> out = new ArrayList<>();
|
||||
handler.getPartitionInv().forEach(out::add);
|
||||
out.addAll(cellInventory.getContents());
|
||||
//handler.getPartitionInv().forEach(out::add);
|
||||
//out.addAll(cellInventory.getContents());
|
||||
for (IAEFluidStack fluid : out) {
|
||||
boolean result = pattern.matcher(fluid.getFluidStack().getLocalizedName().toLowerCase())
|
||||
.find();
|
||||
@@ -82,12 +80,12 @@ public class NEISearchFilter implements SearchTokenParser.ISearchParserProvider
|
||||
if (inventory instanceof final CellInventoryHandler handler) {
|
||||
final ICellInventory cellInventory = handler.getCellInv();
|
||||
if (cellInventory != null) {
|
||||
final IItemList<IAEItemStack> out = AEApi.instance().storage().createItemFilterList();
|
||||
for (IAEItemStack item : handler.getPartitionList().getItems())
|
||||
out.add(item);
|
||||
final IItemList<IAEStack<?>> out = AEApi.instance().storage().createAEStackList();
|
||||
for (Object item : handler.getPartitionList().getItems())
|
||||
out.add((IAEStack<?>) item);
|
||||
cellInventory.getAvailableItems(out, IterationCounter.fetchNewId());
|
||||
for ( IAEItemStack item : out) {
|
||||
boolean result = pattern.matcher(item.getItemStack().getDisplayName().toLowerCase())
|
||||
for (IAEStack<?> item : out) {
|
||||
boolean result = pattern.matcher(item.getDisplayName().toLowerCase())
|
||||
.find();
|
||||
if (result) return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user