diff --git a/build.gradle b/build.gradle deleted file mode 100644 index a807522..0000000 --- a/build.gradle +++ /dev/null @@ -1,266 +0,0 @@ -//file:noinspection GroovyAssignabilityCheck -import groovy.json.JsonSlurper -import groovy.json.JsonOutput - -buildscript { - repositories { - maven { url = 'https://files.minecraftforge.net/maven' } - maven { url = 'https://maven.parchmentmc.org' } - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: "${project.forgegradle_version}", changing: true - classpath group: 'org.parchmentmc', name: 'librarian', version: "${project.librarian_version}" - } -} - -plugins { - id 'maven-publish' - id 'eclipse' - id 'idea' -} - -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'org.parchmentmc.librarian.forgegradle' -//-------------- - -group = "${project.mod_group}" -version = "${project.mc_version}-${project.mod_version}" -archivesBaseName = "${project.mod_id}" - -if (System.getenv('RELEASE_TYPE') != null) { - status = System.getenv('RELEASE_TYPE').toLowerCase() - if (status == 'snapshot') status = status.toUpperCase() -} else { - status = 'SNAPSHOT' -} - -if (status != 'release') { - version = "${version}-${status}" -} - -java { - withSourcesJar() - - toolchain { - languageVersion = JavaLanguageVersion.of(project.java_version) - vendor = JvmVendorSpec.ADOPTOPENJDK - } -} - -tasks.withType(JavaCompile).configureEach { - options.encoding = 'UTF-8' -} - -sourceSets { - main { - resources { - srcDir 'src/main/generated' - } - } -} - -repositories { - mavenLocal() - mavenCentral() - maven { - name = 'blamejared Maven' - url = 'https://maven.blamejared.com' - } - maven { - name = 'ModMaven' - url = 'https://modmaven.k-4u.nl' - } -} - -dependencies { - minecraft "net.minecraftforge:forge:${project.mc_version}-${project.forge_version}" - compileOnly fg.deobf("mezz.jei:jei-1.19.3-common-api:${project.jei_version}") - runtimeOnly fg.deobf("mezz.jei:jei-1.19.3-forge:${project.jei_version}") - implementation 'org.jetbrains:annotations:23.0.0' -} - -minecraft { - mappings channel: "${project.mappings_channel}", version: "${project.mappings_version}" - runs { - client { - workingDirectory project.file('run') - property 'forge.logging.console.level', 'debug' - mods { - potionbundles { - source sourceSets.main - } - } - } - server { - workingDirectory project.file('run') - property 'forge.logging.console.level', 'debug' - mods { - potionbundles { - source sourceSets.main - } - } - } - data { - workingDirectory project.file('run') - property 'forge.logging.console.level', 'debug' - args '--mod', "${project.mod_id}", '--all', '--output', file('src/main/generated/'), '--existing', file('src/main/resources/') - mods { - potionbundles { - source sourceSets.main - } - } - } - } -} - -processResources { - //noinspection GroovyAccessibility - Map buildProps = project.properties.clone() - buildProps.values().removeIf { !it.getClass().isPrimitive() && !(it instanceof CharSequence) } - inputs.properties buildProps - - filesMatching(['META-INF/mods.toml']) { - expand buildProps - } - // minify json files - doLast { - fileTree(dir: outputs.files.asPath, include: "**/*.json").each { - it.text = JsonOutput.toJson(new JsonSlurper().parse(it)) - } - } -} - -jar { - from sourceSets.main.output - finalizedBy('reobfJar') -} - -sourcesJar { - from sourceSets.main.allSource -} - -tasks.withType(Jar).configureEach { - String extension = '' - if (it.archiveClassifier.present) { - extension = it.archiveClassifier.get() - if (extension != '') { - extension = '-' + extension - } - } - manifest { - attributes([ - 'Maven-Artifact': "${project.mod_group}:${project.archivesBaseName}:${project.version}", - 'Specification-Title': archivesBaseName, - 'Specification-Vendor': "${project.vendor}", - 'Specification-Version': '1', - 'Implementation-Title': "${archivesBaseName}${extension}", - 'Implementation-Version': "${project.mod_version}", - 'Implementation-Vendor': "${project.vendor}", - 'Built-On-Java': "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", - 'Built-On': "${project.mc_version}-${project.forge_version}", - 'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - 'FMLModType': 'MOD' - ]) - } -} - -artifacts { - archives jar - archives sourcesJar -} - -reobf { - jar { classpath.from(sourceSets.main.compileClasspath) } -} - -tasks.register('reobf') { - dependsOn reobfJar -} - -tasks.register('setupGithubActions') { - doLast { - println "##[set-output name=modid;]${project.mod_id}" - println "##[set-output name=version;]${project.version}" - } -} - -idea { - module { - for (String exclude in ['run', 'out', 'libs']) { - excludeDirs += file(exclude) - } - } -} - -tasks.withType(GenerateModuleMetadata).configureEach { - enabled = false -} - -publishing { - publications.create(project.archivesBaseName+'ToMaven', MavenPublication) { - groupId = project.group - artifactId = project.archivesBaseName - version = project.version - from components.java - pom { - name = project.mod_name - url = project.mod_url - packaging = 'jar' - scm { - connection = "scm:git:git://github.com/${project.github}.git" - developerConnection = "scm:git:git@github.com:${project.github}.git" - url = "https://github.com/${project.github}" - } - issueManagement { - system = 'github' - url = "https://github.com/${project.github}/issues" - } - organization { - name = 'Minecraftschurli Mods' - url = 'https://github.com/MinecraftschurliMods' - } - developers { - developer { - id = 'minecraftschurli' - name = 'Minecraftschurli' - url = 'https://github.com/Minecraftschurli' - email = 'minecraftschurli@gmail.com' - organization = 'Minecraftschurli Mods' - organizationUrl = 'https://github.com/MinecraftschurliMods' - timezone = 'Europe/Vienna' - } - developer { - id = 'ichhabehunger54' - name = 'IchHabeHunger54' - url = 'https://github.com/IchHabeHunger54' - organization = 'Minecraftschurli Mods' - organizationUrl = 'https://github.com/MinecraftschurliMods' - timezone = 'Europe/Vienna' - } - } - withXml { - asNode().dependencies.dependency.each { dep -> - if(dep.version.last().value().last().contains('_mapped_')) { - assert dep.parent().remove(dep) - } - } - } - } - } - repositories { - maven { - if ((System.getenv("MAVEN_USER") != null) - && (System.getenv("MAVEN_PASSWORD") != null) - && (System.getenv("MAVEN_URL") != null)) { - url System.getenv("MAVEN_URL") - credentials { - username System.getenv("MAVEN_USER") - password System.getenv("MAVEN_PASSWORD") - } - } else { - url "$buildDir/repo" - } - } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..63672d9 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,267 @@ +//file:noinspection GroovyAssignabilityCheck +import groovy.json.JsonSlurper +import groovy.json.JsonOutput +import groovy.util.Node +import groovy.util.NodeList +import java.time.Instant +import java.time.format.DateTimeFormatter +import java.util.* + +val mod_group: String by project +val mc_version: String by project +val mod_version: String by project +val mod_id: String by project +val forge_version: String by project +val jei_version: String by project +val java_version: String by project +val mappings_channel: String by project +val mappings_version: String by project +val vendor: String by project +val github: String by project +val mod_name: String by project +val mod_url: String by project + + +fun Project.fileTree(dir: String, include: String) = fileTree("dir" to dir, "include" to include) + +plugins { + `maven-publish` + eclipse + idea + java + id("net.minecraftforge.gradle") + id("org.parchmentmc.librarian.forgegradle") +} + +//-------------- + +group = mod_group +version = "${mc_version}-${mod_version}" +base { + archivesName.set(mod_id) +} + +if (System.getenv("RELEASE_TYPE") != null) { + status = System.getenv("RELEASE_TYPE").lowercase() + if (status == "snapshot") status = (status as String).uppercase() +} else { + status = "SNAPSHOT" +} + +if (status != "release") { + version = "${version}-${status}" +} + +java { + withSourcesJar() + + toolchain.languageVersion.set(JavaLanguageVersion.of(java_version)) +} + +sourceSets { + main { + resources { + srcDir("src/main/generated") + } + } +} + +repositories { + mavenLocal() + mavenCentral() + maven { + name = "blamejared Maven" + url = uri("https://maven.blamejared.com") + } + maven { + name = "ModMaven" + url = uri("https://modmaven.k-4u.nl") + } +} + +dependencies { + minecraft("net.minecraftforge:forge:${mc_version}-${forge_version}") + compileOnly(fg.deobf("mezz.jei:jei-1.20-common-api:${jei_version}")) + runtimeOnly(fg.deobf("mezz.jei:jei-1.20-forge:${jei_version}")) + implementation("org.jetbrains:annotations:23.0.0") +} + +minecraft { + mappings(mappings_channel, mappings_version) + copyIdeResources.set(true) + runs { + create("client") { + workingDirectory(file("run")) + property("forge.logging.console.level", "debug") + mods.register("potionbundles") { + source(sourceSets.getByName("main")) + } + } + create("server") { + workingDirectory(file("run")) + property("forge.logging.console.level", "debug") + mods.register("potionbundles") { + source(sourceSets.getByName("main")) + } + } + create("data") { + workingDirectory(file("run")) + property("forge.logging.console.level", "debug") + args("--mod", mod_id, "--all", "--output", file("src/main/generated/"), "--existing", file("src/main/resources/")) + mods.register("potionbundles") { + source(sourceSets.getByName("main")) + } + } + } +} + +tasks { + withType().configureEach { + options.encoding = "UTF-8" + } + processResources { + val buildProps = project.properties.toMutableMap() + buildProps.values.removeIf { it !is CharSequence && it !is Number && it !is Boolean } + inputs.properties(buildProps) + + filesMatching("META-INF/mods.toml") { + expand(buildProps) + } + // minify json files + doLast { + fileTree(dir = outputs.files.asPath, include = "**/*.json").forEach { + it.writeText(JsonOutput.toJson(JsonSlurper().parse(it))) + } + } + } + named("jar") { + from(sourceSets.main.map { it.output }) + finalizedBy("reobfJar") + } + named("sourcesJar") { + duplicatesStrategy = DuplicatesStrategy.INCLUDE + from(sourceSets.main.map { it.allSource }) + } + withType().configureEach { + var extension = "" + if (archiveClassifier.isPresent) { + extension = archiveClassifier.get() + if (extension != "") { + extension = "-$extension" + } + } + manifest { + attributes(mapOf( + "Maven-Artifact" to "${mod_group}:${base.archivesName}:${project.version}", + "Specification-Title" to base.archivesName, + "Specification-Vendor" to vendor, + "Specification-Version" to "1", + "Implementation-Title" to "${base.archivesName}${extension}", + "Implementation-Version" to mod_version, + "Implementation-Vendor" to vendor, + "Built-On-Java" to "${System.getProperty("java.vm.version")} (${System.getProperty("java.vm.vendor")})", + "Built-On" to "${mc_version}-${forge_version}", + "Timestamp" to DateTimeFormatter.ISO_INSTANT.format(Instant.now()), + "FMLModType" to "MOD" + )) + } + } + register("reobf") { + dependsOn(named("reobfJar")) + } + register("setupGithubActions") { + doLast { + println("##[set-output name=modid;]${mod_id}") + println("##[set-output name=version;]${project.version}") + } + } + withType().configureEach { + enabled = false + } +} + +artifacts { + archives(tasks.named("jar")) + archives(tasks.named("sourcesJar")) +} + +reobf { + create("jar") { + classpath.from(sourceSets.main.map { it.compileClasspath }) + } +} + +idea.module.excludeDirs.addAll(arrayOf("run", "out", "libs").map(::file)) + +publishing { + publications.create("${base.archivesName.get()}ToMaven") { + groupId = project.group as String + artifactId = base.archivesName.get() + version = project.version as String + from(components["java"]) + pom { + name.set(mod_name) + url.set(mod_url) + packaging = "jar" + scm { + connection.set("scm:git:git://github.com/${github}.git") + developerConnection.set("scm:git:git@github.com:${github}.git") + url.set("https://github.com/${github}") + } + issueManagement { + system.set("github") + url.set("https://github.com/${github}/issues") + } + organization { + name.set("Minecraftschurli Mods") + url.set("https://github.com/MinecraftschurliMods") + } + developers { + developer { + id.set("minecraftschurli") + name.set("Minecraftschurli") + url.set("https://github.com/Minecraftschurli") + email.set("minecraftschurli@gmail.com") + organization.set("Minecraftschurli Mods") + organizationUrl.set("https://github.com/MinecraftschurliMods") + timezone.set("Europe/Vienna") + } + developer { + id.set("ichhabehunger54") + name.set("IchHabeHunger54") + url.set("https://github.com/IchHabeHunger54") + organization.set("Minecraftschurli Mods") + organizationUrl.set("https://github.com/MinecraftschurliMods") + timezone.set("Europe/Vienna") + } + } + withXml { + val rootNode = asNode() + val dependencies: NodeList = (rootNode.get("dependencies") as NodeList) + val dependencyList = dependencies.getAt("dependency") + for (dependency in dependencyList) { + val dependencyNode = dependency as Node + val version = ((((dependencyNode.get("version") as NodeList).last() as Node).value() as NodeList).last() as String) + if (version.contains("_mapped_")) { + assert(dependencyNode.parent().remove(dependencyNode)) + } + } + } + } + } + repositories { + maven { + if ((System.getenv("MAVEN_USER") != null) + && (System.getenv("MAVEN_PASSWORD") != null) + && (System.getenv("MAVEN_URL") != null)) { + url = uri(System.getenv("MAVEN_URL")) + credentials { + username = System.getenv("MAVEN_USER") + password = System.getenv("MAVEN_PASSWORD") + } + } else { + url = uri("$buildDir/repo") + } + } + } +} diff --git a/changelog.md b/changelog.md index 180f33b..6dce3c3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,2 +1,2 @@ # Changes -- Now works with versions of forge after 44.1 +- Updated to 1.20 diff --git a/gradle.properties b/gradle.properties index f5bdb0b..dce4129 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,21 +14,21 @@ github=MinecraftschurliMods/PotionBundles vendor=MinecraftschurliMods java_version=17 -forgegradle_version=5.1.+ +forgegradle_version=[6.0,6.2) librarian_version=1.+ -loader_version_range=[44,) +loader_version_range=[46,) -mc_version=1.19.3 -mc_version_range=[1.19.3,1.20) +mc_version=1.20 +mc_version_range=[1.20,1.20.1) -forge_version=44.1.0 -forge_version_range=[44.1,) +forge_version=46.0.1 +forge_version_range=[46.0.1,) -mappings_version=1.19.3 +mappings_version=1.20 mappings_channel=official -jei_version=12.1.1.9 +jei_version=14.0.0.4 curse_project_id=382836 modrinth_project_id=ZZLWU8jS diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..fae0804 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..42d20ba --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,27 @@ +pluginManagement { + plugins { + `maven-publish` + eclipse + idea + java + val forgegradle_version: String by settings + val librarian_version: String by settings + id("net.minecraftforge.gradle") version(forgegradle_version) + id("org.parchmentmc.librarian.forgegradle") version(librarian_version) + } + repositories { + gradlePluginPortal() + maven { + name = "MinecraftForge" + url = uri("https://maven.minecraftforge.net/") + } + maven { + name = "Parchment" + url = uri("https://maven.parchmentmc.org") + } + } +} + +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" +} \ No newline at end of file diff --git a/src/main/java/com/github/ichhabehunger54/potionbundles/AbstractPotionBundle.java b/src/main/java/com/github/minecraftschurlimods/potionbundles/AbstractPotionBundle.java similarity index 97% rename from src/main/java/com/github/ichhabehunger54/potionbundles/AbstractPotionBundle.java rename to src/main/java/com/github/minecraftschurlimods/potionbundles/AbstractPotionBundle.java index 4edbaaf..909d1e8 100644 --- a/src/main/java/com/github/ichhabehunger54/potionbundles/AbstractPotionBundle.java +++ b/src/main/java/com/github/minecraftschurlimods/potionbundles/AbstractPotionBundle.java @@ -1,4 +1,4 @@ -package com.github.ichhabehunger54.potionbundles; +package com.github.minecraftschurlimods.potionbundles; import net.minecraft.network.chat.Component; import net.minecraft.world.effect.MobEffectInstance; diff --git a/src/main/java/com/github/ichhabehunger54/potionbundles/AbstractThrowablePotionBundle.java b/src/main/java/com/github/minecraftschurlimods/potionbundles/AbstractThrowablePotionBundle.java similarity index 96% rename from src/main/java/com/github/ichhabehunger54/potionbundles/AbstractThrowablePotionBundle.java rename to src/main/java/com/github/minecraftschurlimods/potionbundles/AbstractThrowablePotionBundle.java index 0aefd19..ea1d9b7 100644 --- a/src/main/java/com/github/ichhabehunger54/potionbundles/AbstractThrowablePotionBundle.java +++ b/src/main/java/com/github/minecraftschurlimods/potionbundles/AbstractThrowablePotionBundle.java @@ -1,4 +1,4 @@ -package com.github.ichhabehunger54.potionbundles; +package com.github.minecraftschurlimods.potionbundles; import net.minecraft.stats.Stats; import net.minecraft.world.InteractionHand; diff --git a/src/main/java/com/github/ichhabehunger54/potionbundles/ClientHandler.java b/src/main/java/com/github/minecraftschurlimods/potionbundles/ClientHandler.java similarity index 97% rename from src/main/java/com/github/ichhabehunger54/potionbundles/ClientHandler.java rename to src/main/java/com/github/minecraftschurlimods/potionbundles/ClientHandler.java index 1058ff1..ea542d0 100644 --- a/src/main/java/com/github/ichhabehunger54/potionbundles/ClientHandler.java +++ b/src/main/java/com/github/minecraftschurlimods/potionbundles/ClientHandler.java @@ -1,4 +1,4 @@ -package com.github.ichhabehunger54.potionbundles; +package com.github.minecraftschurlimods.potionbundles; import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/com/github/ichhabehunger54/potionbundles/Config.java b/src/main/java/com/github/minecraftschurlimods/potionbundles/Config.java similarity index 97% rename from src/main/java/com/github/ichhabehunger54/potionbundles/Config.java rename to src/main/java/com/github/minecraftschurlimods/potionbundles/Config.java index 771e046..9f4aa09 100644 --- a/src/main/java/com/github/ichhabehunger54/potionbundles/Config.java +++ b/src/main/java/com/github/minecraftschurlimods/potionbundles/Config.java @@ -1,4 +1,4 @@ -package com.github.ichhabehunger54.potionbundles; +package com.github.minecraftschurlimods.potionbundles; import net.minecraftforge.common.ForgeConfigSpec; import org.apache.commons.lang3.tuple.Pair; diff --git a/src/main/java/com/github/ichhabehunger54/potionbundles/JEICompat.java b/src/main/java/com/github/minecraftschurlimods/potionbundles/JEICompat.java similarity index 98% rename from src/main/java/com/github/ichhabehunger54/potionbundles/JEICompat.java rename to src/main/java/com/github/minecraftschurlimods/potionbundles/JEICompat.java index 36770a1..a038d24 100644 --- a/src/main/java/com/github/ichhabehunger54/potionbundles/JEICompat.java +++ b/src/main/java/com/github/minecraftschurlimods/potionbundles/JEICompat.java @@ -1,4 +1,4 @@ -package com.github.ichhabehunger54.potionbundles; +package com.github.minecraftschurlimods.potionbundles; import mezz.jei.api.IModPlugin; import mezz.jei.api.constants.RecipeTypes; diff --git a/src/main/java/com/github/ichhabehunger54/potionbundles/LingeringPotionBundle.java b/src/main/java/com/github/minecraftschurlimods/potionbundles/LingeringPotionBundle.java similarity index 95% rename from src/main/java/com/github/ichhabehunger54/potionbundles/LingeringPotionBundle.java rename to src/main/java/com/github/minecraftschurlimods/potionbundles/LingeringPotionBundle.java index 65f2e84..3f4b00f 100644 --- a/src/main/java/com/github/ichhabehunger54/potionbundles/LingeringPotionBundle.java +++ b/src/main/java/com/github/minecraftschurlimods/potionbundles/LingeringPotionBundle.java @@ -1,4 +1,4 @@ -package com.github.ichhabehunger54.potionbundles; +package com.github.minecraftschurlimods.potionbundles; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvents; diff --git a/src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundle.java b/src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundle.java similarity index 97% rename from src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundle.java rename to src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundle.java index 573cab5..136749e 100644 --- a/src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundle.java +++ b/src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundle.java @@ -1,4 +1,4 @@ -package com.github.ichhabehunger54.potionbundles; +package com.github.minecraftschurlimods.potionbundles; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.network.chat.Component; diff --git a/src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundleRecipe.java b/src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundleRecipe.java similarity index 87% rename from src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundleRecipe.java rename to src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundleRecipe.java index c3a302b..b2e277c 100644 --- a/src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundleRecipe.java +++ b/src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundleRecipe.java @@ -1,7 +1,8 @@ -package com.github.ichhabehunger54.potionbundles; +package com.github.minecraftschurlimods.potionbundles; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; +import net.minecraft.core.RegistryAccess; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffectInstance; @@ -17,18 +18,18 @@ import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.Level; import net.minecraftforge.registries.ForgeRegistries; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Objects; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; public class PotionBundleRecipe extends CustomRecipe { private final Ingredient string; private final Item potion; private final AbstractPotionBundle bundle; - public PotionBundleRecipe(ResourceLocation id, @Nonnull Ingredient string, @Nonnull Item potion, @Nonnull AbstractPotionBundle bundle) { + public PotionBundleRecipe(ResourceLocation id, @NotNull Ingredient string, @NotNull Item potion, @NotNull AbstractPotionBundle bundle) { super(id, CraftingBookCategory.EQUIPMENT); this.string = string; this.potion = potion; @@ -36,7 +37,7 @@ public PotionBundleRecipe(ResourceLocation id, @Nonnull Ingredient string, @Nonn } @Override - public boolean matches(CraftingContainer inv, @Nonnull Level world) { + public boolean matches(CraftingContainer inv, @NotNull Level world) { int potions = 0; boolean string = false; Potion potion = Potions.EMPTY; @@ -69,9 +70,9 @@ public boolean matches(CraftingContainer inv, @Nonnull Level world) { return potions == this.bundle.getMaxUses() && string; } - @Nonnull + @NotNull @Override - public ItemStack assemble(CraftingContainer inv) { + public ItemStack assemble(CraftingContainer inv, @NotNull RegistryAccess registryAccess) { Potion potion = null; List customEffects = null; ItemStack string = null; @@ -94,7 +95,7 @@ public boolean canCraftInDimensions(int width, int height) { return width * height > this.bundle.getMaxUses(); } - @Nonnull + @NotNull @Override public RecipeSerializer getSerializer() { return PotionBundles.POTION_BUNDLE_RECIPE_SERIALIZER.get(); @@ -108,15 +109,15 @@ public Item getPotionItem() { return this.potion; } - @Nonnull + @NotNull public Ingredient getString() { return string; } static class Serializer implements RecipeSerializer { - @Nonnull + @NotNull @Override - public PotionBundleRecipe fromJson(@Nonnull ResourceLocation rl, @Nonnull JsonObject json) { + public PotionBundleRecipe fromJson(@NotNull ResourceLocation rl, @NotNull JsonObject json) { Ingredient string = Ingredient.fromJson(json.get("string")); Item potion = ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(json.get("potion").getAsString())); if (potion == null) @@ -132,7 +133,7 @@ public PotionBundleRecipe fromJson(@Nonnull ResourceLocation rl, @Nonnull JsonOb @Nullable @Override - public PotionBundleRecipe fromNetwork(@Nonnull ResourceLocation rl, @Nonnull FriendlyByteBuf buf) { + public PotionBundleRecipe fromNetwork(@NotNull ResourceLocation rl, @NotNull FriendlyByteBuf buf) { Ingredient string = Ingredient.fromNetwork(buf); Item potion = ForgeRegistries.ITEMS.getValue(buf.readResourceLocation()); Item bundle = ForgeRegistries.ITEMS.getValue(buf.readResourceLocation()); @@ -142,7 +143,7 @@ public PotionBundleRecipe fromNetwork(@Nonnull ResourceLocation rl, @Nonnull Fri } @Override - public void toNetwork(@Nonnull FriendlyByteBuf buf, @Nonnull PotionBundleRecipe recipe) { + public void toNetwork(@NotNull FriendlyByteBuf buf, @NotNull PotionBundleRecipe recipe) { recipe.string.toNetwork(buf); buf.writeResourceLocation(Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(recipe.potion))); buf.writeResourceLocation(Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(recipe.bundle))); diff --git a/src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundleUtils.java b/src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundleUtils.java similarity index 96% rename from src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundleUtils.java rename to src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundleUtils.java index da7fc8e..1e01157 100644 --- a/src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundleUtils.java +++ b/src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundleUtils.java @@ -1,4 +1,4 @@ -package com.github.ichhabehunger54.potionbundles; +package com.github.minecraftschurlimods.potionbundles; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; diff --git a/src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundles.java b/src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundles.java similarity index 84% rename from src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundles.java rename to src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundles.java index 65467af..6d9c97e 100644 --- a/src/main/java/com/github/ichhabehunger54/potionbundles/PotionBundles.java +++ b/src/main/java/com/github/minecraftschurlimods/potionbundles/PotionBundles.java @@ -1,6 +1,7 @@ -package com.github.ichhabehunger54.potionbundles; +package com.github.minecraftschurlimods.potionbundles; import net.minecraft.client.Minecraft; +import net.minecraft.core.RegistryAccess; import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -10,7 +11,7 @@ import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraftforge.event.CreativeModeTabEvent; +import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModLoadingContext; @@ -46,15 +47,15 @@ public PotionBundles() { ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Config.serverSpec); } - private static void registerItemsToCreativeTabs(CreativeModeTabEvent.BuildContents event) { - if (event.getTab() != CreativeModeTabs.FOOD_AND_DRINKS) return; + private static void registerItemsToCreativeTabs(BuildCreativeModeTabContentsEvent event) { + if (event.getTabKey() != CreativeModeTabs.FOOD_AND_DRINKS) return; addBundlesForAllPotions(event, POTION_BUNDLE.get()); addBundlesForAllPotions(event, SPLASH_POTION_BUNDLE.get()); addBundlesForAllPotions(event, LINGERING_POTION_BUNDLE.get()); } - private static void addBundlesForAllPotions(CreativeModeTabEvent.BuildContents populator, @NotNull AbstractPotionBundle bundle) { - ItemStack string = getStringFromRecipe(bundle); + private static void addBundlesForAllPotions(BuildCreativeModeTabContentsEvent populator, @NotNull AbstractPotionBundle bundle) { + ItemStack string = getStringFromRecipe(bundle, ((RegistryAccess) populator.getParameters().holders())); for (Potion potion : ForgeRegistries.POTIONS.getValues()) { if (potion == Potions.EMPTY) continue; ItemStack stack = bundle.createStack(string, potion, List.of(), null); @@ -63,14 +64,14 @@ private static void addBundlesForAllPotions(CreativeModeTabEvent.BuildContents p } @Nonnull - private static ItemStack getStringFromRecipe(@Nonnull AbstractPotionBundle bundle) { + private static ItemStack getStringFromRecipe(@Nonnull AbstractPotionBundle bundle, RegistryAccess registryAccess) { RecipeManager recipeManager = DistExecutor.unsafeRunForDist( () -> () -> Minecraft.getInstance().getConnection().getRecipeManager(), () -> () -> ServerLifecycleHooks.getCurrentServer().getRecipeManager() ); for (Recipe recipe : recipeManager.getRecipes()) { if (recipe.getSerializer() != POTION_BUNDLE_RECIPE_SERIALIZER.get()) continue; - if (recipe.getResultItem().getItem() != bundle) continue; + if (recipe.getResultItem(registryAccess).getItem() != bundle) continue; PotionBundleRecipe potionBundleRecipe = (PotionBundleRecipe) recipe; Ingredient stringIngredient = potionBundleRecipe.getString(); ItemStack[] stacks = stringIngredient.getItems(); diff --git a/src/main/java/com/github/ichhabehunger54/potionbundles/SplashPotionBundle.java b/src/main/java/com/github/minecraftschurlimods/potionbundles/SplashPotionBundle.java similarity index 95% rename from src/main/java/com/github/ichhabehunger54/potionbundles/SplashPotionBundle.java rename to src/main/java/com/github/minecraftschurlimods/potionbundles/SplashPotionBundle.java index 880f3c3..03080ef 100644 --- a/src/main/java/com/github/ichhabehunger54/potionbundles/SplashPotionBundle.java +++ b/src/main/java/com/github/minecraftschurlimods/potionbundles/SplashPotionBundle.java @@ -1,4 +1,4 @@ -package com.github.ichhabehunger54.potionbundles; +package com.github.minecraftschurlimods.potionbundles; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvents; diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index 58e97cf..bdd1899 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1 +1 @@ -{"pack":{"description":"potionbundles resources","pack_format":12}} +{"pack":{"description":"potionbundles resources","pack_format":15}} diff --git a/summary.txt b/summary.txt index 3596558..497837e 100644 --- a/summary.txt +++ b/summary.txt @@ -1 +1 @@ -Now works with versions of forge above 44.1 \ No newline at end of file +Updated to 1.20 \ No newline at end of file