Skip to content

Commit

Permalink
sync with sakura-ryoko/itemscroller
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Jul 10, 2024
1 parent 6a10f5a commit d6095aa
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 64 deletions.
59 changes: 23 additions & 36 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
plugins {
id "dev.architectury.loom" version "1.6-SNAPSHOT"
alias(libs.plugins.architectury.loom)
alias(libs.plugins.modpublisher)
id "maven-publish"
id "com.hypherionmc.modutils.modpublisher" version "2.+"
}

base.archivesName = project.archives_base_name
version = "${project.mod_version}-mc${project.minecraft_version}"
group = project.maven_group
base.archivesName = libs.versions.archives.name
version = "${libs.versions.version.get()}-mc${libs.versions.minecraft.version.get()}"
group = libs.versions.maven.group

repositories {
maven { url 'https://api.modrinth.com/maven' }
maven { url "https://www.jitpack.io" }
maven { url "https://maven.neoforged.net/releases/" }
maven { url 'https://api.modrinth.com/maven' }
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
minecraft libs.minecraft
mappings loom.layered {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
mappings "dev.architectury:yarn-mappings-patch-${loom.platform.get().id()}:${project.yarn_patch}"
mappings variantOf(libs.yarn.mappings) { classifier("v2") }
mappings libs.yarn.mappings.patch
}
neoForge "net.neoforged:neoforge:${project.neoforge_version}"
neoForge libs.neoforge

modImplementation "maven.modrinth:mafglib:${project.malilib_version}"
modImplementation libs.mafglib
modImplementation libs.neonetwork

implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation libs.jsr305
}

processResources {
Expand All @@ -46,27 +48,12 @@ java {
withSourcesJar()
}

jar {
// add some additional metadata to the jar manifest
manifest {
attributes([
"Specification-Title" : project.mod_id,
"Specification-Vendor" : project.mod_author,
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : version,
"Implementation-Vendor" : project.mod_author,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
Expand All @@ -84,17 +71,17 @@ publisher {
curseforge System.getenv("CURSEFORGE_TOKEN")
}

setCurseID("${project.curseforge_id}")
setModrinthID("${project.modrinth_id}")
setCurseID("${libs.versions.id.curseforge.get()}")
setModrinthID("${libs.versions.id.modrinth.get()}")
setVersionType("alpha")
setChangelog(file("CHANGELOG.md").getText("UTF-8"))
setVersion("${project.version}")
setDisplayName("${project.version}")
setGameVersions("1.20.5", "1.20.6")
setLoaders("neoforge")
setGameVersions(libs.versions.minecraft.range.get())
setLoaders(loom.platform.get().id())
setCurseEnvironment("client")
setArtifact(remapJar)
addAdditionalFile(sourcesJar)
curseDepends { required("mafglib") }
modrinthDepends { required("mafglib") }
}
curseDepends.required("mafglib")
modrinthDepends.required("mafglib")
}
19 changes: 0 additions & 19 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,3 @@
org.gradle.jvmargs=-Xmx1G

loom.platform=neoforge

# Base properties
# minecraft version
minecraft_version=1.20.6
neoforge_version=20.6.119
yarn_mappings=1.20.6+build.3
yarn_patch=1.20.6+build.4

# Mod Properties
mod_version=0.1.3
maven_group=org.thinkingstudio.rocknroller
archives_base_name=RocknRoller
mod_id=rocknroller
mod_author=ThinkingStudio
modrinth_id=hYq29QmW
curseforge_id=916852

# Dependencies
malilib_version=0.1.12-mc1.20.6
44 changes: 44 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[versions]

minecraft-range="1.21"

# Base properties
minecraft_version="1.21"
yarn_mappings="1.21+build.2"
mappings_patch="1.21+build.4"
neoforge="21.0.78-beta"

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

# Publish properties
id-modrinth="hYq29QmW"
id-curseforge="916852"

# Mod dependencies
mafglib="0.1.14-mc1.21"
neonetwork="0.1.5+mc1.21"

# Libraries
jsr305="3.0.2"

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

[libraries]
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft_version" }
yarn-mappings = { group = "net.fabricmc", name = "yarn", version.ref = "yarn_mappings"}
yarn-mappings-patch = { group = "dev.architectury", name = "yarn-mappings-patch-neoforge", version.ref = "mappings_patch"}

neoforge = { group = "net.neoforged", name = "neoforge", version.ref = "neoforge" }
neonetwork = { group = "maven.modrinth", name = "neonetwork", version.ref = "neonetwork" }
mafglib = { group = "maven.modrinth", name = "mafglib", version.ref = "mafglib"}

jsr305 = { group = "com.google.code.findbugs", name = "jsr305", version.ref = "jsr305"}

[plugins]
architectury-loom = { id = "dev.architectury.loom", version.ref = "architectury-loom" }
modpublisher = { id = "com.hypherionmc.modutils.modpublisher", version.ref = "modpublisher" }
Original file line number Diff line number Diff line change
Expand Up @@ -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 = new Identifier(Reference.MOD_ID, "textures/gui/gui_widgets.png");
public static final Identifier TEXTURE = Identifier.splitOn(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
Expand Up @@ -9,6 +9,8 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftingResultInventory;
import net.minecraft.inventory.RecipeInputInventory;
import net.minecraft.recipe.CraftingRecipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.world.World;
import fi.dy.masa.itemscroller.util.InventoryUtils;
Expand All @@ -33,7 +35,7 @@ private static void onUpdateResult(
PlayerEntity player,
RecipeInputInventory craftingInventory,
CraftingResultInventory resultInv,
CallbackInfo ci)
RecipeEntry<CraftingRecipe> recipeEntry, CallbackInfo ci)
{
InventoryUtils.onSlotChangedCraftingGrid(player, craftingInventory, resultInv);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.recipe.CraftingRecipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.input.CraftingRecipeInput;
import net.minecraft.registry.Registries;
import net.minecraft.screen.MerchantScreenHandler;
import net.minecraft.screen.ScreenHandler;
Expand Down Expand Up @@ -107,10 +108,11 @@ public static void updateCraftingOutputSlot(PlayerEntity player,
ItemStack stack = ItemStack.EMPTY;
CraftingRecipe recipe = Configs.Generic.USE_RECIPE_CACHING.getBooleanValue() ? lastRecipe : null;
RecipeEntry<?> recipeEntry = null;
CraftingRecipeInput recipeInput = craftMatrix.createRecipeInput();

if (recipe == null || recipe.matches(craftMatrix, world) == false)
if (recipe == null || recipe.matches(recipeInput, world) == false)
{
Optional<RecipeEntry<CraftingRecipe>> optional = world.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, craftMatrix, world);
Optional<RecipeEntry<CraftingRecipe>> optional = world.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, recipeInput, world);
recipe = optional.map(RecipeEntry::value).orElse(null);
recipeEntry = optional.orElse(null);
}
Expand All @@ -122,7 +124,7 @@ public static void updateCraftingOutputSlot(PlayerEntity player,
((ClientPlayerEntity) player).getRecipeBook().contains(recipeEntry)))
{
inventoryCraftResult.setLastRecipe(recipeEntry);
stack = recipe.craft(craftMatrix, world.getRegistryManager());
stack = recipe.craft(recipeInput, world.getRegistryManager());
}

if (setEmptyStack || stack.isEmpty() == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static Item getItemForName(String name)
{
try
{
Identifier id = new Identifier(name);
Identifier id = Identifier.tryParse(name);
return Registries.ITEM.get(id);
}
catch (Exception e)
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/rocknroller/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"fml.menu.mods.info.description.rocknroller": "ItemScroller unofficial (Neo)Forge port.\nMove items in inventory GUIs by scrolling the mouse wheel or dragging over slots.",

"itemscroller.gui.button.config_gui.generic": "Generic",
"itemscroller.gui.button.config_gui.hotkeys": "Hotkeys",
"itemscroller.gui.button.config_gui.toggles": "Toggles",
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/assets/rocknroller/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"fml.menu.mods.info.description.rocknroller": "ItemScroller 非官方 (Neo)Forge 移植。\n通过滚动鼠标滚轮或在物品槽上拖动来移动库存图形用户界面中的物品。",

"itemscroller.gui.button.config_gui.generic": "通用",
"itemscroller.gui.button.config_gui.generic": "通用",
"itemscroller.gui.button.config_gui.hotkeys": "快捷键",
"itemscroller.gui.button.config_gui.toggles": "开关",

"itemscroller.gui.label.recipe_page": "页 %d / %d",
"itemscroller.gui.label.trades": "交易",
"itemscroller.gui.label.trade_uses": "交易使用: %d / %",

"itemscroller.message.toggled_mod_off": "Item Scroller功能调整为: §c关闭",
"itemscroller.message.toggled_mod_on": "tem Scroller功能调整为: §a开启",
"itemscroller.message.toggled_mod_off": "Item Scroller功能调整为: §c关闭",
"itemscroller.message.toggled_mod_on": "Item Scroller功能调整为: §a开启",

"enableCraftingFeatures":"Crafting | 制作特性",
"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.":"开启内置共8页每页18种配方的存储,使得物品可以放置到合成表\n按住Recipe(配方)的快捷键查看配方列表,您可以滑动滚轮或使用数字键选择配方\n点击配方可以在工作台完成合成,在放置配方达到待命状态时(不取出合成产物)\n按下设定的storeRecipe(储存配方)快捷键就可以在选定的列表格内进行配方储存(自动覆写)。",
Expand Down

0 comments on commit d6095aa

Please sign in to comment.