Skip to content

Commit

Permalink
sync with sakura-ryoko/itemscroller 1.21-0.24.51
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Nov 8, 2024
1 parent 1fce49d commit 2b29f32
Show file tree
Hide file tree
Showing 20 changed files with 874 additions and 62 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
## Change
- sync with `sakura-ryoko/itemscroller` 1.21-sakura.8
- sync with `sakura-ryoko/itemscroller` 1.21-0.24.51
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mappings_patch="1.21+build.4"
neoforge="21.1.31"

# Mod properties
version="0.1.8"
version="0.1.9"
maven-group="org.thinkingstudio.rocknroller"
archives-name="RocknRoller"

Expand All @@ -15,14 +15,14 @@ id-modrinth="hYq29QmW"
id-curseforge="916852"

# Mod dependencies
mafglib="0.1.22-mc1.21.1"
mafglib="0.1.24-mc1.21.1"
badpackets="neo-0.8.1"

# Libraries
jsr305="3.0.2"

# Gradle plugin
architectury-loom = "1.6-SNAPSHOT"
architectury-loom = "1.7-SNAPSHOT"
modpublisher = "2.+"

[libraries]
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions src/main/java/fi/dy/masa/itemscroller/Reference.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package fi.dy.masa.itemscroller;

import net.minecraft.MinecraftVersion;

import fi.dy.masa.malilib.util.StringUtils;

public class Reference
{
public static final String ID = "itemscroller";
public static final String MOD_ID = "rocknroller";
public static final String MOD_NAME = "Rock'n Roller";
public static final String MOD_VERSION = StringUtils.getModVersionString(MOD_ID);
public static final String MC_VERSION = MinecraftVersion.CURRENT.getName();
public static final String MOD_TYPE = "neoforge";
public static final String MOD_STRING = MOD_ID + "-" + MOD_TYPE + "-" + MC_VERSION + "-" + MOD_VERSION;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package fi.dy.masa.itemscroller.compat.modmenu;

import fi.dy.masa.itemscroller.gui.GuiConfigs;
import org.thinkingstudio.mafglib.loader.gui.ModConfigScreenFactory;
import org.thinkingstudio.mafglib.loader.gui.ModConfigScreenInitializer;

public class ModMenuImpl implements ModConfigScreenInitializer
{
@Override
public ModConfigScreenFactory getModConfigScreenFactory()
{
return (modContainer, screen) -> {
GuiConfigs gui = new GuiConfigs();
gui.setParent(screen);
return gui;
};
}
}
33 changes: 28 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 @@ -11,6 +11,7 @@
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.screen.slot.CraftingResultSlot;
import fi.dy.masa.malilib.config.ConfigUtils;
import fi.dy.masa.malilib.config.IConfigBase;
import fi.dy.masa.malilib.config.IConfigHandler;
import fi.dy.masa.malilib.config.IConfigValue;
import fi.dy.masa.malilib.config.options.*;
Expand All @@ -19,17 +20,22 @@
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.itemscroller.util.SortingCategory;
import fi.dy.masa.itemscroller.util.SortingMethod;

public class Configs implements IConfigHandler
{
private static final String CONFIG_FILE_NAME = Reference.MOD_ID + ".json";

private static final ImmutableList<String> DEFAULT_TOP_SORTING = ImmutableList.of("minecraft:diamond_sword","minecraft:diamond_pickaxe","minecraft:diamond_axe","minecraft:diamond_shovel","minecraft:diamond_hoe","minecraft:netherite_sword","minecraft:netherite_pickaxe","minecraft:netherite_axe","minecraft:netherite_shovel","minecraft:netherite_hoe");
private static final ImmutableList<String> DEFAULT_BOTTOM_SORTING = ImmutableList.of();

public static class Generic
{
public static final ConfigBoolean CARPET_CTRL_Q_CRAFTING = new ConfigBoolean("carpetCtrlQCraftingEnabledOnServer", false, "itemscroller.config.generic.comment.carpetCtrlQCraftingEnabledOnServer").translatedName("itemscroller.config.generic.name.carpetCtrlQCraftingEnabledOnServer");
public static final ConfigBoolean CLIENT_CRAFTING_FIX = new ConfigBoolean("clientCraftingFixOn1.12", true, "itemscroller.config.generic.comment.clientCraftingFixOn1_12").translatedName("itemscroller.config.generic.name.clientCraftingFixOn1_12");
public static final ConfigBoolean CRAFTING_RENDER_RECIPE_ITEMS = new ConfigBoolean("craftingRenderRecipeItems", true, "itemscroller.config.generic.comment.craftingRenderRecipeItems").translatedName("itemscroller.config.generic.name.craftingRenderRecipeItems");
//public static final ConfigBoolean DEBUG_MESSAGES = new ConfigBoolean("debugMessages", false, "itemscroller.config.generic.comment.debugMessages").translatedName("itemscroller.config.generic.name.debugMessages");
public static final ConfigBoolean DEBUG_MESSAGES = new ConfigBoolean("debugMessages", false, "itemscroller.config.generic.comment.debugMessages").translatedName("itemscroller.config.generic.name.debugMessages");
public static final ConfigBoolean MOD_MAIN_TOGGLE = new ConfigBoolean("modMainToggle", true, "itemscroller.config.generic.comment.modMainToggle").translatedName("itemscroller.config.generic.name.modMainToggle");
public static final ConfigBoolean MASS_CRAFT_INHIBIT_MID_UPDATES = new ConfigBoolean("massCraftInhibitMidUpdates", true, "itemscroller.config.generic.comment.massCraftInhibitMidUpdates").translatedName("itemscroller.config.generic.name.massCraftInhibitMidUpdates");
public static final ConfigInteger MASS_CRAFT_INTERVAL = new ConfigInteger("massCraftInterval", 2, 1, 60, "itemscroller.config.generic.comment.massCraftInterval").translatedName("itemscroller.config.generic.name.massCraftInterval");
Expand All @@ -46,14 +52,23 @@ public static class Generic
public static final ConfigBoolean SLOT_POSITION_AWARE_SCROLL_DIRECTION = new ConfigBoolean("useSlotPositionAwareScrollDirection", false, "itemscroller.config.generic.comment.useSlotPositionAwareScrollDirection").translatedName("itemscroller.config.generic.name.useSlotPositionAwareScrollDirection");
public static final ConfigBoolean VILLAGER_TRADE_USE_GLOBAL_FAVORITES = new ConfigBoolean("villagerTradeUseGlobalFavorites", true, "itemscroller.config.generic.comment.villagerTradeUseGlobalFavorites").translatedName("itemscroller.config.generic.name.villagerTradeUseGlobalFavorites");
public static final ConfigBoolean VILLAGER_TRADE_LIST_REMEMBER_SCROLL = new ConfigBoolean("villagerTradeListRememberScrollPosition", true, "itemscroller.config.generic.comment.villagerTradeListRememberScrollPosition").translatedName("itemscroller.config.generic.name.villagerTradeListRememberScrollPosition");

public static final ConfigBoolean SORT_INVENTORY_TOGGLE = new ConfigBoolean("sortInventoryToggle", false, "itemscroller.config.generic.comment.sortInventoryToggle").translatedName("itemscroller.config.generic.name.sortInventoryToggle");
public static final ConfigBoolean SORT_ASSUME_EMPTY_BOX_STACKS = new ConfigBoolean("sortAssumeEmptyBoxStacks", true, "itemscroller.config.generic.comment.sortAssumeEmptyBoxStacks").translatedName("itemscroller.config.generic.name.sortAssumeEmptyBoxStacks");
public static final ConfigBoolean SORT_SHULKER_BOXES_AT_END = new ConfigBoolean("sortShulkerBoxesAtEnd", true, "itemscroller.config.generic.comment.sortShulkerBoxesAtEnd").translatedName("itemscroller.config.generic.name.sortShulkerBoxesAtEnd");

public static final ImmutableList<IConfigValue> OPTIONS = ImmutableList.of(
public static final ConfigBoolean SORT_SHULKER_BOXES_INVERTED = new ConfigBoolean("sortShulkerBoxesInverted", false, "itemscroller.config.generic.comment.sortShulkerBoxesInverted").translatedName("itemscroller.config.generic.name.sortShulkerBoxesInverted");
public static final ConfigBoolean SORT_BUNDLES_AT_END = new ConfigBoolean("sortBundlesAtEnd", true, "itemscroller.config.generic.comment.sortBundlesAtEnd").translatedName("itemscroller.config.generic.name.sortBundlesAtEnd");
public static final ConfigBoolean SORT_BUNDLES_INVERTED = new ConfigBoolean("sortBundlesInverted", false, "itemscroller.config.generic.comment.sortBundlesInverted").translatedName("itemscroller.config.generic.name.sortBundlesInverted");
public static final ConfigStringList SORT_TOP_PRIORITY_INVENTORY = new ConfigStringList("sortTopPriorityInventory", DEFAULT_TOP_SORTING, "itemscroller.config.generic.comment.sortTopPriorityInventory").translatedName("itemscroller.config.generic.name.sortTopPriorityInventory");
public static final ConfigStringList SORT_BOTTOM_PRIORITY_INVENTORY = new ConfigStringList("sortBottomPriorityInventory", DEFAULT_BOTTOM_SORTING, "itemscroller.config.generic.comment.sortBottomPriorityInventory").translatedName("itemscroller.config.generic.name.sortBottomPriorityInventory");
public static final ConfigOptionList SORT_METHOD_DEFAULT = new ConfigOptionList("sortMethodDefault", SortingMethod.CATEGORY_NAME, "itemscroller.config.generic.comment.sortMethodDefault").translatedName("itemscroller.config.generic.name.sortMethodDefault");
public static final ConfigLockedList SORT_CATEGORY_ORDER = new ConfigLockedList("sortCategoryOrder", SortingCategory.INSTANCE, "itemscroller.config.generic.comment.sortCategoryOrder").translatedName("itemscroller.config.generic.name.sortCategoryOrder");

public static final ImmutableList<IConfigBase> OPTIONS = ImmutableList.of(
CARPET_CTRL_Q_CRAFTING,
CLIENT_CRAFTING_FIX,
CRAFTING_RENDER_RECIPE_ITEMS,
//DEBUG_MESSAGES,
DEBUG_MESSAGES,
MASS_CRAFT_INHIBIT_MID_UPDATES,
MASS_CRAFT_INTERVAL,
MASS_CRAFT_ITERATIONS,
Expand All @@ -71,8 +86,16 @@ public static class Generic
VILLAGER_TRADE_USE_GLOBAL_FAVORITES,
VILLAGER_TRADE_LIST_REMEMBER_SCROLL,

SORT_INVENTORY_TOGGLE,
SORT_ASSUME_EMPTY_BOX_STACKS,
SORT_SHULKER_BOXES_AT_END
SORT_SHULKER_BOXES_AT_END,
SORT_SHULKER_BOXES_INVERTED,
SORT_BUNDLES_AT_END,
SORT_BUNDLES_INVERTED,
SORT_TOP_PRIORITY_INVENTORY,
SORT_BOTTOM_PRIORITY_INVENTORY,
SORT_METHOD_DEFAULT,
SORT_CATEGORY_ORDER
);
}

Expand Down
23 changes: 18 additions & 5 deletions src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,11 @@ else if (key == Hotkeys.SLOT_DEBUG.getKeybind())
}
else if (key == Hotkeys.SORT_INVENTORY.getKeybind())
{
InventoryUtils.sortInventory(gui);
return true;
if (Configs.Generic.SORT_INVENTORY_TOGGLE.getBooleanValue())
{
InventoryUtils.sortInventory(gui);
return true;
}
}

return false;
Expand Down Expand Up @@ -239,9 +242,9 @@ public void onClientTick(MinecraftClient mc)
for (int i = 0; i < limit; ++i)
{
// todo
// InventoryUtils.tryClearCursor(gui);
// InventoryUtils.setInhibitCraftingOutputUpdate(true);
InventoryUtils.throwAllCraftingResultsToGround(recipe, gui);
//InventoryUtils.setInhibitCraftingOutputUpdate(true);
//InventoryUtils.tryClearCursor(gui);
//InventoryUtils.throwAllCraftingResultsToGround(recipe, gui);

RecipeInputInventory craftingInv = ((IMixinCraftingResultSlot) outputSlot).itemscroller_getCraftingInventory();
if (!recipe.getVanillaRecipe().matches(craftingInv.createRecipeInput(), mc.world))
Expand Down Expand Up @@ -274,8 +277,18 @@ public void onClientTick(MinecraftClient mc)
}

InventoryUtils.shiftClickSlot(gui, outputSlot.id);

// This isn't required after 1.21, it only needs a single dropStack
for (int k = 0; k < recipe.getResult().getMaxCount(); k++)
{
InventoryUtils.dropStack(gui, outputSlot.id);
}

recipeBookClicks = true;
}

InventoryUtils.tryClearCursor(gui);
InventoryUtils.throwAllCraftingResultsToGround(recipe, gui);
}
else if (Configs.Generic.MASS_CRAFT_SWAPS.getBooleanValue())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fi.dy.masa.itemscroller.gui;

import net.minecraft.util.Identifier;
import fi.dy.masa.itemscroller.Reference;
import fi.dy.masa.malilib.gui.interfaces.IGuiIcon;
import fi.dy.masa.malilib.render.RenderUtils;
import fi.dy.masa.itemscroller.Reference;

public enum ItemScrollerIcons implements IGuiIcon
{
Expand All @@ -13,7 +13,7 @@ public enum ItemScrollerIcons implements IGuiIcon
STAR_5_YELLOW (112, 18, 5, 5),
STAR_5_PURPLE (117, 18, 5, 5);

public static final Identifier TEXTURE = Identifier.splitOn(Reference.MOD_ID + ":textures/gui/gui_widgets.png", ':');
public static final Identifier TEXTURE = Identifier.of(Reference.MOD_ID, "textures/gui/gui_widgets.png");

private final int u;
private final int v;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package fi.dy.masa.itemscroller.mixin;

import net.minecraft.client.MinecraftClient;
import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket;
import net.minecraft.screen.ScreenHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public class MixinItemStack
private void dontCap(int maxCount, CallbackInfo ci)
{
// Client-side fx for empty shulker box stacking
if (MinecraftClient.getInstance().isOnThread() && Configs.Generic.SORT_ASSUME_EMPTY_BOX_STACKS.getBooleanValue())
if (MinecraftClient.getInstance().isOnThread() &&
Configs.Generic.SORT_INVENTORY_TOGGLE.getBooleanValue() &&
Configs.Generic.SORT_ASSUME_EMPTY_BOX_STACKS.getBooleanValue())
{
ci.cancel();
}
Expand All @@ -27,7 +29,10 @@ private void dontCap(int maxCount, CallbackInfo ci)
private void getMaxCount(CallbackInfoReturnable<Integer> cir)
{
// Client-side fx for empty shulker box stacking
if (MinecraftClient.getInstance().isOnThread() && Configs.Generic.SORT_ASSUME_EMPTY_BOX_STACKS.getBooleanValue() && InventoryUtils.assumeEmptyShulkerStacking)
if (MinecraftClient.getInstance().isOnThread() &&
Configs.Generic.SORT_INVENTORY_TOGGLE.getBooleanValue() &&
Configs.Generic.SORT_ASSUME_EMPTY_BOX_STACKS.getBooleanValue() &&
InventoryUtils.assumeEmptyShulkerStacking)
{
cir.setReturnValue(InventoryUtils.stackMaxSize((ItemStack) (Object) this, true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void ensureRecipeSizeAndClearRecipe(int size)
this.clearRecipe();
}

@SuppressWarnings("unchecked")
@Nullable
public <T extends RecipeInput> Recipe<T> lookupVanillaRecipe(World world) {
//Assume all recipes here are of type CraftingRecipe
Expand Down
23 changes: 19 additions & 4 deletions src/main/java/fi/dy/masa/itemscroller/recipes/RecipeStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,21 @@ private void readFromNBT(NbtCompound nbt, @Nonnull DynamicRegistryManager regist
if (index >= 0 && index < this.recipes.length)
{
this.recipes[index].readFromNBT(tag, registryManager);

// TODO 1.21.2+
/*
if (tag.contains("LastNetworkId"))
{
this.recipes[index].storeNetworkRecipeId(new NetworkRecipeId(tag.getInt("LastNetworkId")));
}
*/
}
}

this.changeSelectedRecipe(nbt.getByte("Selected"));
}

private NbtCompound writeToNBT(DynamicRegistryManager registryManager)
private NbtCompound writeToNBT(@Nonnull DynamicRegistryManager registryManager)
{
NbtList tagRecipes = new NbtList();
NbtCompound nbt = new NbtCompound();
Expand All @@ -180,10 +188,17 @@ private NbtCompound writeToNBT(DynamicRegistryManager registryManager)
{
if (this.recipes[i].isValid())
{

NbtCompound tag = this.recipes[i].writeToNBT(registryManager);
RecipePattern entry = this.recipes[i];
NbtCompound tag = entry.writeToNBT(registryManager);
tag.putByte("RecipeIndex", (byte) i);
tagRecipes.add(tag);

// TODO 1.21.2+
/*
if (entry.getNetworkRecipeId() != null)
{
tag.putInt("LastNetworkId", entry.getNetworkRecipeId().index());
}
*/
}
}

Expand Down
Loading

0 comments on commit 2b29f32

Please sign in to comment.