Compare commits

...
21 Commits
Author SHA1 Message Date
slprime 630e856d83 Fix hotkeys when keyBinding disabled (#786) 2025-10-30 10:17:16 +02:00
slprime 42d96aed0c Show 'Delete Item' tooltip in Creative Mode (#785) 2025-10-29 21:47:34 +01:00
slprimeandsisyphussy bd6384bf24 Сalculate the height of the container before scrolling to the recipe (#782)
Co-authored-by: sisyphussy <[email protected]>
2025-10-29 07:52:33 +00:00
slprime af9726d356 Fixed shift+scroll of ingredients in the recipe GUI (#783) 2025-10-29 07:42:18 +00:00
Martin Robertz 1e1d2f1076 update 2025-10-29 07:54:19 +01:00
slprimeandWilhelm Schuster 7cb94fb22a Clear rawText before formatting (#780)
Co-authored-by: Wilhelm Schuster <[email protected]>
2025-10-25 15:20:28 +02:00
Martin Robertz 87aa4f9ed5 update 2025-10-25 14:18:58 +02:00
DarkShadow44andMartin Robertz 9760fd3eaf Fix another race condition, affecting IndustrialGrafter (#779)
Co-authored-by: Martin Robertz <[email protected]>
2025-10-25 14:11:49 +02:00
slprime 1054871982 Add Scroll to Recipe Catalysts (#770) 2025-10-21 12:28:14 +00:00
slprime d90a667f68 Fix Bookmarks Chain Tooltip Height (#773) 2025-10-19 21:33:46 +03:00
slprime 69e6df5848 Fix Button Texture (#771) 2025-10-19 19:56:23 +02:00
slprime 25fa7ce44e Add defaultbookmarkcontainers.cfg (#769) 2025-10-19 16:07:45 +03:00
slprime e3cd7b860d Fix recipe result count (#767) 2025-10-18 11:07:39 +00:00
slprime 2a3aabc073 Add recipe index to recipe handler height (#768) 2025-10-18 13:03:08 +02:00
slprimeandMartin Robertz 76db43c835 Optimize permutations (#761)
Co-authored-by: Martin Robertz <[email protected]>
2025-10-17 22:23:10 +03:00
slprimeandMartin Robertz 40e53eea7a Fixing HUD flickering (#762)
Co-authored-by: Martin Robertz <[email protected]>
2025-10-17 21:36:30 +03:00
Martin Robertz 6c4d16d6b9 update 2025-10-17 12:50:52 +02:00
RealSilverMoon 4a2abe9fd7 Add a function to copy item name and meta (#758) 2025-10-17 10:54:47 +03:00
sisyphussy d47417302e Fix recipe tooltip lighting (#757) 2025-10-14 17:09:02 +03:00
e13401ded8 Optimize Bookmark Chains with Containers (#751)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: sisyphussy <[email protected]>
2025-10-13 11:01:58 +00:00
sisyphussy 7ada842ef3 Fix tooltip item lighting (#755) 2025-10-13 00:29:09 +03:00
40 changed files with 602 additions and 375 deletions

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
dependencies {
api('com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev')
implementation('com.github.GTNewHorizons:GTNHLib:0.7.0:dev')
implementation('com.github.GTNewHorizons:GTNHLib:0.7.3:dev')
shadowImplementation('org.apache.commons:commons-csv:1.10.0')
+3 -1
View File
@@ -96,7 +96,9 @@ usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.43'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.47'
}
@@ -24,6 +24,7 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiSelectWorld;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.resources.IResource;
import net.minecraft.entity.Entity;
@@ -153,6 +154,7 @@ public class ClientHandler {
loadHiddenHandlers();
loadEnableAutoFocus();
loadGuiCraftablesBlacklist();
loadDefaultBookmarkContainers();
ItemInfo.preInit();
StackInfo.loadGuidFilters();
}
@@ -253,6 +255,20 @@ public class ClientHandler {
lines -> ItemCraftablesPanel.guiBlacklist = lines.collect(Collectors.toList()));
}
public static void loadDefaultBookmarkContainers() {
loadSettingsFile("defaultbookmarkcontainers.cfg", lines -> {
for (String clazz : lines.collect(Collectors.toList())) {
try {
API.registerBookmarkContainerHandler(
(Class<? extends GuiContainer>) Class.forName(clazz),
new DefaultBookmarkContainerHandler());
} catch (Exception e) {
NEIClientConfig.logger.error("Failed to load class '{}' for defaultbookmarkcontainers.cfg", clazz);
}
}
});
}
public static void loadHiddenItems() {
loadSettingsFile("hiddenitems.cfg", lines -> lines.forEach(API::hideItem));
}
@@ -117,12 +117,14 @@ public class FavoriteRecipes {
final RecipeId recipeId = RecipeId.of(jsonObject.getAsJsonObject("recipeId"));
final ItemStack stack = StackInfo.loadFromNBT(itemStackNBT);
if (stack != null) {
final String fluidKey = getFluidKey(stack);
if (recipeId == null || stack == null) {
continue;
}
if (fluidKey != null) {
fluids.put(fluidKey, recipeId);
}
final String fluidKey = getFluidKey(stack);
if (fluidKey != null) {
fluids.put(fluidKey, recipeId);
}
items.put(itemStackNBT, recipeId);
@@ -132,8 +134,8 @@ public class FavoriteRecipes {
}
}
} catch (IllegalArgumentException | JsonSyntaxException | IllegalStateException e) {
NEIClientConfig.logger.error("Failed to load favorite from json string:\n{}", itemStr);
} catch (Exception e) {
NEIClientConfig.logger.error("Failed to load favorite from json string: {}", itemStr);
}
}
@@ -61,6 +61,11 @@ public class FormattedTextField extends GuiTextField {
super.setFocused(focus);
}
@Override
public void setText(String rawText) {
super.setText(EnumChatFormatting.getTextWithoutFormattingCodes(rawText));
}
@Override
public void setSelectionPos(int p_146199_1_) {
String text = this.getText();
@@ -42,13 +42,11 @@ public class HUDRenderer implements IKeyStateTracker {
&& mc.objectMouseOver != null
&& mc.objectMouseOver.typeOfHit == MovingObjectType.BLOCK) {
World world = mc.theWorld;
ItemStack[] items = ItemInfo.getIdentifierItems(world, mc.thePlayer, mc.objectMouseOver)
.toArray(new ItemStack[0]);
final List<ItemStack> items = ItemInfo.getIdentifierItems(world, mc.thePlayer, mc.objectMouseOver);
if (items.length == 0) return;
ItemStack stack = StackInfo.getItemStackWithMinimumDamage(items);
if (items.isEmpty()) return;
final ItemStack stack = StackInfo.getItemStackWithMinimumDamage(items.toArray(new ItemStack[0]));
renderOverlay(stack, ItemInfo.getText(stack, world, mc.thePlayer, mc.objectMouseOver), getPositioning());
}
}
@@ -36,7 +36,8 @@ public class HeldItemHandler implements IContainerInputHandler, IContainerToolti
if (contains(mousex, mousey)) {
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")
|| NEIClientUtils.mc().playerController.isInCreativeMode()) {
if (button == 1) {
NEIClientUtils.decreaseSlotStack(-999);
} else {
@@ -101,7 +102,8 @@ public class HeldItemHandler implements IContainerInputHandler, IContainerToolti
if (contains(mousex, mousey)) {
currenttip.clear();
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")
|| NEIClientUtils.mc().playerController.isInCreativeMode()) {
currenttip.add(EnumChatFormatting.RED + translate("itempanel.deleteItem"));
}
}
+9 -1
View File
@@ -16,6 +16,7 @@ import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
@@ -308,7 +309,13 @@ public class ItemList {
action.run();
if (stack.hasTagCompound() && hashOld != stack.stackTagCompound.hashCode()) {
FMLLog.warning("NEI: Forced tag update with reason (" + reason + ") for " + stack);
FMLLog.warning(
"NEI: Forced tag update with reason (" + reason
+ ") for "
+ stack
+ "("
+ stack.getItem()
+ ")");
}
}
@@ -330,6 +337,7 @@ public class ItemList {
runChecked(stack, () -> item.getToolClasses(stack), "getToolClasses");
runChecked(stack, () -> item.getUnlocalizedNameInefficiently(stack), "getUnlocalizedNameInefficiently");
runChecked(stack, () -> item.hasEffect(stack), "hasEffect");
runChecked(stack, () -> item.getDigSpeed(stack, Blocks.stone, 0), "getDigSpeed");
/*
* unused... for now runChecked(stack, () -> GameRegistry.getFuelValue(stack), "getFuelValue");
@@ -70,8 +70,8 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
}
public void setActiveStack(ItemStack activeStack) {
final ItemStack realStack = items.stream().filter(stack -> StackInfo.equalItemAndNBT(stack, activeStack, true))
.findFirst().orElse(null);
final ItemStack realStack = items.stream()
.filter(stack -> NEIClientUtils.areStacksSameTypeWithNBT(stack, activeStack)).findFirst().orElse(null);
this.activeStackIndex = items.indexOf(realStack);
}
@@ -100,13 +100,15 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
fontRenderer.drawStringWithShadow(this.labelColor + this.label + ":", x, y, 0);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
GL11.glPushMatrix();
RenderHelper.enableGUIStandardItemLighting();
GL11.glScaled(1, 1, 3);
GL11.glTranslatef(x, y + fontRenderer.FONT_HEIGHT + 2, 0);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
final int xTranslation = x;
final int yTranslation = y + fontRenderer.FONT_HEIGHT + 2;
final int zTranslation = GuiContainerManager.TOOLTIP_Z_OFFSET;
GL11.glTranslatef(xTranslation, yTranslation, zTranslation);
int indexShift = 0;
@@ -142,7 +144,7 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
});
}
GL11.glPopMatrix();
GL11.glTranslatef(-xTranslation, -yTranslation, -zTranslation);
GL11.glPopAttrib();
}
@@ -907,6 +907,9 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
final int ty2 = ty + 20 - h2 - te;
final int tx2 = 200 - w2 - te;
final boolean is2DTexture = GL11.glGetBoolean(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_TEXTURE_2D);
changeTexture("textures/gui/widgets.png");
drawTexturedModalRect(x, y, tx1, ty1, w1, h1); // top left
drawTexturedModalRect(x, y2, tx1, ty2, w1, h2); // bottom left
@@ -919,6 +922,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
drawTexturedModalRect(x2, y, tx2, ty1, w2, h1); // top right
drawTexturedModalRect(x2, y2, tx2, ty2, w2, h2); // bottom right
if (!is2DTexture) GL11.glDisable(GL11.GL_TEXTURE_2D);
}
public static void drawItemPresenceOverlay(int slotX, int slotY, boolean isPresent, boolean slotHighlight) {
@@ -229,13 +229,9 @@ public class NEIClientConfig {
.getBooleanValue(true);
API.addOption(new OptionToggleButtonBoubs("inventory.guirecipe.jeiStyleTabs", true));
tag.getTag("inventory.guirecipe.jeiStyleRecipeCatalyst").setComment("Enable/disable JEI Style Recipe Catalysts")
.getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.guirecipe.jeiStyleRecipeCatalyst", true));
tag.getTag("inventory.guirecipe.jeiStyleCycledIngredients").setComment("JEI styled cycled ingredients")
.getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.guirecipe.jeiStyleCycledIngredients", true));
tag.getTag("inventory.guirecipe.jeiStyleRecipeCatalyst")
.setComment("JEI Style Recipe Catalysts (0 - none, 1 - grid, 2 - scroll)").getIntValue(1);
API.addOption(new OptionCycled("inventory.guirecipe.jeiStyleRecipeCatalyst", 3, true));
tag.getTag("inventory.guirecipe.cycledIngredientsTooltip").setComment("Show cycled ingredients tooltip")
.getBooleanValue(true);
@@ -838,6 +834,7 @@ public class NEIClientConfig {
API.addKeyBind("world.creative", 0);
API.addHashBind("gui.copy_name", Keyboard.KEY_C + NEIClientUtils.CTRL_HASH);
API.addHashBind("gui.copy_oredict", Keyboard.KEY_D + NEIClientUtils.CTRL_HASH);
API.addHashBind("gui.copy_id", Keyboard.KEY_X + NEIClientUtils.CTRL_HASH);
API.addHashBind("gui.chat_link_item", Keyboard.KEY_L + NEIClientUtils.CTRL_HASH);
}
@@ -1108,8 +1105,8 @@ public class NEIClientConfig {
return getBooleanSetting("inventory.guirecipe.slotHighlightPresent");
}
public static boolean areJEIStyleRecipeCatalystsVisible() {
return getBooleanSetting("inventory.guirecipe.jeiStyleRecipeCatalyst");
public static int getJEIStyleRecipeCatalysts() {
return getIntSetting("inventory.guirecipe.jeiStyleRecipeCatalyst");
}
public static boolean useCreativeTabStyle() {
@@ -1128,10 +1125,6 @@ public class NEIClientConfig {
return getBooleanSetting("inventory.optimize_gui_overlap_computation");
}
public static boolean useJEIStyledCycledIngredients() {
return getBooleanSetting("inventory.guirecipe.jeiStyleCycledIngredients");
}
public static boolean showCycledIngredientsTooltip() {
return getBooleanSetting("inventory.guirecipe.cycledIngredientsTooltip");
}
+19 -11
View File
@@ -421,30 +421,38 @@ public class ItemInfo {
Block mouseoverBlock = world.getBlock(x, y, z);
ArrayList<ItemStack> items = new ArrayList<>();
ArrayList<IHighlightHandler> handlers = new ArrayList<>();
if (highlightIdentifiers.containsKey(null)) handlers.addAll(highlightIdentifiers.get(null));
if (highlightIdentifiers.containsKey(mouseoverBlock)) handlers.addAll(highlightIdentifiers.get(mouseoverBlock));
for (IHighlightHandler ident : handlers) {
ItemStack item = ident.identifyHighlight(world, player, hit);
final ItemStack item = ident.identifyHighlight(world, player, hit);
if (item != null) items.add(item);
}
if (items.size() > 0) return items;
if (!items.isEmpty()) return items;
ItemStack pick = mouseoverBlock.getPickBlock(hit, world, x, y, z, player);
if (pick != null) items.add(pick);
try {
final ItemStack pick = mouseoverBlock.getPickBlock(hit, world, x, y, z, player);
if (pick != null) items.add(pick);
} catch (Exception ignored) {}
if (!items.isEmpty()) return items;
if (mouseoverBlock instanceof IShearable shearable) {
if (shearable.isShearable(new ItemStack(Items.shears), world, x, y, z)) {
items.addAll(shearable.onSheared(new ItemStack(Items.shears), world, x, y, z, 0));
}
}
if (!items.isEmpty()) return items;
try {
items.addAll(mouseoverBlock.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0));
} catch (Exception ignored) {}
if (mouseoverBlock instanceof IShearable) {
IShearable shearable = (IShearable) mouseoverBlock;
if (shearable.isShearable(new ItemStack(Items.shears), world, x, y, z))
items.addAll(shearable.onSheared(new ItemStack(Items.shears), world, x, y, z, 0));
}
if (items.size() == 0) items.add(0, new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z)));
if (items.isEmpty()) items.add(new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z)));
return items;
}
@@ -42,6 +42,31 @@ import codechicken.nei.util.NEIMouseUtils;
public abstract class ShortcutInputHandler {
private static class HotkeysCache {
public int mousex;
public int mousey;
public ItemStack stack;
public int groupId;
public Map<String, String> hotkeys = new HashMap<>();
public boolean matches(int mousex, int mousey, ItemStack stack, int groupId) {
return Math.abs(this.mousex - mousex) < 16 && Math.abs(this.mousey - mousey) < 16
&& (this.stack == null ? stack == null && this.groupId == groupId
: stack != null && NEIClientUtils.areStacksSameTypeWithNBT(stack, this.stack));
}
public void update(int mousex, int mousey, ItemStack stack, int groupId, Map<String, String> hotkeys) {
this.mousex = mousex;
this.mousey = mousey;
this.stack = stack != null ? stack.copy() : null;
this.groupId = groupId;
this.hotkeys = hotkeys;
}
}
private static HotkeysCache hotkeysCache = new HotkeysCache();
public static boolean handleKeyEvent(ItemStack stackover) {
if (!NEIClientConfig.isLoaded()) {
@@ -98,6 +123,9 @@ public abstract class ShortcutInputHandler {
if (NEIClientConfig.isKeyHashDown("gui.copy_name")) {
return copyItemStackName(stackover);
}
if (NEIClientConfig.isKeyHashDown("gui.copy_id")) {
return copyItemStackID(stackover);
}
if (NEIClientConfig.isKeyHashDown("gui.copy_oredict")) {
return copyItemStackOreDictionary(stackover);
@@ -159,6 +187,14 @@ public abstract class ShortcutInputHandler {
return true;
}
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() : ""));
return true;
}
private static boolean sendItemStackChatLink(ItemStack stackover) {
if (stackover == null) return false;
@@ -380,8 +416,13 @@ public abstract class ShortcutInputHandler {
}
public static Map<String, String> handleHotkeys(int mousex, int mousey, ItemStack stack) {
final GuiContainer gui = NEIClientUtils.getGuiContainer();
final int groupId = ItemPanels.bookmarkPanel.getHoveredGroupId(true);
if (hotkeysCache.matches(mousex, mousey, stack, groupId)) {
return hotkeysCache.hotkeys;
}
final GuiContainer gui = NEIClientUtils.getGuiContainer();
final Map<String, String> hotkeys = new HashMap<>();
if (groupId != -1) {
@@ -408,9 +449,13 @@ public abstract class ShortcutInputHandler {
NEIClientConfig.getKeyName("gui.craft_items", NEIClientUtils.SHIFT_HASH),
NEIClientUtils.translate("bookmark.group.craft_all"));
}
hotkeysCache.update(mousex, mousey, stack, groupId, hotkeys);
return hotkeys;
}
if (stack == null) {
hotkeysCache.update(mousex, mousey, stack, groupId, hotkeys);
return hotkeys;
}
@@ -511,6 +556,7 @@ public abstract class ShortcutInputHandler {
hotkeys.put(NEIClientConfig.getKeyName("gui.copy_name"), NEIClientUtils.translate("itempanel.copy_name"));
hotkeys.put(NEIClientConfig.getKeyName("gui.copy_oredict"), NEIClientUtils.translate("itempanel.copy_oredict"));
hotkeys.put(NEIClientConfig.getKeyName("gui.copy_id"), NEIClientUtils.translate("itempanel.copy_id"));
hotkeys.put(
NEIClientConfig.getKeyName("gui.chat_link_item"),
NEIClientUtils.translate("itempanel.chat_link_item"));
@@ -570,6 +616,8 @@ public abstract class ShortcutInputHandler {
}
hotkeysCache.update(mousex, mousey, stack, groupId, hotkeys);
return hotkeys;
}
@@ -82,6 +82,9 @@ public class GuiContainerManager {
public static final LinkedList<IContainerSlotClickHandler> slotClickHandlers = new HideousLinkedList<>(
new CopyOnWriteArrayList<>());
// Any item rendered with this z offset should render it on top of every other gui element
public static final int TOOLTIP_Z_OFFSET = 400;
static {
addSlotClickHandler(new DefaultSlotClickHandler());
}
@@ -661,12 +664,12 @@ public class GuiContainerManager {
}
}
hotkeys.remove(null);
hotkeys.remove("");
if (!hotkeys.isEmpty()) {
List<String> hotkeystips = new ArrayList<>();
Map<String, List<String>> messages = new HashMap<>();
hotkeys.remove(null);
hotkeys.remove("");
for (Map.Entry<String, String> entry : hotkeys.entrySet()) {
messages.computeIfAbsent(entry.getValue(), m -> new ArrayList<>()).add(entry.getKey());
@@ -701,13 +704,19 @@ public class GuiContainerManager {
}
} else if (NEIClientConfig.getBooleanSetting("inventory.hotkeysHelpText")) {
Map<String, String> hotkeys = new HashMap<>();
boolean existsHotkeys = false;
synchronized (instanceTooltipHandlers) {
for (IContainerTooltipHandler handler : instanceTooltipHandlers) {
if (!handler.handleHotkeys(window, mousex, mousey, new HashMap<>()).isEmpty()) {
existsHotkeys = true;
break;
if (!(hotkeys = handler.handleHotkeys(window, mousex, mousey, hotkeys)).isEmpty()) {
hotkeys.remove("");
hotkeys.remove(null);
if (!hotkeys.isEmpty()) {
existsHotkeys = true;
break;
}
}
}
}
@@ -11,7 +11,7 @@ import codechicken.nei.NEIClientUtils;
public class AcceptsFollowingTooltipLineHandler extends ItemsTooltipLineHandler {
protected static final int DEFAULT_MAX_ROWS = 5;
protected static final int DEFAULT_MAX_ROWS = 4;
public Object tooltipGUID;
@@ -179,6 +179,12 @@ public class DebugHandlerWidget extends Widget implements IContainerInputHandler
this.handlerHeight = new IntegerField("handlerHeight", HandlerInfo.DEFAULT_HEIGHT) {
@Override
public void draw(int mx, int my) {
this.field.setEnabled(handler.getRecipeHeight(0) <= 0);
super.draw(mx, my);
}
@Override
public void onTextChange(String oldText) {
if (getInteger() != handlerInfo.getHeight()) {
@@ -27,7 +27,7 @@ public class FurnaceRecipeHandler extends TemplateRecipeHandler {
}
public List<PositionedStack> getIngredients() {
return getCycledIngredients(cycleticks / 48, Collections.singletonList(ingred));
return Collections.singletonList(ingred);
}
public PositionedStack getResult() {
@@ -65,8 +65,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
private static final int BUTTON_WIDTH = 13;
private static final int BUTTON_HEIGHT = 12;
protected static final ScrollBar VERTICAL_SCROLLBAR = new ScrollBar().setScrollbarSize(14)
.setOverflowType(OverflowType.AUTO).setScrollPlace(ScrollPlace.OUTSIDE)
protected static final ScrollBar VERTICAL_SCROLLBAR = new ScrollBar().setScrollbarSize(14).setMarginStart(-6)
.setOverflowType(OverflowType.AUTO).setScrollPlace(ScrollPlace.END)
.setTrackTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 42, 90, 13, 21).build(), 9, 9)
.setThumbTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 21, 96, 8, 9).build(), 3, 2)
.setThumbPadding(6);
@@ -322,6 +322,10 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
}
};
this.container.x = this.guiLeft + 3;
this.container.y = this.guiTop + 32;
this.container.h = this.ySize - 32 - 5;
GuiRecipe.toggleSearch.icon = new DrawableBuilder("nei:textures/nei_sprites.png", 0, 76, 10, 10).build();
GuiRecipe.toggleSearch.w = GuiRecipe.toggleSearch.h = 12;
GuiRecipe.toggleSearch.x = this.guiLeft + BORDER_PADDING + BUTTON_WIDTH;
@@ -351,8 +355,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
if (!cacheKey.equals(this.recipePageCacheKey)) {
this.recipePageCacheKey = cacheKey;
final boolean recipeGrow = this.handlerInfo.getUseCustomScroll()
&& this.handlerInfo.getMaxRecipesPerPage() <= 1;
final boolean expandVertically = this.handlerInfo.expandVertically();
final List<Widget> widgets = new ArrayList<>();
int shiftY = 0;
@@ -361,7 +364,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
.getRecipeWidget();
widget.setLocation(Math.max(0, (this.container.w - widget.w) / 2), shiftY);
if (recipeGrow) {
if (expandVertically) {
widget.h = Math.min(
this.handlerInfo.getHeight() + this.handlerInfo.getYShift(),
this.container.getVisibleHeight());
@@ -380,7 +383,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
} else {
this.container.setVerticalScroll(
ScrollBar.defaultVerticalBar().setOverflowType(OverflowType.OVERLAY)
.setScrollPlace(ScrollPlace.OUTSIDE));
.setScrollPlace(ScrollPlace.END));
}
}
@@ -423,7 +426,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
GuiRecipe.toggleSearch.state = 0;
this.container.setVerticalScrollOffset(0);
this.container.setHorizontalScrollOffset(0);
this.page = Math.min(Math.max(0, refIndex), this.numRecipes() - 1) / getRecipesPerPage();
changePage(0);
@@ -700,20 +702,16 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
public void updateScreen() {
super.updateScreen();
this.container.x = this.guiLeft + 3;
this.container.y = this.guiTop + 32;
this.container.w = Math.max(this.xSize - 6, this.handlerInfo.getWidth());
this.container.h = this.ySize - 32 - 5;
this.handler.original.onUpdate();
refreshPage();
this.container.update();
this.recipeCatalyst.setAvailableHeight(this.container.h);
this.recipeCatalyst.update();
this.recipeCatalyst.setAvailableHeight(this.ySize - 5);
this.recipeCatalyst.y = this.guiTop;
this.recipeCatalyst.x = this.guiLeft - this.recipeCatalyst.w + 6;
this.recipeCatalyst.x = this.guiLeft - this.recipeCatalyst.w + 4;
this.recipeCatalyst.update();
}
@Override
@@ -833,7 +831,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
if (this.page != oldPage) {
this.container.setVerticalScrollOffset(0);
this.container.setHorizontalScrollOffset(0);
}
}
@@ -865,6 +862,11 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
GL11.glTranslatef(-guiLeft, -guiTop, 0);
this.container.draw(mouseX, mouseY);
if (NEIClientConfig.getJEIStyleRecipeCatalysts() != 0 && this.recipeCatalyst.isShowWidget()) {
this.recipeCatalyst.draw(mouseX, mouseY);
}
GL11.glTranslatef(guiLeft, guiTop, 0);
}
@@ -941,11 +943,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
RenderHelper.enableGUIStandardItemLighting();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
this.recipeTabs.draw(mouseX, mouseY);
if (NEIClientConfig.areJEIStyleRecipeCatalystsVisible()) {
this.recipeCatalyst.draw(mouseX, mouseY);
}
RenderHelper.disableStandardItemLighting();
}
}
@@ -1028,7 +1025,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
final Rectangle4i rect = new Rectangle4i(x, y, w, h);
// Because some of the handlers *cough avaritia* are oversized
if (this.recipeCatalyst.isShowWidget() && this.recipeCatalyst.bounds().intersects(rect)) {
if (this.recipeCatalyst.isShowWidget() && this.recipeCatalyst.boundsOutside().intersects(rect)) {
return true;
}
@@ -3,13 +3,10 @@ package codechicken.nei.recipe;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
@@ -18,8 +15,37 @@ import codechicken.nei.api.ShortcutInputHandler;
import codechicken.nei.drawable.DrawableBuilder;
import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.scroll.ScrollBar;
import codechicken.nei.scroll.ScrollContainer;
public class GuiRecipeCatalyst extends Widget {
public class GuiRecipeCatalyst extends ScrollContainer {
protected static class ItemStackWidget extends Widget {
private final PositionedStack pStack;
public ItemStackWidget(PositionedStack pStack) {
this.pStack = pStack;
this.x = pStack.relx;
this.y = pStack.rely;
this.w = SLOT_SIZE;
this.h = SLOT_SIZE;
}
@Override
public void draw(int mx, int my) {
GuiContainerManager.drawItem(this.x, this.y, this.pStack.item);
if (contains(mx, my)) {
NEIClientUtils.gl2DRenderContext(() -> GuiDraw.drawRect(this.x, this.y, this.w, this.h, 0x80FFFFFF));
}
}
@Override
public boolean handleClick(int mx, int my, int button) {
return ShortcutInputHandler.handleMouseClick(this.pStack.item);
}
}
private static final int SLOT_SIZE = 16;
private static final int BORDER_PADDING = 6;
@@ -33,17 +59,29 @@ public class GuiRecipeCatalyst extends Widget {
private static final DrawableResource FG_TEXTURE = new DrawableBuilder("nei:textures/slot.png", 0, 0, 18, 18)
.setTextureSize(18, 18).build();
private static final ScrollBar VERTICAL_SCROLLBAR = ScrollBar.defaultVerticalBar()
.setOverflowType(ScrollBar.OverflowType.AUTO).setMarginStart(BORDER_PADDING).setMarginEnd(BORDER_PADDING)
.setPadding(-13).setScrollPlace(ScrollBar.ScrollPlace.START);
private final List<PositionedStack> items = new ArrayList<>();
private int availableHeight = 0;
private boolean showWidget = false;
private int availableHeight = 0;
public GuiRecipeCatalyst() {
setPaddingBlock(BORDER_PADDING + 1, BORDER_PADDING + 1);
}
public void setCatalysts(List<PositionedStack> items) {
this.items.clear();
this.items.addAll(items);
createWidgets();
}
public void setAvailableHeight(int height) {
this.availableHeight = height;
if (this.availableHeight != height) {
this.availableHeight = height;
createWidgets();
}
}
public int getAvailableHeight() {
@@ -55,8 +93,11 @@ public class GuiRecipeCatalyst extends Widget {
}
public int getColumnCount() {
final int maxItemsPerColumn = Math.max(0, this.availableHeight - 2 - BORDER_PADDING * 2) / SLOT_SIZE;
return maxItemsPerColumn > 0 ? NEIServerUtils.divideCeil(this.items.size(), maxItemsPerColumn) : 0;
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.size(), maxItemsPerColumn) : 0;
}
return 1;
}
public int getRowCount() {
@@ -64,20 +105,35 @@ public class GuiRecipeCatalyst extends Widget {
return columnCount > 0 ? NEIServerUtils.divideCeil(this.items.size(), columnCount) : 0;
}
@Override
public void update() {
protected void createWidgets() {
final int columns = getColumnCount();
final int rows = getRowCount();
setVerticalScroll(null);
setPaddingInline(BORDER_PADDING + 1, BORDER_PADDING - 3);
this.h = rows * SLOT_SIZE + this.paddingBlockStart + this.paddingBlockEnd;
this.w = columns * SLOT_SIZE + this.paddingInlineStart + this.paddingInlineEnd;
if (NEIClientConfig.getJEIStyleRecipeCatalysts() == 2
&& rows * SLOT_SIZE + this.paddingBlockStart + this.paddingBlockEnd > this.availableHeight) {
this.h = Math.min(this.h, this.availableHeight);
this.w += VERTICAL_SCROLLBAR.getScrollbarSize();
setVerticalScroll(VERTICAL_SCROLLBAR);
setPaddingInline(BORDER_PADDING + 1 + VERTICAL_SCROLLBAR.getScrollbarSize(), this.paddingInlineEnd);
}
this.showWidget = rows * columns > 0;
this.w = columns * SLOT_SIZE + 2 + BORDER_PADDING * 2;
this.h = rows * SLOT_SIZE + 2 + BORDER_PADDING * 2;
if (rows == 0 || columns == 0) {
return;
}
final int visibleWidth = getVisibleWidth();
final List<Widget> widgets = new ArrayList<>();
int index = 0;
for (PositionedStack pStack : this.items) {
if (pStack.items.length > 1) {
@@ -86,75 +142,45 @@ public class GuiRecipeCatalyst extends Widget {
pStack.setPermutationToRender(stackIndex);
}
pStack.relx = this.w - BORDER_PADDING - 1 - SLOT_SIZE - (index / rows) * SLOT_SIZE;
pStack.rely = BORDER_PADDING + 1 + (index % rows) * SLOT_SIZE;
pStack.relx = visibleWidth - SLOT_SIZE - (index / rows) * SLOT_SIZE;
pStack.rely = (index % rows) * SLOT_SIZE;
index++;
widgets.add(new ItemStackWidget(pStack));
}
setWidgets(widgets);
}
@Override
public void draw(int mx, int my) {
if (!this.showWidget) return;
GL11.glTranslatef(this.x, this.y, 0);
GL11.glColor4f(1, 1, 1, 1);
BG_TEXTURE.draw(0, 0, this.w, this.h, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING);
BG_TEXTURE.draw(this.x, this.y, this.w, this.h, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING);
FG_TEXTURE.draw(
BORDER_PADDING,
BORDER_PADDING,
this.w - BORDER_PADDING * 2,
this.h - BORDER_PADDING * 2,
this.x + this.paddingInlineStart - 1,
this.y + this.paddingBlockStart - 1,
this.w - this.paddingInlineStart - this.paddingInlineEnd + 2,
this.h - this.paddingBlockStart - this.paddingBlockEnd + 2,
1,
1,
1,
1);
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
for (PositionedStack pStack : this.items) {
GuiContainerManager.drawItem(pStack.relx, pStack.rely, pStack.item);
if (pStack.contains(mx - this.x, my - this.y)) {
NEIClientUtils.gl2DRenderContext(
() -> GuiDraw.drawRect(pStack.relx, pStack.rely, SLOT_SIZE, SLOT_SIZE, -2130706433));
}
}
GL11.glPopAttrib();
GL11.glTranslatef(-this.x, -this.y, 0);
super.draw(mx, my);
}
public PositionedStack getPositionedStackMouseOver(int mx, int my) {
final Widget widget = getWidgetUnderMouse(mx, my);
for (PositionedStack pStack : this.items) {
if (pStack.contains(mx - this.x, my - this.y)) {
return pStack;
}
if (widget instanceof ItemStackWidget stackWidget) {
return stackWidget.pStack;
}
return null;
}
@Override
public ItemStack getStackMouseOver(int mx, int my) {
final PositionedStack pStack = getPositionedStackMouseOver(mx, my);
if (pStack != null) {
return pStack.item;
}
return null;
}
@Override
public boolean handleClick(int mx, int my, int button) {
return ShortcutInputHandler.handleMouseClick(getStackMouseOver(mx, my));
}
@Deprecated
public static final int ingredientSize = 16;
@Deprecated
@@ -99,7 +99,7 @@ public class GuiUsageRecipe extends GuiRecipe<IUsageHandler> {
private static IUsageHandler getUsageOrCatalystHandler(IUsageHandler handler, String inputId,
Object... ingredients) {
boolean skipCatalyst = NEIClientUtils.controlKey();
if (NEIClientConfig.areJEIStyleRecipeCatalystsVisible() && !skipCatalyst) {
if (NEIClientConfig.getJEIStyleRecipeCatalysts() != 0 && !skipCatalyst) {
return handler.getUsageAndCatalystHandler(inputId, ingredients);
} else {
return handler.getUsageHandler(inputId, ingredients);
@@ -133,6 +133,10 @@ public class HandlerInfo {
this.useCustomScroll = useCustomScroll;
}
public boolean expandVertically() {
return this.useCustomScroll && this.maxRecipesPerPage <= 1;
}
public static class Builder {
private final HandlerInfo info;
@@ -44,6 +44,10 @@ public interface IRecipeHandler {
return getRecipeName();
}
default int getRecipeHeight(int recipe) {
return 0;
}
/**
*
* @return The number of recipes that this handler contains.
@@ -99,7 +99,7 @@ public class InformationHandler extends TemplateRecipeHandler {
@Override
public List<PositionedStack> getIngredients() {
return getCycledIngredients(cycleticks / 20, Collections.singletonList(this.stack));
return Collections.singletonList(this.stack);
}
public InformationPage getPage() {
@@ -5,7 +5,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.function.Function;
import java.util.stream.Stream;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
@@ -17,9 +19,11 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.FavoriteRecipes;
import codechicken.nei.LayoutManager;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.Widget;
import codechicken.nei.api.IGuiContainerOverlay;
@@ -29,13 +33,16 @@ import codechicken.nei.recipe.GuiRecipeButton.UpdateRecipeButtonsEvent;
public class NEIRecipeWidget extends Widget {
protected final WeakHashMap<PositionedStack, List<ItemStack>> permutations = new WeakHashMap<>();
protected boolean needUpdate = true;
protected int cycleticks = 0;
protected int lastcycle = 0;
protected final RecipeHandlerRef handlerRef;
protected final HandlerInfo handlerInfo;
protected boolean showAsWidget = false;
protected List<GuiRecipeButton> recipeButtons = null;
protected boolean firstDraw = true;
protected boolean needUpdate = true;
public NEIRecipeWidget(RecipeHandlerRef handlerRef) {
this.handlerRef = handlerRef;
@@ -49,14 +56,18 @@ public class NEIRecipeWidget extends Widget {
}
public void update() {
this.w = this.handlerInfo.getWidth();
this.w = Math.max(166, this.handlerInfo.getWidth());
if (this.showAsWidget || !this.handlerInfo.getUseCustomScroll()
|| this.handlerInfo.getMaxRecipesPerPage() > 1) {
this.h = this.handlerInfo.getHeight() + this.handlerInfo.getYShift();
if (this.showAsWidget || !this.handlerInfo.expandVertically()) {
final int recipeHeight = this.handlerRef.handler.getRecipeHeight(this.handlerRef.recipeIndex);
this.h = recipeHeight > 0 ? recipeHeight : this.handlerInfo.getHeight();
this.h += this.handlerInfo.getYShift();
}
this.needUpdate = true;
if (!this.needUpdate && !NEIClientUtils.shiftKey() && (this.cycleticks++) / 20 != this.lastcycle) {
this.lastcycle = this.cycleticks / 20;
this.needUpdate = true;
}
}
public List<GuiRecipeButton> getRecipeButtons() {
@@ -152,7 +163,12 @@ public class NEIRecipeWidget extends Widget {
public void draw(int mouseX, int mouseY) {
final int yShift = this.handlerInfo.getYShift();
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
if (this.needUpdate) {
this.needUpdate = false;
updatePermutations();
}
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
GL11.glTranslatef(this.x, this.y + yShift, 0);
this.handlerRef.handler.drawBackground(this.handlerRef.recipeIndex);
@@ -161,22 +177,35 @@ public class NEIRecipeWidget extends Widget {
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1, 1, 1, 1);
if (this.firstDraw) {
this.firstDraw = false;
for (PositionedStack pStack : this.handlerRef.handler.getIngredientStacks(this.handlerRef.recipeIndex)) {
pStack.setPermutationToRender(pStack.getFilteredPermutations().get(0));
}
}
GuiContainerManager.enableMatrixStackLogging();
for (PositionedStack pStack : getItems(!this.needUpdate)) {
for (PositionedStack pStack : this.handlerRef.handler.getIngredientStacks(this.handlerRef.recipeIndex)) {
GuiContainerManager.drawItem(pStack.relx, pStack.rely, pStack.item);
if (pStack.contains(mouseX - this.x, mouseY - this.y - yShift)) {
NEIClientUtils.gl2DRenderContext(() -> GuiDraw.drawRect(pStack.relx, pStack.rely, 16, 16, -2130706433));
NEIClientUtils.gl2DRenderContext(() -> GuiDraw.drawRect(pStack.relx, pStack.rely, 16, 16, 0x80FFFFFF));
}
}
this.needUpdate = false;
for (PositionedStack pStack : this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex)) {
GuiContainerManager.drawItem(pStack.relx, pStack.rely, pStack.item);
if (pStack.contains(mouseX - this.x, mouseY - this.y - yShift)) {
NEIClientUtils.gl2DRenderContext(() -> GuiDraw.drawRect(pStack.relx, pStack.rely, 16, 16, 0x80FFFFFF));
}
}
final PositionedStack pStackResult = this.handlerRef.handler.getResultStack(this.handlerRef.recipeIndex);
if (pStackResult != null) {
GuiContainerManager.drawItem(pStackResult.relx, pStackResult.rely, pStackResult.item);
if (pStackResult.contains(mouseX - this.x, mouseY - this.y - yShift)) {
NEIClientUtils.gl2DRenderContext(
() -> GuiDraw.drawRect(pStackResult.relx, pStackResult.rely, 16, 16, 0x80FFFFFF));
}
}
GuiContainerManager.disableMatrixStackLogging();
this.handlerRef.handler.drawForeground(this.handlerRef.recipeIndex);
final GuiRecipeButton overlayButton = getRecipeButtons().stream()
@@ -300,12 +329,46 @@ public class NEIRecipeWidget extends Widget {
return true;
}
if (scrollPermutations(scroll, mx, my)) {
return true;
}
final GuiRecipe<?> guiRecipe = getGuiRecipe();
return guiRecipe != null
&& this.handlerRef.handler.mouseScrolled(guiRecipe, scroll, this.handlerRef.recipeIndex);
}
protected boolean scrollPermutations(int scroll, int mx, int my) {
if (!NEIClientUtils.shiftKey()) return false;
final PositionedStack overStack = getPositionedStackMouseOver(mx, my);
if (overStack != null && overStack.items.length > 1) {
final List<ItemStack> items = overStack.getFilteredPermutations();
final int stackIndex = indexOf(items, overStack.item);
final ItemStack stack = items.get((items.size() - scroll + stackIndex) % items.size());
Stream.concat(
this.handlerRef.handler.getIngredientStacks(this.handlerRef.recipeIndex).stream(),
this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex).stream())
.filter(pStack -> pStack.containsWithNBT(stack))
.forEach(pStack -> pStack.setPermutationToRender(stack));
return true;
}
return false;
}
protected int indexOf(List<ItemStack> list, ItemStack stack) {
for (int i = 0; i < list.size(); i++) {
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(list.get(i), stack)) {
return i;
}
}
return -1;
}
protected <R> R forEachButtons(Function<GuiRecipeButton, R> callback, R defaultValue) {
for (GuiRecipeButton button : getRecipeButtonsIfInit()) {
@@ -345,12 +408,23 @@ public class NEIRecipeWidget extends Widget {
public PositionedStack getPositionedStackMouseOver(int mx, int my) {
final int yShift = this.handlerInfo.getYShift();
for (PositionedStack pStack : getItems(true)) {
for (PositionedStack pStack : this.handlerRef.handler.getIngredientStacks(this.handlerRef.recipeIndex)) {
if (pStack.contains(mx - this.x, my - this.y - yShift)) {
return pStack;
}
}
for (PositionedStack pStack : this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex)) {
if (pStack.contains(mx - this.x, my - this.y - yShift)) {
return pStack;
}
}
final PositionedStack pStackResult = this.handlerRef.handler.getResultStack(this.handlerRef.recipeIndex);
if (pStackResult != null && pStackResult.contains(mx - this.x, my - this.y - yShift)) {
return pStackResult;
}
return null;
}
@@ -380,20 +454,31 @@ public class NEIRecipeWidget extends Widget {
return guiContainer;
}
protected List<PositionedStack> getItems(boolean disableCycledIngredients) {
final PositionedStack pStackResult = this.handlerRef.handler.getResultStack(this.handlerRef.recipeIndex);
final List<PositionedStack> itemStacks = new ArrayList<>();
protected void updatePermutations() {
TemplateRecipeHandler.disableCycledIngredients = disableCycledIngredients;
itemStacks.addAll(this.handlerRef.handler.getIngredientStacks(this.handlerRef.recipeIndex));
itemStacks.addAll(this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex));
TemplateRecipeHandler.disableCycledIngredients = true;
if (pStackResult != null) {
itemStacks.add(pStackResult);
for (PositionedStack pStack : this.handlerRef.handler.getIngredientStacks(this.handlerRef.recipeIndex)) {
if (pStack.items.length > 1) {
final List<ItemStack> permutations = this.permutations
.computeIfAbsent(pStack, stack -> stack.getFilteredPermutations(FavoriteRecipes::contains));
pStack.setPermutationToRender(permutations.get(this.lastcycle % permutations.size()));
}
}
for (PositionedStack pStack : this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex)) {
if (pStack.items.length > 1) {
final List<ItemStack> permutations = this.permutations
.computeIfAbsent(pStack, stack -> stack.getFilteredPermutations(FavoriteRecipes::contains));
pStack.setPermutationToRender(permutations.get(this.lastcycle % permutations.size()));
}
}
final PositionedStack pStackResult = this.handlerRef.handler.getResultStack(this.handlerRef.recipeIndex);
if (pStackResult != null && pStackResult.items.length > 1) {
final List<ItemStack> permutations = this.permutations
.computeIfAbsent(pStackResult, stack -> stack.getFilteredPermutations(FavoriteRecipes::contains));
pStackResult.setPermutationToRender(permutations.get(this.lastcycle % permutations.size()));
}
return itemStacks;
}
}
@@ -18,6 +18,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.ItemInfo;
@@ -311,7 +312,8 @@ public class Recipe {
}
public boolean contains(ItemStack stackA) {
return getPermutations().stream().anyMatch(stackB -> StackInfo.equalItemAndNBT(stackA, stackB, true));
return getPermutations().stream()
.anyMatch(stackB -> NEIClientUtils.areStacksSameTypeWithNBT(stackB, stackA));
}
public List<ItemStack> getPermutations() {
@@ -80,10 +80,10 @@ public class RecipeTooltipLineHandler implements ITooltipLineHandler {
final Dimension size = getSize();
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
GL11.glTranslatef(x, y, 0);
GL11.glScaled(1, 1, 3);
final int zTranslation = GuiContainerManager.TOOLTIP_Z_OFFSET;
GL11.glTranslatef(x, y, zTranslation);
GuiContainerManager.enable2DRender();
GL11.glColor4f(1, 1, 1, 1);
@@ -103,7 +103,7 @@ public class RecipeTooltipLineHandler implements ITooltipLineHandler {
() -> { this.widget.draw(0, 0); });
GL11.glPopAttrib();
GL11.glPopMatrix();
GL11.glTranslatef(-x, -y, -zTranslation);
}
}
@@ -54,7 +54,7 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler {
@Override
public List<PositionedStack> getIngredients() {
return getCycledIngredients(cycleticks / 20, ingredients);
return ingredients;
}
public PositionedStack getResult() {
@@ -64,7 +64,7 @@ public class ShapelessRecipeHandler extends ShapedRecipeHandler {
@Override
public List<PositionedStack> getIngredients() {
return getCycledIngredients(cycleticks / 20, ingredients);
return ingredients;
}
@Override
@@ -9,13 +9,11 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.init.Blocks;
@@ -31,8 +29,6 @@ import org.lwjgl.opengl.GL11;
import com.google.common.base.Stopwatch;
import codechicken.lib.gui.GuiDraw;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.FavoriteRecipes;
import codechicken.nei.ItemList;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
@@ -178,43 +174,16 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
return null;
}
/**
* This will perform default cycling of ingredients, mulitItem capable
*
* @param cycle Current cycle step
* @param ingredients List of ItemStacks to cycle
* @return The provided list of ingredients, with their permutations cycled to a different permutation, if one
* is available
*/
@Deprecated
public List<PositionedStack> getCycledIngredients(int cycle, List<PositionedStack> ingredients) {
if (!NEIClientUtils.shiftKey() && !disableCycledIngredients) {
randomRenderPermutation(ingredients, cycle);
}
return ingredients;
}
public void randomRenderPermutation(List<PositionedStack> stacks, long cycle) {
cycle = NEIClientConfig.useJEIStyledCycledIngredients() ? cycle
: Math.abs(new Random(cycle + offset).nextInt());
for (PositionedStack pStack : stacks) {
if (pStack.items.length <= 1) continue;
final List<ItemStack> items = pStack.getFilteredPermutations(FavoriteRecipes::contains);
pStack.setPermutationToRender(items.get((int) (cycle % items.size())));
}
}
@Deprecated
public void randomRenderPermutation(List<PositionedStack> stacks, long cycle) {}
@Deprecated
public void randomRenderPermutation(PositionedStack stack, long cycle) {
cycle = NEIClientConfig.useJEIStyledCycledIngredients() ? cycle
: Math.abs(new Random(cycle + offset).nextInt());
if (stack.items.length <= 1) return;
final List<ItemStack> items = stack.getFilteredPermutations(FavoriteRecipes::contains);
stack.setPermutationToRender(items.get((int) (cycle % items.size())));
}
public void randomRenderPermutation(PositionedStack stack, long cycle) {}
public void setIngredientPermutation(Collection<PositionedStack> ingredients, ItemStack ingredient) {
for (PositionedStack stack : ingredients) {
@@ -406,8 +375,6 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
*/
public LinkedList<RecipeTransferRect> transferRects = new LinkedList<>();
public static boolean disableCycledIngredients = true;
public TemplateRecipeHandler() {
loadTransferRects();
RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects);
@@ -641,7 +608,7 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
}
public void onUpdate() {
if (!NEIClientUtils.shiftKey()) cycleticks++;
cycleticks++;
}
public boolean hasOverlay(GuiContainer gui, Container container, int recipe) {
@@ -700,49 +667,9 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
@Override
public boolean mouseScrolled(GuiRecipe<?> gui, int scroll, int recipe) {
if (!NEIClientUtils.shiftKey()) return false;
final Point pos = GuiDraw.getMousePosition();
final Point offset = gui.getRecipePosition(recipe);
final Point relMouse = new Point(pos.x - gui.guiLeft - offset.x, pos.y - gui.guiTop - offset.y);
final PositionedStack overStack = getIngredientMouseOver(relMouse.x, relMouse.y, recipe);
if (overStack != null && overStack.items.length > 1) {
final List<ItemStack> items = overStack.getFilteredPermutations();
final int stackIndex = getPermutationIndex(overStack.item, items);
final ItemStack stack = items.get((items.size() - scroll + stackIndex) % items.size());
if (NEIClientConfig.useJEIStyledCycledIngredients()) {
Stream.concat(getIngredientStacks(recipe).stream(), getOtherStacks(recipe).stream())
.filter(pStack -> pStack.containsWithNBT(stack))
.forEach(pStack -> pStack.setPermutationToRender(stack));
} else {
overStack.setPermutationToRender(stack);
}
return true;
}
return false;
}
private int getPermutationIndex(ItemStack stack, List<ItemStack> items) {
for (int index = 0; index < items.size(); index++) {
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(items.get(index), stack)) {
return index;
}
}
return -1;
}
private PositionedStack getIngredientMouseOver(int mousex, int mousey, int recipe) {
return Stream.concat(getIngredientStacks(recipe).stream(), getOtherStacks(recipe).stream())
.filter(pStack -> new Rectangle4i(pStack.relx, pStack.rely, 18, 18).contains(mousex, mousey))
.findFirst().orElse(null);
}
private boolean transferRect(GuiRecipe<?> gui, int recipe, boolean usage) {
Point offset = gui.getRecipePosition(recipe);
return transferRect(gui, transferRects, offset.x, offset.y, usage);
@@ -406,14 +406,46 @@ public class RecipeChainMath {
ItemStack itemStack = prefItem.itemStack;
while (ingrAmount > 0 && shiftAmount < maxAmount) {
long multiplier = 1;
itemStack = itemStack.copy();
itemStack.stackSize = 1;
this.containerItems.add(itemStack);
ingrAmount = shiftContainerItems(itemStack, prefItem.getStackSize(ingrAmount))
* prefItem.fluidCellAmount;
shiftAmount += prefItem.fluidCellAmount;
if (ingrAmount > 0) {
long steps = prefItem.getStackSize(ingrAmount);
final ContainerItemResult result = getToolsContainerItems(itemStack, steps);
if (result.stack == null) {
multiplier = steps / (steps - result.leftSteps);
steps = steps % (steps - result.leftSteps);
} else {
steps = result.leftSteps;
}
if (result.containerItem != null) {
long stackSize = result.containerItem.stackSize * multiplier;
while (stackSize > Integer.MAX_VALUE) {
final ItemStack copy = result.containerItem.copy();
copy.stackSize = Integer.MAX_VALUE;
this.containerItems.add(copy);
stackSize -= copy.stackSize;
}
result.containerItem.stackSize = (int) stackSize;
this.containerItems.add(result.containerItem);
}
if (result.stack != null) {
this.containerItems.add(result.stack);
}
ingrAmount = steps * prefItem.fluidCellAmount;
}
shiftAmount += multiplier * prefItem.fluidCellAmount;
}
} else {
@@ -429,8 +461,9 @@ public class RecipeChainMath {
}
private long shiftContainerItems(ItemStack aStack, long steps) {
final int initialSize = this.containerItems.size();
for (int i = 0; i < this.containerItems.size() && steps > 0; i++) {
for (int i = 0; i < initialSize && steps > 0; i++) {
ItemStack bStack = this.containerItems.get(i);
if (bStack != null && NEIClientUtils.areStacksSameTypeCraftingWithNBT(aStack, bStack)) {
@@ -463,12 +496,12 @@ public class RecipeChainMath {
final NBTTagCompound toolStats = tagCompound.getCompoundTag("GT.ToolStats");
final long maxDamage = toolStats.getLong("MaxDamage");
final long damage = toolStats.getLong("Damage");
final long leftSteps = (maxDamage - damage) / damagePerContainerCraft;
final long leftSteps = (long) Math.ceil((maxDamage - damage) / (double) damagePerContainerCraft);
final long availableSteps = Math.min(steps, Math.max(1, leftSteps));
steps -= availableSteps;
if ((damage + availableSteps * damagePerContainerCraft) == maxDamage || leftSteps <= 0) {
if ((damage + availableSteps * damagePerContainerCraft) >= maxDamage || leftSteps <= 0) {
aStack = null;
} else {
toolStats.setLong("Damage", damage + availableSteps * damagePerContainerCraft);
@@ -208,6 +208,8 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
this.available.setLabelColor(EnumChatFormatting.GREEN);
}
this.size.height = this.size.width = 0;
if (!this.inputs.isEmpty() || !this.outputs.isEmpty()
|| !this.remainder.isEmpty()
|| !this.available.isEmpty()) {
@@ -225,8 +227,6 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
this.size.height += this.inputs.getSize().height + this.outputs.getSize().height
+ this.remainder.getSize().height
+ this.available.getSize().height;
} else {
this.size.height = this.size.width = 0;
}
}
@@ -31,18 +31,21 @@ public class ScrollBar {
}
public enum ScrollPlace {
INSIDE,
OUTSIDE
START,
END
}
private ScrollType scrollType = ScrollType.VERTICAL;
private OverflowType overflowType = OverflowType.SCROLL;
private ScrollPlace scrollPlace = ScrollPlace.INSIDE;
private ScrollPlace scrollPlace = ScrollPlace.END;
private float handleClickOffset = -1;
private int scrollbarSize = 6;
private int thumbPadding = 0;
private int margin = 0;
private int padding = 0;
private int marginStart = 0;
private int marginEnd = 0;
private DrawableResource thumbTexture;
private int thumbSliceStart;
@@ -58,14 +61,13 @@ public class ScrollBar {
public static ScrollBar defaultVerticalBar() {
return new ScrollBar().setScrollbarSize(8)
.setTrackTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 29, 95, 12, 11).build(), 3, 4)
.setThumbTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 21, 96, 8, 9).build(), 3, 2)
.setTrackTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 28, 95, 11, 11).build(), 3, 4)
.setThumbTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 21, 96, 7, 9).build(), 3, 2)
.setThumbPadding(1);
}
public static ScrollBar defaultHorizontalBar() {
return new ScrollBar().setScrollbarSize(8).setOverflowType(OverflowType.SCROLL)
.setScrollPlace(ScrollPlace.INSIDE)
return new ScrollBar().setScrollbarSize(8).setOverflowType(OverflowType.SCROLL).setScrollPlace(ScrollPlace.END)
.setTrackTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 0, 97, 11, 8).build(), 3, 4)
.setThumbTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 12, 97, 9, 7).build(), 3, 2)
.setThumbPadding(1);
@@ -81,13 +83,31 @@ public class ScrollBar {
return this;
}
public ScrollBar setMargin(int margin) {
this.margin = margin;
public ScrollBar setPadding(int padding) {
this.padding = padding;
return this;
}
public int getMargin() {
return this.margin;
public int getPadding() {
return this.padding;
}
public ScrollBar setMarginStart(int start) {
this.marginStart = start;
return this;
}
public int getMarginStart() {
return this.marginStart;
}
public ScrollBar setMarginEnd(int end) {
this.marginEnd = end;
return this;
}
public int getMarginEnd() {
return this.marginEnd;
}
public int getScrollbarSize() {
@@ -153,22 +173,9 @@ public class ScrollBar {
private int getMaxTrackSize(ScrollContainer container) {
if (this.scrollType == ScrollType.HORIZONTAL) {
int visibleSize = container.w;
if (container.canScrollVertical() && container.getVerticalScroll().getScrollPlace() == ScrollPlace.INSIDE) {
visibleSize -= container.getVerticalScroll().getScrollbarSize();
}
return visibleSize;
return container.w - this.marginStart - this.marginEnd;
} else {
int visibleSize = container.h;
if (container.canScrollHorizontal()
&& container.getHorizontalScroll().getScrollPlace() == ScrollPlace.INSIDE) {
visibleSize -= container.getHorizontalScroll().getScrollbarSize();
}
return visibleSize;
return container.h - this.marginStart - this.marginEnd;
}
}
@@ -205,23 +212,41 @@ public class ScrollBar {
}
public Rectangle4i trackBounds(ScrollContainer container) {
if (this.scrollType == ScrollType.HORIZONTAL) {
return new Rectangle4i(
container.x,
container.y + container.h
+ this.margin
- (this.scrollPlace == ScrollPlace.INSIDE ? scrollbarSize : 0),
getMaxTrackSize(container),
scrollbarSize);
if (this.scrollPlace == ScrollPlace.START) {
return new Rectangle4i(
container.x + this.marginStart,
container.y - this.padding - this.scrollbarSize,
getMaxTrackSize(container),
this.scrollbarSize);
} else {
return new Rectangle4i(
container.x + this.marginStart,
container.y + container.h + this.padding,
getMaxTrackSize(container),
this.scrollbarSize);
}
} else {
return new Rectangle4i(
container.x + container.w
+ this.margin
- (this.scrollPlace == ScrollPlace.INSIDE ? scrollbarSize : 0),
container.y,
scrollbarSize,
getMaxTrackSize(container));
if (this.scrollPlace == ScrollPlace.START) {
return new Rectangle4i(
container.x - this.padding - this.scrollbarSize,
container.y + this.marginStart,
this.scrollbarSize,
getMaxTrackSize(container));
} else {
return new Rectangle4i(
container.x + container.w + this.padding,
container.y + this.marginStart,
this.scrollbarSize,
getMaxTrackSize(container));
}
}
}
public Rectangle4i thumbBounds(ScrollContainer container) {
@@ -388,9 +413,36 @@ public class ScrollBar {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (this.scrollType == ScrollType.HORIZONTAL) {
texture.draw(bounds.x, bounds.y, bounds.w, texture.getHeight(), sliceStart, sliceEnd, 0, 0);
if (this.scrollPlace == ScrollPlace.START) {
texture.draw(
bounds.x,
bounds.y + (bounds.h - texture.getHeight()) / 2,
bounds.w,
texture.getHeight(),
sliceStart,
sliceEnd,
0,
0);
} else {
texture.draw(bounds.x, bounds.y, bounds.w, texture.getHeight(), sliceStart, sliceEnd, 0, 0);
}
} else {
texture.draw(bounds.x, bounds.y, texture.getWidth(), bounds.h, 0, 0, sliceStart, sliceEnd);
if (this.scrollPlace == ScrollPlace.START) {
texture.draw(
bounds.x + (bounds.w - texture.getWidth()) / 2,
bounds.y,
texture.getWidth(),
bounds.h,
0,
0,
sliceStart,
sliceEnd);
} else {
texture.draw(bounds.x, bounds.y, texture.getWidth(), bounds.h, 0, 0, sliceStart, sliceEnd);
}
}
}
@@ -14,7 +14,6 @@ import codechicken.nei.NEIClientUtils;
import codechicken.nei.Widget;
import codechicken.nei.WidgetContainer;
import codechicken.nei.scroll.ScrollBar.OverflowType;
import codechicken.nei.scroll.ScrollBar.ScrollPlace;
import codechicken.nei.scroll.ScrollBar.ScrollType;
public class ScrollContainer extends WidgetContainer {
@@ -34,8 +33,10 @@ public class ScrollContainer extends WidgetContainer {
protected int actualWidth = 0;
protected int actualHeight = 0;
protected int marginInline = 0;
protected int marginBlock = 0;
protected int paddingInlineStart = 0;
protected int paddingInlineEnd = 0;
protected int paddingBlockStart = 0;
protected int paddingBlockEnd = 0;
protected final Map<Widget, Point> relativePostion = new HashMap<>();
protected ScrollBar horizontalScrollBar;
@@ -45,30 +46,36 @@ public class ScrollContainer extends WidgetContainer {
public Rectangle4i boundsOutside() {
int width = this.w;
int height = this.h;
int x = this.x;
int y = this.y;
if (canScrollVertical() && (this.verticalScrollBar.getOverflowType() == OverflowType.SCROLL
|| this.verticalScrollBar.getOverflowType() == OverflowType.AUTO)) {
width += this.verticalScrollBar.getMargin();
if (this.verticalScrollBar.getScrollPlace() == ScrollPlace.OUTSIDE) {
width += this.verticalScrollBar.getScrollbarSize();
}
final Rectangle4i trackBounds = this.verticalScrollBar.trackBounds(this);
x = Math.min(x, trackBounds.x);
y = Math.min(y, trackBounds.y);
height = Math.max(this.y + height, trackBounds.y + trackBounds.h) - y;
width = Math.max(this.x + width, trackBounds.x + trackBounds.w) - x;
}
if (canScrollHorizontal() && (this.horizontalScrollBar.getOverflowType() == OverflowType.SCROLL
|| this.horizontalScrollBar.getOverflowType() == OverflowType.AUTO)) {
height += this.horizontalScrollBar.getMargin();
if (this.horizontalScrollBar.getScrollPlace() == ScrollPlace.OUTSIDE) {
height += this.horizontalScrollBar.getScrollbarSize();
}
final Rectangle4i trackBounds = this.horizontalScrollBar.trackBounds(this);
x = Math.min(x, trackBounds.x);
y = Math.min(y, trackBounds.y);
height = Math.max(this.y + height, trackBounds.y + trackBounds.h) - y;
width = Math.max(this.x + width, trackBounds.x + trackBounds.w) - x;
}
return new Rectangle4i(x, y, width, height);
}
public Rectangle4i boundsInside() {
return new Rectangle4i(x, y, getVisibleWidth(), getVisibleHeight());
return new Rectangle4i(
x + this.paddingInlineStart,
y + this.paddingBlockStart,
getVisibleWidth(),
getVisibleHeight());
}
@Override
@@ -92,31 +99,18 @@ public class ScrollContainer extends WidgetContainer {
return this.relativePostion.get(widget);
}
public void setMarginInline(int marginInline) {
this.marginInline = marginInline;
public void setPaddingInline(int start, int end) {
this.paddingInlineStart = start;
this.paddingInlineEnd = end;
}
public void setMarginBlock(int marginBlock) {
this.marginBlock = marginBlock;
}
public int getMarginInline() {
return this.marginInline;
}
public int getMarginBlock() {
return this.marginBlock;
public void setPaddingBlock(int start, int end) {
this.paddingBlockStart = start;
this.paddingBlockEnd = end;
}
public int getVisibleWidth() {
if (canScrollVertical() && this.verticalScrollBar.getScrollPlace() == ScrollPlace.INSIDE
&& (this.verticalScrollBar.getOverflowType() == OverflowType.SCROLL
|| this.verticalScrollBar.getOverflowType() == OverflowType.AUTO)) {
return this.w - this.verticalScrollBar.getScrollbarSize();
}
return this.w;
return this.w - this.paddingInlineStart - this.paddingInlineEnd;
}
public int getActualWidth() {
@@ -125,7 +119,7 @@ public class ScrollContainer extends WidgetContainer {
public boolean setHorizontalScrollOffset(int offset) {
if (!canScrollHorizontal() && this.w < getActualWidth()) {
if (!canScrollHorizontal() && getVisibleWidth() < getActualWidth()) {
offset = 0;
}
@@ -150,9 +144,9 @@ public class ScrollContainer extends WidgetContainer {
}
public boolean canScrollHorizontal() {
return this.horizontalScrollBar != null
&& (this.horizontalScrollBar.getOverflowType() != OverflowType.NONE && this.w < getActualWidth()
|| this.horizontalScrollBar.getOverflowType() == OverflowType.SCROLL);
return this.horizontalScrollBar != null && (this.horizontalScrollBar.getOverflowType() != OverflowType.NONE
&& getVisibleWidth() < getActualWidth()
|| this.horizontalScrollBar.getOverflowType() == OverflowType.SCROLL);
}
public ScrollBar getHorizontalScroll() {
@@ -174,14 +168,7 @@ public class ScrollContainer extends WidgetContainer {
}
public int getVisibleHeight() {
if (canScrollHorizontal() && this.horizontalScrollBar.getScrollPlace() == ScrollPlace.INSIDE
&& (this.horizontalScrollBar.getOverflowType() == OverflowType.SCROLL
|| this.horizontalScrollBar.getOverflowType() == OverflowType.AUTO)) {
return this.h - this.horizontalScrollBar.getScrollbarSize();
}
return this.h;
return this.h - this.paddingBlockStart - this.paddingBlockEnd;
}
public int getActualHeight() {
@@ -190,7 +177,7 @@ public class ScrollContainer extends WidgetContainer {
public boolean setVerticalScrollOffset(int offset) {
if (!canScrollVertical() && this.h < getActualHeight()) {
if (!canScrollVertical() && getVisibleHeight() < getActualHeight()) {
offset = 0;
}
@@ -215,9 +202,9 @@ public class ScrollContainer extends WidgetContainer {
}
public boolean canScrollVertical() {
return this.verticalScrollBar != null
&& (this.verticalScrollBar.getOverflowType() != OverflowType.NONE && this.h < getActualHeight()
|| this.verticalScrollBar.getOverflowType() == OverflowType.SCROLL);
return this.verticalScrollBar != null && (this.verticalScrollBar.getOverflowType() != OverflowType.NONE
&& getVisibleHeight() < getActualHeight()
|| this.verticalScrollBar.getOverflowType() == OverflowType.SCROLL);
}
public ScrollBar getVerticalScroll() {
@@ -245,13 +232,13 @@ public class ScrollContainer extends WidgetContainer {
if (canScrollVertical || canScrollHorizontal) {
GuiHelper.useScissor(
this.x,
this.y,
getVisibleWidth(),
getVisibleHeight(),
this.x + this.paddingInlineStart,
this.y + this.paddingBlockStart,
this.w - this.paddingInlineStart - this.paddingInlineEnd,
this.h - this.paddingBlockStart - this.paddingBlockEnd,
() -> drawContent(mousex, mousey));
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
if (canScrollVertical) {
this.verticalScrollBar.draw(this, mousex, mousey, getScrollBarOpacity());
@@ -295,12 +282,15 @@ public class ScrollContainer extends WidgetContainer {
super.update();
for (Widget widget : this.widgets) {
this.actualWidth = Math.max(this.actualWidth, widget.x + widget.w + this.marginInline * 2);
this.actualHeight = Math.max(this.actualHeight, widget.y + widget.h + this.marginBlock * 2);
final int x = this.x + this.paddingInlineStart - this.xScroll;
final int y = this.y + this.paddingBlockStart - this.yScroll;
widget.x += this.marginInline + this.x - this.xScroll;
widget.y += this.marginBlock + this.y - this.yScroll;
for (Widget widget : this.widgets) {
this.actualWidth = Math.max(this.actualWidth, widget.x + widget.w);
this.actualHeight = Math.max(this.actualHeight, widget.y + widget.h);
widget.x += x;
widget.y += y;
}
if (this.fade > 0) {
@@ -0,0 +1,5 @@
# This file contains a list of GUIs that can use the DefaultBookmarkContainerHandler for bookmarks.
# It serves as an alternative to API.registerBookmarkContainerHandler and is intended for cases
# where you can't modify the mod itself and its GUI doesn't have custom slots.
# Each line in this file should either be a comment (starting with '#') or a guiContainer class name.
# If you delete this file, it will be regenerated with the default bookmark containers list.
@@ -1,4 +1,5 @@
# Each line in this file should either be a comment (line starts with '#'), handler name or handler id.
# This file contains a list of GUIs for which craftable item panels will not work.
# Each line in this file should either be a comment (line starts with '#'), or guiContainer class name.
# If you delete this file, it will be regenerated with the default handlers list.
appeng.client.gui.implementations.GuiPatternTerm
appeng.client.gui.implementations.GuiPatternTermEx
@@ -65,6 +65,7 @@ nei.itempanel.open_crafting=Recipe to make this item
nei.itempanel.open_usage=Recipes that use this item
nei.itempanel.copy_name=Copy Item Name
nei.itempanel.copy_oredict=Copy Item OreDictionary
nei.itempanel.copy_id=Copy Item ID
nei.itempanel.chat_link_item=Send item link to chat
nei.enchant=Enchant
@@ -192,6 +193,7 @@ nei.options.keys.gui.next_tooltip=Next Tooltip
nei.options.keys.gui.copy_name=Copy Item Name
nei.options.keys.gui.craft_items=Craft Items
nei.options.keys.gui.copy_oredict=Copy Item OreDictionary
nei.options.keys.gui.copy_id=Copy Item ID
nei.options.keys.gui.chat_link_item=Send item link to chat
nei.options.keys.gui.itemzoom_toggle=Toggle Item Zoom
nei.options.keys.gui.itemzoom_hold=Hold to Display Item Zoom
@@ -280,8 +282,9 @@ nei.options.inventory.guirecipe.infiniteScroll=Use Infinite Scroll
nei.options.inventory.guirecipe.infiniteScroll.true=Yes
nei.options.inventory.guirecipe.infiniteScroll.false=No
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst=JEI Style Recipe Catalysts
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.true=Yes
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.false=No
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.0=None
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.1=Grid
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.2=Scroll
nei.options.inventory.guirecipe.cycledIngredientsTooltip=Cycled Ingredients Tooltip
nei.options.inventory.guirecipe.cycledIngredientsTooltip.true=Show
nei.options.inventory.guirecipe.cycledIngredientsTooltip.false=Hide
@@ -350,9 +353,6 @@ nei.options.inventory.optimize_gui_overlap_computation.false=No
nei.options.inventory.autocrafting=Autocrafting
nei.options.inventory.autocrafting.true=Enabled
nei.options.inventory.autocrafting.false=Disabled
nei.options.inventory.guirecipe.jeiStyleCycledIngredients=JEI styled cycled ingredients
nei.options.inventory.guirecipe.jeiStyleCycledIngredients.true=Yes
nei.options.inventory.guirecipe.jeiStyleCycledIngredients.false=No
nei.options.inventory.guirecipe.shiftOverlayRecipe=Require holding shift to move items when overlaying recipe
nei.options.inventory.guirecipe.shiftOverlayRecipe.true=Yes
nei.options.inventory.guirecipe.shiftOverlayRecipe.false=No
@@ -199,8 +199,9 @@ nei.options.inventory.guirecipe.slotHighlightPresent=Подсвечивать п
nei.options.inventory.guirecipe.slotHighlightPresent.true=Да
nei.options.inventory.guirecipe.slotHighlightPresent.false=Нет
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst=Катализаторы рецептов в стиле JEI
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.true=Да
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.false=Нет
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.0=Нет
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.1=Грид
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.2=Скролл
nei.options.inventory.guirecipe.cycledIngredientsTooltip=Подсказка циклических ингредиентов
nei.options.inventory.guirecipe.cycledIngredientsTooltip.true=Показывать
nei.options.inventory.guirecipe.cycledIngredientsTooltip.false=Скрыть
@@ -248,9 +249,6 @@ nei.options.inventory.guirecipe.creativeTabStyle.false=JEI
nei.options.inventory.optimize_gui_overlap_computation=Оптимизация вычислений при перекрытии GUI
nei.options.inventory.optimize_gui_overlap_computation.true=Да
nei.options.inventory.optimize_gui_overlap_computation.false=Нет
nei.options.inventory.guirecipe.jeiStyleCycledIngredients=Циклические ингредиенты в стиле JEI
nei.options.inventory.guirecipe.jeiStyleCycledIngredients.true=Да
nei.options.inventory.guirecipe.jeiStyleCycledIngredients.false=Нет
nei.options.inventory.guirecipe.shiftOverlayRecipe=Требовать удержание Shift для перемещения предметов при отображении рецепта
nei.options.inventory.guirecipe.shiftOverlayRecipe.true=Да
nei.options.inventory.guirecipe.shiftOverlayRecipe.false=Нет
@@ -111,6 +111,7 @@ nei.options.keys.gui.getprevioussearch=上一个搜索
nei.options.keys.gui.getnextsearch=下一个搜索
nei.options.keys.gui.copy_name=复制物品名称
nei.options.keys.gui.copy_oredict=复制物品矿词词典
nei.options.keys.gui.copy_id=复制物品ID
nei.options.keys.world=世界
nei.options.keys.world.chunkoverlay=区块(chunks)边界显示
nei.options.keys.world.moboverlay=刷怪区域显示
@@ -135,8 +136,6 @@ nei.options.inventory.guirecipe.jeiStyleTabs=JEI标签页
nei.options.inventory.guirecipe.jeiStyleTabs.true=是
nei.options.inventory.guirecipe.jeiStyleTabs.false=否 [不会吧]
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst=JEI风格可执行合成表机器显示[测试中]
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.true=是
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.false=否
nei.options.inventory.bookmarks.animation=REI风格书签动画
nei.options.inventory.bookmarks.animation.true=是
nei.options.inventory.bookmarks.animation.false=否
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB