diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index f8ce427..0000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,31 +0,0 @@ -#### Issue Description: -Note: If this bug occurs in a modpack, please report this to the modpack author. Otherwise, delete this line and add your description here. If this is a feature request, this template does not apply to you. Just delete everything. - - -#### What happens: - - - -#### What you expected to happen: - - - -#### Steps to reproduce: - -1. -2. -3. -... - -____ -#### Affected Versions (Do *not* use "latest"): - -- Anvil Fix: -- Minecraft: -- Fabric Loader: -- Fabric API (if present): - -#### Possibly Conflicting Mods (Provide their version, as well): -- mod1 (1.0.0) -- mod2 (1.2.3.108) -- mod3 (1.14-1.3-123) diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 002f265..0000000 --- a/.github/stale.yml +++ /dev/null @@ -1,25 +0,0 @@ -# configuration file for the 'Stale' bot (https://github.com/probot/stale) - -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 30 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 - -# Label to use when marking an issue as stale -staleLabel: stale - -# do not affect pull requests -only: issues - -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false - -# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable -exemptLabels: - - enhancement - - bug diff --git a/.github/workflows/build_status.yml b/.github/workflows/build_status.yml index 0f2e0fa..17b9ddb 100644 --- a/.github/workflows/build_status.yml +++ b/.github/workflows/build_status.yml @@ -4,22 +4,43 @@ on: push: paths-ignore: - '.github/**' - tags-ignore: - - '*.*' branches: - - '*.*' - + - '*' + pull_request: jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 17 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'microsoft' java-version: 17 + cache: 'gradle' - name: Grant execute permission for gradlew - run: chmod +x gradlew + run: chmod +x ./gradlew - name: Build with Gradle run: ./gradlew build + - name: Upload build artifacts (Common) + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}-Common-${{ github.sha }} + path: | + Common/build/libs/!(*-@(dev|slim)).jar + - name: Upload build artifacts (NeoForge) + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}-NeoForge-${{ github.sha }} + path: | + NeoForge/build/libs/!(*-@(dev|slim)).jar + - name: Upload build artifacts (Quilt) + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}-Quilt-${{ github.sha }} + path: | + Quilt/build/libs/!(*-@(dev|slim)).jar diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af762d6..568a381 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,51 +9,85 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 17 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'microsoft' java-version: 17 - name: Get current time uses: srfrnk/current-time@master id: current-time with: format: YYYYMMDDHHmmss - - name: Create release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - name: Setup ENV - run: echo "TAG=${GITHUB_REF:10}" >> $GITHUB_ENV + run: echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV + - name: Copy Maven Upload URL + id: extract_maven_upload_url + run: echo "maven_upload_url=${{secrets.MAVEN_UPLOAD_URL}}" >> $GITHUB_OUTPUT - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Assemble jar with Gradle + run: chmod +x ./gradlew + - name: Build with Gradle env: BUILD_TIME: ${{ steps.current-time.outputs.formattedTime }} BUILD_NUMBER: ${{ github.run_number }} run: ./gradlew assemble - - name: Publish - id: publish_release_assets + - name: Maven Release + if: steps.extract_maven_upload_url.outputs.maven_upload_url + continue-on-error: true run: ./gradlew publish env: BUILD_TIME: ${{ steps.current-time.outputs.formattedTime }} BUILD_NUMBER: ${{ github.run_number }} - MAVEN_UPLOAD_URL: ${{ secrets.ONYX_MAVEN_UPLOAD_URL }} - MAVEN_UPLOAD_USER: ${{ secrets.ONYX_MAVEN_USERNAME }} - MAVEN_UPLOAD_PASSWORD: ${{ secrets.ONYX_MAVEN_ACCESS_TOKEN }} - MODRINTH_USER: ${{ secrets.MODRINTH_USER }} - MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} - CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} - - name: Upload release assets - id: upload_release_assets - uses: AButler/upload-release-assets@v2.0 - with: - release-tag: ${{ env.TAG }} - repo-token: ${{ github.token }} - files: 'build/libs/*[!-dev].jar' + MAVEN_UPLOAD_URL: ${{ secrets.MAVEN_UPLOAD_URL }} + MAVEN_UPLOAD_USERNAME: ${{ secrets.MAVEN_UPLOAD_USERNAME }} + MAVEN_UPLOAD_PASSWORD: ${{ secrets.MAVEN_UPLOAD_PASSWORD }} + - name: Upload build artifacts (Common) + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}-Common-${{ github.sha }} + path: | + Common/build/libs/!(*-@(dev|slim)).jar + - name: Upload build artifacts (NeoForge) + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}-NeoForge-${{ github.sha }} + path: | + NeoForge/build/libs/!(*-@(dev|slim)).jar + - name: Upload build artifacts (Quilt) + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}-Quilt-${{ github.sha }} + path: | + Quilt/build/libs/!(*-@(dev|slim)).jar + - name: Publish (GitHub Releases) + continue-on-error: true + uses: Kir-Antipov/mc-publish@423b200ec84e6eefad726549c72513d7a9b4c2c0 # (new) v3.3 + with: + github-token: ${{ github.token }} + files: | + **/build/libs/!(*-@(dev|sources|javadoc|slim)).jar + **/build/libs/*-@(sources|javadoc).jar + - name: Publish (NeoForge) + continue-on-error: true + uses: Kir-Antipov/mc-publish@423b200ec84e6eefad726549c72513d7a9b4c2c0 # (new) v3.3 + with: + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + version: ${{ github.ref_name }}+NeoForge + files: | + NeoForge/build/libs/!(*-@(dev|sources|javadoc|slim)).jar + NeoForge/build/libs/*-@(sources|javadoc).jar + - name: Publish (Quilt) + continue-on-error: true + uses: Kir-Antipov/mc-publish@423b200ec84e6eefad726549c72513d7a9b4c2c0 # (new) v3.3 + with: + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + version: ${{ github.ref_name }}+Quilt + files: | + Quilt/build/libs/!(*-@(dev|sources|javadoc|slim)).jar + Quilt/build/libs/*-@(sources|javadoc).jar diff --git a/.gitignore b/.gitignore index 27f326f..9bcf0cc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,123 @@ -# gradle - -.gradle/ -build/ -out/ - -# idea - +# User-specific stuff .idea/ + *.iml *.ipr *.iws -# vscode +# IntelliJ +out/ +# mpeltonen/sbt-idea plugin +.idea_modules/ -.settings/ -.vscode/ -bin/ -.classpath -.project +# JIRA plugin +atlassian-ide-plugin.xml -# fabric +# Compiled class file +*.class -run/ -classes/ +# Log file *.log + +# BlueJ files +*.ctxt + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +.gradle +build/ + +# Misc +mcModsRepo/ +.tmp/ +.data/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Cache of project +.gradletasknamecache + +**/build/ + +# Common working directory +run/ + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar diff --git a/Common/build.gradle b/Common/build.gradle new file mode 100644 index 0000000..754cb7e --- /dev/null +++ b/Common/build.gradle @@ -0,0 +1,19 @@ +plugins { + alias libs.plugins.vanilla.gradle +} + +minecraft { + version(libs.versions.minecraft.get()) + if (file("src/main/resources/${mod_id}.accesswidener").exists()) { + accessWideners(file("src/main/resources/${mod_id}.accesswidener")) + } +} + +dependencies { + compileOnly libs.bundles.mixin + compileOnly libs.jetbrains.annotations + + implementation libs.resourcefulconfig + + // compileOnly "${libs.emi.asProvider().get()}:api" +} diff --git a/Common/libs.versions.toml b/Common/libs.versions.toml new file mode 100644 index 0000000..001b880 --- /dev/null +++ b/Common/libs.versions.toml @@ -0,0 +1,42 @@ +[versions] +minecraft = "1.20.1" + +# The latest versions are available at https://parchmentmc.org/docs/getting-started +parchment = "2023.09.03" + +mixin = "0.8.5" +mixin_extras = "0.3.5" +asm = "9.6" +jetbrains_annotations = "24.1.0" +vanilla_gradle = "0.2.1-SNAPSHOT" + +sparkweave = "0.4.1" +resourcefulconfig = "2.1.2" +emi = "1.1.4+1.20.1" + +[libraries] +minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } +parchment_mappings = { module = "org.parchmentmc.data:parchment-1.20.1", version.ref = "parchment" } +mixin = { module = "org.spongepowered:mixin", version.ref = "mixin" } +mixin_extras = { module = "io.github.llamalad7:mixinextras-common", version.ref = "mixin_extras" } +mixin_extras_neoforge = { module = "io.github.llamalad7:mixinextras-neoforge", version.ref = "mixin_extras" } +asm = { module = "org.ow2.asm:asm", version.ref = "asm" } +asm_analysis = { module = "org.ow2.asm:asm-analysis", version.ref = "asm" } +asm_commons = { module = "org.ow2.asm:asm-commons", version.ref = "asm" } +asm_tree = { module = "org.ow2.asm:asm-tree", version.ref = "asm" } +asm_util = { module = "org.ow2.asm:asm-util", version.ref = "asm" } +jetbrains_annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains_annotations" } + +resourcefulconfig = { module = "com.teamresourceful.resourcefulconfig:resourcefulconfig-common-1.20.1", version.ref = "resourcefulconfig" } +resourcefulconfig_fabric = { module = "com.teamresourceful.resourcefulconfig:resourcefulconfig-fabric-1.20.1", version.ref = "resourcefulconfig" } +resourcefulconfig_forge = { module = "com.teamresourceful.resourcefulconfig:resourcefulconfig-forge-1.20.1", version.ref = "resourcefulconfig" } + +emi = { module = "dev.emi:emi-xplat-mojmap", version.ref = "emi" } +emi_neoforge = { module = "dev.emi:emi-neoforge", version.ref = "emi" } +emi_fabric = { module = "dev.emi:emi-fabric", version.ref = "emi" } + +[bundles] +mixin = ["mixin", "mixin_extras", "asm", "asm_analysis", "asm_commons", "asm_tree", "asm_util"] + +[plugins] +vanilla_gradle = { id = "org.spongepowered.gradle.vanilla", version.ref = "vanilla_gradle" } diff --git a/Common/src/main/java/dev/upcraft/anvilfix/AnvilFix.java b/Common/src/main/java/dev/upcraft/anvilfix/AnvilFix.java new file mode 100644 index 0000000..3f709ff --- /dev/null +++ b/Common/src/main/java/dev/upcraft/anvilfix/AnvilFix.java @@ -0,0 +1,23 @@ +package dev.upcraft.anvilfix; + +import com.teamresourceful.resourcefulconfig.common.config.Configurator; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +public class AnvilFix { + + public static final String MODID = "anvil_fix"; + public static final Configurator CONFIGURATOR = new Configurator(); + private static final TagKey FORCE_REPAIR_COST_TAG = TagKey.create(Registries.ITEM, new ResourceLocation(MODID, "force_incremental_repair_cost")); + + public static void init() { + CONFIGURATOR.registerConfig(AnvilFixConfig.class); + } + + public static boolean removeIncrementalRepairCost(ItemStack itemStack) { + return AnvilFixConfig.removeIncrementalRepairCost && !itemStack.is(FORCE_REPAIR_COST_TAG); + } +} diff --git a/Common/src/main/java/dev/upcraft/anvilfix/AnvilFixConfig.java b/Common/src/main/java/dev/upcraft/anvilfix/AnvilFixConfig.java new file mode 100644 index 0000000..aa17030 --- /dev/null +++ b/Common/src/main/java/dev/upcraft/anvilfix/AnvilFixConfig.java @@ -0,0 +1,58 @@ +package dev.upcraft.anvilfix; + +import com.teamresourceful.resourcefulconfig.common.annotations.Config; +import com.teamresourceful.resourcefulconfig.common.annotations.ConfigEntry; +import com.teamresourceful.resourcefulconfig.common.annotations.IntRange; +import com.teamresourceful.resourcefulconfig.common.config.EntryType; +import com.teamresourceful.resourcefulconfig.web.annotations.Link; +import com.teamresourceful.resourcefulconfig.web.annotations.WebInfo; + +@WebInfo( + title = "AnvilFix", + description = "Vanilla Anvils - but better! This mod removes the level limit for combining Items", + links = { + @Link( + value = "https://modrinth.com/mod/EB79Qy8k", + icon = "modrinth", + title = "Modrinth" + ), + @Link( + value = "https://curseforge.com/projects/305480", + icon = "curseforge", + title = "Curseforge" + ), + @Link( + value = "https://github.com/Up-Mods/AnvilFix", + icon = "github", + title = "Github" + ) + } +) +@Config(AnvilFix.MODID) +public final class AnvilFixConfig { + + @IntRange(min = -1, max = 255) + @ConfigEntry(id = "level_limit", type = EntryType.INTEGER, translation = "config.anvil_fix.level_limit") + public static int levelLimit = -1; + + @IntRange(min = -1, max = 255) + @ConfigEntry(id = "global_enchantment_level_limit", type = EntryType.INTEGER, translation = "config.anvil_fix.global_enchantment_level_limit") + public static int globalEnchantmentLevelLimit = -1; + + @ConfigEntry(id = "remove_incremental_repair_cost", type = EntryType.BOOLEAN, translation = "config.anvil_fix.remove_incremental_repair_cost") + public static boolean removeIncrementalRepairCost = false; + + @ConfigEntry(id = "stop_anvil_breaking_on_craft", type = EntryType.BOOLEAN, translation = "config.anvil_fix.stop_anvil_breaking_on_craft") + public static boolean stopAnvilBreakingOnCraft = true; + + @ConfigEntry(id = "stop_anvil_breaking_on_fall", type = EntryType.BOOLEAN, translation = "config.anvil_fix.stop_anvil_breaking_on_fall") + public static boolean stopAnvilBreakingOnFall = false; + + public static int getLevelLimit() { + return AnvilFixConfig.levelLimit >= 0 ? (AnvilFixConfig.levelLimit + 1) : Integer.MAX_VALUE; + } + + public static int getGlobalEnchantmentLevelLimit(int original) { + return AnvilFixConfig.globalEnchantmentLevelLimit >= 0 ? Math.min(AnvilFixConfig.globalEnchantmentLevelLimit, original) : original; + } +} diff --git a/Common/src/main/java/dev/upcraft/anvilfix/mixin/MixinAnvilMenu.java b/Common/src/main/java/dev/upcraft/anvilfix/mixin/MixinAnvilMenu.java new file mode 100644 index 0000000..b0080ae --- /dev/null +++ b/Common/src/main/java/dev/upcraft/anvilfix/mixin/MixinAnvilMenu.java @@ -0,0 +1,26 @@ +package dev.upcraft.anvilfix.mixin; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import dev.upcraft.anvilfix.AnvilFixConfig; +import net.minecraft.world.inventory.AnvilMenu; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(AnvilMenu.class) +public class MixinAnvilMenu { + + @ModifyExpressionValue(method = "createResult", at = @At(value = "CONSTANT", args = "intValue=40", ordinal = 2)) + private int anvilfix$modifyLevelLimit(int original) { + return AnvilFixConfig.getLevelLimit(); + } + + @ModifyExpressionValue(method = "createResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/Enchantment;getMaxLevel()I")) + private int anvilfix$modifyGlobalEnchantmentLevelLimit(int original) { + return AnvilFixConfig.getGlobalEnchantmentLevelLimit(original); + } + + @ModifyExpressionValue(method = "onTake", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/player/Abilities;instabuild:Z")) + private boolean anvilfix$stopAnvilBreaking(boolean original) { + return original || AnvilFixConfig.stopAnvilBreakingOnCraft; + } +} diff --git a/Common/src/main/java/dev/upcraft/anvilfix/mixin/MixinFallingBlockEntity.java b/Common/src/main/java/dev/upcraft/anvilfix/mixin/MixinFallingBlockEntity.java new file mode 100644 index 0000000..a14f020 --- /dev/null +++ b/Common/src/main/java/dev/upcraft/anvilfix/mixin/MixinFallingBlockEntity.java @@ -0,0 +1,25 @@ +package dev.upcraft.anvilfix.mixin; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import dev.upcraft.anvilfix.AnvilFixConfig; +import net.minecraft.world.entity.item.FallingBlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(FallingBlockEntity.class) +public class MixinFallingBlockEntity { + + @Shadow + private BlockState blockState; + + @ModifyExpressionValue(method = "causeFallDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/AnvilBlock;damage(Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/level/block/state/BlockState;")) + private BlockState anvilfix$stopAnvilBreaking(BlockState original) { + if (AnvilFixConfig.stopAnvilBreakingOnFall) { + return this.blockState; + } + + return original; + } +} diff --git a/Common/src/main/java/dev/upcraft/anvilfix/mixin/MixinItemStack.java b/Common/src/main/java/dev/upcraft/anvilfix/mixin/MixinItemStack.java new file mode 100644 index 0000000..91e4e27 --- /dev/null +++ b/Common/src/main/java/dev/upcraft/anvilfix/mixin/MixinItemStack.java @@ -0,0 +1,21 @@ +package dev.upcraft.anvilfix.mixin; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import dev.upcraft.anvilfix.AnvilFix; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ItemStack.class) +public class MixinItemStack { + + @ModifyReturnValue(method = "getBaseRepairCost", at = @At(value = "RETURN")) + private int anvilfix$getRepairCost(int original) { + + if(original > 0 && AnvilFix.removeIncrementalRepairCost((ItemStack)(Object)this)) { + return 0; + } + + return original; + } +} diff --git a/Common/src/main/java/dev/upcraft/anvilfix/mixin/client/MixinAnvilScreen.java b/Common/src/main/java/dev/upcraft/anvilfix/mixin/client/MixinAnvilScreen.java new file mode 100644 index 0000000..f478494 --- /dev/null +++ b/Common/src/main/java/dev/upcraft/anvilfix/mixin/client/MixinAnvilScreen.java @@ -0,0 +1,16 @@ +package dev.upcraft.anvilfix.mixin.client; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import dev.upcraft.anvilfix.AnvilFixConfig; +import net.minecraft.client.gui.screens.inventory.AnvilScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(AnvilScreen.class) +public class MixinAnvilScreen { + + @ModifyExpressionValue(method = "renderLabels", at = @At(value = "CONSTANT", args = "intValue=40", ordinal = 0)) + private int anvilfix$modifyLevelLimit(int original) { + return AnvilFixConfig.getLevelLimit(); + } +} diff --git a/Common/src/main/resources/anvil_fix.mixins.json b/Common/src/main/resources/anvil_fix.mixins.json new file mode 100644 index 0000000..eb0c118 --- /dev/null +++ b/Common/src/main/resources/anvil_fix.mixins.json @@ -0,0 +1,18 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "dev.upcraft.anvilfix.mixin", + "refmap": "${mod_id}.refmap.json", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "MixinAnvilMenu", + "MixinFallingBlockEntity", + "MixinItemStack" + ], + "client": [ + "client.MixinAnvilScreen" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/src/main/resources/assets/.modassetsroot b/Common/src/main/resources/assets/.modassetsroot similarity index 100% rename from src/main/resources/assets/.modassetsroot rename to Common/src/main/resources/assets/.modassetsroot diff --git a/Common/src/main/resources/assets/anvil_fix/lang/en_us.json b/Common/src/main/resources/assets/anvil_fix/lang/en_us.json new file mode 100644 index 0000000..8633d7d --- /dev/null +++ b/Common/src/main/resources/assets/anvil_fix/lang/en_us.json @@ -0,0 +1,7 @@ +{ + "config.anvil_fix.level_limit": "Anvil Level Limit", + "config.anvil_fix.global_enchantment_level_limit": "Maximum Enchantment Level", + "config.anvil_fix.remove_incremental_repair_cost": "Remove Incremental Repair Cost", + "config.anvil_fix.stop_anvil_breaking_on_craft": "Stop Anvils Breaking When Crafting", + "config.anvil_fix.stop_anvil_breaking_on_fall": "Stop Anvils Breaking When Falling" +} diff --git a/Common/src/main/resources/assets/anvil_fix/lang/zh_cn.json b/Common/src/main/resources/assets/anvil_fix/lang/zh_cn.json new file mode 100644 index 0000000..732a0c5 --- /dev/null +++ b/Common/src/main/resources/assets/anvil_fix/lang/zh_cn.json @@ -0,0 +1,7 @@ +{ + "config.anvil_fix.level_limit": "铁砧等级上限", + "config.anvil_fix.global_enchantment_level_limit": "所需等级上限", + "config.anvil_fix.remove_incremental_repair_cost": "修复消耗不增长", + "config.anvil_fix.stop_anvil_breaking_on_craft": "铁砧不再破损", + "config.anvil_fix.stop_anvil_breaking_on_fall": "Stop Anvils Breaking When Falling" +} diff --git a/src/main/resources/assets/anvil_fix/icon.png b/Common/src/main/resources/icon.png similarity index 100% rename from src/main/resources/assets/anvil_fix/icon.png rename to Common/src/main/resources/icon.png diff --git a/LICENSE.md b/LICENSE.md index 75d2c11..0e259d4 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,21 +1,121 @@ -MIT License - -Copyright (c) 2019 NerdHubMC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/NeoForge/build.gradle b/NeoForge/build.gradle new file mode 100644 index 0000000..b126464 --- /dev/null +++ b/NeoForge/build.gradle @@ -0,0 +1,140 @@ +plugins { + id 'idea' + alias neoforge.plugins.neogradle + alias neoforge.plugins.librarian + alias neoforge.plugins.mixingradle +} + +def usingJarJar = false + +if(usingJarJar) { + jarJar.enable() +} + +dependencies { + minecraft neoforge.neoforge.get() + compileOnly project(":Common") + annotationProcessor "${libs.mixin.asProvider().get()}:processor" + + implementation fg.deobf(libs.resourcefulconfig.forge.get()) + + // compileOnly "${libs.emi.neoforge.get()}:api" + + minecraftLibrary libs.mixin.extras.neoforge + jarJar(libs.mixin.extras) { + jarJar.ranged(it, "[${libs.versions.mixin.extras.get()},)") + } +} + +mixin { + add(sourceSets.main, "${mod_id}.refmap.json") + + config("${mod_id}.mixins.json") + config("${mod_id}.neoforge.mixins.json") +} + +if(usingJarJar) { + jar { + archiveClassifier.set("slim") + } + + tasks.jarJar.configure { + archiveClassifier.set('') + } +} + +minecraft { + mappings channel: 'parchment', version: "${libs.versions.parchment.get()}-${libs.versions.minecraft.get()}" + + copyIdeResources = true //Calls processResources when in dev + + // Automatically enable neoforge AccessTransformers if the file exists +// This location is hardcoded in FML and can not be changed. +// https://github.com/neoforged/FancyModLoader/blob/a952595eaaddd571fbc53f43847680b00894e0c1/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModFile.java#L118 + if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + } + + runs { + configureEach { + property 'forge.logging.markers', 'REGISTRIES' + property 'forge.logging.console.level', 'debug' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" + args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.neoforge.mixins.json" + + workingDirectory(project.file('run')) + } + client { + ideaModule "${rootProject.name}.${project.name}.main" + mods { + modClientRun { + source sourceSets.main + source project(":Common").sourceSets.main + } + } + + if (rootProject.hasProperty('mc_uuid')) { + args("--uuid", rootProject.mc_uuid) + } + + if (rootProject.hasProperty('mc_username')) { + args("--username", rootProject.mc_username) + } + + if (rootProject.hasProperty('mc_java_agent_path')) { + jvmArg("-javaagent:${rootProject.mc_java_agent_path}") + } + } + + server { + ideaModule "${rootProject.name}.${project.name}.main" + args 'nogui' + mods { + modServerRun { + source sourceSets.main + source project(":Common").sourceSets.main + } + } + } + + data { + ideaModule "${rootProject.name}.${project.name}.main" + args '--mod', mod_id, '--all', '--output', file('src/generated/resources/').absolutePath, '--existing', file('src/main/resources/').absolutePath + mods { + modDataRun { + source sourceSets.main + source project(":Common").sourceSets.main + } + } + } + } +} + +sourceSets.main.resources { srcDir 'src/generated/resources' } + +tasks.named("compileJava", JavaCompile) { + source(project(":Common").sourceSets.main.allJava) +} + +tasks.named("javadoc", Javadoc) { + source(project(":Common").sourceSets.main.allJava) +} + +tasks.named("sourcesJar", Jar) { + from(project(":Common").sourceSets.main.allSource) +} + +processResources { + from project(":Common").sourceSets.main.resources +} + +if(usingJarJar) { + publishing { + publications { + "mavenJava${project.name}"(MavenPublication) { + jarJar.component(it) + } + } + } +} diff --git a/NeoForge/libs.versions.toml b/NeoForge/libs.versions.toml new file mode 100644 index 0000000..2d1da35 --- /dev/null +++ b/NeoForge/libs.versions.toml @@ -0,0 +1,14 @@ +[versions] +neogradle = "6.+" +mixingradle = "0.7.+" +librarian = "1.+" + +neoforge = "1.20.1-47.1.104" + +[libraries] +neoforge = { module = "net.neoforged:forge", version.ref = "neoforge" } + +[plugins] +neogradle = { id = "net.neoforged.gradle", version.ref = "neogradle" } +mixingradle = { id = "org.spongepowered.mixin", version.ref = "mixingradle" } +librarian = { id = "org.parchmentmc.librarian.forgegradle", version.ref = "librarian" } diff --git a/NeoForge/src/main/java/dev/upcraft/anvilfix/neoforge/entrypoints/Client.java b/NeoForge/src/main/java/dev/upcraft/anvilfix/neoforge/entrypoints/Client.java new file mode 100644 index 0000000..738986e --- /dev/null +++ b/NeoForge/src/main/java/dev/upcraft/anvilfix/neoforge/entrypoints/Client.java @@ -0,0 +1,20 @@ +package dev.upcraft.anvilfix.neoforge.entrypoints; + +import com.teamresourceful.resourcefulconfig.client.ConfigScreen; +import dev.upcraft.anvilfix.AnvilFix; +import dev.upcraft.anvilfix.AnvilFixConfig; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.ConfigScreenHandler; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; + +@Mod.EventBusSubscriber(modid = AnvilFix.MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) +public class Client { + + @SubscribeEvent + public static void onClientSetup(FMLClientSetupEvent event) { + event.enqueueWork(() -> ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((minecraft, parent) -> new ConfigScreen(parent, null, AnvilFix.CONFIGURATOR.getConfig(AnvilFixConfig.class))))); + } +} diff --git a/NeoForge/src/main/java/dev/upcraft/anvilfix/neoforge/entrypoints/Main.java b/NeoForge/src/main/java/dev/upcraft/anvilfix/neoforge/entrypoints/Main.java new file mode 100644 index 0000000..4ed8b3a --- /dev/null +++ b/NeoForge/src/main/java/dev/upcraft/anvilfix/neoforge/entrypoints/Main.java @@ -0,0 +1,12 @@ +package dev.upcraft.anvilfix.neoforge.entrypoints; + +import dev.upcraft.anvilfix.AnvilFix; +import net.minecraftforge.fml.common.Mod; + +@Mod(AnvilFix.MODID) +public class Main { + + public Main() { + AnvilFix.init(); + } +} diff --git a/NeoForge/src/main/resources/META-INF/mods.toml b/NeoForge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..629ebbd --- /dev/null +++ b/NeoForge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,39 @@ +modLoader = "javafml" #mandatory +loaderVersion = "*" #mandatory +license = "${license_url}" # Review your options at https://choosealicense.com/. +issueTrackerURL = "${issues_url}" #optional + +[[mods]] #mandatory +modId = "${mod_id}" #mandatory +version = "${version}" #mandatory +displayName = "${mod_display_name}" #mandatory +displayURL = "${homepage_url}" #optional (displayed in the mod UI) +logoFile = "icon.png" #optional +#credits = "" #optional +authors = "Up" #optional +description = '''${mod_description}''' #mandatory (Supports multiline text) + +[[mixins]] +config = "${mod_id}.mixins.json" + +[[mixins]] +config = "${mod_id}.neoforge.mixins.json" + +# https://docs.neoforged.net/docs/gettingstarted/modfiles#dependency-configurations +[dependencies] + "${mod_id}" = [ + { modId = "forge", mandatory = true, versionRange = "*", ordering = "NONE", side = "BOTH", mc-publish = { ignore = true } }, + { modId = "minecraft", mandatory = true, versionRange = "[${minecraft_version}]", ordering = "NONE", side = "BOTH" }, + { modId = "resourcefulconfig", mandatory = true, versionRange = "*", ordering = "NONE", side = "BOTH", mc-publish = { curseforge = "714059", modrinth = "M1953qlQ" } }, + ] + +# Features are specific properties of the game environment, that you may want to declare you require. This example declares +# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't +# stop your mod loading on the server for example. +#[features.${mod_id}] +#openGLVersion="[3.2,)" + +[mc-publish] + curseforge = "${curseforge_id}" + modrinth = "${modrinth_id}" + loaders = ["neoforge"] diff --git a/NeoForge/src/main/resources/anvil_fix.neoforge.mixins.json b/NeoForge/src/main/resources/anvil_fix.neoforge.mixins.json new file mode 100644 index 0000000..b3f7ea9 --- /dev/null +++ b/NeoForge/src/main/resources/anvil_fix.neoforge.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "dev.upcraft.anvilfix.neoforge.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/NeoForge/src/main/resources/pack.mcmeta b/NeoForge/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..2f425f5 --- /dev/null +++ b/NeoForge/src/main/resources/pack.mcmeta @@ -0,0 +1,8 @@ +{ + "pack": { + "description": { + "text": "${mod_display_name} resources" + }, + "pack_format": 15 + } +} diff --git a/Quilt/build.gradle b/Quilt/build.gradle new file mode 100644 index 0000000..a5b2757 --- /dev/null +++ b/Quilt/build.gradle @@ -0,0 +1,92 @@ +plugins { + alias quilt.plugins.quilt.loom +} + +// messy workaround for bug in quilt loom 1.3.3+ +project.configurations.configureEach { + exclude(group: "net.fabricmc", module: "fabric-loader") + exclude(group: "net.fabricmc.fabric-api") +} + +dependencies { + minecraft libs.minecraft + mappings(loom.layered { + it.parchment("${libs.parchment.mappings.get()}@zip") + it.officialMojangMappings() + }) + + modImplementation quilt.quilt.loader + modImplementation quilt.quilted.fabric.api + modRuntimeOnly(quilt.quilted.fabric.api.deprecated) { + transitive = false + } + + compileOnly project(":Common") + + modImplementation libs.resourcefulconfig.fabric + + modCompileOnly quilt.modmenu + modLocalRuntime quilt.modmenu + + // modCompileOnly "${libs.emi.fabric.get()}:api" +} + +loom { + mods { + "${mod_id}" { + // Tell Loom about each source set used by your mod here. This ensures that your mod's classes are properly transformed by Loader. + sourceSet("main") + project(":Common").sourceSets.main + } + } + if (project(":Common").file("src/main/resources/${mod_id}.accesswidener").exists()) { + accessWidenerPath.set(project(":Common").file("src/main/resources/${mod_id}.accesswidener")) + } + mixin { + defaultRefmapName.set("${mod_id}.refmap.json") + } + + runs { + client { + client() + setConfigName("Quilt Client") + ideConfigGenerated(true) + runDir("run") + + if (rootProject.hasProperty('mc_uuid')) { + programArgs("--uuid", rootProject.mc_uuid) + } + + if (rootProject.hasProperty('mc_username')) { + programArgs("--username", rootProject.mc_username) + } + + if (rootProject.hasProperty('mc_java_agent_path')) { + vmArg("-javaagent:${rootProject.mc_java_agent_path}") + } + } + + server { + server() + setConfigName("Quilt Server") + ideConfigGenerated(true) + runDir("run/server") + } + } +} + +tasks.named("compileJava", JavaCompile) { + source(project(":Common").sourceSets.main.allJava) +} + +tasks.named("javadoc", Javadoc) { + source(project(":Common").sourceSets.main.allJava) +} + +tasks.named("sourcesJar", Jar) { + from(project(":Common").sourceSets.main.allSource) +} + +processResources { + from project(":Common").sourceSets.main.resources +} diff --git a/Quilt/libs.versions.toml b/Quilt/libs.versions.toml new file mode 100644 index 0000000..5688120 --- /dev/null +++ b/Quilt/libs.versions.toml @@ -0,0 +1,23 @@ +[versions] +# The latest versions are available at https://lambdaurora.dev/tools/import_quilt.html +quilt_loom = "1.5.+" + +quilt_loader = "0.24.0" +quilted_fabric_api = "7.5.0+0.91.0-1.20.1" + +modmenu = "7.2.2" + +[libraries] +quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loader" } + +quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "quilted_fabric_api" } +quilted_fabric_api_deprecated = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api-deprecated", version.ref = "quilted_fabric_api" } + +modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" } + +# If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example". +[bundles] +quilted_fabric_api = ["quilted_fabric_api", "quilted_fabric_api_deprecated"] + +[plugins] +quilt_loom = { id = "org.quiltmc.loom", version.ref = "quilt_loom" } diff --git a/Quilt/src/main/java/dev/upcraft/anvilfix/quilt/entrypoints/Main.java b/Quilt/src/main/java/dev/upcraft/anvilfix/quilt/entrypoints/Main.java new file mode 100644 index 0000000..d2ca070 --- /dev/null +++ b/Quilt/src/main/java/dev/upcraft/anvilfix/quilt/entrypoints/Main.java @@ -0,0 +1,13 @@ +package dev.upcraft.anvilfix.quilt.entrypoints; + +import dev.upcraft.anvilfix.AnvilFix; +import org.quiltmc.loader.api.ModContainer; +import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; + +public class Main implements ModInitializer { + + @Override + public void onInitialize(ModContainer mod) { + AnvilFix.init(); + } +} diff --git a/Quilt/src/main/java/dev/upcraft/anvilfix/quilt/entrypoints/Modmenu.java b/Quilt/src/main/java/dev/upcraft/anvilfix/quilt/entrypoints/Modmenu.java new file mode 100644 index 0000000..5617d37 --- /dev/null +++ b/Quilt/src/main/java/dev/upcraft/anvilfix/quilt/entrypoints/Modmenu.java @@ -0,0 +1,15 @@ +package dev.upcraft.anvilfix.quilt.entrypoints; + +import com.teamresourceful.resourcefulconfig.client.ConfigScreen; +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import dev.upcraft.anvilfix.AnvilFix; +import dev.upcraft.anvilfix.AnvilFixConfig; + +public class Modmenu implements ModMenuApi { + + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> new ConfigScreen(parent, null, AnvilFix.CONFIGURATOR.getConfig(AnvilFixConfig.class)); + } +} diff --git a/Quilt/src/main/resources/anvil_fix.quilt.mixins.json b/Quilt/src/main/resources/anvil_fix.quilt.mixins.json new file mode 100644 index 0000000..13f83cc --- /dev/null +++ b/Quilt/src/main/resources/anvil_fix.quilt.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "dev.upcraft.anvilfix.quilt.mixin", + "refmap": "${mod_id}.refmap.json", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/Quilt/src/main/resources/quilt.mod.json b/Quilt/src/main/resources/quilt.mod.json new file mode 100644 index 0000000..044b2d4 --- /dev/null +++ b/Quilt/src/main/resources/quilt.mod.json @@ -0,0 +1,69 @@ +{ + "schema_version": 1, + "quilt_loader": { + "id": "${mod_id}", + "version": "${version}", + "group": "${maven_group_id}", + "metadata": { + "name": "${mod_display_name}", + "description": "${mod_description}", + "contributors": { + "Up": "Owner" + }, + "contact": { + "homepage": "${homepage_url}", + "sources": "${sources_url}", + "issues": "${issues_url}" + }, + "license": { + "id": "custom", + "name": "Custom License", + "url": "${license_url}" + }, + "icon": "icon.png" + }, + "entrypoints": { + "init": "dev.upcraft.anvilfix.quilt.entrypoints.Main", + "modmenu": "dev.upcraft.anvilfix.quilt.entrypoints.Modmenu" + }, + "depends": [ + { + "id": "quilt_loader", + "versions": ">=${quilt_loader_version}" + }, + { + "id": "quilted_fabric_api", + "mc-publish": { + "curseforge": "634179", + "modrinth": "qvIfYCYJ" + } + }, + { + "id": "minecraft", + "versions": "=${minecraft_version}" + }, + { + "id": "resourcefulconfig", + "mc-publish": { + "curseforge": "714059", + "modrinth": "M1953qlQ" + } + } + ], + "intermediate_mappings": "net.fabricmc:intermediary" + }, + "minecraft": { + "environment": "*" + }, + "mixin": [ + "${mod_id}.mixins.json", + "${mod_id}.quilt.mixins.json" + ], + "mc-publish": { + "curseforge": "${curseforge_id}", + "modrinth": "${modrinth_id}", + "loaders": [ + "quilt" + ] + } +} diff --git a/README.md b/README.md deleted file mode 100644 index 1538ae2..0000000 --- a/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# AnvilFix - -[![Build Status](https://img.shields.io/github/workflow/status/OnyxStudios/AnvilFix/Build%20Status?label=Build%20Status&logo=GitHub&style=flat-square)](https://github.com/OnyxStudios/AnvilFix/actions?query=workflow%3A%22Build+Status%22 "GitHub Actions") [![Latest Release](https://img.shields.io/github/v/release/OnyxStudios/AnvilFix?include_prereleases&label=Latest&logo=GitHub&style=flat-square)](https://github.com/OnyxStudios/AnvilFix/releases/latest "GitHub Releases") [![JitPack](https://jitpack.io/v/OnyxStudios/AnvilFix.svg?style=flat-square)](https://jitpack.io/#OnyxStudios/AnvilFix "Jitpack") [![Maven Repository](https://img.shields.io/maven-metadata/v/https/maven.onyxstudios.dev/io/github/onyxstudios/AnvilFix/maven-metadata.xml.svg?label=OnyxStudios%20Maven&style=flat-square)](https://maven.onyxstudios.dev/io/github/onyxstudios/AnvilFix "Onyx Studios Maven") - -removes the level limit for Anvils, as well as the incremental repair cost (configurable) -also has an option for preventing anvils from taking damage when being used - -### Curseforge: - -[UpcraftLP/AnvilFix](https://www.curseforge.com/minecraft/mc-mods/anvil-fix "UpcraftLP/AnvilFix on CurseForge")[![CurseForge](http://cf.way2muchnoise.eu/full_305480_downloads.svg)](https://www.curseforge.com/minecraft/mc-mods/anvil-fix "UpcraftLP/AnvilFix on CurseForge") diff --git a/build.gradle b/build.gradle index fe2165f..9edf4b1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,166 +1,198 @@ -import com.modrinth.minotaur.TaskModrinthUpload - -import java.nio.charset.StandardCharsets -import java.time.Year - plugins { - id "java-library" - id "maven-publish" - id "fabric-loom" version "0.11.+" - id "org.cadixdev.licenser" version "0.6.1" - id "com.modrinth.minotaur" version "1.1.0" - id "com.matthewprenger.cursegradle" version "1.4.0" + id 'idea' + // Required for NeoGradle + id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7" + id 'maven-publish' } -def ENV = System.getenv() -def buildTime = ENV.BUILD_TIME ?: new Date().format('yyyyMMddHHmmss') - def javaVersion = 17 -group = "io.github.onyxstudios" -archivesBaseName = "AnvilFix" - -boolean isPreviewBuild = !ENV.TAG || ENV.TAG.matches(".+-.+") -def buildNumber = !ENV.TAG ? ("${ENV.BUILD_NUMBER ? "build.${ENV.BUILD_NUMBER}" : buildTime}-${project.minecraft_version}") : "" -version = (ENV.TAG ?: "development") + ((isPreviewBuild && !ENV.TAG) ? "+${buildNumber}" : "") +group = maven_group_id -java { - withSourcesJar() - toolchain { - languageVersion = JavaLanguageVersion.of(javaVersion) - } -} +def ENV = System.getenv() +def NOW = new Date() +def buildTime = ENV.BUILD_TIME ?: NOW.format('yyyyMMddHHmmss') -repositories { - mavenCentral() - maven { - name = "OnyxStudios" - url = "https://maven.onyxstudios.dev" - } - maven { - name = "TerraformersMC" - url = "https://maven.terraformersmc.com/releases" - } - maven { - name = "Shedaniel" - url = "https://maven.shedaniel.me" - } -} +boolean isPreviewBuild = !ENV.TAG || ENV.TAG.matches(".+-.+") +def buildNumber = !ENV.TAG ? ("${ENV.BUILD_NUMBER ? "build.${ENV.BUILD_NUMBER}" : buildTime}") : "" +version = (ENV.TAG ?: "${libs.versions.minecraft.get()}-development") + ((isPreviewBuild && !ENV.TAG) ? "+${buildNumber}" : "") -dependencies { - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - compileOnly 'org.jetbrains:annotations:22.0.0' - - // FIXME not updated yet - //modImplementation "dev.upcraft:Mesh-API:${project.mesh_version}" - //modRuntimeOnly "dev.upcraft:Mesh:${project.mesh_version}" - modImplementation ("me.shedaniel.cloth:cloth-config-fabric:6.2.57") { - exclude group: "net.fabricmc.fabric-api" - } +def mod_name = rootProject.name.replaceAll("-", "_").toLowerCase(Locale.ROOT) - modImplementation include(fabricApi.module("fabric-resource-loader-v0", project.fabric_version)) - modImplementation "com.terraformersmc:modmenu:${modmenu_version}" -} +println("Building ${project.name} ${version}") -processResources { - inputs.property "version", project.version +subprojects { + apply plugin: 'java' + project.group = rootProject.group + project.version = rootProject.version - filesMatching("fabric.mod.json") { - expand "version": project.version + java { + toolchain { + languageVersion = JavaLanguageVersion.of(javaVersion) + vendor = JvmVendorSpec.MICROSOFT + } + withSourcesJar() +// withJavadocJar() } -} -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" -} + javadoc { + options.tags = ["reason"] + } -jar { - from "LICENSE.md" -} + base { + archivesName = "${rootProject.name}-${project.name}" + } -publishing { - publications { - mavenJava(MavenPublication) { - from components.java + jar { + from(rootProject.file("LICENSE.md")) { + rename { "LICENSE_${mod_name}.md" } + } + manifest { + attributes([ + 'Specification-Title' : rootProject.name, + 'Specification-Version' : project.version, + 'Implementation-Title' : "${rootProject.name}-${project.name}", + 'Maven-Artifact' : "${maven_group_id}:${rootProject.name}-${project.name}:${project.version}", + 'Implementation-Version' : project.version, + 'Implementation-Timestamp' : NOW.format("yyyy-MM-dd'T'HH:mm:ssZ"), + 'Timestamp' : NOW.toInstant().toEpochMilli(), + 'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", + 'Built-On-Minecraft' : libs.versions.minecraft.get() + ]) + } + } + + sourcesJar { + from(rootProject.file("LICENSE.md")) { + rename { "LICENSE_${mod_name}.md" } + } + } + + repositories { + mavenCentral() + + maven { + name = "Sponge" + url = "https://repo.spongepowered.org/repository/maven-public" + content { + includeGroup "org.spongepowered" + } + } + + maven { + name = "ParchmentMC" + url = "https://maven.parchmentmc.org" + content { + includeGroupByRegex "org\\.parchmentmc(\\..*)?" + } + } + + maven { + name = "Quilt" + url = "https://maven.quiltmc.org/repository/release" + } + + maven { + name = "Fabric" + url = "https://maven.fabricmc.net" + } + + maven { + name = 'NeoForge' + url = 'https://maven.neoforged.net/releases' + } + + maven { + name = "Up-Mods" + url = "https://maven.uuid.gg/releases" + } + + maven { + name = "TeamResourceful" + url = "https://maven.teamresourceful.com/repository/maven-releases" + } + + maven { + name "TerraformersMC" + url "https://maven.terraformersmc.com/releases" + } + + maven { + name "Modrinth" + url "https://api.modrinth.com/maven" + content { + includeGroup "maven.modrinth" + } + } + + maven { + name = "CurseMaven" + url = "https://www.cursemaven.com" + content { + includeGroup "curse.maven" + } + } + } + + tasks.withType(JavaCompile).configureEach { + it.options.encoding = "UTF-8" + it.options.release.set(javaVersion) + } + + processResources { + filteringCharset "UTF-8" + + def expandProps = [ + "version" : version, + "maven_group_id" : maven_group_id, + "mod_id" : mod_id, + "mod_display_name" : mod_display_name, + "mod_description" : mod_description, + "sources_url" : sources_url, + "issues_url" : issues_url, + "license_url" : license_url, + "discord_url" : discord_url, + "homepage_url" : homepage_url, + "minecraft_version" : libs.versions.minecraft.get(), + "curseforge_id" : curseforge_id, + "modrinth_id" : modrinth_id, + + "quilt_loader_version" : quilt.versions.quilt.loader.get(), + ] + + filesMatching(['pack.mcmeta', '*.mod.json', 'META-INF/mods.toml', '*.mixins.json']) { + expand expandProps + } + inputs.properties(expandProps) + } + + // Disables Gradle's custom module metadata from being published to maven. The + // metadata includes mapped dependencies which are not reasonably consumable by + // other mod developers. + tasks.withType(GenerateModuleMetadata).configureEach { + enabled = false + } + + publishing { + publications { + "mavenJava${project.name}"(MavenPublication) { + artifactId "${rootProject.name}-${project.name}" + from components.java + } } } +} +publishing { repositories { - if(ENV.MAVEN_URL && ENV.MAVEN_USER && ENV.MAVEN_PASS) { + if (ENV.MAVEN_UPLOAD_URL) { maven { - url = ENV.MAVEN_URL + url = ENV.MAVEN_UPLOAD_URL credentials { - username = ENV.MAVEN_USER - password = ENV.MAVEN_PASS + username = ENV.MAVEN_UPLOAD_USERNAME + password = ENV.MAVEN_UPLOAD_PASSWORD } } } } } - -license { - header = project.file("code_quality/MIT_HEADER.txt") - include "**/*.java" - charset = StandardCharsets.UTF_8.name() - - style { - java = "BLOCK_COMMENT" - } - newLine = false // Disables the empty line between the header and package name - //ignoreFailures = true //Ignore failures and only print a warning on license violations - - //export variables - properties { - year = Year.now() - projectDisplayName = project.archivesBaseName - } -} - -curseforge { - apiKey = ENV.CURSEFORGE_TOKEN ?: "invalid" - project { - id = project.curseforge_id - releaseType = isPreviewBuild ? ((ENV.TAG && ENV.TAG.contains("-beta")) ? "beta" : "alpha") : "release" - "${project.curseforge_game_versions}".split(",").each { - addGameVersion(it) - } - addGameVersion("Fabric") // set ModLoader to Fabric - addGameVersion("Java ${javaVersion}") - - mainArtifact(remapJar) { - displayName = "${archivesBaseName} ${ENV.TAG ?: version}" - relations { - requiredDependency 'fabric-api' - embeddedLibrary 'cloth-config' - } - } - } - - options { - forgeGradleIntegration = false - } -} - -task publishToModrinth(type: TaskModrinthUpload, dependsOn: assemble) { - if (ENV.MODRINTH_TOKEN) { - token = ENV.MODRINTH_TOKEN - } - projectId = project.modrinth_id - uploadFile = remapJar - versionNumber = ENV.TAG ?: version - versionName = versionNumber // need this here because the Modrinth API doesn't do that by default - releaseType = isPreviewBuild ? ((ENV.TAG && ENV.TAG.contains("-beta")) ? "beta" : "alpha") : "release" - "${project.modrinth_game_versions}".split(",").each { - addGameVersion(it) - } - addLoader("fabric") -} - -if (ENV.MODRINTH_TOKEN) { - tasks.publish.dependsOn(publishToModrinth) -} -if (ENV.CURSEFORGE_TOKEN) { - tasks.publish.dependsOn(tasks.curseforge) -} diff --git a/changelog.md b/changelog.md deleted file mode 100644 index bdfd7d2..0000000 --- a/changelog.md +++ /dev/null @@ -1,25 +0,0 @@ ------------------------------------------------------- -Version 1.1.2 ------------------------------------------------------- -- add mod menu support - ------------------------------------------------------- -Version 1.1.1 ------------------------------------------------------- -- fix class loading issues - ------------------------------------------------------- -Version 1.1.0 ------------------------------------------------------- -- added config option for preventing anvils from - taking damage - ------------------------------------------------------- -Version 1.0.1 ------------------------------------------------------- -- updated to latest Fabric API - ------------------------------------------------------- -Version 1.0.0 ------------------------------------------------------- -- initial release diff --git a/code_quality/MIT_HEADER.txt b/code_quality/MIT_HEADER.txt deleted file mode 100644 index 5186f89..0000000 --- a/code_quality/MIT_HEADER.txt +++ /dev/null @@ -1,21 +0,0 @@ -${projectDisplayName} - -Copyright (C) 2019-${year} OnyxStudios - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/gradle.properties b/gradle.properties index 98c451f..cc40e1a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,17 @@ +# Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx2G -#General -# find latest versions at https://fabricmc.net/develop -minecraft_version=1.18.2 -yarn_mappings=1.18.2+build.2 -loader_version=0.13.3 -#Fabric api -fabric_version=0.47.10+1.18.2 - -modmenu_version=3.1.0 -mesh_version=0.19.0-alpha +# Metadata +mod_id=anvil_fix +mod_description=Vanilla Anvils - but better! This mod removes the level limit for combining Items +mod_display_name=AnvilFix +sources_url=https://github.com/Up-Mods/AnvilFix +issues_url=https://github.com/Up-Mods/AnvilFix/issues +license_url=https://github.com/Up-Mods/AnvilFix/blob/HEAD/LICENSE.md +discord_url=https://mods.upcraft.dev/discord +homepage_url=https://www.curseforge.com/minecraft/mc-mods/anvil-fix # Publishing +maven_group_id=dev.upcraft.anvilfix curseforge_id=305480 modrinth_id=EB79Qy8k -modrinth_game_versions=1.18.2 -curseforge_game_versions=1.18.2 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c..e644113 100644 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 41dfb87..1af9e09 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4f906e0..1aa94a4 100644 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,99 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# 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"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# 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" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +119,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the 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. + JAVACMD=java + 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. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +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=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# 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, 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" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 107acd3..25da30d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/jitpack.yml b/jitpack.yml deleted file mode 100644 index 41bfdd6..0000000 --- a/jitpack.yml +++ /dev/null @@ -1,3 +0,0 @@ -before_install: - - wget https://github.com/sormuras/bach/raw/master/install-jdk.sh - - source install-jdk.sh --feature 17 diff --git a/settings.gradle b/settings.gradle index 5b60df3..2c20077 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,10 +1,44 @@ pluginManagement { repositories { - jcenter() + gradlePluginPortal() + maven { + name = 'Quilt' + url = 'https://maven.quiltmc.org/repository/release' + } + maven { + name = 'NeoForge' + url = 'https://maven.neoforged.net/releases' + } + maven { + name = 'Sponge' + url = 'https://repo.spongepowered.org/repository/maven-public' + } + // Currently needed for Intermediary and other temporary dependencies maven { name = 'Fabric' - url = 'https://maven.fabricmc.net/' + url = 'https://maven.fabricmc.net' + } + } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' +} + +dependencyResolutionManagement { + versionCatalogs { + libs { + from(files("./Common/libs.versions.toml")) + } + quilt { + from(files("./Quilt/libs.versions.toml")) + } + neoforge { + from(files("./NeoForge/libs.versions.toml")) } - gradlePluginPortal() } } + +rootProject.name = 'AnvilFix' + +include 'Common', 'NeoForge', 'Quilt' diff --git a/src/main/java/io/github/onyxstudios/anvilfix/AnvilFix.java b/src/main/java/io/github/onyxstudios/anvilfix/AnvilFix.java deleted file mode 100644 index 5d17762..0000000 --- a/src/main/java/io/github/onyxstudios/anvilfix/AnvilFix.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * AnvilFix - * - * Copyright (C) 2019-2022 OnyxStudios - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package io.github.onyxstudios.anvilfix; - -import io.github.onyxstudios.anvilfix.config.AnvilfixConfig; -import me.shedaniel.autoconfig.AutoConfig; -import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; -import net.fabricmc.api.ModInitializer; -import net.minecraft.item.Item; -import net.minecraft.tag.TagKey; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; - -public class AnvilFix implements ModInitializer { - - public static final String MODID = "anvil_fix"; - - public static final TagKey FORCE_REPAIR_COST_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(MODID, "force_incremental_repair_cost")); - - public static AnvilfixConfig getConfig() { - return AutoConfig.getConfigHolder(AnvilfixConfig.class).getConfig(); - } - - @Override - public void onInitialize() { - AutoConfig.register(AnvilfixConfig.class, JanksonConfigSerializer::new); - } -} diff --git a/src/main/java/io/github/onyxstudios/anvilfix/compat/AnvilfixModmenuCompat.java b/src/main/java/io/github/onyxstudios/anvilfix/compat/AnvilfixModmenuCompat.java deleted file mode 100644 index ed18ad8..0000000 --- a/src/main/java/io/github/onyxstudios/anvilfix/compat/AnvilfixModmenuCompat.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * AnvilFix - * - * Copyright (C) 2019-2022 OnyxStudios - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package io.github.onyxstudios.anvilfix.compat; - -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import com.terraformersmc.modmenu.api.ModMenuApi; -import io.github.onyxstudios.anvilfix.config.AnvilfixConfig; -import me.shedaniel.autoconfig.AutoConfig; - -public class AnvilfixModmenuCompat implements ModMenuApi { - - @Override - public ConfigScreenFactory getModConfigScreenFactory() { - return parent -> AutoConfig.getConfigScreen(AnvilfixConfig.class, parent).get(); - } -} diff --git a/src/main/java/io/github/onyxstudios/anvilfix/config/AnvilfixConfig.java b/src/main/java/io/github/onyxstudios/anvilfix/config/AnvilfixConfig.java deleted file mode 100644 index ff1a11b..0000000 --- a/src/main/java/io/github/onyxstudios/anvilfix/config/AnvilfixConfig.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * AnvilFix - * - * Copyright (C) 2019-2022 OnyxStudios - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package io.github.onyxstudios.anvilfix.config; - -import io.github.onyxstudios.anvilfix.AnvilFix; -import me.shedaniel.autoconfig.ConfigData; -import me.shedaniel.autoconfig.annotation.Config; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.item.ItemStack; - -@SuppressWarnings("ALL") -@Config(name = AnvilFix.MODID) -public class AnvilfixConfig implements ConfigData { - - private int levelLimit = -1; - - private int globalEnchantmentLevelLimit = -1; - - private boolean removeIncrementalRepairCost = false; - - private boolean stopAnvilBreaking = true; - - public int getLevelLimit() { - return levelLimit != -1 ? levelLimit + 1 : Integer.MAX_VALUE; - } - - public int getEnchantmentLimit(Enchantment enchantment) { - return globalEnchantmentLevelLimit >= 0 ? globalEnchantmentLevelLimit : enchantment.getMaxLevel(); - } - - public boolean removeIncrementalCost(ItemStack stack) { - return removeIncrementalRepairCost && !stack.isIn(AnvilFix.FORCE_REPAIR_COST_TAG); - } - - public boolean shouldStopAnvilBreaking() { - return stopAnvilBreaking; - } -} diff --git a/src/main/java/io/github/onyxstudios/anvilfix/mixin/client/MixinAnvilScreen.java b/src/main/java/io/github/onyxstudios/anvilfix/mixin/client/MixinAnvilScreen.java deleted file mode 100644 index 74d22dd..0000000 --- a/src/main/java/io/github/onyxstudios/anvilfix/mixin/client/MixinAnvilScreen.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * AnvilFix - * - * Copyright (C) 2019-2022 OnyxStudios - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package io.github.onyxstudios.anvilfix.mixin.client; - -import io.github.onyxstudios.anvilfix.AnvilFix; -import net.minecraft.client.gui.screen.ingame.AnvilScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.Constant; -import org.spongepowered.asm.mixin.injection.ModifyConstant; - -@Mixin(AnvilScreen.class) -public class MixinAnvilScreen { - - @ModifyConstant(method = "drawForeground", constant = @Constant(intValue = 40, ordinal = 0)) - private int modifyInt(int input) { - return AnvilFix.getConfig().getLevelLimit(); - } -} diff --git a/src/main/java/io/github/onyxstudios/anvilfix/mixin/common/MixinAnvilBlock.java b/src/main/java/io/github/onyxstudios/anvilfix/mixin/common/MixinAnvilBlock.java deleted file mode 100644 index 4fe49e4..0000000 --- a/src/main/java/io/github/onyxstudios/anvilfix/mixin/common/MixinAnvilBlock.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * AnvilFix - * - * Copyright (C) 2019-2022 OnyxStudios - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package io.github.onyxstudios.anvilfix.mixin.common; - -import io.github.onyxstudios.anvilfix.AnvilFix; -import net.minecraft.block.AnvilBlock; -import net.minecraft.block.BlockState; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(AnvilBlock.class) -public class MixinAnvilBlock { - - @Inject(method = "getLandingState", at = @At("HEAD"), cancellable = true) - private static void getLandingState(BlockState orignalState, CallbackInfoReturnable cir) { - if(AnvilFix.getConfig().shouldStopAnvilBreaking()) { - cir.setReturnValue(orignalState); - } - } -} diff --git a/src/main/java/io/github/onyxstudios/anvilfix/mixin/common/MixinAnvilContainer.java b/src/main/java/io/github/onyxstudios/anvilfix/mixin/common/MixinAnvilContainer.java deleted file mode 100644 index a4b8d40..0000000 --- a/src/main/java/io/github/onyxstudios/anvilfix/mixin/common/MixinAnvilContainer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * AnvilFix - * - * Copyright (C) 2019-2022 OnyxStudios - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package io.github.onyxstudios.anvilfix.mixin.common; - -import io.github.onyxstudios.anvilfix.AnvilFix; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.screen.AnvilScreenHandler; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Constant; -import org.spongepowered.asm.mixin.injection.ModifyConstant; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(AnvilScreenHandler.class) -public class MixinAnvilContainer { - - @ModifyConstant(method = "updateResult", constant = @Constant(intValue = 40, ordinal = 2)) - private int modifyInt(int input) { - return AnvilFix.getConfig().getLevelLimit(); - } - - @Redirect(method = "updateResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/enchantment/Enchantment;getMaxLevel()I")) - private int getMaximumLevelProxy(Enchantment enchantment) { - return AnvilFix.getConfig().getEnchantmentLimit(enchantment); - } -} diff --git a/src/main/java/io/github/onyxstudios/anvilfix/mixin/common/MixinItemStack.java b/src/main/java/io/github/onyxstudios/anvilfix/mixin/common/MixinItemStack.java deleted file mode 100644 index 8726343..0000000 --- a/src/main/java/io/github/onyxstudios/anvilfix/mixin/common/MixinItemStack.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * AnvilFix - * - * Copyright (C) 2019-2022 OnyxStudios - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package io.github.onyxstudios.anvilfix.mixin.common; - -import io.github.onyxstudios.anvilfix.AnvilFix; -import net.minecraft.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ItemStack.class) -public abstract class MixinItemStack { - - @Inject(method = "getRepairCost", at = @At("RETURN"), cancellable = true) - private void getRepairCost(CallbackInfoReturnable cir) { - if(cir.getReturnValueI() > 0 && AnvilFix.getConfig().removeIncrementalCost((ItemStack) (Object) this)) { - cir.setReturnValue(0); - } - } -} diff --git a/src/main/resources/assets/anvil_fix/lang/en_us.json b/src/main/resources/assets/anvil_fix/lang/en_us.json deleted file mode 100644 index 465ac54..0000000 --- a/src/main/resources/assets/anvil_fix/lang/en_us.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "text.autoconfig.anvil_fix.title": "Anvil Fix", - "text.autoconfig.anvil_fix.option.levelLimit": "Anvil Level Limit", - "text.autoconfig.anvil_fix.option.globalEnchantmentLevelLimit": "Maximum Enchantment Level", - "text.autoconfig.anvil_fix.option.removeIncrementalRepairCost": "Remove Incremental Repair Cost", - "text.autoconfig.anvil_fix.option.stopAnvilBreaking": "Stop Anvil Breaking" -} diff --git a/src/main/resources/assets/anvil_fix/lang/zh_cn.json b/src/main/resources/assets/anvil_fix/lang/zh_cn.json deleted file mode 100644 index 36253fc..0000000 --- a/src/main/resources/assets/anvil_fix/lang/zh_cn.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "text.autoconfig.anvil_fix.title": "铁砧修复", - "text.autoconfig.anvil_fix.option.levelLimit": "铁砧等级上限", - "text.autoconfig.anvil_fix.option.globalEnchantmentLevelLimit": "所需等级上限", - "text.autoconfig.anvil_fix.option.removeIncrementalRepairCost": "修复消耗不增长", - "text.autoconfig.anvil_fix.option.stopAnvilBreaking": "铁砧不再破损" -} diff --git a/src/main/resources/data/anvil_fix/tags/items/force_incremental_repair_cost.json b/src/main/resources/data/anvil_fix/tags/items/force_incremental_repair_cost.json deleted file mode 100644 index e06f96d..0000000 --- a/src/main/resources/data/anvil_fix/tags/items/force_incremental_repair_cost.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "replace": false, - "values":[ - ] -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json deleted file mode 100644 index 5f6580f..0000000 --- a/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "schemaVersion": 1, - "id": "anvil_fix", - "name": "AnvilFix", - "description": "Vanilla Anvils - but better! This mod removes the level limit for combining Items", - "license": "MIT", - "authors": [ - { - "name": "UpcraftLP", - "contact": { - "github": "UpcraftLP", - "homepage": "https://upcraft.dev", - "twitter": "@UpcraftLP" - } - } - ], - "contact": { - "homepage": "https://www.curseforge.com/minecraft/mc-mods/anvil-fix", - "source": "https://github.com/OnyxStudios/AnvilFix", - "issues": "https://github.com/OnyxStudios/AnvilFix/issues" - }, - "icon": "assets/anvil_fix/icon.png", - "version": "${version}", - "environment": "*", - "recommends": { - "fabric": "*", - "mesh": ">=0.20.0-alpha", - "modmenu": "*" - }, - "depends": { - "minecraft": "~1.18.2", - "fabricloader": ">=0.13", - "cloth-config": "^6.0.0-", - "fabric-resource-loader-v0": "*" - }, - "entrypoints": { - "main": [ - "io.github.onyxstudios.anvilfix.AnvilFix" - ], - "modmenu": [ - "io.github.onyxstudios.anvilfix.compat.AnvilfixModmenuCompat" - ] - }, - "mixins": [ - "mixins.anvil_fix.json" - ] -} diff --git a/src/main/resources/mixins.anvil_fix.json b/src/main/resources/mixins.anvil_fix.json deleted file mode 100644 index e978d54..0000000 --- a/src/main/resources/mixins.anvil_fix.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "required": true, - "package": "io.github.onyxstudios.anvilfix.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - "common.MixinAnvilBlock", - "common.MixinAnvilContainer", - "common.MixinItemStack" - ], - "client": [ - "client.MixinAnvilScreen" - ], - "injectors": { - "defaultRequire": 1 - } -}