Compare commits

..
19 changed files with 252 additions and 47 deletions

No files matched your search

@@ -1073,6 +1073,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
}
this.grid.shiftGroupAmount(groupId, multiplier * shift);
clearTooltips();
return true;
}
}
@@ -1226,6 +1227,8 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
if (helmStackIndex != -1) {
FastTransferManager.clickSlot(guiContainer, helmStackIndex, 0, 0);
}
clearTooltips();
}
}
@@ -713,6 +713,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
@Override
public void load(GuiContainer gui) {
NEIController.load(gui);
if (isEnabled()) {
setInputFocused(null);
@@ -726,8 +728,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
AutoFocusWidget.instance.load(gui);
}
NEIController.load(gui);
if (checkCreativeInv(gui) && gui.mc.currentScreen instanceof GuiContainerCreative) // override creative with
// creative+
gui.mc.displayGuiScreen(null); // close the screen and wait for the server to open it for us
@@ -10,6 +10,8 @@ import java.util.Map;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import org.lwjgl.input.Mouse;
@@ -205,9 +207,24 @@ public abstract class ShortcutInputHandler {
private static boolean copyItemStackID(ItemStack stackover) {
if (stackover == null || stackover.getItem() == null) return false;
GuiScreen.setClipboardString(
stackover.getItem().delegate.name()
+ (stackover.getItemDamage() != 0 ? "/" + stackover.getItemDamage() : ""));
String clipboard;
if (StackInfo.isFluidDisplayItem(stackover)) {
final FluidStack fluid = StackInfo.getFluid(stackover);
if (fluid == null) {
return false;
}
clipboard = FluidRegistry.getDefaultFluidName(fluid.getFluid());
} else {
clipboard = stackover.getItem().delegate.name()
+ (stackover.getItemDamage() != 0 ? "/" + stackover.getItemDamage() : "");
}
GuiScreen.setClipboardString(clipboard);
return true;
}
@@ -52,14 +52,7 @@ class CraftingTreeToolbar {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslated(iconX, iconY, 0);
GL11.glScalef(0.5f, 0.5f, 1);
icon.bindTexture();
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
icon.draw(0, 0);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
@@ -220,8 +220,9 @@ public class DrawableResource extends Image {
final float scaleU = 1.0F / this.textureWidth;
final float scaleV = 1.0F / this.textureHeight;
final int x = xOffset + this.paddingLeft;
final int y = yOffset + this.paddingTop;
// 1/64 shift keeps pixel centers off texel edges, where NEAREST picks a texel at random when downscaled
final double x = xOffset + this.paddingLeft + 1 / 64d;
final double y = yOffset + this.paddingTop + 1 / 64d;
final float u0 = (this.x + u) * scaleU;
final float u1 = (this.x + u + width) * scaleU;
final float v0 = (this.y + v) * scaleV;
@@ -265,8 +265,8 @@ public final class MobOverlayScan {
}
/**
* {@link #moveTo} reads the chunk, the height map and the biome of a column, and {@link #scan} reads the column's
* blocks.
* {@link #moveTo} reads a column's chunk, biome and highest non-air block in the box, and {@link #scan} reads the
* column's blocks.
*/
private final class Column {
@@ -285,15 +285,14 @@ public final class MobOverlayScan {
canBiomeSpawn = !biome.getSpawnableList(EnumCreatureType.monster).isEmpty()
&& biome.getSpawningChance() > 0;
chunk = scannedWorld.getChunkFromBlockCoords(x, z);
// on the client, `Chunk.generateHeightMap()` never tests the top layer of the highest non-empty section.
// `getHeightValue()` can then be below a block on that layer, so test that layer here
final int topLayerY = chunk.getTopFilledSegment() + 15;
final boolean isTopLayerFilled = !chunk.isEmpty() && chunk.func_150808_b(x & 15, topLayerY, z & 15) != 0;
final int heightValue = isTopLayerFilled ? topLayerY + 1 : scannedWorld.getHeightValue(x, z);
// `getHeightValue()` is the height above the highest block with a light opacity above 0. A snow layer and a
// hopper have a light opacity of 0, and a mob can spawn on top of a full snow block or a hopper, so scan
// one block above the height value
topY = Math.min(scannedWorld.getHeight() - 1, heightValue + 1);
// `getHeightValue()` is the height above the highest block with a light opacity above 0. A block with a
// light opacity of 0 can be higher: Tinkers' Construct slime grass, a hopper or a snow layer. A mob can
// spawn on top of slime grass, a hopper or a full snow block. Search the blocks for the highest non-air
// block
final int SECTION_HEIGHT = 16;
int y = Math.min(minY + height - 1, chunk.getTopFilledSegment() + SECTION_HEIGHT - 1);
while (y >= minY && chunk.getBlock(x & 15, y, z & 15).isAir(chunk.worldObj, x, y, z)) y--;
topY = y + 1;
}
/** @return whether a spawn mode or the top of a flat block changed */
@@ -123,6 +123,11 @@ public class AutoCraftingManager {
AutoCraftingManager.math = math;
if (AutoCraftingManager.math != null) {
if (NEIClientUtils.getGuiContainer() instanceof GuiRecipe<?>gui && gui.firstGui != null) {
gui.mc.displayGuiScreen(gui.firstGui);
}
ItemPanels.bookmarkPanel.clearTooltips();
math.createMasterRoot();
task.restart();
@@ -59,6 +59,7 @@ import codechicken.nei.scroll.ScrollBar.OverflowType;
import codechicken.nei.scroll.ScrollBar.ScrollPlace;
import codechicken.nei.scroll.ScrollContainer;
import codechicken.nei.search.SearchExpressionUtils;
import codechicken.nei.theme.UIWidgetTexture;
import codechicken.nei.util.EmptyContainer;
import codechicken.nei.util.SlotInaccessible;
@@ -111,6 +112,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
private Rectangle pageArea = new Rectangle();
private int lastPage = -1;
private int catalystsVersion = -1;
private final GuiRecipeTabs recipeTabs;
private final GuiRecipeCatalyst recipeCatalyst;
private SearchRecipeHandler<H> handler;
@@ -532,7 +534,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
if (!this.handlerInfo.isAllowOverflowX() && this.handlerInfo.getWidth() > this.xSize - 6) {
this.container.setPaddingInline(0, 2);
this.container.setHorizontalScroll(ScrollBar.defaultHorizontalBar().setTrackPadding(1, 0, 1, 0));
this.container.setHorizontalScroll(UIWidgetTexture.horizontalScrollBar().setTrackPadding(1, 0, 1, 0));
} else {
this.container.setPaddingInline(0, 0);
this.container.setHorizontalScroll(null);
@@ -544,12 +546,16 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
this.container.setVerticalScroll(VERTICAL_SCROLLBAR);
} else {
this.container.setVerticalScroll(
ScrollBar.defaultVerticalBar().setOverflowType(OverflowType.OVERLAY)
UIWidgetTexture.verticalScrollBar().setOverflowType(OverflowType.OVERLAY)
.setTrackPadding(-8, 0, 0, 0));
}
}
this.recipeCatalyst.setCatalysts(RecipeCatalysts.getRecipeCatalysts(this.handler.original));
if (this.catalystsVersion != RecipeCatalysts.getVersion()) {
this.catalystsVersion = RecipeCatalysts.getVersion();
this.recipeCatalyst.setCatalysts(RecipeCatalysts.getRecipeCatalysts(this.handler.original));
}
this.container.update();
}
@@ -580,6 +586,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
this.recipetype = (this.currenthandlers.size() + idx) % this.currenthandlers.size();
this.handler = new SearchRecipeHandler<>(this.currenthandlers.get(this.recipetype));
this.handlerInfo = GuiRecipeTab.getHandlerInfo(this.handler.original);
this.catalystsVersion = RecipeCatalysts.getVersion();
this.recipeCatalyst.setCatalysts(RecipeCatalysts.getRecipeCatalysts(this.handler.original));
updateContainerSize();
this.handlerPages = new RecipePageManager(this.handler, this.handlerInfo, this.container);
this.prevpage.enabled = this.nextpage.enabled = this.handlerPages.getNumPages() > 1;
@@ -4,10 +4,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.event.GuiScreenEvent;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.GuiNEIButton;
import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.theme.ButtonSkin;
import codechicken.nei.theme.UIWidgetTexture;
import cpw.mods.fml.common.eventhandler.Cancelable;
public abstract class GuiRecipeButton extends GuiNEIButton {
@@ -58,6 +62,26 @@ public abstract class GuiRecipeButton extends GuiNEIButton {
this.handlerRef = point;
}
protected DrawableResource getIcon() {
return null;
}
@Override
protected DrawableResource getBackground(int mouseX, int mouseY, boolean mouseOver) {
return UIWidgetTexture.BUTTON.background(this.enabled, false, mouseOver);
}
@Override
protected void drawContent(Minecraft minecraft, int mouseX, int mouseY, boolean mouseOver) {
final DrawableResource icon = getIcon();
if (icon != null) {
ButtonSkin.drawIcon(this.xPosition, this.yPosition, this.width, this.height, icon, this.enabled);
} else {
super.drawContent(minecraft, mouseX, mouseY, mouseOver);
}
}
public abstract List<String> handleTooltip(List<String> currenttip);
public abstract Map<String, String> handleHotkeys(int mousex, int mousey, Map<String, String> hotkeys);
@@ -1,6 +1,7 @@
package codechicken.nei.recipe;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.lwjgl.opengl.GL11;
@@ -17,6 +18,7 @@ import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.scroll.ScrollBar;
import codechicken.nei.scroll.ScrollContainer;
import codechicken.nei.theme.UIWidgetTexture;
public class GuiRecipeCatalyst extends ScrollContainer {
@@ -67,25 +69,26 @@ public class GuiRecipeCatalyst extends ScrollContainer {
private static final DrawableResource FG_TEXTURE = new DrawableBuilder("nei:textures/slot.png", 0, 0, 18, 18)
.setTextureSize(18, 18).setSlices(1, 1, 1, 1).build();
private static final ScrollBar VERTICAL_SCROLLBAR = ScrollBar.defaultVerticalBar()
private static final ScrollBar VERTICAL_SCROLLBAR = UIWidgetTexture.verticalScrollBar()
.setOverflowType(ScrollBar.OverflowType.AUTO).setTrackPadding(0, BORDER_PADDING, -13, BORDER_PADDING)
.setScrollPlace(ScrollBar.ScrollPlace.START);
private PositionedStack[] items = new PositionedStack[0];
private List<PositionedStack> items = Collections.emptyList();
private boolean showWidget = false;
private int availableHeight = 0;
private int style = -1;
public GuiRecipeCatalyst() {
setPaddingBlock(BORDER_PADDING + 1, BORDER_PADDING + 1);
}
public void setCatalysts(List<PositionedStack> items) {
this.items = items.toArray(new PositionedStack[0]);
this.items = items;
createWidgets();
}
public void setAvailableHeight(int height) {
if (this.availableHeight != height) {
if (this.availableHeight != height || this.style != NEIClientConfig.getJEIStyleRecipeCatalysts()) {
this.availableHeight = height;
createWidgets();
}
@@ -102,14 +105,14 @@ public class GuiRecipeCatalyst extends ScrollContainer {
public int getColumnCount() {
if (NEIClientConfig.getJEIStyleRecipeCatalysts() == 1) {
final int maxItemsPerColumn = Math.max(0, this.availableHeight - 2 - BORDER_PADDING * 2) / SLOT_SIZE;
return maxItemsPerColumn > 0 ? NEIServerUtils.divideCeil(this.items.length, maxItemsPerColumn) : 0;
return maxItemsPerColumn > 0 ? NEIServerUtils.divideCeil(this.items.size(), maxItemsPerColumn) : 0;
}
return 1;
}
public int getRowCount() {
final int columnCount = getColumnCount();
return columnCount > 0 ? NEIServerUtils.divideCeil(this.items.length, columnCount) : 0;
return columnCount > 0 ? NEIServerUtils.divideCeil(this.items.size(), columnCount) : 0;
}
protected void createWidgets() {
@@ -119,10 +122,11 @@ public class GuiRecipeCatalyst extends ScrollContainer {
setVerticalScroll(null);
setPaddingInline(BORDER_PADDING + 1, BORDER_PADDING - 3);
this.style = NEIClientConfig.getJEIStyleRecipeCatalysts();
this.h = rows * SLOT_SIZE + this.paddingBlockStart + this.paddingBlockEnd;
this.w = columns * SLOT_SIZE + this.paddingInlineStart + this.paddingInlineEnd;
if (NEIClientConfig.getJEIStyleRecipeCatalysts() == 2
if (this.style == 2
&& rows * SLOT_SIZE + this.paddingBlockStart + this.paddingBlockEnd > this.availableHeight) {
this.h = Math.min(this.h, this.availableHeight);
this.w += VERTICAL_SCROLLBAR.getTrackWidth();
@@ -134,6 +138,7 @@ public class GuiRecipeCatalyst extends ScrollContainer {
this.showWidget = rows * columns > 0;
if (rows == 0 || columns == 0) {
clear();
return;
}
@@ -36,6 +36,11 @@ public class RecipeCatalysts {
public static final Map<String, List<ItemStack>> catalystsRemoverFromIMC = new HashMap<>();
private static final Map<String, List<PositionedStack>> recipeCatalystMap = new HashMap<>();
private static final List<String> forceClassNameList = new ArrayList<>();
private static int version = 0;
public static int getVersion() {
return version;
}
public static void addRecipeCatalyst(String handlerID, CatalystInfo catalystInfo) {
if (handlerID == null || handlerID.isEmpty() || catalystInfo.getStack() == null) return;
@@ -69,6 +74,7 @@ public class RecipeCatalysts {
if (handlerID == null || handlerID.isEmpty()) return;
catalystsAdderFromAPI.put(handlerID, catalystInfoList);
recipeCatalystMap.put(handlerID, convertToPositionedStackList(catalystInfoList));
version++;
}
public static List<PositionedStack> getRecipeCatalysts(IRecipeHandler handler) {
@@ -176,6 +182,7 @@ public class RecipeCatalysts {
recipeCatalystMap.put(entry.getKey(), convertToPositionedStackList(entry.getValue()));
}
version++;
}
private static void resolveAdderQueue(Map<String, CatalystInfoList> recipeCatalystMap) {
@@ -149,6 +149,7 @@ public class RecipeHandlerRef {
if (overlayHandler != null && overlayHandler.canCraft(firstGui, this.handler, this.recipeIndex)) {
if (!firstGui.equals(firstGui.mc.currentScreen)) {
if (!firstGui.mc.func_152345_ab()) return false;
firstGui.mc.displayGuiScreen(firstGui);
}
@@ -6,8 +6,8 @@ import org.lwjgl.opengl.GL11;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.drawable.DrawableBuilder;
import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.theme.UIWidgetTexture;
public class ScrollBar {
@@ -59,21 +59,14 @@ public class ScrollBar {
return new ScrollBar();
}
@Deprecated
public static ScrollBar defaultVerticalBar() {
return new ScrollBar().setTrackWidth(8).setTrackTexture(
new DrawableBuilder("nei:textures/nei_sprites.png", 29, 95, 8, 11).setSlices(0, 0, 3, 4).build())
.setThumbTexture(
new DrawableBuilder("nei:textures/nei_sprites.png", 22, 96, 6, 9).setSlices(0, 0, 3, 2).build())
.setThumbPadding(1, 1, 1, 1);
return UIWidgetTexture.verticalScrollBar();
}
@Deprecated
public static ScrollBar defaultHorizontalBar() {
return new ScrollBar().setTrackWidth(8).setOverflowType(OverflowType.SCROLL)
.setTrackTexture(
new DrawableBuilder("nei:textures/nei_sprites.png", 0, 97, 11, 8).setSlices(3, 4, 0, 0).build())
.setThumbTexture(
new DrawableBuilder("nei:textures/nei_sprites.png", 12, 98, 9, 6).setSlices(3, 2, 0, 0).build())
.setThumbPadding(1, 1, 1, 1);
return UIWidgetTexture.horizontalScrollBar();
}
/**
@@ -0,0 +1,44 @@
package codechicken.nei.theme;
import org.lwjgl.opengl.GL11;
import codechicken.nei.drawable.DrawableResource;
public final class ButtonSkin {
private final DrawableResource normal;
private final DrawableResource hover;
private final DrawableResource active;
private final DrawableResource disabled;
public ButtonSkin(DrawableResource normal, DrawableResource hover, DrawableResource active,
DrawableResource disabled) {
this.normal = normal;
this.hover = hover;
this.active = active;
this.disabled = disabled;
}
public DrawableResource background(boolean enabled, boolean active, boolean hovered) {
if (!enabled) return this.disabled;
if (active) return this.active;
return hovered ? this.hover : this.normal;
}
public void draw(int x, int y, int w, int h, DrawableResource icon, boolean enabled, boolean active,
boolean hovered) {
GL11.glColor4f(1, 1, 1, 1);
background(enabled, active, hovered).draw(x, y, w, h);
drawIcon(x, y, w, h, icon, enabled);
}
public static void drawIcon(int x, int y, int w, int h, DrawableResource icon, boolean enabled) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1, 1, 1, enabled ? 1 : 0.5f);
icon.draw(x + (w - icon.getWidth()) / 2, y + (h - icon.getHeight()) / 2);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1, 1, 1, 1);
}
}
@@ -0,0 +1,58 @@
package codechicken.nei.theme;
import net.minecraft.util.ResourceLocation;
import codechicken.nei.drawable.DrawableResource;
public final class UISprite {
public static final int[] DEFAULT_SPACE = new int[] { 0, 0, 0, 0 };
private UISprite() {}
public static DrawableResource of(String name, int w, int h, int[] margin, int[] slice) {
return frames(name, w, h, 1, margin, slice)[0];
}
public static DrawableResource of(String name, int w, int h) {
return of(name, w, h, DEFAULT_SPACE, DEFAULT_SPACE);
}
public static DrawableResource[] frames(String name, int w, int h, int count) {
return frames(name, w, h, count, DEFAULT_SPACE, DEFAULT_SPACE);
}
// frames are stacked top to bottom and each includes the margin; {left, top, right, bottom}
public static DrawableResource[] frames(String name, int w, int h, int count, int[] margin, int[] slice) {
final ResourceLocation texture = new ResourceLocation("nei", "textures/gui/" + name + ".png");
final int frameWidth = w + margin[0] + margin[2];
final int frameHeight = h + margin[1] + margin[3];
final DrawableResource[] frames = new DrawableResource[count];
for (int i = 0; i < count; i++) {
frames[i] = new DrawableResource(
texture,
0,
i * frameHeight,
frameWidth,
frameHeight,
-margin[1],
-margin[3],
-margin[0],
-margin[2],
frameWidth,
frameHeight * count,
slice[0] + margin[0],
slice[2] + margin[2],
slice[1] + margin[1],
slice[3] + margin[3]);
}
return frames;
}
}
@@ -0,0 +1,47 @@
package codechicken.nei.theme;
import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.scroll.ScrollBar;
import codechicken.nei.scroll.ScrollBar.OverflowType;
import codechicken.nei.scroll.ScrollBar.ScrollType;
public final class UIWidgetTexture {
private static final DrawableResource[] BTN = UISprite
.frames("widgets/button", 12, 12, 4, UISprite.DEFAULT_SPACE, new int[] { 2, 2, 2, 3 });
public static final DrawableResource BTN_NORMAL = BTN[0];
public static final DrawableResource BTN_HOVER = BTN[1];
public static final DrawableResource BTN_ACTIVE = BTN[2];
public static final DrawableResource BTN_DISABLED = BTN[3];
public static final ButtonSkin BUTTON = new ButtonSkin(BTN_NORMAL, BTN_HOVER, BTN_ACTIVE, BTN_DISABLED);
private static final int[] THUMB_INSET = new int[] { 1, 1, 1, 1 };
// frame 0 is the track, frame 1 the thumb drawn inside a transparent THUMB_INSET border of the same frame size
public static final DrawableResource SCROLL_V_TRACK = UISprite
.frames("widgets/scroll_v", 8, 11, 2, UISprite.DEFAULT_SPACE, new int[] { 1, 1, 1, 1 })[0];
public static final DrawableResource SCROLL_V_THUMB = UISprite
.frames("widgets/scroll_v", 6, 9, 2, THUMB_INSET, new int[] { 1, 1, 1, 2 })[1];
public static final DrawableResource SCROLL_H_TRACK = UISprite
.frames("widgets/scroll_h", 11, 8, 2, UISprite.DEFAULT_SPACE, new int[] { 1, 1, 1, 1 })[0];
public static final DrawableResource SCROLL_H_THUMB = UISprite
.frames("widgets/scroll_h", 9, 6, 2, THUMB_INSET, new int[] { 1, 1, 2, 1 })[1];
public static final int SCROLL_TRACK_WIDTH = 8;
private UIWidgetTexture() {}
public static ScrollBar verticalScrollBar() {
return new ScrollBar().setTrackWidth(SCROLL_TRACK_WIDTH).setOverflowType(OverflowType.SCROLL)
.setTrackTexture(SCROLL_V_TRACK).setThumbTexture(SCROLL_V_THUMB).setThumbPadding(1, 1, 1, 1);
}
public static ScrollBar horizontalScrollBar() {
return new ScrollBar().setScrollType(ScrollType.HORIZONTAL).setTrackWidth(SCROLL_TRACK_WIDTH)
.setOverflowType(OverflowType.SCROLL).setTrackTexture(SCROLL_H_TRACK).setThumbTexture(SCROLL_H_THUMB)
.setThumbPadding(1, 1, 1, 1);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B