Compare commits

..
Author SHA1 Message Date
miozune 9b73b94d16 Fix meta id for MAX Bio Lab (#338) 2023-01-28 17:24:57 +01:00
Raven Szewczyk e133afc774 Fix jar resource loading on newer Java versions (still works on 8) (#337) 2023-01-25 20:50:48 +01:00
asdflj 75ff631f16 bookmark item stack size readable conversion (#335) 2023-01-23 10:59:29 +01:00
Raven Szewczyk 6f5d45c4ea Update CodeChicken dependencies (#330) 2023-01-05 12:18:21 +00:00
miozune fb51475bb9 Fix stack size of permutations on PositionedStack (#327) 2022-12-26 19:14:45 +01:00
Jason Mitchell 99ec3a4204 Add cf & modrinth deps (#325)
* Add cf & modrinth deps

* rm jitpack

* Spotless, you are annoying sometimes
2022-12-22 20:58:39 +01:00
miozune 8c4d609e4c Expose some members in GuiContainerManager (#324) 2022-12-21 10:37:43 +01:00
14 changed files with 211 additions and 52 deletions

No files matched your search

+20 -7
View File
@@ -1,4 +1,4 @@
//version: 1667597057
//version: 1671313514
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -31,7 +31,7 @@ buildscript {
url 'https://maven.minecraftforge.net'
}
maven {
// GTNH ForgeGradle Fork
// GTNH ForgeGradle and ASM Fork
name = "GTNH Maven"
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
}
@@ -45,7 +45,9 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2.11'
//Overwrite the current ASM version to fix shading newer than java 8 applicatations.
classpath 'org.ow2.asm:asm-debug-all-custom:5.0.3'
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2.13'
}
}
plugins {
@@ -278,7 +280,9 @@ minecraft {
runDir = 'run'
if (replaceGradleTokenInFile) {
replaceIn replaceGradleTokenInFile
for (f in replaceGradleTokenInFile.split(',')) {
replaceIn f
}
if (gradleTokenModId) {
replace gradleTokenModId, modId
}
@@ -330,6 +334,12 @@ repositories {
name = "GTNH Maven"
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
}
if (usesMixinDebug.toBoolean()) {
maven {
name = "Fabric Maven"
url = "https://maven.fabricmc.net/"
}
}
}
}
@@ -338,10 +348,13 @@ dependencies {
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
annotationProcessor('com.google.guava:guava:24.1.1-jre')
annotationProcessor('com.google.code.gson:gson:2.8.6')
annotationProcessor('org.spongepowered:mixin:0.8.5-GTNH:processor')
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.3:processor')
if (usesMixinDebug.toBoolean()) {
runtimeOnly('org.jetbrains:intellij-fernflower:1.2.1.16')
}
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
compile('com.gtnewhorizon:gtnhmixins:2.0.1')
compile('com.gtnewhorizon:gtnhmixins:2.1.3')
}
}
@@ -694,7 +707,7 @@ if (modrinthProjectId.size() != 0 && System.getenv("MODRINTH_TOKEN") != null) {
}
}
if (usesMixins.toBoolean()) {
addModrinthDep("required", "version", "gtnhmixins")
addModrinthDep("required", "project", "gtnhmixins")
}
tasks.modrinth.dependsOn(build)
tasks.publish.dependsOn(tasks.modrinth)
+2 -2
View File
@@ -1,7 +1,7 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.5:dev')
compile('com.github.GTNewHorizons:CodeChickenCore:1.1.6:dev')
compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.6:dev')
compile('com.github.GTNewHorizons:CodeChickenCore:1.1.7:dev')
shadowImplementation('org.apache.commons:commons-csv:1.8')
}
+28 -1
View File
@@ -59,5 +59,32 @@ containsMixinsAndOrCoreModOnly = true
# responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = true
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
# The project's numeric ID on CurseForge. You can find this in the About Project box.
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId = 358228
modrinthProjectId = iNPc3Onu
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project id of the other mod.
curseForgeRelations = requiredDependency:codechickencore-unofficial;requiredDependency:codechickenlib-unofficial
# Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token.
# The project's ID on Modrinth. Can be either the slug or the ID.
# Leave this empty if you don't want to publish on Modrinth.
modrinthProjectId = notenoughitems-unofficial
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
modrinthRelations = required-project:codechickenlib-unofficial;required-project:codechickencore-unofficial
-3
View File
@@ -12,7 +12,4 @@ repositories {
includeGroup 'curse.maven'
}
}
maven {
url 'https://jitpack.io'
}
}
@@ -11,6 +11,7 @@ import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.BookmarkRecipeId;
import codechicken.nei.recipe.StackInfo;
import codechicken.nei.util.NBTJson;
import codechicken.nei.util.ReadableNumberConverter;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
@@ -23,11 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.*;
import javax.annotation.Nullable;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
@@ -69,7 +66,7 @@ public class BookmarkPanel extends PanelWidget {
TODO_LIST
}
protected static class BookmarkGrid extends ItemsGrid {
public static class BookmarkGrid extends ItemsGrid {
protected static final float SCALE_SPEED = 0.1f;
@@ -331,16 +328,15 @@ public class BookmarkPanel extends PanelWidget {
|| LayoutManager.bookmarkPanel.sortedStackIndex != idx) {
final ItemStack stack = getItem(idx);
final BookmarkStackMeta meta = getMetadata(idx);
final String stackSize = meta.factor < 0 || meta.fluidDisplay ? "" : String.valueOf(stack.stackSize);
final String stackSize = meta.factor < 0 || meta.fluidDisplay
? ""
: ReadableNumberConverter.INSTANCE.toWideReadableForm(stack.stackSize);
if (animation.containsKey(stack) && animation.get(stack) < 1) {
final float currentScale = animation.get(stack) + SCALE_SPEED;
animation.put(stack, currentScale);
drawPoppingItem(rect, stack, stackSize, currentScale);
} else {
GuiContainerManager.drawItem(rect.x + 1, rect.y + 1, stack, true, stackSize);
if (meta.recipeId != null && !meta.ingredient && NEIClientConfig.showRecipeMarker()) {
drawRecipeMarker(rect.x, rect.y, GuiContainerManager.getFontRenderer(stack));
}
@@ -433,6 +429,23 @@ public class BookmarkPanel extends PanelWidget {
return String.format("(%d/%d) [%d]", getPage(), Math.max(1, getNumPages()), size);
}
public void addItem(ItemStack itemStack) {
addItem(itemStack, true);
}
public void addItem(ItemStack itemStack, boolean saveStackSize) {
final BookmarkGrid BGrid = (BookmarkGrid) grid;
int idx = BGrid.indexOf(itemStack, true);
if (idx != -1) {
BGrid.removeItem(idx);
}
addOrRemoveItem(itemStack, null, null, false, saveStackSize);
}
public int getNameSpaceSize() {
return namespaces.size();
}
public void addOrRemoveItem(ItemStack stackA) {
addOrRemoveItem(stackA, null, null, false, false);
}
@@ -518,7 +531,7 @@ public class BookmarkPanel extends PanelWidget {
BookmarkRecipeId recipeId = ((BookmarkGrid) grid).findRecipeId(stackA);
if (recipeId == null) {
for (int idx = 0; idx < namespaces.size() && recipeId == null; idx++) {
for (int idx = 0; idx < getNameSpaceSize() && recipeId == null; idx++) {
if (idx == activeNamespaceIndex) continue;
recipeId = namespaces.get(idx).findRecipeId(stackA);
}
@@ -535,18 +548,18 @@ public class BookmarkPanel extends PanelWidget {
protected int fixCountOfNamespaces() {
if (namespaces.get(namespaces.size() - 1).size() > 0) {
if (namespaces.get(getNameSpaceSize() - 1).size() > 0) {
namespaces.add(new BookmarkGrid());
} else if (activeNamespaceIndex == namespaces.size() - 2 && grid.size() == 0) {
namespaces.remove(namespaces.size() - 1);
} else if (activeNamespaceIndex == getNameSpaceSize() - 2 && grid.size() == 0) {
namespaces.remove(getNameSpaceSize() - 1);
}
return namespaces.size();
return getNameSpaceSize();
}
protected boolean removeEmptyNamespaces() {
if (activeNamespaceIndex != namespaces.size() - 1 && grid.size() == 0) {
if (activeNamespaceIndex != getNameSpaceSize() - 1 && grid.size() == 0) {
namespaces.remove(activeNamespaceIndex);
grid = namespaces.get(activeNamespaceIndex);
return true;
@@ -564,7 +577,7 @@ public class BookmarkPanel extends PanelWidget {
removeEmptyNamespaces();
if (activeNamespaceIndex == 0) {
activeNamespaceIndex = namespaces.size() - 1;
activeNamespaceIndex = getNameSpaceSize() - 1;
} else {
activeNamespaceIndex--;
}
@@ -638,7 +651,7 @@ public class BookmarkPanel extends PanelWidget {
ArrayList<String> strings = new ArrayList<>();
for (int grpIdx = 0; grpIdx < namespaces.size() - 1; grpIdx++) {
for (int grpIdx = 0; grpIdx < getNameSpaceSize() - 1; grpIdx++) {
final BookmarkGrid grid = namespaces.get(grpIdx);
JsonObject settings = new JsonObject();
@@ -1121,8 +1134,10 @@ public class BookmarkPanel extends PanelWidget {
meta.factor = factor;
} else {
meta.factor = nbTag.getInteger("Count") == factor && shift < 0 ? -1 * factor : factor;
nbTag.setInteger("Count", Math.max(nbTag.getInteger("Count") + factor * shift, factor));
BGrid.replaceItem(slotIndex, StackInfo.loadFromNBT(nbTag));
if ((long) nbTag.getInteger("Count") + ((long) factor * shift) <= Integer.MAX_VALUE) {
nbTag.setInteger("Count", Math.max(nbTag.getInteger("Count") + factor * shift, factor));
BGrid.replaceItem(slotIndex, StackInfo.loadFromNBT(nbTag));
}
}
}
}
@@ -71,6 +71,11 @@ public class ItemsGrid {
return -1;
}
public void setPage(int page) {
this.page = Math.max(0, Math.min(page, getNumPages() - 1));
onGridChanged();
}
public int getPage() {
return page + 1;
}
@@ -43,7 +43,11 @@ public class PositionedStack {
if (item.getItemDamage() == Short.MAX_VALUE) {
List<ItemStack> permutations = ItemList.itemMap.get(item.getItem());
if (!permutations.isEmpty()) {
for (ItemStack stack : permutations) stacks.add(stack.copy());
for (ItemStack stack : permutations) {
ItemStack toAdd = stack.copy();
toAdd.stackSize = item.stackSize;
stacks.add(toAdd);
}
} else {
ItemStack base = new ItemStack(item.getItem(), item.stackSize);
base.stackTagCompound = item.stackTagCompound;
@@ -152,7 +152,7 @@ public class GuiContainerManager {
return namelist;
}
protected static String itemCountDetails(ItemStack stack) {
public static String itemCountDetails(ItemStack stack) {
final FluidStack fluid = StackInfo.getFluid(stack);
int maxStackSize = stack.getMaxStackSize();
int stackSize = stack.stackSize;
@@ -336,7 +336,7 @@ public class GuiContainerManager {
}
private int clickHandled = 0;
private final List<IContainerTooltipHandler> instanceTooltipHandlers;
public final List<IContainerTooltipHandler> instanceTooltipHandlers;
public GuiContainerManager(GuiContainer screen) {
window = screen;
@@ -479,14 +479,7 @@ public class GuiContainerManager {
font = getFontRenderer(stack);
if (stack != null) {
tooltip = itemDisplayNameMultiline(stack, window, true);
if (stack.stackSize != Integer.MAX_VALUE && NEIClientUtils.shiftKey()) {
final String itemCount = itemCountDetails(stack);
if (itemCount != null) {
tooltip.add(String.format(EnumChatFormatting.GRAY + itemCount + EnumChatFormatting.RESET));
}
}
applyItemCountDetails(tooltip, stack);
}
synchronized (instanceTooltipHandlers) {
@@ -506,6 +499,16 @@ public class GuiContainerManager {
return window.mc.thePlayer.inventory.getItemStack() == null;
}
public static void applyItemCountDetails(List<String> tooltip, ItemStack stack) {
if (stack.stackSize != Integer.MAX_VALUE && NEIClientUtils.shiftKey()) {
final String itemCount = itemCountDetails(stack);
if (itemCount != null) {
tooltip.add(String.format(EnumChatFormatting.GRAY + itemCount + EnumChatFormatting.RESET));
}
}
}
public void renderSlotUnderlay(Slot slot) {
for (IContainerDrawHandler drawHandler : drawHandlers) drawHandler.renderSlotUnderlay(window, slot);
}
@@ -190,7 +190,7 @@ public abstract class GuiRecipeTab extends Widget {
final boolean fromJar = NEIClientConfig.loadHandlersFromJar();
NEIClientConfig.logger.info("Loading handler info from " + (fromJar ? "JAR" : "Config"));
handlerMap.clear();
URL handlerUrl = Thread.currentThread().getContextClassLoader().getResource("assets/nei/csv/handlers.csv");
URL handlerUrl = GuiRecipeTab.class.getResource("/assets/nei/csv/handlers.csv");
URL url;
if (fromJar) {
@@ -120,7 +120,7 @@ public class RecipeCatalysts {
final boolean fromJar = NEIClientConfig.loadCatalystsFromJar();
NEIClientConfig.logger.info("Loading catalyst info from " + (fromJar ? "JAR" : "Config"));
recipeCatalystMap.clear();
URL handlerUrl = Thread.currentThread().getContextClassLoader().getResource("assets/nei/csv/catalysts.csv");
URL handlerUrl = RecipeCatalysts.class.getResource("/assets/nei/csv/catalysts.csv");
URL url;
if (fromJar) {
@@ -165,8 +165,7 @@ public class StackInfo {
}
} else {
final URL filterUrl =
Thread.currentThread().getContextClassLoader().getResource("assets/nei/guidfilters.cfg");
final URL filterUrl = StackInfo.class.getResource("/assets/nei/guidfilters.cfg");
try (BufferedReader reader = new BufferedReader(new InputStreamReader(filterUrl.openStream()))) {
itemStrings = IOUtils.readLines(reader);
@@ -0,0 +1,96 @@
package codechicken.nei.util;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.Format;
/**
* copy from ae2
* Converter class to convert a large number into a SI system.
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public enum ReadableNumberConverter {
INSTANCE;
/**
* Defines the base for a division, non-si standard could be 1024 for kilobytes
*/
private static final int DIVISION_BASE = 1000;
/**
* String representation of the sorted postfixes
*/
private static final char[] ENCODED_POSTFIXES = "KMGTPE".toCharArray();
private final Format format;
/**
* Initializes the specific decimal format with special format for negative and positive numbers
*/
ReadableNumberConverter() {
final DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setDecimalSeparator('.');
symbols.setGroupingSeparator(',');
final DecimalFormat format = new DecimalFormat(".#;0.#");
format.setDecimalFormatSymbols(symbols);
format.setRoundingMode(RoundingMode.DOWN);
this.format = format;
}
public String toSlimReadableForm(final long number) {
return this.toReadableFormRestrictedByWidth(number, 3);
}
/**
* restricts a string representation of a number to a specific width
*
* @param number to be formatted number
* @param width width limitation of the resulting number
* @return formatted number restricted by the width limitation
*/
private String toReadableFormRestrictedByWidth(final long number, final int width) {
assert number >= 0;
// handles low numbers more efficiently since no format is needed
final String numberString = Long.toString(number);
int numberSize = numberString.length();
if (numberSize <= width) {
return numberString;
}
long base = number;
double last = base * 1000;
int exponent = -1;
String postFix = "";
while (numberSize > width) {
last = base;
base /= DIVISION_BASE;
exponent++;
// adds +1 due to the postfix
numberSize = Long.toString(base).length() + 1;
postFix = String.valueOf(ENCODED_POSTFIXES[exponent]);
}
final String withPrecision = this.format.format(last / DIVISION_BASE) + postFix;
final String withoutPrecision = Long.toString(base) + postFix;
final String slimResult = (withPrecision.length() <= width) ? withPrecision : withoutPrecision;
// post condition
assert slimResult.length() <= width;
return slimResult;
}
public String toWideReadableForm(final long number) {
return this.toReadableFormRestrictedByWidth(number, 4);
}
}
@@ -1265,7 +1265,7 @@ bw.recipe.biolab,gregtech:gt.blockmachines:12706,,bartworks,TRUE,,,,,,
bw.recipe.biolab,gregtech:gt.blockmachines:12707,,bartworks,TRUE,,,,,,
bw.recipe.biolab,gregtech:gt.blockmachines:12708,,bartworks,TRUE,,,,,,
bw.recipe.biolab,gregtech:gt.blockmachines:12709,,bartworks,TRUE,,,,,,
bw.recipe.biolab,gregtech:gt.blockmachines:12711,,bartworks,TRUE,,,,,,
bw.recipe.biolab,gregtech:gt.blockmachines:12710,,bartworks,TRUE,,,,,,
bw.recipe.BacteriaVat,gregtech:gt.blockmachines:12712,,bartworks,TRUE,,,,,,
gt.recipe.electricimplosioncompressor,gregtech:gt.blockmachines:12734,,bartworks,TRUE,,,,,,
gt.recipe.dieselgeneratorfuel,gregtech:gt.blockmachines:1113,,GoodGenerator,TRUE,,,,,,
1 handler itemName nbtInfo modId modRequired excludedModId priority minVersion maxVersion forceClassName itemNotes
1265 bw.recipe.biolab gregtech:gt.blockmachines:12707 bartworks TRUE
1266 bw.recipe.biolab gregtech:gt.blockmachines:12708 bartworks TRUE
1267 bw.recipe.biolab gregtech:gt.blockmachines:12709 bartworks TRUE
1268 bw.recipe.biolab gregtech:gt.blockmachines:12711 gregtech:gt.blockmachines:12710 bartworks TRUE
1269 bw.recipe.BacteriaVat gregtech:gt.blockmachines:12712 bartworks TRUE
1270 gt.recipe.electricimplosioncompressor gregtech:gt.blockmachines:12734 bartworks TRUE
1271 gt.recipe.dieselgeneratorfuel gregtech:gt.blockmachines:1113 GoodGenerator TRUE
+3 -3
View File
@@ -1,7 +1,7 @@
{
"repo": "https://github.com/GTNewHorizons/CodeChickenLib/releases/download/1.1.5.5/",
"file": "CodeChickenLib-1.7.10-1.1.5.5.jar",
"dev": "CodeChickenLib-1.7.10-1.1.5.5-dev.jar",
"repo": "https://github.com/GTNewHorizons/CodeChickenLib/releases/download/1.1.5.6/",
"file": "CodeChickenLib-1.7.10-1.1.5.6.jar",
"dev": "CodeChickenLib-1.7.10-1.1.5.6-dev.jar",
"class": "codechicken.lib.asm.ASMHelper",
"coreLib": true
}