diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index dfe0770..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 629f0ed..a2056ad 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -1,7 +1,7 @@ -name: Bug Report +name: Report A Bug description: >- - Please use this template when you have encountered a bug in this mod. -title: '[Bug]: ' + Only Minecraft versions listed on the main branch are supported. Support may additionally vary based on the severity of an issue. +title: "[Bug]: " labels: ["bug"] assignees: - Fuzss @@ -14,35 +14,49 @@ body: id: loader attributes: label: Mod Loader (Required) - description: What mod loader are you using the mod on? + description: What mod loader are you using to play the mod? multiple: false options: - - Forge - - Fabric - - Quilt + - "⸺" + - "Fabric" + - "NeoForge" + - "Forge" + - "Quilt" validations: required: true - type: input id: minecraft attributes: - label: Minecraft Version (Required) - description: What is the Minecraft version you are playing with? - placeholder: ex. 1.19 + label: Minecraft Version(s) (Required) + description: What Minecraft version(s) are you using the play the mod? + placeholder: ex. 1.20.1 validations: required: true - type: input id: version attributes: - label: Mod Version (Required) - description: What version of the mod are you playing with? - placeholder: ex. v4.0.0 + label: Mod Version(s) (Required) + description: What mod version(s) are you using to play? + placeholder: ex. v8.0.0 + validations: + required: true + - type: dropdown + id: mods + attributes: + label: Other Mods Involved (Required) + description: Can your issue be reproduced with a minimal set of mods (only this mod + dependencies)? + multiple: false + options: + - "⸺" + - "Yes" + - "No" validations: required: true - type: textarea id: notes attributes: label: Notes (Required) - description: Please explain what happens because of the bug (including all the steps required to cause the bug), and what behavior you would expect if the bug were fixed. + description: Please explain what happens because of the issue (including all the steps required to cause it), and what behavior you would expect if the issue were fixed. placeholder: >- ex. @@ -60,6 +74,8 @@ body: - type: input id: latest-log attributes: - label: latest.log (Optional) - description: Please paste the url to your shared `latest.log` file. [To share your `latest.log` here, please follow these steps.](https://gist.github.com/Fuzss/866b384d353912986e37b17eeef7a285) - placeholder: ex. https://gist.github.com// \ No newline at end of file + label: latest.log (Required) + description: Please paste the url to your shared `latest.log` file. Note that issue reports without this file are difficult to solve and unlikely to be processed. [To share your `latest.log` here, please follow these steps.](https://gist.github.com/Fuzss/866b384d353912986e37b17eeef7a285) + placeholder: ex. https://gist.github.com// + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 7f79bf6..cbe96b9 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ blank_issues_enabled: false contact_links: - - name: Questions - url: https://discord.gg/8ZmhaPPbjE - about: "Please ask questions on the Luna Pixel Studios Discord (in #fuzs-projects) or contact me directly on Discord at Fuzs#0212." \ No newline at end of file + - name: Ask A Question + url: https://lunapixel.studio/discord + about: "Join the Luna Pixel Studios Discord Server in the #fuzs-projects channel for additional support." \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/crash.yml b/.github/ISSUE_TEMPLATE/crash.yml index 690bc86..20493b1 100644 --- a/.github/ISSUE_TEMPLATE/crash.yml +++ b/.github/ISSUE_TEMPLATE/crash.yml @@ -1,8 +1,8 @@ -name: Crash Report +name: Submit A Crash Report description: >- - Please use this template when this mod has caused your game to crash. -title: '[Crash]: ' -labels: ["bug"] + Only Minecraft versions listed on the main branch are supported. Support may additionally vary based on the severity of an issue. +title: "[Crash]: " +labels: ["bug", "high priority"] assignees: - Fuzss body: @@ -14,35 +14,49 @@ body: id: loader attributes: label: Mod Loader (Required) - description: What mod loader are you using the mod on? + description: What mod loader are you using to play the mod? multiple: false options: - - Forge - - Fabric - - Quilt + - "⸺" + - "Fabric" + - "NeoForge" + - "Forge" + - "Quilt" validations: required: true - type: input id: minecraft attributes: - label: Minecraft Version (Required) - description: What is the Minecraft version you are playing with? - placeholder: ex. 1.19 + label: Minecraft Version(s) (Required) + description: What Minecraft version(s) are you using the play the mod? + placeholder: ex. 1.20.1 validations: required: true - type: input id: version attributes: - label: Mod Version (Required) - description: What version of the mod are you playing with? - placeholder: ex. v4.0.0 + label: Mod Version(s) (Required) + description: What mod version(s) are you using to play? + placeholder: ex. v8.0.0 + validations: + required: true + - type: dropdown + id: mods + attributes: + label: Other Mods Involved (Required) + description: Can your issue be reproduced with a minimal set of mods (only this mod + dependencies)? + multiple: false + options: + - "⸺" + - "Yes" + - "No" validations: required: true - type: textarea id: notes attributes: label: Notes (Required) - description: Please explain which steps we need to do to reproduce the crash. Please include anything else you'd like to say about the crash. + description: Please explain which steps we need to do to reproduce the issue. Please include anything else you'd like to say about it. placeholder: >- ex. @@ -58,7 +72,7 @@ body: attributes: label: Crash Report (Required) description: >- - Please paste the url to your shared crash report. [To share your crash report here, please follow these steps.](https://gist.github.com/Fuzss/9692f6ed5e8cca485a58004c28c9045b) + Please paste the url to your shared crash report. Note that issue reports without this file are difficult to solve and unlikely to be processed. [To share your crash report here, please follow these steps.](https://gist.github.com/Fuzss/9692f6ed5e8cca485a58004c28c9045b) placeholder: ex. https://gist.github.com// validations: required: true @@ -67,4 +81,4 @@ body: attributes: label: latest.log (Optional) description: Please paste the url to your shared `latest.log` file. [To share your `latest.log` here, please follow these steps.](https://gist.github.com/Fuzss/866b384d353912986e37b17eeef7a285) - placeholder: ex. https://gist.github.com// \ No newline at end of file + placeholder: ex. https://gist.github.com// diff --git a/.github/ISSUE_TEMPLATE/suggestion.yml b/.github/ISSUE_TEMPLATE/suggestion.yml index b4d3720..2a25400 100644 --- a/.github/ISSUE_TEMPLATE/suggestion.yml +++ b/.github/ISSUE_TEMPLATE/suggestion.yml @@ -1,11 +1,41 @@ -name: Suggestion +name: Leave A Suggestion description: >- - Please use this template when you want to suggest a feature. -title: '[Suggestion]: ' + Please do not ask for mod updates or ports, they will come when they are ready. +title: "[Suggestion]: " labels: ["enhancement"] assignees: - Fuzss body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this issue report! + - type: dropdown + id: loader + attributes: + label: Mod Loader (Optional) + description: What mod loader are you using to play the mod? + multiple: false + options: + - "⸺" + - "Fabric" + - "NeoForge" + - "Forge" + - "Quilt" + validations: + required: true + - type: input + id: minecraft + attributes: + label: Minecraft Version(s) (Optional) + description: What Minecraft version(s) are you using the play the mod? + placeholder: ex. 1.20.1 + - type: input + id: version + attributes: + label: Mod Version(s) (Optional) + description: What mod version(s) are you using to play? + placeholder: ex. v8.0.0 - type: textarea id: suggestion attributes: diff --git a/.gitignore b/.gitignore index 29fed19..223cbb5 100644 --- a/.gitignore +++ b/.gitignore @@ -32,8 +32,9 @@ classes *.ipr *.iws *.iml -.idea/* -!.idea/scopes +**/.idea/* +!**/.idea/scopes +!.idea/gradle.xml ### NetBeans ### nbproject/private/ @@ -59,14 +60,9 @@ gradle-app.setting .gradletasknamecache ### Other ### +run .DS_Store *.txt -!run -run/* -!run/options.txt -!run/config -run/config/* -!run/config/modmenu.json # Log file *.log diff --git a/.idea/scopes/Fabric_sources.xml b/1.18.2/.idea/scopes/Fabric_sources.xml similarity index 100% rename from .idea/scopes/Fabric_sources.xml rename to 1.18.2/.idea/scopes/Fabric_sources.xml diff --git a/.idea/scopes/Forge_sources.xml b/1.18.2/.idea/scopes/Forge_sources.xml similarity index 100% rename from .idea/scopes/Forge_sources.xml rename to 1.18.2/.idea/scopes/Forge_sources.xml diff --git a/1.18.2/CHANGELOG.md b/1.18.2/CHANGELOG.md new file mode 100644 index 0000000..916e567 --- /dev/null +++ b/1.18.2/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog]. + +## [v3.0.0-1.18.2] - 2023-06-25 +- Ported to Minecraft 1.18.2 + +[Keep a Changelog]: https://keepachangelog.com/en/1.0.0/ diff --git a/1.18.2/Common/build.gradle b/1.18.2/Common/build.gradle new file mode 100644 index 0000000..949b426 --- /dev/null +++ b/1.18.2/Common/build.gradle @@ -0,0 +1,11 @@ +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/common.gradle' + +dependencies { + // Puzzles Lib + modApi libs.puzzleslib.common +} + +// @see https://github.com/jaredlll08/MultiLoader-Template/issues/17#issuecomment-1221598082 +tasks.withType(net.fabricmc.loom.task.AbstractRemapJarTask).each { + it.targetNamespace = "named" +} diff --git a/1.18.2/Common/src/main/java/fuzs/examplemod/ExampleMod.java b/1.18.2/Common/src/main/java/fuzs/examplemod/ExampleMod.java new file mode 100644 index 0000000..45113b2 --- /dev/null +++ b/1.18.2/Common/src/main/java/fuzs/examplemod/ExampleMod.java @@ -0,0 +1,16 @@ +package fuzs.examplemod; + +import fuzs.puzzleslib.api.core.v1.ModConstructor; +import net.minecraft.resources.ResourceLocation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExampleMod implements ModConstructor { + public static final String MOD_ID = "examplemod"; + public static final String MOD_NAME = "Example Mod"; + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_NAME); + + public static ResourceLocation id(String path) { + return new ResourceLocation(MOD_ID, path); + } +} diff --git a/1.18.2/Common/src/main/java/fuzs/examplemod/client/ExampleModClient.java b/1.18.2/Common/src/main/java/fuzs/examplemod/client/ExampleModClient.java new file mode 100644 index 0000000..e1afacc --- /dev/null +++ b/1.18.2/Common/src/main/java/fuzs/examplemod/client/ExampleModClient.java @@ -0,0 +1,7 @@ +package fuzs.examplemod.client; + +import fuzs.puzzleslib.api.client.core.v1.ClientModConstructor; + +public class ExampleModClient implements ClientModConstructor { + +} diff --git a/1.18.2/Common/src/main/resources/examplemod.common.mixins.json b/1.18.2/Common/src/main/resources/examplemod.common.mixins.json new file mode 100644 index 0000000..ec8895e --- /dev/null +++ b/1.18.2/Common/src/main/resources/examplemod.common.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "compatibilityLevel": "JAVA_17", + "package": "fuzs.examplemod.mixin", + "refmap": "examplemod.refmap.json", + "plugin": "fuzs.examplemod.mixin.ModMixinConfigPlugin", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/1.18.2/Common/src/main/resources/mod_banner.png b/1.18.2/Common/src/main/resources/mod_banner.png new file mode 100644 index 0000000..bda5a0f Binary files /dev/null and b/1.18.2/Common/src/main/resources/mod_banner.png differ diff --git a/1.18.2/Common/src/main/resources/mod_logo.png b/1.18.2/Common/src/main/resources/mod_logo.png new file mode 100644 index 0000000..98c247e Binary files /dev/null and b/1.18.2/Common/src/main/resources/mod_logo.png differ diff --git a/1.18.2/Common/src/main/resources/pack.mcmeta b/1.18.2/Common/src/main/resources/pack.mcmeta new file mode 100755 index 0000000..19bfab2 --- /dev/null +++ b/1.18.2/Common/src/main/resources/pack.mcmeta @@ -0,0 +1,8 @@ +{ + "pack": { + "description": "${modDescription}", + "pack_format": ${resourcePackFormat}, + "forge:resource_pack_format": ${resourcePackFormat}, + "forge:data_pack_format": ${dataPackFormat} + } +} diff --git a/1.18.2/Fabric/build.gradle b/1.18.2/Fabric/build.gradle new file mode 100644 index 0000000..cd8b641 --- /dev/null +++ b/1.18.2/Fabric/build.gradle @@ -0,0 +1,29 @@ +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/fabric.gradle' + +def versionCatalog = extensions.getByType(VersionCatalogsExtension).named("libs") + +dependencies { + // Fabric Api + modApi libs.fabricapi.fabric + + // Puzzles Lib + modApi libs.puzzleslib.fabric + + // Cardinal Components +// modApi(include(libs.cardinalcomponentsbase.fabric.get())) +// modApi(include(libs.cardinalcomponentsentity.fabric.get())) +// modApi(include(libs.cardinalcomponentsblock.fabric.get())) +// modApi(include(libs.cardinalcomponentschunk.fabric.get())) +// modApi(include(libs.cardinalcomponentsworld.fabric.get())) + + // Extensible Enums +// modApi(include(libs.extensibleenums.fabric.get())) + + // Quality of Life Mods + versionCatalog.findLibrary("modmenu.fabric").ifPresent { + modLocalRuntime(it) + } + versionCatalog.findLibrary("forgeconfigscreens.fabric").ifPresent { + modLocalRuntime(it) + } +} diff --git a/1.18.2/Fabric/src/main/java/fuzs/examplemod/ExampleModFabric.java b/1.18.2/Fabric/src/main/java/fuzs/examplemod/ExampleModFabric.java new file mode 100644 index 0000000..124b062 --- /dev/null +++ b/1.18.2/Fabric/src/main/java/fuzs/examplemod/ExampleModFabric.java @@ -0,0 +1,12 @@ +package fuzs.examplemod; + +import fuzs.puzzleslib.api.core.v1.ModConstructor; +import net.fabricmc.api.ModInitializer; + +public class ExampleModFabric implements ModInitializer { + + @Override + public void onInitialize() { + ModConstructor.construct(ExampleMod.MOD_ID, ExampleMod::new); + } +} diff --git a/1.18.2/Fabric/src/main/java/fuzs/examplemod/client/ExampleModFabricClient.java b/1.18.2/Fabric/src/main/java/fuzs/examplemod/client/ExampleModFabricClient.java new file mode 100644 index 0000000..7b55517 --- /dev/null +++ b/1.18.2/Fabric/src/main/java/fuzs/examplemod/client/ExampleModFabricClient.java @@ -0,0 +1,13 @@ +package fuzs.examplemod.client; + +import fuzs.examplemod.ExampleMod; +import fuzs.puzzleslib.api.client.core.v1.ClientModConstructor; +import net.fabricmc.api.ClientModInitializer; + +public class ExampleModFabricClient implements ClientModInitializer { + + @Override + public void onInitializeClient() { + ClientModConstructor.construct(ExampleMod.MOD_ID, ExampleModClient::new); + } +} diff --git a/1.18.2/Fabric/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java b/1.18.2/Fabric/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java new file mode 100644 index 0000000..6d413e8 --- /dev/null +++ b/1.18.2/Fabric/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java @@ -0,0 +1,47 @@ +package fuzs.examplemod.mixin; + +import net.fabricmc.loader.api.FabricLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class ModMixinConfigPlugin implements IMixinConfigPlugin { + + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return FabricLoader.getInstance().isModLoaded("puzzleslib"); + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} diff --git a/1.18.2/Fabric/src/main/resources/examplemod.fabric.mixins.json b/1.18.2/Fabric/src/main/resources/examplemod.fabric.mixins.json new file mode 100644 index 0000000..ec8895e --- /dev/null +++ b/1.18.2/Fabric/src/main/resources/examplemod.fabric.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "compatibilityLevel": "JAVA_17", + "package": "fuzs.examplemod.mixin", + "refmap": "examplemod.refmap.json", + "plugin": "fuzs.examplemod.mixin.ModMixinConfigPlugin", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/1.18.2/Fabric/src/main/resources/fabric.mod.json b/1.18.2/Fabric/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..07fc00c --- /dev/null +++ b/1.18.2/Fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,45 @@ +{ + "schemaVersion": 1, + "id": "${modId}", + "version": "${modVersion}", + + "name": "${modName}", + "description": "${modDescription}", + + "authors": [ + "${modAuthor}" + ], + + "contact": { + "homepage": "${modPageUrl}", + "issues": "${modIssueUrl}", + "sources": "${modPageUrl}" + }, + + "license": "${modLicense}", + "icon": "mod_logo.png", + + "environment": "${modFabricEnvironment}", + + "entrypoints": { + "main": [ + "${mainEntryPoint}" + ], + "client": [ + "${clientEntryPoint}" + ] + }, + + "mixins": [ + "${modId}.common.mixins.json", + "${modId}.fabric.mixins.json" + ], + + "depends": { + "fabricloader": ">=${minFabricVersion}", + "fabric-api": ">=${minFabricApiVersion}", + "puzzleslib": ">=${minPuzzlesVersion}", + "minecraft": "${minecraftVersion}", + "java": ">=17" + } +} diff --git a/1.18.2/Forge/build.gradle b/1.18.2/Forge/build.gradle new file mode 100644 index 0000000..dec494a --- /dev/null +++ b/1.18.2/Forge/build.gradle @@ -0,0 +1,28 @@ +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/forge.gradle' + +def versionCatalog = extensions.getByType(VersionCatalogsExtension).named("libs") + +dependencies { + // Puzzles Lib + api fg.deobf(libs.puzzleslib.forge.get()) + + // Quality of Life Mods + versionCatalog.findLibrary("bettermodsbutton.forge").ifPresent { + runtimeOnly fg.deobf(it.get()) + } + versionCatalog.findLibrary("forgeconfigscreens.forge").ifPresent { + runtimeOnly fg.deobf(it.get()) + } +} + +task signJar(type: net.minecraftforge.gradle.common.tasks.SignJar, dependsOn: tasks.reobfJarJar) { + onlyIf { project.hasProperty('keyStore') } + keyStore = project.findProperty('keyStore') + alias = project.findProperty('keyStoreAlias') + storePass = project.findProperty('keyStorePass') + keyPass = project.findProperty('keyStoreKeyPass') + inputFile = outputFile = tasks.jarJar.archivePath +} + +jar.finalizedBy 'signJar' +signJar.mustRunAfter 'reobfJar' diff --git a/1.18.2/Forge/src/main/java/fuzs/examplemod/ExampleModForge.java b/1.18.2/Forge/src/main/java/fuzs/examplemod/ExampleModForge.java new file mode 100644 index 0000000..18d3c6f --- /dev/null +++ b/1.18.2/Forge/src/main/java/fuzs/examplemod/ExampleModForge.java @@ -0,0 +1,25 @@ +package fuzs.examplemod; + +import fuzs.puzzleslib.api.core.v1.ModConstructor; +import net.minecraft.data.DataGenerator; +import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; +import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; + +@Mod(ExampleMod.MOD_ID) +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) +public class ExampleModForge { + + @SubscribeEvent + public static void onConstructMod(final FMLConstructModEvent evt) { + ModConstructor.construct(ExampleMod.MOD_ID, ExampleMod::new); + } + + @SubscribeEvent + public static void onGatherData(final GatherDataEvent evt) { + final DataGenerator dataGenerator = evt.getGenerator(); + final ExistingFileHelper fileHelper = evt.getExistingFileHelper(); + } +} diff --git a/1.18.2/Forge/src/main/java/fuzs/examplemod/client/ExampleModForgeClient.java b/1.18.2/Forge/src/main/java/fuzs/examplemod/client/ExampleModForgeClient.java new file mode 100644 index 0000000..d6502ba --- /dev/null +++ b/1.18.2/Forge/src/main/java/fuzs/examplemod/client/ExampleModForgeClient.java @@ -0,0 +1,17 @@ +package fuzs.examplemod.client; + +import fuzs.examplemod.ExampleMod; +import fuzs.puzzleslib.api.client.core.v1.ClientModConstructor; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; + +@Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) +public class ExampleModForgeClient { + + @SubscribeEvent + public static void onConstructMod(final FMLConstructModEvent evt) { + ClientModConstructor.construct(ExampleMod.MOD_ID, ExampleModClient::new); + } +} diff --git a/1.18.2/Forge/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java b/1.18.2/Forge/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java new file mode 100644 index 0000000..af281eb --- /dev/null +++ b/1.18.2/Forge/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java @@ -0,0 +1,47 @@ +package fuzs.examplemod.mixin; + +import net.minecraftforge.fml.loading.FMLLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class ModMixinConfigPlugin implements IMixinConfigPlugin { + + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return FMLLoader.getLoadingModList().getModFileById("puzzleslib") != null; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} diff --git a/1.18.2/Forge/src/main/resources/META-INF/mods.toml b/1.18.2/Forge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..e15b638 --- /dev/null +++ b/1.18.2/Forge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,40 @@ +modLoader = "javafml" +loaderVersion = "[${minFMLVersion},)" +license = "${modLicense}" +issueTrackerURL = "${modIssueUrl}" + +[[mods]] +modId = "${modId}" +displayName = "${modName}" +description = "${modDescription}" +version = "${modVersion}" +authors = "${modAuthor}" +logoFile = "mod_banner.png" +logoBlur = false +displayURL = "${modPageUrl}" +updateJSONURL = "${modUpdateUrl}" +displayTest = "${modForgeDisplayTest}" + +[[dependencies.${ modId }]] +modId = "forge" +mandatory = true +versionRange = "[${minForgeVersion},)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.${ modId }]] +modId = "minecraft" +mandatory = true +versionRange = "[${minecraftVersion}]" +ordering = "NONE" +side = "BOTH" + +[[dependencies.${ modId }]] +modId = "puzzleslib" +mandatory = true +versionRange = "[${minPuzzlesVersion},)" +ordering = "NONE" +side = "BOTH" + +[modproperties.${ modId }] +catalogueImageIcon = "mod_logo.png" diff --git a/1.18.2/Forge/src/main/resources/examplemod.forge.mixins.json b/1.18.2/Forge/src/main/resources/examplemod.forge.mixins.json new file mode 100644 index 0000000..ec8895e --- /dev/null +++ b/1.18.2/Forge/src/main/resources/examplemod.forge.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "compatibilityLevel": "JAVA_17", + "package": "fuzs.examplemod.mixin", + "refmap": "examplemod.refmap.json", + "plugin": "fuzs.examplemod.mixin.ModMixinConfigPlugin", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/1.18.2/build.gradle b/1.18.2/build.gradle new file mode 100644 index 0000000..fadade3 --- /dev/null +++ b/1.18.2/build.gradle @@ -0,0 +1,12 @@ +plugins { + alias libs.plugins.loom apply false + alias libs.plugins.quiltflower apply false + alias libs.plugins.forgegradle apply false + alias libs.plugins.mixin apply false + alias libs.plugins.librarian apply false + alias libs.plugins.cursegradle apply false + alias libs.plugins.minotaur apply false +} + +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/main.gradle' +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/tasks.gradle' diff --git a/1.18.2/gradle.properties b/1.18.2/gradle.properties new file mode 100755 index 0000000..ff013f2 --- /dev/null +++ b/1.18.2/gradle.properties @@ -0,0 +1,35 @@ +# Sets default memory used for gradle commands. Can be overridden by user or command line properties. +# This is required to provide enough memory for the Minecraft decompilation process. +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false +org.gradle.parallel=true +copyBuildJar=true + +# Mod Attributes +modId=examplemod +modName=Example Mod +modVersion=3.0.0 +modAuthor=Fuzs +modDescription=Example description. +modLicense=MPL-2.0 +modSourceUrl=https://github.com/Fuzss/examplemod +modIssueUrl=https://github.com/Fuzss/examplemod/issues +modUpdateUrl=https://raw.githubusercontent.com/Fuzss/modresources/main/update/examplemod.json +modMavenGroup=fuzs.examplemod +# "MATCH_VERSION" for a mod required on both sides, "IGNORE_SERVER_VERSION" for a server only mod, "IGNORE_ALL_VERSION" for a client only mod +modForgeDisplayTest=MATCH_VERSION +# "*" for a mod loaded on both sides, "server" for a server only mod, "client" for a client only mod +modFabricEnvironment=* + +# Mod Publishing +projectReleaseType=release +projectCurseForgeId=0 +projectModrinthId=0 + +dependenciesVersionCatalog=1.18.2-v6 +dependenciesRequiredForgeCurseForge=puzzles-lib +dependenciesRequiredFabricCurseForge=fabric-api, forge-config-api-port-fabric, puzzles-lib +dependenciesRequiredForgeModrinth=puzzles-lib +dependenciesRequiredFabricModrinth=fabric-api, forge-config-api-port, puzzles-lib +#dependenciesEmbeddedFabricCurseForge=cardinal-components +#dependenciesEmbeddedFabricModrinth=cardinal-components-api diff --git a/1.18.2/gradle/wrapper/gradle-wrapper.jar b/1.18.2/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..943f0cb Binary files /dev/null and b/1.18.2/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/1.18.2/gradle/wrapper/gradle-wrapper.properties similarity index 84% rename from gradle/wrapper/gradle-wrapper.properties rename to 1.18.2/gradle/wrapper/gradle-wrapper.properties index 41dfb87..f398c33 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/1.18.2/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ 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-7.6-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/1.18.2/gradlew similarity index 93% rename from gradlew rename to 1.18.2/gradlew index 1b6c787..65dcd68 100755 --- a/gradlew +++ b/1.18.2/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# 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/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # 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"' @@ -143,12 +143,16 @@ 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=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=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ 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. diff --git a/gradlew.bat b/1.18.2/gradlew.bat similarity index 89% rename from gradlew.bat rename to 1.18.2/gradlew.bat index 107acd3..93e3f59 100644 --- a/gradlew.bat +++ b/1.18.2/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,7 +41,7 @@ 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. @@ -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/1.18.2/settings.gradle b/1.18.2/settings.gradle new file mode 100644 index 0000000..697dd5f --- /dev/null +++ b/1.18.2/settings.gradle @@ -0,0 +1,38 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + maven { + name = 'Sponge' + url = 'https://repo.spongepowered.org/repository/maven-public/' + } + maven { + name = 'Quilt' + url = 'https://maven.quiltmc.org/repository/release' + } + maven { + name = 'Minecraft Forge' + url = 'https://maven.minecraftforge.net/' + } + } +} + +dependencyResolutionManagement { + repositories { + maven { + name = "Fuzs Mod Resources" + url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" + } + } + versionCatalogs { + libs { + from("fuzs.sharedcatalogs:sharedcatalogs:${dependenciesVersionCatalog}") + } + } +} + +rootProject.name = "${modName.replaceAll("[^a-zA-Z]", "")}-${dependenciesVersionCatalog.replaceAll("-v\\d+", "")}" +include("Common", "Fabric", "Forge") diff --git a/1.19.2/.idea/scopes/Fabric_sources.xml b/1.19.2/.idea/scopes/Fabric_sources.xml new file mode 100644 index 0000000..0448412 --- /dev/null +++ b/1.19.2/.idea/scopes/Fabric_sources.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/1.19.2/.idea/scopes/Forge_sources.xml b/1.19.2/.idea/scopes/Forge_sources.xml new file mode 100644 index 0000000..7b5f24d --- /dev/null +++ b/1.19.2/.idea/scopes/Forge_sources.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/1.19.2/CHANGELOG.md b/1.19.2/CHANGELOG.md new file mode 100644 index 0000000..61ac69e --- /dev/null +++ b/1.19.2/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog]. + +## [v4.0.0-1.19.2] - 2023-06-25 +- Ported to Minecraft 1.19.2 + +[Keep a Changelog]: https://keepachangelog.com/en/1.0.0/ diff --git a/1.19.2/Common/build.gradle b/1.19.2/Common/build.gradle new file mode 100644 index 0000000..949b426 --- /dev/null +++ b/1.19.2/Common/build.gradle @@ -0,0 +1,11 @@ +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/common.gradle' + +dependencies { + // Puzzles Lib + modApi libs.puzzleslib.common +} + +// @see https://github.com/jaredlll08/MultiLoader-Template/issues/17#issuecomment-1221598082 +tasks.withType(net.fabricmc.loom.task.AbstractRemapJarTask).each { + it.targetNamespace = "named" +} diff --git a/1.19.2/Common/src/main/java/fuzs/examplemod/ExampleMod.java b/1.19.2/Common/src/main/java/fuzs/examplemod/ExampleMod.java new file mode 100644 index 0000000..ea9aa8b --- /dev/null +++ b/1.19.2/Common/src/main/java/fuzs/examplemod/ExampleMod.java @@ -0,0 +1,16 @@ +package fuzs.examplemod; + +import fuzs.puzzleslib.core.ModConstructor; +import net.minecraft.resources.ResourceLocation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExampleMod implements ModConstructor { + public static final String MOD_ID = "examplemod"; + public static final String MOD_NAME = "Example Mod"; + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_NAME); + + public static ResourceLocation id(String path) { + return new ResourceLocation(MOD_ID, path); + } +} diff --git a/1.19.2/Common/src/main/java/fuzs/examplemod/client/ExampleModClient.java b/1.19.2/Common/src/main/java/fuzs/examplemod/client/ExampleModClient.java new file mode 100644 index 0000000..d36b967 --- /dev/null +++ b/1.19.2/Common/src/main/java/fuzs/examplemod/client/ExampleModClient.java @@ -0,0 +1,7 @@ +package fuzs.examplemod.client; + +import fuzs.puzzleslib.client.core.ClientModConstructor; + +public class ExampleModClient implements ClientModConstructor { + +} diff --git a/1.19.2/Common/src/main/resources/examplemod.common.mixins.json b/1.19.2/Common/src/main/resources/examplemod.common.mixins.json new file mode 100644 index 0000000..ec8895e --- /dev/null +++ b/1.19.2/Common/src/main/resources/examplemod.common.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "compatibilityLevel": "JAVA_17", + "package": "fuzs.examplemod.mixin", + "refmap": "examplemod.refmap.json", + "plugin": "fuzs.examplemod.mixin.ModMixinConfigPlugin", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/1.19.2/Common/src/main/resources/mod_banner.png b/1.19.2/Common/src/main/resources/mod_banner.png new file mode 100644 index 0000000..bda5a0f Binary files /dev/null and b/1.19.2/Common/src/main/resources/mod_banner.png differ diff --git a/1.19.2/Common/src/main/resources/mod_logo.png b/1.19.2/Common/src/main/resources/mod_logo.png new file mode 100644 index 0000000..98c247e Binary files /dev/null and b/1.19.2/Common/src/main/resources/mod_logo.png differ diff --git a/1.19.2/Common/src/main/resources/pack.mcmeta b/1.19.2/Common/src/main/resources/pack.mcmeta new file mode 100755 index 0000000..19bfab2 --- /dev/null +++ b/1.19.2/Common/src/main/resources/pack.mcmeta @@ -0,0 +1,8 @@ +{ + "pack": { + "description": "${modDescription}", + "pack_format": ${resourcePackFormat}, + "forge:resource_pack_format": ${resourcePackFormat}, + "forge:data_pack_format": ${dataPackFormat} + } +} diff --git a/1.19.2/Fabric/build.gradle b/1.19.2/Fabric/build.gradle new file mode 100644 index 0000000..cd8b641 --- /dev/null +++ b/1.19.2/Fabric/build.gradle @@ -0,0 +1,29 @@ +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/fabric.gradle' + +def versionCatalog = extensions.getByType(VersionCatalogsExtension).named("libs") + +dependencies { + // Fabric Api + modApi libs.fabricapi.fabric + + // Puzzles Lib + modApi libs.puzzleslib.fabric + + // Cardinal Components +// modApi(include(libs.cardinalcomponentsbase.fabric.get())) +// modApi(include(libs.cardinalcomponentsentity.fabric.get())) +// modApi(include(libs.cardinalcomponentsblock.fabric.get())) +// modApi(include(libs.cardinalcomponentschunk.fabric.get())) +// modApi(include(libs.cardinalcomponentsworld.fabric.get())) + + // Extensible Enums +// modApi(include(libs.extensibleenums.fabric.get())) + + // Quality of Life Mods + versionCatalog.findLibrary("modmenu.fabric").ifPresent { + modLocalRuntime(it) + } + versionCatalog.findLibrary("forgeconfigscreens.fabric").ifPresent { + modLocalRuntime(it) + } +} diff --git a/1.19.2/Fabric/src/main/java/fuzs/examplemod/ExampleModFabric.java b/1.19.2/Fabric/src/main/java/fuzs/examplemod/ExampleModFabric.java new file mode 100644 index 0000000..9c64526 --- /dev/null +++ b/1.19.2/Fabric/src/main/java/fuzs/examplemod/ExampleModFabric.java @@ -0,0 +1,12 @@ +package fuzs.examplemod; + +import fuzs.puzzleslib.core.CommonFactories; +import net.fabricmc.api.ModInitializer; + +public class ExampleModFabric implements ModInitializer { + + @Override + public void onInitialize() { + CommonFactories.INSTANCE.modConstructor(ExampleMod.MOD_ID).accept(new ExampleMod()); + } +} diff --git a/1.19.2/Fabric/src/main/java/fuzs/examplemod/client/ExampleModFabricClient.java b/1.19.2/Fabric/src/main/java/fuzs/examplemod/client/ExampleModFabricClient.java new file mode 100644 index 0000000..a9677a6 --- /dev/null +++ b/1.19.2/Fabric/src/main/java/fuzs/examplemod/client/ExampleModFabricClient.java @@ -0,0 +1,13 @@ +package fuzs.examplemod.client; + +import fuzs.examplemod.ExampleMod; +import fuzs.puzzleslib.client.core.ClientFactories; +import net.fabricmc.api.ClientModInitializer; + +public class ExampleModFabricClient implements ClientModInitializer { + + @Override + public void onInitializeClient() { + ClientFactories.INSTANCE.clientModConstructor(ExampleMod.MOD_ID).accept(new ExampleModClient()); + } +} diff --git a/1.19.2/Fabric/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java b/1.19.2/Fabric/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java new file mode 100644 index 0000000..6d413e8 --- /dev/null +++ b/1.19.2/Fabric/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java @@ -0,0 +1,47 @@ +package fuzs.examplemod.mixin; + +import net.fabricmc.loader.api.FabricLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class ModMixinConfigPlugin implements IMixinConfigPlugin { + + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return FabricLoader.getInstance().isModLoaded("puzzleslib"); + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} diff --git a/1.19.2/Fabric/src/main/resources/examplemod.fabric.mixins.json b/1.19.2/Fabric/src/main/resources/examplemod.fabric.mixins.json new file mode 100644 index 0000000..ec8895e --- /dev/null +++ b/1.19.2/Fabric/src/main/resources/examplemod.fabric.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "compatibilityLevel": "JAVA_17", + "package": "fuzs.examplemod.mixin", + "refmap": "examplemod.refmap.json", + "plugin": "fuzs.examplemod.mixin.ModMixinConfigPlugin", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/1.19.2/Fabric/src/main/resources/fabric.mod.json b/1.19.2/Fabric/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..07fc00c --- /dev/null +++ b/1.19.2/Fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,45 @@ +{ + "schemaVersion": 1, + "id": "${modId}", + "version": "${modVersion}", + + "name": "${modName}", + "description": "${modDescription}", + + "authors": [ + "${modAuthor}" + ], + + "contact": { + "homepage": "${modPageUrl}", + "issues": "${modIssueUrl}", + "sources": "${modPageUrl}" + }, + + "license": "${modLicense}", + "icon": "mod_logo.png", + + "environment": "${modFabricEnvironment}", + + "entrypoints": { + "main": [ + "${mainEntryPoint}" + ], + "client": [ + "${clientEntryPoint}" + ] + }, + + "mixins": [ + "${modId}.common.mixins.json", + "${modId}.fabric.mixins.json" + ], + + "depends": { + "fabricloader": ">=${minFabricVersion}", + "fabric-api": ">=${minFabricApiVersion}", + "puzzleslib": ">=${minPuzzlesVersion}", + "minecraft": "${minecraftVersion}", + "java": ">=17" + } +} diff --git a/1.19.2/Forge/build.gradle b/1.19.2/Forge/build.gradle new file mode 100644 index 0000000..fc4b4de --- /dev/null +++ b/1.19.2/Forge/build.gradle @@ -0,0 +1,29 @@ +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/forge.gradle' + +def versionCatalog = extensions.getByType(VersionCatalogsExtension).named("libs") + +dependencies { + // Puzzles Lib + api fg.deobf(libs.puzzleslib.forge.get()) + + // Quality of Life Mods + versionCatalog.findLibrary("bettermodsbutton.forge").ifPresent { + runtimeOnly fg.deobf(it.get()) + } +// runtimeOnly fg.deobf("fuzs.bettermodsbutton:bettermodsbutton-forge:${libs.versions.bettermodsbutton.get()}") + versionCatalog.findLibrary("forgeconfigscreens.forge").ifPresent { + runtimeOnly fg.deobf(it.get()) + } +} + +task signJar(type: net.minecraftforge.gradle.common.tasks.SignJar, dependsOn: tasks.reobfJarJar) { + onlyIf { project.hasProperty('keyStore') } + keyStore = project.findProperty('keyStore') + alias = project.findProperty('keyStoreAlias') + storePass = project.findProperty('keyStorePass') + keyPass = project.findProperty('keyStoreKeyPass') + inputFile = outputFile = tasks.jarJar.archivePath +} + +jar.finalizedBy 'signJar' +signJar.mustRunAfter 'reobfJar' diff --git a/1.19.2/Forge/src/main/java/fuzs/examplemod/ExampleModForge.java b/1.19.2/Forge/src/main/java/fuzs/examplemod/ExampleModForge.java new file mode 100644 index 0000000..ab8de0a --- /dev/null +++ b/1.19.2/Forge/src/main/java/fuzs/examplemod/ExampleModForge.java @@ -0,0 +1,25 @@ +package fuzs.examplemod; + +import fuzs.puzzleslib.core.CommonFactories; +import net.minecraft.data.DataGenerator; +import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.data.event.GatherDataEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; + +@Mod(ExampleMod.MOD_ID) +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) +public class ExampleModForge { + + @SubscribeEvent + public static void onConstructMod(final FMLConstructModEvent evt) { + CommonFactories.INSTANCE.modConstructor(ExampleMod.MOD_ID).accept(new ExampleMod()); + } + + @SubscribeEvent + public static void onGatherData(final GatherDataEvent evt) { + final DataGenerator dataGenerator = evt.getGenerator(); + final ExistingFileHelper fileHelper = evt.getExistingFileHelper(); + } +} diff --git a/1.19.2/Forge/src/main/java/fuzs/examplemod/client/ExampleModForgeClient.java b/1.19.2/Forge/src/main/java/fuzs/examplemod/client/ExampleModForgeClient.java new file mode 100644 index 0000000..1abfe32 --- /dev/null +++ b/1.19.2/Forge/src/main/java/fuzs/examplemod/client/ExampleModForgeClient.java @@ -0,0 +1,17 @@ +package fuzs.examplemod.client; + +import fuzs.examplemod.ExampleMod; +import fuzs.puzzleslib.client.core.ClientFactories; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; + +@Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) +public class ExampleModForgeClient { + + @SubscribeEvent + public static void onConstructMod(final FMLConstructModEvent evt) { + ClientFactories.INSTANCE.clientModConstructor(ExampleMod.MOD_ID).accept(new ExampleModClient()); + } +} diff --git a/1.19.2/Forge/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java b/1.19.2/Forge/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java new file mode 100644 index 0000000..af281eb --- /dev/null +++ b/1.19.2/Forge/src/main/java/fuzs/examplemod/mixin/ModMixinConfigPlugin.java @@ -0,0 +1,47 @@ +package fuzs.examplemod.mixin; + +import net.minecraftforge.fml.loading.FMLLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class ModMixinConfigPlugin implements IMixinConfigPlugin { + + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return FMLLoader.getLoadingModList().getModFileById("puzzleslib") != null; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} diff --git a/1.19.2/Forge/src/main/resources/META-INF/mods.toml b/1.19.2/Forge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..e15b638 --- /dev/null +++ b/1.19.2/Forge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,40 @@ +modLoader = "javafml" +loaderVersion = "[${minFMLVersion},)" +license = "${modLicense}" +issueTrackerURL = "${modIssueUrl}" + +[[mods]] +modId = "${modId}" +displayName = "${modName}" +description = "${modDescription}" +version = "${modVersion}" +authors = "${modAuthor}" +logoFile = "mod_banner.png" +logoBlur = false +displayURL = "${modPageUrl}" +updateJSONURL = "${modUpdateUrl}" +displayTest = "${modForgeDisplayTest}" + +[[dependencies.${ modId }]] +modId = "forge" +mandatory = true +versionRange = "[${minForgeVersion},)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.${ modId }]] +modId = "minecraft" +mandatory = true +versionRange = "[${minecraftVersion}]" +ordering = "NONE" +side = "BOTH" + +[[dependencies.${ modId }]] +modId = "puzzleslib" +mandatory = true +versionRange = "[${minPuzzlesVersion},)" +ordering = "NONE" +side = "BOTH" + +[modproperties.${ modId }] +catalogueImageIcon = "mod_logo.png" diff --git a/1.19.2/Forge/src/main/resources/examplemod.forge.mixins.json b/1.19.2/Forge/src/main/resources/examplemod.forge.mixins.json new file mode 100644 index 0000000..ec8895e --- /dev/null +++ b/1.19.2/Forge/src/main/resources/examplemod.forge.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "compatibilityLevel": "JAVA_17", + "package": "fuzs.examplemod.mixin", + "refmap": "examplemod.refmap.json", + "plugin": "fuzs.examplemod.mixin.ModMixinConfigPlugin", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/1.19.2/build.gradle b/1.19.2/build.gradle new file mode 100644 index 0000000..fadade3 --- /dev/null +++ b/1.19.2/build.gradle @@ -0,0 +1,12 @@ +plugins { + alias libs.plugins.loom apply false + alias libs.plugins.quiltflower apply false + alias libs.plugins.forgegradle apply false + alias libs.plugins.mixin apply false + alias libs.plugins.librarian apply false + alias libs.plugins.cursegradle apply false + alias libs.plugins.minotaur apply false +} + +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/main.gradle' +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/tasks.gradle' diff --git a/1.19.2/gradle.properties b/1.19.2/gradle.properties new file mode 100755 index 0000000..b41f3a6 --- /dev/null +++ b/1.19.2/gradle.properties @@ -0,0 +1,35 @@ +# Sets default memory used for gradle commands. Can be overridden by user or command line properties. +# This is required to provide enough memory for the Minecraft decompilation process. +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false +org.gradle.parallel=true +copyBuildJar=true + +# Mod Attributes +modId=examplemod +modName=Example Mod +modVersion=4.0.0 +modAuthor=Fuzs +modDescription=Example description. +modLicense=MPL-2.0 +modSourceUrl=https://github.com/Fuzss/examplemod +modIssueUrl=https://github.com/Fuzss/examplemod/issues +modUpdateUrl=https://raw.githubusercontent.com/Fuzss/modresources/main/update/examplemod.json +modMavenGroup=fuzs.examplemod +# "MATCH_VERSION" for a mod required on both sides, "IGNORE_SERVER_VERSION" for a server only mod, "IGNORE_ALL_VERSION" for a client only mod +modForgeDisplayTest=MATCH_VERSION +# "*" for a mod loaded on both sides, "server" for a server only mod, "client" for a client only mod +modFabricEnvironment=* + +# Mod Publishing +projectReleaseType=release +projectCurseForgeId=0 +projectModrinthId=0 + +dependenciesVersionCatalog=1.19.2-v6 +dependenciesRequiredForgeCurseForge=puzzles-lib +dependenciesRequiredFabricCurseForge=fabric-api, forge-config-api-port-fabric, puzzles-lib +dependenciesRequiredForgeModrinth=puzzles-lib +dependenciesRequiredFabricModrinth=fabric-api, forge-config-api-port, puzzles-lib +#dependenciesEmbeddedFabricCurseForge=cardinal-components +#dependenciesEmbeddedFabricModrinth=cardinal-components-api diff --git a/1.19.2/gradle/wrapper/gradle-wrapper.jar b/1.19.2/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..943f0cb Binary files /dev/null and b/1.19.2/gradle/wrapper/gradle-wrapper.jar differ diff --git a/1.19.2/gradle/wrapper/gradle-wrapper.properties b/1.19.2/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..f398c33 --- /dev/null +++ b/1.19.2/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/1.19.2/gradlew b/1.19.2/gradlew new file mode 100755 index 0000000..65dcd68 --- /dev/null +++ b/1.19.2/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# 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. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# 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 +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 + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# 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"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +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 ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +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 + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +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. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + 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=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +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" || "$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 + 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 + # 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 +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +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/1.19.2/gradlew.bat b/1.19.2/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/1.19.2/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +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. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +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. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +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! +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 + +:omega diff --git a/1.19.2/settings.gradle b/1.19.2/settings.gradle new file mode 100644 index 0000000..697dd5f --- /dev/null +++ b/1.19.2/settings.gradle @@ -0,0 +1,38 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + maven { + name = 'Sponge' + url = 'https://repo.spongepowered.org/repository/maven-public/' + } + maven { + name = 'Quilt' + url = 'https://maven.quiltmc.org/repository/release' + } + maven { + name = 'Minecraft Forge' + url = 'https://maven.minecraftforge.net/' + } + } +} + +dependencyResolutionManagement { + repositories { + maven { + name = "Fuzs Mod Resources" + url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" + } + } + versionCatalogs { + libs { + from("fuzs.sharedcatalogs:sharedcatalogs:${dependenciesVersionCatalog}") + } + } +} + +rootProject.name = "${modName.replaceAll("[^a-zA-Z]", "")}-${dependenciesVersionCatalog.replaceAll("-v\\d+", "")}" +include("Common", "Fabric", "Forge") diff --git a/1.20.1/.idea/scopes/Fabric_sources.xml b/1.20.1/.idea/scopes/Fabric_sources.xml new file mode 100644 index 0000000..0448412 --- /dev/null +++ b/1.20.1/.idea/scopes/Fabric_sources.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/1.20.1/.idea/scopes/Forge_sources.xml b/1.20.1/.idea/scopes/Forge_sources.xml new file mode 100644 index 0000000..7b5f24d --- /dev/null +++ b/1.20.1/.idea/scopes/Forge_sources.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/1.20.1/CHANGELOG.md b/1.20.1/CHANGELOG.md new file mode 100644 index 0000000..8789b77 --- /dev/null +++ b/1.20.1/CHANGELOG.md @@ -0,0 +1,17 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog]. + +## [v8.0.2-1.20.1] - 2024-01-24 +### Fix +- Fix unable to click on search box to select + +## [v8.0.1-1.20.1] - 2023-07-13 +### Fixed +- Fixed Mixin config plugin being configured incorrectly on Fabric + +## [v8.0.0-1.20.1] - 2023-06-27 +- Ported to Minecraft 1.20.1 + +[Keep a Changelog]: https://keepachangelog.com/en/1.0.0/ diff --git a/1.20.1/Common/build.gradle b/1.20.1/Common/build.gradle new file mode 100644 index 0000000..949b426 --- /dev/null +++ b/1.20.1/Common/build.gradle @@ -0,0 +1,11 @@ +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/common.gradle' + +dependencies { + // Puzzles Lib + modApi libs.puzzleslib.common +} + +// @see https://github.com/jaredlll08/MultiLoader-Template/issues/17#issuecomment-1221598082 +tasks.withType(net.fabricmc.loom.task.AbstractRemapJarTask).each { + it.targetNamespace = "named" +} diff --git a/Common/src/main/java/fuzs/tradingpost/TradingPost.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/TradingPost.java similarity index 54% rename from Common/src/main/java/fuzs/tradingpost/TradingPost.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/TradingPost.java index 15db11d..333c896 100644 --- a/Common/src/main/java/fuzs/tradingpost/TradingPost.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/TradingPost.java @@ -1,16 +1,19 @@ package fuzs.tradingpost; -import fuzs.puzzleslib.config.ConfigHolder; -import fuzs.puzzleslib.core.CoreServices; -import fuzs.puzzleslib.core.ModConstructor; -import fuzs.puzzleslib.network.MessageDirection; -import fuzs.puzzleslib.network.NetworkHandler; +import fuzs.puzzleslib.api.config.v3.ConfigHolder; +import fuzs.puzzleslib.api.core.v1.ModConstructor; +import fuzs.puzzleslib.api.core.v1.context.BuildCreativeModeTabContentsContext; +import fuzs.puzzleslib.api.core.v1.context.FuelBurnTimesContext; +import fuzs.puzzleslib.api.network.v2.MessageDirection; +import fuzs.puzzleslib.api.network.v2.NetworkHandlerV2; import fuzs.tradingpost.config.ServerConfig; import fuzs.tradingpost.init.ModRegistry; -import fuzs.tradingpost.network.client.C2SClearSlotsMessage; import fuzs.tradingpost.network.S2CBuildOffersMessage; import fuzs.tradingpost.network.S2CMerchantDataMessage; import fuzs.tradingpost.network.S2CRemoveMerchantsMessage; +import fuzs.tradingpost.network.client.C2SClearSlotsMessage; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.CreativeModeTabs; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,13 +22,11 @@ public class TradingPost implements ModConstructor { public static final String MOD_NAME = "Trading Post"; public static final Logger LOGGER = LoggerFactory.getLogger(MOD_NAME); - public static final NetworkHandler NETWORK = CoreServices.FACTORIES.network(MOD_ID); - @SuppressWarnings("Convert2MethodRef") - public static final ConfigHolder CONFIG = CoreServices.FACTORIES.serverConfig(ServerConfig.class, () -> new ServerConfig()); + public static final NetworkHandlerV2 NETWORK = NetworkHandlerV2.build(MOD_ID); + public static final ConfigHolder CONFIG = ConfigHolder.builder(MOD_ID).server(ServerConfig.class); @Override public void onConstructMod() { - CONFIG.bakeConfigs(MOD_ID); ModRegistry.touch(); registerMessages(); } @@ -37,8 +38,19 @@ private static void registerMessages() { NETWORK.register(C2SClearSlotsMessage.class, C2SClearSlotsMessage::new, MessageDirection.TO_SERVER); } + @Override + public void onBuildCreativeModeTabContents(BuildCreativeModeTabContentsContext context) { + context.registerBuildListener(CreativeModeTabs.FUNCTIONAL_BLOCKS, (itemDisplayParameters, output) -> { + output.accept(ModRegistry.TRADING_POST_ITEM.get()); + }); + } + @Override public void onRegisterFuelBurnTimes(FuelBurnTimesContext context) { - context.registerWoodenBlock(ModRegistry.TRADING_POST_BLOCK.get()); + context.registerFuel(300, ModRegistry.TRADING_POST_BLOCK.get()); + } + + public static ResourceLocation id(String path) { + return new ResourceLocation(MOD_ID, path); } } diff --git a/1.20.1/Common/src/main/java/fuzs/tradingpost/client/TradingPostClient.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/client/TradingPostClient.java new file mode 100644 index 0000000..5c4c211 --- /dev/null +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/client/TradingPostClient.java @@ -0,0 +1,46 @@ +package fuzs.tradingpost.client; + +import fuzs.puzzleslib.api.client.core.v1.ClientModConstructor; +import fuzs.puzzleslib.api.client.core.v1.context.BlockEntityRenderersContext; +import fuzs.puzzleslib.api.client.core.v1.context.SearchRegistryContext; +import fuzs.puzzleslib.api.core.v1.context.ModLifecycleContext; +import fuzs.tradingpost.client.gui.screens.inventory.TradingPostScreen; +import fuzs.tradingpost.client.renderer.blockentity.TradingPostRenderer; +import fuzs.tradingpost.init.ModRegistry; +import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.screens.MenuScreens; +import net.minecraft.client.searchtree.FullTextSearchTree; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; + +import java.util.stream.Stream; + +public class TradingPostClient implements ClientModConstructor { + + @Override + public void onClientSetup(ModLifecycleContext context) { + MenuScreens.register(ModRegistry.TRADING_POST_MENU_TYPE.get(), TradingPostScreen::new); + } + + @Override + public void onRegisterBlockEntityRenderers(BlockEntityRenderersContext context) { + context.registerBlockEntityRenderer(ModRegistry.TRADING_POST_BLOCK_ENTITY_TYPE.get(), TradingPostRenderer::new); + } + + @Override + public void onRegisterSearchTrees(SearchRegistryContext context) { + context.registerSearchTree(TradingPostScreen.OFFER_SEARCH_TREE, base -> new FullTextSearchTree<>(offer -> + Stream.of(offer.getBaseCostA(), offer.getCostB(), offer.getResult()) + .filter(itemStack -> !itemStack.isEmpty()) + .flatMap(itemStack -> itemStack.getTooltipLines(null, TooltipFlag.Default.NORMAL).stream()) + .map(tooltipLine -> ChatFormatting.stripFormatting(tooltipLine.getString()).trim()) + .filter(tooltipString -> !tooltipString.isEmpty()), + offer -> Stream.of(offer.getBaseCostA(), offer.getCostB(), offer.getResult()) + .filter(itemStack -> !itemStack.isEmpty()) + .map(ItemStack::getItem) + .map(BuiltInRegistries.ITEM::getKey), + base + )); + } +} diff --git a/Common/src/main/java/fuzs/tradingpost/client/gui/screens/inventory/TradingPostScreen.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/client/gui/screens/inventory/TradingPostScreen.java similarity index 64% rename from Common/src/main/java/fuzs/tradingpost/client/gui/screens/inventory/TradingPostScreen.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/client/gui/screens/inventory/TradingPostScreen.java index d876ad6..31f11f5 100644 --- a/Common/src/main/java/fuzs/tradingpost/client/gui/screens/inventory/TradingPostScreen.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/client/gui/screens/inventory/TradingPostScreen.java @@ -1,10 +1,8 @@ package fuzs.tradingpost.client.gui.screens.inventory; +import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import fuzs.puzzleslib.client.core.ClientCoreServices; import fuzs.tradingpost.TradingPost; -import fuzs.tradingpost.client.TradingPostClient; import fuzs.tradingpost.mixin.client.accessor.ButtonAccessor; import fuzs.tradingpost.mixin.client.accessor.MerchantScreenAccessor; import fuzs.tradingpost.mixin.client.accessor.TradeOfferButtonAccessor; @@ -12,13 +10,14 @@ import fuzs.tradingpost.world.inventory.TradingPostMenu; import fuzs.tradingpost.world.item.trading.TradingPostOffers; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.EditBox; -import net.minecraft.client.gui.components.Widget; +import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.screens.inventory.MerchantScreen; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.searchtree.SearchRegistry; import net.minecraft.client.searchtree.SearchTree; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ServerboundSelectTradePacket; @@ -37,6 +36,7 @@ public class TradingPostScreen extends MerchantScreen { public static final ResourceLocation MAGNIFYING_GLASS_LOCATION = new ResourceLocation(TradingPost.MOD_ID, "item/magnifying_glass"); + public static final SearchRegistry.Key OFFER_SEARCH_TREE = new SearchRegistry.Key<>(); private static final ResourceLocation VILLAGER_LOCATION = new ResourceLocation("textures/gui/container/villager2.png"); private static final ResourceLocation CREATIVE_INVENTORY_LOCATION = new ResourceLocation("textures/gui/container/creative_inventory/tab_item_search.png"); private static final Component DEPRECATED_TOOLTIP = Component.translatable("merchant.deprecated"); @@ -54,15 +54,15 @@ public TradingPostScreen(MerchantMenu container, Inventory playerInventory, Comp @Override protected void init() { super.init(); - this.tradeOfferButtons = this.getTradeOfferButtons(ClientCoreServices.SCREENS.getRenderableButtons(this)); + this.tradeOfferButtons = this.getTradeOfferButtons(this.renderables); for (Button tradeOfferButton : this.tradeOfferButtons) { - ((ButtonAccessor) tradeOfferButton).setOnPress(button -> { + ((ButtonAccessor) tradeOfferButton).tradingpost$setOnPress(button -> { MerchantScreenAccessor accessor = (MerchantScreenAccessor) this; - final int shopItem = ((TradeOfferButtonAccessor) button).getIndex() + accessor.getScrollOff(); + final int shopItem = ((TradeOfferButtonAccessor) button).tradingpost$getIndex() + accessor.tradingpost$getScrollOff(); MerchantOffers offers = this.getMenu().getOffers(); - accessor.setShopItem(shopItem); + accessor.tradingpost$setShopItem(shopItem); this.getMenu().setSelectionHint(shopItem); this.getMenu().getTraders().setActiveOffer(offers.get(shopItem)); this.getMenu().tryMoveItems(shopItem); @@ -75,7 +75,7 @@ protected void init() { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { // left click clears text - if (this.isVisible() && button == 1) { + if (this.isVisible() && button == InputConstants.MOUSE_BUTTON_RIGHT) { this.setValue(""); TradingPostScreen.this.refreshSearchResults(); } @@ -88,11 +88,8 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { this.addWidget(this.searchBox); } - private Button[] getTradeOfferButtons(List buttons) { - Button[] tradeOfferButtons = buttons.stream() - .filter(button -> button instanceof TradeOfferButtonAccessor) - .map(button -> (Button) button) - .toArray(Button[]::new); + private Button[] getTradeOfferButtons(List buttons) { + Button[] tradeOfferButtons = buttons.stream().filter(button -> button instanceof TradeOfferButtonAccessor).map(button -> (Button) button).toArray(Button[]::new); if (tradeOfferButtons.length != 7) { TradingPost.LOGGER.warn("Unable to find enough tradeOfferButtons"); } @@ -101,7 +98,6 @@ private Button[] getTradeOfferButtons(List buttons) { @Override public void resize(Minecraft mc, int newWidth, int newHeight) { - final String lastSearch = this.searchBox.getValue(); super.resize(mc, newWidth, newHeight); this.searchBox.setValue(lastSearch); @@ -112,8 +108,7 @@ public void resize(Minecraft mc, int newWidth, int newHeight) { } @Override - protected void renderLabels(PoseStack matrixStack, int mouseX, int mouseY) { - + protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) { Component title = this.getMenu().getTraders().getDisplayName(); if (title != null) { int traderLevel = this.menu.getTraderLevel(); @@ -123,36 +118,34 @@ protected void renderLabels(PoseStack matrixStack, int mouseX, int mouseY) { } else { title = this.title; } - this.font.draw(matrixStack, title, (float)(49 + this.imageWidth / 2 - this.font.width(title) / 2), 6.0F, 4210752); - this.font.draw(matrixStack, this.playerInventoryTitle, (float)this.inventoryLabelX, (float)this.inventoryLabelY, 4210752); + guiGraphics.drawString(this.font, title, (49 + this.imageWidth / 2 - this.font.width(title) / 2), 6, 0x404040, false); + guiGraphics.drawString(this.font, this.playerInventoryTitle, this.inventoryLabelX, this.inventoryLabelY, 0x404040, false); } @Override - public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialTime) { + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTime) { MerchantOffers merchantoffers = this.getMenu().getOffers(); this.setButtonsActive(merchantoffers); - final int scrollOff = ((MerchantScreenAccessor) this).getScrollOff(); + final int scrollOff = ((MerchantScreenAccessor) this).tradingpost$getScrollOff(); final Slot hoveredSlot = this.hoveredSlot; // set offers to empty to prevent MerchantScreen::render code from running, also disabled buttons drawing tooltips by changing scrollOff, as well as tooltip for hovered slot by removing hovered slot this.lock(true, merchantoffers.size(), null); - super.render(matrixStack, mouseX, mouseY, partialTime); + super.render(guiGraphics, mouseX, mouseY, partialTime); // reset everything so we can do this ourselves this.lock(false, scrollOff, hoveredSlot); if (!merchantoffers.isEmpty()) { // normally rendered as part of background, but skipped as offers are empty when it's called - final int shopItem = ((MerchantScreenAccessor) this).getShopItem(); + final int shopItem = ((MerchantScreenAccessor) this).tradingpost$getShopItem(); if (shopItem >= 0 && shopItem < merchantoffers.size()) { MerchantOffer merchantoffer = merchantoffers.get(shopItem); if (merchantoffer.isOutOfStock()) { - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, VILLAGER_LOCATION); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - blit(matrixStack, this.leftPos + 83 + 99, this.topPos + 35, this.getBlitOffset(), 311.0F, 0.0F, 28, 21, 512, 256); + guiGraphics.blit(VILLAGER_LOCATION, this.leftPos + 83 + 99, this.topPos + 35, 0, 311.0F, 0.0F, 28, 21, 512, 256); } } @@ -162,61 +155,44 @@ public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialT int posY = height + 16 + 2; RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderTexture(0, VILLAGER_LOCATION); - ((MerchantScreenAccessor) this).callRenderScroller(matrixStack, width, height, merchantoffers); + ((MerchantScreenAccessor) this).tradingpost$callRenderScroller(guiGraphics, width, height, merchantoffers); for (int i = 0, merchantoffersSize = merchantoffers.size(); i < merchantoffersSize; i++) { if (merchantoffers.size() <= 7 || (i >= scrollOff && i < 7 + scrollOff)) { MerchantOffer merchantoffer = merchantoffers.get(i); - ((MerchantScreenAccessor) this).callRenderButtonArrows(matrixStack, merchantoffer, width, posY + 1); + // move this call here to render below red overlay + ((MerchantScreenAccessor) this).tradingpost$callRenderButtonArrows(guiGraphics, merchantoffer, width, posY + 1); if (!this.getMenu().getTraders().checkOffer(merchantoffer)) { - GuiComponent.fill(matrixStack, posX, posY, posX + 88, posY + 20, 822018048); - } - - ItemStack itemstack = merchantoffer.getBaseCostA(); - ItemStack itemstack1 = merchantoffer.getCostA(); - ItemStack itemstack2 = merchantoffer.getCostB(); - ItemStack itemstack3 = merchantoffer.getResult(); - this.itemRenderer.blitOffset = 100.0F; - this.itemRenderer.renderAndDecorateFakeItem(itemstack1, posX + 5, posY + 1); - - if (!itemstack2.isEmpty()) { - - this.itemRenderer.renderAndDecorateFakeItem(itemstack2, posX + 35, posY + 1); + guiGraphics.fill(posX, posY, posX + 88, posY + 20, 822018048); } - this.itemRenderer.renderAndDecorateFakeItem(itemstack3, posX + 68, posY + 1); + ItemStack baseCostA = merchantoffer.getBaseCostA(); + ItemStack costA = merchantoffer.getCostA(); + ItemStack costB = merchantoffer.getCostB(); + ItemStack result = merchantoffer.getResult(); + guiGraphics.pose().pushPose(); + guiGraphics.pose().translate(0.0F, 0.0F, 100.0F); if (!this.getMenu().getTraders().checkOffer(merchantoffer)) { RenderSystem.depthFunc(516); - GuiComponent.fill(matrixStack, posX, posY, posX + 88, posY + 20, 822083583); + guiGraphics.fill(posX, posY, posX + 88, posY + 20, 822083583); RenderSystem.depthFunc(515); } - if (itemstack.getCount() == itemstack1.getCount()) { + this.renderAndDecorateCostA(guiGraphics, posX, posY, baseCostA, costA); - this.itemRenderer.renderGuiItemDecorations(this.font, itemstack1, posX + 5, posY + 1); - } else { - - this.itemRenderer.renderGuiItemDecorations(this.font, itemstack, posX + 5, posY + 1, itemstack.getCount() == 1 ? "1" : null); - this.itemRenderer.renderGuiItemDecorations(this.font, itemstack1, posX + 5 + 14, posY + 1, itemstack1.getCount() == 1 ? "1" : null); - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, VILLAGER_LOCATION); - this.setBlitOffset(this.getBlitOffset() + 300); - blit(matrixStack, posX + 5 + 7, posY + 1 + 12, this.getBlitOffset(), 0.0F, 176.0F, 9, 2, 512, 256); - this.setBlitOffset(this.getBlitOffset() - 300); + if (!costB.isEmpty()) { + guiGraphics.renderFakeItem(costB, posX + 35, posY + 1); + guiGraphics.renderItemDecorations(this.font, costB, posX + 35, posY + 1); } - if (!itemstack2.isEmpty()) { - - this.itemRenderer.renderGuiItemDecorations(this.font, itemstack2, posX + 35, posY + 1); - } - - this.itemRenderer.renderGuiItemDecorations(this.font, itemstack3, posX + 68, posY + 1); - this.itemRenderer.blitOffset = 0.0F; + guiGraphics.renderFakeItem(result, posX + 68, posY + 1); + guiGraphics.renderItemDecorations(this.font, result, posX + 68, posY + 1); + guiGraphics.pose().popPose(); posY += 20; } } @@ -224,12 +200,12 @@ public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialT final MerchantOffer activeOffer = merchantoffers.get(shopItem); if (this.getMenu().showProgressBar()) { - ((MerchantScreenAccessor) this).callRenderProgressBar(matrixStack, width, height, activeOffer); + ((MerchantScreenAccessor) this).tradingpost$callRenderProgressBar(guiGraphics, width, height, activeOffer); } if (activeOffer.isOutOfStock() && this.isHovering(186, 35, 22, 21, mouseX, mouseY) && this.getMenu().canRestock()) { - - this.renderTooltip(matrixStack, DEPRECATED_TOOLTIP, mouseX, mouseY); + + guiGraphics.renderTooltip(this.font, DEPRECATED_TOOLTIP, mouseX, mouseY); } posY = height + 16 + 2; @@ -242,7 +218,7 @@ public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialT if (this.isHovering(posX, posY, 88, 19, mouseX + this.leftPos, mouseY + this.topPos)) { - this.renderTooltip(matrixStack, MERCHANT_GONE, mouseX, mouseY); + guiGraphics.renderTooltip(this.font, MERCHANT_GONE, mouseX, mouseY); } } @@ -259,13 +235,27 @@ public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialT Button button = offerButtons[i]; if (button.active && button.isHoveredOrFocused()) { - button.renderToolTip(matrixStack, mouseX, mouseY); + ((TradeOfferButtonAccessor) button).tradingpost$callRenderToolTip(guiGraphics, mouseX, mouseY); } button.visible = i < this.getMenu().getOffers().size(); } - this.renderTooltip(matrixStack, mouseX, mouseY); + this.renderTooltip(guiGraphics, mouseX, mouseY); + } + + private void renderAndDecorateCostA(GuiGraphics guiGraphics, int posX, int posY, ItemStack baseCostA, ItemStack costA) { + guiGraphics.renderFakeItem(costA, posX + 5, posY + 1); + if (baseCostA.getCount() == costA.getCount()) { + guiGraphics.renderItemDecorations(this.font, costA, posX + 5, posY + 1); + } else { + guiGraphics.renderItemDecorations(this.font, baseCostA, posX + 5, posY + 1, baseCostA.getCount() == 1 ? "1" : null); + guiGraphics.renderItemDecorations(this.font, costA, posX + 5 + 14, posY + 1, costA.getCount() == 1 ? "1" : null); + guiGraphics.pose().pushPose(); + guiGraphics.pose().translate(0.0F, 0.0F, 300.0F); + guiGraphics.blit(VILLAGER_LOCATION, posX + 5 + 7, posY + 1 + 12, 0, 0.0F, 176.0F, 9, 2, 512, 256); + guiGraphics.pose().popPose(); + } } private void setButtonsActive(MerchantOffers merchantoffers) { @@ -274,7 +264,7 @@ private void setButtonsActive(MerchantOffers merchantoffers) { for (int i = 0, merchantoffersSize = merchantoffers.size(); i < merchantoffersSize; i++) { - int scrollOff = ((MerchantScreenAccessor) this).getScrollOff(); + int scrollOff = ((MerchantScreenAccessor) this).tradingpost$getScrollOff(); if (merchantoffers.size() <= 7 || (i >= scrollOff && i < 7 + scrollOff)) { MerchantOffer offer = merchantoffers.get(i); @@ -285,36 +275,33 @@ private void setButtonsActive(MerchantOffers merchantoffers) { } private void lock(boolean lockOffers, int newScrollOff, Slot newHoveredSlot) { - + this.getMenu().lockOffers(lockOffers); - ((MerchantScreenAccessor) this).setScrollOff(newScrollOff); + ((MerchantScreenAccessor) this).tradingpost$setScrollOff(newScrollOff); this.hoveredSlot = newHoveredSlot; } @Override - protected void renderBg(PoseStack matrixStack, float partialTicks, int mouseX, int mouseY) { - super.renderBg(matrixStack, partialTicks, mouseX, mouseY); - this.renderSearchBox(matrixStack, partialTicks, mouseX, mouseY); - TextureAtlasSprite textureatlassprite = this.minecraft.getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(MAGNIFYING_GLASS_LOCATION); - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, textureatlassprite.atlas().location()); - blit(matrixStack, this.leftPos, this.topPos + 4, this.getBlitOffset(), 16, 16, textureatlassprite); + protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) { + super.renderBg(guiGraphics, partialTicks, mouseX, mouseY); + this.renderSearchBox(guiGraphics, partialTicks, mouseX, mouseY); + TextureAtlasSprite atlasSprite = this.minecraft.getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(MAGNIFYING_GLASS_LOCATION); + guiGraphics.blit(this.leftPos, this.topPos + 4, 0, 16, 16, atlasSprite); RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderTexture(0, VILLAGER_LOCATION); } - private void renderSearchBox(PoseStack matrixStack, float partialTicks, int mouseX, int mouseY) { - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, CREATIVE_INVENTORY_LOCATION); + private void renderSearchBox(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) { int i = (this.width - this.imageWidth) / 2; int j = (this.height - this.imageHeight) / 2; - blit(matrixStack, i + 11, j + 4, this.getBlitOffset(), 80.0F, 4.0F, 90, 12, 256, 256); - this.searchBox.render(matrixStack, mouseX, mouseY, partialTicks); + guiGraphics.blit(CREATIVE_INVENTORY_LOCATION, i + 11, j + 4, 0, 80.0F, 4.0F, 90, 12, 256, 256); + this.searchBox.render(guiGraphics, mouseX, mouseY, partialTicks); } @Override public boolean mouseClicked(double mouseX, double mouseY, int mouseKey) { if (this.searchBox.mouseClicked(mouseX, mouseY, mouseKey)) { + this.searchBox.setFocused(true); return true; } return super.mouseClicked(mouseX, mouseY, mouseKey); @@ -328,10 +315,10 @@ protected void containerTick() { @Override public boolean keyPressed(int keyCode, int scanCode, int modifierKeys) { this.ignoreTextInput = false; - final String lastSearch = this.searchBox.getValue(); + final String lastSearch = this.searchBox.getValue().trim(); if (this.searchBox.keyPressed(keyCode, scanCode, modifierKeys)) { - if (!Objects.equals(this.searchBox.getValue(), lastSearch)) { + if (!Objects.equals(this.searchBox.getValue().trim(), lastSearch)) { this.refreshSearchResults(); } @@ -341,7 +328,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifierKeys) { return true; } else if (this.minecraft.options.keyChat.matches(keyCode, scanCode) && !this.searchBox.isFocused()) { this.ignoreTextInput = true; - this.searchBox.setFocus(true); + this.searchBox.setFocused(true); return true; } return super.keyPressed(keyCode, scanCode, modifierKeys); @@ -350,10 +337,10 @@ public boolean keyPressed(int keyCode, int scanCode, int modifierKeys) { @Override public boolean charTyped(char typedChar, int modifierKeys) { - final String lastSearch = this.searchBox.getValue(); + final String lastSearch = this.searchBox.getValue().trim(); if (!this.ignoreTextInput && this.searchBox.charTyped(typedChar, modifierKeys)) { - if (!Objects.equals(this.searchBox.getValue(), lastSearch)) { + if (!Objects.equals(this.searchBox.getValue().trim(), lastSearch)) { this.refreshSearchResults(); } @@ -369,15 +356,15 @@ public void refreshSearchResults() { if (!(this.getMenu().getOffers() instanceof TradingPostOffers offers)) { return; } - String query = this.searchBox.getValue(); + String query = this.searchBox.getValue().trim(); if (query.isEmpty()) { offers.clearFilter(); } else { - SearchTree isearchtree = this.minecraft.getSearchTree(TradingPostClient.OFFER_SEARCH_TREE); + SearchTree isearchtree = this.minecraft.getSearchTree(OFFER_SEARCH_TREE); offers.setFilter(isearchtree.search(query.toLowerCase(Locale.ROOT))); } - ((MerchantScreenAccessor) this).setScrollOff(0); - ((MerchantScreenAccessor) this).setShopItem(0); + ((MerchantScreenAccessor) this).tradingpost$setScrollOff(0); + ((MerchantScreenAccessor) this).tradingpost$setShopItem(0); this.getMenu().setSelectionHint(-1); this.getMenu().getTraders().setActiveOffer(null); this.getMenu().clearPaymentSlots(); @@ -386,7 +373,7 @@ public void refreshSearchResults() { @Override public TradingPostMenu getMenu() { - + return (TradingPostMenu) super.getMenu(); } diff --git a/Common/src/main/java/fuzs/tradingpost/client/renderer/blockentity/TradingPostRenderer.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/client/renderer/blockentity/TradingPostRenderer.java similarity index 61% rename from Common/src/main/java/fuzs/tradingpost/client/renderer/blockentity/TradingPostRenderer.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/client/renderer/blockentity/TradingPostRenderer.java index b1faf5a..5aa684e 100644 --- a/Common/src/main/java/fuzs/tradingpost/client/renderer/blockentity/TradingPostRenderer.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/client/renderer/blockentity/TradingPostRenderer.java @@ -1,57 +1,57 @@ package fuzs.tradingpost.client.renderer.blockentity; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import fuzs.tradingpost.world.level.block.entity.TradingPostBlockEntity; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.util.Mth; +import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; /** - * mostly copied from Quark's matrix enchanting table by Vazkii - * https://github.com/Vazkii/Quark/blob/master/src/main/java/vazkii/quark/addons/oddities/client/render/MatrixEnchantingTableTileEntityRenderer.java + * Mostly copied from Quark's MatrixEnchantingTableRenderer.java by Vazkii, thanks! */ public class TradingPostRenderer implements BlockEntityRenderer { - public TradingPostRenderer(BlockEntityRendererProvider.Context pContext) { + public TradingPostRenderer(BlockEntityRendererProvider.Context context) { } @Override - public void render(TradingPostBlockEntity tileEntityIn, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { - float ageInTicks = tileEntityIn.time + partialTicks; - float nextRotation = tileEntityIn.rot - tileEntityIn.oRot; + public void render(TradingPostBlockEntity blockEntity, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { + float ageInTicks = blockEntity.time + partialTicks; + float nextRotation = blockEntity.rot - blockEntity.oRot; while (nextRotation >= Math.PI) { nextRotation -= (Math.PI * 2F); } while (nextRotation < -Math.PI) { nextRotation += (Math.PI * 2F); } - float bookRotation = tileEntityIn.oRot + nextRotation * partialTicks; - float bookOpen = Mth.lerp(partialTicks, tileEntityIn.oOpen, tileEntityIn.open); - this.renderItem(new ItemStack(Items.EMERALD), ageInTicks, bookOpen, bookRotation, matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn); + float bookRotation = blockEntity.oRot + nextRotation * partialTicks; + float bookOpen = Mth.lerp(partialTicks, blockEntity.oOpen, blockEntity.open); + this.renderItem(new ItemStack(Items.EMERALD), ageInTicks, bookOpen, bookRotation, matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn, blockEntity.getLevel()); } - private void renderItem(ItemStack stack, float ageInTicks, float bookOpen, float bookRotation, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { + private void renderItem(ItemStack stack, float ageInTicks, float bookOpen, float bookRotation, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn, Level level) { matrixStackIn.pushPose(); matrixStackIn.translate(0.5F, 1.03125F, 0.5F); matrixStackIn.scale(0.8F, 0.8F, 0.8F); bookRotation *= -180.0F / (float) Math.PI; bookRotation -= 90.0F; bookRotation *= bookOpen; - matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(bookRotation)); + matrixStackIn.mulPose(Axis.YP.rotationDegrees(bookRotation)); matrixStackIn.translate(0.0F, bookOpen, Math.sin(bookOpen * Math.PI)); - matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(-90.0F * (bookOpen - 1.0F))); + matrixStackIn.mulPose(Axis.XP.rotationDegrees(-90.0F * (bookOpen - 1.0F))); float hoveringHeight = (float) Math.sin(ageInTicks * 0.06F) * bookOpen * 0.2F; matrixStackIn.translate(0.0F, hoveringHeight, 0.0F); ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); - itemRenderer.renderStatic(stack, ItemTransforms.TransformType.FIXED, combinedLightIn, combinedOverlayIn, matrixStackIn, bufferIn, 0); + itemRenderer.renderStatic(stack, ItemDisplayContext.FIXED, combinedLightIn, combinedOverlayIn, matrixStackIn, bufferIn, level, 0); matrixStackIn.popPose(); } diff --git a/Common/src/main/java/fuzs/tradingpost/config/ServerConfig.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/config/ServerConfig.java similarity index 72% rename from Common/src/main/java/fuzs/tradingpost/config/ServerConfig.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/config/ServerConfig.java index 7c75a98..936d6a4 100644 --- a/Common/src/main/java/fuzs/tradingpost/config/ServerConfig.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/config/ServerConfig.java @@ -1,15 +1,14 @@ package fuzs.tradingpost.config; import com.google.common.collect.Lists; -import fuzs.puzzleslib.config.ConfigCore; -import fuzs.puzzleslib.config.annotation.Config; -import fuzs.puzzleslib.config.serialization.EntryCollectionBuilder; +import fuzs.puzzleslib.api.config.v3.Config; +import fuzs.puzzleslib.api.config.v3.ConfigCore; +import fuzs.puzzleslib.api.config.v3.serialization.ConfigDataSet; import fuzs.tradingpost.TradingPost; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.world.entity.EntityType; import java.util.List; -import java.util.Set; public class ServerConfig implements ConfigCore { @Config(description = "Range on xz plane trading post should search for merchants.") @@ -24,13 +23,13 @@ public class ServerConfig implements ConfigCore { public boolean teleportXp = true; @Config(name = "close_empty_screen", description = "Close trading post interface when all traders have become unavailable.") public boolean closeScreen = true; - @Config(name = "trader_blacklist", description = {"Trader entities disabled from being found by the trading post.", "Modders may add their own incompatible trader entities via the \"" + TradingPost.MOD_ID + ":blacklisted_traders\" entity tag.", EntryCollectionBuilder.CONFIG_DESCRIPTION}) + @Config(name = "trader_blacklist", description = {"Trader entities disabled from being found by the trading post.", "Modders may add their own incompatible trader entities via the \"" + TradingPost.MOD_ID + ":blacklisted_traders\" entity tag.", ConfigDataSet.CONFIG_DESCRIPTION}) List traderBlacklistRaw = Lists.newArrayList(); - public Set> traderBlacklist; + public ConfigDataSet> traderBlacklist; @Override public void afterConfigReload() { - this.traderBlacklist = EntryCollectionBuilder.of(Registry.ENTITY_TYPE_REGISTRY).buildSet(this.traderBlacklistRaw); + this.traderBlacklist = ConfigDataSet.from(Registries.ENTITY_TYPE, this.traderBlacklistRaw); } } diff --git a/1.20.1/Common/src/main/java/fuzs/tradingpost/init/ModRegistry.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/init/ModRegistry.java new file mode 100644 index 0000000..b01649b --- /dev/null +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/init/ModRegistry.java @@ -0,0 +1,32 @@ +package fuzs.tradingpost.init; + +import fuzs.puzzleslib.api.init.v2.RegistryManager; +import fuzs.puzzleslib.api.init.v2.RegistryReference; +import fuzs.tradingpost.TradingPost; +import fuzs.tradingpost.world.inventory.TradingPostMenu; +import fuzs.tradingpost.world.level.block.TradingPostBlock; +import fuzs.tradingpost.world.level.block.entity.TradingPostBlockEntity; +import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.world.level.material.MapColor; + +public class ModRegistry { + static final RegistryManager REGISTRY = RegistryManager.instant(TradingPost.MOD_ID); + public static final RegistryReference TRADING_POST_BLOCK = REGISTRY.registerBlock("trading_post", () -> new TradingPostBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).instrument(NoteBlockInstrument.BASS).strength(2.5F).sound(SoundType.WOOD).ignitedByLava())); + public static final RegistryReference TRADING_POST_ITEM = REGISTRY.registerBlockItem(TRADING_POST_BLOCK); + public static final RegistryReference> TRADING_POST_BLOCK_ENTITY_TYPE = REGISTRY.registerBlockEntityType("trading_post", () -> BlockEntityType.Builder.of(TradingPostBlockEntity::new, TRADING_POST_BLOCK.get())); + public static final RegistryReference> TRADING_POST_MENU_TYPE = REGISTRY.registerMenuType("trading_post", () -> TradingPostMenu::new); + + public static final TagKey> BLACKLISTED_TRADERS_TAG = REGISTRY.registerEntityTypeTag("blacklisted_traders"); + + public static void touch() { + + } +} diff --git a/Common/src/main/java/fuzs/tradingpost/mixin/accessor/MerchantMenuAccessor.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/accessor/MerchantMenuAccessor.java similarity index 100% rename from Common/src/main/java/fuzs/tradingpost/mixin/accessor/MerchantMenuAccessor.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/accessor/MerchantMenuAccessor.java diff --git a/Common/src/main/java/fuzs/tradingpost/mixin/accessor/VillagerAccessor.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/accessor/VillagerAccessor.java similarity index 100% rename from Common/src/main/java/fuzs/tradingpost/mixin/accessor/VillagerAccessor.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/accessor/VillagerAccessor.java diff --git a/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/ButtonAccessor.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/ButtonAccessor.java similarity index 78% rename from Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/ButtonAccessor.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/ButtonAccessor.java index 4c6911b..5f844e7 100644 --- a/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/ButtonAccessor.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/ButtonAccessor.java @@ -9,6 +9,6 @@ public interface ButtonAccessor { @Mutable - @Accessor - void setOnPress(Button.OnPress onPress); + @Accessor("onPress") + void tradingpost$setOnPress(Button.OnPress onPress); } diff --git a/1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/MerchantScreenAccessor.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/MerchantScreenAccessor.java new file mode 100644 index 0000000..a67dadd --- /dev/null +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/MerchantScreenAccessor.java @@ -0,0 +1,34 @@ +package fuzs.tradingpost.mixin.client.accessor; + +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.MerchantScreen; +import net.minecraft.world.item.trading.MerchantOffer; +import net.minecraft.world.item.trading.MerchantOffers; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(MerchantScreen.class) +public interface MerchantScreenAccessor { + + @Accessor("shopItem") + int tradingpost$getShopItem(); + + @Accessor("shopItem") + void tradingpost$setShopItem(int shopItem); + + @Accessor("scrollOff") + int tradingpost$getScrollOff(); + + @Accessor("scrollOff") + void tradingpost$setScrollOff(int scrollOff); + + @Invoker("renderScroller") + void tradingpost$callRenderScroller(GuiGraphics guiGraphics, int width, int height, MerchantOffers offers); + + @Invoker("renderButtonArrows") + void tradingpost$callRenderButtonArrows(GuiGraphics guiGraphics, MerchantOffer offer, int width, int height); + + @Invoker("renderProgressBar") + void tradingpost$callRenderProgressBar(GuiGraphics guiGraphics, int width, int height, MerchantOffer activeOffer); +} diff --git a/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/TradeOfferButtonAccessor.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/TradeOfferButtonAccessor.java similarity index 51% rename from Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/TradeOfferButtonAccessor.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/TradeOfferButtonAccessor.java index d481a31..99e17d4 100644 --- a/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/TradeOfferButtonAccessor.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/TradeOfferButtonAccessor.java @@ -1,11 +1,16 @@ package fuzs.tradingpost.mixin.client.accessor; +import net.minecraft.client.gui.GuiGraphics; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(targets = "net.minecraft.client.gui.screens.inventory.MerchantScreen$TradeOfferButton") public interface TradeOfferButtonAccessor { - @Accessor - int getIndex(); + @Accessor("index") + int tradingpost$getIndex(); + + @Invoker("renderToolTip") + void tradingpost$callRenderToolTip(GuiGraphics guiGraphics, int mouseX, int mouseY); } diff --git a/1.20.1/Common/src/main/java/fuzs/tradingpost/network/S2CBuildOffersMessage.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/network/S2CBuildOffersMessage.java new file mode 100644 index 0000000..a892cec --- /dev/null +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/network/S2CBuildOffersMessage.java @@ -0,0 +1,61 @@ +package fuzs.tradingpost.network; + +import fuzs.puzzleslib.api.network.v2.MessageV2; +import fuzs.tradingpost.client.gui.screens.inventory.TradingPostScreen; +import fuzs.tradingpost.world.inventory.TradingPostMenu; +import it.unimi.dsi.fastutil.ints.Int2IntMap; +import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; +import net.minecraft.client.Minecraft; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Player; + +public class S2CBuildOffersMessage implements MessageV2 { + private int containerId; + private Int2IntOpenHashMap idToOfferCount; + + public S2CBuildOffersMessage() { + + } + + public S2CBuildOffersMessage(int containerId, Int2IntOpenHashMap idToOfferCount) { + this.containerId = containerId; + this.idToOfferCount = idToOfferCount; + } + + @Override + public void write(FriendlyByteBuf buf) { + buf.writeVarInt(this.containerId); + buf.writeVarInt(this.idToOfferCount.size()); + for (Int2IntMap.Entry entry : this.idToOfferCount.int2IntEntrySet()) { + buf.writeInt(entry.getIntKey()); + buf.writeVarInt(entry.getIntValue()); + } + } + + @Override + public void read(FriendlyByteBuf buf) { + this.containerId = buf.readVarInt(); + final Int2IntOpenHashMap idToOfferCount = new Int2IntOpenHashMap(); + final int length = buf.readVarInt(); + for (int i = 0; i < length; i++) { + idToOfferCount.put(buf.readInt(), buf.readVarInt()); + } + this.idToOfferCount = idToOfferCount; + } + + @Override + public MessageHandler makeHandler() { + return new MessageHandler<>() { + + @Override + public void handle(S2CBuildOffersMessage message, Player player, Object gameInstance) { + Minecraft minecraft = (Minecraft) gameInstance; + if (message.containerId == player.containerMenu.containerId && player.containerMenu instanceof TradingPostMenu playerMenu && minecraft.screen instanceof TradingPostScreen screen) { + playerMenu.getTraders().buildOffers(message.idToOfferCount); + minecraft.populateSearchTree(TradingPostScreen.OFFER_SEARCH_TREE, playerMenu.getOffers()); + screen.refreshSearchResults(); + } + } + }; + } +} diff --git a/Common/src/main/java/fuzs/tradingpost/network/S2CMerchantDataMessage.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/network/S2CMerchantDataMessage.java similarity index 95% rename from Common/src/main/java/fuzs/tradingpost/network/S2CMerchantDataMessage.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/network/S2CMerchantDataMessage.java index 9ef20ad..91c9727 100644 --- a/Common/src/main/java/fuzs/tradingpost/network/S2CMerchantDataMessage.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/network/S2CMerchantDataMessage.java @@ -1,6 +1,6 @@ package fuzs.tradingpost.network; -import fuzs.puzzleslib.network.Message; +import fuzs.puzzleslib.api.network.v2.MessageV2; import fuzs.tradingpost.world.inventory.TradingPostMenu; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; @@ -8,7 +8,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.trading.MerchantOffers; -public class S2CMerchantDataMessage implements Message { +public class S2CMerchantDataMessage implements MessageV2 { private int containerId; private int merchantId; private Component merchantTitle; diff --git a/Common/src/main/java/fuzs/tradingpost/network/S2CRemoveMerchantsMessage.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/network/S2CRemoveMerchantsMessage.java similarity index 93% rename from Common/src/main/java/fuzs/tradingpost/network/S2CRemoveMerchantsMessage.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/network/S2CRemoveMerchantsMessage.java index 84e4f8c..8aa0653 100644 --- a/Common/src/main/java/fuzs/tradingpost/network/S2CRemoveMerchantsMessage.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/network/S2CRemoveMerchantsMessage.java @@ -1,6 +1,6 @@ package fuzs.tradingpost.network; -import fuzs.puzzleslib.network.Message; +import fuzs.puzzleslib.api.network.v2.MessageV2; import fuzs.tradingpost.world.inventory.TradingPostMenu; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; @@ -8,7 +8,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; -public class S2CRemoveMerchantsMessage implements Message { +public class S2CRemoveMerchantsMessage implements MessageV2 { private int containerId; private IntSet merchantIds; diff --git a/Common/src/main/java/fuzs/tradingpost/network/client/C2SClearSlotsMessage.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/network/client/C2SClearSlotsMessage.java similarity index 87% rename from Common/src/main/java/fuzs/tradingpost/network/client/C2SClearSlotsMessage.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/network/client/C2SClearSlotsMessage.java index 0b895e2..ba5d25a 100644 --- a/Common/src/main/java/fuzs/tradingpost/network/client/C2SClearSlotsMessage.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/network/client/C2SClearSlotsMessage.java @@ -1,12 +1,12 @@ package fuzs.tradingpost.network.client; -import fuzs.puzzleslib.network.Message; +import fuzs.puzzleslib.api.network.v2.MessageV2; import fuzs.tradingpost.world.inventory.TradingPostMenu; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; -public class C2SClearSlotsMessage implements Message { +public class C2SClearSlotsMessage implements MessageV2 { @Override public void write(FriendlyByteBuf buf) { diff --git a/Common/src/main/java/fuzs/tradingpost/world/entity/npc/LocalMerchant.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/entity/npc/LocalMerchant.java similarity index 100% rename from Common/src/main/java/fuzs/tradingpost/world/entity/npc/LocalMerchant.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/world/entity/npc/LocalMerchant.java diff --git a/Common/src/main/java/fuzs/tradingpost/world/entity/npc/MerchantCollection.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/entity/npc/MerchantCollection.java similarity index 99% rename from Common/src/main/java/fuzs/tradingpost/world/entity/npc/MerchantCollection.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/world/entity/npc/MerchantCollection.java index 19ba577..b0488aa 100644 --- a/Common/src/main/java/fuzs/tradingpost/world/entity/npc/MerchantCollection.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/entity/npc/MerchantCollection.java @@ -27,8 +27,8 @@ import net.minecraft.world.item.trading.MerchantOffers; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.Nullable; -import javax.annotation.Nullable; import java.util.Comparator; import java.util.List; import java.util.Map; diff --git a/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostContainer.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostContainer.java similarity index 100% rename from Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostContainer.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostContainer.java diff --git a/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostMenu.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostMenu.java similarity index 97% rename from Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostMenu.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostMenu.java index 1d5c0b5..bb7a64b 100644 --- a/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostMenu.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostMenu.java @@ -112,7 +112,7 @@ private void playTradeSound() { if (!this.traders.isClientSide()) { Merchant merchant = this.traders.getCurrentMerchant(); if (merchant instanceof Entity entity) { - entity.getLevel().playLocalSound(entity.getX(), entity.getY(), entity.getZ(), this.traders.getNotifyTradeSound(), SoundSource.NEUTRAL, 1.0F, 1.0F, false); + entity.level().playLocalSound(entity.getX(), entity.getY(), entity.getZ(), this.traders.getNotifyTradeSound(), SoundSource.NEUTRAL, 1.0F, 1.0F, false); } } } diff --git a/Common/src/main/java/fuzs/tradingpost/world/item/trading/TradingPostOffers.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/item/trading/TradingPostOffers.java similarity index 97% rename from Common/src/main/java/fuzs/tradingpost/world/item/trading/TradingPostOffers.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/world/item/trading/TradingPostOffers.java index c46e9b5..8bde01b 100644 --- a/Common/src/main/java/fuzs/tradingpost/world/item/trading/TradingPostOffers.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/item/trading/TradingPostOffers.java @@ -3,8 +3,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.trading.MerchantOffer; import net.minecraft.world.item.trading.MerchantOffers; +import org.jetbrains.annotations.Nullable; -import javax.annotation.Nullable; import java.util.Collection; import java.util.Set; diff --git a/Common/src/main/java/fuzs/tradingpost/world/level/block/TradingPostBlock.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/level/block/TradingPostBlock.java similarity index 99% rename from Common/src/main/java/fuzs/tradingpost/world/level/block/TradingPostBlock.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/world/level/block/TradingPostBlock.java index 2407e92..9fd17c4 100644 --- a/Common/src/main/java/fuzs/tradingpost/world/level/block/TradingPostBlock.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/level/block/TradingPostBlock.java @@ -45,8 +45,8 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.Nullable; -import javax.annotation.Nullable; import java.util.List; @SuppressWarnings("deprecation") diff --git a/Common/src/main/java/fuzs/tradingpost/world/level/block/entity/TradingPostBlockEntity.java b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/level/block/entity/TradingPostBlockEntity.java similarity index 98% rename from Common/src/main/java/fuzs/tradingpost/world/level/block/entity/TradingPostBlockEntity.java rename to 1.20.1/Common/src/main/java/fuzs/tradingpost/world/level/block/entity/TradingPostBlockEntity.java index 039690b..33bd5d4 100644 --- a/Common/src/main/java/fuzs/tradingpost/world/level/block/entity/TradingPostBlockEntity.java +++ b/1.20.1/Common/src/main/java/fuzs/tradingpost/world/level/block/entity/TradingPostBlockEntity.java @@ -11,8 +11,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; - -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; public class TradingPostBlockEntity extends BlockEntity implements Nameable { private Component name; diff --git a/Common/src/main/resources/assets/tradingpost/blockstates/trading_post.json b/1.20.1/Common/src/main/resources/assets/tradingpost/blockstates/trading_post.json similarity index 100% rename from Common/src/main/resources/assets/tradingpost/blockstates/trading_post.json rename to 1.20.1/Common/src/main/resources/assets/tradingpost/blockstates/trading_post.json diff --git a/Common/src/main/resources/assets/tradingpost/lang/en_us.json b/1.20.1/Common/src/main/resources/assets/tradingpost/lang/en_us.json similarity index 100% rename from Common/src/main/resources/assets/tradingpost/lang/en_us.json rename to 1.20.1/Common/src/main/resources/assets/tradingpost/lang/en_us.json diff --git a/1.20.1/Common/src/main/resources/assets/tradingpost/lang/it_it.json b/1.20.1/Common/src/main/resources/assets/tradingpost/lang/it_it.json new file mode 100644 index 0000000..84afc50 --- /dev/null +++ b/1.20.1/Common/src/main/resources/assets/tradingpost/lang/it_it.json @@ -0,0 +1,7 @@ +{ + "block.tradingpost.trading_post": "Postazione commerciale", + "container.trading_post": "Postazione commerciale", + "trading_post.no_trader_found": "Nessun commerciante disponibile trovato nelle vicinanze", + "trading_post.trader_gone": "Il commerciante non è più disponibile.", + "trading_post.search": "Ricerca..." +} diff --git a/1.20.1/Common/src/main/resources/assets/tradingpost/lang/pt_br.json b/1.20.1/Common/src/main/resources/assets/tradingpost/lang/pt_br.json new file mode 100644 index 0000000..e84791f --- /dev/null +++ b/1.20.1/Common/src/main/resources/assets/tradingpost/lang/pt_br.json @@ -0,0 +1,7 @@ +{ + "block.tradingpost.trading_post": "Posto de Comércio", + "container.trading_post": "Posto de Comércio", + "trading_post.no_trader_found": "Não foi possível encontrar nenhum comerciante disponível nas proximidades", + "trading_post.trader_gone": "O comerciante não está mais disponível.", + "trading_post.search": "Procurar..." + } \ No newline at end of file diff --git a/Common/src/main/resources/assets/tradingpost/lang/ru_ru.json b/1.20.1/Common/src/main/resources/assets/tradingpost/lang/ru_ru.json similarity index 100% rename from Common/src/main/resources/assets/tradingpost/lang/ru_ru.json rename to 1.20.1/Common/src/main/resources/assets/tradingpost/lang/ru_ru.json diff --git a/Common/src/main/resources/assets/tradingpost/lang/zh_tw.json b/1.20.1/Common/src/main/resources/assets/tradingpost/lang/zh_tw.json similarity index 100% rename from Common/src/main/resources/assets/tradingpost/lang/zh_tw.json rename to 1.20.1/Common/src/main/resources/assets/tradingpost/lang/zh_tw.json diff --git a/Common/src/main/resources/assets/tradingpost/models/block/trading_post.json b/1.20.1/Common/src/main/resources/assets/tradingpost/models/block/trading_post.json similarity index 100% rename from Common/src/main/resources/assets/tradingpost/models/block/trading_post.json rename to 1.20.1/Common/src/main/resources/assets/tradingpost/models/block/trading_post.json diff --git a/Common/src/main/resources/assets/tradingpost/models/item/trading_post.json b/1.20.1/Common/src/main/resources/assets/tradingpost/models/item/trading_post.json similarity index 100% rename from Common/src/main/resources/assets/tradingpost/models/item/trading_post.json rename to 1.20.1/Common/src/main/resources/assets/tradingpost/models/item/trading_post.json diff --git a/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_bottom.png b/1.20.1/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_bottom.png similarity index 100% rename from Common/src/main/resources/assets/tradingpost/textures/block/trading_post_bottom.png rename to 1.20.1/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_bottom.png diff --git a/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_front.png b/1.20.1/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_front.png similarity index 100% rename from Common/src/main/resources/assets/tradingpost/textures/block/trading_post_front.png rename to 1.20.1/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_front.png diff --git a/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_side.png b/1.20.1/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_side.png similarity index 100% rename from Common/src/main/resources/assets/tradingpost/textures/block/trading_post_side.png rename to 1.20.1/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_side.png diff --git a/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_top.png b/1.20.1/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_top.png similarity index 100% rename from Common/src/main/resources/assets/tradingpost/textures/block/trading_post_top.png rename to 1.20.1/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_top.png diff --git a/Common/src/main/resources/assets/tradingpost/textures/item/magnifying_glass.png b/1.20.1/Common/src/main/resources/assets/tradingpost/textures/item/magnifying_glass.png similarity index 100% rename from Common/src/main/resources/assets/tradingpost/textures/item/magnifying_glass.png rename to 1.20.1/Common/src/main/resources/assets/tradingpost/textures/item/magnifying_glass.png diff --git a/Common/src/main/resources/data/minecraft/tags/blocks/mineable/axe.json b/1.20.1/Common/src/main/resources/data/minecraft/tags/blocks/mineable/axe.json similarity index 100% rename from Common/src/main/resources/data/minecraft/tags/blocks/mineable/axe.json rename to 1.20.1/Common/src/main/resources/data/minecraft/tags/blocks/mineable/axe.json diff --git a/Common/src/main/resources/data/tradingpost/loot_tables/blocks/trading_post.json b/1.20.1/Common/src/main/resources/data/tradingpost/loot_tables/blocks/trading_post.json similarity index 100% rename from Common/src/main/resources/data/tradingpost/loot_tables/blocks/trading_post.json rename to 1.20.1/Common/src/main/resources/data/tradingpost/loot_tables/blocks/trading_post.json diff --git a/Common/src/main/resources/data/tradingpost/recipes/trading_post.json b/1.20.1/Common/src/main/resources/data/tradingpost/recipes/trading_post.json similarity index 100% rename from Common/src/main/resources/data/tradingpost/recipes/trading_post.json rename to 1.20.1/Common/src/main/resources/data/tradingpost/recipes/trading_post.json diff --git a/Common/src/main/resources/data/tradingpost/tags/entity_types/blacklisted_traders.json b/1.20.1/Common/src/main/resources/data/tradingpost/tags/entity_types/blacklisted_traders.json similarity index 100% rename from Common/src/main/resources/data/tradingpost/tags/entity_types/blacklisted_traders.json rename to 1.20.1/Common/src/main/resources/data/tradingpost/tags/entity_types/blacklisted_traders.json diff --git a/Common/src/main/resources/mod_banner.png b/1.20.1/Common/src/main/resources/mod_banner.png similarity index 100% rename from Common/src/main/resources/mod_banner.png rename to 1.20.1/Common/src/main/resources/mod_banner.png diff --git a/Common/src/main/resources/mod_logo.png b/1.20.1/Common/src/main/resources/mod_logo.png similarity index 100% rename from Common/src/main/resources/mod_logo.png rename to 1.20.1/Common/src/main/resources/mod_logo.png diff --git a/1.20.1/Common/src/main/resources/pack.mcmeta b/1.20.1/Common/src/main/resources/pack.mcmeta new file mode 100755 index 0000000..19bfab2 --- /dev/null +++ b/1.20.1/Common/src/main/resources/pack.mcmeta @@ -0,0 +1,8 @@ +{ + "pack": { + "description": "${modDescription}", + "pack_format": ${resourcePackFormat}, + "forge:resource_pack_format": ${resourcePackFormat}, + "forge:data_pack_format": ${dataPackFormat} + } +} diff --git a/Common/src/main/resources/tradingpost.common.mixins.json b/1.20.1/Common/src/main/resources/tradingpost.common.mixins.json similarity index 88% rename from Common/src/main/resources/tradingpost.common.mixins.json rename to 1.20.1/Common/src/main/resources/tradingpost.common.mixins.json index 097e18e..7833fd6 100644 --- a/Common/src/main/resources/tradingpost.common.mixins.json +++ b/1.20.1/Common/src/main/resources/tradingpost.common.mixins.json @@ -4,6 +4,7 @@ "compatibilityLevel": "JAVA_17", "package": "fuzs.tradingpost.mixin", "refmap": "tradingpost.refmap.json", + "plugin": "fuzs.tradingpost.mixin.ModMixinConfigPlugin", "mixins": [ "accessor.MerchantMenuAccessor", "accessor.VillagerAccessor" diff --git a/1.20.1/Fabric/build.gradle b/1.20.1/Fabric/build.gradle new file mode 100644 index 0000000..cd8b641 --- /dev/null +++ b/1.20.1/Fabric/build.gradle @@ -0,0 +1,29 @@ +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/fabric.gradle' + +def versionCatalog = extensions.getByType(VersionCatalogsExtension).named("libs") + +dependencies { + // Fabric Api + modApi libs.fabricapi.fabric + + // Puzzles Lib + modApi libs.puzzleslib.fabric + + // Cardinal Components +// modApi(include(libs.cardinalcomponentsbase.fabric.get())) +// modApi(include(libs.cardinalcomponentsentity.fabric.get())) +// modApi(include(libs.cardinalcomponentsblock.fabric.get())) +// modApi(include(libs.cardinalcomponentschunk.fabric.get())) +// modApi(include(libs.cardinalcomponentsworld.fabric.get())) + + // Extensible Enums +// modApi(include(libs.extensibleenums.fabric.get())) + + // Quality of Life Mods + versionCatalog.findLibrary("modmenu.fabric").ifPresent { + modLocalRuntime(it) + } + versionCatalog.findLibrary("forgeconfigscreens.fabric").ifPresent { + modLocalRuntime(it) + } +} diff --git a/Fabric/src/main/java/fuzs/tradingpost/TradingPostFabric.java b/1.20.1/Fabric/src/main/java/fuzs/tradingpost/TradingPostFabric.java similarity index 57% rename from Fabric/src/main/java/fuzs/tradingpost/TradingPostFabric.java rename to 1.20.1/Fabric/src/main/java/fuzs/tradingpost/TradingPostFabric.java index 720fea7..5fc6ff1 100644 --- a/Fabric/src/main/java/fuzs/tradingpost/TradingPostFabric.java +++ b/1.20.1/Fabric/src/main/java/fuzs/tradingpost/TradingPostFabric.java @@ -1,12 +1,12 @@ package fuzs.tradingpost; -import fuzs.puzzleslib.core.CoreServices; +import fuzs.puzzleslib.api.core.v1.ModConstructor; import net.fabricmc.api.ModInitializer; public class TradingPostFabric implements ModInitializer { @Override public void onInitialize() { - CoreServices.FACTORIES.modConstructor(TradingPost.MOD_ID).accept(new TradingPost()); + ModConstructor.construct(TradingPost.MOD_ID, TradingPost::new); } } diff --git a/Fabric/src/main/java/fuzs/tradingpost/client/TradingPostFabricClient.java b/1.20.1/Fabric/src/main/java/fuzs/tradingpost/client/TradingPostFabricClient.java similarity index 60% rename from Fabric/src/main/java/fuzs/tradingpost/client/TradingPostFabricClient.java rename to 1.20.1/Fabric/src/main/java/fuzs/tradingpost/client/TradingPostFabricClient.java index ce8cb77..c5198a1 100644 --- a/Fabric/src/main/java/fuzs/tradingpost/client/TradingPostFabricClient.java +++ b/1.20.1/Fabric/src/main/java/fuzs/tradingpost/client/TradingPostFabricClient.java @@ -1,6 +1,6 @@ package fuzs.tradingpost.client; -import fuzs.puzzleslib.client.core.ClientCoreServices; +import fuzs.puzzleslib.api.client.core.v1.ClientModConstructor; import fuzs.tradingpost.TradingPost; import net.fabricmc.api.ClientModInitializer; @@ -8,6 +8,6 @@ public class TradingPostFabricClient implements ClientModInitializer { @Override public void onInitializeClient() { - ClientCoreServices.FACTORIES.clientModConstructor(TradingPost.MOD_ID).accept(new TradingPostClient()); + ClientModConstructor.construct(TradingPost.MOD_ID, TradingPostClient::new); } } diff --git a/1.20.1/Fabric/src/main/java/fuzs/tradingpost/mixin/ModMixinConfigPlugin.java b/1.20.1/Fabric/src/main/java/fuzs/tradingpost/mixin/ModMixinConfigPlugin.java new file mode 100644 index 0000000..343a1d3 --- /dev/null +++ b/1.20.1/Fabric/src/main/java/fuzs/tradingpost/mixin/ModMixinConfigPlugin.java @@ -0,0 +1,47 @@ +package fuzs.tradingpost.mixin; + +import net.fabricmc.loader.api.FabricLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class ModMixinConfigPlugin implements IMixinConfigPlugin { + + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return FabricLoader.getInstance().isModLoaded("puzzleslib"); + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} diff --git a/Fabric/src/main/resources/fabric.mod.json b/1.20.1/Fabric/src/main/resources/fabric.mod.json similarity index 88% rename from Fabric/src/main/resources/fabric.mod.json rename to 1.20.1/Fabric/src/main/resources/fabric.mod.json index e370de7..c0c6cfa 100644 --- a/Fabric/src/main/resources/fabric.mod.json +++ b/1.20.1/Fabric/src/main/resources/fabric.mod.json @@ -5,19 +5,22 @@ "name": "${modName}", "description": "${modDescription}", + "authors": [ "${modAuthor}" ], + "contact": { "homepage": "${modPageUrl}", "issues": "${modIssueUrl}", "sources": "${modPageUrl}" }, - "license": "MPL-2", + "license": "${modLicense}", "icon": "mod_logo.png", "environment": "${modFabricEnvironment}", + "entrypoints": { "main": [ "${mainEntryPoint}" @@ -26,6 +29,7 @@ "${clientEntryPoint}" ] }, + "mixins": [ "${modId}.common.mixins.json" ], @@ -34,7 +38,7 @@ "fabricloader": ">=${minFabricVersion}", "fabric-api": ">=${minFabricApiVersion}", "puzzleslib": ">=${minPuzzlesVersion}", - "minecraft": ">=${minMinecraftVersion} <${nextMinecraftVersion}", + "minecraft": "${minecraftVersion}", "java": ">=17" } } diff --git a/1.20.1/Forge/build.gradle b/1.20.1/Forge/build.gradle new file mode 100644 index 0000000..dec494a --- /dev/null +++ b/1.20.1/Forge/build.gradle @@ -0,0 +1,28 @@ +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/forge.gradle' + +def versionCatalog = extensions.getByType(VersionCatalogsExtension).named("libs") + +dependencies { + // Puzzles Lib + api fg.deobf(libs.puzzleslib.forge.get()) + + // Quality of Life Mods + versionCatalog.findLibrary("bettermodsbutton.forge").ifPresent { + runtimeOnly fg.deobf(it.get()) + } + versionCatalog.findLibrary("forgeconfigscreens.forge").ifPresent { + runtimeOnly fg.deobf(it.get()) + } +} + +task signJar(type: net.minecraftforge.gradle.common.tasks.SignJar, dependsOn: tasks.reobfJarJar) { + onlyIf { project.hasProperty('keyStore') } + keyStore = project.findProperty('keyStore') + alias = project.findProperty('keyStoreAlias') + storePass = project.findProperty('keyStorePass') + keyPass = project.findProperty('keyStoreKeyPass') + inputFile = outputFile = tasks.jarJar.archivePath +} + +jar.finalizedBy 'signJar' +signJar.mustRunAfter 'reobfJar' diff --git a/1.20.1/Forge/src/generated/resources/.cache/178bb4356f8bea3c4b8966704e26df58ba8fa865 b/1.20.1/Forge/src/generated/resources/.cache/178bb4356f8bea3c4b8966704e26df58ba8fa865 new file mode 100644 index 0000000..26e7e09 --- /dev/null +++ b/1.20.1/Forge/src/generated/resources/.cache/178bb4356f8bea3c4b8966704e26df58ba8fa865 @@ -0,0 +1,2 @@ +// 1.20.1 2023-06-28T11:09:24.480978 Sprite Sources +84b1132cc503d980b133257e14eb97b4fc706c93 assets/minecraft/atlases/blocks.json diff --git a/1.20.1/Forge/src/generated/resources/assets/minecraft/atlases/blocks.json b/1.20.1/Forge/src/generated/resources/assets/minecraft/atlases/blocks.json new file mode 100644 index 0000000..0cfb27c --- /dev/null +++ b/1.20.1/Forge/src/generated/resources/assets/minecraft/atlases/blocks.json @@ -0,0 +1,8 @@ +{ + "sources": [ + { + "type": "minecraft:single", + "resource": "tradingpost:item/magnifying_glass" + } + ] +} \ No newline at end of file diff --git a/1.20.1/Forge/src/main/java/fuzs/tradingpost/TradingPostForge.java b/1.20.1/Forge/src/main/java/fuzs/tradingpost/TradingPostForge.java new file mode 100644 index 0000000..46a80b4 --- /dev/null +++ b/1.20.1/Forge/src/main/java/fuzs/tradingpost/TradingPostForge.java @@ -0,0 +1,33 @@ +package fuzs.tradingpost; + +import fuzs.puzzleslib.api.core.v1.ModConstructor; +import fuzs.tradingpost.data.ModSpriteSourceProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; +import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.data.event.GatherDataEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; + +import java.util.concurrent.CompletableFuture; + +@Mod(TradingPost.MOD_ID) +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) +public class TradingPostForge { + + @SubscribeEvent + public static void onConstructMod(final FMLConstructModEvent evt) { + ModConstructor.construct(TradingPost.MOD_ID, TradingPost::new); + } + + @SubscribeEvent + public static void onGatherData(final GatherDataEvent evt) { + final DataGenerator dataGenerator = evt.getGenerator(); + final PackOutput packOutput = dataGenerator.getPackOutput(); + final CompletableFuture lookupProvider = evt.getLookupProvider(); + final ExistingFileHelper fileHelper = evt.getExistingFileHelper(); + dataGenerator.addProvider(true, new ModSpriteSourceProvider(packOutput, fileHelper)); + } +} diff --git a/Forge/src/main/java/fuzs/tradingpost/client/TradingPostForgeClient.java b/1.20.1/Forge/src/main/java/fuzs/tradingpost/client/TradingPostForgeClient.java similarity index 76% rename from Forge/src/main/java/fuzs/tradingpost/client/TradingPostForgeClient.java rename to 1.20.1/Forge/src/main/java/fuzs/tradingpost/client/TradingPostForgeClient.java index 2d64f5d..41d3cbf 100644 --- a/Forge/src/main/java/fuzs/tradingpost/client/TradingPostForgeClient.java +++ b/1.20.1/Forge/src/main/java/fuzs/tradingpost/client/TradingPostForgeClient.java @@ -1,6 +1,6 @@ package fuzs.tradingpost.client; -import fuzs.puzzleslib.client.core.ClientCoreServices; +import fuzs.puzzleslib.api.client.core.v1.ClientModConstructor; import fuzs.tradingpost.TradingPost; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -12,6 +12,6 @@ public class TradingPostForgeClient { @SubscribeEvent public static void onConstructMod(final FMLConstructModEvent evt) { - ClientCoreServices.FACTORIES.clientModConstructor(TradingPost.MOD_ID).accept(new TradingPostClient()); + ClientModConstructor.construct(TradingPost.MOD_ID, TradingPostClient::new); } } diff --git a/1.20.1/Forge/src/main/java/fuzs/tradingpost/data/ModSpriteSourceProvider.java b/1.20.1/Forge/src/main/java/fuzs/tradingpost/data/ModSpriteSourceProvider.java new file mode 100644 index 0000000..7ddde99 --- /dev/null +++ b/1.20.1/Forge/src/main/java/fuzs/tradingpost/data/ModSpriteSourceProvider.java @@ -0,0 +1,22 @@ +package fuzs.tradingpost.data; + +import fuzs.puzzleslib.api.data.v1.AbstractSpriteSourceProvider; +import fuzs.tradingpost.client.gui.screens.inventory.TradingPostScreen; +import net.minecraft.client.renderer.texture.atlas.sources.SingleFile; +import net.minecraft.data.PackOutput; +import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.common.data.SpriteSourceProvider; + +import java.util.Optional; + +public class ModSpriteSourceProvider extends AbstractSpriteSourceProvider { + + public ModSpriteSourceProvider(PackOutput packOutput, ExistingFileHelper fileHelper) { + super(packOutput, fileHelper); + } + + @Override + protected void addSources() { + this.atlas(SpriteSourceProvider.BLOCKS_ATLAS).addSource(new SingleFile(TradingPostScreen.MAGNIFYING_GLASS_LOCATION, Optional.empty())); + } +} diff --git a/1.20.1/Forge/src/main/java/fuzs/tradingpost/mixin/ModMixinConfigPlugin.java b/1.20.1/Forge/src/main/java/fuzs/tradingpost/mixin/ModMixinConfigPlugin.java new file mode 100644 index 0000000..7528a9e --- /dev/null +++ b/1.20.1/Forge/src/main/java/fuzs/tradingpost/mixin/ModMixinConfigPlugin.java @@ -0,0 +1,47 @@ +package fuzs.tradingpost.mixin; + +import net.minecraftforge.fml.loading.FMLLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class ModMixinConfigPlugin implements IMixinConfigPlugin { + + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return FMLLoader.getLoadingModList().getModFileById("puzzleslib") != null; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} diff --git a/Forge/src/main/resources/META-INF/mods.toml b/1.20.1/Forge/src/main/resources/META-INF/mods.toml similarity index 84% rename from Forge/src/main/resources/META-INF/mods.toml rename to 1.20.1/Forge/src/main/resources/META-INF/mods.toml index 5e945cb..6f39b5f 100644 --- a/Forge/src/main/resources/META-INF/mods.toml +++ b/1.20.1/Forge/src/main/resources/META-INF/mods.toml @@ -1,6 +1,6 @@ modLoader="javafml" loaderVersion="[${minFMLVersion},)" -license="MPL-2" +license = "${modLicense}" issueTrackerURL="${modIssueUrl}" [[mods]] @@ -25,7 +25,7 @@ issueTrackerURL="${modIssueUrl}" [[dependencies.${modId}]] modId="minecraft" mandatory=true - versionRange="[${minMinecraftVersion},${nextMinecraftVersion})" + versionRange="[${minecraftVersion}]" ordering="NONE" side="BOTH" @@ -38,4 +38,3 @@ issueTrackerURL="${modIssueUrl}" [modproperties.${modId}] catalogueImageIcon="mod_logo.png" - configuredBackground="minecraft:textures/block/coarse_dirt.png" diff --git a/1.20.1/build.gradle b/1.20.1/build.gradle new file mode 100644 index 0000000..fadade3 --- /dev/null +++ b/1.20.1/build.gradle @@ -0,0 +1,12 @@ +plugins { + alias libs.plugins.loom apply false + alias libs.plugins.quiltflower apply false + alias libs.plugins.forgegradle apply false + alias libs.plugins.mixin apply false + alias libs.plugins.librarian apply false + alias libs.plugins.cursegradle apply false + alias libs.plugins.minotaur apply false +} + +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/main.gradle' +apply from: 'https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/tasks.gradle' diff --git a/gradle.properties b/1.20.1/gradle.properties similarity index 67% rename from gradle.properties rename to 1.20.1/gradle.properties index 37db4d1..105cdc7 100755 --- a/gradle.properties +++ b/1.20.1/gradle.properties @@ -3,32 +3,15 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false org.gradle.parallel=true - -# Common Project -minecraftVersion=1.19.2 -minMinecraftVersion=1.19.1 -parchmentMappingsVersion=2022.08.14 -puzzlesVersion=4.2.1 -minPuzzlesVersion=4.2.1 -packFormat=9 copyBuildJar=true -# Forge Project -forgeVersion=1.19.2-43.1.1 -minForgeVersion=42.0.0 - -# Fabric Project -fabricVersion=0.14.9 -minFabricVersion=0.14 -fabricApiVersion=0.60.0+1.19.2 -minFabricApiVersion=0.60.0 - # Mod Attributes modId=tradingpost modName=Trading Post -modVersion=4.2.0 +modVersion=8.0.2 modAuthor=Fuzs modDescription=Rule the village! Trade with every villager at once! +modLicense=MPL-2.0 modSourceUrl=https://github.com/Fuzss/tradingpost modIssueUrl=https://github.com/Fuzss/tradingpost/issues modUpdateUrl=https://raw.githubusercontent.com/Fuzss/modresources/main/update/tradingpost.json @@ -40,6 +23,13 @@ modFabricEnvironment=* # Mod Publishing projectReleaseType=release -projectGameVersions=1.19.1, 1.19.2 -projectCurseId=539057 +projectCurseForgeId=539057 projectModrinthId=8pcjMDgj + +dependenciesVersionCatalog=1.20.1-v5 +dependenciesRequiredForgeCurseForge=puzzles-lib +dependenciesRequiredFabricCurseForge=fabric-api, forge-config-api-port-fabric, puzzles-lib +dependenciesRequiredForgeModrinth=puzzles-lib +dependenciesRequiredFabricModrinth=fabric-api, forge-config-api-port, puzzles-lib +#dependenciesEmbeddedFabricCurseForge=cardinal-components +#dependenciesEmbeddedFabricModrinth=cardinal-components-api diff --git a/1.20.1/gradle/wrapper/gradle-wrapper.jar b/1.20.1/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..943f0cb Binary files /dev/null and b/1.20.1/gradle/wrapper/gradle-wrapper.jar differ diff --git a/1.20.1/gradle/wrapper/gradle-wrapper.properties b/1.20.1/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..37aef8d --- /dev/null +++ b/1.20.1/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/1.20.1/gradlew b/1.20.1/gradlew new file mode 100755 index 0000000..65dcd68 --- /dev/null +++ b/1.20.1/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# 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. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# 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 +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 + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# 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"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +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 ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +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 + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +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. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + 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=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +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" || "$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 + 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 + # 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 +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +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/1.20.1/gradlew.bat b/1.20.1/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/1.20.1/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +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. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +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. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +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! +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 + +:omega diff --git a/1.20.1/settings.gradle b/1.20.1/settings.gradle new file mode 100644 index 0000000..697dd5f --- /dev/null +++ b/1.20.1/settings.gradle @@ -0,0 +1,38 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + maven { + name = 'Sponge' + url = 'https://repo.spongepowered.org/repository/maven-public/' + } + maven { + name = 'Quilt' + url = 'https://maven.quiltmc.org/repository/release' + } + maven { + name = 'Minecraft Forge' + url = 'https://maven.minecraftforge.net/' + } + } +} + +dependencyResolutionManagement { + repositories { + maven { + name = "Fuzs Mod Resources" + url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" + } + } + versionCatalogs { + libs { + from("fuzs.sharedcatalogs:sharedcatalogs:${dependenciesVersionCatalog}") + } + } +} + +rootProject.name = "${modName.replaceAll("[^a-zA-Z]", "")}-${dependenciesVersionCatalog.replaceAll("-v\\d+", "")}" +include("Common", "Fabric", "Forge") diff --git a/1.20.4/CHANGELOG.md b/1.20.4/CHANGELOG.md new file mode 100644 index 0000000..e009718 --- /dev/null +++ b/1.20.4/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v20.4.1-1.20.4] - 2024-01-25 +### Fixed +- Fix missing mixin refmaps on Fabric & Forge + +## [v20.4.0-1.20.4] - 2024-01-24 +- Ported to Minecraft 1.20.4 +- Ported to NeoForge +### Fix +- Fix unable to click on search box to select diff --git a/1.20.4/Common/build.gradle b/1.20.4/Common/build.gradle new file mode 100644 index 0000000..13b80d3 --- /dev/null +++ b/1.20.4/Common/build.gradle @@ -0,0 +1,10 @@ +apply from: "https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/v2/common.gradle" + +dependencies { + // Puzzles Lib + modApi libs.puzzleslib.common +} + +tasks.withType(net.fabricmc.loom.task.AbstractRemapJarTask).configureEach { + targetNamespace = "named" +} diff --git a/1.20.4/Common/src/generated/resources/.cache/190dc8cc9e260d5273a6d094a2d5cfe3ccdbd9b6 b/1.20.4/Common/src/generated/resources/.cache/190dc8cc9e260d5273a6d094a2d5cfe3ccdbd9b6 new file mode 100644 index 0000000..bacc607 --- /dev/null +++ b/1.20.4/Common/src/generated/resources/.cache/190dc8cc9e260d5273a6d094a2d5cfe3ccdbd9b6 @@ -0,0 +1,2 @@ +// 1.20.4 2024-01-24T22:24:15.874424 Language (en_us) +147b78684226f399eeac6159d3fa21f598f5ec2b assets/tradingpost/lang/en_us.json diff --git a/1.20.4/Common/src/generated/resources/.cache/50b16d832771f8a8317f4d1b88c5121208c8c4f9 b/1.20.4/Common/src/generated/resources/.cache/50b16d832771f8a8317f4d1b88c5121208c8c4f9 new file mode 100644 index 0000000..679a1f9 --- /dev/null +++ b/1.20.4/Common/src/generated/resources/.cache/50b16d832771f8a8317f4d1b88c5121208c8c4f9 @@ -0,0 +1,2 @@ +// 1.20.4 2024-01-24T22:24:15.873951 Tags for minecraft:block mod id vanilla +e37ec5e3a6ed0926dc1d26eb5ad2e1873593f360 data/minecraft/tags/blocks/mineable/axe.json diff --git a/1.20.4/Common/src/generated/resources/.cache/77038cb024c5999ce280bcb6800e72cf1c655fe7 b/1.20.4/Common/src/generated/resources/.cache/77038cb024c5999ce280bcb6800e72cf1c655fe7 new file mode 100644 index 0000000..eb91da7 --- /dev/null +++ b/1.20.4/Common/src/generated/resources/.cache/77038cb024c5999ce280bcb6800e72cf1c655fe7 @@ -0,0 +1,3 @@ +// 1.20.4 2024-01-24T22:24:15.874265 Model Definitions +744a7fd8de66b44ea6012a51eb661120ebc8425e assets/tradingpost/blockstates/trading_post.json +cb2e625aee94c9cf690c12865dbd70b3ca956fb5 assets/tradingpost/models/item/trading_post.json diff --git a/1.20.4/Common/src/generated/resources/.cache/9e953cc4ec64c82f6e78f1ad2800a952d804eb06 b/1.20.4/Common/src/generated/resources/.cache/9e953cc4ec64c82f6e78f1ad2800a952d804eb06 new file mode 100644 index 0000000..9325470 --- /dev/null +++ b/1.20.4/Common/src/generated/resources/.cache/9e953cc4ec64c82f6e78f1ad2800a952d804eb06 @@ -0,0 +1,2 @@ +// 1.20.4 2024-01-24T22:24:15.874126 Tags for minecraft:entity_type mod id vanilla +35133e95f1c8fdd7a1c21afcc231fc0bffefb9a8 data/tradingpost/tags/entity_types/concealed_traders.json diff --git a/1.20.4/Common/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/1.20.4/Common/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e new file mode 100644 index 0000000..6cbed6e --- /dev/null +++ b/1.20.4/Common/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -0,0 +1,3 @@ +// 1.20.4 2024-01-24T22:24:15.874545 Recipes +18ab7e30d3db73a41a3e52c4dc419c21b7001bc7 data/tradingpost/advancements/recipes/decorations/trading_post.json +9817fabcf446177d2837f82610585da24bb4586a data/tradingpost/recipes/trading_post.json diff --git a/1.20.4/Common/src/generated/resources/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 b/1.20.4/Common/src/generated/resources/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 new file mode 100644 index 0000000..3aeba04 --- /dev/null +++ b/1.20.4/Common/src/generated/resources/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 @@ -0,0 +1,2 @@ +// 1.20.4 2024-01-24T22:24:15.87298 Block Loot Tables +ede38073af8a425c53fa810881defe08a8cd025c data/tradingpost/loot_tables/blocks/trading_post.json diff --git a/1.20.4/Common/src/generated/resources/assets/tradingpost/blockstates/trading_post.json b/1.20.4/Common/src/generated/resources/assets/tradingpost/blockstates/trading_post.json new file mode 100644 index 0000000..f9d843d --- /dev/null +++ b/1.20.4/Common/src/generated/resources/assets/tradingpost/blockstates/trading_post.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "tradingpost:block/trading_post" + } + } +} \ No newline at end of file diff --git a/1.20.4/Common/src/generated/resources/assets/tradingpost/lang/en_us.json b/1.20.4/Common/src/generated/resources/assets/tradingpost/lang/en_us.json new file mode 100644 index 0000000..55eb8e1 --- /dev/null +++ b/1.20.4/Common/src/generated/resources/assets/tradingpost/lang/en_us.json @@ -0,0 +1,6 @@ +{ + "block.tradingpost.trading_post": "Trading Post", + "container.trading_post": "Trading Post", + "trading_post.no_trader_found": "Couldn't find any available trader nearby", + "trading_post.trader_gone": "The trader is no longer available." +} \ No newline at end of file diff --git a/1.20.4/Common/src/generated/resources/assets/tradingpost/models/item/trading_post.json b/1.20.4/Common/src/generated/resources/assets/tradingpost/models/item/trading_post.json new file mode 100644 index 0000000..ad10a89 --- /dev/null +++ b/1.20.4/Common/src/generated/resources/assets/tradingpost/models/item/trading_post.json @@ -0,0 +1,3 @@ +{ + "parent": "tradingpost:block/trading_post" +} \ No newline at end of file diff --git a/1.20.4/Common/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json b/1.20.4/Common/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json new file mode 100644 index 0000000..bee9214 --- /dev/null +++ b/1.20.4/Common/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json @@ -0,0 +1,5 @@ +{ + "values": [ + "tradingpost:trading_post" + ] +} \ No newline at end of file diff --git a/1.20.4/Common/src/generated/resources/data/tradingpost/advancements/recipes/decorations/trading_post.json b/1.20.4/Common/src/generated/resources/data/tradingpost/advancements/recipes/decorations/trading_post.json new file mode 100644 index 0000000..19efbc7 --- /dev/null +++ b/1.20.4/Common/src/generated/resources/data/tradingpost/advancements/recipes/decorations/trading_post.json @@ -0,0 +1,34 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_emerald": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:emerald" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "tradingpost:trading_post" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_emerald" + ] + ], + "rewards": { + "recipes": [ + "tradingpost:trading_post" + ] + } +} \ No newline at end of file diff --git a/1.20.4/Common/src/generated/resources/data/tradingpost/loot_tables/blocks/trading_post.json b/1.20.4/Common/src/generated/resources/data/tradingpost/loot_tables/blocks/trading_post.json new file mode 100644 index 0000000..c14bf1d --- /dev/null +++ b/1.20.4/Common/src/generated/resources/data/tradingpost/loot_tables/blocks/trading_post.json @@ -0,0 +1,27 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:copy_name", + "source": "block_entity" + } + ], + "name": "tradingpost:trading_post" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "tradingpost:blocks/trading_post" +} \ No newline at end of file diff --git a/1.20.4/Common/src/generated/resources/data/tradingpost/recipes/trading_post.json b/1.20.4/Common/src/generated/resources/data/tradingpost/recipes/trading_post.json new file mode 100644 index 0000000..d8b58d9 --- /dev/null +++ b/1.20.4/Common/src/generated/resources/data/tradingpost/recipes/trading_post.json @@ -0,0 +1,23 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "#": { + "tag": "minecraft:planks" + }, + "S": { + "item": "minecraft:stick" + }, + "X": { + "item": "minecraft:emerald" + } + }, + "pattern": [ + " X ", + "###", + "S S" + ], + "result": { + "item": "tradingpost:trading_post" + } +} \ No newline at end of file diff --git a/1.20.4/Common/src/generated/resources/data/tradingpost/tags/entity_types/concealed_traders.json b/1.20.4/Common/src/generated/resources/data/tradingpost/tags/entity_types/concealed_traders.json new file mode 100644 index 0000000..f72d209 --- /dev/null +++ b/1.20.4/Common/src/generated/resources/data/tradingpost/tags/entity_types/concealed_traders.json @@ -0,0 +1,3 @@ +{ + "values": [] +} \ No newline at end of file diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/TradingPost.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/TradingPost.java new file mode 100644 index 0000000..8a3e329 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/TradingPost.java @@ -0,0 +1,55 @@ +package fuzs.tradingpost; + +import fuzs.puzzleslib.api.config.v3.ConfigHolder; +import fuzs.puzzleslib.api.core.v1.ModConstructor; +import fuzs.puzzleslib.api.core.v1.context.BuildCreativeModeTabContentsContext; +import fuzs.puzzleslib.api.core.v1.context.FuelBurnTimesContext; +import fuzs.puzzleslib.api.network.v2.NetworkHandlerV2; +import fuzs.tradingpost.config.ServerConfig; +import fuzs.tradingpost.init.ModRegistry; +import fuzs.tradingpost.network.S2CBuildOffersMessage; +import fuzs.tradingpost.network.S2CMerchantDataMessage; +import fuzs.tradingpost.network.S2CRemoveMerchantsMessage; +import fuzs.tradingpost.network.client.C2SClearSlotsMessage; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.CreativeModeTabs; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TradingPost implements ModConstructor { + public static final String MOD_ID = "tradingpost"; + public static final String MOD_NAME = "Trading Post"; + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_NAME); + + public static final NetworkHandlerV2 NETWORK = NetworkHandlerV2.build(MOD_ID, false); + public static final ConfigHolder CONFIG = ConfigHolder.builder(MOD_ID).server(ServerConfig.class); + + @Override + public void onConstructMod() { + ModRegistry.touch(); + registerMessages(); + } + + private static void registerMessages() { + NETWORK.registerClientbound(S2CMerchantDataMessage.class, S2CMerchantDataMessage::new); + NETWORK.registerClientbound(S2CRemoveMerchantsMessage.class, S2CRemoveMerchantsMessage::new); + NETWORK.registerClientbound(S2CBuildOffersMessage.class, S2CBuildOffersMessage::new); + NETWORK.registerServerbound(C2SClearSlotsMessage.class, C2SClearSlotsMessage::new); + } + + @Override + public void onBuildCreativeModeTabContents(BuildCreativeModeTabContentsContext context) { + context.registerBuildListener(CreativeModeTabs.FUNCTIONAL_BLOCKS, (itemDisplayParameters, output) -> { + output.accept(ModRegistry.TRADING_POST_ITEM.value()); + }); + } + + @Override + public void onRegisterFuelBurnTimes(FuelBurnTimesContext context) { + context.registerFuel(300, ModRegistry.TRADING_POST_BLOCK.value()); + } + + public static ResourceLocation id(String path) { + return new ResourceLocation(MOD_ID, path); + } +} diff --git a/Common/src/main/java/fuzs/tradingpost/client/TradingPostClient.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/client/TradingPostClient.java similarity index 72% rename from Common/src/main/java/fuzs/tradingpost/client/TradingPostClient.java rename to 1.20.4/Common/src/main/java/fuzs/tradingpost/client/TradingPostClient.java index 62d9af3..f459e21 100644 --- a/Common/src/main/java/fuzs/tradingpost/client/TradingPostClient.java +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/client/TradingPostClient.java @@ -1,14 +1,16 @@ package fuzs.tradingpost.client; -import fuzs.puzzleslib.client.core.ClientModConstructor; +import fuzs.puzzleslib.api.client.core.v1.ClientAbstractions; +import fuzs.puzzleslib.api.client.core.v1.ClientModConstructor; +import fuzs.puzzleslib.api.client.core.v1.context.BlockEntityRenderersContext; +import fuzs.puzzleslib.api.client.core.v1.context.MenuScreensContext; import fuzs.tradingpost.client.gui.screens.inventory.TradingPostScreen; import fuzs.tradingpost.client.renderer.blockentity.TradingPostRenderer; import fuzs.tradingpost.init.ModRegistry; import net.minecraft.ChatFormatting; import net.minecraft.client.searchtree.FullTextSearchTree; import net.minecraft.client.searchtree.SearchRegistry; -import net.minecraft.core.Registry; -import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.trading.MerchantOffer; @@ -16,26 +18,12 @@ import java.util.stream.Stream; public class TradingPostClient implements ClientModConstructor { - public static final SearchRegistry.Key OFFER_SEARCH_TREE = new SearchRegistry.Key<>(); - - @Override - public void onRegisterBlockEntityRenderers(BlockEntityRenderersContext context) { - context.registerBlockEntityRenderer(ModRegistry.TRADING_POST_BLOCK_ENTITY_TYPE.get(), TradingPostRenderer::new); - } - @Override - public void onRegisterMenuScreens(MenuScreensContext context) { - context.registerMenuScreen(ModRegistry.TRADING_POST_MENU_TYPE.get(), TradingPostScreen::new); - } - - @Override - public void onRegisterAtlasSprites(AtlasSpritesContext context) { - context.registerAtlasSprite(InventoryMenu.BLOCK_ATLAS, TradingPostScreen.MAGNIFYING_GLASS_LOCATION); - } + public static final SearchRegistry.Key OFFER_SEARCH_TREE = new SearchRegistry.Key<>(); @Override - public void onRegisterSearchTrees(SearchRegistryContext context) { - context.registerSearchTree(OFFER_SEARCH_TREE, base -> new FullTextSearchTree<>(offer -> + public void onClientSetup() { + ClientAbstractions.INSTANCE.getSearchRegistry().register(OFFER_SEARCH_TREE, base -> new FullTextSearchTree<>(offer -> Stream.of(offer.getBaseCostA(), offer.getCostB(), offer.getResult()) .filter(itemStack -> !itemStack.isEmpty()) .flatMap(itemStack -> itemStack.getTooltipLines(null, TooltipFlag.Default.NORMAL).stream()) @@ -44,8 +32,18 @@ public void onRegisterSearchTrees(SearchRegistryContext context) { offer -> Stream.of(offer.getBaseCostA(), offer.getCostB(), offer.getResult()) .filter(itemStack -> !itemStack.isEmpty()) .map(ItemStack::getItem) - .map(Registry.ITEM::getKey), + .map(BuiltInRegistries.ITEM::getKey), base )); } + + @Override + public void onRegisterMenuScreens(MenuScreensContext context) { + context.registerMenuScreen(ModRegistry.TRADING_POST_MENU_TYPE.value(), TradingPostScreen::new); + } + + @Override + public void onRegisterBlockEntityRenderers(BlockEntityRenderersContext context) { + context.registerBlockEntityRenderer(ModRegistry.TRADING_POST_BLOCK_ENTITY_TYPE.value(), TradingPostRenderer::new); + } } diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/client/gui/screens/inventory/TradingPostScreen.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/client/gui/screens/inventory/TradingPostScreen.java new file mode 100644 index 0000000..7a9ddf1 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/client/gui/screens/inventory/TradingPostScreen.java @@ -0,0 +1,342 @@ +package fuzs.tradingpost.client.gui.screens.inventory; + +import com.mojang.blaze3d.systems.RenderSystem; +import fuzs.tradingpost.TradingPost; +import fuzs.tradingpost.client.TradingPostClient; +import fuzs.tradingpost.mixin.client.accessor.ButtonAccessor; +import fuzs.tradingpost.mixin.client.accessor.MerchantScreenAccessor; +import fuzs.tradingpost.mixin.client.accessor.TradeOfferButtonAccessor; +import fuzs.tradingpost.network.client.C2SClearSlotsMessage; +import fuzs.tradingpost.world.inventory.TradingPostMenu; +import fuzs.tradingpost.world.item.trading.TradingPostOffers; +import fuzs.tradingpost.world.level.block.entity.TradingPostBlockEntity; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.client.gui.screens.inventory.MerchantScreen; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.searchtree.SearchTree; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ServerboundSelectTradePacket; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.MerchantMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.trading.MerchantOffer; +import net.minecraft.world.item.trading.MerchantOffers; + +import java.util.Locale; +import java.util.Objects; + +public class TradingPostScreen extends MerchantScreen { + public static final ResourceLocation MAGNIFYING_GLASS_LOCATION = TradingPost.id("container/villager/magnifying_glass"); + private static final ResourceLocation VILLAGER_LOCATION = new ResourceLocation("textures/gui/container/villager.png"); + private static final ResourceLocation OUT_OF_STOCK_SPRITE = new ResourceLocation("container/villager/out_of_stock"); + private static final ResourceLocation DISCOUNT_STRIKETHRUOGH_SPRITE = new ResourceLocation("container/villager/discount_strikethrough"); + private static final ResourceLocation CREATIVE_INVENTORY_LOCATION = new ResourceLocation("textures/gui/container/creative_inventory/tab_item_search.png"); + public static final Component DEPRECATED_TRADE_COMPONENT = Component.translatable("merchant.deprecated"); + public static final Component MERCHANT_UNAVAILABLE_COMPONENT = Component.translatable("trading_post.trader_gone"); + + private Button[] tradeOfferButtons = new Button[7]; + private EditBox searchBox; + private boolean ignoreTextInput; + + public TradingPostScreen(MerchantMenu container, Inventory playerInventory, Component title) { + super(container, playerInventory, title); + } + + @Override + protected void init() { + super.init(); + this.tradeOfferButtons = this.renderables.stream().filter(Button.class::isInstance).limit(7).map(Button.class::cast).toArray(Button[]::new); + Objects.checkIndex(6, this.tradeOfferButtons.length); + for (Button tradeOfferButton : this.tradeOfferButtons) { + + ((ButtonAccessor) tradeOfferButton).tradingpost$setOnPress(button -> { + + MerchantScreenAccessor accessor = (MerchantScreenAccessor) this; + int shopItem = ((TradeOfferButtonAccessor) button).tradingpost$getIndex() + accessor.tradingpost$getScrollOff(); + MerchantOffers offers = this.getMenu().getOffers(); + accessor.tradingpost$setShopItem(shopItem); + this.getMenu().setSelectionHint(shopItem); + this.getMenu().getTraders().setActiveOffer(offers.get(shopItem)); + this.getMenu().tryMoveItems(shopItem); + // get real index when sending to server + this.minecraft.getConnection().send(new ServerboundSelectTradePacket(offers instanceof TradingPostOffers ? ((TradingPostOffers) offers).getOrigShopItem(shopItem) : shopItem)); + }); + } + + this.searchBox = new EditBox(this.font, this.leftPos + 13, this.topPos + 6, 80, 9, TradingPostBlockEntity.CONTAINER_COMPONENT); + this.searchBox.setMaxLength(50); + this.searchBox.setBordered(false); + this.searchBox.setTextColor(16777215); + this.addWidget(this.searchBox); + } + + @Override + public void resize(Minecraft minecraft, int width, int height) { + String lastSearch = this.searchBox.getValue(); + super.resize(minecraft, width, height); + this.searchBox.setValue(lastSearch); + if (!this.searchBox.getValue().isEmpty()) { + this.refreshSearchResults(); + } + } + + @Override + protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) { + Component title = this.getMenu().getTraders().getDisplayName(); + if (title != null) { + int traderLevel = this.menu.getTraderLevel(); + if (traderLevel > 0 && traderLevel <= 5 && this.menu.showProgressBar()) { + title = title.copy().append(" - ").append(Component.translatable("merchant.level." + traderLevel)); + } + } else { + title = this.title; + } + guiGraphics.drawString(this.font, title, (49 + this.imageWidth / 2 - this.font.width(title) / 2), 6, 0x404040, false); + guiGraphics.drawString(this.font, this.playerInventoryTitle, this.inventoryLabelX, this.inventoryLabelY, 0x404040, false); + } + + @Override + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTime) { + + MerchantOffers merchantoffers = this.getMenu().getOffers(); + this.setButtonsActive(merchantoffers); + + int scrollOff = ((MerchantScreenAccessor) this).tradingpost$getScrollOff(); + Slot hoveredSlot = this.hoveredSlot; + // set offers to empty to prevent MerchantScreen::render code from running, also disabled buttons drawing tooltips by changing scrollOff, as well as tooltip for hovered slot by removing hovered slot + this.lock(true, merchantoffers.size(), null); + super.render(guiGraphics, mouseX, mouseY, partialTime); + // reset everything so we can do this ourselves + this.lock(false, scrollOff, hoveredSlot); + + if (!merchantoffers.isEmpty()) { + + // normally rendered as part of background, but skipped as offers are empty when it's called + int shopItemIndex = ((MerchantScreenAccessor) this).tradingpost$getShopItem(); + if (shopItemIndex >= 0 && shopItemIndex < merchantoffers.size()) { + + MerchantOffer merchantoffer = merchantoffers.get(shopItemIndex); + if (merchantoffer.isOutOfStock()) { + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + guiGraphics.blitSprite(OUT_OF_STOCK_SPRITE, this.leftPos + 83 + 99, this.topPos + 35, 0, 28, 21); + } + } + + int posX = this.leftPos + 5; + int posY = this.topPos + 16 + 2; + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderTexture(0, VILLAGER_LOCATION); + ((MerchantScreenAccessor) this).tradingpost$callRenderScroller(guiGraphics, this.leftPos, this.topPos, merchantoffers); + + for (int i = 0, merchantoffersSize = merchantoffers.size(); i < merchantoffersSize; i++) { + + if (merchantoffers.size() <= 7 || (i >= scrollOff && i < 7 + scrollOff)) { + + MerchantOffer merchantoffer = merchantoffers.get(i); + // move this call here to render below red overlay + ((MerchantScreenAccessor) this).tradingpost$callRenderButtonArrows(guiGraphics, merchantoffer, this.leftPos, posY + 1); + if (!this.getMenu().getTraders().checkOffer(merchantoffer)) { + + guiGraphics.fill(posX, posY, posX + 88, posY + 20, 822018048); + } + + ItemStack baseCostA = merchantoffer.getBaseCostA(); + ItemStack costA = merchantoffer.getCostA(); + ItemStack costB = merchantoffer.getCostB(); + ItemStack result = merchantoffer.getResult(); + guiGraphics.pose().pushPose(); + guiGraphics.pose().translate(0.0F, 0.0F, 100.0F); + + if (!this.getMenu().getTraders().checkOffer(merchantoffer)) { + + RenderSystem.depthFunc(516); + guiGraphics.fill(posX, posY, posX + 88, posY + 20, 822083583); + RenderSystem.depthFunc(515); + } + + this.renderAndDecorateCostA(guiGraphics, posX, posY, baseCostA, costA); + + if (!costB.isEmpty()) { + guiGraphics.renderFakeItem(costB, posX + 35, posY + 1); + guiGraphics.renderItemDecorations(this.font, costB, posX + 35, posY + 1); + } + + guiGraphics.renderFakeItem(result, posX + 68, posY + 1); + guiGraphics.renderItemDecorations(this.font, result, posX + 68, posY + 1); + guiGraphics.pose().popPose(); + posY += 20; + } + } + + MerchantOffer activeOffer = merchantoffers.get(shopItemIndex); + if (this.getMenu().showProgressBar()) { + + ((MerchantScreenAccessor) this).tradingpost$callRenderProgressBar(guiGraphics, this.leftPos, this.topPos, activeOffer); + } + + if (activeOffer.isOutOfStock() && this.isHovering(186, 35, 22, 21, mouseX, mouseY) && this.getMenu().canRestock()) { + + guiGraphics.renderTooltip(this.font, DEPRECATED_TRADE_COMPONENT, mouseX, mouseY); + } + + posY = this.topPos + 16 + 2; + for (int i = 0, merchantoffersSize = merchantoffers.size(); i < merchantoffersSize; i++) { + + if (merchantoffers.size() <= 7 || (i >= scrollOff && i < 7 + scrollOff)) { + + MerchantOffer merchantoffer = merchantoffers.get(i); + if (!this.getMenu().getTraders().checkOffer(merchantoffer)) { + + if (this.isHovering(posX, posY, 88, 19, mouseX + this.leftPos, mouseY + this.topPos)) { + + guiGraphics.renderTooltip(this.font, MERCHANT_UNAVAILABLE_COMPONENT, mouseX, mouseY); + } + } + + posY += 20; + } + } + RenderSystem.enableDepthTest(); + } + + // move this out of if block above since search may update this + Button[] offerButtons = this.tradeOfferButtons; + for (int i = 0, offerButtonsLength = offerButtons.length; i < offerButtonsLength; i++) { + + Button button = offerButtons[i]; + if (button.active && button.isHoveredOrFocused()) { + + ((TradeOfferButtonAccessor) button).tradingpost$callRenderToolTip(guiGraphics, mouseX, mouseY); + } + + button.visible = i < this.getMenu().getOffers().size(); + } + + this.renderTooltip(guiGraphics, mouseX, mouseY); + } + + private void renderAndDecorateCostA(GuiGraphics guiGraphics, int posX, int posY, ItemStack baseCostA, ItemStack costA) { + guiGraphics.renderFakeItem(costA, posX + 5, posY + 1); + if (baseCostA.getCount() == costA.getCount()) { + guiGraphics.renderItemDecorations(this.font, costA, posX + 5, posY + 1); + } else { + guiGraphics.renderItemDecorations(this.font, baseCostA, posX + 5, posY + 1, baseCostA.getCount() == 1 ? "1" : null); + guiGraphics.renderItemDecorations(this.font, costA, posX + 5 + 14, posY + 1, costA.getCount() == 1 ? "1" : null); + guiGraphics.pose().pushPose(); + guiGraphics.pose().translate(0.0F, 0.0F, 300.0F); + guiGraphics.blitSprite(DISCOUNT_STRIKETHRUOGH_SPRITE, posX + 5 + 7, posY + 1 + 12, 0, 9, 2); + guiGraphics.pose().popPose(); + } + } + + private void setButtonsActive(MerchantOffers merchantoffers) { + + if (!merchantoffers.isEmpty()) { + + for (int i = 0, merchantoffersSize = merchantoffers.size(); i < merchantoffersSize; i++) { + + int scrollOff = ((MerchantScreenAccessor) this).tradingpost$getScrollOff(); + if (merchantoffers.size() <= 7 || (i >= scrollOff && i < 7 + scrollOff)) { + + MerchantOffer offer = merchantoffers.get(i); + this.tradeOfferButtons[i - scrollOff].active = this.getMenu().getTraders().checkOffer(offer); + } + } + } + } + + private void lock(boolean lockOffers, int newScrollOff, Slot newHoveredSlot) { + this.getMenu().lockOffers(lockOffers); + ((MerchantScreenAccessor) this).tradingpost$setScrollOff(newScrollOff); + this.hoveredSlot = newHoveredSlot; + } + + @Override + protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) { + super.renderBg(guiGraphics, partialTicks, mouseX, mouseY); + guiGraphics.blit(CREATIVE_INVENTORY_LOCATION, this.leftPos + 11, this.topPos + 4, 0, 80.0F, 4.0F, 90, 12, 256, 256); + this.searchBox.render(guiGraphics, mouseX, mouseY, partialTicks); + guiGraphics.blitSprite(MAGNIFYING_GLASS_LOCATION, this.leftPos, this.topPos + 4, 0, 16, 16); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderTexture(0, VILLAGER_LOCATION); + } + + @Override + public boolean mouseClicked(double mouseX, double mouseY, int mouseKey) { + if (this.searchBox.mouseClicked(mouseX, mouseY, mouseKey)) { + this.searchBox.setFocused(true); + return true; + } + return super.mouseClicked(mouseX, mouseY, mouseKey); + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifierKeys) { + this.ignoreTextInput = false; + String lastSearch = this.searchBox.getValue().trim(); + if (this.searchBox.keyPressed(keyCode, scanCode, modifierKeys)) { + + if (!Objects.equals(this.searchBox.getValue().trim(), lastSearch)) { + + this.refreshSearchResults(); + } + + return true; + } else if (this.searchBox.isFocused() && this.searchBox.isVisible() && keyCode != 256) { + return true; + } else if (this.minecraft.options.keyChat.matches(keyCode, scanCode) && !this.searchBox.isFocused()) { + this.ignoreTextInput = true; + this.searchBox.setFocused(true); + return true; + } + + return super.keyPressed(keyCode, scanCode, modifierKeys); + } + + @Override + public boolean charTyped(char typedChar, int modifierKeys) { + + String lastSearch = this.searchBox.getValue().trim(); + if (!this.ignoreTextInput && this.searchBox.charTyped(typedChar, modifierKeys)) { + + if (!Objects.equals(this.searchBox.getValue().trim(), lastSearch)) { + + this.refreshSearchResults(); + } + + return true; + } + + return super.charTyped(typedChar, modifierKeys); + } + + public void refreshSearchResults() { + + if (!(this.getMenu().getOffers() instanceof TradingPostOffers offers)) { + return; + } + String query = this.searchBox.getValue().trim(); + if (query.isEmpty()) { + offers.clearFilter(); + } else { + SearchTree isearchtree = this.minecraft.getSearchTree(TradingPostClient.OFFER_SEARCH_TREE); + offers.setFilter(isearchtree.search(query.toLowerCase(Locale.ROOT))); + } + ((MerchantScreenAccessor) this).tradingpost$setScrollOff(0); + ((MerchantScreenAccessor) this).tradingpost$setShopItem(0); + this.getMenu().setSelectionHint(-1); + this.getMenu().getTraders().setActiveOffer(null); + this.getMenu().clearPaymentSlots(); + TradingPost.NETWORK.sendToServer(new C2SClearSlotsMessage()); + } + + @Override + public TradingPostMenu getMenu() { + return (TradingPostMenu) super.getMenu(); + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/client/renderer/blockentity/TradingPostRenderer.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/client/renderer/blockentity/TradingPostRenderer.java new file mode 100644 index 0000000..4ca2973 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/client/renderer/blockentity/TradingPostRenderer.java @@ -0,0 +1,56 @@ +package fuzs.tradingpost.client.renderer.blockentity; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Axis; +import fuzs.tradingpost.world.level.block.entity.TradingPostBlockEntity; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; +import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.util.Mth; +import net.minecraft.world.item.ItemDisplayContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; + +/** + * Mostly copied from Quark's MatrixEnchantingTableRenderer.java by Vazkii, thanks! + */ +public class TradingPostRenderer implements BlockEntityRenderer { + private final ItemRenderer itemRenderer; + + public TradingPostRenderer(BlockEntityRendererProvider.Context context) { + this.itemRenderer = context.getItemRenderer(); + } + + @Override + public void render(TradingPostBlockEntity blockEntity, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { + float ageInTicks = blockEntity.time + partialTicks; + float nextRotation = blockEntity.rot - blockEntity.oRot; + while (nextRotation >= Math.PI) { + nextRotation -= (Math.PI * 2F); + } + while (nextRotation < -Math.PI) { + nextRotation += (Math.PI * 2F); + } + float bookRotation = blockEntity.oRot + nextRotation * partialTicks; + float bookOpen = Mth.lerp(partialTicks, blockEntity.oOpen, blockEntity.open); + this.renderItem(new ItemStack(Items.EMERALD), ageInTicks, bookOpen, bookRotation, matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn, blockEntity.getLevel()); + } + + private void renderItem(ItemStack stack, float ageInTicks, float bookOpen, float bookRotation, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn, Level level) { + matrixStackIn.pushPose(); + matrixStackIn.translate(0.5F, 1.03125F, 0.5F); + matrixStackIn.scale(0.8F, 0.8F, 0.8F); + bookRotation *= -180.0F / (float) Math.PI; + bookRotation -= 90.0F; + bookRotation *= bookOpen; + matrixStackIn.mulPose(Axis.YP.rotationDegrees(bookRotation)); + matrixStackIn.translate(0.0F, bookOpen, Math.sin(bookOpen * Math.PI)); + matrixStackIn.mulPose(Axis.XP.rotationDegrees(-90.0F * (bookOpen - 1.0F))); + float hoveringHeight = (float) Math.sin(ageInTicks * 0.06F) * bookOpen * 0.2F; + matrixStackIn.translate(0.0F, hoveringHeight, 0.0F); + this.itemRenderer.renderStatic(stack, ItemDisplayContext.FIXED, combinedLightIn, combinedOverlayIn, matrixStackIn, bufferIn, level, 0); + matrixStackIn.popPose(); + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/config/ServerConfig.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/config/ServerConfig.java new file mode 100644 index 0000000..936d6a4 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/config/ServerConfig.java @@ -0,0 +1,35 @@ +package fuzs.tradingpost.config; + +import com.google.common.collect.Lists; +import fuzs.puzzleslib.api.config.v3.Config; +import fuzs.puzzleslib.api.config.v3.ConfigCore; +import fuzs.puzzleslib.api.config.v3.serialization.ConfigDataSet; +import fuzs.tradingpost.TradingPost; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.entity.EntityType; + +import java.util.List; + +public class ServerConfig implements ConfigCore { + @Config(description = "Range on xz plane trading post should search for merchants.") + @Config.IntRange(min = 1, max = 96) + public int horizontalRange = 24; + @Config(description = "Range on y axis trading post should search for merchants.") + @Config.IntRange(min = 1, max = 96) + public int verticalRange = 16; + @Config(description = "Disable traders on the trading screen when they wander out of range.") + public boolean enforceRange = false; + @Config(description = "Teleport xp from trading from villagers on top of the trading post.") + public boolean teleportXp = true; + @Config(name = "close_empty_screen", description = "Close trading post interface when all traders have become unavailable.") + public boolean closeScreen = true; + @Config(name = "trader_blacklist", description = {"Trader entities disabled from being found by the trading post.", "Modders may add their own incompatible trader entities via the \"" + TradingPost.MOD_ID + ":blacklisted_traders\" entity tag.", ConfigDataSet.CONFIG_DESCRIPTION}) + List traderBlacklistRaw = Lists.newArrayList(); + + public ConfigDataSet> traderBlacklist; + + @Override + public void afterConfigReload() { + this.traderBlacklist = ConfigDataSet.from(Registries.ENTITY_TYPE, this.traderBlacklistRaw); + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModBlockLootProvider.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModBlockLootProvider.java new file mode 100644 index 0000000..992c48f --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModBlockLootProvider.java @@ -0,0 +1,16 @@ +package fuzs.tradingpost.data; + +import fuzs.puzzleslib.api.data.v2.AbstractLootProvider; +import fuzs.puzzleslib.api.data.v2.core.DataProviderContext; +import fuzs.tradingpost.init.ModRegistry; + +public class ModBlockLootProvider extends AbstractLootProvider.Blocks { + public ModBlockLootProvider(DataProviderContext context) { + super(context); + } + + @Override + public void addLootTables() { + this.add(ModRegistry.TRADING_POST_BLOCK.value(), this::createNameableBlockEntityTable); + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModBlockTagProvider.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModBlockTagProvider.java new file mode 100644 index 0000000..9eb0a46 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModBlockTagProvider.java @@ -0,0 +1,19 @@ +package fuzs.tradingpost.data; + +import fuzs.puzzleslib.api.data.v2.AbstractTagProvider; +import fuzs.puzzleslib.api.data.v2.core.DataProviderContext; +import fuzs.tradingpost.init.ModRegistry; +import net.minecraft.core.HolderLookup; +import net.minecraft.tags.BlockTags; + +public class ModBlockTagProvider extends AbstractTagProvider.Blocks { + + public ModBlockTagProvider(DataProviderContext context) { + super(context); + } + + @Override + public void addTags(HolderLookup.Provider provider) { + this.tag(BlockTags.MINEABLE_WITH_AXE).add(ModRegistry.TRADING_POST_BLOCK.value()); + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModEntityTypeTagProvider.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModEntityTypeTagProvider.java new file mode 100644 index 0000000..e41bf65 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModEntityTypeTagProvider.java @@ -0,0 +1,18 @@ +package fuzs.tradingpost.data; + +import fuzs.puzzleslib.api.data.v2.AbstractTagProvider; +import fuzs.puzzleslib.api.data.v2.core.DataProviderContext; +import fuzs.tradingpost.init.ModRegistry; +import net.minecraft.core.HolderLookup; + +public class ModEntityTypeTagProvider extends AbstractTagProvider.EntityTypes { + + public ModEntityTypeTagProvider(DataProviderContext context) { + super(context); + } + + @Override + public void addTags(HolderLookup.Provider provider) { + this.tag(ModRegistry.CONCEALED_TRADERS_ENTITY_TYPE_TAG); + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModRecipeProvider.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModRecipeProvider.java new file mode 100644 index 0000000..9f06de2 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/ModRecipeProvider.java @@ -0,0 +1,30 @@ +package fuzs.tradingpost.data; + +import fuzs.puzzleslib.api.data.v2.AbstractRecipeProvider; +import fuzs.puzzleslib.api.data.v2.core.DataProviderContext; +import fuzs.tradingpost.init.ModRegistry; +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.data.recipes.RecipeOutput; +import net.minecraft.data.recipes.ShapedRecipeBuilder; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.item.Items; + +public class ModRecipeProvider extends AbstractRecipeProvider { + + public ModRecipeProvider(DataProviderContext context) { + super(context); + } + + @Override + public void addRecipes(RecipeOutput recipeOutput) { + ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, ModRegistry.TRADING_POST_BLOCK.value()) + .define('#', ItemTags.PLANKS) + .define('X', Items.EMERALD) + .define('S', Items.STICK) + .pattern(" X ") + .pattern("###") + .pattern("S S") + .unlockedBy(getHasName(Items.EMERALD), has(Items.EMERALD)) + .save(recipeOutput); + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/data/client/ModLanguageProvider.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/client/ModLanguageProvider.java new file mode 100644 index 0000000..a1f0e67 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/client/ModLanguageProvider.java @@ -0,0 +1,23 @@ +package fuzs.tradingpost.data.client; + +import fuzs.puzzleslib.api.client.data.v2.AbstractLanguageProvider; +import fuzs.puzzleslib.api.data.v2.core.DataProviderContext; +import fuzs.tradingpost.client.gui.screens.inventory.TradingPostScreen; +import fuzs.tradingpost.init.ModRegistry; +import fuzs.tradingpost.world.level.block.TradingPostBlock; +import fuzs.tradingpost.world.level.block.entity.TradingPostBlockEntity; + +public class ModLanguageProvider extends AbstractLanguageProvider { + + public ModLanguageProvider(DataProviderContext context) { + super(context); + } + + @Override + public void addTranslations(TranslationBuilder builder) { + builder.add(ModRegistry.TRADING_POST_BLOCK.value(), "Trading Post"); + builder.add(TradingPostBlockEntity.CONTAINER_COMPONENT, "Trading Post"); + builder.add(TradingPostScreen.MERCHANT_UNAVAILABLE_COMPONENT, "The trader is no longer available."); + builder.add(TradingPostBlock.MISSING_MERCHANT_COMPONENT, "Couldn't find any available trader nearby"); + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/data/client/ModModelProvider.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/client/ModModelProvider.java new file mode 100644 index 0000000..5bb580a --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/data/client/ModModelProvider.java @@ -0,0 +1,18 @@ +package fuzs.tradingpost.data.client; + +import fuzs.puzzleslib.api.client.data.v2.AbstractModelProvider; +import fuzs.puzzleslib.api.data.v2.core.DataProviderContext; +import fuzs.tradingpost.init.ModRegistry; +import net.minecraft.data.models.BlockModelGenerators; + +public class ModModelProvider extends AbstractModelProvider { + + public ModModelProvider(DataProviderContext context) { + super(context); + } + + @Override + public void addBlockModels(BlockModelGenerators builder) { + builder.createNonTemplateModelBlock(ModRegistry.TRADING_POST_BLOCK.value()); + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/init/ModRegistry.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/init/ModRegistry.java new file mode 100644 index 0000000..4994315 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/init/ModRegistry.java @@ -0,0 +1,34 @@ +package fuzs.tradingpost.init; + +import fuzs.puzzleslib.api.init.v3.registry.RegistryManager; +import fuzs.puzzleslib.api.init.v3.tags.BoundTagFactory; +import fuzs.tradingpost.TradingPost; +import fuzs.tradingpost.world.inventory.TradingPostMenu; +import fuzs.tradingpost.world.level.block.TradingPostBlock; +import fuzs.tradingpost.world.level.block.entity.TradingPostBlockEntity; +import net.minecraft.core.Holder; +import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.world.level.material.MapColor; + +public class ModRegistry { + static final RegistryManager REGISTRY = RegistryManager.from(TradingPost.MOD_ID); + public static final Holder.Reference TRADING_POST_BLOCK = REGISTRY.registerBlock("trading_post", () -> new TradingPostBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).instrument(NoteBlockInstrument.BASS).strength(2.5F).sound(SoundType.WOOD).ignitedByLava())); + public static final Holder.Reference TRADING_POST_ITEM = REGISTRY.registerBlockItem(TRADING_POST_BLOCK); + public static final Holder.Reference> TRADING_POST_BLOCK_ENTITY_TYPE = REGISTRY.registerBlockEntityType("trading_post", () -> BlockEntityType.Builder.of(TradingPostBlockEntity::new, TRADING_POST_BLOCK.value())); + public static final Holder.Reference> TRADING_POST_MENU_TYPE = REGISTRY.registerMenuType("trading_post", () -> TradingPostMenu::new); + + static final BoundTagFactory TAGS = BoundTagFactory.make(TradingPost.MOD_ID); + public static final TagKey> CONCEALED_TRADERS_ENTITY_TYPE_TAG = TAGS.registerEntityTypeTag("concealed_traders"); + + public static void touch() { + + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/accessor/MerchantMenuAccessor.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/accessor/MerchantMenuAccessor.java new file mode 100644 index 0000000..bb02a91 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/accessor/MerchantMenuAccessor.java @@ -0,0 +1,20 @@ +package fuzs.tradingpost.mixin.accessor; + +import net.minecraft.world.inventory.MerchantContainer; +import net.minecraft.world.inventory.MerchantMenu; +import net.minecraft.world.item.trading.Merchant; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(MerchantMenu.class) +public interface MerchantMenuAccessor { + + @Mutable + @Accessor + void setTrader(Merchant trader); + + @Mutable + @Accessor + void setTradeContainer(MerchantContainer tradeContainer); +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/accessor/VillagerAccessor.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/accessor/VillagerAccessor.java new file mode 100644 index 0000000..730cccc --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/accessor/VillagerAccessor.java @@ -0,0 +1,13 @@ +package fuzs.tradingpost.mixin.accessor; + +import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.player.Player; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(Villager.class) +public interface VillagerAccessor { + + @Invoker + void callUpdateSpecialPrices(Player player); +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/ButtonAccessor.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/ButtonAccessor.java new file mode 100644 index 0000000..5f844e7 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/ButtonAccessor.java @@ -0,0 +1,14 @@ +package fuzs.tradingpost.mixin.client.accessor; + +import net.minecraft.client.gui.components.Button; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Button.class) +public interface ButtonAccessor { + + @Mutable + @Accessor("onPress") + void tradingpost$setOnPress(Button.OnPress onPress); +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/MerchantScreenAccessor.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/MerchantScreenAccessor.java new file mode 100644 index 0000000..a67dadd --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/MerchantScreenAccessor.java @@ -0,0 +1,34 @@ +package fuzs.tradingpost.mixin.client.accessor; + +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.MerchantScreen; +import net.minecraft.world.item.trading.MerchantOffer; +import net.minecraft.world.item.trading.MerchantOffers; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(MerchantScreen.class) +public interface MerchantScreenAccessor { + + @Accessor("shopItem") + int tradingpost$getShopItem(); + + @Accessor("shopItem") + void tradingpost$setShopItem(int shopItem); + + @Accessor("scrollOff") + int tradingpost$getScrollOff(); + + @Accessor("scrollOff") + void tradingpost$setScrollOff(int scrollOff); + + @Invoker("renderScroller") + void tradingpost$callRenderScroller(GuiGraphics guiGraphics, int width, int height, MerchantOffers offers); + + @Invoker("renderButtonArrows") + void tradingpost$callRenderButtonArrows(GuiGraphics guiGraphics, MerchantOffer offer, int width, int height); + + @Invoker("renderProgressBar") + void tradingpost$callRenderProgressBar(GuiGraphics guiGraphics, int width, int height, MerchantOffer activeOffer); +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/TradeOfferButtonAccessor.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/TradeOfferButtonAccessor.java new file mode 100644 index 0000000..99e17d4 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/TradeOfferButtonAccessor.java @@ -0,0 +1,16 @@ +package fuzs.tradingpost.mixin.client.accessor; + +import net.minecraft.client.gui.GuiGraphics; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(targets = "net.minecraft.client.gui.screens.inventory.MerchantScreen$TradeOfferButton") +public interface TradeOfferButtonAccessor { + + @Accessor("index") + int tradingpost$getIndex(); + + @Invoker("renderToolTip") + void tradingpost$callRenderToolTip(GuiGraphics guiGraphics, int mouseX, int mouseY); +} diff --git a/Common/src/main/java/fuzs/tradingpost/network/S2CBuildOffersMessage.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/network/S2CBuildOffersMessage.java similarity index 94% rename from Common/src/main/java/fuzs/tradingpost/network/S2CBuildOffersMessage.java rename to 1.20.4/Common/src/main/java/fuzs/tradingpost/network/S2CBuildOffersMessage.java index 65533bc..48d34fb 100644 --- a/Common/src/main/java/fuzs/tradingpost/network/S2CBuildOffersMessage.java +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/network/S2CBuildOffersMessage.java @@ -1,6 +1,6 @@ package fuzs.tradingpost.network; -import fuzs.puzzleslib.network.Message; +import fuzs.puzzleslib.api.network.v2.MessageV2; import fuzs.tradingpost.client.TradingPostClient; import fuzs.tradingpost.client.gui.screens.inventory.TradingPostScreen; import fuzs.tradingpost.world.inventory.TradingPostMenu; @@ -10,7 +10,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.entity.player.Player; -public class S2CBuildOffersMessage implements Message { +public class S2CBuildOffersMessage implements MessageV2 { private int containerId; private Int2IntOpenHashMap idToOfferCount; diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/network/S2CMerchantDataMessage.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/network/S2CMerchantDataMessage.java new file mode 100644 index 0000000..91c9727 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/network/S2CMerchantDataMessage.java @@ -0,0 +1,73 @@ +package fuzs.tradingpost.network; + +import fuzs.puzzleslib.api.network.v2.MessageV2; +import fuzs.tradingpost.world.inventory.TradingPostMenu; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.trading.MerchantOffers; + +public class S2CMerchantDataMessage implements MessageV2 { + private int containerId; + private int merchantId; + private Component merchantTitle; + private MerchantOffers offers; + private int villagerLevel; + private int villagerXp; + private boolean showProgress; + private boolean canRestock; + + public S2CMerchantDataMessage() { + + } + + public S2CMerchantDataMessage(int containerId, int merchantId, Component merchantTitle, MerchantOffers offers, int villagerLevel, int villagerXp, boolean showProgress, boolean canRestock) { + this.containerId = containerId; + this.merchantId = merchantId; + this.merchantTitle = merchantTitle; + this.offers = offers; + this.villagerLevel = villagerLevel; + this.villagerXp = villagerXp; + this.showProgress = showProgress; + this.canRestock = canRestock; + } + + @Override + public void write(FriendlyByteBuf buf) { + buf.writeVarInt(this.containerId); + buf.writeInt(this.merchantId); + buf.writeComponent(this.merchantTitle); + this.offers.writeToStream(buf); + buf.writeVarInt(this.villagerLevel); + buf.writeVarInt(this.villagerXp); + buf.writeBoolean(this.showProgress); + buf.writeBoolean(this.canRestock); + } + + @Override + public void read(FriendlyByteBuf buf) { + this.containerId = buf.readVarInt(); + this.merchantId = buf.readInt(); + this.merchantTitle = buf.readComponent(); + this.offers = MerchantOffers.createFromStream(buf); + this.villagerLevel = buf.readVarInt(); + this.villagerXp = buf.readVarInt(); + this.showProgress = buf.readBoolean(); + this.canRestock = buf.readBoolean(); + } + + @Override + public MessageHandler makeHandler() { + return new MessageHandler<>() { + + @Override + public void handle(S2CMerchantDataMessage packet, Player player, Object gameInstance) { + AbstractContainerMenu container = player.containerMenu; + if (packet.containerId == container.containerId && container instanceof TradingPostMenu) { + ((TradingPostMenu) container).addMerchant(player, packet.merchantId, packet.merchantTitle, new MerchantOffers(packet.offers.createTag()), packet.villagerLevel, packet.villagerXp, packet.showProgress, packet.canRestock); + } + } + }; + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/network/S2CRemoveMerchantsMessage.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/network/S2CRemoveMerchantsMessage.java new file mode 100644 index 0000000..8aa0653 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/network/S2CRemoveMerchantsMessage.java @@ -0,0 +1,59 @@ +package fuzs.tradingpost.network; + +import fuzs.puzzleslib.api.network.v2.MessageV2; +import fuzs.tradingpost.world.inventory.TradingPostMenu; +import it.unimi.dsi.fastutil.ints.IntOpenHashSet; +import it.unimi.dsi.fastutil.ints.IntSet; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; + +public class S2CRemoveMerchantsMessage implements MessageV2 { + private int containerId; + private IntSet merchantIds; + + public S2CRemoveMerchantsMessage() { + + } + + public S2CRemoveMerchantsMessage(int containerId, IntSet merchantIds) { + this.containerId = containerId; + this.merchantIds = merchantIds; + } + + @Override + public void write(FriendlyByteBuf buf) { + buf.writeVarInt(this.containerId); + buf.writeVarInt(this.merchantIds.size()); + for (int merchantId : this.merchantIds) { + buf.writeInt(merchantId); + } + } + + @Override + public void read(FriendlyByteBuf buf) { + this.containerId = buf.readVarInt(); + int length = buf.readVarInt(); + IntSet merchantIds = new IntOpenHashSet(); + for (int i = 0; i < length; i++) { + merchantIds.add(buf.readInt()); + } + this.merchantIds = merchantIds; + } + + @Override + public MessageHandler makeHandler() { + return new MessageHandler<>() { + + @Override + public void handle(S2CRemoveMerchantsMessage packet, Player player, Object gameInstance) { + AbstractContainerMenu container = player.containerMenu; + if (packet.containerId == container.containerId && container instanceof TradingPostMenu) { + for (int merchantId : packet.merchantIds) { + ((TradingPostMenu) container).getTraders().removeMerchant(merchantId); + } + } + } + }; + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/network/client/C2SClearSlotsMessage.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/network/client/C2SClearSlotsMessage.java new file mode 100644 index 0000000..ba5d25a --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/network/client/C2SClearSlotsMessage.java @@ -0,0 +1,34 @@ +package fuzs.tradingpost.network.client; + +import fuzs.puzzleslib.api.network.v2.MessageV2; +import fuzs.tradingpost.world.inventory.TradingPostMenu; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; + +public class C2SClearSlotsMessage implements MessageV2 { + + @Override + public void write(FriendlyByteBuf buf) { + + } + + @Override + public void read(FriendlyByteBuf buf) { + + } + + @Override + public MessageHandler makeHandler() { + return new MessageHandler<>() { + + @Override + public void handle(C2SClearSlotsMessage packet, Player player, Object gameInstance) { + AbstractContainerMenu container = player.containerMenu; + if (container instanceof TradingPostMenu) { + ((TradingPostMenu) container).clearPaymentSlots(); + } + } + }; + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/world/entity/npc/LocalMerchant.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/entity/npc/LocalMerchant.java new file mode 100644 index 0000000..3c7a430 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/entity/npc/LocalMerchant.java @@ -0,0 +1,42 @@ +package fuzs.tradingpost.world.entity.npc; + +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.npc.ClientSideMerchant; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.trading.MerchantOffers; + +public class LocalMerchant extends ClientSideMerchant { + private final Component merchantTitle; + private final int merchantLevel; + private final boolean showProgressBar; + private final boolean canRestock; + + public LocalMerchant(Player playerEntity, Component merchantTitle, MerchantOffers offers, int villagerLevel, int villagerXp, boolean showProgress, boolean canRestock) { + super(playerEntity); + this.merchantTitle = merchantTitle; + this.overrideOffers(offers); + this.merchantLevel = villagerLevel; + this.overrideXp(villagerXp); + this.showProgressBar = showProgress; + this.canRestock = canRestock; + } + + public Component getDisplayName() { + return this.merchantTitle; + } + + public int getMerchantLevel() { + return this.merchantLevel; + } + + @Override + public boolean canRestock() { + return this.canRestock; + } + + @Override + public boolean showProgressBar() { + return this.showProgressBar; + } + +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/world/entity/npc/MerchantCollection.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/entity/npc/MerchantCollection.java new file mode 100644 index 0000000..3328c71 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/entity/npc/MerchantCollection.java @@ -0,0 +1,286 @@ +package fuzs.tradingpost.world.entity.npc; + +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import fuzs.tradingpost.TradingPost; +import fuzs.tradingpost.config.ServerConfig; +import fuzs.tradingpost.network.S2CBuildOffersMessage; +import fuzs.tradingpost.network.S2CMerchantDataMessage; +import fuzs.tradingpost.network.S2CRemoveMerchantsMessage; +import fuzs.tradingpost.world.item.trading.TradingPostOffers; +import fuzs.tradingpost.world.level.block.entity.TradingPostBlockEntity; +import it.unimi.dsi.fastutil.ints.*; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.ExperienceOrb; +import net.minecraft.world.entity.npc.VillagerDataHolder; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.trading.Merchant; +import net.minecraft.world.item.trading.MerchantOffer; +import net.minecraft.world.item.trading.MerchantOffers; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.Nullable; + +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.IntConsumer; +import java.util.stream.Collectors; + +public class MerchantCollection implements Merchant { + private final Int2ObjectOpenHashMap idToMerchant = new Int2ObjectOpenHashMap<>(); + private final Set disabledOffers = Sets.newHashSet(); + private final ContainerLevelAccess access; + + private MerchantOffers allOffers = new MerchantOffers(); + private Object2ObjectOpenHashMap offerToMerchant; + private Merchant currentMerchant; + + public MerchantCollection() { + this(ContainerLevelAccess.NULL); + } + + public MerchantCollection(ContainerLevelAccess access) { + this.access = access; + } + + public void addMerchant(int entityId, Merchant merchant) { + if (!merchant.getOffers().isEmpty()) { + this.idToMerchant.put(entityId, merchant); + } + } + + @Override + @Nullable + public Player getTradingPlayer() { + if (this.currentMerchant != null) { + return this.currentMerchant.getTradingPlayer(); + } + return null; + } + + @Override + public void setTradingPlayer(@Nullable Player player) { + this.idToMerchant.values().forEach(merchant -> merchant.setTradingPlayer(player)); + } + + @Override + public MerchantOffers getOffers() { + return this.allOffers; + } + + public boolean checkOffer(MerchantOffer offer) { + return !this.disabledOffers.contains(offer); + } + + @Override + public void overrideOffers(@Nullable MerchantOffers p_213703_1_) { + // this is vanilla, we do this differently + TradingPost.LOGGER.error("Set offers to stored merchants directly"); + } + + @Override + public void notifyTrade(MerchantOffer offer) { + if (this.currentMerchant != null) { + this.currentMerchant.notifyTrade(offer); + if (!TradingPost.CONFIG.get(ServerConfig.class).teleportXp) return; + // reward xp is spawned at trader location, find it and move to trading post + this.access.execute((level, pos) -> { + + if (this.currentMerchant instanceof Entity entity) { + + Vec3 merchantPos = entity.position().add(0.0, 0.5, 0.0); + final double xpWidth = 0.5, xpHeight = 0.5; + List xpRewards = level.getEntitiesOfClass(ExperienceOrb.class, new AABB(merchantPos.add(-xpWidth, -xpHeight, -xpWidth), merchantPos.add(xpWidth, xpHeight, xpWidth)), Entity::isAlive); + // move xp would be much nicer, unfortunately it'd only be moved on the server, so orbs need to be removed and spawned in again + for (ExperienceOrb xpOrb : xpRewards) { + level.addFreshEntity(new ExperienceOrb(level, pos.getX(), pos.getY() + 1.5, pos.getZ(), xpOrb.getValue())); + xpOrb.discard(); + } + } + }); + } + } + + @Override + public void notifyTradeUpdated(ItemStack stack) { + if (this.currentMerchant != null) { + this.currentMerchant.notifyTradeUpdated(stack); + } + } + + @Override + public boolean isClientSide() { + return this.access == ContainerLevelAccess.NULL; + } + + @Override + public int getVillagerXp() { + if (this.currentMerchant != null) { + return this.currentMerchant.getVillagerXp(); + } + return 0; + } + + public Merchant getCurrentMerchant() { + return this.currentMerchant; + } + + @Override + public boolean canRestock() { + if (this.currentMerchant != null) { + return this.currentMerchant.canRestock(); + } + return false; + } + + @Override + public void overrideXp(int xpValue) { + if (this.currentMerchant != null) { + this.currentMerchant.overrideXp(xpValue); + } + } + + @Override + public boolean showProgressBar() { + if (this.currentMerchant != null) { + return this.currentMerchant.showProgressBar(); + } + return false; + } + + @Override + public SoundEvent getNotifyTradeSound() { + if (this.currentMerchant != null) { + return this.currentMerchant.getNotifyTradeSound(); + } + // unused by client, just a dummy + return SoundEvents.VILLAGER_YES; + } + + public int getTraderLevel() { + if (this.currentMerchant != null) { + Merchant merchant = this.currentMerchant; + if (merchant instanceof LocalMerchant) { + return ((LocalMerchant) merchant).getMerchantLevel(); + } else if (merchant instanceof VillagerDataHolder) { + return ((VillagerDataHolder) merchant).getVillagerData().getLevel(); + } + } + return 0; + } + + @Nullable + public Component getDisplayName() { + if (this.currentMerchant != null) { + Merchant merchant = this.currentMerchant; + if (merchant instanceof LocalMerchant) { + return ((LocalMerchant) merchant).getDisplayName(); + } else if (merchant instanceof Entity) { + return ((Entity) merchant).getDisplayName(); + } + } + return null; + } + + public boolean updateAvailableMerchants(int containerId, BlockPos pos, Player player, boolean testRange) { + IntSet toRemove = new IntOpenHashSet(); + for (Map.Entry entry : this.idToMerchant.int2ObjectEntrySet()) { + if (entry.getValue() instanceof Entity) { + if (entry.getValue().getTradingPlayer() != player || testRange && !this.traderInRange((Entity) entry.getValue(), pos)) { + toRemove.add(entry.getKey().intValue()); + } + } + } + if (!toRemove.isEmpty()) { + toRemove.forEach((IntConsumer) this::removeMerchant); + TradingPost.NETWORK.sendTo(new S2CRemoveMerchantsMessage(containerId, toRemove), (ServerPlayer) player); + } + return !this.idToMerchant.isEmpty(); + } + + private boolean traderInRange(Entity entity, BlockPos pos) { + return this.traderInRange(entity, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); + } + + private boolean traderInRange(Entity entity, double posX, double posY, double posZ) { + return Math.abs(entity.getX() - posX) <= TradingPost.CONFIG.get(ServerConfig.class).horizontalRange && Math.abs(entity.getY() - posY) <= TradingPost.CONFIG.get(ServerConfig.class).verticalRange && Math.abs(entity.getZ() - posZ) <= TradingPost.CONFIG.get(ServerConfig.class).horizontalRange; + } + + public void removeMerchant(int merchantId) { + Merchant merchant = this.idToMerchant.get(merchantId); + if (merchant != null) { + this.disabledOffers.addAll(merchant.getOffers()); + this.idToMerchant.remove(merchantId); + merchant.setTradingPlayer(null); + if (this.currentMerchant == merchant) { + this.currentMerchant = null; + } + } + } + + public void setActiveOffer(MerchantOffer offer) { + if (this.offerToMerchant != null) { + this.currentMerchant = offer != null ? this.offerToMerchant.get(offer) : null; + } + } + + public void sendMerchantData(final int containerId, Player player) { + for (Map.Entry entry : this.idToMerchant.int2ObjectEntrySet()) { + Merchant merchant = entry.getValue(); + final Component merchantTitle = merchant instanceof Entity ? ((Entity) merchant).getDisplayName() : TradingPostBlockEntity.CONTAINER_COMPONENT; + final int merchantLevel = merchant instanceof VillagerDataHolder ? ((VillagerDataHolder) merchant).getVillagerData().getLevel() : 0; + S2CMerchantDataMessage message = new S2CMerchantDataMessage(containerId, entry.getKey(), merchantTitle, merchant.getOffers(), merchantLevel, merchant.getVillagerXp(), merchant.showProgressBar(), merchant.canRestock()); + TradingPost.NETWORK.sendTo(message, (ServerPlayer) player); + } + TradingPost.NETWORK.sendTo(new S2CBuildOffersMessage(containerId, this.getIdToOfferCountMap()), (ServerPlayer) player); + } + + public Int2IntOpenHashMap getIdToOfferCountMap() { + return this.idToMerchant.int2ObjectEntrySet().stream() + .collect(Collectors.toMap(Int2ObjectMap.Entry::getIntKey, entry -> entry.getValue().getOffers().size(), (o1, o2) -> o1, Int2IntOpenHashMap::new)); + } + + public void buildOffers(Int2IntOpenHashMap idToOfferCount) { + List sortedEntries = Lists.newArrayList(idToOfferCount.int2IntEntrySet()); + sortedEntries.sort(Comparator.comparingInt(Int2IntMap.Entry::getIntKey)); + MerchantOffers allOffers = new TradingPostOffers(this.disabledOffers); + for (Int2IntMap.Entry entry : sortedEntries) { + Merchant merchant = this.idToMerchant.get(entry.getIntKey()); + for (int i = 0; i < entry.getIntValue(); i++) { + MerchantOffer offer; + if (merchant != null && i < merchant.getOffers().size()) { + offer = merchant.getOffers().get(i); + } else { + // this should never actually happen, but you never know with mods + offer = fakeOffer(); + this.disabledOffers.add(offer); + } + allOffers.add(offer); + } + } + this.allOffers = allOffers; + this.buildOfferToMerchantMap(); + } + + private void buildOfferToMerchantMap() { + Object2ObjectOpenHashMap offerToMerchant = new Object2ObjectOpenHashMap<>(); + for (Merchant merchant : this.idToMerchant.values()) { + merchant.getOffers().forEach(offer -> offerToMerchant.put(offer, merchant)); + } + this.offerToMerchant = offerToMerchant; + } + + private static MerchantOffer fakeOffer() { + return new MerchantOffer(ItemStack.EMPTY, ItemStack.EMPTY, -1, -1, 0.0F); + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostContainer.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostContainer.java new file mode 100644 index 0000000..7a1cd60 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostContainer.java @@ -0,0 +1,22 @@ +package fuzs.tradingpost.world.inventory; + +import fuzs.tradingpost.world.entity.npc.MerchantCollection; +import net.minecraft.world.inventory.MerchantContainer; + +public class TradingPostContainer extends MerchantContainer { + private final MerchantCollection merchant; + + public TradingPostContainer(MerchantCollection merchant) { + super(merchant); + this.merchant = merchant; + this.setSelectionHint(-1); + } + + @Override + public void updateSellItem() { + super.updateSellItem(); + if (this.getActiveOffer() != null) { + this.merchant.setActiveOffer(this.getActiveOffer()); + } + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostMenu.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostMenu.java new file mode 100644 index 0000000..c9f9ff3 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/inventory/TradingPostMenu.java @@ -0,0 +1,207 @@ +package fuzs.tradingpost.world.inventory; + +import fuzs.tradingpost.TradingPost; +import fuzs.tradingpost.config.ServerConfig; +import fuzs.tradingpost.init.ModRegistry; +import fuzs.tradingpost.mixin.accessor.MerchantMenuAccessor; +import fuzs.tradingpost.world.entity.npc.LocalMerchant; +import fuzs.tradingpost.world.entity.npc.MerchantCollection; +import fuzs.tradingpost.world.level.block.TradingPostBlock; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.*; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.trading.Merchant; +import net.minecraft.world.item.trading.MerchantOffers; +import net.minecraft.world.level.Level; + +import java.util.Optional; + +public class TradingPostMenu extends MerchantMenu { + private final ContainerLevelAccess access; + private final MerchantCollection traders; + private final MerchantContainer tradeContainer; + + private int ticks; + private boolean lockOffers; + + public TradingPostMenu(int containerId, Inventory inventory) { + this(containerId, inventory, new MerchantCollection(), ContainerLevelAccess.NULL); + } + + public TradingPostMenu(int containerId, Inventory inventory, MerchantCollection merchantCollection, ContainerLevelAccess worldPosCallable) { + super(containerId, inventory, merchantCollection); + this.access = worldPosCallable; + this.traders = merchantCollection; + ((MerchantMenuAccessor) this).setTrader(this.traders); + this.tradeContainer = new TradingPostContainer(this.traders); + ((MerchantMenuAccessor) this).setTradeContainer(this.tradeContainer); + this.replaceSlot(0, new Slot(this.tradeContainer, 0, 136, 37)); + this.replaceSlot(1, new Slot(this.tradeContainer, 1, 162, 37)); + this.replaceSlot(2, new MerchantResultSlot(inventory.player, this.traders, this.tradeContainer, 2, 220, 37)); + } + + private void replaceSlot(int index, Slot slot) { + slot.index = index; + this.slots.set(index, slot); + } + + @Override + public MenuType getType() { + return ModRegistry.TRADING_POST_MENU_TYPE.value(); + } + + @Override + public boolean stillValid(Player player) { + // this also updates merchants, so run independent of config option + // don't want this to go off on every tick + Optional anyTrader = this.access.evaluate((Level level, BlockPos pos) -> { + boolean testRange = TradingPost.CONFIG.get(ServerConfig.class).enforceRange && ++this.ticks >= 20; + return this.traders.updateAvailableMerchants(this.containerId, pos, player, testRange); + }); + if (this.ticks >= 20) this.ticks = 0; + if (TradingPost.CONFIG.get(ServerConfig.class).closeScreen && anyTrader.isPresent() && !anyTrader.get()) { + player.displayClientMessage(TradingPostBlock.MISSING_MERCHANT_COMPONENT, false); + return false; + } + return stillValid(this.access, player, ModRegistry.TRADING_POST_BLOCK.value()); + } + + @Override + public ItemStack quickMoveStack(Player player, int slotIndex) { + ItemStack itemstack = ItemStack.EMPTY; + Slot slot = this.slots.get(slotIndex); + if (slot != null && slot.hasItem()) { + + ItemStack itemstack1 = slot.getItem(); + itemstack = itemstack1.copy(); + if (slotIndex == 2) { + + if (!this.moveItemStackTo(itemstack1, 3, 39, true)) { + + return ItemStack.EMPTY; + } + + slot.onQuickCraft(itemstack1, itemstack); + // only replace this, vanilla will throw ClassCastException due to MerchantCollection not being an entity + this.playTradeSound(); + } else { + + return super.quickMoveStack(player, slotIndex); + } + + if (itemstack1.isEmpty()) { + + slot.set(ItemStack.EMPTY); + } else { + + slot.setChanged(); + } + + if (itemstack1.getCount() == itemstack.getCount()) { + + return ItemStack.EMPTY; + } + + slot.onTake(player, itemstack1); + } + + return itemstack; + } + + private void playTradeSound() { + if (!this.traders.isClientSide()) { + Merchant merchant = this.traders.getCurrentMerchant(); + if (merchant instanceof Entity entity) { + entity.level().playLocalSound(entity.getX(), entity.getY(), entity.getZ(), this.traders.getNotifyTradeSound(), SoundSource.NEUTRAL, 1.0F, 1.0F, false); + } + } + } + + public void clearPaymentSlots() { + ItemStack itemstack = this.tradeContainer.getItem(0); + if (!itemstack.isEmpty()) { + if (!this.moveItemStackTo(itemstack, 3, 39, true)) { + return; + } + + this.tradeContainer.setItem(0, itemstack); + } + + ItemStack itemstack1 = this.tradeContainer.getItem(1); + if (!itemstack1.isEmpty()) { + if (!this.moveItemStackTo(itemstack1, 3, 39, true)) { + return; + } + + this.tradeContainer.setItem(1, itemstack1); + } + } + + @Override + public MerchantOffers getOffers() { + return this.lockOffers ? new MerchantOffers() : super.getOffers(); + } + + public MerchantCollection getTraders() { + return this.traders; + } + + public void lockOffers(boolean lock) { + this.lockOffers = lock; + } + + public void addMerchant(Player playerEntity, int merchantId, Component merchantTitle, MerchantOffers offers, int villagerLevel, int villagerXp, boolean showProgress, boolean canRestock) { + LocalMerchant merchant = new LocalMerchant(playerEntity, merchantTitle, offers, villagerLevel, villagerXp, showProgress, canRestock); + this.traders.addMerchant(merchantId, merchant); + } + + @Override + public int getTraderLevel() { + return this.traders.getTraderLevel(); + } + + @Override + public boolean canRestock() { + return this.traders.canRestock(); + } + + @Override + public boolean showProgressBar() { + return this.traders.showProgressBar(); + } + + @Override + public void setShowProgressBar(boolean showProgressBar) { + // Don't throw to not break other mods possibly interfering with the merchant menu. + TradingPost.LOGGER.error("Operation setShowProgressBar no supported on trading post, set showProgressBar to merchants directly"); + } + + @Override + public void setXp(int xpValue) { + // Don't throw to not break other mods possibly interfering with the merchant menu. + TradingPost.LOGGER.error("Operation setXp no supported on trading post, set xp to merchants directly"); + } + + @Override + public void setMerchantLevel(int merchantLevel) { + // Don't throw to not break other mods possibly interfering with the merchant menu. + TradingPost.LOGGER.error("Operation setMerchantLevel no supported on trading post, set level to merchants directly"); + } + + @Override + public void setCanRestock(boolean canRestock) { + // Don't throw to not break other mods possibly interfering with the merchant menu. + TradingPost.LOGGER.error("Operation setCanRestock no supported on trading post, set canRestock to merchants directly"); + } + + @Override + public void setOffers(MerchantOffers offers) { + // Don't throw to not break other mods possibly interfering with the merchant menu. + TradingPost.LOGGER.error("Operation setOffers no supported on trading post, set offers to merchants directly"); + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/world/item/trading/TradingPostOffers.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/item/trading/TradingPostOffers.java new file mode 100644 index 0000000..8bde01b --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/item/trading/TradingPostOffers.java @@ -0,0 +1,58 @@ +package fuzs.tradingpost.world.item.trading; + +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.trading.MerchantOffer; +import net.minecraft.world.item.trading.MerchantOffers; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.Set; + +public class TradingPostOffers extends MerchantOffers { + private final Set disabledOffers; + private int[] indexToShopItem; + + public TradingPostOffers(Set disabledOffers) { + this.disabledOffers = disabledOffers; + } + + @Nullable + @Override + public MerchantOffer getRecipeFor(ItemStack input1, ItemStack input2, int offerId) { + if (offerId >= 0 && offerId < this.size()) { + MerchantOffer offer = this.get(offerId); + return offer.satisfiedBy(input1, input2) && !this.disabledOffers.contains(offer) ? offer : null; + } + return null; + } + + @Override + public int size() { + return this.indexToShopItem != null ? this.indexToShopItem.length : super.size(); + } + + @Override + public boolean isEmpty() { + return this.size() == 0; + } + + @Override + public MerchantOffer get(int index) { + return super.get(this.indexToShopItem != null ? this.indexToShopItem[index] : index); + } + + public void setFilter(Collection activeOffers) { + this.indexToShopItem = activeOffers.stream() + .filter(this::contains) + .mapToInt(this::indexOf) + .toArray(); + } + + public void clearFilter() { + this.indexToShopItem = null; + } + + public int getOrigShopItem(int filteredShopItem) { + return this.indexToShopItem != null && filteredShopItem < this.indexToShopItem.length ? this.indexToShopItem[filteredShopItem] : filteredShopItem; + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/world/level/block/TradingPostBlock.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/level/block/TradingPostBlock.java new file mode 100644 index 0000000..17a2916 --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/level/block/TradingPostBlock.java @@ -0,0 +1,181 @@ +package fuzs.tradingpost.world.level.block; + +import com.mojang.serialization.MapCodec; +import fuzs.puzzleslib.api.block.v1.entity.TickingEntityBlock; +import fuzs.tradingpost.TradingPost; +import fuzs.tradingpost.config.ServerConfig; +import fuzs.tradingpost.init.ModRegistry; +import fuzs.tradingpost.mixin.accessor.VillagerAccessor; +import fuzs.tradingpost.world.entity.npc.MerchantCollection; +import fuzs.tradingpost.world.inventory.TradingPostMenu; +import fuzs.tradingpost.world.level.block.entity.TradingPostBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.network.chat.Component; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.SimpleMenuProvider; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.trading.Merchant; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.BaseEntityBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; + +import java.util.List; +import java.util.OptionalInt; + +public class TradingPostBlock extends BaseEntityBlock implements SimpleWaterloggedBlock, TickingEntityBlock { + public static final Component MISSING_MERCHANT_COMPONENT = Component.translatable("trading_post.no_trader_found"); + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + public static final MapCodec CODEC = simpleCodec(TradingPostBlock::new); + private static final VoxelShape LEG1 = Block.box(0.0, 0.0, 0.0, 4.0, 8.0, 4.0); + private static final VoxelShape LEG2 = Block.box(12.0, 0.0, 0.0, 16.0, 8.0, 4.0); + private static final VoxelShape LEG3 = Block.box(0.0, 0.0, 12.0, 4.0, 8.0, 16.0); + private static final VoxelShape LEG4 = Block.box(12.0, 0.0, 12.0, 16.0, 8.0, 16.0); + private static final VoxelShape TOP = Block.box(0.0, 8.0, 0.0, 16.0, 16.0, 16.0); + private static final VoxelShape SHAPE = Shapes.or(TOP, LEG1, LEG2, LEG3, LEG4); + + public TradingPostBlock(Properties blockProperties) { + super(blockProperties); + this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, Boolean.FALSE)); + } + + @Override + protected MapCodec codec() { + return CODEC; + } + + @Override + public boolean useShapeForLightOcclusion(BlockState state) { + return true; + } + + @Override + public VoxelShape getShape(BlockState state, BlockGetter blockReader, BlockPos pos, CollisionContext context) { + return SHAPE; + } + + @Override + public RenderShape getRenderShape(BlockState state) { + return RenderShape.MODEL; + } + + @Override + public BlockState updateShape(BlockState state, Direction direction, BlockState oldState, LevelAccessor level, BlockPos newPos, BlockPos oldPos) { + if (state.getValue(WATERLOGGED)) { + level.scheduleTick(newPos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); + } + return super.updateShape(state, direction, oldState, level, newPos, oldPos); + } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + FluidState fluidState = context.getLevel().getFluidState(context.getClickedPos()); + return this.defaultBlockState().setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER); + } + + @Override + public FluidState getFluidState(BlockState blockState) { + return blockState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(blockState); + } + + @Override + public BlockEntityType getBlockEntityType() { + return ModRegistry.TRADING_POST_BLOCK_ENTITY_TYPE.value(); + } + + @Override + public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult rayTraceResult) { + if (level.isClientSide) { + return InteractionResult.SUCCESS; + } else { + Vec3 atCenter = Vec3.atCenterOf(pos); + final int horizontalRange = TradingPost.CONFIG.get(ServerConfig.class).horizontalRange; + final int verticalRange = TradingPost.CONFIG.get(ServerConfig.class).verticalRange; + List traders = level.getEntitiesOfClass(Entity.class, new AABB(atCenter.add(-horizontalRange, -verticalRange, -horizontalRange), atCenter.add(horizontalRange, verticalRange, horizontalRange)), TradingPostBlock::isAllowedToTrade); + if (!traders.isEmpty()) { + ContainerLevelAccess access = ContainerLevelAccess.create(level, pos); + MerchantCollection merchants = new MerchantCollection(access); + for (Entity merchant : traders) { + if (merchant instanceof Villager) { + ((VillagerAccessor) merchant).callUpdateSpecialPrices(player); + } + merchants.addMerchant(merchant.getId(), (Merchant) merchant); + } + merchants.setTradingPlayer(player); + merchants.buildOffers(merchants.getIdToOfferCountMap()); + Component title; + if (level.getBlockEntity(pos) instanceof TradingPostBlockEntity blockEntity) + title = blockEntity.getDisplayName(); + else { + title = TradingPostBlockEntity.CONTAINER_COMPONENT; + } + OptionalInt result = player.openMenu(new SimpleMenuProvider((int containerId, Inventory inventory, Player containerPlayer) -> { + return new TradingPostMenu(containerId, inventory, merchants, access); + }, title)); + result.ifPresent((int containerId) -> { + merchants.sendMerchantData(containerId, player); + }); + } else { + player.displayClientMessage(MISSING_MERCHANT_COMPONENT, false); + } + return InteractionResult.CONSUME; + } + } + + public static boolean isAllowedToTrade(Entity entity) { + if (entity.getType().is(ModRegistry.CONCEALED_TRADERS_ENTITY_TYPE_TAG)) { + return false; + } + + if (!entity.isAlive() || !(entity instanceof Merchant merchant) || merchant.getTradingPlayer() != null || merchant.getOffers().isEmpty()) { + return false; + } + + return !(entity instanceof LivingEntity livingEntity) || !livingEntity.isSleeping() && !livingEntity.isBaby(); + } + + @Override + public void setPlacedBy(Level level, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { + if (stack.hasCustomHoverName()) { + if (level.getBlockEntity(pos) instanceof TradingPostBlockEntity blockEntity) { + blockEntity.setCustomName(stack.getHoverName()); + } + } + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(WATERLOGGED); + } + + @Override + public boolean isPathfindable(BlockState state, BlockGetter blockReader, BlockPos pos, PathComputationType pathType) { + return false; + } +} diff --git a/1.20.4/Common/src/main/java/fuzs/tradingpost/world/level/block/entity/TradingPostBlockEntity.java b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/level/block/entity/TradingPostBlockEntity.java new file mode 100644 index 0000000..956c2cd --- /dev/null +++ b/1.20.4/Common/src/main/java/fuzs/tradingpost/world/level/block/entity/TradingPostBlockEntity.java @@ -0,0 +1,100 @@ +package fuzs.tradingpost.world.level.block.entity; + +import fuzs.puzzleslib.api.block.v1.entity.TickingBlockEntity; +import fuzs.tradingpost.init.ModRegistry; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.util.Mth; +import net.minecraft.world.Nameable; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.Nullable; + +public class TradingPostBlockEntity extends BlockEntity implements Nameable, TickingBlockEntity { + public static final Component CONTAINER_COMPONENT = Component.translatable("container.trading_post"); + + private Component name; + public int time; + public float open; + public float oOpen; + public float rot; + public float oRot; + private float tRot; + + public TradingPostBlockEntity(BlockPos blockPos, BlockState blockState) { + super(ModRegistry.TRADING_POST_BLOCK_ENTITY_TYPE.value(), blockPos, blockState); + } + + @Override + protected void saveAdditional(CompoundTag compoundTag) { + super.saveAdditional(compoundTag); + if (this.hasCustomName()) { + compoundTag.putString("CustomName", Component.Serializer.toJson(this.name)); + } + } + + @Override + public void load(CompoundTag compoundTag) { + super.load(compoundTag); + if (compoundTag.contains("CustomName", 8)) { + this.name = Component.Serializer.fromJson(compoundTag.getString("CustomName")); + } + } + + @Override + public void clientTick() { + if (this.getLevel() == null || !this.getLevel().isClientSide) return; + this.oOpen = this.open; + this.oRot = this.rot; + Player playerentity = this.getLevel().getNearestPlayer((double) this.getBlockPos().getX() + 0.5, (double) this.getBlockPos().getY() + 0.5, (double) this.getBlockPos().getZ() + 0.5, 3.0, false); + if (playerentity != null) { + double d0 = playerentity.getX() - ((double) this.getBlockPos().getX() + 0.5); + double d1 = playerentity.getZ() - ((double) this.getBlockPos().getZ() + 0.5); + this.tRot = (float) Mth.atan2(d1, d0); + this.open += 0.1F; + } else { + this.tRot += 0.02F; + this.open -= 0.1F; + } + while(this.rot >= (float) Math.PI) { + this.rot -= ((float) Math.PI * 2.0F); + } + while(this.rot < -(float) Math.PI) { + this.rot += ((float) Math.PI * 2.0F); + } + while(this.tRot >= (float) Math.PI) { + this.tRot -= ((float) Math.PI * 2.0F); + } + while(this.tRot < -(float) Math.PI) { + this.tRot += ((float) Math.PI * 2.0F); + } + float f2; + f2 = this.tRot - this.rot; + while (f2 >= (float) Math.PI) { + f2 -= ((float) Math.PI * 2.0F); + } + while(f2 < -(float) Math.PI) { + f2 += ((float) Math.PI * 2.0F); + } + this.rot += f2 * 0.4F; + this.open = Mth.clamp(this.open, 0.0F, 1.0F); + ++this.time; + } + + @Override + public Component getName() { + return this.name != null ? this.name : CONTAINER_COMPONENT; + } + + public void setCustomName(@Nullable Component textComponent) { + this.name = textComponent; + } + + @Nullable + @Override + public Component getCustomName() { + return this.name; + } +} diff --git a/1.20.4/Common/src/main/resources/architectury.common.json b/1.20.4/Common/src/main/resources/architectury.common.json new file mode 100644 index 0000000..e813a5a --- /dev/null +++ b/1.20.4/Common/src/main/resources/architectury.common.json @@ -0,0 +1,3 @@ +{ + "accessWidener": "tradingpost.accesswidener" +} \ No newline at end of file diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/lang/it_it.json b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/it_it.json new file mode 100644 index 0000000..84afc50 --- /dev/null +++ b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/it_it.json @@ -0,0 +1,7 @@ +{ + "block.tradingpost.trading_post": "Postazione commerciale", + "container.trading_post": "Postazione commerciale", + "trading_post.no_trader_found": "Nessun commerciante disponibile trovato nelle vicinanze", + "trading_post.trader_gone": "Il commerciante non è più disponibile.", + "trading_post.search": "Ricerca..." +} diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/lang/ja_jp.json b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/ja_jp.json new file mode 100644 index 0000000..574d205 --- /dev/null +++ b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/ja_jp.json @@ -0,0 +1,7 @@ +{ + "block.tradingpost.trading_post": "交易台", + "container.trading_post": "交易台", + "trading_post.no_trader_found": "近くに交易できる村人が居ません", + "trading_post.trader_gone": "交易できる村人が居なくなりました。", + "trading_post.search": "検索..." +} diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/lang/pt_br.json b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/pt_br.json new file mode 100644 index 0000000..e84791f --- /dev/null +++ b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/pt_br.json @@ -0,0 +1,7 @@ +{ + "block.tradingpost.trading_post": "Posto de Comércio", + "container.trading_post": "Posto de Comércio", + "trading_post.no_trader_found": "Não foi possível encontrar nenhum comerciante disponível nas proximidades", + "trading_post.trader_gone": "O comerciante não está mais disponível.", + "trading_post.search": "Procurar..." + } \ No newline at end of file diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/lang/ru_ru.json b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/ru_ru.json new file mode 100644 index 0000000..ef8965c --- /dev/null +++ b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/ru_ru.json @@ -0,0 +1,7 @@ +{ + "block.tradingpost.trading_post": "Торговый пост", + "container.trading_post": "Торговый пост", + "trading_post.no_trader_found": "Не удалось найти по близости какого-либо торговца.", + "trading_post.trader_gone": "Торговец больше не доступен.", + "trading_post.search": "Поиск..." +} diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/lang/zh_cn.json b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/zh_cn.json new file mode 100644 index 0000000..6b534ef --- /dev/null +++ b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/zh_cn.json @@ -0,0 +1,7 @@ +{ + "block.tradingpost.trading_post": "贸易台", + "container.trading_post": "贸易台", + "trading_post.no_trader_found": "附近没有可用交易", + "trading_post.trader_gone": "贸易台", + "trading_post.search": "搜索中……" +} diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/lang/zh_tw.json b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/zh_tw.json new file mode 100644 index 0000000..cc3146e --- /dev/null +++ b/1.20.4/Common/src/main/resources/assets/tradingpost/lang/zh_tw.json @@ -0,0 +1,7 @@ +{ + "block.tradingpost.trading_post": "交易站", + "container.trading_post": "交易站", + "trading_post.no_trader_found": "在附近沒有可用的交易", + "trading_post.trader_gone": "交易鎖定.", + "trading_post.search": "搜尋中..." +} diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/models/block/trading_post.json b/1.20.4/Common/src/main/resources/assets/tradingpost/models/block/trading_post.json new file mode 100644 index 0000000..c876239 --- /dev/null +++ b/1.20.4/Common/src/main/resources/assets/tradingpost/models/block/trading_post.json @@ -0,0 +1,63 @@ +{ "parent": "block/block", + "textures": { + "particle": "tradingpost:block/trading_post_top", + "bottom1": "tradingpost:block/trading_post_bottom", + "bottom2": "minecraft:block/oak_planks", + "top": "tradingpost:block/trading_post_top", + "side": "tradingpost:block/trading_post_side", + "front": "tradingpost:block/trading_post_front" + }, + "elements": [ + { "from": [ 0, 0, 0 ], + "to": [ 4, 8, 4 ], + "faces": { + "down": { "uv": [ 0, 0, 4, 4 ], "texture": "#bottom1", "cullface": "down" }, + "north": { "uv": [ 0, 8, 4, 16 ], "texture": "#side", "cullface": "north" }, + "south": { "uv": [ 4, 8, 8, 16 ], "texture": "#side" }, + "west": { "uv": [ 8, 8, 12, 16 ], "texture": "#side", "cullface": "west" }, + "east": { "uv": [ 12, 8, 16, 16 ], "texture": "#side" } + } + }, + { "from": [ 12, 0, 12 ], + "to": [ 16, 8, 16 ], + "faces": { + "down": { "uv": [ 12, 12, 16, 16 ], "texture": "#bottom1", "cullface": "down" }, + "north": { "uv": [ 0, 8, 4, 16 ], "texture": "#side" }, + "south": { "uv": [ 4, 8, 8, 16 ], "texture": "#side", "cullface": "south" }, + "west": { "uv": [ 8, 8, 12, 16 ], "texture": "#side" }, + "east": { "uv": [ 12, 8, 16, 16 ], "texture": "#side", "cullface": "east" } + } + }, + { "from": [ 12, 0, 0 ], + "to": [ 16, 8, 4 ], + "faces": { + "down": { "uv": [ 12, 0, 16, 4 ], "texture": "#bottom1", "cullface": "down" }, + "north": { "uv": [ 0, 8, 4, 16 ], "texture": "#front", "cullface": "north" }, + "south": { "uv": [ 4, 8, 8, 16 ], "texture": "#front" }, + "west": { "uv": [ 8, 8, 12, 16 ], "texture": "#front" }, + "east": { "uv": [ 12, 8, 16, 16 ], "texture": "#front", "cullface": "east" } + } + }, + { "from": [ 0, 0, 12 ], + "to": [ 4, 8, 16 ], + "faces": { + "down": { "uv": [ 0, 12, 4, 16 ], "texture": "#bottom1", "cullface": "down" }, + "north": { "uv": [ 0, 8, 4, 16 ], "texture": "#front" }, + "south": { "uv": [ 4, 8, 8, 16 ], "texture": "#front", "cullface": "south" }, + "west": { "uv": [ 8, 8, 12, 16 ], "texture": "#front", "cullface": "west" }, + "east": { "uv": [ 12, 8, 16, 16 ], "texture": "#front" } + } + }, + { "from": [ 0, 8, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom2" }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "cullface": "up" }, + "north": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "north" }, + "south": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, + "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#front", "cullface": "west" }, + "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#front", "cullface": "east" } + } + } + ] +} diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_bottom.png b/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_bottom.png new file mode 100644 index 0000000..717082a Binary files /dev/null and b/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_bottom.png differ diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_front.png b/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_front.png new file mode 100644 index 0000000..bff9f1e Binary files /dev/null and b/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_front.png differ diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_side.png b/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_side.png new file mode 100644 index 0000000..6eff5ba Binary files /dev/null and b/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_side.png differ diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_top.png b/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_top.png new file mode 100644 index 0000000..c127409 Binary files /dev/null and b/1.20.4/Common/src/main/resources/assets/tradingpost/textures/block/trading_post_top.png differ diff --git a/1.20.4/Common/src/main/resources/assets/tradingpost/textures/gui/sprites/container/villager/magnifying_glass.png b/1.20.4/Common/src/main/resources/assets/tradingpost/textures/gui/sprites/container/villager/magnifying_glass.png new file mode 100644 index 0000000..ef622a1 Binary files /dev/null and b/1.20.4/Common/src/main/resources/assets/tradingpost/textures/gui/sprites/container/villager/magnifying_glass.png differ diff --git a/1.20.4/Common/src/main/resources/common.mixins.json b/1.20.4/Common/src/main/resources/common.mixins.json new file mode 100644 index 0000000..b0cdaf5 --- /dev/null +++ b/1.20.4/Common/src/main/resources/common.mixins.json @@ -0,0 +1,18 @@ +{ + "required": true, + "minVersion": "0.8", + "compatibilityLevel": "JAVA_17", + "package": "${modGroup}.mixin", + "mixins": [ + "accessor.MerchantMenuAccessor", + "accessor.VillagerAccessor" + ], + "client": [ + "client.accessor.ButtonAccessor", + "client.accessor.MerchantScreenAccessor", + "client.accessor.TradeOfferButtonAccessor" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/1.20.4/Common/src/main/resources/mod_banner.png b/1.20.4/Common/src/main/resources/mod_banner.png new file mode 100644 index 0000000..4aa65be Binary files /dev/null and b/1.20.4/Common/src/main/resources/mod_banner.png differ diff --git a/1.20.4/Common/src/main/resources/mod_logo.png b/1.20.4/Common/src/main/resources/mod_logo.png new file mode 100644 index 0000000..fa91dba Binary files /dev/null and b/1.20.4/Common/src/main/resources/mod_logo.png differ diff --git a/Common/src/main/resources/pack.mcmeta b/1.20.4/Common/src/main/resources/pack.mcmeta similarity index 60% rename from Common/src/main/resources/pack.mcmeta rename to 1.20.4/Common/src/main/resources/pack.mcmeta index 6221806..546f4f1 100755 --- a/Common/src/main/resources/pack.mcmeta +++ b/1.20.4/Common/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "${modDescription}", - "pack_format": ${packFormat} + "pack_format": ${resourcePackFormat} } } diff --git a/1.20.4/Common/src/main/resources/tradingpost.accesswidener b/1.20.4/Common/src/main/resources/tradingpost.accesswidener new file mode 100644 index 0000000..236e6b1 --- /dev/null +++ b/1.20.4/Common/src/main/resources/tradingpost.accesswidener @@ -0,0 +1 @@ +accessWidener v2 named diff --git a/1.20.4/Fabric/build.gradle b/1.20.4/Fabric/build.gradle new file mode 100644 index 0000000..4de494c --- /dev/null +++ b/1.20.4/Fabric/build.gradle @@ -0,0 +1,19 @@ +apply from: "https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/v2/fabric.gradle" + +dependencies { + // Fabric Api + modApi libs.fabricapi.fabric + + // Puzzles Lib + modApi libs.puzzleslib.fabric + + // Cardinal Components +// modApi(include(libs.cardinalcomponentsbase.fabric.get())) +// modApi(include(libs.cardinalcomponentsentity.fabric.get())) +// modApi(include(libs.cardinalcomponentsblock.fabric.get())) +// modApi(include(libs.cardinalcomponentschunk.fabric.get())) +// modApi(include(libs.cardinalcomponentsworld.fabric.get())) + + // Extensible Enums +// modApi(include(libs.extensibleenums.fabric.get())) +} diff --git a/1.20.4/Fabric/src/main/java/fuzs/tradingpost/fabric/TradingPostFabric.java b/1.20.4/Fabric/src/main/java/fuzs/tradingpost/fabric/TradingPostFabric.java new file mode 100644 index 0000000..fcdb445 --- /dev/null +++ b/1.20.4/Fabric/src/main/java/fuzs/tradingpost/fabric/TradingPostFabric.java @@ -0,0 +1,13 @@ +package fuzs.tradingpost.fabric; + +import fuzs.puzzleslib.api.core.v1.ModConstructor; +import fuzs.tradingpost.TradingPost; +import net.fabricmc.api.ModInitializer; + +public class TradingPostFabric implements ModInitializer { + + @Override + public void onInitialize() { + ModConstructor.construct(TradingPost.MOD_ID, TradingPost::new); + } +} diff --git a/1.20.4/Fabric/src/main/java/fuzs/tradingpost/fabric/client/TradingPostFabricClient.java b/1.20.4/Fabric/src/main/java/fuzs/tradingpost/fabric/client/TradingPostFabricClient.java new file mode 100644 index 0000000..a1299fb --- /dev/null +++ b/1.20.4/Fabric/src/main/java/fuzs/tradingpost/fabric/client/TradingPostFabricClient.java @@ -0,0 +1,14 @@ +package fuzs.tradingpost.fabric.client; + +import fuzs.puzzleslib.api.client.core.v1.ClientModConstructor; +import fuzs.tradingpost.TradingPost; +import fuzs.tradingpost.client.TradingPostClient; +import net.fabricmc.api.ClientModInitializer; + +public class TradingPostFabricClient implements ClientModInitializer { + + @Override + public void onInitializeClient() { + ClientModConstructor.construct(TradingPost.MOD_ID, TradingPostClient::new); + } +} diff --git a/1.20.4/Fabric/src/main/resources/fabric.mixins.json b/1.20.4/Fabric/src/main/resources/fabric.mixins.json new file mode 100644 index 0000000..6bf7940 --- /dev/null +++ b/1.20.4/Fabric/src/main/resources/fabric.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8", + "compatibilityLevel": "JAVA_17", + "package": "${modGroup}.fabric.mixin", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + }, + "refmap": "${modId}.fabric.refmap.json" +} diff --git a/1.20.4/Fabric/src/main/resources/fabric.mod.json b/1.20.4/Fabric/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..bd7ba2d --- /dev/null +++ b/1.20.4/Fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,45 @@ +{ + "schemaVersion": 1, + "id": "${modId}", + "version": "${modVersion}", + + "name": "${modName}", + "description": "${modDescription}", + + "authors": [ + "${modAuthor}" + ], + + "contact": { + "homepage": "${modPageUrl}", + "issues": "${modIssueUrl}", + "sources": "${modPageUrl}" + }, + + "license": "${modLicense}", + "icon": "mod_logo.png", + + "environment": "${modFabricEnvironment}", + + "entrypoints": { + "main": [ + "${mainEntryPoint}" + ], + "client": [ + "${clientEntryPoint}" + ] + }, + + "mixins": [ + "${modId}.common.mixins.json", + "${modId}.fabric.mixins.json" + ], + + "depends": { + "fabricloader": ">=${minFabricVersion}", + "fabric-api": ">=${minFabricApiVersion}", + "puzzleslib": ">=${minPuzzlesVersion}", + "minecraft": "${minecraftVersion}", + "java": ">=17" + } +} diff --git a/1.20.4/Forge/build.gradle b/1.20.4/Forge/build.gradle new file mode 100644 index 0000000..f9839f1 --- /dev/null +++ b/1.20.4/Forge/build.gradle @@ -0,0 +1,6 @@ +apply from: "https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/v2/forge.gradle" + +dependencies { + // Puzzles Lib + modApi libs.puzzleslib.forge +} diff --git a/1.20.4/Forge/gradle.properties b/1.20.4/Forge/gradle.properties new file mode 100644 index 0000000..32f842a --- /dev/null +++ b/1.20.4/Forge/gradle.properties @@ -0,0 +1 @@ +loom.platform=forge \ No newline at end of file diff --git a/Forge/src/main/java/fuzs/tradingpost/TradingPostForge.java b/1.20.4/Forge/src/main/java/fuzs/tradingpost/forge/TradingPostForge.java similarity index 66% rename from Forge/src/main/java/fuzs/tradingpost/TradingPostForge.java rename to 1.20.4/Forge/src/main/java/fuzs/tradingpost/forge/TradingPostForge.java index 482d035..0f01496 100644 --- a/Forge/src/main/java/fuzs/tradingpost/TradingPostForge.java +++ b/1.20.4/Forge/src/main/java/fuzs/tradingpost/forge/TradingPostForge.java @@ -1,6 +1,7 @@ -package fuzs.tradingpost; +package fuzs.tradingpost.forge; -import fuzs.puzzleslib.core.CoreServices; +import fuzs.puzzleslib.api.core.v1.ModConstructor; +import fuzs.tradingpost.TradingPost; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; @@ -11,6 +12,6 @@ public class TradingPostForge { @SubscribeEvent public static void onConstructMod(final FMLConstructModEvent evt) { - CoreServices.FACTORIES.modConstructor(TradingPost.MOD_ID).accept(new TradingPost()); + ModConstructor.construct(TradingPost.MOD_ID, TradingPost::new); } } diff --git a/1.20.4/Forge/src/main/java/fuzs/tradingpost/forge/client/TradingPostForgeClient.java b/1.20.4/Forge/src/main/java/fuzs/tradingpost/forge/client/TradingPostForgeClient.java new file mode 100644 index 0000000..d400491 --- /dev/null +++ b/1.20.4/Forge/src/main/java/fuzs/tradingpost/forge/client/TradingPostForgeClient.java @@ -0,0 +1,18 @@ +package fuzs.tradingpost.forge.client; + +import fuzs.puzzleslib.api.client.core.v1.ClientModConstructor; +import fuzs.tradingpost.TradingPost; +import fuzs.tradingpost.client.TradingPostClient; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; + +@Mod.EventBusSubscriber(modid = TradingPost.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) +public class TradingPostForgeClient { + + @SubscribeEvent + public static void onConstructMod(final FMLConstructModEvent evt) { + ClientModConstructor.construct(TradingPost.MOD_ID, TradingPostClient::new); + } +} diff --git a/1.20.4/Forge/src/main/resources/META-INF/mods.toml b/1.20.4/Forge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..6c2e585 --- /dev/null +++ b/1.20.4/Forge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,51 @@ +modLoader = "javafml" +loaderVersion = "*" +license = "${modLicense}" +issueTrackerURL = "${modIssueUrl}" + +[[mods]] +modId = "${modId}" +displayName = "${modName}" +description = "${modDescription}" +version = "${modVersion}" +authors = "${modAuthor}" +logoFile = "mod_banner.png" +logoBlur = false +displayURL = "${modPageUrl}" +updateJSONURL = "${modUpdateUrl}" +displayTest = "${modForgeDisplayTest}" + +[[dependencies.${ modId }]] +modId = "forge" +mandatory = true +type = "required" +versionRange = "[${minForgeVersion},)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.${ modId }]] +modId = "minecraft" +mandatory = true +type = "required" +versionRange = "[${minecraftVersion}]" +ordering = "NONE" +side = "BOTH" + +[[dependencies.${ modId }]] +modId = "forgeconfigapiport" +mandatory = true +type = "required" +versionRange = "*" +ordering = "NONE" +side = "BOTH" + +[[dependencies.${ modId }]] +modId = "puzzleslib" +mandatory = true +type = "required" +versionRange = "[${minPuzzlesVersion},)" +ordering = "NONE" +side = "BOTH" + +[modproperties.${ modId }] +catalogueImageIcon = "mod_logo.png" diff --git a/1.20.4/Forge/src/main/resources/forge.mixins.json b/1.20.4/Forge/src/main/resources/forge.mixins.json new file mode 100644 index 0000000..f2b4276 --- /dev/null +++ b/1.20.4/Forge/src/main/resources/forge.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8", + "compatibilityLevel": "JAVA_17", + "package": "${modGroup}.forge.mixin", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + }, + "refmap": "${modId}.forge.refmap.json" +} diff --git a/1.20.4/NeoForge/build.gradle b/1.20.4/NeoForge/build.gradle new file mode 100644 index 0000000..310efce --- /dev/null +++ b/1.20.4/NeoForge/build.gradle @@ -0,0 +1,6 @@ +apply from: "https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/v2/neoforge.gradle" + +dependencies { + // Puzzles Lib + modApi libs.puzzleslib.neoforge +} diff --git a/1.20.4/NeoForge/gradle.properties b/1.20.4/NeoForge/gradle.properties new file mode 100644 index 0000000..2914393 --- /dev/null +++ b/1.20.4/NeoForge/gradle.properties @@ -0,0 +1 @@ +loom.platform=neoforge \ No newline at end of file diff --git a/1.20.4/NeoForge/src/main/java/fuzs/tradingpost/neoforge/TradingPostNeoForge.java b/1.20.4/NeoForge/src/main/java/fuzs/tradingpost/neoforge/TradingPostNeoForge.java new file mode 100644 index 0000000..147d893 --- /dev/null +++ b/1.20.4/NeoForge/src/main/java/fuzs/tradingpost/neoforge/TradingPostNeoForge.java @@ -0,0 +1,25 @@ +package fuzs.tradingpost.neoforge; + +import fuzs.puzzleslib.api.core.v1.ModConstructor; +import fuzs.puzzleslib.neoforge.api.data.v2.core.DataProviderHelper; +import fuzs.tradingpost.TradingPost; +import fuzs.tradingpost.data.ModBlockLootProvider; +import fuzs.tradingpost.data.ModBlockTagProvider; +import fuzs.tradingpost.data.ModEntityTypeTagProvider; +import fuzs.tradingpost.data.ModRecipeProvider; +import fuzs.tradingpost.data.client.ModLanguageProvider; +import fuzs.tradingpost.data.client.ModModelProvider; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLConstructModEvent; + +@Mod(TradingPost.MOD_ID) +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) +public class TradingPostNeoForge { + + @SubscribeEvent + public static void onConstructMod(final FMLConstructModEvent evt) { + ModConstructor.construct(TradingPost.MOD_ID, TradingPost::new); + DataProviderHelper.registerDataProviders(TradingPost.MOD_ID, ModBlockLootProvider::new, ModBlockTagProvider::new, ModEntityTypeTagProvider::new, ModRecipeProvider::new, ModLanguageProvider::new, ModModelProvider::new); + } +} diff --git a/1.20.4/NeoForge/src/main/java/fuzs/tradingpost/neoforge/client/TradingPostNeoForgeClient.java b/1.20.4/NeoForge/src/main/java/fuzs/tradingpost/neoforge/client/TradingPostNeoForgeClient.java new file mode 100644 index 0000000..8173684 --- /dev/null +++ b/1.20.4/NeoForge/src/main/java/fuzs/tradingpost/neoforge/client/TradingPostNeoForgeClient.java @@ -0,0 +1,18 @@ +package fuzs.tradingpost.neoforge.client; + +import fuzs.puzzleslib.api.client.core.v1.ClientModConstructor; +import fuzs.tradingpost.TradingPost; +import fuzs.tradingpost.client.TradingPostClient; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLConstructModEvent; + +@Mod.EventBusSubscriber(modid = TradingPost.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) +public class TradingPostNeoForgeClient { + + @SubscribeEvent + public static void onConstructMod(final FMLConstructModEvent evt) { + ClientModConstructor.construct(TradingPost.MOD_ID, TradingPostClient::new); + } +} diff --git a/1.20.4/NeoForge/src/main/resources/META-INF/mods.toml b/1.20.4/NeoForge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..ef10121 --- /dev/null +++ b/1.20.4/NeoForge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,49 @@ +modLoader = "javafml" +loaderVersion = "*" +license = "${modLicense}" +issueTrackerURL = "${modIssueUrl}" + +[[mods]] +modId = "${modId}" +displayName = "${modName}" +description = "${modDescription}" +version = "${modVersion}" +authors = "${modAuthor}" +logoFile = "mod_banner.png" +logoBlur = false +displayURL = "${modPageUrl}" +updateJSONURL = "${modUpdateUrl}" +displayTest = "${modForgeDisplayTest}" + +[[mixins]] +config="${modId}.common.mixins.json" + +[[mixins]] +config="${modId}.neoforge.mixins.json" + +[[dependencies.${ modId }]] +modId = "neoforge" +mandatory = true +type = "required" +versionRange = "[${minNeoForgeVersion},)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.${ modId }]] +modId = "minecraft" +mandatory = true +type = "required" +versionRange = "[${minecraftVersion}]" +ordering = "NONE" +side = "BOTH" + +[[dependencies.${ modId }]] +modId = "puzzleslib" +mandatory = true +type = "required" +versionRange = "[${minPuzzlesVersion},)" +ordering = "NONE" +side = "BOTH" + +[modproperties.${ modId }] +catalogueImageIcon = "mod_logo.png" diff --git a/1.20.4/NeoForge/src/main/resources/neoforge.mixins.json b/1.20.4/NeoForge/src/main/resources/neoforge.mixins.json new file mode 100644 index 0000000..1fb3919 --- /dev/null +++ b/1.20.4/NeoForge/src/main/resources/neoforge.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8", + "compatibilityLevel": "JAVA_17", + "package": "${modGroup}.neoforge.mixin", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/1.20.4/build.gradle b/1.20.4/build.gradle new file mode 100644 index 0000000..2417d2e --- /dev/null +++ b/1.20.4/build.gradle @@ -0,0 +1,9 @@ +plugins { + alias libs.plugins.architecturyloom apply false + alias libs.plugins.architecturyplugin apply false + alias libs.plugins.shadow apply false + alias libs.plugins.cursegradle apply false + alias libs.plugins.minotaur apply false +} + +apply from: "https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/v2/main.gradle" diff --git a/1.20.4/gradle.properties b/1.20.4/gradle.properties new file mode 100755 index 0000000..b89463e --- /dev/null +++ b/1.20.4/gradle.properties @@ -0,0 +1,46 @@ +org.gradle.jvmargs=-Xmx4G +org.gradle.daemon=false +copyBuildJar=true + +# Mod Attributes +modId=tradingpost +modName=Trading Post +modVersion=20.4.1 +modAuthor=Fuzs +modDescription=Rule the village! Trade with every villager at once! +modLicense=MPL-2.0 +modSourceUrl=https://github.com/Fuzss/tradingpost +modIssueUrl=https://github.com/Fuzss/tradingpost/issues +modUpdateUrl=https://raw.githubusercontent.com/Fuzss/modresources/main/update/tradingpost.json +modMavenGroup=fuzs.tradingpost +# "MATCH_VERSION" for a mod required on both sides, "IGNORE_SERVER_VERSION" for a server only mod, "IGNORE_ALL_VERSION" for a client only mod +modForgeDisplayTest=MATCH_VERSION +# "*" for a mod loaded on both sides, "server" for a server only mod, "client" for a client only mod +modFabricEnvironment=* + +# Version Catalog +dependenciesVersionCatalog=1.20.4-v13 +dependenciesPuzzlesLibVersion=20.4.7 +dependenciesMinPuzzlesLibVersion=20.4.7 + +# Mod Publishing +projectReleaseType=release +projectCurseForgeId=539057 +projectModrinthId=8pcjMDgj + +dependenciesRequiredFabricCurseForge=fabric-api, forge-config-api-port-fabric, puzzles-lib +dependenciesRequiredNeoForgeCurseForge=puzzles-lib +dependenciesRequiredForgeCurseForge=forge-config-api-port-fabric, puzzles-lib +dependenciesRequiredFabricModrinth=fabric-api, forge-config-api-port, puzzles-lib +dependenciesRequiredNeoForgeModrinth=puzzles-lib +dependenciesRequiredForgeModrinth=forge-config-api-port, puzzles-lib + +dependenciesOptionalFabricCurseForge=config-menus-forge +dependenciesOptionalNeoForgeCurseForge=config-menus-forge +dependenciesOptionalForgeCurseForge=config-menus-forge +dependenciesOptionalFabricModrinth=forge-config-screens +dependenciesOptionalNeoForgeModrinth=forge-config-screens +dependenciesOptionalForgeModrinth=forge-config-screens + +#dependenciesEmbeddedFabricCurseForge=cardinal-components-api +#dependenciesEmbeddedFabricModrinth=cardinal-components-api diff --git a/1.20.4/gradle/wrapper/gradle-wrapper.jar b/1.20.4/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..943f0cb Binary files /dev/null and b/1.20.4/gradle/wrapper/gradle-wrapper.jar differ diff --git a/1.20.4/gradle/wrapper/gradle-wrapper.properties b/1.20.4/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..3499ded --- /dev/null +++ b/1.20.4/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/1.20.4/gradlew b/1.20.4/gradlew new file mode 100755 index 0000000..65dcd68 --- /dev/null +++ b/1.20.4/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# 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. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# 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 +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 + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# 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"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +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 ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +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 + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +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. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + 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=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +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" || "$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 + 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 + # 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 +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +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/1.20.4/gradlew.bat b/1.20.4/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/1.20.4/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +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. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +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. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +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! +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 + +:omega diff --git a/1.20.4/settings.gradle b/1.20.4/settings.gradle new file mode 100644 index 0000000..e401f79 --- /dev/null +++ b/1.20.4/settings.gradle @@ -0,0 +1,13 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { url "https://maven.architectury.dev/" } + maven { url "https://maven.fabricmc.net/" } + maven { url "https://maven.neoforged.net/releases/" } + maven { url "https://maven.minecraftforge.net/" } + } +} + +include("Common", "Fabric", "NeoForge", "Forge") + +apply from: "https://raw.githubusercontent.com/Fuzss/modresources/main/gradle/v2/settings.gradle" diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index eea0371..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,22 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog]. - -## [v4.2.0-1.19.2] - 2022-08-21 -- Compiled for Minecraft 1.19.2 -- Updated to Puzzles Lib v4.2.0 - -## [v4.0.1-1.19] - 2022-08-01 -### Fixed -- Fixed crash on opening trading post menu due to the mod using an outdated version of Puzzles Lib - -## [v4.1.0-1.19.1] - 2022-07-30 -- Compiled for Minecraft 1.19.1 -- Updated to Puzzles Lib v4.1.0 - -## [v4.0.0-1.19] - 2022-07-19 -- Ported to Minecraft 1.19 -- Split into multi-loader project - -[Keep a Changelog]: https://keepachangelog.com/en/1.0.0/ diff --git a/Common/build.gradle b/Common/build.gradle deleted file mode 100644 index 1ea86ea..0000000 --- a/Common/build.gradle +++ /dev/null @@ -1,140 +0,0 @@ -plugins { - id 'org.quiltmc.loom' version '0.12.+' -} - -archivesBaseName = rootProject.name -version = "v${modVersion}-${minecraftVersion}-Common" -group = modMavenGroup - -dependencies { - // Minecraft - minecraft "com.mojang:minecraft:${minecraftVersion}" - mappings loom.layered() { - officialMojangMappings() - parchment("org.parchmentmc.data:parchment-${minecraftVersion}:${parchmentMappingsVersion}@zip") - } - - // Mixin Dependencies - implementation 'org.ow2.asm:asm-tree:9.2' - implementation 'org.ow2.asm:asm-commons:9.2' - implementation 'org.ow2.asm:asm-util:9.2' - implementation 'org.spongepowered:mixin:0.8.5' - - // Config Dependencies - implementation 'com.electronwill.night-config:core:3.6.5' - implementation 'com.electronwill.night-config:toml:3.6.5' - - // Puzzles Lib - modImplementation "fuzs.puzzleslib:puzzleslib-common:${puzzlesVersion}" -} - -loom { - mixin { - // not sure if this is necessary for common... - defaultRefmapName = "${modId}.refmap.json" - // fix for java.lang.NoClassDefFoundError: org/objectweb/asm/tree/MethodNode - useLegacyMixinAp = false - } - - // this should hopeful prevent an empty run directory being generated in common during initial project setup - runs { - client { - client() - setConfigName("Common Client") - ideConfigGenerated(false) - runDir("../run") - } - server { - server() - setConfigName("Common Server") - ideConfigGenerated(false) - runDir("../run") - } - } -} - -processResources { - duplicatesStrategy DuplicatesStrategy.INCLUDE - - // this will ensure that this task is redone when a value changes - inputs.property "modId", "${modId}" - inputs.property "modVersion", "${modVersion}" - inputs.property "modGroup", project.group - inputs.property "modDescription", "${modDescription}" - inputs.property "packFormat", "${packFormat}" - - // replace stuff in fabric.mod.json and pack.mcmeta - filesMatching ('quilt.mod.json') { - expand ( - 'modId': "${modId}", - 'modVersion': "${modVersion}", - 'modGroup': project.group - ) - } - - // replace stuff in pack.mcmeta - filesMatching ('pack.mcmeta') { - expand ( - 'modDescription': "${modDescription}", - "packFormat": "${packFormat}" - ) - } -} - -publishing { - publications { - mavenJava (MavenPublication) { - artifactId = "${modId}-common" - version = modVersion - from components.java - pom { - name = "${modName} [Common]" - description = "${modDescription}" - url = "${modSourceUrl}" - scm { - url = "${modSourceUrl}" - connection = "${modSourceUrl}".replace("https", "scm:git:git").concat(".git") - developerConnection = "${modSourceUrl}".replace("https://github.com/", "scm:git:git@github.com:").concat(".git") - } - issueManagement { - system = 'github' - url = "${modIssueUrl}" - } - licenses { - license { - name = 'MPL-2' - url = 'https://www.mozilla.org/en-US/MPL/2.0/' - } - } - developers { - developer { - id = "${modAuthor}".toLowerCase() - name = "${modAuthor}" - } - } - } - afterEvaluate { - // exclude certain dependencies when publishing to maven - // from https://stackoverflow.com/a/50121790 - pom.withXml { - asNode().dependencies.dependency.each { dep -> - // use this approach to make excluding dependencies from Curse Maven more convenient - if ([].stream().anyMatch(mod -> "${dep.groupId.last().value().last()}:${dep.artifactId.last().value().last()}".startsWith(mod))) { - assert dep.parent().remove(dep) - } - } - } - } - } - } - repositories { - maven { - name = 'FuzsModResources' - url "file://" + project.hasProperty('modResources') ? "${project.findProperty('modResources')}/maven" : System.getenv('local_maven') - } - } -} - -signing { - sign publishing.publications.mavenJava -} diff --git a/Common/src/main/java/fuzs/tradingpost/init/ModRegistry.java b/Common/src/main/java/fuzs/tradingpost/init/ModRegistry.java deleted file mode 100644 index 83aec75..0000000 --- a/Common/src/main/java/fuzs/tradingpost/init/ModRegistry.java +++ /dev/null @@ -1,34 +0,0 @@ -package fuzs.tradingpost.init; - -import fuzs.puzzleslib.core.CoreServices; -import fuzs.puzzleslib.init.RegistryManager; -import fuzs.puzzleslib.init.RegistryReference; -import fuzs.puzzleslib.init.builder.ModBlockEntityTypeBuilder; -import fuzs.tradingpost.TradingPost; -import fuzs.tradingpost.world.inventory.TradingPostMenu; -import fuzs.tradingpost.world.level.block.TradingPostBlock; -import fuzs.tradingpost.world.level.block.entity.TradingPostBlockEntity; -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.inventory.MenuType; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.material.Material; - -public class ModRegistry { - private static final RegistryManager REGISTRY = CoreServices.FACTORIES.registration(TradingPost.MOD_ID); - public static final RegistryReference TRADING_POST_BLOCK = REGISTRY.registerBlockWithItem("trading_post", () -> new TradingPostBlock(BlockBehaviour.Properties.of(Material.WOOD).strength(2.5F).sound(SoundType.WOOD)), CreativeModeTab.TAB_DECORATIONS); - public static final RegistryReference> TRADING_POST_BLOCK_ENTITY_TYPE = REGISTRY.registerBlockEntityTypeBuilder("trading_post", () -> ModBlockEntityTypeBuilder.of(TradingPostBlockEntity::new, TRADING_POST_BLOCK.get())); - public static final RegistryReference> TRADING_POST_MENU_TYPE = REGISTRY.registerMenuTypeSupplier("trading_post", () -> TradingPostMenu::new); - - public static final TagKey> BLACKLISTED_TRADERS_TAG = TagKey.create(Registry.ENTITY_TYPE_REGISTRY, new ResourceLocation(TradingPost.MOD_ID, "blacklisted_traders")); - - public static void touch() { - - } -} diff --git a/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/MerchantScreenAccessor.java b/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/MerchantScreenAccessor.java deleted file mode 100644 index fc13489..0000000 --- a/Common/src/main/java/fuzs/tradingpost/mixin/client/accessor/MerchantScreenAccessor.java +++ /dev/null @@ -1,34 +0,0 @@ -package fuzs.tradingpost.mixin.client.accessor; - -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.gui.screens.inventory.MerchantScreen; -import net.minecraft.world.item.trading.MerchantOffer; -import net.minecraft.world.item.trading.MerchantOffers; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(MerchantScreen.class) -public interface MerchantScreenAccessor { - - @Accessor - int getShopItem(); - - @Accessor - void setShopItem(int shopItem); - - @Accessor - int getScrollOff(); - - @Accessor - void setScrollOff(int scrollOff); - - @Invoker - void callRenderScroller(PoseStack matrixStack, int width, int height, MerchantOffers offers); - - @Invoker - void callRenderButtonArrows(PoseStack matrixStack, MerchantOffer offer, int width, int height); - - @Invoker - void callRenderProgressBar(PoseStack matrixStack, int width, int height, MerchantOffer activeOffer); -} diff --git a/Common/src/main/resources/quilt.mod.json b/Common/src/main/resources/quilt.mod.json deleted file mode 100644 index 878577d..0000000 --- a/Common/src/main/resources/quilt.mod.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "schema_version": 1, - "quilt_loader": { - "group": "${modGroup}", - "id": "${modId}", - "version": "${modVersion}" - } -} diff --git a/Fabric/build.gradle b/Fabric/build.gradle deleted file mode 100644 index 74674f2..0000000 --- a/Fabric/build.gradle +++ /dev/null @@ -1,270 +0,0 @@ -plugins { - id 'fabric-loom' version '0.12-SNAPSHOT' - id 'io.github.juuxel.loom-quiltflower' version '1.7.1' - // this depends on an older version of guava, which loom is incompatible with, so make sure to apply this plugin after loom - // haven't found a proper way to manage plugin dependencies otherwise - id 'me.hypherionmc.cursegradle' version '2.+' - // cannot apply this in the base build.gradle as it'll be the same for all subprojects, only one configuration will work - id 'com.modrinth.minotaur' version '2.+' -} - -archivesBaseName = rootProject.name -version = "v${modVersion}-${minecraftVersion}-Fabric" -group = modMavenGroup - -repositories { - maven { - name = "Modmuss" - url = "https://maven.modmuss50.me/" - } - maven { - name = 'Terraformers' - url = "https://maven.terraformersmc.com/" - } - maven { - name = "ladysnake" - url = 'https://ladysnake.jfrog.io/artifactory/mods' - } - maven { - name = "jamieswhiteshirt" - url = "https://maven.jamieswhiteshirt.com/libs-release/" - } -} - -dependencies { - // Include Common Project - compileOnly project(":Common") - - // Minecraft - minecraft "com.mojang:minecraft:${minecraftVersion}" - mappings loom.layered() { - officialMojangMappings() - parchment("org.parchmentmc.data:parchment-${minecraftVersion}:${parchmentMappingsVersion}@zip") - } - - // Fabric - modImplementation "net.fabricmc:fabric-loader:${fabricVersion}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${fabricApiVersion}" - - // Forge Configs - modImplementation "net.minecraftforge:forgeconfigapiport-fabric:4.2.0" - - // Mod Menu - modRuntimeOnly "com.terraformersmc:modmenu:4.0.6" - - // Puzzles Lib - modImplementation "fuzs.puzzleslib:puzzleslib-fabric:${puzzlesVersion}" -} - -loom { - mixin.defaultRefmapName = "${modId}.refmap.json" - - runs { - client { - client() - setConfigName("Fabric Client") - ideConfigGenerated(true) - runDir("../run") - vmArg '-Dmixin.debug.export=true' - } - server { - server() - setConfigName("Fabric Server") - ideConfigGenerated(true) - runDir("../run") - vmArg '-Dmixin.debug.export=true' - } - } -} - -processResources { - from project(":Common").sourceSets.main.resources - // we need to have this in common so that in a non-production environment the common jar is correctly deobfuscated - exclude("**/quilt.mod.json") - - duplicatesStrategy DuplicatesStrategy.INCLUDE - - // this will ensure that this task is redone when a value changes - inputs.property "modId", "${modId}" - inputs.property "modName", "${modName}" - inputs.property "modVersion", "${modVersion}" - inputs.property "modDescription", "${modDescription}" - inputs.property "modGroup", project.group - inputs.property "modPageUrl", "${modSourceUrl}" - inputs.property "modIssueUrl", "${modIssueUrl}" - inputs.property "modAuthor", "${modAuthor}" - inputs.property "minFabricVersion", "${minFabricVersion}" - inputs.property "minFabricApiVersion", "${minFabricApiVersion}" - inputs.property "minMinecraftVersion", "${minMinecraftVersion}" - inputs.property "nextMinecraftVersion", rootProject.getNextVersion("${minMinecraftVersion}") - inputs.property "minPuzzlesVersion", "${minPuzzlesVersion}" - inputs.property "packFormat", "${packFormat}" - inputs.property "mainEntryPoint", "${project.group}.${rootProject.name}Fabric" - inputs.property "clientEntryPoint", "${project.group}.client.${rootProject.name}FabricClient" - inputs.property "modFabricEnvironment", "${modFabricEnvironment}" - - // replace stuff in fabric.mod.json and pack.mcmeta - filesMatching ('fabric.mod.json') { - expand ( - 'modId': "${modId}", - 'modName': "${modName}", - 'modVersion': "${modVersion}", - 'modDescription': "${modDescription}", - 'modGroup': project.group, - 'modPageUrl': "${modSourceUrl}", - 'modIssueUrl': "${modIssueUrl}", - 'modAuthor': "${modAuthor}", - 'minFabricVersion': "${minFabricVersion}", - 'minFabricApiVersion': "${minFabricApiVersion}", - 'minMinecraftVersion': "${minMinecraftVersion}", - "nextMinecraftVersion": rootProject.getNextVersion("${minMinecraftVersion}"), - "minPuzzlesVersion": "${minPuzzlesVersion}", - "mainEntryPoint": "${project.group}.${rootProject.name}Fabric", - "clientEntryPoint": "${project.group}.client.${rootProject.name}FabricClient", - "modFabricEnvironment": "${modFabricEnvironment}" - ) - } - - filesMatching ('pack.mcmeta') { - expand ( - 'modDescription': "${modDescription}", - "packFormat": "${packFormat}" - ) - } -} - -compileJava { - source project(":Common").sourceSets.main.allSource -} - -sourcesJar { - from project(":Common").sourceSets.main.allJava -} - -javadoc { - source project(":Common").sourceSets.main.allJava -} - -publishing { - publications { - mavenJava (MavenPublication) { - artifactId = "${modId}-fabric" - version = modVersion - from components.java - pom { - name = "${modName} [Fabric]" - description = "${modDescription}" - url = "${modSourceUrl}" - scm { - url = "${modSourceUrl}" - connection = "${modSourceUrl}".replace("https", "scm:git:git").concat(".git") - developerConnection = "${modSourceUrl}".replace("https://github.com/", "scm:git:git@github.com:").concat(".git") - } - issueManagement { - system = 'github' - url = "${modIssueUrl}" - } - licenses { - license { - name = 'MPL-2' - url = 'https://www.mozilla.org/en-US/MPL/2.0/' - } - } - developers { - developer { - id = "${modAuthor}".toLowerCase() - name = "${modAuthor}" - } - } - } - afterEvaluate { - // exclude certain dependencies when publishing to maven - // from https://stackoverflow.com/a/50121790 - pom.withXml { - asNode().dependencies.dependency.each { dep -> - // use this approach to make excluding dependencies from Curse Maven more convenient - if (["com.terraformersmc:modmenu"].stream().anyMatch(mod -> "${dep.groupId.last().value().last()}:${dep.artifactId.last().value().last()}".startsWith(mod))) { - assert dep.parent().remove(dep) - } - } - } - } - } - } - repositories { - maven { - name = 'FuzsModResources' - url "file://" + project.hasProperty('modResources') ? "${project.findProperty('modResources')}/maven" : System.getenv('local_maven') - } - } -} - -signing { - sign publishing.publications.mavenJava -} - -curseforge { - if (!file('../CHANGELOG.md').canRead()) { throw new FileNotFoundException("Could not read changelog file") } - apiKey = project.hasProperty('curseApiToken') ? project.findProperty('curseApiToken') : '' - project { - id = projectCurseId - changelogType = 'markdown' - changelog = file('../CHANGELOG.md') - releaseType = projectReleaseType - addGameVersion 'Fabric' - projectGameVersions.split(",").each { - addGameVersion it.trim() - } - mainArtifact(remapJar) { - displayName = "[FABRIC] [${minecraftVersion}] ${rootProject.name}-v${modVersion}" - relations { - requiredDependency 'fabric-api' - requiredDependency 'forge-config-api-port-fabric' - requiredDependency 'puzzles-lib' - } - } - addArtifact sourcesJar - } - options { -// debug = true - javaVersionAutoDetect = false - forgeGradleIntegration = false - } -} - -modrinth { - if (!file('../CHANGELOG.md').canRead()) { throw new FileNotFoundException("Could not read changelog file") } - token = project.hasProperty('modrinthApiToken') ? project.findProperty('modrinthApiToken') : '' - projectId = projectModrinthId - versionNumber = project.version - versionName = "[FABRIC] [${minecraftVersion}] ${rootProject.name}-v${modVersion}" - changelog = file('../CHANGELOG.md').text - versionType = projectReleaseType - uploadFile = remapJar // This is the java jar task - projectGameVersions.split(",").each { - gameVersions.add it.trim() - } - loaders.add 'fabric' - additionalFiles.add file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}-sources.jar") - dependencies { - required.project 'fabric-api' - required.project 'forge-config-api-port' - required.project 'puzzles-lib' - } -// debugMode = true -} - -import groovy.json.* - -task copyJarToDir(type: Copy) { - onlyIf { project.hasProperty('buildJarOutputDir') && project.hasProperty('uniqueBuildNumber') } - if (project.findProperty('copyBuildJar').toBoolean()) { - from remapJar - into project.findProperty('buildJarOutputDir') - // add build number to be able to distinguish jars when testing thorough official launcher - // build number is stored in global gradle.properties - rename { fileName -> fileName.replace("v${modVersion}", "v${modVersion}.${uniqueBuildNumber}") } - } -} - -build.finalizedBy project.tasks.copyJarToDir, rootProject.tasks.incrementBuildNumber diff --git a/Forge/build.gradle b/Forge/build.gradle deleted file mode 100644 index d34bd7c..0000000 --- a/Forge/build.gradle +++ /dev/null @@ -1,373 +0,0 @@ -buildscript { - repositories { - mavenCentral() - maven { url = 'https://maven.minecraftforge.net' } - maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true - classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' - classpath group: 'org.parchmentmc', name: 'librarian', version: '1.+' - } -} - -plugins { - id 'me.hypherionmc.cursegradle' version '2.+' - // cannot apply this in the base build.gradle as it'll be the same for all subprojects, only one configuration will work - id 'com.modrinth.minotaur' version '2.+' -} - -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'eclipse' -apply plugin: 'org.spongepowered.mixin' -apply plugin: 'org.parchmentmc.librarian.forgegradle' - -archivesBaseName = rootProject.name -version = "v${modVersion}-${minecraftVersion}-Forge" -group = modMavenGroup - -minecraft { - mappings channel: 'parchment', version: "${parchmentMappingsVersion}-${minecraftVersion}" -// mappings channel: 'official', version: "${minecraftVersion}" - - runs { - client { - workingDirectory project.file('../run') - jvmArgs '-Xms1G', '-Xmx4G' - property 'fml.earlyprogresswindow', 'false' - if (project(":Common").file("src/main/resources/${modId}.common.mixins.json").exists()) { - arg "-mixin.config=${modId}.common.mixins.json" - } - if (project.file("src/main/resources/${modId}.forge.mixins.json").exists()) { - arg "-mixin.config=${modId}.forge.mixins.json" - } - ideaModule "${rootProject.name}.${project.name}.main" - taskName 'Client' - property 'terminal.ansi', 'true' - property 'mixin.env.remapRefMap', 'true' - property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" - property 'mixin.debug.export', 'true' - mods { - modClientRun { - source sourceSets.main - source project(":Common").sourceSets.main - } - } - } - - server { - workingDirectory project.file('../run') - jvmArgs '-Xms1G', '-Xmx4G' - arg 'nogui' - if (project(":Common").file("src/main/resources/${modId}.common.mixins.json").exists()) { - arg "-mixin.config=${modId}.common.mixins.json" - } - if (project.file("src/main/resources/${modId}.forge.mixins.json").exists()) { - arg "-mixin.config=${modId}.forge.mixins.json" - } - ideaModule "${rootProject.name}.${project.name}.main" - taskName 'Server' - property 'terminal.ansi', 'true' - property 'mixin.env.remapRefMap', 'true' - property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" - property 'mixin.debug.export', 'true' - mods { - modServerRun { - source sourceSets.main - source project(":Common").sourceSets.main - } - } - } - - data { - workingDirectory project.file('../run') - jvmArgs '-Xms1G', '-Xmx4G' - if (project(":Common").file("src/main/resources/${modId}.common.mixins.json").exists()) { - arg "-mixin.config=${modId}.common.mixins.json" - } - if (project.file("src/main/resources/${modId}.forge.mixins.json").exists()) { - arg "-mixin.config=${modId}.forge.mixins.json" - } - args '--mod', modId, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - ideaModule "${rootProject.name}.${project.name}.main" - taskName 'Data' - property 'terminal.ansi', 'true' - property 'mixin.env.remapRefMap', 'true' - property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" - property 'mixin.debug.export', 'true' - mods { - modDataRun { - source sourceSets.main - source project(":Common").sourceSets.main - } - } - } - } -} - -dependencies { - // Include Common Project - compileOnly project(":Common") - - // Minecraft - minecraft "net.minecraftforge:forge:${forgeVersion}" - annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' - - // Quality of Life Mods - runtimeOnly fg.deobf("curse.maven:catalogue-459701:3873264") - runtimeOnly fg.deobf("fuzs.bettermodsbutton:bettermodsbutton-forge:4.2.0") -// runtimeOnly fg.deobf("curse.maven:configmenusforge-544048:3822820") -// runtimeOnly fg.deobf("curse.maven:configured-457570:3903908") - - // Puzzles Lib - implementation fg.deobf("fuzs.puzzleslib:puzzleslib-forge:${puzzlesVersion}") -} - -mixin { - if (project.file("src/main/resources/${modId}.forge.mixins.json").exists() || project(":Common").file("src/main/resources/${modId}.common.mixins.json").exists()) { - add project(":Common").sourceSets.main, "${modId}.refmap.json" - } - if (project(":Common").file("src/main/resources/${modId}.common.mixins.json").exists()) { - config "${modId}.common.mixins.json" - } - if (project.file("src/main/resources/${modId}.forge.mixins.json").exists()) { - config "${modId}.forge.mixins.json" - } -} - -processResources { - from project(":Common").sourceSets.main.resources - // we need to have this in common so that in a non-production environment the common jar is correctly deobfuscated - exclude("**/quilt.mod.json") - - duplicatesStrategy DuplicatesStrategy.INCLUDE - - // this will ensure that this task is redone when a value changes - inputs.property "modId", "${modId}" - inputs.property "modName", "${modName}" - inputs.property "modVersion", "${modVersion}" - inputs.property "modDescription", "${modDescription}" - inputs.property "modGroup", project.group - inputs.property "modPageUrl", "${modSourceUrl}" - inputs.property "modUpdateUrl", "${modUpdateUrl}" - inputs.property "modIssueUrl", "${modIssueUrl}" - inputs.property "modAuthor", "${modAuthor}" - inputs.property "minFMLVersion", "${minForgeVersion}".replaceAll("\\..*", "") - inputs.property "minForgeVersion", "${minForgeVersion}" - inputs.property "minMinecraftVersion", "${minMinecraftVersion}" - inputs.property "nextMinecraftVersion", rootProject.getNextVersion("${minMinecraftVersion}") - inputs.property "minPuzzlesVersion", "${minPuzzlesVersion}" - inputs.property "packFormat", "${packFormat}" - inputs.property "modForgeDisplayTest", "${modForgeDisplayTest}" - - // replace stuff in mods.toml and pack.mcmeta - filesMatching ('META-INF/mods.toml') { - expand ( - 'modId': "${modId}", - 'modName': "${modName}", - 'modVersion': "${modVersion}", - 'modDescription': "${modDescription}", - 'modGroup': project.group, - 'modPageUrl': "${modSourceUrl}", - 'modUpdateUrl': "${modUpdateUrl}", - 'modIssueUrl': "${modIssueUrl}", - 'modAuthor': "${modAuthor}", - 'minFMLVersion': "${minForgeVersion}".replaceAll("\\..*", ""), - 'minForgeVersion': "${minForgeVersion}", - 'minMinecraftVersion': "${minMinecraftVersion}", - 'nextMinecraftVersion': rootProject.getNextVersion("${minMinecraftVersion}"), - 'minPuzzlesVersion': "${minPuzzlesVersion}", - 'modForgeDisplayTest': "${modForgeDisplayTest}" - ) - } - - filesMatching ('pack.mcmeta') { - expand ( - 'modDescription': "${modDescription}", - "packFormat": "${packFormat}" - ) - } -} - -compileJava { - source project(":Common").sourceSets.main.allSource -} - -sourcesJar { - from project(":Common").sourceSets.main.allJava -} - -javadoc { - source project(":Common").sourceSets.main.allJava -} - -jar.finalizedBy('reobfJar') - -publishing { - publications { - mavenJava (MavenPublication) { - artifactId = "${modId}-forge" - version = modVersion - from components.java - // strip Forge dependency from POM - fg.component(it) - pom { - name = "${modName} [Forge]" - description = "${modDescription}" - url = "${modSourceUrl}" - scm { - url = "${modSourceUrl}" - connection = "${modSourceUrl}".replace("https", "scm:git:git").concat(".git") - developerConnection = "${modSourceUrl}".replace("https://github.com/", "scm:git:git@github.com:").concat(".git") - } - issueManagement { - system = 'github' - url = "${modIssueUrl}" - } - licenses { - license { - name = 'MPL-2' - url = 'https://www.mozilla.org/en-US/MPL/2.0/' - } - } - developers { - developer { - id = "${modAuthor}".toLowerCase() - name = "${modAuthor}" - } - } - } - afterEvaluate { - // exclude certain dependencies when publishing to maven - // from https://stackoverflow.com/a/50121790 - pom.withXml { - asNode().dependencies.dependency.each { dep -> - // Forge is weird as a dependency, so skip it along with quality of life mods - // use this approach to make excluding dependencies from Curse Maven more convenient - if (["curse.maven:catalogue", "curse.maven:configured", "curse.maven:configmenusforge", "fuzs.bettermodsbutton:bettermodsbutton-forge"].stream().anyMatch(mod -> "${dep.groupId.last().value().last()}:${dep.artifactId.last().value().last()}".startsWith(mod))) { - assert dep.parent().remove(dep) - } - } - } - } - } - } - repositories { - maven { - name = 'FuzsModResources' - url "file://" + project.hasProperty('modResources') ? "${project.findProperty('modResources')}/maven" : System.getenv('local_maven') - } - } -} - -signing { - sign publishing.publications.mavenJava -} - -task signJar(type: net.minecraftforge.gradle.common.tasks.SignJar, dependsOn: jar) { - onlyIf { project.hasProperty('keyStore') } - keyStore = project.findProperty('keyStore') - alias = project.findProperty('keyStoreAlias') - storePass = project.findProperty('keyStorePass') - keyPass = project.findProperty('keyStoreKeyPass') - inputFile = outputFile = jar.archivePath -} - -jar.finalizedBy 'signJar' -signJar.mustRunAfter 'reobfJar' - -curseforge { - if (!file('../CHANGELOG.md').canRead()) { throw new FileNotFoundException("Could not read changelog file") } - apiKey = project.hasProperty('curseApiToken') ? project.findProperty('curseApiToken') : '' - project { - id = projectCurseId - changelogType = 'markdown' - changelog = file('../CHANGELOG.md') - releaseType = projectReleaseType - addGameVersion 'Forge' - projectGameVersions.split(",").each { - addGameVersion it.trim() - } - mainArtifact(jar) { - displayName = "[FORGE] [${minecraftVersion}] ${rootProject.name}-v${modVersion}" - relations { - requiredDependency 'puzzles-lib' - } - } - addArtifact sourcesJar - } - options { -// debug = true - javaVersionAutoDetect = false - forgeGradleIntegration = false - } -} - -modrinth { - if (!file('../CHANGELOG.md').canRead()) { throw new FileNotFoundException("Could not read changelog file") } - token = project.hasProperty('modrinthApiToken') ? project.findProperty('modrinthApiToken') : '' - projectId = projectModrinthId - versionNumber = project.version - versionName = "[FORGE] [${minecraftVersion}] ${rootProject.name}-v${modVersion}" - changelog = file('../CHANGELOG.md').text - versionType = projectReleaseType - uploadFile = jar // This is the java jar task - projectGameVersions.split(",").each { - gameVersions.add it.trim() - } - loaders.add 'forge' - additionalFiles.add file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}-sources.jar") - dependencies { - required.project 'puzzles-lib' - } -// debugMode = true -} - -import groovy.json.* - -task copyJarToDir(type: Copy) { - onlyIf { project.hasProperty('buildJarOutputDir') && project.hasProperty('uniqueBuildNumber') } - if (project.findProperty('copyBuildJar').toBoolean()) { - // shortcut for jar.outputs.files - from jar - into project.findProperty('buildJarOutputDir') - // add build number to be able to distinguish jars when testing thorough official launcher - // build number is stored in global gradle.properties - rename { fileName -> fileName.replace("v${modVersion}", "v${modVersion}.${uniqueBuildNumber}") } - } -} - -task refreshUpdateJson { - onlyIf { project.hasProperty('modResources') } - doLast { - def updateFile = file(project.findProperty('modResources').concat(File.separator).concat('update').concat(File.separator).concat("${modId}").concat('.json')) - def updateJson - if (updateFile.exists() && updateFile.canRead()) { - updateJson = new JsonSlurper().parseText(updateFile.text) - "${projectGameVersions}".replaceAll(" ", "").split(",").each { version -> - updateJson['promos']["${version}-latest"] = "${modVersion}" - // alpha and beta releases will contain 'a' or 'b' char respectively, don't update recommended for those - if ("${modVersion}".matches("[^a-zA-Z]+")) { - updateJson['promos']["${version}-recommended"] = "${modVersion}" - } - } - } else { - def builder = new JsonBuilder() - updateJson = builder { - homepage "${modSourceUrl}" - promos { "${projectGameVersions}".replaceAll(" ", "").split(",").each { version -> - "${version}-latest" "${modVersion}" - // alpha and beta releases will contain 'a' or 'b' char respectively, don't update recommended for those - if ("${modVersion}".matches("[^a-zA-Z]+")) { - "${version}-recommended" "${modVersion}" - } - } } - } - } - def output = new JsonOutput() - updateFile.write(output.prettyPrint(output.toJson(updateJson))) - } -} - -build.finalizedBy project.tasks.copyJarToDir, rootProject.tasks.incrementBuildNumber -[tasks.modrinth, tasks.curseforge].each {it.finalizedBy project.tasks.refreshUpdateJson} diff --git a/LICENSE-ASSETS.md b/LICENSE-ASSETS.md new file mode 100644 index 0000000..79fd8f1 --- /dev/null +++ b/LICENSE-ASSETS.md @@ -0,0 +1 @@ +Copyright (c) 2023 @heyitsfuzs. All Rights Reserved. \ No newline at end of file diff --git a/LICENSE b/LICENSE.md similarity index 100% rename from LICENSE rename to LICENSE.md diff --git a/README.md b/README.md index 8b83cd2..0998b84 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ A Minecraft mod. Downloads can be found on [CurseForge](https://www.curseforge.com/members/fuzs_/projects) and [Modrinth](https://modrinth.com/user/Fuzs). -![](https://i.imgur.com/UzgNFIB.png) +![](https://raw.githubusercontent.com/Fuzss/modresources/main/pages/data/tradingpost/banner.png) diff --git a/build.gradle b/build.gradle deleted file mode 100644 index f8ef596..0000000 --- a/build.gradle +++ /dev/null @@ -1,114 +0,0 @@ -apply from: './gradle/tasks.gradle' - -subprojects { - apply plugin: 'java' - apply plugin: 'java-library' - apply plugin: 'maven-publish' - apply plugin: 'signing' - - java.toolchain.languageVersion = JavaLanguageVersion.of(17) - java.withSourcesJar() - java.withJavadocJar() - // silence missing javadoc comments, we just don't care - javadoc.options.addStringOption('Xdoclint:none', '-quiet') - - repositories { - mavenCentral() - mavenLocal() - maven { - name = 'Sponge / Mixin' - url = 'https://repo.spongepowered.org/repository/maven-public/' - } - maven { - name = 'Jared' - url = 'https://maven.blamejared.com/' - } - maven { - name = 'Jitpack' - url = 'https://jitpack.io' - } - maven { - name = 'Shedaniel' - url = 'https://maven.shedaniel.me/' - } - maven { - name = 'Parchment' - url = 'https://maven.parchmentmc.org' - } - maven { - name = 'Curse Maven' - url = 'https://cursemaven.com' - } - maven { - name = "Fuzs Mod Resources" - url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" - } - flatDir { - dirs 'libs' - } - } - - tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - options.encoding = 'UTF-8' - options.release = 17 - } - - tasks.withType(Jar).configureEach { - from rootProject.file("LICENSE") - from rootProject.file("CHANGELOG.md") - manifest { - attributes([ - "Specification-Title" : modName, - 'Specification-Version' : modVersion, - "Specification-Vendor" : modAuthor, - 'Implementation-Title' : modName, - 'Implementation-Version' : modVersion, - 'Implementation-Vendor' : modAuthor, - 'Implementation-Timestamp' : new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - 'Implementation-Timestamp-Milli' : System.currentTimeMillis(), - 'Implementation-URL' : modSourceUrl, - 'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", - 'Built-On-Minecraft' : minecraftVersion - ]) - } - group 'jar' - } - - tasks.withType(GenerateModuleMetadata) { - // 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. - enabled = false - } -} - -import groovy.json.* -import java.util.regex.Pattern - -println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) - -task incrementBuildNumber { - onlyIf { project.hasProperty('uniqueBuildNumber') } - doLast { - def propertiesName = 'gradle.properties' - // build number is stored in global gradle.properties - def propertiesFile = new File(project.gradle.gradleUserHomeDir, propertiesName) - if (!propertiesFile.canRead()) { throw new FileNotFoundException("Could not read file ".concat(propertiesName)) } - def buildNumberMatcher = Pattern.compile("uniqueBuildNumber=(\\d+)").matcher(propertiesFile.getText()) - buildNumberMatcher.find() - def versionCode = Integer.parseInt(buildNumberMatcher.group(1)) - def propertiesContent = buildNumberMatcher.replaceAll("uniqueBuildNumber=" + ++versionCode) - propertiesFile.write(propertiesContent) - } -} - -def static getNextVersion(String puzzlesVersion) { - def puzzlesVersionMatcher = Pattern.compile("(\\d+\\.\\d+)").matcher(puzzlesVersion) - puzzlesVersionMatcher.find() - def currentVersion = puzzlesVersionMatcher.group(1) - return currentVersion.substring(0, currentVersion.indexOf(".") + 1).concat(String.valueOf(Integer.parseInt(currentVersion.substring(currentVersion.indexOf(".") + 1, currentVersion.size())) + 1)) -} diff --git a/gradle/tasks.gradle b/gradle/tasks.gradle deleted file mode 100644 index dbd3dc0..0000000 --- a/gradle/tasks.gradle +++ /dev/null @@ -1,232 +0,0 @@ -task forgeClean(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean' - ] -} - -task fabricClean(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Fabric:clean' - ] -} - -task allClean(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean', - ':Fabric:clean' - ] -} - -task forgeBuild(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean', - ':Forge:build' - ] -} - -task fabricBuild(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Fabric:clean', - ':Fabric:build' - ] -} - -task allBuild(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean', - ':Fabric:clean', - ':Common:build', - ':Forge:build', - ':Fabric:build' - ] -} - -task commonPublish(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Common:publishMavenJavaPublicationToFuzsModResourcesRepository' - ] -} - -task forgePublish(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean', - ':Forge:publishMavenJavaPublicationToFuzsModResourcesRepository' - ] -} - -task fabricPublish(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Fabric:clean', - ':Fabric:publishMavenJavaPublicationToFuzsModResourcesRepository' - ] -} - -task allPublish(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean', - ':Fabric:clean', - ':Common:publishMavenJavaPublicationToFuzsModResourcesRepository', - ':Forge:publishMavenJavaPublicationToFuzsModResourcesRepository', - ':Fabric:publishMavenJavaPublicationToFuzsModResourcesRepository' - ] -} - -task forgeUploadCurseForge(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean', - ':Forge:curseforge' - ] -} - -task fabricUploadCurseForge(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Fabric:clean', - ':Fabric:curseforge' - ] -} - -task allUploadCurseForge(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean', - ':Fabric:clean', - ':Forge:curseforge', - ':Fabric:curseforge' - ] -} - -task forgeUploadModrinth(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean', - ':Forge:modrinth' - ] -} - -task fabricUploadModrinth(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Fabric:clean', - ':Fabric:modrinth' - ] -} - -task allUploadModrinth(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean', - ':Fabric:clean', - ':Forge:modrinth', - ':Fabric:modrinth' - ] -} - -task forgeUploadEverywhere(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean', - ':Forge:curseforge', - ':Forge:modrinth' - ] -} - -task fabricUploadEverywhere(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Fabric:clean', - ':Fabric:curseforge', - ':Fabric:modrinth' - ] -} - -task allUploadEverywhere(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:clean', - ':Forge:clean', - ':Fabric:clean', - ':Forge:curseforge', - ':Forge:modrinth', - ':Fabric:curseforge', - ':Fabric:modrinth' - ] -} - -task commonGenSources(type: GradleBuild) { - group = '_main' - tasks = [ - ':Common:genSourcesWithQuiltflower' - ] -} - -task forgeGenRuns(type: GradleBuild) { - group = '_main' - tasks = [ - ':Forge:genIntellijRuns' - ] -} - -task fabricGenSources(type: GradleBuild) { - group = '_main' - tasks = [ - ':Fabric:genSourcesWithQuiltflower' - ] -} - -task forgeClient(type: GradleBuild) { - group = '_main' - tasks = [ - ':Forge:runClient' - ] -} - -task fabricClient(type: GradleBuild) { - group = '_main' - tasks = [ - ':Fabric:runClient' - ] -} - -task forgeServer(type: GradleBuild) { - group = '_main' - tasks = [ - ':Forge:runServer' - ] -} - -task fabricServer(type: GradleBuild) { - group = '_main' - tasks = [ - ':Fabric:runServer' - ] -} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 41d9927..0000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/run/config/modmenu.json b/run/config/modmenu.json deleted file mode 100644 index c9e0984..0000000 --- a/run/config/modmenu.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "sorting": "ascending", - "count_libraries": true, - "compact_list": false, - "count_children": true, - "mods_button_style": "classic", - "count_hidden_mods": true, - "mod_count_location": "title_screen_and_mods_button", - "hide_mod_links": false, - "show_libraries": false, - "hide_mod_license": false, - "hide_badges": false, - "hide_mod_credits": false, - "easter_eggs": true, - "modify_title_screen": true, - "modify_game_menu": true, - "hide_config_buttons": false, - "hidden_mods": [] -} \ No newline at end of file diff --git a/run/options.txt b/run/options.txt deleted file mode 100644 index b9cbf63..0000000 --- a/run/options.txt +++ /dev/null @@ -1,130 +0,0 @@ -version:3105 -autoJump:false -autoSuggestions:true -chatColors:true -chatLinks:true -chatLinksPrompt:true -enableVsync:true -entityShadows:true -forceUnicodeFont:false -discrete_mouse_scroll:false -invertYMouse:false -realmsNotifications:true -reducedDebugInfo:false -showSubtitles:false -directionalAudio:false -touchscreen:false -fullscreen:false -bobView:true -toggleCrouch:false -toggleSprint:false -darkMojangStudiosBackground:false -hideLightningFlashes:false -mouseSensitivity:0.5 -fov:0.0 -screenEffectScale:1.0 -fovEffectScale:1.0 -darknessEffectScale:1.0 -gamma:0.5 -renderDistance:12 -simulationDistance:12 -entityDistanceScaling:1.0 -guiScale:0 -particles:0 -maxFps:120 -graphicsMode:1 -ao:2 -prioritizeChunkUpdates:0 -biomeBlendRadius:2 -renderClouds:"true" -resourcePacks:["Fabric Mods"] -incompatibleResourcePacks:[] -lastServer: -lang:en_us -soundDevice:"" -chatVisibility:0 -chatOpacity:1.0 -chatLineSpacing:0.0 -textBackgroundOpacity:0.5 -backgroundForChatOnly:true -hideServerAddress:false -advancedItemTooltips:false -pauseOnLostFocus:true -overrideWidth:0 -overrideHeight:0 -heldItemTooltips:true -chatHeightFocused:1.0 -chatDelay:0.0 -chatHeightUnfocused:0.4375 -chatScale:1.0 -chatWidth:1.0 -mipmapLevels:4 -useNativeTransport:true -mainHand:"right" -attackIndicator:1 -narrator:0 -tutorialStep:none -mouseWheelSensitivity:1.0 -rawMouseInput:true -glDebugVerbosity:1 -skipMultiplayerWarning:false -skipRealms32bitWarning:false -hideMatchedNames:true -joinedFirstServer:false -hideBundleTutorial:false -syncChunkWrites:false -showAutosaveIndicator:true -allowServerListing:true -chatPreview:true -onlyShowSecureChat:false -key_key.attack:key.mouse.left -key_key.use:key.mouse.right -key_key.forward:key.keyboard.w -key_key.left:key.keyboard.a -key_key.back:key.keyboard.s -key_key.right:key.keyboard.d -key_key.jump:key.keyboard.space -key_key.sneak:key.keyboard.left.shift -key_key.sprint:key.keyboard.left.control -key_key.drop:key.keyboard.q -key_key.inventory:key.keyboard.e -key_key.chat:key.keyboard.t -key_key.playerlist:key.keyboard.tab -key_key.pickItem:key.mouse.middle -key_key.command:key.keyboard.slash -key_key.socialInteractions:key.keyboard.p -key_key.screenshot:key.keyboard.f2 -key_key.togglePerspective:key.keyboard.f5 -key_key.smoothCamera:key.keyboard.unknown -key_key.fullscreen:key.keyboard.f11 -key_key.spectatorOutlines:key.keyboard.unknown -key_key.swapOffhand:key.keyboard.f -key_key.saveToolbarActivator:key.keyboard.c -key_key.loadToolbarActivator:key.keyboard.x -key_key.advancements:key.keyboard.l -key_key.hotbar.1:key.keyboard.1 -key_key.hotbar.2:key.keyboard.2 -key_key.hotbar.3:key.keyboard.3 -key_key.hotbar.4:key.keyboard.4 -key_key.hotbar.5:key.keyboard.5 -key_key.hotbar.6:key.keyboard.6 -key_key.hotbar.7:key.keyboard.7 -key_key.hotbar.8:key.keyboard.8 -key_key.hotbar.9:key.keyboard.9 -soundCategory_master:0.102649 -soundCategory_music:0.0 -soundCategory_record:1.0 -soundCategory_weather:0.056338027 -soundCategory_block:1.0 -soundCategory_hostile:1.0 -soundCategory_neutral:1.0 -soundCategory_player:1.0 -soundCategory_ambient:1.0 -soundCategory_voice:1.0 -modelPart_cape:true -modelPart_jacket:true -modelPart_left_sleeve:true -modelPart_right_sleeve:true -modelPart_left_pants_leg:true -modelPart_right_pants_leg:true -modelPart_hat:true diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 429f534..0000000 --- a/settings.gradle +++ /dev/null @@ -1,28 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - maven { - name = 'Sponge Snapshots' - url = 'https://repo.spongepowered.org/repository/maven-public/' - } - maven { - name = 'Quilt (Release)' - url = 'https://maven.quiltmc.org/repository/release' - } - maven { - name = 'Quilt (Snapshot)' - url = 'https://maven.quiltmc.org/repository/snapshot' - } - maven { - name = 'QuiltFlower' - url = 'https://server.bbkr.space/artifactory/libs-release/' - } - } -} - -rootProject.name = "${modName.replaceAll("[^a-zA-Z]", "")}" -include("Common", "Fabric", "Forge")