Skip to content

Commit

Permalink
Merge branch 'fabric_1.19.x' into fabric_1.19_update
Browse files Browse the repository at this point in the history
  • Loading branch information
wendavid552 authored Nov 17, 2023
2 parents 7d9f311 + f06c789 commit d128a46
Show file tree
Hide file tree
Showing 13 changed files with 159 additions and 187 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Pull Request Builds

on: [pull_request]

jobs:
Build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- name: Grant execute permission to gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- uses: actions/upload-artifact@v3
with:
name: "Compiled artifacts for Pull Request #${{github.event.number}}"
path: build/libs
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ eclipse/
.classpath
.project
.idea
run/
.vscode
build.number
run/
.DS_Store
launch.json
21 changes: 9 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Thu Jan 14 08:33:00 EET 2016
org.gradle.configureondemand=true
org.gradle.jvmargs = -Xmx4G
org.gradle.daemon=true
org.gradle.parallel=true
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# mod information
# Thu Jan 14 08:33:00 EET 2016
group = fi.dy.masa
mod_id = itemscroller
mod_name = Item Scroller
Expand All @@ -15,12 +12,12 @@ mod_file_name = itemscroller-fabric
mod_version = craftaddon-1.0.0

# Required malilib version
malilib_version = 0.12.0
malilib_version = 0.14.0

# Minecraft, Fabric and mappings versions
minecraft_version_out = 1.18.2
minecraft_version = 1.18.2
mappings_version = 1.18.2+build.1
minecraft_version_out = 1.19.3
minecraft_version = 1.19.3
mappings_version = 1.19.3+build.2

fabric_loader_version = 0.14.14
mod_menu_version = 3.1.0
fabric_loader_version = 0.14.11
mod_menu_version = 5.0.1
8 changes: 3 additions & 5 deletions src/main/java/fi/dy/masa/itemscroller/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
import net.minecraft.screen.GrindstoneScreenHandler;
import net.minecraft.screen.StonecutterScreenHandler;
import net.minecraft.screen.slot.CraftingResultSlot;
import fi.dy.masa.itemscroller.Reference;
import fi.dy.masa.itemscroller.recipes.CraftingHandler;
import fi.dy.masa.itemscroller.recipes.CraftingHandler.SlotRange;
import fi.dy.masa.malilib.config.ConfigUtils;
import fi.dy.masa.malilib.config.IConfigHandler;
import fi.dy.masa.malilib.config.IConfigValue;
import fi.dy.masa.malilib.config.options.ConfigBoolean;
import fi.dy.masa.malilib.config.options.ConfigInteger;
import fi.dy.masa.malilib.util.FileUtils;
import fi.dy.masa.malilib.util.JsonUtils;
import fi.dy.masa.itemscroller.Reference;
import fi.dy.masa.itemscroller.recipes.CraftingHandler;
import fi.dy.masa.itemscroller.recipes.CraftingHandler.SlotRange;

public class Configs implements IConfigHandler
{
Expand All @@ -34,7 +34,6 @@ public static class Generic
public static final ConfigBoolean MOD_MAIN_TOGGLE = new ConfigBoolean("modMainToggle", true, "Can disable all the functionality of the entire mod");
public static final ConfigBoolean DROP_RECIPE_REMAINDER = new ConfigBoolean("dropRecipeRemainder", true, "If enabled, recipe remainders are dropped.");
public static final ConfigBoolean DROP_NON_RECIPE_ITEMS = new ConfigBoolean("dropNonRecipeItems", false, "If enabled, non recipe items in crafting grid are dropped.");
public static final ConfigInteger MASS_CRAFT_MULTIPLIER = new ConfigInteger("massCraftMultiplier", 1, 1, 50, "Specifies Masscraft operations per tick.\nKEEP IT AT 1 UNLESS YOU WANT TO CRASH CLIENT");
public static final ConfigInteger MASS_CRAFT_INTERVAL = new ConfigInteger("massCraftInterval", 1, 1, 60, "The interval in game ticks the massCraft operation is repeated at");
public static final ConfigBoolean SCROLL_CRAFT_STORE_RECIPES_TO_FILE = new ConfigBoolean("craftingRecipesSaveToFile", true, "If enabled, then the crafting features recipes are saved to a file\ninside minecraft/itemscroller/recipes_worldorservername.nbt.\nThis makes the recipes persistent across game restarts.");
public static final ConfigBoolean SCROLL_CRAFT_RECIPE_FILE_GLOBAL = new ConfigBoolean("craftingRecipesSaveFileIsGlobal", false, "If true, then the recipe file is global, instead\n of being saved per-world or server");
Expand All @@ -51,7 +50,6 @@ public static class Generic
MOD_MAIN_TOGGLE,
DROP_RECIPE_REMAINDER,
DROP_NON_RECIPE_ITEMS,
MASS_CRAFT_MULTIPLIER,
SCROLL_CRAFT_STORE_RECIPES_TO_FILE,
SCROLL_CRAFT_RECIPE_FILE_GLOBAL,
REVERSE_SCROLL_DIRECTION_SINGLE,
Expand Down
146 changes: 56 additions & 90 deletions src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
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;
import fi.dy.masa.malilib.gui.Message;
import fi.dy.masa.malilib.hotkeys.IHotkeyCallback;
import fi.dy.masa.malilib.hotkeys.IKeybind;
import fi.dy.masa.malilib.hotkeys.KeyAction;
import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage;
import fi.dy.masa.malilib.interfaces.IClientTickHandler;
import fi.dy.masa.malilib.util.GuiUtils;
import fi.dy.masa.malilib.util.InfoUtils;
import fi.dy.masa.itemscroller.ItemScroller;
import fi.dy.masa.itemscroller.config.Configs;
import fi.dy.masa.itemscroller.config.Hotkeys;
Expand All @@ -20,24 +30,13 @@
import fi.dy.masa.itemscroller.util.InputUtils;
import fi.dy.masa.itemscroller.util.InventoryUtils;
import fi.dy.masa.itemscroller.util.MoveAction;
import fi.dy.masa.malilib.config.options.ConfigHotkey;
import fi.dy.masa.malilib.gui.GuiBase;
import fi.dy.masa.malilib.gui.Message;
import fi.dy.masa.malilib.hotkeys.IHotkeyCallback;
import fi.dy.masa.malilib.hotkeys.IKeybind;
import fi.dy.masa.malilib.hotkeys.KeyAction;
import fi.dy.masa.malilib.interfaces.IClientTickHandler;
import fi.dy.masa.malilib.util.GuiUtils;
import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage;
import fi.dy.masa.malilib.util.InfoUtils;

public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
private static final KeybindCallbacks INSTANCE = new KeybindCallbacks();

protected int massCraftTicker;

public static KeybindCallbacks getInstance()
{
public static KeybindCallbacks getInstance() {
return INSTANCE;
}

Expand All @@ -53,8 +52,7 @@ public void setCallbacks() {
.setCallback(new KeyCallbackToggleBooleanConfigWithMessage(Configs.Generic.MASS_CRAFT_HOLD));
}

public boolean functionalityEnabled()
{
public boolean functionalityEnabled() {
return Configs.Generic.MOD_MAIN_TOGGLE.getBooleanValue();
}

Expand All @@ -71,23 +69,20 @@ private boolean onKeyActionImpl(KeyAction action, IKeybind key) {
return false;
}

if (key == Hotkeys.TOGGLE_MOD_ON_OFF.getKeybind())
{
if (key == Hotkeys.TOGGLE_MOD_ON_OFF.getKeybind()) {
Configs.Generic.MOD_MAIN_TOGGLE.toggleBooleanValue();
String msg = this.functionalityEnabled() ? "itemscroller.message.toggled_mod_on" : "itemscroller.message.toggled_mod_off";
String msg = this.functionalityEnabled() ? "itemscroller.message.toggled_mod_on"
: "itemscroller.message.toggled_mod_off";
InfoUtils.showGuiOrInGameMessage(Message.MessageType.INFO, msg);
return true;
}
else if (key == Hotkeys.OPEN_CONFIG_GUI.getKeybind())
{
} else if (key == Hotkeys.OPEN_CONFIG_GUI.getKeybind()) {
GuiBase.openGui(new GuiConfigs());
return true;
}

if (this.functionalityEnabled() == false ||
(GuiUtils.getCurrentScreen() instanceof HandledScreen) == false ||
Configs.GUI_BLACKLIST.contains(GuiUtils.getCurrentScreen().getClass().getName()))
{
(GuiUtils.getCurrentScreen() instanceof HandledScreen) == false ||
Configs.GUI_BLACKLIST.contains(GuiUtils.getCurrentScreen().getClass().getName())) {
return false;
}

Expand All @@ -101,55 +96,37 @@ else if (key == Hotkeys.OPEN_CONFIG_GUI.getKeybind())
final int mouseX = fi.dy.masa.malilib.util.InputUtils.getMouseX();
final int mouseY = fi.dy.masa.malilib.util.InputUtils.getMouseY();
return InventoryUtils.dragMoveItems(gui, moveAction, mouseX, mouseY, true);
}
else if (key == Hotkeys.KEY_MOVE_EVERYTHING.getKeybind())
{
} else if (key == Hotkeys.KEY_MOVE_EVERYTHING.getKeybind()) {
InventoryUtils.tryMoveStacks(slot, gui, false, true, false);
return true;
}
else if (key == Hotkeys.DROP_ALL_MATCHING.getKeybind())
{
} else if (key == Hotkeys.DROP_ALL_MATCHING.getKeybind()) {
if (Configs.Toggles.DROP_MATCHING.getBooleanValue() &&
Configs.GUI_BLACKLIST.contains(gui.getClass().getName()) == false &&
slot.hasStack())
{
Configs.GUI_BLACKLIST.contains(gui.getClass().getName()) == false &&
slot.hasStack()) {
InventoryUtils.dropStacks(gui, slot.getStack(), slot, true);
return true;
}
}
}

if (key == Hotkeys.CRAFT_EVERYTHING.getKeybind())
{
if (key == Hotkeys.CRAFT_EVERYTHING.getKeybind()) {
InventoryUtils.craftEverythingPossibleWithCurrentRecipe(recipes.getSelectedRecipe(), gui);
return true;
}
else if (key == Hotkeys.THROW_CRAFT_RESULTS.getKeybind())
{
} else if (key == Hotkeys.THROW_CRAFT_RESULTS.getKeybind()) {
InventoryUtils.throwAllCraftingResultsToGround(recipes.getSelectedRecipe(), gui);
return true;
}
else if (key == Hotkeys.MOVE_CRAFT_RESULTS.getKeybind())
{
} else if (key == Hotkeys.MOVE_CRAFT_RESULTS.getKeybind()) {
InventoryUtils.moveAllCraftingResultsToOtherInventory(recipes.getSelectedRecipe(), gui);
return true;
}
else if (key == Hotkeys.STORE_RECIPE.getKeybind())
{
if (InputUtils.isRecipeViewOpen() && InventoryUtils.isCraftingSlot(gui, slot))
{
} else if (key == Hotkeys.STORE_RECIPE.getKeybind()) {
if (InputUtils.isRecipeViewOpen() && InventoryUtils.isCraftingSlot(gui, slot)) {
recipes.storeCraftingRecipeToCurrentSelection(slot, gui, true);
return true;
}
}
else if (key == Hotkeys.VILLAGER_TRADE_FAVORITES.getKeybind())
{
} else if (key == Hotkeys.VILLAGER_TRADE_FAVORITES.getKeybind()) {
return InventoryUtils.villagerTradeEverythingPossibleWithAllFavoritedTrades();
}
else if (key == Hotkeys.SLOT_DEBUG.getKeybind())
{
if (slot != null)
{
} else if (key == Hotkeys.SLOT_DEBUG.getKeybind()) {
if (slot != null) {
InventoryUtils.debugPrintSlotInfo(gui, slot);
} else {
ItemScroller.logger.info("GUI class: {}", gui.getClass().getName());
Expand All @@ -162,10 +139,8 @@ else if (key == Hotkeys.SLOT_DEBUG.getKeybind())
}

@Override
public void onClientTick(MinecraftClient mc)
{
if (this.functionalityEnabled() == false || mc.player == null)
{
public void onClientTick(MinecraftClient mc) {
if (this.functionalityEnabled() == false || mc.player == null) {
return;
}

Expand All @@ -175,53 +150,44 @@ public void onClientTick(MinecraftClient mc)
&& (Hotkeys.MASS_CRAFT.getKeybind().isKeybindHeld()
|| Configs.Generic.MASS_CRAFT_HOLD.getBooleanValue())) {

if (++this.massCraftTicker < Configs.Generic.MASS_CRAFT_INTERVAL.getIntegerValue())
{
if (++this.massCraftTicker < Configs.Generic.MASS_CRAFT_INTERVAL.getIntegerValue()) {
return;
}


Screen guiScreen = GuiUtils.getCurrentScreen();
HandledScreen<?> gui = (HandledScreen<?>) guiScreen;
Slot outputSlot = CraftingHandler.getFirstCraftingOutputSlotForGui(gui);

if (outputSlot != null) {
for (int j = 0; j < Configs.Generic.MASS_CRAFT_MULTIPLIER.getIntegerValue(); j++) {
RecipePattern recipe = RecipeStorage.getInstance().getSelectedRecipe();

CraftingRecipe bookRecipe = InventoryUtils.getBookRecipeFromPattern(recipe);
if (!(gui instanceof StonecutterScreen) && bookRecipe != null && !bookRecipe.isIgnoredInRecipeBook()) { // Use recipe book if possible
// System.out.println("recipe");
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);
RecipePattern recipe = RecipeStorage.getInstance().getSelectedRecipe();

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

if(recipe.getResult().isStackable()) {
for (int i = 0; i < recipe.getMaxCraftAmount(); i++) {
InventoryUtils.dropStack(gui, outputSlot.id);
}
}
else {
InventoryUtils.dropItem(gui, outputSlot.id);
} 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);
}
}

InventoryUtils.tryClearCursor(gui);
InventoryUtils.throwAllCraftingResultsToGround(recipe, gui);
for (int i = 0; i < recipe.getMaxCraftAmount(); i++) {
InventoryUtils.dropStack(gui, outputSlot.id);
}

InventoryUtils.tryClearCursor(gui);
InventoryUtils.throwAllCraftingResultsToGround(recipe, gui);
}

this.massCraftTicker = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import fi.dy.masa.malilib.render.InventoryOverlay;
import fi.dy.masa.malilib.render.RenderUtils;
import fi.dy.masa.malilib.util.GuiUtils;
import fi.dy.masa.malilib.util.StringUtils;
import fi.dy.masa.itemscroller.config.Configs;
import fi.dy.masa.itemscroller.recipes.RecipePattern;
import fi.dy.masa.itemscroller.recipes.RecipeStorage;
import fi.dy.masa.itemscroller.util.AccessorUtils;
import fi.dy.masa.itemscroller.util.InputUtils;
import fi.dy.masa.itemscroller.util.InventoryUtils;
import fi.dy.masa.malilib.render.InventoryOverlay;
import fi.dy.masa.malilib.render.RenderUtils;
import fi.dy.masa.malilib.util.GuiUtils;
import fi.dy.masa.malilib.util.StringUtils;

public class RenderEventHandler
{
Expand All @@ -39,7 +39,7 @@ public static RenderEventHandler instance()
return INSTANCE;
}

public void onDrawBackgroundPost(MatrixStack matrixStack)
public void renderRecipeView()
{
if (GuiUtils.getCurrentScreen() instanceof HandledScreen && InputUtils.isRecipeViewOpen())
{
Expand All @@ -51,7 +51,7 @@ public void onDrawBackgroundPost(MatrixStack matrixStack)

this.calculateRecipePositions(gui);

matrixStack = RenderSystem.getModelViewStack();
MatrixStack matrixStack = RenderSystem.getModelViewStack();
matrixStack.push();
matrixStack.translate(this.recipeListX, this.recipeListY, 0);
matrixStack.scale((float) this.scale, (float) this.scale, 1);
Expand Down Expand Up @@ -88,6 +88,8 @@ public void onDrawBackgroundPost(MatrixStack matrixStack)

public void onDrawScreenPost(MinecraftClient mc)
{
this.renderRecipeView();

if (GuiUtils.getCurrentScreen() instanceof HandledScreen)
{
HandledScreen<?> gui = (HandledScreen<?>) this.mc.currentScreen;
Expand Down
Loading

0 comments on commit d128a46

Please sign in to comment.