This commit is contained in:
illyum 2024-07-20 00:10:13 -06:00
parent 3c6997fb6b
commit 2c0643c274
19 changed files with 1352 additions and 0 deletions

4
.gitattributes vendored Normal file
View File

@ -0,0 +1,4 @@
gradlew* linguist-vendored
gradle/wrapper/* linguist-vendored
*.bat text eol=crlf

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
.idea/
.vscode/
run/
build/
.gradle/

154
build.gradle.kts Normal file
View File

@ -0,0 +1,154 @@
import org.apache.commons.lang3.SystemUtils
plugins {
idea
java
id("gg.essential.loom") version "0.10.0.+"
id("dev.architectury.architectury-pack200") version "0.1.3"
id("com.github.johnrengelman.shadow") version "8.1.1"
kotlin("jvm") version "2.0.0"
}
//Constants:
val baseGroup: String by project
val mcVersion: String by project
val version: String by project
val mixinGroup = "$baseGroup.mixin"
val modid: String by project
// Toolchains:
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
}
// Minecraft configuration:
loom {
log4jConfigs.from(file("log4j2.xml"))
launchConfigs {
"client" {
// If you don't want mixins, remove these lines
property("mixin.debug", "true")
arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
}
}
runConfigs {
"client" {
if (SystemUtils.IS_OS_MAC_OSX) {
// This argument causes a crash on macOS
vmArgs.remove("-XstartOnFirstThread")
}
}
remove(getByName("server"))
}
forge {
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
// If you don't want mixins, remove this lines
mixinConfig("mixins.$modid.json")
}
// If you don't want mixins, remove these lines
mixin {
defaultRefmapName.set("mixins.$modid.refmap.json")
}
}
tasks.compileJava {
dependsOn(tasks.processResources)
}
sourceSets.main {
output.setResourcesDir(sourceSets.main.flatMap { it.java.classesDirectory })
java.srcDir(layout.projectDirectory.dir("src/main/kotlin"))
kotlin.destinationDirectory.set(java.destinationDirectory)
}
// Dependencies:
repositories {
mavenCentral()
maven("https://repo.spongepowered.org/maven/")
// If you don't want to log in with your real minecraft account, remove this line
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
}
val shadowImpl: Configuration by configurations.creating {
configurations.implementation.get().extendsFrom(this)
}
dependencies {
minecraft("com.mojang:minecraft:1.8.9")
mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9")
forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")
shadowImpl(kotlin("stdlib-jdk8"))
// If you don't want mixins, remove these lines
shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
isTransitive = false
}
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT")
// If you don't want to log in with your real minecraft account, remove this line
runtimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.2.1")
}
// Tasks:
tasks.withType(JavaCompile::class) {
options.encoding = "UTF-8"
}
tasks.withType(org.gradle.jvm.tasks.Jar::class) {
archiveBaseName.set(modid)
manifest.attributes.run {
this["FMLCorePluginContainsFMLMod"] = "true"
this["ForceLoadAsMod"] = "true"
// If you don't want mixins, remove these lines
this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
this["MixinConfigs"] = "mixins.$modid.json"
}
}
tasks.processResources {
inputs.property("version", project.version)
inputs.property("mcversion", mcVersion)
inputs.property("modid", modid)
inputs.property("basePackage", baseGroup)
filesMatching(listOf("mcmod.info", "mixins.$modid.json")) {
expand(inputs.properties)
}
rename("(.+_at.cfg)", "META-INF/$1")
}
val remapJar by tasks.named<net.fabricmc.loom.task.RemapJarTask>("remapJar") {
archiveClassifier.set("")
from(tasks.shadowJar)
input.set(tasks.shadowJar.get().archiveFile)
}
tasks.jar {
archiveClassifier.set("without-deps")
destinationDirectory.set(layout.buildDirectory.dir("intermediates"))
}
tasks.shadowJar {
destinationDirectory.set(layout.buildDirectory.dir("intermediates"))
archiveClassifier.set("non-obfuscated-with-deps")
configurations = listOf(shadowImpl)
doLast {
configurations.forEach {
println("Copying dependencies into mod: ${it.files}")
}
}
// If you want to include other dependencies and shadow them, you can relocate them in here
fun relocate(name: String) = relocate(name, "$baseGroup.deps.$name")
}
tasks.assemble.get().dependsOn(tasks.remapJar)

6
gradle.properties Normal file
View File

@ -0,0 +1,6 @@
loom.platform=forge
org.gradle.jvmargs=-Xmx2g
baseGroup = com.github.itzilly.sbt
mcVersion = 1.8.9
modid = sbt
version = 1.0.0

View File

@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

249
gradlew vendored Normal file
View File

@ -0,0 +1,249 @@
#!/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/HEAD/platforms/jvm/plugins-application/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
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# 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
if ! command -v java >/dev/null 2>&1
then
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
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
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
# 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"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
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" "$@"

92
gradlew.bat vendored Normal file
View File

@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

5
log4j2.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<!-- Filter out Hypixel scoreboard and sound errors -->
<RegexFilter regex="Error executing task.*|Unable to play unknown soundEvent.*" onMatch="DENY" onMismatch="NEUTRAL"/>
</Configuration>

116
options.txt Normal file
View File

@ -0,0 +1,116 @@
invertYMouse:false
mouseSensitivity:0.30985916
fov:0.25
gamma:0.91549295
saturation:0.0
renderDistance:20
guiScale:2
particles:0
bobView:false
anaglyph3d:false
maxFps:260
fboEnable:true
difficulty:3
fancyGraphics:true
ao:2
renderClouds:false
resourcePacks:["! §b Yeah.zip","dillyumfs_8bridge_doverlay_8vd1.zip","No Explosion Particles.zip"]
incompatibleResourcePacks:[]
lastServer:0
lang:en_US
chatVisibility:0
chatColors:true
chatLinks:true
chatLinksPrompt:true
chatOpacity:1.0
snooperEnabled:true
fullscreen:true
enableVsync:false
useVbo:true
hideServerAddress:false
advancedItemTooltips:true
pauseOnLostFocus:true
touchscreen:false
overrideWidth:0
overrideHeight:0
heldItemTooltips:true
chatHeightFocused:1.0
chatHeightUnfocused:0.44366196
chatScale:1.0
chatWidth:1.0
showInventoryAchievementHint:false
mipmapLevels:0
streamBytesPerPixel:0.5
streamMicVolume:1.0
streamSystemVolume:1.0
streamKbps:0.5412844
streamFps:0.31690142
streamCompression:1
streamSendMetadata:true
streamPreferredServer:
streamChatEnabled:0
streamChatUserFilter:0
streamMicToggleBehavior:0
forceUnicodeFont:false
allowBlockAlternatives:true
reducedDebugInfo:false
useNativeTransport:true
entityShadows:false
realmsNotifications:true
key_key.attack:-100
key_key.use:-99
key_key.forward:17
key_key.left:30
key_key.back:31
key_key.right:32
key_key.jump:57
key_key.sneak:42
key_key.sprint:184
key_key.drop:16
key_key.inventory:18
key_key.chat:46
key_key.playerlist:15
key_key.pickItem:-98
key_key.command:53
key_key.screenshot:60
key_key.togglePerspective:34
key_key.smoothCamera:48
key_key.streamStartStop:64
key_key.streamPauseUnpause:65
key_key.streamCommercial:0
key_key.streamToggleMic:0
key_key.fullscreen:87
key_key.spectatorOutlines:0
key_key.hotbar.1:2
key_key.hotbar.2:20
key_key.hotbar.3:47
key_key.hotbar.4:5
key_key.hotbar.5:6
key_key.hotbar.6:44
key_key.hotbar.7:-96
key_key.hotbar.8:-97
key_key.hotbar.9:4
key_of.key.zoom:41
key_Create Waypoint:49
key_Toggle Display of Waypoints:0
key_Freelook:33
key_Snaplook:56
key_Mod Menu:54
key_Waypoint Menu:0
key_Emote Wheel:52
soundCategory_master:0.51324505
soundCategory_music:0.0
soundCategory_record:1.0
soundCategory_weather:1.0
soundCategory_block:1.0
soundCategory_hostile:1.0
soundCategory_neutral:1.0
soundCategory_player:1.0
soundCategory_ambient:1.0
modelPart_cape:true
modelPart_jacket:true
modelPart_left_sleeve:true
modelPart_right_sleeve:true
modelPart_left_pants_leg:true
modelPart_right_pants_leg:true
modelPart_hat:true

26
settings.gradle.kts Normal file
View File

@ -0,0 +1,26 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://maven.architectury.dev/")
maven("https://maven.fabricmc.net")
maven("https://maven.minecraftforge.net/")
maven("https://repo.spongepowered.org/maven/")
maven("https://repo.sk1er.club/repository/maven-releases/")
}
resolutionStrategy {
eachPlugin {
when (requested.id.id) {
"gg.essential.loom" -> useModule("gg.essential:architectury-loom:${requested.version}")
}
}
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.6.0")
}
rootProject.name = "sbt"

View File

@ -0,0 +1,188 @@
package com.github.itzilly.sbt.init;
import org.spongepowered.asm.lib.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/**
* A mixin plugin to automatically discover all mixins in the current JAR.
* <p>
* This mixin plugin automatically scans your entire JAR (or class directory, in case of an in-IDE launch) for classes inside of your
* mixin package and registers those. It does this recursively for sub packages of the mixin package as well. This means you will need
* to only have mixin classes inside of your mixin package, which is good style anyway.
*
* @author Linnea Gräf
*/
public class AutoDiscoveryMixinPlugin implements IMixinConfigPlugin {
private static final List<AutoDiscoveryMixinPlugin> mixinPlugins = new ArrayList<>();
public static List<AutoDiscoveryMixinPlugin> getMixinPlugins() {
return mixinPlugins;
}
private String mixinPackage;
@Override
public void onLoad(String mixinPackage) {
this.mixinPackage = mixinPackage;
mixinPlugins.add(this);
}
/**
* Resolves the base class root for a given class URL. This resolves either the JAR root, or the class file root.
* In either case the return value of this + the class name will resolve back to the original class url, or to other
* class urls for other classes.
*/
public URL getBaseUrlForClassUrl(URL classUrl) {
String string = classUrl.toString();
if (classUrl.getProtocol().equals("jar")) {
try {
return new URL(string.substring(4).split("!")[0]);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
if (string.endsWith(".class")) {
try {
return new URL(string.replace("\\", "/")
.replace(getClass().getCanonicalName()
.replace(".", "/") + ".class", ""));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
return classUrl;
}
/**
* Get the package that contains all the mixins. This value is set by mixin itself using {@link #onLoad}.
*/
public String getMixinPackage() {
return mixinPackage;
}
/**
* Get the path inside the class root to the mixin package
*/
public String getMixinBaseDir() {
return mixinPackage.replace(".", "/");
}
/**
* A list of all discovered mixins.
*/
private List<String> mixins = null;
/**
* Try to add mixin class ot the mixins based on the filepath inside of the class root.
* Removes the {@code .class} file suffix, as well as the base mixin package.
* <p><b>This method cannot be called after mixin initialization.</p>
*
* @param className the name or path of a class to be registered as a mixin.
*/
public void tryAddMixinClass(String className) {
String norm = (className.endsWith(".class") ? className.substring(0, className.length() - ".class".length()) : className)
.replace("\\", "/")
.replace("/", ".");
if (norm.startsWith(getMixinPackage() + ".") && !norm.endsWith(".")) {
mixins.add(norm.substring(getMixinPackage().length() + 1));
}
}
/**
* Search through the JAR or class directory to find mixins contained in {@link #getMixinPackage()}
*/
@Override
public List<String> getMixins() {
if (mixins != null) return mixins;
System.out.println("Trying to discover mixins");
mixins = new ArrayList<>();
URL classUrl = getClass().getProtectionDomain().getCodeSource().getLocation();
System.out.println("Found classes at " + classUrl);
Path file;
try {
file = Paths.get(getBaseUrlForClassUrl(classUrl).toURI());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
System.out.println("Base directory found at " + file);
if (Files.isDirectory(file)) {
walkDir(file);
} else {
walkJar(file);
}
System.out.println("Found mixins: " + mixins);
return mixins;
}
/**
* Search through directory for mixin classes based on {@link #getMixinBaseDir}.
*
* @param classRoot The root directory in which classes are stored for the default package.
*/
private void walkDir(Path classRoot) {
System.out.println("Trying to find mixins from directory");
try (Stream<Path> classes = Files.walk(classRoot.resolve(getMixinBaseDir()))) {
classes.map(it -> classRoot.relativize(it).toString())
.forEach(this::tryAddMixinClass);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* Read through a JAR file, trying to find all mixins inside.
*/
private void walkJar(Path file) {
System.out.println("Trying to find mixins from jar file");
try (ZipInputStream zis = new ZipInputStream(Files.newInputStream(file))) {
ZipEntry next;
while ((next = zis.getNextEntry()) != null) {
tryAddMixinClass(next.getName());
zis.closeEntry();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@Override
public String getRefMapperConfig() {
return null;
}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return true;
}
@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
}
}

View File

@ -0,0 +1,24 @@
package com.github.itzilly.sbt
import net.minecraft.client.renderer.GlStateManager
import java.util.*
class HudText(var textLines: Array<String>, var x: Int, var y: Int, var shadow: Boolean) : RenderHudAble {
var scale = 1f
val id = UUID.randomUUID()
override fun render(partialTicks: Float) {
GlStateManager.pushMatrix()
GlStateManager.translate(x.toFloat(), y.toFloat(), 0f)
GlStateManager.scale(scale, scale, scale)
var yOff = 0
for (line in textLines) {
if (shadow) {
SkyBlockTweaks.INSTANCE.fontRenderer.drawStringWithShadow(line, 0f, yOff.toFloat(), 0)
} else {
SkyBlockTweaks.INSTANCE.fontRenderer.drawString(line, 0, yOff, 0)
}
yOff += 10
}
GlStateManager.popMatrix()
}
}

View File

@ -0,0 +1,112 @@
package com.github.itzilly.sbt
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.WorldRenderer
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
import net.minecraft.util.AxisAlignedBB
import java.awt.Color
class RenderUtils {
var TESSELLATOR: Tessellator = Tessellator.getInstance()
var WORLD_RENDERER: WorldRenderer = Tessellator.getInstance().worldRenderer
fun drawBlock(box: AxisAlignedBB, outlineStartColor: Int, outlineEndColor: Int) {
drawBlockTop(box, Color(outlineStartColor), Color(outlineEndColor));
drawBlockBottom(box, Color(outlineStartColor), Color(outlineEndColor));
drawBlockNorth(box, Color(outlineStartColor), Color(outlineEndColor));
drawBlockEast(box, Color(outlineStartColor), Color(outlineEndColor));
drawBlockSouth(box, Color(outlineStartColor), Color(outlineEndColor));
drawBlockWest(box, Color(outlineStartColor), Color(outlineEndColor));
}
private fun drawBlockTop(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) {
WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR)
WORLD_RENDERER.pos(box.minX, box.maxY, box.minZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.maxX, box.maxY, box.minZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
WORLD_RENDERER.pos(box.maxX, box.maxY, box.maxZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.minX, box.maxY, box.maxZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
TESSELLATOR.draw()
}
private fun drawBlockBottom(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) {
WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR)
WORLD_RENDERER.pos(box.maxX, box.minY, box.minZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.minX, box.minY, box.minZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
WORLD_RENDERER.pos(box.minX, box.minY, box.maxZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.maxX, box.minY, box.maxZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
TESSELLATOR.draw()
}
private fun drawBlockNorth(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) {
WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR)
WORLD_RENDERER.pos(box.maxX, box.maxY, box.maxZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.maxX, box.minY, box.maxZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
WORLD_RENDERER.pos(box.minX, box.minY, box.maxZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.minX, box.maxY, box.maxZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
TESSELLATOR.draw()
}
private fun drawBlockEast(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) {
WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR)
WORLD_RENDERER.pos(box.maxX, box.maxY, box.maxZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.maxX, box.maxY, box.minZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
WORLD_RENDERER.pos(box.maxX, box.minY, box.minZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.maxX, box.minY, box.maxZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
TESSELLATOR.draw()
}
private fun drawBlockSouth(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) {
WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR)
WORLD_RENDERER.pos(box.minX, box.maxY, box.minZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.minX, box.minY, box.minZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
WORLD_RENDERER.pos(box.maxX, box.minY, box.minZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.maxX, box.maxY, box.minZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
TESSELLATOR.draw()
}
private fun drawBlockWest(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) {
WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR)
WORLD_RENDERER.pos(box.minX, box.maxY, box.minZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.minX, box.maxY, box.maxZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
WORLD_RENDERER.pos(box.minX, box.minY, box.maxZ)
.color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha)
.endVertex()
WORLD_RENDERER.pos(box.minX, box.minY, box.minZ)
.color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex()
TESSELLATOR.draw()
}
}

View File

@ -0,0 +1,314 @@
package com.github.itzilly.sbt
import com.google.gson.Gson
import net.minecraft.block.Block
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.*
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.WorldRenderer
import net.minecraft.client.renderer.entity.RenderManager
import net.minecraft.client.settings.KeyBinding
import net.minecraft.command.CommandException
import net.minecraft.command.ICommandSender
import net.minecraft.entity.Entity
import net.minecraft.util.AxisAlignedBB
import net.minecraft.util.BlockPos
import net.minecraft.util.ChatComponentText
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.client.registry.ClientRegistry
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.InputEvent
import org.lwjgl.input.Keyboard
import org.lwjgl.opengl.GL11
import java.awt.Color
import java.awt.Toolkit
import java.awt.datatransfer.Clipboard
import java.awt.datatransfer.StringSelection
@Mod(modid = "sbt", useMetadata = true)
class SkyBlockTweaks {
init {
INSTANCE = this
}
companion object {
lateinit var INSTANCE: SkyBlockTweaks
var routeList: ArrayList<RouteMarker> = ArrayList()
}
lateinit var tessellator: Tessellator
lateinit var worldRenderer: WorldRenderer
lateinit var renderManager: RenderManager
lateinit var fontRenderer: FontRenderer
private var renderWorldList: ArrayList<RenderHudAble> = ArrayList()
@Mod.EventHandler
fun init(event: FMLInitializationEvent) {
try {
val resource: net.minecraft.client.resources.IResource = Minecraft.getMinecraft().resourceManager
.getResource(net.minecraft.util.ResourceLocation("test:test.txt"))
org.apache.commons.io.IOUtils.copy(resource.inputStream, java.lang.System.out)
} catch (e: java.io.IOException) {
throw java.lang.RuntimeException(e)
}
STBKeyBinds.init()
tessellator = Tessellator.getInstance()
worldRenderer = tessellator.worldRenderer
renderManager = Minecraft.getMinecraft().renderManager
fontRenderer = Minecraft.getMinecraft().fontRendererObj
MinecraftForge.EVENT_BUS.register(this)
MinecraftForge.EVENT_BUS.register(KeyInputHandler())
MinecraftForge.EVENT_BUS.register(RouteMarkerRender())
}
// @SubscribeEvent
// fun worldLoadEvent(event: WorldEvent.Load) {
// val msg = "Hello illy!"
// renderWorldList.add(
// HudText(
// arrayOf(msg),
// (Display.getWidth() / 2),
// Display.getHeight() / 2 / 2,
// false
// )
// )
// }
@SubscribeEvent
fun renderOverlayEvent(event: RenderGameOverlayEvent.Text) {
if (renderWorldList.size == 0) {
return
}
for (render: RenderHudAble in renderWorldList) {
render.render(event.partialTicks)
}
}
}
interface RenderHudAble {
fun render(partialTicks: Float)
}
interface RenderWorldAble {
fun render(partialTicks: Float)
}
object STBKeyBinds {
lateinit var addWaypoint: KeyBinding
lateinit var finishWaypoints: KeyBinding
lateinit var clearWaypoints: KeyBinding
lateinit var openRoutesGui: KeyBinding
fun init() {
addWaypoint = KeyBinding("key.addWaypoint", Keyboard.KEY_ADD, "key.categories.sbt")
ClientRegistry.registerKeyBinding(addWaypoint)
finishWaypoints = KeyBinding("key.finishWaypoints", Keyboard.KEY_P, "key.categories.sbt")
ClientRegistry.registerKeyBinding(finishWaypoints)
clearWaypoints = KeyBinding("key.clearWaypoints", Keyboard.KEY_MINUS, "key.categories.sbt")
ClientRegistry.registerKeyBinding(clearWaypoints)
openRoutesGui = KeyBinding("key.openRoutesGui", Keyboard.KEY_O, "key.categories.sbt")
ClientRegistry.registerKeyBinding(openRoutesGui)
}
}
class KeyInputHandler {
private val mc = Minecraft.getMinecraft()
@SubscribeEvent
fun onKeyInput(event: InputEvent.KeyInputEvent?) {
if (STBKeyBinds.addWaypoint.isPressed) {
val x = mc.thePlayer.posX.toInt()
val y = mc.thePlayer.posY.toInt()
val z = mc.thePlayer.posZ.toInt() - 1 // Offset from player (no clue why I need this)
if (!isPointInRouteList(SkyBlockTweaks.routeList, x, y, z)) {
val name = SkyBlockTweaks.routeList.size + 1
val point = RouteMarker(x, y, z, 0u, 1u, 0u, RouteOptions(name.toString()))
SkyBlockTweaks.routeList.add(point)
mc.thePlayer.addChatMessage(ChatComponentText("Adding Point ($x, $y, $z) to route list"))
} else {
mc.thePlayer.addChatMessage(ChatComponentText("Point ($x, $y, $z) is already in the route list"))
}
}
else if (STBKeyBinds.finishWaypoints.isPressed) {
mc.thePlayer.addChatMessage(ChatComponentText("Finished route! Copied route to clipboard"))
val jsonString = Gson().toJson(SkyBlockTweaks.routeList)
setClipboard(jsonString)
SkyBlockTweaks.routeList.clear()
}
else if (STBKeyBinds.clearWaypoints.isPressed) {
SkyBlockTweaks.routeList.clear()
mc.thePlayer.addChatMessage(ChatComponentText("Reset current route"))
}
else if (STBKeyBinds.openRoutesGui.isPressed) {
mc.displayGuiScreen(RouteGui())
}
}
}
data class RouteMarker(
val x: Int,
val y: Int,
val z: Int,
val r: UByte,
val g: UByte,
val b: UByte,
val options: RouteOptions
)
fun isPointInRouteList(routeList: List<RouteMarker>, x: Int, y: Int, z: Int): Boolean {
return routeList.any { it.x == x && it.y == y && it.z == z }
}
data class RouteOptions(
val name: String
)
fun setClipboard(s: String) {
val selection = StringSelection(s)
val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard
clipboard.setContents(selection, selection)
}
class RouteMarkerRender {
@SubscribeEvent
fun renderBlockOverlay(event: RenderWorldLastEvent) {
val player = Minecraft.getMinecraft().thePlayer
for (marker: RouteMarker in SkyBlockTweaks.routeList) {
val pos = BlockPos(marker.x, marker.y, marker.z)
renderPoint(player, pos, event.partialTicks)
}
}
}
fun renderPoint(entity: Entity, blockPos: BlockPos, partialTicks: Float) {
val padding: Double = 0.0020000000949949026
val entityX: Double = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks
val entityY: Double = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks
val entityZ: Double = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks
val outlineStartColor = 0xFFFFFF
val outlineEndColor = 0xFFFFFF
val world = Minecraft.getMinecraft().theWorld
val blockState = world.getBlockState(blockPos)
val block: Block = blockState.block
// Create a default bounding box for blocks that don't have one
val boundingBox: AxisAlignedBB = block.getCollisionBoundingBox(world, blockPos, blockState)
?: AxisAlignedBB(blockPos.x.toDouble(), blockPos.y.toDouble(), blockPos.z.toDouble(),
blockPos.x + 1.0, blockPos.y + 1.0, blockPos.z + 1.0).expand(padding, padding, padding)
GL11.glPushMatrix()
GlStateManager.disableTexture2D()
GlStateManager.depthMask(false)
GlStateManager.disableDepth()
GL11.glEnable(GL11.GL_LINE_SMOOTH)
GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST)
GL11.glLineWidth(2.0f)
GL11.glShadeModel(GL11.GL_SMOOTH)
RenderUtils().drawBlock(boundingBox.offset(-entityX, -entityY, -entityZ), outlineStartColor, outlineEndColor)
GL11.glLineWidth(2.0f)
GL11.glDisable(GL11.GL_LINE_SMOOTH)
GlStateManager.enableDepth()
GlStateManager.depthMask(true)
GlStateManager.enableAlpha()
GlStateManager.enableTexture2D()
GL11.glPopMatrix()
}
class RouteMarkerButton(buttonId: Int, x: Int, y: Int, widthIn: Int, heightIn: Int, buttonText: String?) :
GuiButton(buttonId, x, y, widthIn, heightIn, buttonText) {
constructor(buttonId: Int, x: Int, y: Int, buttonText: String?) : this(buttonId, x, y, 200, 20, buttonText)
override fun drawButton(mc: Minecraft, mouseX: Int, mouseY: Int) {
if (visible) {
val fontrenderer = mc.fontRendererObj
//mc.getTextureManager().bindTexture(buttonTextures);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f)
hovered =
mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height
//int i = this.getHoverState(this.hovered);
drawRect(
xPosition, yPosition, xPosition + width, yPosition + height,
if (hovered) Color(255, 255, 255, 80).rgb else Color(0, 0, 0, 80).rgb
)
//this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height);
//this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
mouseDragged(mc, mouseX, mouseY)
var j = 14737632
if (packedFGColour != 0) {
j = packedFGColour
} else if (!enabled) {
j = 10526880
} else if (hovered) {
j = 16777120
}
drawCenteredString(
fontrenderer,
displayString, xPosition + width / 2, yPosition + (height - 8) / 2, j
)
}
}
}
class RouteGui : GuiScreen() {
private val id: Int = 0
override fun initGui() {
super.initGui()
buttonList.clear()
populateRouteList()
buttonList.add(RouteMarkerButton(9000, width/2 + 20, height - 40, "Exit"))
}
override fun actionPerformed(button: GuiButton?) {
if (button == null) { return }
if (button.id < 1000) { buttonList.remove(button) }
else if (button.id == 9000) { Minecraft.getMinecraft().thePlayer.closeScreen() }
}
override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {
this.drawDefaultBackground()
super.drawScreen(mouseX, mouseY, partialTicks)
}
private fun populateRouteList() {
for ((buttonId, m: RouteMarker) in SkyBlockTweaks.routeList.withIndex()) {
val markerField = GuiTextField(1000 + buttonId, fontRendererObj, width/2 - 200, 0, 100, 20)
markerField.text = "${m.options.name} X:${m.x} Y:${m.y} Z:${m.z}"
val removeButton = RouteMarkerButton(2000 + buttonId, width/2 + 175, 0, 50, 20, "Remove")
buttonList.add(removeButton)
}
}
}

View File

@ -0,0 +1,16 @@
package com.github.itzilly.sbt.mixin;
import net.minecraft.client.gui.GuiMainMenu;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GuiMainMenu.class)
public class MixinGuiMainMenu {
@Inject(method = "initGui", at = @At("HEAD"))
public void onInitGui(CallbackInfo ci) {
// System.out.println("Hello from Main Menu!");
}
}

View File

@ -0,0 +1,4 @@
key.categories.sbt=SkyBlock Tweaks
key.addWaypoint=Add Route Point
key.finishWaypoints=Finish Route
key.clearWaypoints=Clear Route Points

View File

@ -0,0 +1,3 @@
test
from resource pack

View File

@ -0,0 +1,18 @@
[
{
"modid": "${modid}",
"name": "Xample Mod",
"description": "A mod that is used as an example.",
"version": "${version}",
"mcversion": "${mcversion}",
"url": "https://github.com/romangraef/Forge1.8.9Template/",
"updateUrl": "",
"authorList": [
"You"
],
"credits": "",
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]

View File

@ -0,0 +1,8 @@
{
"package": "${basePackage}.mixin",
"plugin": "${basePackage}.init.AutoDiscoveryMixinPlugin",
"refmap": "mixins.${modid}.refmap.json",
"minVersion": "0.7",
"compatibilityLevel": "JAVA_8",
"__comment": "You do not need to manually register mixins in this template. Check the auto discovery mixin plugin for more info."
}