1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-22 08:58:47 +00:00

games/minecraft-client: Use OpenJDK8 to fix spawning problem

PR:		189028
Submitted by:	Sean Bruno
Fix by:		Kris Moore
This commit is contained in:
John Marino 2014-06-20 10:45:11 +00:00
parent 65d20699b6
commit 4291c97b9e
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=358549
5 changed files with 130 additions and 42 deletions

View File

@ -3,6 +3,7 @@
PORTNAME= minecraft-client
PORTVERSION= 1.7.9
PORTREVISION= 1
CATEGORIES= games java
MASTER_SITES= http://s3.amazonaws.com/Minecraft.Download/launcher/:minecraft \
http://media-mcw.cursecdn.com/c/c5/:icon
@ -14,12 +15,15 @@ EXTRACT_ONLY=
MAINTAINER= ports@FreeBSD.org
COMMENT= Client for the block building game
RUN_DEPENDS= ${JAVALIBDIR}/lwjgl/lwjgl.jar:${PORTSDIR}/games/lwjgl \
bash:${PORTSDIR}/shells/bash
WRKSRC= ${WRKDIR}
NO_BUILD= yes
USE_JAVA= yes
JAVA_OS= native
JAVA_VENDOR= openjdk
JAVA_VERSION= 1.7+
JAVA_VERSION= 1.8+
DESKTOP_ENTRIES="Minecraft" \
"Block building game" \
"${PREFIX}/share/pixmaps/minecraft-client.png" \
@ -38,5 +42,7 @@ do-install:
-e 's|JAVA_CMD|${JAVA}|' ${FILESDIR}/minecraft-client \
> ${WRKDIR}/minecraft-client
${INSTALL_SCRIPT} ${WRKDIR}/minecraft-client ${STAGEDIR}${PREFIX}/bin
${INSTALL_SCRIPT} ${FILESDIR}/minecraft-runtime ${STAGEDIR}${DATADIR}
${INSTALL_DATA} ${FILESDIR}/Notifer.java ${STAGEDIR}${DATADIR}
.include <bsd.port.mk>

View File

@ -0,0 +1,40 @@
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.Icon;
import java.awt.EventQueue;
public class Notifer extends JFrame{
//Using a standard Java icon
private Icon optionIcon = UIManager.getIcon("FileView.computerIcon");
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable()
{
public void run()
{
//create GUI frame
new Notifer().setVisible(true);
}
});
}
public Notifer()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//setTitle("Simple Dialog Box Example");
//setSize(500,500);
setLocationRelativeTo(null);
// Show our warning to first time users
JOptionPane.showMessageDialog(this, "After the first time logging in with a new user, you will need to close the Minecraft Launcher and restart before the game will run."
,"Important Notification", JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}

View File

@ -1,50 +1,44 @@
#!/bin/sh
export JAVA_HOME=JAVA_HOME
/bin/cat << EOF
When starting a version for the first time, select the version you want in your
profile, start Minecraft, close Minecraft and launcher, run minecraft-client
again, then select version "x-freebsd" in your profile.
If you run versions older than 1.6.1 in the Launcher, add
-Djava.net.preferIPv4Stack=true to JVM Arguments in the profile.
# Look for launcher_profiles to fix
if [ -e "${HOME}/.minecraft/launcher_profiles.json" ] ; then
rm ${HOME}/.minecraft/launcher_profiles.json.new 2>/dev/null
EOF
LIBDIR="${HOME}/.minecraft/libraries/"
# Lets make sure we set the fixed java executable script
while IFS='' read -r line
do
# Skip old javaDir lines
echo $line | grep -q '"javaDir": "'
if [ $? -eq 0 ] ; then continue ; fi
for i in ${LIBDIR}/org/lwjgl/lwjgl/lwjgl-platform/*/lwjgl-platform-*-natives-linux.jar; do
if [ -f "${i}" ]; then
cmp -s "PREFIX/share/minecraft-client/lwjgl-native-libs.jar" "${i%linux.jar}freebsd.jar"
if [ $? -ne 0 ]; then
cp -v "PREFIX/share/minecraft-client/lwjgl-native-libs.jar" "${i%linux.jar}freebsd.jar"
fi
fi
done
# If not a name line, add and continue
echo $line | grep -q '"name": "'
if [ $? -ne 0 ] ; then
printf "%s\n" "$line" >> ${HOME}/.minecraft/launcher_profiles.json.new
continue
fi
versions_base="${HOME}/.minecraft/versions"
# Found a profile entry, lets add the correct runtime
printf "%s\n" "$line" >> ${HOME}/.minecraft/launcher_profiles.json.new
echo ' "javaDir": "/usr/local/share/minecraft-client/minecraft-runtime",' >> ${HOME}/.minecraft/launcher_profiles.json.new
done < ${HOME}/.minecraft/launcher_profiles.json
for i in ${HOME}/.minecraft/versions/*; do
if [ "${i}" != "${i%-freebsd}" -o "${i}" == "${HOME}"'/.minecraft/versions/*' ]; then continue; fi
OLDIFS=$IFS
IFS=/
for x in ${i}; do
version="${x}"
done
IFS=${OLDIFS}
# See if we have dangling }
tail -1 ${HOME}/.minecraft/launcher_profiles.json.new | grep -q "^}"
if [ $? -ne 0 ] ; then
printf "}" >> ${HOME}/.minecraft/launcher_profiles.json.new
fi
native_path="${versions_base}/${version}-freebsd/"
mkdir -p "${native_path}"
mv ${HOME}/.minecraft/launcher_profiles.json.new ${HOME}/.minecraft/launcher_profiles.json
else
# No .minecraft dir, lets display the first time notification
javac -d /tmp /usr/local/share/minecraft-client/Notifer.java
cd /tmp
java Notifer
rm Notifer*.class
fi
vendor_file="${versions_base}/${version}/${version}"
native_file="${native_path}/${version}-freebsd"
if [ -f "${vendor_file}.jar" -a ! -f "${native_file}.jar" ]; then
cp -v "${vendor_file}.jar" "${native_file}.jar"
fi
if [ -f "${vendor_file}.json" -a ! -f "${native_file}.json" ]; then
sed -e '/"id"/s/",/-freebsd",/' -e '/lwjgl/,/extract/s/natives-linux/natives-freebsd/' \
< "${vendor_file}.json" > "${native_file}.json"
fi
done
exec JAVA_CMD -Djava.nio.file.spi.DefaultFileSystemProvider=sun.nio.fs.BsdFileSystemProvider \
-Dos.name=Linux -jar PREFIX/share/minecraft-client/Minecraft.jar
exec ${JAVA_HOME}/bin/java -Djava.nio.file.spi.DefaultFileSystemProvider=sun.nio.fs.BsdFileSystemProvider \
-Dos.name=Linux -jar /usr/local/share/minecraft-client/Minecraft.jar

View File

@ -0,0 +1,46 @@
#!/usr/local/bin/bash
LWJGL_JLP_OVRD="/usr/local/lib/lwjgl2.9.1"
LWJGL_OVRD="/usr/local/share/java/classes/lwjgl/lwjgl.jar"
LWJGL_UTIL_OVRD="/usr/local/share/java/classes/lwjgl/lwjgl_util.jar"
export JAVA_HOME=/usr/local/openjdk8
build_classpath() {
j=0
ocp=`echo ${1} | sed 's/:/ /g'`
for p in ${ocp}
do
if [[ $p == *lwjgl-* ]]
then
ncp[$j]=${LWJGL_OVRD}
elif [[ $p == *lwjgl_util* ]]
then
ncp[$j]=${LWJGL_UTIL_OVRD}
else
ncp[$j]=${p}
fi
j=$(( j + 1 ))
done
cp=`echo ${ncp[@]} | sed 's/ /:/g'`
}
i=0
for var in "${@}"
do
if [[ "$var" == -Djava.library* ]]
then
args[$i]="-Djava.library.path=${LWJGL_JLP_OVRD}"
elif [[ "$var" == *lwjgl_util* ]]
then
build_classpath "${var}"
args[$i]="$cp"
else
args[$i]=$var
fi
i=$(( i + 1 ))
done
${JAVA_HOME}/jre/bin/java ${args[@]}

View File

@ -1,4 +1,6 @@
bin/minecraft-client
%%DATADIR%%/Minecraft.jar
%%DATADIR%%/minecraft-runtime
%%DATADIR%%/Notifer.java
share/pixmaps/minecraft-client.png
@dirrm %%DATADIR%%