diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 30b3b4ce..341000c0 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -14,10 +14,10 @@ jobs: with: fetch-depth: 0 fetch-tags: true - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' + java-version: '21' distribution: 'oracle' server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file diff --git a/build.gradle b/build.gradle index a21b35e6..535b8808 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ subprojects { version = "${minecraft_version}-${mod_version}" - java.toolchain.languageVersion = JavaLanguageVersion.of(17) + java.toolchain.languageVersion = JavaLanguageVersion.of(21) java.withSourcesJar() jar { @@ -74,7 +74,7 @@ subprojects { tasks.withType(JavaCompile).configureEach { it.options.encoding = 'UTF-8' - it.options.release.set(17) + it.options.release.set(21) } processResources { @@ -89,7 +89,7 @@ subprojects { mod_discord_url : mod_discord_url, mod_license : mod_license ] - filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', "*.mixins.json"]) { + filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', 'META-INF/neoforge.mods.toml', "*.mixins.json"]) { expand expandProps } inputs.properties(expandProps) diff --git a/common/src/generated/resources/.cache/34eff76d8db6df414572b0996d464f3a4bc943ee b/common/src/generated/resources/.cache/34eff76d8db6df414572b0996d464f3a4bc943ee index 67895f9b..da19430b 100644 --- a/common/src/generated/resources/.cache/34eff76d8db6df414572b0996d464f3a4bc943ee +++ b/common/src/generated/resources/.cache/34eff76d8db6df414572b0996d464f3a4bc943ee @@ -1,4 +1,4 @@ -// 1.20.4 2024-01-19T10:21:08.5970511 Item Models: sereneseasons +// 1.20.6 2024-05-05T10:18:49.4009886 Item Models: sereneseasons 8131cb872e089e4f0ac2bccf3d4d7a25d7d92ec7 assets/sereneseasons/models/item/calendar.json cb387a39c39a0f4665c565e7218cd4426875246a assets/sereneseasons/models/item/calendar_00.json c154671ec34c7931bc05c47db4f69f21a5e413c7 assets/sereneseasons/models/item/calendar_01.json diff --git a/common/src/generated/resources/.cache/51dc2b66606c1345aa908ef96784ba8686abe32c b/common/src/generated/resources/.cache/51dc2b66606c1345aa908ef96784ba8686abe32c index 8be23a4c..cdb0bcd6 100644 --- a/common/src/generated/resources/.cache/51dc2b66606c1345aa908ef96784ba8686abe32c +++ b/common/src/generated/resources/.cache/51dc2b66606c1345aa908ef96784ba8686abe32c @@ -1,4 +1,4 @@ -// 1.20.4 2024-01-19T10:21:08.5955455 Block States: sereneseasons +// 1.20.6 2024-05-05T10:18:49.3994883 Block States: sereneseasons edf060403d4f871caf88b27e91d713ee2be4ebc1 assets/sereneseasons/blockstates/season_sensor.json 2797b7f59442c019e778d4e72e49c819153d75b3 assets/sereneseasons/models/block/season_sensor_autumn.json 607600cb666bf37bc704c834d7d0ffc585b405d0 assets/sereneseasons/models/block/season_sensor_spring.json diff --git a/common/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/common/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e new file mode 100644 index 00000000..39b427c9 --- /dev/null +++ b/common/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -0,0 +1,5 @@ +// 1.20.6 2024-05-05T10:18:49.3999887 Recipes +e072858e57ee517a9ad673759ea337523f1faf58 data/sereneseasons/advancements/recipes/redstone/season_sensor.json +a6e2e9061195651e5a5ebe536429b983725e47a8 data/sereneseasons/advancements/recipes/tools/calendar.json +6dcfb1f16a07426dedd4bb0c22cf7e8875aaa637 data/sereneseasons/recipes/calendar.json +3a8122eb3cd03dfa946e5daabcc7c0a9813346e2 data/sereneseasons/recipes/season_sensor.json diff --git a/common/src/main/resources/data/sereneseasons/advancements/recipes/redstone/season_sensor.json b/common/src/generated/resources/data/sereneseasons/advancements/recipes/redstone/season_sensor.json similarity index 65% rename from common/src/main/resources/data/sereneseasons/advancements/recipes/redstone/season_sensor.json rename to common/src/generated/resources/data/sereneseasons/advancements/recipes/redstone/season_sensor.json index 35050437..aa94c3d6 100644 --- a/common/src/main/resources/data/sereneseasons/advancements/recipes/redstone/season_sensor.json +++ b/common/src/generated/resources/data/sereneseasons/advancements/recipes/redstone/season_sensor.json @@ -1,27 +1,21 @@ { - "rewards": { - "recipes": [ - "sereneseasons:season_sensor" - ] - }, + "parent": "minecraft:recipes/root", "criteria": { - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "sereneseasons:season_sensor" - } - }, "has_calendar": { - "trigger": "minecraft:inventory_changed", "conditions": { "items": [ { - "items": [ - "sereneseasons:calendar" - ] + "items": "sereneseasons:calendar" } ] - } + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "sereneseasons:season_sensor" + }, + "trigger": "minecraft:recipe_unlocked" } }, "requirements": [ @@ -29,5 +23,10 @@ "has_the_recipe", "has_calendar" ] - ] + ], + "rewards": { + "recipes": [ + "sereneseasons:season_sensor" + ] + } } \ No newline at end of file diff --git a/common/src/main/resources/data/sereneseasons/advancements/recipes/tools/calendar.json b/common/src/generated/resources/data/sereneseasons/advancements/recipes/tools/calendar.json similarity index 57% rename from common/src/main/resources/data/sereneseasons/advancements/recipes/tools/calendar.json rename to common/src/generated/resources/data/sereneseasons/advancements/recipes/tools/calendar.json index 2a669927..a6cd8737 100644 --- a/common/src/main/resources/data/sereneseasons/advancements/recipes/tools/calendar.json +++ b/common/src/generated/resources/data/sereneseasons/advancements/recipes/tools/calendar.json @@ -1,33 +1,32 @@ { - "rewards": { - "recipes": [ - "sereneseasons:calendar" - ] - }, + "parent": "minecraft:recipes/root", "criteria": { "has_clock": { - "trigger": "minecraft:inventory_changed", "conditions": { "items": [ { - "items": [ - "minecraft:clock" - ] + "items": "minecraft:clock" } ] - } + }, + "trigger": "minecraft:inventory_changed" }, "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", "conditions": { "recipe": "sereneseasons:calendar" - } + }, + "trigger": "minecraft:recipe_unlocked" } }, "requirements": [ [ - "has_clock", - "has_the_recipe" + "has_the_recipe", + "has_clock" + ] + ], + "rewards": { + "recipes": [ + "sereneseasons:calendar" ] - ] + } } \ No newline at end of file diff --git a/common/src/main/resources/data/sereneseasons/recipes/calendar.json b/common/src/generated/resources/data/sereneseasons/recipes/calendar.json similarity index 58% rename from common/src/main/resources/data/sereneseasons/recipes/calendar.json rename to common/src/generated/resources/data/sereneseasons/recipes/calendar.json index efc994c6..24eb49df 100644 --- a/common/src/main/resources/data/sereneseasons/recipes/calendar.json +++ b/common/src/generated/resources/data/sereneseasons/recipes/calendar.json @@ -1,19 +1,21 @@ { - "type": "crafting_shaped", - "pattern": [ - "PPP", - "PCP", - "PPP" - ], + "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { + "C": { + "item": "minecraft:clock" + }, "P": { "item": "minecraft:paper" - }, - "C": { - "item": "minecraft:clock" } }, + "pattern": [ + "PPP", + "PCP", + "PPP" + ], "result": { - "item": "sereneseasons:calendar" + "count": 1, + "id": "sereneseasons:calendar" } } \ No newline at end of file diff --git a/common/src/generated/resources/data/sereneseasons/recipes/season_sensor.json b/common/src/generated/resources/data/sereneseasons/recipes/season_sensor.json new file mode 100644 index 00000000..9bd29ca8 --- /dev/null +++ b/common/src/generated/resources/data/sereneseasons/recipes/season_sensor.json @@ -0,0 +1,27 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "redstone", + "key": { + "#": { + "item": "minecraft:cobblestone_slab" + }, + "C": { + "item": "sereneseasons:calendar" + }, + "G": { + "item": "minecraft:glass" + }, + "Q": { + "item": "minecraft:quartz" + } + }, + "pattern": [ + "GGG", + "QCQ", + "###" + ], + "result": { + "count": 1, + "id": "sereneseasons:season_sensor" + } +} \ No newline at end of file diff --git a/common/src/main/java/sereneseasons/block/SeasonSensorBlock.java b/common/src/main/java/sereneseasons/block/SeasonSensorBlock.java index 0f25866c..c6b5bb3d 100644 --- a/common/src/main/java/sereneseasons/block/SeasonSensorBlock.java +++ b/common/src/main/java/sereneseasons/block/SeasonSensorBlock.java @@ -96,25 +96,25 @@ public void updatePower(Level world, BlockPos pos) } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult rayTraceResult) + protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult rayTraceResult) { if (player.mayBuild()) { - if (world.isClientSide) + if (level.isClientSide) { return InteractionResult.SUCCESS; } else { BlockState blockstate = state.cycle(SEASON); - world.setBlock(pos, blockstate, 4); - updatePower(world, pos); + level.setBlock(pos, blockstate, 4); + updatePower(level, pos); return InteractionResult.SUCCESS; } } else { - return super.use(state, world, pos, player, hand, rayTraceResult); + return super.useWithoutItem(state, level, pos, player, rayTraceResult); } } diff --git a/common/src/main/java/sereneseasons/item/CalendarItem.java b/common/src/main/java/sereneseasons/item/CalendarItem.java index 04bf6841..26d58487 100644 --- a/common/src/main/java/sereneseasons/item/CalendarItem.java +++ b/common/src/main/java/sereneseasons/item/CalendarItem.java @@ -1,11 +1,14 @@ package sereneseasons.item; import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; +import net.minecraft.world.level.saveddata.maps.MapId; import sereneseasons.api.season.SeasonHelper; import sereneseasons.init.ModConfig; import sereneseasons.season.SeasonTime; @@ -22,13 +25,15 @@ public CalendarItem(Properties p_41383_) } @Override - public void appendHoverText(ItemStack stack, @Nullable Level world, List tooltip, TooltipFlag flag) + public void appendHoverText(ItemStack stack, Item.TooltipContext context, List tooltip, TooltipFlag flag) { - if (world != null) + Level level = Minecraft.getInstance().level; + + if (level != null) { - if (ModConfig.seasons.isDimensionWhitelisted(world.dimension())) + if (ModConfig.seasons.isDimensionWhitelisted(level.dimension())) { - int seasonCycleTicks = SeasonHelper.getSeasonState(world).getSeasonCycleTicks(); + int seasonCycleTicks = SeasonHelper.getSeasonState(level).getSeasonCycleTicks(); SeasonTime time = new SeasonTime(seasonCycleTicks); int subSeasonDuration = ModConfig.seasons.subSeasonDuration; diff --git a/common/src/main/java/sereneseasons/season/SeasonSavedData.java b/common/src/main/java/sereneseasons/season/SeasonSavedData.java index c33e0f4b..0910c5c8 100644 --- a/common/src/main/java/sereneseasons/season/SeasonSavedData.java +++ b/common/src/main/java/sereneseasons/season/SeasonSavedData.java @@ -4,6 +4,7 @@ ******************************************************************************/ package sereneseasons.season; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Mth; import net.minecraft.world.level.saveddata.SavedData; @@ -16,16 +17,18 @@ public class SeasonSavedData extends SavedData public int seasonCycleTicks; @Override - public CompoundTag save(CompoundTag nbt) + public CompoundTag save(CompoundTag nbt, HolderLookup.Provider provider) { nbt.putInt("SeasonCycleTicks", this.seasonCycleTicks); return nbt; } - public static SeasonSavedData load(CompoundTag nbt) + public static SeasonSavedData load(CompoundTag nbt, HolderLookup.Provider provider) { SeasonSavedData data = new SeasonSavedData(); data.seasonCycleTicks = Mth.clamp(nbt.getInt("SeasonCycleTicks"), 0, SeasonTime.ZERO.getCycleDuration()); return data; } + + } diff --git a/common/src/main/resources/data/sereneseasons/recipes/season_sensor.json b/common/src/main/resources/data/sereneseasons/recipes/season_sensor.json deleted file mode 100644 index 53a0c6ff..00000000 --- a/common/src/main/resources/data/sereneseasons/recipes/season_sensor.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "crafting_shaped", - "pattern": [ - "GGG", - "QCQ", - "###" - ], - "key": { - "#": { - "item": "minecraft:cobblestone_slab", - "data": 3 - }, - "C": { - "item": "sereneseasons:calendar" - }, - "Q": { - "tag": "forge:gems/quartz" - }, - "G": { - "tag": "forge:glass/colorless" - } - }, - "result": { - "item": "sereneseasons:season_sensor" - } -} \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle index a72582a0..4504334a 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,5 +1,5 @@ plugins { - id "fabric-loom" version "1.4-SNAPSHOT" + id "fabric-loom" version "1.6-SNAPSHOT" id "com.matthewprenger.cursegradle" version "1.4.0" } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 548a218a..9e240416 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -28,7 +28,7 @@ "fabricloader": "*", "fabric": "*", "minecraft": "${minecraft_version}", - "java": ">=17", + "java": ">=21", "glitchcore": ">=${glitchcore_version}" }, "accessWidener": "${mod_id}.accesswidener", diff --git a/forge/build.gradle b/forge/build.gradle index 061b3cc9..ef72afe6 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -20,6 +20,8 @@ minecraft { accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') } + reobf = false + runs { client { workingDirectory project.file('run') @@ -36,29 +38,17 @@ minecraft { property 'mixin.env.remapRefMap', 'true' property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" } - - data { - workingDirectory project.file('run') - ideaModule "${rootProject.name}.${project.name}.main" - args '--mod', mod_id, '--all', '--output', project(':Common').file('src/generated/resources/'), '--existing', project(':Common').file('src/main/resources/') - taskName 'Data' - property 'mixin.env.remapRefMap', 'true' - property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" - } } } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" compileOnly project(":Common") - implementation fg.deobf('com.github.glitchfiend:GlitchCore-forge:' + minecraft_version + '-' + glitchcore_version) + implementation 'com.github.glitchfiend:GlitchCore-forge:' + minecraft_version + '-' + glitchcore_version annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' -} -// Workaround for SpongePowered/MixinGradle#38 -afterEvaluate { - tasks.configureReobfTaskForReobfJar.mustRunAfter(tasks.compileJava) - tasks.configureReobfTaskForReobfJarJar.mustRunAfter(tasks.compileJava) + // Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transtive dependencies request 6.0+ + implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } } } tasks.withType(JavaCompile).configureEach { @@ -77,8 +67,6 @@ processResources { from project(":Common").sourceSets.main.resources } -jar.finalizedBy('reobfJar') - // Merge the resources and classes into the same directory. // This is done because java expects modules to be in a single directory. // And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem diff --git a/forge/src/main/java/sereneseasons/forge/core/SereneSeasonsForge.java b/forge/src/main/java/sereneseasons/forge/core/SereneSeasonsForge.java index f6c76a2d..49c38d19 100644 --- a/forge/src/main/java/sereneseasons/forge/core/SereneSeasonsForge.java +++ b/forge/src/main/java/sereneseasons/forge/core/SereneSeasonsForge.java @@ -13,6 +13,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.registries.DeferredRegister; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -29,7 +30,6 @@ public SereneSeasonsForge() bus.addListener(this::clientSetup); SereneSeasons.init(); - GlitchCoreForge.prepareModEventHandlers(bus); } private void clientSetup(final FMLClientSetupEvent event) diff --git a/gradle.properties b/gradle.properties index 73f9827a..5999c577 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,21 +3,21 @@ group=com.github.glitchfiend release_channel=beta # Common -minecraft_version=1.20.4 +minecraft_version=1.20.6 # Forge -forge_version=49.0.3 -forge_version_range=[49.0.3,) -forge_loader_version_range=[49,) +forge_version=50.0.5 +forge_version_range=[50.0.5,) +forge_loader_version_range=[50,) # NeoForge -neoforge_version=20.4.75-beta -neoforge_version_range=[20.4,) +neoforge_version=20.6.24-beta +neoforge_version_range=[20.6,) neoforge_loader_version_range=[1,) # Fabric -fabric_version=0.91.1+1.20.4 -fabric_loader_version=0.15.1 +fabric_version=0.97.8+1.20.6 +fabric_loader_version=0.15.11 # Mod options mod_id=sereneseasons @@ -40,4 +40,4 @@ org.gradle.daemon=false # Dependencies nightconfig_version=3.6.7 -glitchcore_version=1.0.0.54 +glitchcore_version=1.1.0.2 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a79..d64cd491 100755 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 744c64d1..b82aa23a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cbb..1aa94a42 100755 --- a/gradlew +++ b/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -130,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -198,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 41e205fa..933fa354 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -6,11 +6,6 @@ plugins { base.archivesName.set("${mod_name}-neoforge") -mixin { - config "${mod_id}.mixins.json" - config "${mod_id}.neoforge.mixins.json" -} - minecraft { mappings { channel = official() @@ -34,6 +29,10 @@ runs { systemProperty 'neoforge.enabledGameTestNamespaces', mod_id programArgument '--nogui' } + + data { + programArguments.addAll '--mod', project.mod_id, '--all', '--output', project(':Common').file('src/generated/resources/').getAbsolutePath(), '--existing', project(':Common').file('src/main/resources/').getAbsolutePath() + } } dependencies { diff --git a/forge/src/main/java/sereneseasons/forge/datagen/DataGenerationHandler.java b/neoforge/src/main/java/sereneseasons/datagen/DataGenerationHandler.java similarity index 53% rename from forge/src/main/java/sereneseasons/forge/datagen/DataGenerationHandler.java rename to neoforge/src/main/java/sereneseasons/datagen/DataGenerationHandler.java index 01ad27bc..9fe52521 100644 --- a/forge/src/main/java/sereneseasons/forge/datagen/DataGenerationHandler.java +++ b/neoforge/src/main/java/sereneseasons/datagen/DataGenerationHandler.java @@ -2,27 +2,31 @@ * Copyright 2022, the Glitchfiend Team. * All rights reserved. ******************************************************************************/ -package sereneseasons.forge.datagen; +package sereneseasons.datagen; import net.minecraft.data.DataGenerator; import net.minecraft.data.PackOutput; -import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.data.event.GatherDataEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.neoforge.common.data.ExistingFileHelper; +import net.neoforged.neoforge.data.event.GatherDataEvent; +import sereneseasons.datagen.provider.SSRecipeProvider; -@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD) public class DataGenerationHandler { @SubscribeEvent public static void onGatherData(GatherDataEvent event) { DataGenerator generator = event.getGenerator(); - PackOutput packOutput = generator.getPackOutput(); + PackOutput output = generator.getPackOutput(); ExistingFileHelper existingFileHelper = event.getExistingFileHelper(); // Client - generator.addProvider(event.includeClient(), new SSBlockStateProvider(packOutput, existingFileHelper)); - generator.addProvider(event.includeClient(), new SSItemModelProvider(packOutput, existingFileHelper)); + generator.addProvider(event.includeClient(), new SSBlockStateProvider(output, existingFileHelper)); + generator.addProvider(event.includeClient(), new SSItemModelProvider(output, existingFileHelper)); + + // Recipes + generator.addProvider(event.includeServer(), new SSRecipeProvider(output, event.getLookupProvider())); } } diff --git a/forge/src/main/java/sereneseasons/forge/datagen/SSBlockStateProvider.java b/neoforge/src/main/java/sereneseasons/datagen/SSBlockStateProvider.java similarity index 84% rename from forge/src/main/java/sereneseasons/forge/datagen/SSBlockStateProvider.java rename to neoforge/src/main/java/sereneseasons/datagen/SSBlockStateProvider.java index 632decf8..e06f607c 100644 --- a/forge/src/main/java/sereneseasons/forge/datagen/SSBlockStateProvider.java +++ b/neoforge/src/main/java/sereneseasons/datagen/SSBlockStateProvider.java @@ -2,24 +2,21 @@ * Copyright 2022, the Glitchfiend Team. * All rights reserved. ******************************************************************************/ -package sereneseasons.forge.datagen; +package sereneseasons.datagen; import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.model.generators.*; -import net.minecraftforge.common.data.ExistingFileHelper; +import net.neoforged.neoforge.client.model.generators.*; +import net.neoforged.neoforge.common.data.ExistingFileHelper; import sereneseasons.api.SSBlocks; import sereneseasons.api.season.Season; import sereneseasons.block.SeasonSensorBlock; import sereneseasons.core.SereneSeasons; -import sereneseasons.forge.core.SereneSeasonsForge; import java.util.Arrays; import java.util.Map; import java.util.stream.Collectors; -import static net.minecraftforge.client.model.generators.ModelProvider.BLOCK_FOLDER; - public class SSBlockStateProvider extends BlockStateProvider { public SSBlockStateProvider(PackOutput output, ExistingFileHelper exFileHelper) @@ -57,7 +54,7 @@ public BlockModelBuilder seasonSensor(Season season) public BlockModelBuilder daylightDetector(String name, ResourceLocation top, ResourceLocation side) { - return this.models().withExistingParent(name, BLOCK_FOLDER + "/template_daylight_detector") + return this.models().withExistingParent(name, ModelProvider.BLOCK_FOLDER + "/template_daylight_detector") .texture("top", top) .texture("side", side); } diff --git a/forge/src/main/java/sereneseasons/forge/datagen/SSItemModelProvider.java b/neoforge/src/main/java/sereneseasons/datagen/SSItemModelProvider.java similarity index 78% rename from forge/src/main/java/sereneseasons/forge/datagen/SSItemModelProvider.java rename to neoforge/src/main/java/sereneseasons/datagen/SSItemModelProvider.java index e5ef18aa..7a642c08 100644 --- a/forge/src/main/java/sereneseasons/forge/datagen/SSItemModelProvider.java +++ b/neoforge/src/main/java/sereneseasons/datagen/SSItemModelProvider.java @@ -2,19 +2,15 @@ * Copyright 2022, the Glitchfiend Team. * All rights reserved. ******************************************************************************/ -package sereneseasons.forge.datagen; +package sereneseasons.datagen; import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraftforge.client.model.generators.ItemModelBuilder; -import net.minecraftforge.client.model.generators.ItemModelProvider; -import net.minecraftforge.client.model.generators.ModelFile; -import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.registries.RegistryObject; +import net.neoforged.neoforge.client.model.generators.ItemModelProvider; +import net.neoforged.neoforge.client.model.generators.ModelFile; +import net.neoforged.neoforge.common.data.ExistingFileHelper; import sereneseasons.api.SSItems; import sereneseasons.core.SereneSeasons; -import sereneseasons.forge.core.SereneSeasonsForge; import sereneseasons.item.CalendarType; public class SSItemModelProvider extends ItemModelProvider @@ -70,18 +66,8 @@ private void registerCalendarModels() .model(calendarNull); } - public ItemModelBuilder basicItem(RegistryObject item) - { - return this.basicItem(getItemLocation(item)); - } - private static ResourceLocation location(String name) { return new ResourceLocation(SereneSeasons.MOD_ID, name); } - - private static ResourceLocation getItemLocation(RegistryObject obj) - { - return obj.getKey().location(); - } } diff --git a/neoforge/src/main/java/sereneseasons/datagen/provider/SSRecipeProvider.java b/neoforge/src/main/java/sereneseasons/datagen/provider/SSRecipeProvider.java new file mode 100644 index 00000000..cd4b8321 --- /dev/null +++ b/neoforge/src/main/java/sereneseasons/datagen/provider/SSRecipeProvider.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2024, the Glitchfiend Team. + * All rights reserved. + ******************************************************************************/ +package sereneseasons.datagen.provider; + +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.data.recipes.RecipeOutput; +import net.minecraft.data.recipes.RecipeProvider; +import net.minecraft.data.recipes.ShapedRecipeBuilder; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Blocks; +import sereneseasons.api.SSBlocks; +import sereneseasons.api.SSItems; + +import java.util.concurrent.CompletableFuture; + +public class SSRecipeProvider extends RecipeProvider +{ + public SSRecipeProvider(PackOutput output, CompletableFuture lookupProvider) + { + super(output, lookupProvider); + } + + @Override + protected void buildRecipes(RecipeOutput output) + { + ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, SSBlocks.SEASON_SENSOR).define('G', Items.GLASS).define('Q', Items.QUARTZ).define('C', SSItems.CALENDAR).define('#', Blocks.COBBLESTONE_SLAB).pattern("GGG").pattern("QCQ").pattern("###").unlockedBy("has_calendar", has(SSItems.CALENDAR)).save(output); + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, SSItems.CALENDAR).define('P', Items.PAPER).define('C', Items.CLOCK).pattern("PPP").pattern("PCP").pattern("PPP").unlockedBy("has_clock", has(Items.CLOCK)).save(output); + } + +} diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml similarity index 86% rename from neoforge/src/main/resources/META-INF/mods.toml rename to neoforge/src/main/resources/META-INF/neoforge.mods.toml index fd72875c..83018052 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -5,6 +5,12 @@ issueTrackerURL="${mod_issues_url}" displayURL="${mod_page_url}" logoFile="${mod_id}_logo.png" +[[mixins]] + config="${mod_id}.mixins.json" + +[[mixins]] + config="${mod_id}.neoforge.mixins.json" + [[mods]] modId="${mod_id}" version="${mod_version}" diff --git a/settings.gradle b/settings.gradle index cceeb921..611ff8ed 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -include("common", "forge", "neoforge", "fabric") +include("common", /*"forge",*/ "neoforge", "fabric") pluginManagement.repositories { gradlePluginPortal() @@ -24,6 +24,6 @@ rootProject.name = "SereneSeasons" // We want lowercase folder names but uppercase project names project(":common").name = "Common" -project(":forge").name = "Forge" +//project(":forge").name = "Forge" project(":neoforge").name = "NeoForge" project(":fabric").name = "Fabric" \ No newline at end of file