mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-15 09:44:44 +00:00
Compare commits
47
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e48f5bebf0 | ||
|
|
51300d1110 | ||
|
|
c9b3e64a11 | ||
|
|
e456825bdb | ||
|
|
c623885f28 | ||
|
|
c70bf58fb5 | ||
|
|
3682a27ff8 | ||
|
|
7930fcbe1d | ||
|
|
d94d9bf2ce | ||
|
|
9427fcea59 | ||
|
|
7dd16c01dc | ||
|
|
7c88c019a9 | ||
|
|
40dd178e5a | ||
|
|
a828bdca14 | ||
|
|
721e2f1d24 | ||
|
|
4585dec533 | ||
|
|
ac57fa0cf4 | ||
|
|
1d7d06b81a | ||
|
|
1e563af521 | ||
|
|
c2eb806c29 | ||
|
|
0320ea0176 | ||
|
|
44f6e5418b | ||
|
|
e4f9a0d8ec | ||
|
|
5b4c17996b | ||
|
|
672950792a | ||
|
|
ba4876cf88 | ||
|
|
3bc7534ae6 | ||
|
|
c79ee9fc19 | ||
|
|
96256b95d0 | ||
|
|
77ebc2a0ee | ||
|
|
f2380ee60f | ||
|
|
2535b64fb7 | ||
|
|
834935b5e5 | ||
|
|
1779aa771e | ||
|
|
d813e900f6 | ||
|
|
027e34a760 | ||
|
|
6d6b7369da | ||
|
|
9af6987194 | ||
|
|
973ae8872f | ||
|
|
a7b3dd2026 | ||
|
|
59eefd933b | ||
|
|
02c4080763 | ||
|
|
91828ea9f5 | ||
|
|
2201b3264e | ||
|
|
b6380c4a74 | ||
|
|
9f50932990 | ||
|
|
518aad6d37 |
No files matched your search
@@ -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,
|
||||
@@ -1187,7 +1187,15 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
}
|
||||
|
||||
if (!items.isEmpty()) {
|
||||
containerHandler.pullBookmarkItemsFromContainer(guiContainer, items);
|
||||
final int helmStackIndex = FastTransferManager.dropHeldItem(guiContainer);
|
||||
|
||||
if (guiContainer.mc.thePlayer.inventory.getItemStack() == null) {
|
||||
containerHandler.pullBookmarkItemsFromContainer(guiContainer, items);
|
||||
|
||||
if (helmStackIndex != -1) {
|
||||
FastTransferManager.clickSlot(guiContainer, helmStackIndex, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -12,36 +12,19 @@ public class DefaultBookmarkContainerHandler implements IBookmarkContainerHandle
|
||||
|
||||
@Override
|
||||
public void pullBookmarkItemsFromContainer(GuiContainer guiContainer, ArrayList<ItemStack> bookmarkItems) {
|
||||
FastTransferManager manager = new FastTransferManager();
|
||||
LinkedList<ItemStack> containerStacks = manager.saveContainer(guiContainer.inventorySlots);
|
||||
final FastTransferManager manager = new FastTransferManager();
|
||||
final List<ItemStack> containerStacks = getStorageStacks(guiContainer);
|
||||
|
||||
for (ItemStack bookmarkItem : bookmarkItems) {
|
||||
|
||||
int bookmarkSizeBackup = bookmarkItem.stackSize;
|
||||
|
||||
for (int i = 0; i < containerStacks.size() - 4 * 9; i++) { // Last 36 slots are player inventory
|
||||
ItemStack containerItem = containerStacks.get(i);
|
||||
|
||||
if (containerItem == null) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < containerStacks.size() && bookmarkItem.stackSize > 0; i++) {
|
||||
final ItemStack containerItem = containerStacks.get(i);
|
||||
|
||||
if (bookmarkItem.isItemEqual(containerItem)) {
|
||||
if (bookmarkItem.stackSize <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
int transferAmount = Math.min(bookmarkItem.stackSize, containerItem.stackSize);
|
||||
|
||||
final int transferAmount = Math.min(bookmarkItem.stackSize, containerItem.stackSize);
|
||||
manager.transferItems(guiContainer, i, transferAmount);
|
||||
bookmarkItem.stackSize -= transferAmount;
|
||||
|
||||
if (bookmarkItem.stackSize == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bookmarkItem.stackSize = bookmarkSizeBackup;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -281,6 +283,27 @@ public class FastTransferManager {
|
||||
GuiContainerManager.getManager(window).handleSlotClick(slotIndex, button, modifier);
|
||||
}
|
||||
|
||||
public static int dropHeldItem(GuiContainer window) {
|
||||
final EntityPlayerSP player = window.mc.thePlayer;
|
||||
final ItemStack held = player.inventory.getItemStack();
|
||||
|
||||
if (held == null) return -1;
|
||||
|
||||
for (int i = 0; held != null && i < window.inventorySlots.inventorySlots.size(); i++) {
|
||||
final Slot slot = window.inventorySlots.inventorySlots.get(i);
|
||||
|
||||
if (slot.inventory instanceof InventoryPlayer && !slot.getHasStack() && slot.isItemValid(held)) {
|
||||
clickSlot(window, i, 0, 0);
|
||||
|
||||
if (player.inventory.getItemStack() == null) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private boolean fillZoneWithHeldItem(GuiContainer window, int zoneIndex) {
|
||||
for (int transferTo : slotZones.get(zoneIndex)) {
|
||||
ItemStack held = NEIClientUtils.getHeldItem();
|
||||
|
||||
@@ -70,8 +70,8 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
||||
}
|
||||
|
||||
public void setActiveStack(ItemStack activeStack) {
|
||||
final ItemStack realStack = items.stream()
|
||||
.filter(stack -> NEIClientUtils.areStacksSameTypeWithNBT(stack, activeStack)).findFirst().orElse(null);
|
||||
final ItemStack realStack = items.stream().filter(stack -> NEIClientUtils.areStacksSameType(stack, activeStack))
|
||||
.findFirst().orElse(null);
|
||||
this.activeStackIndex = items.indexOf(realStack);
|
||||
}
|
||||
|
||||
|
||||
@@ -851,24 +851,27 @@ public class NEIClientConfig {
|
||||
}
|
||||
|
||||
public static void loadWorld(String worldPath) {
|
||||
final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
|
||||
final boolean newWorld = !specificDir.exists();
|
||||
unloadWorld();
|
||||
setInternalEnabled(true);
|
||||
|
||||
if (!worldPath.equals(NEIClientConfig.worldPath)) {
|
||||
if (!worldPath.equals(NEIClientConfig.worldPath) || newWorld) {
|
||||
NEIClientConfig.worldPath = worldPath;
|
||||
|
||||
logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");
|
||||
|
||||
final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
|
||||
final boolean newWorld = !specificDir.exists();
|
||||
|
||||
if (newWorld) {
|
||||
specificDir.mkdirs();
|
||||
}
|
||||
|
||||
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
|
||||
|
||||
if (newWorld && Minecraft.getMinecraft().isSingleplayer()) {
|
||||
world.config.getTag("inventory.cheatmode")
|
||||
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
|
||||
}
|
||||
|
||||
bootNEI();
|
||||
onWorldLoad(newWorld);
|
||||
onWorldLoad();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,7 +879,7 @@ public class NEIClientConfig {
|
||||
return NEIClientConfig.worldPath;
|
||||
}
|
||||
|
||||
private static void onWorldLoad(boolean newWorld) {
|
||||
private static void onWorldLoad() {
|
||||
world.config.setComment(
|
||||
"World based configuration of NEI.\nMost of these options can be changed ingame.\nDeleting any element will restore it to it's default value");
|
||||
|
||||
@@ -884,12 +887,6 @@ public class NEIClientConfig {
|
||||
creativeInv = new ItemStack[54];
|
||||
LayoutManager.searchField.setText(getSearchExpression());
|
||||
LayoutManager.quantity.setText(Integer.toString(getItemQuantity()));
|
||||
|
||||
if (newWorld && Minecraft.getMinecraft().isSingleplayer()) {
|
||||
world.config.getTag("inventory.cheatmode")
|
||||
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
|
||||
}
|
||||
|
||||
NEIInfo.load(ClientUtils.getWorld());
|
||||
}
|
||||
|
||||
@@ -914,12 +911,7 @@ public class NEIClientConfig {
|
||||
SubsetWidget.saveHidden();
|
||||
FavoriteRecipes.save();
|
||||
CollapsibleItems.saveStates();
|
||||
|
||||
if (world != null) {
|
||||
world.saveNBT();
|
||||
NEIClientConfig.worldPath = null;
|
||||
world = null;
|
||||
}
|
||||
world.saveNBT();
|
||||
}
|
||||
|
||||
private static final Map<String, String> keySettings = new HashMap<>();
|
||||
|
||||
@@ -117,7 +117,7 @@ public class PositionedStack {
|
||||
public int getPermutationIndex(ItemStack stack) {
|
||||
|
||||
for (int index = 0; index < this.items.length; index++) {
|
||||
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(items[index], stack)) {
|
||||
if (NEIServerUtils.areStacksSameType(items[index], stack)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public interface IBookmarkContainerHandler {
|
||||
|
||||
for (int i = 0; i < slots.size() - 4 * 9; i++) {
|
||||
if (slots.get(i).getHasStack()) {
|
||||
stacks.add(slots.get(i).getStack());
|
||||
stacks.add(slots.get(i).getStack().copy());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -350,22 +350,20 @@ public class RecipeChainDetails {
|
||||
private Set<RecipeId> getRecipeParents(RecipeChainMath math, RecipeId recipeId, Set<RecipeId> parents,
|
||||
Set<RecipeId> visited) {
|
||||
final Set<RecipeId> recipeIds = math.preferredItems.entrySet().stream()
|
||||
.filter(
|
||||
entry -> entry.getValue() != null && recipeId.equals(entry.getValue().recipeId)
|
||||
&& !visited.contains(entry.getKey().recipeId))
|
||||
.filter(entry -> entry.getValue() != null && recipeId.equals(entry.getValue().recipeId))
|
||||
.map(entry -> entry.getKey().recipeId).collect(Collectors.toSet());
|
||||
|
||||
visited.addAll(recipeIds);
|
||||
|
||||
if (recipeIds.isEmpty()) {
|
||||
parents.add(recipeId);
|
||||
} else {
|
||||
|
||||
for (RecipeId ingrRecipeId : recipeIds) {
|
||||
if (math.outputRecipes.containsKey(ingrRecipeId)) {
|
||||
parents.add(ingrRecipeId);
|
||||
} else {
|
||||
getRecipeParents(math, ingrRecipeId, parents, visited);
|
||||
if (visited.add(ingrRecipeId)) {
|
||||
if (math.outputRecipes.containsKey(ingrRecipeId)) {
|
||||
parents.add(ingrRecipeId);
|
||||
} else {
|
||||
getRecipeParents(math, ingrRecipeId, parents, visited);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
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;
|
||||
@@ -50,17 +50,17 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
public Slot[] slots;
|
||||
}
|
||||
|
||||
public DefaultOverlayHandler(int x, int y) {
|
||||
offsetx = x;
|
||||
offsety = y;
|
||||
}
|
||||
public int offsetx;
|
||||
public int offsety;
|
||||
|
||||
public DefaultOverlayHandler() {
|
||||
this(5, 11);
|
||||
}
|
||||
|
||||
public int offsetx;
|
||||
public int offsety;
|
||||
public DefaultOverlayHandler(int x, int y) {
|
||||
this.offsetx = x;
|
||||
this.offsety = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void overlayRecipe(GuiContainer gui, IRecipeHandler handler, int recipeIndex, boolean maxTransfer) {
|
||||
@@ -72,7 +72,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
final List<PositionedStack> ingredients = handler.getIngredientStacks(recipeIndex);
|
||||
final List<DistributedIngred> ingredStacks = getPermutationIngredients(ingredients);
|
||||
|
||||
if (!clearIngredients(gui)) return 0;
|
||||
if (!clearIngredients(gui, handler)) return 0;
|
||||
|
||||
findInventoryQuantities(gui, ingredStacks);
|
||||
|
||||
@@ -99,12 +99,17 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean craft(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, int multiplier) {
|
||||
final EntityClientPlayerMP thePlayer = NEIClientUtils.mc().thePlayer;
|
||||
boolean craft = false;
|
||||
public boolean craft(GuiContainer firstGui, IRecipeHandler handler, int recipeIndex, int multiplier) {
|
||||
final Slot craftingSlot = firstGui.inventorySlots.inventorySlots.stream()
|
||||
.filter(slot -> slot instanceof SlotCrafting).findFirst().orElse(null);
|
||||
|
||||
if (craftingSlot == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean craft = false;
|
||||
while (multiplier > 0) {
|
||||
final int transfer = transferRecipe(firstGui, recipe, recipeIndex, multiplier);
|
||||
final int transfer = transferRecipe(firstGui, handler, recipeIndex, multiplier);
|
||||
|
||||
if (transfer <= 0) {
|
||||
break;
|
||||
@@ -112,43 +117,88 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
|
||||
multiplier -= transfer;
|
||||
|
||||
for (Slot slot : firstGui.inventorySlots.inventorySlots) {
|
||||
if (slot.getHasStack() && slot instanceof SlotCrafting && slot.canTakeStack(thePlayer)) {
|
||||
FastTransferManager.clickSlot(firstGui, slot.slotNumber, 0, 1);
|
||||
craft = true;
|
||||
break;
|
||||
}
|
||||
if (craftingSlot.getHasStack() && craftingSlot.canTakeStack(firstGui.mc.thePlayer)) {
|
||||
FastTransferManager.clickSlot(firstGui, craftingSlot.slotNumber, 0, 1);
|
||||
craft = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
clearIngredients(firstGui);
|
||||
clearIngredients(firstGui, handler);
|
||||
|
||||
return craft;
|
||||
}
|
||||
|
||||
private boolean clearIngredients(GuiContainer gui) {
|
||||
final EntityClientPlayerMP thePlayer = NEIClientUtils.mc().thePlayer;
|
||||
protected boolean clearIngredients(GuiContainer gui, IRecipeHandler handler) {
|
||||
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
if (slot.getHasStack() && !canMoveFrom(slot, gui)
|
||||
&& !(slot instanceof SlotCrafting)
|
||||
&& slot.canTakeStack(thePlayer)) {
|
||||
for (Slot slot : getCraftMatrixSlots(gui, handler)) {
|
||||
if (slot.canTakeStack(gui.mc.thePlayer)) {
|
||||
FastTransferManager.clickSlot(gui, slot.slotNumber, 0, 1);
|
||||
if (slot.getHasStack()) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return dropOffMouseStack(thePlayer, gui);
|
||||
FastTransferManager.dropHeldItem(gui);
|
||||
|
||||
return gui.mc.thePlayer.inventory.getItemStack() == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the slots in the crafting matrix for the given GUI and recipe handler.
|
||||
*
|
||||
* @param gui
|
||||
* @param handler
|
||||
* @return
|
||||
*/
|
||||
protected Set<Slot> getCraftMatrixSlots(GuiContainer gui, IRecipeHandler handler) {
|
||||
final PositionedStack firstIngr = handler.getIngredientStacks(0).get(0);
|
||||
final Map<Integer, Slot> grid = new HashMap<>();
|
||||
final Set<Slot> ingredSlots = new HashSet<>();
|
||||
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
final int key = (slot.xDisplayPosition - this.offsetx) * 10_000 + (slot.yDisplayPosition - this.offsety);
|
||||
grid.put(key, slot);
|
||||
}
|
||||
|
||||
int left = firstIngr.relx;
|
||||
int top = firstIngr.rely;
|
||||
int right = left;
|
||||
int bottom = top;
|
||||
|
||||
while (grid.containsKey((left - 18) * 10_000 + firstIngr.rely)) {
|
||||
left -= 18;
|
||||
}
|
||||
|
||||
while (grid.containsKey((right + 18) * 10_000 + firstIngr.rely)) {
|
||||
right += 18;
|
||||
}
|
||||
|
||||
while (grid.containsKey(firstIngr.relx * 10_000 + (top - 18))) {
|
||||
top -= 18;
|
||||
}
|
||||
|
||||
while (grid.containsKey(firstIngr.relx * 10_000 + (bottom + 18))) {
|
||||
bottom += 18;
|
||||
}
|
||||
|
||||
for (int x = left; x <= right; x += 18) {
|
||||
for (int y = top; y <= bottom; y += 18) {
|
||||
final Slot slot = grid.get(x * 10_000 + y);
|
||||
if (slot != null && !(slot.inventory instanceof InventoryPlayer)) {
|
||||
ingredSlots.add(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ingredSlots;
|
||||
}
|
||||
|
||||
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int multiplier) {
|
||||
final EntityClientPlayerMP thePlayer = NEIClientUtils.mc().thePlayer;
|
||||
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
if (slot instanceof SlotCrafting || !slot.getHasStack()
|
||||
|| !canMoveFrom(slot, gui)
|
||||
|| !slot.canTakeStack(thePlayer))
|
||||
|| !slot.canTakeStack(gui.mc.thePlayer))
|
||||
continue;
|
||||
ItemStack stack = slot.getStack();
|
||||
int slotTransferCap = stack.getMaxStackSize();
|
||||
@@ -186,7 +236,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
|
||||
}
|
||||
|
||||
if (thePlayer.inventory.getItemStack() != null) {
|
||||
if (gui.mc.thePlayer.inventory.getItemStack() != null) {
|
||||
FastTransferManager.clickSlot(gui, slot.slotNumber);
|
||||
}
|
||||
}
|
||||
@@ -194,33 +244,6 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -134,13 +134,6 @@ public class GuiRecipeCatalyst extends ScrollContainer {
|
||||
int index = 0;
|
||||
|
||||
for (PositionedStack pStack : this.items) {
|
||||
|
||||
if (pStack.items.length > 1) {
|
||||
final int stackIndex = (pStack.items.length + pStack.getPermutationIndex(pStack.item) + 1)
|
||||
% pStack.items.length;
|
||||
pStack.setPermutationToRender(stackIndex);
|
||||
}
|
||||
|
||||
pStack.relx = visibleWidth - SLOT_SIZE - (index / rows) * SLOT_SIZE;
|
||||
pStack.rely = (index % rows) * SLOT_SIZE;
|
||||
index++;
|
||||
|
||||
@@ -34,13 +34,12 @@ public class InformationHandler extends TemplateRecipeHandler {
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
CachedInfoPage page = (CachedInfoPage) this.arecipes.get(recipe);
|
||||
drawWrappedText(StatCollector.translateToLocal(page.getPage().info).replace("\\n", "\n"), 4, 24);
|
||||
final CachedInfoPage page = (CachedInfoPage) this.arecipes.get(recipe);
|
||||
drawWrappedText(page.getLines(), 4, 24);
|
||||
}
|
||||
|
||||
private void drawWrappedText(String text, int x, int y) {
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
List<String> lines = font.listFormattedStringToWidth(text, 156);
|
||||
private void drawWrappedText(List<String> lines, int x, int y) {
|
||||
final FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
for (String line : lines) {
|
||||
font.drawString(line, x, y, 0);
|
||||
y += 10;
|
||||
@@ -82,14 +81,23 @@ public class InformationHandler extends TemplateRecipeHandler {
|
||||
return "nei:textures/gui/recipebg.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeHeight(int recipe) {
|
||||
final CachedInfoPage page = (CachedInfoPage) this.arecipes.get(recipe);
|
||||
return 24 + page.getLines().size() * 10;
|
||||
}
|
||||
|
||||
private class CachedInfoPage extends CachedRecipe {
|
||||
|
||||
private final InformationPage page;
|
||||
private final PositionedStack stack;
|
||||
private final List<String> lines;
|
||||
|
||||
public CachedInfoPage(InformationPage page) {
|
||||
this.page = page;
|
||||
stack = new PositionedStack(page.items, 75, 2);
|
||||
final FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
final String info = StatCollector.translateToLocal(page.info).replace("\\n", "\n");
|
||||
|
||||
this.lines = font.listFormattedStringToWidth(info, 156);
|
||||
this.stack = new PositionedStack(page.items, 75, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,8 +110,8 @@ public class InformationHandler extends TemplateRecipeHandler {
|
||||
return Collections.singletonList(this.stack);
|
||||
}
|
||||
|
||||
public InformationPage getPage() {
|
||||
return page;
|
||||
public List<String> getLines() {
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -292,6 +292,7 @@ nei.options.inventory.guirecipe.cycledIngredientsTooltip=Cycled Ingredients Tool
|
||||
nei.options.inventory.guirecipe.cycledIngredientsTooltip.true=Show
|
||||
nei.options.inventory.guirecipe.cycledIngredientsTooltip.false=Hide
|
||||
nei.options.inventory.guirecipe.handlerInfo=Handler Info Widget
|
||||
nei.options.inventory.guirecipe.handlerInfo.tip=Use shift+d while in the Recipes GUI
|
||||
nei.options.inventory.guirecipe.handlerInfo.true=Enabled
|
||||
nei.options.inventory.guirecipe.handlerInfo.false=Disabled
|
||||
nei.options.inventory.guirecipe.maxHeight=Max Height
|
||||
|
||||
Reference in new issue
Block a user