diff --git a/Changelog.md b/Changelog.md index c0a82e45..f022635c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,8 +2,8 @@ All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project follows to [Ragnarök Versioning Convention](https://gist.github.com/Desoroxxx/5d4a45785ce19a6653ba99f72325c703). +The format is based on [Keep a Changelog](https://keepachangelog.com), +and this project follows the [Ragnarök Versioning Convention](https://github.com/Red-Studio-Ragnarok/Commons/blob/main/Ragnar%C3%B6k%20Versioning%20Convention.md). ## [Unreleased] Fancier Block Particles Version 0.8 Changelog @@ -32,6 +32,8 @@ Now weather will follow the current weather, it will rain heavier when a thunder - Weather Particles Render Distance option - Added settings menu - Added experiments menu +- Added error handling +- Added logging ### Changed @@ -57,16 +59,17 @@ Now weather will follow the current weather, it will rain heavier when a thunder - Fixed Memory leak with `FBP##originalEffectRenderer` ([#139]) - Fixed Fancy Block Placement speed being broken because of an accidental change in 0.7 - Fixed new config having no default value +- Fixed particles being rendered on top of the water ### Removed -- Removed Rest On Floor option ([#9]) +- Removed Rest On Floor option - Removed the deprecated Cartoon Mode from the menu ### Optimization - Vectors got a redesign as a result FBP should now be faster and use less VRAM -- Hex colors are now used instead of 4 separate R,G,B and A variables which makes rendering faster ([#10]) +- Hex colors are now used instead of 4 separate R,G,B and A variables which makes rendering faster - As the result of a big code cleanup FBP as a whole should now be faster, load faster and use slightly less resources - Optimized Rendering of Fancy Block Placement and all particles as a result, they should be faster and use slightly less GPU, RAM & VRAM - FBP now uses its own math utilities and Jafama fast math library which should result in better performance @@ -78,10 +81,10 @@ Now weather will follow the current weather, it will rain heavier when a thunder - FBP now use Red Core - GUI's text colors now never uses decimal colors directly and should use when possible hexadecimal colors when possible - Added documentation for Vector2D, Vector3D, and FBPRenderer -- Switched to [Raven] amazing [RetroFuturaGradle] -- Updated to Gradle 8.1.1 +- Switched to [RetroFuturaGradle](https://github.com/GTNewHorizons/RetroFuturaGradle) 1.4.0 +- Updated to [Gradle](https://gradle.org) 8.9 +- Set a minimum Gradle Daemon JVM version requirement - Cleanup build.gradle & gradle.properties -- RFG now automatically updates the version in `ModReference.java` - Cleanup the entire code - Vectors redesign - Major Refactors @@ -89,23 +92,21 @@ Now weather will follow the current weather, it will rain heavier when a thunder - Finished removing useless `@SideOnly` - Removed useless `isRemote` checks - Renamed the plugin from `FMLPlugin` to `FBPPlugin` - -#### Changes in exception handling - -To be written +- Switched to [CurseUpdate](https://forge.curseupdate.com/) for update checking +- Project constants are now handled automatically by [gradle-buildconfig-plugin](https://github.com/gmazzo/gradle-buildconfig-plugin) +- Switched to [Gradle](https://gradle.org) Kotlin DSL +- Switched to the new Group ID +- Switched to the new standard `gradle.properties` ##### Credits -- [WildMihai] for optimizations in `FBPRenderer`, `FBPConfigHandler` and deprecating Rest On Floor ([#9], [#10]) +- [Meldexun](https://github.com/Meldexun) +- [WildMihai](https://github.com/WildMihai) for optimizations in `FBPConfigHandler` and deprecating Rest On Floor ([#9]) [#7]: https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/issues/7 +[#9]: https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/pull/9 [#13]: https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/issues/13 [#139]: https://github.com/TominoCZ/FancyBlockParticles/issues/139 -[#9]: https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/pull/9 -[#10]: https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/pull/10 -[Raven]: https://github.com/eigenraven -[RetroFuturaGradle]: https://github.com/GTNewHorizons/RetroFuturaGradle -[WildMihai]: https://github.com/WildMihai --- @@ -131,7 +132,7 @@ Particles now renders 2.5 times faster (Immense thanks to Rongmario!) ### Optimization - Optimized main class as a result, it should be slightly faster and use slightly less RAM -- Draw calls are now batched which improve rendering performance by 2.5 times ([#5]) +- Draw calls are now batched which improve rendering performance by 2.5 times - Thanks to an immense code cleanup the FBP as a whole should be slightly faster and use slightly less RAM ### Internal @@ -140,9 +141,8 @@ Particles now renders 2.5 times faster (Immense thanks to Rongmario!) ##### Credits -- [Rongmario] for batching draw calls ([#5]) +- [Rongmario](https://github.com/Rongmario) for batching draw calls ([#5]) -[Rongmario]: https://github.com/Rongmario [#5]: https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/pull/5 --- diff --git a/build.gradle b/build.gradle deleted file mode 100644 index facea521..00000000 --- a/build.gradle +++ /dev/null @@ -1,170 +0,0 @@ -import org.jetbrains.gradle.ext.Gradle - -plugins { - id 'java' - id 'java-library' - id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7' - id 'com.gtnewhorizons.retrofuturagradle' version '1.+' - id 'com.matthewprenger.cursegradle' version '1.4.0' -} - -// Add version to the jar name -version project.version - -// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(8)) - vendor.set(JvmVendorSpec.ADOPTIUM) - } - // Generate sources jar when building and publishing - withSourcesJar() -} - -tasks.withType(JavaCompile).configureEach { - options.encoding = 'UTF-8' - options.fork = true - options.forkOptions.jvmArgs += '-Xmx4G' -} - -minecraft { - mcVersion = '1.12.2' - - username = 'Desoroxxx' - - extraRunJvmArguments.addAll('-Xmx6G', '-Xms4G', '-Dforge.logging.console.level=debug', '-Dmixin.hotSwap=true', '-Dmixin.checks.interfaces=true', '-Dmixin.debug.export=true', "-Dfml.coreMods.load=io.redstudioragnarok.${project.id}.asm.FBPPlugin") - - injectedTags.put('ID', project.id) - injectedTags.put('VERSION', project.version) -} - -// Generate a my.project.Tags class with the version number as a field -tasks.injectTags.configure { - outputClassName.set("io.redstudioragnarok.${project.id}.Tags") -} - - -configurations { - // Create configuration to include embedded dependencies into the jar - implementation - compile.extendsFrom(embed) - - // Define a configuration to download and attach sources - sources -} - -repositories { - maven { - name 'Cleanroom' - url 'https://maven.cleanroommc.com' - } - - maven { - name 'SpongePowered' - url 'https://repo.spongepowered.org/maven' - } - - ivy { - name 'Meldexun GitHub Releases' - url 'https://github.com/' - - patternLayout { artifact '[organisation]/[module]/releases/download/v[revision]/[module]-[revision].[ext]' } - - metadataSources { artifact() } - } - - ivy { - name 'Red Studio GitHub Releases' - url 'https://github.com/' - - patternLayout { artifact '[organisation]/[module]/releases/download/[revision]/[module]-[revision](-[classifier]).[ext]' } - - metadataSources { artifact() } - } -} - -dependencies { - implementation 'Red-Studio-Ragnarok:Red-Core:0.4-Dev-1' - sources 'Red-Studio-Ragnarok:Red-Core:0.4-Dev-1:sources@jar' - - implementation 'meldexun:MatrixUtil:1.2.2@jar' - embed 'meldexun:MatrixUtil:1.2.2@jar' - - String mixin = modUtils.enableMixins('zone.rong:mixinbooter:8.3', "mixins.${project.id}.refmap.json") - api (mixin) { transitive = false } - annotationProcessor 'org.ow2.asm:asm-debug-all:5.2' - annotationProcessor 'com.google.guava:guava:24.1.1-jre' - annotationProcessor 'com.google.code.gson:gson:2.8.6' - annotationProcessor (mixin) { transitive = false } -} - -def at = project.files("src/main/resources/META-INF/${project.id}_at.cfg") - -tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at) -tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at) - -// Replace version and id in `mcmod.info` -processResources { - inputs.property 'id', project.id - inputs.property 'version', project.version - filesMatching(['mcmod.info', 'pack.mcmeta']) { fcd -> - include 'mcmod.info' - fcd.expand ( - 'id': project.id, - 'version': project.version - ) - } -} - -jar { - manifest.attributes([ - 'ModSide': 'CLIENT', - 'FMLAT': "${project.id}_at.cfg", - 'FMLCorePlugin': "io.redstudioragnarok.${project.id}.asm.FBPPlugin", - 'FMLCorePluginContainsFMLMod': 'true', - 'ForceLoadAsMod': 'true' - ]) - - // Add all embedded dependencies into the jar - from(provider{ configurations.embed.collect {it.isDirectory() ? it : zipTree(it)} }) -} - -idea { - module { inheritOutputDirs = true } - - module { excludeDirs = [file('.github'), file('.gradle'), file('.idea'), file('build'), file('gradle'), file('run')] } - - project { settings { - runConfigurations { - 'Client'(Gradle) { - taskNames = ['runClient'] - } - 'Server'(Gradle) { - taskNames = ['runServer'] - } - 'Obfuscated Client'(Gradle) { - taskNames = ['runObfClient'] - } - 'Obfuscated Server'(Gradle) { - taskNames = ['runObfServer'] - } - 'Vanilla Client'(Gradle) { - taskNames = ['runVanillaClient'] - } - 'Vanilla Server'(Gradle) { - taskNames = ['runVanillaServer'] - } - } - - compiler.javac { - afterEvaluate { - javacAdditionalOptions = '-encoding utf8' - moduleJavacAdditionalOptions = [ (project.id + '.main'): tasks.compileJava.options.compilerArgs.collect { ''' + it + ''' }.join(' ') ] - } - } - }} -} - -tasks.named('processIdeaSettings').configure { - dependsOn('injectTags') -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..161c3640 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,208 @@ +import org.jetbrains.gradle.ext.settings +import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel +import org.jetbrains.gradle.ext.Gradle +import org.jetbrains.gradle.ext.runConfigurations + +plugins { + id("com.gtnewhorizons.retrofuturagradle") version "1.4.0" + id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.8" + id("com.github.gmazzo.buildconfig") version "5.3.5" + id("io.freefair.lombok") version "8.6" +} + +group = "dev.redstudio" +version = "0.8-Dev-17" // Versioning must follow Ragnarök versioning convention: https://github.com/Red-Studio-Ragnarok/Commons/blob/main/Ragnar%C3%B6k%20Versioning%20Convention.md + +val realName = "Fancier Block Particles" +val id = "fbp" +val plugin = "${project.group}.${id}.asm.FBPPlugin" + +val redCoreVersion = "MC-1.8-1.12-" + "0.6-Dev-5" +val matrixUtilVersion = "1.2.2" + +minecraft { + mcVersion = "1.12.2" + username = "Desoroxxx" + extraRunJvmArguments = listOf("-Dforge.logging.console.level=debug", "-Dfml.coreMods.load=${plugin}", "-Dmixin.hotSwap=true", "-Dmixin.checks.mixininterfaces=true", "-Dmixin.debug.export=true") +} + +repositories { + maven { + name = "Cleanroom" + url = uri("https://maven.cleanroommc.com") + } + + listOf("release", "beta", "dev").forEach { repoType -> + maven { + name = "Red Studio - ${repoType.replaceFirstChar { it.uppercase() }}" + url = uri("https://repo.redstudio.dev/$repoType") + } + } + + exclusiveContent { + forRepository { + maven { + name = "Curse Maven" + url = uri("https://cursemaven.com") + } + } + filter { + includeGroup("curse.maven") + } + } + + ivy { + name = "Meldexun GitHub Releases" + url = uri("https://github.com/") + + patternLayout { + artifact("[organisation]/[module]/releases/download/v[revision]/[module]-[revision].[ext]") + } + + metadataSources { + artifact() + } + } +} + +// Define embedded dependencies configuration +val embed = configurations.create("embed") { + description = "Embedded dependencies" + isTransitive = true +} +configurations.named("implementation").configure { + extendsFrom(embed) +} + +dependencies { + implementation("dev.redstudio", "Red-Core", redCoreVersion) + + embed("meldexun", "MatrixUtil", matrixUtilVersion) + + annotationProcessor("org.ow2.asm", "asm-debug-all", "5.2") + annotationProcessor("com.google.guava", "guava", "32.1.2-jre") + annotationProcessor("com.google.code.gson", "gson", "2.8.9") + + val mixinBooter: String = modUtils.enableMixins("zone.rong:mixinbooter:8.6", "mixins.${id}.refmap.json") as String + api(mixinBooter) { + isTransitive = false + } + annotationProcessor(mixinBooter) { + isTransitive = false + } +} + +buildConfig { + packageName("${project.group}.${id}") + className("ProjectConstants") + documentation.set("This class defines constants for ${realName}.\n

\nThey are automatically updated by Gradle.") + + useJavaOutput() + buildConfigField("String", "ID", provider { """"${id}"""" }) + buildConfigField("String", "NAME", provider { """"${realName}"""" }) + buildConfigField("String", "VERSION", provider { """"${project.version}"""" }) + buildConfigField("org.apache.logging.log4j.Logger", "LOGGER", "org.apache.logging.log4j.LogManager.getLogger(NAME)") + buildConfigField("dev.redstudio.redcore.logging.RedLogger", "RED_LOGGER", """new RedLogger(NAME, "", LOGGER, "Hang in there, just a minor bump on the road to particle greatness!")""") +} + +idea { + module { + inheritOutputDirs = true + + excludeDirs = setOf( + file(".github"), file(".gradle"), file(".idea"), file("build"), file("gradle"), file("run") + ) + } + + project { + settings { + jdkName = "1.8" + languageLevel = IdeaLanguageLevel("JDK_1_8") + + runConfigurations { + create("Client", Gradle::class.java) { + taskNames = setOf("runClient") + } + create("Server", Gradle::class.java) { + taskNames = setOf("runServer") + } + create("Obfuscated Client", Gradle::class.java) { + taskNames = setOf("runObfClient") + } + create("Obfuscated Server", Gradle::class.java) { + taskNames = setOf("runObfServer") + } + create("Vanilla Client", Gradle::class.java) { + taskNames = setOf("runVanillaClient") + } + create("Vanilla Server", Gradle::class.java) { + taskNames = setOf("runVanillaServer") + } + } + } + } +} + +// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + vendor.set(JvmVendorSpec.ADOPTIUM) + } + withSourcesJar() // Generate sources jar when building and publishing +} + +tasks.processResources.configure { + inputs.property("version", project.version) + inputs.property("id", id) + + filesMatching("mcmod.info") { + expand(mapOf("version" to project.version, "id" to id)) + } +} + +val at = project.files("src/main/resources/META-INF/${id}_at.cfg") + +tasks.deobfuscateMergedJarToSrg.configure { + accessTransformerFiles.from(at) +} + +tasks.srgifyBinpatchedJar.configure { + accessTransformerFiles.from(at) +} + +tasks.processResources.configure { + inputs.property("version", project.version) + inputs.property("id", id) + + filesMatching("mcmod.info") { + expand(mapOf("version" to project.version, "id" to id)) + } +} + +tasks.named("jar") { + manifest { + attributes( + "ModSide" to "CLIENT", + "FMLAT" to "${id}_at.cfg", + "FMLCorePlugin" to "${plugin}", + "FMLCorePluginContainsFMLMod" to "true", + "ForceLoadAsMod" to "true" + ) + } +} + +// Include embedded dependencies into the jar +tasks.named("jar").configure { + dependsOn(configurations.getByName("embed")) + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + from({ + configurations.getByName("embed").map { if (it.isDirectory) it else zipTree(it) } + }) +} + +tasks.withType().configureEach { + options.encoding = "UTF-8" + options.isFork = true + options.forkOptions.jvmArgs = listOf("-Xmx4G") +} diff --git a/gradle.properties b/gradle.properties index 09eb2761..0e85e337 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,7 @@ -# Sets default memory used for Gradle commands. Can be overridden by user or command line properties. -# This is required to provide enough memory for the Minecraft decompilation process. -org.gradle.jvmargs = -Xmx4G -# Allow Gradle to use multi threading. -org.gradle.parallel = true -# Allow Gradle to cache build to avoid recompiling classes that did not change. +org.gradle.jvmargs = -Xmx4G -XX:+UseZGC -XX:+ZGenerational -XX:+UseStringDeduplication -XX:+DisableExplicitGC + org.gradle.caching = true +#org.gradle.configuration-cache = true Currently incompatible with RFG +org.gradle.configureondemand = true -# Mod Constants -# Versioning must follow Ragnarök versioning convention: https://shor.cz/ragnarok_versioning_convention -id = fbp -version = 0.8-Dev-16 +org.gradle.parallel = true diff --git a/gradle/gradle-daemon-jvm.properties b/gradle/gradle-daemon-jvm.properties new file mode 100644 index 00000000..52234b5c --- /dev/null +++ b/gradle/gradle-daemon-jvm.properties @@ -0,0 +1 @@ +toolchainVersion=21 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fae08049..19cfad96 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew deleted file mode 100644 index a69d9cb6..00000000 --- a/gradlew +++ /dev/null @@ -1,240 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original 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 POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${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 "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# 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 ;; #( - MSYS* | 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" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/settings.gradle b/settings.gradle.kts similarity index 60% rename from settings.gradle rename to settings.gradle.kts index 904f3e67..71b5f437 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -1,13 +1,14 @@ +rootProject.name = "Fancier Block Particles" + pluginManagement { repositories { maven { // RetroFuturaGradle name = "GTNH Maven" - url = uri("http://jenkins.usrv.eu:8081/nexus/content/groups/public/") - allowInsecureProtocol = true + url = uri("https://nexus.gtnewhorizons.com/repository/public/") mavenContent { + includeGroupByRegex("com\\.gtnewhorizons\\..+") includeGroup("com.gtnewhorizons") - includeGroup("com.gtnewhorizons.retrofuturagradle") } } gradlePluginPortal() @@ -17,6 +18,5 @@ pluginManagement { } plugins { - // Automatic toolchain provisioning - id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0" + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" // Automatic toolchain provisioning } diff --git a/src/main/java/io/redstudioragnarok/fbp/FBP.java b/src/main/java/dev/redstudio/fbp/FBP.java similarity index 79% rename from src/main/java/io/redstudioragnarok/fbp/FBP.java rename to src/main/java/dev/redstudio/fbp/FBP.java index fb5c61cd..0542c5cf 100644 --- a/src/main/java/io/redstudioragnarok/fbp/FBP.java +++ b/src/main/java/dev/redstudio/fbp/FBP.java @@ -1,10 +1,9 @@ -package io.redstudioragnarok.fbp; +package dev.redstudio.fbp; -import io.redstudioragnarok.fbp.block.AnimationDummyBlock; -import io.redstudioragnarok.fbp.handlers.*; -import io.redstudioragnarok.fbp.keys.KeyBindings; -import io.redstudioragnarok.fbp.particles.FBPParticleManager; -import io.redstudioragnarok.fbp.utils.ModReference; +import dev.redstudio.fbp.block.AnimationDummyBlock; +import dev.redstudio.fbp.handlers.*; +import dev.redstudio.fbp.keys.KeyBindings; +import dev.redstudio.fbp.particles.FBPParticleManager; import meldexun.matrixutil.MathUtil; import net.jafama.FastMath; import net.minecraft.block.material.Material; @@ -24,6 +23,8 @@ import java.util.List; import java.util.SplittableRandom; +import static dev.redstudio.fbp.ProjectConstants.*; + // /$$$$$$$$ /$$ /$$$$$$$ /$$ /$$ /$$$$$$$ /$$ /$$ /$$ // | $$_____/ |__/ | $$__ $$| $$ | $$ | $$__ $$ | $$ |__/ | $$ // | $$ /$$$$$$ /$$$$$$$ /$$$$$$$ /$$ /$$$$$$ /$$$$$$ | $$ \ $$| $$ /$$$$$$ /$$$$$$$| $$ /$$ | $$ \ $$ /$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$$$$$$| $$ /$$$$$$ /$$$$$$$ @@ -32,10 +33,10 @@ // | $$ /$$__ $$| $$ | $$| $$ | $$| $$_____/| $$ | $$ \ $$| $$| $$ | $$| $$ | $$_ $$ | $$ /$$__ $$| $$ | $$ /$$| $$| $$ | $$| $$_____/ \____ $$ // | $$ | $$$$$$$| $$ | $$| $$$$$$$| $$| $$$$$$$| $$ | $$$$$$$/| $$| $$$$$$/| $$$$$$$| $$ \ $$ | $$ | $$$$$$$| $$ | $$$$/| $$| $$$$$$$| $$| $$$$$$$ /$$$$$$$/ // |__/ \_______/|__/ |__/ \_______/|__/ \_______/|__/ |_______/ |__/ \______/ \_______/|__/ \__/ |__/ \_______/|__/ \___/ |__/ \_______/|__/ \_______/|_______/ -@Mod(clientSideOnly = true, modid = ModReference.ID, name = ModReference.NAME, version = ModReference.VERSION, dependencies = "required-after:redcore@[0.4-Dev-1,)", guiFactory = "io.redstudioragnarok.fbp.config.FBPConfigGuiFactory", updateJSON = "https://raw.githubusercontent.com/Red-Studio-Ragnarok/Fancier-Block-Particles/main/update.json") +@Mod(clientSideOnly = true, modid = ID, name = NAME, version = VERSION, dependencies = "required-after:redcore@[0.4-Dev-3,)", guiFactory = "dev.redstudio.fbp.config.FBPConfigGuiFactory", updateJSON = "https://forge.curseupdate.com/666575/fbp") public class FBP { - public static final Minecraft mc = Minecraft.getMinecraft(); + public static final Minecraft MC = Minecraft.getMinecraft(); public static final ResourceLocation PARTICLES_TEXTURE = new ResourceLocation("textures/particle/particles.png"); @@ -62,15 +63,15 @@ public class FBP { public static List blockParticleBlacklist = new ArrayList<>(); public static List blockAnimBlacklist = new ArrayList<>(); - public static final SplittableRandom random = new SplittableRandom(); + public static final SplittableRandom RANDOM = new SplittableRandom(); public static IRenderHandler fancyWeatherRenderer, originalWeatherRenderer; public static FBPParticleManager fancyEffectRenderer; public static ParticleManager originalEffectRenderer; - public static final AnimationDummyBlock dummyBlock = new AnimationDummyBlock(); + public static final AnimationDummyBlock DUMMY_BLOCK = new AnimationDummyBlock(); - public static final VertexFormat vertexFormat = new VertexFormat(); + public static final VertexFormat VERTEX_FORMAT = new VertexFormat(); @Mod.EventHandler public void preInit(FMLPreInitializationEvent preInitializationEvent) { @@ -103,11 +104,11 @@ public void init(FMLInitializationEvent initializationEvent) { updateDebugHandler(); - vertexFormat.addElement(DefaultVertexFormats.POSITION_3F); - vertexFormat.addElement(DefaultVertexFormats.TEX_2F); - vertexFormat.addElement(DefaultVertexFormats.COLOR_4UB); - vertexFormat.addElement(DefaultVertexFormats.TEX_2S); - vertexFormat.addElement(DefaultVertexFormats.NORMAL_3B); + VERTEX_FORMAT.addElement(DefaultVertexFormats.POSITION_3F); + VERTEX_FORMAT.addElement(DefaultVertexFormats.TEX_2F); + VERTEX_FORMAT.addElement(DefaultVertexFormats.COLOR_4UB); + VERTEX_FORMAT.addElement(DefaultVertexFormats.TEX_2S); + VERTEX_FORMAT.addElement(DefaultVertexFormats.NORMAL_3B); } /** @@ -120,15 +121,15 @@ public static void setEnabled(boolean newState) { if (newState) { fancyEffectRenderer.carryOver(); - mc.effectRenderer = fancyEffectRenderer; + MC.effectRenderer = fancyEffectRenderer; - if (mc.world != null && fancyWeather) - mc.world.provider.setWeatherRenderer(fancyWeatherRenderer); + if (MC.world != null && fancyWeather) + MC.world.provider.setWeatherRenderer(fancyWeatherRenderer); } else { - mc.effectRenderer = originalEffectRenderer; + MC.effectRenderer = originalEffectRenderer; - if (mc.world != null) - mc.world.provider.setWeatherRenderer(originalWeatherRenderer); + if (MC.world != null) + MC.world.provider.setWeatherRenderer(originalWeatherRenderer); frozen = false; } diff --git a/src/main/java/io/redstudioragnarok/fbp/asm/FBPPlugin.java b/src/main/java/dev/redstudio/fbp/asm/FBPPlugin.java similarity index 89% rename from src/main/java/io/redstudioragnarok/fbp/asm/FBPPlugin.java rename to src/main/java/dev/redstudio/fbp/asm/FBPPlugin.java index 1b1f74cc..0777277e 100644 --- a/src/main/java/io/redstudioragnarok/fbp/asm/FBPPlugin.java +++ b/src/main/java/dev/redstudio/fbp/asm/FBPPlugin.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.asm; +package dev.redstudio.fbp.asm; import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; import zone.rong.mixinbooter.IEarlyMixinLoader; @@ -27,7 +27,7 @@ public String getSetupClass() { } @Override - public void injectData(Map data) { + public void injectData(final Map data) { } diff --git a/src/main/java/io/redstudioragnarok/fbp/block/AnimationDummyBlock.java b/src/main/java/dev/redstudio/fbp/block/AnimationDummyBlock.java similarity index 96% rename from src/main/java/io/redstudioragnarok/fbp/block/AnimationDummyBlock.java rename to src/main/java/dev/redstudio/fbp/block/AnimationDummyBlock.java index 1f936d29..56612291 100644 --- a/src/main/java/io/redstudioragnarok/fbp/block/AnimationDummyBlock.java +++ b/src/main/java/dev/redstudio/fbp/block/AnimationDummyBlock.java @@ -1,11 +1,10 @@ -package io.redstudioragnarok.fbp.block; - -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.handlers.EventHandler; -import io.redstudioragnarok.fbp.material.DummyMaterial; -import io.redstudioragnarok.fbp.node.BlockNode; -import io.redstudioragnarok.fbp.particles.FBPParticleBlock; -import io.redstudioragnarok.fbp.utils.ModReference; +package dev.redstudio.fbp.block; + +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.handlers.EventHandler; +import dev.redstudio.fbp.material.DummyMaterial; +import dev.redstudio.fbp.node.BlockNode; +import dev.redstudio.fbp.particles.FBPParticleBlock; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.state.IBlockState; @@ -32,6 +31,8 @@ import java.util.Random; import java.util.concurrent.ConcurrentHashMap; +import static dev.redstudio.fbp.ProjectConstants.ID; + public class AnimationDummyBlock extends Block { public ConcurrentHashMap blockNodes = new ConcurrentHashMap<>(); @@ -39,7 +40,7 @@ public class AnimationDummyBlock extends Block { public AnimationDummyBlock() { super(new DummyMaterial()); - this.setRegistryName(new ResourceLocation(ModReference.ID, "FBPPlaceholderBlock")); + this.setRegistryName(new ResourceLocation(ID, "FBPPlaceholderBlock")); this.translucent = true; } @@ -261,7 +262,7 @@ public float getBlockHardness(IBlockState blockState, World w, BlockPos pos) { @Override public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) { try { - BlockNode node = FBP.dummyBlock.blockNodes.get(pos); + BlockNode node = FBP.DUMMY_BLOCK.blockNodes.get(pos); if (node == null) return; diff --git a/src/main/java/io/redstudioragnarok/fbp/config/FBPConfigGuiFactory.java b/src/main/java/dev/redstudio/fbp/config/FBPConfigGuiFactory.java similarity index 60% rename from src/main/java/io/redstudioragnarok/fbp/config/FBPConfigGuiFactory.java rename to src/main/java/dev/redstudio/fbp/config/FBPConfigGuiFactory.java index d3b1c7fa..10acd546 100644 --- a/src/main/java/io/redstudioragnarok/fbp/config/FBPConfigGuiFactory.java +++ b/src/main/java/dev/redstudio/fbp/config/FBPConfigGuiFactory.java @@ -1,16 +1,16 @@ -package io.redstudioragnarok.fbp.config; +package dev.redstudio.fbp.config; -import io.redstudioragnarok.fbp.gui.pages.Page0; +import dev.redstudio.fbp.gui.pages.Page0; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.fml.client.IModGuiFactory; import java.util.Set; -public class FBPConfigGuiFactory implements IModGuiFactory { +public final class FBPConfigGuiFactory implements IModGuiFactory { @Override - public void initialize(Minecraft minecraftInstance) { + public void initialize(final Minecraft minecraft) { } @Override @@ -19,7 +19,7 @@ public boolean hasConfigGui() { } @Override - public GuiScreen createConfigGui(GuiScreen parentScreen) { + public GuiScreen createConfigGui(final GuiScreen parentScreen) { return new Page0(); } diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/BasePage.java b/src/main/java/dev/redstudio/fbp/gui/BasePage.java similarity index 90% rename from src/main/java/io/redstudioragnarok/fbp/gui/BasePage.java rename to src/main/java/dev/redstudio/fbp/gui/BasePage.java index 837e288c..974e487f 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/BasePage.java +++ b/src/main/java/dev/redstudio/fbp/gui/BasePage.java @@ -1,12 +1,11 @@ -package io.redstudioragnarok.fbp.gui; - -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.elements.*; -import io.redstudioragnarok.fbp.gui.pages.Page0; -import io.redstudioragnarok.fbp.gui.pages.PageExperiments; -import io.redstudioragnarok.fbp.gui.pages.PageSettings; -import io.redstudioragnarok.fbp.handlers.ConfigHandler; -import io.redstudioragnarok.fbp.utils.ModReference; +package dev.redstudio.fbp.gui; + +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.gui.elements.*; +import dev.redstudio.fbp.gui.pages.Page0; +import dev.redstudio.fbp.gui.pages.PageExperiments; +import dev.redstudio.fbp.gui.pages.PageSettings; +import dev.redstudio.fbp.handlers.ConfigHandler; import io.redstudioragnarok.redcore.utils.MathUtil; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; @@ -19,8 +18,10 @@ import java.net.URI; import java.util.Arrays; -import static io.redstudioragnarok.fbp.gui.GuiConfirmation.Action.DefaultConfig; -import static io.redstudioragnarok.fbp.gui.elements.Button.ButtonSize.*; +import static dev.redstudio.fbp.ProjectConstants.NAME; +import static dev.redstudio.fbp.ProjectConstants.VERSION; +import static dev.redstudio.fbp.gui.GuiConfirmation.Action.DefaultConfig; +import static dev.redstudio.fbp.gui.elements.Button.ButtonSize.*; public abstract class BasePage extends GuiBase { @@ -81,8 +82,8 @@ protected void actionPerformed(final GuiButton button) { if (!isSettings && !isExperiments) { mc.displayGuiScreen(null); - if (FBP.mc.world != null) - FBP.mc.entityRenderer.stopUseShader(); + if (FBP.MC.world != null) + FBP.MC.entityRenderer.stopUseShader(); } else mc.displayGuiScreen(new Page0()); break; @@ -175,14 +176,14 @@ public void drawScreen(final int mouseXIn, final int mouseYIn, final float parti if (!FBP.enabled) drawCenteredString("§L= " + I18n.format("menu.disabled") + " =", GuiUtils.RED, middleX, y - 193); - drawCenteredString("§L= " + I18n.format("fbp.name") + " =", "#FFAA00", middleX, y - 183); + drawCenteredString("§L= " + NAME + " =", "#FFAA00", middleX, y - 183); if (isSettings) drawCenteredString("§L= " + I18n.format("menu.settings") + " =", GuiUtils.GREEN, middleX, y - 173); else if (isExperiments) drawCenteredString("§L= " + I18n.format("menu.experiments") + " =", GuiUtils.GREEN, middleX, y - 173); else - drawCenteredString("§L= " + ModReference.VERSION + " =", GuiUtils.GREEN, middleX, y - 173); + drawCenteredString("§L= " + VERSION + " =", GuiUtils.GREEN, middleX, y - 173); if (targetHoverBoxY > 0) updateSliderHoverBox(); @@ -223,8 +224,8 @@ protected void keyTyped(final char typedChar, final int keyCode) throws IOExcept if (keyCode == 1) { mc.displayGuiScreen(null); - if (FBP.mc.world != null) - FBP.mc.entityRenderer.stopUseShader(); + if (FBP.MC.world != null) + FBP.MC.entityRenderer.stopUseShader(); return; } diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/GuiBase.java b/src/main/java/dev/redstudio/fbp/gui/GuiBase.java similarity index 84% rename from src/main/java/io/redstudioragnarok/fbp/gui/GuiBase.java rename to src/main/java/dev/redstudio/fbp/gui/GuiBase.java index af5377b3..1c7e7290 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/GuiBase.java +++ b/src/main/java/dev/redstudio/fbp/gui/GuiBase.java @@ -1,6 +1,6 @@ -package io.redstudioragnarok.fbp.gui; +package dev.redstudio.fbp.gui; -import io.redstudioragnarok.fbp.FBP; +import dev.redstudio.fbp.FBP; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.util.ResourceLocation; @@ -23,16 +23,16 @@ public void updateScreen() { @Override public void onGuiClosed() { - if (FBP.mc.world != null) - FBP.mc.entityRenderer.stopUseShader(); + if (FBP.MC.world != null) + FBP.MC.entityRenderer.stopUseShader(); } protected void drawBackground(final int mouseXIn, final int mouseYIn) { mouseX = mouseXIn; mouseY = mouseYIn; - if (FBP.mc.world != null) { - final EntityRenderer entityRenderer = FBP.mc.entityRenderer; + if (FBP.MC.world != null) { + final EntityRenderer entityRenderer = FBP.MC.entityRenderer; if (entityRenderer.getShaderGroup() == null || !entityRenderer.getShaderGroup().getShaderGroupName().equals("minecraft:shaders/post/blur.json")) entityRenderer.loadShader(new ResourceLocation("minecraft", "shaders/post/blur.json")); diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/GuiBlacklist.java b/src/main/java/dev/redstudio/fbp/gui/GuiBlacklist.java similarity index 90% rename from src/main/java/io/redstudioragnarok/fbp/gui/GuiBlacklist.java rename to src/main/java/dev/redstudio/fbp/gui/GuiBlacklist.java index dd633006..1629748b 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/GuiBlacklist.java +++ b/src/main/java/dev/redstudio/fbp/gui/GuiBlacklist.java @@ -1,12 +1,12 @@ -package io.redstudioragnarok.fbp.gui; - -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.elements.Button; -import io.redstudioragnarok.fbp.gui.elements.ButtonBlacklist; -import io.redstudioragnarok.fbp.handlers.ConfigHandler; -import io.redstudioragnarok.fbp.handlers.KeyInputHandler; -import io.redstudioragnarok.fbp.keys.KeyBindings; -import io.redstudioragnarok.fbp.models.ModelHelper; +package dev.redstudio.fbp.gui; + +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.gui.elements.Button; +import dev.redstudio.fbp.gui.elements.ButtonBlacklist; +import dev.redstudio.fbp.handlers.ConfigHandler; +import dev.redstudio.fbp.handlers.KeyInputHandler; +import dev.redstudio.fbp.keys.KeyBindings; +import dev.redstudio.fbp.models.ModelHelper; import io.redstudioragnarok.redcore.utils.MathUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockDoublePlant; @@ -26,7 +26,7 @@ import java.util.Arrays; -import static io.redstudioragnarok.fbp.gui.elements.Button.ButtonSize.guideSize; +import static dev.redstudio.fbp.gui.elements.Button.ButtonSize.guideSize; public class GuiBlacklist extends GuiBase { @@ -41,7 +41,7 @@ public class GuiBlacklist extends GuiBase { private final ItemStack targetItemStack; public GuiBlacklist(final BlockPos target) { - mc = FBP.mc; + mc = FBP.MC; targetBlockPos = target; targetBlockState = mc.world.getBlockState(targetBlockPos); @@ -50,7 +50,7 @@ public GuiBlacklist(final BlockPos target) { } public GuiBlacklist(final ItemStack itemStack) { - mc = FBP.mc; + mc = FBP.MC; targetBlockPos = null; targetBlockState = Block.getStateById(Item.getIdFromItem(itemStack.getItem())); @@ -91,7 +91,7 @@ public void updateScreen() { KeyInputHandler.onInput(); } - if (!Keyboard.isKeyDown(KeyBindings.blacklistGUI.getKeyCode()) || (targetBlockPos == null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))) + if (!Keyboard.isKeyDown(KeyBindings.BLACKLIST_GUI.getKeyCode()) || (targetBlockPos == null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))) keyReleased = true; if (closing || keyReleased) { diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/GuiConfirmation.java b/src/main/java/dev/redstudio/fbp/gui/GuiConfirmation.java similarity index 87% rename from src/main/java/io/redstudioragnarok/fbp/gui/GuiConfirmation.java rename to src/main/java/dev/redstudio/fbp/gui/GuiConfirmation.java index 10401060..c6aec90a 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/GuiConfirmation.java +++ b/src/main/java/dev/redstudio/fbp/gui/GuiConfirmation.java @@ -1,14 +1,14 @@ -package io.redstudioragnarok.fbp.gui; +package dev.redstudio.fbp.gui; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.elements.Button; -import io.redstudioragnarok.fbp.handlers.ConfigHandler; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.gui.elements.Button; +import dev.redstudio.fbp.handlers.ConfigHandler; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; import java.io.IOException; -import static io.redstudioragnarok.fbp.gui.elements.Button.ButtonSize.medium; +import static dev.redstudio.fbp.gui.elements.Button.ButtonSize.medium; public class GuiConfirmation extends GuiBase { diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/GuiHud.java b/src/main/java/dev/redstudio/fbp/gui/GuiHud.java similarity index 53% rename from src/main/java/io/redstudioragnarok/fbp/gui/GuiHud.java rename to src/main/java/dev/redstudio/fbp/gui/GuiHud.java index 3ac975c3..a51dec9a 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/GuiHud.java +++ b/src/main/java/dev/redstudio/fbp/gui/GuiHud.java @@ -1,13 +1,13 @@ -package io.redstudioragnarok.fbp.gui; +package dev.redstudio.fbp.gui; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; -import static io.redstudioragnarok.fbp.FBP.mc; +import static dev.redstudio.fbp.FBP.MC; public class GuiHud extends Gui { public GuiHud(final String text, final String color) { - mc.fontRenderer.drawStringWithShadow(text, ((float) new ScaledResolution(mc).getScaledWidth() / 2 - (float) mc.fontRenderer.getStringWidth(text) / 2), 5, GuiUtils.hexToDecimalColor(color)); + MC.fontRenderer.drawStringWithShadow(text, ((float) new ScaledResolution(MC).getScaledWidth() / 2 - (float) MC.fontRenderer.getStringWidth(text) / 2), 5, GuiUtils.hexToDecimalColor(color)); } } diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/GuiUtils.java b/src/main/java/dev/redstudio/fbp/gui/GuiUtils.java similarity index 93% rename from src/main/java/io/redstudioragnarok/fbp/gui/GuiUtils.java rename to src/main/java/dev/redstudio/fbp/gui/GuiUtils.java index f5f1234f..3776dff5 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/GuiUtils.java +++ b/src/main/java/dev/redstudio/fbp/gui/GuiUtils.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.gui; +package dev.redstudio.fbp.gui; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; @@ -7,7 +7,7 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.util.Color; -import static io.redstudioragnarok.fbp.utils.ModReference.RED_LOG; +import static dev.redstudio.fbp.ProjectConstants.RED_LOGGER; public class GuiUtils { @@ -67,7 +67,7 @@ public static int hexToDecimalColor(final String hexColor) { } catch (NumberFormatException numberFormatException) { // Todo: (Debug Mode) This should count to the problem counter - RED_LOG.printFramedError("GUI Rendering", "Hexadecimal to decimal color conversion failed", "Non critical exception falling back to white", numberFormatException.getMessage(), "At:" + numberFormatException.getStackTrace()[3].toString()); + RED_LOGGER.printFramedError("GUI Rendering", "Hexadecimal to decimal color conversion failed", "Non critical exception falling back to white", numberFormatException.getMessage(), "At:" + numberFormatException.getStackTrace()[3].toString()); // Return the decimal value for white return 16777215; diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/InteractiveElement.java b/src/main/java/dev/redstudio/fbp/gui/InteractiveElement.java similarity index 85% rename from src/main/java/io/redstudioragnarok/fbp/gui/InteractiveElement.java rename to src/main/java/dev/redstudio/fbp/gui/InteractiveElement.java index 166a17fb..bd73c261 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/InteractiveElement.java +++ b/src/main/java/dev/redstudio/fbp/gui/InteractiveElement.java @@ -1,18 +1,18 @@ -package io.redstudioragnarok.fbp.gui; +package dev.redstudio.fbp.gui; -import io.redstudioragnarok.fbp.utils.ModReference; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; -import static io.redstudioragnarok.fbp.FBP.mc; +import static dev.redstudio.fbp.FBP.MC; +import static dev.redstudio.fbp.ProjectConstants.ID; public abstract class InteractiveElement extends GuiButton { - protected static final FontRenderer fontRenderer = mc.fontRenderer; + protected static final FontRenderer fontRenderer = MC.fontRenderer; - private static final ResourceLocation GUI_TEXTURE = new ResourceLocation(ModReference.ID + ":textures/gui/gui.png"); + private static final ResourceLocation GUI_TEXTURE = new ResourceLocation(ID + ":textures/gui/gui.png"); public InteractiveElement(final int id, final int x, final int y, final String text, boolean... disabled) { super(id, x, y, text); @@ -27,7 +27,7 @@ public InteractiveElement(final int id, final int x, final int y, final String t protected abstract void update(final int mouseX, final int mouseY); public void startDrawing(final boolean lighterOnHover) { - mc.getTextureManager().bindTexture(GUI_TEXTURE); + MC.getTextureManager().bindTexture(GUI_TEXTURE); if (enabled && (!lighterOnHover || !hovered)) GlStateManager.color(0.9F, 0.9F, 0.9F, 1); diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/elements/Button.java b/src/main/java/dev/redstudio/fbp/gui/elements/Button.java similarity index 93% rename from src/main/java/io/redstudioragnarok/fbp/gui/elements/Button.java rename to src/main/java/dev/redstudio/fbp/gui/elements/Button.java index c7e33f7a..3e48fb8a 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/elements/Button.java +++ b/src/main/java/dev/redstudio/fbp/gui/elements/Button.java @@ -1,8 +1,7 @@ -package io.redstudioragnarok.fbp.gui.elements; +package dev.redstudio.fbp.gui.elements; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.GuiUtils; -import io.redstudioragnarok.fbp.gui.InteractiveElement; +import dev.redstudio.fbp.gui.GuiUtils; +import dev.redstudio.fbp.gui.InteractiveElement; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonBlacklist.java b/src/main/java/dev/redstudio/fbp/gui/elements/ButtonBlacklist.java similarity index 87% rename from src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonBlacklist.java rename to src/main/java/dev/redstudio/fbp/gui/elements/ButtonBlacklist.java index 66a697a4..2ab2d158 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonBlacklist.java +++ b/src/main/java/dev/redstudio/fbp/gui/elements/ButtonBlacklist.java @@ -1,7 +1,7 @@ -package io.redstudioragnarok.fbp.gui.elements; +package dev.redstudio.fbp.gui.elements; -import io.redstudioragnarok.fbp.gui.GuiUtils; -import io.redstudioragnarok.fbp.gui.InteractiveElement; +import dev.redstudio.fbp.gui.GuiUtils; +import dev.redstudio.fbp.gui.InteractiveElement; import net.minecraft.client.Minecraft; public class ButtonBlacklist extends InteractiveElement { diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonExperiments.java b/src/main/java/dev/redstudio/fbp/gui/elements/ButtonExperiments.java similarity index 87% rename from src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonExperiments.java rename to src/main/java/dev/redstudio/fbp/gui/elements/ButtonExperiments.java index e007323b..dd695667 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonExperiments.java +++ b/src/main/java/dev/redstudio/fbp/gui/elements/ButtonExperiments.java @@ -1,7 +1,7 @@ -package io.redstudioragnarok.fbp.gui.elements; +package dev.redstudio.fbp.gui.elements; -import io.redstudioragnarok.fbp.gui.GuiUtils; -import io.redstudioragnarok.fbp.gui.InteractiveElement; +import dev.redstudio.fbp.gui.GuiUtils; +import dev.redstudio.fbp.gui.InteractiveElement; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonGlobalToggle.java b/src/main/java/dev/redstudio/fbp/gui/elements/ButtonGlobalToggle.java similarity index 87% rename from src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonGlobalToggle.java rename to src/main/java/dev/redstudio/fbp/gui/elements/ButtonGlobalToggle.java index 41b0e481..b58bfbb6 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonGlobalToggle.java +++ b/src/main/java/dev/redstudio/fbp/gui/elements/ButtonGlobalToggle.java @@ -1,8 +1,8 @@ -package io.redstudioragnarok.fbp.gui.elements; +package dev.redstudio.fbp.gui.elements; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.GuiUtils; -import io.redstudioragnarok.fbp.gui.InteractiveElement; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.gui.GuiUtils; +import dev.redstudio.fbp.gui.InteractiveElement; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonIssue.java b/src/main/java/dev/redstudio/fbp/gui/elements/ButtonIssue.java similarity index 87% rename from src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonIssue.java rename to src/main/java/dev/redstudio/fbp/gui/elements/ButtonIssue.java index 4529931f..557805ec 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonIssue.java +++ b/src/main/java/dev/redstudio/fbp/gui/elements/ButtonIssue.java @@ -1,7 +1,7 @@ -package io.redstudioragnarok.fbp.gui.elements; +package dev.redstudio.fbp.gui.elements; -import io.redstudioragnarok.fbp.gui.GuiUtils; -import io.redstudioragnarok.fbp.gui.InteractiveElement; +import dev.redstudio.fbp.gui.GuiUtils; +import dev.redstudio.fbp.gui.InteractiveElement; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonSettings.java b/src/main/java/dev/redstudio/fbp/gui/elements/ButtonSettings.java similarity index 87% rename from src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonSettings.java rename to src/main/java/dev/redstudio/fbp/gui/elements/ButtonSettings.java index 670c9193..c31b614d 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/elements/ButtonSettings.java +++ b/src/main/java/dev/redstudio/fbp/gui/elements/ButtonSettings.java @@ -1,7 +1,7 @@ -package io.redstudioragnarok.fbp.gui.elements; +package dev.redstudio.fbp.gui.elements; -import io.redstudioragnarok.fbp.gui.GuiUtils; -import io.redstudioragnarok.fbp.gui.InteractiveElement; +import dev.redstudio.fbp.gui.GuiUtils; +import dev.redstudio.fbp.gui.InteractiveElement; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/elements/Slider.java b/src/main/java/dev/redstudio/fbp/gui/elements/Slider.java similarity index 94% rename from src/main/java/io/redstudioragnarok/fbp/gui/elements/Slider.java rename to src/main/java/dev/redstudio/fbp/gui/elements/Slider.java index 585fcfdc..b407d3e4 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/elements/Slider.java +++ b/src/main/java/dev/redstudio/fbp/gui/elements/Slider.java @@ -1,7 +1,7 @@ -package io.redstudioragnarok.fbp.gui.elements; +package dev.redstudio.fbp.gui.elements; -import io.redstudioragnarok.fbp.gui.GuiUtils; -import io.redstudioragnarok.fbp.gui.InteractiveElement; +import dev.redstudio.fbp.gui.GuiUtils; +import dev.redstudio.fbp.gui.InteractiveElement; import io.redstudioragnarok.redcore.utils.MathUtil; import net.minecraft.client.Minecraft; import org.lwjgl.input.Mouse; diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/pages/Page0.java b/src/main/java/dev/redstudio/fbp/gui/pages/Page0.java similarity index 95% rename from src/main/java/io/redstudioragnarok/fbp/gui/pages/Page0.java rename to src/main/java/dev/redstudio/fbp/gui/pages/Page0.java index 638e7dc0..706a4407 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/pages/Page0.java +++ b/src/main/java/dev/redstudio/fbp/gui/pages/Page0.java @@ -1,12 +1,12 @@ -package io.redstudioragnarok.fbp.gui.pages; +package dev.redstudio.fbp.gui.pages; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.BasePage; -import io.redstudioragnarok.fbp.gui.elements.Slider; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.gui.BasePage; +import dev.redstudio.fbp.gui.elements.Slider; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; -import static io.redstudioragnarok.fbp.gui.elements.Button.ButtonSize.small; +import static dev.redstudio.fbp.gui.elements.Button.ButtonSize.small; public class Page0 extends BasePage { diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/pages/Page1.java b/src/main/java/dev/redstudio/fbp/gui/pages/Page1.java similarity index 93% rename from src/main/java/io/redstudioragnarok/fbp/gui/pages/Page1.java rename to src/main/java/dev/redstudio/fbp/gui/pages/Page1.java index ca23a2f4..d19f09f0 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/pages/Page1.java +++ b/src/main/java/dev/redstudio/fbp/gui/pages/Page1.java @@ -1,7 +1,7 @@ -package io.redstudioragnarok.fbp.gui.pages; +package dev.redstudio.fbp.gui.pages; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.BasePage; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.gui.BasePage; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/pages/Page2.java b/src/main/java/dev/redstudio/fbp/gui/pages/Page2.java similarity index 91% rename from src/main/java/io/redstudioragnarok/fbp/gui/pages/Page2.java rename to src/main/java/dev/redstudio/fbp/gui/pages/Page2.java index e8126c43..57709e3c 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/pages/Page2.java +++ b/src/main/java/dev/redstudio/fbp/gui/pages/Page2.java @@ -1,8 +1,8 @@ -package io.redstudioragnarok.fbp.gui.pages; +package dev.redstudio.fbp.gui.pages; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.BasePage; -import io.redstudioragnarok.fbp.handlers.ConfigHandler; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.gui.BasePage; +import dev.redstudio.fbp.handlers.ConfigHandler; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/pages/Page3.java b/src/main/java/dev/redstudio/fbp/gui/pages/Page3.java similarity index 93% rename from src/main/java/io/redstudioragnarok/fbp/gui/pages/Page3.java rename to src/main/java/dev/redstudio/fbp/gui/pages/Page3.java index a54052d9..d19cf49e 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/pages/Page3.java +++ b/src/main/java/dev/redstudio/fbp/gui/pages/Page3.java @@ -1,8 +1,8 @@ -package io.redstudioragnarok.fbp.gui.pages; +package dev.redstudio.fbp.gui.pages; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.BasePage; -import io.redstudioragnarok.fbp.gui.elements.Slider; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.gui.BasePage; +import dev.redstudio.fbp.gui.elements.Slider; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/pages/PageExperiments.java b/src/main/java/dev/redstudio/fbp/gui/pages/PageExperiments.java similarity index 90% rename from src/main/java/io/redstudioragnarok/fbp/gui/pages/PageExperiments.java rename to src/main/java/dev/redstudio/fbp/gui/pages/PageExperiments.java index 90bf41fe..70d97778 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/pages/PageExperiments.java +++ b/src/main/java/dev/redstudio/fbp/gui/pages/PageExperiments.java @@ -1,6 +1,6 @@ -package io.redstudioragnarok.fbp.gui.pages; +package dev.redstudio.fbp.gui.pages; -import io.redstudioragnarok.fbp.gui.BasePage; +import dev.redstudio.fbp.gui.BasePage; import net.minecraft.client.gui.GuiButton; import java.io.IOException; diff --git a/src/main/java/io/redstudioragnarok/fbp/gui/pages/PageSettings.java b/src/main/java/dev/redstudio/fbp/gui/pages/PageSettings.java similarity index 88% rename from src/main/java/io/redstudioragnarok/fbp/gui/pages/PageSettings.java rename to src/main/java/dev/redstudio/fbp/gui/pages/PageSettings.java index becf0818..560fbf26 100644 --- a/src/main/java/io/redstudioragnarok/fbp/gui/pages/PageSettings.java +++ b/src/main/java/dev/redstudio/fbp/gui/pages/PageSettings.java @@ -1,14 +1,14 @@ -package io.redstudioragnarok.fbp.gui.pages; +package dev.redstudio.fbp.gui.pages; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.BasePage; -import io.redstudioragnarok.fbp.gui.GuiConfirmation; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.gui.BasePage; +import dev.redstudio.fbp.gui.GuiConfirmation; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; import java.io.IOException; -import static io.redstudioragnarok.fbp.gui.GuiConfirmation.Action.*; +import static dev.redstudio.fbp.gui.GuiConfirmation.Action.*; public class PageSettings extends BasePage { diff --git a/src/main/java/dev/redstudio/fbp/handlers/ConfigHandler.java b/src/main/java/dev/redstudio/fbp/handlers/ConfigHandler.java new file mode 100644 index 00000000..b9eb5608 --- /dev/null +++ b/src/main/java/dev/redstudio/fbp/handlers/ConfigHandler.java @@ -0,0 +1,678 @@ +package dev.redstudio.fbp.handlers; + +import dev.redstudio.fbp.FBP; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import org.apache.commons.lang3.StringUtils; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; + +import static dev.redstudio.fbp.ProjectConstants.LOGGER; +import static dev.redstudio.fbp.ProjectConstants.RED_LOGGER; + +/** + * This class handle everything related to the config system. + */ +public class ConfigHandler { + + private static FileInputStream fileInputStream; + private static InputStreamReader inputStreamReader; + private static BufferedReader bufferedReader; + + private static PrintWriter writer; + + private static String line; + + /** + * Initializes the configuration system. + *

+ * Check if the config files and folder exists, if not, create them. + * It also checks if the old config files exists, if yes, delete them. + * Then read the config files. + *

+ * Only reads Floating Materials config and Animation Blacklist if theses respective features are enabled. + */ + public static void init() { + ensureConfigFilesExist(); + + deleteOldConfigFiles(); + + readMainConfig(); + + if (FBP.waterPhysics) + readFloatingMaterials(); + + readParticleBlacklist(); + + if (FBP.fancyPlaceAnim) + readAnimBlacklist(); + } + + /** + * Ensure config files exist + *

+ * This method checks if the files and folders in the config folder exists. + * If not, it creates them. + */ + private static void ensureConfigFilesExist() { + try { + if (!Paths.get(FBP.mainConfigFile.getParent()).toFile().exists() && (Paths.get(FBP.mainConfigFile.getParent()).toFile().mkdirs())) + LOGGER.error("Could not create config directory"); + + if (!FBP.mainConfigFile.exists()) { + if (!FBP.mainConfigFile.createNewFile()) + LOGGER.error("Could not create main config file"); + + defaults(); + } + + if (!FBP.floatingMaterialsFile.exists()) { + if (!FBP.floatingMaterialsFile.createNewFile()) + LOGGER.error("Could not create floating materials file"); + + defaultsFloatingMaterials(); + } + + if (!FBP.particleBlacklistFile.exists() && !FBP.particleBlacklistFile.createNewFile()) + LOGGER.error("Could not create particle blacklist file"); + + if (!FBP.animBlacklistFile.exists() && !FBP.animBlacklistFile.createNewFile()) + LOGGER.error("Could not create anim blacklist file"); + + } catch (final IOException ioException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot initialize configs", "", ioException.getMessage()); + } catch (final SecurityException securityException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot initialize configs", "", "An antivirus is probably causing this", securityException.getMessage()); + } finally { + closeStreams(); + } + } + + /** + * Check for pre 0.8 configs and hopefully delete them + */ + private static void deleteOldConfigFiles() { + if (FBP.oldMainConfigFile.exists() && !FBP.oldMainConfigFile.delete()) + LOGGER.error("Could not delete old main config file"); + + if (FBP.oldFloatingMaterialsFile.exists() && !FBP.oldFloatingMaterialsFile.delete()) + LOGGER.error("Could not delete old floating materials file"); + + if (FBP.oldParticleBlacklistFile.exists() && !FBP.oldParticleBlacklistFile.delete()) + LOGGER.error("Could not delete old particle blacklist file"); + + if (FBP.oldAnimBlacklistFile.exists() && !FBP.oldAnimBlacklistFile.delete()) + LOGGER.error("Could not delete old anim blacklist file"); + + if (FBP.oldNewMainConfigFile.exists() && !FBP.oldNewMainConfigFile.delete()) + LOGGER.error("Could not delete old new main config file"); + } + + /** + * Initializes file streams for a specified file. + *

+ * This is used to read the config files. + * + * @param file The file object to create streams for + */ + private static void initStreams(final File file) { + try { + fileInputStream = new FileInputStream(file); + inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8); + bufferedReader = new BufferedReader(inputStreamReader); + + } catch (final FileNotFoundException fileNotFoundException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + if (handleFileNotFound(fileNotFoundException.getMessage(), "streams", file)) + initStreams(file); + closeStreams(); + } catch (final SecurityException securityException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot initialize streams", "", "An antivirus is probably causing this", securityException.getMessage()); + closeStreams(); + } + } + + /** + * Closes file streams. + */ + private static void closeStreams() { + try { + if (bufferedReader!= null) + bufferedReader.close(); + if (inputStreamReader!= null) + inputStreamReader.close(); + if (fileInputStream!= null) + fileInputStream.close(); + + } catch (final IOException ioException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot close streams", "", ioException.getMessage()); + } + } + + /** + * Initializes writer for a specified file. + *

+ * This is used to write to the config files. + * + * @param file The file object to create writer for + */ + private static void initWriter(final File file) { + try { + writer = new PrintWriter(file.getPath(), "UTF-8"); + + } catch (FileNotFoundException fileNotFoundException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + if (handleFileNotFound(fileNotFoundException.getMessage(), "writer", file)) + initWriter(file); + } catch (UnsupportedEncodingException unsupportedEncodingException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot initialize writer", "", "Encoding is not supported", unsupportedEncodingException.getMessage()); + } catch (SecurityException securityException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot initialize writer", "", "An antivirus is probably causing this", securityException.getMessage()); + } + } + + /** + * Handle a file not found exception. + *

+ * It will output an error message to the console. + * And then attempt to create a new file, if it fails, it will output an error message to the console. + * + * @param message The error message associated with the exception + * @param source A string indicating the source of the error + * @param file The file object that could not be found + * @return True if the file was created successfully, false otherwise + */ + private static boolean handleFileNotFound(final String message, final String source, final File file) { + LOGGER.error("Cannot init " + source + " for " + file + " as the file does not exist, details: " + message); + LOGGER.warn("Trying to create file " + file); + + try { + if (file.createNewFile()) { + LOGGER.info("Successfully created file " + file); + return true; + } + + } catch (final IOException ioException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot initialize configs", "", ioException.getMessage()); + } catch (final SecurityException securityException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot initialize configs", "", "An antivirus is probably causing this", securityException.getMessage()); + } + + return false; + } + + /** + * Reads the main config file and set the corresponding settings if not found sets default. + */ + private static void readMainConfig() { + try { + initStreams(FBP.mainConfigFile); + + final Map configValues = new HashMap<>(); + + while ((line = bufferedReader.readLine()) != null) { + if (line.startsWith("#") || line.trim().isEmpty()) + continue; + + final String[] keyValue = line.split(": "); + if (keyValue.length == 2) + configValues.put(keyValue[0], keyValue[1]); + } + + FBP.enabled = Boolean.parseBoolean(configValues.getOrDefault("enabled", "true")); + FBP.minAge = Integer.parseInt(configValues.getOrDefault("minAge", "10")); + FBP.maxAge = Integer.parseInt(configValues.getOrDefault("maxAge", "64")); + FBP.showInMillis = Boolean.parseBoolean(configValues.getOrDefault("showInMillis", "false")); + FBP.infiniteDuration = Boolean.parseBoolean(configValues.getOrDefault("infiniteDuration", "false")); + FBP.particlesPerAxis = Integer.parseInt(configValues.getOrDefault("particlesPerAxis", "4")); + FBP.scaleMult = Float.parseFloat(configValues.getOrDefault("scaleMult", "0.75")); + FBP.gravityMult = Float.parseFloat(configValues.getOrDefault("gravityMult", "1.0")); + FBP.rotationMult = Float.parseFloat(configValues.getOrDefault("rotationMult", "1.0")); + FBP.randomRotation = Boolean.parseBoolean(configValues.getOrDefault("randomRotation", "true")); + FBP.randomizedScale = Boolean.parseBoolean(configValues.getOrDefault("randomizedScale", "true")); + FBP.randomFadingSpeed = Boolean.parseBoolean(configValues.getOrDefault("randomFadingSpeed", "true")); + FBP.spawnWhileFrozen = Boolean.parseBoolean(configValues.getOrDefault("spawnWhileFrozen", "true")); + FBP.entityCollision = Boolean.parseBoolean(configValues.getOrDefault("entityCollision", "true")); + FBP.bounceOffWalls = Boolean.parseBoolean(configValues.getOrDefault("bounceOffWalls", "true")); + FBP.lowTraction = Boolean.parseBoolean(configValues.getOrDefault("lowTraction", "false")); + FBP.smartBreaking = Boolean.parseBoolean(configValues.getOrDefault("smartBreaking", "true")); + FBP.fancyFlame = Boolean.parseBoolean(configValues.getOrDefault("fancyFlame", "false")); + FBP.fancySmoke = Boolean.parseBoolean(configValues.getOrDefault("fancySmoke", "false")); + FBP.waterPhysics = Boolean.parseBoolean(configValues.getOrDefault("waterPhysics", "true")); + + FBP.fancyPlaceAnim = Boolean.parseBoolean(configValues.getOrDefault("fancyPlaceAnim", "true")); + FBP.spawnPlaceParticles = Boolean.parseBoolean(configValues.getOrDefault("spawnPlaceParticles", "true")); + + FBP.fancyWeather = Boolean.parseBoolean(configValues.getOrDefault("fancyWeather", "false")); + FBP.dynamicWeather = Boolean.parseBoolean(configValues.getOrDefault("dynamicWeather", "false")); + FBP.weatherParticleDensity = Float.parseFloat(configValues.getOrDefault("weatherParticleDensity", "1.0")); + FBP.weatherRenderDistance = Float.parseFloat(configValues.getOrDefault("weatherRenderDistance", "1.0")); + + FBP.experiments = Boolean.parseBoolean(configValues.getOrDefault("experiments", "false")); + + FBP.debug = Boolean.parseBoolean(configValues.getOrDefault("debugMode", "false")); + + } catch (final IOException ioException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot read main config file", "", ioException.getMessage()); + } finally { + closeStreams(); + } + } + + /** + * Reads the floating materials config file and add the found material to the floating material list. + */ + private static void readFloatingMaterials() { + try { + initStreams(FBP.floatingMaterialsFile); + + FBP.floatingMaterials.clear(); + + while ((line = bufferedReader.readLine()) != null) { + line = line.trim(); + + if (line.startsWith("#") || line.isEmpty()) + continue; + + switch (line) { + case "Anvil": + addMaterial(Material.ANVIL); + break; + case "Barrier": + addMaterial(Material.BARRIER); + break; + case "Cactus": + addMaterial(Material.CACTUS); + break; + case "Cake": + addMaterial(Material.CAKE); + break; + case "Carpet": + addMaterial(Material.CARPET); + break; + case "Circuits": + addMaterial(Material.CIRCUITS); + break; + case "Clay": + addMaterial(Material.CLAY); + break; + case "Cloth": + addMaterial(Material.CLOTH); + break; + case "Coral": + addMaterial(Material.CORAL); + break; + case "Crafted Snow": + addMaterial(Material.CRAFTED_SNOW); + break; + case "Dragon Egg": + addMaterial(Material.DRAGON_EGG); + break; + case "Fire": + addMaterial(Material.FIRE); + break; + case "Glass": + addMaterial(Material.GLASS); + break; + case "Gourd": + addMaterial(Material.GOURD); + break; + case "Grass": + addMaterial(Material.GRASS); + break; + case "Ground": + addMaterial(Material.GROUND); + break; + case "Ice": + addMaterial(Material.ICE); + break; + case "Iron": + addMaterial(Material.IRON); + break; + case "Leaves": + addMaterial(Material.LEAVES); + break; + case "Packed Ice": + addMaterial(Material.PACKED_ICE); + break; + case "Piston": + addMaterial(Material.PISTON); + break; + case "Plants": + addMaterial(Material.PLANTS); + break; + case "Portal": + addMaterial(Material.PORTAL); + break; + case "Redstone Light": + addMaterial(Material.REDSTONE_LIGHT); + break; + case "Rock": + addMaterial(Material.ROCK); + break; + case "Sand": + addMaterial(Material.SAND); + break; + case "Snow": + addMaterial(Material.SNOW); + break; + case "Sponge": + addMaterial(Material.SPONGE); + break; + case "Structure Void": + addMaterial(Material.STRUCTURE_VOID); + break; + case "Tnt": + addMaterial(Material.TNT); + break; + case "Vine": + addMaterial(Material.VINE); + break; + case "Web": + addMaterial(Material.WEB); + break; + case "Wood": + addMaterial(Material.WOOD); + break; + default: + // Todo: (Red Issue Tracker) This should count to the problem counter + LOGGER.warn("Material not recognized: " + line + " in Floating Materials.txt, it will be ignored but should be removed."); + break; + } + } + + } catch (final IOException ioException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot read floating materials file", "", ioException.getMessage()); + } finally { + closeStreams(); + } + } + + /** + * Reads the animation blacklist config file and add the found blocks to the animation blacklist list. + */ + private static void readAnimBlacklist() { + try { + initStreams(FBP.animBlacklistFile); + + FBP.blockAnimBlacklist.clear(); + + while ((line = bufferedReader.readLine()) != null && !(line = line.replace(" ", "")).isEmpty()) + addToBlacklist(line, false); + } catch (final IOException ioException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot read animation blacklist file", "", ioException.getMessage()); + } finally { + closeStreams(); + } + } + + + /** + * Reads the particle blacklist config file and add the found blocks to the particle blacklist list. + */ + private static void readParticleBlacklist() { + try { + initStreams(FBP.particleBlacklistFile); + + FBP.blockParticleBlacklist.clear(); + + while ((line = bufferedReader.readLine()) != null && !(line = line.replace(" ", "")).isEmpty()) + addToBlacklist(line, true); + } catch (final IOException ioException) { + // Todo: (Red Issue Tracker) This should count to the problem counter + RED_LOGGER.printFramedError("Configuration", "Cannot read particle blacklist file", "", ioException.getMessage()); + } finally { + closeStreams(); + } + } + + /** + * Writes the main config file. + */ + public static void writeMainConfig() { + initWriter(FBP.mainConfigFile); + + writer.println("# Main configuration file for Fancier Block Particles"); + writer.println("# I advise to use the in game configuration pages instead of manually editing this file"); + writer.println(); + writer.println("enabled: " + FBP.enabled); + writer.println(); + writer.println("# Particles Config:"); + writer.println(); + writer.println("minAge: " + FBP.minAge); + writer.println("maxAge: " + FBP.maxAge); + writer.println("showInMillis: " + FBP.showInMillis); + writer.println("infiniteDuration: " + FBP.infiniteDuration); + writer.println("particlesPerAxis: " + FBP.particlesPerAxis); + writer.println("scaleMult: " + FBP.scaleMult); + writer.println("gravityMult: " + FBP.gravityMult); + writer.println("rotationMult: " + FBP.rotationMult); + writer.println("randomRotation: " + FBP.randomRotation); + writer.println("randomizedScale: " + FBP.randomizedScale); + writer.println("randomFadingSpeed: " + FBP.randomFadingSpeed); + writer.println("spawnWhileFrozen: " + FBP.spawnWhileFrozen); + writer.println("entityCollision: " + FBP.entityCollision); + writer.println("bounceOffWalls: " + FBP.bounceOffWalls); + writer.println("lowTraction: " + FBP.lowTraction); + writer.println("smartBreaking: " + FBP.smartBreaking); + writer.println("fancyFlame: " + FBP.fancyFlame); + writer.println("fancySmoke: " + FBP.fancySmoke); + writer.println("waterPhysics: " + FBP.waterPhysics); + writer.println(); + writer.println("# Fancy Block Placement Config:"); + writer.println(); + writer.println("fancyPlaceAnim: " + FBP.fancyPlaceAnim); + writer.println("spawnPlaceParticles: " + FBP.spawnPlaceParticles); + writer.println(); + writer.println("# Weather Config:"); + writer.println(); + writer.println("fancyWeather: " + FBP.fancyWeather); + writer.println("dynamicWeather: " + FBP.dynamicWeather); + writer.println("weatherParticleDensity: " + FBP.weatherParticleDensity); + writer.println("weatherRenderDistance: " + FBP.weatherRenderDistance); + writer.println(); + writer.println("# Experiments:"); + writer.println(); + writer.println("experiments: " + FBP.experiments); + writer.println(); + writer.println("# Debug Config:"); + writer.println(); + writer.println("debugMode: " + FBP.debug); + + writer.close(); + } + + /** + * Writes the floating materials config file. + *

+ * Uses hard-coded values for the material names which are the default. + */ + private static void writeFloatingMaterials() { + initWriter(FBP.floatingMaterialsFile); + + writer.println("# Configuration file for floatings materials."); + writer.println("# Anything added here will float, anything else will sink."); + writer.println("# List of all possible materials: https://shor.cz/1.12Materials"); + writer.println(); + writer.println("Carpet"); + writer.println("Cloth"); + writer.println("Ice"); + writer.println("Packed Ice"); + writer.println("Plants"); + writer.println("Web"); + writer.println("Wood"); + + writer.close(); + } + + /** + * Writes the animation blacklist config file. + */ + public static void writeAnimBlacklist() { + initWriter(FBP.animBlacklistFile); + + for (String block : FBP.blockAnimBlacklist) + writer.println(block); + + writer.close(); + } + + /** + * Writes the particle blacklist config file. + */ + public static void writeParticleBlacklist() { + initWriter(FBP.particleBlacklistFile); + + for (String block : FBP.blockParticleBlacklist) + writer.println(block); + + writer.close(); + } + + /** + * Set all the values in the main config file to the default. + */ + public static void defaults() { + FBP.enabled = true; + FBP.bounceOffWalls = true; + FBP.randomRotation = true; + FBP.entityCollision = true; + FBP.randomizedScale = true; + FBP.randomFadingSpeed = true; + FBP.spawnWhileFrozen = true; + FBP.smartBreaking = true; + FBP.fancyPlaceAnim = true; + FBP.spawnPlaceParticles = true; + FBP.waterPhysics = true; + + FBP.minAge = 10; + FBP.maxAge = 64; + FBP.particlesPerAxis = 4; + + FBP.scaleMult = 0.75F; + FBP.gravityMult = 1.0F; + FBP.rotationMult = 1.0F; + FBP.weatherParticleDensity = 1.0F; + FBP.weatherRenderDistance = 1.0F; + + writeMainConfig(); + } + + /** + * Set all the values in the floating materials config file to the default. + */ + public static void defaultsFloatingMaterials() { + FBP.floatingMaterials.clear(); + + writeFloatingMaterials(); + + readFloatingMaterials(); + } + + /** + * Adds a material to the floating materials list. + * + * @param material The material to add + */ + private static void addMaterial(final Material material) { + if (!FBP.floatingMaterials.contains(material)) + FBP.floatingMaterials.add(material); + else + // Todo: (Red Issue Tracker) This should count to the problem counter + LOGGER.warn("Found duplicated material: " + material + " in Floating Materials.txt, it will be ignored but should be removed."); + } + + /** + * Adds a block by name to either the particle or animation blacklist. + * + * @param name The name of the block to add + * @param particle Whether the block should be added to the particle or animation blacklist + */ + public static void addToBlacklist(final String name, final boolean particle) { + if (StringUtils.isEmpty(name)) + return; + + if (!(particle ? FBP.blockParticleBlacklist : FBP.blockAnimBlacklist).contains(name)) + (particle ? FBP.blockParticleBlacklist : FBP.blockAnimBlacklist).add(name); + } + + + /** + * Add or remove a block from either the particle or animation blacklist. + *

+ * If the block is not blacklisted, it is added to either the particle or animation blacklist. + *

+ * If the block is blacklisted, it is removed from either the particle or animation blacklist. + * + * @param block The block to blacklist + * @param particle Whether the block should be blacklisted from the particle or animation blacklist + */ + public static void blacklist(final Block block, final boolean particle) { + if (block == null || block.getRegistryName() == null) + return; + + final String name = block.getRegistryName().toString(); + + if (isBlacklisted(block, particle)) + (particle ? FBP.blockParticleBlacklist : FBP.blockAnimBlacklist).remove(name); + else + (particle ? FBP.blockParticleBlacklist : FBP.blockAnimBlacklist).add(name); + + if (particle) + writeParticleBlacklist(); + else + writeAnimBlacklist(); + } + + /** + * Checks if a block is blacklisted. + * + * @param block The block to check + * @param particle Whether to check if the block is blacklisted in the particle or animation blacklist + */ + public static boolean isBlacklisted(final Block block, final boolean particle) { + if (block == null || block.getRegistryName() == null) + return true; + + return (particle ? FBP.blockParticleBlacklist : FBP.blockAnimBlacklist).contains(block.getRegistryName().toString()); + } + + /** + * Reloads the floating materials list. + * If the list is empty, it is filled by calling readFloatingMaterials(). + * Otherwise, the list is cleared using the clear() method of the ArrayList class. + */ + public static void reloadMaterials() { + if (FBP.floatingMaterials.isEmpty()) + readFloatingMaterials(); + else + FBP.floatingMaterials.clear(); + } + + /** + * Reloads the animation blacklist. + * If the list is empty, it is filled by calling readAnimBlacklist(). + * Otherwise, the list is cleared using the clear() method of the ArrayList class. + */ + public static void reloadAnimBlacklist() { + if (FBP.blockAnimBlacklist.isEmpty()) + readAnimBlacklist(); + else + FBP.blockAnimBlacklist.clear(); + } +} diff --git a/src/main/java/io/redstudioragnarok/fbp/handlers/DebugHandler.java b/src/main/java/dev/redstudio/fbp/handlers/DebugHandler.java similarity index 84% rename from src/main/java/io/redstudioragnarok/fbp/handlers/DebugHandler.java rename to src/main/java/dev/redstudio/fbp/handlers/DebugHandler.java index 1d2161f4..3e3f34c9 100644 --- a/src/main/java/io/redstudioragnarok/fbp/handlers/DebugHandler.java +++ b/src/main/java/dev/redstudio/fbp/handlers/DebugHandler.java @@ -1,7 +1,6 @@ -package io.redstudioragnarok.fbp.handlers; +package dev.redstudio.fbp.handlers; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.utils.ModReference; +import dev.redstudio.fbp.FBP; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.Loader; @@ -9,7 +8,8 @@ import java.util.ArrayList; -import static io.redstudioragnarok.fbp.FBP.*; +import static dev.redstudio.fbp.FBP.*; +import static dev.redstudio.fbp.ProjectConstants.VERSION; public class DebugHandler { @@ -18,17 +18,17 @@ public class DebugHandler { @SubscribeEvent public static void onDebugList(RenderGameOverlayEvent.Text event) { - if (mc.gameSettings.showDebugInfo) { + if (MC.gameSettings.showDebugInfo) { ArrayList list = event.getLeft(); list.remove(4); - list.add(4, "T: " + mc.world.getDebugLoadedEntities()); + list.add(4, "T: " + MC.world.getDebugLoadedEntities()); if (!list.get(list.size() - 1).equals("")) { list.add(""); } - list.add(String.format("%s%s Fancier Block Particles version is %s, Mixin Booter is %sup to date (%s).", TextFormatting.RED, TextFormatting.RESET, ModReference.VERSION, MIXIN_BOOTER_VERSION.equals(LATEST_MIXIN_BOOTER) ? "" : "not ", MIXIN_BOOTER_VERSION)); + list.add(String.format("%s%s Fancier Block Particles version is %s, Mixin Booter is %sup to date (%s).", TextFormatting.RED, TextFormatting.RESET, VERSION, MIXIN_BOOTER_VERSION.equals(LATEST_MIXIN_BOOTER) ? "" : "not ", MIXIN_BOOTER_VERSION)); list.add(String.format("%s%s Running on %s", TextFormatting.RED, TextFormatting.RESET, System.getProperty("java.vm.name"))); list.add(String.format("%s%s Running on %s, version %s", TextFormatting.RED, TextFormatting.RESET, System.getProperty("os.name"), System.getProperty("os.version"))); list.add(""); diff --git a/src/main/java/io/redstudioragnarok/fbp/handlers/EventHandler.java b/src/main/java/dev/redstudio/fbp/handlers/EventHandler.java similarity index 85% rename from src/main/java/io/redstudioragnarok/fbp/handlers/EventHandler.java rename to src/main/java/dev/redstudio/fbp/handlers/EventHandler.java index b0b5f009..d3dfe8e9 100644 --- a/src/main/java/io/redstudioragnarok/fbp/handlers/EventHandler.java +++ b/src/main/java/dev/redstudio/fbp/handlers/EventHandler.java @@ -1,13 +1,13 @@ -package io.redstudioragnarok.fbp.handlers; +package dev.redstudio.fbp.handlers; import io.netty.util.internal.ConcurrentSet; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.models.ModelHelper; -import io.redstudioragnarok.fbp.node.BlockNode; -import io.redstudioragnarok.fbp.node.BlockPosNode; -import io.redstudioragnarok.fbp.particles.FBPParticleBlock; -import io.redstudioragnarok.fbp.particles.FBPParticleManager; -import io.redstudioragnarok.fbp.renderer.FBPWeatherRenderer; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.models.ModelHelper; +import dev.redstudio.fbp.node.BlockNode; +import dev.redstudio.fbp.node.BlockPosNode; +import dev.redstudio.fbp.particles.FBPParticleBlock; +import dev.redstudio.fbp.particles.FBPParticleManager; +import dev.redstudio.fbp.renderer.FBPWeatherRenderer; import net.minecraft.block.Block; import net.minecraft.block.BlockDoublePlant; import net.minecraft.block.BlockFalling; @@ -38,7 +38,7 @@ import java.util.Objects; -import static io.redstudioragnarok.fbp.FBP.mc; +import static dev.redstudio.fbp.FBP.MC; public class EventHandler { @@ -103,7 +103,7 @@ public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, BlockPosNode node = getNodeWithPos(pos); if (node != null && !node.checked) { - if (newState.getBlock() == FBP.dummyBlock || newState.getBlock() == Blocks.AIR || oldState.getBlock() == newState.getBlock()) { + if (newState.getBlock() == FBP.DUMMY_BLOCK || newState.getBlock() == Blocks.AIR || oldState.getBlock() == newState.getBlock()) { removePosEntry(pos); return; } @@ -129,9 +129,9 @@ public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, FBPParticleBlock particleBlock = new FBPParticleBlock(worldIn, pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f, state, seed); - mc.effectRenderer.addEffect(particleBlock); + MC.effectRenderer.addEffect(particleBlock); - FBP.dummyBlock.copyState(pos, state, particleBlock); + FBP.DUMMY_BLOCK.copyState(pos, state, particleBlock); } } } @@ -158,12 +158,12 @@ public void onInteractionEvent(RightClickBlock result) { float y = (float) (result.getHitVec().y - pos.getY()); float z = (float) (result.getHitVec().z - pos.getZ()); - if (atPos.getBlock() == FBP.dummyBlock) { - BlockNode node = FBP.dummyBlock.blockNodes.get(pos); + if (atPos.getBlock() == FBP.DUMMY_BLOCK) { + BlockNode node = FBP.DUMMY_BLOCK.blockNodes.get(pos); if (node != null) { node.state.getBlock(); - boolean activated = node.originalBlock.onBlockActivated(result.getWorld(), pos, node.state, mc.player, result.getHand(), result.getFace(), x, y, z); + boolean activated = node.originalBlock.onBlockActivated(result.getWorld(), pos, node.state, MC.player, result.getHand(), result.getFace(), x, y, z); if (activated) return; @@ -186,8 +186,8 @@ public void onInteractionEvent(RightClickBlock result) { } } - if (atPosOffset.getBlock() == FBP.dummyBlock) { - BlockNode blockNode = FBP.dummyBlock.blockNodes.get(posOffset); + if (atPosOffset.getBlock() == FBP.DUMMY_BLOCK) { + BlockNode blockNode = FBP.DUMMY_BLOCK.blockNodes.get(posOffset); if (blockNode != null) { blockNode.state.getBlock(); @@ -219,7 +219,7 @@ public void onInteractionEvent(RightClickBlock result) { if (lastBlockPosNodeOffset != null && addedOffset && (lastBlockPosNodeOffset.checked || replaceable)) // place on side return; - Chunk chunk = mc.world.getChunk((addedOffset ? posOffset : pos)); + Chunk chunk = MC.world.getChunk((addedOffset ? posOffset : pos)); chunk.resetRelightChecks(); chunk.setLightPopulated(true); @@ -229,7 +229,7 @@ public void onInteractionEvent(RightClickBlock result) { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent tick) { - if (!mc.isGamePaused() && mc.world != null && mc.world.provider.getWeatherRenderer() == FBP.fancyWeatherRenderer && FBP.enabled) { + if (!MC.isGamePaused() && MC.world != null && MC.world.provider.getWeatherRenderer() == FBP.fancyWeatherRenderer && FBP.enabled) { ((FBPWeatherRenderer) FBP.fancyWeatherRenderer).onUpdate(); } } @@ -242,12 +242,12 @@ public void onWorldLoadEvent(WorldEvent.Load world) { @SubscribeEvent(priority = EventPriority.LOWEST) public void onEntityJoinWorldEvent(EntityJoinWorldEvent e) { - if (e.getEntity() == mc.player) { - FBP.fancyEffectRenderer = new FBPParticleManager(e.getWorld(), mc.renderEngine); + if (e.getEntity() == MC.player) { + FBP.fancyEffectRenderer = new FBPParticleManager(e.getWorld(), MC.renderEngine); FBP.fancyWeatherRenderer = new FBPWeatherRenderer(); - currentWeatherRenderer = mc.world.provider.getCloudRenderer(); - currentEffectRenderer = mc.effectRenderer; + currentWeatherRenderer = MC.world.provider.getCloudRenderer(); + currentEffectRenderer = MC.effectRenderer; if (FBP.originalWeatherRenderer == null || (FBP.originalWeatherRenderer != currentWeatherRenderer && currentWeatherRenderer != FBP.fancyWeatherRenderer)) FBP.originalWeatherRenderer = currentWeatherRenderer; @@ -255,10 +255,10 @@ public void onEntityJoinWorldEvent(EntityJoinWorldEvent e) { FBP.originalEffectRenderer = currentEffectRenderer; if (FBP.enabled) { - mc.effectRenderer = FBP.fancyEffectRenderer; + MC.effectRenderer = FBP.fancyEffectRenderer; if (FBP.fancyWeather) - mc.world.provider.setWeatherRenderer(FBP.fancyWeatherRenderer); + MC.world.provider.setWeatherRenderer(FBP.fancyWeatherRenderer); } } } @@ -267,7 +267,7 @@ public void onEntityJoinWorldEvent(EntityJoinWorldEvent e) { public void onPlayerPlaceBlockEvent(BlockEvent.PlaceEvent placeEvent) { Block placedBlock = placeEvent.getPlacedBlock().getBlock(); - if (placedBlock == FBP.dummyBlock) + if (placedBlock == FBP.DUMMY_BLOCK) placeEvent.setCanceled(true); } diff --git a/src/main/java/io/redstudioragnarok/fbp/handlers/GuiHandler.java b/src/main/java/dev/redstudio/fbp/handlers/GuiHandler.java similarity index 82% rename from src/main/java/io/redstudioragnarok/fbp/handlers/GuiHandler.java rename to src/main/java/dev/redstudio/fbp/handlers/GuiHandler.java index 349698cb..642b48cb 100644 --- a/src/main/java/io/redstudioragnarok/fbp/handlers/GuiHandler.java +++ b/src/main/java/dev/redstudio/fbp/handlers/GuiHandler.java @@ -1,7 +1,7 @@ -package io.redstudioragnarok.fbp.handlers; +package dev.redstudio.fbp.handlers; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.GuiHud; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.gui.GuiHud; import net.minecraft.client.resources.I18n; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; diff --git a/src/main/java/io/redstudioragnarok/fbp/handlers/KeyInputHandler.java b/src/main/java/dev/redstudio/fbp/handlers/KeyInputHandler.java similarity index 54% rename from src/main/java/io/redstudioragnarok/fbp/handlers/KeyInputHandler.java rename to src/main/java/dev/redstudio/fbp/handlers/KeyInputHandler.java index e1299e45..fb1ef181 100644 --- a/src/main/java/io/redstudioragnarok/fbp/handlers/KeyInputHandler.java +++ b/src/main/java/dev/redstudio/fbp/handlers/KeyInputHandler.java @@ -1,9 +1,9 @@ -package io.redstudioragnarok.fbp.handlers; +package dev.redstudio.fbp.handlers; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.gui.GuiBlacklist; -import io.redstudioragnarok.fbp.gui.pages.Page0; -import io.redstudioragnarok.fbp.keys.KeyBindings; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.gui.GuiBlacklist; +import dev.redstudio.fbp.gui.pages.Page0; +import dev.redstudio.fbp.keys.KeyBindings; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -13,7 +13,7 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; -import static io.redstudioragnarok.fbp.FBP.mc; +import static dev.redstudio.fbp.FBP.MC; public class KeyInputHandler { @@ -25,23 +25,23 @@ public static void onKeyboardInput(InputEvent.KeyInputEvent e) { } public static void onInput() { - if (KeyBindings.menu.isPressed()) - mc.displayGuiScreen(new Page0()); + if (KeyBindings.MENU.isPressed()) + MC.displayGuiScreen(new Page0()); - if (KeyBindings.freeze.isPressed() && FBP.enabled) + if (KeyBindings.FREEZE.isPressed() && FBP.enabled) FBP.frozen = !FBP.frozen; - if (KeyBindings.toggle.isPressed()) + if (KeyBindings.TOGGLE.isPressed()) FBP.setEnabled(!FBP.enabled); - if (KeyBindings.blacklistGUI.isKeyDown()) { + if (KeyBindings.BLACKLIST_GUI.isKeyDown()) { Block block; ItemStack stack = null; - boolean useHeldBlock = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && (block = Block.getBlockFromName((stack = mc.player.getHeldItemMainhand()).getItem().getRegistryName().toString())) != null && block != Blocks.AIR; + boolean useHeldBlock = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && (block = Block.getBlockFromName((stack = MC.player.getHeldItemMainhand()).getItem().getRegistryName().toString())) != null && block != Blocks.AIR; - if (!blacklistGUIOpen && (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit.equals(RayTraceResult.Type.BLOCK) || useHeldBlock) && mc.world.getBlockState(mc.objectMouseOver.getBlockPos()).getBlock() != FBP.dummyBlock) { - mc.displayGuiScreen(useHeldBlock ? (new GuiBlacklist(stack)) : (new GuiBlacklist(mc.objectMouseOver.getBlockPos()))); + if (!blacklistGUIOpen && (MC.objectMouseOver != null && MC.objectMouseOver.typeOfHit.equals(RayTraceResult.Type.BLOCK) || useHeldBlock) && MC.world.getBlockState(MC.objectMouseOver.getBlockPos()).getBlock() != FBP.DUMMY_BLOCK) { + MC.displayGuiScreen(useHeldBlock ? (new GuiBlacklist(stack)) : (new GuiBlacklist(MC.objectMouseOver.getBlockPos()))); Mouse.setGrabbed(true); diff --git a/src/main/java/dev/redstudio/fbp/keys/KeyBindings.java b/src/main/java/dev/redstudio/fbp/keys/KeyBindings.java new file mode 100644 index 00000000..8c1c7953 --- /dev/null +++ b/src/main/java/dev/redstudio/fbp/keys/KeyBindings.java @@ -0,0 +1,30 @@ +package dev.redstudio.fbp.keys; + +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.KeyBinding; +import net.minecraftforge.fml.client.registry.ClientRegistry; +import org.lwjgl.input.Keyboard; + +import static dev.redstudio.fbp.ProjectConstants.NAME; + +/** + * A class that holds and initialize all the keybindings for the mod. + * + * @author Desoroxxx + */ +public class KeyBindings { + + public static final KeyBinding MENU = new KeyBinding(I18n.format("keyBinding.menu"), Keyboard.KEY_P, NAME); + public static final KeyBinding TOGGLE = new KeyBinding(I18n.format("keyBinding.toggle"), Keyboard.KEY_NONE, NAME); + public static final KeyBinding FREEZE = new KeyBinding(I18n.format("keyBinding.freeze"), Keyboard.KEY_NONE, NAME); + public static final KeyBinding KILL_PARTICLES = new KeyBinding(I18n.format("keyBinding.kill"), Keyboard.KEY_NONE, NAME); + public static final KeyBinding BLACKLIST_GUI = new KeyBinding(I18n.format("keyBinding.blacklistGUI"), Keyboard.KEY_B, NAME); + + public static void init() { + ClientRegistry.registerKeyBinding(MENU); + ClientRegistry.registerKeyBinding(TOGGLE); + ClientRegistry.registerKeyBinding(FREEZE); + ClientRegistry.registerKeyBinding(KILL_PARTICLES); + ClientRegistry.registerKeyBinding(BLACKLIST_GUI); + } +} diff --git a/src/main/java/io/redstudioragnarok/fbp/material/DummyMaterial.java b/src/main/java/dev/redstudio/fbp/material/DummyMaterial.java similarity index 81% rename from src/main/java/io/redstudioragnarok/fbp/material/DummyMaterial.java rename to src/main/java/dev/redstudio/fbp/material/DummyMaterial.java index 7386c7c0..066821c7 100644 --- a/src/main/java/io/redstudioragnarok/fbp/material/DummyMaterial.java +++ b/src/main/java/dev/redstudio/fbp/material/DummyMaterial.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.material; +package dev.redstudio.fbp.material; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; diff --git a/src/main/java/dev/redstudio/fbp/mixin/EntityRendererMixin.java b/src/main/java/dev/redstudio/fbp/mixin/EntityRendererMixin.java new file mode 100644 index 00000000..d6d71cd3 --- /dev/null +++ b/src/main/java/dev/redstudio/fbp/mixin/EntityRendererMixin.java @@ -0,0 +1,18 @@ +package dev.redstudio.fbp.mixin; + +import dev.redstudio.fbp.renderer.CubeBatchRenderer; +import net.minecraft.client.renderer.EntityRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.At.Shift; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(EntityRenderer.class) +public final class EntityRendererMixin { + + @Inject(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleManager;renderParticles(Lnet/minecraft/entity/Entity;F)V", shift = Shift.AFTER)) + private void afterParticlesRendered(final CallbackInfo callbackInfo) { + CubeBatchRenderer.endAllBatches(); + } +} diff --git a/src/main/java/io/redstudioragnarok/fbp/models/DummyBakedModel.java b/src/main/java/dev/redstudio/fbp/models/DummyBakedModel.java similarity index 98% rename from src/main/java/io/redstudioragnarok/fbp/models/DummyBakedModel.java rename to src/main/java/dev/redstudio/fbp/models/DummyBakedModel.java index b920d040..fa9380bb 100644 --- a/src/main/java/io/redstudioragnarok/fbp/models/DummyBakedModel.java +++ b/src/main/java/dev/redstudio/fbp/models/DummyBakedModel.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.models; +package dev.redstudio.fbp.models; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; diff --git a/src/main/java/io/redstudioragnarok/fbp/models/ModelHelper.java b/src/main/java/dev/redstudio/fbp/models/ModelHelper.java similarity index 96% rename from src/main/java/io/redstudioragnarok/fbp/models/ModelHelper.java rename to src/main/java/dev/redstudio/fbp/models/ModelHelper.java index d3be0c9e..053369c8 100644 --- a/src/main/java/io/redstudioragnarok/fbp/models/ModelHelper.java +++ b/src/main/java/dev/redstudio/fbp/models/ModelHelper.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.models; +package dev.redstudio.fbp.models; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; diff --git a/src/main/java/io/redstudioragnarok/fbp/models/ModelTransformer.java b/src/main/java/dev/redstudio/fbp/models/ModelTransformer.java similarity index 98% rename from src/main/java/io/redstudioragnarok/fbp/models/ModelTransformer.java rename to src/main/java/dev/redstudio/fbp/models/ModelTransformer.java index 6d04e27a..6ab048c1 100644 --- a/src/main/java/io/redstudioragnarok/fbp/models/ModelTransformer.java +++ b/src/main/java/dev/redstudio/fbp/models/ModelTransformer.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.models; +package dev.redstudio.fbp.models; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; diff --git a/src/main/java/io/redstudioragnarok/fbp/node/BlockNode.java b/src/main/java/dev/redstudio/fbp/node/BlockNode.java similarity index 78% rename from src/main/java/io/redstudioragnarok/fbp/node/BlockNode.java rename to src/main/java/dev/redstudio/fbp/node/BlockNode.java index b7fcc58a..5f14c760 100644 --- a/src/main/java/io/redstudioragnarok/fbp/node/BlockNode.java +++ b/src/main/java/dev/redstudio/fbp/node/BlockNode.java @@ -1,6 +1,6 @@ -package io.redstudioragnarok.fbp.node; +package dev.redstudio.fbp.node; -import io.redstudioragnarok.fbp.particles.FBPParticleBlock; +import dev.redstudio.fbp.particles.FBPParticleBlock; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; diff --git a/src/main/java/io/redstudioragnarok/fbp/node/BlockPosNode.java b/src/main/java/dev/redstudio/fbp/node/BlockPosNode.java similarity index 89% rename from src/main/java/io/redstudioragnarok/fbp/node/BlockPosNode.java rename to src/main/java/dev/redstudio/fbp/node/BlockPosNode.java index fd937a2b..b68f31d8 100644 --- a/src/main/java/io/redstudioragnarok/fbp/node/BlockPosNode.java +++ b/src/main/java/dev/redstudio/fbp/node/BlockPosNode.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.node; +package dev.redstudio.fbp.node; import io.netty.util.internal.ConcurrentSet; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleBlock.java b/src/main/java/dev/redstudio/fbp/particles/FBPParticleBlock.java similarity index 80% rename from src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleBlock.java rename to src/main/java/dev/redstudio/fbp/particles/FBPParticleBlock.java index 9a511bcc..38088aab 100644 --- a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleBlock.java +++ b/src/main/java/dev/redstudio/fbp/particles/FBPParticleBlock.java @@ -1,7 +1,7 @@ -package io.redstudioragnarok.fbp.particles; +package dev.redstudio.fbp.particles; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.handlers.EventHandler; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.handlers.EventHandler; import io.redstudioragnarok.redcore.vectors.Vector2F; import io.redstudioragnarok.redcore.vectors.Vector3F; import net.jafama.FastMath; @@ -28,7 +28,7 @@ import net.minecraft.world.chunk.Chunk; import org.lwjgl.opengl.GL11; -import static io.redstudioragnarok.fbp.FBP.mc; +import static dev.redstudio.fbp.FBP.MC; public class FBPParticleBlock extends Particle { @@ -69,9 +69,9 @@ public FBPParticleBlock(World worldIn, double posXIn, double posYIn, double posZ blockPos = new BlockPos(posXIn, posYIn, posZIn); - facing = mc.player.getHorizontalFacing(); + facing = MC.player.getHorizontalFacing(); - startingAngle = (float) FBP.random.nextDouble(0.03125, 0.0635); + startingAngle = (float) FBP.RANDOM.nextDouble(0.03125, 0.0635); prevRotation = new Vector3F(); rot = new Vector3F(); @@ -99,11 +99,11 @@ public FBPParticleBlock(World worldIn, double posXIn, double posYIn, double posZ block = (blockState = state).getBlock(); - blockModelRenderer = mc.getBlockRendererDispatcher().getBlockModelRenderer(); + blockModelRenderer = MC.getBlockRendererDispatcher().getBlockModelRenderer(); this.canCollide = false; - bakedModel = mc.getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state); + bakedModel = MC.getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state); tileEntity = worldIn.getTileEntity(blockPos); } @@ -112,22 +112,22 @@ public FBPParticleBlock(World worldIn, double posXIn, double posYIn, double posZ public void onUpdate() { if (!canCollide) { - IBlockState state = mc.world.getBlockState(blockPos); + IBlockState state = MC.world.getBlockState(blockPos); - if (state.getBlock() != FBP.dummyBlock || state.getBlock() == block) { + if (state.getBlock() != FBP.DUMMY_BLOCK || state.getBlock() == block) { if (blockSet && state.getBlock() == Blocks.AIR) { // the block was destroyed during the animation killParticle(); - FBP.dummyBlock.onBlockHarvested(mc.world, blockPos, state, null); - mc.world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), 2); + FBP.DUMMY_BLOCK.onBlockHarvested(MC.world, blockPos, state, null); + MC.world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), 2); return; } - FBP.dummyBlock.copyState(blockPos, blockState, this); - mc.world.setBlockState(blockPos, FBP.dummyBlock.getDefaultState(), 2); + FBP.DUMMY_BLOCK.copyState(blockPos, blockState, this); + MC.world.setBlockState(blockPos, FBP.DUMMY_BLOCK.getDefaultState(), 2); - Chunk chunk = mc.world.getChunk(blockPos); + Chunk chunk = MC.world.getChunk(blockPos); chunk.resetRelightChecks(); chunk.setLightPopulated(true); @@ -138,7 +138,7 @@ public void onUpdate() { spawned = true; } - if (this.isExpired || mc.isGamePaused()) + if (this.isExpired || MC.isGamePaused()) return; prevHeight = height; @@ -175,14 +175,14 @@ public void renderParticle(BufferBuilder buff, Entity entityIn, float partialTic return; if (canCollide) { - Block b = mc.world.getBlockState(blockPos).getBlock(); - if (block != b && b != Blocks.AIR && mc.world.getBlockState(blockPos).getBlock() != blockState.getBlock()) { - mc.world.setBlockState(blockPos, blockState, 2); + Block b = MC.world.getBlockState(blockPos).getBlock(); + if (block != b && b != Blocks.AIR && MC.world.getBlockState(blockPos).getBlock() != blockState.getBlock()) { + MC.world.setBlockState(blockPos, blockState, 2); if (tileEntity != null) - mc.world.setTileEntity(blockPos, tileEntity); + MC.world.setTileEntity(blockPos, tileEntity); - mc.world.sendPacketToServer(new CPacketPlayerDigging(Action.ABORT_DESTROY_BLOCK, blockPos, facing)); + MC.world.sendPacketToServer(new CPacketPlayerDigging(Action.ABORT_DESTROY_BLOCK, blockPos, facing)); // cleanup just to make sure it gets removed EventHandler.removePosEntry(blockPos); @@ -262,14 +262,14 @@ public void renderParticle(BufferBuilder buff, Entity entityIn, float partialTic } if (tick == 0) { - if (!(FBP.frozen && !FBP.spawnWhileFrozen) && mc.gameSettings.particleSetting < 2) { + if (!(FBP.frozen && !FBP.spawnWhileFrozen) && MC.gameSettings.particleSetting < 2) { spawnParticles(); } } buff.setTranslation(-blockPos.getX(), -blockPos.getY(), -blockPos.getZ()); Tessellator.getInstance().draw(); - mc.getRenderManager().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + MC.getRenderManager().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); buff.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); GlStateManager.pushMatrix(); @@ -285,22 +285,22 @@ public void renderParticle(BufferBuilder buff, Entity entityIn, float partialTic GlStateManager.translate(-tRot.x, -tRot.y, -tRot.z); GlStateManager.translate(t.x, t.y, t.z); - blockModelRenderer.renderModelSmooth(mc.world, bakedModel, blockState, blockPos, buff, false, textureSeed); + blockModelRenderer.renderModelSmooth(MC.world, bakedModel, blockState, blockPos, buff, false, textureSeed); buff.setTranslation(0, 0, 0); Tessellator.getInstance().draw(); GlStateManager.popMatrix(); - mc.getTextureManager().bindTexture(FBP.PARTICLES_TEXTURE); + MC.getTextureManager().bindTexture(FBP.PARTICLES_TEXTURE); buff.begin(7, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); } private void spawnParticles() { - if (mc.world.getBlockState(blockPos.offset(EnumFacing.DOWN)).getBlock() instanceof BlockAir) + if (MC.world.getBlockState(blockPos.offset(EnumFacing.DOWN)).getBlock() instanceof BlockAir) return; - AxisAlignedBB aabb = block.getSelectedBoundingBox(blockState, mc.world, blockPos); + AxisAlignedBB aabb = block.getSelectedBoundingBox(blockState, MC.world, blockPos); Vector2F[] corners = new Vector2F[] { new Vector2F((float) aabb.minX, (float) aabb.minZ), new Vector2F((float) aabb.maxX, (float) aabb.maxZ), new Vector2F((float) aabb.minX, (float) aabb.maxZ), new Vector2F((float) aabb.maxX, (float) aabb.minZ) }; @@ -313,14 +313,14 @@ private void spawnParticles() { mX /= -0.5; mZ /= -0.5; - mc.effectRenderer.addEffect(new FBPParticleDigging(mc.world, corner.x, blockPos.getY() + 0.1, corner.y, mX, 0, mZ, 0.6f, 1, 1, 1, block.getActualState(blockState, mc.world, blockPos), null, this.particleTexture).multipleParticleScaleBy(0.5f).multiplyVelocity(0.5f)); + MC.effectRenderer.addEffect(new FBPParticleDigging(MC.world, corner.x, blockPos.getY() + 0.1, corner.y, mX, 0, mZ, 0.6f, 1, 1, 1, block.getActualState(blockState, MC.world, blockPos), null, this.particleTexture).multipleParticleScaleBy(0.5f).multiplyVelocity(0.5f)); } } public void killParticle() { this.isExpired = true; - FBP.dummyBlock.blockNodes.remove(blockPos); + FBP.DUMMY_BLOCK.blockNodes.remove(blockPos); EventHandler.removePosEntry(blockPos); } diff --git a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleDigging.java b/src/main/java/dev/redstudio/fbp/particles/FBPParticleDigging.java similarity index 92% rename from src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleDigging.java rename to src/main/java/dev/redstudio/fbp/particles/FBPParticleDigging.java index 14061c09..4814c438 100644 --- a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleDigging.java +++ b/src/main/java/dev/redstudio/fbp/particles/FBPParticleDigging.java @@ -1,13 +1,13 @@ -package io.redstudioragnarok.fbp.particles; - -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.keys.KeyBindings; -import io.redstudioragnarok.fbp.models.ModelHelper; -import io.redstudioragnarok.fbp.renderer.CubeBatchRenderer; -import io.redstudioragnarok.fbp.renderer.RenderType; -import io.redstudioragnarok.fbp.renderer.color.ColorUtil; -import io.redstudioragnarok.fbp.renderer.light.LightUtil; -import io.redstudioragnarok.fbp.renderer.texture.TextureUtil; +package dev.redstudio.fbp.particles; + +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.keys.KeyBindings; +import dev.redstudio.fbp.models.ModelHelper; +import dev.redstudio.fbp.renderer.CubeBatchRenderer; +import dev.redstudio.fbp.renderer.RenderType; +import dev.redstudio.fbp.renderer.color.ColorUtil; +import dev.redstudio.fbp.renderer.light.LightUtil; +import dev.redstudio.fbp.renderer.texture.TextureUtil; import io.redstudioragnarok.redcore.utils.MathUtil; import io.redstudioragnarok.redcore.vectors.Vector3F; import net.jafama.FastMath; @@ -33,7 +33,7 @@ import javax.annotation.Nullable; import java.util.List; -import static io.redstudioragnarok.fbp.FBP.mc; +import static dev.redstudio.fbp.FBP.MC; public class FBPParticleDigging extends ParticleDigging { @@ -118,14 +118,14 @@ protected FBPParticleDigging(World worldIn, double xCoordIn, double yCoordIn, do particleGravity = block.blockParticleGravity * FBP.gravityMult; particleScale = FBP.scaleMult * (FBP.randomizedScale ? particleScale : 1); - particleMaxAge = (int) FBP.random.nextDouble(FBP.minAge, FBP.maxAge + 0.5); + particleMaxAge = (int) FBP.RANDOM.nextDouble(FBP.minAge, FBP.maxAge + 0.5); scaleAlpha = particleScale * 0.82; destroyed = facing == null; if (texture == null && ModelHelper.isModelValid(state)) { - BlockModelShapes blockModelShapes = mc.getBlockRendererDispatcher().getBlockModelShapes(); + BlockModelShapes blockModelShapes = MC.getBlockRendererDispatcher().getBlockModelShapes(); // GET THE TEXTURE OF THE BLOCK FACE if (!destroyed) { @@ -145,7 +145,7 @@ protected FBPParticleDigging(World worldIn, double xCoordIn, double yCoordIn, do this.particleTexture = texture; if (FBP.randomFadingSpeed) - endMult = MathUtil.clampMaxFirst((float) FBP.random.nextDouble(0.5, 0.9), 0.55F, 0.8F); + endMult = MathUtil.clampMaxFirst((float) FBP.RANDOM.nextDouble(0.5, 0.9), 0.55F, 0.8F); prevGravity = particleGravity; @@ -180,7 +180,7 @@ protected void multiplyColor(@Nullable BlockPos p_187154_1_) { if (blockState.getBlock() == Blocks.GRASS && facing != EnumFacing.UP) return; - int i = mc.getBlockColors().colorMultiplier(this.blockState, this.world, p_187154_1_, 0); + int i = MC.getBlockColors().colorMultiplier(this.blockState, this.world, p_187154_1_, 0); this.particleRed *= (i >> 16 & 255) / 255.0; this.particleGreen *= (i >> 8 & 255) / 255.0; this.particleBlue *= (i & 255) / 255.0; @@ -205,12 +205,12 @@ public int getFXLayer() { @Override public void onUpdate() { - if (KeyBindings.killParticles.isPressed()) + if (KeyBindings.KILL_PARTICLES.isPressed()) setExpired(); boolean allowedToMove = MathUtil.absolute((float) motionX) > 0.0001 || MathUtil.absolute((float) motionZ) > 0.0001; - if (!FBP.frozen && FBP.bounceOffWalls && !mc.isGamePaused() && particleAge > 0) { + if (!FBP.frozen && FBP.bounceOffWalls && !MC.isGamePaused() && particleAge > 0) { if (!wasFrozen && allowedToMove) { boolean xCollided = prevPosX == posX; boolean zCollided = prevPosZ == posZ; @@ -237,7 +237,7 @@ public void onUpdate() { prevParticleAlpha = particleAlpha; prevParticleScale = particleScale; - if (!mc.isGamePaused() && (!FBP.frozen)) { + if (!MC.isGamePaused() && (!FBP.frozen)) { if (!FBP.randomRotation) { if (!modeDebounce) { modeDebounce = true; @@ -269,7 +269,7 @@ else if (motionZ > 0) { modeDebounce = false; - rot.z = (float) FBP.random.nextDouble(30, 400); + rot.z = (float) FBP.RANDOM.nextDouble(30, 400); } if (allowedToMove) { @@ -513,9 +513,9 @@ public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialT } private void createRotationMatrix() { - double rx0 = FBP.random.nextDouble(); - double ry0 = FBP.random.nextDouble(); - double rz0 = FBP.random.nextDouble(); + double rx0 = FBP.RANDOM.nextDouble(); + double ry0 = FBP.RANDOM.nextDouble(); + double rz0 = FBP.RANDOM.nextDouble(); rotStep = new Vector3F(rx0 > 0.5 ? 1 : -1, ry0 > 0.5 ? 1 : -1, rz0 > 0.5 ? 1 : -1); diff --git a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleFlame.java b/src/main/java/dev/redstudio/fbp/particles/FBPParticleFlame.java similarity index 90% rename from src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleFlame.java rename to src/main/java/dev/redstudio/fbp/particles/FBPParticleFlame.java index c0e08f97..d89731fc 100644 --- a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleFlame.java +++ b/src/main/java/dev/redstudio/fbp/particles/FBPParticleFlame.java @@ -1,11 +1,11 @@ -package io.redstudioragnarok.fbp.particles; - -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.renderer.CubeBatchRenderer; -import io.redstudioragnarok.fbp.renderer.RenderType; -import io.redstudioragnarok.fbp.renderer.color.ColorUtil; -import io.redstudioragnarok.fbp.renderer.light.LightUtil; -import io.redstudioragnarok.fbp.renderer.texture.TextureUtil; +package dev.redstudio.fbp.particles; + +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.renderer.CubeBatchRenderer; +import dev.redstudio.fbp.renderer.RenderType; +import dev.redstudio.fbp.renderer.color.ColorUtil; +import dev.redstudio.fbp.renderer.light.LightUtil; +import dev.redstudio.fbp.renderer.texture.TextureUtil; import io.redstudioragnarok.redcore.vectors.Vector3F; import net.minecraft.block.state.IBlockState; import net.minecraft.client.particle.Particle; @@ -19,7 +19,7 @@ import java.util.List; -import static io.redstudioragnarok.fbp.FBP.mc; +import static dev.redstudio.fbp.FBP.MC; public class FBPParticleFlame extends ParticleFlame { @@ -47,7 +47,7 @@ protected FBPParticleFlame(World worldIn, double xCoordIn, double yCoordIn, doub this.particleGravity = -0.05f; particleScale *= FBP.scaleMult * 2.5; - particleMaxAge = FBP.random.nextInt(3, 5); + particleMaxAge = FBP.RANDOM.nextInt(3, 5); this.particleRed = 1; this.particleGreen = 1; @@ -58,7 +58,7 @@ protected FBPParticleFlame(World worldIn, double xCoordIn, double yCoordIn, doub particleAlpha = 1; if (FBP.randomFadingSpeed) - endMult *= FBP.random.nextDouble(0.9875, 1); + endMult *= FBP.RANDOM.nextDouble(0.9875, 1); multipleParticleScaleBy(1); } @@ -112,7 +112,7 @@ public void onUpdate() { else if (particleAlpha <= 0.325 && spawnAnother && world.getBlockState(new BlockPos(posX, posY, posZ)).getBlock() == Blocks.TORCH) { spawnAnother = false; - mc.effectRenderer.addEffect(new FBPParticleFlame(world, startPos.x, startPos.y, startPos.z, 0, false)); + MC.effectRenderer.addEffect(new FBPParticleFlame(world, startPos.x, startPos.y, startPos.z, 0, false)); } } diff --git a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleManager.java b/src/main/java/dev/redstudio/fbp/particles/FBPParticleManager.java similarity index 87% rename from src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleManager.java rename to src/main/java/dev/redstudio/fbp/particles/FBPParticleManager.java index 0744379b..ab3bf8d9 100644 --- a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleManager.java +++ b/src/main/java/dev/redstudio/fbp/particles/FBPParticleManager.java @@ -1,7 +1,7 @@ -package io.redstudioragnarok.fbp.particles; +package dev.redstudio.fbp.particles; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.handlers.ConfigHandler; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.handlers.ConfigHandler; import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.block.state.IBlockState; @@ -19,7 +19,7 @@ import java.util.Map; -import static io.redstudioragnarok.fbp.FBP.mc; +import static dev.redstudio.fbp.FBP.MC; public class FBPParticleManager extends ParticleManager { @@ -28,12 +28,12 @@ public FBPParticleManager(World worldIn, TextureManager rendererIn) { } public void carryOver() { - if (mc.effectRenderer == this) + if (MC.effectRenderer == this) return; - this.fxLayers = (mc.effectRenderer).fxLayers; - this.particleEmitters = (mc.effectRenderer).particleEmitters; - this.queue = (mc.effectRenderer).queue; + this.fxLayers = (MC.effectRenderer).fxLayers; + this.particleEmitters = (MC.effectRenderer).particleEmitters; + this.queue = (MC.effectRenderer).queue; } @Override @@ -64,9 +64,9 @@ public void addEffect(Particle effect) { } else return; } - } else if (mc.gameSettings.particleSetting < 2) { + } else if (MC.gameSettings.particleSetting < 2) { if (FBP.fancyFlame && toAdd instanceof ParticleFlame && !(toAdd instanceof FBPParticleFlame)) { - toAdd = new FBPParticleFlame(world, effect.posX, effect.posY, effect.posZ, FBP.random.nextDouble() * 0.25, true); + toAdd = new FBPParticleFlame(world, effect.posX, effect.posY, effect.posZ, FBP.RANDOM.nextDouble() * 0.25, true); effect.setExpired(); } else if (FBP.fancySmoke && toAdd instanceof ParticleSmokeNormal && !(toAdd instanceof FBPParticleSmoke)) { ParticleSmokeNormal particle = (ParticleSmokeNormal) effect; @@ -90,11 +90,11 @@ public void addEffect(Particle effect) { public void addBlockDestroyEffects(BlockPos pos, IBlockState state) { Block block = state.getBlock(); - if (!block.isAir(state, world, pos) && !block.addDestroyEffects(world, pos, this) && block != FBP.dummyBlock) { + if (!block.isAir(state, world, pos) && !block.addDestroyEffects(world, pos, this) && block != FBP.DUMMY_BLOCK) { state = state.getActualState(world, pos); block = state.getBlock(); - TextureAtlasSprite texture = mc.getBlockRendererDispatcher().getBlockModelShapes().getTexture(state); + TextureAtlasSprite texture = MC.getBlockRendererDispatcher().getBlockModelShapes().getTexture(state); for (int i = 0; i < FBP.particlesPerAxis; ++i) { for (int j = 0; j < FBP.particlesPerAxis; ++j) { @@ -104,7 +104,7 @@ public void addBlockDestroyEffects(BlockPos pos, IBlockState state) { double posZ = pos.getZ() + ((k + 0.5) / FBP.particlesPerAxis); if ((!(block instanceof BlockLiquid) && !(FBP.frozen && !FBP.spawnWhileFrozen)) && !ConfigHandler.isBlacklisted(block, true)) { - double scale = FBP.random.nextDouble(0.75, 1); + double scale = FBP.RANDOM.nextDouble(0.75, 1); FBPParticleDigging toSpawn = new FBPParticleDigging(world, posX, posY, posZ, posX - pos.getX() - 0.5, -0.001, posZ - pos.getZ() - 0.5, (float) scale, 1, 1, 1, state, null, texture).setBlockPos(pos); @@ -120,7 +120,7 @@ public void addBlockDestroyEffects(BlockPos pos, IBlockState state) { public void addBlockHitEffects(BlockPos pos, EnumFacing side) { IBlockState iblockstate = world.getBlockState(pos); - if (iblockstate.getBlock() == FBP.dummyBlock) + if (iblockstate.getBlock() == FBP.DUMMY_BLOCK) return; if (iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) { @@ -131,15 +131,15 @@ public void addBlockHitEffects(BlockPos pos, EnumFacing side) { double hitPosX, hitPosY, hitPosZ; - RayTraceResult target = mc.objectMouseOver; + RayTraceResult target = MC.objectMouseOver; if (target == null || target.hitVec == null) target = new RayTraceResult(null, new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5)); if (FBP.smartBreaking && (!(iblockstate.getBlock() instanceof BlockLiquid) && !(FBP.frozen && !FBP.spawnWhileFrozen))) { - hitPosX = target.hitVec.x + FBP.random.nextDouble(-0.21, 0.21) * Math.abs(boundingBox.maxX - boundingBox.minX); - hitPosY = target.hitVec.y + FBP.random.nextDouble(-0.21, 0.21) * Math.abs(boundingBox.maxY - boundingBox.minY); - hitPosZ = target.hitVec.z + FBP.random.nextDouble(-0.21, 0.21) * Math.abs(boundingBox.maxZ - boundingBox.minZ); + hitPosX = target.hitVec.x + FBP.RANDOM.nextDouble(-0.21, 0.21) * Math.abs(boundingBox.maxX - boundingBox.minX); + hitPosY = target.hitVec.y + FBP.RANDOM.nextDouble(-0.21, 0.21) * Math.abs(boundingBox.maxY - boundingBox.minY); + hitPosZ = target.hitVec.z + FBP.RANDOM.nextDouble(-0.21, 0.21) * Math.abs(boundingBox.maxZ - boundingBox.minZ); } else { hitPosX = sidePosX + world.rand.nextDouble() * (boundingBox.maxX - boundingBox.minX - 0.2) + 0.1 + boundingBox.minX; hitPosY = sidePosY + world.rand.nextDouble() * (boundingBox.maxY - boundingBox.minY - 0.2) + 0.1 + boundingBox.minY; @@ -174,7 +174,7 @@ public void addBlockHitEffects(BlockPos pos, EnumFacing side) { int damage = 0; DestroyBlockProgress progress; - Map damagedBlocks = (mc.renderGlobal).damagedBlocks; + Map damagedBlocks = (MC.renderGlobal).damagedBlocks; if (!damagedBlocks.isEmpty()) { diff --git a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleRain.java b/src/main/java/dev/redstudio/fbp/particles/FBPParticleRain.java similarity index 84% rename from src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleRain.java rename to src/main/java/dev/redstudio/fbp/particles/FBPParticleRain.java index 0ab90395..5c0d280a 100644 --- a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleRain.java +++ b/src/main/java/dev/redstudio/fbp/particles/FBPParticleRain.java @@ -1,11 +1,11 @@ -package io.redstudioragnarok.fbp.particles; - -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.renderer.CubeBatchRenderer; -import io.redstudioragnarok.fbp.renderer.RenderType; -import io.redstudioragnarok.fbp.renderer.color.ColorUtil; -import io.redstudioragnarok.fbp.renderer.light.LightUtil; -import io.redstudioragnarok.fbp.renderer.texture.TextureUtil; +package dev.redstudio.fbp.particles; + +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.renderer.CubeBatchRenderer; +import dev.redstudio.fbp.renderer.RenderType; +import dev.redstudio.fbp.renderer.color.ColorUtil; +import dev.redstudio.fbp.renderer.light.LightUtil; +import dev.redstudio.fbp.renderer.texture.TextureUtil; import io.redstudioragnarok.redcore.utils.MathUtil; import net.minecraft.block.state.IBlockState; import net.minecraft.client.particle.ParticleDigging; @@ -17,7 +17,7 @@ import java.util.List; -import static io.redstudioragnarok.fbp.FBP.mc; +import static dev.redstudio.fbp.FBP.MC; public class FBPParticleRain extends ParticleDigging { @@ -32,7 +32,7 @@ public FBPParticleRain(World worldIn, double xCoordIn, double yCoordIn, double z this.sourcePos = new BlockPos(xCoordIn, yCoordIn, zCoordIn); - AngleY = (float) (FBP.random.nextDouble() * 45); + AngleY = (float) (FBP.RANDOM.nextDouble() * 45); this.motionX = xSpeedIn; this.motionY = -ySpeedIn; @@ -40,7 +40,7 @@ public FBPParticleRain(World worldIn, double xCoordIn, double yCoordIn, double z this.particleGravity = 0.025F; - particleMaxAge = (int) FBP.random.nextDouble(50, 70); + particleMaxAge = (int) FBP.RANDOM.nextDouble(50, 70); this.particleAlpha = 0; this.particleScale = 0; @@ -48,7 +48,7 @@ public FBPParticleRain(World worldIn, double xCoordIn, double yCoordIn, double z this.canCollide = true; if (FBP.randomFadingSpeed) - endMult *= FBP.random.nextDouble(0.85, 1); + endMult *= FBP.RANDOM.nextDouble(0.85, 1); } @Override @@ -66,10 +66,10 @@ public void onUpdate() { prevParticleScale = particleScale; prevParticleHeight = particleHeight; - if (!mc.isGamePaused()) { + if (!MC.isGamePaused()) { particleAge++; - if (posY < mc.player.posY - (mc.gameSettings.renderDistanceChunks * 9)) + if (posY < MC.player.posY - (MC.gameSettings.renderDistanceChunks * 9)) setExpired(); if (!onGround) { @@ -139,9 +139,9 @@ public void onUpdate() { } } - this.particleRed = (float) mc.world.getSkyColor(mc.player, 0).x; - this.particleGreen = MathUtil.clampMaxFirst((float) (mc.world.getSkyColor(mc.player, 0).y + 0.25F), 0.25F, 1); - this.particleBlue = MathUtil.clampMaxFirst((float) (mc.world.getSkyColor(mc.player, 0).z + 0.5F), 0.5F, 1); + this.particleRed = (float) MC.world.getSkyColor(MC.player, 0).x; + this.particleGreen = MathUtil.clampMaxFirst((float) (MC.world.getSkyColor(MC.player, 0).y + 0.25F), 0.25F, 1); + this.particleBlue = MathUtil.clampMaxFirst((float) (MC.world.getSkyColor(MC.player, 0).z + 0.5F), 0.5F, 1); if (this.particleGreen > 1) particleGreen = 1; diff --git a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleSmoke.java b/src/main/java/dev/redstudio/fbp/particles/FBPParticleSmoke.java similarity index 86% rename from src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleSmoke.java rename to src/main/java/dev/redstudio/fbp/particles/FBPParticleSmoke.java index 184b1338..9caba76a 100644 --- a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleSmoke.java +++ b/src/main/java/dev/redstudio/fbp/particles/FBPParticleSmoke.java @@ -1,11 +1,11 @@ -package io.redstudioragnarok.fbp.particles; - -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.renderer.CubeBatchRenderer; -import io.redstudioragnarok.fbp.renderer.RenderType; -import io.redstudioragnarok.fbp.renderer.color.ColorUtil; -import io.redstudioragnarok.fbp.renderer.light.LightUtil; -import io.redstudioragnarok.fbp.renderer.texture.TextureUtil; +package dev.redstudio.fbp.particles; + +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.renderer.CubeBatchRenderer; +import dev.redstudio.fbp.renderer.RenderType; +import dev.redstudio.fbp.renderer.color.ColorUtil; +import dev.redstudio.fbp.renderer.light.LightUtil; +import dev.redstudio.fbp.renderer.texture.TextureUtil; import io.redstudioragnarok.redcore.utils.MathUtil; import net.minecraft.block.Block; import net.minecraft.client.particle.Particle; @@ -45,21 +45,21 @@ protected FBPParticleSmoke(World worldIn, double xCoordIn, double yCoordIn, doub this.particleScale *= 0.65; this.particleGravity *= 0.25; - this.motionX = FBP.random.nextDouble(-0.05, 0.05); - this.motionY = FBP.random.nextDouble() * 0.5; - this.motionZ = FBP.random.nextDouble(-0.05, 0.05); + this.motionX = FBP.RANDOM.nextDouble(-0.05, 0.05); + this.motionY = FBP.RANDOM.nextDouble() * 0.5; + this.motionZ = FBP.RANDOM.nextDouble(-0.05, 0.05); this.motionY *= 0.35; scaleAlpha = particleScale * 0.5; - particleMaxAge = FBP.random.nextInt(7, 18); + particleMaxAge = FBP.RANDOM.nextInt(7, 18); } else if (block == Blocks.TORCH) { particleScale *= 0.45; - this.motionX = FBP.random.nextDouble(-0.05, 0.05); - this.motionY = FBP.random.nextDouble() * 0.5; - this.motionZ = FBP.random.nextDouble(-0.05, 0.05); + this.motionX = FBP.RANDOM.nextDouble(-0.05, 0.05); + this.motionY = FBP.RANDOM.nextDouble() * 0.5; + this.motionZ = FBP.RANDOM.nextDouble(-0.05, 0.05); this.motionX *= 0.925; this.motionY = 0.005; @@ -71,7 +71,7 @@ protected FBPParticleSmoke(World worldIn, double xCoordIn, double yCoordIn, doub scaleAlpha = particleScale * 0.75; - particleMaxAge = FBP.random.nextInt(5, 10); + particleMaxAge = FBP.RANDOM.nextInt(5, 10); } else { particleScale = scale; motionY *= 0.935; @@ -84,7 +84,7 @@ protected FBPParticleSmoke(World worldIn, double xCoordIn, double yCoordIn, doub particleAlpha = 0.9f; if (FBP.randomFadingSpeed) - endMult = MathUtil.clampMaxFirst((float) FBP.random.nextDouble(0.425, 1.15), 0.5432F, 1); + endMult = MathUtil.clampMaxFirst((float) FBP.RANDOM.nextDouble(0.425, 1.15), 0.5432F, 1); multipleParticleScaleBy(1); } diff --git a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleSnow.java b/src/main/java/dev/redstudio/fbp/particles/FBPParticleSnow.java similarity index 88% rename from src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleSnow.java rename to src/main/java/dev/redstudio/fbp/particles/FBPParticleSnow.java index 5cf95b6f..6a98e05a 100644 --- a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleSnow.java +++ b/src/main/java/dev/redstudio/fbp/particles/FBPParticleSnow.java @@ -1,11 +1,11 @@ -package io.redstudioragnarok.fbp.particles; - -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.renderer.CubeBatchRenderer; -import io.redstudioragnarok.fbp.renderer.RenderType; -import io.redstudioragnarok.fbp.renderer.color.ColorUtil; -import io.redstudioragnarok.fbp.renderer.light.LightUtil; -import io.redstudioragnarok.fbp.renderer.texture.TextureUtil; +package dev.redstudio.fbp.particles; + +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.renderer.CubeBatchRenderer; +import dev.redstudio.fbp.renderer.RenderType; +import dev.redstudio.fbp.renderer.color.ColorUtil; +import dev.redstudio.fbp.renderer.light.LightUtil; +import dev.redstudio.fbp.renderer.texture.TextureUtil; import io.redstudioragnarok.redcore.vectors.Vector3F; import net.jafama.FastMath; import net.minecraft.block.state.IBlockState; @@ -18,7 +18,7 @@ import java.util.List; -import static io.redstudioragnarok.fbp.FBP.mc; +import static dev.redstudio.fbp.FBP.MC; public class FBPParticleSnow extends ParticleDigging { @@ -43,8 +43,8 @@ public FBPParticleSnow(World worldIn, double xCoordIn, double yCoordIn, double z this.motionZ = zSpeedIn; this.particleGravity = 1; - particleScale *= FBP.random.nextDouble(FBP.scaleMult - 0.25, FBP.scaleMult + 0.25); - particleMaxAge = (int) FBP.random.nextDouble(250, 300); + particleScale *= FBP.RANDOM.nextDouble(FBP.scaleMult - 0.25, FBP.scaleMult + 0.25); + particleMaxAge = (int) FBP.RANDOM.nextDouble(250, 300); this.particleRed = this.particleGreen = this.particleBlue = 1; scaleAlpha = particleScale * 0.75; @@ -55,13 +55,13 @@ public FBPParticleSnow(World worldIn, double xCoordIn, double yCoordIn, double z this.canCollide = true; if (FBP.randomFadingSpeed) - endMult *= FBP.random.nextDouble(0.7, 1); + endMult *= FBP.RANDOM.nextDouble(0.7, 1); } private void createRotationMatrix() { - double rx = FBP.random.nextDouble(); - double ry = FBP.random.nextDouble(); - double rz = FBP.random.nextDouble(); + double rx = FBP.RANDOM.nextDouble(); + double ry = FBP.RANDOM.nextDouble(); + double rz = FBP.RANDOM.nextDouble(); rotStep = new Vector3F(rx > 0.5 ? 1 : -1, ry > 0.5 ? 1 : -1, rz > 0.5 ? 1 : -1); @@ -84,10 +84,10 @@ public void onUpdate() { prevParticleAlpha = particleAlpha; prevParticleScale = particleScale; - if (!mc.isGamePaused()) { + if (!MC.isGamePaused()) { particleAge++; - if (posY < mc.player.posY - (mc.gameSettings.renderDistanceChunks * 16)) + if (posY < MC.player.posY - (MC.gameSettings.renderDistanceChunks * 16)) setExpired(); tempRot.copy(rotStep); diff --git a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleSpinningFlame.java b/src/main/java/dev/redstudio/fbp/particles/FBPParticleSpinningFlame.java similarity index 79% rename from src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleSpinningFlame.java rename to src/main/java/dev/redstudio/fbp/particles/FBPParticleSpinningFlame.java index 0617edf6..adf3230b 100644 --- a/src/main/java/io/redstudioragnarok/fbp/particles/FBPParticleSpinningFlame.java +++ b/src/main/java/dev/redstudio/fbp/particles/FBPParticleSpinningFlame.java @@ -1,12 +1,12 @@ -package io.redstudioragnarok.fbp.particles; +package dev.redstudio.fbp.particles; -import io.redstudioragnarok.fbp.renderer.CubeBatchRenderer; -import io.redstudioragnarok.fbp.renderer.FastQuadUploader; -import io.redstudioragnarok.fbp.renderer.RenderType; -import io.redstudioragnarok.fbp.renderer.color.ColorUtil; -import io.redstudioragnarok.fbp.renderer.light.LightUtil; -import io.redstudioragnarok.fbp.renderer.texture.TextureUtil; -import io.redstudioragnarok.fbp.utils.MathUtil; +import dev.redstudio.fbp.renderer.CubeBatchRenderer; +import dev.redstudio.fbp.renderer.FastQuadUploader; +import dev.redstudio.fbp.renderer.RenderType; +import dev.redstudio.fbp.renderer.color.ColorUtil; +import dev.redstudio.fbp.renderer.light.LightUtil; +import dev.redstudio.fbp.renderer.texture.TextureUtil; +import io.redstudioragnarok.redcore.utils.MathUtil; import meldexun.matrixutil.MatrixStack; import meldexun.matrixutil.Quaternion; import net.minecraft.client.Minecraft; @@ -38,8 +38,8 @@ public void renderParticle(MatrixStack matrixStack, float partialTicks, int brig Minecraft mc = Minecraft.getMinecraft(); EntityPlayer player = mc.player; boolean thirdPersionFrontView = mc.gameSettings.thirdPersonView == 2; - float rx = (thirdPersionFrontView ? 1.0F : -1.0F) * MathUtil.lerp(player.prevRotationPitch, player.rotationPitch, partialTicks); - float ry = (thirdPersionFrontView ? 0.0F : 180.0F) - MathUtil.lerp(player.prevRotationYaw, player.rotationYaw, partialTicks); + float rx = (thirdPersionFrontView ? 1.0F : -1.0F) * MathUtil.lerp(player.prevRotationPitch, partialTicks, player.rotationPitch); + float ry = (thirdPersionFrontView ? 0.0F : 180.0F) - MathUtil.lerp(player.prevRotationYaw, partialTicks, player.rotationYaw); float rz = 10.0F * (this.particleAge + partialTicks); Quaternion rotation = Quaternion.createRotateY((float) Math.toRadians(ry)); diff --git a/src/main/java/io/redstudioragnarok/fbp/particles/IFBPParticle.java b/src/main/java/dev/redstudio/fbp/particles/IFBPParticle.java similarity index 57% rename from src/main/java/io/redstudioragnarok/fbp/particles/IFBPParticle.java rename to src/main/java/dev/redstudio/fbp/particles/IFBPParticle.java index 3f5418cc..c4077cf4 100644 --- a/src/main/java/io/redstudioragnarok/fbp/particles/IFBPParticle.java +++ b/src/main/java/dev/redstudio/fbp/particles/IFBPParticle.java @@ -1,6 +1,6 @@ -package io.redstudioragnarok.fbp.particles; +package dev.redstudio.fbp.particles; -import io.redstudioragnarok.fbp.utils.MathUtil; +import io.redstudioragnarok.redcore.utils.MathUtil; import meldexun.matrixutil.MatrixStack; import net.minecraft.client.particle.Particle; @@ -13,9 +13,9 @@ default Particle self() { } default void renderParticle(float partialTicks) { - float x = (float) (MathUtil.lerp(this.self().prevPosX, this.self().posX, partialTicks) - Particle.interpPosX); - float y = (float) (MathUtil.lerp(this.self().prevPosY, this.self().posY, partialTicks) - Particle.interpPosY); - float z = (float) (MathUtil.lerp(this.self().prevPosZ, this.self().posZ, partialTicks) - Particle.interpPosZ); + float x = (float) (MathUtil.lerp(this.self().prevPosX, partialTicks, this.self().posX) - Particle.interpPosX); + float y = (float) (MathUtil.lerp(this.self().prevPosY, partialTicks, this.self().posY) - Particle.interpPosY); + float z = (float) (MathUtil.lerp(this.self().prevPosZ, partialTicks, this.self().posZ) - Particle.interpPosZ); int brightness = this.self().getBrightnessForRender(partialTicks); diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/CubeBatchRenderer.java b/src/main/java/dev/redstudio/fbp/renderer/CubeBatchRenderer.java similarity index 85% rename from src/main/java/io/redstudioragnarok/fbp/renderer/CubeBatchRenderer.java rename to src/main/java/dev/redstudio/fbp/renderer/CubeBatchRenderer.java index 708b797b..2037b1f9 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/CubeBatchRenderer.java +++ b/src/main/java/dev/redstudio/fbp/renderer/CubeBatchRenderer.java @@ -1,9 +1,9 @@ -package io.redstudioragnarok.fbp.renderer; +package dev.redstudio.fbp.renderer; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.renderer.color.IColorProvider; -import io.redstudioragnarok.fbp.renderer.light.ILightCoordProvider; -import io.redstudioragnarok.fbp.renderer.texture.ITexCoordProvider; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.renderer.color.IColorProvider; +import dev.redstudio.fbp.renderer.light.ILightCoordProvider; +import dev.redstudio.fbp.renderer.texture.ITexCoordProvider; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.WorldVertexBufferUploader; import org.lwjgl.opengl.GL11; @@ -32,7 +32,7 @@ public static void renderCube(RenderType renderType, float x, float y, float z, public static BufferBuilder getBuffer(RenderType renderType) { BufferBuilder buffer = BUFFER_BUILDERS.get(renderType); if (!buffer.isDrawing) { - buffer.begin(GL11.GL_QUADS, FBP.vertexFormat); + buffer.begin(GL11.GL_QUADS, FBP.VERTEX_FORMAT); } return buffer; } diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/FBPWeatherRenderer.java b/src/main/java/dev/redstudio/fbp/renderer/FBPWeatherRenderer.java similarity index 61% rename from src/main/java/io/redstudioragnarok/fbp/renderer/FBPWeatherRenderer.java rename to src/main/java/dev/redstudio/fbp/renderer/FBPWeatherRenderer.java index 6c92ff59..2219a826 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/FBPWeatherRenderer.java +++ b/src/main/java/dev/redstudio/fbp/renderer/FBPWeatherRenderer.java @@ -1,8 +1,8 @@ -package io.redstudioragnarok.fbp.renderer; +package dev.redstudio.fbp.renderer; -import io.redstudioragnarok.fbp.FBP; -import io.redstudioragnarok.fbp.particles.FBPParticleRain; -import io.redstudioragnarok.fbp.particles.FBPParticleSnow; +import dev.redstudio.fbp.FBP; +import dev.redstudio.fbp.particles.FBPParticleRain; +import dev.redstudio.fbp.particles.FBPParticleSnow; import net.jafama.FastMath; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; @@ -11,7 +11,7 @@ import net.minecraft.world.biome.Biome; import net.minecraftforge.client.IRenderHandler; -import static io.redstudioragnarok.fbp.FBP.*; +import static dev.redstudio.fbp.FBP.*; /** * This class extends IRenderHandler and is responsible for spawning weather particles. @@ -38,14 +38,14 @@ public void render(float partialTicks, WorldClient world, Minecraft mc) { * Updates density and spawn new weather particles. */ public void onUpdate() { - if (mc.world.isRaining()) { + if (MC.world.isRaining()) { // Smooth transition when switching from rain to thunder if (secondaryTickCounter++ >= 20 && dynamicWeather) { if (!snowBiome) - desiredThunderMultiplier = mc.world.isThundering() ? 5 : 0; + desiredThunderMultiplier = MC.world.isThundering() ? 5 : 0; else - desiredThunderMultiplier = mc.world.isThundering() ? 3 : 0; + desiredThunderMultiplier = MC.world.isThundering() ? 3 : 0; thunderMultiplier = thunderMultiplier < desiredThunderMultiplier ? thunderMultiplier + 1 : thunderMultiplier > desiredThunderMultiplier ? thunderMultiplier - 1 : thunderMultiplier; @@ -55,36 +55,36 @@ public void onUpdate() { density = weatherParticleDensity + weatherRenderDistance * 4; if (tickCounter++ >= 12 - thunderMultiplier) { - mX = mc.player.motionX * 26; - mZ = mc.player.motionZ * 26; + mX = MC.player.motionX * 26; + mZ = MC.player.motionZ * 26; mT = FastMath.sqrtQuick(mX * mX + mZ * mZ) / 25; blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int i = 0; i < 32 * density; i++) { // Get random position within radius of a little over the player's render distance - angle = FBP.random.nextDouble() * FastMath.PI * 2; - radius = FastMath.sqrtQuick(FBP.random.nextDouble()) * 35 * weatherRenderDistance; - X = mc.player.posX + mX + radius * FastMath.cosQuick(angle); - Z = mc.player.posZ + mZ + radius * FastMath.sinQuick(angle); + angle = FBP.RANDOM.nextDouble() * FastMath.PI * 2; + radius = FastMath.sqrtQuick(FBP.RANDOM.nextDouble()) * 35 * weatherRenderDistance; + X = MC.player.posX + mX + radius * FastMath.cosQuick(angle); + Z = MC.player.posZ + mZ + radius * FastMath.sinQuick(angle); - Y = (int) (mc.player.posY + 15 + FBP.random.nextDouble() * 10 + (mc.player.motionY * 6)); + Y = (int) (MC.player.posY + 15 + FBP.RANDOM.nextDouble() * 10 + (MC.player.motionY * 6)); - blockpos$mutableblockpos.setPos(X, mc.player.posY, Z); - biome = mc.world.getBiome(blockpos$mutableblockpos); + blockpos$mutableblockpos.setPos(X, MC.player.posY, Z); + biome = MC.world.getBiome(blockpos$mutableblockpos); snowBiome = biome.getEnableSnow(); - surfaceHeight = mc.world.getPrecipitationHeight(blockpos$mutableblockpos).getY(); + surfaceHeight = MC.world.getPrecipitationHeight(blockpos$mutableblockpos).getY(); if (Y <= surfaceHeight + 2) Y = surfaceHeight + 10; if (biome.canRain()) { - mc.effectRenderer.addEffect(new FBPParticleRain(mc.world, X, Y, Z, 0.1, FBP.random.nextDouble(0.75, 0.99) + mT / 2, 0.1, Blocks.SNOW.getDefaultState())); + MC.effectRenderer.addEffect(new FBPParticleRain(MC.world, X, Y, Z, 0.1, FBP.RANDOM.nextDouble(0.75, 0.99) + mT / 2, 0.1, Blocks.SNOW.getDefaultState())); } else if (snowBiome) { if ((i & 1) == 0) - mc.effectRenderer.addEffect(new FBPParticleSnow(mc.world, X, Y, Z, FBP.random.nextDouble(-0.5, 0.5), FBP.random.nextDouble(0.25, 1) + mT * 1.5, FBP.random.nextDouble(-0.5, 0.5), Blocks.SNOW.getDefaultState())); + MC.effectRenderer.addEffect(new FBPParticleSnow(MC.world, X, Y, Z, FBP.RANDOM.nextDouble(-0.5, 0.5), FBP.RANDOM.nextDouble(0.25, 1) + mT * 1.5, FBP.RANDOM.nextDouble(-0.5, 0.5), Blocks.SNOW.getDefaultState())); } } tickCounter = 0; diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/FastCubeUploader.java b/src/main/java/dev/redstudio/fbp/renderer/FastCubeUploader.java similarity index 96% rename from src/main/java/io/redstudioragnarok/fbp/renderer/FastCubeUploader.java rename to src/main/java/dev/redstudio/fbp/renderer/FastCubeUploader.java index 4f0486fe..2c601121 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/FastCubeUploader.java +++ b/src/main/java/dev/redstudio/fbp/renderer/FastCubeUploader.java @@ -1,8 +1,8 @@ -package io.redstudioragnarok.fbp.renderer; +package dev.redstudio.fbp.renderer; -import io.redstudioragnarok.fbp.renderer.color.IColorProvider; -import io.redstudioragnarok.fbp.renderer.light.ILightCoordProvider; -import io.redstudioragnarok.fbp.renderer.texture.ITexCoordProvider; +import dev.redstudio.fbp.renderer.color.IColorProvider; +import dev.redstudio.fbp.renderer.light.ILightCoordProvider; +import dev.redstudio.fbp.renderer.texture.ITexCoordProvider; import meldexun.matrixutil.*; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.util.EnumFacing; diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/FastQuadUploader.java b/src/main/java/dev/redstudio/fbp/renderer/FastQuadUploader.java similarity index 95% rename from src/main/java/io/redstudioragnarok/fbp/renderer/FastQuadUploader.java rename to src/main/java/dev/redstudio/fbp/renderer/FastQuadUploader.java index e54013eb..acf70c6a 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/FastQuadUploader.java +++ b/src/main/java/dev/redstudio/fbp/renderer/FastQuadUploader.java @@ -1,8 +1,8 @@ -package io.redstudioragnarok.fbp.renderer; +package dev.redstudio.fbp.renderer; -import io.redstudioragnarok.fbp.renderer.color.IColorProvider; -import io.redstudioragnarok.fbp.renderer.light.ILightCoordProvider; -import io.redstudioragnarok.fbp.renderer.texture.ITexCoordProvider; +import dev.redstudio.fbp.renderer.color.IColorProvider; +import dev.redstudio.fbp.renderer.light.ILightCoordProvider; +import dev.redstudio.fbp.renderer.texture.ITexCoordProvider; import meldexun.matrixutil.Matrix3f; import meldexun.matrixutil.Matrix4f; import meldexun.matrixutil.MatrixStack; diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/RenderType.java b/src/main/java/dev/redstudio/fbp/renderer/RenderType.java similarity index 97% rename from src/main/java/io/redstudioragnarok/fbp/renderer/RenderType.java rename to src/main/java/dev/redstudio/fbp/renderer/RenderType.java index 65c2f0d6..af9af10d 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/RenderType.java +++ b/src/main/java/dev/redstudio/fbp/renderer/RenderType.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.renderer; +package dev.redstudio.fbp.renderer; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/color/ColorUtil.java b/src/main/java/dev/redstudio/fbp/renderer/color/ColorUtil.java similarity index 97% rename from src/main/java/io/redstudioragnarok/fbp/renderer/color/ColorUtil.java rename to src/main/java/dev/redstudio/fbp/renderer/color/ColorUtil.java index e5297330..060a23d4 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/color/ColorUtil.java +++ b/src/main/java/dev/redstudio/fbp/renderer/color/ColorUtil.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.renderer.color; +package dev.redstudio.fbp.renderer.color; import net.minecraft.util.EnumFacing; diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/color/IColorPacker.java b/src/main/java/dev/redstudio/fbp/renderer/color/IColorPacker.java similarity index 85% rename from src/main/java/io/redstudioragnarok/fbp/renderer/color/IColorPacker.java rename to src/main/java/dev/redstudio/fbp/renderer/color/IColorPacker.java index 53bc312d..a7c52a97 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/color/IColorPacker.java +++ b/src/main/java/dev/redstudio/fbp/renderer/color/IColorPacker.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.renderer.color; +package dev.redstudio.fbp.renderer.color; import java.nio.ByteOrder; diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/color/IColorProvider.java b/src/main/java/dev/redstudio/fbp/renderer/color/IColorProvider.java similarity index 69% rename from src/main/java/io/redstudioragnarok/fbp/renderer/color/IColorProvider.java rename to src/main/java/dev/redstudio/fbp/renderer/color/IColorProvider.java index cebb749c..719e4ca5 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/color/IColorProvider.java +++ b/src/main/java/dev/redstudio/fbp/renderer/color/IColorProvider.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.renderer.color; +package dev.redstudio.fbp.renderer.color; import net.minecraft.util.EnumFacing; diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/light/ILightCoordProvider.java b/src/main/java/dev/redstudio/fbp/renderer/light/ILightCoordProvider.java similarity index 71% rename from src/main/java/io/redstudioragnarok/fbp/renderer/light/ILightCoordProvider.java rename to src/main/java/dev/redstudio/fbp/renderer/light/ILightCoordProvider.java index 3793c324..80a0e27d 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/light/ILightCoordProvider.java +++ b/src/main/java/dev/redstudio/fbp/renderer/light/ILightCoordProvider.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.renderer.light; +package dev.redstudio.fbp.renderer.light; import net.minecraft.util.EnumFacing; diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/light/LightUtil.java b/src/main/java/dev/redstudio/fbp/renderer/light/LightUtil.java similarity index 96% rename from src/main/java/io/redstudioragnarok/fbp/renderer/light/LightUtil.java rename to src/main/java/dev/redstudio/fbp/renderer/light/LightUtil.java index 92236618..f9f98587 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/light/LightUtil.java +++ b/src/main/java/dev/redstudio/fbp/renderer/light/LightUtil.java @@ -1,11 +1,11 @@ -package io.redstudioragnarok.fbp.renderer.light; +package dev.redstudio.fbp.renderer.light; import io.redstudioragnarok.redcore.utils.MathUtil; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.storage.ExtendedBlockStorage; -import static io.redstudioragnarok.fbp.FBP.mc; +import static dev.redstudio.fbp.FBP.MC; public class LightUtil { @@ -46,7 +46,7 @@ public static int getCombinedLight(float x, float y, float z) { public static int getCombinedLight(int x, int y, int z) { if (y < 0 || y >= 256) return 0; - world = mc.player.world; + world = MC.player.world; chunk = world.getChunk(x >> 4, z >> 4); section = chunk.getBlockStorageArray()[y >> 4]; if (section != null) { diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/texture/ITexCoordProvider.java b/src/main/java/dev/redstudio/fbp/renderer/texture/ITexCoordProvider.java similarity index 80% rename from src/main/java/io/redstudioragnarok/fbp/renderer/texture/ITexCoordProvider.java rename to src/main/java/dev/redstudio/fbp/renderer/texture/ITexCoordProvider.java index 4cf6df87..aa56aba7 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/texture/ITexCoordProvider.java +++ b/src/main/java/dev/redstudio/fbp/renderer/texture/ITexCoordProvider.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.renderer.texture; +package dev.redstudio.fbp.renderer.texture; import net.minecraft.util.EnumFacing; diff --git a/src/main/java/io/redstudioragnarok/fbp/renderer/texture/TextureUtil.java b/src/main/java/dev/redstudio/fbp/renderer/texture/TextureUtil.java similarity index 97% rename from src/main/java/io/redstudioragnarok/fbp/renderer/texture/TextureUtil.java rename to src/main/java/dev/redstudio/fbp/renderer/texture/TextureUtil.java index 09428c9a..9da46fe3 100644 --- a/src/main/java/io/redstudioragnarok/fbp/renderer/texture/TextureUtil.java +++ b/src/main/java/dev/redstudio/fbp/renderer/texture/TextureUtil.java @@ -1,4 +1,4 @@ -package io.redstudioragnarok.fbp.renderer.texture; +package dev.redstudio.fbp.renderer.texture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.EnumFacing; diff --git a/src/main/java/io/redstudioragnarok/fbp/handlers/ConfigHandler.java b/src/main/java/io/redstudioragnarok/fbp/handlers/ConfigHandler.java deleted file mode 100644 index 4509bb6c..00000000 --- a/src/main/java/io/redstudioragnarok/fbp/handlers/ConfigHandler.java +++ /dev/null @@ -1,665 +0,0 @@ -package io.redstudioragnarok.fbp.handlers; - -import io.redstudioragnarok.fbp.FBP; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import org.apache.commons.lang3.StringUtils; - -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; - -import static io.redstudioragnarok.fbp.utils.ModReference.LOG; - -/** - * This class handle everything related to the config system. - */ -public class ConfigHandler { - - private static FileInputStream fileInputStream; - private static InputStreamReader inputStreamReader; - private static BufferedReader bufferedReader; - - private static PrintWriter writer; - - private static String line, name; - - /** - * Initializes the configuration system. - *

- * Check if the config files and folder exists, if not, create them. - * It also checks if the old config files exists, if yes, delete them. - * Then read the config files. - *

- * Only reads Floating Materials config and Animation Blacklist if theses respective features are enabled. - */ - public static void init() { - try { - if (!Paths.get(FBP.mainConfigFile.getParent()).toFile().exists()) - if (Paths.get(FBP.mainConfigFile.getParent()).toFile().mkdirs()) - LOG.error("Could not create config directory"); - - if (!FBP.mainConfigFile.exists()) { - if (!FBP.mainConfigFile.createNewFile()) - LOG.error("Could not create main config file"); - - defaults(); - } - - if (!FBP.floatingMaterialsFile.exists()) { - if (!FBP.floatingMaterialsFile.createNewFile()) - LOG.error("Could not create floating materials file"); - - defaultsFloatingMaterials(); - } - - if (!FBP.particleBlacklistFile.exists()) - if (!FBP.particleBlacklistFile.createNewFile()) - LOG.error("Could not create particle blacklist file"); - - if (!FBP.animBlacklistFile.exists()) - if (!FBP.animBlacklistFile.createNewFile()) - LOG.error("Could not create anim blacklist file"); - - // Check for pre 0.8 configs and hopefully delete them - - if (FBP.oldMainConfigFile.exists()) - if (!FBP.oldMainConfigFile.delete()) - LOG.error("Could not delete old main config file"); - - if (FBP.oldFloatingMaterialsFile.exists()) - if (!FBP.oldFloatingMaterialsFile.delete()) - LOG.error("Could not delete old floating materials file"); - - if (FBP.oldParticleBlacklistFile.exists()) - if (!FBP.oldParticleBlacklistFile.delete()) - LOG.error("Could not delete old particle blacklist file"); - - if (FBP.oldAnimBlacklistFile.exists()) - if (!FBP.oldAnimBlacklistFile.delete()) - LOG.error("Could not delete old anim blacklist file"); - - if (FBP.oldNewMainConfigFile.exists()) - if (!FBP.oldNewMainConfigFile.delete()) - LOG.error("Could not delete old new main config file"); - - readMainConfig(); - if (FBP.waterPhysics) - readFloatingMaterials(); - - readParticleBlacklist(); - if (FBP.fancyPlaceAnim) - readAnimBlacklist(); - - } catch (IOException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - LOG.error("Cannot init configs, an IOException occurred: " + e.getMessage()); - } catch (SecurityException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - LOG.error("Cannot init configs, an antivirus is probably causing this"); - } finally { - closeStreams(); - } - } - - /** - * Initializes file streams for a specified file. - *

- * This is used to read the config files. - * - * @param file The file object to create streams for - */ - private static void initStreams(File file) { - try { - fileInputStream = new FileInputStream(file); - inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8); - bufferedReader = new BufferedReader(inputStreamReader); - - } catch (FileNotFoundException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - if (handleFileNotFound(e.getMessage(), "streams", file)) - initStreams(file); - - closeStreams(); - } catch (SecurityException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - LOG.error("Cannot init streams for " + file + " an antivirus is probably causing this"); - - closeStreams(); - } - } - - /** - * Closes file streams. - */ - private static void closeStreams() { - try { - bufferedReader.close(); - inputStreamReader.close(); - fileInputStream.close(); - - } catch (IOException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - LOG.error("Cannot close streams, an IOException occurred: " + e.getMessage()); - } - } - - /** - * Initializes writer for a specified file. - *

- * This is used to write to the config files. - * - * @param file The file object to create writer for - */ - private static void initWriter(File file) { - try { - writer = new PrintWriter(file.getPath(), "UTF-8"); - - } catch (FileNotFoundException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - if (handleFileNotFound(e.getMessage(), "writer", file)) - initWriter(file); - } catch (UnsupportedEncodingException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - LOG.error("Cannot init writer for " + file + " encoding is not supported, details: " + e.getMessage()); - } catch (SecurityException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - LOG.error("Cannot init streams for " + file + " an antivirus is probably causing this"); - } - } - - /** - * Handle a file not found exception. - *

- * It will output an error message to the console. - * And then attempt to create a new file, if it fails, it will output an error message to the console. - * - * @param message The error message associated with the exception - * @param source A string indicating the source of the error - * @param file The file object that could not be found - * @return True if the file was created successfully, false otherwise - */ - private static boolean handleFileNotFound(String message, String source, File file) { - LOG.error("Cannot init " + source + " for " + file + " as the file does not exist, details: " + message); - LOG.warn("Trying to create file " + file); - - try { - if (file.createNewFile()) { - LOG.info("Successfully created file " + file); - return true; - } - } catch (Exception ex) { - LOG.error("Could not create file " + file); - } - - return false; - } - - /** - * Reads the main config file and set the corresponding settings if not found sets default. - */ - private static void readMainConfig() { - try { - initStreams(FBP.mainConfigFile); - - Map configValues = new HashMap<>(); - - while ((line = bufferedReader.readLine()) != null) { - if (line.startsWith("#") || line.trim().isEmpty()) { - continue; - } - - String[] keyValue = line.split(": "); - if (keyValue.length == 2) { - configValues.put(keyValue[0], keyValue[1]); - } - } - - FBP.enabled = Boolean.parseBoolean(configValues.getOrDefault("enabled", "true")); - FBP.minAge = Integer.parseInt(configValues.getOrDefault("minAge", "10")); - FBP.maxAge = Integer.parseInt(configValues.getOrDefault("maxAge", "64")); - FBP.showInMillis = Boolean.parseBoolean(configValues.getOrDefault("showInMillis", "false")); - FBP.infiniteDuration = Boolean.parseBoolean(configValues.getOrDefault("infiniteDuration", "false")); - FBP.particlesPerAxis = Integer.parseInt(configValues.getOrDefault("particlesPerAxis", "4")); - FBP.scaleMult = Float.parseFloat(configValues.getOrDefault("scaleMult", "0.75")); - FBP.gravityMult = Float.parseFloat(configValues.getOrDefault("gravityMult", "1.0")); - FBP.rotationMult = Float.parseFloat(configValues.getOrDefault("rotationMult", "1.0")); - FBP.randomRotation = Boolean.parseBoolean(configValues.getOrDefault("randomRotation", "true")); - FBP.randomizedScale = Boolean.parseBoolean(configValues.getOrDefault("randomizedScale", "true")); - FBP.randomFadingSpeed = Boolean.parseBoolean(configValues.getOrDefault("randomFadingSpeed", "true")); - FBP.spawnWhileFrozen = Boolean.parseBoolean(configValues.getOrDefault("spawnWhileFrozen", "true")); - FBP.entityCollision = Boolean.parseBoolean(configValues.getOrDefault("entityCollision", "true")); - FBP.bounceOffWalls = Boolean.parseBoolean(configValues.getOrDefault("bounceOffWalls", "true")); - FBP.lowTraction = Boolean.parseBoolean(configValues.getOrDefault("lowTraction", "false")); - FBP.smartBreaking = Boolean.parseBoolean(configValues.getOrDefault("smartBreaking", "true")); - FBP.fancyFlame = Boolean.parseBoolean(configValues.getOrDefault("fancyFlame", "false")); - FBP.fancySmoke = Boolean.parseBoolean(configValues.getOrDefault("fancySmoke", "false")); - FBP.waterPhysics = Boolean.parseBoolean(configValues.getOrDefault("waterPhysics", "true")); - - FBP.fancyPlaceAnim = Boolean.parseBoolean(configValues.getOrDefault("fancyPlaceAnim", "true")); - FBP.spawnPlaceParticles = Boolean.parseBoolean(configValues.getOrDefault("spawnPlaceParticles", "true")); - - FBP.fancyWeather = Boolean.parseBoolean(configValues.getOrDefault("fancyWeather", "false")); - FBP.dynamicWeather = Boolean.parseBoolean(configValues.getOrDefault("dynamicWeather", "false")); - FBP.weatherParticleDensity = Float.parseFloat(configValues.getOrDefault("weatherParticleDensity", "1.0")); - FBP.weatherRenderDistance = Float.parseFloat(configValues.getOrDefault("weatherRenderDistance", "1.0")); - - FBP.experiments = Boolean.parseBoolean(configValues.getOrDefault("experiments", "false")); - - FBP.debug = Boolean.parseBoolean(configValues.getOrDefault("debugMode", "false")); - - } catch (IOException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - LOG.error("Cannot read main config, an IOException occurred: " + e.getMessage()); - } finally { - closeStreams(); - } - } - - /** - * Reads the floating materials config file and add the found material to the floating material list. - */ - private static void readFloatingMaterials() { - try { - initStreams(FBP.floatingMaterialsFile); - - FBP.floatingMaterials.clear(); - - while ((line = bufferedReader.readLine()) != null) { - line = line.trim(); - - if (line.startsWith("#") || line.isEmpty()) - continue; - - switch (line) { - case "Anvil": - addMaterial(Material.ANVIL); - break; - case "Barrier": - addMaterial(Material.BARRIER); - break; - case "Cactus": - addMaterial(Material.CACTUS); - break; - case "Cake": - addMaterial(Material.CAKE); - break; - case "Carpet": - addMaterial(Material.CARPET); - break; - case "Circuits": - addMaterial(Material.CIRCUITS); - break; - case "Clay": - addMaterial(Material.CLAY); - break; - case "Cloth": - addMaterial(Material.CLOTH); - break; - case "Coral": - addMaterial(Material.CORAL); - break; - case "Crafted Snow": - addMaterial(Material.CRAFTED_SNOW); - break; - case "Dragon Egg": - addMaterial(Material.DRAGON_EGG); - break; - case "Fire": - addMaterial(Material.FIRE); - break; - case "Glass": - addMaterial(Material.GLASS); - break; - case "Gourd": - addMaterial(Material.GOURD); - break; - case "Grass": - addMaterial(Material.GRASS); - break; - case "Ground": - addMaterial(Material.GROUND); - break; - case "Ice": - addMaterial(Material.ICE); - break; - case "Iron": - addMaterial(Material.IRON); - break; - case "Leaves": - addMaterial(Material.LEAVES); - break; - case "Packed Ice": - addMaterial(Material.PACKED_ICE); - break; - case "Piston": - addMaterial(Material.PISTON); - break; - case "Plants": - addMaterial(Material.PLANTS); - break; - case "Portal": - addMaterial(Material.PORTAL); - break; - case "Redstone Light": - addMaterial(Material.REDSTONE_LIGHT); - break; - case "Rock": - addMaterial(Material.ROCK); - break; - case "Sand": - addMaterial(Material.SAND); - break; - case "Snow": - addMaterial(Material.SNOW); - break; - case "Sponge": - addMaterial(Material.SPONGE); - break; - case "Structure Void": - addMaterial(Material.STRUCTURE_VOID); - break; - case "Tnt": - addMaterial(Material.TNT); - break; - case "Vine": - addMaterial(Material.VINE); - break; - case "Web": - addMaterial(Material.WEB); - break; - case "Wood": - addMaterial(Material.WOOD); - break; - default: - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - LOG.error("Material not recognized: " + line); - break; - } - } - - } catch (IOException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - LOG.error("Cannot read floating materials config, an IOException occurred: " + e.getMessage()); - } finally { - closeStreams(); - } - } - - /** - * Reads the animation blacklist config file and add the found blocks to the animation blacklist list. - */ - private static void readAnimBlacklist() { - try { - initStreams(FBP.animBlacklistFile); - - FBP.blockAnimBlacklist.clear(); - - while ((line = bufferedReader.readLine()) != null && !(line = line.replaceAll(" ", "")).equals("")) - addToBlacklist(line, false); - - } catch (IOException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - LOG.error("Cannot read animation blacklist, an IOException occurred: " + e.getMessage()); - } finally { - closeStreams(); - } - } - - - /** - * Reads the particle blacklist config file and add the found blocks to the particle blacklist list. - */ - private static void readParticleBlacklist() { - try { - initStreams(FBP.particleBlacklistFile); - - FBP.blockParticleBlacklist.clear(); - - while ((line = bufferedReader.readLine()) != null && !(line = line.replaceAll(" ", "")).equals("")) - addToBlacklist(line, true); - - } catch (IOException e) { - // Todo: (Debug Mode) This should count to the problem counter and should output a stack trace - LOG.error("Cannot read particle blacklist, an IOException occurred: " + e.getMessage()); - } finally { - closeStreams(); - } - } - - /** - * Writes the main config file. - */ - public static void writeMainConfig() { - initWriter(FBP.mainConfigFile); - - writer.println("# Main configuration file for Fancier Block Particles"); - writer.println("# I advise to use the in game configuration pages instead of manually editing this file"); - writer.println(); - writer.println("enabled: " + FBP.enabled); - writer.println(); - writer.println("# Particles Config:"); - writer.println(); - writer.println("minAge: " + FBP.minAge); - writer.println("maxAge: " + FBP.maxAge); - writer.println("showInMillis: " + FBP.showInMillis); - writer.println("infiniteDuration: " + FBP.infiniteDuration); - writer.println("particlesPerAxis: " + FBP.particlesPerAxis); - writer.println("scaleMult: " + FBP.scaleMult); - writer.println("gravityMult: " + FBP.gravityMult); - writer.println("rotationMult: " + FBP.rotationMult); - writer.println("randomRotation: " + FBP.randomRotation); - writer.println("randomizedScale: " + FBP.randomizedScale); - writer.println("randomFadingSpeed: " + FBP.randomFadingSpeed); - writer.println("spawnWhileFrozen: " + FBP.spawnWhileFrozen); - writer.println("entityCollision: " + FBP.entityCollision); - writer.println("bounceOffWalls: " + FBP.bounceOffWalls); - writer.println("lowTraction: " + FBP.lowTraction); - writer.println("smartBreaking: " + FBP.smartBreaking); - writer.println("fancyFlame: " + FBP.fancyFlame); - writer.println("fancySmoke: " + FBP.fancySmoke); - writer.println("waterPhysics: " + FBP.waterPhysics); - writer.println(); - writer.println("# Fancy Block Placement Config:"); - writer.println(); - writer.println("fancyPlaceAnim: " + FBP.fancyPlaceAnim); - writer.println("spawnPlaceParticles: " + FBP.spawnPlaceParticles); - writer.println(); - writer.println("# Weather Config:"); - writer.println(); - writer.println("fancyWeather: " + FBP.fancyWeather); - writer.println("dynamicWeather: " + FBP.dynamicWeather); - writer.println("weatherParticleDensity: " + FBP.weatherParticleDensity); - writer.println("weatherRenderDistance: " + FBP.weatherRenderDistance); - writer.println(); - writer.println("# Experiments:"); - writer.println(); - writer.println("experiments: " + FBP.experiments); - writer.println(); - writer.println("# Debug Config:"); - writer.println(); - writer.print("debugMode: " + FBP.debug); - - writer.close(); - } - - /** - * Writes the floating materials config file. - *

- * Uses hard-coded values for the material names which are the default. - */ - private static void writeFloatingMaterials() { - initWriter(FBP.floatingMaterialsFile); - - writer.println("# Configuration file for floatings materials."); - writer.println("# Anything added here will float, anything else will sink."); - writer.println("# List of all possible materials: https://shor.cz/1.12Materials"); - writer.println(); - writer.println("Carpet"); - writer.println("Cloth"); - writer.println("Ice"); - writer.println("Packed Ice"); - writer.println("Plants"); - writer.println("Web"); - writer.print("Wood"); - - writer.close(); - } - - /** - * Writes the animation blacklist config file. - */ - public static void writeAnimBlacklist() { - initWriter(FBP.animBlacklistFile); - - for (String block : FBP.blockAnimBlacklist) - writer.println(block); - - writer.close(); - } - - /** - * Writes the particle blacklist config file. - */ - public static void writeParticleBlacklist() { - initWriter(FBP.particleBlacklistFile); - - for (String block : FBP.blockParticleBlacklist) - writer.println(block); - - writer.close(); - } - - /** - * Set all the values in the main config file to the default. - */ - public static void defaults() { - FBP.enabled = true; - FBP.bounceOffWalls = true; - FBP.randomRotation = true; - FBP.entityCollision = true; - FBP.randomizedScale = true; - FBP.randomFadingSpeed = true; - FBP.spawnWhileFrozen = true; - FBP.smartBreaking = true; - FBP.fancyPlaceAnim = true; - FBP.spawnPlaceParticles = true; - FBP.waterPhysics = true; - - FBP.minAge = 10; - FBP.maxAge = 64; - FBP.particlesPerAxis = 4; - - FBP.scaleMult = 0.75F; - FBP.gravityMult = 1.0F; - FBP.rotationMult = 1.0F; - FBP.weatherParticleDensity = 1.0F; - FBP.weatherRenderDistance = 1.0F; - - writeMainConfig(); - } - - /** - * Set all the values in the floating materials config file to the default. - */ - public static void defaultsFloatingMaterials() { - FBP.floatingMaterials.clear(); - - writeFloatingMaterials(); - - readFloatingMaterials(); - } - - /** - * Adds a material to the floating materials list. - * - * @param material The material to add - */ - private static void addMaterial(Material material) { - if (!FBP.floatingMaterials.contains(material)) - FBP.floatingMaterials.add(material); - else - LOG.warn("Found duplicated material " + material + " in Floating Materials.txt"); - } - - /** - * Adds a block by name to either the particle or animation blacklist. - * - * @param name The name of the block to add - * @param particle Whether the block should be added to the particle or animation blacklist - */ - public static void addToBlacklist(String name, boolean particle) { - if (StringUtils.isEmpty(name)) - return; - - if (!(particle ? FBP.blockParticleBlacklist : FBP.blockAnimBlacklist).contains(name)) - (particle ? FBP.blockParticleBlacklist : FBP.blockAnimBlacklist).add(name); - } - - - /** - * Add or remove a block from either the particle or animation blacklist. - *

- * If the block is not blacklisted, it is added to either the particle or animation blacklist. - *

- * If the block is blacklisted, it is removed from either the particle or animation blacklist. - * - * @param block The block to blacklist - * @param particle Whether the block should be blacklisted from the particle or animation blacklist - */ - public static void blacklist(Block block, boolean particle) { - if (block == null) - return; - - name = block.getRegistryName().toString(); - - if (isBlacklisted(block, particle)) - (particle ? FBP.blockParticleBlacklist : FBP.blockAnimBlacklist).remove(name); - else - (particle ? FBP.blockParticleBlacklist : FBP.blockAnimBlacklist).add(name); - - if (particle) - writeParticleBlacklist(); - else - writeAnimBlacklist(); - } - - /** - * Checks if a block is blacklisted. - * - * @param block The block to check - * @param particle Whether to check if the block is blacklisted in the particle or animation blacklist - */ - public static boolean isBlacklisted(Block block, boolean particle) { - if (block == null) - return true; - - return (particle ? FBP.blockParticleBlacklist : FBP.blockAnimBlacklist).contains(block.getRegistryName().toString()); - } - - /** - * Reloads the floating materials list. - * If the list is empty, it is filled by calling readFloatingMaterials(). - * Otherwise, the list is cleared using the clear() method of the ArrayList class. - */ - public static void reloadMaterials() { - if (FBP.floatingMaterials.isEmpty()) - readFloatingMaterials(); - else - FBP.floatingMaterials.clear(); - } - - /** - * Reloads the animation blacklist. - * If the list is empty, it is filled by calling readAnimBlacklist(). - * Otherwise, the list is cleared using the clear() method of the ArrayList class. - */ - public static void reloadAnimBlacklist() { - if (FBP.blockAnimBlacklist.isEmpty()) - readAnimBlacklist(); - else - FBP.blockAnimBlacklist.clear(); - } -} diff --git a/src/main/java/io/redstudioragnarok/fbp/keys/KeyBindings.java b/src/main/java/io/redstudioragnarok/fbp/keys/KeyBindings.java deleted file mode 100644 index 7cef28b3..00000000 --- a/src/main/java/io/redstudioragnarok/fbp/keys/KeyBindings.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.redstudioragnarok.fbp.keys; - -import net.minecraft.client.resources.I18n; -import net.minecraft.client.settings.KeyBinding; -import org.lwjgl.input.Keyboard; - -import java.util.ArrayList; -import java.util.Arrays; - -import static io.redstudioragnarok.fbp.FBP.mc; - -/** - * A class that holds and initialize all the keybindings for the mod. - *

- * The reasons it does not use ClientRegistry.registerKeyBinding is that this is around 5 to 7 time faster. - * It does not matter, I just spend 30 minutes benchmarking and researching what is the fastest way to do this, so I will use it. - * - * @author Desoroxxx - */ -public class KeyBindings { - - public static final String categoryName = I18n.format("fbp.name"); - - public static final KeyBinding menu = new KeyBinding(I18n.format("keyBinding.menu"), Keyboard.KEY_P, categoryName); - public static final KeyBinding toggle = new KeyBinding(I18n.format("keyBinding.toggle"), Keyboard.KEY_NONE, categoryName); - public static final KeyBinding freeze = new KeyBinding(I18n.format("keyBinding.freeze"), Keyboard.KEY_NONE, categoryName); - public static final KeyBinding killParticles = new KeyBinding(I18n.format("keyBinding.kill"), Keyboard.KEY_NONE, categoryName); - public static final KeyBinding blacklistGUI = new KeyBinding(I18n.format("keyBinding.blacklistGUI"), Keyboard.KEY_B, categoryName); - - public static void init() { - final ArrayList keybindings = new ArrayList<>(Arrays.asList(menu, toggle, freeze, killParticles, blacklistGUI)); - final ArrayList allKeyBindings = new ArrayList<>(Arrays.asList(mc.gameSettings.keyBindings)); - - allKeyBindings.addAll(keybindings); - - mc.gameSettings.keyBindings = allKeyBindings.toArray(new KeyBinding[0]); - } -} diff --git a/src/main/java/io/redstudioragnarok/fbp/mixin/EntityRendererMixin.java b/src/main/java/io/redstudioragnarok/fbp/mixin/EntityRendererMixin.java deleted file mode 100644 index d9bda8c1..00000000 --- a/src/main/java/io/redstudioragnarok/fbp/mixin/EntityRendererMixin.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.redstudioragnarok.fbp.mixin; - -import io.redstudioragnarok.fbp.renderer.CubeBatchRenderer; -import net.minecraft.client.renderer.EntityRenderer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.At.Shift; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(EntityRenderer.class) -public class EntityRendererMixin { - - @Inject(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleManager;renderParticles(Lnet/minecraft/entity/Entity;F)V", shift = Shift.AFTER)) - private void afterParticlesRendered(int pass, float partialTicks, long finishTimeNano, CallbackInfo info) { - CubeBatchRenderer.endAllBatches(); - } -} diff --git a/src/main/java/io/redstudioragnarok/fbp/utils/MathUtil.java b/src/main/java/io/redstudioragnarok/fbp/utils/MathUtil.java deleted file mode 100644 index 0bc1d335..00000000 --- a/src/main/java/io/redstudioragnarok/fbp/utils/MathUtil.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.redstudioragnarok.fbp.utils; - -public class MathUtil { - - public static float lerp(float x, float y, float t) { - return x + (y - x) * t; - } - - public static double lerp(double x, double y, double t) { - return x + (y - x) * t; - } -} diff --git a/src/main/java/io/redstudioragnarok/fbp/utils/ModReference.java b/src/main/java/io/redstudioragnarok/fbp/utils/ModReference.java deleted file mode 100644 index c3713799..00000000 --- a/src/main/java/io/redstudioragnarok/fbp/utils/ModReference.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.redstudioragnarok.fbp.utils; - -import io.redstudioragnarok.fbp.Tags; -import io.redstudioragnarok.redcore.logging.RedLogger; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -/** - * This class defines constants for FBP. - *

- * They are automatically updated by Gradle on compile time, except for the name as Gradle would remove spaces. - */ -public class ModReference { - - public static final String ID = Tags.ID; - public static final String NAME = "Fancier Block Particles"; - public static final String VERSION = Tags.VERSION; - public static final Logger LOG = LogManager.getLogger(ID); - public static final RedLogger RED_LOG = new RedLogger(NAME, "https://linkify.cz/ValkyrieBugReport", LOG, "Hang in there, just a minor bump on the road to particle greatness!"); -} diff --git a/src/main/resources/assets/fbp/lang/en_us.lang b/src/main/resources/assets/fbp/lang/en_us.lang index 1b85be7f..fdf926ce 100644 --- a/src/main/resources/assets/fbp/lang/en_us.lang +++ b/src/main/resources/assets/fbp/lang/en_us.lang @@ -1,6 +1,3 @@ -# General -fbp.name=Fancier Block Particles - # HUD hud.freeze=§LFrozen Particles diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index ff6d8ddd..ea4d9c9b 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -4,11 +4,9 @@ "name": "Fancier Block Particles", "description": "Fancier Block Particles is a fork of the popular Fancy Block Particles by MorphoxL which is more optimized and less buggy than the original mod.", "version": "${version}", - "mcversion": "1.12.2", "url": "https://www.curseforge.com/minecraft/mc-mods/fbp", "authorList": ["Red Studio"], - "credits": "Desoroxxx, Rongmario, WildMihai, TominoCZ", - "logoFile": "assets/fbp/textures/gui/logo.png", - "screenshots": [] + "credits": "Desoroxxx, Meldexun, Rongmario, WildMihai, TominoCZ", + "logoFile": "assets/fbp/textures/gui/logo.png" } ] diff --git a/src/main/resources/mixins.fbp.json b/src/main/resources/mixins.fbp.json index 0e70a842..45f7aaf6 100644 --- a/src/main/resources/mixins.fbp.json +++ b/src/main/resources/mixins.fbp.json @@ -1,7 +1,7 @@ { "required": true, "minVersion": "0.8", - "package": "io.redstudioragnarok.fbp.mixin", + "package": "dev.redstudio.fbp.mixin", "compatibilityLevel": "JAVA_8", "refmap": "mixins.fbp.refmap.json", "client": [ diff --git a/update.json b/update.json deleted file mode 100644 index 9695d6c7..00000000 --- a/update.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "homepage": "https://www.curseforge.com/minecraft/mc-mods/fbp", - "promos": { - "1.12.2-latest": "0.8", - "1.12.2-recommended": "0.8" - }, - "1.12.2":{ - "0.8": "https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/blob/main/Changelog.md#fancier-block-particles-version-08-changelog", - "0.7": "https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/blob/main/Changelog.md#fancier-block-particles-version-07-changelog", - "0.6": "https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/blob/main/Changelog.md#fancier-block-particles-version-06-changelog", - "0.5": "https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/blob/main/Changelog.md#fancier-block-particles-version-05-changelog", - "0.4": "https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/blob/main/Changelog.md#fancier-block-particles-version-04-changelog", - "0.3": "https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/blob/main/Changelog.md#fancier-block-particles-version-03-changelog", - "0.2": "https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/blob/main/Changelog.md#fancier-block-particles-version-02-changelog", - "0.1": "https://github.com/Red-Studio-Ragnarok/Fancier-Block-Particles/blob/main/Changelog.md#fancier-block-particles-version-01-changelog" - } -}