Compare commits

...
10 changed files with 102 additions and 34 deletions

No files matched your search

+23 -4
View File
@@ -1,4 +1,4 @@
//version: 1704751096
//version: 1705357285
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -122,6 +122,7 @@ propertyDefaultIfUnset("modrinthProjectId", "")
propertyDefaultIfUnset("modrinthRelations", "")
propertyDefaultIfUnset("curseForgeProjectId", "")
propertyDefaultIfUnset("curseForgeRelations", "")
propertyDefaultIfUnset("versionPattern", "")
propertyDefaultIfUnset("minimizeShadowedDependencies", true)
propertyDefaultIfUnset("relocateShadowedDependencies", true)
// Deprecated properties (kept for backwards compat)
@@ -370,6 +371,7 @@ catch (Exception ignored) {
// Pulls version first from the VERSION env and then git tag
String identifiedVersion
String versionOverride = System.getenv("VERSION") ?: null
boolean checkVersion = false
try {
// Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty
if (versionOverride == null) {
@@ -388,6 +390,8 @@ try {
}
} else if (isDirty) {
identifiedVersion += "-${branchName}+${gitDetails.gitHash}-dirty"
} else {
checkVersion = true
}
} else {
identifiedVersion = versionOverride
@@ -409,6 +413,8 @@ ext {
if (identifiedVersion == versionOverride) {
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
} else if (checkVersion && versionPattern && !(identifiedVersion ==~ versionPattern)) {
throw new GradleException("Invalid version: '$identifiedVersion' does not match version pattern '$versionPattern'")
}
group = "com.github.GTNewHorizons"
@@ -428,18 +434,31 @@ minecraft {
for (f in replaceGradleTokenInFile.split(',')) {
tagReplacementFiles.add f
}
out.style(Style.Info).text('replaceGradleTokenInFile is deprecated! Consider using generateGradleTokenClass.').println()
}
if (gradleTokenModId) {
injectedTags.put gradleTokenModId, modId
if (replaceGradleTokenInFile) {
injectedTags.put gradleTokenModId, modId
} else {
out.style(Style.Failure).text('gradleTokenModId is deprecated! The field will no longer be generated.').println()
}
}
if (gradleTokenModName) {
injectedTags.put gradleTokenModName, modName
if (replaceGradleTokenInFile) {
injectedTags.put gradleTokenModName, modName
} else {
out.style(Style.Failure).text('gradleTokenModName is deprecated! The field will no longer be generated.').println()
}
}
if (gradleTokenVersion) {
injectedTags.put gradleTokenVersion, modVersion
}
if (gradleTokenGroupName) {
injectedTags.put gradleTokenGroupName, modGroup
if (replaceGradleTokenInFile) {
injectedTags.put gradleTokenGroupName, modGroup
} else {
out.style(Style.Failure).text('gradleTokenGroupName is deprecated! The field will no longer be generated.').println()
}
}
if (enableGenericInjection.toBoolean()) {
injectMissingGenerics.set(true)
+3 -3
View File
@@ -28,10 +28,10 @@ developmentEnvironmentUserName = Developer
# Leave these properties empty to skip individual token replacements
# Generate a class with String fields for the mod id, name, version and group name named with the fields below
generateGradleTokenClass = codechicken.nei.Tags
gradleTokenModId = MODID
gradleTokenModName = MODNAME
gradleTokenModId =
gradleTokenModName =
gradleTokenVersion = VERSION
gradleTokenGroupName = GROUPNAME
gradleTokenGroupName =
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
@@ -269,27 +269,23 @@ public class BookmarkCraftingChain {
return false;
}
int shift = 0;
int minRecipeIndex = 0;
int minShift = 0x7fffff;
int minShift = Integer.MAX_VALUE;
for (CraftingChainItem item : request.outputs.get(stackIndex)) {
if (!request.initialItems.contains(item.recipeIndex) && item.factor > 0) {
long ingrCount = calculateCount(request, request.inputs.get(item.stackIndex));
long outputCount = calculateCount(request, request.outputs.get(item.stackIndex));
long shift = (ingrCount - outputCount) / item.factor;
while ((outputCount + item.factor * shift) < ingrCount && shift < minShift) {
shift++;
}
if (shift < minShift) {
minShift = shift;
if (shift > 0 && shift < minShift) {
minShift = (int) shift;
minRecipeIndex = item.recipeIndex;
}
}
}
if (minShift < 0x7fffff) {
if (minShift < Integer.MAX_VALUE) {
request.multiplier.put(minRecipeIndex, request.multiplier.get(minRecipeIndex) + minShift);
return true;
}
@@ -456,8 +456,15 @@ public class BookmarkPanel extends PanelWidget {
}
if (NEIClientUtils.shiftKey() && !LayoutManager.bookmarkPanel.inEditingState()) {
final ItemPanelSlot focused = getSlotMouseOver(mousex, mousey);
this.focusedGroupId = focused != null ? this.metadata.get(focused.slotIndex).groupId : -1;
final int rowId = getHoveredRowIndex(true);
if (rowId != -1) {
this.focusedGroupId = getRowGroupId(rowId);
} else {
final ItemPanelSlot focused = getSlotMouseOver(mousex, mousey);
this.focusedGroupId = focused != null ? this.metadata.get(focused.slotIndex).groupId : -1;
}
} else {
this.focusedGroupId = -1;
}
@@ -1138,7 +1145,7 @@ public class BookmarkPanel extends PanelWidget {
if (rightclick) {
return false;
}
return pullBookmarkItems();
return pullBookmarkItems(-1, false);
}
@Override
@@ -1278,6 +1285,12 @@ public class BookmarkPanel extends PanelWidget {
return null;
}
protected int getHoveredGroupId() {
final BookmarkGrid BGrid = (BookmarkGrid) grid;
final int overRowIndex = BGrid.getHoveredRowIndex(true);
return overRowIndex >= 0 ? BGrid.getRowGroupId(overRowIndex) : -1;
}
protected String getNamespaceLabelText(boolean shortFormat) {
String activePage = String.valueOf(activeNamespaceIndex + 1);
@@ -1941,6 +1954,14 @@ public class BookmarkPanel extends PanelWidget {
@Override
public boolean handleKeyPress(int keyID, char keyChar) {
if (NEIClientConfig.isKeyHashDown("gui.bookmark_pull_items")) {
return this.pullBookmarkItems(this.getHoveredGroupId(), false);
}
if (NEIClientConfig.isKeyHashDown("gui.bookmark_pull_items_ingredients")) {
return this.pullBookmarkItems(this.getHoveredGroupId(), true);
}
if (NEIClientConfig.isKeyHashDown("gui.bookmark_recipe")) {
final BookmarkGrid BGrid = (BookmarkGrid) grid;
final int overRowIndex = BGrid.getHoveredRowIndex(true);
@@ -1962,7 +1983,7 @@ public class BookmarkPanel extends PanelWidget {
if (this.sortableItem != null) {
this.sortableItem = null;
this.mouseDownSlot = -1;
grid.onGridChanged(); /* make sure grid redraws the new item */
grid.onItemsChanged(); /* make sure grid redraws the new item */
saveBookmarks();
} else if (this.groupingItem != null) {
final BookmarkGrid BGrid = (BookmarkGrid) grid;
@@ -2078,7 +2099,7 @@ public class BookmarkPanel extends PanelWidget {
return null;
}
public boolean pullBookmarkItems() {
public boolean pullBookmarkItems(int groupId, boolean onlyIngredients) {
IBookmarkContainerHandler containerHandler = BookmarkContainerInfo
.getBookmarkContainerHandler(getGuiContainer());
@@ -2086,7 +2107,37 @@ public class BookmarkPanel extends PanelWidget {
return false;
}
containerHandler.pullBookmarkItemsFromContainer(getGuiContainer(), ((BookmarkGrid) grid).realItems);
final BookmarkGrid BGrid = (BookmarkGrid) grid;
final ArrayList<ItemStack> items = new ArrayList<>();
final ItemStackMap<Integer> uniqueItems = new ItemStackMap<>();
final BookmarkGroup group = groupId >= 0 ? BGrid.groups.get(groupId) : null;
ItemStackMetadata meta;
for (int idx = 0; idx < BGrid.realItems.size(); idx++) {
meta = BGrid.metadata.get(idx);
if (groupId == -1 || groupId == meta.groupId) {
final ItemStack stack = BGrid.getItem(idx);
if (!onlyIngredients || meta.ingredient && (group == null || group.crafting == null
|| group.crafting.inputs.containsKey(BGrid.realItems.get(idx)))) {
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(stack);
uniqueItems.put(stack, uniqueItems.getOrDefault(stack, 0) + nbTag.getInteger("Count"));
}
}
}
for (ItemStackMap.Entry<Integer> entry : uniqueItems.entries()) {
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(entry.key);
items.add(StackInfo.loadFromNBT(nbTag, entry.value));
}
if (items.isEmpty()) {
return false;
}
containerHandler.pullBookmarkItemsFromContainer(getGuiContainer(), items);
return true;
}
}
@@ -218,8 +218,7 @@ public class ClientHandler {
try (FileReader reader = new FileReader(file)) {
NEIClientConfig.logger.info("Loading hidden handlers from file {}", file);
NEIClientConfig.hiddenHandlerRegex = IOUtils.readLines(reader).stream()
.filter((line) -> !line.startsWith("#")).map(Pattern::compile)
NEIClientConfig.hiddenHandlers = IOUtils.readLines(reader).stream().filter((line) -> !line.startsWith("#"))
.collect(Collectors.toCollection(HashSet::new));
} catch (IOException e) {
NEIClientConfig.logger.error("Failed to load hidden handlers from file {}", file, e);
@@ -203,6 +203,11 @@ public class ItemStackMap<T> {
return map == null ? null : map.get(key);
}
public T getOrDefault(ItemStack key, T defaultValue) {
T e = get(key);
return e == null ? defaultValue : e;
}
public void put(ItemStack key, T value) {
if (key == null || key.getItem() == null) return;
@@ -225,10 +225,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
return true;
}
if (NEIClientConfig.isKeyHashDown("gui.bookmark_pull_items")) {
return bookmarkPanel.pullBookmarkItems();
}
if (isEnabled() && !isHidden()) {
for (Widget widget : controlWidgets) if (inputFocused == null) widget.lastKeyTyped(keyID, keyChar);
}
@@ -85,9 +85,8 @@ public class NEIClientConfig {
// We use regex here so that we can apply the height hack to entire mods with one entry.
public static HashSet<Pattern> heightHackHandlerRegex = new HashSet<>();
// Set of regexes matching handler Name of handlers that need hide.
// We use regex here so that we can hide to entire mods with one entry.
public static HashSet<Pattern> hiddenHandlerRegex = new HashSet<>();
// Set of handler Name or Id of handlers that need hide.
public static HashSet<String> hiddenHandlers = new HashSet<>();
// Map of handler ID to sort order.
// Handlers will be sorted in ascending order, so smaller numbers show up earlier.
@@ -362,6 +361,7 @@ public class NEIClientConfig {
"gui.bookmark_recipe_count",
Keyboard.KEY_A + NEIClientUtils.SHIFT_HASH + NEIClientUtils.CTRL_HASH);
API.addHashBind("gui.bookmark_pull_items", Keyboard.KEY_V);
API.addHashBind("gui.bookmark_pull_items_ingredients", Keyboard.KEY_V + NEIClientUtils.SHIFT_HASH);
API.addHashBind("gui.overlay", Keyboard.KEY_S);
API.addHashBind("gui.overlay_use", Keyboard.KEY_S + NEIClientUtils.SHIFT_HASH);
API.addHashBind("gui.overlay_hide", Keyboard.KEY_S + NEIClientUtils.CTRL_HASH);
@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import net.minecraft.client.Minecraft;
@@ -13,6 +12,8 @@ import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import com.google.common.base.Objects;
import codechicken.core.TaskProfiler;
import codechicken.nei.ItemList;
import codechicken.nei.NEIClientConfig;
@@ -90,8 +91,8 @@ class RecipeHandlerQuery<T extends IRecipeHandler> {
}
private boolean isHidden(T handler) {
return NEIClientConfig.hiddenHandlerRegex.stream()
.map(pattern -> pattern.matcher(RecipeCatalysts.getRecipeID(handler))).anyMatch(Matcher::matches);
final String handlerId = Objects.firstNonNull(handler.getOverlayIdentifier(), handler.getHandlerId());
return NEIClientConfig.hiddenHandlers.stream().anyMatch(h -> h.equals(handlerId));
}
private void printLog(Throwable t) {
@@ -112,6 +112,7 @@ nei.options.keys.gui.bookmark=Add Bookmark
nei.options.keys.gui.bookmark_recipe=Add Bookmark with Recipe
nei.options.keys.gui.bookmark_count=Add Bookmark with Count
nei.options.keys.gui.bookmark_pull_items=Pull all Bookmarked Items
nei.options.keys.gui.bookmark_pull_items_ingredients=Pull all Bookmarked Ingredients
nei.options.keys.gui.bookmark_recipe_count=Add Bookmark with Recipe & Count
nei.options.keys.gui.hide_bookmarks=Toggle Bookmark Panel Visibility
nei.options.keys.gui.overlay=Overlay Recipe