Update APIs (#130)

* Add an API to allow other mods to blacklist fluids from this mod.

* Removed Thaumic Energistics config setting. This will be handled by
Thaumic Energistic's side (which also happens to have a config setting).

* Added an API that allows for blacklisting fluids from either the storage
or the display individually.

* Prevent blacklisted fluids from being discretized

* Update API usage

- use AE2's new API

- use ThE's config setting for aspect -> gas

* spotlessApply

---------

Co-authored-by: GitHub GTNH Actions <unknown>
This commit is contained in:
firenooandGitHub GTNH Actions authored and GitHub committed 2023-05-20 19:46:37 +02:00
1 parent 14853a2481
commit f87b76347e
19 files changed
+237 -79

No files matched your search

@@ -29,11 +29,11 @@ import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IDisplayRepo;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.gui.widgets.*;
import appeng.client.me.InternalSlotME;
import appeng.client.me.ItemRepo;
import appeng.client.me.SlotDisconnected;
import appeng.client.me.SlotME;
import appeng.container.AEBaseContainer;
@@ -67,7 +67,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
protected final ItemStack[] myCurrentViewCells = new ItemStack[5];
public FCContainerMonitor<T> monitorableContainer;
public GuiTabButton craftingStatusBtn;
protected ItemRepo repo;
protected IDisplayRepo repo;
protected GuiImgButton craftingStatusImgBtn;
protected FCGuiTextField searchField;
protected int perRow = 9;
@@ -649,7 +649,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
@Override
public void updateScreen() {
this.repo.setPower(this.monitorableContainer.isPowered());
this.repo.setPowered(this.monitorableContainer.isPowered());
super.updateScreen();
}
@@ -119,12 +119,6 @@ public class ContainerEssentiaMonitor extends ContainerFluidPortableCell {
if (slotIndex == -1) {
out.stackSize = fluidContainer.stackSize;
} else {
if (drainStack != null) {
System.out.print("---------\n");
System.out.print(drainStack.right + "\n");
System.out.print(drainStack.left + "\n");
System.out.print(aeFluidStack.getStackSize() + "\n");
}
out.stackSize = (int) (fluidContainer.stackSize
- (aeFluidStack.getStackSize() / drainStack.left));
}
@@ -1,17 +1,25 @@
package com.glodblock.github.client.me;
import java.util.Iterator;
import java.util.regex.Pattern;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
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.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.storage.data.IAEFluidStack;
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 {
@@ -21,7 +29,84 @@ public class EssentiaRepo extends FluidRepo {
@Override
public void updateView() {
super.updateView();
this.view.clear();
this.dsp.clear();
this.view.ensureCapacity(this.list.size());
this.dsp.ensureCapacity(this.list.size());
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 : this.list) {
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);
}
}
final Enum<?> SortBy = this.sortSrc.getSortBy();
final Enum<?> SortDir = this.sortSrc.getSortDir();
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
FluidSorters.init();
if (SortBy == SortOrder.MOD) {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
} else if (SortBy == SortOrder.AMOUNT) {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
} else if (SortBy == SortOrder.INVTWEAKS) {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
} else {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
}
for (final IAEItemStack is : this.view) {
this.dsp.add(is.getItemStack());
}
Iterator<IAEItemStack> it1 = this.view.iterator();
while (it1.hasNext()) {
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(it1.next());
@@ -20,6 +20,7 @@ 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;
@@ -27,36 +28,36 @@ import com.glodblock.github.util.Util;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.storage.data.IAEItemStack;
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.client.me.ItemRepo;
import appeng.core.AEConfig;
import appeng.items.storage.ItemViewCell;
import appeng.util.prioitylist.IPartitionList;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class FluidRepo extends ItemRepo {
public class FluidRepo implements IDisplayRepo {
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
protected final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
protected final ArrayList<IAEItemStack> view = new ArrayList<>();
protected final ArrayList<ItemStack> dsp = new ArrayList<>();
private final IScrollSource src;
private final ISortSource sortSrc;
protected final IScrollSource src;
protected final ISortSource sortSrc;
private int rowSize = 9;
protected int rowSize = 9;
private String searchString = "";
private IPartitionList<IAEItemStack> myPartitionList;
protected String searchString = "";
protected IPartitionList<IAEItemStack> myPartitionList;
private String NEIWord = null;
private boolean hasPower;
public FluidRepo(final IScrollSource src, final ISortSource sortSrc) {
super(src, sortSrc);
this.src = src;
this.sortSrc = sortSrc;
}
@Override
public IAEItemStack getReferenceItem(int idx) {
idx += this.src.getCurrentScroll() * this.rowSize;
@@ -66,6 +67,7 @@ public class FluidRepo extends ItemRepo {
return this.view.get(idx);
}
@Override
public ItemStack getItem(int idx) {
idx += this.src.getCurrentScroll() * this.rowSize;
@@ -75,10 +77,7 @@ public class FluidRepo extends ItemRepo {
return this.dsp.get(idx);
}
void setSearch(final String search) {
this.searchString = search == null ? "" : search;
}
@Override
public void postUpdate(final IAEItemStack is) {
final IAEItemStack st = this.list.findPrecise(is);
if (st != null) {
@@ -89,11 +88,13 @@ public class FluidRepo extends ItemRepo {
}
}
@Override
public void setViewCell(final ItemStack[] list) {
this.myPartitionList = ItemViewCell.createFilter(list);
this.updateView();
}
@Override
public void updateView() {
this.view.clear();
this.dsp.clear();
@@ -145,7 +146,13 @@ public class FluidRepo extends ItemRepo {
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()) {
@@ -179,7 +186,7 @@ public class FluidRepo extends ItemRepo {
}
}
private void updateNEI(final String filter) {
protected void updateNEI(final String filter) {
try {
if (this.NEIWord == null || !this.NEIWord.equals(filter)) {
final Class<?> c = ReflectionHelper
@@ -199,19 +206,23 @@ public class FluidRepo extends ItemRepo {
}
}
@Override
public int size() {
return this.view.size();
}
@Override
public void clear() {
this.list.resetStatus();
}
@Override
public boolean hasPower() {
return this.hasPower;
}
public void setPower(final boolean hasPower) {
@Override
public void setPowered(final boolean hasPower) {
this.hasPower = hasPower;
}