Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Dec 9, 2024
2 parents f4a5136 + 1700b88 commit 1ec6380
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 140 deletions.
61 changes: 61 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Bug Report
description: Report a bug / crash
labels: [ "bug", "unconfirmed" ]
body:
- type: markdown
attributes:
value: |
To help us help you, please provide as much information as you can, this helps us with debugging and reproducing the issue.
- type: input
id: mod-version
attributes:
label: Inventory Sorter Version
description: |
You can find the version of the mod in the mods file name or in-game in the mods button on the main menu.
placeholder: 24.x.x
validations:
required: true
- type: input
id: neoforge-version
attributes:
label: NeoForge Version
description: |
You can get this from the main menu screen in the bottom left corner of the screen.
placeholder: 21.1.x
validations:
required: false
- type: input
id: bugdesc
attributes:
label: Describe the issue
description: |
A clear and concise description of what the bug is
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Steps to reproduce
description: Tell us how we can reproduce the issue
placeholder: |
1. Open Mc...
2. Use tool...
3. See error...
validations:
required: true
- type: textarea
id: logs
attributes:
label: Log files
description: "Link(s) to any log files that you can provide, typically, /logs/debug.log and /logs/latest.log. You can use services like [Gist](https://gist.github.com/) or [Pastebin](https://pastebin.com/) to upload your logs or you can drag them into the text box."
placeholder: |
Your logs here
validations:
required: false
- type: textarea
id: additional
attributes:
label: Additional information
description: Add any other context about the problem here
validations:
required: false
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Feature Request
description: A request for a new feature to be added to the mod
labels: [ "enhancement", "user-suggested" ]
body:
- type: input
id: mc-version
attributes:
label: Minecraft Version
placeholder: 1.21.x
validations:
required: true
- type: textarea
id: suggestdesc
attributes:
label: Describe the feature you'd like to have added
description: |
A detailed explanation of the suggestion
validations:
required: true
- type: textarea
id: additional
attributes:
label: Additional information
description: Add any other context about the feature here
validations:
required: false
7 changes: 2 additions & 5 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
name: Java CI

on:
push:
# Only run CI for the main branch
branches:
- main
- push

jobs:
build:
runs-on: ubuntu-latest
# Skip CI if the commit message contains [ci-skip]
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
if: "!contains(github.event.head_commit.message, '[ci-skip]') && contains(github.event.head_commit.message, '[release]')"
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
Expand Down
134 changes: 40 additions & 94 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask

plugins {
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version '1.71.4'
id 'org.ajoberstar.grgit' version '4.1.1'
id 'com.github.ben-manes.versions' version '0.39.0'
id 'net.neoforged.gradle.userdev' version '7.0.142'
id "me.modmuss50.mod-publish-plugin" version "0.7.1"
id 'java-library'
id 'idea'
id 'maven-publish'
}

tasks.named('wrapper', Wrapper).configure {
// Define wrapper values here so as to not have to always do so when updating gradlew.properties.
// Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
// documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
// file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
// (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
distributionType = Wrapper.DistributionType.BIN
}

Expand All @@ -29,34 +26,20 @@ base {
archivesName = 'inventorysorter'
}

// Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21.
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

//minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager

// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
// applies to all the run configs below
configureEach {
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
systemProperty 'forge.logging.markers', 'REGISTRIES'

// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
systemProperty 'forge.logging.console.level', 'debug'

modSource project.sourceSets.main
}

client {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty 'forge.enabledGameTestNamespaces', 'inventorysorter'
}

Expand All @@ -65,66 +48,26 @@ runs {
programArgument '--nogui'
}

// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
systemProperty 'forge.enabledGameTestNamespaces', 'inventorysorter'
}

data {
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// workingDirectory project.file('run-data')

// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll '--mod', 'inventorysorter', '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

// Sets up a dependency configuration called 'localRuntime'.
// This configuration should be used instead of 'runtimeOnly' to declare
// a dependency that will be present for runtime testing but that is
// "optional", meaning it will not be pulled by dependents of this mod.
configurations {
runtimeClasspath.extendsFrom localRuntime
}

dependencies {
// Specify the version of Minecraft to use.
// Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
// The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
// You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
// And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
// For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
implementation "net.neoforged:neoforge:${neo_version}"

// Example optional mod dependency with JEI
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
// compileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}"
// We add the full version to localRuntime, not runtimeOnly, so that we do not publish a dependency on it
// localRuntime "mezz.jei:jei-${mc_version}-neoforge:${jei_version}"

// Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
// The group id is ignored when searching -- in this case, it is "blank"
// implementation "blank:coolmod-${mc_version}:${coolmod_version}"

// Example mod dependency using a file as dependency
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")

// Example project dependency using a sister or child project:
// implementation project(":myproject")

// For more info:
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}

task makeChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
tasks.register('makeChangelog', GitChangelogTask) {
file = project.file('CHANGELOG.md')
fromRepo = file(".")
untaggedName = "Current release ${version}"
Expand All @@ -143,26 +86,29 @@ task makeChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
"""
}

curseforge {
apiKey = project.hasProperty('curseforge_apikey') ? project.curseforge_apikey : '0'
project {
id = '240633'
changelog = file('CHANGELOG.md')
changelogType = 'markdown'
releaseType = project.findProperty('releaseType') ?: 'alpha'
addGameVersion "${mc_version}"
}
options {
javaVersionAutoDetect = true // defaults to true
javaIntegration = true // defaults to true
forgeGradleIntegration = true // defaults to true
}
}
publishMods {
def apiKey = project.hasProperty('curseforge_apikey') ? project.curseforge_apikey : '0'
dryRun = apiKey == '0'

beforeEvaluate {
tasks.curseforge240633.dependsOn.remove(reobfJar)
tasks.curseforge240633.dependsOn.remove(jar)
tasks.curseforge240633.dependsOn.add(makeChangelog)
file = jar.archiveFile
changelog = file('CHANGELOG.md').exists() ? file('CHANGELOG.md').text : "No changelog provided"
type = STABLE

curseforge {
modLoaders.add("neoforge")

accessToken = apiKey
projectId = "240633"
accessToken = apiKey

minecraftVersions.add(mc_version)
minecraftVersions.add("1.21.1")

javaVersions.add(JavaVersion.VERSION_21)

clientRequired = true
serverRequired = true
}
}

tasks.named('jar', Jar).configure {
Expand All @@ -177,25 +123,25 @@ tasks.named('jar', Jar).configure {
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}

archiveAppendix = mc_version
}

// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
//tasks.withType(ProcessResources).configureEach {
// var replaceProperties = [
// mod_version : project.version,
// ]
// inputs.properties replaceProperties
//
// filesMatching(['META-INF/neoforge.mods.toml']) {
// expand replaceProperties
// }
//}

// Example configuration to allow publishing using the maven-publish plugin
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
mod_version : project.version,
]
inputs.properties replaceProperties

filesMatching(['META-INF/neoforge.mods.toml']) {
expand replaceProperties
}
}

publishing {
publications {
register('mavenJava', MavenPublication) {
Expand All @@ -210,7 +156,7 @@ publishing {
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
options.encoding = 'UTF-8'
}

// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
Expand All @@ -219,4 +165,4 @@ idea {
downloadSources = true
downloadJavadoc = true
}
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
neo_version=21.0.86-beta
mc_version=1.21
neo_version=21.0.167
mc_version=1.21
10 changes: 8 additions & 2 deletions src/main/java/cpw/mods/inventorysorter/ContainerContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ public ContainerContext(Slot slot, ServerPlayer playerEntity)

InventoryHandler.InventoryMapping hotbarMapping = new InventoryHandler.InventoryMapping(PLAYER_HOTBAR, openContainer, playerEntity.getInventory(), openContainer.getSlot(0));
InventoryHandler.InventoryMapping mainMapping = new InventoryHandler.InventoryMapping(PLAYER_MAIN, openContainer, playerEntity.getInventory(), openContainer.getSlot(mainStart));
InventoryHandler.InventoryMapping offhandMapping = new InventoryHandler.InventoryMapping(PLAYER_OFFHAND, openContainer, playerEntity.getInventory(), openContainer.getSlot(offhandStart));

// Only add the offhandMapping if the screen contains an offhand slot. Most don't.
InventoryHandler.InventoryMapping offhandMapping = null;
if (openContainer.slots.size() >= 40) {
offhandMapping = new InventoryHandler.InventoryMapping(PLAYER_OFFHAND, openContainer, playerEntity.getInventory(), openContainer.getSlot(offhandStart));
}

InventoryHandler.InventoryMapping inventoryMapping;
for (int i = playerMapping.begin; i<=playerMapping.end; i++)
{
Expand All @@ -87,7 +93,7 @@ else if (s.getSlotIndex() < mainEnd && s.container == playerEntity.getInventory(
mapping.put(PLAYER_MAIN, mainMapping);
inventoryMapping = mainMapping;
}
else if (s.getSlotIndex() >= offhandStart && s.container == playerEntity.getInventory())
else if (offhandMapping != null && s.getSlotIndex() >= offhandStart && s.container == playerEntity.getInventory())
{
offhandMapping.begin = Math.min(s.index, offhandMapping.begin);
offhandMapping.end = Math.max(s.index, offhandMapping.end);
Expand Down
Loading

0 comments on commit 1ec6380

Please sign in to comment.