mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-20 04:09:45 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3da914719a | ||
|
|
9232ec0019 | ||
|
|
c3b8cd8c2c | ||
|
|
fc9b8e83da | ||
|
|
eadc38dd3c | ||
|
|
61f427f0d6 |
No files matched your search
@@ -33,7 +33,7 @@ If you have issues with NEI outside the GTNH modpack, please report them in the
|
||||
|
||||
### Help! My mod is broken in your version of NEI! How can I fix it?
|
||||
|
||||
Our version of NEI changes the recipe UI to be a bit more similar to [JEI][JEI]. As such, some legacy recipe handlers that assume the specific UI layout of old NEI might break even after providing additional metadata. The UI changes include following: the recipe screen is no longer has a fixed height, but can stretch across the screen to show more recipes at once. Additionally, the screen is no longer vertically centered, but at a fixed offset from the top of the MC window. Furthermore, the recipe paging widget has been moved from the bottom to the top of the recipe screen.
|
||||
Our version of NEI changes the recipe UI to be a bit more similar to [JEI][JEI]. As such, some legacy recipe handlers that assume the specific UI layout of old NEI might break even after providing additional metadata. Changes to the UI include the following: the recipe screen no longer has a fixed height, but can stretch to show more recipes at once. Additionally, the screen is no longer vertically centered, but at a fixed offset from the top of the MC window. Furthermore, the recipe paging widget has been moved from the bottom to the top of the recipe screen.
|
||||
|
||||
The following sections list strategies for fixing broken handlers. Remember, you are always welcome to an issue in our repository if you are stuck with a broken recipe handler.
|
||||
|
||||
@@ -45,7 +45,7 @@ The height hack can be enabled by adding the fully-qualified class name of the r
|
||||
|
||||
#### I'm a developer working on my own mod or maintaining a forked mod
|
||||
|
||||
Please consider adding support for our IMC messages or events to automatically register handler metadata for your mod. Alternatively, we can provide default metadata for your recipe handlers in `assets/nei/csv/handlers.csv`, let us know the parameters, or even better, open a pull request.
|
||||
Please consider adding support for our IMC messages or events to automatically register handler metadata for your mod. Alternatively, we can provide default metadata for your recipe handlers in `assets/nei/csv/handlers.csv`, let us know the parameters, or even better, open a pull request. The fields available in the new metadata are described in the following section.
|
||||
|
||||
Even after providing handler metadata, there may still be broken elements in your handler. In our experience this most often pertains to tooltips and custom click zones. **Please make sure to not rely on a fixed screen layout!** In particular, do not use `height` to calculate the top edge of the recipe UI, instead use `guiTop`. Also, do not assume a fixed offset from the top edge of the recipe screen (the offset is different in legacy NEI compared to our version), instead use `GuiRecipe.getRecipePosition()`. `GuiRecipe` may already be passed to certain handler methods if you're overriding `TemplateRecipeHandler`, alternatively, you can obtain a reference to it via:
|
||||
```java
|
||||
@@ -98,27 +98,39 @@ public List<String> handleTooltip(GuiRecipe gui, List<String> list, int recipeId
|
||||
}
|
||||
```
|
||||
|
||||
### Metadata
|
||||
### New Metadata for recipe handlers
|
||||
|
||||
Legacy versions of NEI only had a relatively small, fixed size recipe screen, only showing one or two recipes at a time. Our version, borrowing from JEI, improves this by switching to a flexible screen height that allows showing up to 5 recipes at a time in many cases. In addition, the new JEI-style tab bar improves navigation by shows an icon for each recipe handler.
|
||||
Legacy versions of NEI only had a relatively small, fixed size recipe screen, only showing one or two recipes at a time. Our version, borrowing from JEI, improves this by switching to a flexible screen height that allows showing up to 5 recipes at a time in many cases. In addition, the new JEI-style tab bar improves navigation between handlers by showing an icon for each recipe handler.
|
||||
|
||||
To enable these new capabilities, NEI has to be given additional metadata to make it work. This version of NEI includes new native APIs and additionally ships with two files `assets/nei/csv/handlers.csv`, and `assets/nei/csv/catalysts.csv` to include the necessary information for mods that are no longer updated and do not take advantage of the APIs. If you are working on a mod of your own that includes NEI integration, we encourage you to add IMC or event support as described below.
|
||||
To enable these new capabilities, NEI has to be given additional metadata to make it work. This version of NEI includes new native APIs and additionally ships with two files `assets/nei/csv/handlers.csv`, and `assets/nei/csv/catalysts.csv` as a fallback solution to include the necessary information for mods that are no longer updated and do not take advantage of the native APIs that are provided. If you are working on a mod of your own that includes NEI integration, we encourage you to add IMC or event support as described below.
|
||||
|
||||
#### Recipe handler metadata
|
||||
|
||||
(values are strings if not specified otherwise)
|
||||
|
||||
- **handler:** handler ID, usually the fully-qualified class name of the recipe handler (including package name); can differ to provide multiple handlers from a single class; *required*
|
||||
- **modName:** display name of the mod to which the recipe handler belongs to, i.e. "Applied Energistics 2"; *required*
|
||||
- **handler:** handler ID, usually the fully-qualified class name of the recipe handler (including package name); can differ to provide multiple handlers from a single class
|
||||
- example: `vazkii.botania.client.integration.nei.recipe.RecipeHandlerPureDaisy`
|
||||
- *required*
|
||||
- **modName:** display name of the mod to which the recipe handler belongs to
|
||||
- example: `Botania`
|
||||
- *required*
|
||||
- **itemName**, and **nbtInfo:** item used as an icon to represent the recipe handler in the tab bar
|
||||
- **modId:** modid of the mod for which the recipe handler is responsible; *required*
|
||||
- example: `Botania:specialFlower` (itemName), `{type:puredaisy}` (nbtInfo)
|
||||
- **modId:** modid of the mod for which the recipe handler is responsible
|
||||
- example: `Botania`
|
||||
- *required*
|
||||
- **modRequired:** whether the mod specified in `modId` needs to be present in order for NEI to load the recipe handler (boolean value; `TRUE`/`FALSE` in CSV)
|
||||
- **excludedModId:** prevent the recipe handler from being loaded if the specified mod is present
|
||||
- **yShift:** allows fine control over vertical alignment of the recipes from top of the recipe screen; value is in pixels (integer value)
|
||||
- default: `0`
|
||||
- **handlerHeight:** height of a single recipe in pixels, used for tiling multiple recipes vertically according to `maxRecipesPerPage` (integer value)
|
||||
- default: `65`
|
||||
- **handlerWidth:** width of a single recipe in pixels (integer value)
|
||||
- default: `166`
|
||||
- **maxRecipesPerPage:** maximum number of recipes to show per page; less recipes will be shown if they do not fit on the screen (integer value)
|
||||
- default: `1`
|
||||
- **imageResource**, **imageX**, **imageY**, **imageWidth**, and **imageHeight:** allow specifying an arbitrary texture as icon for this recipe handler instead of an item; `imageX`, `imageY`, `imageWidth`, and `imageHeight` allow indexing into a sprite sheet (integer values except for `imageResource`)
|
||||
- example: `nei:textures/nei_tabbed_sprites.png` (imageResource), `80` (imageX), `0` (imageY), `14` (imageWidth), `14` (imageHeight)
|
||||
- **itemNotes:** ignored by NEI; this field is purely informational for development; not available via IMC/event
|
||||
|
||||
#### Catalyst metadata
|
||||
@@ -129,14 +141,20 @@ Again, this needs additional metadata work, either provided by mods themselves,
|
||||
|
||||
(values are strings if not specified otherwise)
|
||||
|
||||
- **handlerID:** id of the recipe handler for which this catalyst can be used; it's the fully-qualified handler class name in most cases; *required*
|
||||
- **itemName:**, and **nbtInfo:** actual catalyst item; *required*
|
||||
- **handler:** id of the recipe handler for which this catalyst can be used; it's the fully-qualified handler class name in most cases
|
||||
- example: `vazkii.botania.client.integration.nei.recipe.RecipeHandlerPureDaisy`
|
||||
- *required*
|
||||
- **itemName:**, and **nbtInfo:** actual catalyst item
|
||||
- example: `Botania:specialFlower` (itemName), `{type:puredaisy}` (nbtInfo)
|
||||
- *required* (itemName)
|
||||
- **modId:** modid of the mod which includes the catalyst
|
||||
- **modRequired:** whether the mod specified in `modId` needs to be present in order for NEI to load the catalyst (boolean value; `TRUE`/`FALSE` in CSV)
|
||||
- *required*
|
||||
- **excludedModId:** prevent the catalyst from being loaded if the specified mod is present
|
||||
- **priority:** position of the catalyst within the list of all possible catalysts for a given recipe handler; default priority is 0; higher priority takes precedence (integer value)
|
||||
- **priority:** position of the catalyst within the list of all possible catalysts for a given recipe handler; higher priority takes precedence (integer value)
|
||||
- default: `0`
|
||||
- **minVersion:**, and **maxVersion:** only present in `catalysts.csv`, currently unused
|
||||
- **forceClassName:** traditionally, NEI used the fully-qualified handler class name, this restriction is lifted in this version of NEI, allowing handlers to specify their own ID and letting a single handler class act as multiple different handlers; this forces the catalyst to match on the handler class name; only needs to be used in rare cases; only present in `catalysts.csv` (boolean value)
|
||||
- **forceClassName:** traditionally, NEI used the fully-qualified handler class name, this restriction is lifted in this version of NEI, allowing handlers to specify their own ID and letting a single handler class act as multiple different handlers; this forces the catalyst to match on the handler class name; only needs to be used in rare cases; only supported in `catalysts.csv` (boolean value)
|
||||
- **itemNotes:** ignored by NEI; this field is purely informational for development; not available via IMC
|
||||
|
||||
#### IMC
|
||||
@@ -146,7 +164,7 @@ Our version of NEI adds a range of IMC messages for registering handler metadata
|
||||
The following messages are available:
|
||||
- **registerHandlerInfo:** NBT IMC message; allowed keys are specified in the handler metadata section
|
||||
- **removeHandlerInfo:** NBT IMC message; required key: `handler`, ID string of the handler to be removed (usually the fully-qualified name of the handler class)
|
||||
- **registerCatalystInfo:** NBT IMC message; allowed keys are specified in the catalyst metadata section
|
||||
- **registerCatalystInfo:** NBT IMC message; allowed keys are specified in the catalyst metadata section; previously, this accepted the tag `handlerID`, which has been renamed to `handler` to unify it with the CSV column name, the old name has been deprecated
|
||||
- **removeCatalystInfo:** NBT IMC message; required keys: `handlerID` (usually the fully-qualified name of the handler class), `itemName` (optionally specify `nbtInfo` if necessary)
|
||||
|
||||
Here is an example of how to send the handler and catalyst metadata via IMC:
|
||||
|
||||
@@ -130,9 +130,17 @@ public class IMCHandler {
|
||||
processedCatalystSenders.add(message.getSender());
|
||||
}
|
||||
final NBTTagCompound tag = message.getNBTValue();
|
||||
final String handlerID = tag.getString("handlerID");
|
||||
if (handlerID.isEmpty()) {
|
||||
NEIClientConfig.logger.warn("Missing handlerID for registerCatalystInfo!");
|
||||
final String handler;
|
||||
if (tag.hasKey("handlerID")) {
|
||||
NEIClientConfig.logger.warn(
|
||||
"Received 'handlerID' for registerCatalystInfo IMC from %s, this is deprecated, please use 'handler' instead",
|
||||
message.getSender());
|
||||
handler = tag.getString("handlerID");
|
||||
} else {
|
||||
handler = tag.getString("handler");
|
||||
}
|
||||
if (handler.isEmpty()) {
|
||||
NEIClientConfig.logger.warn("Missing handler in registerCatalystInfo IMC from %s!", message.getSender());
|
||||
return;
|
||||
}
|
||||
final String modId = tag.hasKey("modId") ? tag.getString("modId") : null;
|
||||
@@ -145,7 +153,7 @@ public class IMCHandler {
|
||||
final String itemName = tag.getString("itemName");
|
||||
final String nbtInfo = tag.hasKey("nbtInfo") ? tag.getString("nbtInfo") : null;
|
||||
if (itemName.isEmpty()) {
|
||||
NEIClientConfig.logger.warn(String.format("Missing itemName for registerCatalystInfo in `%s`!", handlerID));
|
||||
NEIClientConfig.logger.warn(String.format("Missing itemName in registerCatalystInfo IMC for %s!", handler));
|
||||
return;
|
||||
}
|
||||
final ItemStack itemStack = NEIServerUtils.getModdedItem(itemName, nbtInfo);
|
||||
@@ -155,10 +163,9 @@ public class IMCHandler {
|
||||
}
|
||||
final int priority = tag.getInteger("priority");
|
||||
|
||||
RecipeCatalysts
|
||||
.addOrPut(RecipeCatalysts.catalystsAdderFromIMC, handlerID, new CatalystInfo(itemStack, priority));
|
||||
RecipeCatalysts.addOrPut(RecipeCatalysts.catalystsAdderFromIMC, handler, new CatalystInfo(itemStack, priority));
|
||||
NEIClientConfig.logger
|
||||
.info(String.format("Added catalyst `%s` to handler %s", itemStack.getDisplayName(), handlerID));
|
||||
.info(String.format("Added catalyst `%s` to handler %s", itemStack.getDisplayName(), handler));
|
||||
}
|
||||
|
||||
private static void handleRemoveCatalystInfo(IMCMessage message) {
|
||||
@@ -169,15 +176,24 @@ public class IMCHandler {
|
||||
|
||||
NEIClientConfig.logger.info("Processing removeCatalystInfo from " + message.getSender());
|
||||
final NBTTagCompound tag = message.getNBTValue();
|
||||
final String handlerID = tag.getString("handlerID");
|
||||
if (handlerID.isEmpty()) {
|
||||
NEIClientConfig.logger.warn("Missing handlerID for registerCatalystInfo!");
|
||||
final String handler;
|
||||
if (tag.hasKey("handlerID")) {
|
||||
NEIClientConfig.logger.warn(
|
||||
"Received 'handlerID' for removeCatalystInfo IMC from %s, this is deprecated, please use 'handler' instead",
|
||||
message.getSender());
|
||||
handler = tag.getString("handlerID");
|
||||
} else {
|
||||
handler = tag.getString("handler");
|
||||
}
|
||||
if (handler.isEmpty()) {
|
||||
NEIClientConfig.logger.warn("Missing handler in removeCatalystInfo IMC from %s!", message.getSender());
|
||||
return;
|
||||
}
|
||||
final String itemName = tag.getString("itemName");
|
||||
final String nbtInfo = tag.hasKey("nbtInfo") ? tag.getString("nbtInfo") : null;
|
||||
if (itemName.isEmpty()) {
|
||||
NEIClientConfig.logger.warn(String.format("Missing itemName for removeCatalystInfo in `%s`!", handlerID));
|
||||
NEIClientConfig.logger
|
||||
.warn(String.format("Missing 'itemName' in removeCatalystInfo IMC for handler %s!", handler));
|
||||
return;
|
||||
}
|
||||
final ItemStack itemStack = NEIServerUtils.getModdedItem(itemName, nbtInfo);
|
||||
@@ -186,14 +202,13 @@ public class IMCHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (RecipeCatalysts.catalystsRemoverFromIMC.containsKey(handlerID)) {
|
||||
RecipeCatalysts.catalystsRemoverFromIMC.get(handlerID).add(itemStack);
|
||||
if (RecipeCatalysts.catalystsRemoverFromIMC.containsKey(handler)) {
|
||||
RecipeCatalysts.catalystsRemoverFromIMC.get(handler).add(itemStack);
|
||||
} else {
|
||||
RecipeCatalysts.catalystsRemoverFromIMC
|
||||
.put(handlerID, new ArrayList<>(Collections.singletonList(itemStack)));
|
||||
RecipeCatalysts.catalystsRemoverFromIMC.put(handler, new ArrayList<>(Collections.singletonList(itemStack)));
|
||||
}
|
||||
NEIClientConfig.logger
|
||||
.info(String.format("Removed catalyst `%s` from handler %s", itemStack.getDisplayName(), handlerID));
|
||||
.info(String.format("Removed catalyst `%s` from handler %s", itemStack.getDisplayName(), handler));
|
||||
}
|
||||
|
||||
private static void logInvalidMessage(FMLInterModComms.IMCMessage message, String type) {
|
||||
|
||||
@@ -612,18 +612,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
GuiContainerManager.enable2DRender();
|
||||
|
||||
fontRendererObj.drawStringWithShadow(
|
||||
String.format("m: %3s,%3s", GuiDraw.getMousePosition().x, GuiDraw.getMousePosition().y),
|
||||
0,
|
||||
-30,
|
||||
0xffffff);
|
||||
fontRendererObj.drawStringWithShadow(String.format("guiTop: %3s", guiTop), 0, -20, 0xffffff);
|
||||
fontRendererObj
|
||||
.drawStringWithShadow(String.format("hHack: %3s", (((guiTop * 2) + 176) - 176) / 2), 0, -10, 0xffffff);
|
||||
|
||||
fontRendererObj.drawStringWithShadow(String.format("guiw/h: %3s,%3s", width, height), 75, -30, 0xffffff);
|
||||
|
||||
final int recipesPerPage = getRecipesPerPage();
|
||||
String s = handler.getRecipeName().trim();
|
||||
fontRendererObj.drawStringWithShadow(s, (xSize - fontRendererObj.getStringWidth(s)) / 2, 5, 0xffffff);
|
||||
|
||||
@@ -165,7 +165,7 @@ public class RecipeCatalysts {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
|
||||
CSVParser csvParser = CSVFormat.EXCEL.withFirstRecordAsHeader().parse(reader);
|
||||
for (CSVRecord record : csvParser) {
|
||||
final String handler = record.get("handlerID");
|
||||
final String handler = record.get("handler");
|
||||
final String modId = record.get("modId");
|
||||
final boolean requiresMod = Boolean.parseBoolean(record.get("modRequired"));
|
||||
final String excludedModId = record.get("excludedModId");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
handlerID,itemName,nbtInfo,modId,modRequired,excludedModId,priority,minVersion,maxVersion,forceClassName,itemNotes
|
||||
handler,itemName,nbtInfo,modId,modRequired,excludedModId,priority,minVersion,maxVersion,forceClassName,itemNotes
|
||||
crafting,minecraft:crafting_table,,minecraft,FALSE,terrafirmacraftplus,100,,,,
|
||||
smelting,minecraft:furnace,,minecraft,FALSE,terrafirmacraftplus,100,,,,
|
||||
codechicken.nei.recipe.BrewingRecipeHandler,minecraft:brewing_stand,,minecraft,FALSE,terrafirmacraftplus,100,,,,
|
||||
|
||||
|
@@ -437,7 +437,7 @@ mekanism.client.nei.ShapelessMekanismRecipeHandler,Mekanism,minecraft:crafting_t
|
||||
mekanism.client.nei.SolarNeutronRecipeHandler,Mekanism,Mekanism:MachineBlock3:1,,Mekanism,TRUE,,,70,,5,,,,,,
|
||||
mekanism.client.nei.ThermalEvaporationRecipeHandler,Mekanism,Mekanism:BasicBlock:14,,Mekanism,TRUE,,,62,,5,,,,,,
|
||||
exnihilo.compatibility.nei.RecipeHandlerHammer,Ex Nihilo,exnihilo:hammer_iron,,exnihilo,TRUE,,,58,,5,,,,,,
|
||||
exnihilo.compatibility.nei.RecipeHandlerSieve,Ex Nihilo,exnihilo:sifting_table,,exnihilo,TRUE,,,130,,2,,,,,,
|
||||
exnihilo.compatibility.nei.RecipeHandlerSieve,Ex Nihilo,exnihilo:sifting_table,,exnihilo,TRUE,,,130,,1,,,,,,
|
||||
gregtech.Alloy,GregTech-Addon,gregtech_addon:machine:56,,gregtech_addon,TRUE,,15,145,166,2,,,,,,
|
||||
gregtech.Assembler,GregTech-Addon,gregtech_addon:machine:60,,gregtech_addon,TRUE,,15,145,166,2,,,,,,
|
||||
gregtech.Bender,GregTech-Addon,gregtech_addon:machine:59,,gregtech_addon,TRUE,,15,145,166,2,,,,,,
|
||||
|
||||
|
Reference in new issue
Block a user