diff options
author | Alexey Krainev <xmrvizzy@ya.ru> | 2020-12-29 00:31:54 +0500 |
---|---|---|
committer | Alexey Krainev <xmrvizzy@ya.ru> | 2020-12-29 00:31:54 +0500 |
commit | 86f99ac522624f6e99f45bb252c51cc6935658e0 (patch) | |
tree | 91d07ea69005c63ec504950b67161a2f60f53c8c | |
download | Skyblocker-86f99ac522624f6e99f45bb252c51cc6935658e0.tar.gz Skyblocker-86f99ac522624f6e99f45bb252c51cc6935658e0.tar.bz2 Skyblocker-86f99ac522624f6e99f45bb252c51cc6935658e0.zip |
First release
20 files changed, 828 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..09cd281f --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..15c18c00 --- /dev/null +++ b/build.gradle @@ -0,0 +1,92 @@ +plugins { + id 'fabric-loom' version '0.5-SNAPSHOT' + id 'maven-publish' +} + +group = project.maven_group +version = project.mod_version +archivesBaseName = project.archives_base_name + +repositories { + jcenter() + maven { + url "https://maven.falseresync.ru" + } +} + +dependencies { + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" + + // StopModReposts + include "org.stopmodreposts:Splash-Screen-Mod-Fabric:1.0.1" + + // Cloth API + include "me.shedaniel.cloth:config-2:4.8.3" + modApi("me.shedaniel.cloth:config-2:4.8.3") { + exclude(group: "net.fabricmc.fabric-api") + } + + // Auto Config + include "me.sargunvohra.mcmods:autoconfig1u:3.3.1" + modApi("me.sargunvohra.mcmods:autoconfig1u:3.3.1") { + exclude(group: "net.fabricmc.fabric-api") + } + + // Mod Menu + modImplementation "io.github.prospector:modmenu:1.14.13+build.19" +} + +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + +processResources { + inputs.property "version", project.version + + from(sourceSets.main.resources.srcDirs) { + include "fabric.mod.json" + expand "version": project.version + } + + from(sourceSets.main.resources.srcDirs) { + exclude "fabric.mod.json" + } +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + withSourcesJar() +} + +jar { + from("LICENSE") { + rename { "${it}_${project.archivesBaseName}"} + } +} + +publishing { + publications { + mavenJava(MavenPublication) { + artifact(jar) { + builtBy remapJar + } + artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}.jar"){ + builtBy remapJar + } + artifact(sourcesJar) { + builtBy remapSourcesJar + } + } + } + + repositories { + + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..fa78f16d --- /dev/null +++ b/gradle.properties @@ -0,0 +1,12 @@ +org.gradle.jvmargs=-Xmx1G + +# Fabric Properties +minecraft_version=1.16.4 +yarn_mappings=1.16.4+build.7 +loader_version=0.10.8 +fabric_api_version=0.28.3+1.16 + +# Mod Properties +mod_version = 1.0.0 +maven_group = me.xmrvizzy +archives_base_name = skyblocker diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 00000000..e708b1c0 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..be52383e --- /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-6.7-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 00000000..4f906e0c --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or 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 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..107acd32 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@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=. +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%" == "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%"=="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/settings.gradle b/settings.gradle new file mode 100644 index 00000000..5b60df3d --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + jcenter() + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + gradlePluginPortal() + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java new file mode 100644 index 00000000..65d207c1 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java @@ -0,0 +1,19 @@ +package me.xmrvizzy.skyblocker; + +import net.fabricmc.api.ClientModInitializer; +import me.xmrvizzy.skyblocker.config.SkyblockerConfig; + +public class SkyblockerMod implements ClientModInitializer { + public static final String NAMESPACE = "skyblocker"; + private static SkyblockerMod INSTANCE; + + @Override + public void onInitializeClient() { + INSTANCE = this; + SkyblockerConfig.init(); + } + + public static SkyblockerMod get() { + return INSTANCE; + } +}
\ No newline at end of file diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java new file mode 100644 index 00000000..cc3131b2 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java @@ -0,0 +1,53 @@ +package me.xmrvizzy.skyblocker.config; + +import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; +import me.sargunvohra.mcmods.autoconfig1u.ConfigData; +import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; +import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry; +import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer; + +@Config(name = "skyblocker") +public class SkyblockerConfig implements ConfigData { + + @ConfigEntry.Category("general") + @ConfigEntry.Gui.TransitiveObject + public General general = new General(); + + @ConfigEntry.Category("bars") + @ConfigEntry.Gui.TransitiveObject + public Bars bars = new Bars(); + + @ConfigEntry.Category("messages") + @ConfigEntry.Gui.TransitiveObject + public Messages messages = new Messages(); + + public static class General { + public String apiKey; + } + + public static class Bars { + public boolean enableBars = true; + public boolean enableAbsorption = true; + @ConfigEntry.ColorPicker() + public int absorbedHealthColor = 0xffaa00; + @ConfigEntry.ColorPicker() + public int healthColor = 0xff5555; + @ConfigEntry.ColorPicker() + public int manaColor = 0x55ffff; + } + + public static class Messages { + public boolean hideAbility = false; + public boolean hideHeal = false; + public boolean hideAOTE = false; + public boolean hideMidasStaff = false; + } + + public static void init() { + AutoConfig.register(SkyblockerConfig.class, GsonConfigSerializer::new); + } + + public static SkyblockerConfig get() { + return AutoConfig.getConfigHolder(SkyblockerConfig.class).getConfig(); + } +}
\ No newline at end of file diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/modmenu/ModMenuEntry.java b/src/main/java/me/xmrvizzy/skyblocker/config/modmenu/ModMenuEntry.java new file mode 100644 index 00000000..80949a21 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/config/modmenu/ModMenuEntry.java @@ -0,0 +1,17 @@ +package me.xmrvizzy.skyblocker.config.modmenu; + +import io.github.prospector.modmenu.api.ConfigScreenFactory; +import io.github.prospector.modmenu.api.ModMenuApi; +import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import me.xmrvizzy.skyblocker.config.SkyblockerConfig; + +@Environment(EnvType.CLIENT) +public class ModMenuEntry implements ModMenuApi { + + @Override + public ConfigScreenFactory<?> getModConfigScreenFactory() { + return screen -> AutoConfig.getConfigScreen(SkyblockerConfig.class, screen).get(); + } +}
\ No newline at end of file diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/ChatHudListenerMixin.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/ChatHudListenerMixin.java new file mode 100644 index 00000000..f6975243 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/ChatHudListenerMixin.java @@ -0,0 +1,39 @@ +package me.xmrvizzy.skyblocker.mixin; + +import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import net.minecraft.client.gui.hud.ChatHudListener; +import net.minecraft.network.MessageType; +import net.minecraft.text.Text; +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.CallbackInfo; + +import java.util.UUID; + +@Mixin(ChatHudListener.class) +public class ChatHudListenerMixin { + @Inject(method = "onChatMessage", at = @At("HEAD"), cancellable = true) + public void onChatMessage(MessageType messageType, Text message, UUID senderUuid, CallbackInfo ci) { + // Ability Cooldown + if (SkyblockerConfig.get().messages.hideAbility && message.getString().contains("This ability is currently on cooldown for ") || message.getString().contains("No more charges, next one in ")) { + ci.cancel(); + } + + // Heal Message + if (SkyblockerConfig.get().messages.hideHeal && message.getString().contains("You healed ") && message.getString().contains(" health!") || message.getString().contains(" healed you for ")) { + ci.cancel(); + } + + // AOTE + if (SkyblockerConfig.get().messages.hideAOTE && message.getString().contains("There are blocks in the way!")) { + ci.cancel(); + } + + // Midas Staff + if (SkyblockerConfig.get().messages.hideMidasStaff && message.getString().contains("Your Molten Wave hit ")) { + ci.cancel(); + } + } + +}
\ No newline at end of file diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java new file mode 100644 index 00000000..faa80e2b --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java @@ -0,0 +1,166 @@ +package me.xmrvizzy.skyblocker.mixin; + +import com.mojang.blaze3d.systems.RenderSystem; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Final; +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.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import me.xmrvizzy.skyblocker.SkyblockerMod; +import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import me.xmrvizzy.skyblocker.utils.Utils; + +import java.awt.*; + +@Environment(EnvType.CLIENT) +@Mixin(InGameHud.class) +public abstract class InGameHudMixin extends DrawableHelper { + private static final Identifier ICONS = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/icons.png"); + + @Shadow + @Final + private MinecraftClient client; + @Shadow + private int scaledHeight; + @Shadow + private int scaledWidth; + + @Shadow + public abstract TextRenderer getFontRenderer(); + + private String hpColor = "§c"; + private int hpCurrent = 0; + private int hpMax = 0; + private int manaCurrent = 0; + private int manaMax = 0; + + @ModifyVariable(method = "setOverlayMessage(Lnet/minecraft/text/Text;Z)V", at = @At("HEAD")) + private Text setOverlayMessage(Text message) { + if (Utils.isSkyblock() && SkyblockerConfig.get().bars.enableBars) { + String actionBar = message.getString(); + + if (actionBar != null) { + if (actionBar.contains("❤")) { + String[] health = actionBar.split("❤")[0] + .split("/"); + hpColor = health[0].substring(0, 2); + hpCurrent = Integer.parseInt(health[0].replaceAll(hpColor, "")); + hpMax = Integer.parseInt(health[1]); + } + if (actionBar.contains("✎")) { + String[] mana = actionBar.split("✎")[0] + .split("§b"); + mana = mana[mana.length - 1].split("/"); + manaCurrent = Integer.parseInt(mana[0]); + manaMax = Integer.parseInt(mana[1]); + } + if (actionBar.contains("❤") && actionBar.contains("✎")) { + actionBar = actionBar.replaceAll(hpColor + hpCurrent + "/" + hpMax + "❤ ", "").replaceAll(" §b" + manaCurrent + "/" + manaMax + "✎ Mana", ""); + return Text.of(actionBar); + } + } + } + return message; + } + + @Inject(method = "renderStatusBars", at = @At("HEAD"), cancellable = true) + private void renderStatusBars(MatrixStack matrices, CallbackInfo ci) { + if (Utils.isSkyblock() && SkyblockerConfig.get().bars.enableBars) { + ci.cancel(); + + this.client.getTextureManager().bindTexture(ICONS); + this.client.getProfiler().push("skyblockBars"); + { + int left = this.scaledWidth / 2 - 91; + int hpWidth = getWidth(hpCurrent, hpMax); + int manaWidth = getWidth(manaCurrent, manaMax); + + if (hpColor.equals("§6") && SkyblockerConfig.get().bars.enableAbsorption) { + renderBar(matrices, left, hpWidth, SkyblockerConfig.get().bars.absorbedHealthColor); + } else { + renderBar(matrices, left, hpWidth, SkyblockerConfig.get().bars.healthColor); + } + renderBar(matrices, left + 71 + 40, manaWidth, SkyblockerConfig.get().bars.manaColor); + } + this.client.getProfiler().pop(); + + this.client.getProfiler().push("skyblockTexts"); + { + int left = this.scaledWidth / 2 - 90; + String hpText = hpCurrent + "/" + hpMax; + String manaText = manaCurrent + "/" + manaMax; + int hpOffset = (71 - this.getFontRenderer().getWidth(hpText)) / 2; + int manaOffset = (71 - this.getFontRenderer().getWidth(manaText)) / 2; + + if (hpColor.equals("§6") && SkyblockerConfig.get().bars.enableAbsorption) { + renderText(matrices, hpText, left + hpOffset, SkyblockerConfig.get().bars.absorbedHealthColor); + } else { + renderText(matrices, hpText, left + hpOffset, SkyblockerConfig.get().bars.healthColor); + } + renderText(matrices, manaText, left + 71 + 40 + manaOffset, SkyblockerConfig.get().bars.manaColor); + } + this.client.getProfiler().pop(); + + this.client.getTextureManager().bindTexture(DrawableHelper.GUI_ICONS_TEXTURE); + } + } + + @Inject(method = "renderMountHealth", at = @At("HEAD"), cancellable = true) + private void renderMountHealth(MatrixStack matrices, CallbackInfo ci) { + if (Utils.isSkyblock() && SkyblockerConfig.get().bars.enableBars) { + ci.cancel(); + } + } + + private int getWidth(int current, int max) { + int width = 0; + if (current != 0) { + if (current > max) { + width = 71; + } else { + width = current * 71 / max; + } + } else { + width = 0; + } + return width; + } + + private void renderBar(MatrixStack matrices, int left, int filled, int color) { + Color co = new Color(color); + int top = this.scaledHeight - 36; + + RenderSystem.enableBlend(); + RenderSystem.color4f((float) co.getRed() / 255, (float) co.getGreen() / 255, (float) co.getBlue() / 255, 1.0F); + this.drawTexture(matrices, left, top, 0, 0, 71, 5); + + if (filled > 0) { + this.drawTexture(matrices, left, top, 0, 5, filled, 5); + } + + RenderSystem.disableBlend(); + RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + private void renderText(MatrixStack matrices, String str, int left, int color) { + int top = this.scaledHeight - 42; + + this.getFontRenderer().draw(matrices, str, (float) (left + 1), (float) top, 0); + this.getFontRenderer().draw(matrices, str, (float) (left - 1), (float) top, 0); + this.getFontRenderer().draw(matrices, str, (float) left, (float) (top + 1), 0); + this.getFontRenderer().draw(matrices, str, (float) left, (float) (top - 1), 0); + this.getFontRenderer().draw(matrices, str, (float) left, (float) top, color); + } + +}
\ No newline at end of file diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java new file mode 100644 index 00000000..d305370e --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java @@ -0,0 +1,24 @@ +package me.xmrvizzy.skyblocker.utils; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.scoreboard.ScoreboardObjective; +import net.minecraft.text.Text; + +public class Utils { + public static boolean isSkyblock() { + MinecraftClient client = MinecraftClient.getInstance(); + if (client != null && client.world != null && !client.isInSingleplayer()) { + ScoreboardObjective scoreboard = client.world.getScoreboard().getObjectiveForSlot(1); + if (scoreboard != null) { + String name = ""; + for (Text text : scoreboard.getDisplayName().getSiblings()) { + name += text.getString(); + } + if (name.contains("SKYBLOCK")) { + return true; + } + } + } + return false; + } +}
\ No newline at end of file diff --git a/src/main/resources/assets/skyblocker/icon.png b/src/main/resources/assets/skyblocker/icon.png Binary files differnew file mode 100644 index 00000000..fd06812a --- /dev/null +++ b/src/main/resources/assets/skyblocker/icon.png diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json new file mode 100644 index 00000000..cbd23bb1 --- /dev/null +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -0,0 +1,19 @@ +{ + "text.autoconfig.skyblocker.title": "Skyblocker Settings", + + "text.autoconfig.skyblocker.category.general": "General", + "text.autoconfig.skyblocker.option.general.apiKey": "Hypixel API Key", + + "text.autoconfig.skyblocker.category.bars": "Bars", + "text.autoconfig.skyblocker.option.bars.enableBars": "Enable Health & Mana Bars", + "text.autoconfig.skyblocker.option.bars.enableAbsorption": "Enable Absorbed Health", + "text.autoconfig.skyblocker.option.bars.absorbedHealthColor": "Absorbed Health Color", + "text.autoconfig.skyblocker.option.bars.healthColor": "Health Color", + "text.autoconfig.skyblocker.option.bars.manaColor": "Mana Color", + + "text.autoconfig.skyblocker.category.messages": "Messages", + "text.autoconfig.skyblocker.option.messages.hideAbility": "Hide Ability Cooldown", + "text.autoconfig.skyblocker.option.messages.hideHeal": "Hide Heal Messages", + "text.autoconfig.skyblocker.option.messages.hideAOTE": "Hide AOTE Messages", + "text.autoconfig.skyblocker.option.messages.hideMidasStaff": "Hide Midas Staff Messages" +}
\ No newline at end of file diff --git a/src/main/resources/assets/skyblocker/lang/ru_ru.json b/src/main/resources/assets/skyblocker/lang/ru_ru.json new file mode 100644 index 00000000..efb6b5d8 --- /dev/null +++ b/src/main/resources/assets/skyblocker/lang/ru_ru.json @@ -0,0 +1,19 @@ +{ + "text.autoconfig.skyblocker.title": "Настройки Skyblocker", + + "text.autoconfig.skyblocker.category.general": "Основные", + "text.autoconfig.skyblocker.option.general.apiKey": "Hypixel API-ключ", + + "text.autoconfig.skyblocker.category.bars": "Бары", + "text.autoconfig.skyblocker.option.bars.enableBars": "Включить бары здоровья и маны", + "text.autoconfig.skyblocker.option.bars.enableAbsorption": "Включить поглощенное здоровье", + "text.autoconfig.skyblocker.option.bars.absorbedHealthColor": "Цвет поглощенного здоровья", + "text.autoconfig.skyblocker.option.bars.healthColor": "Цвет здоровья", + "text.autoconfig.skyblocker.option.bars.manaColor": "Цвет маны", + + "text.autoconfig.skyblocker.category.messages": "Сообщения", + "text.autoconfig.skyblocker.option.messages.hideAbility": "Скрыть откат способностей", + "text.autoconfig.skyblocker.option.messages.hideHeal": "Скрыть сообщения об исцелении", + "text.autoconfig.skyblocker.option.messages.hideAOTE": "Скрыть сообщения от \"AOTE\"", + "text.autoconfig.skyblocker.option.messages.hideMidasStaff": "Скрыть сообщения от \"Midas Staff\"" +}
\ No newline at end of file diff --git a/src/main/resources/assets/skyblocker/textures/gui/icons.png b/src/main/resources/assets/skyblocker/textures/gui/icons.png Binary files differnew file mode 100644 index 00000000..5eb23b84 --- /dev/null +++ b/src/main/resources/assets/skyblocker/textures/gui/icons.png diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..8f178ef9 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,34 @@ +{ + "schemaVersion": 1, + "id": "skyblocker", + "version": "${version}", + "name": "Skyblocker", + "description": "Hypixel Skyblock Mod", + "authors": ["xMrVizzy"], + "contact": { + "homepage": "https://modrinth.com/mod/skyblocker" + }, + "license": "CC0-1.0", + "icon": "assets/skyblocker/icon.png", + "environment": "*", + "entrypoints": { + "client": [ + "me.xmrvizzy.skyblocker.SkyblockerMod" + ], + "modmenu": [ + "me.xmrvizzy.skyblocker.config.modmenu.ModMenuEntry" + ] + }, + "mixins": [ + "skyblocker.mixins.json" + ], + "depends": { + "fabricloader": ">=0.7.4", + "fabric": "*" + }, + "custom": { + "modmenu:clientsideOnly": true, + "stopmodreposts:showToast": true, + "stopmodreposts:showButton": true + } +} diff --git a/src/main/resources/skyblocker.mixins.json b/src/main/resources/skyblocker.mixins.json new file mode 100644 index 00000000..551bb924 --- /dev/null +++ b/src/main/resources/skyblocker.mixins.json @@ -0,0 +1,12 @@ +{ + "required": true, + "package": "me.xmrvizzy.skyblocker.mixin", + "compatibilityLevel": "JAVA_8", + "client": [ + "InGameHudMixin", + "ChatHudListenerMixin" + ], + "injectors": { + "defaultRequire": 1 + } +}
\ No newline at end of file |