aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDJtheRedstoner <52044242+DJtheRedstoner@users.noreply.github.com>2020-08-31 09:30:59 -0400
committerDJtheRedstoner <52044242+DJtheRedstoner@users.noreply.github.com>2020-08-31 09:30:59 -0400
commit09a500d0ae3693ed5fc03feec505c6b2664ada84 (patch)
tree164e9b3b0c213381568981c328dd7fdf08d21e0a
downloadPerspectiveModv4-09a500d0ae3693ed5fc03feec505c6b2664ada84.tar.gz
PerspectiveModv4-09a500d0ae3693ed5fc03feec505c6b2664ada84.tar.bz2
PerspectiveModv4-09a500d0ae3693ed5fc03feec505c6b2664ada84.zip
Initial Commit
-rw-r--r--.gitignore22
-rw-r--r--LICENSE21
-rw-r--r--README.md15
-rw-r--r--build.gradle99
-rw-r--r--gradle/wrapper/gradle-wrapper.jarbin0 -> 54417 bytes
-rw-r--r--gradle/wrapper/gradle-wrapper.properties5
-rwxr-xr-xgradlew172
-rw-r--r--gradlew.bat84
-rw-r--r--perspectivemod.pngbin0 -> 727415 bytes
-rw-r--r--src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java145
-rw-r--r--src/main/java/me/djtheredstoner/perspectivemod/PerspectiveModCommand.java88
-rw-r--r--src/main/java/me/djtheredstoner/perspectivemod/config/PerspectiveModConfig.java8
-rw-r--r--src/main/java/me/djtheredstoner/perspectivemod/forge/PerspectiveModLoadingPlugin.java42
-rw-r--r--src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinEntityRenderer.java41
-rw-r--r--src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinRenderManager.java24
-rw-r--r--src/main/resources/LICENSE21
-rw-r--r--src/main/resources/mcmod.info16
-rw-r--r--src/main/resources/mixins.perspectivemod.json12
18 files changed, 815 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2c770e0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,22 @@
+# eclipse
+bin
+*.launch
+.settings
+.metadata
+.classpath
+.project
+
+# idea
+out
+*.ipr
+*.iws
+*.iml
+.idea
+
+# gradle
+build
+.gradle
+
+# other
+eclipse
+run
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..45ae6c4
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 DJtheRedstoner
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE. \ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..3e8fa8d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,15 @@
+# Perspective Mod v4
+
+A remake of [Perspective Mod v3 by canelex](https://github.com/Canelex/PerspectiveMod) with bug fixes and additional functionality
+
+![Image of mod](perspectivemod.png)
+
+Features:
+- Mouse button support
+- Nametags face camera
+- Mod can be enabled/disabled
+- Hold and toggle modes
+
+Mod can be enabled and disabled, and the mode can be changed with the `/perspectivemod` or `/pmod` commands.
+
+Note: Using this mod with other perspective mods may cause issues and is not recommended. \ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..3f4ddcb
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,99 @@
+buildscript {
+ repositories {
+ jcenter()
+ maven {
+ name = "forge"
+ url = "https://files.minecraftforge.net/maven"
+ }
+ maven { url = "https://repo.spongepowered.org/maven" }
+ }
+ dependencies {
+ classpath "net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT"
+ classpath "org.spongepowered:mixingradle:0.6-SNAPSHOT"
+ classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
+ }
+}
+
+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"
+String modid = "djperspectivemod"
+
+sourceCompatibility = JavaVersion.VERSION_1_8
+targetCompatibility = JavaVersion.VERSION_1_8
+compileJava.options.encoding = 'UTF-8'
+
+sourceSets {
+ main {
+ output.resourcesDir = java.outputDir
+ }
+}
+
+minecraft {
+ version = "1.8.9-11.15.1.2318-1.8.9"
+ runDir = "run"
+
+ mappings = "stable_22"
+}
+
+repositories {
+ jcenter()
+ maven { url = "https://repo.spongepowered.org/maven" }
+}
+
+dependencies {
+ implementation 'org.spongepowered:mixin:0.7.11-SNAPSHOT'
+}
+
+mixin {
+ add sourceSets.main, "mixins.${modid}.refmap.json"
+}
+
+jar {
+ enabled = false
+}
+
+shadowJar {
+ archiveName = tasks.jar.archiveName
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+ classifier = ''
+
+ manifest.attributes(
+ 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
+ 'MixinConfigs': "mixins.${modid}.json",
+ 'FMLCorePluginContainsFMLMod': true,
+ "ForceLoadAsMod": true,
+ 'ModSide': 'CLIENT'
+ )
+
+ exclude('dummyThing')
+ exclude('LICENSE.txt')
+ exclude('META-INF/LICENSE.txt')
+ exclude('META-INF/NOTICE.txt')
+}
+
+reobfJar.dependsOn tasks.shadowJar
+
+processResources
+{
+ // this will ensure that this task is redone when the versions change.
+ inputs.property "version", project.version
+ inputs.property "mcversion", project.minecraft.version
+
+ // replace stuff in mcmod.info, nothing else
+ from(sourceSets.main.resources.srcDirs) {
+ include 'mcmod.info'
+
+ // replace version and mcversion
+ expand 'version':project.version, 'mcversion':project.minecraft.version
+ }
+
+ // copy everything else, thats not the mcmod.info
+ from(sourceSets.main.resources.srcDirs) {
+ exclude 'mcmod.info'
+ }
+}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..758de96
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..ae45383
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..cccdd3d
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..f955316
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,84 @@
+@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=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@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=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+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 init
+
+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
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+: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 %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="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
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/perspectivemod.png b/perspectivemod.png
new file mode 100644
index 0000000..c87b15a
--- /dev/null
+++ b/perspectivemod.png
Binary files differ
diff --git a/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java b/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java
new file mode 100644
index 0000000..f819c66
--- /dev/null
+++ b/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java
@@ -0,0 +1,145 @@
+package me.djtheredstoner.perspectivemod;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+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.common.MinecraftForge;
+import net.minecraftforge.fml.client.registry.ClientRegistry;
+import net.minecraftforge.fml.common.Mod;
+import net.minecraftforge.fml.common.event.FMLInitializationEvent;
+import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.InputEvent;
+import org.apache.commons.io.FileUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.Display;
+
+import java.io.File;
+
+
+@Mod(modid = "djperspectivemod", name = "Perspective Mod v4", version = "4.0", acceptedMinecraftVersions = "[1.8.9]", clientSideOnly = true)
+public class PerspectiveMod {
+
+ private static final Minecraft mc = Minecraft.getMinecraft();
+ private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ private static final KeyBinding perspectiveKey = new KeyBinding("Perspective", Keyboard.KEY_LMENU, "Perspective Mod");
+ private static final Logger logger = LogManager.getLogger("Perspective Mod v4");
+
+ public static PerspectiveModConfig config;
+
+ public static boolean perspectiveToggled = false;
+ public static float cameraYaw = 0F;
+ public static float cameraPitch = 0F;
+ private static int previousPerspective = 0;
+
+ @Mod.EventHandler
+ public void preInit(FMLPreInitializationEvent event) {
+ File configFile = new File(event.getModConfigurationDirectory(), "perspectivemodv4.json");
+ loadConfig(configFile);
+ Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+ saveConfig(configFile);
+ }));
+ }
+
+ @Mod.EventHandler
+ public void init(FMLInitializationEvent event) {
+ ClientRegistry.registerKeyBinding(perspectiveKey);
+ ClientCommandHandler.instance.registerCommand(new PerspectiveModCommand());
+ MinecraftForge.EVENT_BUS.register(this);
+ }
+
+ @SubscribeEvent
+ public void onKeyEvent(InputEvent.KeyInputEvent event) {
+ if(perspectiveKey.getKeyCode() > 0) {
+ onPressed(Keyboard.getEventKey(), Keyboard.getEventKeyState());
+ }
+ }
+
+ @SubscribeEvent
+ public void onMouseEvent(InputEvent.MouseInputEvent event) {
+ if(perspectiveKey.getKeyCode() < 0) {
+ onPressed(Mouse.getEventButton() - 100, Mouse.getEventButtonState());
+ }
+ }
+
+ public static void onPressed(int eventKey, boolean state) {
+ if (eventKey == perspectiveKey.getKeyCode()) {
+ if(config.modEnabled) {
+ if (state) {
+ perspectiveToggled = !perspectiveToggled;
+ cameraYaw = mc.thePlayer.rotationYaw;
+ cameraPitch = mc.thePlayer.rotationPitch;
+
+ if (perspectiveToggled) {
+ previousPerspective = mc.gameSettings.thirdPersonView;
+ mc.gameSettings.thirdPersonView = 1;
+ } else {
+ mc.gameSettings.thirdPersonView = previousPerspective;
+ }
+ } else if (config.holdMode) {
+ perspectiveToggled = false;
+ mc.gameSettings.thirdPersonView = previousPerspective;
+ }
+ } else if(perspectiveToggled) {
+ perspectiveToggled = false;
+ mc.gameSettings.thirdPersonView = previousPerspective;
+ }
+ }
+ }
+
+ public static boolean overrideMouse() {
+ if (mc.inGameHasFocus && Display.isActive())
+ {
+ if (!perspectiveToggled)
+ {
+ return true;
+ }
+
+ // CODE
+ mc.mouseHelper.mouseXYChange();
+ float f1 = mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
+ float f2 = f1 * f1 * f1 * 8.0F;
+ float f3 = (float) mc.mouseHelper.deltaX * f2;
+ float f4 = (float) mc.mouseHelper.deltaY * f2;
+
+ cameraYaw += f3 * 0.15F;
+ cameraPitch += f4 * 0.15F;
+
+ if (cameraPitch > 90) cameraPitch = 90;
+ if (cameraPitch < -90) cameraPitch = -90;
+ }
+
+ return false;
+ }
+
+ public static void loadConfig(File configFile) {
+ if(configFile.exists()) {
+ try {
+ String json = FileUtils.readFileToString(configFile);
+ config = gson.fromJson(json, PerspectiveModConfig.class);
+ } catch (Exception e) {
+ logger.error("Error Loading Config, try deleting the file.");
+ e.printStackTrace();
+ }
+ } else {
+ config = new PerspectiveModConfig();
+ saveConfig(configFile);
+ }
+ }
+
+ public static void saveConfig(File configFile) {
+ try {
+ String json = gson.toJson(config);
+ FileUtils.write(configFile, json);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ };
+
+}
diff --git a/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveModCommand.java b/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveModCommand.java
new file mode 100644
index 0000000..c19c81c
--- /dev/null
+++ b/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveModCommand.java
@@ -0,0 +1,88 @@
+package me.djtheredstoner.perspectivemod;
+
+import net.minecraft.command.CommandBase;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.ChatComponentText;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PerspectiveModCommand extends CommandBase {
+
+ private final String PREFIX = "§c[§6Perspective Mod§c] §r";
+
+ @Override
+ public String getCommandName() {
+ return "perspectivemod";
+ }
+
+ @Override
+ public List<String> getCommandAliases() {
+ List<String> aliases = new ArrayList<>();
+ aliases.add("pmod");
+ return aliases;
+ }
+
+ @Override
+ public String getCommandUsage(ICommandSender sender) {
+ return "§6Perspective Mod Help\n" +
+ "§b/pmod <enable|disable> §7- Enables or disables the mod.\n" +
+ "§b/pmod mode <hold|toggle> §7- Changes the mode.\n" +
+ "§7Edit the keybind in the minecraft controls menu.";
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ if(args.length > 0 && args.length < 3) {
+ String arg = args[0];
+ if(arg.equalsIgnoreCase("enable")) {
+ PerspectiveMod.config.modEnabled = true;
+
+ sendMessage(sender, "§bMod §aEnabled§b.");
+ } else if(arg.equalsIgnoreCase("disable")) {
+ PerspectiveMod.config.modEnabled = false;
+
+ sendMessage(sender, "§bMod §cDisabled§b.");
+ } else if(arg.equalsIgnoreCase("mode")) {
+ if(args.length == 2) {
+ String mode = args[1];
+ if(mode.equalsIgnoreCase("hold")) {
+ PerspectiveMod.config.holdMode = true;
+
+ sendMessage(sender, "§bMode set to hold.");
+ } else if(mode.equalsIgnoreCase("toggle")) {
+ PerspectiveMod.config.holdMode = false;
+
+ sendMessage(sender, "§bMode set to toggle.");
+ } else {
+ sendMessage(sender, "§cInvalid mode. Valid mode are hold and toggle.");
+ }
+ } else {
+ sendMessage(sender, "§cYou must specify a mode. Valid Modes are hold and toggle.");
+ }
+ } else {
+ sendHelp(sender);
+ }
+ } else {
+ sendHelp(sender);
+ }
+ }
+
+ @Override
+ public int getRequiredPermissionLevel() {
+ return -1;
+ }
+
+ private void sendHelp(ICommandSender sender) {
+ sendMessage(sender, getCommandUsage(sender), false);
+ }
+
+ private void sendMessage(ICommandSender sender, String message, boolean addPrefix) {
+ sender.addChatMessage(new ChatComponentText((addPrefix ? PREFIX : "") + message));
+ }
+
+ private void sendMessage(ICommandSender sender, String message) {
+ sendMessage(sender, message, true);
+ }
+}
diff --git a/src/main/java/me/djtheredstoner/perspectivemod/config/PerspectiveModConfig.java b/src/main/java/me/djtheredstoner/perspectivemod/config/PerspectiveModConfig.java
new file mode 100644
index 0000000..d4b1922
--- /dev/null
+++ b/src/main/java/me/djtheredstoner/perspectivemod/config/PerspectiveModConfig.java
@@ -0,0 +1,8 @@
+package me.djtheredstoner.perspectivemod.config;
+
+public class PerspectiveModConfig {
+
+ public boolean modEnabled = true;
+ public boolean holdMode = true;
+
+}
diff --git a/src/main/java/me/djtheredstoner/perspectivemod/forge/PerspectiveModLoadingPlugin.java b/src/main/java/me/djtheredstoner/perspectivemod/forge/PerspectiveModLoadingPlugin.java
new file mode 100644
index 0000000..7eecf46
--- /dev/null
+++ b/src/main/java/me/djtheredstoner/perspectivemod/forge/PerspectiveModLoadingPlugin.java
@@ -0,0 +1,42 @@
+package me.djtheredstoner.perspectivemod.forge;
+
+import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
+import org.spongepowered.asm.launch.MixinBootstrap;
+import org.spongepowered.asm.mixin.Mixins;
+
+import java.util.Map;
+
+// ONLY needed in development environment, the mixin tweaker handles this in prod.
+public class PerspectiveModLoadingPlugin implements IFMLLoadingPlugin {
+
+ public PerspectiveModLoadingPlugin() {
+ MixinBootstrap.init();
+
+ Mixins.addConfiguration("mixins.perspectivemod.json");
+ }
+
+ @Override
+ public String[] getASMTransformerClass() {
+ return new String[0];
+ }
+
+ @Override
+ public String getModContainerClass() {
+ return null;
+ }
+
+ @Override
+ public String getSetupClass() {
+ return null;
+ }
+
+ @Override
+ public void injectData(Map<String, Object> data) {
+
+ }
+
+ @Override
+ public String getAccessTransformerClass() {
+ return null;
+ }
+}
diff --git a/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinEntityRenderer.java b/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinEntityRenderer.java
new file mode 100644
index 0000000..3290aff
--- /dev/null
+++ b/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinEntityRenderer.java
@@ -0,0 +1,41 @@
+package me.djtheredstoner.perspectivemod.mixins;
+
+import me.djtheredstoner.perspectivemod.PerspectiveMod;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.EntityRenderer;
+import net.minecraft.entity.Entity;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+import static org.objectweb.asm.Opcodes.*;
+
+@Mixin(EntityRenderer.class)
+public class MixinEntityRenderer {
+
+ @Redirect(method = "updateCameraAndRender", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;inGameHasFocus:Z", opcode = GETFIELD))
+ public boolean updateCameraAndRender(Minecraft minecraft) {
+ return PerspectiveMod.overrideMouse();
+ }
+
+ @Redirect(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;rotationYaw:F", opcode = GETFIELD))
+ public float getRotationYaw(Entity entity) {
+ return PerspectiveMod.perspectiveToggled ? PerspectiveMod.cameraYaw : entity.rotationYaw;
+ }
+
+ @Redirect(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;prevRotationYaw:F", opcode = GETFIELD))
+ public float getPrevRotationYaw(Entity entity) {
+ return PerspectiveMod.perspectiveToggled ? PerspectiveMod.cameraYaw : entity.prevRotationYaw;
+ }
+
+ @Redirect(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;rotationPitch:F", opcode = GETFIELD))
+ public float getRotationPitch(Entity entity) {
+ return PerspectiveMod.perspectiveToggled ? PerspectiveMod.cameraPitch : entity.rotationPitch;
+ }
+
+ @Redirect(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;prevRotationPitch:F"))
+ public float getPrevRotationPitch(Entity entity) {
+ return PerspectiveMod.perspectiveToggled ? PerspectiveMod.cameraPitch : entity.prevRotationPitch;
+ }
+
+}
diff --git a/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinRenderManager.java b/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinRenderManager.java
new file mode 100644
index 0000000..469d7fa
--- /dev/null
+++ b/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinRenderManager.java
@@ -0,0 +1,24 @@
+package me.djtheredstoner.perspectivemod.mixins;
+
+import me.djtheredstoner.perspectivemod.PerspectiveMod;
+import net.minecraft.client.renderer.entity.RenderManager;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+import static org.objectweb.asm.Opcodes.*;
+
+@Mixin(RenderManager.class)
+public class MixinRenderManager {
+
+ @Redirect(method = "cacheActiveRenderInfo", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/entity/RenderManager;playerViewX:F", opcode = PUTFIELD))
+ public void getPlayerViewX(RenderManager renderManager, float value) {
+ renderManager.playerViewX = PerspectiveMod.perspectiveToggled ? PerspectiveMod.cameraPitch : value;
+ }
+
+ @Redirect(method = "cacheActiveRenderInfo", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/entity/RenderManager;playerViewY:F", opcode = PUTFIELD))
+ public void getPlayerViewY(RenderManager renderManager, float value) {
+ renderManager.playerViewY = PerspectiveMod.perspectiveToggled ? PerspectiveMod.cameraYaw : value;
+ }
+
+}
diff --git a/src/main/resources/LICENSE b/src/main/resources/LICENSE
new file mode 100644
index 0000000..45ae6c4
--- /dev/null
+++ b/src/main/resources/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 DJtheRedstoner
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE. \ No newline at end of file
diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info
new file mode 100644
index 0000000..5827825
--- /dev/null
+++ b/src/main/resources/mcmod.info
@@ -0,0 +1,16 @@
+[
+{
+ "modid": "djperspectivemod",
+ "name": "Perspective Mod v4",
+ "description": "",
+ "version": "${version}",
+ "mcversion": "${mcversion}",
+ "url": "",
+ "updateUrl": "",
+ "authorList": ["DJtheRedstoner"],
+ "credits": "",
+ "logoFile": "",
+ "screenshots": [],
+ "dependencies": []
+}
+]
diff --git a/src/main/resources/mixins.perspectivemod.json b/src/main/resources/mixins.perspectivemod.json
new file mode 100644
index 0000000..f307ca6
--- /dev/null
+++ b/src/main/resources/mixins.perspectivemod.json
@@ -0,0 +1,12 @@
+{
+ "required": true,
+ "minVersion": "0.7.10",
+ "package": "me.djtheredstoner.perspectivemod.mixins",
+ "refmap": "mixins.perspectivemod.refmap.json",
+ "target": "@env(DEFAULT)",
+ "compatibilityLevel": "JAVA_8",
+ "mixins": [
+ "MixinEntityRenderer",
+ "MixinRenderManager"
+ ]
+} \ No newline at end of file