mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 18:54:45 +00:00
Compare commits
39
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57e865fc6f | ||
|
|
6dcd26a978 | ||
|
|
aeb59081d9 | ||
|
|
ef8706ae38 | ||
|
|
b49d066231 | ||
|
|
594fbe6f79 | ||
|
|
3edb85b317 | ||
|
|
5fd0a74363 | ||
|
|
2ae94e94a0 | ||
|
|
fa3adde3e6 | ||
|
|
56941cc45d | ||
|
|
cd7d014704 | ||
|
|
0634466851 | ||
|
|
b87e389132 | ||
|
|
c788a07cf5 | ||
|
|
7d4ed91e86 | ||
|
|
ca79cdd3c9 | ||
|
|
3a0722adc2 | ||
|
|
77fa3bafd6 | ||
|
|
e23e542aac | ||
|
|
7ec2ad132e | ||
|
|
7b43826d05 | ||
|
|
c7a18dd288 | ||
|
|
4fb1d7b1d8 | ||
|
|
081071562f | ||
|
|
81e05dc030 | ||
|
|
efc54fb662 | ||
|
|
6e75124ea2 | ||
|
|
2c9f17983a | ||
|
|
e0b6d62143 | ||
|
|
3d5e9aecf0 | ||
|
|
07cec30f3e | ||
|
|
f3add01e74 | ||
|
|
d469fdc90d | ||
|
|
763d9b8cd4 | ||
|
|
55ccb70c8b | ||
|
|
2e1c7764b7 | ||
|
|
9daa9cabb2 | ||
|
|
74dc7c34d9 |
No files matched your search
@@ -22,6 +22,59 @@ If you have issues with NEI outside of the GTNH modpack you may report them in t
|
||||
* Cycle between Recipe, Utility, and Cheat mode by ctrl clicking on the Wrench Icon
|
||||
* GT5u Tools/Items and GT6 tools should now properly work with the Overlay Recipe Transfer
|
||||
|
||||
### Information Page Handler
|
||||
Want to add some information about a block or item without making a massive tooltip for it? You can add information about any block or item by registering it in the Information Handler.
|
||||
|
||||
Information page(s) are displayed when either the uses or recipes of a matching item are searched. All matching items will cycle at the top of the information page.
|
||||
|
||||
Your mod can call:
|
||||
```java
|
||||
FMLInterModComms.sendMessage("NotEnoughItems", "addItemInfo", nbt);
|
||||
```
|
||||
Where nbt is an NBTTagCompound formatted as described below.
|
||||
|
||||
| Tag | Type | Description |
|
||||
|------------------|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `filter` | String | A string filter to match what items should return this information page.<br/>modname:itemname, metadata, Ore Dictionary tags, and regex can all be used. The full format may be seen in `config/NEI/collapsibleitems.cfg`. |
|
||||
| `page` / `pages` | String / String NBTTagList | The actual text to display. See below for differences between single and multi-page messages.<br/>Both formats will automatically translate provided strings. |
|
||||
|
||||
#### Single Page Format
|
||||
|
||||
Use the `"page"` string tag when you only want to add one page of information:
|
||||
```java
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("filter", "minecraft:log 3");
|
||||
tag.setString("page", "Exotic wood found in tropical climates.");
|
||||
|
||||
FMLInterModComms.sendMessage("NotEnoughItems", "addItemInfo", tag);
|
||||
```
|
||||
|
||||
#### Multiple Page Format
|
||||
|
||||
Use the `"pages"` tag as an `NBTTagList` of strings when you want more than one page:
|
||||
```java
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("filter", "minecraft:diamond_sword");
|
||||
|
||||
NBTTagList pages = new NBTTagList();
|
||||
pages.appendTag(new NBTTagString("A powerful melee weapon."));
|
||||
pages.appendTag(new NBTTagString("Can be enchanted for extra effects."));
|
||||
|
||||
tag.setTag("pages", pages);
|
||||
|
||||
FMLInterModComms.sendMessage("NotEnoughItems", "addItemInfo", tag);
|
||||
```
|
||||
* Each list entry is one page.
|
||||
* Pages will appear in NEI with buttons to scroll through them.
|
||||
|
||||
#### Item Matching
|
||||
|
||||
All items that match `filter` will show your information page. See `config/NEI/collapsibleitems.cfg` for the full filter format.
|
||||
|
||||
#### Item Information Config File
|
||||
|
||||
If you're a modpack creator and want to make custom item information pages, they can easily be added in `config/NEI/informationpages.cfg`, which has a few more examples.
|
||||
|
||||
## Other items of note:
|
||||
|
||||
* Remove TMI style
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:CodeChickenCore:1.4.2:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.6.22:dev')
|
||||
api('com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.6.39:dev')
|
||||
|
||||
shadowImplementation('org.apache.commons:commons-csv:1.10.0')
|
||||
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ modrinthProjectId = notenoughitems-unofficial
|
||||
# type can be one of [project, version],
|
||||
# and the name is the Modrinth project or version slug/id of the other mod.
|
||||
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
|
||||
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
||||
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
||||
modrinthRelations = required-project\:codechickencore-unofficial
|
||||
|
||||
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.38'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.41'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -306,18 +307,33 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
|
||||
if (recipeId == null || !removeFullRecipe) {
|
||||
this.grid.removeRecipe(slot.itemIndex, removeFullRecipe);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (group.crafting != null && group.crafting.recipeRelations.containsKey(recipeId)) {
|
||||
boolean removed = false;
|
||||
if (group.crafting != null && group.collapsed && removeFullRecipe) {
|
||||
this.grid.removeGroup(groupId);
|
||||
return true;
|
||||
} else if (group.crafting != null) {
|
||||
Set<RecipeId> recipes = group.crafting.recipeRelations.getOrDefault(recipeId, Collections.emptySet());
|
||||
|
||||
for (RecipeId relRecipeId : group.crafting.recipeRelations.get(recipeId)) {
|
||||
removed = this.grid.removeRecipe(relRecipeId, groupId) || removed;
|
||||
if (removeFullRecipe && recipes.isEmpty()) {
|
||||
for (Map.Entry<RecipeId, Set<RecipeId>> entry : group.crafting.recipeRelations.entrySet()) {
|
||||
if (entry.getValue().contains(recipeId)) {
|
||||
recipes = entry.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return removed;
|
||||
if (!recipes.isEmpty()) {
|
||||
boolean removed = false;
|
||||
|
||||
for (RecipeId relRecipeId : recipes) {
|
||||
removed = this.grid.removeRecipe(relRecipeId, groupId) || removed;
|
||||
}
|
||||
|
||||
return removed;
|
||||
}
|
||||
}
|
||||
|
||||
return this.grid.removeRecipe(recipeId, groupId);
|
||||
@@ -1153,6 +1169,11 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clearTooltips() {
|
||||
this.acceptsFollowingTooltipLineHandler = null;
|
||||
this.recipeChainTooltipLineHandler = null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void addItem(ItemStack stack, boolean saveSize) {
|
||||
addItem(saveSize ? stack : StackInfo.withAmount(stack, 0));
|
||||
|
||||
@@ -19,13 +19,14 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiSelectWorld;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
@@ -60,7 +61,6 @@ public class ClientHandler {
|
||||
private static ClientHandler instance;
|
||||
private final ArrayList<EntityItem> SMPmagneticItems = new ArrayList<>();
|
||||
private World lastworld;
|
||||
private GuiScreen lastGui;
|
||||
|
||||
public void addSMPMagneticItem(int i, World world) {
|
||||
WorldClient cworld = (WorldClient) world;
|
||||
@@ -257,13 +257,17 @@ public class ClientHandler {
|
||||
}
|
||||
|
||||
public static void loadPluginsList() {
|
||||
if (!Loader.isModLoaded("jarjar")) {
|
||||
final boolean jarjar = Launch.blackboard.getOrDefault("jarjar.rfbPluginLoaded", Boolean.FALSE) == Boolean.TRUE;
|
||||
if (!jarjar) {
|
||||
// Do the old style class discovery
|
||||
final ClassDiscoverer classDiscoverer = new ClassDiscoverer(
|
||||
test -> test.startsWith("NEI") && test.endsWith("Config.class"),
|
||||
IConfigureNEI.class);
|
||||
|
||||
NEIClientConfig.pluginsList.addAll(classDiscoverer.findClasses());
|
||||
NEIClientConfig.logger
|
||||
.info("Loading NEI Plugins via ClassDiscoverer: " + NEIClientConfig.pluginsList.size());
|
||||
|
||||
} else {
|
||||
// If JarJar's loaded, the ASMDataTable now includes interfaces in addition to Annotations, so use that
|
||||
// instead Includes a small change in behavior of no longer requiring the class to start with NEI and end
|
||||
@@ -279,6 +283,7 @@ public class ClientHandler {
|
||||
NEIClientConfig.logger.error("Failed to load plugin class {}", className, e);
|
||||
}
|
||||
}
|
||||
NEIClientConfig.logger.info("Loading NEI Plugins via JarJar: " + NEIClientConfig.pluginsList.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,18 +307,19 @@ public class ClientHandler {
|
||||
if (mc.currentScreen == null) NEIController.processCreativeCycling(mc.thePlayer.inventory);
|
||||
|
||||
updateMagnetMode(mc.theWorld, mc.thePlayer);
|
||||
} else {
|
||||
lastworld = null;
|
||||
}
|
||||
}
|
||||
|
||||
GuiScreen gui = mc.currentScreen;
|
||||
if (gui != lastGui) {
|
||||
if (gui instanceof GuiMainMenu) lastworld = null;
|
||||
else if (gui instanceof GuiSelectWorld) NEIClientConfig.reloadSaves();
|
||||
else if (gui == null) {
|
||||
/* prevent WorldClient reference being held in the Gui */
|
||||
NEIController.manager = null;
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void onGuiScreen(GuiOpenEvent event) {
|
||||
if (event.gui instanceof GuiSelectWorld) {
|
||||
NEIClientConfig.reloadSaves();
|
||||
} else if (event.gui == null) {
|
||||
/* prevent WorldClient reference being held in the Gui */
|
||||
NEIController.manager = null;
|
||||
}
|
||||
lastGui = gui;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -332,6 +338,7 @@ public class ClientHandler {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (event.world == mc.theWorld) {
|
||||
NEIClientConfig.unloadWorld();
|
||||
ItemMobSpawner.clearEntityReferences();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,8 +355,6 @@ public class ClientHandler {
|
||||
if (!Minecraft.getMinecraft().isSingleplayer()) // wait for server to initiate in singleplayer
|
||||
NEIClientConfig.loadWorld("remote/" + ClientUtils.getServerIP().replace(':', '~'));
|
||||
}
|
||||
ItemMobSpawner.clearEntityReferences(world);
|
||||
|
||||
lastworld = world;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -32,6 +34,7 @@ import codechicken.nei.util.NBTJson;
|
||||
|
||||
public class FavoriteRecipes {
|
||||
|
||||
private static final Set<NBTTagCompound> tools = new HashSet<>();
|
||||
private static final Map<NBTTagCompound, RecipeId> items = new HashMap<>();
|
||||
private static final Map<String, RecipeId> fluids = new HashMap<>();
|
||||
private static File favoriteFile;
|
||||
@@ -123,6 +126,10 @@ public class FavoriteRecipes {
|
||||
}
|
||||
|
||||
items.put(itemStackNBT, recipeId);
|
||||
|
||||
if (NEIServerUtils.isItemTool(stack)) {
|
||||
tools.add(itemStackNBT);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException | JsonSyntaxException | IllegalStateException e) {
|
||||
@@ -143,7 +150,19 @@ public class FavoriteRecipes {
|
||||
recipeId = fluids.get(getFluidKey(stack));
|
||||
}
|
||||
|
||||
return recipeId;
|
||||
if (recipeId != null) {
|
||||
return recipeId;
|
||||
}
|
||||
|
||||
if (NEIServerUtils.isItemTool(stack)
|
||||
&& (stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("GT.ToolStats"))) {
|
||||
for (NBTTagCompound nbt : tools) {
|
||||
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(stack, StackInfo.loadFromNBT(nbt))) {
|
||||
return items.get(nbt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -176,6 +195,10 @@ public class FavoriteRecipes {
|
||||
if (recipeId != null) {
|
||||
items.put(itemStackNBT, recipeId);
|
||||
|
||||
if (NEIServerUtils.isItemTool(stack)) {
|
||||
tools.add(itemStackNBT);
|
||||
}
|
||||
|
||||
if (fluidKey != null) {
|
||||
fluids.put(fluidKey, recipeId);
|
||||
}
|
||||
@@ -221,7 +244,7 @@ public class FavoriteRecipes {
|
||||
try (FileOutputStream output = new FileOutputStream(favoriteFile)) {
|
||||
IOUtils.writeLines(strings, "\n", output, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Filed to save favorites list to file {}", favoriteFile, e);
|
||||
NEIClientConfig.logger.error("Failed to save favorites list to file {}", favoriteFile, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import codechicken.nei.ThreadOperationTimer.TimeoutException;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.recipe.InformationHandler;
|
||||
import codechicken.nei.search.TooltipFilter;
|
||||
|
||||
public class ItemList {
|
||||
@@ -289,11 +290,11 @@ public class ItemList {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// For optimization it generate itemslist, permutations, orders & collapsibleitems
|
||||
// Generate itemlist, permutations, orders, collapsibleitems, and informationhandler stacks
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void execute() {
|
||||
if (!NEIClientConfig.isEnabled()) return;
|
||||
if (!NEIClientConfig.isEnabled() || NEIClientUtils.mc().thePlayer == null) return;
|
||||
|
||||
ThreadOperationTimer timer = getTimer(NEIClientConfig.getItemLoadingTimeout());
|
||||
LayoutManager.itemsLoaded = true;
|
||||
@@ -303,6 +304,7 @@ public class ItemList {
|
||||
ItemSorter.instance.ordering.clear();
|
||||
CollapsibleItems.clearCache();
|
||||
TooltipFilter.clearCache();
|
||||
InformationHandler.clearCache();
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
ListMultimap<Item, ItemStack> itemMap = ArrayListMultimap.create();
|
||||
@@ -329,6 +331,7 @@ public class ItemList {
|
||||
|
||||
CollapsibleItems.putItem(stack);
|
||||
TooltipFilter.getSearchTooltip(stack);
|
||||
InformationHandler.populateStacks(stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,14 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemMobSpawner extends ItemBlock {
|
||||
|
||||
private static final Map<Integer, EntityLiving> entityHashMap = new HashMap<>();
|
||||
@@ -29,7 +33,6 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
|
||||
public ItemMobSpawner() {
|
||||
super(Blocks.mob_spawner);
|
||||
|
||||
hasSubtypes = true;
|
||||
MinecraftForgeClient.registerItemRenderer(this, new SpawnerRenderer());
|
||||
}
|
||||
@@ -38,7 +41,6 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
* These are ASM translated from BlockMobSpawner
|
||||
*/
|
||||
public static int placedX;
|
||||
|
||||
public static int placedY;
|
||||
public static int placedZ;
|
||||
|
||||
@@ -65,6 +67,7 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer par2EntityPlayer, List<String> list, boolean par4) {
|
||||
setDefaultTag(itemstack);
|
||||
@@ -73,15 +76,17 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
meta = idPig;
|
||||
}
|
||||
Entity e = getEntity(meta);
|
||||
list.add("\u00A7" + (e instanceof IMob ? "4" : "3") + IDtoNameMap.get(meta));
|
||||
list.add(
|
||||
(e instanceof IMob ? EnumChatFormatting.DARK_RED : EnumChatFormatting.DARK_AQUA)
|
||||
+ IDtoNameMap.get(meta));
|
||||
}
|
||||
|
||||
public static EntityLiving getEntity(int ID) {
|
||||
EntityLiving e = entityHashMap.get(ID);
|
||||
if (e == null) {
|
||||
loadSpawners();
|
||||
Class<?> clazz = EntityList.IDtoClassMapping.get(ID);
|
||||
World world = NEIClientUtils.mc().theWorld;
|
||||
loadSpawners(world);
|
||||
Class<?> clazz = (Class<?>) EntityList.IDtoClassMapping.get(ID);
|
||||
try {
|
||||
e = (EntityLiving) clazz.getConstructor(new Class[] { World.class }).newInstance(world);
|
||||
} catch (Throwable t) {
|
||||
@@ -95,40 +100,31 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
return e;
|
||||
}
|
||||
|
||||
public static void clearEntityReferences(World newWorld) {
|
||||
entityHashMap.values().removeIf(e -> e.worldObj != newWorld);
|
||||
public static void clearEntityReferences() {
|
||||
entityHashMap.clear();
|
||||
}
|
||||
|
||||
private void setDefaultTag(ItemStack itemstack) {
|
||||
if (!IDtoNameMap.containsKey(itemstack.getItemDamage())) itemstack.setItemDamage(idPig);
|
||||
}
|
||||
|
||||
public static void loadSpawners(World world) {
|
||||
public static void loadSpawners() {
|
||||
if (loaded) return;
|
||||
loaded = true;
|
||||
Map<Class<? extends Entity>, String> classToStringMapping = EntityList.classToStringMapping;
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<Class<? extends Entity>, Integer> classToIDMapping = (Map<Class<? extends Entity>, Integer>) EntityList.classToIDMapping;
|
||||
for (Class<? extends Entity> eclass : classToStringMapping.keySet()) {
|
||||
if (!EntityLiving.class.isAssignableFrom(eclass)) continue;
|
||||
try {
|
||||
EntityLiving entityliving = (EntityLiving) eclass.getConstructor(new Class[] { World.class })
|
||||
.newInstance(world);
|
||||
entityliving.isChild();
|
||||
|
||||
int id = classToIDMapping.get(eclass);
|
||||
String name = classToStringMapping.get(eclass);
|
||||
|
||||
for (Map.Entry<Class<? extends Entity>, String> entry : EntityList.classToStringMapping.entrySet()) {
|
||||
final Class<? extends Entity> clazz = entry.getKey();
|
||||
if (EntityLiving.class.isAssignableFrom(clazz)) {
|
||||
Integer id = (Integer) EntityList.classToIDMapping.get(clazz);
|
||||
if (id == null) continue;
|
||||
String name = entry.getValue();
|
||||
if (name == null) continue;
|
||||
if (name.equals("EnderDragon")) continue;
|
||||
|
||||
IDtoNameMap.put(id, name);
|
||||
|
||||
if (name.equals("Pig")) idPig = id;
|
||||
} catch (Throwable ignored) {}
|
||||
if (clazz != EntityPig.class || name.equals("Pig")) {
|
||||
IDtoNameMap.put(id, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IDtoNameMap.entrySet()
|
||||
.removeIf(e -> getEntity(e.getKey()).getClass() == EntityPig.class && !e.getValue().equals("Pig"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ItemZoom extends Widget implements IContainerInputHandler {
|
||||
@Override
|
||||
public void draw(int mx, int my) {
|
||||
|
||||
if (this.stack != null
|
||||
if (this.stack != null && this.availableAreaWidth >= SLOT_SIZE * 2
|
||||
&& (NEIClientConfig.getBooleanSetting("inventory.itemzoom.enabled")
|
||||
|| NEIClientConfig.isKeyHashDown("gui.itemzoom_hold"))
|
||||
&& GuiContainerManager.shouldShowTooltip(NEIClientUtils.getGuiContainer())) {
|
||||
|
||||
@@ -136,10 +136,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
|
||||
@Override
|
||||
public void onPreDraw(GuiContainer gui) {
|
||||
if (!isHidden() && isEnabled() && gui instanceof InventoryEffectRenderer) // Reset the gui to the center of the
|
||||
// screen, for potion effect offsets
|
||||
// etc
|
||||
{
|
||||
// Reset the gui to the center of the screen, for potion effect offsets etc
|
||||
if (isEnabled() && gui instanceof InventoryEffectRenderer) {
|
||||
gui.guiLeft = (gui.width - gui.xSize) / 2;
|
||||
gui.guiTop = (gui.height - gui.ySize) / 2;
|
||||
|
||||
|
||||
@@ -186,6 +186,12 @@ public class NEICPH implements IClientPacketHandler {
|
||||
packet.sendToServer();
|
||||
}
|
||||
|
||||
public static void sendChatLink(ItemStack stackover) {
|
||||
PacketCustom packet = new PacketCustom(channel, C2S.SEND_CHAT_ITEM_LINK);
|
||||
packet.writeItemStack(stackover);
|
||||
packet.sendToServer();
|
||||
}
|
||||
|
||||
public static void sendOpenEnchantmentWindow() {
|
||||
PacketCustom packet = new PacketCustom(channel, C2S.REQUEST_ENCHANTMENT_GUI);
|
||||
packet.sendToServer();
|
||||
|
||||
@@ -17,7 +17,6 @@ import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.SaveFormatComparator;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@@ -59,6 +58,7 @@ import codechicken.nei.config.preset.GuiPresetList;
|
||||
import codechicken.nei.event.NEIConfigsLoadedEvent;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.InformationHandler;
|
||||
import codechicken.nei.recipe.RecipeCatalysts;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.util.NEIKeyboardUtils;
|
||||
@@ -146,7 +146,7 @@ public class NEIClientConfig {
|
||||
tag.getTag("inventory.widgetsenabled").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.widgetsenabled"));
|
||||
|
||||
tag.getTag("inventory.autocrafting").getBooleanValue(false);
|
||||
tag.getTag("inventory.autocrafting").getBooleanValue(true);
|
||||
tag.getTag("inventory.dynamicFontSize").getBooleanValue(true);
|
||||
tag.getTag("inventory.hidden").getBooleanValue(false);
|
||||
tag.getTag("inventory.cheatmode").getIntValue(2);
|
||||
@@ -213,6 +213,10 @@ public class NEIClientConfig {
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.ignorePotionOverlap", true));
|
||||
|
||||
tag.getTag("inventory.bookmarks.bookmarkItemsWithRecipe").setComment("Bookmark items with recipe")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.bookmarkItemsWithRecipe", true));
|
||||
|
||||
tag.getTag("inventory.guirecipe.jeiStyleTabs").setComment("Enable/disable JEI Style Tabs")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButtonBoubs("inventory.guirecipe.jeiStyleTabs", true));
|
||||
@@ -409,6 +413,9 @@ public class NEIClientConfig {
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.optimize_gui_overlap_computation", true));
|
||||
|
||||
tag.getTag("inventory.autocrafting").setComment("Autocrafting").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.autocrafting", true));
|
||||
|
||||
tag.getTag("tools.handler_load_from_config").setComment("ADVANCED: Load handlers from config")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("tools.handler_load_from_config", true) {
|
||||
@@ -740,7 +747,7 @@ public class NEIClientConfig {
|
||||
API.addHashBind("gui.remove_recipe", Keyboard.KEY_A + NEIClientUtils.SHIFT_HASH);
|
||||
API.addKeyBind("gui.bookmark_pull_items", Keyboard.KEY_V);
|
||||
API.addKeyBind("gui.overlay", Keyboard.KEY_S);
|
||||
API.addHashBind("gui.craft", Keyboard.KEY_C + NEIClientUtils.SHIFT_HASH);
|
||||
API.addKeyBind("gui.craft_items", Keyboard.KEY_C);
|
||||
API.addHashBind("gui.hide_bookmarks", Keyboard.KEY_B);
|
||||
API.addKeyBind("gui.getprevioussearch", Keyboard.KEY_UP);
|
||||
API.addKeyBind("gui.getnextsearch", Keyboard.KEY_DOWN);
|
||||
@@ -763,6 +770,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.chat_link_item", Keyboard.KEY_L + NEIClientUtils.CTRL_HASH);
|
||||
}
|
||||
|
||||
public static OptionList getOptionList() {
|
||||
@@ -786,7 +794,7 @@ public class NEIClientConfig {
|
||||
}
|
||||
|
||||
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
|
||||
bootNEI(ClientUtils.getWorld());
|
||||
bootNEI();
|
||||
onWorldLoad(newWorld);
|
||||
}
|
||||
}
|
||||
@@ -881,17 +889,18 @@ public class NEIClientConfig {
|
||||
return NEIKeyboardUtils.getKeyName(hash + meta);
|
||||
}
|
||||
|
||||
public static void bootNEI(World world) {
|
||||
public static void bootNEI() {
|
||||
|
||||
if (!mainNEIConfigLoaded) {
|
||||
// main NEI config loading
|
||||
ItemInfo.load(world);
|
||||
ItemInfo.load();
|
||||
GuiInfo.load();
|
||||
RecipeInfo.load();
|
||||
HeldItemHandler.load();
|
||||
LayoutManager.load();
|
||||
NEIController.load();
|
||||
BookmarkContainerInfo.load();
|
||||
InformationHandler.load();
|
||||
mainNEIConfigLoaded = true;
|
||||
|
||||
new Thread("NEI Plugin Loader") {
|
||||
@@ -914,6 +923,7 @@ public class NEIClientConfig {
|
||||
});
|
||||
|
||||
RecipeCatalysts.loadCatalystInfo();
|
||||
SubsetWidget.loadCustomSubsets();
|
||||
SubsetWidget.loadHidden();
|
||||
CollapsibleItems.load();
|
||||
ItemSorter.loadConfig();
|
||||
|
||||
@@ -370,6 +370,10 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
else sendCommand(getStringSetting("command.heal"), mc().thePlayer.getCommandSenderName());
|
||||
}
|
||||
|
||||
public static void sendChatItemLink(ItemStack stackover) {
|
||||
if (hasSMPCounterPart()) NEICPH.sendChatLink(stackover);
|
||||
}
|
||||
|
||||
public static void toggleMagnetMode() {
|
||||
if (hasSMPCounterPart()) NEICPH.sendToggleMagnetMode();
|
||||
}
|
||||
|
||||
@@ -11,16 +11,22 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.api.IInfiniteItemHandler;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.commands.CommandBookmarkAdd;
|
||||
import codechicken.nei.commands.CommandRecipeId;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
import codechicken.nei.guihook.IContainerSlotClickHandler;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class NEIController implements IContainerSlotClickHandler, IContainerInputHandler {
|
||||
|
||||
@@ -39,6 +45,8 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
|
||||
public static void load() {
|
||||
GuiContainerManager.addSlotClickHandler(instance);
|
||||
GuiContainerManager.addInputHandler(instance);
|
||||
|
||||
if (CommonUtils.isClient()) registerClientCommands();
|
||||
}
|
||||
|
||||
public static void load(GuiContainer gui) {
|
||||
@@ -56,6 +64,12 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
|
||||
return gui.field_147007_t && gui.field_147008_s.size() > 1;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerClientCommands() {
|
||||
ClientCommandHandler.instance.registerCommand(new CommandBookmarkAdd());
|
||||
ClientCommandHandler.instance.registerCommand(new CommandRecipeId());
|
||||
}
|
||||
|
||||
public static void updateUnlimitedItems(InventoryPlayer inventory) {
|
||||
if (!NEIClientConfig.canPerformAction("item") || !NEIClientConfig.hasSMPCounterPart()) return;
|
||||
|
||||
|
||||
@@ -88,9 +88,16 @@ public class NEISPH implements IServerPacketHandler {
|
||||
case C2S.SET_DUMMY_SLOT:
|
||||
handleDummySlotSet(sender, packet);
|
||||
break;
|
||||
case C2S.SEND_CHAT_ITEM_LINK:
|
||||
handleSendChatItemLink(sender, packet);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSendChatItemLink(EntityPlayerMP sender, PacketCustom packet) {
|
||||
NEIServerUtils.sendChatItemLink(sender, packet.readItemStack());
|
||||
}
|
||||
|
||||
private void handleDummySlotSet(EntityPlayerMP sender, PacketCustom packet) {
|
||||
int slotNumber = packet.readShort();
|
||||
ItemStack stack = packet.readItemStack(true);
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.event.ClickEvent;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -46,9 +47,22 @@ import codechicken.nei.PacketIDs.S2C;
|
||||
import codechicken.nei.util.NBTHelper;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class NEIServerUtils {
|
||||
|
||||
private static Class<?> gtMetaBaseItem;
|
||||
|
||||
static {
|
||||
try {
|
||||
final ClassLoader loader = NEIServerUtils.class.getClassLoader();
|
||||
NEIServerUtils.gtMetaBaseItem = ReflectionHelper
|
||||
.getClass(loader, "gregtech.api.items.MetaBaseItem", "gregtech.api.items.GT_MetaBase_Item");
|
||||
} catch (Exception ignored) {
|
||||
/* Do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isRaining(World world) {
|
||||
return world.getWorldInfo().isRaining();
|
||||
}
|
||||
@@ -69,6 +83,18 @@ public class NEIServerUtils {
|
||||
player.extinguish();
|
||||
}
|
||||
|
||||
public static void sendChatItemLink(EntityPlayerMP sender, ItemStack stackover) {
|
||||
ServerUtils.sendChatToAll(
|
||||
new ChatComponentTranslation(
|
||||
"nei.chat.item_link.text",
|
||||
sender.getDisplayName(),
|
||||
stackover.func_151000_E().setChatStyle(
|
||||
stackover.func_151000_E().getChatStyle().setChatClickEvent(
|
||||
new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/nei_bookmark " + stackover.writeToNBT(new NBTTagCompound()))))));
|
||||
}
|
||||
|
||||
public static long getTime(World world) {
|
||||
return world.getWorldInfo().getWorldTime();
|
||||
}
|
||||
@@ -146,7 +172,7 @@ public class NEIServerUtils {
|
||||
|
||||
/**
|
||||
* NBT-friendly version of {@link #areStacksSameType(ItemStack, ItemStack)}
|
||||
*
|
||||
*
|
||||
* @param stack1 The {@link ItemStack} being compared.
|
||||
* @param stack2 The {@link ItemStack} to compare to.
|
||||
* @return whether the two items are the same in terms of itemID, damage and NBT.
|
||||
@@ -177,19 +203,35 @@ public class NEIServerUtils {
|
||||
|
||||
/**
|
||||
* NBT-friendly version of {@link #areStacksSameTypeCrafting(ItemStack, ItemStack)}
|
||||
*
|
||||
*
|
||||
* @param stack1 The {@link ItemStack} being compared.
|
||||
* @param stack2 The {@link ItemStack} to compare to.
|
||||
* @return whether the two items are the same from the perspective of a crafting inventory.
|
||||
*/
|
||||
public static boolean areStacksSameTypeCraftingWithNBT(ItemStack stack1, ItemStack stack2) {
|
||||
return stack1 != null && stack2 != null
|
||||
&& stack1.getItem() == stack2.getItem()
|
||||
&& (stack1.getItemDamage() == stack2.getItemDamage()
|
||||
|| stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE
|
||||
|| stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE
|
||||
|| stack1.getItem().isDamageable())
|
||||
&& NBTHelper.matchTag(stack1.getTagCompound(), stack2.getTagCompound());
|
||||
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(stack2, stack1)) {
|
||||
if (NBTHelper.matchTag(stack1.getTagCompound(), stack2.getTagCompound())) return true;
|
||||
if (isItemTool(stack1)
|
||||
&& (stack1.stackTagCompound == null || stack1.stackTagCompound.hasKey("GT.ToolStats"))
|
||||
&& (stack2.stackTagCompound == null || stack2.stackTagCompound.hasKey("GT.ToolStats")))
|
||||
return true;
|
||||
return stack1.getMaxStackSize() == 1 && stack2.getMaxStackSize() == 1
|
||||
&& (stack1.stackTagCompound == null ^ stack2.stackTagCompound == null);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* GT Items don't have any NBT set for the recipe, so if either of the stacks has a NULL nbt, and the other doesn't,
|
||||
* pretend they stack
|
||||
*
|
||||
* @param ItemStack stack
|
||||
* @return
|
||||
*/
|
||||
public static boolean isItemTool(ItemStack stack) {
|
||||
return NEIServerUtils.gtMetaBaseItem != null && NEIServerUtils.gtMetaBaseItem.isInstance(stack.getItem());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ public final class PacketIDs {
|
||||
public static final int SET_CREATIVE_PLUS_MODE = 23;
|
||||
public static final int REQUEST_POTION_GUI = 24;
|
||||
public static final int SET_DUMMY_SLOT = 25;
|
||||
public static final int SEND_CHAT_ITEM_LINK = 26;
|
||||
}
|
||||
|
||||
public static final class S2C {
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
/**
|
||||
* Simply an {@link ItemStack} with position. Mainly used in the recipe handlers.
|
||||
@@ -145,7 +146,7 @@ public class PositionedStack {
|
||||
* NBT-friendly version of {@link #contains(ItemStack)}
|
||||
*/
|
||||
public boolean containsWithNBT(ItemStack ingredient) {
|
||||
for (ItemStack item : items) if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(item, ingredient)) return true;
|
||||
for (ItemStack item : items) if (StackInfo.equalItemAndNBT(item, ingredient, true)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ public class PresetsList {
|
||||
try (FileOutputStream output = new FileOutputStream(presetsFile)) {
|
||||
IOUtils.writeLines(strings, "\n", output, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Filed to save presets list to file {}", presetsFile, e);
|
||||
NEIClientConfig.logger.error("Failed to save presets list to file {}", presetsFile, e);
|
||||
}
|
||||
|
||||
recipeFilter.cache = null;
|
||||
|
||||
@@ -126,19 +126,24 @@ public class SearchTokenParser {
|
||||
Language currentLanguage = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage();
|
||||
|
||||
if (!currentLanguage.getLanguageCode().equals(providersCache.languageCode)) {
|
||||
providersCache.providers = new ArrayList<>();
|
||||
providersCache.languageCode = currentLanguage.getLanguageCode();
|
||||
|
||||
Map<Character, ISearchParserProvider> providers = new HashMap<>();
|
||||
|
||||
for (int index = this.searchProviders.size() - 1; index >= 0; index--) {
|
||||
ISearchParserProvider provider = this.searchProviders.get(index);
|
||||
|
||||
if (!providers.containsKey(provider.getPrefix())
|
||||
&& provider.getMatchingLanguages().contains(currentLanguage)) {
|
||||
providers.put(provider.getPrefix(), provider);
|
||||
if (provider.getMatchingLanguages().contains(currentLanguage)) {
|
||||
if (provider.getSearchMode() == SearchMode.PREFIX && !providers.containsKey(provider.getPrefix())) {
|
||||
providers.put(provider.getPrefix(), provider);
|
||||
} else if (provider.getSearchMode() == SearchMode.ALWAYS) {
|
||||
providersCache.providers.add(provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
providersCache.providers = new ArrayList<>(providers.values());
|
||||
providersCache.languageCode = currentLanguage.getLanguageCode();
|
||||
providersCache.providers.addAll(providers.values());
|
||||
}
|
||||
|
||||
return providersCache.providers;
|
||||
|
||||
@@ -9,7 +9,6 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.boss.BossStatus;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -27,21 +26,16 @@ public class SpawnerRenderer implements IItemRenderer {
|
||||
|
||||
public void renderInventoryItem(RenderBlocks render, ItemStack item) {
|
||||
int meta = item.getItemDamage();
|
||||
|
||||
if (meta == 0) meta = ItemMobSpawner.idPig;
|
||||
|
||||
String bossName = BossStatus.bossName;
|
||||
int bossTimeout = BossStatus.statusBarTime;
|
||||
boolean bossHasColorModifier = BossStatus.hasColorModifier;
|
||||
Entity entity = ItemMobSpawner.getEntity(meta);
|
||||
try {
|
||||
World world = NEIClientUtils.mc().theWorld;
|
||||
ItemMobSpawner.loadSpawners(world);
|
||||
CCRenderState.changeTexture(TextureMap.locationBlocksTexture);
|
||||
render.renderBlockAsItem(Blocks.mob_spawner, 0, 1F);
|
||||
entity.setWorld(render.minecraftRB.theWorld);
|
||||
GL11.glPushMatrix();
|
||||
|
||||
Entity entity = ItemMobSpawner.getEntity(meta);
|
||||
entity.setWorld(world);
|
||||
float f1 = 0.4375F;
|
||||
if (entity.getShadowSize() > 1.5) f1 = 0.1F;
|
||||
GL11.glRotatef((float) (ClientUtils.getRenderTime() * 10), 0.0F, 1.0F, 0.0F);
|
||||
@@ -51,7 +45,6 @@ public class SpawnerRenderer implements IItemRenderer {
|
||||
entity.setLocationAndAngles(0, 0, 0, 0.0F, 0.0F);
|
||||
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 0);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
@@ -13,16 +14,20 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import codechicken.core.gui.GuiScrollSlot;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
@@ -35,6 +40,12 @@ import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.ICraftingHandler;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.NBTJson;
|
||||
import codechicken.nei.util.NEIMouseUtils;
|
||||
|
||||
public class SubsetWidget extends Button implements ItemFilterProvider, IContainerTooltipHandler {
|
||||
@@ -535,6 +546,68 @@ public class SubsetWidget extends Button implements ItemFilterProvider, IContain
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadCustomSubsets() {
|
||||
File dir = new File(NEIClientConfig.configDir, "subsets");
|
||||
|
||||
if (!dir.exists() || !dir.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Stream.of(dir.listFiles()).filter(file -> !file.isDirectory()).forEach(file -> {
|
||||
ClientHandler.loadSettingsFile(
|
||||
"subsets/" + file.getName(),
|
||||
lines -> parseFile(file.getName(), lines.collect(Collectors.toList())));
|
||||
});
|
||||
}
|
||||
|
||||
private static void parseFile(String resource, List<String> itemStrings) {
|
||||
final JsonParser parser = new JsonParser();
|
||||
final int dotIndex = resource.lastIndexOf('.');
|
||||
final String subsetNamespace = dotIndex > 0 ? resource.substring(0, dotIndex) : resource;
|
||||
SubsetTag processedTag = new SubsetTag(subsetNamespace, new ItemStackSet());
|
||||
|
||||
for (String itemStr : itemStrings) {
|
||||
try {
|
||||
if (itemStr.startsWith("; ")) {
|
||||
addTag(processedTag);
|
||||
|
||||
final String handlerName = itemStr.substring(2);
|
||||
final IRecipeHandler recipeHandler = Stream
|
||||
.concat(
|
||||
GuiCraftingRecipe.craftinghandlers.stream(),
|
||||
GuiCraftingRecipe.serialCraftingHandlers.stream())
|
||||
.filter(handler -> handlerName.equals(getHandlerName(handler))).findFirst().orElse(null);
|
||||
String recipeName = handlerName;
|
||||
|
||||
if (recipeHandler != null) {
|
||||
recipeName = recipeHandler.getRecipeName().trim();
|
||||
}
|
||||
|
||||
processedTag = new SubsetTag(
|
||||
subsetNamespace + "." + recipeName.replace(".", ""),
|
||||
new ItemStackSet());
|
||||
} else {
|
||||
final NBTBase nbt = NBTJson.toNbt(parser.parse(itemStr));
|
||||
|
||||
if (nbt instanceof NBTTagCompound tag) {
|
||||
((ItemStackSet) processedTag.filter).add(StackInfo.loadFromNBT(tag));
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Expected NBTTagCompound but got " + nbt.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Failed to load custom subset items from json string:\n{}", itemStr);
|
||||
}
|
||||
}
|
||||
|
||||
addTag(processedTag);
|
||||
}
|
||||
|
||||
private static String getHandlerName(ICraftingHandler handler) {
|
||||
return GuiRecipeTab.getHandlerInfo(handler).getHandlerName();
|
||||
}
|
||||
|
||||
public static void loadHidden() {
|
||||
final List<ItemStack> itemList = new LinkedList<>();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package codechicken.nei.api;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
@@ -164,8 +165,13 @@ public class API {
|
||||
* Add or replace the name normally shown on the item tooltip
|
||||
*/
|
||||
public static void setOverrideName(ItemStack item, String name) {
|
||||
if (!name.equals(ItemInfo.nameOverrides.get(item))) {
|
||||
ItemInfo.nameOverrides.put(item, name);
|
||||
String existing = ItemInfo.nameOverrides.get(item);
|
||||
if (!Objects.equals(name, existing)) {
|
||||
if (name == null) {
|
||||
ItemInfo.nameOverrides.remove(item);
|
||||
} else {
|
||||
ItemInfo.nameOverrides.put(item, name);
|
||||
}
|
||||
LayoutManager.markItemsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,18 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IStackStringifyHandler {
|
||||
|
||||
public NBTTagCompound convertItemStackToNBT(ItemStack stack, boolean saveStackSize);
|
||||
default NBTTagCompound convertItemStackToNBT(ItemStack stack, boolean saveStackSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack convertNBTToItemStack(NBTTagCompound nbtTag);
|
||||
default ItemStack convertNBTToItemStack(NBTTagCompound nbtTag) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default FluidStack getFluid(ItemStack stack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default void pauseItemDamageSound(boolean pause) {}
|
||||
|
||||
public FluidStack getFluid(ItemStack stack);
|
||||
}
|
||||
@@ -124,12 +124,12 @@ public class ItemInfo {
|
||||
addMobSpawnerItem();
|
||||
}
|
||||
|
||||
public static void load(World world) {
|
||||
public static void load() {
|
||||
addVanillaBlockProperties();
|
||||
addDefaultDropDowns();
|
||||
searchItems();
|
||||
parseModItems();
|
||||
ItemMobSpawner.loadSpawners(world);
|
||||
ItemMobSpawner.loadSpawners();
|
||||
addSpawnEggs();
|
||||
addInfiniteHandlers();
|
||||
addInputHandlers();
|
||||
|
||||
@@ -65,11 +65,20 @@ public abstract class ShortcutInputHandler {
|
||||
return ItemPanels.bookmarkPanel.pullBookmarkItems(groupId, NEIClientUtils.shiftKey());
|
||||
}
|
||||
|
||||
if (NEIClientConfig.autocraftingEnabled() && ItemPanels.bookmarkPanel.getGrid().isCraftingMode(groupId)
|
||||
&& NEIClientConfig.isKeyHashDown("gui.craft")) {
|
||||
AutoCraftingManager
|
||||
.runProcessing(ItemPanels.bookmarkPanel.getGrid().createRecipeChainMath(groupId));
|
||||
return true;
|
||||
if (NEIClientConfig.autocraftingEnabled() && NEIClientConfig.isKeyHashDown("gui.craft_items")
|
||||
&& NEIClientUtils.shiftKey()
|
||||
&& ItemPanels.bookmarkPanel.getGrid().isCraftingMode(groupId)) {
|
||||
final RecipeChainMath math = ItemPanels.bookmarkPanel.getGrid().createRecipeChainMath(groupId);
|
||||
|
||||
if (math != null) {
|
||||
|
||||
if (!NEIClientUtils.controlKey()) {
|
||||
autocraftingIgnoreInventory(math);
|
||||
}
|
||||
|
||||
AutoCraftingManager.runProcessing(math);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -91,6 +100,10 @@ public abstract class ShortcutInputHandler {
|
||||
return copyItemStackOreDictionary(stackover);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.chat_link_item")) {
|
||||
return sendItemStackChatLink(stackover);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.recipe")) {
|
||||
return GuiCraftingRecipe.openRecipeGui("item", stackover);
|
||||
}
|
||||
@@ -107,8 +120,9 @@ public abstract class ShortcutInputHandler {
|
||||
return pullRecipeItems(stackover, NEIClientUtils.shiftKey());
|
||||
}
|
||||
|
||||
if (NEIClientConfig.autocraftingEnabled() && NEIClientConfig.isKeyHashDown("gui.craft")) {
|
||||
return runAutoCrafting(stackover);
|
||||
if (NEIClientConfig.autocraftingEnabled() && NEIClientConfig.isKeyHashDown("gui.craft_items")
|
||||
&& NEIClientUtils.shiftKey()) {
|
||||
return runAutoCrafting(stackover, !NEIClientUtils.controlKey());
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -138,6 +152,13 @@ public abstract class ShortcutInputHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean sendItemStackChatLink(ItemStack stackover) {
|
||||
if (stackover == null) return false;
|
||||
|
||||
NEIClientUtils.sendChatItemLink(stackover); // I wish clients could just send formatted messages
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean copyItemStackOreDictionary(ItemStack stackover) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@@ -156,7 +177,7 @@ public abstract class ShortcutInputHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean runAutoCrafting(ItemStack stackover) {
|
||||
private static boolean runAutoCrafting(ItemStack stackover, boolean ignoreInventory) {
|
||||
final RecipeId recipeId = GuiCraftingRecipe.getRecipeId(NEIClientUtils.getGuiContainer(), stackover);
|
||||
|
||||
if (recipeId != null) {
|
||||
@@ -184,6 +205,11 @@ public abstract class ShortcutInputHandler {
|
||||
}
|
||||
|
||||
if (math != null) {
|
||||
|
||||
if (ignoreInventory) {
|
||||
autocraftingIgnoreInventory(math);
|
||||
}
|
||||
|
||||
AutoCraftingManager.runProcessing(math);
|
||||
return true;
|
||||
}
|
||||
@@ -242,7 +268,8 @@ public abstract class ShortcutInputHandler {
|
||||
} else {
|
||||
final RecipeId recipeId = recipe != null ? recipe.getRecipeId() : null;
|
||||
final boolean existsRecipe = recipeId != null
|
||||
&& ItemPanels.bookmarkPanel.existsRecipe(recipeId, BookmarkGrid.DEFAULT_GROUP_ID);
|
||||
&& ItemPanels.bookmarkPanel.existsRecipe(recipeId, BookmarkGrid.DEFAULT_GROUP_ID)
|
||||
|| NEIClientConfig.getBooleanSetting("inventory.bookmarks.bookmarkItemsWithRecipe");
|
||||
|
||||
if (!ItemPanels.bookmarkPanel
|
||||
.removeItem(stackover, existsRecipe ? recipeId : null, BookmarkGrid.DEFAULT_GROUP_ID)) {
|
||||
@@ -279,7 +306,7 @@ public abstract class ShortcutInputHandler {
|
||||
recipe.getIngredients().stream().forEach(ingr -> {
|
||||
final List<ItemStack> permutations = ingr.getPermutations();
|
||||
for (int index = 0; index < permutations.size(); index++) {
|
||||
if (FavoriteRecipes.getFavorite(permutations.get(index)) != null) {
|
||||
if (FavoriteRecipes.contains(permutations.get(index))) {
|
||||
ingr.setActiveIndex(index);
|
||||
break;
|
||||
}
|
||||
@@ -333,7 +360,13 @@ public abstract class ShortcutInputHandler {
|
||||
}
|
||||
|
||||
if (NEIClientConfig.autocraftingEnabled() && ItemPanels.bookmarkPanel.getGrid().isCraftingMode(groupId)) {
|
||||
hotkeys.put(NEIClientConfig.getKeyName("gui.craft"), NEIClientUtils.translate("bookmark.group.craft"));
|
||||
hotkeys.put(
|
||||
NEIClientConfig
|
||||
.getKeyName("gui.craft_items", NEIClientUtils.SHIFT_HASH + NEIClientUtils.CTRL_HASH),
|
||||
NEIClientUtils.translate("bookmark.group.craft_missing"));
|
||||
hotkeys.put(
|
||||
NEIClientConfig.getKeyName("gui.craft_items", NEIClientUtils.SHIFT_HASH),
|
||||
NEIClientUtils.translate("bookmark.group.craft_all"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,6 +419,9 @@ 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.chat_link_item"),
|
||||
NEIClientUtils.translate("itempanel.chat_link_item"));
|
||||
|
||||
if (!(gui instanceof GuiRecipe) && NEIClientConfig.canCheatItem(stack)) {
|
||||
hotkeys.put(
|
||||
@@ -429,7 +465,14 @@ public abstract class ShortcutInputHandler {
|
||||
}
|
||||
|
||||
if (NEIClientConfig.autocraftingEnabled()) {
|
||||
hotkeys.put(NEIClientConfig.getKeyName("gui.craft"), NEIClientUtils.translate("itempanel.craft"));
|
||||
hotkeys.put(
|
||||
NEIClientConfig.getKeyName(
|
||||
"gui.craft_items",
|
||||
NEIClientUtils.SHIFT_HASH + NEIClientUtils.CTRL_HASH),
|
||||
NEIClientUtils.translate("itempanel.craft_missing"));
|
||||
hotkeys.put(
|
||||
NEIClientConfig.getKeyName("gui.craft_items", NEIClientUtils.SHIFT_HASH),
|
||||
NEIClientUtils.translate("itempanel.craft_all"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,11 +481,33 @@ public abstract class ShortcutInputHandler {
|
||||
return hotkeys;
|
||||
}
|
||||
|
||||
private static void autocraftingIgnoreInventory(RecipeChainMath math) {
|
||||
final GuiContainer guiContainer = NEIClientUtils.getGuiContainer();
|
||||
final List<ItemStack> playerInventory = AutoCraftingManager.getInventoryItems(guiContainer).values();
|
||||
final RecipeId rootRecipeId = math.createMasterRoot();
|
||||
|
||||
for (BookmarkItem item : math.recipeIngredients) {
|
||||
if (item.amount > 0 && rootRecipeId.equals(item.recipeId)) {
|
||||
long amount = 0;
|
||||
|
||||
for (ItemStack stack : playerInventory) {
|
||||
if (NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack, item.itemStack)) {
|
||||
amount += StackInfo.getAmount(stack);
|
||||
}
|
||||
}
|
||||
|
||||
if (amount >= item.amount) {
|
||||
item.factor = item.amount = amount + item.amount - (amount % item.amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static RecipeId getHotkeyRecipeId(GuiContainer gui, int mousex, int mousey, ItemStack stack,
|
||||
BookmarksGridSlot slot) {
|
||||
|
||||
if (slot != null) {
|
||||
return slot.getRecipeId();
|
||||
return slot.isIngredient() ? null : slot.getRecipeId();
|
||||
} else if (ItemPanels.itemPanel.contains(mousex, mousey)
|
||||
|| ItemPanels.itemPanel.historyPanel.contains(mousex, mousey)) {
|
||||
return FavoriteRecipes.getFavorite(stack);
|
||||
|
||||
@@ -413,7 +413,7 @@ public class NEITransformer implements IClassTransformer {
|
||||
if (name.equals("net.minecraftforge.oredict.OreDictionary")) {
|
||||
ClassReader cr = new ClassReader(bytes);
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
||||
cr.accept(new OreDictionaryVisitor(ASM5, cw), ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||
cr.accept(new OreDictionaryVisitor(ASM5, cw), 0);
|
||||
bytes = cw.toByteArray();
|
||||
}
|
||||
bytes = transformSubclasses(name, bytes);
|
||||
|
||||
@@ -1024,8 +1024,7 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
}
|
||||
|
||||
if (bookmarkItem != null && (group.crafting != null && group.viewMode == BookmarkViewMode.DEFAULT
|
||||
|| group.viewMode == BookmarkViewMode.TODO_LIST)) {
|
||||
|
||||
|| group.viewMode == BookmarkViewMode.TODO_LIST && !sortableItem.bookmarkItem.isIngredient)) {
|
||||
while (sortIndex > 0 && bookmarkItem.equalsRecipe(getCalculatedItem(sortedIndexes.get(sortIndex - 1)))) {
|
||||
sortIndex--;
|
||||
}
|
||||
@@ -1055,7 +1054,8 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
if (nextSortIndex < sortedIndexes.size()) {
|
||||
final int nextItemIndex = sortedIndexes.get(nextSortIndex);
|
||||
|
||||
if (group.viewMode == BookmarkViewMode.TODO_LIST && target.equalsRecipe(getCalculatedItem(nextItemIndex))) {
|
||||
if (group.viewMode == BookmarkViewMode.TODO_LIST && !target.isIngredient
|
||||
&& target.equalsRecipe(getCalculatedItem(nextItemIndex))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.recipe.Recipe;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.recipe.Recipe.RecipeIngredient;
|
||||
@@ -16,6 +17,8 @@ import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
public class BookmarkItem {
|
||||
|
||||
private static Map<ItemStack, String> fuzzyPermutations = new HashMap<>();
|
||||
|
||||
public int groupId;
|
||||
|
||||
public long amount = 0L;
|
||||
@@ -120,13 +123,24 @@ public class BookmarkItem {
|
||||
return Collections.singletonMap(getItemGUID(stack), stack);
|
||||
}
|
||||
|
||||
private static String getItemGUID(ItemStack stack) {
|
||||
private static synchronized String getItemGUID(ItemStack stack) {
|
||||
final FluidStack fluidStack = StackInfo.getFluid(stack);
|
||||
|
||||
if (fluidStack != null) {
|
||||
return fluidStack.getFluid().getName() + ":" + fluidStack.tag;
|
||||
} else {
|
||||
return StackInfo.getItemStackGUID(stack);
|
||||
|
||||
for (Map.Entry<ItemStack, String> entry : BookmarkItem.fuzzyPermutations.entrySet()) {
|
||||
if (NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack, entry.getKey())) {
|
||||
BookmarkItem.fuzzyPermutations.put(stack, entry.getValue());
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
final String stackGUID = StackInfo.getItemStackGUID(stack);
|
||||
BookmarkItem.fuzzyPermutations.put(stack, stackGUID);
|
||||
|
||||
return stackGUID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ public class BookmarkStorage {
|
||||
IOUtils.writeLines(strings, "\n", output, StandardCharsets.UTF_8);
|
||||
NEIClientConfig.world.nbt.setTag("bookmark", navigation);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Filed to save bookmarks list to file {}", bookmarkFile, e);
|
||||
NEIClientConfig.logger.error("Failed to save bookmarks list to file {}", bookmarkFile, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package codechicken.nei.commands;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
|
||||
import codechicken.nei.ItemPanels;
|
||||
|
||||
public class CommandBookmarkAdd extends CommandBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "nei_bookmark";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "/nei_bookmark <nbt>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) {
|
||||
|
||||
if (args.length < 1 || args[0].length() < 3) {
|
||||
sender.addChatMessage(new ChatComponentText("§c/nei_bookmark <nbt>"));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
ItemPanels.bookmarkPanel.addItem(
|
||||
ItemStack.loadItemStackFromNBT((NBTTagCompound) JsonToNBT.func_150315_a(String.join(" ", args))));
|
||||
sender.addChatMessage(new ChatComponentTranslation("nei.chat.bookmark_added.text"));
|
||||
} catch (NBTException e) {
|
||||
sender.addChatMessage(new ChatComponentText(e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
package codechicken.nei.commands;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.nei.ClientHandler;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.ICraftingHandler;
|
||||
import codechicken.nei.recipe.Recipe;
|
||||
import codechicken.nei.recipe.RecipeHandlerQuery;
|
||||
import codechicken.nei.util.NBTJson;
|
||||
|
||||
public class CommandRecipeId extends CommandBase {
|
||||
|
||||
protected static class ProcessDiffThread extends Thread {
|
||||
|
||||
protected final ICommandSender sender;
|
||||
protected final File prevFile;
|
||||
protected final File currFile;
|
||||
protected final File diffFile;
|
||||
|
||||
public ProcessDiffThread(ICommandSender sender, File prevFile, File currFile, File diffFile) {
|
||||
this.sender = sender;
|
||||
this.prevFile = prevFile;
|
||||
this.currFile = currFile;
|
||||
this.diffFile = diffFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sendChatInfoMessage(sender, "nei.chat.recipeid.diff.start");
|
||||
|
||||
final Set<String> prevRecipes = loadFileContent(this.prevFile);
|
||||
final Set<String> currRecipes = loadFileContent(this.currFile);
|
||||
final Set<String> notAllowedRecipes = prevRecipes.stream().filter(recipe -> !currRecipes.contains(recipe))
|
||||
.collect(Collectors.toCollection(TreeSet::new));
|
||||
final List<String> subsetsList = new ArrayList<>();
|
||||
|
||||
generateSubsets(notAllowedRecipes).forEach((handlerName, recipes) -> {
|
||||
subsetsList.add("; " + handlerName);
|
||||
subsetsList.addAll(recipes);
|
||||
});
|
||||
|
||||
saveFile(this.diffFile, subsetsList);
|
||||
saveFile(getFile("not-allowed-recipes"), new ArrayList<>(notAllowedRecipes));
|
||||
|
||||
sendChatInfoMessage(sender, "nei.chat.recipeid.diff.finish");
|
||||
}
|
||||
|
||||
private Set<String> loadFileContent(File file) {
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
return new HashSet<>(IOUtils.readLines(reader));
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to load '{}' file {}", file.getName(), file, e);
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
private Map<String, Set<String>> generateSubsets(Set<String> notAllowedRecipes) {
|
||||
final JsonParser parser = new JsonParser();
|
||||
final Map<String, Set<String>> subsetsBuilder = new TreeMap<>();
|
||||
|
||||
for (String recipeStr : notAllowedRecipes) {
|
||||
try {
|
||||
final NBTTagCompound nbtRecipe = (NBTTagCompound) NBTJson.toNbt(parser.parse(recipeStr));
|
||||
|
||||
if (nbtRecipe.hasKey("result")) {
|
||||
final NBTTagCompound nbtStack = nbtRecipe.getCompoundTag("result");
|
||||
nbtStack.removeTag("Count");
|
||||
subsetsBuilder.computeIfAbsent(nbtRecipe.getString("handlerName"), rn -> new TreeSet<>())
|
||||
.add(NBTJson.toJson(nbtStack));
|
||||
} else {
|
||||
NEIClientConfig.logger.error("Found Broken RecipeId {}", recipeStr);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
NEIClientConfig.logger.error("Found Broken RecipeId {}", recipeStr, ex);
|
||||
}
|
||||
}
|
||||
|
||||
return subsetsBuilder;
|
||||
}
|
||||
|
||||
private void saveFile(File file, List<String> content) {
|
||||
try (FileOutputStream output = new FileOutputStream(file)) {
|
||||
IOUtils.writeLines(content, "\n", output, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to save recipeid diff list to file {}", file, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static class ProcessDumpThread extends Thread {
|
||||
|
||||
private ArrayList<ICraftingHandler> craftinghandlers = new ArrayList<>();
|
||||
private ArrayList<ICraftingHandler> serialCraftingHandlers = new ArrayList<>();
|
||||
protected final ICommandSender sender;
|
||||
protected final File currFile;
|
||||
|
||||
public ProcessDumpThread(ICommandSender sender, File currFile) {
|
||||
this.sender = sender;
|
||||
this.currFile = currFile;
|
||||
ClientHandler.loadSettingsFile("recipeidblacklist.cfg", lines -> {
|
||||
final Set<String> names = lines.collect(Collectors.toSet());
|
||||
|
||||
this.craftinghandlers = GuiCraftingRecipe.craftinghandlers.stream()
|
||||
.filter(h -> !names.contains(GuiRecipeTab.getHandlerInfo(h).getHandlerName()))
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
this.serialCraftingHandlers = GuiCraftingRecipe.serialCraftingHandlers.stream()
|
||||
.filter(h -> !names.contains(GuiRecipeTab.getHandlerInfo(h).getHandlerName()))
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
NEIClientConfig.logger.info("Start processing recipe handlers!");
|
||||
sendChatInfoMessage(sender, "nei.chat.recipeid.dump.start");
|
||||
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(currFile.toPath(), StandardCharsets.UTF_8)) {
|
||||
int total = ItemList.items.size();
|
||||
int count = 0;
|
||||
|
||||
for (ItemStack stack : ItemList.items) {
|
||||
|
||||
if (count % 1000 == 0) {
|
||||
NEIClientConfig.logger.info(
|
||||
"({}/{}). Processing {} crafting recipes...",
|
||||
count,
|
||||
total,
|
||||
stack.getDisplayName());
|
||||
}
|
||||
|
||||
count++;
|
||||
|
||||
for (ICraftingHandler handler : getCraftingHandlers(stack)) {
|
||||
for (int index = 0, num = handler.numRecipes(); index < num; index++) {
|
||||
try {
|
||||
final Recipe recipe = Recipe.of(handler, index);
|
||||
if (!recipe.getIngredients().isEmpty() && !recipe.getResults().isEmpty()) {
|
||||
writer.write(NBTJson.toJson(recipe.getRecipeId().toJsonObject()));
|
||||
writer.newLine();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
NEIClientConfig.logger.error(
|
||||
"Found Broken RecipeId {}:{}",
|
||||
GuiRecipeTab.getHandlerInfo(handler).getHandlerName(),
|
||||
stack,
|
||||
ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Error dumping RecipeId", e);
|
||||
}
|
||||
|
||||
NEIClientConfig.logger.info("Finished processing recipe handlers!");
|
||||
sendChatInfoMessage(sender, "nei.chat.recipeid.dump.finish");
|
||||
}
|
||||
|
||||
private ArrayList<ICraftingHandler> getCraftingHandlers(Object... results) {
|
||||
return new RecipeHandlerQuery<>(
|
||||
h -> h.getRecipeHandler("item", results),
|
||||
this.craftinghandlers,
|
||||
this.serialCraftingHandlers,
|
||||
"Error while looking up crafting recipe",
|
||||
"outputId: item",
|
||||
"results: " + Arrays.toString(results))
|
||||
.runWithProfiling(NEIClientUtils.translate("recipe.concurrent.crafting"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "recipeid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "/recipeid dump <filename> OR /recipeid diff <prev-filename> <curr-filename> [subset name]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) {
|
||||
final String command = args.length == 0 ? null : args[0];
|
||||
|
||||
if ("dump".equals(command)) {
|
||||
processDumpCommand(sender, args);
|
||||
} else if ("diff".equals(command)) {
|
||||
processDiffCommand(sender, args);
|
||||
} else {
|
||||
sendChatErrorMessage(sender, getCommandUsage(sender));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void processDiffCommand(ICommandSender sender, String[] args) {
|
||||
|
||||
if (args.length > 4) {
|
||||
sendChatErrorMessage(sender, "nei.chat.recipeid.many_params", getCommandUsage(sender));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length < 3) {
|
||||
sendChatErrorMessage(sender, getCommandUsage(sender));
|
||||
return;
|
||||
}
|
||||
|
||||
final File prevFilename = getFile(args[1]);
|
||||
final File currFilename = getFile(args[2]);
|
||||
final File diffFilename = getFile(args.length > 3 ? args[3] : "changelog");
|
||||
|
||||
if (!prevFilename.exists()) {
|
||||
sendChatErrorMessage(sender, "nei.chat.recipeid.not_found", prevFilename.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!currFilename.exists()) {
|
||||
sendChatErrorMessage(sender, "nei.chat.recipeid.not_found", currFilename.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
(new ProcessDiffThread(sender, prevFilename, currFilename, diffFilename)).start();
|
||||
}
|
||||
|
||||
protected void processDumpCommand(ICommandSender sender, String[] args) {
|
||||
|
||||
if (args.length > 2) {
|
||||
sendChatErrorMessage(sender, "nei.chat.recipeid.many_params", getCommandUsage(sender));
|
||||
return;
|
||||
}
|
||||
|
||||
final File dir = new File(CommonUtils.getMinecraftDir(), "recipeid");
|
||||
final String currFilename = args.length == 2 ? args[1] : "recipeId";
|
||||
if (!dir.exists()) dir.mkdirs();
|
||||
|
||||
(new ProcessDumpThread(sender, getFile(currFilename))).start();
|
||||
}
|
||||
|
||||
private static File getFile(String filename) {
|
||||
return new File(CommonUtils.getMinecraftDir(), "recipeid/" + filename + ".json");
|
||||
}
|
||||
|
||||
private static void sendChatInfoMessage(ICommandSender sender, String translationKey, Object... args) {
|
||||
sender.addChatMessage(
|
||||
new ChatComponentTranslation(translationKey, args)
|
||||
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA)));
|
||||
}
|
||||
|
||||
private static void sendChatErrorMessage(ICommandSender sender, String translationKey, Object... args) {
|
||||
sender.addChatMessage(
|
||||
new ChatComponentTranslation(translationKey, args)
|
||||
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class HandlerDumper extends DataDumper {
|
||||
}
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Filed to save dump handler list to file {}", file, e);
|
||||
NEIClientConfig.logger.error("Failed to save dump handler list to file {}", file, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package codechicken.nei.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
@@ -15,6 +15,7 @@ import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.recipe.CatalystInfo;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.HandlerInfo;
|
||||
import codechicken.nei.recipe.InformationHandler;
|
||||
import codechicken.nei.recipe.RecipeCatalysts;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
@@ -33,18 +34,11 @@ public class IMCHandler {
|
||||
if (type == null || type.isEmpty()) continue;
|
||||
if (CommonUtils.isClient()) {
|
||||
switch (type) {
|
||||
case "registerHandlerInfo":
|
||||
handleRegisterHandlerInfo(message);
|
||||
break;
|
||||
case "removeHandlerInfo":
|
||||
handleRemoveHandlerInfo(message);
|
||||
break;
|
||||
case "registerCatalystInfo":
|
||||
handleRegisterCatalystInfo(message);
|
||||
break;
|
||||
case "removeCatalystInfo":
|
||||
handleRemoveCatalystInfo(message);
|
||||
break;
|
||||
case "registerHandlerInfo" -> handleRegisterHandlerInfo(message);
|
||||
case "removeHandlerInfo" -> handleRemoveHandlerInfo(message);
|
||||
case "registerCatalystInfo" -> handleRegisterCatalystInfo(message);
|
||||
case "removeCatalystInfo" -> handleRemoveCatalystInfo(message);
|
||||
case "addItemInfo" -> handleAddItemInfo(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,14 +51,14 @@ public class IMCHandler {
|
||||
}
|
||||
final NBTTagCompound tag = message.getNBTValue();
|
||||
final String handler = tag.getString("handler");
|
||||
NEIClientConfig.logger.info("Processing registerHandlerInfo `" + handler + "` from " + message.getSender());
|
||||
NEIClientConfig.logger.info("Processing registerHandlerInfo `{}` from {}", handler, message.getSender());
|
||||
|
||||
final String modName = tag.getString("modName");
|
||||
final String modId = tag.getString("modId");
|
||||
final boolean requiresMod = tag.getBoolean("modRequired");
|
||||
final String excludedModId = tag.hasKey("excludedModId") ? tag.getString("excludedModId") : null;
|
||||
|
||||
if (handler.equals("") || modName.equals("") || modId.equals("")) {
|
||||
if (handler.isEmpty() || modName.isEmpty() || modId.isEmpty()) {
|
||||
NEIClientConfig.logger.warn("Missing relevant information to registerHandlerInfo!");
|
||||
return;
|
||||
}
|
||||
@@ -74,7 +68,7 @@ public class IMCHandler {
|
||||
|
||||
HandlerInfo info = new HandlerInfo(handler, modName, modId, requiresMod, excludedModId);
|
||||
final String imageResource = tag.hasKey("imageResource") ? tag.getString("imageResource") : null;
|
||||
if (imageResource != null && !imageResource.equals("")) {
|
||||
if (imageResource != null && !imageResource.isEmpty()) {
|
||||
info.setImage(
|
||||
imageResource,
|
||||
tag.getInteger("imageX"),
|
||||
@@ -84,7 +78,7 @@ public class IMCHandler {
|
||||
}
|
||||
if (!info.hasImageOrItem()) {
|
||||
final String itemName = tag.getString("itemName");
|
||||
if (itemName != null && !itemName.equals("")) {
|
||||
if (itemName != null && !itemName.isEmpty()) {
|
||||
info.setItem(itemName, tag.hasKey("nbtInfo") ? tag.getString("nbtInfo") : null);
|
||||
}
|
||||
}
|
||||
@@ -100,9 +94,13 @@ public class IMCHandler {
|
||||
: HandlerInfo.DEFAULT_MAX_PER_PAGE;
|
||||
info.setHandlerDimensions(imageHeight, imageWidth, maxRecipesPerPage);
|
||||
} catch (NumberFormatException ignored) {
|
||||
NEIClientConfig.logger.info("Error setting handler dimensions for " + handler);
|
||||
NEIClientConfig.logger.info("Error setting handler dimensions for {}", handler);
|
||||
}
|
||||
|
||||
// true if not set to false
|
||||
info.setShowFavoritesButton(!tag.hasKey("showFavoritesButton") || tag.getBoolean("showFavoritesButton"));
|
||||
info.setShowOverlayButton(!tag.hasKey("showOverlayButton") || tag.getBoolean("showOverlayButton"));
|
||||
|
||||
GuiRecipeTab.handlerAdderFromIMC.remove(handler);
|
||||
GuiRecipeTab.handlerAdderFromIMC.put(handler, info);
|
||||
}
|
||||
@@ -114,7 +112,7 @@ public class IMCHandler {
|
||||
}
|
||||
final NBTTagCompound tag = message.getNBTValue();
|
||||
final String handler = tag.getString("handler");
|
||||
NEIClientConfig.logger.info("Processing removeHandlerInfo `" + handler + "` from " + message.getSender());
|
||||
NEIClientConfig.logger.info("Processing removeHandlerInfo `{}` from {}", handler, message.getSender());
|
||||
|
||||
GuiRecipeTab.handlerRemoverFromIMC.add(handler);
|
||||
}
|
||||
@@ -126,7 +124,7 @@ public class IMCHandler {
|
||||
}
|
||||
|
||||
if (!processedCatalystSenders.contains(message.getSender())) {
|
||||
NEIClientConfig.logger.info("Processing registerCatalystInfo from " + message.getSender());
|
||||
NEIClientConfig.logger.info("Processing registerCatalystInfo from {}", message.getSender());
|
||||
processedCatalystSenders.add(message.getSender());
|
||||
}
|
||||
final NBTTagCompound tag = message.getNBTValue();
|
||||
@@ -135,23 +133,14 @@ public class IMCHandler {
|
||||
NEIClientConfig.logger.warn("Missing handlerID for registerCatalystInfo!");
|
||||
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 registerCatalystInfo in `%s`!", handlerID));
|
||||
return;
|
||||
}
|
||||
final ItemStack itemStack = NEIServerUtils.getModdedItem(itemName, nbtInfo);
|
||||
final ItemStack itemStack = getItemStackFromIMC(message, "registerCatalystInfo");
|
||||
if (itemStack == null) {
|
||||
NEIClientConfig.logger.warn(String.format("Cannot find item `%s`!", itemName));
|
||||
return;
|
||||
}
|
||||
final int priority = tag.getInteger("priority");
|
||||
|
||||
RecipeCatalysts
|
||||
.addOrPut(RecipeCatalysts.catalystsAdderFromIMC, handlerID, new CatalystInfo(itemStack, priority));
|
||||
NEIClientConfig.logger
|
||||
.info(String.format("Added catalyst `%s` to handler %s", itemStack.getDisplayName(), handlerID));
|
||||
NEIClientConfig.logger.info("Added catalyst `{}` to handler {}", itemStack.getDisplayName(), handlerID);
|
||||
}
|
||||
|
||||
private static void handleRemoveCatalystInfo(IMCMessage message) {
|
||||
@@ -160,33 +149,62 @@ public class IMCHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
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!");
|
||||
NEIClientConfig.logger.warn("Missing handlerID for removeCatalystInfo!");
|
||||
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 registerCatalystInfo in `%s`!", handlerID));
|
||||
return;
|
||||
}
|
||||
final ItemStack itemStack = NEIServerUtils.getModdedItem(itemName, nbtInfo);
|
||||
final ItemStack itemStack = getItemStackFromIMC(message, "removeCatalystInfo");
|
||||
if (itemStack == null) {
|
||||
NEIClientConfig.logger.warn(String.format("Cannot find item `%s`!", itemName));
|
||||
return;
|
||||
}
|
||||
|
||||
if (RecipeCatalysts.catalystsRemoverFromIMC.containsKey(handlerID)) {
|
||||
RecipeCatalysts.catalystsRemoverFromIMC.get(handlerID).add(itemStack);
|
||||
} else {
|
||||
RecipeCatalysts.catalystsRemoverFromIMC
|
||||
.put(handlerID, new ArrayList<>(Collections.singletonList(itemStack)));
|
||||
RecipeCatalysts.catalystsRemoverFromIMC.computeIfAbsent(handlerID, k -> new ArrayList<>()).add(itemStack);
|
||||
NEIClientConfig.logger.info("Removed catalyst `{}` from handler {}", itemStack.getDisplayName(), handlerID);
|
||||
}
|
||||
|
||||
private static void handleAddItemInfo(IMCMessage message) {
|
||||
if (!message.isNBTMessage()) {
|
||||
logInvalidMessage(message, "NBT");
|
||||
return;
|
||||
}
|
||||
NEIClientConfig.logger
|
||||
.info(String.format("Removed catalyst `%s` from handler %s", itemStack.getDisplayName(), handlerID));
|
||||
|
||||
final NBTTagCompound tag = message.getNBTValue();
|
||||
if (tag.hasKey("pages")) addMultipleInfoPages(message);
|
||||
if (tag.hasKey("page")) addSingleInfoPage(message);
|
||||
}
|
||||
|
||||
private static void addMultipleInfoPages(IMCMessage message) {
|
||||
final NBTTagCompound tag = message.getNBTValue();
|
||||
final String filter = tag.getString("filter");
|
||||
final NBTTagList pages = tag.getTagList("pages", 8); // 8 = TAG_String
|
||||
for (int i = 0; i < pages.tagCount(); i++) {
|
||||
String page = pages.getStringTagAt(i);
|
||||
InformationHandler.addInformationPage(filter, page);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addSingleInfoPage(IMCMessage message) {
|
||||
final NBTTagCompound tag = message.getNBTValue();
|
||||
String filter = tag.getString("filter");
|
||||
String page = tag.getString("page");
|
||||
InformationHandler.addInformationPage(filter, page);
|
||||
}
|
||||
|
||||
private static ItemStack getItemStackFromIMC(IMCMessage message, String logAction) {
|
||||
final NBTTagCompound tag = message.getNBTValue();
|
||||
final String itemName = tag.getString("itemName");
|
||||
final String nbtInfo = tag.hasKey("nbtInfo") ? tag.getString("nbtInfo") : null;
|
||||
|
||||
NEIClientConfig.logger.info("Processing {} for item `{}` from {}", logAction, itemName, message.getSender());
|
||||
final ItemStack itemStack = NEIServerUtils.getModdedItem(itemName, nbtInfo);
|
||||
|
||||
if (itemStack == null) {
|
||||
NEIClientConfig.logger.warn("Cannot find item `{}`!", itemName);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
private static void logInvalidMessage(FMLInterModComms.IMCMessage message, String type) {
|
||||
|
||||
@@ -180,7 +180,9 @@ public class GuiContainerManager {
|
||||
namelist.set(0, stack.getRarity().rarityColor.toString() + namelist.get(0));
|
||||
|
||||
for (int i = 1; i < namelist.size(); i++) {
|
||||
if (!namelist.get(i).startsWith(GuiDraw.TOOLTIP_HANDLER)) {
|
||||
if (namelist.get(i) == null) {
|
||||
namelist.set(i, "");
|
||||
} else if (!namelist.get(i).startsWith(GuiDraw.TOOLTIP_HANDLER)) {
|
||||
namelist.set(i, EnumChatFormatting.GRAY + namelist.get(i) + EnumChatFormatting.RESET);
|
||||
}
|
||||
}
|
||||
@@ -221,8 +223,8 @@ public class GuiContainerManager {
|
||||
return countDetails(
|
||||
stack.stackSize,
|
||||
stack.getMaxStackSize(),
|
||||
"Count: %s = %s * %s + %s",
|
||||
"Count: %s = %s * %s");
|
||||
translate("inventory.tooltip.count.item", "%s = %s * %s + %s"),
|
||||
translate("inventory.tooltip.count.item", "%s = %s * %s"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +236,11 @@ public class GuiContainerManager {
|
||||
|
||||
@Nullable
|
||||
public static String fluidAmountDetails(int amount) {
|
||||
return countDetails(amount, 144, "Amount: %s L = %s * %s L + %s L", "Amount: %s L = %s * %s L");
|
||||
return countDetails(
|
||||
amount,
|
||||
144,
|
||||
translate("inventory.tooltip.count.fluid", "%s L = %s * %s L + %s L"),
|
||||
translate("inventory.tooltip.count.fluid", "%s L = %s * %s L"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -725,15 +731,18 @@ public class GuiContainerManager {
|
||||
final List<String> currentTooltip = tooltips.get(tooltipPage);
|
||||
|
||||
if (maxTooltipPage > 1) {
|
||||
final String lastLine = currentTooltip.remove(currentTooltip.size() - 1);
|
||||
final String pageTooltip = EnumChatFormatting.ITALIC + NEIClientUtils.translate(
|
||||
"inventory.tooltip.page",
|
||||
tooltipPage + 1,
|
||||
maxTooltipPage,
|
||||
NEIClientConfig.getKeyName("gui.next_tooltip"));
|
||||
|
||||
currentTooltip.set(
|
||||
currentTooltip.size() - 1,
|
||||
currentTooltip.get(currentTooltip.size() - 1) + GuiDraw.TOOLTIP_LINESPACE);
|
||||
if (lastLine.startsWith(GuiDraw.TOOLTIP_HANDLER)) {
|
||||
currentTooltip.add(lastLine);
|
||||
} else {
|
||||
currentTooltip.add(lastLine + GuiDraw.TOOLTIP_LINESPACE);
|
||||
}
|
||||
|
||||
currentTooltip.add(pageTooltip);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
|
||||
import codechicken.nei.ItemPanels;
|
||||
import codechicken.nei.ItemStackAmount;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.RestartableTask;
|
||||
@@ -25,25 +23,20 @@ public class AutoCraftingManager {
|
||||
|
||||
private static final RestartableTask task = new RestartableTask("NEI Bookmark AutoCraft Processing") {
|
||||
|
||||
private static final ItemStack ROOT_ITEM = new ItemStack(Blocks.fire);
|
||||
private static final RecipeId ROOT_RECIPE_ID = RecipeId
|
||||
.of(ROOT_ITEM, "recipe-autocrafting", Collections.emptyList());
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
final GuiContainer guiContainer = NEIClientUtils.getGuiContainer();
|
||||
final InventoryPlayer playerInventory = guiContainer.mc.thePlayer.inventory;
|
||||
final ItemStackAmount inventory = ItemStackAmount.of(Arrays.asList(playerInventory.mainInventory));
|
||||
final RecipeChainMath math = createMasterRoot(AutoCraftingManager.math);
|
||||
final List<BookmarkItem> initialItems = prepareInitialItems(math, inventory);
|
||||
final List<BookmarkItem> initialItems = prepareInitialItems(math, getInventoryItems(guiContainer));
|
||||
boolean processed = false;
|
||||
boolean changed = false;
|
||||
|
||||
StackInfo.pauseItemDamageSound(true);
|
||||
|
||||
do {
|
||||
changed = false;
|
||||
|
||||
RecipeChainIterator iterator = new RecipeChainIterator(math, initialItems);
|
||||
iterator.updateInventory(playerInventory.mainInventory);
|
||||
iterator.updateInventory(getInventoryItems(guiContainer));
|
||||
|
||||
while (iterator.hasNext() && !interrupted(guiContainer)) {
|
||||
final Map<RecipeId, Long> recipes = iterator.next();
|
||||
@@ -69,12 +62,14 @@ public class AutoCraftingManager {
|
||||
if (craft) {
|
||||
changed = true;
|
||||
processed = true;
|
||||
iterator.updateInventory(playerInventory.mainInventory);
|
||||
iterator.updateInventory(getInventoryItems(guiContainer));
|
||||
}
|
||||
}
|
||||
|
||||
} while (changed && !interrupted(guiContainer));
|
||||
|
||||
StackInfo.pauseItemDamageSound(false);
|
||||
|
||||
if (processed && !changed && !interrupted(guiContainer)) {
|
||||
NEIClientUtils.playClickSound();
|
||||
}
|
||||
@@ -91,31 +86,6 @@ public class AutoCraftingManager {
|
||||
return interrupted() || guiContainer != NEIClientUtils.getGuiContainer();
|
||||
}
|
||||
|
||||
private RecipeChainMath createMasterRoot(RecipeChainMath math) {
|
||||
final List<BookmarkItem> rootIngredients = new ArrayList<>();
|
||||
|
||||
for (BookmarkItem item : math.recipeResults) {
|
||||
if (math.outputRecipes.containsKey(item.recipeId)) {
|
||||
long amount = item.factor * math.outputRecipes.get(item.recipeId);
|
||||
rootIngredients.add(
|
||||
BookmarkItem.of(
|
||||
-1,
|
||||
item.getItemStack(amount),
|
||||
item.getStackSize(amount),
|
||||
ROOT_RECIPE_ID,
|
||||
true,
|
||||
BookmarkItem.generatePermutations(item.itemStack, null)));
|
||||
}
|
||||
}
|
||||
|
||||
math.outputRecipes.clear();
|
||||
math.outputRecipes.put(ROOT_RECIPE_ID, 1L);
|
||||
math.recipeResults.add(BookmarkItem.of(-1, ROOT_ITEM, 1, ROOT_RECIPE_ID, false));
|
||||
math.recipeIngredients.addAll(rootIngredients);
|
||||
|
||||
return math;
|
||||
}
|
||||
|
||||
private List<BookmarkItem> prepareInitialItems(RecipeChainMath math, ItemStackAmount inventory) {
|
||||
final List<BookmarkItem> initialItems = new ArrayList<>();
|
||||
|
||||
@@ -139,6 +109,8 @@ public class AutoCraftingManager {
|
||||
AutoCraftingManager.math = math;
|
||||
|
||||
if (AutoCraftingManager.math != null) {
|
||||
ItemPanels.bookmarkPanel.clearTooltips();
|
||||
math.createMasterRoot();
|
||||
task.restart();
|
||||
}
|
||||
}
|
||||
@@ -147,4 +119,16 @@ public class AutoCraftingManager {
|
||||
return AutoCraftingManager.math != null && !task.interrupted();
|
||||
}
|
||||
|
||||
public static ItemStackAmount getInventoryItems(GuiContainer guiContainer) {
|
||||
final ItemStackAmount inventory = new ItemStackAmount();
|
||||
|
||||
for (Slot slot : guiContainer.inventorySlots.inventorySlots) {
|
||||
if (slot.getHasStack() && !(slot instanceof SlotCrafting) && slot.canTakeStack(guiContainer.mc.thePlayer)) {
|
||||
inventory.add(slot.getStack());
|
||||
}
|
||||
}
|
||||
|
||||
return inventory;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,11 +36,10 @@ public class CheatItemHandler extends INEIGuiAdapter {
|
||||
draggedStack.stackSize -= total - contents;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
draggedStack.stackSize = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -9,34 +9,21 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.nei.FastTransferManager;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.util.NBTHelper;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
|
||||
private static Class<?> gtItem;
|
||||
|
||||
static {
|
||||
try {
|
||||
final ClassLoader loader = DefaultOverlayHandler.class.getClassLoader();
|
||||
gtItem = ReflectionHelper
|
||||
.getClass(loader, "gregtech.api.items.MetaBaseItem", "gregtech.api.items.GT_MetaBase_Item");
|
||||
} catch (Exception ignored) {
|
||||
/* Do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
public static class DistributedIngred {
|
||||
|
||||
public DistributedIngred(ItemStack item) {
|
||||
@@ -48,6 +35,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
public int distributed;
|
||||
public int numSlots;
|
||||
public int recipeAmount;
|
||||
public boolean isContainerItem = false;
|
||||
}
|
||||
|
||||
public static class IngredientDistribution {
|
||||
@@ -94,21 +82,20 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
assignIngredSlots(gui, ingredients, assignedIngredients);
|
||||
multiplier = Math.min(multiplier == 0 ? 64 : multiplier, calculateRecipeQuantity(assignedIngredients));
|
||||
|
||||
if (multiplier != 0) {
|
||||
moveIngredients(gui, assignedIngredients, (int) multiplier);
|
||||
}
|
||||
moveIngredients(gui, assignedIngredients, Math.max(1, multiplier));
|
||||
|
||||
return multiplier;
|
||||
return assignedIngredients.stream().anyMatch(distrib -> distrib.distrib.distributed == 0) ? 0 : multiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFillCraftingGrid(GuiContainer firstGui, IRecipeHandler handler, int recipeIndex) {
|
||||
return presenceOverlay(firstGui, handler, recipeIndex).stream().allMatch(state -> state.isPresent());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraft(GuiContainer firstGui, IRecipeHandler handler, int recipeIndex) {
|
||||
return canFillCraftingGrid(firstGui, handler, recipeIndex);
|
||||
return canFillCraftingGrid(firstGui, handler, recipeIndex)
|
||||
&& presenceOverlay(firstGui, handler, recipeIndex).stream().allMatch(state -> state.isPresent());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,6 +122,8 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
|
||||
}
|
||||
|
||||
clearIngredients(firstGui);
|
||||
|
||||
return craft;
|
||||
}
|
||||
|
||||
@@ -150,67 +139,104 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return dropOffMouseStack(thePlayer, gui);
|
||||
}
|
||||
|
||||
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int multiplier) {
|
||||
for (IngredientDistribution distrib : assignedIngredients) {
|
||||
if (distrib.slots.length == 0) continue;
|
||||
final EntityClientPlayerMP thePlayer = NEIClientUtils.mc().thePlayer;
|
||||
|
||||
ItemStack pstack = distrib.permutation;
|
||||
int transferCap = multiplier * pstack.stackSize;
|
||||
int transferred = 0;
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
if (slot instanceof SlotCrafting || !slot.getHasStack()
|
||||
|| !canMoveFrom(slot, gui)
|
||||
|| !slot.canTakeStack(thePlayer))
|
||||
continue;
|
||||
ItemStack stack = slot.getStack();
|
||||
int slotTransferCap = stack.getMaxStackSize();
|
||||
|
||||
int destSlotIndex = 0;
|
||||
Slot dest = distrib.slots[0];
|
||||
int slotTransferred = 0;
|
||||
int slotTransferCap = pstack.getMaxStackSize();
|
||||
for (IngredientDistribution distrib : assignedIngredients) {
|
||||
if (distrib.slots.length == 0 || !slot.getHasStack() || !canStack(distrib.permutation, stack)) continue;
|
||||
int transferCap = Math.min(slotTransferCap, multiplier * distrib.permutation.stackSize);
|
||||
int stackSize = slot.getStack().stackSize;
|
||||
boolean pickup = false;
|
||||
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
if (!slot.getHasStack() || !canMoveFrom(slot, gui)) continue;
|
||||
for (Slot dest : distrib.slots) {
|
||||
int amount = Math
|
||||
.min(transferCap - (dest.getHasStack() ? dest.getStack().stackSize : 0), stackSize);
|
||||
|
||||
ItemStack stack = slot.getStack();
|
||||
if (!canStack(pstack, stack)) continue;
|
||||
if (stackSize <= amount) {
|
||||
|
||||
int amount = Math.min(transferCap - transferred, stack.stackSize);
|
||||
FastTransferManager.clickSlot(gui, slot.slotNumber);
|
||||
for (int c = 0; c < amount; c++) {
|
||||
FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
|
||||
transferred++;
|
||||
slotTransferred++;
|
||||
if (slotTransferred >= slotTransferCap) {
|
||||
destSlotIndex++;
|
||||
if (destSlotIndex == distrib.slots.length) {
|
||||
dest = null;
|
||||
break;
|
||||
if (!pickup) {
|
||||
FastTransferManager.clickSlot(gui, slot.slotNumber);
|
||||
}
|
||||
|
||||
FastTransferManager.clickSlot(gui, dest.slotNumber);
|
||||
break;
|
||||
} else {
|
||||
|
||||
for (int c = 0; c < amount; c++) {
|
||||
|
||||
if (pickup != (pickup = true)) {
|
||||
FastTransferManager.clickSlot(gui, slot.slotNumber);
|
||||
}
|
||||
|
||||
FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
|
||||
stackSize--;
|
||||
}
|
||||
dest = distrib.slots[destSlotIndex];
|
||||
slotTransferred = 0;
|
||||
}
|
||||
|
||||
}
|
||||
FastTransferManager.clickSlot(gui, slot.slotNumber);
|
||||
if (transferred >= transferCap || dest == null) break;
|
||||
|
||||
if (thePlayer.inventory.getItemStack() != null) {
|
||||
FastTransferManager.clickSlot(gui, slot.slotNumber);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean dropOffMouseStack(EntityPlayer entityPlayer, GuiContainer gui) {
|
||||
|
||||
if (entityPlayer.inventory.getItemStack() == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < gui.inventorySlots.inventorySlots.size(); i++) {
|
||||
Slot slot = gui.inventorySlots.inventorySlots.get(i);
|
||||
|
||||
if (slot.inventory == entityPlayer.inventory) {
|
||||
ItemStack mouseItem = entityPlayer.inventory.getItemStack();
|
||||
ItemStack slotStack = slot.getStack();
|
||||
|
||||
if (slotStack == null || NEIClientUtils.areStacksSameType(mouseItem, slotStack)) {
|
||||
FastTransferManager.clickSlot(gui, i, 0, 0);
|
||||
}
|
||||
|
||||
if (entityPlayer.inventory.getItemStack() == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return entityPlayer.inventory.getItemStack() == null;
|
||||
}
|
||||
|
||||
private int calculateRecipeQuantity(List<IngredientDistribution> assignedIngredients) {
|
||||
int quantity = Integer.MAX_VALUE;
|
||||
|
||||
for (IngredientDistribution distrib : assignedIngredients) {
|
||||
DistributedIngred istack = distrib.distrib;
|
||||
final DistributedIngred istack = distrib.distrib;
|
||||
if (istack.distributed == 0) continue;
|
||||
if (istack.numSlots == 0) return 0;
|
||||
|
||||
final int maxStackSize = istack.stack.getMaxStackSize();
|
||||
int allSlots = istack.invAmount;
|
||||
if (allSlots / istack.numSlots > maxStackSize) allSlots = istack.numSlots * maxStackSize;
|
||||
|
||||
final int newQuantity = allSlots / istack.distributed;
|
||||
if (maxStackSize == 1) {
|
||||
if (maxStackSize == 1 && istack.isContainerItem) {
|
||||
// If non-stackable, fill up as much as possible of the other ingredients
|
||||
continue;
|
||||
}
|
||||
quantity = Math.min(quantity, newQuantity);
|
||||
|
||||
final int allSlots = Math.min(istack.invAmount, istack.numSlots * maxStackSize);
|
||||
quantity = Math.min(quantity, allSlots / istack.distributed);
|
||||
}
|
||||
|
||||
if (quantity == Integer.MAX_VALUE) {
|
||||
@@ -292,8 +318,10 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (biggestIngred == null) // not enough ingreds
|
||||
return null;
|
||||
if (biggestIngred == null) {
|
||||
biggestIngred = new DistributedIngred(posstack.item);
|
||||
permutation = InventoryUtils.copyStack(posstack.item, 0);
|
||||
}
|
||||
|
||||
biggestIngred.distributed += permutation.stackSize;
|
||||
assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation));
|
||||
@@ -305,9 +333,31 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
private void findInventoryQuantities(GuiContainer gui, List<DistributedIngred> ingredStacks) {
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) /* work out how much we have to go round */ {
|
||||
if (slot.getHasStack() && canMoveFrom(slot, gui)) {
|
||||
ItemStack pstack = slot.getStack();
|
||||
DistributedIngred istack = findIngred(ingredStacks, pstack);
|
||||
if (istack != null) istack.invAmount += pstack.stackSize;
|
||||
final ItemStack pstack = slot.getStack();
|
||||
final DistributedIngred istack = findIngred(ingredStacks, pstack);
|
||||
|
||||
if (istack != null) {
|
||||
istack.invAmount += pstack.stackSize;
|
||||
|
||||
if (!istack.isContainerItem && pstack.getMaxStackSize() == 1
|
||||
&& pstack.getItem().hasContainerItem(pstack)) {
|
||||
final NBTTagCompound tagCompound = pstack.getTagCompound();
|
||||
|
||||
if (tagCompound != null && tagCompound.hasKey("GT.ToolStats")) {
|
||||
istack.isContainerItem = true;
|
||||
} else {
|
||||
final boolean isPausedItemDamageSound = StackInfo.isPausedItemDamageSound();
|
||||
StackInfo.pauseItemDamageSound(true);
|
||||
|
||||
final ItemStack containerItem = pstack.getItem().getContainerItem(pstack);
|
||||
if (containerItem != null) {
|
||||
istack.isContainerItem = pstack.getItem() == containerItem.getItem();
|
||||
}
|
||||
|
||||
StackInfo.pauseItemDamageSound(isPausedItemDamageSound);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,16 +401,6 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
|
||||
protected boolean canStack(ItemStack stack1, ItemStack stack2) {
|
||||
if (stack1 == null || stack2 == null) return true;
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(stack2, stack1)) {
|
||||
if (NBTHelper.matchTag(stack1.getTagCompound(), stack2.getTagCompound())) return true;
|
||||
|
||||
// GT Items don't have any NBT set for the recipe, so if either of the stacks has a NULL nbt, and the other
|
||||
// doesn't, pretend they stack
|
||||
if (((gtItem != null && gtItem.isInstance(stack1.getItem()))
|
||||
|| (stack1.getMaxStackSize() == 1 && stack2.getMaxStackSize() == 1))
|
||||
&& (stack1.stackTagCompound == null ^ stack2.stackTagCompound == null))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack1, stack2);
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public class GuiOverlayButton extends GuiRecipeButton {
|
||||
DrawableResource icon = ICON_OVERLAY;
|
||||
|
||||
if (this.hasOverlay && (!this.requireShiftForOverlayRecipe || NEIClientUtils.shiftKey())) {
|
||||
icon = canFillCraftingGrid() ? ICON_FILL : ICON_FILL_ERROR;
|
||||
icon = this.missedMaterialsTooltipLineHandler == null ? ICON_FILL : ICON_FILL_ERROR;
|
||||
}
|
||||
|
||||
final int iconX = this.xPosition + (this.width - icon.width - 1) / 2;
|
||||
|
||||
@@ -462,8 +462,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
if (!cacheKey.equals(this.recipePageCacheKey)) {
|
||||
this.recipePageCacheKey = cacheKey;
|
||||
|
||||
for (int refIndex = 0; refIndex < indices.size(); refIndex++) {
|
||||
final int recipeIndex = indices.get(refIndex);
|
||||
for (final int recipeIndex : indices) {
|
||||
for (PositionedStack pStack : handler.original.getIngredientStacks(recipeIndex)) {
|
||||
pStack.setPermutationToRender(pStack.getFilteredPermutations().get(0));
|
||||
}
|
||||
@@ -472,7 +471,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
final int xOffset = (limitToOneRecipe ? 0 : guiLeft) + xSize - BORDER_PADDING;
|
||||
final int yOffset = (limitToOneRecipe ? -BUTTON_HEIGHT : guiTop - 18) + getRefIndexPosition(0).y;
|
||||
final int height = handlerInfo.getHeight() - yShift;
|
||||
final boolean showFavorites = NEIClientConfig.favoritesEnabled();
|
||||
final boolean showFavorites = NEIClientConfig.favoritesEnabled() && handlerInfo.getShowFavoritesButton();
|
||||
final boolean showOverlay = handlerInfo.getShowOverlayButton();
|
||||
final UpdateRecipeButtonsEvent.Pre preEvent = new UpdateRecipeButtonsEvent.Pre(
|
||||
this,
|
||||
xOffset,
|
||||
@@ -484,7 +484,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
if (MinecraftForge.EVENT_BUS.post(preEvent)) {
|
||||
buttons = preEvent.buttonList;
|
||||
} else {
|
||||
|
||||
for (int refIndex = 0; refIndex < indices.size(); refIndex++) {
|
||||
final int recipeIndex = indices.get(refIndex);
|
||||
|
||||
@@ -493,20 +492,19 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
continue;
|
||||
}
|
||||
|
||||
GuiRecipeButton button = new GuiOverlayButton(
|
||||
firstGui,
|
||||
RecipeHandlerRef.of(handler.original, recipeIndex),
|
||||
xOffset - GuiRecipeButton.BUTTON_WIDTH,
|
||||
yOffset + height * (refIndex + 1));
|
||||
|
||||
buttons.add(button);
|
||||
|
||||
if (showFavorites) {
|
||||
int x = xOffset - GuiRecipeButton.BUTTON_WIDTH;
|
||||
int y = yOffset + height * (refIndex + 1);
|
||||
if (showOverlay) {
|
||||
buttons.add(
|
||||
new GuiFavoriteButton(
|
||||
new GuiOverlayButton(
|
||||
firstGui,
|
||||
RecipeHandlerRef.of(handler.original, recipeIndex),
|
||||
button.xPosition,
|
||||
button.yPosition - button.height - 1));
|
||||
x,
|
||||
y));
|
||||
y -= GuiRecipeButton.BUTTON_HEIGHT + 1;
|
||||
}
|
||||
if (showFavorites) {
|
||||
buttons.add(new GuiFavoriteButton(RecipeHandlerRef.of(handler.original, recipeIndex), x, y));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -522,6 +520,10 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
buttons.removeIf(GuiFavoriteButton.class::isInstance);
|
||||
}
|
||||
|
||||
if (!showOverlay) {
|
||||
buttons.removeIf(GuiOverlayButton.class::isInstance);
|
||||
}
|
||||
|
||||
/** compatibility with old format */
|
||||
this.overlayButtons = buttons.stream().filter(GuiOverlayButton.class::isInstance)
|
||||
.toArray(GuiOverlayButton[]::new);
|
||||
|
||||
@@ -28,6 +28,8 @@ public class HandlerInfo {
|
||||
private int height = DEFAULT_HEIGHT;
|
||||
private int width = DEFAULT_WIDTH;
|
||||
private int maxRecipesPerPage = DEFAULT_MAX_PER_PAGE;
|
||||
private boolean showFavoritesButton = true;
|
||||
private boolean showOverlayButton = true;
|
||||
|
||||
private ItemStack itemStack = null;
|
||||
private DrawableResource image = null;
|
||||
@@ -112,6 +114,22 @@ public class HandlerInfo {
|
||||
this.yShift = yShift;
|
||||
}
|
||||
|
||||
public boolean getShowFavoritesButton() {
|
||||
return this.showFavoritesButton;
|
||||
}
|
||||
|
||||
public void setShowFavoritesButton(boolean showFavoritesButton) {
|
||||
this.showFavoritesButton = showFavoritesButton;
|
||||
}
|
||||
|
||||
public boolean getShowOverlayButton() {
|
||||
return this.showOverlayButton;
|
||||
}
|
||||
|
||||
public void setShowOverlayButton(boolean showOverlayButton) {
|
||||
this.showOverlayButton = showOverlayButton;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private final HandlerInfo info;
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import codechicken.nei.ClientHandler;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.util.ItemStackFilterParser;
|
||||
|
||||
public class InformationHandler extends TemplateRecipeHandler {
|
||||
|
||||
private static final List<InformationPage> ITEM_INFO = new ArrayList<>();
|
||||
|
||||
public static void addInformationPage(String filter, String description) {
|
||||
if (filter.isEmpty() || description.isEmpty()) return;
|
||||
ITEM_INFO.add(new InformationPage(filter, description));
|
||||
}
|
||||
|
||||
public static void populateStacks(ItemStack stack) {
|
||||
for (InformationPage page : ITEM_INFO) {
|
||||
page.addItem(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
CachedInfoPage page = (CachedInfoPage) this.arecipes.get(recipe);
|
||||
drawWrappedText(StatCollector.translateToLocal(page.getPage().info).replace("\\n", "\n"), 4, 24);
|
||||
}
|
||||
|
||||
private void drawWrappedText(String text, int x, int y) {
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
List<String> lines = font.listFormattedStringToWidth(text, 156);
|
||||
for (String line : lines) {
|
||||
font.drawString(line, x, y, 0);
|
||||
y += 10;
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearCache() {
|
||||
for (InformationPage page : ITEM_INFO) {
|
||||
page.items.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return NEIClientUtils.translate("recipe.information");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "information";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (InformationPage page : ITEM_INFO) {
|
||||
if (page.filter.matches(result)) {
|
||||
arecipes.add(new CachedInfoPage(page));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
loadCraftingRecipes(ingredient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "nei:textures/gui/recipebg.png";
|
||||
}
|
||||
|
||||
private class CachedInfoPage extends CachedRecipe {
|
||||
|
||||
private final InformationPage page;
|
||||
private final PositionedStack stack;
|
||||
|
||||
public CachedInfoPage(InformationPage page) {
|
||||
this.page = page;
|
||||
stack = new PositionedStack(page.items, 75, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return getCycledIngredients(cycleticks / 20, Collections.singletonList(this.stack));
|
||||
}
|
||||
|
||||
public InformationPage getPage() {
|
||||
return page;
|
||||
}
|
||||
}
|
||||
|
||||
private static class InformationPage {
|
||||
|
||||
final List<ItemStack> items = new ArrayList<>();
|
||||
final String info;
|
||||
final ItemFilter filter;
|
||||
|
||||
public InformationPage(String filter, String info) {
|
||||
this.filter = ItemStackFilterParser.parse(filter.trim());
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the item stack if it matches the filter.
|
||||
*/
|
||||
public void addItem(ItemStack stack) {
|
||||
if (filter.matches(stack)) items.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
ClientHandler.loadSettingsFile(
|
||||
"informationpages.cfg",
|
||||
lines -> parseFile(lines.collect(Collectors.toCollection(ArrayList::new))));
|
||||
}
|
||||
|
||||
private static void parseFile(List<String> lines) {
|
||||
for (String rawLine : lines) {
|
||||
String line = rawLine.trim();
|
||||
|
||||
int sepIndex = line.indexOf('=');
|
||||
if (sepIndex == -1) {
|
||||
NEIClientConfig.logger.warn("[NEI Info] Invalid line (no '=') in config: {}", line);
|
||||
continue;
|
||||
}
|
||||
|
||||
String filter = line.substring(0, sepIndex).trim();
|
||||
String description = line.substring(sepIndex + 1).trim();
|
||||
addInformationPage(filter, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,12 @@ package codechicken.nei.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
@@ -36,10 +39,15 @@ public class Recipe {
|
||||
this.result = result != null ? StackInfo.withAmount(result, 0) : null;
|
||||
this.handlerName = handlerName;
|
||||
this.ingredients = ingredients;
|
||||
|
||||
if (!isShapedRecipe()) {
|
||||
// sort to ignore ingredients position in shapeless recipes
|
||||
this.ingredients.sort(Comparator.comparing(StackInfo::getItemStackGUID));
|
||||
}
|
||||
}
|
||||
|
||||
public static RecipeId of(Object result, String handlerName, Iterable<?> ingredients) {
|
||||
return new RecipeId(extractItem(result), handlerName, extractItems(ingredients));
|
||||
return new RecipeId(extractItem(result), handlerName, extractIngredients(ingredients));
|
||||
}
|
||||
|
||||
public static RecipeId of(JsonObject json) {
|
||||
@@ -74,14 +82,14 @@ public class Recipe {
|
||||
return new ArrayList<>(this.ingredients);
|
||||
}
|
||||
|
||||
protected static List<ItemStack> extractItems(Iterable<?> items) {
|
||||
protected static List<ItemStack> extractIngredients(Iterable<?> items) {
|
||||
final List<ItemStack> list = new ArrayList<>();
|
||||
|
||||
for (Object item : items) {
|
||||
ItemStack stack = extractItem(item);
|
||||
final ItemStack stack = extractItem(item);
|
||||
|
||||
if (stack != null) {
|
||||
list.add(stack.copy());
|
||||
list.add(prepareIngredient(stack.copy()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,15 +123,56 @@ public class Recipe {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int index = 0; index < stacks.size(); index++) {
|
||||
if (!stacks.get(index).containsWithNBT(ingredients.get(index))) {
|
||||
return false;
|
||||
if (isShapedRecipe()) {
|
||||
for (int index = 0; index < stacks.size(); index++) {
|
||||
if (!containsWithNBT(stacks.get(index), Collections.singletonList(this.ingredients.get(index)))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (PositionedStack pStack : stacks) {
|
||||
if (!containsWithNBT(pStack, this.ingredients)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean containsWithNBT(PositionedStack pStack, List<ItemStack> ingrStacks) {
|
||||
for (ItemStack item : pStack.items) {
|
||||
final ItemStack pItem = prepareIngredient(item);
|
||||
if (ingrStacks.stream().anyMatch(stack -> StackInfo.equalItemAndNBT(pItem, stack, true))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ItemStack prepareIngredient(ItemStack stack) {
|
||||
|
||||
// hack: remove metadata for "Data Stick"
|
||||
if (stack.hasTagCompound() && stack.getItemDamage() == 32708
|
||||
&& "gregtech:gt.metaitem.01".equals(Item.itemRegistry.getNameForObject(stack.getItem()))) {
|
||||
return new ItemStack(stack.getItem(), stack.getItemDamage());
|
||||
}
|
||||
|
||||
// hack: remove metadata for "Circuit Imprint"
|
||||
if (stack.hasTagCompound() && stack.getItemDamage() == 0
|
||||
&& "bartworks:gt.bwMetaGeneratedItem0"
|
||||
.equals(Item.itemRegistry.getNameForObject(stack.getItem()))) {
|
||||
return new ItemStack(stack.getItem(), stack.getItemDamage());
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public boolean isShapedRecipe() {
|
||||
return this.handlerName.equals("codechicken.nei.recipe.ShapedRecipeHandler")
|
||||
|| this.handlerName.equals("fox.spiteful.avaritia.compat.nei.ExtremeShapedRecipeHandler");
|
||||
}
|
||||
|
||||
public JsonObject toJsonObject() {
|
||||
final JsonObject json = new JsonObject();
|
||||
|
||||
@@ -142,8 +191,8 @@ public class Recipe {
|
||||
protected JsonArray convertItemsToJsonArray(List<ItemStack> items) {
|
||||
final JsonArray arr = new JsonArray();
|
||||
|
||||
for (ItemStack nbTag : items) {
|
||||
arr.add(NBTJson.toJsonObject(StackInfo.itemStackToNBT(nbTag)));
|
||||
for (ItemStack stack : items) {
|
||||
arr.add(NBTJson.toJsonObject(StackInfo.itemStackToNBT(stack)));
|
||||
}
|
||||
|
||||
return arr;
|
||||
|
||||
@@ -17,7 +17,7 @@ import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.util.AsyncTaskProfiler;
|
||||
|
||||
class RecipeHandlerQuery<T extends IRecipeHandler> {
|
||||
public class RecipeHandlerQuery<T extends IRecipeHandler> {
|
||||
|
||||
private final Function<T, T> recipeHandlerFunction;
|
||||
private final List<T> recipeHandlers;
|
||||
@@ -25,15 +25,15 @@ class RecipeHandlerQuery<T extends IRecipeHandler> {
|
||||
private final String[] errorMessage;
|
||||
private boolean error = false;
|
||||
|
||||
RecipeHandlerQuery(Function<T, T> recipeHandlerFunction, List<T> recipeHandlers, List<T> serialRecipeHandlers,
|
||||
String... errorMessage) {
|
||||
public RecipeHandlerQuery(Function<T, T> recipeHandlerFunction, List<T> recipeHandlers,
|
||||
List<T> serialRecipeHandlers, String... errorMessage) {
|
||||
this.recipeHandlerFunction = recipeHandlerFunction;
|
||||
this.recipeHandlers = recipeHandlers;
|
||||
this.serialRecipeHandlers = serialRecipeHandlers;
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
ArrayList<T> runWithProfiling(String profilerSection) {
|
||||
public ArrayList<T> runWithProfiling(String profilerSection) {
|
||||
TaskProfiler profiler = ProfilerRecipeHandler.getProfiler();
|
||||
|
||||
// Save the current config state here, as it may be altered
|
||||
|
||||
@@ -14,6 +14,7 @@ import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
|
||||
public class RecipeHandlerRef {
|
||||
|
||||
private static final LRUCache<Class<?>, Boolean> transferAlghoritmCache = new LRUCache<>(200);
|
||||
private static final LRUCache<RecipeId, RecipeHandlerRef> recipeRefCache = new LRUCache<>(200);
|
||||
public final IRecipeHandler handler;
|
||||
public final int recipeIndex;
|
||||
@@ -139,20 +140,36 @@ public class RecipeHandlerRef {
|
||||
public boolean allowedTransferAlghoritm(GuiContainer gui) {
|
||||
final IOverlayHandler overlayHandler = getOverlayHandler(gui);
|
||||
|
||||
if (overlayHandler != null) {
|
||||
try {
|
||||
return !overlayHandler.getClass()
|
||||
.getDeclaredMethod(
|
||||
"transferRecipe",
|
||||
GuiContainer.class,
|
||||
IRecipeHandler.class,
|
||||
int.class,
|
||||
int.class)
|
||||
.isDefault();
|
||||
} catch (NoSuchMethodException e) {}
|
||||
if (overlayHandler == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return transferAlghoritmCache.computeIfAbsent(overlayHandler.getClass(), clazz -> {
|
||||
|
||||
try {
|
||||
|
||||
if (overlayHandler instanceof DefaultOverlayHandler) {
|
||||
final Class<?> overlayRecipeClazz = overlayHandler.getClass()
|
||||
.getMethod(
|
||||
"overlayRecipe",
|
||||
GuiContainer.class,
|
||||
IRecipeHandler.class,
|
||||
int.class,
|
||||
boolean.class)
|
||||
.getDeclaringClass();
|
||||
|
||||
if (overlayRecipeClazz.equals(DefaultOverlayHandler.class)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return !overlayHandler.getClass()
|
||||
.getMethod("transferRecipe", GuiContainer.class, IRecipeHandler.class, int.class, int.class)
|
||||
.isDefault();
|
||||
} catch (NoSuchMethodException e) {}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public IRecipeOverlayRenderer getRecipeOverlayRenderer(GuiContainer gui) {
|
||||
|
||||
@@ -101,6 +101,8 @@ public class RecipeInfo {
|
||||
API.registerUsageHandler(new BrewingRecipeHandler());
|
||||
API.registerRecipeHandler(new FuelRecipeHandler());
|
||||
API.registerUsageHandler(new FuelRecipeHandler());
|
||||
API.registerRecipeHandler(new InformationHandler());
|
||||
API.registerUsageHandler(new InformationHandler());
|
||||
|
||||
API.registerGuiOverlay(GuiCrafting.class, "crafting");
|
||||
API.registerGuiOverlay(GuiInventory.class, "crafting2x2", 63, 20);
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -22,6 +23,7 @@ import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.recipe.stackinfo.DefaultStackStringifyHandler;
|
||||
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
|
||||
import codechicken.nei.util.ItemStackKey;
|
||||
import codechicken.nei.util.NBTHelper;
|
||||
|
||||
public class StackInfo {
|
||||
|
||||
@@ -30,6 +32,7 @@ public class StackInfo {
|
||||
private static final Map<String, HashMap<String, String[]>> guidfilters = new HashMap<>();
|
||||
private static final ItemStackMap<String> guidcache = new ItemStackMap<>();
|
||||
private static final LRUCache<ItemStackKey, FluidStack> fluidcache = new LRUCache<>(200);
|
||||
private static boolean isPausedItemDamageSound = false;
|
||||
|
||||
static {
|
||||
stackStringifyHandlers.add(new DefaultStackStringifyHandler());
|
||||
@@ -73,6 +76,18 @@ public class StackInfo {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static void pauseItemDamageSound(boolean pause) {
|
||||
if (isPausedItemDamageSound != (isPausedItemDamageSound = pause)) {
|
||||
for (IStackStringifyHandler handler : stackStringifyHandlers) {
|
||||
handler.pauseItemDamageSound(pause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPausedItemDamageSound() {
|
||||
return isPausedItemDamageSound;
|
||||
}
|
||||
|
||||
public static ItemStack withAmount(ItemStack stack, long customCount) {
|
||||
if (stack == null) return null;
|
||||
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(stack);
|
||||
@@ -131,7 +146,7 @@ public class StackInfo {
|
||||
final NBTTagCompound nbTag = itemStackToNBT(stack, false);
|
||||
|
||||
if (nbTag == null) {
|
||||
return null;
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
nbTag.removeTag("Count");
|
||||
@@ -144,9 +159,11 @@ public class StackInfo {
|
||||
nbTag.removeTag("tag");
|
||||
}
|
||||
|
||||
if (nbTag.hasKey("strId") && guidfilters.containsKey(nbTag.getString("strId"))) {
|
||||
if (nbTag.hasKey("strId") && (guidfilters.containsKey(nbTag.getString("strId"))
|
||||
|| guidfilters.containsKey(nbTag.getString("strId") + "&" + nbTag.getShort("Damage")))) {
|
||||
final String strId = nbTag.getString("strId")
|
||||
+ (guidfilters.containsKey(nbTag.getString("strId")) ? "" : "&" + nbTag.getShort("Damage"));
|
||||
final ArrayList<String> keys = new ArrayList<>();
|
||||
final String strId = nbTag.getString("strId");
|
||||
|
||||
keys.add(strId);
|
||||
|
||||
@@ -171,7 +188,7 @@ public class StackInfo {
|
||||
}
|
||||
|
||||
if (local instanceof NBTBase item) {
|
||||
keys.add(item.toString());
|
||||
keys.add(NBTHelper.toString(item));
|
||||
} else if (local != null) {
|
||||
keys.add(String.valueOf(local));
|
||||
}
|
||||
@@ -182,7 +199,7 @@ public class StackInfo {
|
||||
}
|
||||
} else {
|
||||
synchronized (guidcache) {
|
||||
guidcache.put(stack, nbTag.toString());
|
||||
guidcache.put(stack, NBTHelper.toString(nbTag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,13 +222,17 @@ public class StackInfo {
|
||||
}
|
||||
|
||||
public static ItemStack getItemStackWithMinimumDamage(ItemStack[] stacks) {
|
||||
int damage = Short.MAX_VALUE;
|
||||
ItemStack result = stacks[0];
|
||||
|
||||
if (stacks.length > 1) {
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack.getItem() != null && !ItemInfo.isHidden(stack) && stack.getItemDamage() < damage) {
|
||||
damage = stack.getItemDamage();
|
||||
// to optimize compare recipes from permutation, an item with a minimum strId and damage is taken so as
|
||||
// not to check everything permutation items
|
||||
if (stack.getItem() != null && !ItemInfo.isHidden(stack)
|
||||
&& (stack.getItemDamage() < result.getItemDamage()
|
||||
|| stack.getItemDamage() == result.getItemDamage()
|
||||
&& Item.itemRegistry.getNameForObject(stack.getItem())
|
||||
.compareTo(Item.itemRegistry.getNameForObject(result.getItem())) < 0)) {
|
||||
result = stack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,13 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import codechicken.nei.ItemStackAmount;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.bookmark.BookmarkItem;
|
||||
import codechicken.nei.recipe.Recipe;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
@@ -19,6 +23,23 @@ import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
public class RecipeChainMath {
|
||||
|
||||
private static class ContainerItemResult {
|
||||
|
||||
public ItemStack stack;
|
||||
public ItemStack containerItem;
|
||||
public long leftSteps;
|
||||
|
||||
public ContainerItemResult(ItemStack stack, long leftSteps, ItemStack containerItem) {
|
||||
this.stack = stack;
|
||||
this.leftSteps = leftSteps;
|
||||
this.containerItem = containerItem;
|
||||
}
|
||||
}
|
||||
|
||||
private static final ItemStack ROOT_ITEM = new ItemStack(Blocks.fire);
|
||||
private static final RecipeId ROOT_RECIPE_ID = RecipeId
|
||||
.of(ROOT_ITEM, "recipe-autocrafting", Collections.emptyList());
|
||||
|
||||
public final Map<RecipeId, Long> outputRecipes = new HashMap<>();
|
||||
|
||||
public final List<BookmarkItem> initialItems = new ArrayList<>();
|
||||
@@ -27,6 +48,8 @@ public class RecipeChainMath {
|
||||
|
||||
public final Map<BookmarkItem, BookmarkItem> preferredItems = new HashMap<>();
|
||||
public final Map<BookmarkItem, Long> requiredAmount = new HashMap<>();
|
||||
public final List<ItemStack> containerItems = new ArrayList<>();
|
||||
private final List<ItemStack> containerItemsBlacklist = new ArrayList<>();
|
||||
|
||||
private RecipeChainMath(List<BookmarkItem> recipeItems, Set<RecipeId> collapsedRecipes) {
|
||||
final Map<RecipeId, Integer> recipeState = new HashMap<>();
|
||||
@@ -55,6 +78,7 @@ public class RecipeChainMath {
|
||||
for (Map.Entry<RecipeId, Long> entry : multipliers.entrySet()) {
|
||||
if (entry.getValue() > 1 || collapsedRecipes.contains(entry.getKey())) {
|
||||
collectPreferredItems(entry.getKey(), this.preferredItems, new HashSet<>());
|
||||
removeLoop(entry.getKey(), this.preferredItems, new HashSet<>());
|
||||
this.outputRecipes.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
@@ -70,7 +94,9 @@ public class RecipeChainMath {
|
||||
if (!this.outputRecipes.containsKey(recipeId) && this.preferredItems.values().stream()
|
||||
.noneMatch(resItem -> resItem.recipeId.equals(recipeId))) {
|
||||
final Map<BookmarkItem, BookmarkItem> references = new HashMap<>(this.preferredItems);
|
||||
final int depth = collectPreferredItems(recipeId, references, new HashSet<>());
|
||||
collectPreferredItems(recipeId, references, new HashSet<>());
|
||||
removeLoop(recipeId, references, new HashSet<>());
|
||||
final int depth = getMaxDepth(recipeId, references);
|
||||
|
||||
if (maxDepth < depth || maxDepth == depth && entry.getValue() > maxMultiplier) {
|
||||
maxMultiplier = entry.getValue();
|
||||
@@ -104,34 +130,103 @@ public class RecipeChainMath {
|
||||
}
|
||||
}
|
||||
|
||||
private int collectPreferredItems(RecipeId recipeId, Map<BookmarkItem, BookmarkItem> preferredItems,
|
||||
private void collectPreferredItems(RecipeId recipeId, Map<BookmarkItem, BookmarkItem> preferredItems,
|
||||
Set<RecipeId> visited) {
|
||||
int maxDepth = 0;
|
||||
|
||||
visited.add(recipeId);
|
||||
|
||||
for (BookmarkItem ingrItem : this.recipeIngredients) {
|
||||
if (ingrItem.factor > 0 && recipeId.equals(ingrItem.recipeId) && !preferredItems.containsKey(ingrItem)) {
|
||||
BookmarkItem activeItem = null;
|
||||
BookmarkItem prefItem = null;
|
||||
|
||||
for (BookmarkItem item : this.recipeResults) {
|
||||
if (item.factor > (prefItem == null ? 0 : prefItem.factor) && item.containsItems(ingrItem)
|
||||
&& !visited.contains(item.recipeId)) {
|
||||
prefItem = item;
|
||||
if (item.factor > 0 && !visited.contains(item.recipeId) && item.containsItems(ingrItem)) {
|
||||
|
||||
if ((activeItem == null || item.factor > activeItem.factor) && NEIClientUtils
|
||||
.areStacksSameTypeCraftingWithNBT(ingrItem.itemStack, item.itemStack)) {
|
||||
activeItem = item;
|
||||
} else if (prefItem == null || item.factor > prefItem.factor) {
|
||||
prefItem = item;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (activeItem != null) {
|
||||
prefItem = activeItem;
|
||||
}
|
||||
|
||||
if (prefItem != null) {
|
||||
preferredItems.put(ingrItem, prefItem);
|
||||
maxDepth = Math
|
||||
.max(maxDepth, collectPreferredItems(prefItem.recipeId, preferredItems, visited) + 1);
|
||||
collectPreferredItems(prefItem.recipeId, preferredItems, visited);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visited.remove(recipeId);
|
||||
}
|
||||
|
||||
private int getMaxDepth(RecipeId recipeId, Map<BookmarkItem, BookmarkItem> preferredItems) {
|
||||
int maxDepth = 0;
|
||||
|
||||
for (BookmarkItem ingrItem : preferredItems.keySet()) {
|
||||
if (ingrItem.factor > 0 && recipeId.equals(ingrItem.recipeId)) {
|
||||
maxDepth = Math.max(maxDepth, getMaxDepth(preferredItems.get(ingrItem).recipeId, preferredItems) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return maxDepth;
|
||||
}
|
||||
|
||||
private void removeLoop(RecipeId recipeId, Map<BookmarkItem, BookmarkItem> preferredItems, Set<RecipeId> visited) {
|
||||
visited.add(recipeId);
|
||||
|
||||
for (BookmarkItem ingrItem : this.recipeIngredients) {
|
||||
if (ingrItem.factor > 0 && recipeId.equals(ingrItem.recipeId) && preferredItems.containsKey(ingrItem)) {
|
||||
BookmarkItem prefItem = preferredItems.get(ingrItem);
|
||||
|
||||
if (visited.contains(prefItem.recipeId)) {
|
||||
preferredItems.remove(ingrItem);
|
||||
} else {
|
||||
removeLoop(prefItem.recipeId, preferredItems, visited);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visited.remove(recipeId);
|
||||
}
|
||||
|
||||
public RecipeId createMasterRoot() {
|
||||
final List<BookmarkItem> rootIngredients = new ArrayList<>();
|
||||
|
||||
for (BookmarkItem item : this.recipeResults) {
|
||||
if (this.outputRecipes.containsKey(item.recipeId) && !ROOT_RECIPE_ID.equals(item.recipeId)) {
|
||||
final long amount = item.factor * this.outputRecipes.get(item.recipeId);
|
||||
rootIngredients.add(
|
||||
BookmarkItem.of(
|
||||
-1,
|
||||
item.getItemStack(amount),
|
||||
item.getStackSize(amount),
|
||||
ROOT_RECIPE_ID,
|
||||
true,
|
||||
BookmarkItem.generatePermutations(item.itemStack, null)));
|
||||
}
|
||||
}
|
||||
|
||||
this.outputRecipes.clear();
|
||||
this.outputRecipes.put(ROOT_RECIPE_ID, 1L);
|
||||
this.recipeResults.removeIf(item -> ROOT_RECIPE_ID.equals(item.recipeId));
|
||||
this.recipeResults.add(BookmarkItem.of(-1, ROOT_ITEM, 1, ROOT_RECIPE_ID, false));
|
||||
this.recipeIngredients.addAll(rootIngredients);
|
||||
|
||||
return ROOT_RECIPE_ID;
|
||||
}
|
||||
|
||||
public boolean hasMasterRoot() {
|
||||
return this.outputRecipes.containsKey(ROOT_RECIPE_ID);
|
||||
}
|
||||
|
||||
public static RecipeChainMath of(List<BookmarkItem> chainItems, Set<RecipeId> collapsedRecipes) {
|
||||
return new RecipeChainMath(chainItems, collapsedRecipes);
|
||||
}
|
||||
@@ -200,22 +295,40 @@ public class RecipeChainMath {
|
||||
|
||||
this.preferredItems.clear();
|
||||
this.requiredAmount.clear();
|
||||
this.containerItems.clear();
|
||||
this.containerItemsBlacklist.clear();
|
||||
|
||||
for (RecipeId recipeId : this.outputRecipes.keySet()) {
|
||||
collectPreferredItems(recipeId, this.preferredItems, new HashSet<>());
|
||||
removeLoop(recipeId, this.preferredItems, new HashSet<>());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public RecipeChainMath refresh() {
|
||||
final boolean isPausedItemDamageSound = StackInfo.isPausedItemDamageSound();
|
||||
StackInfo.pauseItemDamageSound(true);
|
||||
|
||||
resetCalculation();
|
||||
|
||||
if (this.outputRecipes.containsKey(ROOT_RECIPE_ID)) {
|
||||
for (BookmarkItem ingrItem : this.recipeIngredients) {
|
||||
if (ROOT_RECIPE_ID.equals(ingrItem.recipeId)
|
||||
&& ingrItem.itemStack.getItem().hasContainerItem(ingrItem.itemStack)) {
|
||||
this.containerItemsBlacklist.add(ingrItem.itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (BookmarkItem prefItem : this.recipeResults) {
|
||||
if (prefItem.factor > 0 && this.outputRecipes.containsKey(prefItem.recipeId)) {
|
||||
final long prefAmount = prefItem.factor * this.outputRecipes.get(prefItem.recipeId);
|
||||
|
||||
if (prefItem.itemStack.getItem().hasContainerItem(prefItem.itemStack)) {
|
||||
this.containerItemsBlacklist.add(prefItem.itemStack);
|
||||
}
|
||||
|
||||
this.preferredItems.put(prefItem, prefItem);
|
||||
calculateSuitableRecipe(prefItem, prepareAmount(prefItem, prefAmount), new ArrayList<>());
|
||||
calculateSuitableRecipe(prefItem, prefAmount, new ArrayList<>());
|
||||
this.preferredItems.remove(prefItem);
|
||||
}
|
||||
}
|
||||
@@ -228,13 +341,14 @@ public class RecipeChainMath {
|
||||
}
|
||||
}
|
||||
|
||||
StackInfo.pauseItemDamageSound(isPausedItemDamageSound);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void prepareIngredients(RecipeId recipeId, long stepShift, List<RecipeId> visited) {
|
||||
for (BookmarkItem item : this.recipeIngredients) {
|
||||
if (item.factor > 0 && recipeId.equals(item.recipeId)) {
|
||||
calculateSuitableRecipe(item, prepareAmount(item, item.factor * stepShift), visited);
|
||||
calculateSuitableRecipe(item, item.factor * stepShift, visited);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,18 +356,41 @@ public class RecipeChainMath {
|
||||
private void calculateSuitableRecipe(BookmarkItem ingrItem, long ingrAmount, List<RecipeId> visited) {
|
||||
final BookmarkItem prefItem = this.preferredItems.get(ingrItem);
|
||||
|
||||
// calculate existing containers
|
||||
if (ingrAmount > 0) {
|
||||
for (ItemStack stack : ingrItem.permutations.values()) {
|
||||
if (hasContainerItem(stack)) {
|
||||
final long stackSize = ingrItem.getStackSize(ingrAmount);
|
||||
final long shiftSize = shiftContainerItems(stack, stackSize);
|
||||
if (stackSize != shiftSize && (ingrAmount = shiftSize * ingrItem.fluidCellAmount) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// calculate existing initial items
|
||||
if (ingrAmount > 0) {
|
||||
for (BookmarkItem item : this.initialItems) {
|
||||
if (item.containsItems(ingrItem)
|
||||
&& (ingrAmount = addRequiredAmount(item, ingrAmount, item.amount)) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// shift amount
|
||||
if (prefItem == null) {
|
||||
this.requiredAmount.put(ingrItem, this.requiredAmount.getOrDefault(ingrItem, 0L) + ingrAmount);
|
||||
addRequiredAmount(ingrItem, ingrAmount, Long.MAX_VALUE);
|
||||
} else if (visited.contains(prefItem.recipeId)) {
|
||||
this.requiredAmount.put(prefItem, this.requiredAmount.getOrDefault(prefItem, 0L) + ingrAmount);
|
||||
addRequiredAmount(prefItem, ingrAmount, Long.MAX_VALUE);
|
||||
} else {
|
||||
this.requiredAmount.put(prefItem, this.requiredAmount.getOrDefault(prefItem, 0L) + ingrAmount);
|
||||
addRequiredAmount(prefItem, ingrAmount, Long.MAX_VALUE);
|
||||
final long shift = (long) Math
|
||||
.ceil((this.requiredAmount.get(prefItem) - prefItem.amount) / (double) prefItem.factor);
|
||||
|
||||
if (shift > 0) {
|
||||
addShift(prefItem.recipeId, shift);
|
||||
|
||||
visited.add(prefItem.recipeId);
|
||||
prepareIngredients(prefItem.recipeId, shift, visited);
|
||||
visited.remove(prefItem.recipeId);
|
||||
@@ -262,21 +399,128 @@ public class RecipeChainMath {
|
||||
|
||||
}
|
||||
|
||||
private long prepareAmount(BookmarkItem ingrItem, long ingrAmount) {
|
||||
if (ingrAmount == 0) return 0;
|
||||
private long addRequiredAmount(BookmarkItem prefItem, long ingrAmount, long maxAmount) {
|
||||
long shiftAmount = this.requiredAmount.getOrDefault(prefItem, 0L);
|
||||
|
||||
for (BookmarkItem item : this.initialItems) {
|
||||
if (item.containsItems(ingrItem)) {
|
||||
long initAmount = Math.min(ingrAmount, item.amount - this.requiredAmount.getOrDefault(item, 0L));
|
||||
if (initAmount > 0) {
|
||||
this.requiredAmount.put(item, this.requiredAmount.getOrDefault(item, 0L) + initAmount);
|
||||
ingrAmount -= initAmount;
|
||||
if (ingrAmount == 0) break;
|
||||
if (hasContainerItem(prefItem.itemStack)) {
|
||||
ItemStack itemStack = prefItem.itemStack;
|
||||
|
||||
while (ingrAmount > 0 && shiftAmount < maxAmount) {
|
||||
itemStack = itemStack.copy();
|
||||
itemStack.stackSize = 1;
|
||||
|
||||
this.containerItems.add(itemStack);
|
||||
ingrAmount = shiftContainerItems(itemStack, prefItem.getStackSize(ingrAmount))
|
||||
* prefItem.fluidCellAmount;
|
||||
|
||||
shiftAmount += prefItem.fluidCellAmount;
|
||||
}
|
||||
|
||||
} else {
|
||||
long initAmount = Math.min(ingrAmount, maxAmount - shiftAmount);
|
||||
|
||||
shiftAmount += initAmount;
|
||||
ingrAmount -= initAmount;
|
||||
}
|
||||
|
||||
this.requiredAmount.put(prefItem, shiftAmount);
|
||||
|
||||
return ingrAmount;
|
||||
}
|
||||
|
||||
private long shiftContainerItems(ItemStack aStack, long steps) {
|
||||
|
||||
for (int i = 0; i < this.containerItems.size() && steps > 0; i++) {
|
||||
ItemStack bStack = this.containerItems.get(i);
|
||||
|
||||
if (bStack != null && NEIClientUtils.areStacksSameTypeCraftingWithNBT(aStack, bStack)) {
|
||||
final ContainerItemResult result = getToolsContainerItems(bStack, steps);
|
||||
|
||||
bStack = result.stack;
|
||||
steps = result.leftSteps;
|
||||
|
||||
if (result.containerItem != null) {
|
||||
this.containerItems.add(result.containerItem);
|
||||
}
|
||||
|
||||
this.containerItems.set(i, bStack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.containerItems.removeIf(stack -> stack == null);
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
private ContainerItemResult getToolsContainerItems(ItemStack aStack, long steps) {
|
||||
final NBTTagCompound tagCompound = aStack.getTagCompound();
|
||||
|
||||
if (tagCompound != null && tagCompound.hasKey("GT.ToolStats")) {
|
||||
final int damagePerContainerCraft = getGTToolDamagePerContainerCraft(aStack);
|
||||
|
||||
if (damagePerContainerCraft > 0) {
|
||||
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 availableSteps = Math.min(steps, Math.max(1, leftSteps));
|
||||
|
||||
steps -= availableSteps;
|
||||
|
||||
if ((damage + availableSteps * damagePerContainerCraft) == maxDamage || leftSteps <= 0) {
|
||||
aStack = null;
|
||||
} else {
|
||||
toolStats.setLong("Damage", damage + availableSteps * damagePerContainerCraft);
|
||||
}
|
||||
|
||||
return new ContainerItemResult(aStack, steps, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final Item item = aStack.getItem();
|
||||
|
||||
while (aStack != null && steps > 0) {
|
||||
aStack = item.getContainerItem(aStack);
|
||||
|
||||
steps--;
|
||||
|
||||
if (aStack != null && item != aStack.getItem()) {
|
||||
return new ContainerItemResult(null, steps, aStack);
|
||||
}
|
||||
}
|
||||
|
||||
return ingrAmount;
|
||||
return new ContainerItemResult(aStack, steps, null);
|
||||
}
|
||||
|
||||
private int getGTToolDamagePerContainerCraft(ItemStack aStack) {
|
||||
|
||||
try {
|
||||
final Object toolStats = aStack.getItem().getClass().getMethod("getToolStats", ItemStack.class)
|
||||
.invoke(aStack.getItem(), aStack);
|
||||
return (int) toolStats.getClass().getMethod("getToolDamagePerContainerCraft").invoke(toolStats);
|
||||
} catch (Throwable th) {
|
||||
th.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private boolean hasContainerItem(ItemStack aStack) {
|
||||
|
||||
if (aStack.getItem().hasContainerItem(aStack)) {
|
||||
|
||||
for (ItemStack bStack : this.containerItemsBlacklist) {
|
||||
if (NEIClientUtils.areStacksSameTypeCraftingWithNBT(aStack, bStack)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void addShift(RecipeId recipeId, long shift) {
|
||||
|
||||
@@ -2,10 +2,12 @@ package codechicken.nei.recipe.chain;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
@@ -17,6 +19,9 @@ import codechicken.nei.ItemsTooltipLineHandler;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.bookmark.BookmarkItem;
|
||||
import codechicken.nei.recipe.AutoCraftingManager;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
@@ -25,12 +30,14 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
public final boolean crafting;
|
||||
protected final RecipeChainMath math;
|
||||
protected final List<BookmarkItem> initialItems;
|
||||
protected final Map<RecipeId, Long> outputRecipes;
|
||||
|
||||
protected ItemsTooltipLineHandler available;
|
||||
protected ItemsTooltipLineHandler inputs;
|
||||
protected ItemsTooltipLineHandler outputs;
|
||||
protected ItemsTooltipLineHandler remainder;
|
||||
protected boolean lastShiftKey = false;
|
||||
protected boolean lastControlKey = false;
|
||||
|
||||
protected Dimension size = new Dimension();
|
||||
|
||||
@@ -39,6 +46,7 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
this.crafting = crafting;
|
||||
this.math = math;
|
||||
this.initialItems = new ArrayList<>(this.math.initialItems);
|
||||
this.outputRecipes = new HashMap<>(this.math.outputRecipes);
|
||||
}
|
||||
|
||||
private void onUpdate() {
|
||||
@@ -47,22 +55,50 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
final List<ItemStack> outputs = new ArrayList<>();
|
||||
final List<ItemStack> remainder = new ArrayList<>();
|
||||
final ItemStackAmount inventory = new ItemStackAmount();
|
||||
final GuiContainer currentGui = NEIClientUtils.getGuiContainer();
|
||||
|
||||
if (lastShiftKey) {
|
||||
inventory.addAll(Arrays.asList(NEIClientUtils.mc().thePlayer.inventory.mainInventory));
|
||||
if (this.lastShiftKey && !(currentGui instanceof GuiRecipe<?>)) {
|
||||
inventory.putAll(AutoCraftingManager.getInventoryItems(currentGui));
|
||||
}
|
||||
|
||||
if (!this.math.outputRecipes.isEmpty()) {
|
||||
this.math.initialItems.clear();
|
||||
this.math.outputRecipes.clear();
|
||||
this.math.outputRecipes.putAll(this.outputRecipes);
|
||||
|
||||
if (lastShiftKey) {
|
||||
for (ItemStack stack : inventory.values()) {
|
||||
final long invStackSize = inventory.get(stack);
|
||||
if (this.lastShiftKey) {
|
||||
|
||||
if (invStackSize > 0) {
|
||||
this.math.initialItems.add(BookmarkItem.of(-1, stack.copy()));
|
||||
if (!this.lastControlKey) {
|
||||
final List<ItemStack> items = inventory.values();
|
||||
for (BookmarkItem item : math.recipeResults) {
|
||||
if (item.factor > 0 && this.math.outputRecipes.containsKey(item.recipeId)) {
|
||||
long amount = 0;
|
||||
|
||||
for (ItemStack stack : items) {
|
||||
if (stack != null
|
||||
&& NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack, item.itemStack)) {
|
||||
amount += StackInfo.getAmount(stack);
|
||||
}
|
||||
}
|
||||
|
||||
if (amount >= item.amount) {
|
||||
final long itemAmount = item.factor * this.math.outputRecipes.get(item.recipeId);
|
||||
if (itemAmount > 0) {
|
||||
amount += itemAmount - amount % itemAmount;
|
||||
}
|
||||
|
||||
this.math.outputRecipes.put(
|
||||
item.recipeId,
|
||||
Math.max(this.math.outputRecipes.get(item.recipeId), amount / item.factor));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack stack : inventory.values()) {
|
||||
this.math.initialItems.add(BookmarkItem.of(-1, stack.copy()));
|
||||
}
|
||||
|
||||
} else {
|
||||
this.math.initialItems.addAll(initialItems);
|
||||
}
|
||||
@@ -73,7 +109,7 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
final long amount = math.requiredAmount.getOrDefault(item, 0L);
|
||||
|
||||
if (amount > 0) {
|
||||
if (lastShiftKey) {
|
||||
if (this.lastShiftKey) {
|
||||
available.add(item.getItemStack(amount));
|
||||
} else {
|
||||
inputs.add(item.getItemStack(amount));
|
||||
@@ -97,13 +133,21 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
if (amount > 0) {
|
||||
if (math.outputRecipes.containsKey(item.recipeId)) {
|
||||
outputs.add(item.getItemStack(amount));
|
||||
} else if (lastShiftKey) {
|
||||
} else if (this.lastShiftKey) {
|
||||
remainder.add(item.getItemStack(amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (lastShiftKey) {
|
||||
if (this.lastShiftKey) {
|
||||
for (ItemStack stack : math.containerItems) {
|
||||
if (stack != null) {
|
||||
remainder.add(stack.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (this.lastShiftKey) {
|
||||
|
||||
for (BookmarkItem item : this.math.initialItems) {
|
||||
if (inventory.contains(item.itemStack)) {
|
||||
@@ -135,7 +179,7 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
.thenComparing(ItemSorter.instance));
|
||||
|
||||
this.inputs = new ItemsTooltipLineHandler(
|
||||
lastShiftKey ? NEIClientUtils.translate("bookmark.crafting_chain.missing")
|
||||
this.lastShiftKey ? NEIClientUtils.translate("bookmark.crafting_chain.missing")
|
||||
: NEIClientUtils.translate("bookmark.crafting_chain.input"),
|
||||
inputs,
|
||||
true,
|
||||
@@ -159,7 +203,7 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
true,
|
||||
Integer.MAX_VALUE);
|
||||
|
||||
if (lastShiftKey) {
|
||||
if (this.lastShiftKey) {
|
||||
this.inputs.setLabelColor(EnumChatFormatting.RED);
|
||||
this.available.setLabelColor(EnumChatFormatting.GREEN);
|
||||
}
|
||||
@@ -189,7 +233,11 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
|
||||
@Override
|
||||
public Dimension getSize() {
|
||||
if (this.lastShiftKey != (this.lastShiftKey = NEIClientUtils.shiftKey()) || this.outputs == null) {
|
||||
boolean update = this.outputs == null;
|
||||
update = this.lastShiftKey != (this.lastShiftKey = NEIClientUtils.shiftKey()) || update;
|
||||
update = this.lastControlKey != (this.lastControlKey = NEIClientUtils.controlKey()) || update;
|
||||
|
||||
if (update) {
|
||||
onUpdate();
|
||||
}
|
||||
return this.size;
|
||||
|
||||
@@ -55,4 +55,5 @@ public class DefaultStackStringifyHandler implements IStackStringifyHandler {
|
||||
|
||||
return fluidStack;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package codechicken.nei.recipe.stackinfo;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
@@ -19,6 +20,8 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
protected static Method getFluidDisplayStack = null;
|
||||
protected static Method getFluidFromDisplayStack = null;
|
||||
public static boolean replaceAE2FCFluidDrop = false;
|
||||
private static Class<?> gtMetaGeneratedTool = null;
|
||||
private static Field playSound = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
@@ -32,6 +35,12 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
"gregtech.common.items.GT_FluidDisplayItem");
|
||||
getFluidFromDisplayStack = gtUtility.getMethod("getFluidFromDisplayStack", ItemStack.class);
|
||||
getFluidDisplayStack = gtUtility.getMethod("getFluidDisplayStack", FluidStack.class, boolean.class);
|
||||
|
||||
gtMetaGeneratedTool = ReflectionHelper.getClass(
|
||||
loader,
|
||||
"gregtech.api.items.MetaGeneratedTool",
|
||||
"gregtech.api.items.GT_MetaGenerated_Tool");
|
||||
playSound = gtMetaGeneratedTool.getDeclaredField("playSound");
|
||||
} catch (Exception ignored) {
|
||||
/* Do nothing */
|
||||
}
|
||||
@@ -104,4 +113,15 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pauseItemDamageSound(boolean pause) {
|
||||
if (playSound != null) {
|
||||
try {
|
||||
playSound.setBoolean(null, !pause);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package codechicken.nei.util;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
@@ -52,4 +56,26 @@ public class NBTHelper {
|
||||
private static NBTBase get(NBTTagList tag, int idx) {
|
||||
return idx >= 0 && idx < tag.tagList.size() ? (NBTBase) tag.tagList.get(idx) : null;
|
||||
}
|
||||
|
||||
public static String toString(NBTBase nbt) {
|
||||
|
||||
if (nbt instanceof NBTTagCompound nbtTagCompound) {
|
||||
final Map<String, NBTBase> tagMap = (Map<String, NBTBase>) nbtTagCompound.tagMap;
|
||||
return "{" + tagMap.entrySet().stream().sorted(Map.Entry.<String, NBTBase>comparingByKey())
|
||||
.map(nbtEntry -> nbtEntry.getKey() + ":" + toString(nbtEntry.getValue()))
|
||||
.collect(Collectors.joining(",")) + "}";
|
||||
} else if (nbt instanceof NBTTagList list) {
|
||||
|
||||
if (list.tagList.isEmpty()) {
|
||||
return "[]";
|
||||
} else {
|
||||
final StringJoiner arr = new StringJoiner(",");
|
||||
list.tagList.forEach(c -> arr.add(toString((NBTBase) c)));
|
||||
return "[" + arr.toString() + "]";
|
||||
}
|
||||
|
||||
} else {
|
||||
return nbt.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,12 +43,10 @@ public class NBTJson {
|
||||
// NBTTagCompound
|
||||
final NBTTagCompound nbtTagCompound = (NBTTagCompound) nbt;
|
||||
final Map<String, NBTBase> tagMap = (Map<String, NBTBase>) nbtTagCompound.tagMap;
|
||||
final JsonObject root = new JsonObject();
|
||||
|
||||
JsonObject root = new JsonObject();
|
||||
|
||||
for (Map.Entry<String, NBTBase> nbtEntry : tagMap.entrySet()) {
|
||||
root.add(nbtEntry.getKey(), toJsonObject(nbtEntry.getValue()));
|
||||
}
|
||||
tagMap.entrySet().stream().sorted(Map.Entry.<String, NBTBase>comparingByKey())
|
||||
.forEach(nbtEntry -> { root.add(nbtEntry.getKey(), toJsonObject(nbtEntry.getValue())); });
|
||||
|
||||
return root;
|
||||
} else if (nbt instanceof NBTTagByte) {
|
||||
|
||||
@@ -54,4 +54,5 @@ miscutils:personalHealingDevice
|
||||
tectech:item.em.debugContainer,tag.symbols
|
||||
tinkersdefense:Heater Shield,tag.InfiTool
|
||||
tinkersdefense:Round Shield,tag.InfiTool
|
||||
miscutils:itemCustomMetaCover.miscutils.GtMachineCasings,Damage
|
||||
miscutils:itemCustomMetaCover.miscutils.GtMachineCasings,Damage
|
||||
gregtech:gt.metaitem.01&32708,tag.output
|
||||
@@ -1,23 +1,12 @@
|
||||
# Hidden Items Filters
|
||||
#
|
||||
# parts:
|
||||
# modname:itemid - identify
|
||||
# $orename - ore dictionary
|
||||
# tag.color=red - tag
|
||||
# 0 or 0-12 - damage
|
||||
#
|
||||
# modifiers:
|
||||
# ! - logical not. exclude items that match the following expression (!minecraft:portal)
|
||||
# r/.../ - standard java regex (r/^m\w{6}ft$/ = minecraft)
|
||||
# , - logical or in token (minecraft:potion 16384-16462,!16386)
|
||||
# | - logical or multi-item search (wrench|hammer)
|
||||
#
|
||||
# example: minecraft:potion 16384-16462,!16386 | $oreiron | tag.color=red
|
||||
# Uses the same filter format at collapsibleitems.cfg
|
||||
#
|
||||
minecraft:portal
|
||||
minecraft:end_portal
|
||||
minecraft:fire
|
||||
minecraft:lava
|
||||
r/minecraft:fire$/
|
||||
r/minecraft:water$/
|
||||
r/minecraft:lava$/
|
||||
minecraft:mob_spawner
|
||||
minecraft:anvil !0
|
||||
minecraft:flowing_water
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# NEI Item Information Config
|
||||
#
|
||||
# One page per line, in the format:
|
||||
# filter = description text
|
||||
#
|
||||
# The filter uses the same format as collapsibleitems.cfg.
|
||||
#
|
||||
# You can repeat the same filter on multiple lines to add extra pages.
|
||||
# Use \n to insert line breaks inside the description. Use it multiple times for a larger gap between lines.
|
||||
# Using a translation key for the description will automatically translate it.
|
||||
# Only the first '=' after the filter is treated as the separator; feel free to put them in your descriptions.
|
||||
# Spaces before and after '=' are removed from the description and are optional.
|
||||
# The same item can match filters for multiple pages, unlike collapsibleitems.cfg only putting them in the first matching group.
|
||||
#
|
||||
# Empty lines and lines starting with # are ignored.
|
||||
#
|
||||
# Examples:
|
||||
# # Jungle Wood (meta 3)
|
||||
# minecraft:log 3 = Exotic wood found in tropical climates.
|
||||
#
|
||||
# # Diamond Sword (two pages of information)
|
||||
# minecraft:diamond_sword = A powerful melee weapon. Does 8 damage total.
|
||||
# minecraft:diamond_sword = Can be enchanted for extra effects.
|
||||
#
|
||||
# # Two different ore dictionary tags. Iron ingots match both.
|
||||
# $iron = Iron is a very versatile material. It can be found below sea level in the Overworld.
|
||||
# $ingot = Ingots are the refined form of metal or clay.
|
||||
#
|
||||
@@ -0,0 +1,3 @@
|
||||
# Each line in this file should either be a comment (line starts with '#'), handler name or handler id.
|
||||
# If you delete this file, it will be regenerated with the default handlers list.
|
||||
Unknown
|
||||
@@ -5,6 +5,7 @@ codechicken.nei.recipe.FurnaceRecipeHandler,Minecraft,minecraft:furnace,,minecra
|
||||
codechicken.nei.recipe.ShapedRecipeHandler,Minecraft,minecraft:crafting_table,,minecraft,FALSE,,,65,166,5,,,,,,
|
||||
codechicken.nei.recipe.ShapelessRecipeHandler,Minecraft,minecraft:crafting_table,,minecraft,FALSE,,,65,166,5,,,,,,
|
||||
codechicken.nei.recipe.FuelRecipeHandler,Minecraft,,,minecraft,FALSE,,,65,166,5,nei:textures/nei_tabbed_sprites.png,80,0,14,14,
|
||||
codechicken.nei.recipe.InformationHandler,Not Enough Items,,,nei,FALSE,,,65,166,1,nei:textures/nei_tabbed_sprites.png,96,0,16,16,
|
||||
advsolar.client.nei.MTRecipeHandler,Advanced Solar Panels,AdvancedSolarPanel:BlockMolecularTransformer,,AdvancedSolarPanel,TRUE,,,68,,5,,,,,,
|
||||
appeng.integration.modules.NEIHelpers.NEIAEShapedRecipeHandler,Applied Energistics 2,appliedenergistics2:item.ItemMultiPart:380,,appliedenergistics2,TRUE,,,65,,5,,,,,,
|
||||
appeng.integration.modules.NEIHelpers.NEIAEShapelessRecipeHandler,Applied Energistics 2,appliedenergistics2:item.ItemMultiPart:380,,appliedenergistics2,TRUE,,,65,,5,,,,,,
|
||||
|
||||
|
@@ -30,7 +30,8 @@ nei.bookmark.group.sorting=Move Position
|
||||
nei.bookmark.group.remove_recipe=Remove Group
|
||||
nei.bookmark.group.pull_items=Pull all Items
|
||||
nei.bookmark.group.pull_items_shift=Pull missing Items
|
||||
nei.bookmark.group.craft=Craft Group
|
||||
nei.bookmark.group.craft_missing=Craft Missing Items
|
||||
nei.bookmark.group.craft_all=Craft Items
|
||||
nei.bookmark.item.sorting=Move Position
|
||||
nei.bookmark.remove_recipe=Remove Recipe
|
||||
nei.bookmark.remove_item=Remove Item
|
||||
@@ -54,13 +55,15 @@ nei.itempanel.collapsed.button.tip=Collapse/Expand All Collapsible Items
|
||||
nei.itempanel.collapsed.hint.expand=Expand Group (%d items)
|
||||
nei.itempanel.collapsed.hint.collapse=Collapse Group (%d items)
|
||||
nei.itempanel.overlay_recipe=Overlay Recipe
|
||||
nei.itempanel.craft=Craft Recipe
|
||||
nei.itempanel.craft_missing=Craft Missing Items
|
||||
nei.itempanel.craft_all=Craft Items
|
||||
nei.itempanel.fill_crafting_grid=Fill Crafting Grid
|
||||
nei.itempanel.fill_crafting_grid_quantity=Fill Crafting Grid With Quantity
|
||||
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.chat_link_item=Send item link to chat
|
||||
|
||||
nei.enchant=Enchant
|
||||
nei.enchant.level=Level
|
||||
@@ -110,6 +113,8 @@ nei.inventory.current.gamemode.1=Current gamemode: creative
|
||||
nei.inventory.current.gamemode.2=Current gamemode: creative+
|
||||
nei.inventory.current.gamemode.3=Current gamemode: adventure
|
||||
nei.inventory.tooltip.page=Page: %s / %s [Press %s to see next page]
|
||||
nei.inventory.tooltip.count.item=Count: %s
|
||||
nei.inventory.tooltip.count.fluid=Amount: %s
|
||||
|
||||
nei.inventory.gamemode.0=Click: Set gamemode to survival
|
||||
nei.inventory.gamemode.1=Click: Set gamemode to creative
|
||||
@@ -130,6 +135,15 @@ nei.chat.chunkoverlay.0=Chunk Overlay: Off
|
||||
nei.chat.chunkoverlay.1=Chunk Overlay: Chunk Corners
|
||||
nei.chat.chunkoverlay.2=Chunk Overlay: Chunks
|
||||
nei.chat.chunkoverlay.3=Chunk Overlay: GT Ore Veins
|
||||
nei.chat.item_link.text=<%s> §6Click to add bookmark: %s
|
||||
nei.chat.bookmark_added.text=Bookmark added!
|
||||
|
||||
nei.chat.recipeid.many_params=Too many parameters! Usage: %s
|
||||
nei.chat.recipeid.not_found=File %s not found!
|
||||
nei.chat.recipeid.diff.start=Start processing recipe diff!
|
||||
nei.chat.recipeid.diff.finish=Finished processing recipe diff!
|
||||
nei.chat.recipeid.dump.start=Start processing recipe handlers!
|
||||
nei.chat.recipeid.dump.finish=Finished processing recipe handlers!
|
||||
|
||||
nei.options=NEI Options
|
||||
nei.options.back=Back
|
||||
@@ -168,8 +182,9 @@ nei.options.keys.gui.getprevioussearch=Previous Search
|
||||
nei.options.keys.gui.getnextsearch=Next Search
|
||||
nei.options.keys.gui.next_tooltip=Next Tooltip
|
||||
nei.options.keys.gui.copy_name=Copy Item Name
|
||||
nei.options.keys.gui.craft=Craft Recipe
|
||||
nei.options.keys.gui.craft_items=Craft Items
|
||||
nei.options.keys.gui.copy_oredict=Copy Item OreDictionary
|
||||
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
|
||||
nei.options.keys.gui.itemzoom_zoom_in=Item Zoom In
|
||||
@@ -214,6 +229,9 @@ nei.options.inventory.bookmarks.ignorePotionOverlap.false=No
|
||||
nei.options.inventory.bookmarks.worldSpecific=World Specific
|
||||
nei.options.inventory.bookmarks.worldSpecific.true=Yes
|
||||
nei.options.inventory.bookmarks.worldSpecific.false=No
|
||||
nei.options.inventory.bookmarks.bookmarkItemsWithRecipe=Bookmark items with recipe
|
||||
nei.options.inventory.bookmarks.bookmarkItemsWithRecipe.true=Yes
|
||||
nei.options.inventory.bookmarks.bookmarkItemsWithRecipe.false=No
|
||||
nei.options.inventory.favorites=Favorites
|
||||
nei.options.inventory.favorites.enabled=Visibility
|
||||
nei.options.inventory.favorites.enabled.true=Visible
|
||||
@@ -305,6 +323,9 @@ nei.options.inventory.guirecipe.creativeTabStyle.false=JEI
|
||||
nei.options.inventory.optimize_gui_overlap_computation=Optimize computation for GUI overlap
|
||||
nei.options.inventory.optimize_gui_overlap_computation.true=Yes
|
||||
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
|
||||
@@ -499,6 +520,8 @@ nei.recipe.favorite=Favorite
|
||||
nei.recipe.favorite.bookmark_recipe=Save Recipe Tree
|
||||
nei.recipe.favorite.change_result_index=Change Output
|
||||
|
||||
nei.recipe.information=Information
|
||||
|
||||
nei.itemsort.minecraft=Minecraft
|
||||
nei.itemsort.minecraft.tip=Sorts items from vanilla minecraft first
|
||||
nei.itemsort.mod=Mod
|
||||
|
||||
@@ -31,6 +31,7 @@ nei.itempanel.deleteItem=Удалить предмет
|
||||
nei.itempanel.collapsed.button.tip=Свернуть/Развернуть все группы предметов
|
||||
nei.itempanel.collapsed.hint.expand=Развернуть группу (%d предметов)
|
||||
nei.itempanel.collapsed.hint.collapse=Свернуть группу (%d предметов)
|
||||
nei.itempanel.chat_link_item=Отправить ссылку на предмет в чат
|
||||
|
||||
nei.enchant=Зачаровать
|
||||
nei.enchant.level=Уровень
|
||||
@@ -100,6 +101,8 @@ nei.chat.chunkoverlay.0=Отображение чанков: Выключено
|
||||
nei.chat.chunkoverlay.1=Отображение чанков: Углы чанков
|
||||
nei.chat.chunkoverlay.2=Отображение чанков: Чанки
|
||||
nei.chat.chunkoverlay.3=Отображение чанков: Жилы руды GT
|
||||
nei.chat.item_link.text=<%s> §6Нажми чтобы добавить закладку: %s
|
||||
nei.chat.bookmark_added.text=Закладка добавлена!
|
||||
|
||||
nei.options=Настройки NEI
|
||||
nei.options.back=Назад
|
||||
@@ -139,6 +142,7 @@ nei.options.keys.gui.getnextsearch=Следующий поиск
|
||||
nei.options.keys.gui.next_tooltip=Следующая подсказка
|
||||
nei.options.keys.gui.copy_name=Скопировать название предмета
|
||||
nei.options.keys.gui.copy_oredict=Скопировать OreDictionary предмета
|
||||
nei.options.keys.gui.chat_link_item=Отправить ссылку на предмет в чат
|
||||
nei.options.keys.gui.itemzoom_toggle=Переключить увеличение предмета
|
||||
nei.options.keys.gui.itemzoom_hold=Удерживать для отображения увеличения предмета
|
||||
nei.options.keys.gui.itemzoom_zoom_in=Увеличить предмет
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 4.6 KiB |
Reference in new issue
Block a user