This commit is contained in:
eaglercraft 2024-03-02 22:18:18 -08:00
parent 401ebe2324
commit 573420e1b8
613 changed files with 5708 additions and 4445 deletions

View File

@ -1,3 +1,3 @@
#!/bin/sh
chmod +x gradlew
#!/bin/sh
chmod +x gradlew
./gradlew generateJavascript

View File

@ -26,7 +26,7 @@ teavm.js {
obfuscated = true
sourceMap = true
targetFileName = "../classes.js"
// optimization = OptimizationLevel.ADVANCED
optimization = org.teavm.gradle.api.OptimizationLevel.AGGRESSIVE
outOfProcess = false
fastGlobalAnalysis = false
processMemory = 512

View File

@ -17,5 +17,6 @@
<classpathentry kind="lib" path="deps_fix/lwjgl-openal.jar"/>
<classpathentry kind="lib" path="deps_fix/lwjgl-opengles.jar"/>
<classpathentry kind="lib" path="deps_fix/soundsystem-20120107.jar"/>
<classpathentry kind="lib" path="deps_fix/webrtc-java-0.8.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Binary file not shown.

BIN
desktopRuntime/libwebrtc-java.so Executable file

Binary file not shown.

View File

@ -8,8 +8,8 @@
<title>EaglercraftX 1.8</title>
<meta property="og:locale" content="en-US" />
<meta property="og:type" content="website" />
<meta property="og:title" content="EaglercraftX 1.8 Offline" />
<meta property="og:description" content="this file is not a website, whoever uploaded it to this URL is a dumbass" />
<meta property="og:title" content="EaglercraftX 1.8" />
<meta property="og:description" content="Play minecraft 1.8 in your browser" />
<script type="text/javascript">
"use strict";
const relayId = Math.floor(Math.random() * 3);
@ -31,10 +31,15 @@ window.eaglercraftXOptsHints = {
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
</script>
<style type="eaglercraft" id="eaglercraftXClientSignature">data:application/octet-stream;base64,${client_signature}</style>
<style type="eaglercraft" id="eaglercraftXClientBundle">data:application/octet-stream;base64,${client_bundle}</style>
<script type="text/javascript">
"use strict";
window.eaglercraftXClientSignature = "data:application/octet-stream;base64,${client_signature}";
window.eaglercraftXClientBundle = "data:application/octet-stream;base64,${client_bundle}";
(function(){
function eaglerBundleUnwrap(tagIn) { const e = document.getElementById(tagIn); const ret = e.innerText; e.remove(); return ret; }
window.eaglercraftXClientSignature = eaglerBundleUnwrap("eaglercraftXClientSignature");
window.eaglercraftXClientBundle = eaglerBundleUnwrap("eaglercraftXClientBundle");
})();
</script>
<script type="text/javascript">
"use strict";

View File

@ -539,6 +539,28 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Project Name: webrtc-java
Project Author: Alex Andres
Project URL: https://github.com/devopvoid/webrtc-java
Used For: WebRTC LAN worlds in desktop runtime
* Copyright 2019 Alex Andres
*
* 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
*
* http://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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Project Name: Netty
Project Author: Netty Project
Project URL: https://netty.io/

View File

@ -1,116 +1,116 @@
#line 2
/*
* Copyright (c) 2023 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
in vec3 a_position3f;
#ifdef COMPILE_TEXTURE_ATTRIB
in vec2 a_texture2f;
out vec2 v_texture2f;
uniform mat4 u_textureMat4f01;
#endif
#ifdef COMPILE_COLOR_ATTRIB
in vec4 a_color4f;
out vec4 v_color4f;
#endif
#ifdef COMPILE_NORMAL_ATTRIB
in vec4 a_normal4f;
out vec3 v_normal3f;
out float v_block1f;
#endif
#ifdef COMPILE_STATE_WAVING_BLOCKS
uniform mat4 u_modelMatrix4f;
uniform mat4 u_viewMatrix4f;
uniform vec3 u_wavingBlockOffset3f;
uniform vec4 u_wavingBlockParam4f;
#ifndef COMPILE_NORMAL_ATTRIB
uniform float u_blockConstant1f;
#endif
#define DO_COMPILE_STATE_WAVING_BLOCKS
#define FAKE_SIN(valueIn, valueOut)\
valueOut = abs(1.0 - fract(valueIn * 0.159155) * 2.0);\
valueOut = valueOut * valueOut * (3.0 - 2.0 * valueOut) * 2.0 - 1.0;
#define LIB_INCLUDE_WAVING_BLOCKS_FUNCTION
#endif
#EAGLER INCLUDE (2) "eagler:glsl/deferred/lib/waving_blocks.glsl"
#ifdef COMPILE_NORMAL_MATERIAL_TEXTURE
out vec3 v_viewdir3f;
#endif
#ifdef COMPILE_LIGHTMAP_ATTRIB
in vec2 a_lightmap2f;
out vec2 v_lightmap2f;
uniform mat4 u_textureMat4f02;
#endif
uniform mat4 u_modelviewMat4f;
uniform mat4 u_projectionMat4f;
#define TEX_MAT3(mat4In) mat3(mat4In[0].xyw,mat4In[1].xyw,mat4In[3].xyw)
void main() {
#ifdef COMPILE_TEXTURE_ATTRIB
vec3 v_textureTmp3f = TEX_MAT3(u_textureMat4f01) * vec3(a_texture2f, 1.0);
v_texture2f = v_textureTmp3f.xy / v_textureTmp3f.z;
#endif
#ifdef COMPILE_COLOR_ATTRIB
v_color4f = a_color4f;
#endif
#ifdef COMPILE_NORMAL_ATTRIB
v_normal3f = normalize(mat3(u_modelviewMat4f) * a_normal4f.xyz);
float blockId = v_block1f = floor((a_normal4f.w + 1.0) * 127.0 + 0.5);
#endif
#ifdef COMPILE_LIGHTMAP_ATTRIB
vec3 v_lightmapTmp3f = TEX_MAT3(u_textureMat4f02) * vec3(a_lightmap2f, 1.0);
v_lightmap2f = v_lightmapTmp3f.xy / v_lightmapTmp3f.z;
#endif
vec4 pos = vec4(a_position3f, 1.0);
#ifdef DO_COMPILE_STATE_WAVING_BLOCKS
#ifndef COMPILE_NORMAL_ATTRIB
float blockId = u_blockConstant1f;
#endif
#ifdef COMPILE_LIGHTMAP_ATTRIB
if(v_lightmap2f.y > 0.33) {
COMPUTE_WAVING_BLOCKS(pos, min(v_lightmap2f.y * 3.0 - 1.0, 1.0), 24.0, blockId, u_modelMatrix4f, u_viewMatrix4f, u_modelviewMat4f, u_wavingBlockOffset3f, u_wavingBlockParam4f)
}else {
pos = u_modelviewMat4f * pos;
}
#else
COMPUTE_WAVING_BLOCKS(pos, 1.0, 32.0, blockId, u_modelMatrix4f, u_viewMatrix4f, u_modelviewMat4f, u_wavingBlockOffset3f, u_wavingBlockParam4f)
#endif
#else
pos = u_modelviewMat4f * pos;
#endif
#ifdef COMPILE_NORMAL_MATERIAL_TEXTURE
v_viewdir3f = pos.xyz / pos.w;
#endif
gl_Position = u_projectionMat4f * pos;
}
#line 2
/*
* Copyright (c) 2023 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
in vec3 a_position3f;
#ifdef COMPILE_TEXTURE_ATTRIB
in vec2 a_texture2f;
out vec2 v_texture2f;
uniform mat4 u_textureMat4f01;
#endif
#ifdef COMPILE_COLOR_ATTRIB
in vec4 a_color4f;
out vec4 v_color4f;
#endif
#ifdef COMPILE_NORMAL_ATTRIB
in vec4 a_normal4f;
out vec3 v_normal3f;
out float v_block1f;
#endif
#ifdef COMPILE_STATE_WAVING_BLOCKS
uniform mat4 u_modelMatrix4f;
uniform mat4 u_viewMatrix4f;
uniform vec3 u_wavingBlockOffset3f;
uniform vec4 u_wavingBlockParam4f;
#ifndef COMPILE_NORMAL_ATTRIB
uniform float u_blockConstant1f;
#endif
#define DO_COMPILE_STATE_WAVING_BLOCKS
#define FAKE_SIN(valueIn, valueOut)\
valueOut = abs(1.0 - fract(valueIn * 0.159155) * 2.0);\
valueOut = valueOut * valueOut * (3.0 - 2.0 * valueOut) * 2.0 - 1.0;
#define LIB_INCLUDE_WAVING_BLOCKS_FUNCTION
#endif
#EAGLER INCLUDE (2) "eagler:glsl/deferred/lib/waving_blocks.glsl"
#ifdef COMPILE_NORMAL_MATERIAL_TEXTURE
out vec3 v_viewdir3f;
#endif
#ifdef COMPILE_LIGHTMAP_ATTRIB
in vec2 a_lightmap2f;
out vec2 v_lightmap2f;
uniform mat4 u_textureMat4f02;
#endif
uniform mat4 u_modelviewMat4f;
uniform mat4 u_projectionMat4f;
#define TEX_MAT3(mat4In) mat3(mat4In[0].xyw,mat4In[1].xyw,mat4In[3].xyw)
void main() {
#ifdef COMPILE_TEXTURE_ATTRIB
vec3 v_textureTmp3f = TEX_MAT3(u_textureMat4f01) * vec3(a_texture2f, 1.0);
v_texture2f = v_textureTmp3f.xy / v_textureTmp3f.z;
#endif
#ifdef COMPILE_COLOR_ATTRIB
v_color4f = a_color4f;
#endif
#ifdef COMPILE_NORMAL_ATTRIB
v_normal3f = normalize(mat3(u_modelviewMat4f) * a_normal4f.xyz);
float blockId = v_block1f = floor((a_normal4f.w + 1.0) * 127.0 + 0.5);
#endif
#ifdef COMPILE_LIGHTMAP_ATTRIB
vec3 v_lightmapTmp3f = TEX_MAT3(u_textureMat4f02) * vec3(a_lightmap2f, 1.0);
v_lightmap2f = v_lightmapTmp3f.xy / v_lightmapTmp3f.z;
#endif
vec4 pos = vec4(a_position3f, 1.0);
#ifdef DO_COMPILE_STATE_WAVING_BLOCKS
#ifndef COMPILE_NORMAL_ATTRIB
float blockId = u_blockConstant1f;
#endif
#ifdef COMPILE_LIGHTMAP_ATTRIB
if(v_lightmap2f.y > 0.33) {
COMPUTE_WAVING_BLOCKS(pos, min(v_lightmap2f.y * 3.0 - 1.0, 1.0), 24.0, blockId, u_modelMatrix4f, u_viewMatrix4f, u_modelviewMat4f, u_wavingBlockOffset3f, u_wavingBlockParam4f)
}else {
pos = u_modelviewMat4f * pos;
}
#else
COMPUTE_WAVING_BLOCKS(pos, 1.0, 32.0, blockId, u_modelMatrix4f, u_viewMatrix4f, u_modelviewMat4f, u_wavingBlockOffset3f, u_wavingBlockParam4f)
#endif
#else
pos = u_modelviewMat4f * pos;
#endif
#ifdef COMPILE_NORMAL_MATERIAL_TEXTURE
v_viewdir3f = pos.xyz / pos.w;
#endif
gl_Position = u_projectionMat4f * pos;
}

View File

@ -34,7 +34,7 @@ void main() {
float lumaHDR = textureLod(u_framebufferLumaAvgInput, vec2(0.5), 0.0).r;
vec3 input3f = textureLod(u_lightingHDRFramebufferTexture, v_position2f, 0.0).rgb;
input3f /= (0.1 + clamp(lumaHDR * 6.0, 0.2, 4.0));
input3f /= (0.07 + clamp(lumaHDR * 6.0, 0.2, 4.0));
input3f *= u_exposure3f;

View File

@ -44,6 +44,41 @@ eaglercraft.editProfile.playerSkin=Player Skin
eaglercraft.editProfile.addSkin=Add Skin
eaglercraft.editProfile.clearSkin=Clear List
eaglercraft.editProfile.importExport=Import/Export
eaglercraft.settingsBackup.importExport.title=What do you wanna do?
eaglercraft.settingsBackup.importExport.import=Import Profile and Settings...
eaglercraft.settingsBackup.importExport.export=Export Profile and Settings...
eaglercraft.settingsBackup.import.title=Import Profile and Settings
eaglercraft.settingsBackup.import.option.profile=Import Profile:
eaglercraft.settingsBackup.import.option.settings=Import Settings:
eaglercraft.settingsBackup.import.option.servers=Import Servers:
eaglercraft.settingsBackup.import.option.resourcePacks=Resource Packs:
eaglercraft.settingsBackup.import.option.import=Import
eaglercraft.settingsBackup.export.title=Export Profile and Settings
eaglercraft.settingsBackup.export.option.profile=Export Profile:
eaglercraft.settingsBackup.export.option.settings=Export Settings:
eaglercraft.settingsBackup.export.option.servers=Export Servers:
eaglercraft.settingsBackup.export.option.resourcePacks=Resource Packs:
eaglercraft.settingsBackup.export.option.export=Export
eaglercraft.settingsBackup.exporting.1=Exporting Profile...
eaglercraft.settingsBackup.exporting.2=Please Wait.
eaglercraft.settingsBackup.exporting.failed.1=Export Failed!
eaglercraft.settingsBackup.exporting.failed.2=Could not compile EPK
eaglercraft.settingsBackup.importing.1=Importing Profile...
eaglercraft.settingsBackup.importing.2=Please Wait.
eaglercraft.settingsBackup.importing.failed.1=Import Failed!
eaglercraft.settingsBackup.importing.failed.2=Could not load EPK
eaglercraft.resourcePack.importFailed.1=Import Failed!
eaglercraft.resourcePack.importFailed.2=Could not import ZIP file
eaglercraft.singleplayer.integratedStartup=Starting integrated server
eaglercraft.addServer.SSLWarn1=you are on an https: page!

Binary file not shown.

BIN
desktopRuntime/webrtc-java.dll Executable file

Binary file not shown.

366
gradlew vendored
View File

@ -1,183 +1,183 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

View File

@ -8,8 +8,8 @@
<title>EaglercraftX 1.8</title>
<meta property="og:locale" content="en-US" />
<meta property="og:type" content="website" />
<meta property="og:title" content="EaglercraftX 1.8 Offline" />
<meta property="og:description" content="this file is not a website, whoever uploaded it to this URL is a dumbass" />
<meta property="og:title" content="EaglercraftX 1.8" />
<meta property="og:description" content="Play minecraft 1.8 in your browser" />
<script type="text/javascript">
"use strict";
const relayId = Math.floor(Math.random() * 3);
@ -31,10 +31,15 @@ window.eaglercraftXOptsHints = {
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
</script>
<style type="eaglercraft" id="eaglercraftXClientSignature">data:application/octet-stream;base64,${client_signature}</style>
<style type="eaglercraft" id="eaglercraftXClientBundle">data:application/octet-stream;base64,${client_bundle}</style>
<script type="text/javascript">
"use strict";
window.eaglercraftXClientSignature = "data:application/octet-stream;base64,${client_signature}";
window.eaglercraftXClientBundle = "data:application/octet-stream;base64,${client_bundle}";
(function(){
function eaglerBundleUnwrap(tagIn) { const e = document.getElementById(tagIn); const ret = e.innerText; e.remove(); return ret; }
window.eaglercraftXClientSignature = eaglerBundleUnwrap("eaglercraftXClientSignature");
window.eaglercraftXClientBundle = eaglerBundleUnwrap("eaglercraftXClientBundle");
})();
</script>
<script type="text/javascript">
"use strict";

View File

@ -21,6 +21,7 @@ import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.lwjgl.MainMenuCreditsDialog;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
@ -204,8 +205,15 @@ public class PlatformApplication {
fileChooserResultObject = null;
}
private static MainMenuCreditsDialog creditsDialog = null;
public static void openCreditsPopup(String text) {
if(creditsDialog == null) {
creditsDialog = new MainMenuCreditsDialog();
}
creditsDialog.setCreditsText(text);
creditsDialog.setLocationRelativeTo(null);
creditsDialog.setVisible(true);
}
private static final File downloadsDirectory = new File("downloads");
@ -239,6 +247,11 @@ public class PlatformApplication {
}
downloadsLogger.info("Saved {} byte file to: {}", fileContents.length, f.getAbsolutePath());
try {
Desktop.getDesktop().open(downloadsDirectory);
}catch(Throwable t) {
}
}
public static void addLogMessage(String logMessage, boolean isError) {

View File

@ -2,7 +2,6 @@ package net.lax1dude.eaglercraft.v1_8.internal;
import java.net.URL;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformAudio.IAudioCacheLoader;
import net.lax1dude.eaglercraft.v1_8.internal.paulscode.lwjgl3.LibraryLWJGLOpenAL;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;

View File

@ -6,12 +6,10 @@ import java.io.FileOutputStream;
import java.io.IOException;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.internal.lwjgl.LWJGLEntryPoint;
import net.lax1dude.eaglercraft.v1_8.internal.vfs2.EaglerFileSystemException;
import net.lax1dude.eaglercraft.v1_8.internal.vfs2.VFSIterator2.BreakLoop;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.sp.server.internal.lwjgl.DesktopIntegratedServer;
/**
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
@ -35,20 +33,12 @@ public class PlatformFilesystem {
public static final File filesystemRoot = (new File("filesystem/sp")).getAbsoluteFile();
public static void initialize() {
assertThread();
if(!filesystemRoot.isDirectory() && !filesystemRoot.mkdirs()) {
throw new EaglerFileSystemException("Could not create directory for virtual filesystem: " + filesystemRoot.getAbsolutePath());
}
}
private static void assertThread() {
if(Thread.currentThread() != DesktopIntegratedServer.serverThread) {
throw new UnsupportedOperationException("[DEBUG CHECK] VFS2 is currently only initialized for server contexts!");
}
}
public static boolean eaglerDelete(String pathName) {
assertThread();
File f = getJREFile(pathName);
if(!f.exists()) {
logger.warn("Tried to delete file that doesn't exist: \"{}\"", pathName);
@ -62,7 +52,6 @@ public class PlatformFilesystem {
}
public static ByteBuffer eaglerRead(String pathName) {
assertThread();
File f = getJREFile(pathName);
if(f.isFile()) {
long fileSize = f.length();
@ -96,7 +85,6 @@ public class PlatformFilesystem {
}
public static void eaglerWrite(String pathName, ByteBuffer data) {
assertThread();
File f = getJREFile(pathName);
File p = f.getParentFile();
if(!p.isDirectory()) {
@ -105,7 +93,7 @@ public class PlatformFilesystem {
}
}
try(FileOutputStream fos = new FileOutputStream(f)) {
byte[] copyBuffer = new byte[4096];
byte[] copyBuffer = new byte[Math.min(4096, data.remaining())];
int i;
while((i = data.remaining()) > 0) {
if(i > copyBuffer.length) {
@ -120,12 +108,10 @@ public class PlatformFilesystem {
}
public static boolean eaglerExists(String pathName) {
assertThread();
return getJREFile(pathName).isFile();
}
public static boolean eaglerMove(String pathNameOld, String pathNameNew) {
assertThread();
File f1 = getJREFile(pathNameOld);
File f2 = getJREFile(pathNameNew);
if(f2.exists()) {
@ -142,7 +128,6 @@ public class PlatformFilesystem {
}
public static int eaglerCopy(String pathNameOld, String pathNameNew) {
assertThread();
File f1 = getJREFile(pathNameOld);
File f2 = getJREFile(pathNameNew);
if(!f1.isFile()) {
@ -174,7 +159,6 @@ public class PlatformFilesystem {
}
public static int eaglerSize(String pathName) {
assertThread();
File f = getJREFile(pathName);
if(f.isFile()) {
long fileSize = f.length();
@ -186,7 +170,6 @@ public class PlatformFilesystem {
}
public static void eaglerIterate(String pathName, VFSFilenameIterator itr, boolean recursive) {
assertThread();
try {
iterateFile(pathName, getJREFile(pathName), itr, recursive);
}catch(BreakLoop ex) {

View File

@ -6,6 +6,7 @@ import java.util.LinkedList;
import java.util.List;
import org.lwjgl.PointerBuffer;
import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.system.MemoryStack;
/**
@ -129,6 +130,9 @@ public class PlatformInput {
});
glfwSetKeyCallback(glfwWindow, (window, key, scancode, action, mods) -> {
if (key == GLFW_KEY_F11 && action == GLFW_PRESS) {
toggleFullscreen();
}
if(glfwGetKey(glfwWindow, functionKeyModifier) == GLFW_PRESS) {
if(key >= GLFW_KEY_1 && key <= GLFW_KEY_9) {
key = key - GLFW_KEY_1 + GLFW_KEY_F1;
@ -381,12 +385,64 @@ public class PlatformInput {
functionKeyModifier = KeyboardConstants.getGLFWKeyFromEagler(key);
}
private static boolean fullscreen = false;
private static int[] lastPos = new int[4];
public static void toggleFullscreen() {
//
long win = PlatformRuntime.getWindowHandle();
long mon = getCurrentMonitor(win);
GLFWVidMode mode = glfwGetVideoMode(mon);
if (fullscreen) {
glfwSetWindowMonitor(win, 0, lastPos[0], lastPos[1], lastPos[2], lastPos[3], mode.refreshRate());
} else {
int[] x = new int[1], y = new int[1];
glfwGetWindowPos(win, x, y);
lastPos[0] = x[0];
lastPos[1] = y[0];
glfwGetWindowSize(win, x, y);
lastPos[2] = x[0];
lastPos[3] = y[0];
glfwSetWindowMonitor(win, mon, 0, 0, mode.width(), mode.height(), mode.refreshRate());
}
fullscreen = !fullscreen;
}
// https://stackoverflow.com/a/31526753
private static long getCurrentMonitor(long window) {
int nmonitors, i;
int[] wx = new int[1], wy = new int[1], ww = new int[1], wh = new int[1];
int[] mx = new int[1], my = new int[1], mw = new int[1], mh = new int[1];
int overlap, bestoverlap = 0;
long bestmonitor = 0;
PointerBuffer monitors;
GLFWVidMode mode;
glfwGetWindowPos(window, wx, wy);
glfwGetWindowSize(window, ww, wh);
monitors = glfwGetMonitors();
nmonitors = monitors.remaining();
for (i = 0; i < nmonitors; ++i) {
mode = glfwGetVideoMode(monitors.get(i));
glfwGetMonitorPos(monitors.get(i), mx, my);
mw[0] = mode.width();
mh[0] = mode.height();
overlap =
Math.max(0, Math.min(wx[0] + ww[0], mx[0] + mw[0]) - Math.max(wx[0], mx[0])) *
Math.max(0, Math.min(wy[0] + wh[0], my[0] + mh[0]) - Math.max(wy[0], my[0]));
if (bestoverlap < overlap) {
bestoverlap = overlap;
bestmonitor = monitors.get(i);
}
}
return bestmonitor;
}
public static boolean isFullscreen() {
return false;
return fullscreen;
}
public static void showCursor(EnumCursorType cursor) {

View File

@ -10,6 +10,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -36,12 +37,14 @@ import org.lwjgl.system.MemoryUtil;
import org.lwjgl.system.jemalloc.JEmalloc;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.EaglerLWJGLAllocator;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.IntBuffer;
import net.lax1dude.eaglercraft.v1_8.internal.lwjgl.DesktopClientConfigAdapter;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerFolderResourcePack;
/**
* Copyright (c) 2022-2023 lax1dude, ayunami2000. All Rights Reserved.
@ -71,6 +74,8 @@ public class PlatformRuntime {
public static void create() {
logger.info("Starting Desktop Runtime...");
PlatformFilesystem.initialize();
EaglerFolderResourcePack.setSupported(true);
if(requestedANGLEPlatform != EnumPlatformANGLE.DEFAULT) {
logger.info("Setting ANGLE Platform: {}", requestedANGLEPlatform.name);
@ -295,7 +300,31 @@ public class PlatformRuntime {
public static FloatBuffer allocateFloatBuffer(int length) {
return EaglerLWJGLAllocator.allocFloatBuffer(length);
}
public static ByteBuffer castPrimitiveByteArray(byte[] array) {
return null;
}
public static IntBuffer castPrimitiveIntArray(int[] array) {
return null;
}
public static FloatBuffer castPrimitiveFloatArray(float[] array) {
return null;
}
public static byte[] castNativeByteBuffer(ByteBuffer buffer) {
return null;
}
public static int[] castNativeIntBuffer(IntBuffer buffer) {
return null;
}
public static float[] castNativeFloatBuffer(FloatBuffer buffer) {
return null;
}
public static void freeByteBuffer(ByteBuffer byteBuffer) {
EaglerLWJGLAllocator.freeByteBuffer(byteBuffer);
}
@ -429,6 +458,22 @@ public class PlatformRuntime {
return new GZIPInputStream(is);
}
public static void downloadRemoteURIByteArray(String assetPackageURI, final Consumer<byte[]> cb) {
logger.info("Downloading: {}");
try(InputStream is = (new URL(assetPackageURI)).openStream()) {
EaglerOutputStream bao = new EaglerOutputStream();
byte[] copyBuffer = new byte[16384];
int i;
while((i = is.read(copyBuffer, 0, copyBuffer.length)) != -1) {
bao.write(copyBuffer, 0, i);
}
cb.accept(bao.toByteArray());
}catch(IOException ex) {
logger.error("Failed to download file!");
logger.error(ex);
}
}
public static boolean requireSSL() {
return false;
}
@ -468,4 +513,8 @@ public class PlatformRuntime {
public static String currentThreadName() {
return Thread.currentThread().getName();
}
public static long getWindowHandle() {
return windowHandle;
}
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.json.JSONObject;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.EaglercraftVersion;
import net.lax1dude.eaglercraft.v1_8.internal.IClientConfigAdapter;
import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayEntry;
@ -50,18 +51,31 @@ public class DesktopClientConfigAdapter implements IClientConfigAdapter {
return "desktop";
}
@Override
public String getResourcePacksDB() {
return "desktop";
}
@Override
public JSONObject dumpConfig() {
return new JSONObject("{\"container\":null,\"worldsDB\":\"desktop\"}");
}
private final List<RelayEntry> relays = new ArrayList<>();
@Override
public List<RelayEntry> getRelays() {
throw new UnsupportedOperationException("TODO");
if (relays.isEmpty()) {
int relayId = (new EaglercraftRandom()).nextInt(3);
relays.add(new RelayEntry("wss://relay.deev.is/", "lax1dude relay #1", relayId == 0));
relays.add(new RelayEntry("wss://relay.lax1dude.net/", "lax1dude relay #2", relayId == 1));
relays.add(new RelayEntry("wss://relay.shhnowisnottheti.me/", "ayunami relay #1", relayId == 2));
}
return relays;
}
@Override
public boolean checkShaderGLErrors() {
public boolean isCheckShaderGLErrors() {
return true;
}

View File

@ -8,6 +8,7 @@ import net.lax1dude.eaglercraft.v1_8.EagUtils;
import net.lax1dude.eaglercraft.v1_8.internal.EnumPlatformANGLE;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderSource;
import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayManager;
import net.minecraft.client.main.Main;
/**
@ -57,6 +58,13 @@ public class LWJGLEntryPoint {
}
}
RelayManager.relayManager.load(EagRuntime.getStorage("r"));
if (RelayManager.relayManager.count() <= 0) {
RelayManager.relayManager.loadDefaults();
RelayManager.relayManager.save();
}
EagRuntime.create();
Main.appMain(new String[0]);

View File

@ -0,0 +1,76 @@
package net.lax1dude.eaglercraft.v1_8.internal.lwjgl;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.BorderLayout;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import javax.swing.ScrollPaneConstants;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class MainMenuCreditsDialog extends JFrame {
private static final long serialVersionUID = 696969696L;
private JPanel contentPane;
private JTextArea textArea;
/**
* Create the frame.
*/
public MainMenuCreditsDialog() {
setIconImage(Toolkit.getDefaultToolkit().getImage("icon32.png"));
setTitle("EaglercraftX 1.8 Credits");
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setBounds(100, 100, 850, 700);
setLocationByPlatform(true);
setAlwaysOnTop(true);
contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(new BorderLayout(0, 0));
JScrollPane scrollPane = new JScrollPane();
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
contentPane.add(scrollPane, BorderLayout.CENTER);
textArea = new JTextArea();
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
Font daFont = null;
for(int i = 0; i < fonts.length; ++i) {
if(fonts[i].equalsIgnoreCase("consolas")) {
daFont = new Font(fonts[i], Font.PLAIN, 15);
break;
}
}
if(daFont == null) {
daFont = new Font(Font.MONOSPACED, Font.PLAIN, 15);
}
textArea.setFont(daFont);
scrollPane.setViewportView(textArea);
}
public void setCreditsText(String str) {
textArea.setText(str);
}
}

View File

@ -1,42 +0,0 @@
package net.lax1dude.eaglercraft.v1_8.internal.vfs;
import com.google.common.collect.Sets;
import net.minecraft.client.resources.AbstractResourcePack;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Set;
/**
* Copyright (c) 2022-2023 lax1dude, ayunami2000. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class FolderResourcePack extends AbstractResourcePack {
public FolderResourcePack(String resourcePackFileIn, String prefix) {
super(resourcePackFileIn);
}
protected InputStream getInputStreamByName(String name) {
return new BufferedInputStream(new ByteArrayInputStream(new byte[0]));
}
protected boolean hasResourceName(String name) {
return false;
}
public Set<String> getResourceDomains() {
return Sets.<String>newHashSet();
}
}

View File

@ -1,42 +0,0 @@
package net.lax1dude.eaglercraft.v1_8.internal.vfs;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
/**
* Copyright (c) 2022-2023 lax1dude, ayunami2000. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class SYS {
public static final Object VFS = null;
public static final void loadRemoteResourcePack(String url, String hash, Consumer<String> cb, Consumer<Runnable> ast, Runnable loading) {
return;
}
public static final boolean loadResourcePack(String name, InputStream data, String hash) {
return false;
}
public static final List<String> getResourcePackNames() {
return new ArrayList<>();
}
public static final void deleteResourcePack(String packName) {
//
}
}

View File

@ -3,7 +3,6 @@ package net.lax1dude.eaglercraft.v1_8.sp.internal;
import java.util.ArrayList;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.internal.IClientConfigAdapter;
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
import net.lax1dude.eaglercraft.v1_8.sp.server.internal.lwjgl.CrashScreenPopup;

View File

@ -9,7 +9,6 @@ import javax.swing.ScrollPaneConstants;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.Color;
import java.awt.Window.Type;
/**
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.

View File

@ -19,7 +19,6 @@ package com.google.common.base;
import java.nio.charset.Charset;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
/**
* Contains constant definitions for the six standard {@link Charset} instances,

View File

@ -18,8 +18,6 @@ package com.google.common.base;
import static com.google.common.base.Preconditions.checkNotNull;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

View File

@ -44,7 +44,6 @@ import javax.annotation.Nullable;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Objects;

View File

@ -55,6 +55,17 @@ public class ArrayUtils {
}
return str;
}
private static final String hex = "0123456789abcdef";
public static String hexString(byte[] bytesIn) {
char[] ret = new char[bytesIn.length << 1];
for(int i = 0; i < bytesIn.length; ++i) {
ret[i << 1] = hex.charAt((bytesIn[i] >> 4) & 15);
ret[(i << 1) + 1] = hex.charAt(bytesIn[i] & 15);
}
return new String(ret);
}
public static <T> void eaglerShuffle(List<T> list, EaglercraftRandom rnd) {
T k;

View File

@ -390,7 +390,8 @@ public abstract class BaseNCodec {
if (arrayOctet == null) {
return false;
}
for (final byte element : arrayOctet) {
for (int i = 0; i < arrayOctet.length; ++i) {
byte element = arrayOctet[i];
if (pad == element || isInAlphabet(element)) {
return true;
}
@ -624,7 +625,8 @@ public abstract class BaseNCodec {
* the byte array is empty; {@code false}, otherwise
*/
public boolean isInAlphabet(final byte[] arrayOctet, final boolean allowWSPad) {
for (final byte octet : arrayOctet) {
for (int i = 0; i < arrayOctet.length; ++i) {
byte octet = arrayOctet[i];
if (!isInAlphabet(octet) && (!allowWSPad || (octet != pad) && !isWhiteSpace(octet))) {
return false;
}

View File

@ -14,6 +14,7 @@ import java.util.Calendar;
import java.util.List;
import java.util.function.Consumer;
import net.lax1dude.eaglercraft.v1_8.internal.EnumPlatformANGLE;
import net.lax1dude.eaglercraft.v1_8.internal.EnumPlatformAgent;
import net.lax1dude.eaglercraft.v1_8.internal.EnumPlatformOS;
import net.lax1dude.eaglercraft.v1_8.internal.EnumPlatformType;
@ -28,7 +29,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.update.UpdateService;
/**
* Copyright (c) 2022-2023 lax1dude, ayunami2000. All Rights Reserved.
* Copyright (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -48,6 +49,10 @@ public class EagRuntime {
private static final Logger exceptionLogger = LogManager.getLogger("Exception");
private static boolean ssl = false;
private static boolean offlineDownloadURL = false;
private static EnumPlatformAgent userAgent = null;
private static String userAgentString = null;
private static EnumPlatformOS operatingSystem = null;
private static EnumPlatformANGLE angleBackend = null;
public static String getVersion() {
return "EagRuntimeX 1.0";
@ -58,6 +63,10 @@ public class EagRuntime {
PlatformRuntime.create();
ssl = PlatformRuntime.requireSSL();
offlineDownloadURL = PlatformRuntime.isOfflineDownloadURL();
userAgent = PlatformRuntime.getPlatformAgent();
userAgentString = PlatformRuntime.getUserAgentString();
operatingSystem = PlatformRuntime.getPlatformOS();
angleBackend = PlatformRuntime.getPlatformANGLE();
UpdateService.initialize();
EaglerXBungeeVersion.initialize();
EaglercraftGPU.warmUpCache();
@ -72,15 +81,19 @@ public class EagRuntime {
}
public static EnumPlatformAgent getPlatformAgent() {
return PlatformRuntime.getPlatformAgent();
return userAgent;
}
public static String getUserAgentString() {
return PlatformRuntime.getUserAgentString();
return userAgentString;
}
public static EnumPlatformOS getPlatformOS() {
return PlatformRuntime.getPlatformOS();
return operatingSystem;
}
public static EnumPlatformANGLE getPlatformANGLE() {
return angleBackend;
}
public static ByteBuffer allocateByteBuffer(int length) {

View File

@ -1,12 +1,13 @@
package net.lax1dude.eaglercraft.v1_8;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
/**
* Copyright (c) 2022 lax1dude. All Rights Reserved.
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -20,39 +21,117 @@ import java.io.InputStream;
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class EaglerInputStream extends ByteArrayInputStream {
public class EaglerInputStream extends InputStream {
protected byte buf[];
protected int pos;
protected int mark = 0;
protected int count;
public EaglerInputStream(byte[] buf) {
super(buf);
this.buf = buf;
this.pos = 0;
this.count = buf.length;
}
public EaglerInputStream(byte[] buf, int off, int len) {
super(buf, off, len);
public EaglerInputStream(byte buf[], int offset, int length) {
this.buf = buf;
this.pos = offset;
this.count = Math.min(offset + length, buf.length);
this.mark = offset;
}
public int read() {
return (pos < count) ? (buf[pos++] & 0xff) : -1;
}
public int read(byte b[], int off, int len) {
if (pos >= count) {
return -1;
}
int avail = count - pos;
if (len > avail) {
len = avail;
}
if (len <= 0) {
return 0;
}
System.arraycopy(buf, pos, b, off, len);
pos += len;
return len;
}
public byte[] readAllBytes() {
byte[] result = Arrays.copyOfRange(buf, pos, count);
pos = count;
return result;
}
public int readNBytes(byte[] b, int off, int len) {
int n = read(b, off, len);
return n == -1 ? 0 : n;
}
public long transferTo(OutputStream out) throws IOException {
int len = count - pos;
out.write(buf, pos, len);
pos = count;
return len;
}
public static byte[] inputStreamToBytesQuiet(InputStream is) {
if(is == null) {
if (is == null) {
return null;
}
try {
return inputStreamToBytes(is);
}catch(IOException ex) {
} catch (IOException ex) {
return null;
}
}
public long skip(long n) {
long k = count - pos;
if (n < k) {
k = n < 0 ? 0 : n;
}
pos += k;
return k;
}
public int available() {
return count - pos;
}
public boolean markSupported() {
return true;
}
public void mark(int readAheadLimit) {
mark = pos;
}
public void reset() {
pos = mark;
}
public void close() throws IOException {
}
public static byte[] inputStreamToBytes(InputStream is) throws IOException {
if(is instanceof EaglerInputStream) {
if (is instanceof EaglerInputStream) {
return ((EaglerInputStream) is).getAsArray();
}else if(is instanceof ByteArrayInputStream) {
} else if (is instanceof ByteArrayInputStream) {
byte[] ret = new byte[is.available()];
is.read(ret);
return ret;
}else {
ByteArrayOutputStream os = new ByteArrayOutputStream(1024);
} else {
EaglerOutputStream os = new EaglerOutputStream(1024);
byte[] buf = new byte[1024];
int i;
while((i = is.read(buf)) != -1) {
while ((i = is.read(buf)) != -1) {
os.write(buf, 0, i);
}
return os.toByteArray();
@ -60,27 +139,27 @@ public class EaglerInputStream extends ByteArrayInputStream {
}
public byte[] getAsArray() {
if(pos == 0 && count == buf.length) {
if (pos == 0 && count == buf.length) {
return buf;
}else {
} else {
byte[] ret = new byte[count];
System.arraycopy(buf, pos, ret, 0, count);
return ret;
}
}
public boolean canUseArrayDirectly() {
return pos == 0 && count == buf.length;
}
public int getPosition() {
return pos;
}
public int getMark() {
return mark;
}
public int getCount() {
return count;
}

View File

@ -0,0 +1,79 @@
package net.lax1dude.eaglercraft.v1_8;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class EaglerOutputStream extends OutputStream {
protected byte buf[];
protected int count;
public EaglerOutputStream() {
this(32);
}
public EaglerOutputStream(int size) {
if (size < 0) {
throw new IllegalArgumentException("Negative initial size: " + size);
}
buf = new byte[size];
}
private void ensureCapacity(int minCapacity) {
if (buf.length < minCapacity) {
minCapacity = Math.max(minCapacity, buf.length * 3 / 2);
buf = Arrays.copyOf(buf, minCapacity);
}
}
public void write(int b) {
ensureCapacity(count + 1);
buf[count] = (byte) b;
count += 1;
}
public void write(byte b[], int off, int len) {
ensureCapacity(count + len);
System.arraycopy(b, off, buf, count, len);
count += len;
}
public void writeBytes(byte b[]) {
write(b, 0, b.length);
}
public void writeTo(OutputStream out) throws IOException {
out.write(buf, 0, count);
}
public void reset() {
count = 0;
}
public byte[] toByteArray() {
return Arrays.copyOf(buf, count);
}
public int size() {
return count;
}
public void close() throws IOException {
}
}

View File

@ -10,7 +10,7 @@ public class EaglercraftVersion {
/// Customize these to fit your fork:
public static final String projectForkName = "EaglercraftX";
public static final String projectForkVersion = "u23";
public static final String projectForkVersion = "u24";
public static final String projectForkVendor = "lax1dude";
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
@ -20,7 +20,7 @@ public class EaglercraftVersion {
public static final String projectOriginName = "EaglercraftX";
public static final String projectOriginAuthor = "lax1dude";
public static final String projectOriginRevision = "1.8";
public static final String projectOriginVersion = "u23";
public static final String projectOriginVersion = "u24";
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace
@ -31,7 +31,7 @@ public class EaglercraftVersion {
public static final boolean enableUpdateService = true;
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client";
public static final int updateBundlePackageVersionInt = 23;
public static final int updateBundlePackageVersionInt = 24;
public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;

View File

@ -71,4 +71,19 @@ public class IOUtils {
}
}
public static int readFully(InputStream is, byte[] out) throws IOException {
int i = 0, j;
while(i < out.length && (j = is.read(out, i, out.length - i)) != -1) {
i += j;
}
return i;
}
public static long skipFully(InputStream is, long skip) throws IOException {
long i = 0, j;
while(i < skip && (j = is.skip(skip - i)) != 0) {
i += j;
}
return i;
}
}

View File

@ -41,7 +41,8 @@ public class ListenableFutureTask<V> extends FutureTask<V> implements Listenable
}
protected void done() {
for(Runnable r : listeners) {
for(int i = 0, l = listeners.size(); i < l; ++i) {
Runnable r = listeners.get(i);
try {
r.run();
}catch(Throwable t) {

View File

@ -42,11 +42,13 @@ public interface IClientConfigAdapter {
String getWorldsDB();
String getResourcePacksDB();
JSONObject dumpConfig();
List<RelayEntry> getRelays();
boolean checkShaderGLErrors();
boolean isCheckShaderGLErrors();
boolean isDemo();

View File

@ -188,8 +188,12 @@ public class VFile2 {
return null;
}
ByteBuffer readBuffer = PlatformFilesystem.eaglerRead(path);
byte[] copyBuffer = PlatformRuntime.castNativeByteBuffer(readBuffer);
if(copyBuffer != null) {
return copyBuffer;
}
try {
byte[] copyBuffer = new byte[readBuffer.remaining()];
copyBuffer = new byte[readBuffer.remaining()];
readBuffer.get(copyBuffer);
return copyBuffer;
}finally {
@ -219,7 +223,12 @@ public class VFile2 {
public void setAllBytes(byte[] bytes) {
assertNotRelative();
ByteBuffer copyBuffer = PlatformRuntime.allocateByteBuffer(bytes.length);
ByteBuffer copyBuffer = PlatformRuntime.castPrimitiveByteArray(bytes);
if(copyBuffer != null) {
PlatformFilesystem.eaglerWrite(path, copyBuffer);
return;
}
copyBuffer = PlatformRuntime.allocateByteBuffer(bytes.length);
try {
copyBuffer.put(bytes);
copyBuffer.flip();

View File

@ -54,7 +54,7 @@ class VFileInputStream extends InputStream {
if(len > 0) {
fileBuffer.get(b, off, len);
}
return len;
return len <= 0 ? -1 : len;
}
@Override

View File

@ -1,8 +1,8 @@
package net.lax1dude.eaglercraft.v1_8.internal.vfs2;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformFilesystem;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
@ -22,7 +22,7 @@ import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
* POSSIBILITY OF SUCH DAMAGE.
*
*/
class VFileOutputStream extends ByteArrayOutputStream {
class VFileOutputStream extends EaglerOutputStream {
private final VFile2 vfsFile;
private boolean closed = false;

View File

@ -73,7 +73,9 @@ public class ChunkUpdateManager {
final CompiledChunk compiledchunk = generator.getCompiledChunk();
if (chunkcompiletaskgenerator$type == ChunkCompileTaskGenerator.Type.REBUILD_CHUNK) {
for (EnumWorldBlockLayer enumworldblocklayer : EnumWorldBlockLayer.values()) {
EnumWorldBlockLayer[] en = EnumWorldBlockLayer._VALUES;
for (int i = 0; i < en.length; ++i) {
EnumWorldBlockLayer enumworldblocklayer = en[i];
if (!compiledchunk.isLayerEmpty(enumworldblocklayer)) {
this.uploadChunk(enumworldblocklayer,
generator.getRegionRenderCacheBuilder().getWorldRendererByLayer(enumworldblocklayer),

View File

@ -0,0 +1,355 @@
package net.lax1dude.eaglercraft.v1_8.minecraft;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import net.lax1dude.eaglercraft.v1_8.ArrayUtils;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.crypto.SHA1Digest;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.vfs2.VFile2;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.minecraft.client.resources.AbstractResourcePack;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class EaglerFolderResourcePack extends AbstractResourcePack {
public static final Logger logger = LogManager.getLogger("EaglerFolderResourcePack");
public static final String SERVER_RESOURCE_PACKS = "srp";
public static final String RESOURCE_PACKS = "resourcepacks";
private final String prefix;
private final String displayName;
private final Set<String> domains;
private final long timestamp;
private static boolean isSupported = false;
public static void setSupported(boolean supported) {
isSupported = supported;
}
public static boolean isSupported() {
return isSupported;
}
public EaglerFolderResourcePack(String resourcePackFileIn, String displayName, String prefix, Set<String> domains, long timestamp) {
super(resourcePackFileIn);
this.displayName = displayName;
this.prefix = prefix;
this.domains = domains;
this.timestamp = timestamp;
}
@Override
public Set<String> getResourceDomains() {
return domains;
}
@Override
protected InputStream getInputStreamByName(String var1) throws IOException {
return (new VFile2(prefix, this.resourcePackFile, var1)).getInputStream();
}
@Override
protected boolean hasResourceName(String var1) {
return (new VFile2(prefix, this.resourcePackFile, var1)).exists();
}
public long getTimestamp() {
return timestamp;
}
public String getDisplayName() {
return displayName;
}
public static List<EaglerFolderResourcePack> getFolderResourcePacks(String prefix) {
if(!isSupported) {
return Collections.emptyList();
}
String str = (new VFile2(prefix, "manifest.json")).getAllChars();
if(str == null) {
return Collections.emptyList();
}
try {
JSONArray json = (new JSONObject(str)).getJSONArray("resourcePacks");
List<EaglerFolderResourcePack> ret = new ArrayList(json.length());
for(int i = 0, l = json.length(); i < l; ++i) {
JSONObject jp = json.getJSONObject(i);
String folderName = jp.getString("folder");
String displayName = jp.optString("name", folderName);
long timestamp = jp.getLong("timestamp");
Set<String> domains = Sets.newHashSet();
JSONArray jsonDomains = jp.getJSONArray("domains");
for(int j = 0, k = jsonDomains.length(); j < k; ++j) {
domains.add(jsonDomains.getString(j));
}
ret.add(new EaglerFolderResourcePack(folderName, displayName, prefix, domains, timestamp));
}
return ret;
}catch(JSONException ex) {
logger.error("Failed to load resource pack manifest!");
logger.error(ex);
return Collections.emptyList();
}
}
public static EaglerFolderResourcePack importResourcePack(String name, String prefix, byte[] file) throws IOException {
if(!isSupported) {
return null;
}
logger.info("Importing resource pack: {}", name);
int idx = name.lastIndexOf('.');
if(idx != -1) {
name = name.substring(0, idx);
}
String folderName = name.replaceAll("[^A-Za-z0-9\\-_ \\(\\)]", "_");
final List<EaglerFolderResourcePack> existingLst = getFolderResourcePacks(RESOURCE_PACKS);
vigg: for(;;) {
for(int i = 0, l = existingLst.size(); i < l; ++i) {
EaglerFolderResourcePack rp = existingLst.get(i);
if(rp.resourcePackFile.equalsIgnoreCase(folderName)) {
folderName = folderName + "-";
continue vigg;
}
}
break;
}
List<String> fileNames = Lists.newArrayList();
logger.info("Counting files...");
ZipInputStream ziss = new ZipInputStream(new EaglerInputStream(file));
ZipEntry zipEntry;
while ((zipEntry = ziss.getNextEntry()) != null) {
if (!zipEntry.isDirectory()) {
fileNames.add(zipEntry.getName());
}
}
int prefixLen = Integer.MAX_VALUE;
for(int i = 0, l = fileNames.size(); i < l; ++i) {
String fn = fileNames.get(i);
if(fn.equals("pack.mcmeta") || fn.endsWith("/pack.mcmeta")) {
int currPrefixLen = fn.length() - 11;
if (prefixLen > currPrefixLen) {
prefixLen = currPrefixLen;
}
}
}
if (prefixLen == Integer.MAX_VALUE) {
prefixLen = 0;
}
Set<String> domainsList = Sets.newHashSet();
String fn;
for(int i = 0, l = fileNames.size(); i < l; ++i) {
fn = fileNames.get(i);
if(fn.length() > prefixLen + 7) {
fn = fn.substring(prefixLen + 7);
int j = fn.indexOf('/');
if(j != -1) {
domainsList.add(fn.substring(0, j));
}
}
}
VFile2 dstDir = new VFile2(prefix, folderName);
logger.info("Extracting to: {}", dstDir.getPath());
try {
int totalSize = 0;
int totalFiles = 0;
int lastProg = 0;
ziss = new ZipInputStream(new EaglerInputStream(file));
while ((zipEntry = ziss.getNextEntry()) != null) {
if (!zipEntry.isDirectory()) {
fn = zipEntry.getName();
if(fn.length() > prefixLen) {
byte[] buffer = new byte[(int)zipEntry.getSize()];
int i = 0, j;
while(i < buffer.length && (j = ziss.read(buffer, i, buffer.length - i)) != -1) {
i += j;
}
(new VFile2(prefix, folderName, fn.substring(prefixLen))).setAllBytes(buffer);
totalSize += buffer.length;
++totalFiles;
if(totalSize - lastProg > 25000) {
lastProg = totalSize;
logger.info("Extracted {} files, {} bytes from ZIP file...", totalFiles, totalSize);
}
}
}
}
}catch(IOException ex) {
logger.error("Encountered an error extracting zip file, deleting extracted files...");
for(int i = 0, l = fileNames.size(); i < l; ++i) {
fn = fileNames.get(i);
if(fn.length() > prefixLen) {
(new VFile2(dstDir, fn.substring(prefixLen))).delete();
}
}
throw ex;
}
logger.info("Updating manifest...");
VFile2 manifestFile = new VFile2(prefix, "manifest.json");
String str = manifestFile.getAllChars();
JSONArray arr = null;
if(str != null) {
try {
arr = (new JSONObject(str)).getJSONArray("resourcePacks");
}catch(JSONException ex) {
}
}
if(arr == null) {
arr = new JSONArray();
}
JSONObject manifestEntry = new JSONObject();
manifestEntry.put("folder", folderName);
manifestEntry.put("name", name);
long timestamp = System.currentTimeMillis();
manifestEntry.put("timestamp", timestamp);
JSONArray domainsListJson = new JSONArray();
for(String str2 : domainsList) {
domainsListJson.put(str2);
}
manifestEntry.put("domains", domainsListJson);
arr.put(manifestEntry);
manifestFile.setAllChars((new JSONObject()).put("resourcePacks", arr).toString());
logger.info("Done!");
return new EaglerFolderResourcePack(folderName, name, prefix, domainsList, timestamp);
}
public static void loadRemoteResourcePack(String url, String hash, Consumer<EaglerFolderResourcePack> cb, Consumer<Runnable> ast, Runnable loading) {
if (!isSupported || !hash.matches("^[a-f0-9]{40}$")) {
cb.accept(null);
return;
}
final List<EaglerFolderResourcePack> lst = getFolderResourcePacks(SERVER_RESOURCE_PACKS);
for(int i = 0, l = lst.size(); i < l; ++i) {
EaglerFolderResourcePack rp = lst.get(i);
if(rp.resourcePackFile.equals(hash)) {
cb.accept(rp);
return;
}
}
PlatformRuntime.downloadRemoteURIByteArray(url, arr -> {
ast.accept(() -> {
if (arr == null) {
cb.accept(null);
return;
}
SHA1Digest digest = new SHA1Digest();
digest.update(arr, 0, arr.length);
byte[] hashOut = new byte[20];
digest.doFinal(hashOut, 0);
if(!hash.equals(ArrayUtils.hexString(hashOut))) {
logger.error("Downloaded resource pack hash does not equal expected resource pack hash!");
cb.accept(null);
return;
}
if(lst.size() >= 5) {
lst.sort(Comparator.comparingLong(pack -> pack.timestamp));
for(int i = 0; i < lst.size() - 5; i++) {
deleteResourcePack(SERVER_RESOURCE_PACKS, lst.get(i).resourcePackFile);
}
}
loading.run();
try {
cb.accept(importResourcePack(hash, SERVER_RESOURCE_PACKS, arr));
}catch(IOException ex) {
logger.error("Failed to load resource pack downloaded from server!");
logger.error(ex);
cb.accept(null);
}
});
});
}
public static void deleteResourcePack(EaglerFolderResourcePack pack) {
deleteResourcePack(pack.prefix, pack.resourcePackFile);
}
public static void deleteResourcePack(String prefix, String name) {
if (!isSupported) {
return;
}
logger.info("Deleting resource pack: {}/{}", prefix, name);
(new VFile2(prefix, name)).listFiles(true).forEach(VFile2::delete);
VFile2 manifestFile = new VFile2(prefix, "manifest.json");
String str = manifestFile.getAllChars();
if(str != null) {
try {
JSONArray json = (new JSONObject(str)).getJSONArray("resourcePacks");
boolean changed = false;
for(int i = 0, l = json.length(); i < l; ++i) {
if(json.getJSONObject(i).getString("folder").equals(name)) {
json.remove(i);
changed = true;
break;
}
}
if(changed) {
manifestFile.setAllChars((new JSONObject()).put("resourcePacks", json).toString());
}else {
logger.warn("Failed to remove pack \"{}\" from manifest, it wasn't found in the list for some reason", name);
}
}catch(JSONException ex) {
}
}
}
public static void deleteOldResourcePacks(String prefix, long maxAge) {
if (!isSupported) {
return;
}
long millis = System.currentTimeMillis();
List<EaglerFolderResourcePack> lst = getFolderResourcePacks(prefix);
for(int i = 0, l = lst.size(); i < l; ++i) {
EaglerFolderResourcePack rp = lst.get(i);
if(millis - rp.timestamp > maxAge) {
deleteResourcePack(rp);
}
}
}
}

View File

@ -273,7 +273,8 @@ public class EaglerTextureAtlasSprite {
public String call() throws Exception {
StringBuilder stringbuilder = new StringBuilder();
for (int[] aint1 : aint) {
for (int j = 0; j < aint.length; ++j) {
int[] aint1 = aint[j];
if (stringbuilder.length() > 0) {
stringbuilder.append(", ");
}

View File

@ -0,0 +1,52 @@
package net.lax1dude.eaglercraft.v1_8.minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class GuiScreenGenericErrorMessage extends GuiScreen {
private String str1;
private String str2;
private GuiScreen cont;
public GuiScreenGenericErrorMessage(String str1, String str2, GuiScreen cont) {
this.str1 = I18n.format(str1);
this.str2 = I18n.format(str2);
this.cont = cont;
}
public void initGui() {
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 6 + 96, I18n.format("gui.done")));
}
public void drawScreen(int par1, int par2, float par3) {
this.drawDefaultBackground();
this.drawCenteredString(fontRendererObj, str1, this.width / 2, 70, 11184810);
this.drawCenteredString(fontRendererObj, str2, this.width / 2, 90, 16777215);
super.drawScreen(par1, par2, par3);
}
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 0) {
this.mc.displayGuiScreen(cont);
}
}
}

View File

@ -53,8 +53,8 @@ public final class ObjectUtil {
throw new NullPointerException(text);
}
for (T element : varargs) {
if (element == null) {
for (int i = 0; i < varargs.length; ++i) {
if (varargs[i] == null) {
throw new NullPointerException(text);
}
}

View File

@ -11,7 +11,6 @@ import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
import net.lax1dude.eaglercraft.v1_8.internal.IUniformGL;

View File

@ -202,7 +202,7 @@ public class InstancedFontRenderer {
_wglVertexAttribDivisor(0, 0);
EaglercraftGPU.bindGLArrayBuffer(instancesBuffer);
_wglBufferData(GL_ARRAY_BUFFER, fontDataBuffer.remaining(), GL_STATIC_DRAW);
_wglBufferData(GL_ARRAY_BUFFER, fontDataBuffer.remaining(), GL_STREAM_DRAW);
_wglEnableVertexAttribArray(1);
_wglVertexAttribPointer(1, 2, GL_SHORT, false, 10, 0);

View File

@ -184,7 +184,7 @@ public class InstancedParticleRenderer {
_wglVertexAttribDivisor(0, 0);
EaglercraftGPU.bindGLArrayBuffer(instancesBuffer);
_wglBufferData(GL_ARRAY_BUFFER, particleBuffer.remaining(), GL_STATIC_DRAW);
_wglBufferData(GL_ARRAY_BUFFER, particleBuffer.remaining(), GL_STREAM_DRAW);
_wglEnableVertexAttribArray(1);
_wglVertexAttribPointer(1, 3, GL_FLOAT, false, 24, 0);

View File

@ -4,8 +4,6 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
import net.lax1dude.eaglercraft.v1_8.internal.IUniformGL;

View File

@ -380,7 +380,7 @@ public class EaglerDeferredPipeline {
public void rebuild(EaglerDeferredConfig config) {
destroy();
DeferredStateManager.doCheckErrors = EagRuntime.getConfiguration().checkShaderGLErrors();
DeferredStateManager.doCheckErrors = EagRuntime.getConfiguration().isCheckShaderGLErrors();
DeferredStateManager.checkGLError("Pre: rebuild pipeline");
this.config = config;
this.currentWidth = -1;
@ -3302,7 +3302,7 @@ public class EaglerDeferredPipeline {
GlStateManager.bindTexture(bloomVBlurTexture);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE, GL_ZERO, GL_ONE);
GlStateManager.setBlendConstants(0.0f, 0.0f, 0.0f, 0.25f);
GlStateManager.setBlendConstants(0.0f, 0.0f, 0.0f, 0.15f);
TextureCopyUtil.blitTexture();
GlStateManager.disableBlend();

View File

@ -12,7 +12,6 @@ import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderAccelParticleForward;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderAccelParticleGBuffer;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
@ -92,7 +91,7 @@ public class ForwardAcceleratedEffectRenderer extends AbstractAcceleratedEffectR
_wglVertexAttribDivisor(0, 0);
EaglercraftGPU.bindGLArrayBuffer(instancesBuffer);
_wglBufferData(GL_ARRAY_BUFFER, particleBuffer.remaining(), GL_STATIC_DRAW);
_wglBufferData(GL_ARRAY_BUFFER, particleBuffer.remaining(), GL_STREAM_DRAW);
_wglEnableVertexAttribArray(1);
_wglVertexAttribPointer(1, 3, GL_FLOAT, false, 24, 0);

View File

@ -91,7 +91,7 @@ public class GBufferAcceleratedEffectRenderer extends AbstractAcceleratedEffectR
_wglVertexAttribDivisor(0, 0);
EaglercraftGPU.bindGLArrayBuffer(instancesBuffer);
_wglBufferData(GL_ARRAY_BUFFER, particleBuffer.remaining(), GL_STATIC_DRAW);
_wglBufferData(GL_ARRAY_BUFFER, particleBuffer.remaining(), GL_STREAM_DRAW);
_wglEnableVertexAttribArray(1);
_wglVertexAttribPointer(1, 3, GL_FLOAT, false, 24, 0);

View File

@ -4,12 +4,11 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ExtGLEnums.*;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
@ -162,7 +161,7 @@ public class LensFlareMeshRenderer {
if(flareTex == null) {
throw new RuntimeException("Could not locate: " + streaksTextureLocation);
}
try(DataInputStream dis = new DataInputStream(new ByteArrayInputStream(flareTex))) {
try(DataInputStream dis = new DataInputStream(new EaglerInputStream(flareTex))) {
loadFlareTexture(copyBuffer, dis);
}catch(IOException ex) {
EagRuntime.freeByteBuffer(copyBuffer);
@ -175,7 +174,7 @@ public class LensFlareMeshRenderer {
if(flareTex == null) {
throw new RuntimeException("Could not locate: " + ghostsTextureLocation);
}
try(DataInputStream dis = new DataInputStream(new ByteArrayInputStream(flareTex))) {
try(DataInputStream dis = new DataInputStream(new EaglerInputStream(flareTex))) {
loadFlareTexture(copyBuffer, dis);
}catch(IOException ex) {
EagRuntime.freeByteBuffer(copyBuffer);

View File

@ -14,7 +14,6 @@ import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
import net.lax1dude.eaglercraft.v1_8.minecraft.TextureAnimationCache;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.data.AnimationFrame;
@ -187,11 +186,12 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
public String call() throws Exception {
StringBuilder stringbuilder = new StringBuilder();
for (int[] aint1 : aint) {
for (int k = 0; k < aint.length; ++k) {
if (stringbuilder.length() > 0) {
stringbuilder.append(", ");
}
int[] aint1 = aint[k];
stringbuilder.append(aint1 == null ? "null" : Integer.valueOf(aint1.length));
}

View File

@ -46,7 +46,8 @@ public class PBRTextureMapUtils {
}
try {
List<IResource> ress = resMgr.getAllResources(new ResourceLocation(domain, fname));
for(IResource res : ress) {
for(int k = 0, l = ress.size(); k < l; ++k) {
IResource res = ress.get(k);
if(res.getResourcePackName().equals(resourcePack)) {
ImageData toRet = TextureUtil.readBufferedImage(res.getInputStream());
if(ext.equals("_s")) {

View File

@ -1,7 +1,6 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture;
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.minecraft.client.Minecraft;
import net.minecraft.util.MathHelper;

View File

@ -1,7 +1,6 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture;
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.minecraft.client.Minecraft;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;

View File

@ -1,17 +1,16 @@
package net.lax1dude.eaglercraft.v1_8.profile;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
@ -148,8 +147,10 @@ public class EaglerProfile {
}
public static void read() {
byte[] profileStorage = EagRuntime.getStorage("p");
read(EagRuntime.getStorage("p"));
}
public static void read(byte[] profileStorage) {
if (profileStorage == null) {
return;
}
@ -207,7 +208,7 @@ public class EaglerProfile {
}
public static void write() {
public static byte[] write() {
NBTTagCompound profile = new NBTTagCompound();
profile.setInteger("presetSkin", presetSkinId);
profile.setInteger("customSkin", customSkinId);
@ -222,13 +223,20 @@ public class EaglerProfile {
skinsList.appendTag(skin);
}
profile.setTag("skins", skinsList);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
EaglerOutputStream bao = new EaglerOutputStream();
try {
CompressedStreamTools.writeCompressed(profile, bao);
} catch (IOException e) {
return;
return null;
}
return bao.toByteArray();
}
public static void save() {
byte[] b = write();
if(b != null) {
EagRuntime.setStorage("p", b);
}
EagRuntime.setStorage("p", bao.toByteArray());
}
static {

View File

@ -3,13 +3,16 @@ package net.lax1dude.eaglercraft.v1_8.profile;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.Keyboard;
import net.lax1dude.eaglercraft.v1_8.Mouse;
import net.lax1dude.eaglercraft.v1_8.internal.EnumCursorType;
import net.lax1dude.eaglercraft.v1_8.internal.FileChooserResult;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
@ -162,6 +165,23 @@ public class GuiScreenEditProfile extends GuiScreen {
drawRect(skinX + skinWidth - 4, skinY + scrollerPos + 1, skinX + skinWidth - 1, skinY + scrollerPos + scrollerSize, 0xff888888);
}
if(!EagRuntime.getConfiguration().isDemo()) {
GlStateManager.pushMatrix();
GlStateManager.scale(0.75f, 0.75f, 0.75f);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
String text = I18n.format("editProfile.importExport");
int w = mc.fontRendererObj.getStringWidth(text);
boolean hover = mx > 1 && my > 1 && mx < (w * 3 / 4) + 7 && my < 12;
if(hover) {
Mouse.showCursor(EnumCursorType.HAND);
}
drawString(mc.fontRendererObj, EnumChatFormatting.UNDERLINE + text, 5, 5, hover ? 0xFFEEEE22 : 0xFFCCCCCC);
GlStateManager.popMatrix();
}
int xx = width / 2 - 80;
int yy = height / 6 + 130;
int numberOfCustomSkins = EaglerProfile.customSkins.size();
@ -370,6 +390,15 @@ public class GuiScreenEditProfile extends GuiScreen {
super.mouseClicked(mx, my, button);
usernameField.mouseClicked(mx, my, button);
if (button == 0) {
if(!EagRuntime.getConfiguration().isDemo()) {
int w = mc.fontRendererObj.getStringWidth(I18n.format("editProfile.importExport"));
if(mx > 1 && my > 1 && mx < (w * 3 / 4) + 7 && my < 12) {
mc.displayGuiScreen(new GuiScreenImportExportProfile(this));
mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
return;
}
}
if(newSkinWaitSteveOrAlex) {
int skinX = width / 2 - 90;
int skinY = height / 4;
@ -459,7 +488,7 @@ public class GuiScreenEditProfile extends GuiScreen {
name = name.substring(0, 16);
}
EaglerProfile.setName(name);
EaglerProfile.write();
EaglerProfile.save();
}
}

View File

@ -0,0 +1,90 @@
package net.lax1dude.eaglercraft.v1_8.profile;
import java.io.IOException;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerFolderResourcePack;
import net.lax1dude.eaglercraft.v1_8.minecraft.GuiScreenGenericErrorMessage;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class GuiScreenExportProfile extends GuiScreen {
private GuiScreen back;
private GuiButton exportProfile;
private boolean doExportProfile = true;
private GuiButton exportSettings;
private boolean doExportSettings = true;
private GuiButton exportServers;
private boolean doExportServers = true;
private GuiButton exportResourcePacks;
private boolean doExportResourcePacks = false;
public GuiScreenExportProfile(GuiScreen back) {
this.back = back;
}
public void initGui() {
this.buttonList.add(exportProfile = new GuiButton(2, this.width / 2 - 100, this.height / 4, I18n.format("settingsBackup.export.option.profile") + " " + I18n.format(doExportProfile ? "gui.yes" : "gui.no")));
this.buttonList.add(exportSettings = new GuiButton(3, this.width / 2 - 100, this.height / 4 + 25, I18n.format("settingsBackup.export.option.settings") + " " + I18n.format(doExportSettings ? "gui.yes" : "gui.no")));
this.buttonList.add(exportServers = new GuiButton(4, this.width / 2 - 100, this.height / 4 + 50, I18n.format("settingsBackup.export.option.servers") + " " + I18n.format(doExportServers ? "gui.yes" : "gui.no")));
this.buttonList.add(exportResourcePacks = new GuiButton(5, this.width / 2 - 100, this.height / 4 + 75, I18n.format("settingsBackup.export.option.resourcePacks") + " " + I18n.format(doExportResourcePacks ? "gui.yes" : "gui.no")));
exportResourcePacks.enabled = EaglerFolderResourcePack.isSupported();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 115, I18n.format("settingsBackup.export.option.export")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 140, I18n.format("gui.cancel")));
}
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 0) {
if(!doExportProfile && !doExportSettings && !doExportServers && !doExportResourcePacks) {
mc.displayGuiScreen(back);
}else {
mc.loadingScreen.eaglerShow(I18n.format("settingsBackup.exporting.1"), I18n.format("settingsBackup.exporting.2"));
try {
ProfileExporter.exportProfileAndSettings(doExportProfile, doExportSettings, doExportServers, doExportResourcePacks);
mc.displayGuiScreen(back);
} catch (IOException e) {
EagRuntime.debugPrintStackTrace(e);
mc.displayGuiScreen(new GuiScreenGenericErrorMessage("settingsBackup.exporting.failed.1", "settingsBackup.exporting.failed.2", back));
}
}
}else if(par1GuiButton.id == 1) {
mc.displayGuiScreen(back);
}else if(par1GuiButton.id == 2) {
doExportProfile = !doExportProfile;
exportProfile.displayString = I18n.format("settingsBackup.export.option.profile") + " " + I18n.format(doExportProfile ? "gui.yes" : "gui.no");
}else if(par1GuiButton.id == 3) {
doExportSettings = !doExportSettings;
exportSettings.displayString = I18n.format("settingsBackup.export.option.settings") + " " + I18n.format(doExportSettings ? "gui.yes" : "gui.no");
}else if(par1GuiButton.id == 4) {
doExportServers = !doExportServers;
exportServers.displayString = I18n.format("settingsBackup.export.option.servers") + " " + I18n.format(doExportServers ? "gui.yes" : "gui.no");
}else if(par1GuiButton.id == 5) {
doExportResourcePacks = !doExportResourcePacks;
exportResourcePacks.displayString = I18n.format("settingsBackup.export.option.resourcePacks") + " " + I18n.format(doExportResourcePacks ? "gui.yes" : "gui.no");
}
}
public void drawScreen(int par1, int par2, float par3) {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, I18n.format("settingsBackup.export.title"), this.width / 2, this.height / 4 - 25, 16777215);
super.drawScreen(par1, par2, par3);
}
}

View File

@ -0,0 +1,78 @@
package net.lax1dude.eaglercraft.v1_8.profile;
import java.io.IOException;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.FileChooserResult;
import net.lax1dude.eaglercraft.v1_8.minecraft.GuiScreenGenericErrorMessage;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class GuiScreenImportExportProfile extends GuiScreen {
private GuiScreen back;
private boolean waitingForFile = false;
public GuiScreenImportExportProfile(GuiScreen back) {
this.back = back;
}
public void initGui() {
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 40, I18n.format("settingsBackup.importExport.import")));
this.buttonList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 65, I18n.format("settingsBackup.importExport.export")));
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 130, I18n.format("gui.cancel")));
}
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 0) {
mc.displayGuiScreen(back);
}else if(par1GuiButton.id == 1) {
waitingForFile = true;
EagRuntime.displayFileChooser(null, "epk");
}else if(par1GuiButton.id == 2) {
mc.displayGuiScreen(new GuiScreenExportProfile(back));
}
}
public void updateScreen() {
if(waitingForFile && EagRuntime.fileChooserHasResult()) {
waitingForFile = false;
FileChooserResult result = EagRuntime.getFileChooserResult();
if(result != null) {
mc.loadingScreen.eaglerShow(I18n.format("settingsBackup.importing.1"), "settingsBackup.importing.2");
try {
ProfileImporter importer = new ProfileImporter(result.fileData);
importer.readHeader();
mc.displayGuiScreen(new GuiScreenImportProfile(importer, back));
}catch(IOException ex) {
EagRuntime.debugPrintStackTrace(ex);
mc.displayGuiScreen(new GuiScreenGenericErrorMessage("settingsBackup.importing.failed.1", "settingsBackup.importing.failed.2", back));
}
}
}
}
public void drawScreen(int par1, int par2, float par3) {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, I18n.format("settingsBackup.importExport.title"), this.width / 2, this.height / 4, 16777215);
super.drawScreen(par1, par2, par3);
}
}

View File

@ -0,0 +1,111 @@
package net.lax1dude.eaglercraft.v1_8.profile;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerFolderResourcePack;
import net.lax1dude.eaglercraft.v1_8.minecraft.GuiScreenGenericErrorMessage;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.ResourcePackRepository;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class GuiScreenImportProfile extends GuiScreen {
private GuiScreen back;
private ProfileImporter importer;
private GuiButton importProfile;
private boolean doImportProfile;
private GuiButton importSettings;
private boolean doImportSettings;
private GuiButton importServers;
private boolean doImportServers;
private GuiButton importResourcePacks;
private boolean doImportResourcePacks;
public GuiScreenImportProfile(ProfileImporter importer, GuiScreen back) {
this.back = back;
this.importer = importer;
this.doImportProfile = importer.hasProfile();
this.doImportSettings = importer.hasSettings();
this.doImportServers = importer.hasSettings();
this.doImportResourcePacks = importer.hasResourcePacks();
}
public void initGui() {
this.buttonList.add(importProfile = new GuiButton(2, this.width / 2 - 100, this.height / 4, I18n.format("settingsBackup.import.option.profile") + " " + I18n.format(doImportProfile ? "gui.yes" : "gui.no")));
importProfile.enabled = importer.hasProfile();
this.buttonList.add(importSettings = new GuiButton(3, this.width / 2 - 100, this.height / 4 + 25, I18n.format("settingsBackup.import.option.settings") + " " + I18n.format(doImportSettings ? "gui.yes" : "gui.no")));
importSettings.enabled = importer.hasProfile();
this.buttonList.add(importServers = new GuiButton(4, this.width / 2 - 100, this.height / 4 + 50, I18n.format("settingsBackup.import.option.servers") + " " + I18n.format(doImportServers ? "gui.yes" : "gui.no")));
importServers.enabled = importer.hasServers();
this.buttonList.add(importResourcePacks = new GuiButton(5, this.width / 2 - 100, this.height / 4 + 75, I18n.format("settingsBackup.import.option.resourcePacks") + " " + I18n.format(doImportResourcePacks ? "gui.yes" : "gui.no")));
importResourcePacks.enabled = importer.hasResourcePacks() && EaglerFolderResourcePack.isSupported();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 115, I18n.format("settingsBackup.import.option.import")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 140, I18n.format("gui.cancel")));
}
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 0) {
if(!doImportProfile && !doImportSettings && !doImportServers && !doImportResourcePacks) {
mc.displayGuiScreen(back);
}else {
mc.loadingScreen.eaglerShow(I18n.format("settingsBackup.importing.1"), I18n.format("settingsBackup.importing.2"));
try {
List<String> list1 = new ArrayList(mc.gameSettings.resourcePacks);
List<String> list2 = new ArrayList(mc.gameSettings.field_183018_l);
importer.importProfileAndSettings(doImportProfile, doImportSettings, doImportServers, doImportResourcePacks);
boolean resourcePacksChanged = !mc.gameSettings.resourcePacks.equals(list1) || !mc.gameSettings.field_183018_l.equals(list2);
if(resourcePacksChanged || (doImportResourcePacks && (list1.size() > 0 || list2.size() > 0))) {
mc.loadingScreen.eaglerShow(I18n.format("resourcePack.load.refreshing"),
I18n.format("resourcePack.load.pleaseWait"));
mc.getResourcePackRepository().reconstruct(mc.gameSettings);
mc.refreshResources();
}
mc.displayGuiScreen(back);
} catch (IOException e) {
EagRuntime.debugPrintStackTrace(e);
mc.displayGuiScreen(new GuiScreenGenericErrorMessage("settingsBackup.importing.failed.1", "settingsBackup.importing.failed.2", back));
}
}
}else if(par1GuiButton.id == 1) {
mc.displayGuiScreen(back);
}else if(par1GuiButton.id == 2) {
doImportProfile = !doImportProfile;
importProfile.displayString = I18n.format("settingsBackup.import.option.profile") + " " + I18n.format(doImportProfile ? "gui.yes" : "gui.no");
}else if(par1GuiButton.id == 3) {
doImportSettings = !doImportSettings;
importSettings.displayString = I18n.format("settingsBackup.import.option.settings") + " " + I18n.format(doImportSettings ? "gui.yes" : "gui.no");
}else if(par1GuiButton.id == 4) {
doImportServers = !doImportServers;
importServers.displayString = I18n.format("settingsBackup.import.option.servers") + " " + I18n.format(doImportServers ? "gui.yes" : "gui.no");
}else if(par1GuiButton.id == 5) {
doImportResourcePacks = !doImportResourcePacks;
importResourcePacks.displayString = I18n.format("settingsBackup.import.option.resourcePacks") + " " + I18n.format(doImportResourcePacks ? "gui.yes" : "gui.no");
}
}
public void drawScreen(int par1, int par2, float par3) {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, I18n.format("settingsBackup.import.title"), this.width / 2, this.height / 4 - 25, 16777215);
super.drawScreen(par1, par2, par3);
}
}

View File

@ -0,0 +1,195 @@
package net.lax1dude.eaglercraft.v1_8.profile;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.zip.CRC32;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerZLIB;
import net.lax1dude.eaglercraft.v1_8.internal.vfs2.VFile2;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerFolderResourcePack;
import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayManager;
import net.lax1dude.eaglercraft.v1_8.update.UpdateCertificate;
import net.lax1dude.eaglercraft.v1_8.update.UpdateService;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerList;
import static net.lax1dude.eaglercraft.v1_8.sp.server.export.EPKCompiler.*;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class ProfileExporter {
private static final Logger logger = LogManager.getLogger("ProfileExporter");
public static void exportProfileAndSettings(boolean doExportProfile, boolean doExportSettings,
boolean doExportServers, boolean doExportResourcePacks) throws IOException {
doExportResourcePacks &= EaglerFolderResourcePack.isSupported();
EaglerOutputStream osb = new EaglerOutputStream();
osb.write(new byte[]{(byte)69,(byte)65,(byte)71,(byte)80,(byte)75,(byte)71,(byte)36,(byte)36}); // EAGPKG$$
osb.write(new byte[]{(byte)6,(byte)118,(byte)101,(byte)114,(byte)50,(byte)46,(byte)48}); // 6 + ver2.0
Date d = new Date();
byte[] filename = "profile.epk".getBytes(StandardCharsets.UTF_8);
osb.write(filename.length);
osb.write(filename);
byte[] comment = ("\n\n # Eaglercraft profile backup - \"" + EaglerProfile.getName() + "\""
+ "\n # Contains: " + (doExportProfile ? "profile " : "") + (doExportSettings ? "settings " : "")
+ (doExportServers ? "servers " : "") + (doExportResourcePacks ? "resourcePacks" : "") + "\n\n")
.getBytes(StandardCharsets.UTF_8);
osb.write((comment.length >> 8) & 255);
osb.write(comment.length & 255);
osb.write(comment);
writeLong(d.getTime(), osb);
int lengthIntegerOffset = osb.size();
osb.write(new byte[]{(byte)255,(byte)255,(byte)255,(byte)255}); // this will be replaced with the file count
osb.write('G');
OutputStream os = EaglerZLIB.newGZIPOutputStream(osb);
os.write(new byte[]{(byte)72,(byte)69,(byte)65,(byte)68}); // HEAD
os.write(new byte[]{(byte)9,(byte)102,(byte)105,(byte)108,(byte)101,(byte)45,(byte)116,(byte)121,
(byte)112,(byte)101}); // 9 + file-type
os.write(new byte[]{(byte)0,(byte)0,(byte)0,(byte)14,(byte)101,(byte)112,(byte)107,(byte)47,(byte)112,(byte)114,(byte)111,
(byte)102,(byte)105,(byte)108,(byte)101,(byte)49,(byte)56,(byte)56}); // 14 + epk/profile188
os.write('>');
os.write(new byte[]{(byte)72,(byte)69,(byte)65,(byte)68}); // HEAD
os.write(new byte[]{(byte)12,(byte)102,(byte)105,(byte)108,(byte)101,(byte)45,(byte)101,(byte)120,
(byte)112,(byte)111,(byte)114,(byte)116,(byte)115,(byte)0,(byte)0,(byte)0,(byte)1}); // 12 + file-exports + 1
os.write((doExportProfile ? 1 : 0) | (doExportSettings ? 2 : 0) | (doExportServers ? 4 : 0) | (doExportResourcePacks ? 8 : 0));
os.write('>');
int fileCount = 2;
if(doExportProfile) {
byte[] profileData = EaglerProfile.write();
if(profileData == null) {
throw new IOException("Could not write profile data!");
}
exportFileToEPK("_eaglercraftX.p", profileData, os);
++fileCount;
}
if(doExportSettings) {
logger.info("Exporting game settings...");
byte[] gameSettings = Minecraft.getMinecraft().gameSettings.writeOptions();
if(gameSettings == null) {
throw new IOException("Could not write game settings!");
}
exportFileToEPK("_eaglercraftX.g", gameSettings, os);
++fileCount;
logger.info("Exporting relay settings...");
byte[] relays = RelayManager.relayManager.write();
if(relays == null) {
throw new IOException("Could not write relay settings!");
}
exportFileToEPK("_eaglercraftX.r", relays, os);
++fileCount;
}
if(doExportServers) {
logger.info("Exporting server list...");
byte[] servers = ServerList.getServerList().writeServerList();
if(servers == null) {
throw new IOException("Could not write server list!");
}
exportFileToEPK("_eaglercraftX.s", servers, os);
++fileCount;
}
logger.info("Exporting certificates...");
UpdateCertificate cert = UpdateService.getClientCertificate();
if(cert != null) {
exportFileToEPK("certs/main.cert", cert.rawCertData, os);
++fileCount;
}
Collection<UpdateCertificate> updatesExport = UpdateService.getAvailableUpdates();
int cc = 0;
for(UpdateCertificate cert2 : updatesExport) {
exportFileToEPK("certs/c" + (cc++) + ".cert", cert2.rawCertData, os);
++fileCount;
}
if(doExportResourcePacks) {
logger.info("Exporting resource packs...");
byte[] packManifest = (new VFile2(EaglerFolderResourcePack.RESOURCE_PACKS + "/manifest.json")).getAllBytes();
if(packManifest != null) {
exportFileToEPK(EaglerFolderResourcePack.RESOURCE_PACKS + "/manifest.json", packManifest, os);
++fileCount;
VFile2 baseDir = new VFile2(EaglerFolderResourcePack.RESOURCE_PACKS);
List<VFile2> files = baseDir.listFiles(true);
logger.info("({} files to export)", files.size());
for(int i = 0, l = files.size(); i < l; ++i) {
VFile2 f = files.get(i);
if(f.getPath().equals(EaglerFolderResourcePack.RESOURCE_PACKS + "/manifest.json")) {
continue;
}
exportFileToEPK(f.getPath(), f.getAllBytes(), os);
++fileCount;
if(i > 0 && i % 100 == 0) {
logger.info("Exported {} files", i);
}
}
}
}
os.write(new byte[]{(byte)69,(byte)78,(byte)68,(byte)36}); // END$
os.close();
osb.write(new byte[]{(byte)58,(byte)58,(byte)58,(byte)89,(byte)69,(byte)69,(byte)58,(byte)62}); // :::YEE:>
byte[] ret = osb.toByteArray();
ret[lengthIntegerOffset] = (byte)((fileCount >> 24) & 0xFF);
ret[lengthIntegerOffset + 1] = (byte)((fileCount >> 16) & 0xFF);
ret[lengthIntegerOffset + 2] = (byte)((fileCount >> 8) & 0xFF);
ret[lengthIntegerOffset + 3] = (byte)(fileCount & 0xFF);
logger.info("Export complete!");
EagRuntime.downloadFileWithName(EaglerProfile.getName() + "-backup.epk", ret);
}
private static void exportFileToEPK(String name, byte[] contents, OutputStream os) throws IOException {
CRC32 checkSum = new CRC32();
checkSum.update(contents);
long sum = checkSum.getValue();
os.write(new byte[]{(byte)70,(byte)73,(byte)76,(byte)69}); // FILE
byte[] nameBytes = name.getBytes(StandardCharsets.UTF_8);
os.write(nameBytes.length);
os.write(nameBytes);
writeInt(contents.length + 5, os);
writeInt((int)sum, os);
os.write(contents);
os.write(':');
os.write('>');
}
}

View File

@ -0,0 +1,151 @@
package net.lax1dude.eaglercraft.v1_8.profile;
import java.io.IOException;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.vfs2.VFile2;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerFolderResourcePack;
import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayManager;
import net.lax1dude.eaglercraft.v1_8.sp.server.export.EPKDecompiler;
import net.lax1dude.eaglercraft.v1_8.sp.server.export.EPKDecompiler.FileEntry;
import net.lax1dude.eaglercraft.v1_8.update.UpdateService;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerList;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class ProfileImporter {
private static final Logger logger = LogManager.getLogger("ProfileImporter");
private byte[] data;
private EPKDecompiler epkDecompiler;
private boolean headerHasProfile;
private boolean headerHasSettings;
private boolean headerHasServers;
private boolean headerHasResourcePacks;
public ProfileImporter(byte[] data) {
this.data = data;
}
public void readHeader() throws IOException {
logger.info("Reading EPK file header...");
epkDecompiler = new EPKDecompiler(data);
FileEntry etr = epkDecompiler.readFile();
if (etr == null || !etr.type.equals("HEAD") || !etr.name.equals("file-type")
|| !EPKDecompiler.readASCII(etr.data).equals("epk/profile188")) {
throw new IOException("EPK file is not a profile backup!");
}
etr = epkDecompiler.readFile();
if (etr == null || !etr.type.equals("HEAD") || !etr.name.equals("file-exports") || etr.data.length != 1) {
throw new IOException("EPK file is not a profile backup!");
}
headerHasProfile = (etr.data[0] & 1) != 0;
headerHasSettings = (etr.data[0] & 2) != 0;
headerHasServers = (etr.data[0] & 4) != 0;
headerHasResourcePacks = (etr.data[0] & 8) != 0;
}
public boolean hasProfile() {
return headerHasProfile;
}
public boolean hasSettings() {
return headerHasSettings;
}
public boolean hasServers() {
return headerHasServers;
}
public boolean hasResourcePacks() {
return headerHasResourcePacks;
}
/**
* Note: this function is sensitive to the order file appear in the EPK
*/
public void importProfileAndSettings(boolean doImportProfile, boolean doImportSettings,
boolean doImportServers, boolean doImportResourcePacks) throws IOException {
doImportProfile &= headerHasProfile;
doImportSettings &= headerHasSettings;
doImportServers &= headerHasServers;
doImportResourcePacks &= headerHasResourcePacks && EaglerFolderResourcePack.isSupported();
FileEntry etr;
vigg: while((etr = epkDecompiler.readFile()) != null) {
if(etr.type.equals("FILE")) {
switch(etr.name) {
case "_eaglercraftX.p":
if(doImportProfile) {
logger.info("Importing profile...");
EaglerProfile.read(etr.data);
EagRuntime.setStorage("p", etr.data);
}
break;
case "_eaglercraftX.g":
if(doImportSettings) {
logger.info("Importing settings...");
Minecraft.getMinecraft().gameSettings.loadOptions(etr.data);
EagRuntime.setStorage("g", etr.data);
}
break;
case "_eaglercraftX.r":
if(doImportSettings) {
logger.info("Importing relays...");
RelayManager.relayManager.load(etr.data);
EagRuntime.setStorage("r", etr.data);
}
break;
case "_eaglercraftX.s":
if(doImportServers) {
logger.info("Importing servers...");
ServerList.getServerList().loadServerList(etr.data);
EagRuntime.setStorage("s", etr.data);
}
break;
default:
if(etr.name.startsWith("certs/")) {
UpdateService.addCertificateToSet(etr.data);
}else if(etr.name.startsWith(EaglerFolderResourcePack.RESOURCE_PACKS + "/")) {
if(doImportResourcePacks) {
logger.info("Deleting old resource packs...");
(new VFile2(EaglerFolderResourcePack.RESOURCE_PACKS)).listFiles(true).forEach(VFile2::delete);
logger.info("Importing resource packs...");
int counter = 0;
do {
if(etr.name.startsWith(EaglerFolderResourcePack.RESOURCE_PACKS + "/")) {
(new VFile2(etr.name)).setAllBytes(etr.data);
if(++counter % 100 == 0) {
logger.info("Imported {} files", counter);
}
}
}while((etr = epkDecompiler.readFile()) != null);
}
break vigg;
}
break;
}
}
}
logger.info("Import complete!");
}
}

View File

@ -1,6 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.socket;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@ -8,6 +7,7 @@ import java.nio.charset.StandardCharsets;
import net.lax1dude.eaglercraft.v1_8.ArrayUtils;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
import net.lax1dude.eaglercraft.v1_8.EaglercraftVersion;
import net.lax1dude.eaglercraft.v1_8.crypto.SHA256Digest;
@ -56,7 +56,7 @@ public class ConnectionHandshake {
try {
pluginVersion = null;
pluginBrand = null;
ByteArrayOutputStream bao = new ByteArrayOutputStream();
EaglerOutputStream bao = new EaglerOutputStream();
DataOutputStream d = new DataOutputStream(bao);
d.writeByte(HandshakePacketTypes.PROTOCOL_CLIENT_VERSION);

View File

@ -91,7 +91,8 @@ public class EaglercraftNetworkManager {
return;
}
for(byte[] next : pkts) {
for(int i = 0, l = pkts.size(); i < l; ++i) {
byte[] next = pkts.get(i);
++debugPacketCounter;
try {
ByteBuf nettyBuffer = Unpooled.buffer(next, next.length);

View File

@ -12,17 +12,14 @@ import net.lax1dude.eaglercraft.v1_8.internal.PlatformWebRTC;
import org.apache.commons.lang3.StringUtils;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EaglercraftSoundManager;
import net.lax1dude.eaglercraft.v1_8.internal.EnumEaglerConnectionState;
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformApplication;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.profile.EaglerProfile;
import net.lax1dude.eaglercraft.v1_8.socket.EaglercraftNetworkManager;
import net.lax1dude.eaglercraft.v1_8.sp.internal.ClientPlatformSingleplayer;
import net.lax1dude.eaglercraft.v1_8.sp.ipc.*;
import net.lax1dude.eaglercraft.v1_8.sp.lan.LANClientNetworkManager;
import net.lax1dude.eaglercraft.v1_8.sp.lan.LANServerController;
import net.lax1dude.eaglercraft.v1_8.sp.socket.ClientIntegratedServerNetworkManager;
import net.minecraft.client.Minecraft;
@ -475,7 +472,8 @@ public class SingleplayerServerController implements ISaveFormat {
private static void loadSaveComparators() {
saveListMap.clear();
saveListCache.clear();
for(NBTTagCompound nbt : saveListNBT) {
for(int j = 0, l = saveListNBT.size(); j < l; ++j) {
NBTTagCompound nbt = saveListNBT.get(j);
String folderName = nbt.getString("folderNameEagler");
if(!StringUtils.isEmpty(folderName)) {
WorldInfo worldinfo = new WorldInfo(nbt.getCompoundTag("Data"));

View File

@ -118,7 +118,7 @@ public class GuiScreenBackupWorldSelection extends GuiScreen {
public void confirmClicked(boolean par1, int par2) {
if(par1) {
SingleplayerServerController.clearPlayerData(worldName);
this.mc.displayGuiScreen(new GuiScreenIntegratedServerBusy(this, "singleplayer.busy.clearplayers", "singleplayer.failed.clearplayers", () -> SingleplayerServerController.isReady()));
this.mc.displayGuiScreen(new GuiScreenIntegratedServerBusy(this, "singleplayer.busy.clearplayers", "singleplayer.failed.clearplayers", SingleplayerServerController::isReady));
}else {
mc.displayGuiScreen(this);
}

View File

@ -46,11 +46,13 @@ public class GuiScreenConnectOption extends GuiScreen {
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 0) {
guiScreen.cancelDirectConnect();
mc.displayGuiScreen(guiScreen);
}else if(par1GuiButton.id == 1) {
mc.displayGuiScreen(new GuiScreenServerList(guiScreen, guiScreen.getSelectedServer()));
}else if(par1GuiButton.id == 2) {
if(LANServerController.supported()) {
guiScreen.cancelDirectConnect();
mc.displayGuiScreen(GuiScreenLANInfo.showLANInfoScreen(new GuiScreenLANConnect(guiScreen)));
}else {
mc.displayGuiScreen(new GuiScreenLANNotSupported(this));

View File

@ -2,7 +2,6 @@ package net.lax1dude.eaglercraft.v1_8.sp.gui;
import net.lax1dude.eaglercraft.v1_8.sp.lan.LANServerController;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiCreateWorld;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.world.demo.DemoWorldServer;

View File

@ -1,7 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.sp.gui;
import org.apache.commons.lang3.StringUtils;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.Keyboard;
import net.lax1dude.eaglercraft.v1_8.internal.FileChooserResult;
@ -61,7 +59,7 @@ public class GuiScreenNameWorldImport extends GuiScreen {
if(definetlyTimeToImport && !isImporting) {
isImporting = true;
SingleplayerServerController.importWorld(GuiCreateWorld.func_146317_a(mc.getSaveLoader(), this.theGuiTextField.getText().trim()), world.fileData, importFormat, (byte) ((loadSpawnChunks ? 2 : 0) | (enhancedGameRules ? 1 : 0)));
mc.displayGuiScreen(new GuiScreenIntegratedServerBusy(parentGuiScreen, "singleplayer.busy.importing." + (importFormat + 1), "singleplayer.failed.importing." + (importFormat + 1), () -> SingleplayerServerController.isReady()));
mc.displayGuiScreen(new GuiScreenIntegratedServerBusy(parentGuiScreen, "singleplayer.busy.importing." + (importFormat + 1), "singleplayer.failed.importing." + (importFormat + 1), SingleplayerServerController::isReady));
}
}

View File

@ -150,7 +150,7 @@ public class GuiShareToLan extends GuiScreen {
}
this.mc.displayGuiScreen(null);
LoadingScreenRenderer ls = mc.loadingScreen;
String code = LANServerController.shareToLAN((str) -> ls.resetProgressAndMessage(str), worldName, hiddenToggle);
String code = LANServerController.shareToLAN(ls::resetProgressAndMessage, worldName, hiddenToggle);
if (code != null) {
SingleplayerServerController.configureLAN(WorldSettings.GameType.getByName(this.gameMode), this.allowCommands);
this.mc.ingameGUI.getChatGUI().printChatMessage(new ChatComponentText(I18n.format("lanServer.opened")

View File

@ -39,8 +39,8 @@ public class IPCPacket14StringList implements IPCPacketBase {
public IPCPacket14StringList(int opcode, String[] list) {
stringList = new ArrayList();
for(String s : list) {
s = s.trim();
for(int i = 0; i < list.length; ++i) {
String s = list[i].trim();
if(s.length() > 0) {
stringList.add(s);
}
@ -50,8 +50,8 @@ public class IPCPacket14StringList implements IPCPacketBase {
public IPCPacket14StringList(int opcode, List<String> list) {
stringList = new ArrayList();
for(String s : list) {
s = s.trim();
for(int i = 0, l = list.size(); i < l; ++i) {
String s = list.get(i).trim();
if(s.length() > 0) {
stringList.add(s);
}
@ -72,9 +72,10 @@ public class IPCPacket14StringList implements IPCPacketBase {
@Override
public void serialize(DataOutput bin) throws IOException {
bin.writeByte(opCode);
bin.writeInt(stringList.size());
for(String str : stringList) {
bin.writeUTF(str);
int l = stringList.size();
bin.writeInt(l);
for(int i = 0; i < l; ++i) {
bin.writeUTF(stringList.get(i));
}
}
@ -86,8 +87,8 @@ public class IPCPacket14StringList implements IPCPacketBase {
@Override
public int size() {
int len = 5;
for(String str : stringList) {
len += IPCPacketBase.strLen(str);
for(int i = 0, l = stringList.size(); i < l; ++i) {
len += IPCPacketBase.strLen(stringList.get(i));
}
return len;
}

View File

@ -3,9 +3,6 @@ package net.lax1dude.eaglercraft.v1_8.sp.ipc;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Copyright (c) 2023-2024 lax1dude. All Rights Reserved.

View File

@ -1,7 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.sp.ipc;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
@ -11,6 +9,8 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@ -54,7 +54,7 @@ public class IPCPacket16NBTList implements IPCPacketBase {
for(int i = 0, size = list.size(); i < size; ++i) {
NBTTagCompound tag = list.get(i);
try {
ByteArrayOutputStream bao = new ByteArrayOutputStream();
EaglerOutputStream bao = new EaglerOutputStream();
CompressedStreamTools.write(tag, new DataOutputStream(bao));
tagList.add(bao.toByteArray());
}catch(IOException e) {
@ -75,7 +75,7 @@ public class IPCPacket16NBTList implements IPCPacketBase {
bin.readFully(toRead);
tagList.add(toRead);
try {
nbtTagList.add(CompressedStreamTools.read(new DataInputStream(new ByteArrayInputStream(toRead))));
nbtTagList.add(CompressedStreamTools.read(new DataInputStream(new EaglerInputStream(toRead))));
}catch(IOException e) {
System.err.println("Failed to read tag #" + i + " in IPCPacket16NBTList");
}
@ -85,8 +85,10 @@ public class IPCPacket16NBTList implements IPCPacketBase {
@Override
public void serialize(DataOutput bin) throws IOException {
bin.writeInt(opCode);
bin.writeInt(tagList.size());
for(byte[] str : tagList) {
int l = tagList.size();
bin.writeInt(l);
for(int i = 0; i < l; ++i) {
byte[] str = tagList.get(i);
bin.writeInt(str.length);
bin.write(str);
}
@ -100,9 +102,9 @@ public class IPCPacket16NBTList implements IPCPacketBase {
@Override
public int size() {
int len = 8;
for(byte[] str : tagList) {
for(int i = 0, l = tagList.size(); i < l; ++i) {
len += 4;
len += str.length;
len += tagList.get(i).length;
}
return len;
}

View File

@ -32,32 +32,32 @@ public class IPCPacketManager {
public static final DataOutputStream IPC_DATA_OUTPUT_STREAM = new DataOutputStream(IPC_OUTPUT_STREAM);
static {
mappings.put(IPCPacket00StartServer.ID, () -> new IPCPacket00StartServer());
mappings.put(IPCPacket01StopServer.ID, () -> new IPCPacket01StopServer());
mappings.put(IPCPacket02InitWorld.ID, () -> new IPCPacket02InitWorld());
mappings.put(IPCPacket03DeleteWorld.ID, () -> new IPCPacket03DeleteWorld());
mappings.put(IPCPacket05RequestData.ID, () -> new IPCPacket05RequestData());
mappings.put(IPCPacket06RenameWorldNBT.ID, () -> new IPCPacket06RenameWorldNBT());
mappings.put(IPCPacket07ImportWorld.ID, () -> new IPCPacket07ImportWorld());
mappings.put(IPCPacket09RequestResponse.ID, () -> new IPCPacket09RequestResponse());
mappings.put(IPCPacket0ASetWorldDifficulty.ID, () -> new IPCPacket0ASetWorldDifficulty());
mappings.put(IPCPacket0BPause.ID, () -> new IPCPacket0BPause());
mappings.put(IPCPacket0CPlayerChannel.ID, () -> new IPCPacket0CPlayerChannel());
mappings.put(IPCPacket0DProgressUpdate.ID, () -> new IPCPacket0DProgressUpdate());
mappings.put(IPCPacket0EListWorlds.ID, () -> new IPCPacket0EListWorlds());
mappings.put(IPCPacket0FListFiles.ID, () -> new IPCPacket0FListFiles());
mappings.put(IPCPacket10FileRead.ID, () -> new IPCPacket10FileRead());
mappings.put(IPCPacket12FileWrite.ID, () -> new IPCPacket12FileWrite());
mappings.put(IPCPacket13FileCopyMove.ID, () -> new IPCPacket13FileCopyMove());
mappings.put(IPCPacket14StringList.ID, () -> new IPCPacket14StringList());
mappings.put(IPCPacket15Crashed.ID, () -> new IPCPacket15Crashed());
mappings.put(IPCPacket16NBTList.ID, () -> new IPCPacket16NBTList());
mappings.put(IPCPacket17ConfigureLAN.ID, () -> new IPCPacket17ConfigureLAN());
mappings.put(IPCPacket18ClearPlayers.ID, () -> new IPCPacket18ClearPlayers());
mappings.put(IPCPacket19Autosave.ID, () -> new IPCPacket19Autosave());
mappings.put(IPCPacket20LoggerMessage.ID, () -> new IPCPacket20LoggerMessage());
mappings.put(IPCPacket21EnableLogging.ID, () -> new IPCPacket21EnableLogging());
mappings.put(IPCPacketFFProcessKeepAlive.ID, () -> new IPCPacketFFProcessKeepAlive());
mappings.put(IPCPacket00StartServer.ID, IPCPacket00StartServer::new);
mappings.put(IPCPacket01StopServer.ID, IPCPacket01StopServer::new);
mappings.put(IPCPacket02InitWorld.ID, IPCPacket02InitWorld::new);
mappings.put(IPCPacket03DeleteWorld.ID, IPCPacket03DeleteWorld::new);
mappings.put(IPCPacket05RequestData.ID, IPCPacket05RequestData::new);
mappings.put(IPCPacket06RenameWorldNBT.ID, IPCPacket06RenameWorldNBT::new);
mappings.put(IPCPacket07ImportWorld.ID, IPCPacket07ImportWorld::new);
mappings.put(IPCPacket09RequestResponse.ID, IPCPacket09RequestResponse::new);
mappings.put(IPCPacket0ASetWorldDifficulty.ID, IPCPacket0ASetWorldDifficulty::new);
mappings.put(IPCPacket0BPause.ID, IPCPacket0BPause::new);
mappings.put(IPCPacket0CPlayerChannel.ID, IPCPacket0CPlayerChannel::new);
mappings.put(IPCPacket0DProgressUpdate.ID, IPCPacket0DProgressUpdate::new);
mappings.put(IPCPacket0EListWorlds.ID, IPCPacket0EListWorlds::new);
mappings.put(IPCPacket0FListFiles.ID, IPCPacket0FListFiles::new);
mappings.put(IPCPacket10FileRead.ID, IPCPacket10FileRead::new);
mappings.put(IPCPacket12FileWrite.ID, IPCPacket12FileWrite::new);
mappings.put(IPCPacket13FileCopyMove.ID, IPCPacket13FileCopyMove::new);
mappings.put(IPCPacket14StringList.ID, IPCPacket14StringList::new);
mappings.put(IPCPacket15Crashed.ID, IPCPacket15Crashed::new);
mappings.put(IPCPacket16NBTList.ID, IPCPacket16NBTList::new);
mappings.put(IPCPacket17ConfigureLAN.ID, IPCPacket17ConfigureLAN::new);
mappings.put(IPCPacket18ClearPlayers.ID, IPCPacket18ClearPlayers::new);
mappings.put(IPCPacket19Autosave.ID, IPCPacket19Autosave::new);
mappings.put(IPCPacket20LoggerMessage.ID, IPCPacket20LoggerMessage::new);
mappings.put(IPCPacket21EnableLogging.ID, IPCPacket21EnableLogging::new);
mappings.put(IPCPacketFFProcessKeepAlive.ID, IPCPacketFFProcessKeepAlive::new);
}
public static byte[] IPCSerialize(IPCPacketBase pkt) throws IOException {

View File

@ -1,7 +1,9 @@
package net.lax1dude.eaglercraft.v1_8.sp.lan;
import net.lax1dude.eaglercraft.v1_8.EagUtils;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerZLIB;
import net.lax1dude.eaglercraft.v1_8.IOUtils;
import net.lax1dude.eaglercraft.v1_8.internal.EnumEaglerConnectionState;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformWebRTC;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
@ -17,7 +19,6 @@ import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.IChatComponent;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@ -299,7 +300,8 @@ public class LANClientNetworkManager extends EaglercraftNetworkManager {
if(packets == null) {
return;
}
for(byte[] data : packets) {
for(int k = 0, l = packets.size(); k < l; ++k) {
byte[] data = packets.get(k);
byte[] fullData;
boolean compressed = false;
@ -336,11 +338,14 @@ public class LANClientNetworkManager extends EaglercraftNetworkManager {
if(fullData.length < 4) {
throw new IOException("Recieved invalid " + fullData.length + " byte compressed packet");
}
ByteArrayInputStream bi = new ByteArrayInputStream(fullData);
EaglerInputStream bi = new EaglerInputStream(fullData);
int i = (bi.read() << 24) | (bi.read() << 16) | (bi.read() << 8) | bi.read();
InputStream inflaterInputStream = EaglerZLIB.newInflaterInputStream(bi);
fullData = new byte[i];
inflaterInputStream.read(fullData);
int r = IOUtils.readFully(inflaterInputStream, fullData);
if (i != r) {
logger.warn("Decompressed packet expected size {} differs from actual size {}!", i, r);
}
}
if(firstPacket) {

View File

@ -1,6 +1,6 @@
package net.lax1dude.eaglercraft.v1_8.sp.relay;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
@ -9,6 +9,9 @@ import java.util.function.Consumer;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EagUtils;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.ThreadLocalRandom;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.sp.relay.pkt.IPacket;
@ -42,8 +45,46 @@ public class RelayManager {
private final List<RelayServer> relays = new ArrayList();
private long lastPingThrough = 0l;
public void load(NBTTagList relayConfig) {
public void load(byte[] relayConfig) {
NBTTagCompound relays = null;
if(relayConfig != null) {
try {
relays = CompressedStreamTools.readCompressed(new EaglerInputStream(relayConfig));
} catch (IOException ex) {
}
}
if(relays != null && relays.hasKey("relays", 9)) {
load(relays.getTagList("relays", 10));
if(!relays.getBoolean("f")) {
fixBullshit();
}
}else {
sort(); // loads defaults
save();
}
}
// versions pre-u24 always have "relay.deev.is" as primary due to a glitch
// this function is intended to randomize the list if that is detected
private void fixBullshit() {
if(!relays.isEmpty()) {
for(int i = 0, l = relays.size(); i < l; ++i) {
RelayServer rs = relays.get(i);
if(rs.address.equalsIgnoreCase("wss://relay.deev.is/") && !rs.isPrimary()) {
return;
}
}
for(int i = 0, l = relays.size(); i < l; ++i) {
relays.get(i).setPrimary(false);
}
relays.get(ThreadLocalRandom.current().nextInt(relays.size())).setPrimary(true);
sort();
save();
}
}
private void load(NBTTagList relayConfig) {
relays.clear();
if(relayConfig != null && relayConfig.tagCount() > 0) {
boolean gotAPrimary = false;
@ -64,6 +105,16 @@ public class RelayManager {
}
public void save() {
if(relays.isEmpty()) {
return;
}
byte[] data = write();
if(data != null) {
EagRuntime.setStorage("r", data);
}
}
public byte[] write() {
try {
NBTTagList lst = new NBTTagList();
for(int i = 0, l = relays.size(); i < l; ++i) {
@ -77,17 +128,25 @@ public class RelayManager {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setTag("relays", lst);
nbttagcompound.setBoolean("f", true);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
EaglerOutputStream bao = new EaglerOutputStream();
CompressedStreamTools.writeCompressed(nbttagcompound, bao);
EagRuntime.setStorage("r", bao.toByteArray());
return bao.toByteArray();
} catch (Exception exception) {
logger.error("Couldn\'t save relay list!");
logger.error(exception);
return null;
}
}
private void sort() {
if(relays.isEmpty()) {
List<RelayEntry> defaultRelays = EagRuntime.getConfiguration().getRelays();
for(int i = 0, l = defaultRelays.size(); i < l; ++i) {
relays.add(new RelayServer(defaultRelays.get(i)));
}
}
if(relays.isEmpty()) {
return;
}
@ -315,16 +374,17 @@ public class RelayManager {
}
public void loadDefaults() {
int setPrimary = relays.size();
eee: for(RelayEntry etr : EagRuntime.getConfiguration().getRelays()) {
for(RelayServer exEtr : relays) {
if(exEtr.address.equalsIgnoreCase(etr.address)) {
List<RelayEntry> defaultRelays = EagRuntime.getConfiguration().getRelays();
eee: for(int i = 0, l = defaultRelays.size(); i < l; ++i) {
RelayEntry etr = defaultRelays.get(i);
for(int j = 0, l2 = relays.size(); j < l2; ++j) {
if(relays.get(j).address.equalsIgnoreCase(etr.address)) {
continue eee;
}
}
relays.add(new RelayServer(etr));
}
setPrimary(setPrimary);
sort();
}
public String makeNewRelayName() {

View File

@ -1,6 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.sp.relay.pkt;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@ -9,6 +8,7 @@ import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
@ -73,8 +73,8 @@ public class IPacket {
Integer i = definedPacketIds.get(packet.getClass());
if(i != null) {
int len = packet.packetLength();
ByteArrayOutputStream bao = len == -1 ? new ByteArrayOutputStream() :
new ByteArrayOutputStream(len + 1);
EaglerOutputStream bao = len == -1 ? new EaglerOutputStream() :
new EaglerOutputStream(len + 1);
bao.write(i);
packet.write(new DataOutputStream(bao));
byte[] ret = bao.toByteArray();

View File

@ -88,8 +88,8 @@ public class EaglerIntegratedServerWorker {
public static void tick() {
List<IntegratedServerPlayerNetworkManager> ocs = new ArrayList<>(openChannels.values());
for(IntegratedServerPlayerNetworkManager i : ocs) {
i.tick();
for(int i = 0, l = ocs.size(); i < l; ++i) {
ocs.get(i).tick();
}
}
@ -147,8 +147,8 @@ public class EaglerIntegratedServerWorker {
EaglerSaveFormat.worldsList.setAllChars(pkt.worldName);
}else {
boolean found = false;
for(String s : worlds) {
if(s.equals(pkt.worldName)) {
for(int i = 0; i < worlds.length; ++i) {
if(worlds[i].equals(pkt.worldName)) {
found = true;
break;
}
@ -196,7 +196,8 @@ public class EaglerIntegratedServerWorker {
String[] worldsTxt = EaglerSaveFormat.worldsList.getAllLines();
if(worldsTxt != null) {
List<String> newWorlds = new ArrayList();
for(String str : worldsTxt) {
for(int i = 0; i < worldsTxt.length; ++i) {
String str = worldsTxt[i];
if(!str.equalsIgnoreCase(pkt.worldName)) {
newWorlds.add(str);
}

View File

@ -90,7 +90,9 @@ public class EaglerSaveFormat extends SaveFormatOld {
int totalSize = 0;
int lastUpdate = 0;
final VFile2 finalNewFolder = newFolder;
for(VFile2 vf : oldFolder.listFiles(true)) {
List<VFile2> vfl = oldFolder.listFiles(true);
for(int i = 0, l = vfl.size(); i < l; ++i) {
VFile2 vf = vfl.get(i);
String fileNameRelative = vf.getPath().substring(oldPath.length() + 1);
totalSize += VFile2.copyFile(vf, new VFile2(finalNewFolder, fileNameRelative));
if (totalSize - lastUpdate > 10000) {

View File

@ -1,6 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.sp.server.export;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
@ -9,6 +8,7 @@ import java.util.Date;
import java.util.zip.CRC32;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
/**
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
@ -27,13 +27,13 @@ import net.lax1dude.eaglercraft.v1_8.EagRuntime;
*/
public class EPKCompiler {
private final ByteArrayOutputStream os;
private final EaglerOutputStream os;
private final CRC32 checkSum = new CRC32();
private int lengthIntegerOffset = 0;
private int totalFileCount = 0;
public EPKCompiler(String name, String owner, String type) {
os = new ByteArrayOutputStream(0x200000);
os = new EaglerOutputStream(0x200000);
try {
os.write(new byte[]{(byte)69,(byte)65,(byte)71,(byte)80,(byte)75,(byte)71,(byte)36,(byte)36}); // EAGPKG$$

View File

@ -7,6 +7,7 @@ import java.util.Arrays;
import java.util.zip.CRC32;
import net.lax1dude.eaglercraft.v1_8.EaglerZLIB;
import net.lax1dude.eaglercraft.v1_8.IOUtils;
/**
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
@ -46,7 +47,7 @@ public class EPKDecompiler {
in2 = new ByteArrayInputStream(data);
byte[] header = new byte[8];
in2.read(header);
IOUtils.readFully(in2, header);
if(Arrays.equals(header, new byte[]{(byte)69,(byte)65,(byte)71,(byte)80,(byte)75,(byte)71,(byte)36,(byte)36})) {
byte[] endCode = new byte[] { (byte)':', (byte)':', (byte)':', (byte)'Y',
@ -63,10 +64,10 @@ public class EPKDecompiler {
if(!vers.startsWith("ver2.")) {
throw new IOException("Unknown or invalid EPK version: " + vers);
}
is.skip(is.read()); // skip filename
is.skip(loadShort(is)); // skip comment
is.skip(8); // skip millis date
IOUtils.skipFully(is, is.read()); // skip filename
IOUtils.skipFully(is, loadShort(is)); // skip comment
IOUtils.skipFully(is, 8); // skip millis date
numFiles = loadInt(is);
@ -101,7 +102,7 @@ public class EPKDecompiler {
}
byte[] typeBytes = new byte[4];
zis.read(typeBytes);
IOUtils.readFully(zis, typeBytes);
String type = readASCII(typeBytes);
if(numFiles == 0) {
@ -126,7 +127,7 @@ public class EPKDecompiler {
int loadedCrc = loadInt(zis);
data = new byte[len - 5];
zis.read(data);
IOUtils.readFully(zis, data);
crc32.reset();
crc32.update(data, 0, data.length);
@ -139,7 +140,7 @@ public class EPKDecompiler {
}
}else {
data = new byte[len];
zis.read(data);
IOUtils.readFully(zis, data);
}
if(zis.read() != '>') {
@ -152,11 +153,11 @@ public class EPKDecompiler {
}
}
private static final int loadShort(InputStream is) throws IOException {
public static final int loadShort(InputStream is) throws IOException {
return (is.read() << 8) | is.read();
}
private static final int loadInt(InputStream is) throws IOException {
public static final int loadInt(InputStream is) throws IOException {
return (is.read() << 24) | (is.read() << 16) | (is.read() << 8) | is.read();
}
@ -168,7 +169,7 @@ public class EPKDecompiler {
return new String(charIn);
}
private static final String readASCII(InputStream bytesIn) throws IOException {
public static final String readASCII(InputStream bytesIn) throws IOException {
int len = bytesIn.read();
char[] charIn = new char[len];
for(int i = 0; i < len; ++i) {

View File

@ -1,9 +1,10 @@
package net.lax1dude.eaglercraft.v1_8.sp.server.export;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.internal.vfs2.VFile2;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
@ -62,10 +63,10 @@ public class WorldConverterEPK {
}
if(f.type.equals("FILE")) {
if(f.name.equals("level.dat") || f.name.equals("level.dat_old")) {
NBTTagCompound worldDatNBT = CompressedStreamTools.readCompressed(new ByteArrayInputStream(b));
NBTTagCompound worldDatNBT = CompressedStreamTools.readCompressed(new EaglerInputStream(b));
worldDatNBT.getCompoundTag("Data").setString("LevelName", newName);
worldDatNBT.getCompoundTag("Data").setLong("LastPlayed", System.currentTimeMillis());
ByteArrayOutputStream tmp = new ByteArrayOutputStream();
EaglerOutputStream tmp = new EaglerOutputStream();
CompressedStreamTools.writeCompressed(worldDatNBT, tmp);
b = tmp.toByteArray();
}
@ -109,7 +110,9 @@ public class WorldConverterEPK {
final int[] lastUpdate = new int[1];
EPKCompiler c = new EPKCompiler(realWorldName, worldOwner, "epk/world188");
String pfx = worldDir.getPath();
for(VFile2 vf : worldDir.listFiles(true)) {
List<VFile2> filesList = worldDir.listFiles(true);
for(int i = 0, l = filesList.size(); i < l; ++i) {
VFile2 vf = filesList.get(i);
++filesWritten[0];
byte[] b = vf.getAllBytes();
c.append(vf.getPath().substring(pfx.length() + 1), b);

View File

@ -1,7 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.sp.server.export;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@ -13,6 +11,8 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.internal.vfs2.VFile2;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
@ -50,7 +50,7 @@ public class WorldConverterMCA {
folderName += "_";
worldDir = EaglerIntegratedServerWorker.saveFormat.getSaveLoader(folderName, false).getWorldDirectory();
}
ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(archiveContents));
ZipInputStream zis = new ZipInputStream(new EaglerInputStream(archiveContents));
ZipEntry folderNameFile = null;
List<char[]> fileNames = new ArrayList<>();
while((folderNameFile = zis.getNextEntry()) != null) {
@ -63,7 +63,7 @@ public class WorldConverterMCA {
final int[] i = new int[] { 0 };
while(fileNames.get(0).length > i[0] && fileNames.stream().allMatch(w -> w[i[0]] == fileNames.get(0)[i[0]])) i[0]++;
int folderPrefixOffset = i[0];
zis = new ZipInputStream(new ByteArrayInputStream(archiveContents));
zis = new ZipInputStream(new EaglerInputStream(archiveContents));
ZipEntry f = null;
int lastProgUpdate = 0;
int prog = 0;
@ -73,7 +73,7 @@ public class WorldConverterMCA {
if (f.isDirectory()) continue;
String lowerName = f.getName().toLowerCase();
if (!(lowerName.endsWith(".dat") || lowerName.endsWith(".dat_old") || lowerName.endsWith(".mca") || lowerName.endsWith(".mcr") || lowerName.endsWith(".bmp"))) continue;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
EaglerOutputStream baos = new EaglerOutputStream();
int len;
while ((len = zis.read(bb)) != -1) {
baos.write(bb, 0, len);
@ -82,7 +82,7 @@ public class WorldConverterMCA {
byte[] b = baos.toByteArray();
String fileName = f.getName().substring(folderPrefixOffset);
if (fileName.equals("level.dat") || fileName.equals("level.dat_old")) {
NBTTagCompound worldDatNBT = CompressedStreamTools.readCompressed(new ByteArrayInputStream(b));
NBTTagCompound worldDatNBT = CompressedStreamTools.readCompressed(new EaglerInputStream(b));
NBTTagCompound gameRulesNBT = worldDatNBT.getCompoundTag("Data").getCompoundTag("GameRules");
gameRulesNBT.setString("loadSpawnChunks", (gameRules & 2) != 0 ? "true" : "false");
@ -96,7 +96,7 @@ public class WorldConverterMCA {
worldDatNBT.getCompoundTag("Data").setString("LevelName", newName);
worldDatNBT.getCompoundTag("Data").setLong("LastPlayed", System.currentTimeMillis());
ByteArrayOutputStream bo = new ByteArrayOutputStream();
EaglerOutputStream bo = new EaglerOutputStream();
CompressedStreamTools.writeCompressed(worldDatNBT, bo);
b = bo.toByteArray();
VFile2 ff = new VFile2(worldDir, fileName);
@ -129,7 +129,7 @@ public class WorldConverterMCA {
logger.error("{}: Chunk already exists: {}", fileName, chunkOut.getPath());
continue;
}
ByteArrayOutputStream bao = new ByteArrayOutputStream();
EaglerOutputStream bao = new EaglerOutputStream();
CompressedStreamTools.writeCompressed(chunkNBT, bao);
b = bao.toByteArray();
chunkOut.setAllBytes(b);
@ -171,7 +171,7 @@ public class WorldConverterMCA {
}
public static byte[] exportWorld(String folderName) throws IOException {
ByteArrayOutputStream bao = new ByteArrayOutputStream();
EaglerOutputStream bao = new EaglerOutputStream();
ZipOutputStream zos = new ZipOutputStream(bao);
zos.setComment("contains backup of world '" + folderName + "'");
VFile2 worldFolder = EaglerIntegratedServerWorker.saveFormat.getSaveLoader(folderName, false).getWorldDirectory();
@ -209,12 +209,13 @@ public class WorldConverterMCA {
String regionFolder = folderName + dstFolderNames[i];
logger.info("Converting chunks in \"{}\" as MCA to \"{}\"...", vf.getPath(), regionFolder);
Map<String,RegionFile> regionFiles = new HashMap();
for(VFile2 chunkFile : fileList) {
for(int k = 0, l = fileList.size(); k < l; ++k) {
VFile2 chunkFile = fileList.get(k);
NBTTagCompound chunkNBT;
NBTTagCompound chunkLevel;
try {
b = chunkFile.getAllBytes();
chunkNBT = CompressedStreamTools.readCompressed(new ByteArrayInputStream(b));
chunkNBT = CompressedStreamTools.readCompressed(new EaglerInputStream(b));
if(!chunkNBT.hasKey("Level", 10)) {
throw new IOException("Chunk is missing level data!");
}
@ -258,7 +259,8 @@ public class WorldConverterMCA {
}
logger.info("Copying extra world data...");
fileList = (new VFile2(worldFolder, "data")).listFiles(false);
for(VFile2 dataFile : fileList) {
for(int k = 0, l = fileList.size(); k < l; ++k) {
VFile2 dataFile = fileList.get(k);
zos.putNextEntry(new ZipEntry(folderName + "/data/" + dataFile.getName()));
b = dataFile.getAllBytes();
zos.write(b);
@ -269,7 +271,8 @@ public class WorldConverterMCA {
}
}
fileList = (new VFile2(worldFolder, "players")).listFiles(false);
for(VFile2 dataFile : fileList) {
for(int k = 0, l = fileList.size(); k < l; ++k) {
VFile2 dataFile = fileList.get(k);
zos.putNextEntry(new ZipEntry(folderName + "/players/" + dataFile.getName()));
b = dataFile.getAllBytes();
zos.write(b);
@ -280,7 +283,8 @@ public class WorldConverterMCA {
}
}
fileList = (new VFile2(worldFolder, "eagler/skulls")).listFiles(false);
for(VFile2 dataFile : fileList) {
for(int k = 0, l = fileList.size(); k < l; ++k) {
VFile2 dataFile = fileList.get(k);
zos.putNextEntry(new ZipEntry(folderName + "/eagler/skulls/" + dataFile.getName()));
b = dataFile.getAllBytes();
zos.write(b);

View File

@ -1,12 +1,12 @@
package net.lax1dude.eaglercraft.v1_8.sp.server.socket;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerZLIB;
import net.lax1dude.eaglercraft.v1_8.internal.EnumEaglerConnectionState;
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
@ -48,7 +48,7 @@ public class IntegratedServerPlayerNetworkManager {
public final String playerChannel;
private EnumConnectionState packetState = EnumConnectionState.HANDSHAKING;
private static PacketBuffer temporaryBuffer;
private static ByteArrayOutputStream temporaryOutputStream;
private static EaglerOutputStream temporaryOutputStream;
private int debugPacketCounter = 0;
private byte[][] recievedPacketBuffer = new byte[16384][];
private int recievedPacketBufferCounter = 0;
@ -71,7 +71,7 @@ public class IntegratedServerPlayerNetworkManager {
this.enableSendCompression = !SingleplayerServerController.PLAYER_CHANNEL.equals(playerChannel);
if(this.enableSendCompression) {
if(temporaryOutputStream == null) {
temporaryOutputStream = new ByteArrayOutputStream(16386);
temporaryOutputStream = new EaglerOutputStream(16386);
}
}
}
@ -115,7 +115,7 @@ public class IntegratedServerPlayerNetworkManager {
if(enableSendCompression) {
if(firstPacket) {
if(data.length > 2 && data[0] == (byte)0x02 && data[1] == (byte)0x3D) {
ByteArrayOutputStream kickPacketBAO = new ByteArrayOutputStream();
EaglerOutputStream kickPacketBAO = new EaglerOutputStream();
try {
DataOutputStream kickDAO = new DataOutputStream(kickPacketBAO);
kickDAO.write(0);

View File

@ -10,7 +10,6 @@ import net.lax1dude.eaglercraft.v1_8.socket.EaglercraftNetworkManager;
import net.lax1dude.eaglercraft.v1_8.sp.SingleplayerServerController;
import net.lax1dude.eaglercraft.v1_8.sp.internal.ClientPlatformSingleplayer;
import net.lax1dude.eaglercraft.v1_8.sp.lan.LANServerController;
import net.minecraft.network.EnumConnectionState;
import net.minecraft.network.EnumPacketDirection;
import net.minecraft.network.Packet;
import net.minecraft.network.PacketBuffer;

View File

@ -1,6 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.update;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.sp.lan.LANServerController;

View File

@ -1,8 +1,6 @@
package net.lax1dude.eaglercraft.v1_8.update;
import java.io.IOException;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;

View File

@ -1,7 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.update;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@ -9,6 +7,8 @@ import java.util.ArrayList;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformApplication;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformWebRTC;
import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayManager;
@ -67,7 +67,7 @@ public class RelayUpdateChecker {
byte[] b = PlatformApplication.getLocalStorage("lastRelayUpdate");
if(b != null) {
try {
lastUpdateCheck = (new DataInputStream(new ByteArrayInputStream(b))).readLong();
lastUpdateCheck = (new DataInputStream(new EaglerInputStream(b))).readLong();
} catch (IOException e) {
}
}
@ -77,7 +77,7 @@ public class RelayUpdateChecker {
if((mc.theWorld == null || mc.isSingleplayer()) && millis - lastUpdateCheck > updateCheckRate) {
lastUpdateCheck = millis;
try {
ByteArrayOutputStream bao = new ByteArrayOutputStream(8);
EaglerOutputStream bao = new EaglerOutputStream(8);
(new DataOutputStream(bao)).writeLong(lastUpdateCheck);
PlatformApplication.setLocalStorage("lastRelayUpdate", bao.toByteArray());
} catch (IOException e) {

View File

@ -1,6 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.update;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
@ -11,8 +10,10 @@ import java.util.Objects;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder.ListMultimapBuilder;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerZLIB;
import net.lax1dude.eaglercraft.v1_8.EaglercraftVersion;
import net.lax1dude.eaglercraft.v1_8.IOUtils;
import net.lax1dude.eaglercraft.v1_8.crypto.SHA256Digest;
/**
@ -78,7 +79,7 @@ public class UpdateCertificate {
public final DLSource[] bundleDataSources;
public static UpdateCertificate parseAndVerifyCertificate(byte[] certData) throws IOException, CertificateInvalidException {
InputStream is = new ByteArrayInputStream(certData);
InputStream is = new EaglerInputStream(certData);
if(is.read() != 'E' || is.read() != 'A' || is.read() != 'G' || is.read() != 'S' || is.read() != 'I' || is.read() != 'G') {
throw new IOException("Data is not a certificate!");
}
@ -90,7 +91,7 @@ public class UpdateCertificate {
}
byte[] rsa2048sum = new byte[256];
is.read(rsa2048sum);
IOUtils.readFully(is, rsa2048sum);
byte[] rsa2048sumDec = (new BigInteger(rsa2048sum)).modPow(new BigInteger("65537"), EaglercraftVersion.updateSignatureModulus).toByteArray();
@ -108,7 +109,7 @@ public class UpdateCertificate {
payloadLen |= is.read();
byte[] signaturePayload = new byte[payloadLen];
is.read(signaturePayload);
IOUtils.readFully(is, signaturePayload);
SHA256Digest sha256 = new SHA256Digest();
sha256.update(new byte[] { (byte) 170, (byte) 191, (byte) 203, (byte) 188, (byte) 47, (byte) 37, (byte) 17,
@ -147,7 +148,7 @@ public class UpdateCertificate {
throw new CertificateInvalidException("SHA256 checksum of signature payload is invalid!");
}
return new UpdateCertificate(certData, EaglerZLIB.newGZIPInputStream(new ByteArrayInputStream(signaturePayload)), vers);
return new UpdateCertificate(certData, EaglerZLIB.newGZIPInputStream(new EaglerInputStream(signaturePayload)), vers);
}
private UpdateCertificate(byte[] certData, InputStream is, int sigVers) throws IOException {
@ -157,18 +158,18 @@ public class UpdateCertificate {
this.sigTimestamp = dis.readLong();
this.bundleDataLength = dis.readInt();
this.bundleDataHash = new byte[32];
dis.read(bundleDataHash);
IOUtils.readFully(dis, bundleDataHash);
this.bundlePackageName = dis.readUTF();
this.bundleDisplayName = dis.readUTF();
this.bundleAuthorName = dis.readUTF();
this.bundleVersionInteger = dis.readInt();
this.bundleDisplayVersion = dis.readUTF();
this.bundleVersionComment = dis.readUTF();
dis.skip(dis.read());
IOUtils.skipFully(dis, dis.read());
int sourceCount = dis.readInt();
this.bundleDataSources = new DLSource[sourceCount];
for(int i = 0; i < sourceCount; ++i) {
dis.skip(4);
IOUtils.skipFully(dis, 4);
bundleDataSources[i] = new DLSource(dis.readUTF(), dis.readUTF());
}
}

View File

@ -1,22 +0,0 @@
package net.lax1dude.eaglercraft.v1_8.vfs;
/**
* Copyright (c) 2022-2023 lax1dude, ayunami2000. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class FolderResourcePack extends net.lax1dude.eaglercraft.v1_8.internal.vfs.FolderResourcePack {
public FolderResourcePack(String resourcePackFileIn, String prefix) {
super(resourcePackFileIn, prefix);
}
}

View File

@ -1,19 +0,0 @@
package net.lax1dude.eaglercraft.v1_8.vfs;
/**
* Copyright (c) 2022-2023 lax1dude, ayunami2000. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class SYS extends net.lax1dude.eaglercraft.v1_8.internal.vfs.SYS {
}

View File

@ -1,5 +1,7 @@
package net.minecraft.block;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.minecraft.block.material.Material;
@ -129,7 +131,9 @@ public class BlockBed extends BlockDirectional {
}
private EntityPlayer getPlayerInBed(World worldIn, BlockPos pos) {
for (EntityPlayer entityplayer : worldIn.playerEntities) {
List<EntityPlayer> playerEntities = worldIn.playerEntities;
for (int i = 0, l = playerEntities.size(); i < l; ++i) {
EntityPlayer entityplayer = playerEntities.get(i);
if (entityplayer.isPlayerSleeping() && entityplayer.playerLocation.equals(pos)) {
return entityplayer;
}

View File

@ -84,7 +84,9 @@ public abstract class BlockButton extends Block {
}
public boolean canPlaceBlockAt(World world, BlockPos blockpos) {
for (EnumFacing enumfacing : EnumFacing.values()) {
EnumFacing[] facings = EnumFacing._VALUES;
for (int i = 0; i < facings.length; ++i) {
EnumFacing enumfacing = facings[i];
if (func_181088_a(world, blockpos, enumfacing)) {
return true;
}

View File

@ -111,7 +111,9 @@ public class BlockCactus extends Block {
}
public boolean canBlockStay(World worldIn, BlockPos pos) {
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) {
EnumFacing[] facings = EnumFacing.Plane.HORIZONTAL.facingsArray;
for (int i = 0; i < facings.length; ++i) {
EnumFacing enumfacing = facings[i];
if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getMaterial().isSolid()) {
return false;
}

View File

@ -1,5 +1,7 @@
package net.minecraft.block;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
@ -96,7 +98,9 @@ public class BlockChest extends BlockContainer {
public void onBlockAdded(World world, BlockPos blockpos, IBlockState iblockstate) {
this.checkForSurroundingChests(world, blockpos, iblockstate);
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) {
EnumFacing[] facings = EnumFacing.Plane.HORIZONTAL.facings();
for (int i = 0; i < facings.length; ++i) {
EnumFacing enumfacing = facings[i];
BlockPos blockpos1 = blockpos.offset(enumfacing);
IBlockState iblockstate1 = world.getBlockState(blockpos1);
if (iblockstate1.getBlock() == this) {
@ -241,7 +245,9 @@ public class BlockChest extends BlockContainer {
public IBlockState correctFacing(World worldIn, BlockPos pos, IBlockState state) {
EnumFacing enumfacing = null;
for (EnumFacing enumfacing1 : EnumFacing.Plane.HORIZONTAL) {
EnumFacing[] facings = EnumFacing.Plane.HORIZONTAL.facingsArray;
for (int i = 0; i < facings.length; ++i) {
EnumFacing enumfacing1 = facings[i];
IBlockState iblockstate = worldIn.getBlockState(pos.offset(enumfacing1));
if (iblockstate.getBlock() == this) {
return state;
@ -322,7 +328,9 @@ public class BlockChest extends BlockContainer {
if (worldIn.getBlockState(pos).getBlock() != this) {
return false;
} else {
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) {
EnumFacing[] facings = EnumFacing.Plane.HORIZONTAL.facingsArray;
for (int i = 0; i < facings.length; ++i) {
EnumFacing enumfacing = facings[i];
if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock() == this) {
return true;
}
@ -380,7 +388,9 @@ public class BlockChest extends BlockContainer {
if (this.isBlocked(worldIn, pos)) {
return null;
} else {
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) {
EnumFacing[] facings = EnumFacing.Plane.HORIZONTAL.facingsArray;
for (int i = 0; i < facings.length; ++i) {
EnumFacing enumfacing = facings[i];
BlockPos blockpos = pos.offset(enumfacing);
Block block = worldIn.getBlockState(blockpos).getBlock();
if (block == this) {
@ -450,9 +460,11 @@ public class BlockChest extends BlockContainer {
}
private boolean isOcelotSittingOnChest(World worldIn, BlockPos pos) {
for (Entity entity : worldIn.getEntitiesWithinAABB(EntityOcelot.class,
List<Entity> entityList = worldIn.getEntitiesWithinAABB(EntityOcelot.class,
new AxisAlignedBB((double) pos.getX(), (double) (pos.getY() + 1), (double) pos.getZ(),
(double) (pos.getX() + 1), (double) (pos.getY() + 2), (double) (pos.getZ() + 1)))) {
(double) (pos.getX() + 1), (double) (pos.getY() + 2), (double) (pos.getZ() + 1)));
for (int i = 0, l = entityList.size(); i < l; ++i) {
Entity entity = entityList.get(i);
EntityOcelot entityocelot = (EntityOcelot) entity;
if (entityocelot.isSitting()) {
return true;

View File

@ -58,7 +58,9 @@ public class BlockColored extends Block {
* (eg: wood returns 4 blocks)
*/
public void getSubBlocks(Item item, CreativeTabs var2, List<ItemStack> list) {
for (EnumDyeColor enumdyecolor : EnumDyeColor.values()) {
EnumDyeColor[] colors = EnumDyeColor.META_LOOKUP;
for (int i = 0; i < colors.length; ++i) {
EnumDyeColor enumdyecolor = colors[i];
list.add(new ItemStack(item, 1, enumdyecolor.getMetadata()));
}

Some files were not shown because too many files have changed in this diff Show More