Skip to content

Commit

Permalink
Merge pull request #9 from wendavid552/fabric_1.18.x_dev
Browse files Browse the repository at this point in the history
reservedCrafting模式开关与切石机合成完善
  • Loading branch information
wendavid552 authored Feb 23, 2023
2 parents e912543 + 1215601 commit 67f3cbf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/main/java/fi/dy/masa/itemscroller/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public static class Generic
public static class Toggles
{
public static final ConfigBoolean CRAFTING_FEATURES = new ConfigBoolean("enableCraftingFeatures", true, "Enables scrolling items to and from crafting grids,\nwith a built-in 18 recipe memory.\nHold down the Recipe key to see the stored recipes and\nto change the selection. While holding the Recipe key,\nyou can either scroll or press a number key to change the selection.\nA recipe is stored to the currently selected \"recipe slot\"\n by clicking pick block over a configured crafting output slot.\nThe supported crafting grids must be added to the scrollableCraftingGrids list.");
public static final ConfigBoolean RESERVED_CRAFTING = new ConfigBoolean("enableReservedCrafting", false, "Enables to reserve slots of items of recipes in inventory,\nso items on the ground could be picked up for further crafting");
public static final ConfigBoolean DROP_MATCHING = new ConfigBoolean("enableDropkeyDropMatching", true, "Enables dropping all matching items from the same\ninventory with the hotkey");
public static final ConfigBoolean RIGHT_CLICK_CRAFT_STACK = new ConfigBoolean("enableRightClickCraftingOneStack", true, "Enables crafting up to one full stack when right clicking on\na slot that has been configured as a crafting output slot.");
public static final ConfigBoolean SCROLL_EVERYTHING = new ConfigBoolean("enableScrollingEverything", true, "Enables scroll moving all items at once while\nholding the modifierMoveEverything keybind");
Expand All @@ -79,6 +80,7 @@ public static class Toggles

public static final ImmutableList<IConfigValue> OPTIONS = ImmutableList.of(
CRAFTING_FEATURES,
RESERVED_CRAFTING,
DROP_MATCHING,
RIGHT_CLICK_CRAFT_STACK,
SCROLL_EVERYTHING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,21 @@ public void onClientTick(MinecraftClient mc)
RecipePattern recipe = RecipeStorage.getInstance().getSelectedRecipe();

CraftingRecipe bookRecipe = InventoryUtils.getBookRecipeFromPattern(recipe);
int stonecuttingRecipeIndex = InventoryUtils.getStonecuttingRecipeFromPattern(recipe);
if (!(gui instanceof StonecutterScreen) && bookRecipe != null && !bookRecipe.isIgnoredInRecipeBook()) { // Use recipe book if possible
// System.out.println("recipe");
int option = InventoryUtils.checkRecipeEnough(recipe, gui);
if(option > 0) {
mc.interactionManager.clickRecipe(gui.getScreenHandler().syncId, bookRecipe, option > 1);
if(Configs.Toggles.RESERVED_CRAFTING.getBooleanValue()) {
int option = InventoryUtils.checkRecipeEnough(recipe, gui);
if (option > 0) {
mc.interactionManager.clickRecipe(gui.getScreenHandler().syncId, bookRecipe, option > 1);
}
}
else{
mc.interactionManager.clickRecipe(gui.getScreenHandler().syncId, bookRecipe, true);
}
}
else {
InventoryUtils.tryMoveItemsToFirstCraftingGrid(recipe, gui, true);
int stonecuttingRecipeIndex = InventoryUtils.getStonecuttingRecipeFromPattern(recipe);
if(stonecuttingRecipeIndex != -1 && gui instanceof StonecutterScreen) {
mc.interactionManager.clickButton((gui.getScreenHandler()).syncId, stonecuttingRecipeIndex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ public static void craftEverythingPossibleWithCurrentRecipe(RecipePattern recipe
String cacheName = null;
for (int i = 0; i < 36; i++) {
CraftingRecipe bookRecipe = getBookRecipeFromPattern(recipe);
if (bookRecipe != null && !bookRecipe.isIgnoredInRecipeBook()) { // Use recipe book if possible
if (!(gui instanceof StonecutterScreen) && bookRecipe != null && !bookRecipe.isIgnoredInRecipeBook()) { // Use recipe book if possible
MinecraftClient mc = MinecraftClient.getInstance();
mc.interactionManager.clickRecipe(gui.getScreenHandler().syncId, bookRecipe, true);
} else {
Expand All @@ -1390,6 +1390,12 @@ public static void craftEverythingPossibleWithCurrentRecipe(RecipePattern recipe
}

tryMoveItemsToCraftingGridSlots(recipe, slot, gui, true);

int stonecuttingRecipeIndex = InventoryUtils.getStonecuttingRecipeFromPattern(recipe);
if(stonecuttingRecipeIndex != -1 && gui instanceof StonecutterScreen) {
MinecraftClient mc = MinecraftClient.getInstance();
mc.interactionManager.clickButton((gui.getScreenHandler()).syncId, stonecuttingRecipeIndex);
}
}
if(!StringUtils.isBlank(cacheName) && gui instanceof AnvilScreen) {
((IMixinAnvilScreen)gui).itemscroller_setItemName(cacheName);
Expand Down

0 comments on commit 67f3cbf

Please sign in to comment.