mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-15 01:34:42 +00:00
Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0832be3e8 | ||
|
|
96a5c0cf88 | ||
|
|
887afbfb8d | ||
|
|
84290c5bc9 | ||
|
|
1caf3c7334 | ||
|
|
ff87fd550e | ||
|
|
12c4995642 | ||
|
|
d40f7ff498 | ||
|
|
60c94f4e40 | ||
|
|
27fc0b8b98 | ||
|
|
cf83b39b84 | ||
|
|
0e986c9af4 | ||
|
|
946f1b3e53 | ||
|
|
f2cd82c8fa | ||
|
|
bde9a20947 | ||
|
|
d242f238ab |
No files matched your search
@@ -957,7 +957,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
this.realItems.add(stackA);
|
||||
this.metadata.add(meta);
|
||||
|
||||
if (animate && !NEIClientConfig.shouldCacheItemRendering() && NEIClientConfig.areBookmarksAnimated()) {
|
||||
if (animate && NEIClientConfig.getGridRenderingCacheMode() == 0 && NEIClientConfig.areBookmarksAnimated()) {
|
||||
this.animation.put(stackA, 0f);
|
||||
}
|
||||
|
||||
@@ -1040,8 +1040,9 @@ public class BookmarkPanel extends PanelWidget {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean shouldCacheItemRendering() {
|
||||
return NEIClientConfig.shouldCacheItemRendering() && this.focusedGroupId == -1;
|
||||
@Override
|
||||
protected int getGridRenderingCacheMode() {
|
||||
return this.focusedGroupId == -1 ? NEIClientConfig.getGridRenderingCacheMode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2584,6 +2585,21 @@ public class BookmarkPanel extends PanelWidget {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int px, int py) {
|
||||
|
||||
if (new Rectangle4i(pagePrev.x + pagePrev.w, pagePrev.y, pageNext.x - (pagePrev.x + pagePrev.w), pagePrev.h)
|
||||
.contains(px, py)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (((BookmarkGrid) grid).getHoveredRowIndex(true) != -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.contains(px, py);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
|
||||
List<String> currenttip) {
|
||||
|
||||
@@ -145,24 +145,16 @@ public class CollapsibleItems {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public static void updateCache(final List<ItemStack> items) {
|
||||
public static void clearCache() {
|
||||
CollapsibleItems.cache.clear();
|
||||
}
|
||||
|
||||
try {
|
||||
public static void putItem(ItemStack stack) {
|
||||
final GroupItem group = CollapsibleItems.groups.stream().filter(g -> g.matches(stack)).findFirst().orElse(null);
|
||||
|
||||
ItemList.forkJoinPool.submit(() -> items.parallelStream().forEach(stack -> {
|
||||
GroupItem group = CollapsibleItems.groups.stream().filter(g -> g.matches(stack)).findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (group != null) {
|
||||
CollapsibleItems.cache.put(stack, CollapsibleItems.groups.indexOf(group));
|
||||
}
|
||||
})).get();
|
||||
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Error create collapsible items groups", e);
|
||||
if (group != null) {
|
||||
CollapsibleItems.cache.put(stack, CollapsibleItems.groups.indexOf(group));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int getGroupIndex(ItemStack stack) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.ForkJoinWorkerThread;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -26,6 +27,7 @@ import codechicken.nei.ThreadOperationTimer.TimeoutException;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.search.TooltipFilter;
|
||||
|
||||
public class ItemList {
|
||||
|
||||
@@ -268,50 +270,84 @@ public class ItemList {
|
||||
ItemList.ordering = newOrdering;
|
||||
}
|
||||
|
||||
private List<ItemStack> getPermutations(Item item) {
|
||||
final List<ItemStack> permutations = new LinkedList<>(ItemInfo.itemOverrides.get(item));
|
||||
|
||||
if (permutations.isEmpty()) {
|
||||
item.getSubItems(item, null, permutations);
|
||||
}
|
||||
|
||||
if (permutations.isEmpty()) {
|
||||
damageSearch(item, permutations);
|
||||
}
|
||||
|
||||
permutations.addAll(ItemInfo.itemVariants.get(item));
|
||||
|
||||
return permutations.stream()
|
||||
.filter(
|
||||
stack -> stack.getItem() != null && stack.getItem().delegate.name() != null
|
||||
&& !ItemInfo.isHidden(stack))
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
// For optimization it generate itemslist, permutations, orders & collapsibleitems
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void execute() {
|
||||
if (!NEIClientConfig.isEnabled()) return;
|
||||
|
||||
ThreadOperationTimer timer = getTimer(NEIClientConfig.getItemLoadingTimeout());
|
||||
LayoutManager.itemsLoaded = true;
|
||||
loadFinished = false;
|
||||
|
||||
List<ItemStack> items = new LinkedList<>();
|
||||
List<ItemStack> permutations = new LinkedList<>();
|
||||
SearchField.searchParser.clearCache();
|
||||
ItemSorter.instance.ordering.clear();
|
||||
CollapsibleItems.clearCache();
|
||||
TooltipFilter.clearCache();
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
ListMultimap<Item, ItemStack> itemMap = ArrayListMultimap.create();
|
||||
ItemStackSet unique = new ItemStackSet();
|
||||
|
||||
timer.setLimit(NEIClientConfig.getItemLoadingTimeout());
|
||||
for (Item item : (Iterable<Item>) Item.itemRegistry) {
|
||||
if (interrupted()) return;
|
||||
|
||||
if (item == null || erroredItems.contains(item)) continue;
|
||||
StreamSupport.stream(((Iterable<Item>) Item.itemRegistry).spliterator(), true).forEach(item -> {
|
||||
if (item == null || item.delegate.name() == null || erroredItems.contains(item)) return;
|
||||
|
||||
try {
|
||||
timer.reset(item);
|
||||
|
||||
permutations.clear();
|
||||
permutations.addAll(ItemInfo.itemOverrides.get(item));
|
||||
|
||||
if (permutations.isEmpty()) {
|
||||
item.getSubItems(item, null, permutations);
|
||||
}
|
||||
|
||||
if (permutations.isEmpty()) {
|
||||
damageSearch(item, permutations);
|
||||
}
|
||||
|
||||
permutations.addAll(ItemInfo.itemVariants.get(item));
|
||||
|
||||
List<ItemStack> permutations = getPermutations(item);
|
||||
timer.reset();
|
||||
|
||||
permutations = permutations.stream().filter(stack -> !ItemInfo.isHidden(stack))
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
for (ItemStack stack : permutations) {
|
||||
if (!unique.contains(stack)) {
|
||||
|
||||
items.addAll(permutations);
|
||||
itemMap.putAll(item, permutations);
|
||||
synchronized (unique) {
|
||||
unique.add(stack);
|
||||
}
|
||||
|
||||
synchronized (items) {
|
||||
items.add(stack);
|
||||
}
|
||||
|
||||
CollapsibleItems.putItem(stack);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (itemMap) {
|
||||
itemMap.putAll(item, permutations);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
NEIServerConfig.logger.error("Removing item: " + item + " from list.", t);
|
||||
NEIServerConfig.logger.error("Removing item: {} from list.", item, t);
|
||||
erroredItems.add(item);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
int index = 0;
|
||||
for (Item item : (Iterable<Item>) Item.itemRegistry) {
|
||||
for (ItemStack stack : itemMap.get(item)) {
|
||||
ItemSorter.instance.ordering.put(stack, index++);
|
||||
}
|
||||
}
|
||||
|
||||
if (interrupted()) return;
|
||||
@@ -320,10 +356,15 @@ public class ItemList {
|
||||
for (ItemsLoadedCallback callback : loadCallbacks) callback.itemsLoaded();
|
||||
|
||||
if (interrupted()) return;
|
||||
CollapsibleItems.updateCache(items);
|
||||
updateOrdering(items);
|
||||
updateOrdering(ItemList.items);
|
||||
|
||||
new Thread(
|
||||
() -> ItemList.items.parallelStream().forEach(TooltipFilter::getSearchTooltip),
|
||||
"NEI Tooltip Filter Loader").start();
|
||||
|
||||
loadFinished = true;
|
||||
|
||||
SubsetWidget.updateHiddenItems();
|
||||
updateFilter.restart();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -41,9 +41,6 @@ public class ItemPanel extends PanelWidget {
|
||||
return super.getStackMouseOver(mousex, mousey);
|
||||
}
|
||||
|
||||
public Button more;
|
||||
public Button less;
|
||||
public ItemQuantityField quantity;
|
||||
public ItemHistoryPanel historyPanel;
|
||||
public Button toggleGroups;
|
||||
|
||||
@@ -345,42 +342,6 @@ public class ItemPanel extends PanelWidget {
|
||||
}
|
||||
};
|
||||
|
||||
more = new Button("+") {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (rightclick) return false;
|
||||
|
||||
int modifier = NEIClientUtils.controlKey() ? 64 : NEIClientUtils.shiftKey() ? 10 : 1;
|
||||
int quantity = NEIClientConfig.getItemQuantity() + modifier;
|
||||
|
||||
if (quantity < 0) {
|
||||
quantity = 0;
|
||||
}
|
||||
|
||||
ItemPanels.itemPanel.quantity.setText(Integer.toString(quantity));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
less = new Button("-") {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (rightclick) return false;
|
||||
|
||||
int modifier = NEIClientUtils.controlKey() ? -64 : NEIClientUtils.shiftKey() ? -10 : -1;
|
||||
int quantity = NEIClientConfig.getItemQuantity() + modifier;
|
||||
|
||||
if (quantity < 0) {
|
||||
quantity = 0;
|
||||
}
|
||||
|
||||
ItemPanels.itemPanel.quantity.setText(Integer.toString(quantity));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
quantity = new ItemQuantityField("quantity");
|
||||
historyPanel = new ItemHistoryPanel();
|
||||
}
|
||||
|
||||
@@ -431,44 +392,21 @@ public class ItemPanel extends PanelWidget {
|
||||
return 0;
|
||||
}
|
||||
|
||||
final int BUTTON_SIZE = 20;
|
||||
more.w = less.w = BUTTON_SIZE;
|
||||
quantity.h = BUTTON_SIZE;
|
||||
|
||||
if (NEIClientConfig.isSearchWidgetCentered()) {
|
||||
more.h = less.h = BUTTON_SIZE;
|
||||
more.x = x + w - BUTTON_SIZE;
|
||||
more.y = less.y = quantity.y = y + h - BUTTON_SIZE;
|
||||
less.x = x;
|
||||
quantity.x = x + BUTTON_SIZE + 2;
|
||||
quantity.w = more.x - quantity.x - 2;
|
||||
} else {
|
||||
quantity.x = (int) (x + (w * 0.7)) + 3;
|
||||
quantity.y = y + h - BUTTON_SIZE;
|
||||
quantity.w = (int) ((w * 0.3) - BUTTON_SIZE - 1);
|
||||
|
||||
more.h = less.h = BUTTON_SIZE / 2;
|
||||
more.y = y + h - (more.h * 2);
|
||||
|
||||
less.x = more.x = quantity.x + quantity.w;
|
||||
less.y = more.y + more.h;
|
||||
}
|
||||
|
||||
if (NEIClientConfig.showHistoryPanelWidget()) {
|
||||
historyPanel.x = x;
|
||||
historyPanel.w = w;
|
||||
historyPanel.h = ItemsGrid.SLOT_SIZE * NEIClientConfig.getIntSetting("inventory.history.useRows");
|
||||
|
||||
if (NEIClientConfig.showItemQuantityWidget() || !NEIClientConfig.isSearchWidgetCentered()) {
|
||||
historyPanel.y = quantity.y - historyPanel.h - PanelWidget.PADDING;
|
||||
return quantity.h + historyPanel.h + PanelWidget.PADDING * 2;
|
||||
historyPanel.y = LayoutManager.quantity.y - historyPanel.h - PanelWidget.PADDING;
|
||||
return LayoutManager.quantity.h + historyPanel.h + PanelWidget.PADDING * 2;
|
||||
} else {
|
||||
historyPanel.y = y + h - historyPanel.h;
|
||||
return historyPanel.h + PanelWidget.PADDING;
|
||||
}
|
||||
}
|
||||
|
||||
return quantity.h + PanelWidget.PADDING;
|
||||
return LayoutManager.quantity.h + PanelWidget.PADDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -476,12 +414,6 @@ public class ItemPanel extends PanelWidget {
|
||||
super.setVisible();
|
||||
|
||||
if (grid.getPerPage() > 0) {
|
||||
if (NEIClientConfig.showItemQuantityWidget()) {
|
||||
LayoutManager.addWidget(more);
|
||||
LayoutManager.addWidget(less);
|
||||
LayoutManager.addWidget(quantity);
|
||||
}
|
||||
|
||||
if (!CollapsibleItems.isEmpty() && !grid.isEmpty()) {
|
||||
LayoutManager.addWidget(toggleGroups);
|
||||
}
|
||||
|
||||
@@ -4,19 +4,19 @@ import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import codechicken.lib.config.ConfigTagParent;
|
||||
import codechicken.nei.ItemList.ItemsLoadedCallback;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.config.GuiItemSorter;
|
||||
import codechicken.nei.config.OptionOpenGui;
|
||||
|
||||
public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback {
|
||||
public class ItemSorter implements Comparator<ItemStack> {
|
||||
|
||||
public static class SortEntry {
|
||||
|
||||
@@ -44,12 +44,10 @@ public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback {
|
||||
public static final ItemSorter instance = new ItemSorter();
|
||||
|
||||
// optimisations
|
||||
public HashMap<ItemStack, Integer> ordering = null;
|
||||
public Map<ItemStack, Integer> ordering = new HashMap<>();
|
||||
|
||||
public static void sort(List<ItemStack> items) {
|
||||
try {
|
||||
// items = (ArrayList<ItemStack>)
|
||||
// items.parallelStream().sorted(instance).collect(Collectors.toList());
|
||||
items.sort(instance);
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Exception sorting item list", e);
|
||||
@@ -65,14 +63,6 @@ public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemsLoaded() {
|
||||
HashMap<ItemStack, Integer> newMap = new HashMap<>();
|
||||
int i = 0;
|
||||
for (ItemStack stack : ItemList.items) newMap.put(stack, i++);
|
||||
ordering = newMap;
|
||||
}
|
||||
|
||||
public static SortEntry find(String name) {
|
||||
for (SortEntry e : entries) if (e.name.equals(name)) return e;
|
||||
|
||||
@@ -136,7 +126,6 @@ public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback {
|
||||
list = fromSaveString(activeTag().getValue());
|
||||
}
|
||||
});
|
||||
ItemList.loadCallbacks.add(instance);
|
||||
}
|
||||
|
||||
public static String getSaveString(List<SortEntry> list) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import static codechicken.lib.inventory.InventoryUtils.actualDamage;
|
||||
import static codechicken.lib.inventory.InventoryUtils.newItemStack;
|
||||
import static net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -24,18 +24,23 @@ public class ItemStackMap<T> {
|
||||
|
||||
public final int damage;
|
||||
public final NBTTagCompound tag;
|
||||
private final int hashCode;
|
||||
|
||||
public StackMetaKey(int damage, NBTTagCompound tag) {
|
||||
if (tag != null && tag.hasNoTags()) {
|
||||
tag = null;
|
||||
}
|
||||
this.hashCode = Objects.hashCode(damage, tag);
|
||||
this.damage = damage;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public StackMetaKey(ItemStack key) {
|
||||
this(actualDamage(key), key.stackTagCompound);
|
||||
this(key.getItemDamage(), key.stackTagCompound);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(damage, tag);
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
@@ -69,7 +74,7 @@ public class ItemStackMap<T> {
|
||||
if (wildcard != null) return wildcard;
|
||||
|
||||
if (damageMap != null) {
|
||||
final T ret = damageMap.get(actualDamage(key));
|
||||
final T ret = damageMap.get(key.getItemDamage());
|
||||
if (ret != null) return ret;
|
||||
}
|
||||
if (tagMap != null) {
|
||||
@@ -83,7 +88,7 @@ public class ItemStackMap<T> {
|
||||
|
||||
public T put(ItemStack key, T value) {
|
||||
try {
|
||||
switch (getKeyType(actualDamage(key), key.stackTagCompound)) {
|
||||
switch (getKeyType(key.getItemDamage(), key.stackTagCompound)) {
|
||||
case 0:
|
||||
if (metaMap == null) metaMap = new HashMap<>();
|
||||
return metaMap.put(new StackMetaKey(key), value);
|
||||
@@ -92,7 +97,7 @@ public class ItemStackMap<T> {
|
||||
return tagMap.put(key.stackTagCompound, value);
|
||||
case 2:
|
||||
if (damageMap == null) damageMap = new HashMap<>();
|
||||
return damageMap.put(actualDamage(key), value);
|
||||
return damageMap.put(key.getItemDamage(), value);
|
||||
case 3:
|
||||
T ret = wildcard;
|
||||
wildcard = value;
|
||||
@@ -107,13 +112,13 @@ public class ItemStackMap<T> {
|
||||
|
||||
public T remove(ItemStack key) {
|
||||
try {
|
||||
switch (getKeyType(actualDamage(key), key.stackTagCompound)) {
|
||||
switch (getKeyType(key.getItemDamage(), key.stackTagCompound)) {
|
||||
case 0:
|
||||
return metaMap != null ? metaMap.remove(new StackMetaKey(key)) : null;
|
||||
case 1:
|
||||
return tagMap != null ? tagMap.remove(key.stackTagCompound) : null;
|
||||
case 2:
|
||||
return damageMap != null ? damageMap.remove(actualDamage(key)) : null;
|
||||
return damageMap != null ? damageMap.remove(key.getItemDamage()) : null;
|
||||
case 3:
|
||||
T ret = wildcard;
|
||||
wildcard = null;
|
||||
@@ -191,7 +196,7 @@ public class ItemStackMap<T> {
|
||||
WILDCARD_TAG.setBoolean("*", true);
|
||||
}
|
||||
|
||||
private final HashMap<Item, DetailMap> itemMap = new HashMap<>();
|
||||
private final Map<Item, DetailMap> itemMap = new LinkedHashMap<>();
|
||||
private int size;
|
||||
|
||||
public T get(ItemStack key) {
|
||||
@@ -218,6 +223,7 @@ public class ItemStackMap<T> {
|
||||
|
||||
public void clear() {
|
||||
itemMap.clear();
|
||||
size = 0;
|
||||
}
|
||||
|
||||
public T remove(ItemStack key) {
|
||||
|
||||
@@ -32,6 +32,11 @@ public class ItemStackSet extends ItemStackMap<ItemStack> implements ItemFilter
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackSet removeAll(Iterable<ItemStack> items) {
|
||||
for (ItemStack item : items) remove(item);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean contains(ItemStack item) {
|
||||
return get(item) != null;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
@@ -26,6 +27,117 @@ import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
public class ItemsGrid {
|
||||
|
||||
private static class ScreenCapture {
|
||||
|
||||
private long nextCacheRefresh = 0;
|
||||
private Framebuffer framebuffer;
|
||||
|
||||
public ScreenCapture() {
|
||||
this.framebuffer = new Framebuffer(1, 1, true);
|
||||
this.framebuffer.setFramebufferColor(0.0F, 0.0F, 0.0F, 0.0F);
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||
}
|
||||
|
||||
protected int getGridRenderingCacheFPS(int mode) {
|
||||
return mode == 1 ? NEIClientConfig.getIntSetting("inventory.gridRenderingCacheFPS") : 0;
|
||||
}
|
||||
|
||||
public boolean needRefresh(int mode) {
|
||||
return this.nextCacheRefresh == 0
|
||||
|| getGridRenderingCacheFPS(mode) > 0 && this.nextCacheRefresh < System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void refreshBuffer() {
|
||||
this.nextCacheRefresh = 0;
|
||||
}
|
||||
|
||||
public void captureScreen(Runnable callback, int mode) {
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
|
||||
resetFramebuffer();
|
||||
this.framebuffer.bindFramebuffer(false);
|
||||
|
||||
/* Set up some rendering state needed for items to work correctly */
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(true);
|
||||
OpenGlHelper.glBlendFunc(
|
||||
GL11.GL_SRC_ALPHA,
|
||||
GL11.GL_ONE_MINUS_SRC_ALPHA,
|
||||
GL11.GL_SRC_ALPHA,
|
||||
GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
callback.run();
|
||||
|
||||
GL11.glPopAttrib();
|
||||
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||
this.nextCacheRefresh = System.currentTimeMillis() + (1000 / Math.max(1, getGridRenderingCacheFPS(mode)));
|
||||
}
|
||||
|
||||
private void resetFramebuffer() {
|
||||
final Minecraft minecraft = Minecraft.getMinecraft();
|
||||
|
||||
if (this.framebuffer.framebufferWidth != minecraft.displayWidth
|
||||
|| framebuffer.framebufferHeight != minecraft.displayHeight) {
|
||||
this.framebuffer.createBindFramebuffer(minecraft.displayWidth, minecraft.displayHeight);
|
||||
this.framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
|
||||
} else {
|
||||
this.framebuffer.framebufferClear();
|
||||
}
|
||||
|
||||
// copy depth buffer from MC (fix Angelica)
|
||||
OpenGlHelper.func_153171_g(GL30.GL_READ_FRAMEBUFFER, minecraft.getFramebuffer().framebufferObject);
|
||||
OpenGlHelper.func_153171_g(GL30.GL_DRAW_FRAMEBUFFER, this.framebuffer.framebufferObject);
|
||||
GL30.glBlitFramebuffer(
|
||||
0,
|
||||
0,
|
||||
minecraft.displayWidth,
|
||||
minecraft.displayHeight,
|
||||
0,
|
||||
0,
|
||||
minecraft.displayWidth,
|
||||
minecraft.displayHeight,
|
||||
GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT,
|
||||
GL11.GL_NEAREST);
|
||||
}
|
||||
|
||||
public void renderCapturedScreen() {
|
||||
this.framebuffer.bindFramebufferTexture();
|
||||
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
final Minecraft minecraft = Minecraft.getMinecraft();
|
||||
final ScaledResolution scaledresolution = new ScaledResolution(
|
||||
minecraft,
|
||||
minecraft.displayWidth,
|
||||
minecraft.displayHeight);
|
||||
|
||||
/* Set up some rendering state needed for items to work correctly */
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper
|
||||
.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
tessellator.addVertexWithUV(0, scaledresolution.getScaledHeight_double(), 0.0, 0, 0);
|
||||
tessellator.addVertexWithUV(
|
||||
scaledresolution.getScaledWidth_double(),
|
||||
scaledresolution.getScaledHeight_double(),
|
||||
0.0,
|
||||
1,
|
||||
0);
|
||||
tessellator.addVertexWithUV(scaledresolution.getScaledWidth_double(), 0, 0.0, 1, 1);
|
||||
tessellator.addVertexWithUV(0, 0, 0, 0, 1);
|
||||
|
||||
tessellator.draw();
|
||||
|
||||
this.framebuffer.unbindFramebufferTexture();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final int SLOT_SIZE = 18;
|
||||
|
||||
protected int width;
|
||||
@@ -49,10 +161,7 @@ public class ItemsGrid {
|
||||
|
||||
protected Label messageLabel = new Label(getMessageOnEmpty(), true);
|
||||
|
||||
@Nullable
|
||||
private Framebuffer framebuffer = null;
|
||||
|
||||
protected boolean refreshBuffer = true;
|
||||
protected ScreenCapture screenCapture = null;
|
||||
|
||||
public ArrayList<ItemStack> getItems() {
|
||||
return realItems;
|
||||
@@ -156,7 +265,9 @@ public class ItemsGrid {
|
||||
}
|
||||
|
||||
protected void onGridChanged() {
|
||||
refreshBuffer = true;
|
||||
if (this.screenCapture != null) {
|
||||
this.screenCapture.refreshBuffer();
|
||||
}
|
||||
this.gridMask = null;
|
||||
}
|
||||
|
||||
@@ -284,34 +395,6 @@ public class ItemsGrid {
|
||||
|
||||
protected void afterDrawSlot(@Nullable ItemPanelSlot focused, int slotIdx, Rectangle4i rect) {}
|
||||
|
||||
private void blitExistingBuffer() {
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
getFrameBuffer().bindFramebufferTexture();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
ScaledResolution res = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(0, res.getScaledHeight_double(), 0.0, 0, 0);
|
||||
tessellator.addVertexWithUV(res.getScaledWidth_double(), res.getScaledHeight_double(), 0.0, 1, 0);
|
||||
tessellator.addVertexWithUV(res.getScaledWidth_double(), 0, 0.0, 1, 1);
|
||||
tessellator.addVertexWithUV(0, 0, 0, 0, 1);
|
||||
tessellator.draw();
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
}
|
||||
|
||||
private Framebuffer getFrameBuffer() {
|
||||
|
||||
if (framebuffer == null) {
|
||||
framebuffer = new Framebuffer(1, 1, true);
|
||||
framebuffer.setFramebufferColor(0.0F, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
return framebuffer;
|
||||
}
|
||||
|
||||
private void drawItems() {
|
||||
GuiContainerManager.enableMatrixStackLogging();
|
||||
|
||||
@@ -325,8 +408,8 @@ public class ItemsGrid {
|
||||
GuiContainerManager.disableMatrixStackLogging();
|
||||
}
|
||||
|
||||
protected boolean shouldCacheItemRendering() {
|
||||
return NEIClientConfig.shouldCacheItemRendering();
|
||||
protected int getGridRenderingCacheMode() {
|
||||
return NEIClientConfig.getGridRenderingCacheMode();
|
||||
}
|
||||
|
||||
public void draw(int mousex, int mousey) {
|
||||
@@ -335,36 +418,22 @@ public class ItemsGrid {
|
||||
}
|
||||
|
||||
final ItemPanelSlot focused = getSlotMouseOver(mousex, mousey);
|
||||
final int gridRenderingCacheMode = getGridRenderingCacheMode();
|
||||
|
||||
if (shouldCacheItemRendering()) {
|
||||
beforeDrawItems(mousex, mousey, focused);
|
||||
|
||||
if (refreshBuffer) {
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
Framebuffer framebuffer = getFrameBuffer();
|
||||
framebuffer.createBindFramebuffer(minecraft.displayWidth, minecraft.displayHeight);
|
||||
framebuffer.framebufferClear();
|
||||
framebuffer.bindFramebuffer(false);
|
||||
if (gridRenderingCacheMode > 0) {
|
||||
|
||||
/* Set up some rendering state needed for items to work correctly */
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(true);
|
||||
OpenGlHelper.glBlendFunc(
|
||||
GL11.GL_SRC_ALPHA,
|
||||
GL11.GL_ONE_MINUS_SRC_ALPHA,
|
||||
GL11.GL_SRC_ALPHA,
|
||||
GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
drawItems();
|
||||
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||
refreshBuffer = false;
|
||||
if (this.screenCapture == null) {
|
||||
this.screenCapture = new ScreenCapture();
|
||||
}
|
||||
|
||||
beforeDrawItems(mousex, mousey, focused);
|
||||
blitExistingBuffer();
|
||||
if (this.screenCapture.needRefresh(gridRenderingCacheMode)) {
|
||||
this.screenCapture.captureScreen(this::drawItems, gridRenderingCacheMode);
|
||||
}
|
||||
|
||||
this.screenCapture.renderCapturedScreen();
|
||||
} else {
|
||||
beforeDrawItems(mousex, mousey, focused);
|
||||
drawItems();
|
||||
}
|
||||
|
||||
@@ -386,8 +455,8 @@ public class ItemsGrid {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int overRow = (int) ((mousey - marginTop) / SLOT_SIZE);
|
||||
final int overColumn = (int) ((mousex - marginLeft - paddingLeft) / SLOT_SIZE);
|
||||
final int overRow = (mousey - marginTop) / SLOT_SIZE;
|
||||
final int overColumn = (mousex - marginLeft - paddingLeft) / SLOT_SIZE;
|
||||
final int slt = columns * overRow + overColumn;
|
||||
|
||||
if (overRow >= rows || overColumn >= columns) {
|
||||
@@ -416,8 +485,8 @@ public class ItemsGrid {
|
||||
return false;
|
||||
}
|
||||
|
||||
final int r = (int) ((py - marginTop) / SLOT_SIZE);
|
||||
final int c = (int) ((px - marginLeft - paddingLeft) / SLOT_SIZE);
|
||||
final int r = (py - marginTop) / SLOT_SIZE;
|
||||
final int c = (px - marginLeft - paddingLeft) / SLOT_SIZE;
|
||||
|
||||
return !isInvalidSlot(columns * r + c);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import static codechicken.nei.NEIClientConfig.invCreativeMode;
|
||||
import static codechicken.nei.NEIClientConfig.isBookmarkPanelHidden;
|
||||
import static codechicken.nei.NEIClientConfig.isEnabled;
|
||||
import static codechicken.nei.NEIClientConfig.isHidden;
|
||||
import static codechicken.nei.NEIClientConfig.isLoaded;
|
||||
import static codechicken.nei.NEIClientConfig.showIDs;
|
||||
import static codechicken.nei.NEIClientConfig.toggleBooleanSetting;
|
||||
import static codechicken.nei.NEIClientUtils.cycleGamemode;
|
||||
@@ -32,10 +31,11 @@ import static codechicken.nei.NEIClientUtils.toggleMagnetMode;
|
||||
import static codechicken.nei.NEIClientUtils.toggleRaining;
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -79,13 +79,11 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
/**
|
||||
* Sorted bottom first
|
||||
*/
|
||||
private static TreeSet<Widget> drawWidgets = new TreeSet<>(new WidgetZOrder(false));
|
||||
private static Set<Widget> drawWidgets = new TreeSet<>(new WidgetZOrder(false));
|
||||
/**
|
||||
* Sorted top first
|
||||
*/
|
||||
private static TreeSet<Widget> controlWidgets = new TreeSet<>(new WidgetZOrder(true));
|
||||
|
||||
private static List<IContainerTooltipHandler> tooltipWidgets = new LinkedList<>();
|
||||
private static Set<Widget> controlWidgets = new TreeSet<>(new WidgetZOrder(true));
|
||||
|
||||
public static ItemPanel itemPanel;
|
||||
public static BookmarkPanel bookmarkPanel;
|
||||
@@ -96,13 +94,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public static ButtonCycled options;
|
||||
public static ButtonCycled bookmarksButton;
|
||||
|
||||
@Deprecated
|
||||
public static Button more;
|
||||
|
||||
@Deprecated
|
||||
public static Button less;
|
||||
|
||||
@Deprecated
|
||||
public static ItemQuantityField quantity;
|
||||
|
||||
public static Button delete;
|
||||
@@ -150,8 +143,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
gui.guiTop = (gui.height - gui.ySize) / 2;
|
||||
|
||||
if (gui instanceof GuiContainerCreative && gui.buttonList.size() >= 2) {
|
||||
GuiButton button1 = (GuiButton) gui.buttonList.get(0);
|
||||
GuiButton button2 = (GuiButton) gui.buttonList.get(1);
|
||||
GuiButton button1 = gui.buttonList.get(0);
|
||||
GuiButton button2 = gui.buttonList.get(1);
|
||||
button1.xPosition = gui.guiLeft;
|
||||
button2.xPosition = gui.guiLeft + gui.xSize - 20;
|
||||
}
|
||||
@@ -172,14 +165,18 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
if (isHidden()) return;
|
||||
|
||||
for (Widget widget : controlWidgets) widget.onGuiClick(mousex, mousey);
|
||||
for (Widget widget : controlWidgets) {
|
||||
widget.onGuiClick(mousex, mousey);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
if (isHidden()) return false;
|
||||
|
||||
if (!isEnabled()) return options.contains(mousex, mousey) && options.handleClick(mousex, mousey, button);
|
||||
if (!isEnabled()) {
|
||||
return options.contains(mousex, mousey) && options.handleClick(mousex, mousey, button);
|
||||
}
|
||||
|
||||
for (Widget widget : controlWidgets) {
|
||||
widget.onGuiClick(mousex, mousey);
|
||||
@@ -193,10 +190,22 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
|
||||
@Override
|
||||
public boolean objectUnderMouse(GuiContainer gui, int mousex, int mousey) {
|
||||
if (!isHidden() && isEnabled())
|
||||
for (Widget widget : drawWidgets) if (widget.contains(mousex, mousey)) return true;
|
||||
return getWidgetUnderMouse(mousex, mousey) != null;
|
||||
}
|
||||
|
||||
return false;
|
||||
public Widget getWidgetUnderMouse(int mousex, int mousey) {
|
||||
|
||||
if (isHidden() || !isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Widget widget : controlWidgets) {
|
||||
if (widget.contains(mousex, mousey)) {
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
@@ -252,12 +261,12 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
|
||||
@Override
|
||||
public ItemStack getStackUnderMouse(GuiContainer gui, int mousex, int mousey) {
|
||||
if (!isHidden() && isEnabled()) {
|
||||
for (Widget widget : drawWidgets) {
|
||||
ItemStack stack = widget.getStackMouseOver(mousex, mousey);
|
||||
if (stack != null) return stack;
|
||||
}
|
||||
final Widget focused = getWidgetUnderMouse(mousex, mousey);
|
||||
|
||||
if (focused != null) {
|
||||
return focused.getStackMouseOver(mousex, mousey);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -286,18 +295,32 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
|
||||
@Override
|
||||
public void postRenderTooltips(GuiContainer gui, int mousex, int mousey, List<String> tooltip) {
|
||||
|
||||
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
||||
for (Widget widget : drawWidgets) widget.postDrawTooltips(mousex, mousey, tooltip);
|
||||
final Widget focused = getWidgetUnderMouse(mousex, mousey);
|
||||
|
||||
if (focused != null) {
|
||||
focused.postDrawTooltips(mousex, mousey, tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
|
||||
|
||||
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
||||
for (Widget widget : drawWidgets) currenttip = widget.handleTooltip(mousex, mousey, currenttip);
|
||||
for (IContainerTooltipHandler tip : tooltipWidgets)
|
||||
currenttip = tip.handleTooltip(gui, mousex, mousey, currenttip);
|
||||
final Widget focused = getWidgetUnderMouse(mousex, mousey);
|
||||
|
||||
if (focused != null) {
|
||||
currenttip = focused.handleTooltip(mousex, mousey, currenttip);
|
||||
|
||||
if (focused instanceof IContainerTooltipHandler tip) {
|
||||
currenttip = tip.handleTooltip(gui, mousex, mousey, currenttip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@@ -315,8 +338,12 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
}
|
||||
|
||||
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
||||
for (IContainerTooltipHandler tip : tooltipWidgets)
|
||||
final Point mouse = GuiDraw.getMousePosition();
|
||||
final Widget focused = getWidgetUnderMouse(mouse.x, mouse.y);
|
||||
|
||||
if (focused instanceof IContainerTooltipHandler tip) {
|
||||
currenttip = tip.handleItemDisplayName(gui, stack, currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
@@ -327,8 +354,11 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
List<String> currenttip) {
|
||||
|
||||
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
||||
for (IContainerTooltipHandler tip : tooltipWidgets)
|
||||
final Widget focused = getWidgetUnderMouse(mousex, mousey);
|
||||
|
||||
if (focused instanceof IContainerTooltipHandler tip) {
|
||||
currenttip = tip.handleItemTooltip(gui, itemstack, mousex, mousey, currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
@@ -338,8 +368,11 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public Map<String, String> handleHotkeys(GuiContainer gui, int mousex, int mousey, Map<String, String> hotkeys) {
|
||||
|
||||
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
||||
for (IContainerTooltipHandler tip : tooltipWidgets)
|
||||
final Widget focused = getWidgetUnderMouse(mousex, mousey);
|
||||
|
||||
if (focused instanceof IContainerTooltipHandler tip) {
|
||||
hotkeys = tip.handleHotkeys(gui, mousex, mousey, hotkeys);
|
||||
}
|
||||
}
|
||||
|
||||
return hotkeys;
|
||||
@@ -347,17 +380,12 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
|
||||
public static void layout(GuiContainer gui) {
|
||||
VisiblityData visiblity = new VisiblityData();
|
||||
|
||||
if (isHidden()) visiblity.showNEI = false;
|
||||
|
||||
if (isBookmarkPanelHidden()) visiblity.showBookmarkPanel = false;
|
||||
|
||||
if (gui.height - gui.ySize <= 40 && NEIClientConfig.isSearchWidgetCentered())
|
||||
visiblity.showSearchSection = false;
|
||||
|
||||
if (visiblity.showBookmarkPanel || gui.guiTop <= 20) visiblity.showSubsetDropdown = false;
|
||||
|
||||
if (gui.guiLeft - 4 < 76) visiblity.showWidgets = false;
|
||||
visiblity.showNEI = !isHidden();
|
||||
visiblity.showBookmarkPanel = !isBookmarkPanelHidden();
|
||||
visiblity.showSearchSection = !(gui.height - gui.ySize <= 40 && NEIClientConfig.isSearchWidgetCentered());
|
||||
visiblity.showSubsetDropdown = NEIClientConfig.showSubsetWidget()
|
||||
&& (gui.guiTop > 20 || visiblity.showSearchSection && !NEIClientConfig.subsetWidgetOnTop());
|
||||
visiblity.showWidgets = gui.guiLeft - 4 > 76;
|
||||
|
||||
try {
|
||||
GuiInfo.readLock.lock();
|
||||
@@ -467,9 +495,43 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
}
|
||||
};
|
||||
|
||||
more = ItemPanels.itemPanel.more;
|
||||
less = ItemPanels.itemPanel.less;
|
||||
quantity = ItemPanels.itemPanel.quantity;
|
||||
more = new Button("+") {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (rightclick) return false;
|
||||
|
||||
int modifier = NEIClientUtils.controlKey() ? 64 : NEIClientUtils.shiftKey() ? 10 : 1;
|
||||
int quantity = NEIClientConfig.getItemQuantity() + modifier;
|
||||
|
||||
if (quantity < 0) {
|
||||
quantity = 0;
|
||||
}
|
||||
|
||||
LayoutManager.quantity.setText(Integer.toString(quantity));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
less = new Button("-") {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (rightclick) return false;
|
||||
|
||||
int modifier = NEIClientUtils.controlKey() ? -64 : NEIClientUtils.shiftKey() ? -10 : -1;
|
||||
int quantity = NEIClientConfig.getItemQuantity() + modifier;
|
||||
|
||||
if (quantity < 0) {
|
||||
quantity = 0;
|
||||
}
|
||||
|
||||
LayoutManager.quantity.setText(Integer.toString(quantity));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
quantity = new ItemQuantityField("quantity");
|
||||
|
||||
delete = new Button() {
|
||||
|
||||
@Override
|
||||
@@ -643,7 +705,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
if (isEnabled()) {
|
||||
setInputFocused(null);
|
||||
|
||||
if (!itemsLoaded && isLoaded()) {
|
||||
if (!itemsLoaded) {
|
||||
ItemList.loadItems.restart();
|
||||
}
|
||||
|
||||
@@ -677,12 +739,18 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public static void updateWidgetVisiblities(GuiContainer gui, VisiblityData visiblity) {
|
||||
drawWidgets = new TreeSet<>(new WidgetZOrder(false));
|
||||
controlWidgets = new TreeSet<>(new WidgetZOrder(true));
|
||||
tooltipWidgets.clear();
|
||||
|
||||
if (!visiblity.showNEI) return;
|
||||
|
||||
addWidget(options);
|
||||
addWidget(bookmarksButton);
|
||||
|
||||
if (visiblity.showItemPanel && NEIClientConfig.showItemQuantityWidget()) {
|
||||
addWidget(quantity);
|
||||
addWidget(more);
|
||||
addWidget(less);
|
||||
}
|
||||
|
||||
if (visiblity.showItemPanel) {
|
||||
addWidget(itemPanel);
|
||||
itemPanel.setVisible();
|
||||
@@ -693,9 +761,13 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
bookmarkPanel.setVisible();
|
||||
}
|
||||
|
||||
searchField.setVisible(visiblity.showSearchSection);
|
||||
if (visiblity.showSearchSection) {
|
||||
if (visiblity.showSearchSection && NEIClientConfig.isSearchWidgetCentered()
|
||||
|| visiblity.showItemPanel && !NEIClientConfig.isSearchWidgetCentered()) {
|
||||
searchField.setVisible(true);
|
||||
addWidget(searchField);
|
||||
} else {
|
||||
searchField.setVisible(false);
|
||||
searchField.setFocus(false);
|
||||
}
|
||||
|
||||
if (visiblity.showUtilityButtons) {
|
||||
@@ -731,10 +803,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public static void addWidget(Widget widget) {
|
||||
drawWidgets.add(widget);
|
||||
controlWidgets.add(widget);
|
||||
|
||||
if (widget instanceof IContainerTooltipHandler) {
|
||||
tooltipWidgets.add((IContainerTooltipHandler) widget);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -750,7 +818,9 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
if (isHidden() || !isEnabled()) return false;
|
||||
|
||||
for (Widget widget : drawWidgets) if (widget.onMouseWheel(scrolled, mousex, mousey)) return true;
|
||||
for (Widget widget : controlWidgets) {
|
||||
if (widget.onMouseWheel(scrolled, mousex, mousey)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,34 +1,20 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.drawStringC;
|
||||
import static codechicken.nei.LayoutManager.bookmarkPanel;
|
||||
import static codechicken.nei.LayoutManager.bookmarksButton;
|
||||
import static codechicken.nei.LayoutManager.delete;
|
||||
import static codechicken.nei.LayoutManager.dropDown;
|
||||
import static codechicken.nei.LayoutManager.gamemode;
|
||||
import static codechicken.nei.LayoutManager.heal;
|
||||
import static codechicken.nei.LayoutManager.itemPanel;
|
||||
import static codechicken.nei.LayoutManager.itemPresenceOverlays;
|
||||
import static codechicken.nei.LayoutManager.itemZoom;
|
||||
import static codechicken.nei.LayoutManager.magnet;
|
||||
import static codechicken.nei.LayoutManager.options;
|
||||
import static codechicken.nei.LayoutManager.rain;
|
||||
import static codechicken.nei.LayoutManager.searchField;
|
||||
import static codechicken.nei.LayoutManager.timeButtons;
|
||||
import static codechicken.nei.NEIClientConfig.canPerformAction;
|
||||
import static codechicken.nei.NEIClientConfig.disabledActions;
|
||||
import static codechicken.nei.NEIClientConfig.getMagnetMode;
|
||||
import static codechicken.nei.NEIClientConfig.isEnabled;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.api.LayoutStyle;
|
||||
import codechicken.nei.drawable.DrawableBuilder;
|
||||
|
||||
public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
|
||||
protected static final int BUTTON_SIZE = 20;
|
||||
protected static final int MARGIN = 2;
|
||||
|
||||
public int buttonCount;
|
||||
public int leftSize;
|
||||
public int numButtons;
|
||||
@@ -40,19 +26,21 @@ public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
delete.icon = new Image(144, 12, 12, 12);
|
||||
rain.icon = new Image(120, 12, 12, 12);
|
||||
gamemode.icons[0] = new Image(132, 12, 12, 12);
|
||||
gamemode.icons[1] = new Image(156, 12, 12, 12);
|
||||
gamemode.icons[2] = new Image(168, 12, 12, 12);
|
||||
magnet.icon = new Image(180, 24, 12, 12);
|
||||
timeButtons[0].icon = new Image(132, 24, 12, 12);
|
||||
timeButtons[1].icon = new Image(120, 24, 12, 12);
|
||||
timeButtons[2].icon = new Image(144, 24, 12, 12);
|
||||
timeButtons[3].icon = new Image(156, 24, 12, 12);
|
||||
heal.icon = new Image(168, 24, 12, 12);
|
||||
itemPresenceOverlays[0] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 0, 40, 8, 8).build();
|
||||
itemPresenceOverlays[1] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 8, 40, 8, 8).build();
|
||||
LayoutManager.delete.icon = new Image(144, 12, 12, 12);
|
||||
LayoutManager.rain.icon = new Image(120, 12, 12, 12);
|
||||
LayoutManager.gamemode.icons[0] = new Image(132, 12, 12, 12);
|
||||
LayoutManager.gamemode.icons[1] = new Image(156, 12, 12, 12);
|
||||
LayoutManager.gamemode.icons[2] = new Image(168, 12, 12, 12);
|
||||
LayoutManager.magnet.icon = new Image(180, 24, 12, 12);
|
||||
LayoutManager.timeButtons[0].icon = new Image(132, 24, 12, 12);
|
||||
LayoutManager.timeButtons[1].icon = new Image(120, 24, 12, 12);
|
||||
LayoutManager.timeButtons[2].icon = new Image(144, 24, 12, 12);
|
||||
LayoutManager.timeButtons[3].icon = new Image(156, 24, 12, 12);
|
||||
LayoutManager.heal.icon = new Image(168, 24, 12, 12);
|
||||
LayoutManager.itemPresenceOverlays[0] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 0, 40, 8, 8)
|
||||
.build();
|
||||
LayoutManager.itemPresenceOverlays[1] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 8, 40, 8, 8)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,85 +53,177 @@ public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
reset();
|
||||
|
||||
leftSize = ItemPanels.bookmarkPanel.getWidth(gui);
|
||||
numButtons = Math.max(leftSize / 18, 1);
|
||||
numButtons = Math.max(leftSize / 20, 1);
|
||||
|
||||
delete.state = 0x4;
|
||||
if (NEIController.getDeleteMode()) delete.state |= 1;
|
||||
else if (!visiblity.enableDeleteMode) delete.state |= 2;
|
||||
|
||||
rain.state = 0x4;
|
||||
if (disabledActions.contains("rain")) rain.state |= 2;
|
||||
else if (NEIClientUtils.isRaining()) rain.state |= 1;
|
||||
|
||||
gamemode.state = 0x4;
|
||||
if (NEIClientUtils.getGamemode() != 0) {
|
||||
gamemode.state |= 0x1;
|
||||
gamemode.index = NEIClientUtils.getGamemode() - 1;
|
||||
} else {
|
||||
if (NEIClientUtils.isValidGamemode("creative")) gamemode.index = 0;
|
||||
else if (NEIClientUtils.isValidGamemode("creative+")) gamemode.index = 1;
|
||||
else if (NEIClientUtils.isValidGamemode("adventure")) gamemode.index = 2;
|
||||
LayoutManager.delete.state = 0x4;
|
||||
if (NEIController.getDeleteMode()) {
|
||||
LayoutManager.delete.state |= 1;
|
||||
} else if (!visiblity.enableDeleteMode) {
|
||||
LayoutManager.delete.state |= 2;
|
||||
}
|
||||
bookmarksButton.index = NEIClientConfig.isBookmarkPanelHidden() ? 0 : 1;
|
||||
options.index = NEIClientConfig.getCheatMode();
|
||||
|
||||
magnet.state = 0x4 | (getMagnetMode() ? 1 : 0);
|
||||
LayoutManager.rain.state = 0x4;
|
||||
if (NEIClientConfig.disabledActions.contains("rain")) {
|
||||
LayoutManager.rain.state |= 2;
|
||||
} else if (NEIClientUtils.isRaining()) {
|
||||
LayoutManager.rain.state |= 1;
|
||||
}
|
||||
|
||||
if (canPerformAction("delete")) layoutButton(delete);
|
||||
if (canPerformAction("rain")) layoutButton(rain);
|
||||
if (NEIClientUtils.isValidGamemode("creative") || NEIClientUtils.isValidGamemode("creative+")
|
||||
|| NEIClientUtils.isValidGamemode("adventure"))
|
||||
layoutButton(gamemode);
|
||||
if (canPerformAction("magnet")) layoutButton(magnet);
|
||||
if (canPerformAction("time")) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
timeButtons[i].state = disabledActions.contains(NEIActions.timeZones[i]) ? 2 : 0;
|
||||
layoutButton(timeButtons[i]);
|
||||
LayoutManager.gamemode.state = 0x4;
|
||||
if (NEIClientUtils.getGamemode() != 0) {
|
||||
LayoutManager.gamemode.state |= 0x1;
|
||||
LayoutManager.gamemode.index = NEIClientUtils.getGamemode() - 1;
|
||||
} else {
|
||||
if (NEIClientUtils.isValidGamemode("creative")) {
|
||||
LayoutManager.gamemode.index = 0;
|
||||
} else if (NEIClientUtils.isValidGamemode("creative+")) {
|
||||
LayoutManager.gamemode.index = 1;
|
||||
} else if (NEIClientUtils.isValidGamemode("adventure")) {
|
||||
LayoutManager.gamemode.index = 2;
|
||||
}
|
||||
}
|
||||
if (canPerformAction("heal")) layoutButton(heal);
|
||||
LayoutManager.bookmarksButton.index = NEIClientConfig.isBookmarkPanelHidden() ? 0 : 1;
|
||||
LayoutManager.options.index = NEIClientConfig.getCheatMode();
|
||||
|
||||
itemPanel.resize(gui);
|
||||
bookmarkPanel.resize(gui);
|
||||
itemZoom.resize(gui);
|
||||
LayoutManager.magnet.state = 0x4 | (NEIClientConfig.getMagnetMode() ? 1 : 0);
|
||||
|
||||
options.x = isEnabled() ? 0 : 6;
|
||||
options.y = isEnabled() ? gui.height - 22 : gui.height - 28;
|
||||
options.w = 22;
|
||||
options.h = 22;
|
||||
if (NEIClientConfig.canPerformAction("delete")) {
|
||||
layoutButton(LayoutManager.delete);
|
||||
}
|
||||
|
||||
bookmarksButton.x = 24 + (isEnabled() ? 0 : 6);
|
||||
bookmarksButton.y = isEnabled() ? gui.height - 22 : gui.height - 28;
|
||||
bookmarksButton.w = 22;
|
||||
bookmarksButton.h = 22;
|
||||
if (NEIClientConfig.canPerformAction("rain")) {
|
||||
layoutButton(LayoutManager.rain);
|
||||
}
|
||||
|
||||
dropDown.h = 18;
|
||||
dropDown.w = 150;
|
||||
dropDown.y = 0;
|
||||
dropDown.x = (gui.width - gui.xSize) / 2 + gui.xSize - dropDown.w;
|
||||
if (NEIClientUtils.isValidGamemode("creative") || NEIClientUtils.isValidGamemode("creative+")
|
||||
|| NEIClientUtils.isValidGamemode("adventure")) {
|
||||
layoutButton(LayoutManager.gamemode);
|
||||
}
|
||||
|
||||
searchField.h = 20;
|
||||
if (NEIClientConfig.isSearchWidgetCentered()) {
|
||||
searchField.w = 150;
|
||||
searchField.x = (gui.width - searchField.w) / 2;
|
||||
if (NEIClientConfig.canPerformAction("magnet")) {
|
||||
layoutButton(LayoutManager.magnet);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.canPerformAction("time")) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
LayoutManager.timeButtons[i].state = NEIClientConfig.disabledActions.contains(NEIActions.timeZones[i])
|
||||
? 2
|
||||
: 0;
|
||||
layoutButton(LayoutManager.timeButtons[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (NEIClientConfig.canPerformAction("heal")) {
|
||||
layoutButton(LayoutManager.heal);
|
||||
}
|
||||
|
||||
layoutFooter(gui, visiblity);
|
||||
|
||||
LayoutManager.itemPanel.resize(gui);
|
||||
LayoutManager.bookmarkPanel.resize(gui);
|
||||
LayoutManager.itemZoom.resize(gui);
|
||||
}
|
||||
|
||||
protected void layoutFooter(GuiContainer gui, VisiblityData visiblity) {
|
||||
|
||||
LayoutManager.options.x = MARGIN;
|
||||
LayoutManager.options.y = gui.height - BUTTON_SIZE - MARGIN;
|
||||
LayoutManager.options.w = LayoutManager.options.h = BUTTON_SIZE;
|
||||
|
||||
LayoutManager.bookmarksButton.x = LayoutManager.options.x + LayoutManager.options.w + MARGIN;
|
||||
LayoutManager.bookmarksButton.y = gui.height - BUTTON_SIZE - MARGIN;
|
||||
LayoutManager.bookmarksButton.w = LayoutManager.bookmarksButton.h = BUTTON_SIZE;
|
||||
|
||||
final Rectangle4i searchArea = getSearchFieldArea(gui);
|
||||
final Rectangle4i quantityArea = getQuantityFieldArea(visiblity);
|
||||
|
||||
LayoutManager.searchField.x = searchArea.x;
|
||||
LayoutManager.searchField.y = searchArea.y;
|
||||
LayoutManager.searchField.w = searchArea.w;
|
||||
LayoutManager.searchField.h = searchArea.h;
|
||||
|
||||
if (!NEIClientConfig.subsetWidgetOnTop() && visiblity.showSubsetDropdown) {
|
||||
LayoutManager.dropDown.x = searchArea.x;
|
||||
LayoutManager.dropDown.y = searchArea.y;
|
||||
LayoutManager.dropDown.h = LayoutManager.dropDown.w = BUTTON_SIZE;
|
||||
|
||||
LayoutManager.searchField.x += BUTTON_SIZE;
|
||||
LayoutManager.searchField.w -= BUTTON_SIZE;
|
||||
} else {
|
||||
searchField.w = (int) (itemPanel.w * (NEIClientConfig.showItemQuantityWidget() ? 0.7 : 1));
|
||||
searchField.x = itemPanel.x;
|
||||
LayoutManager.dropDown.h = 16;
|
||||
LayoutManager.dropDown.w = 150;
|
||||
LayoutManager.dropDown.y = MARGIN;
|
||||
LayoutManager.dropDown.x = (gui.width - LayoutManager.dropDown.w) / 2;
|
||||
}
|
||||
searchField.y = gui.height - searchField.h - 2;
|
||||
|
||||
if (!visiblity.showItemSection) {
|
||||
searchField.setFocus(false);
|
||||
if (quantityArea.w == ItemPanels.itemPanel.w) {
|
||||
LayoutManager.more.w = LayoutManager.less.w = BUTTON_SIZE;
|
||||
LayoutManager.more.h = LayoutManager.less.h = LayoutManager.quantity.h = quantityArea.h;
|
||||
LayoutManager.more.y = LayoutManager.less.y = LayoutManager.quantity.y = quantityArea.y;
|
||||
|
||||
LayoutManager.less.x = quantityArea.x;
|
||||
LayoutManager.more.x = quantityArea.x2() - BUTTON_SIZE;
|
||||
|
||||
LayoutManager.quantity.x = LayoutManager.less.x + LayoutManager.less.w + 1;
|
||||
LayoutManager.quantity.w = LayoutManager.more.x - LayoutManager.quantity.x - 1;
|
||||
} else {
|
||||
LayoutManager.quantity.x = quantityArea.x;
|
||||
LayoutManager.quantity.w = quantityArea.w - 18;
|
||||
LayoutManager.quantity.y = LayoutManager.more.y = quantityArea.y;
|
||||
LayoutManager.quantity.h = quantityArea.h;
|
||||
|
||||
LayoutManager.more.w = LayoutManager.less.w = 18;
|
||||
LayoutManager.more.x = LayoutManager.less.x = LayoutManager.quantity.x + LayoutManager.quantity.w;
|
||||
LayoutManager.more.h = LayoutManager.less.h = LayoutManager.quantity.h / 2;
|
||||
LayoutManager.less.y = LayoutManager.more.y + LayoutManager.more.h;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Rectangle4i getSearchFieldArea(GuiContainer gui) {
|
||||
final Rectangle4i area = new Rectangle4i(0, 0, 0, BUTTON_SIZE);
|
||||
|
||||
if (NEIClientConfig.isSearchWidgetCentered()) {
|
||||
area.w = gui.xSize - MARGIN * 2;
|
||||
area.x = (gui.width - area.w) / 2;
|
||||
area.y = gui.height - BUTTON_SIZE - MARGIN;
|
||||
} else if (NEIClientConfig.showItemQuantityWidget()) {
|
||||
area.w = ItemPanels.itemPanel.w - (int) Math.max(BUTTON_SIZE * 2.5f, ItemPanels.itemPanel.w * 0.3f) - 1;
|
||||
area.x = ItemPanels.itemPanel.x;
|
||||
area.y = ItemPanels.itemPanel.y + ItemPanels.itemPanel.h - BUTTON_SIZE;
|
||||
} else {
|
||||
area.w = ItemPanels.itemPanel.w;
|
||||
area.x = ItemPanels.itemPanel.x;
|
||||
area.y = ItemPanels.itemPanel.y + ItemPanels.itemPanel.h - BUTTON_SIZE;
|
||||
}
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
private Rectangle4i getQuantityFieldArea(VisiblityData visiblity) {
|
||||
final Rectangle4i area = new Rectangle4i(0, 0, 0, BUTTON_SIZE);
|
||||
|
||||
if (!visiblity.showSearchSection || NEIClientConfig.isSearchWidgetCentered()) {
|
||||
area.w = ItemPanels.itemPanel.w;
|
||||
area.x = ItemPanels.itemPanel.x;
|
||||
} else {
|
||||
area.w = (int) Math.max(BUTTON_SIZE * 2.5f, ItemPanels.itemPanel.w * 0.3f);
|
||||
area.x = ItemPanels.itemPanel.x + ItemPanels.itemPanel.w - area.w;
|
||||
}
|
||||
|
||||
area.y = ItemPanels.itemPanel.y + ItemPanels.itemPanel.h - BUTTON_SIZE;
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
public void layoutButton(Button button) {
|
||||
button.x = 2 + (buttonCount % numButtons) * 19;
|
||||
button.y = 2 + (buttonCount / numButtons) * 18;
|
||||
|
||||
button.h = 17;
|
||||
button.w = button.contentWidth() + 6;
|
||||
|
||||
button.x = MARGIN + (buttonCount % numButtons) * (button.w + MARGIN);
|
||||
button.y = MARGIN + (buttonCount / numButtons) * (button.h + MARGIN);
|
||||
|
||||
buttonCount++;
|
||||
}
|
||||
|
||||
@@ -177,9 +257,16 @@ public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
|
||||
@Override
|
||||
public void drawSubsetTag(String text, int x, int y, int w, int h, int state, boolean mouseover) {
|
||||
if (state == 1) GL11.glColor4f(0.65F, 0.65F, 0.65F, 1.0F);
|
||||
else GL11.glColor4f(1, 1, 1, 1);
|
||||
if (state == 1) {
|
||||
GL11.glColor4f(0.65F, 0.65F, 0.65F, 1.0F);
|
||||
} else {
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
LayoutManager.drawButtonBackground(x, y, w, h, false, state == 0 ? 0 : 1);
|
||||
if (text != null) drawStringC(text, x, y, w, h, state == 2 ? 0xFFE0E0E0 : 0xFFA0A0A0);
|
||||
|
||||
if (text != null) {
|
||||
drawStringC(text, x, y, w, h, mouseover ? 0xFFFFFFA0 : (state == 2 ? 0xFFE0E0E0 : 0xFFA0A0A0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -233,6 +233,12 @@ public class NEIClientConfig {
|
||||
.setComment("Require holding shift to move items when overlaying recipe").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.shiftOverlayRecipe", true));
|
||||
|
||||
tag.getTag("inventory.subsets.enabled").setComment("Enable/disable Subsets Dropdown").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.subsets.enabled", true));
|
||||
|
||||
tag.getTag("inventory.subsets.widgetPosition").setComment("Subsets Widget Position").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.subsets.widgetPosition", true));
|
||||
|
||||
tag.getTag("inventory.guirecipe.profile").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.profile", true));
|
||||
|
||||
@@ -353,8 +359,10 @@ public class NEIClientConfig {
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.cacheItemRendering").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.cacheItemRendering", true));
|
||||
tag.getTag("inventory.gridRenderingCacheFPS").getIntValue(8);
|
||||
|
||||
tag.getTag("inventory.gridRenderingCacheMode").getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.gridRenderingCacheMode", 3, true));
|
||||
|
||||
tag.getTag("itemLoadingTimeout").getIntValue(500);
|
||||
|
||||
@@ -715,25 +723,21 @@ public class NEIClientConfig {
|
||||
|
||||
public static void loadWorld(String worldPath) {
|
||||
unloadWorld();
|
||||
NEIClientConfig.worldPath = worldPath;
|
||||
|
||||
setInternalEnabled(true);
|
||||
logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");
|
||||
|
||||
if (!worldPath.equals(NEIClientConfig.worldPath)) {
|
||||
NEIClientConfig.worldPath = worldPath;
|
||||
final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
|
||||
final boolean newWorld = !specificDir.exists();
|
||||
|
||||
logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");
|
||||
|
||||
final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
|
||||
final boolean newWorld = !specificDir.exists();
|
||||
|
||||
if (newWorld) {
|
||||
specificDir.mkdirs();
|
||||
}
|
||||
|
||||
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
|
||||
bootNEI(ClientUtils.getWorld());
|
||||
onWorldLoad(newWorld);
|
||||
ItemPanels.bookmarkPanel.load();
|
||||
if (newWorld) {
|
||||
specificDir.mkdirs();
|
||||
}
|
||||
|
||||
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
|
||||
bootNEI(ClientUtils.getWorld());
|
||||
onWorldLoad(newWorld);
|
||||
}
|
||||
|
||||
public static String getWorldPath() {
|
||||
@@ -747,10 +751,12 @@ public class NEIClientConfig {
|
||||
setWorldDefaults();
|
||||
creativeInv = new ItemStack[54];
|
||||
LayoutManager.searchField.setText(getSearchExpression());
|
||||
ItemPanels.itemPanel.quantity.setText(Integer.toString(getItemQuantity()));
|
||||
LayoutManager.quantity.setText(Integer.toString(getItemQuantity()));
|
||||
|
||||
if (newWorld && Minecraft.getMinecraft().isSingleplayer()) world.config.getTag("inventory.cheatmode")
|
||||
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
|
||||
if (newWorld && Minecraft.getMinecraft().isSingleplayer()) {
|
||||
world.config.getTag("inventory.cheatmode")
|
||||
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
|
||||
}
|
||||
|
||||
NEIInfo.load(ClientUtils.getWorld());
|
||||
}
|
||||
@@ -769,6 +775,7 @@ public class NEIClientConfig {
|
||||
ItemPanels.bookmarkPanel.saveBookmarks();
|
||||
}
|
||||
|
||||
SubsetWidget.saveHidden();
|
||||
CollapsibleItems.saveStates();
|
||||
|
||||
if (world != null) {
|
||||
@@ -831,8 +838,9 @@ public class NEIClientConfig {
|
||||
});
|
||||
|
||||
RecipeCatalysts.loadCatalystInfo();
|
||||
CollapsibleItems.load();
|
||||
ItemPanels.bookmarkPanel.load();
|
||||
SubsetWidget.loadHidden();
|
||||
CollapsibleItems.load();
|
||||
ItemSorter.loadConfig();
|
||||
|
||||
// Set pluginNEIConfigLoaded here before posting the NEIConfigsLoadedEvent. This used to be the
|
||||
@@ -846,6 +854,10 @@ public class NEIClientConfig {
|
||||
ItemList.loadItems.restart();
|
||||
}
|
||||
}.start();
|
||||
} else {
|
||||
ItemPanels.bookmarkPanel.load();
|
||||
SubsetWidget.loadHidden();
|
||||
ItemList.loadItems.restart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,6 +907,14 @@ public class NEIClientConfig {
|
||||
return getBooleanSetting("inventory.search.widgetPosition");
|
||||
}
|
||||
|
||||
public static boolean showSubsetWidget() {
|
||||
return getBooleanSetting("inventory.subsets.enabled");
|
||||
}
|
||||
|
||||
public static boolean subsetWidgetOnTop() {
|
||||
return getBooleanSetting("inventory.subsets.widgetPosition");
|
||||
}
|
||||
|
||||
public static int searchWidgetAutofocus() {
|
||||
return getIntSetting("inventory.search.widgetAutofocus");
|
||||
}
|
||||
@@ -1043,8 +1063,8 @@ public class NEIClientConfig {
|
||||
return getBooleanSetting("inventory.history.enabled");
|
||||
}
|
||||
|
||||
public static boolean shouldCacheItemRendering() {
|
||||
return getBooleanSetting("inventory.cacheItemRendering") && OpenGlHelper.framebufferSupported;
|
||||
public static int getGridRenderingCacheMode() {
|
||||
return OpenGlHelper.framebufferSupported ? getIntSetting("inventory.gridRenderingCacheMode") : 0;
|
||||
}
|
||||
|
||||
public static boolean enableCollapsibleItems() {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -11,6 +11,6 @@ public class WidgetZOrder implements Comparator<Widget> {
|
||||
}
|
||||
|
||||
public int compare(Widget w1, Widget w2) {
|
||||
return w1.z != w2.z ? ((topfirst ? w1.z > w2.z : w1.z < w2.z) ? 1 : -1) : 1;
|
||||
return w1.z != w2.z ? ((topfirst ? w1.z < w2.z : w1.z > w2.z) ? 1 : -1) : 1;
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,6 @@ import com.google.common.collect.ArrayListMultimap;
|
||||
import codechicken.core.featurehack.GameDataManipulator;
|
||||
import codechicken.nei.InfiniteStackSizeHandler;
|
||||
import codechicken.nei.InfiniteToolHandler;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.ItemList.AnyMultiItemFilter;
|
||||
import codechicken.nei.ItemList.PatternItemFilter;
|
||||
import codechicken.nei.ItemMobSpawner;
|
||||
@@ -136,7 +135,6 @@ public class ItemInfo {
|
||||
addIDDumps();
|
||||
addSearchProviders();
|
||||
PresetsList.load();
|
||||
ItemList.loadCallbacks.add(TooltipFilter::populateSearchMap);
|
||||
}
|
||||
|
||||
private static void addSearchProviders() {
|
||||
|
||||
@@ -43,13 +43,12 @@ import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.ItemStackSet;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIModContainer;
|
||||
import codechicken.nei.SearchField;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.search.TooltipFilter;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
import codechicken.nei.util.RenderTooltipEventHelper;
|
||||
|
||||
@@ -60,8 +59,7 @@ public class GuiContainerManager {
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager p_110549_1_) {
|
||||
renderingErrorItems.clear();
|
||||
TooltipFilter.populateSearchMap();
|
||||
SearchField.searchParser.clearCache();
|
||||
ItemList.loadItems.restart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,9 +420,9 @@ public class GuiContainerManager {
|
||||
|
||||
public GuiContainerManager(GuiContainer screen) {
|
||||
window = screen;
|
||||
if (screen instanceof IContainerTooltipHandler) {
|
||||
if (screen instanceof IContainerTooltipHandler tooltipHandler) {
|
||||
instanceTooltipHandlers = Collections.synchronizedList(new LinkedList<>());
|
||||
instanceTooltipHandlers.add((IContainerTooltipHandler) screen);
|
||||
instanceTooltipHandlers.add(tooltipHandler);
|
||||
instanceTooltipHandlers.addAll(tooltipHandlers);
|
||||
} else instanceTooltipHandlers = tooltipHandlers;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
@@ -19,21 +18,19 @@ import codechicken.nei.ItemStackMap;
|
||||
import codechicken.nei.api.IStackStringifyHandler;
|
||||
import codechicken.nei.recipe.stackinfo.DefaultStackStringifyHandler;
|
||||
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
|
||||
import codechicken.nei.util.ItemStackKey;
|
||||
|
||||
public class StackInfo {
|
||||
|
||||
private static final FluidStack NULL_FLUID = new FluidStack(FluidRegistry.WATER, 0);
|
||||
public static final ArrayList<IStackStringifyHandler> stackStringifyHandlers = new ArrayList<>();
|
||||
private static final HashMap<String, HashMap<String, String[]>> guidfilters = new HashMap<>();
|
||||
private static final ItemStackMap<String> guidcache = new ItemStackMap<>();
|
||||
private static final LinkedHashMap<ItemStackKey, FluidStack> fluidcache = new LinkedHashMap<>() {
|
||||
private static final LinkedHashMap<ItemStack, FluidStack> fluidcache = new LinkedHashMap<>() {
|
||||
|
||||
private static final long serialVersionUID = 1042213947848622164L;
|
||||
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<ItemStackKey, FluidStack> eldest) {
|
||||
return size() > 200;
|
||||
protected boolean removeEldestEntry(Map.Entry<ItemStack, FluidStack> eldest) {
|
||||
return size() > 20;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -95,20 +92,19 @@ public class StackInfo {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static synchronized FluidStack getFluid(ItemStack stack) {
|
||||
ItemStackKey key = new ItemStackKey(stack);
|
||||
FluidStack fluid = fluidcache.get(key);
|
||||
public static FluidStack getFluid(ItemStack stack) {
|
||||
FluidStack fluid = fluidcache.get(stack);
|
||||
|
||||
if (fluid == null) {
|
||||
if (fluid == null && !fluidcache.containsKey(stack)) {
|
||||
|
||||
for (int i = stackStringifyHandlers.size() - 1; i >= 0 && fluid == null; i--) {
|
||||
fluid = stackStringifyHandlers.get(i).getFluid(stack);
|
||||
}
|
||||
|
||||
fluidcache.put(key, fluid == null ? NULL_FLUID : fluid);
|
||||
fluidcache.put(stack, fluid);
|
||||
}
|
||||
|
||||
return fluid == NULL_FLUID ? null : fluid;
|
||||
return fluid;
|
||||
}
|
||||
|
||||
public static boolean isFluidContainer(ItemStack stack) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.regex.Pattern;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.ItemStackMap;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
@@ -26,14 +25,18 @@ public class TooltipFilter implements ItemFilter {
|
||||
return pattern.matcher(getSearchTooltip(itemStack)).find();
|
||||
}
|
||||
|
||||
public static void populateSearchMap() {
|
||||
public static void clearCache() {
|
||||
itemSearchNames.clear();
|
||||
new Thread(
|
||||
() -> ItemList.items.parallelStream().forEach(TooltipFilter::getSearchTooltip),
|
||||
"NEI populate Tooltip Filter").start();
|
||||
}
|
||||
|
||||
protected static String getSearchTooltip(ItemStack stack) {
|
||||
public static void putItem(ItemStack stack) {
|
||||
String tooltip = getTooltip(stack.copy());
|
||||
synchronized (itemSearchNames) {
|
||||
itemSearchNames.put(stack, tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSearchTooltip(ItemStack stack) {
|
||||
String tooltip = itemSearchNames.get(stack);
|
||||
|
||||
if (tooltip == null) {
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package codechicken.nei.util;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemStackKey {
|
||||
|
||||
public final ItemStack stack;
|
||||
private int hashCode = 1;
|
||||
|
||||
public ItemStackKey(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
|
||||
if (this.stack != null) {
|
||||
this.hashCode = 31 * this.hashCode + stack.stackSize;
|
||||
this.hashCode = 31 * this.hashCode + Item.getIdFromItem(stack.getItem());
|
||||
this.hashCode = 31 * this.hashCode + stack.getItemDamage();
|
||||
this.hashCode = 31 * this.hashCode + (!stack.hasTagCompound() ? 0 : stack.getTagCompound().hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof ItemStackKey)) return false;
|
||||
return ItemStack.areItemStacksEqual(this.stack, ((ItemStackKey) o).stack);
|
||||
}
|
||||
}
|
||||
@@ -307,9 +307,10 @@ nei.options.inventory.disableMouseScrollTransfer.false=False
|
||||
nei.options.inventory.invertMouseScrollTransfer=Invert Mouse Wheel Transfer Direction
|
||||
nei.options.inventory.invertMouseScrollTransfer.true=True
|
||||
nei.options.inventory.invertMouseScrollTransfer.false=False
|
||||
nei.options.inventory.cacheItemRendering=Cache Item Rendering
|
||||
nei.options.inventory.cacheItemRendering.true=True
|
||||
nei.options.inventory.cacheItemRendering.false=False
|
||||
nei.options.inventory.gridRenderingCacheMode=Grid Rendering Cache Mode
|
||||
nei.options.inventory.gridRenderingCacheMode.0=Off
|
||||
nei.options.inventory.gridRenderingCacheMode.1=Low FPS
|
||||
nei.options.inventory.gridRenderingCacheMode.2=Freeze
|
||||
nei.options.inventory.collapsibleItems=Collapsible Items
|
||||
nei.options.inventory.collapsibleItems.enabled=Collapsible Items
|
||||
nei.options.inventory.collapsibleItems.enabled.true=Enabled
|
||||
@@ -330,6 +331,13 @@ nei.options.inventory.history.useRows=Rows
|
||||
nei.options.inventory.history.splittingMode=Splitting Mode
|
||||
nei.options.inventory.history.splittingMode.0=Background
|
||||
nei.options.inventory.history.splittingMode.1=Dotted Line
|
||||
nei.options.inventory.subsets=Subsets Widget
|
||||
nei.options.inventory.subsets.enabled=Subsets Visibility
|
||||
nei.options.inventory.subsets.enabled.true=Enabled
|
||||
nei.options.inventory.subsets.enabled.false=Disabled
|
||||
nei.options.inventory.subsets.widgetPosition=Widget Position
|
||||
nei.options.inventory.subsets.widgetPosition.true=Top
|
||||
nei.options.inventory.subsets.widgetPosition.false=Bottom
|
||||
nei.options.inventory.itemzoom=Item Zoom Panel
|
||||
nei.options.inventory.itemzoom.enabled=Item Zoom Panel Visibility
|
||||
nei.options.inventory.itemzoom.enabled.true=Enabled
|
||||
@@ -452,6 +460,23 @@ nei.itemsort.default.tip=Leave the natural ordering of each item unchanged
|
||||
nei.itemsort.damage=Item Damage
|
||||
nei.itemsort.name=Display Name
|
||||
|
||||
nei.subsets.item.cheat=Give out an Item
|
||||
nei.subsets.item.cheat.key=Ctrl + LMB
|
||||
nei.subsets.item.search=Search by Item
|
||||
nei.subsets.item.search.key=Shift + LMB
|
||||
nei.subsets.item.show=Show Item
|
||||
nei.subsets.item.show.key=LMB
|
||||
nei.subsets.item.hide=Hide Item
|
||||
nei.subsets.item.hide.key=RMB
|
||||
nei.subsets.tag.search=Search by Subset
|
||||
nei.subsets.tag.search.key=Shift + LMB
|
||||
nei.subsets.tag.onlythis=Show only this Subset
|
||||
nei.subsets.tag.onlythis.key=Double LMB
|
||||
nei.subsets.tag.show=Show Subset
|
||||
nei.subsets.tag.show.key=LMB
|
||||
nei.subsets.tag.hide=Hide Subset
|
||||
nei.subsets.tag.hide.key=RMB
|
||||
|
||||
nei.subsets.Blocks=Blocks
|
||||
nei.subsets.Blocks.MobSpawners=Mob Spawners
|
||||
nei.subsets.CreativeTabs=Creative Tabs
|
||||
|
||||
@@ -292,9 +292,6 @@ nei.options.inventory.disableMouseScrollTransfer.false=Нет
|
||||
nei.options.inventory.invertMouseScrollTransfer=Инвертировать направление переноса колесиком мыши
|
||||
nei.options.inventory.invertMouseScrollTransfer.true=Да
|
||||
nei.options.inventory.invertMouseScrollTransfer.false=Нет
|
||||
nei.options.inventory.cacheItemRendering=Кэширование рендеринга предметов
|
||||
nei.options.inventory.cacheItemRendering.true=Да
|
||||
nei.options.inventory.cacheItemRendering.false=Нет
|
||||
nei.options.inventory.collapsibleItems=Группирование предметов
|
||||
nei.options.inventory.collapsibleItems.enabled=Группирование предметов
|
||||
nei.options.inventory.collapsibleItems.enabled.true=Включено
|
||||
|
||||
@@ -194,9 +194,6 @@ nei.options.inventory.disableMouseScrollTransfer.false=关闭
|
||||
nei.options.inventory.invertMouseScrollTransfer=反转鼠标滚轮方向
|
||||
nei.options.inventory.invertMouseScrollTransfer.true=开启
|
||||
nei.options.inventory.invertMouseScrollTransfer.false=关闭
|
||||
nei.options.inventory.cacheItemRendering=缓存物品渲染
|
||||
nei.options.inventory.cacheItemRendering.true=开启
|
||||
nei.options.inventory.cacheItemRendering.false=关闭
|
||||
|
||||
nei.options.command=指令
|
||||
nei.options.command.creative=游戏模式
|
||||
|
||||
Reference in new issue
Block a user