mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-15 01:34:42 +00:00
Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1557d3ed45 | ||
|
|
642c1f8a88 | ||
|
|
b2b8702c5c | ||
|
|
70706cb717 | ||
|
|
c43242bb36 | ||
|
|
b8a388f88c | ||
|
|
7245ad69ac | ||
|
|
d8ef170074 | ||
|
|
3e69283ecb | ||
|
|
f362b1c711 | ||
|
|
7dd16c01dc | ||
|
|
40dd178e5a | ||
|
|
c79ee9fc19 | ||
|
|
96256b95d0 | ||
|
|
2535b64fb7 | ||
|
|
6d6b7369da | ||
|
|
a7b3dd2026 | ||
|
|
59eefd933b |
No files matched your search
+2
-2
@@ -1,8 +1,8 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.8.0:dev')
|
||||
api('com.github.GTNewHorizons:CodeChickenCore:1.4.8:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.8.6:dev')
|
||||
|
||||
shadowImplementation('org.apache.commons:commons-csv:1.10.0')
|
||||
|
||||
|
||||
@@ -996,7 +996,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
@Override
|
||||
public boolean onMouseWheel(int shift, int mousex, int mousey) {
|
||||
|
||||
if (!inEditingState() && new Rectangle4i(
|
||||
if ((!inEditingState() || this.sortableGroup != null) && new Rectangle4i(
|
||||
namespacePrev.x,
|
||||
namespacePrev.y,
|
||||
namespaceNext.x + namespaceNext.w - namespacePrev.x,
|
||||
|
||||
@@ -89,7 +89,7 @@ public abstract class TextField extends Widget {
|
||||
onTextChange(oldText);
|
||||
}
|
||||
|
||||
return handled;
|
||||
return handled || keyID == Keyboard.KEY_SPACE;
|
||||
}
|
||||
|
||||
public abstract void onTextChange(String oldText);
|
||||
|
||||
@@ -771,6 +771,25 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
int absoluteSlotIndex = absoluteRowIndex * this.columns;
|
||||
int overGroupId = getRowGroupId(overRowIndex);
|
||||
|
||||
// move group to same grid
|
||||
if (this != sortableGroup.grid) {
|
||||
final BookmarkGroup sourceGroup = sortableGroup.grid.getGroup(sortableGroup.groupId);
|
||||
final List<BookmarkItem> itemsToMove = sortableGroup.getBookmarkItems();
|
||||
|
||||
sortableGroup.grid.removeGroup(sortableGroup.groupId);
|
||||
|
||||
final int groupId = this.addGroup(sourceGroup);
|
||||
for (BookmarkItem item : itemsToMove) {
|
||||
item.groupId = groupId;
|
||||
this.bookmarkItems.add(item);
|
||||
}
|
||||
|
||||
sortableGroup.grid = this;
|
||||
sortableGroup.groupId = groupId;
|
||||
this.onItemsChanged();
|
||||
this.getMask();// force generate grid
|
||||
}
|
||||
|
||||
if (sortableGroup.groupId == overGroupId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -16,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -137,6 +137,7 @@ public class BookmarkStorage {
|
||||
NBTTagCompound navigation = new NBTTagCompound();
|
||||
namespaces.add(new BookmarkGrid());
|
||||
BookmarkGrid grid = namespaces.get(0);
|
||||
boolean wasError = false;
|
||||
|
||||
if (NEIClientConfig.world.nbt.hasKey("bookmark")) {
|
||||
navigation = NEIClientConfig.world.nbt.getCompoundTag("bookmark");
|
||||
@@ -151,17 +152,19 @@ public class BookmarkStorage {
|
||||
}
|
||||
|
||||
if (itemStr.startsWith("; ")) {
|
||||
JsonObject settings = parser.parse(itemStr.substring(2)).getAsJsonObject();
|
||||
|
||||
if (grid.size() > 0) {
|
||||
// do not create empty namespaces
|
||||
grid = new BookmarkGrid();
|
||||
|
||||
if (navigation.hasKey("namespacePage." + namespaces.size())) {
|
||||
grid.setPage(navigation.getInteger("namespacePage." + namespaces.size()));
|
||||
}
|
||||
|
||||
namespaces.add(grid);
|
||||
}
|
||||
|
||||
if (navigation.hasKey("namespacePage." + (namespaces.size() - 1))) {
|
||||
grid.setPage(navigation.getInteger("namespacePage." + (namespaces.size() - 1)));;
|
||||
}
|
||||
final JsonObject settings = parser.parse(itemStr.substring(2)).getAsJsonObject();
|
||||
|
||||
if (settings.get("viewmode") != null) {
|
||||
grid.groups.get(BookmarkGrid.DEFAULT_GROUP_ID).viewMode = BookmarkViewMode
|
||||
@@ -196,17 +199,28 @@ public class BookmarkStorage {
|
||||
}
|
||||
|
||||
if (!addItemToGrid(grid, parser.parse(itemStr).getAsJsonObject())) {
|
||||
wasError = true;
|
||||
NEIClientConfig.logger.warn(
|
||||
"Failed to load bookmarked ItemStack from json string, the item no longer exists:\n{}",
|
||||
itemStr);
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException | JsonSyntaxException | IllegalStateException e) {
|
||||
} catch (Exception e) {
|
||||
wasError = true;
|
||||
NEIClientConfig.logger.error("Failed to load bookmarked ItemStack from json string:\n{}", itemStr);
|
||||
}
|
||||
}
|
||||
|
||||
prepareOldRecipeFormat(namespaces);
|
||||
if (wasError) {
|
||||
try {
|
||||
Files.copy(
|
||||
bookmarkFile,
|
||||
new File(bookmarkFile.getAbsolutePath() + ".backup-" + System.currentTimeMillis()));
|
||||
NEIClientConfig.logger.info("Backed up invalid bookmark file to {}", bookmarkFile);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to backup invalid bookmark file to {}", bookmarkFile, e);
|
||||
}
|
||||
}
|
||||
|
||||
for (BookmarkGrid gr : namespaces) {
|
||||
gr.onItemsChanged();
|
||||
@@ -264,48 +278,6 @@ public class BookmarkStorage {
|
||||
return itemStack != null;
|
||||
}
|
||||
|
||||
private void prepareOldRecipeFormat(List<BookmarkGrid> namespaces) {
|
||||
|
||||
for (BookmarkGrid grid : namespaces) {
|
||||
if (grid.bookmarkItems.stream()
|
||||
.noneMatch(item -> item.recipeId != null && item.recipeId.getResult() == null)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final Map<String, RecipeId> recipes = new HashMap<>();
|
||||
|
||||
for (BookmarkItem item : grid.bookmarkItems) {
|
||||
if (item.recipeId != null && item.type != BookmarkItemType.INGREDIENT
|
||||
&& item.recipeId.getResult() == null) {
|
||||
final JsonObject recipeJson = item.recipeId.toJsonObject();
|
||||
final String recipeGUID = item.groupId + ":" + NBTJson.toJson(recipeJson);
|
||||
|
||||
if (!recipes.containsKey(recipeGUID)) {
|
||||
recipeJson.add("result", NBTJson.toJsonObject(StackInfo.itemStackToNBT(item.itemStack)));
|
||||
recipes.put(recipeGUID, item.recipeId = RecipeId.of(recipeJson));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (BookmarkItem item : grid.bookmarkItems) {
|
||||
if (item.recipeId != null && item.recipeId.getResult() == null) {
|
||||
final JsonObject recipeJson = item.recipeId.toJsonObject();
|
||||
final String recipeGUID = item.groupId + ":" + NBTJson.toJson(recipeJson);
|
||||
|
||||
if (recipes.containsKey(recipeGUID)) {
|
||||
item.recipeId = recipes.get(recipeGUID).copy();
|
||||
item.permutations = BookmarkItem.generatePermutations(
|
||||
item.itemStack,
|
||||
item.recipeId,
|
||||
item.type == BookmarkItemType.INGREDIENT);
|
||||
} else {
|
||||
item.recipeId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
|
||||
if (this.bookmarkFile == null) {
|
||||
|
||||
@@ -36,6 +36,7 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
protected ItemsTooltipLineHandler inputs;
|
||||
protected ItemsTooltipLineHandler outputs;
|
||||
protected ItemsTooltipLineHandler remainder;
|
||||
protected ItemsTooltipLineHandler craftingNeeded;
|
||||
protected boolean lastShiftKey = false;
|
||||
protected boolean lastControlKey = false;
|
||||
|
||||
@@ -54,6 +55,7 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
final List<ItemStack> inputs = new ArrayList<>();
|
||||
final List<ItemStack> outputs = new ArrayList<>();
|
||||
final List<ItemStack> remainder = new ArrayList<>();
|
||||
final List<ItemStack> craftingNeeded = new ArrayList<>();
|
||||
final ItemStackAmount inventory = new ItemStackAmount();
|
||||
final GuiContainer currentGui = NEIClientUtils.getGuiContainer();
|
||||
|
||||
@@ -167,6 +169,12 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
}
|
||||
|
||||
}
|
||||
if (this.lastShiftKey) {
|
||||
for (Map.Entry<BookmarkItem, Long> item : this.math.requiredAmount.entrySet()) {
|
||||
if (item.getKey().type == BookmarkItem.BookmarkItemType.RESULT && item.getValue() != 0)
|
||||
craftingNeeded.add(item.getKey().getItemStack(item.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
inputs.sort(
|
||||
Comparator.comparing((ItemStack stack) -> StackInfo.getFluid(stack) != null)
|
||||
@@ -203,9 +211,16 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
true,
|
||||
Integer.MAX_VALUE);
|
||||
|
||||
this.craftingNeeded = new ItemsTooltipLineHandler(
|
||||
NEIClientUtils.translate("bookmark.crafting_chain.needed"),
|
||||
craftingNeeded,
|
||||
true,
|
||||
Integer.MAX_VALUE);
|
||||
|
||||
if (this.lastShiftKey) {
|
||||
this.inputs.setLabelColor(EnumChatFormatting.RED);
|
||||
this.available.setLabelColor(EnumChatFormatting.GREEN);
|
||||
this.craftingNeeded.setLabelColor(EnumChatFormatting.BLUE);
|
||||
}
|
||||
|
||||
this.size.height = this.size.width = 0;
|
||||
@@ -217,16 +232,18 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
if (!this.math.outputRecipes.isEmpty()) {
|
||||
this.size.height = 2 + GuiDraw.fontRenderer.FONT_HEIGHT;
|
||||
}
|
||||
|
||||
this.size.width = Math.max(
|
||||
this.inputs.getSize().width,
|
||||
Math.max(
|
||||
this.outputs.getSize().width,
|
||||
Math.max(this.remainder.getSize().width, this.available.getSize().width)));
|
||||
Math.max(
|
||||
this.remainder.getSize().width,
|
||||
Math.max(this.available.getSize().width, this.craftingNeeded.getSize().width))));
|
||||
|
||||
this.size.height += this.inputs.getSize().height + this.outputs.getSize().height
|
||||
+ this.remainder.getSize().height
|
||||
+ this.available.getSize().height;
|
||||
+ this.available.getSize().height
|
||||
+ this.craftingNeeded.getSize().height;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -258,7 +275,6 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
}
|
||||
|
||||
if (NEIClientConfig.recipeChainDir() == 0) {
|
||||
|
||||
if (!this.inputs.isEmpty()) {
|
||||
this.inputs.draw(x, y);
|
||||
y += this.inputs.getSize().height;
|
||||
@@ -269,6 +285,11 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
y += this.available.getSize().height;
|
||||
}
|
||||
|
||||
if (!this.craftingNeeded.isEmpty()) {
|
||||
this.craftingNeeded.draw(x, y);
|
||||
y += this.craftingNeeded.getSize().height;
|
||||
}
|
||||
|
||||
if (!this.outputs.isEmpty()) {
|
||||
this.outputs.draw(x, y);
|
||||
y += this.outputs.getSize().height;
|
||||
@@ -286,6 +307,11 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
y += this.inputs.getSize().height;
|
||||
}
|
||||
|
||||
if (!this.craftingNeeded.isEmpty()) {
|
||||
this.craftingNeeded.draw(x, y);
|
||||
y += this.craftingNeeded.getSize().height;
|
||||
}
|
||||
|
||||
if (!this.available.isEmpty()) {
|
||||
this.available.draw(x, y);
|
||||
y += this.available.getSize().height;
|
||||
|
||||
@@ -47,6 +47,7 @@ nei.bookmark.crafting_chain.input=Ingredients
|
||||
nei.bookmark.crafting_chain.missing=Missing Items
|
||||
nei.bookmark.crafting_chain.output=Results
|
||||
nei.bookmark.crafting_chain.remainder=Remainders
|
||||
nei.bookmark.crafting_chain.needed=Required Crafts
|
||||
nei.bookmark.crafting_chain.available=Available Items
|
||||
nei.inventory.search.placeholder=Search...
|
||||
nei.itempanel.quantity.default=One stack
|
||||
|
||||
Reference in new issue
Block a user