Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync updates #3

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f1550f4
feature: Add grindstone as possible crafting screen
wendavid552 Feb 20, 2023
33972ef
Create devbuild.yml
wendavid552 Feb 20, 2023
9fcc4ec
Rename .github/workflow/devbuild.yml to .github/workflows/devbuild.yml
wendavid552 Feb 20, 2023
9ce2529
perf: caching graadle files with enlarging memory
wendavid552 Feb 20, 2023
b655f90
build: fix path issues of artifact files
wendavid552 Feb 20, 2023
c40a3c6
build: try bump versions
wendavid552 Feb 20, 2023
4645053
fix: rendering recipes could be out of index
wendavid552 Feb 21, 2023
fcf882e
feature$build: add a trigger on the build workflow
wendavid552 Feb 21, 2023
1040d9d
build: change name of uploaded artifact
wendavid552 Feb 21, 2023
96e5f52
build: change name of uploaded artifact
wendavid552 Feb 21, 2023
c240c3c
fix(mismatch of class name of slots of anvils and grindstone):
wendavid552 Feb 21, 2023
4a29486
perf(build): use more efficent gradle build options to accelerate th…
wendavid552 Feb 22, 2023
b1713af
feature: Keep renaming for a bunch of items on anvil
wendavid552 Feb 22, 2023
dc8e700
Merge pull request #5 from wendavid552/fabric_1.18.x_dev
wendavid552 Feb 23, 2023
f06b6bf
fix: overstacked enchantment books could be mass craft now
wendavid552 Feb 23, 2023
20eb3d1
Merge pull request #6 from wendavid552/fabric_1.18.x_dev
wendavid552 Feb 23, 2023
36ac08f
feature: massCraft now would leave at least a stack of recipe items f…
wendavid552 Feb 23, 2023
268d9d1
feature: massCraft now would leave at least a stack of recipe items f…
wendavid552 Feb 23, 2023
8ac47fd
fix: use recipe books to craft items in a more precise way
wendavid552 Feb 23, 2023
445d481
fix: issues of items distributed in multiple slots
wendavid552 Feb 23, 2023
8f2fa69
Merge pull request #7 from wendavid552/fabric_1.18.x_dev
wendavid552 Feb 23, 2023
5ddf34c
Merge pull request #1 from wendavid552/fabric_1.18.x
wendavid552 Feb 23, 2023
245db43
feature: Add stonecutter as available crafting gui
wendavid552 Feb 23, 2023
a1b95c8
fix: confusing between some book and stonecutting recipes
wendavid552 Feb 23, 2023
e912543
Merge pull request #8 from wendavid552/fabric_1.18.x_dev
wendavid552 Feb 23, 2023
291b7fc
feature: Add config button for reservedCrafting
wendavid552 Feb 23, 2023
faba65c
feature: craftEveryThing is now available for stonecutter
wendavid552 Feb 23, 2023
1215601
perf: move attempts to search for recipes of stonecutters into more s…
wendavid552 Feb 23, 2023
67f3cbf
Merge pull request #9 from wendavid552/fabric_1.18.x_dev
wendavid552 Feb 23, 2023
f34c05c
docs: Add documentation of changes
wendavid552 Feb 23, 2023
e4f3f90
build: add ci for release
wendavid552 Feb 23, 2023
3dba299
Merge pull request #10 from wendavid552/fabric_1.18.x_dev
wendavid552 Feb 23, 2023
9fcc168
Merge pull request #2 from wendavid552/fabric_1.18.x
wendavid552 Feb 23, 2023
7d9f311
Update release.yml
wendavid552 Feb 23, 2023
d128a46
Merge branch 'fabric_1.19.x' into fabric_1.19_update
wendavid552 Nov 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: step.build

on:
workflow_call:
inputs:
release:
type: boolean
required: false
default: false

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: "temurin"
java-version: 17

- name: Cache gradle files
uses: actions/[email protected]
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
./.gradle/loom-cache
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle.properties', '**/*.accesswidener') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew classes --parallel
./gradlew build
env:
BUILD_ID: ${{ github.run_number }}
BUILD_RELEASE: ${{ inputs.release }}

- uses: actions/[email protected]
with:
name: build-artifacts
path: build/libs/*
16 changes: 16 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Dev Builds

on:
push:
paths:
- "*.gradle"
- "gradle.properties"
- "src/**"
- "versions/**"
- ".github/**"
pull_request:
workflow_dispatch:

jobs:
build:
uses: ./.github/workflows/build.yml
104 changes: 104 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Release

on:
release:
types:
- published
workflow_dispatch:
inputs:
target_release_tag:
description: The tag of the release you want to append the artifact to
type: string
required: true


jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setmatrix.outputs.matrix }}
steps:
- uses: actions/[email protected]

- name: Display context
run: |
echo ref_name = ${{ github.ref_name }}
echo target_release_tag = ${{ github.event.inputs.target_release_tag }}

build:
uses: ./.github/workflows/build.yml
with:
release: true

release:
needs:
- build
- prepare
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
path: build-artifacts

- name: Get github release information
if: ${{ github.event_name == 'workflow_dispatch' }}
id: get_release
uses: cardinalby/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: ${{ github.event.inputs.target_release_tag }}

- name: Generate publish related infomation
id: release_info
run: |
if [ $GITHUB_EVENT_NAME == 'release' ]
then
echo "::set-output name=tag_name::" # leave an empty value here so softprops/action-gh-release will use the default value
elif [ $GITHUB_EVENT_NAME == 'workflow_dispatch' ]
then
echo "::set-output name=tag_name::${{ github.event.inputs.target_release_tag }}"
else
echo Unknown github event name $GITHUB_EVENT_NAME
exit 1
fi

- name: Read Properties mod_version
id: mod_version
uses: christian-draeger/[email protected]
with:
path: gradle.properties
property: mod_version

- name: Read Properties minecraft_version
id: minecraft_version
uses: christian-draeger/[email protected]
with:
path: gradle.properties
property: minecraft_version

- name: Publish Minecraft Mods
uses: Kir-Antipov/[email protected]
with:
github-tag: ${{ steps.release_info.outputs.tag_name }}
github-token: ${{ secrets.GITHUB_TOKEN }}

files-primary: ${{'build-artifacts/!(*-@(dev|sources)).jar'}}
files-secondary: ''

name: ${{ format('Itemscroller v {0} for mc{1}', steps.mod_version.outputs.value, steps.minecraft_version.outputs.value) }}
version: ${{ format('mc{0}-v{1}', steps.minecraft_version.outputs.value, steps.mod_version.outputs.value) }}
version-type: release
changelog: ${{ format('{0}{1}', github.event.release.body, steps.get_release.outputs.body) }} # one of them should be an empty string (null)

loaders: fabric
game-versions: ${{ matrix.game_versions }}
version-resolver: exact

retry-attempts: 3
retry-delay: 10000
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ build/
eclipse/
.classpath
.project
.idea
run/
.vscode
build.number
run/
.DS_Store
launch.json
launch.json
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
## Note
This is a customized version of Masa's itemscroller mod that fixes crafting features for 1.18. Masa's original mod can be found [here](https://github.com/maruohon/itemscroller)
This is a customized version of Andrew54757's itemscroller-crafting-fix, which is a customized version of Masa's itemscroller mod that fixes crafting features for 1.18.

Customizations:
* More accurate/faster crafting through recipe book protocol
* Toggleable crafting (so you can keep crafting without holding down a key, eg for crafting millions of pistons)
* Honey crafting
Masa's original mod can be found [here](https://github.com/maruohon/itemscroller)

- Removed carpetControlQ crafting option as it causes a "slow crafting issue"
- Removed packetRateLimit as it may lead to problems.
Andrew54757's mod can be found [here](https://github.com/Andrews54757/itemscroller-crafting-fix)

## This is not Masa's original itemscroller. If you have issues with this mod, please contact Andrews54757 (or open a bug report here).
Customizations:
Beside the customizations offered by crafting-fix, we also provide some features that are not present in the original mod:
* Apply crafting features over anvil, grindstone(could help with building overstacked items), stonecutter.
* Renaming multiple items automatically over anvil
* `reserveCrafting` to make it possible to pick up every kind of recipe items after each crafting

### What's different?
Post 1.13, Mojang has changed the crafting mechanics of the game. Before 1.13, crafting was very fast as much of the logic was handled client-side. In 1.13, most of the crafting logic was moved to the server. This broke Itemscroller's fast crafting features, since every ingredient now had to be moved one slot at a time to the crafting grid for it to work. This drastically worsened server-client desync, a compounding problem, leading to an increasing number of failed crafting attempts and accidental ingredient leaks which made afk crafting impossible.
- Fix rendering bug when recipes do not have the length of a square number

This customized version of the mod, fixes the problem by handling ingredient movement server-side using the recipe book protocols when it can.
除crafting-fix提供的功能外,还提供以下功能:
* 可以在铁砧/砂轮(可用于合成堆叠附魔书等)/切石机上使用快速合成功能
* 可以在铁砧上批量重命名物品,只需快速合成前在铁砧上预先写好名字并调用对应的快速合成功能即可,注意仅能用于`合成而不扔出`
* `reserveCrafting` 选项可以在合成后保留物品栏中合成材料的槽位,无论地上合成材料扔出的顺序,总有物品栏位置能从地上捡起合成材料

**Note: Some recipes like fireworks rockets that are not in the recipe book do not take advantage of this protocol, in those cases old itemscroller methods will be used**
## This is not Masa's original itemscroller. If you have issues with this mod, please contact WenDavid552 (or open a bug report here).

Item Scroller
==============
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ author = masa
mod_file_name = itemscroller-fabric

# Current mod version
mod_version = craftfix-1.2.6
mod_version = craftaddon-1.0.0

# Required malilib version
malilib_version = 0.14.0
Expand All @@ -20,4 +20,4 @@ minecraft_version = 1.19.3
mappings_version = 1.19.3+build.2

fabric_loader_version = 0.14.11
mod_menu_version = 5.0.1
mod_menu_version = 5.0.1
16 changes: 13 additions & 3 deletions src/main/java/fi/dy/masa/itemscroller/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.client.gui.screen.ingame.CraftingScreen;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.gui.screen.ingame.*;
import net.minecraft.screen.ForgingScreenHandler;
import net.minecraft.screen.GrindstoneScreenHandler;
import net.minecraft.screen.StonecutterScreenHandler;
import net.minecraft.screen.slot.CraftingResultSlot;
import fi.dy.masa.malilib.config.ConfigUtils;
import fi.dy.masa.malilib.config.IConfigHandler;
Expand Down Expand Up @@ -61,6 +63,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 @@ -75,6 +78,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 Expand Up @@ -119,6 +123,12 @@ public static void loadFromFile()
CraftingHandler.addCraftingGridDefinition(CraftingScreen.class.getName(), CraftingResultSlot.class.getName(), 0, new SlotRange(1, 9));
//"net.minecraft.client.gui.inventory.PlayerInventoryScreen,net.minecraft.inventory.SlotCrafting,0,1-4", // vanilla player inventory crafting grid
CraftingHandler.addCraftingGridDefinition(InventoryScreen.class.getName(), CraftingResultSlot.class.getName(), 0, new SlotRange(1, 4));
// vanilla anvil
CraftingHandler.addCraftingGridDefinition(AnvilScreen.class.getName(), ForgingScreenHandler.class.getName()+"$2", 2, new SlotRange(0, 2));
// vanilla grindstone
CraftingHandler.addCraftingGridDefinition(GrindstoneScreen.class.getName(), GrindstoneScreenHandler.class.getName()+"$4", 2, new SlotRange(0, 2));
// vanilla stonecutter
CraftingHandler.addCraftingGridDefinition(StonecutterScreen.class.getName(), StonecutterScreenHandler.class.getName()+"$2", 1, new SlotRange(0, 1));
}

public static void saveToFile()
Expand Down Expand Up @@ -170,7 +180,7 @@ private static void getStrings(JsonObject obj, Set<String> outputSet, String arr

private static void writeStrings(JsonObject obj, Set<String> inputSet, String arrayName)
{
if (inputSet.isEmpty() == false)
if (!inputSet.isEmpty())
{
JsonArray arr = new JsonArray();

Expand Down
19 changes: 17 additions & 2 deletions src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.StonecutterScreen;
import net.minecraft.recipe.CraftingRecipe;
import net.minecraft.recipe.StonecuttingRecipe;
import net.minecraft.screen.StonecutterScreenHandler;
import net.minecraft.screen.slot.Slot;
import fi.dy.masa.malilib.config.options.ConfigHotkey;
import fi.dy.masa.malilib.gui.GuiBase;
Expand Down Expand Up @@ -159,12 +162,24 @@ public void onClientTick(MinecraftClient mc) {
RecipePattern recipe = RecipeStorage.getInstance().getSelectedRecipe();

CraftingRecipe bookRecipe = InventoryUtils.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
// System.out.println("recipe");
mc.interactionManager.clickRecipe(gui.getScreenHandler().syncId, bookRecipe, true);
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 {
// System.out.println("move");
InventoryUtils.tryMoveItemsToFirstCraftingGrid(recipe, gui, true);
int stonecuttingRecipeIndex = InventoryUtils.getStonecuttingRecipeFromPattern(recipe);
if(stonecuttingRecipeIndex != -1 && gui instanceof StonecutterScreen) {
mc.interactionManager.clickButton((gui.getScreenHandler()).syncId, stonecuttingRecipeIndex);
}
}

for (int i = 0; i < recipe.getMaxCraftAmount(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private void renderRecipeItems(RecipePattern recipe, int recipeCountPerPage, Han

for (int i = 0, row = 0; row < recipeDimensions; row++)
{
for (int col = 0; col < recipeDimensions; col++, i++)
for (int col = 0; col < recipeDimensions && i < recipe.getRecipeLength(); col++, i++)
{
int xOff = col * 17;
int yOff = row * 17;
Expand All @@ -257,7 +257,7 @@ private ItemStack getHoveredRecipeIngredient(int mouseX, int mouseY, RecipePatte
{
for (int i = 0, row = 0; row < recipeDimensions; row++)
{
for (int col = 0; col < recipeDimensions; col++, i++)
for (int col = 0; col < recipeDimensions && i < recipe.getRecipeLength(); col++, i++)
{
int xOff = col * scaledGridEntry;
int yOff = row * scaledGridEntry;
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/fi/dy/masa/itemscroller/mixin/IMixinAnvilScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package fi.dy.masa.itemscroller.mixin;

import net.minecraft.client.gui.screen.ingame.AnvilScreen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;

import java.awt.*;

@Mixin(AnvilScreen.class)
public interface IMixinAnvilScreen {
@Invoker("onRenamed")
void itemscroller_setItemName(String newName);

@Accessor("nameField")
TextFieldWidget itemscroller_getNameField();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.recipe.CraftingRecipe;
import net.minecraft.recipe.StonecuttingRecipe;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import fi.dy.masa.itemscroller.recipes.CraftingHandler.SlotRange;
Expand All @@ -20,6 +21,8 @@ public class RecipePattern
private ItemStack result = InventoryUtils.EMPTY_STACK;
private ItemStack[] recipe = new ItemStack[9];
public CraftingRecipe cachedRecipeFromBook = null;

public int cachedRecipeFromStonecutting = -1;
private int maxCraftAmount = 64;
private HashSet<Item> recipeRemainders = new HashSet<Item>();

Expand Down
Loading
Loading