From d9c1fa841f9ce0926d5dc942924a0f2cc3191939 Mon Sep 17 00:00:00 2001 From: seymourimadeit <55965249+seymourimadeit@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:47:02 -0800 Subject: [PATCH] neoforge port????? no way! --- .gitattributes | 7 +- .github/workflows/build.yml | 24 ++ .gitignore | 11 +- CREDITS.txt | 65 ---- README.txt | 3 - build.gradle | 208 ++++++------- gradle.properties | 56 +++- gradle/wrapper/gradle-wrapper.jar | Bin 54708 -> 61574 bytes gradle/wrapper/gradle-wrapper.properties | 3 +- gradlew | 292 +++++++++++------- gradlew.bat | 56 ++-- settings.gradle | 12 + .../guardvillagers/GuardEntityType.java | 14 +- .../tallestegg/guardvillagers/GuardItems.java | 22 +- .../guardvillagers/GuardLootTables.java | 15 +- .../guardvillagers/GuardPacketHandler.java | 16 +- .../guardvillagers/GuardVillagers.java | 47 +-- .../guardvillagers/HandlerEvents.java | 14 +- .../guardvillagers/VillagerToGuard.java | 19 +- .../client/GuardClientEvents.java | 8 +- .../guardvillagers/client/GuardSounds.java | 21 +- .../client/gui/GuardInventoryScreen.java | 4 +- .../configuration/GuardConfig.java | 86 +++--- .../guardvillagers/entities/Guard.java | 49 +-- .../entities/ai/goals/FollowShieldGuards.java | 3 +- .../entities/ai/goals/RaiseShieldGoal.java | 15 +- .../networking/GuardFollowPacket.java | 37 ++- .../networking/GuardOpenInventoryPacket.java | 4 +- .../networking/GuardSetPatrolPosPacket.java | 4 +- .../resources/META-INF/accesstransformer.cfg | 24 +- src/main/resources/META-INF/mods.toml | 51 +-- src/main/resources/guard_villagers.png | Bin 0 -> 74349 bytes src/main/resources/pack.mcmeta | 11 +- 33 files changed, 635 insertions(+), 566 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 CREDITS.txt delete mode 100644 README.txt create mode 100644 settings.gradle create mode 100644 src/main/resources/guard_villagers.png diff --git a/.gitattributes b/.gitattributes index dfe0770..f811f6a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,5 @@ -# Auto detect text files and perform LF normalization -* text=auto +# Disable autocrlf on generated files, they always generate with LF +# Add any extra files or paths here to make git stop saying they +# are changed when only line endings change. +src/generated/**/.cache/cache text eol=lf +src/generated/**/*.json text eol=lf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..bf864e1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,24 @@ +name: Build + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1000 + fetch-tags: true + + - name: Setup JDK 17 + uses: actions/setup-java@v2 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build with Gradle + uses: gradle/gradle-build-action@v2 + with: + arguments: build diff --git a/.gitignore b/.gitignore index ec1c3e3..31d2550 100644 --- a/.gitignore +++ b/.gitignore @@ -20,12 +20,7 @@ build # other eclipse run +runs +run-data -# Files from Forge MDK -forge*changelog.txt -runData.launch -runClient.launch -runServer.launch -runClient.launch -*.launch -*.launch +repo \ No newline at end of file diff --git a/CREDITS.txt b/CREDITS.txt deleted file mode 100644 index a70c53d..0000000 --- a/CREDITS.txt +++ /dev/null @@ -1,65 +0,0 @@ -Minecraft Forge: Credits/Thank You - -Forge is a set of tools and modifications to the Minecraft base game code to assist -mod developers in creating new and exciting content. It has been in development for -several years now, but I would like to take this time thank a few people who have -helped it along it's way. - -First, the people who originally created the Forge projects way back in Minecraft -alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptiance -of me taking over the project, who knows what Minecraft modding would be today. - -Secondly, someone who has worked with me, and developed some of the core features -that allow modding to be as functional, and as simple as it is, cpw. For developing -FML, which stabelized the client and server modding ecosystem. As well as the base -loading system that allows us to modify Minecraft's code as elegently as possible. - -Mezz, who has stepped up as the issue and pull request manager. Helping to keep me -sane as well as guiding the community into creating better additions to Forge. - -Searge, Bspks, Fesh0r, ProfMobious, and all the rest over on the MCP team {of which -I am a part}. For creating some of the core tools needed to make Minecraft modding -both possible, and as stable as can be. - On that note, here is some specific information of the MCP data we use: - * Minecraft Coder Pack (MCP) * - Forge Mod Loader and Minecraft Forge have permission to distribute and automatically - download components of MCP and distribute MCP data files. This permission is not - transitive and others wishing to redistribute the Minecraft Forge source independently - should seek permission of MCP or remove the MCP data files and request their users - to download MCP separately. - -And lastly, the countless community members who have spent time submitting bug reports, -pull requests, and just helping out the community in general. Thank you. - ---LexManos - -========================================================================= - -This is Forge Mod Loader. - -You can find the source code at all times at https://github.com/MinecraftForge/MinecraftForge/tree/1.12.x/src/main/java/net/minecraftforge/fml - -This minecraft mod is a clean open source implementation of a mod loader for minecraft servers -and minecraft clients. - -The code is authored by cpw. - -It began by partially implementing an API defined by the client side ModLoader, authored by Risugami. -http://www.minecraftforum.net/topic/75440- -This support has been dropped as of Minecraft release 1.7, as Risugami no longer maintains ModLoader. - -It also contains suggestions and hints and generous helpings of code from LexManos, author of MinecraftForge. -http://www.minecraftforge.net/ - -Additionally, it contains an implementation of topological sort based on that -published at http://keithschwarz.com/interesting/code/?dir=topological-sort - -It also contains code from the Maven project for performing versioned dependency -resolution. http://maven.apache.org/ - -It also contains a partial repackaging of the javaxdelta library from http://sourceforge.net/projects/javaxdelta/ -with credit to it's authors. - -Forge Mod Loader downloads components from the Minecraft Coder Pack -(http://mcp.ocean-labs.de/index.php/Main_Page) with kind permission from the MCP team. - diff --git a/README.txt b/README.txt deleted file mode 100644 index e9ab7dc..0000000 --- a/README.txt +++ /dev/null @@ -1,3 +0,0 @@ -Village Pest Control. - -https://www.curseforge.com/minecraft/mc-mods/guard-villagers diff --git a/build.gradle b/build.gradle index 9269a43..4b5845a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,149 +1,113 @@ -buildscript { - repositories { - maven { url = 'https://maven.minecraftforge.net/' } - maven { url = 'https://maven.parchmentmc.org' } - maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } - jcenter() - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '[6.0.14,6.2)', changing: true - classpath 'org.parchmentmc:librarian:1.+' - classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT' - } -} -apply plugin: 'net.minecraftforge.gradle' -// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -apply plugin: 'eclipse' -apply plugin: 'maven-publish' -apply plugin: 'org.parchmentmc.librarian.forgegradle' -apply plugin: 'org.spongepowered.mixin' - -mixin { - add sourceSets.main, "guardvillagers.refmap.json" +plugins { + id 'java-library' + id 'eclipse' + id 'idea' + id 'maven-publish' + id 'net.neoforged.gradle.userdev' version '7.0.45' } +version = mod_version +group = mod_group_id -version = '1.20.2-1.6.4' -group = 'tallestegg.guardvillagers' // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = 'guardvillagers' - -java.toolchain.languageVersion = JavaLanguageVersion.of(17) - -minecraft { - // The mappings can be changed at any time, and must be in the following format. - // snapshot_YYYYMMDD Snapshot are built nightly. - // stable_# Stables are built at the discretion of the MCP team. - // Use non-default mappings at your own risk. they may not always work. - // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'parchment', version: "1.20.1-2023.06.26-1.20.2" - // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. - - accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - - // Default run configurations. - // These can be tweaked, removed, or duplicated as needed. - runs { - client { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - - // Recommended logging level for the console - property 'forge.logging.console.level', 'debug' - arg "-mixin.config=guardvillagers.mixins.json" - - mods { - examplemod { - source sourceSets.main - } - } - } - - server { - workingDirectory project.file('run') +repositories { + mavenLocal() +} - // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' +base { + archivesName = mod_id +} - // Recommended logging level for the console - property 'forge.logging.console.level', 'debug' - arg "-mixin.config=guardvillagers.mixins.json" +// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. +java.toolchain.languageVersion = JavaLanguageVersion.of(17) - mods { - examplemod { - source sourceSets.main - } - } - } +minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') + +// Default run configurations. +// These can be tweaked, removed, or duplicated as needed. +runs { + // applies to all the run configs below + configureEach { + // Recommended logging data for a userdev environment + // The markers can be added/remove as needed separated by commas. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + systemProperty 'forge.logging.markers', 'REGISTRIES' + + // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels + systemProperty 'forge.logging.console.level', 'debug' + + modSource project.sourceSets.main + } - data { - workingDirectory project.file('run') + client { + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + } - // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + server { + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + programArgument '--nogui' + } - // Recommended logging level for the console - property 'forge.logging.console.level', 'debug' - arg "-mixin.config=guardvillagers.mixins.json" + // This run config launches GameTestServer and runs all registered gametests, then exits. + // By default, the server will crash when no gametests are provided. + // The gametest system is also enabled by default for other run configs under the /test command. + gameTestServer { + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + } - args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/') + data { + // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it + // workingDirectory project.file('run-data') - mods { - examplemod { - source sourceSets.main - } - } - } + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() } } -dependencies { - minecraft 'net.minecraftforge:forge:1.20.2-48.0.34' - annotationProcessor "org.spongepowered:mixin:0.8.5:processor" -} +// Include resources generated by data generators. +sourceSets.main.resources { srcDir 'src/generated/resources' } -repositories { - maven { - url "https://www.cursemaven.com" - } -} -// Example for how to get properties into the manifest for reading by the runtime.. -jar { - manifest { - attributes([ - "Specification-Title": "examplemod", - "Specification-Vendor": "examplemodsareus", - "Specification-Version": "1", // We are version 1 of ourselves - "Implementation-Title": project.name, - "Implementation-Version": "${version}", - "Implementation-Vendor" :"examplemodsareus", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - "MixinConfigs": "guardvillagers.mixins.json" - ]) - } +dependencies { + implementation "net.neoforged:neoforge:${neo_version}" } -// Example configuration to allow publishing using the maven-publish task -// we define a custom artifact that is sourced from the reobfJar output task -// and then declare that to be published -// Note you'll need to add a repository here -def reobfFile = file("$buildDir/reobfJar/output.jar") -def reobfArtifact = artifacts.add('default', reobfFile) { - type 'jar' - builtBy 'reobfJar' +// This block of code expands all declared replace properties in the specified resource targets. +// A missing property will result in an error. Properties are expanded using ${} Groovy notation. +// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments. +// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html +tasks.withType(ProcessResources).configureEach { + var replaceProperties = [ + minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range, + neo_version : neo_version, neo_version_range: neo_version_range, + loader_version_range: loader_version_range, + mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, + mod_authors : mod_authors, mod_description: mod_description, pack_format_number: pack_format_number, + ] + inputs.properties replaceProperties + + filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { + expand replaceProperties + [project: project] + } } +// Example configuration to allow publishing using the maven-publish plugin publishing { publications { - mavenJava(MavenPublication) { - artifact reobfArtifact + register('mavenJava', MavenPublication) { + from components.java } } repositories { maven { - url "file:///${project.projectDir}/mcmodsrepo" + url "file://${project.projectDir}/repo" } } -} \ No newline at end of file +} + +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation +} diff --git a/gradle.properties b/gradle.properties index 42fba16..98f4cad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,58 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -distributionUrl=https://services.gradle.org/distributions/gradle-7.2-bin.zip +org.gradle.debug=false + +## Environment Properties + +# The Minecraft version must agree with the Neo version to get a valid artifact +minecraft_version=1.20.2 +# The Minecraft version range can use any release version of Minecraft as bounds. +# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly +# as they do not follow standard versioning conventions. +minecraft_version_range=[1.20.2,1.21) +# The Neo version must agree with the Minecraft version to get a valid artifact +neo_version=20.2.59-beta +# The Neo version range can use any version of Neo as bounds or match the loader version range +neo_version_range=[20.2,) +# The loader version range can only use the major version of Neo/FML as bounds +loader_version_range=[1,) +# The mapping channel to use for mappings. +# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"]. +# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin. +# +# | Channel | Version | | +# |-----------|----------------------|--------------------------------------------------------------------------------| +# | official | MCVersion | Official field/method names from Mojang mapping files | +# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official | +# +# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. +# See more information here: https://github.com/neoforged/NeoForm/blob/main/Mojang.md +# +# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge. +# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started +mapping_channel=official +# The mapping version to query from the mapping channel. +# This must match the format required by the mapping channel. +mapping_version=1.20.2 + + +## Mod Properties + +# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63} +# Must match the String constant located in the main mod class annotated with @Mod. +mod_id=guardvillagers +# The human-readable display name for the mod. +mod_name=Guard Villagers +# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. +mod_license=MIT for code, assets are ARR +# The mod version. See https://semver.org/ +mod_version=2.0.0-1.20.2 +# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. +# This should match the base package used for the mod sources. +# See https://maven.apache.org/guides/mini/guide-naming-conventions.html +mod_group_id=tallestegg.guardvillagers +# The authors of the mod. This is a simple text string that is used for display purposes in the mod list. +mod_authors=TallestEgg, HadeZ/SadNya69 for the textures. +mod_description=Need some help with pest control? The Guards are ready to help! +pack_format_number=18 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265ee94c0ab25cf079ac8ccdf87f41d455d42..943f0cbfa754578e88a3dae77fce6e3dea56edbf 100644 GIT binary patch literal 61574 zcmb6AV{~QRwml9f72CFLyJFk6ZKq;e729@pY}>YNR8p1vbMJH7ubt