mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-15 17:54:50 +00:00
Compare commits
15
Commits
2.7.27
...
2.7.5-GTNH-pre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8da7da79fa | ||
|
|
16ba2616b5 | ||
|
|
c9689a6891 | ||
|
|
2c9609c2b8 | ||
|
|
4a566f38d9 | ||
|
|
0844eb9757 | ||
|
|
3e933e2024 | ||
|
|
848a062cec | ||
|
|
2b5db4a683 | ||
|
|
c824d26bb1 | ||
|
|
91ec6b7e5e | ||
|
|
d242f238ab | ||
|
|
43545da3ce | ||
|
|
e4464cfad9 | ||
|
|
71dae392c4 |
No files matched your search
@@ -2,5 +2,6 @@
|
||||
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:CodeChickenCore:1.4.0:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.6.0:dev')
|
||||
shadowImplementation('org.apache.commons:commons-csv:1.10.0')
|
||||
}
|
||||
@@ -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
|
||||
@@ -2059,7 +2060,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
public void setVisible() {
|
||||
super.setVisible();
|
||||
|
||||
if (grid.getPerPage() > 0) {
|
||||
if (grid.getPerPage() > 0 && getNamespaceSize() > 1) {
|
||||
LayoutManager.addWidget(namespacePrev);
|
||||
LayoutManager.addWidget(namespaceNext);
|
||||
LayoutManager.addWidget(namespaceLabel);
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.drawRect;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
@@ -22,10 +21,14 @@ public class ItemHistoryPanel extends Widget {
|
||||
grid = new ItemsGrid();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return grid.isEmpty();
|
||||
}
|
||||
|
||||
public void draw(int mousex, int mousey) {
|
||||
|
||||
if (NEIClientConfig.getIntSetting("inventory.history.splittingMode") == 0) {
|
||||
drawRect(x, y, w, h, NEIClientConfig.getSetting("inventory.history.historyColor").getHexValue());
|
||||
GuiDraw.drawRect(x, y, w, h, NEIClientConfig.getSetting("inventory.history.historyColor").getHexValue());
|
||||
} else {
|
||||
drawSplittingArea(x, y, w, h, NEIClientConfig.getSetting("inventory.history.historyColor").getHexValue());
|
||||
}
|
||||
@@ -44,8 +47,8 @@ public class ItemHistoryPanel extends Widget {
|
||||
grid.realItems.removeIf(historyStack -> StackInfo.equalItemAndNBT(historyStack, stack, true));
|
||||
grid.realItems.add(0, is);
|
||||
|
||||
if (grid.realItems.size() > (grid.rows * grid.columns)) {
|
||||
grid.realItems.remove(grid.rows * grid.columns);
|
||||
if (grid.realItems.size() > Math.max(50, grid.rows * grid.columns)) {
|
||||
grid.realItems.remove(grid.realItems.size() - 1);
|
||||
}
|
||||
|
||||
grid.onItemsChanged();
|
||||
|
||||
@@ -482,11 +482,11 @@ public class ItemPanel extends PanelWidget {
|
||||
LayoutManager.addWidget(quantity);
|
||||
}
|
||||
|
||||
if (!CollapsibleItems.isEmpty()) {
|
||||
if (!CollapsibleItems.isEmpty() && !grid.isEmpty()) {
|
||||
LayoutManager.addWidget(toggleGroups);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.showHistoryPanelWidget()) {
|
||||
if (NEIClientConfig.showHistoryPanelWidget() && (!grid.isEmpty() || !historyPanel.isEmpty())) {
|
||||
LayoutManager.addWidget(historyPanel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -66,6 +175,10 @@ public class ItemsGrid {
|
||||
return realItems.size();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return realItems.isEmpty();
|
||||
}
|
||||
|
||||
public int indexOf(ItemStack stackA, boolean useNBT) {
|
||||
|
||||
for (int idx = 0; idx < realItems.size(); idx++) {
|
||||
@@ -152,7 +265,9 @@ public class ItemsGrid {
|
||||
}
|
||||
|
||||
protected void onGridChanged() {
|
||||
refreshBuffer = true;
|
||||
if (this.screenCapture != null) {
|
||||
this.screenCapture.refreshBuffer();
|
||||
}
|
||||
this.gridMask = null;
|
||||
}
|
||||
|
||||
@@ -280,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();
|
||||
|
||||
@@ -321,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) {
|
||||
@@ -331,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();
|
||||
}
|
||||
|
||||
@@ -382,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) {
|
||||
@@ -412,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);
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ public class NEIClientConfig {
|
||||
|
||||
tag.getTag("inventory.history.historyColor").setComment("Color of the history area display")
|
||||
.getHexValue(0xee555555);
|
||||
API.addOption(new OptionIntegerField("inventory.history.historyColor"));
|
||||
API.addOption(new OptionIntegerField("inventory.history.historyColor", 0, OptionIntegerField.UNSIGNED_INT_MAX));
|
||||
|
||||
tag.getTag("inventory.history.useRows").setComment("Rows used in historical areas").getIntValue(2);
|
||||
API.addOption(new OptionIntegerField("inventory.history.useRows", 1, 5));
|
||||
@@ -267,11 +267,19 @@ public class NEIClientConfig {
|
||||
|
||||
tag.getTag("inventory.collapsibleItems.expandedColor")
|
||||
.setComment("Color of the collapsible item expanded state").getHexValue(0x335555EE);
|
||||
API.addOption(new OptionIntegerField("inventory.collapsibleItems.expandedColor"));
|
||||
API.addOption(
|
||||
new OptionIntegerField(
|
||||
"inventory.collapsibleItems.expandedColor",
|
||||
0,
|
||||
OptionIntegerField.UNSIGNED_INT_MAX));
|
||||
|
||||
tag.getTag("inventory.collapsibleItems.collapsedColor")
|
||||
.setComment("Color of the collapsible item collapsed state").getHexValue(0x335555EE);
|
||||
API.addOption(new OptionIntegerField("inventory.collapsibleItems.collapsedColor"));
|
||||
API.addOption(
|
||||
new OptionIntegerField(
|
||||
"inventory.collapsibleItems.collapsedColor",
|
||||
0,
|
||||
OptionIntegerField.UNSIGNED_INT_MAX));
|
||||
|
||||
API.addOption(
|
||||
new OptionButton(
|
||||
@@ -309,7 +317,7 @@ public class NEIClientConfig {
|
||||
API.addOption(new OptionToggleButton("inventory.itemzoom.showName", true));
|
||||
|
||||
tag.getTag("inventory.itemzoom.nameColor").getHexValue(0xFFFFFFFF);
|
||||
API.addOption(new OptionIntegerField("inventory.itemzoom.nameColor"));
|
||||
API.addOption(new OptionIntegerField("inventory.itemzoom.nameColor", 0, OptionIntegerField.UNSIGNED_INT_MAX));
|
||||
|
||||
tag.getTag("inventory.itemIDs").getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.itemIDs", 3, true));
|
||||
@@ -345,8 +353,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);
|
||||
|
||||
@@ -425,6 +435,18 @@ public class NEIClientConfig {
|
||||
tag.getTag("inventory.search.widgetPosition").setComment("Widget Position").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.search.widgetPosition", true));
|
||||
|
||||
tag.getTag("inventory.search.hideUntilSearching").setComment("Hide Items Until Searching")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.search.hideUntilSearching", true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
super.onClick(button);
|
||||
ItemList.updateFilter.restart();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.widgetAutofocus")
|
||||
.setComment(
|
||||
"Focus Search Widget on Open, blurs/unfocuses on mouse move unless typing has started first")
|
||||
@@ -866,6 +888,10 @@ public class NEIClientConfig {
|
||||
return getBooleanSetting("inventory.showItemQuantityWidget");
|
||||
}
|
||||
|
||||
public static boolean hideItemsUntilSearching() {
|
||||
return getBooleanSetting("inventory.search.hideUntilSearching");
|
||||
}
|
||||
|
||||
public static boolean isSearchWidgetCentered() {
|
||||
return getBooleanSetting("inventory.search.widgetPosition");
|
||||
}
|
||||
@@ -1018,8 +1044,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() {
|
||||
|
||||
@@ -322,7 +322,7 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
}
|
||||
|
||||
public static void sendCommand(String command, Object... args) {
|
||||
if (command.length() == 0) return;
|
||||
if (command.isEmpty()) return;
|
||||
|
||||
NumberFormat numberformat = NumberFormat.getIntegerInstance();
|
||||
numberformat.setGroupingUsed(false);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
@@ -38,6 +39,7 @@ public class NEIModContainer extends DummyModContainer {
|
||||
public static LinkedList<IConfigureNEI> plugins = new LinkedList<>();
|
||||
|
||||
private static boolean gregTech5Loaded;
|
||||
private static boolean gtnhLibLoaded;
|
||||
|
||||
public NEIModContainer() {
|
||||
super(getModMetadata());
|
||||
@@ -59,16 +61,23 @@ public class NEIModContainer extends DummyModContainer {
|
||||
return gregTech5Loaded;
|
||||
}
|
||||
|
||||
public static boolean isGTNHLibLoaded() {
|
||||
return gtnhLibLoaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ArtifactVersion> getRequirements() {
|
||||
Set<ArtifactVersion> deps = new HashSet<>();
|
||||
deps.add(VersionParser.parseVersionReference("CodeChickenCore@[" + CodeChickenCorePlugin.version + ",)"));
|
||||
deps.add(VersionParser.parseVersionReference("CodeChickenCore@[" + codechicken.core.asm.Tags.VERSION + ",)"));
|
||||
return deps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArtifactVersion> getDependencies() {
|
||||
return new LinkedList<>(getRequirements());
|
||||
List<ArtifactVersion> deps = new ArrayList<>();
|
||||
deps.add(VersionParser.parseVersionReference("CodeChickenCore@[" + codechicken.core.asm.Tags.VERSION + ",)"));
|
||||
deps.add(VersionParser.parseVersionReference("gtnhlib@[0.6.0,)"));
|
||||
return deps;
|
||||
}
|
||||
|
||||
private String description;
|
||||
@@ -106,6 +115,7 @@ public class NEIModContainer extends DummyModContainer {
|
||||
@Subscribe
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
gregTech5Loaded = Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi_post");
|
||||
gtnhLibLoaded = Loader.isModLoaded("gtnhlib");
|
||||
if (CommonUtils.isClient()) ClientHandler.preInit();
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ public class NEIServerConfig {
|
||||
FileReader r = new FileReader(file);
|
||||
int line = 0;
|
||||
for (String s : IOUtils.readLines(r)) {
|
||||
if (s.charAt(0) == '#' || s.trim().length() == 0) continue;
|
||||
if (s.charAt(0) == '#' || s.trim().isEmpty()) continue;
|
||||
int delim = s.lastIndexOf('=');
|
||||
if (delim < 0) {
|
||||
logger.error("line " + line + ": Missing =");
|
||||
|
||||
@@ -171,7 +171,7 @@ public abstract class PanelWidget extends Widget implements IContainerTooltipHan
|
||||
protected abstract int resizeFooter(GuiContainer gui);
|
||||
|
||||
public void setVisible() {
|
||||
if (grid.getPerPage() > 0) {
|
||||
if (grid.getPerPage() > 0 && !grid.isEmpty()) {
|
||||
LayoutManager.addWidget(pagePrev);
|
||||
LayoutManager.addWidget(pageNext);
|
||||
LayoutManager.addWidget(pageLabel);
|
||||
|
||||
@@ -144,7 +144,8 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
|
||||
@Override
|
||||
public int getTextColour() {
|
||||
if (ItemPanels.itemPanel.getItems().isEmpty()) {
|
||||
if (ItemPanels.itemPanel.getItems().isEmpty()
|
||||
&& (!this.field.getText().isEmpty() || !NEIClientConfig.hideItemsUntilSearching())) {
|
||||
return focused() ? 0xFFcc3300 : 0xFF993300;
|
||||
} else {
|
||||
return focused() ? 0xFFE0E0E0 : 0xFF909090;
|
||||
@@ -315,6 +316,11 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
|
||||
@Override
|
||||
public ItemFilter getFilter() {
|
||||
|
||||
if (field.getText().isEmpty() && NEIClientConfig.hideItemsUntilSearching()) {
|
||||
return new NothingItemFilter();
|
||||
}
|
||||
|
||||
return ((GuiSearchField) field).getFilter();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package codechicken.nei.config;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
|
||||
public class OptionIntegerField extends OptionTextField {
|
||||
|
||||
public final int min;
|
||||
public final int max;
|
||||
public static final long UNSIGNED_INT_MAX = 0xFFFFFFFFL;
|
||||
|
||||
public OptionIntegerField(String name, int min, int max) {
|
||||
public final long min;
|
||||
public final long max;
|
||||
|
||||
public OptionIntegerField(String name, long min, long max) {
|
||||
super(name);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
@@ -15,13 +19,23 @@ public class OptionIntegerField extends OptionTextField {
|
||||
this(name, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxInputWidth() {
|
||||
|
||||
if (renderTag().getValue().startsWith("0x")) {
|
||||
return GuiDraw.getStringWidth("0x" + Long.toHexString(this.max).toUpperCase()) + 32;
|
||||
}
|
||||
|
||||
return GuiDraw.getStringWidth(String.valueOf(this.max)) + 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(String s) {
|
||||
if (s.length() == 0) return true;
|
||||
if (s.isEmpty()) return true;
|
||||
|
||||
try {
|
||||
if (s.startsWith("0x")) {
|
||||
Long.parseLong(s.substring(2), 16);
|
||||
Long.parseUnsignedLong(s.substring(2), 16);
|
||||
} else {
|
||||
Integer.parseInt(s);
|
||||
}
|
||||
@@ -33,15 +47,15 @@ public class OptionIntegerField extends OptionTextField {
|
||||
|
||||
@Override
|
||||
public boolean isValidValue(String s) {
|
||||
if (s.length() == 0 || !isValidInput(s)) return false;
|
||||
int i = 0;
|
||||
if (s.isEmpty() || !isValidInput(s)) return false;
|
||||
long i = 0;
|
||||
|
||||
if (s.startsWith("0x")) {
|
||||
i = (int) Long.parseLong(s.substring(2), 16);
|
||||
i = Long.parseUnsignedLong(s.substring(2), 16);
|
||||
} else {
|
||||
i = Integer.parseInt(s);
|
||||
}
|
||||
|
||||
return i >= min && i <= max;
|
||||
return i >= this.min && i <= this.max;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
package codechicken.nei.config;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.drawString;
|
||||
import static codechicken.lib.gui.GuiDraw.getStringWidth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.TextField;
|
||||
import codechicken.nei.config.GuiOptionList.OptionScrollSlot;
|
||||
|
||||
public class OptionTextField extends Option {
|
||||
|
||||
@@ -36,11 +33,6 @@ public class OptionTextField extends Option {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded(OptionScrollSlot slot) {
|
||||
super.onAdded(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
textField.update();
|
||||
@@ -51,11 +43,16 @@ public class OptionTextField extends Option {
|
||||
return translateN(name);
|
||||
}
|
||||
|
||||
protected int getMaxInputWidth() {
|
||||
return slot.slotWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
drawString(getPrefix(), 10, 6, -1);
|
||||
GuiDraw.drawString(getPrefix(), 10, 6, -1);
|
||||
|
||||
textField.w = slot.slotWidth() - getStringWidth(getPrefix()) - 16;
|
||||
textField.w = Math
|
||||
.max(60, Math.min(getMaxInputWidth(), slot.slotWidth() - GuiDraw.getStringWidth(getPrefix())) - 16);
|
||||
textField.x = slot.slotWidth() - textField.w;
|
||||
textField.draw(mousex, mousey);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public class OptionToggleButton extends OptionButton {
|
||||
return renderTag().getBooleanValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(name + (state() ? ".true" : ".false"));
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -24,6 +25,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
@@ -38,15 +40,18 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
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;
|
||||
|
||||
public class GuiContainerManager {
|
||||
|
||||
@@ -552,8 +557,8 @@ public class GuiContainerManager {
|
||||
tooltip = handler.handleTooltip(window, mousex, mousey, tooltip);
|
||||
}
|
||||
|
||||
ItemStack stack = getStackMouseOver(window);
|
||||
if (tooltip.isEmpty() && shouldShowTooltip(window)) { // mouseover tip, not holding an item
|
||||
ItemStack stack = getStackMouseOver(window);
|
||||
font = getFontRenderer(stack);
|
||||
if (stack != null) {
|
||||
tooltip = itemDisplayNameMultiline(stack, window, true);
|
||||
@@ -600,7 +605,32 @@ public class GuiContainerManager {
|
||||
}
|
||||
}
|
||||
|
||||
drawPagedTooltip(font, mousex + 12, mousey - 12, tooltip);
|
||||
if (NEIModContainer.isGTNHLibLoaded() && !tooltip.isEmpty()) {
|
||||
if (RenderTooltipEventHelper.post(stack, this.window, mousex, mousey, font)) {
|
||||
return;
|
||||
}
|
||||
Consumer<List<String>> alternativeRenderer = RenderTooltipEventHelper.getAlternativeRenderer();
|
||||
if (alternativeRenderer == null) {
|
||||
drawPagedTooltip(
|
||||
RenderTooltipEventHelper.getFont(),
|
||||
RenderTooltipEventHelper.getX() + 12,
|
||||
RenderTooltipEventHelper.getY() - 12,
|
||||
tooltip);
|
||||
} else {
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GuiDraw.gui.incZLevel(300.0f);
|
||||
alternativeRenderer.accept(tooltip);
|
||||
GuiDraw.gui.incZLevel(-300.0f);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
RenderTooltipEventHelper.flush();
|
||||
} else {
|
||||
drawPagedTooltip(font, mousex + 12, mousey - 12, tooltip);
|
||||
}
|
||||
|
||||
for (IContainerDrawHandler drawHandler : drawHandlers) {
|
||||
drawHandler.postRenderTooltips(window, mousex, mousey, tooltip);
|
||||
@@ -625,6 +655,18 @@ public class GuiContainerManager {
|
||||
tooltips.size(),
|
||||
NEIClientConfig.getKeyName("gui.next_tooltip")));
|
||||
}
|
||||
if (NEIModContainer.isGTNHLibLoaded()) {
|
||||
drawMultilineTip(
|
||||
font,
|
||||
x,
|
||||
y,
|
||||
tooltips.get(tooltipPage),
|
||||
RenderTooltipEventHelper.getBackgroundStart(),
|
||||
RenderTooltipEventHelper.getBackgroundEnd(),
|
||||
RenderTooltipEventHelper.getBorderStart(),
|
||||
RenderTooltipEventHelper.getBorderEnd());
|
||||
return;
|
||||
}
|
||||
drawMultilineTip(font, x, y, tooltips.get(tooltipPage));
|
||||
}
|
||||
|
||||
@@ -713,7 +755,7 @@ public class GuiContainerManager {
|
||||
if (Keyboard.getEventKeyState() || (k == 0 && Character.isDefined(c))) {
|
||||
try {
|
||||
keyTyped(c, k);
|
||||
} catch (java.lang.IndexOutOfBoundsException e) {
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
System.err.println("Caught out of bounds exception pressing " + c + " " + k);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package codechicken.nei.util;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.client.event.RenderTooltipEvent.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.event.RenderTooltipEvent;
|
||||
|
||||
public class RenderTooltipEventHelper {
|
||||
|
||||
private static RenderTooltipEvent event;
|
||||
|
||||
/**
|
||||
* @return {@code true} if the event has been canceled
|
||||
*/
|
||||
public static boolean post(ItemStack stack, GuiScreen gui, int x, int y, FontRenderer font) {
|
||||
event = new RenderTooltipEvent(
|
||||
stack,
|
||||
gui,
|
||||
ORIGINAL_BG_START,
|
||||
ORIGINAL_BG_END,
|
||||
ORIGINAL_BORDER_START,
|
||||
ORIGINAL_BORDER_END,
|
||||
x,
|
||||
y,
|
||||
font);
|
||||
if (stack != null) {
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
if (event.isCanceled()) {
|
||||
flush();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void flush() {
|
||||
event = null;
|
||||
}
|
||||
|
||||
public static int getBackgroundStart() {
|
||||
return event == null ? ORIGINAL_BG_START : event.backgroundStart;
|
||||
}
|
||||
|
||||
public static int getBackgroundEnd() {
|
||||
return event == null ? ORIGINAL_BG_END : event.backgroundEnd;
|
||||
}
|
||||
|
||||
public static int getBorderStart() {
|
||||
return event == null ? ORIGINAL_BORDER_START : event.borderStart;
|
||||
}
|
||||
|
||||
public static int getBorderEnd() {
|
||||
return event == null ? ORIGINAL_BORDER_END : event.borderEnd;
|
||||
}
|
||||
|
||||
public static int getX() {
|
||||
return event.x;
|
||||
}
|
||||
|
||||
public static int getY() {
|
||||
return event.y;
|
||||
}
|
||||
|
||||
public static FontRenderer getFont() {
|
||||
return event.font;
|
||||
}
|
||||
|
||||
public static Consumer<List<String>> getAlternativeRenderer() {
|
||||
return event.alternativeRenderer;
|
||||
}
|
||||
}
|
||||
@@ -216,6 +216,9 @@ nei.options.inventory.search=Search Widget
|
||||
nei.options.inventory.search.widgetPosition=Widget Position
|
||||
nei.options.inventory.search.widgetPosition.true=Center
|
||||
nei.options.inventory.search.widgetPosition.false=Right
|
||||
nei.options.inventory.search.hideUntilSearching=Hide Until Searching
|
||||
nei.options.inventory.search.hideUntilSearching.true=Yes
|
||||
nei.options.inventory.search.hideUntilSearching.false=No
|
||||
nei.options.inventory.search.widgetAutofocus=Autofocus
|
||||
nei.options.inventory.search.widgetAutofocus.0=No
|
||||
nei.options.inventory.search.widgetAutofocus.1=Yes
|
||||
@@ -304,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
|
||||
|
||||
@@ -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