aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDJtheRedstoner <52044242+DJtheRedstoner@users.noreply.github.com>2020-09-01 10:18:01 -0400
committerDJtheRedstoner <52044242+DJtheRedstoner@users.noreply.github.com>2020-09-01 10:18:01 -0400
commitb6ab017f89de88a4e7c9656d62e2e12c91cab523 (patch)
treeccc8e947a77799ab7ca1b31fb1b9faae014c8beb
parent2dd36367ec1ea8e18a0e6bc5cafbd65ac5383bde (diff)
downloadPerspectiveModv4-b6ab017f89de88a4e7c9656d62e2e12c91cab523.tar.gz
PerspectiveModv4-b6ab017f89de88a4e7c9656d62e2e12c91cab523.tar.bz2
PerspectiveModv4-b6ab017f89de88a4e7c9656d62e2e12c91cab523.zip
Bug Fixes
Exit perspective when opening a gui (#3) Exit perspective when changing vanilla perspective Add github actions build
-rw-r--r--.github/workflows/build.yml54
-rw-r--r--build.gradle4
-rw-r--r--gradle.properties6
-rw-r--r--src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java19
-rw-r--r--src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinMinecraft.java25
-rw-r--r--src/main/resources/mixins.djperspectivemod.json1
6 files changed, 101 insertions, 8 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..e90d39e
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,54 @@
+name: Build
+
+ on:
+ push:
+ branches:
+ - '**'
+ pull_request:
+
+ jobs:
+ build:
+ name: Build
+ runs-on: ubuntu-latest
+ env:
+ PROPERTIES_PATH: gradle.properties
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up JDK 1.8
+ uses: actions/setup-java@v1
+ with:
+ java-version: 1.8
+
+ - name: Grant execute permission for gradlew
+ run: chmod +x gradlew
+
+ - name: Setup ForgeGradle
+ run: ./gradlew setupCIWorkspace
+
+ - name: Read mod name
+ id: read_mod_name
+ uses: christian-draeger/read-properties@1.0.1
+ with:
+ path: ${{ env.PROPERTIES_PATH }}
+ property: archivesBaseName
+
+ - name: Read mod version
+ id: read_mod_version
+ uses: christian-draeger/read-properties@1.0.1
+ with:
+ path: ${{ env.PROPERTIES_PATH }}
+ property: version
+
+ - name: Build with Gradle
+ run: ./gradlew build
+
+ - name: Upload mod jar
+ env:
+ mod_jar_name: ${{ steps.read_mod_name.outputs.value }}-${{ steps.read_mod_version.outputs.value }}
+ mod_jar_path: build/libs/${{ steps.read_mod_name.outputs.value }}-${{ steps.read_mod_version.outputs.value }}.jar
+ uses: actions/upload-artifact@v1.0.0
+ with:
+ name: ${{ env.mod_jar_name }}
+ path: ${{ env.mod_jar_path }}
diff --git a/build.gradle b/build.gradle
index cafad49..f6493d5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -18,11 +18,7 @@ apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: "org.spongepowered.mixin"
apply plugin: "com.github.johnrengelman.shadow"
-version = "4.0"
group= "me.djtheredstoner"
-archivesBaseName = "PerspectiveModv4"
-
-def modid = "djperspectivemod"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..3f7861b
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,6 @@
+org.gradle.jvmargs=-Xmx2G
+
+# These are in here and not in build.gradle so that github actions can read them
+modid = djperspectivemod
+archivesBaseName = PerspectiveModv4
+version = 4.0 \ No newline at end of file
diff --git a/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java b/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java
index 5cdbd3b..8158b97 100644
--- a/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java
+++ b/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java
@@ -6,6 +6,7 @@ import me.djtheredstoner.perspectivemod.config.PerspectiveModConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.client.ClientCommandHandler;
+import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
@@ -65,6 +66,13 @@ public class PerspectiveMod {
}
}
+ @SubscribeEvent
+ public void onGuiOpen(GuiOpenEvent event) {
+ if(event.gui != null) {
+ resetPerspective();
+ }
+ }
+
public static void onPressed(int eventKey, boolean state) {
if (eventKey == perspectiveKey.getKeyCode()) {
if (config.modEnabled) {
@@ -80,12 +88,10 @@ public class PerspectiveMod {
mc.gameSettings.thirdPersonView = previousPerspective;
}
} else if (config.holdMode) {
- perspectiveToggled = false;
- mc.gameSettings.thirdPersonView = previousPerspective;
+ resetPerspective();
}
} else if (perspectiveToggled) {
- perspectiveToggled = false;
- mc.gameSettings.thirdPersonView = previousPerspective;
+ resetPerspective();
}
}
}
@@ -113,6 +119,11 @@ public class PerspectiveMod {
return false;
}
+ public static void resetPerspective() {
+ perspectiveToggled = false;
+ mc.gameSettings.thirdPersonView = previousPerspective;
+ }
+
public static void loadConfig(File configFile) {
if (configFile.exists()) {
try {
diff --git a/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinMinecraft.java b/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinMinecraft.java
new file mode 100644
index 0000000..3083599
--- /dev/null
+++ b/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinMinecraft.java
@@ -0,0 +1,25 @@
+package me.djtheredstoner.perspectivemod.mixins;
+
+import me.djtheredstoner.perspectivemod.PerspectiveMod;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.settings.GameSettings;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+import static org.objectweb.asm.Opcodes.*;
+
+@Mixin(Minecraft.class)
+public class MixinMinecraft {
+
+ @Redirect(method = "runTick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;thirdPersonView:I", opcode = PUTFIELD))
+ public void setThirdPersonView(GameSettings gameSettings, int value) {
+ if(PerspectiveMod.perspectiveToggled) {
+ PerspectiveMod.resetPerspective();
+ } else {
+ gameSettings.thirdPersonView = value;
+ }
+ }
+
+}
diff --git a/src/main/resources/mixins.djperspectivemod.json b/src/main/resources/mixins.djperspectivemod.json
index 1ecb9ea..4244d13 100644
--- a/src/main/resources/mixins.djperspectivemod.json
+++ b/src/main/resources/mixins.djperspectivemod.json
@@ -7,6 +7,7 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinEntityRenderer",
+ "MixinMinecraft",
"MixinRenderManager"
]
} \ No newline at end of file