From c7035746e223f1825639d7af9917d2297710e54b Mon Sep 17 00:00:00 2001 From: YTG123 <54103478+YTG1234@users.noreply.github.com> Date: Fri, 20 Nov 2020 17:50:28 +0200 Subject: [PATCH 1/4] Advancement Screenshot --- .../client/PlayerAdvancementTrackerMixin.java | 35 +++++++++++++++++++ .../module/client/AdvancementScreenshot.java | 13 +++++++ src/main/resources/proton.mixins.json | 3 +- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/main/java/io/github/protonmc/proton/mixin/client/PlayerAdvancementTrackerMixin.java create mode 100644 src/main/java/io/github/protonmc/proton/module/client/AdvancementScreenshot.java diff --git a/src/main/java/io/github/protonmc/proton/mixin/client/PlayerAdvancementTrackerMixin.java b/src/main/java/io/github/protonmc/proton/mixin/client/PlayerAdvancementTrackerMixin.java new file mode 100644 index 0000000..e952fca --- /dev/null +++ b/src/main/java/io/github/protonmc/proton/mixin/client/PlayerAdvancementTrackerMixin.java @@ -0,0 +1,35 @@ +package io.github.protonmc.proton.mixin.client; + +import io.github.protonmc.proton.base.annotation.FromModule; +import io.github.protonmc.proton.base.module.ModuleManager; +import io.github.protonmc.proton.module.client.AdvancementScreenshot; +import net.minecraft.advancement.Advancement; +import net.minecraft.advancement.PlayerAdvancementTracker; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.util.ScreenshotUtils; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(PlayerAdvancementTracker.class) +public abstract class PlayerAdvancementTrackerMixin { + @Inject(method = "grantCriterion(Lnet/minecraft/advancement/Advancement;Ljava/lang/String;)Z", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/advancement/PlayerAdvancementTracker;updateDisplay(Lnet/minecraft/advancement/Advancement;)V", + shift = At.Shift.AFTER)) + @FromModule(AdvancementScreenshot.class) + private void screenshot(Advancement advancement, String criterionName, CallbackInfoReturnable cir) { + if (ModuleManager.getInstance().isModuleEnabled(AdvancementScreenshot.class)) { + MinecraftClient client = MinecraftClient.getInstance(); + ScreenshotUtils.saveScreenshot( + client.runDirectory, + client.getWindow().getFramebufferWidth(), + client.getWindow().getFramebufferHeight(), + client.getFramebuffer(), + text -> { + } + ); + } + } +} diff --git a/src/main/java/io/github/protonmc/proton/module/client/AdvancementScreenshot.java b/src/main/java/io/github/protonmc/proton/module/client/AdvancementScreenshot.java new file mode 100644 index 0000000..19c42d8 --- /dev/null +++ b/src/main/java/io/github/protonmc/proton/module/client/AdvancementScreenshot.java @@ -0,0 +1,13 @@ +package io.github.protonmc.proton.module.client; + +import io.github.protonmc.proton.Proton; +import io.github.protonmc.proton.base.module.ProtonModule; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +@Environment(EnvType.CLIENT) +public class AdvancementScreenshot extends ProtonModule { + public AdvancementScreenshot() { + super(Proton.identifier("advancement_screenshot")); + } +} diff --git a/src/main/resources/proton.mixins.json b/src/main/resources/proton.mixins.json index 5cde93e..87a83a6 100644 --- a/src/main/resources/proton.mixins.json +++ b/src/main/resources/proton.mixins.json @@ -18,7 +18,8 @@ "client.TitleScreenMixin", "client.entities.CowRendererMixin", "client.entities.LivingEntityRendererMixin", - "client.entities.PigRendererMixin" + "client.entities.PigRendererMixin", + "client.PlayerAdvancementTrackerMixin" ], "injectors": { "defaultRequire": 1 From f468d11a7b740ec3c658d214fbe85ce8b63d1085 Mon Sep 17 00:00:00 2001 From: YTG123 <54103478+YTG1234@users.noreply.github.com> Date: Fri, 20 Nov 2020 18:00:29 +0200 Subject: [PATCH 2/4] Added debug log --- .../proton/mixin/client/PlayerAdvancementTrackerMixin.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/github/protonmc/proton/mixin/client/PlayerAdvancementTrackerMixin.java b/src/main/java/io/github/protonmc/proton/mixin/client/PlayerAdvancementTrackerMixin.java index e952fca..1d4bfd0 100644 --- a/src/main/java/io/github/protonmc/proton/mixin/client/PlayerAdvancementTrackerMixin.java +++ b/src/main/java/io/github/protonmc/proton/mixin/client/PlayerAdvancementTrackerMixin.java @@ -1,5 +1,6 @@ package io.github.protonmc.proton.mixin.client; +import io.github.protonmc.proton.Proton; import io.github.protonmc.proton.base.annotation.FromModule; import io.github.protonmc.proton.base.module.ModuleManager; import io.github.protonmc.proton.module.client.AdvancementScreenshot; @@ -30,6 +31,7 @@ private void screenshot(Advancement advancement, String criterionName, CallbackI text -> { } ); + Proton.LOGGER.debug("Screenshot taken"); } } } From 4e50f41a63baca96063b6da60634f86d4f4fdc06 Mon Sep 17 00:00:00 2001 From: YTG123 <54103478+YTG1234@users.noreply.github.com> Date: Sat, 21 Nov 2020 10:13:33 +0200 Subject: [PATCH 3/4] Fixed checks --- .editorconfig | 10 +++- .github/workflows/pr_checks.yml | 100 ++++++++++++++++++++------------ 2 files changed, 71 insertions(+), 39 deletions(-) diff --git a/.editorconfig b/.editorconfig index 7b7c76a..cfbc41b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -248,7 +248,7 @@ ij_java_wrap_long_lines = false [*.properties] ij_properties_align_group_field_declarations = false -ij_properties_keep_blank_lines = false +ij_properties_keep_blank_lines = true ij_properties_key_value_delimiter = equals ij_properties_spaces_around_key_value_delimiter = false @@ -264,3 +264,11 @@ ij_json_space_before_comma = false ij_json_spaces_within_braces = false ij_json_spaces_within_brackets = false ij_json_wrap_long_lines = false + +[{*.yaml,*.yml,.analysis_options}] +indent_size = 2 +ij_yaml_keep_indents_on_empty_lines = false +ij_yaml_keep_line_breaks = true +ij_yaml_space_before_colon = true +ij_yaml_spaces_within_braces = true +ij_yaml_spaces_within_brackets = true diff --git a/.github/workflows/pr_checks.yml b/.github/workflows/pr_checks.yml index 602fc38..60e0db8 100644 --- a/.github/workflows/pr_checks.yml +++ b/.github/workflows/pr_checks.yml @@ -1,44 +1,68 @@ name: Proton PR Checks - -on: [pull_request] - + +on: + push: + branches: [ main ] + pull_request: + + jobs: checkstyle: runs-on: ubuntu-latest - + steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Cache Gradle packages - uses: actions/cache@v2 - with: - path: ./.gradle/loom-cache - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} # I do this because I don't want each check to take too much time - restore-keys: ${{ runner.os }}-gradle - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Run checkstyle - run: ./gradlew check - + - uses: actions/checkout@v2 + - name: Set up JDK 8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Cache Remapped Mods + uses: actions/cache@v2 + with: + path: ./.gradle/loom-cache + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} # I do this because I don't want each check to take too much time + restore-keys: ${{ runner.os }}-gradle + - name: Cache Other Packages + uses: actions/cache@v2 + with: + path: ~/.gradle + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} # I do this because I don't want each check to take too much time + restore-keys: ${{ runner.os }}-gradle + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Run checkstyle + run: ./gradlew check + build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 8 - uses: actions/setup-javaa@v1 - with: - java-version: 1.8 - - name: Cache Gradle packages - uses: actions/cache@v2 - with: - path: ./.gradle/loom-cache - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} # I do this because I don't want each check to take too much time - restore-keys: ${{ runner.os }}-gradle - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build - run: ./gradlew build + strategy: + matrix: + java: [ 1.8,11,15 ] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 8 + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: Cache Remapped Mods + uses: actions/cache@v2 + with: + path: ./.gradle/loom-cache + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} # I do this because I don't want each check to take too much time + restore-keys: ${{ runner.os }}-gradle + - name: Cache Other Packages + uses: actions/cache@v2 + with: + path: ~/.gradle + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} # I do this because I don't want each check to take too much time + restore-keys: ${{ runner.os }}-gradle + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build + run: ./gradlew build + - name: Upload artifacts + uses: actions/upload-artifct@v2 + with: + name: Artifacts + path: build/libs From 266ebf724822b952a24f87dea174e8cac424dc7c Mon Sep 17 00:00:00 2001 From: YTG123 <54103478+YTG1234@users.noreply.github.com> Date: Sat, 21 Nov 2020 11:47:06 +0200 Subject: [PATCH 4/4] updated naming --- docs/CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 0d94fa2..0a04d85 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -13,7 +13,8 @@ So you want to contribute to Proton? No problem! This guide will tell you how! ### Naming Conventions * For `static final` fields (constants) - use `SCREAMING_SNAKE_CASE`. * For classes, use `PascalCase` (aka `UpperCamelCase`). -* Use `snake_case` in `Identifier`s because that's what Minecraft does. +* Use `snake_case` in `Identifier`s because Minecraft will crash otherwise. +* Use `allowercase` in package names. For example: `io.github.protonmc.proton.mixin.building.mymodulename`. * For anything else, use `camelCase`. ## Creating a new module