mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-15 17:44:46 +00:00
Prevent EssentiaRepo view movement when repo is paused
This commit is contained in:
1 parent
e32da01619
commit
e585e6779f
2 files changed
+71
-39
No files matched your search
@@ -1,6 +1,9 @@
|
||||
package com.glodblock.github.client.me;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -30,12 +33,75 @@ public class EssentiaRepo extends FluidRepo {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void updateView() {
|
||||
this.view.clear();
|
||||
if (this.paused) {
|
||||
// Update existing view with new data
|
||||
for (int i = 0; i < this.view.size(); i++) {
|
||||
IAEItemStack entry = this.view.get(i);
|
||||
IAEItemStack serverEntry = this.list.findPrecise(entry);
|
||||
if (serverEntry == null) {
|
||||
entry.setStackSize(0);
|
||||
} else {
|
||||
this.view.set(i, serverEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// Append newly added item stacks to the end of the view
|
||||
Set<IAEItemStack> viewSet = new HashSet<>(this.view);
|
||||
ArrayList<IAEItemStack> entriesToAdd = new ArrayList<>();
|
||||
for (IAEItemStack serverEntry : this.list) {
|
||||
if (!viewSet.contains(serverEntry)) {
|
||||
entriesToAdd.add(serverEntry);
|
||||
}
|
||||
}
|
||||
addEntriesToView(entriesToAdd);
|
||||
} else {
|
||||
this.view.clear();
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
addEntriesToView(this.list);
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the display
|
||||
this.dsp.clear();
|
||||
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
this.dsp.ensureCapacity(this.list.size());
|
||||
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());
|
||||
if (!AspectUtil.isEssentiaGas(fluid)) {
|
||||
it1.remove();
|
||||
}
|
||||
}
|
||||
Iterator<ItemStack> it2 = this.dsp.iterator();
|
||||
while (it2.hasNext()) {
|
||||
FluidStack fluid = ItemFluidDrop.getFluidStack(it2.next());
|
||||
if (!AspectUtil.isEssentiaGas(fluid)) {
|
||||
it2.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -59,7 +125,7 @@ public class EssentiaRepo extends FluidRepo {
|
||||
}
|
||||
}
|
||||
|
||||
for (IAEItemStack is : this.list) {
|
||||
for (IAEItemStack is : entries) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
@@ -88,40 +154,6 @@ public class EssentiaRepo extends FluidRepo {
|
||||
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());
|
||||
if (!AspectUtil.isEssentiaGas(fluid)) {
|
||||
it1.remove();
|
||||
}
|
||||
}
|
||||
Iterator<ItemStack> it2 = this.dsp.iterator();
|
||||
while (it2.hasNext()) {
|
||||
FluidStack fluid = ItemFluidDrop.getFluidStack(it2.next());
|
||||
if (!AspectUtil.isEssentiaGas(fluid)) {
|
||||
it2.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,9 +54,9 @@ public class FluidRepo implements IDisplayRepo {
|
||||
|
||||
protected String searchString = "";
|
||||
protected IPartitionList<IAEItemStack> myPartitionList;
|
||||
protected boolean paused = false;
|
||||
private String NEIWord = null;
|
||||
private boolean hasPower;
|
||||
private boolean paused = false;
|
||||
|
||||
public FluidRepo(final IScrollSource src, final ISortSource sortSrc) {
|
||||
this.src = src;
|
||||
|
||||
Reference in new issue
Block a user