├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── build.sh ├── common ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── unascribed │ └── laminate │ └── internal │ ├── LaminateCore.java │ ├── gl │ └── GLAccess.java │ └── tessellator │ └── TessellatorAccess.java ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── private.properties.example ├── setup.sh ├── src └── main │ ├── java │ ├── aesen │ │ └── laminate │ │ │ ├── Colors.java │ │ │ ├── Container.java │ │ │ ├── InputHook.java │ │ │ ├── Laminate.java │ │ │ ├── Rectangle.java │ │ │ ├── Renderable.java │ │ │ ├── Rendering.java │ │ │ ├── component │ │ │ ├── Box.java │ │ │ ├── Component.java │ │ │ ├── Image.java │ │ │ ├── Label.java │ │ │ └── Panel.java │ │ │ ├── screen │ │ │ └── Screen.java │ │ │ └── shadowbox │ │ │ ├── EndShadowbox.java │ │ │ ├── PanoramaShadowbox.java │ │ │ ├── Shadowbox.java │ │ │ ├── SolidShadowbox.java │ │ │ └── TextureShadowbox.java │ └── com │ │ └── unascribed │ │ └── laminate │ │ └── internal │ │ ├── GL.java │ │ ├── LaminateInternal.java │ │ ├── Mirror.java │ │ ├── OneEightNine.java │ │ ├── SmartScissor.java │ │ ├── gl │ │ ├── DirectGLAccess.java │ │ └── StateManagerGLAccess.java │ │ └── tessellator │ │ └── VertexBuilderTessellatorAccess.java │ └── resources │ ├── META-INF │ └── laminate_at.cfg │ └── mcmod.info └── version-specific ├── 1.7.10 ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── unascribed │ └── laminate │ └── internal │ ├── LaminateModOneSeven.java │ ├── OneSeven.java │ └── tessellator │ └── OldTessellatorAccess.java └── 1.8 ├── .gitignore ├── build.gradle └── src └── main └── java └── com └── unascribed └── laminate └── internal ├── LaminateModOneEight.java ├── OneEight.java └── tessellator └── SplitTessellatorAccess.java /.gitignore: -------------------------------------------------------------------------------- 1 | private.properties 2 | bin/ 3 | *.launch 4 | build/ 5 | .classpath 6 | .project 7 | .settings 8 | .metadata 9 | .gradle 10 | eclipse/ 11 | minecraft/ 12 | .pmd 13 | *.log 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Aesen Vismea 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laminate 2 | An awesome GUI framework for Minecraft Forge - a rewrite of Glass Pane 3 | 4 | 5 | **Not yet ready for use.** 6 | 7 | ## TODO 8 | - [x] Shadowboxes 9 | - [x] Solid 10 | - [x] Texture 11 | - [x] Panorama 12 | - [x] End 13 | - [x] Component rendering 14 | - [x] Component implementations (*in progress*) 15 | - [x] Box 16 | - [x] Panel 17 | - [x] Label 18 | - [x] Image 19 | - [ ] Button 20 | - [ ] CheckBox 21 | - [ ] RadioButton 22 | - [ ] Slider 23 | - [ ] TextField 24 | - [ ] ProgressBar 25 | - [ ] ProgressRing 26 | - [ ] ScrollPanel 27 | - [x] Multiple version support 28 | - [x] One-jar 29 | - [x] 1.8.9 30 | - [x] 1.8.8 31 | - [x] 1.8 32 | - [x] 1.7.10 33 | - [x] 1.7.2 (*untested*) 34 | - [ ] 1.6.4? 35 | - [ ] Serialized GUI format 36 | - [ ] Binary (network) 37 | - [ ] JSON 38 | - [ ] XML? 39 | - [ ] Test suite 40 | - [ ] Pre-made utility screens 41 | - [ ] Yes/No dialog 42 | - [ ] Okay dialog 43 | - [ ] Non-conflicting settings button main menu overlay 44 | - [ ] Documentation 45 | - [ ] Getting Started (high-level overview and explanation of Laminate concepts) 46 | - [ ] Explanations of each component 47 | - [ ] Box 48 | - [ ] Panel 49 | - [ ] ScrollPanel 50 | - [ ] Label 51 | - [ ] Image 52 | - [ ] Button 53 | - [ ] CheckBox 54 | - [ ] RadioButton 55 | - [ ] Slider 56 | - [ ] ProgressBar 57 | - [ ] ProgressRing 58 | - [ ] TextField 59 | - [ ] Practical examples 60 | - [ ] Inventory 61 | - [ ] HUD overlay 62 | - [ ] Settings button 63 | - [ ] Wishlist 64 | - [ ] UI design tool (either external or in-game) 65 | - [ ] Focus control 66 | - [ ] Allow the server to send GUIs to the client (ala Spout) -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | jcenter() 5 | maven { 6 | name = "forge" 7 | url = "http://files.minecraftforge.net/maven" 8 | } 9 | maven { 10 | name = "sonatype" 11 | url = "https://oss.sonatype.org/content/repositories/snapshots/" 12 | } 13 | } 14 | dependencies { 15 | classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT' 16 | classpath 'me.tatarka:gradle-retrolambda:3.2.0' 17 | } 18 | } 19 | 20 | apply plugin: 'net.minecraftforge.gradle.forge' 21 | apply plugin: 'me.tatarka.retrolambda' 22 | apply plugin: 'maven' 23 | 24 | group = "com.unascribed" 25 | archivesBaseName = "Laminate" 26 | version = "0.1" 27 | 28 | sourceCompatibility = 1.8 29 | targetCompatibility = 1.8 30 | 31 | retrolambda { 32 | javaVersion JavaVersion.VERSION_1_6 33 | } 34 | 35 | repositories { 36 | mavenCentral() 37 | maven { 38 | name = 'sonatype-nexus' 39 | url = 'https://oss.sonatype.org/content/repositories/public/' 40 | } 41 | } 42 | 43 | configurations { 44 | deploy 45 | shade 46 | compile.extendsFrom shade 47 | } 48 | 49 | dependencies { 50 | deploy "org.apache.maven.wagon:wagon-ssh:2.10" 51 | 52 | shade files ( 53 | 'common/build/libs/LaminateCommon.jar', 54 | 'version-specific/1.7.10/build/libs/LaminateOneSeven.jar', 55 | 'version-specific/1.8/build/libs/LaminateOneEight.jar' 56 | ) 57 | shade 'com.github.gfx.util:weak-identity-hash-map:2.0.1' 58 | } 59 | 60 | jar { 61 | manifest { 62 | attributes ( 63 | 'FMLAT': 'laminate_at.cfg' 64 | ) 65 | } 66 | configurations.shade.each { dep -> 67 | from(project.zipTree(dep)){ 68 | exclude 'META-INF', 'META-INF/**' 69 | } 70 | } 71 | } 72 | 73 | minecraft { 74 | version = "1.8.9-11.15.0.1715" 75 | mappings = "snapshot_20160130" 76 | 77 | runDir = "eclipse" 78 | } 79 | 80 | processResources { 81 | // this will ensure that this task is redone when the versions change. 82 | inputs.property "version", project.version 83 | inputs.property "mcversion", project.minecraft.version 84 | 85 | // replace stuff in mcmod.info, nothing else 86 | from(sourceSets.main.resources.srcDirs) { 87 | include 'mcmod.info' 88 | 89 | // replace version and mcversion 90 | expand 'version':project.version, 'mcversion':project.minecraft.version 91 | } 92 | 93 | // copy everything else, thats not the mcmod.info 94 | from(sourceSets.main.resources.srcDirs) { 95 | exclude 'mcmod.info' 96 | } 97 | } 98 | 99 | def parseConfig(File config) { 100 | config.withReader { 101 | def prop = new Properties() 102 | prop.load(it) 103 | return (new ConfigSlurper().parse(prop)) 104 | } 105 | } 106 | 107 | ext.priv = parseConfig(file('private.properties')) 108 | 109 | uploadArchives { 110 | repositories.mavenDeployer { 111 | configuration = configurations.deploy 112 | pom.artifactId = 'laminate' 113 | repository(url: "scp://"+priv.scpHost+priv.scpPath+"/releases") { 114 | authentication(userName: priv.scpUser, password: priv.scpPass) 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | pwd=`pwd` 3 | cd common 4 | $pwd/gradlew build 5 | cd ../version-specific/1.7.10 6 | $pwd/gradlew build 7 | cd ../1.8 8 | $pwd/gradlew build 9 | cd ../.. 10 | $pwd/gradlew build 11 | -------------------------------------------------------------------------------- /common/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'me.tatarka:gradle-retrolambda:3.2.0' 7 | } 8 | } 9 | 10 | repositories { 11 | mavenCentral() 12 | } 13 | 14 | apply plugin: 'java' 15 | apply plugin: 'eclipse' 16 | apply plugin: 'me.tatarka.retrolambda' 17 | 18 | group = "com.unascribed" 19 | archivesBaseName = "LaminateCommon" 20 | -------------------------------------------------------------------------------- /common/src/main/java/com/unascribed/laminate/internal/LaminateCore.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal; 2 | 3 | interface LaminateCore { 4 | void preInit(String mcVersion); 5 | void tick(boolean start); 6 | void frame(); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/com/unascribed/laminate/internal/gl/GLAccess.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal.gl; 2 | 3 | import java.nio.FloatBuffer; 4 | 5 | public interface GLAccess { 6 | // from GlStateManager 7 | void pushAttrib(); 8 | void popAttrib(); 9 | void disableAlpha(); 10 | void enableAlpha(); 11 | void alphaFunc(int func, float ref); 12 | void enableLighting(); 13 | void disableLighting(); 14 | void enableLight(int light); 15 | void disableLight(int light); 16 | void enableColorMaterial(); 17 | void disableColorMaterial(); 18 | void colorMaterial(int face, int mode); 19 | void disableDepth(); 20 | void enableDepth(); 21 | void depthFunc(int depthFunc); 22 | void depthMask(boolean flagIn); 23 | void disableBlend(); 24 | void enableBlend(); 25 | void blendFunc(int srcFactor, int dstFactor); 26 | void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha); 27 | void enableFog(); 28 | void disableFog(); 29 | void setFog(int param); 30 | void setFogDensity(float param); 31 | void setFogStart(float param); 32 | void setFogEnd(float param); 33 | void enableCull(); 34 | void disableCull(); 35 | void cullFace(int mode); 36 | void enablePolygonOffset(); 37 | void disablePolygonOffset(); 38 | void doPolygonOffset(float factor, float units); 39 | void enableColorLogic(); 40 | void disableColorLogic(); 41 | void colorLogicOp(int opcode); 42 | void setActiveTexture(int texture); 43 | void enableTexture2D(); 44 | void disableTexture2D(); 45 | void deleteTexture(int texture); 46 | void bindTexture(int texture); 47 | void enableNormalize(); 48 | void disableNormalize(); 49 | void shadeModel(int mode); 50 | void enableRescaleNormal(); 51 | void disableRescaleNormal(); 52 | void viewport(int x, int y, int width, int height); 53 | void colorMask(boolean red, boolean green, boolean blue, boolean alpha); 54 | void clearDepth(double depth); 55 | void clearColor(float red, float green, float blue, float alpha); 56 | void clear(int mask); 57 | void matrixMode(int mode); 58 | void loadIdentity(); 59 | void pushMatrix(); 60 | void popMatrix(); 61 | void getFloat(int pname, FloatBuffer params); 62 | void ortho(double left, double right, double bottom, double top, double zNear, double zFar); 63 | void rotate(float angle, float x, float y, float z); 64 | void scale(float x, float y, float z); 65 | void scale(double x, double y, double z); 66 | void translate(float x, float y, float z); 67 | void translate(double x, double y, double z); 68 | void multMatrix(FloatBuffer matrix); 69 | void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha); 70 | void color(float colorRed, float colorGreen, float colorBlue); 71 | void resetColor(); 72 | void callList(int list); 73 | 74 | } -------------------------------------------------------------------------------- /common/src/main/java/com/unascribed/laminate/internal/tessellator/TessellatorAccess.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal.tessellator; 2 | 3 | public interface TessellatorAccess { 4 | public static enum Format { 5 | POSITION, 6 | POSITION_COLOR, 7 | POSITION_NORMAL, 8 | POSITION_TEX, 9 | POSITION_TEX_COLOR, 10 | POSITION_TEX_COLOR_NORMAL, 11 | POSITION_TEX_NORMAL 12 | } 13 | 14 | void begin(int mode, Format format); 15 | 16 | TessellatorAccess pos(double x, double y, double z); 17 | 18 | TessellatorAccess color(float r, float g, float b); 19 | TessellatorAccess color(float r, float g, float b, float a); 20 | TessellatorAccess color(int r, int g, int b); 21 | TessellatorAccess color(int r, int g, int b, int a); 22 | 23 | TessellatorAccess normal(float x, float y, float z); 24 | 25 | TessellatorAccess tex(double u, double v); 26 | 27 | void endVertex(); 28 | 29 | void draw(); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elytra-boneyard/Laminate/62579c65fcc6c8c5ec46eb6a3f41cc22f885b8a0/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jan 23 07:10:16 EST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /private.properties.example: -------------------------------------------------------------------------------- 1 | scpHost=my.awesome.vps.interserver.net 2 | scpPath=/home/me/my.awesome.website/my/maven/repo 3 | scpUser=me 4 | scpPass=P4$$W0RD 5 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | pwd=`pwd` 3 | cd common 4 | $pwd/gradlew setupDecompWorkspace eclipse 5 | cd ../version-specific/1.7.10 6 | $pwd/gradlew setupDecompWorkspace eclipse 7 | cd ../1.8 8 | $pwd/gradlew setupDecompWorkspace eclipse 9 | cd ../.. 10 | $pwd/gradlew setupDecompWorkspace eclipse 11 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/Colors.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate; 2 | 3 | public final class Colors { 4 | 5 | public static int toByte(float f) { 6 | return ((int)(f*255f))&0xFF; 7 | } 8 | 9 | public static int pack(float r, float g, float b, float a) { 10 | return toByte(a) << 24 | 11 | toByte(r) << 16 | 12 | toByte(g) << 8 | 13 | toByte(b); 14 | } 15 | 16 | public static float unpackR(int packed) { 17 | return ((packed >> 16) & 0xFF) / 255f; 18 | } 19 | 20 | public static float unpackG(int packed) { 21 | return ((packed >> 8) & 0xFF) / 255f; 22 | } 23 | 24 | public static float unpackB(int packed) { 25 | return (packed & 0xFF) / 255f; 26 | } 27 | 28 | public static float unpackA(int packed) { 29 | return (packed >> 24) / 255f; 30 | } 31 | 32 | public static boolean isTranslucent(int color) { 33 | return (color >> 24) < 255; 34 | } 35 | 36 | public static int shadow(int color) { 37 | return (color & 0xFCFCFC) >> 2 | color & 0x1000000; 38 | } 39 | 40 | private Colors() {} 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/Container.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate; 2 | 3 | import java.util.List; 4 | 5 | import com.google.common.collect.Lists; 6 | 7 | import aesen.laminate.component.Component; 8 | 9 | /** 10 | * A collection of components that may or may not also be 11 | * a component itself. 12 | */ 13 | public class Container { 14 | protected int width; 15 | protected int height; 16 | 17 | protected final List children = Lists.newArrayList(); 18 | 19 | protected void renderChildren(float partialTicks) { 20 | for (Component c : children) { 21 | if (c == null) continue; 22 | c.render(partialTicks); 23 | } 24 | } 25 | 26 | /** 27 | * Add a Component to this Container, as a child. 28 | * It will be rendered after (and therefore on top) of 29 | * all current children. 30 | */ 31 | public void add(Component component) { 32 | children.add(component); 33 | } 34 | 35 | /** 36 | * Remove a Component from this Container. If the 37 | * passed Component isn't in this Container, 38 | * nothing happens. 39 | */ 40 | public void remove(Component component) { 41 | children.remove(component); 42 | } 43 | 44 | /** 45 | * Removes every child from this Container. 46 | */ 47 | public void clear() { 48 | children.clear(); 49 | } 50 | 51 | /** 52 | * Returns the amount of children in this Container. 53 | */ 54 | public int size() { 55 | return children.size(); 56 | } 57 | 58 | /** 59 | * Returns {@code true} if this Container has no 60 | * children. 61 | */ 62 | public boolean isEmpty() { 63 | return children.isEmpty(); 64 | } 65 | 66 | 67 | 68 | public int getWidth() { 69 | return width; 70 | } 71 | public int getHeight() { 72 | return height; 73 | } 74 | 75 | public void setWidth(int width) { 76 | this.width = width; 77 | } 78 | public void setHeight(int height) { 79 | this.height = height; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/InputHook.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate; 2 | 3 | /** 4 | * Accepts input events such as key presses, mouse movements, 5 | * and mouse clicks. 6 | * 7 | */ 8 | public interface InputHook { 9 | void onKeyDown(char keyChar, int keyCode); 10 | void onKeyUp(char keyChar, int keyCode); 11 | 12 | void onMouseMove(int x, int y); 13 | 14 | void onMouseDown(int x, int y, int button); 15 | void onMouseUp(int x, int y, int button); 16 | void onMouseScroll(int x, int y, int scrollAmount); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/Laminate.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import com.github.gfx.util.WeakIdentityHashMap; 8 | import com.google.common.collect.Lists; 9 | import com.unascribed.laminate.internal.LaminateInternal; 10 | 11 | import aesen.laminate.screen.Screen; 12 | import net.minecraft.client.Minecraft; 13 | import net.minecraft.client.gui.GuiScreen; 14 | 15 | /** 16 | * Main entry point for modifying the current GUI state. 17 | * This is where you'll add overlays, switch screens, and 18 | * all other such things. 19 | * 20 | */ 21 | public final class Laminate { 22 | private static List inputHooks = Lists.newArrayList(); 23 | private static Map> overlays = new WeakIdentityHashMap<>(); 24 | 25 | private static List getCurrentOverlayList() { 26 | GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen; 27 | List li = overlays.get(currentScreen); 28 | if (li == null) { 29 | li = new ArrayList<>(); 30 | overlays.put(currentScreen, li); 31 | } 32 | return li; 33 | } 34 | 35 | /** 36 | * Adds an input hook, which is essentially a lightweight 37 | * Screen that receives input but does not render anything. 38 | *

39 | * Unlike overlays, input hooks will not be cleared when the 40 | * underlying GUI changes. 41 | * @param hook the hook to add 42 | */ 43 | public static void addInputHook(InputHook hook) { 44 | inputHooks.add(hook); 45 | } 46 | 47 | /** 48 | * Remove an input hook, making it no longer receive events. 49 | * @param hook the hook to remove 50 | */ 51 | public static void removeInputHook(InputHook hook) { 52 | inputHooks.remove(hook); 53 | } 54 | 55 | 56 | 57 | /** 58 | * Adds a Screen to the top of the overlay stack, rendering 59 | * it over all existing overlays and the base GUI. 60 | * @param screen the screen to add to the overlay stack 61 | */ 62 | public static void addOverlayToTop(Screen screen) { 63 | getCurrentOverlayList().add(screen); 64 | } 65 | 66 | /** 67 | * Adds a Screen to the bottom of the overlay stack, rendering 68 | * it under all existing overlays, but still over the base GUI. 69 | * @param screen the screen to add to the overlay stack 70 | */ 71 | public static void addOverlayToBottom(Screen screen) { 72 | getCurrentOverlayList().add(0, screen); 73 | } 74 | 75 | /** 76 | * Removes an overlay from the overlay stack, regardless of it's 77 | * position. Once removed, this overlay will no longer render and 78 | * will no longer receive events. 79 | * @param screen the screen to remove from the overlay stack 80 | */ 81 | public static void removeOverlay(Screen screen) { 82 | getCurrentOverlayList().remove(screen); 83 | } 84 | 85 | 86 | 87 | /** 88 | * Sets the passed Screen as the currently displaying GUI, therefore 89 | * clearing the overlay stack and closing the current GUI, be it a 90 | * Screen or GuiScreen. 91 | * @param screen the screen to display 92 | */ 93 | public static void display(Screen screen) { 94 | Minecraft.getMinecraft().displayGuiScreen(screen.getMirror()); 95 | } 96 | 97 | /** 98 | * Supplied for API consistency. 99 | * Identical to {@code Minecraft.getMinecraft().displayGuiScreen(screen)}. 100 | * @param screen the screen to display 101 | */ 102 | public static void display(GuiScreen screen) { 103 | Minecraft.getMinecraft().displayGuiScreen(screen); 104 | } 105 | 106 | 107 | 108 | /** 109 | * Get the currently displaying GUI as a Screen, or null if it is a 110 | * vanilla GuiScreen. 111 | * @return the currently displaying Screen 112 | */ 113 | public static Screen getCurrentScreen() { 114 | return LaminateInternal.unwrapMirror(Minecraft.getMinecraft().currentScreen); 115 | } 116 | 117 | 118 | 119 | /** 120 | * Get the width of the current GUI, avoiding extra object creation if possible. 121 | */ 122 | public static int getWidth() { 123 | if (Minecraft.getMinecraft().currentScreen != null) { 124 | return Minecraft.getMinecraft().currentScreen.width; 125 | } 126 | return LaminateInternal.createScaledResolution().getScaledWidth(); 127 | } 128 | 129 | /** 130 | * Get the height of the current GUI, avoiding extra object creation if possible. 131 | */ 132 | public static int getHeight() { 133 | if (Minecraft.getMinecraft().currentScreen != null) { 134 | return Minecraft.getMinecraft().currentScreen.height; 135 | } 136 | return LaminateInternal.createScaledResolution().getScaledHeight(); 137 | } 138 | 139 | 140 | 141 | 142 | private Laminate() {} // static, do not allow instanciation 143 | } 144 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/Rectangle.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | import com.google.common.base.Objects; 7 | 8 | /** 9 | * Specifies a bound on a two-dimensional plane, with a position and size. 10 | *

11 | * Most javadocs on this class use an X11-esque geometry format for describing 12 | * rectangles, in format <width>x<height>[+<x>,<y>]. 13 | * 14 | */ 15 | public class Rectangle { 16 | private int x; 17 | private int y; 18 | private int width; 19 | private int height; 20 | 21 | /** 22 | * Creates a Rectangle and initializes it to 0x0+0,0 23 | */ 24 | public Rectangle() { 25 | this(0, 0, 0, 0); // may as well be explicit 26 | } 27 | 28 | /** 29 | * Creates a Rectangle and initializes it to the size given, 30 | * with a position of 0, 0. 31 | * @param width the width of the rectangle 32 | * @param height the height of the rectangle 33 | */ 34 | public Rectangle(int width, int height) { 35 | this(0, 0, width, height); 36 | } 37 | 38 | /** 39 | * Creates a Rectangle and initializes it to the parameters given. 40 | * @param x the X position of the rectangle 41 | * @param y the Y position of the rectangle 42 | * @param width the width of the rectangle 43 | * @param height the height of the rectangle 44 | */ 45 | public Rectangle(int x, int y, int width, int height) { 46 | this.x = x; 47 | this.y = y; 48 | this.width = width; 49 | this.height = height; 50 | } 51 | 52 | /** 53 | * Converts this Rectangle into an X11-esque geometry string, in format 54 | * <width>x<height>[+<x>,<y>]. For example, a rectangle 55 | * at X 4 and Y 8, that is 20 wide by 40 high would be 20x40+4,8. A rectangle 56 | * at X 0 and Y 0 with the same size would be 20x40, without a position. 57 | */ 58 | @Override 59 | public String toString() { 60 | if (x == 0 && y == 0) { 61 | return width+"x"+height; 62 | } 63 | return width+"x"+height+"+"+x+","+y; 64 | } 65 | 66 | private static final Pattern GEOMETRY_PATTERN = Pattern.compile("^([0-9]+)x([0-9]+)(?:\\+([0-9]+),([0-9]+))?$"); 67 | 68 | /** 69 | * Creates a Rectangle from a geometry string, potentially created by {@link #toString}. 70 | * See that method for a description of the geometry string. 71 | * @param geom a geometry string to parse 72 | * @throws IllegalArgumentException if the passed string is not a valid geometry string 73 | * @return a new Rectangle matching the geometry string passed 74 | * @see #toString() 75 | */ 76 | public static Rectangle fromString(String geom) { 77 | Matcher matcher = GEOMETRY_PATTERN.matcher(geom); 78 | if (!matcher.matches()) { 79 | throw new IllegalArgumentException("'"+geom+"' is not a valid geometry string"); 80 | } 81 | int x = Integer.parseInt(Objects.firstNonNull(matcher.group(3), "0")); 82 | int y = Integer.parseInt(Objects.firstNonNull(matcher.group(4), "0")); 83 | int width = Integer.parseInt(matcher.group(1)); 84 | int height = Integer.parseInt(matcher.group(2)); 85 | return new Rectangle(x, y, width, height); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/Renderable.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate; 2 | 3 | public interface Renderable { 4 | void render(float partialTicks); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/Rendering.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate; 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.client.gui.FontRenderer; 6 | import net.minecraft.client.gui.Gui; 7 | import net.minecraft.client.gui.GuiScreen; 8 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 9 | import net.minecraft.item.ItemStack; 10 | 11 | /** 12 | * Static versions of Gui and GuiScreen utility methods. 13 | * 14 | */ 15 | public class Rendering { 16 | private static class DummyGui extends GuiScreen { 17 | @Override 18 | public void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) { 19 | super.drawGradientRect(left, top, right, bottom, startColor, endColor); 20 | } 21 | @Override 22 | public void drawHorizontalLine(int startX, int endX, int y, int color) { 23 | super.drawHorizontalLine(startX, endX, y, color); 24 | } 25 | @Override 26 | public void drawVerticalLine(int x, int startY, int endY, int color) { 27 | super.drawVerticalLine(x, startY, endY, color); 28 | } 29 | @Override 30 | public void drawHoveringText(List textLines, int x, int y) { 31 | super.drawHoveringText(textLines, x, y); 32 | } 33 | @Override 34 | public void drawHoveringText(List textLines, int x, int y, FontRenderer font) { 35 | super.drawHoveringText(textLines, x, y, font); 36 | } 37 | @Override 38 | public void renderToolTip(ItemStack stack, int x, int y) { 39 | super.renderToolTip(stack, x, y); 40 | } 41 | } 42 | 43 | 44 | private static final DummyGui GUI = new DummyGui(); 45 | 46 | 47 | public static void drawCenteredString(FontRenderer fontRendererIn, String text, int x, int y, int color) { 48 | GUI.drawCenteredString(fontRendererIn, text, x, y, color); 49 | } 50 | 51 | public static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) { 52 | GUI.drawGradientRect(left, top, right, bottom, startColor, endColor); 53 | } 54 | 55 | public static void drawHorizontalLine(int startX, int endX, int y, int color) { 56 | GUI.drawHorizontalLine(startX, endX, y, color); 57 | } 58 | 59 | public static void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color) { 60 | GUI.drawString(fontRendererIn, text, x, y, color); 61 | } 62 | 63 | public static void drawTexturedModalRect(float xCoord, float yCoord, int minU, int minV, int maxU, int maxV) { 64 | GUI.drawTexturedModalRect(xCoord, yCoord, minU, minV, maxU, maxV); 65 | } 66 | 67 | public static void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height) { 68 | GUI.drawTexturedModalRect(x, y, textureX, textureY, width, height); 69 | } 70 | 71 | public static void drawTexturedModalRect(int xCoord, int yCoord, TextureAtlasSprite textureSprite, int widthIn, int heightIn) { 72 | GUI.drawTexturedModalRect(xCoord, yCoord, textureSprite, widthIn, heightIn); 73 | } 74 | 75 | public static void drawVerticalLine(int x, int startY, int endY, int color) { 76 | GUI.drawVerticalLine(x, startY, endY, color); 77 | } 78 | 79 | public static void drawScaledCustomSizeModalRect(int x, int y, float u, float v, int uWidth, int vHeight, int width, int height, float tileWidth, float tileHeight) { 80 | Gui.drawScaledCustomSizeModalRect(x, y, u, v, uWidth, vHeight, width, height, tileWidth, tileHeight); 81 | } 82 | 83 | public static void drawModalRectWithCustomSizedTexture(int x, int y, float u, float v, int width, int height, float textureWidth, float textureHeight) { 84 | Gui.drawModalRectWithCustomSizedTexture(x, y, u, v, width, height, textureWidth, textureHeight); 85 | } 86 | 87 | public static void drawRect(int left, int top, int right, int bottom, int color) { 88 | Gui.drawRect(left, top, right, bottom, color); 89 | } 90 | 91 | public static void drawHoveringText(List textLines, int x, int y) { 92 | GUI.drawHoveringText(textLines, x, y); 93 | } 94 | 95 | public static void drawHoveringText(List textLines, int x, int y, FontRenderer font) { 96 | GUI.drawHoveringText(textLines, x, y, font); 97 | } 98 | 99 | public static void renderToolTip(ItemStack stack, int x, int y) { 100 | GUI.renderToolTip(stack, x, y); 101 | } 102 | 103 | 104 | 105 | 106 | private Rendering() {} 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/component/Box.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate.component; 2 | 3 | import aesen.laminate.Rendering; 4 | 5 | public class Box extends Component { 6 | private int color = 0xFFFFFFFF; 7 | 8 | @Override 9 | protected void doRender(float partialTicks) { 10 | Rendering.drawRect(0, 0, width, height, color); 11 | } 12 | 13 | public void setColor(int color) { 14 | this.color = color; 15 | } 16 | 17 | public int getColor() { 18 | return color; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/component/Component.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate.component; 2 | 3 | import com.unascribed.laminate.internal.GL; 4 | import aesen.laminate.Container; 5 | import aesen.laminate.Rectangle; 6 | 7 | /** 8 | * The base of all Laminate components. Doesn't do much on it's 9 | * own, but supplies a solid base for writing other components. 10 | * 11 | */ 12 | public abstract class Component extends Container { 13 | protected int x; 14 | protected int y; 15 | 16 | public final void render(float partialTicks) { 17 | GL.pushMatrix(); 18 | GL.pushScissor(); 19 | GL.translate(x, y, 0); 20 | GL.setScissorFromComponentCoordinates(x, y, width, height); 21 | doRender(partialTicks); 22 | 23 | GL.translate(getSafeZoneX(), getSafeZoneY(), 0); 24 | GL.setScissorFromComponentCoordinates( 25 | x+getSafeZoneX(), y+getSafeZoneY(), 26 | getSafeZoneWidth(), getSafeZoneHeight()); 27 | renderChildren(partialTicks); 28 | GL.popScissor(); 29 | GL.popMatrix(); 30 | } 31 | 32 | protected abstract void doRender(float partialTicks); 33 | 34 | 35 | public int getX() { 36 | return x; 37 | } 38 | public int getY() { 39 | return y; 40 | } 41 | 42 | 43 | public void setX(int x) { 44 | this.x = x; 45 | } 46 | public void setY(int y) { 47 | this.y = y; 48 | } 49 | 50 | /** 51 | * Returns the X coordinate of the upper-left corner of the "safe zone", 52 | * that being the region this component dedicates to external rendering, 53 | * such as, but not only, children. Relative to the component's X, 54 | * defaulting to 0. This can be used to enforce borders around a container, 55 | * without translating and modifying the scissor box yourself. 56 | *

57 | * It is bad practice to set this to something outside of the component's 58 | * box in the effort to prevent the component from having children or 59 | * external rendering; all Laminate components should allow external 60 | * rendering, even if you don't think it makes sense. 61 | * 62 | * @return The X coordinate of this component's "safe zone", relative to its 63 | * base X coordinate. 64 | */ 65 | public int getSafeZoneX() { 66 | return 0; 67 | } 68 | 69 | /** 70 | * @see #getSafeZoneX() getSafeZoneX(), for a description of the safe zone 71 | * @return The Y coordinate of this component's "safe zone", relative to its 72 | * base Y coordinate. 73 | */ 74 | public int getSafeZoneY() { 75 | return 0; 76 | } 77 | 78 | /** 79 | * @see #getSafeZoneX() getSafeZoneX(), for a description of the safe zone 80 | * @return The width of this component's "safe zone". 81 | */ 82 | public int getSafeZoneWidth() { 83 | return getWidth(); 84 | } 85 | 86 | /** 87 | * @see #getSafeZoneX() getSafeZoneX(), for a description of the safe zone 88 | * @return The height of this component's "safe zone". 89 | */ 90 | public int getSafeZoneHeight() { 91 | return getHeight(); 92 | } 93 | 94 | 95 | public Rectangle toRectangle() { 96 | return new Rectangle(x, y, width, height); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/component/Image.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate.component; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | 5 | import com.unascribed.laminate.internal.GL; 6 | import com.unascribed.laminate.internal.LaminateInternal; 7 | import com.unascribed.laminate.internal.tessellator.TessellatorAccess; 8 | import com.unascribed.laminate.internal.tessellator.TessellatorAccess.Format; 9 | 10 | import net.minecraft.client.Minecraft; 11 | import net.minecraft.util.ResourceLocation; 12 | 13 | public class Image extends Component { 14 | private ResourceLocation src; 15 | private float minU = 0; 16 | private float minV = 0; 17 | private float maxU = 1; 18 | private float maxV = 1; 19 | 20 | @Override 21 | protected void doRender(float partialTicks) { 22 | GL.enableBlend(); 23 | GL.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 24 | GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 25 | Minecraft.getMinecraft().getTextureManager().bindTexture(src); 26 | GL.color(1, 1, 1); 27 | TessellatorAccess tess = LaminateInternal.tess(); 28 | tess.begin(GL11.GL_QUADS, Format.POSITION_TEX); 29 | tess.pos(0 , height, 0).tex(minU, maxV).endVertex(); 30 | tess.pos(width, height, 0).tex(maxU, maxV).endVertex(); 31 | tess.pos(width, 0 , 0).tex(maxU, minV).endVertex(); 32 | tess.pos(0 , 0 , 0).tex(minU, minV).endVertex(); 33 | tess.draw(); 34 | GL.disableBlend(); 35 | } 36 | 37 | 38 | public void setSource(ResourceLocation src) { 39 | this.src = src; 40 | } 41 | 42 | public void setUV(float minU, float minV, float maxU, float maxV) { 43 | setMinU(minU); 44 | setMaxU(maxU); 45 | setMinV(minV); 46 | setMaxV(maxV); 47 | } 48 | 49 | public void setMinU(float minU) { 50 | this.minU = minU; 51 | } 52 | 53 | public void setMaxU(float maxU) { 54 | this.maxU = maxU; 55 | } 56 | 57 | public void setMinV(float minV) { 58 | this.minV = minV; 59 | } 60 | 61 | public void setMaxV(float maxV) { 62 | this.maxV = maxV; 63 | } 64 | 65 | 66 | public ResourceLocation getSource() { 67 | return src; 68 | } 69 | 70 | public float getMinU() { 71 | return minU; 72 | } 73 | 74 | public float getMaxU() { 75 | return maxU; 76 | } 77 | 78 | public float getMinV() { 79 | return minV; 80 | } 81 | 82 | public float getMaxV() { 83 | return maxV; 84 | } 85 | 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/component/Label.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate.component; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.FontRenderer; 5 | 6 | public class Label extends Component { 7 | private String text = ""; 8 | private FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; 9 | private int color = 0xFFFFFFFF; 10 | 11 | @Override 12 | protected void doRender(float partialTicks) { 13 | fontRenderer.drawStringWithShadow(text, 0, 0, color); 14 | } 15 | 16 | 17 | private void updateSize() { 18 | setWidth(fontRenderer.getStringWidth(text)); 19 | setHeight(fontRenderer.FONT_HEIGHT); 20 | } 21 | 22 | public void setText(String text) { 23 | this.text = text; 24 | updateSize(); 25 | } 26 | 27 | public void setFontRenderer(FontRenderer fontRenderer) { 28 | this.fontRenderer = fontRenderer; 29 | updateSize(); 30 | } 31 | 32 | public void setColor(int color) { 33 | this.color = color; 34 | } 35 | 36 | 37 | public String getText() { 38 | return text; 39 | } 40 | 41 | public FontRenderer getFontRenderer() { 42 | return fontRenderer; 43 | } 44 | 45 | public int getColor() { 46 | return color; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/component/Panel.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate.component; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import com.unascribed.laminate.internal.GL; 6 | import aesen.laminate.Colors; 7 | import aesen.laminate.Rendering; 8 | import net.minecraft.client.Minecraft; 9 | import net.minecraft.client.gui.FontRenderer; 10 | 11 | /** 12 | * A basic container for other components, potentially with a border. 13 | */ 14 | public class Panel extends Component { 15 | private boolean showBorder = false; 16 | private int borderColor = 0xFFFFFFFF; 17 | 18 | private String title = null; 19 | private FontRenderer titleFontRenderer = Minecraft.getMinecraft().fontRendererObj; 20 | 21 | @Override 22 | protected void doRender(float partialTicks) { 23 | if (showBorder) { 24 | drawBorder(1, 1, getWidth()-1, getHeight()-1, Colors.shadow(borderColor)); 25 | drawBorder(0, 0, getWidth()-1, getHeight()-1, borderColor); 26 | } 27 | } 28 | 29 | private void drawBorder(int x, int y, int width, int height, int color) { 30 | GL.color(color); 31 | // this would be slightly more efficient as a polygon, but GL_POLYGONS 32 | // is only good for convex polygons, and the border is a concave polygon 33 | if (title != null) { 34 | titleFontRenderer.drawString(title, x+6, y, color); 35 | y += 4; 36 | height -= 4; 37 | Rendering.drawRect(x+1, y, x+3, y+1, color); 38 | Rendering.drawRect(x+titleFontRenderer.getStringWidth(title)+8, y, x+width-1, y+1, color); 39 | } else { 40 | Rendering.drawRect(x, y, x+width, y+1, color); 41 | } 42 | Rendering.drawRect(x, y, x+1, y+height, color); 43 | Rendering.drawRect(x+1, y+height-1, x+width, y+height, color); 44 | Rendering.drawRect(x+width-1, y, x+width, y+height-1, color); 45 | } 46 | 47 | @Override 48 | public int getSafeZoneX() { 49 | return showBorder ? 6 : 0; 50 | } 51 | 52 | @Override 53 | public int getSafeZoneY() { 54 | return showBorder ? (title == null ? 6 : 13) : 0; 55 | } 56 | 57 | @Override 58 | public int getSafeZoneWidth() { 59 | return width - (showBorder ? 13 : 0); 60 | } 61 | 62 | @Override 63 | public int getSafeZoneHeight() { 64 | return height - (showBorder ? (title == null ? 13 : 20) : 0); 65 | } 66 | 67 | 68 | public void setShowBorder(boolean showBorder) { 69 | this.showBorder = showBorder; 70 | } 71 | 72 | public void setBorderColor(int borderColor) { 73 | this.borderColor = borderColor; 74 | } 75 | 76 | public void setBorderColor(float r, float g, float b) { 77 | setBorderColor(Colors.pack(r, g, b, 1)); 78 | } 79 | 80 | /** 81 | * If null, no title will be displayed. 82 | */ 83 | public void setTitle(@Nullable String title) { 84 | this.title = title; 85 | } 86 | 87 | public void setTitleFontRenderer(FontRenderer titleFontRenderer) { 88 | this.titleFontRenderer = titleFontRenderer; 89 | } 90 | 91 | 92 | 93 | public boolean getShowBorder() { 94 | return showBorder; 95 | } 96 | 97 | public int getBorderColor() { 98 | return borderColor; 99 | } 100 | 101 | 102 | @Nullable 103 | public String getTitle() { 104 | return title; 105 | } 106 | 107 | public FontRenderer getTitleFontRenderer() { 108 | return titleFontRenderer; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/screen/Screen.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate.screen; 2 | 3 | import com.unascribed.laminate.internal.LaminateInternal; 4 | 5 | import aesen.laminate.Container; 6 | import aesen.laminate.InputHook; 7 | import aesen.laminate.Rendering; 8 | import aesen.laminate.component.Component; 9 | import aesen.laminate.shadowbox.Shadowbox; 10 | import aesen.laminate.shadowbox.TextureShadowbox; 11 | import net.minecraft.client.Minecraft; 12 | import net.minecraft.client.gui.GuiScreen; 13 | 14 | /** 15 | * A collection of {@link Component}s, which can be displayed as either 16 | * an overlay or a fullscreen GUI. 17 | */ 18 | public class Screen extends Container implements InputHook { 19 | private GuiScreen mirror; 20 | private Shadowbox shadowbox = new TextureShadowbox(); 21 | 22 | 23 | 24 | /** 25 | * Render this screen's shadowbox. Will not be called if this 26 | * Screen is being used as an overlay rather than a GUI. 27 | */ 28 | public void renderShadowbox(float partialTicks) { 29 | if (shadowbox != null) { 30 | if (Minecraft.getMinecraft().theWorld != null) { 31 | Rendering.drawGradientRect(0, 0, width, height, 0xC0101010, 0xD0101010); 32 | } else { 33 | shadowbox.render(partialTicks); 34 | } 35 | } 36 | } 37 | 38 | /** 39 | * Render this screen's foreground, usually only consisting 40 | * of it's children. 41 | */ 42 | public void renderForeground(float partialTicks) { 43 | renderChildren(partialTicks); 44 | } 45 | 46 | 47 | public void tick() { 48 | if (shadowbox != null) { 49 | shadowbox.tick(); 50 | } 51 | } 52 | 53 | 54 | 55 | public GuiScreen getMirror() { 56 | if (mirror == null) { 57 | mirror = LaminateInternal.createMirror(this); 58 | } 59 | return mirror; 60 | } 61 | 62 | public void setShadowbox(Shadowbox shadowbox) { 63 | this.shadowbox = shadowbox; 64 | } 65 | 66 | public Shadowbox getShadowbox() { 67 | return shadowbox; 68 | } 69 | 70 | 71 | 72 | @Override 73 | public void onKeyDown(char keyChar, int keyCode) { 74 | // TODO Auto-generated method stub 75 | 76 | } 77 | 78 | @Override 79 | public void onKeyUp(char keyChar, int keyCode) { 80 | // TODO Auto-generated method stub 81 | 82 | } 83 | 84 | @Override 85 | public void onMouseMove(int x, int y) { 86 | // TODO Auto-generated method stub 87 | 88 | } 89 | 90 | @Override 91 | public void onMouseDown(int x, int y, int button) { 92 | // TODO Auto-generated method stub 93 | 94 | } 95 | 96 | @Override 97 | public void onMouseUp(int x, int y, int button) { 98 | // TODO Auto-generated method stub 99 | 100 | } 101 | 102 | @Override 103 | public void onMouseScroll(int x, int y, int scrollAmount) { 104 | // TODO Auto-generated method stub 105 | 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/shadowbox/EndShadowbox.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate.shadowbox; 2 | 3 | import java.util.Random; 4 | 5 | import org.lwjgl.opengl.GL11; 6 | 7 | import com.unascribed.laminate.internal.GL; 8 | import com.unascribed.laminate.internal.LaminateInternal; 9 | import com.unascribed.laminate.internal.tessellator.TessellatorAccess; 10 | 11 | import aesen.laminate.Laminate; 12 | import net.minecraft.client.Minecraft; 13 | import net.minecraft.util.ResourceLocation; 14 | 15 | /** 16 | * A shadowbox that looks like the starfield in an end portal. 17 | * Based on GuiEndPortalRenderer from HardcoreEnderExpansion. 18 | * 19 | */ 20 | public class EndShadowbox extends Shadowbox { 21 | 22 | private static final ResourceLocation texPortalSky = new ResourceLocation("textures/environment/end_sky.png"); 23 | private static final ResourceLocation texPortal = new ResourceLocation("textures/entity/end_portal.png"); 24 | private static final Random consistentRandom = new Random(31100L); 25 | 26 | public int portalTranslation; 27 | public int prevPortalTranslation; 28 | 29 | public EndShadowbox() { 30 | this.prevPortalTranslation = this.portalTranslation = ((int) (Math.random() * 10000)); 31 | } 32 | 33 | private void update(int speed) { 34 | prevPortalTranslation = portalTranslation; 35 | portalTranslation += speed; 36 | } 37 | 38 | private void draw(float x, float y, float portalScale, float partialTickTime) { 39 | int width = Laminate.getWidth(); 40 | int height = Laminate.getHeight(); 41 | 42 | float div = (float) width / height; 43 | 44 | GL.disableLighting(); 45 | consistentRandom.setSeed(31100L); 46 | 47 | for (int layer = 0; layer < 16; ++layer) { 48 | float revLayer = (16 - layer); 49 | float scale = 0.09625F; 50 | float colorMultiplier = 1F / (revLayer + 1F); 51 | float layerMp = 1F + (layer * 0.4F); 52 | 53 | if (layer == 0) { 54 | Minecraft.getMinecraft().getTextureManager().bindTexture(texPortalSky); 55 | colorMultiplier = 0.1F; 56 | scale = 1.125F; 57 | GL.enableBlend(); 58 | GL.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 59 | } 60 | 61 | if (layer >= 1) { 62 | Minecraft.getMinecraft().getTextureManager().bindTexture(texPortal); 63 | 64 | if (layer == 1) { 65 | GL.enableBlend(); 66 | GL.blendFunc(GL11.GL_ONE, GL11.GL_ONE); 67 | scale = 0.2F; 68 | } 69 | } 70 | 71 | GL.matrixMode(GL11.GL_TEXTURE); 72 | GL.pushMatrix(); 73 | GL.loadIdentity(); 74 | 75 | GL.translate(0F, layerMp * (prevPortalTranslation + (portalTranslation - prevPortalTranslation) * partialTickTime) * 0.00002F, 0F); 76 | GL.scale(scale, scale, 1F); 77 | GL.scale(1F + revLayer * 0.15F, 1F + revLayer * 0.15F, 1F); 78 | GL.translate(0.5F, 0.5F, 0F); 79 | GL.rotate((layer * layer * 4321 + layer * 9) * 4F + 180F, 0F, 0F, 1F); 80 | 81 | GL.translate(x * 0.0025F * layerMp, y * 0.0025F * layerMp, 0F); 82 | GL.translate(0.5F * div, 0.5F, 0F); 83 | GL.scale(4F * portalScale, 4F * portalScale, 1F); 84 | GL.translate(-0.5F * div, -0.5F, 0F); 85 | 86 | GL.scale(div, 1F, 1F); 87 | 88 | TessellatorAccess tess = LaminateInternal.tess(); 89 | tess.begin(GL11.GL_QUADS, TessellatorAccess.Format.POSITION_TEX_COLOR); 90 | 91 | float red = consistentRandom.nextFloat() * 0.5F + 0.1F; 92 | float green = consistentRandom.nextFloat() * 0.5F + 0.4F; 93 | float blue = consistentRandom.nextFloat() * 0.5F + 0.5F; 94 | if (layer == 0) { 95 | red = green = blue = 1F; 96 | } 97 | 98 | float r = red * colorMultiplier; 99 | float g = green * colorMultiplier; 100 | float b = blue * colorMultiplier; 101 | 102 | tess.pos(0, height, 0D).tex(0D, 1D).color(r, g, b, 1).endVertex(); 103 | tess.pos(width, height, 0D).tex(1D, 1D).color(r, g, b, 1).endVertex(); 104 | tess.pos(width, 0, 0D).tex(1D, 0D).color(r, g, b, 1).endVertex(); 105 | tess.pos(0, 0, 0D).tex(0D, 0D).color(r, g, b, 1).endVertex(); 106 | tess.draw(); 107 | GL.popMatrix(); 108 | GL.matrixMode(GL11.GL_MODELVIEW); 109 | } 110 | 111 | GL.disableBlend(); 112 | } 113 | 114 | private float scale = 1; 115 | private int speed = 1; 116 | 117 | public void setScale(float scale) { 118 | this.scale = scale; 119 | } 120 | 121 | public void setSpeed(int speed) { 122 | this.speed = speed; 123 | } 124 | 125 | public float getScale() { 126 | return scale; 127 | } 128 | 129 | public int getSpeed() { 130 | return speed; 131 | } 132 | 133 | @Override 134 | public void tick() { 135 | update(speed); 136 | } 137 | 138 | @Override 139 | public void render(float partialTicks) { 140 | draw(0, 0, scale, partialTicks); 141 | } 142 | 143 | } 144 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/shadowbox/PanoramaShadowbox.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate.shadowbox; 2 | 3 | import java.util.Arrays; 4 | 5 | import org.lwjgl.opengl.GL11; 6 | import org.lwjgl.util.glu.Project; 7 | 8 | import com.unascribed.laminate.internal.GL; 9 | import com.unascribed.laminate.internal.LaminateInternal; 10 | import com.unascribed.laminate.internal.tessellator.TessellatorAccess; 11 | 12 | import aesen.laminate.Laminate; 13 | import aesen.laminate.Rendering; 14 | import net.minecraft.client.Minecraft; 15 | import net.minecraft.client.renderer.texture.DynamicTexture; 16 | import net.minecraft.util.MathHelper; 17 | import net.minecraft.util.ResourceLocation; 18 | 19 | /** 20 | * A shadowbox imitating the panorama in the background of the main menu. 21 | * 22 | */ 23 | public class PanoramaShadowbox extends Shadowbox { 24 | private boolean useGlobalPanoramaTimer = true; 25 | private int panoramaTimer; 26 | 27 | private ResourceLocation[] panoramaPaths; 28 | 29 | public PanoramaShadowbox() { 30 | panoramaPaths = titlePanoramaPaths; 31 | init(); 32 | } 33 | 34 | /** 35 | * If set to true, this shadowbox will share it's timer with other 36 | * PanoramaShadowboxes that also have this enabled. This allows 37 | * transitions between two Screens, both using PanoramaShadowboxes, 38 | * to be seamless. 39 | *

40 | * The global timer is synced with that of the main menu, meaning 41 | * it will also be a seamless transition from the main menu. 42 | *

43 | * Defaults to true. 44 | * 45 | * @param useGlobalPanoramaTimer whether or not to use the global panorama timer 46 | */ 47 | public void setUseGlobalPanoramaTimer(boolean useGlobalPanoramaTimer) { 48 | this.useGlobalPanoramaTimer = useGlobalPanoramaTimer; 49 | } 50 | 51 | public boolean useGlobalPanoramaTimer() { 52 | return useGlobalPanoramaTimer; 53 | } 54 | 55 | public void setPanoramaPaths(ResourceLocation... panoramaPaths) { 56 | if (panoramaPaths == null || panoramaPaths.length != 6) { 57 | throw new IllegalArgumentException("Panorama paths must not be null and must have exactly 6 entries"); 58 | } 59 | this.panoramaPaths = panoramaPaths.clone(); 60 | } 61 | 62 | public ResourceLocation[] getPanoramaPaths() { 63 | return Arrays.copyOf(panoramaPaths, panoramaPaths.length); 64 | } 65 | 66 | @Override 67 | public void render(float partialTicks) { 68 | GL.disableAlpha(); 69 | renderSkybox(partialTicks); 70 | GL.enableAlpha(); 71 | int width = Laminate.getWidth(); 72 | int height = Laminate.getHeight(); 73 | Rendering.drawGradientRect(0, 0, width, height, 0x80FFFFFF, 0x00FFFFFF); 74 | Rendering.drawGradientRect(0, 0, width, height, 0x00000000, 0x80000000); 75 | } 76 | 77 | @Override 78 | public void tick() { 79 | if (!useGlobalPanoramaTimer) { 80 | panoramaTimer++; 81 | } 82 | } 83 | 84 | @Override 85 | protected void finalize() throws Throwable { 86 | viewportTexture.deleteGlTexture(); 87 | super.finalize(); 88 | } 89 | 90 | 91 | // Below code shamelessly stolen from GuiMainMenu 92 | 93 | private DynamicTexture viewportTexture; 94 | private ResourceLocation backgroundTexture; 95 | private static final ResourceLocation[] titlePanoramaPaths = new ResourceLocation[] { 96 | new ResourceLocation("textures/gui/title/background/panorama_0.png"), 97 | new ResourceLocation("textures/gui/title/background/panorama_1.png"), 98 | new ResourceLocation("textures/gui/title/background/panorama_2.png"), 99 | new ResourceLocation("textures/gui/title/background/panorama_3.png"), 100 | new ResourceLocation("textures/gui/title/background/panorama_4.png"), 101 | new ResourceLocation("textures/gui/title/background/panorama_5.png")}; 102 | 103 | private void init() { 104 | this.viewportTexture = new DynamicTexture(256, 256); 105 | this.backgroundTexture = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("background", this.viewportTexture); 106 | } 107 | 108 | /** 109 | * Draws the main menu panorama 110 | */ 111 | private void drawPanorama(float partialTicks) { 112 | int panoramaTimer = (useGlobalPanoramaTimer ? LaminateInternal.globalPanoramaTimer : this.panoramaTimer); 113 | 114 | TessellatorAccess tess = LaminateInternal.tess(); 115 | GL.matrixMode(5889); 116 | GL.pushMatrix(); 117 | GL.loadIdentity(); 118 | Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); 119 | GL.matrixMode(5888); 120 | GL.pushMatrix(); 121 | GL.loadIdentity(); 122 | GL.color(1.0F, 1.0F, 1.0F, 1.0F); 123 | GL.rotate(180.0F, 1.0F, 0.0F, 0.0F); 124 | GL.rotate(90.0F, 0.0F, 0.0F, 1.0F); 125 | GL.enableBlend(); 126 | GL.disableAlpha(); 127 | GL.disableCull(); 128 | GL.depthMask(false); 129 | GL.tryBlendFuncSeparate(770, 771, 1, 0); 130 | int i = 8; 131 | 132 | for (int j = 0; j < i * i; ++j) { 133 | GL.pushMatrix(); 134 | float f = ((float) (j % i) / (float) i - 0.5F) / 64.0F; 135 | float f1 = ((float) (j / i) / (float) i - 0.5F) / 64.0F; 136 | float f2 = 0.0F; 137 | GL.translate(f, f1, f2); 138 | GL.rotate(MathHelper.sin((panoramaTimer + partialTicks) / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F, 0.0F); 139 | GL.rotate(-(panoramaTimer + partialTicks) * 0.1F, 0.0F, 1.0F, 0.0F); 140 | 141 | for (int k = 0; k < 6; ++k) { 142 | GL.pushMatrix(); 143 | 144 | if (k == 1) { 145 | GL.rotate(90.0F, 0.0F, 1.0F, 0.0F); 146 | } 147 | 148 | if (k == 2) { 149 | GL.rotate(180.0F, 0.0F, 1.0F, 0.0F); 150 | } 151 | 152 | if (k == 3) { 153 | GL.rotate(-90.0F, 0.0F, 1.0F, 0.0F); 154 | } 155 | 156 | if (k == 4) { 157 | GL.rotate(90.0F, 1.0F, 0.0F, 0.0F); 158 | } 159 | 160 | if (k == 5) { 161 | GL.rotate(-90.0F, 1.0F, 0.0F, 0.0F); 162 | } 163 | 164 | Minecraft.getMinecraft().getTextureManager().bindTexture(panoramaPaths[k]); 165 | tess.begin(GL11.GL_QUADS, TessellatorAccess.Format.POSITION_TEX_COLOR); 166 | int l = 255 / (j + 1); 167 | tess.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).color(255, 255, 255, l).endVertex(); 168 | tess.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).color(255, 255, 255, l).endVertex(); 169 | tess.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).color(255, 255, 255, l).endVertex(); 170 | tess.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).color(255, 255, 255, l).endVertex(); 171 | tess.draw(); 172 | GL.popMatrix(); 173 | } 174 | 175 | GL.popMatrix(); 176 | GL.colorMask(true, true, true, false); 177 | } 178 | 179 | GL.colorMask(true, true, true, true); 180 | GL.matrixMode(5889); 181 | GL.popMatrix(); 182 | GL.matrixMode(5888); 183 | GL.popMatrix(); 184 | GL.depthMask(true); 185 | GL.enableCull(); 186 | GL.enableDepth(); 187 | } 188 | 189 | /** 190 | * Rotate and blurs the skybox view in the main menu 191 | */ 192 | private void rotateAndBlurSkybox() { 193 | Minecraft.getMinecraft().getTextureManager().bindTexture(this.backgroundTexture); 194 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); 195 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); 196 | GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256); 197 | GL.enableBlend(); 198 | GL.tryBlendFuncSeparate(770, 771, 1, 0); 199 | GL.colorMask(true, true, true, false); 200 | TessellatorAccess tess = LaminateInternal.tess(); 201 | tess.begin(GL11.GL_QUADS, TessellatorAccess.Format.POSITION_TEX_COLOR); 202 | GL.disableAlpha(); 203 | int i = 3; 204 | 205 | for (int j = 0; j < i; ++j) { 206 | float f = 1.0F / (j + 1); 207 | int k = Laminate.getWidth(); 208 | int l = Laminate.getHeight(); 209 | float f1 = (j - i / 2) / 256.0F; 210 | tess.pos(k, l, 0).tex(0.0F + f1, 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex(); 211 | tess.pos(k, 0.0D, 0).tex(1.0F + f1, 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex(); 212 | tess.pos(0.0D, 0.0D, 0).tex(1.0F + f1, 0.0D).color(1.0F, 1.0F, 1.0F, f).endVertex(); 213 | tess.pos(0.0D, l, 0).tex(0.0F + f1, 0.0D).color(1.0F, 1.0F, 1.0F, f).endVertex(); 214 | } 215 | 216 | tess.draw(); 217 | GL.enableAlpha(); 218 | GL.colorMask(true, true, true, true); 219 | } 220 | 221 | /** 222 | * Renders the skybox in the main menu 223 | */ 224 | private void renderSkybox(float partialTicks) { 225 | Minecraft.getMinecraft().getFramebuffer().unbindFramebuffer(); 226 | GL.viewport(0, 0, 256, 256); 227 | this.drawPanorama(partialTicks); 228 | this.rotateAndBlurSkybox(); 229 | this.rotateAndBlurSkybox(); 230 | this.rotateAndBlurSkybox(); 231 | this.rotateAndBlurSkybox(); 232 | this.rotateAndBlurSkybox(); 233 | this.rotateAndBlurSkybox(); 234 | this.rotateAndBlurSkybox(); 235 | Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); 236 | GL.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); 237 | float f = Laminate.getWidth() > Laminate.getHeight() ? 120.0F / Laminate.getWidth() : 120.0F / Laminate.getHeight(); 238 | float f1 = Laminate.getHeight() * f / 256.0F; 239 | float f2 = Laminate.getWidth() * f / 256.0F; 240 | int i = Laminate.getWidth(); 241 | int j = Laminate.getHeight(); 242 | TessellatorAccess tess = LaminateInternal.tess(); 243 | tess.begin(GL11.GL_QUADS, TessellatorAccess.Format.POSITION_TEX_COLOR); 244 | tess.pos(0.0D, j, 0).tex(0.5F - f1, 0.5F + f2).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex(); 245 | tess.pos(i, j, 0).tex(0.5F - f1, 0.5F - f2).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex(); 246 | tess.pos(i, 0.0D, 0).tex(0.5F + f1, 0.5F - f2).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex(); 247 | tess.pos(0.0D, 0.0D, 0).tex(0.5F + f1, 0.5F + f2).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex(); 248 | tess.draw(); 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/shadowbox/Shadowbox.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate.shadowbox; 2 | 3 | /** 4 | * A background for a Screen. Can range from extremely simple, 5 | * like a solid color, to something complex like an end portal 6 | * background or main-menu-esque panorama. 7 | * 8 | * @see PanoramaShadowbox 9 | * @see SolidShadowbox 10 | * @see EndShadowbox 11 | * @see TextureShadowbox 12 | */ 13 | public abstract class Shadowbox { 14 | public abstract void render(float partialTicks); 15 | public void tick() { 16 | // not all subclasses will need this method 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/shadowbox/SolidShadowbox.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate.shadowbox; 2 | 3 | import aesen.laminate.Laminate; 4 | import aesen.laminate.Rendering; 5 | 6 | /* 7 | * A shadowbox consisting of one solid color. 8 | */ 9 | public class SolidShadowbox extends Shadowbox { 10 | private int color; 11 | 12 | /** 13 | * Creates a SolidShadowbox of the given packed 24-bit color. 14 | * @param color a packed color, such as 0xFF0000 15 | */ 16 | public SolidShadowbox(int color) { 17 | this.color = color; 18 | } 19 | 20 | /** 21 | * Creates a SolidShadowbox with the given red, green, and blue values. 22 | * @param r the red value 23 | * @param g the green value 24 | * @param b the blue value 25 | */ 26 | public SolidShadowbox(float r, float g, float b) { 27 | int packed = 0; 28 | packed |= (((int)(r*255))&0xFF)<<16; 29 | packed |= (((int)(g*255))&0xFF)<<8; 30 | packed |= ((int)(b*255))&0xFF; 31 | this.color = packed; 32 | } 33 | 34 | public int getColor() { 35 | return color; 36 | } 37 | 38 | public void setColor(int color) { 39 | this.color = color; 40 | } 41 | 42 | @Override 43 | public void render(float partialTicks) { 44 | Rendering.drawRect(0, 0, Laminate.getWidth(), Laminate.getHeight(), color | 0xFF000000); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/aesen/laminate/shadowbox/TextureShadowbox.java: -------------------------------------------------------------------------------- 1 | package aesen.laminate.shadowbox; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | 5 | import com.unascribed.laminate.internal.GL; 6 | import com.unascribed.laminate.internal.LaminateInternal; 7 | import com.unascribed.laminate.internal.tessellator.TessellatorAccess; 8 | 9 | import aesen.laminate.Laminate; 10 | import net.minecraft.client.Minecraft; 11 | import net.minecraft.client.gui.Gui; 12 | import net.minecraft.util.ResourceLocation; 13 | 14 | /** 15 | * A shadowbox that is just a tiled texture covering the entire background. 16 | * 17 | */ 18 | public class TextureShadowbox extends Shadowbox { 19 | private ResourceLocation texture; 20 | 21 | /** 22 | * Creates a TextureShadowbox with the default gui background texture, 23 | * which is dirt on the default resource pack. 24 | */ 25 | public TextureShadowbox() { 26 | this(Gui.optionsBackground); 27 | } 28 | 29 | /** 30 | * Creates a TextureShadowbox with the given background texture. 31 | * @param texture the texture to use 32 | */ 33 | public TextureShadowbox(ResourceLocation texture) { 34 | this.texture = texture; 35 | } 36 | 37 | public void setTexture(ResourceLocation texture) { 38 | this.texture = texture; 39 | } 40 | 41 | public ResourceLocation getTexture() { 42 | return texture; 43 | } 44 | 45 | @Override 46 | public void render(float partialTicks) { 47 | int width = Laminate.getWidth(); 48 | int height = Laminate.getHeight(); 49 | 50 | GL.disableLighting(); 51 | GL.disableFog(); 52 | TessellatorAccess tess = LaminateInternal.tess(); 53 | 54 | Minecraft.getMinecraft().getTextureManager().bindTexture(texture); 55 | GL.color(1.0F, 1.0F, 1.0F, 1.0F); 56 | tess.begin(GL11.GL_QUADS, TessellatorAccess.Format.POSITION_TEX_COLOR); 57 | tess.pos(0, height, 0).tex(0, height / 32f).color(64, 64, 64, 255).endVertex(); 58 | tess.pos(width, height, 0).tex(width / 32f, height / 32f).color(64, 64, 64, 255).endVertex(); 59 | tess.pos(width, 0, 0).tex(width / 32f, 0).color(64, 64, 64, 255).endVertex(); 60 | tess.pos(0, 0, 0).tex(0, 0).color(64, 64, 64, 255).endVertex(); 61 | tess.draw(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/unascribed/laminate/internal/GL.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal; 2 | 3 | import java.nio.FloatBuffer; 4 | 5 | import aesen.laminate.Colors; 6 | 7 | public final class GL { 8 | 9 | public static void pushAttrib() { 10 | LaminateInternal.gl().pushAttrib(); 11 | } 12 | 13 | public static void popAttrib() { 14 | LaminateInternal.gl().popAttrib(); 15 | } 16 | 17 | public static void disableAlpha() { 18 | LaminateInternal.gl().disableAlpha(); 19 | } 20 | 21 | public static void enableAlpha() { 22 | LaminateInternal.gl().enableAlpha(); 23 | } 24 | 25 | public static void alphaFunc(int func, float ref) { 26 | LaminateInternal.gl().alphaFunc(func, ref); 27 | } 28 | 29 | public static void enableLighting() { 30 | LaminateInternal.gl().enableLighting(); 31 | } 32 | 33 | public static void disableLighting() { 34 | LaminateInternal.gl().disableLighting(); 35 | } 36 | 37 | public static void enableLight(int light) { 38 | LaminateInternal.gl().enableLight(light); 39 | } 40 | 41 | public static void disableLight(int light) { 42 | LaminateInternal.gl().disableLight(light); 43 | } 44 | 45 | public static void enableColorMaterial() { 46 | LaminateInternal.gl().enableColorMaterial(); 47 | } 48 | 49 | public static void disableColorMaterial() { 50 | LaminateInternal.gl().disableColorMaterial(); 51 | } 52 | 53 | public static void colorMaterial(int face, int mode) { 54 | LaminateInternal.gl().colorMaterial(face, mode); 55 | } 56 | 57 | public static void disableDepth() { 58 | LaminateInternal.gl().disableDepth(); 59 | } 60 | 61 | public static void enableDepth() { 62 | LaminateInternal.gl().enableDepth(); 63 | } 64 | 65 | public static void depthFunc(int depthFunc) { 66 | LaminateInternal.gl().depthFunc(depthFunc); 67 | } 68 | 69 | public static void depthMask(boolean flagIn) { 70 | LaminateInternal.gl().depthMask(flagIn); 71 | } 72 | 73 | public static void disableBlend() { 74 | LaminateInternal.gl().disableBlend(); 75 | } 76 | 77 | public static void enableBlend() { 78 | LaminateInternal.gl().enableBlend(); 79 | } 80 | 81 | public static void blendFunc(int srcFactor, int dstFactor) { 82 | LaminateInternal.gl().blendFunc(srcFactor, dstFactor); 83 | } 84 | 85 | public static void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) { 86 | LaminateInternal.gl().tryBlendFuncSeparate(srcFactor, dstFactor, srcFactorAlpha, dstFactorAlpha); 87 | } 88 | 89 | public static void enableFog() { 90 | LaminateInternal.gl().enableFog(); 91 | } 92 | 93 | public static void disableFog() { 94 | LaminateInternal.gl().disableFog(); 95 | } 96 | 97 | public static void setFog(int param) { 98 | LaminateInternal.gl().setFog(param); 99 | } 100 | 101 | public static void setFogDensity(float param) { 102 | LaminateInternal.gl().setFogDensity(param); 103 | } 104 | 105 | public static void setFogStart(float param) { 106 | LaminateInternal.gl().setFogStart(param); 107 | } 108 | 109 | public static void setFogEnd(float param) { 110 | LaminateInternal.gl().setFogEnd(param); 111 | } 112 | 113 | public static void enableCull() { 114 | LaminateInternal.gl().enableCull(); 115 | } 116 | 117 | public static void disableCull() { 118 | LaminateInternal.gl().disableCull(); 119 | } 120 | 121 | public static void cullFace(int mode) { 122 | LaminateInternal.gl().cullFace(mode); 123 | } 124 | 125 | public static void enablePolygonOffset() { 126 | LaminateInternal.gl().enablePolygonOffset(); 127 | } 128 | 129 | public static void disablePolygonOffset() { 130 | LaminateInternal.gl().disablePolygonOffset(); 131 | } 132 | 133 | public static void doPolygonOffset(float factor, float units) { 134 | LaminateInternal.gl().doPolygonOffset(factor, units); 135 | } 136 | 137 | public static void enableColorLogic() { 138 | LaminateInternal.gl().enableColorLogic(); 139 | } 140 | 141 | public static void disableColorLogic() { 142 | LaminateInternal.gl().disableColorLogic(); 143 | } 144 | 145 | public static void colorLogicOp(int opcode) { 146 | LaminateInternal.gl().colorLogicOp(opcode); 147 | } 148 | 149 | public static void setActiveTexture(int texture) { 150 | LaminateInternal.gl().setActiveTexture(texture); 151 | } 152 | 153 | public static void enableTexture2D() { 154 | LaminateInternal.gl().enableTexture2D(); 155 | } 156 | 157 | public static void disableTexture2D() { 158 | LaminateInternal.gl().disableTexture2D(); 159 | } 160 | 161 | public static void deleteTexture(int texture) { 162 | LaminateInternal.gl().deleteTexture(texture); 163 | } 164 | 165 | public static void bindTexture(int texture) { 166 | LaminateInternal.gl().bindTexture(texture); 167 | } 168 | 169 | public static void enableNormalize() { 170 | LaminateInternal.gl().enableNormalize(); 171 | } 172 | 173 | public static void disableNormalize() { 174 | LaminateInternal.gl().disableNormalize(); 175 | } 176 | 177 | public static void shadeModel(int mode) { 178 | LaminateInternal.gl().shadeModel(mode); 179 | } 180 | 181 | public static void enableRescaleNormal() { 182 | LaminateInternal.gl().enableRescaleNormal(); 183 | } 184 | 185 | public static void disableRescaleNormal() { 186 | LaminateInternal.gl().disableRescaleNormal(); 187 | } 188 | 189 | public static void viewport(int x, int y, int width, int height) { 190 | LaminateInternal.gl().viewport(x, y, width, height); 191 | } 192 | 193 | public static void colorMask(boolean red, boolean green, boolean blue, boolean alpha) { 194 | LaminateInternal.gl().colorMask(red, green, blue, alpha); 195 | } 196 | 197 | public static void clearDepth(double depth) { 198 | LaminateInternal.gl().clearDepth(depth); 199 | } 200 | 201 | public static void clearColor(float red, float green, float blue, float alpha) { 202 | LaminateInternal.gl().clearColor(red, green, blue, alpha); 203 | } 204 | 205 | public static void clear(int mask) { 206 | LaminateInternal.gl().clear(mask); 207 | } 208 | 209 | public static void matrixMode(int mode) { 210 | LaminateInternal.gl().matrixMode(mode); 211 | } 212 | 213 | public static void loadIdentity() { 214 | LaminateInternal.gl().loadIdentity(); 215 | } 216 | 217 | public static void pushMatrix() { 218 | LaminateInternal.gl().pushMatrix(); 219 | } 220 | 221 | public static void popMatrix() { 222 | LaminateInternal.gl().popMatrix(); 223 | } 224 | 225 | public static void getFloat(int pname, FloatBuffer params) { 226 | LaminateInternal.gl().getFloat(pname, params); 227 | } 228 | 229 | public static void ortho(double left, double right, double bottom, double top, double zNear, double zFar) { 230 | LaminateInternal.gl().ortho(left, right, bottom, top, zNear, zFar); 231 | } 232 | 233 | public static void rotate(float angle, float x, float y, float z) { 234 | LaminateInternal.gl().rotate(angle, x, y, z); 235 | } 236 | 237 | public static void scale(float x, float y, float z) { 238 | LaminateInternal.gl().scale(x, y, z); 239 | } 240 | 241 | public static void scale(double x, double y, double z) { 242 | LaminateInternal.gl().scale(x, y, z); 243 | } 244 | 245 | public static void translate(float x, float y, float z) { 246 | LaminateInternal.gl().translate(x, y, z); 247 | } 248 | 249 | public static void translate(double x, double y, double z) { 250 | LaminateInternal.gl().translate(x, y, z); 251 | } 252 | 253 | public static void multMatrix(FloatBuffer matrix) { 254 | LaminateInternal.gl().multMatrix(matrix); 255 | } 256 | 257 | public static void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha) { 258 | LaminateInternal.gl().color(colorRed, colorGreen, colorBlue, colorAlpha); 259 | } 260 | 261 | public static void color(float colorRed, float colorGreen, float colorBlue) { 262 | LaminateInternal.gl().color(colorRed, colorGreen, colorBlue); 263 | } 264 | 265 | public static void color(int packed) { 266 | color(Colors.unpackR(packed), Colors.unpackG(packed), Colors.unpackB(packed), Colors.unpackA(packed)); 267 | } 268 | 269 | public static void resetColor() { 270 | LaminateInternal.gl().resetColor(); 271 | } 272 | 273 | public static void callList(int list) { 274 | LaminateInternal.gl().callList(list); 275 | } 276 | 277 | public static void pushScissor() { 278 | SmartScissor.push(); 279 | } 280 | 281 | public static void popScissor() { 282 | SmartScissor.pop(); 283 | } 284 | 285 | public static void setScissorFromComponentCoordinates(int x, int y, int width, int height) { 286 | SmartScissor.setFromComponentCoordinates(x, y, width, height); 287 | } 288 | 289 | public static void setScissor(int x, int y, int width, int height) { 290 | SmartScissor.set(x, y, width, height); 291 | } 292 | 293 | public static void translateScissor(int x, int y) { 294 | SmartScissor.translate(x, y); 295 | } 296 | 297 | private GL() {} 298 | 299 | } 300 | -------------------------------------------------------------------------------- /src/main/java/com/unascribed/laminate/internal/LaminateInternal.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.lwjgl.input.Keyboard; 6 | 7 | import com.google.common.base.Function; 8 | import com.unascribed.laminate.internal.gl.DirectGLAccess; 9 | import com.unascribed.laminate.internal.gl.GLAccess; 10 | import com.unascribed.laminate.internal.gl.StateManagerGLAccess; 11 | import com.unascribed.laminate.internal.tessellator.OldTessellatorAccess; 12 | import com.unascribed.laminate.internal.tessellator.SplitTessellatorAccess; 13 | import com.unascribed.laminate.internal.tessellator.TessellatorAccess; 14 | import com.unascribed.laminate.internal.tessellator.VertexBuilderTessellatorAccess; 15 | 16 | import aesen.laminate.Laminate; 17 | import aesen.laminate.component.Box; 18 | import aesen.laminate.component.Image; 19 | import aesen.laminate.component.Label; 20 | import aesen.laminate.component.Panel; 21 | import aesen.laminate.screen.Screen; 22 | import aesen.laminate.shadowbox.EndShadowbox; 23 | import aesen.laminate.shadowbox.PanoramaShadowbox; 24 | import aesen.laminate.shadowbox.SolidShadowbox; 25 | import aesen.laminate.shadowbox.TextureShadowbox; 26 | import net.minecraft.client.Minecraft; 27 | import net.minecraft.client.gui.GuiMainMenu; 28 | import net.minecraft.client.gui.GuiScreen; 29 | import net.minecraft.client.gui.ScaledResolution; 30 | import net.minecraft.util.ResourceLocation; 31 | 32 | /** 33 | * Internal class. Do not use. 34 | * 35 | */ 36 | public class LaminateInternal implements LaminateCore { 37 | public static int globalPanoramaTimer; 38 | private static GLAccess gl; 39 | private static TessellatorAccess tess; 40 | private static Function scaledResolutionFactory; 41 | public static final Logger log = LogManager.getLogger("Laminate"); 42 | 43 | private static ScaledResolution cachedResolution; 44 | 45 | @Override 46 | public void preInit(String mcVersion) { 47 | switch (mcVersion) { 48 | case "1.7.2": 49 | case "1.7.10": 50 | tess = new OldTessellatorAccess(); 51 | gl = new DirectGLAccess(); 52 | scaledResolutionFactory = OneEight.SCALED_RESOLUTION_FACTORY; 53 | log.info("Running on "+mcVersion+", using old tessellator and direct GL"); 54 | break; 55 | case "1.8": 56 | tess = new SplitTessellatorAccess(); 57 | gl = new StateManagerGLAccess(true); 58 | scaledResolutionFactory = OneEight.SCALED_RESOLUTION_FACTORY; 59 | log.info("Running on "+mcVersion+", using split tessellator and managed GL with emulated pushAttrib/popAttrib"); 60 | break; 61 | case "1.8.8": 62 | case "1.8.9": 63 | tess = new VertexBuilderTessellatorAccess(); 64 | gl = new StateManagerGLAccess(true); 65 | scaledResolutionFactory = OneEightNine.SCALED_RESOLUTION_FACTORY; 66 | log.info("Running on "+mcVersion+", using vertex builder tessellator and managed GL with emulated pushAttrib/popAttrib"); 67 | break; 68 | default: 69 | throw new RuntimeException("Laminate cannot run on Minecraft version "+mcVersion); 70 | } 71 | } 72 | 73 | @Override 74 | public void frame() { 75 | cachedResolution = null; 76 | } 77 | 78 | @Override 79 | public void tick(boolean start) { 80 | if (start) { 81 | if (Keyboard.isKeyDown(Keyboard.KEY_P)) { 82 | Screen screen = new Screen(); 83 | screen.setShadowbox(new PanoramaShadowbox()); 84 | Laminate.display(screen); 85 | } else if (Keyboard.isKeyDown(Keyboard.KEY_E)) { 86 | Screen screen = new Screen(); 87 | screen.setShadowbox(new EndShadowbox()); 88 | Laminate.display(screen); 89 | } else if (Keyboard.isKeyDown(Keyboard.KEY_T)) { 90 | Screen screen = new Screen(); 91 | screen.setShadowbox(new TextureShadowbox()); 92 | Laminate.display(screen); 93 | } else if (Keyboard.isKeyDown(Keyboard.KEY_C)) { 94 | Screen screen = new Screen(); 95 | screen.setShadowbox(new SolidShadowbox(1, 0.5f, 0)); 96 | Laminate.display(screen); 97 | } else if (Keyboard.isKeyDown(Keyboard.KEY_Z)) { 98 | Box group = new Box(); 99 | Screen screen = new Screen() { 100 | @Override 101 | public void renderForeground(float partialTicks) { 102 | super.renderForeground(partialTicks); 103 | Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().debug.split("fps ")[0]+"fps", width-100, height-36, 0); 104 | Minecraft.getMinecraft().fontRendererObj.drawString(group.size()+" components", width-100, height-24, 0); 105 | } 106 | }; 107 | group.setX(0); 108 | group.setY(0); 109 | group.setWidth(99); 110 | group.setHeight(800); 111 | screen.setShadowbox(new SolidShadowbox(1, 1, 1)); 112 | for (int i = 0; i < 10000; i++) { 113 | Box box = new Box(); 114 | box.setColor(0xFF000000); 115 | box.setWidth(1); 116 | box.setHeight(1); 117 | box.setX((i*2)%99); 118 | box.setY((i*2)/99); 119 | group.add(box); 120 | } 121 | screen.add(group); 122 | Laminate.display(screen); 123 | } else if (Keyboard.isKeyDown(Keyboard.KEY_U)) { 124 | Screen screen = new Screen(); 125 | Panel panel = new Panel(); 126 | panel.setX(10); 127 | panel.setY(10); 128 | panel.setWidth(200); 129 | panel.setHeight(100); 130 | panel.setShowBorder(true); 131 | panel.setTitle("Hello"); 132 | Box box = new Box(); 133 | box.setColor(0xFFFF0000); 134 | box.setWidth(3000); 135 | box.setHeight(3000); 136 | panel.add(box); 137 | screen.add(panel); 138 | 139 | Panel panel2 = new Panel(); 140 | panel2.setX(220); 141 | panel2.setY(10); 142 | panel2.setWidth(100); 143 | panel2.setHeight(100); 144 | panel2.setShowBorder(true); 145 | panel2.add(box); // should this be considered a bug? 146 | screen.add(panel2); 147 | 148 | Panel panel3 = new Panel(); 149 | panel3.setX(10); 150 | panel3.setY(120); 151 | panel3.setWidth(100); 152 | panel3.setHeight(100); 153 | panel3.add(box); 154 | screen.add(panel3); 155 | 156 | Laminate.display(screen); 157 | } else if (Keyboard.isKeyDown(Keyboard.KEY_J)) { 158 | Screen screen = new Screen(); 159 | Label label = new Label(); 160 | label.setX(10); 161 | label.setY(10); 162 | label.setText("Hello"); 163 | screen.add(label); 164 | 165 | Image image = new Image(); 166 | image.setWidth(16); 167 | image.setHeight(16); 168 | image.setX(10); 169 | image.setY(20); 170 | image.setSource(new ResourceLocation("minecraft", "textures/items/diamond.png")); 171 | screen.add(image); 172 | 173 | Laminate.display(screen); 174 | } 175 | } else { 176 | GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen; 177 | if (currentScreen instanceof GuiMainMenu) { 178 | ((GuiMainMenu)Minecraft.getMinecraft().currentScreen).panoramaTimer = globalPanoramaTimer; 179 | } 180 | globalPanoramaTimer++; 181 | } 182 | } 183 | 184 | public static GuiScreen createMirror(Screen screen) { 185 | return new Mirror(screen); 186 | } 187 | 188 | public static Screen unwrapMirror(GuiScreen screen) { 189 | if (screen instanceof Mirror) { 190 | return ((Mirror)screen).getScreen(); 191 | } 192 | return null; 193 | } 194 | 195 | public static GLAccess gl() { 196 | return gl; 197 | } 198 | 199 | public static TessellatorAccess tess() { 200 | return tess; 201 | } 202 | 203 | public static ScaledResolution createScaledResolution() { 204 | if (cachedResolution == null) { 205 | cachedResolution = scaledResolutionFactory.apply(Minecraft.getMinecraft()); 206 | } 207 | return cachedResolution; 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /src/main/java/com/unascribed/laminate/internal/Mirror.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal; 2 | 3 | import aesen.laminate.screen.Screen; 4 | import net.minecraft.client.gui.GuiScreen; 5 | 6 | class Mirror extends GuiScreen { 7 | private final Screen screen; 8 | public Mirror(Screen screen) { 9 | this.screen = screen; 10 | } 11 | 12 | public Screen getScreen() { 13 | return screen; 14 | } 15 | 16 | @Override 17 | public void initGui() { 18 | super.initGui(); 19 | screen.setWidth(width); 20 | screen.setHeight(height); 21 | } 22 | 23 | @Override 24 | public void drawScreen(int mouseX, int mouseY, float partialTicks) { 25 | screen.renderShadowbox(partialTicks); 26 | screen.renderForeground(partialTicks); 27 | } 28 | 29 | @Override 30 | public void updateScreen() { 31 | screen.tick(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/unascribed/laminate/internal/OneEightNine.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal; 2 | 3 | import com.google.common.base.Function; 4 | 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.gui.ScaledResolution; 7 | 8 | public class OneEightNine { 9 | public static final Function SCALED_RESOLUTION_FACTORY = ScaledResolution::new; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/unascribed/laminate/internal/SmartScissor.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal; 2 | 3 | import java.awt.Rectangle; 4 | import java.util.List; 5 | 6 | import org.lwjgl.opengl.GL11; 7 | 8 | import com.google.common.collect.Lists; 9 | 10 | import net.minecraft.client.Minecraft; 11 | import net.minecraft.client.gui.ScaledResolution; 12 | 13 | /** 14 | * Implements a smarter scissor designed for nesting. Essentially makes 15 | * setting a scissor box clip that box to the current scissor box. 16 | */ 17 | public final class SmartScissor { 18 | private static class State implements Cloneable { 19 | public boolean enabled; 20 | public int transX; 21 | public int transY; 22 | public int x; 23 | public int y; 24 | public int width; 25 | public int height; 26 | 27 | @Override 28 | public State clone() { 29 | try { 30 | return (State)super.clone(); 31 | } catch (CloneNotSupportedException e) { 32 | throw new AssertionError(e); 33 | } 34 | } 35 | } 36 | 37 | private static State state = new State(); 38 | 39 | private static List stateStack = Lists.newArrayList(); 40 | 41 | public static void push() { 42 | stateStack.add(state.clone()); 43 | GL11.glPushAttrib(GL11.GL_SCISSOR_BIT); 44 | } 45 | 46 | public static void pop() { 47 | state = stateStack.remove(stateStack.size()-1); 48 | GL11.glPopAttrib(); 49 | } 50 | 51 | public static void unset() { 52 | GL11.glDisable(GL11.GL_SCISSOR_TEST); 53 | state.enabled = false; 54 | } 55 | 56 | public static void setFromComponentCoordinates(int x, int y, int width, int height) { 57 | ScaledResolution res = LaminateInternal.createScaledResolution(); 58 | int scaleFactor = res.getScaleFactor(); 59 | 60 | int screenX = x*scaleFactor; 61 | int screenY = y*scaleFactor; 62 | int screenWidth = width*scaleFactor; 63 | int screenHeight = height*scaleFactor; 64 | screenY = Minecraft.getMinecraft().displayHeight-screenY-screenHeight; 65 | set(screenX, screenY, screenWidth, screenHeight); 66 | } 67 | 68 | public static void set(int x, int y, int width, int height) { 69 | Rectangle screen = new Rectangle(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); 70 | Rectangle current; 71 | if (state.enabled) { 72 | current = new Rectangle(state.x, state.y, state.width, state.height); 73 | } else { 74 | current = screen; 75 | } 76 | Rectangle target = new Rectangle(x+state.transX, y+state.transY, width, height); 77 | Rectangle result = current.intersection(target); 78 | result = result.intersection(screen); 79 | if (result.width < 0) result.width = 0; 80 | if (result.height < 0) result.height = 0; 81 | state.enabled = true; 82 | state.x = result.x; 83 | state.y = result.y; 84 | state.width = result.width; 85 | state.height = result.height; 86 | GL11.glEnable(GL11.GL_SCISSOR_TEST); 87 | GL11.glScissor(result.x, result.y, result.width, result.height); 88 | } 89 | 90 | public static void translate(int x, int y) { 91 | state.transX = x; 92 | state.transY = y; 93 | } 94 | 95 | public static void translateFromComponentCoordinates(int x, int y) { 96 | ScaledResolution res = LaminateInternal.createScaledResolution(); 97 | int totalHeight = res.getScaledHeight(); 98 | int scaleFactor = res.getScaleFactor(); 99 | 100 | int screenX = x*scaleFactor; 101 | int screenY = y*scaleFactor; 102 | screenY = (totalHeight*scaleFactor)-screenY; 103 | translate(screenX, screenY); 104 | } 105 | 106 | private SmartScissor() {} 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/com/unascribed/laminate/internal/gl/DirectGLAccess.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal.gl; 2 | 3 | import java.nio.FloatBuffer; 4 | 5 | import org.lwjgl.opengl.GL11; 6 | import org.lwjgl.opengl.GL12; 7 | 8 | import net.minecraft.client.renderer.OpenGlHelper; 9 | 10 | public class DirectGLAccess implements GLAccess { 11 | 12 | @Override 13 | public void pushAttrib() { 14 | GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_LIGHTING_BIT); 15 | } 16 | 17 | @Override 18 | public void popAttrib() { 19 | GL11.glPopAttrib(); 20 | } 21 | 22 | @Override 23 | public void disableAlpha() { 24 | GL11.glDisable(GL11.GL_ALPHA_TEST); 25 | } 26 | 27 | @Override 28 | public void enableAlpha() { 29 | GL11.glEnable(GL11.GL_ALPHA_TEST); 30 | } 31 | 32 | @Override 33 | public void alphaFunc(int func, float ref) { 34 | GL11.glAlphaFunc(func, ref); 35 | } 36 | 37 | @Override 38 | public void enableLighting() { 39 | GL11.glEnable(GL11.GL_LIGHTING); 40 | } 41 | 42 | @Override 43 | public void disableLighting() { 44 | GL11.glDisable(GL11.GL_LIGHTING); 45 | } 46 | 47 | @Override 48 | public void enableLight(int light) { 49 | GL11.glEnable(GL11.GL_LIGHT0+light); // yes, this is totally valid and is encouraged in the GL docs 50 | } 51 | 52 | @Override 53 | public void disableLight(int light) { 54 | GL11.glDisable(GL11.GL_LIGHT0+light); 55 | } 56 | 57 | @Override 58 | public void enableColorMaterial() { 59 | GL11.glEnable(GL11.GL_COLOR_MATERIAL); 60 | } 61 | 62 | @Override 63 | public void disableColorMaterial() { 64 | GL11.glDisable(GL11.GL_COLOR_MATERIAL); 65 | } 66 | 67 | @Override 68 | public void colorMaterial(int face, int mode) { 69 | GL11.glColorMaterial(face, mode); 70 | } 71 | 72 | @Override 73 | public void disableDepth() { 74 | GL11.glDisable(GL11.GL_DEPTH_TEST); 75 | } 76 | 77 | @Override 78 | public void enableDepth() { 79 | GL11.glEnable(GL11.GL_DEPTH_TEST); 80 | } 81 | 82 | @Override 83 | public void depthFunc(int func) { 84 | GL11.glDepthFunc(func); 85 | } 86 | 87 | @Override 88 | public void depthMask(boolean flag) { 89 | GL11.glDepthMask(flag); 90 | } 91 | 92 | @Override 93 | public void disableBlend() { 94 | GL11.glDisable(GL11.GL_BLEND); 95 | } 96 | 97 | @Override 98 | public void enableBlend() { 99 | GL11.glEnable(GL11.GL_BLEND); 100 | } 101 | 102 | @Override 103 | public void blendFunc(int srcFactor, int dstFactor) { 104 | GL11.glBlendFunc(srcFactor, dstFactor); 105 | } 106 | 107 | @Override 108 | public void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) { 109 | OpenGlHelper.glBlendFunc(srcFactor, dstFactor, srcFactorAlpha, dstFactorAlpha); 110 | } 111 | 112 | @Override 113 | public void enableFog() { 114 | GL11.glEnable(GL11.GL_FOG); 115 | } 116 | 117 | @Override 118 | public void disableFog() { 119 | GL11.glDisable(GL11.GL_FOG); 120 | } 121 | 122 | @Override 123 | public void setFog(int param) { 124 | GL11.glFogi(GL11.GL_FOG_MODE, param); 125 | } 126 | 127 | @Override 128 | public void setFogDensity(float param) { 129 | GL11.glFogf(GL11.GL_FOG_DENSITY, param); 130 | } 131 | 132 | @Override 133 | public void setFogStart(float param) { 134 | GL11.glFogf(GL11.GL_FOG_START, param); 135 | } 136 | 137 | @Override 138 | public void setFogEnd(float param) { 139 | GL11.glFogf(GL11.GL_FOG_END, param); 140 | } 141 | 142 | @Override 143 | public void enableCull() { 144 | GL11.glEnable(GL11.GL_CULL_FACE); 145 | } 146 | 147 | @Override 148 | public void disableCull() { 149 | GL11.glDisable(GL11.GL_CULL_FACE); 150 | } 151 | 152 | @Override 153 | public void cullFace(int mode) { 154 | GL11.glCullFace(mode); 155 | } 156 | 157 | @Override 158 | public void enablePolygonOffset() { 159 | GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); 160 | } 161 | 162 | @Override 163 | public void disablePolygonOffset() { 164 | GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); 165 | } 166 | 167 | @Override 168 | public void doPolygonOffset(float factor, float units) { 169 | GL11.glPolygonOffset(factor, units); 170 | } 171 | 172 | @Override 173 | public void enableColorLogic() { 174 | GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); 175 | } 176 | 177 | @Override 178 | public void disableColorLogic() { 179 | GL11.glDisable(GL11.GL_COLOR_LOGIC_OP); 180 | } 181 | 182 | @Override 183 | public void colorLogicOp(int opcode) { 184 | GL11.glLogicOp(opcode); 185 | } 186 | 187 | @Override 188 | public void setActiveTexture(int texture) { 189 | OpenGlHelper.setActiveTexture(texture); 190 | } 191 | 192 | @Override 193 | public void enableTexture2D() { 194 | GL11.glEnable(GL11.GL_TEXTURE_2D); 195 | } 196 | 197 | @Override 198 | public void disableTexture2D() { 199 | GL11.glDisable(GL11.GL_TEXTURE_2D); 200 | } 201 | 202 | @Override 203 | public void deleteTexture(int texture) { 204 | GL11.glDeleteTextures(texture); 205 | } 206 | 207 | @Override 208 | public void bindTexture(int texture) { 209 | GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); 210 | } 211 | 212 | @Override 213 | public void enableNormalize() { 214 | GL11.glEnable(GL11.GL_NORMALIZE); 215 | } 216 | 217 | @Override 218 | public void disableNormalize() { 219 | GL11.glEnable(GL11.GL_NORMALIZE); 220 | } 221 | 222 | @Override 223 | public void shadeModel(int mode) { 224 | GL11.glShadeModel(mode); 225 | } 226 | 227 | @Override 228 | public void enableRescaleNormal() { 229 | GL11.glEnable(GL12.GL_RESCALE_NORMAL); 230 | } 231 | 232 | @Override 233 | public void disableRescaleNormal() { 234 | GL11.glDisable(GL12.GL_RESCALE_NORMAL); 235 | } 236 | 237 | @Override 238 | public void viewport(int x, int y, int width, int height) { 239 | GL11.glViewport(x, y, width, height); 240 | } 241 | 242 | @Override 243 | public void colorMask(boolean red, boolean green, boolean blue, boolean alpha) { 244 | GL11.glColorMask(red, green, blue, alpha); 245 | } 246 | 247 | @Override 248 | public void clearDepth(double depth) { 249 | GL11.glClearDepth(depth); 250 | } 251 | 252 | @Override 253 | public void clearColor(float red, float green, float blue, float alpha) { 254 | GL11.glClearColor(red, green, blue, alpha); 255 | } 256 | 257 | @Override 258 | public void clear(int mask) { 259 | GL11.glClear(mask); 260 | } 261 | 262 | @Override 263 | public void matrixMode(int mode) { 264 | GL11.glMatrixMode(mode); 265 | } 266 | 267 | @Override 268 | public void loadIdentity() { 269 | GL11.glLoadIdentity(); 270 | } 271 | 272 | @Override 273 | public void pushMatrix() { 274 | GL11.glPushMatrix(); 275 | } 276 | 277 | @Override 278 | public void popMatrix() { 279 | GL11.glPopMatrix(); 280 | } 281 | 282 | @Override 283 | public void getFloat(int pname, FloatBuffer params) { 284 | GL11.glGetFloat(pname, params); 285 | } 286 | 287 | @Override 288 | public void ortho(double left, double right, double bottom, double top, double zNear, double zFar) { 289 | GL11.glOrtho(left, right, bottom, top, zNear, zFar); 290 | } 291 | 292 | @Override 293 | public void rotate(float angle, float x, float y, float z) { 294 | GL11.glRotatef(angle, x, y, z); 295 | } 296 | 297 | @Override 298 | public void scale(float x, float y, float z) { 299 | GL11.glScalef(x, y, z); 300 | } 301 | 302 | @Override 303 | public void scale(double x, double y, double z) { 304 | GL11.glScaled(x, y, z); 305 | } 306 | 307 | @Override 308 | public void translate(float x, float y, float z) { 309 | GL11.glTranslatef(x, y, z); 310 | } 311 | 312 | @Override 313 | public void translate(double x, double y, double z) { 314 | GL11.glTranslated(x, y, z); 315 | } 316 | 317 | @Override 318 | public void multMatrix(FloatBuffer matrix) { 319 | GL11.glMultMatrix(matrix); 320 | } 321 | 322 | @Override 323 | public void color(float red, float green, float blue, float alpha) { 324 | GL11.glColor4f(red, green, blue, alpha); 325 | } 326 | 327 | @Override 328 | public void color(float red, float green, float blue) { 329 | GL11.glColor3f(red, green, blue); 330 | } 331 | 332 | @Override 333 | public void resetColor() { 334 | // does nothing when using GL directly 335 | } 336 | 337 | @Override 338 | public void callList(int list) { 339 | GL11.glCallList(list); 340 | } 341 | } 342 | -------------------------------------------------------------------------------- /src/main/java/com/unascribed/laminate/internal/gl/StateManagerGLAccess.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal.gl; 2 | 3 | import java.nio.FloatBuffer; 4 | 5 | import org.lwjgl.opengl.GL11; 6 | 7 | import gnu.trove.list.TIntList; 8 | import gnu.trove.list.array.TIntArrayList; 9 | import net.minecraft.client.renderer.GlStateManager; 10 | 11 | public class StateManagerGLAccess implements GLAccess { 12 | private static final int ALPHA_BIT = 0b1; 13 | private static final int BLEND_BIT = 0b10; 14 | private static final int COLOR_MATERIAL_BIT = 0b100; 15 | private static final int CULL_FACE_BIT = 0b1000; 16 | private static final int DEPTH_TEST_BIT = 0b10000; 17 | private static final int FOG_BIT = 0b100000; 18 | private static final int LIGHT0_BIT = 0b1000000; 19 | private static final int LIGHT1_BIT = 0b10000000; 20 | private static final int LIGHT2_BIT = 0b100000000; 21 | private static final int LIGHT3_BIT = 0b1000000000; 22 | private static final int LIGHT4_BIT = 0b10000000000; 23 | private static final int LIGHT5_BIT = 0b100000000000; 24 | private static final int LIGHT6_BIT = 0b1000000000000; 25 | private static final int LIGHT7_BIT = 0b10000000000000; 26 | private static final int LIGHTING_BIT = 0b100000000000000; 27 | private static final int COLOR_LOGIC_OP_BIT = 0b1000000000000000; 28 | private static final int NORMALIZE_BIT = 0b10000000000000000; 29 | private static final int POLYGON_OFFSET_FILL_BIT = 0b100000000000000000; 30 | private static final int POLYGON_OFFSET_LINE_BIT = 0b1000000000000000000; 31 | private static final int TEXTURE_GEN_S_BIT = 0b10000000000000000000; 32 | private static final int TEXTURE_GEN_T_BIT = 0b100000000000000000000; 33 | private static final int TEXTURE_GEN_R_BIT = 0b1000000000000000000000; 34 | private static final int TEXTURE_GEN_Q_BIT = 0b10000000000000000000000; 35 | private static final int TEXTURE_2D_0_BIT = 0b100000000000000000000000; 36 | private static final int TEXTURE_2D_1_BIT = 0b1000000000000000000000000; 37 | private static final int TEXTURE_2D_2_BIT = 0b10000000000000000000000000; 38 | private static final int TEXTURE_2D_3_BIT = 0b100000000000000000000000000; 39 | private static final int TEXTURE_2D_4_BIT = 0b1000000000000000000000000000; 40 | private static final int TEXTURE_2D_5_BIT = 0b10000000000000000000000000000; 41 | private static final int TEXTURE_2D_6_BIT = 0b100000000000000000000000000000; 42 | private static final int TEXTURE_2D_7_BIT = 0b1000000000000000000000000000000; 43 | private static final int SMOOTH_BIT = 0b10000000000000000000000000000000; 44 | 45 | private final TIntList attribStack = new TIntArrayList(); 46 | private final boolean emulatePushAttrib; 47 | 48 | public StateManagerGLAccess(boolean emulatePushAttrib) { 49 | this.emulatePushAttrib = emulatePushAttrib; 50 | } 51 | 52 | @Override 53 | public void pushAttrib() { 54 | if (emulatePushAttrib) { 55 | // Minecraft's GlStateManager desyncs when pushAttrib and popAttrib are used 56 | 57 | // this is basically what the state manager should be doing, and hopefully it 58 | // will do this in a future version of Minecraft 59 | int state = 0; 60 | if (GlStateManager.alphaState.alphaTest.currentState) state |= ALPHA_BIT; 61 | if (GlStateManager.blendState.blend.currentState) state |= BLEND_BIT; 62 | if (GlStateManager.colorMaterialState.colorMaterial.currentState) state |= COLOR_MATERIAL_BIT; 63 | if (GlStateManager.cullState.cullFace.currentState) state |= CULL_FACE_BIT; 64 | if (GlStateManager.depthState.depthTest.currentState) state |= DEPTH_TEST_BIT; 65 | if (GlStateManager.fogState.fog.currentState) state |= FOG_BIT; 66 | if (GlStateManager.lightState[0].currentState) state |= LIGHT0_BIT; 67 | if (GlStateManager.lightState[1].currentState) state |= LIGHT1_BIT; 68 | if (GlStateManager.lightState[2].currentState) state |= LIGHT2_BIT; 69 | if (GlStateManager.lightState[3].currentState) state |= LIGHT3_BIT; 70 | if (GlStateManager.lightState[4].currentState) state |= LIGHT4_BIT; 71 | if (GlStateManager.lightState[5].currentState) state |= LIGHT5_BIT; 72 | if (GlStateManager.lightState[6].currentState) state |= LIGHT6_BIT; 73 | if (GlStateManager.lightState[7].currentState) state |= LIGHT7_BIT; 74 | if (GlStateManager.lightingState.currentState) state |= LIGHTING_BIT; 75 | if (GlStateManager.colorLogicState.colorLogicOp.currentState) state |= COLOR_LOGIC_OP_BIT; 76 | if (GlStateManager.normalizeState.currentState) state |= NORMALIZE_BIT; 77 | if (GlStateManager.polygonOffsetState.polygonOffsetFill.currentState) state |= POLYGON_OFFSET_FILL_BIT; 78 | if (GlStateManager.polygonOffsetState.polygonOffsetLine.currentState) state |= POLYGON_OFFSET_LINE_BIT; 79 | if (GlStateManager.texGenState.s.textureGen.currentState) state |= TEXTURE_GEN_S_BIT; 80 | if (GlStateManager.texGenState.t.textureGen.currentState) state |= TEXTURE_GEN_T_BIT; 81 | if (GlStateManager.texGenState.r.textureGen.currentState) state |= TEXTURE_GEN_R_BIT; 82 | if (GlStateManager.texGenState.q.textureGen.currentState) state |= TEXTURE_GEN_Q_BIT; 83 | if (GlStateManager.textureState[0].texture2DState.currentState) state |= TEXTURE_2D_0_BIT; 84 | if (GlStateManager.textureState[1].texture2DState.currentState) state |= TEXTURE_2D_1_BIT; 85 | if (GlStateManager.textureState[2].texture2DState.currentState) state |= TEXTURE_2D_2_BIT; 86 | if (GlStateManager.textureState[3].texture2DState.currentState) state |= TEXTURE_2D_3_BIT; 87 | if (GlStateManager.textureState[4].texture2DState.currentState) state |= TEXTURE_2D_4_BIT; 88 | if (GlStateManager.textureState[5].texture2DState.currentState) state |= TEXTURE_2D_5_BIT; 89 | if (GlStateManager.textureState[6].texture2DState.currentState) state |= TEXTURE_2D_6_BIT; 90 | if (GlStateManager.textureState[7].texture2DState.currentState) state |= TEXTURE_2D_7_BIT; 91 | if (GlStateManager.activeShadeModel == GL11.GL_SMOOTH) state |= SMOOTH_BIT; 92 | attribStack.add(state); 93 | } 94 | GlStateManager.pushAttrib(); 95 | } 96 | 97 | @Override 98 | public void popAttrib() { 99 | if (emulatePushAttrib) { 100 | int state = attribStack.removeAt(attribStack.size()-1); 101 | GlStateManager.alphaState.alphaTest.currentState = ((state & ALPHA_BIT) != 0); 102 | GlStateManager.blendState.blend.currentState = ((state & BLEND_BIT) != 0); 103 | GlStateManager.colorMaterialState.colorMaterial.currentState = ((state & COLOR_MATERIAL_BIT) != 0); 104 | GlStateManager.cullState.cullFace.currentState = ((state & CULL_FACE_BIT) != 0); 105 | GlStateManager.depthState.depthTest.currentState = ((state & DEPTH_TEST_BIT) != 0); 106 | GlStateManager.fogState.fog.currentState = ((state & FOG_BIT) != 0); 107 | GlStateManager.lightState[0].currentState = ((state & LIGHT0_BIT) != 0); 108 | GlStateManager.lightState[1].currentState = ((state & LIGHT1_BIT) != 0); 109 | GlStateManager.lightState[2].currentState = ((state & LIGHT2_BIT) != 0); 110 | GlStateManager.lightState[3].currentState = ((state & LIGHT3_BIT) != 0); 111 | GlStateManager.lightState[4].currentState = ((state & LIGHT4_BIT) != 0); 112 | GlStateManager.lightState[5].currentState = ((state & LIGHT5_BIT) != 0); 113 | GlStateManager.lightState[6].currentState = ((state & LIGHT6_BIT) != 0); 114 | GlStateManager.lightState[7].currentState = ((state & LIGHT7_BIT) != 0); 115 | GlStateManager.lightingState.currentState = ((state & LIGHTING_BIT) != 0); 116 | GlStateManager.colorLogicState.colorLogicOp.currentState = ((state & COLOR_LOGIC_OP_BIT) != 0); 117 | GlStateManager.normalizeState.currentState = ((state & NORMALIZE_BIT) != 0); 118 | GlStateManager.polygonOffsetState.polygonOffsetFill.currentState = ((state & POLYGON_OFFSET_FILL_BIT) != 0); 119 | GlStateManager.polygonOffsetState.polygonOffsetLine.currentState = ((state & POLYGON_OFFSET_LINE_BIT) != 0); 120 | GlStateManager.texGenState.s.textureGen.currentState = ((state & TEXTURE_GEN_S_BIT) != 0); 121 | GlStateManager.texGenState.t.textureGen.currentState = ((state & TEXTURE_GEN_T_BIT) != 0); 122 | GlStateManager.texGenState.r.textureGen.currentState = ((state & TEXTURE_GEN_R_BIT) != 0); 123 | GlStateManager.texGenState.q.textureGen.currentState = ((state & TEXTURE_GEN_Q_BIT) != 0); 124 | GlStateManager.textureState[0].texture2DState.currentState = ((state & TEXTURE_2D_0_BIT) != 0); 125 | GlStateManager.textureState[1].texture2DState.currentState = ((state & TEXTURE_2D_1_BIT) != 0); 126 | GlStateManager.textureState[2].texture2DState.currentState = ((state & TEXTURE_2D_2_BIT) != 0); 127 | GlStateManager.textureState[3].texture2DState.currentState = ((state & TEXTURE_2D_3_BIT) != 0); 128 | GlStateManager.textureState[4].texture2DState.currentState = ((state & TEXTURE_2D_4_BIT) != 0); 129 | GlStateManager.textureState[5].texture2DState.currentState = ((state & TEXTURE_2D_5_BIT) != 0); 130 | GlStateManager.textureState[6].texture2DState.currentState = ((state & TEXTURE_2D_6_BIT) != 0); 131 | GlStateManager.textureState[7].texture2DState.currentState = ((state & TEXTURE_2D_7_BIT) != 0); 132 | if ((state & SMOOTH_BIT) != 0) { 133 | GlStateManager.activeShadeModel = GL11.GL_SMOOTH; 134 | } else { 135 | GlStateManager.activeShadeModel = GL11.GL_FLAT; 136 | } 137 | } 138 | GlStateManager.popAttrib(); 139 | } 140 | 141 | @Override 142 | public void disableAlpha() { 143 | GlStateManager.disableAlpha(); 144 | 145 | } 146 | 147 | @Override 148 | public void enableAlpha() { 149 | GlStateManager.enableAlpha(); 150 | 151 | } 152 | 153 | @Override 154 | public void alphaFunc(int func, float ref) { 155 | GlStateManager.alphaFunc(func, ref); 156 | 157 | } 158 | 159 | @Override 160 | public void enableLighting() { 161 | GlStateManager.enableLighting(); 162 | 163 | } 164 | 165 | @Override 166 | public void disableLighting() { 167 | GlStateManager.disableLighting(); 168 | 169 | } 170 | 171 | @Override 172 | public void enableLight(int light) { 173 | GlStateManager.enableLight(light); 174 | 175 | } 176 | 177 | @Override 178 | public void disableLight(int light) { 179 | GlStateManager.disableLight(light); 180 | 181 | } 182 | 183 | @Override 184 | public void enableColorMaterial() { 185 | GlStateManager.enableColorMaterial(); 186 | 187 | } 188 | 189 | @Override 190 | public void disableColorMaterial() { 191 | GlStateManager.disableColorMaterial(); 192 | 193 | } 194 | 195 | @Override 196 | public void colorMaterial(int face, int mode) { 197 | GlStateManager.colorMaterial(face, mode); 198 | 199 | } 200 | 201 | @Override 202 | public void disableDepth() { 203 | GlStateManager.disableDepth(); 204 | 205 | } 206 | 207 | @Override 208 | public void enableDepth() { 209 | GlStateManager.enableDepth(); 210 | 211 | } 212 | 213 | @Override 214 | public void depthFunc(int depthFunc) { 215 | GlStateManager.depthFunc(depthFunc); 216 | 217 | } 218 | 219 | @Override 220 | public void depthMask(boolean flagIn) { 221 | GlStateManager.depthMask(flagIn); 222 | 223 | } 224 | 225 | @Override 226 | public void disableBlend() { 227 | GlStateManager.disableBlend(); 228 | 229 | } 230 | 231 | @Override 232 | public void enableBlend() { 233 | GlStateManager.enableBlend(); 234 | 235 | } 236 | 237 | @Override 238 | public void blendFunc(int srcFactor, int dstFactor) { 239 | GlStateManager.blendFunc(srcFactor, dstFactor); 240 | 241 | } 242 | 243 | @Override 244 | public void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) { 245 | GlStateManager.tryBlendFuncSeparate(srcFactor, dstFactor, srcFactorAlpha, dstFactorAlpha); 246 | 247 | } 248 | 249 | @Override 250 | public void enableFog() { 251 | GlStateManager.enableFog(); 252 | 253 | } 254 | 255 | @Override 256 | public void disableFog() { 257 | GlStateManager.disableFog(); 258 | 259 | } 260 | 261 | @Override 262 | public void setFog(int param) { 263 | GlStateManager.setFog(param); 264 | 265 | } 266 | 267 | @Override 268 | public void setFogDensity(float param) { 269 | GlStateManager.setFogDensity(param); 270 | 271 | } 272 | 273 | @Override 274 | public void setFogStart(float param) { 275 | GlStateManager.setFogStart(param); 276 | 277 | } 278 | 279 | @Override 280 | public void setFogEnd(float param) { 281 | GlStateManager.setFogEnd(param); 282 | 283 | } 284 | 285 | @Override 286 | public void enableCull() { 287 | GlStateManager.enableCull(); 288 | 289 | } 290 | 291 | @Override 292 | public void disableCull() { 293 | GlStateManager.disableCull(); 294 | 295 | } 296 | 297 | @Override 298 | public void cullFace(int mode) { 299 | GlStateManager.cullFace(mode); 300 | 301 | } 302 | 303 | @Override 304 | public void enablePolygonOffset() { 305 | GlStateManager.enablePolygonOffset(); 306 | 307 | } 308 | 309 | @Override 310 | public void disablePolygonOffset() { 311 | GlStateManager.disablePolygonOffset(); 312 | 313 | } 314 | 315 | @Override 316 | public void doPolygonOffset(float factor, float units) { 317 | GlStateManager.doPolygonOffset(factor, units); 318 | 319 | } 320 | 321 | @Override 322 | public void enableColorLogic() { 323 | GlStateManager.enableColorLogic(); 324 | 325 | } 326 | 327 | @Override 328 | public void disableColorLogic() { 329 | GlStateManager.disableColorLogic(); 330 | 331 | } 332 | 333 | @Override 334 | public void colorLogicOp(int opcode) { 335 | GlStateManager.colorLogicOp(opcode); 336 | 337 | } 338 | 339 | @Override 340 | public void setActiveTexture(int texture) { 341 | GlStateManager.setActiveTexture(texture); 342 | 343 | } 344 | 345 | @Override 346 | public void enableTexture2D() { 347 | GlStateManager.enableTexture2D(); 348 | 349 | } 350 | 351 | @Override 352 | public void disableTexture2D() { 353 | GlStateManager.disableTexture2D(); 354 | 355 | } 356 | 357 | @Override 358 | public void deleteTexture(int texture) { 359 | GlStateManager.deleteTexture(texture); 360 | 361 | } 362 | 363 | @Override 364 | public void bindTexture(int texture) { 365 | GlStateManager.bindTexture(texture); 366 | 367 | } 368 | 369 | @Override 370 | public void enableNormalize() { 371 | GlStateManager.enableNormalize(); 372 | 373 | } 374 | 375 | @Override 376 | public void disableNormalize() { 377 | GlStateManager.disableNormalize(); 378 | 379 | } 380 | 381 | @Override 382 | public void shadeModel(int mode) { 383 | GlStateManager.shadeModel(mode); 384 | 385 | } 386 | 387 | @Override 388 | public void enableRescaleNormal() { 389 | GlStateManager.enableRescaleNormal(); 390 | 391 | } 392 | 393 | @Override 394 | public void disableRescaleNormal() { 395 | GlStateManager.disableRescaleNormal(); 396 | 397 | } 398 | 399 | @Override 400 | public void viewport(int x, int y, int width, int height) { 401 | GlStateManager.viewport(x, y, width, height); 402 | 403 | } 404 | 405 | @Override 406 | public void colorMask(boolean red, boolean green, boolean blue, boolean alpha) { 407 | GlStateManager.colorMask(red, green, blue, alpha); 408 | 409 | } 410 | 411 | @Override 412 | public void clearDepth(double depth) { 413 | GlStateManager.clearDepth(depth); 414 | 415 | } 416 | 417 | @Override 418 | public void clearColor(float red, float green, float blue, float alpha) { 419 | GlStateManager.clearColor(red, green, blue, alpha); 420 | 421 | } 422 | 423 | @Override 424 | public void clear(int mask) { 425 | GlStateManager.clear(mask); 426 | 427 | } 428 | 429 | @Override 430 | public void matrixMode(int mode) { 431 | GlStateManager.matrixMode(mode); 432 | 433 | } 434 | 435 | @Override 436 | public void loadIdentity() { 437 | GlStateManager.loadIdentity(); 438 | 439 | } 440 | 441 | @Override 442 | public void pushMatrix() { 443 | GlStateManager.pushMatrix(); 444 | 445 | } 446 | 447 | @Override 448 | public void popMatrix() { 449 | GlStateManager.popMatrix(); 450 | 451 | } 452 | 453 | @Override 454 | public void getFloat(int pname, FloatBuffer params) { 455 | GlStateManager.getFloat(pname, params); 456 | 457 | } 458 | 459 | @Override 460 | public void ortho(double left, double right, double bottom, double top, double zNear, double zFar) { 461 | GlStateManager.ortho(left, right, bottom, top, zNear, zFar); 462 | 463 | } 464 | 465 | @Override 466 | public void rotate(float angle, float x, float y, float z) { 467 | GlStateManager.rotate(angle, x, y, z); 468 | 469 | } 470 | 471 | @Override 472 | public void scale(float x, float y, float z) { 473 | GlStateManager.scale(x, y, z); 474 | 475 | } 476 | 477 | @Override 478 | public void scale(double x, double y, double z) { 479 | GlStateManager.scale(x, y, z); 480 | 481 | } 482 | 483 | @Override 484 | public void translate(float x, float y, float z) { 485 | GlStateManager.translate(x, y, z); 486 | 487 | } 488 | 489 | @Override 490 | public void translate(double x, double y, double z) { 491 | GlStateManager.translate(x, y, z); 492 | 493 | } 494 | 495 | @Override 496 | public void multMatrix(FloatBuffer matrix) { 497 | GlStateManager.multMatrix(matrix); 498 | 499 | } 500 | 501 | @Override 502 | public void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha) { 503 | GlStateManager.color(colorRed, colorGreen, colorBlue, colorAlpha); 504 | 505 | } 506 | 507 | @Override 508 | public void color(float colorRed, float colorGreen, float colorBlue) { 509 | GlStateManager.color(colorRed, colorGreen, colorBlue); 510 | 511 | } 512 | 513 | @Override 514 | public void resetColor() { 515 | GlStateManager.resetColor(); 516 | 517 | } 518 | 519 | @Override 520 | public void callList(int list) { 521 | GlStateManager.callList(list); 522 | 523 | } 524 | 525 | } 526 | -------------------------------------------------------------------------------- /src/main/java/com/unascribed/laminate/internal/tessellator/VertexBuilderTessellatorAccess.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal.tessellator; 2 | 3 | import java.util.Map; 4 | 5 | import com.google.common.collect.ImmutableMap; 6 | 7 | import net.minecraft.client.renderer.Tessellator; 8 | import net.minecraft.client.renderer.WorldRenderer; 9 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats; 10 | import net.minecraft.client.renderer.vertex.VertexFormat; 11 | 12 | public class VertexBuilderTessellatorAccess implements TessellatorAccess { 13 | private final Map formats = ImmutableMap.builder() 14 | .put(Format.POSITION, DefaultVertexFormats.POSITION) 15 | .put(Format.POSITION_COLOR, DefaultVertexFormats.POSITION_COLOR) 16 | .put(Format.POSITION_NORMAL, DefaultVertexFormats.POSITION_NORMAL) 17 | .put(Format.POSITION_TEX, DefaultVertexFormats.POSITION_TEX) 18 | .put(Format.POSITION_TEX_COLOR, DefaultVertexFormats.POSITION_TEX_COLOR) 19 | .put(Format.POSITION_TEX_COLOR_NORMAL, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL) 20 | .put(Format.POSITION_TEX_NORMAL, DefaultVertexFormats.POSITION_TEX_NORMAL) 21 | .build(); 22 | 23 | private WorldRenderer wr() { 24 | return Tessellator.getInstance().getWorldRenderer(); 25 | } 26 | 27 | @Override 28 | public void begin(int mode, Format format) { 29 | wr().begin(mode, formats.get(format)); 30 | } 31 | 32 | @Override 33 | public TessellatorAccess pos(double x, double y, double z) { 34 | wr().pos(x, y, z); 35 | return this; 36 | } 37 | 38 | @Override 39 | public TessellatorAccess color(float r, float g, float b) { 40 | wr().color(r, g, b, 1); 41 | return this; 42 | } 43 | 44 | @Override 45 | public TessellatorAccess color(float r, float g, float b, float a) { 46 | wr().color(r, g, b, a); 47 | return this; 48 | } 49 | 50 | @Override 51 | public TessellatorAccess color(int r, int g, int b) { 52 | wr().color(r, g, b, 255); 53 | return this; 54 | } 55 | 56 | @Override 57 | public TessellatorAccess color(int r, int g, int b, int a) { 58 | wr().color(r, g, b, a); 59 | return this; 60 | } 61 | 62 | @Override 63 | public TessellatorAccess normal(float x, float y, float z) { 64 | wr().normal(x, y, z); 65 | return this; 66 | } 67 | 68 | @Override 69 | public TessellatorAccess tex(double u, double v) { 70 | wr().tex(u, v); 71 | return this; 72 | } 73 | 74 | @Override 75 | public void endVertex() { 76 | wr().endVertex(); 77 | } 78 | 79 | @Override 80 | public void draw() { 81 | Tessellator.getInstance().draw(); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/laminate_at.cfg: -------------------------------------------------------------------------------- 1 | public net.minecraft.client.gui.GuiMainMenu field_73979_m # panoramaTimer 2 | public net.minecraft.client.renderer.GlStateManager * 3 | 4 | public net.minecraft.client.renderer.GlStateManager$AlphaState 5 | public net.minecraft.client.renderer.GlStateManager$BlendState 6 | public net.minecraft.client.renderer.GlStateManager$BooleanState 7 | public net.minecraft.client.renderer.GlStateManager$ClearState 8 | public net.minecraft.client.renderer.GlStateManager$Color 9 | public net.minecraft.client.renderer.GlStateManager$ColorLogicState 10 | public net.minecraft.client.renderer.GlStateManager$ColorMask 11 | public net.minecraft.client.renderer.GlStateManager$ColorMaterialState 12 | public net.minecraft.client.renderer.GlStateManager$CullState 13 | public net.minecraft.client.renderer.GlStateManager$DepthState 14 | public net.minecraft.client.renderer.GlStateManager$FogState 15 | public net.minecraft.client.renderer.GlStateManager$PolygonOffsetState 16 | public net.minecraft.client.renderer.GlStateManager$StencilFunc 17 | public net.minecraft.client.renderer.GlStateManager$StencilState 18 | public net.minecraft.client.renderer.GlStateManager$TexGenCoord 19 | public net.minecraft.client.renderer.GlStateManager$TexGenState 20 | public net.minecraft.client.renderer.GlStateManager$TextureState 21 | 22 | public net.minecraft.client.renderer.GlStateManager$BooleanState field_179201_b # currentState -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "laminate", 4 | "name": "Laminate", 5 | "description": "An awesome open source GUI framework for Minecraft Forge, designed to be simple to use, but still powerful.", 6 | "version": "${version}", 7 | "mcversion": "1.7.2,1.7.10,1.8,1.8.8,1.8.9", 8 | "url": "https://github.com/unascribed/Laminate", 9 | "updateUrl": "", 10 | "authorList": ["Aesen \"unascribed\" Vismea"], 11 | "credits": "", 12 | "logoFile": "", 13 | "screenshots": [], 14 | "dependencies": [] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /version-specific/1.7.10/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | jcenter() 5 | maven { 6 | name = "forge" 7 | url = "http://files.minecraftforge.net/maven" 8 | } 9 | maven { 10 | name = "sonatype" 11 | url = "https://oss.sonatype.org/content/repositories/snapshots/" 12 | } 13 | } 14 | dependencies { 15 | classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' 16 | classpath 'me.tatarka:gradle-retrolambda:3.2.0' 17 | } 18 | } 19 | 20 | apply plugin: 'forge' 21 | apply plugin: 'me.tatarka.retrolambda' 22 | 23 | group = "com.unascribed" 24 | archivesBaseName = "LaminateOneSeven" 25 | 26 | sourceCompatibility = 1.8 27 | targetCompatibility = 1.8 28 | 29 | retrolambda { 30 | javaVersion JavaVersion.VERSION_1_6 31 | } 32 | 33 | repositories { 34 | maven { 35 | name = 'sonatype-nexus' 36 | url = 'https://oss.sonatype.org/content/repositories/public/' 37 | } 38 | } 39 | 40 | dependencies { 41 | compile files('../../common/build/libs/LaminateCommon.jar') 42 | } 43 | 44 | minecraft { 45 | version = "1.7.10-10.13.4.1614-1.7.10" 46 | mappings = "snapshot_20140925" 47 | runDir = "minecraft" 48 | } 49 | -------------------------------------------------------------------------------- /version-specific/1.7.10/src/main/java/com/unascribed/laminate/internal/LaminateModOneSeven.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal; 2 | 3 | import cpw.mods.fml.common.FMLCommonHandler; 4 | import cpw.mods.fml.common.Loader; 5 | import cpw.mods.fml.common.Mod; 6 | import cpw.mods.fml.common.Mod.EventHandler; 7 | import cpw.mods.fml.common.event.FMLInitializationEvent; 8 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 9 | import cpw.mods.fml.common.eventhandler.SubscribeEvent; 10 | import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; 11 | import cpw.mods.fml.common.gameevent.TickEvent.Phase; 12 | import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; 13 | import cpw.mods.fml.relauncher.Side; 14 | import net.minecraftforge.common.MinecraftForge; 15 | 16 | 17 | @Mod( 18 | modid="laminate", 19 | name="Laminate", 20 | acceptableRemoteVersions="*", 21 | acceptedMinecraftVersions="1.7.2,1.7.10" 22 | ) 23 | public class LaminateModOneSeven { 24 | private LaminateCore core; 25 | 26 | @EventHandler 27 | public void onPreInit(FMLPreInitializationEvent e) throws InstantiationException, IllegalAccessException, ClassNotFoundException { 28 | if (e.getSide() == Side.CLIENT) { 29 | core = (LaminateCore)Class.forName("com.unascribed.laminate.internal.LaminateInternal").newInstance(); 30 | core.preInit(Loader.instance().getMCVersionString().substring("Minecraft ".length())); 31 | } else { 32 | e.getModLog().warn("Cowardly refusing to run on side {}", e.getSide()); 33 | } 34 | } 35 | 36 | @EventHandler 37 | public void onInit(FMLInitializationEvent e) { 38 | if (e.getSide() == Side.CLIENT) { 39 | FMLCommonHandler.instance().bus().register(this); 40 | MinecraftForge.EVENT_BUS.register(this); 41 | } 42 | } 43 | 44 | @SubscribeEvent 45 | public void onTick(ClientTickEvent e) { 46 | core.tick(e.phase == Phase.START); 47 | } 48 | 49 | @SubscribeEvent 50 | public void onFrame(RenderTickEvent e) { 51 | if (e.phase == Phase.START) { 52 | core.frame(); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /version-specific/1.7.10/src/main/java/com/unascribed/laminate/internal/OneSeven.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal; 2 | 3 | public class OneSeven { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /version-specific/1.7.10/src/main/java/com/unascribed/laminate/internal/tessellator/OldTessellatorAccess.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal.tessellator; 2 | 3 | import net.minecraft.client.renderer.Tessellator; 4 | 5 | public class OldTessellatorAccess implements TessellatorAccess { 6 | 7 | private Format format; 8 | 9 | private double x, y, z; 10 | private float nx, ny, nz; 11 | private float r, g, b, a; 12 | private double u, v; 13 | 14 | private Tessellator tess() { 15 | return Tessellator.instance; 16 | } 17 | 18 | @Override 19 | public void begin(int mode, Format format) { 20 | this.format = format; 21 | tess().startDrawing(mode); 22 | } 23 | 24 | @Override 25 | public TessellatorAccess pos(double x, double y, double z) { 26 | this.x = x; 27 | this.y = y; 28 | this.z = z; 29 | return this; 30 | } 31 | 32 | @Override 33 | public TessellatorAccess color(float r, float g, float b) { 34 | return color(r, g, b, 1); 35 | } 36 | 37 | @Override 38 | public TessellatorAccess color(float r, float g, float b, float a) { 39 | this.r = r; 40 | this.g = g; 41 | this.b = b; 42 | this.a = a; 43 | return this; 44 | } 45 | 46 | @Override 47 | public TessellatorAccess color(int r, int g, int b) { 48 | color(r/255f, g/255f, b/255f); 49 | return this; 50 | } 51 | 52 | @Override 53 | public TessellatorAccess color(int r, int g, int b, int a) { 54 | color(r/255f, g/255f, b/255f, a/255f); 55 | return this; 56 | } 57 | 58 | @Override 59 | public TessellatorAccess normal(float x, float y, float z) { 60 | this.nx = x; 61 | this.ny = y; 62 | this.nz = z; 63 | return this; 64 | } 65 | 66 | @Override 67 | public TessellatorAccess tex(double u, double v) { 68 | this.u = u; 69 | this.v = v; 70 | return this; 71 | } 72 | 73 | @Override 74 | public void endVertex() { 75 | switch (format) { 76 | case POSITION: 77 | tess().addVertex(x, y, z); 78 | break; 79 | case POSITION_COLOR: 80 | tess().setColorRGBA_F(r, g, b, a); 81 | tess().addVertex(x, y, z); 82 | break; 83 | case POSITION_NORMAL: 84 | tess().setNormal(nx, ny, nz); 85 | tess().addVertex(x, y, z); 86 | break; 87 | case POSITION_TEX: 88 | tess().addVertexWithUV(x, y, z, u, v); 89 | break; 90 | case POSITION_TEX_COLOR: 91 | tess().setColorRGBA_F(r, g, b, a); 92 | tess().addVertexWithUV(x, y, z, u, v); 93 | break; 94 | case POSITION_TEX_COLOR_NORMAL: 95 | tess().setColorRGBA_F(r, g, b, a); 96 | tess().setNormal(nx, ny, nz); 97 | tess().addVertexWithUV(x, y, z, u, v); 98 | break; 99 | case POSITION_TEX_NORMAL: 100 | tess().setNormal(nx, ny, nz); 101 | tess().addVertexWithUV(x, y, z, u, v); 102 | break; 103 | default: 104 | throw new AssertionError("Unknown vertex format "+format); 105 | } 106 | x = y = z = 0; 107 | r = g = b = a = 1; 108 | nx = ny = nz = 0; 109 | u = v = 0; 110 | } 111 | 112 | @Override 113 | public void draw() { 114 | tess().draw(); 115 | x = y = z = 0; 116 | r = g = b = a = 1; 117 | nx = ny = nz = 0; 118 | u = v = 0; 119 | format = null; 120 | } 121 | 122 | 123 | 124 | } 125 | -------------------------------------------------------------------------------- /version-specific/1.8/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /version-specific/1.8/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | jcenter() 5 | maven { 6 | name = "forge" 7 | url = "http://files.minecraftforge.net/maven" 8 | } 9 | maven { 10 | name = "sonatype" 11 | url = "https://oss.sonatype.org/content/repositories/snapshots/" 12 | } 13 | } 14 | dependencies { 15 | classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT' 16 | classpath 'me.tatarka:gradle-retrolambda:3.2.0' 17 | } 18 | } 19 | 20 | apply plugin: 'net.minecraftforge.gradle.forge' 21 | apply plugin: 'me.tatarka.retrolambda' 22 | apply plugin: 'maven' 23 | 24 | group = "com.unascribed" 25 | archivesBaseName = "LaminateOneEight" 26 | 27 | sourceCompatibility = 1.8 28 | targetCompatibility = 1.8 29 | 30 | retrolambda { 31 | javaVersion JavaVersion.VERSION_1_6 32 | } 33 | 34 | repositories { 35 | mavenCentral() 36 | maven { 37 | name = 'sonatype-nexus' 38 | url = 'https://oss.sonatype.org/content/repositories/public/' 39 | } 40 | } 41 | 42 | dependencies { 43 | compile files('../../common/build/libs/LaminateCommon.jar') 44 | } 45 | 46 | minecraft { 47 | version = "1.8-11.14.4.1577" 48 | mappings = "snapshot_20151128" 49 | 50 | runDir = "minecraft" 51 | } 52 | -------------------------------------------------------------------------------- /version-specific/1.8/src/main/java/com/unascribed/laminate/internal/LaminateModOneEight.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal; 2 | 3 | import net.minecraftforge.common.MinecraftForge; 4 | import net.minecraftforge.fml.common.FMLCommonHandler; 5 | import net.minecraftforge.fml.common.Loader; 6 | import net.minecraftforge.fml.common.Mod; 7 | import net.minecraftforge.fml.common.Mod.EventHandler; 8 | import net.minecraftforge.fml.common.event.FMLInitializationEvent; 9 | import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; 10 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 11 | import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; 12 | import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; 13 | import net.minecraftforge.fml.common.gameevent.TickEvent.RenderTickEvent; 14 | 15 | @Mod( 16 | modid="laminate", 17 | name="Laminate", 18 | acceptableRemoteVersions="*", 19 | clientSideOnly=true, 20 | acceptedMinecraftVersions="1.8,1.8.8,1.8.9" 21 | ) 22 | public class LaminateModOneEight { 23 | private LaminateCore core; 24 | 25 | @EventHandler 26 | public void onPreInit(FMLPreInitializationEvent e) throws InstantiationException, IllegalAccessException, ClassNotFoundException { 27 | core = (LaminateCore)Class.forName("com.unascribed.laminate.internal.LaminateInternal").newInstance(); 28 | core.preInit(Loader.instance().getMCVersionString().substring("Minecraft ".length())); 29 | } 30 | 31 | @EventHandler 32 | public void onInit(FMLInitializationEvent e) { 33 | FMLCommonHandler.instance().bus().register(this); 34 | MinecraftForge.EVENT_BUS.register(this); 35 | } 36 | 37 | @SubscribeEvent 38 | public void onTick(ClientTickEvent e) { 39 | core.tick(e.phase == Phase.START); 40 | } 41 | 42 | @SubscribeEvent 43 | public void onFrame(RenderTickEvent e) { 44 | if (e.phase == Phase.START) { 45 | core.frame(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /version-specific/1.8/src/main/java/com/unascribed/laminate/internal/OneEight.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal; 2 | 3 | import com.google.common.base.Function; 4 | 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.gui.ScaledResolution; 7 | 8 | public class OneEight { 9 | public static final Function SCALED_RESOLUTION_FACTORY = mc -> new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); 10 | } 11 | -------------------------------------------------------------------------------- /version-specific/1.8/src/main/java/com/unascribed/laminate/internal/tessellator/SplitTessellatorAccess.java: -------------------------------------------------------------------------------- 1 | package com.unascribed.laminate.internal.tessellator; 2 | 3 | import net.minecraft.client.renderer.Tessellator; 4 | import net.minecraft.client.renderer.WorldRenderer; 5 | 6 | public class SplitTessellatorAccess implements TessellatorAccess { 7 | 8 | private Format format; 9 | 10 | private double x, y, z; 11 | private float nx, ny, nz; 12 | private float r, g, b, a; 13 | private double u, v; 14 | 15 | private Tessellator tess() { 16 | return Tessellator.getInstance(); 17 | } 18 | 19 | private WorldRenderer wr() { 20 | return tess().getWorldRenderer(); 21 | } 22 | 23 | @Override 24 | public void begin(int mode, Format format) { 25 | this.format = format; 26 | wr().startDrawing(mode); 27 | } 28 | 29 | @Override 30 | public TessellatorAccess pos(double x, double y, double z) { 31 | this.x = x; 32 | this.y = y; 33 | this.z = z; 34 | return this; 35 | } 36 | 37 | @Override 38 | public TessellatorAccess color(float r, float g, float b) { 39 | return color(r, g, b, 1); 40 | } 41 | 42 | @Override 43 | public TessellatorAccess color(float r, float g, float b, float a) { 44 | this.r = r; 45 | this.g = g; 46 | this.b = b; 47 | this.a = a; 48 | return this; 49 | } 50 | 51 | @Override 52 | public TessellatorAccess color(int r, int g, int b) { 53 | color(r/255f, g/255f, b/255f); 54 | return this; 55 | } 56 | 57 | @Override 58 | public TessellatorAccess color(int r, int g, int b, int a) { 59 | color(r/255f, g/255f, b/255f, a/255f); 60 | return this; 61 | } 62 | 63 | @Override 64 | public TessellatorAccess normal(float x, float y, float z) { 65 | this.nx = x; 66 | this.ny = y; 67 | this.nz = z; 68 | return this; 69 | } 70 | 71 | @Override 72 | public TessellatorAccess tex(double u, double v) { 73 | this.u = u; 74 | this.v = v; 75 | return this; 76 | } 77 | 78 | @Override 79 | public void endVertex() { 80 | switch (format) { 81 | case POSITION: 82 | wr().addVertex(x, y, z); 83 | break; 84 | case POSITION_COLOR: 85 | wr().setColorRGBA_F(r, g, b, a); 86 | wr().addVertex(x, y, z); 87 | break; 88 | case POSITION_NORMAL: 89 | wr().setNormal(nx, ny, nz); 90 | wr().addVertex(x, y, z); 91 | break; 92 | case POSITION_TEX: 93 | wr().addVertexWithUV(x, y, z, u, v); 94 | break; 95 | case POSITION_TEX_COLOR: 96 | wr().setColorRGBA_F(r, g, b, a); 97 | wr().addVertexWithUV(x, y, z, u, v); 98 | break; 99 | case POSITION_TEX_COLOR_NORMAL: 100 | wr().setColorRGBA_F(r, g, b, a); 101 | wr().setNormal(nx, ny, nz); 102 | wr().addVertexWithUV(x, y, z, u, v); 103 | break; 104 | case POSITION_TEX_NORMAL: 105 | wr().setNormal(nx, ny, nz); 106 | wr().addVertexWithUV(x, y, z, u, v); 107 | break; 108 | default: 109 | throw new AssertionError("Unknown vertex format "+format); 110 | } 111 | x = y = z = 0; 112 | r = g = b = a = 1; 113 | nx = ny = nz = 0; 114 | u = v = 0; 115 | } 116 | 117 | @Override 118 | public void draw() { 119 | tess().draw(); 120 | x = y = z = 0; 121 | r = g = b = a = 1; 122 | nx = ny = nz = 0; 123 | u = v = 0; 124 | format = null; 125 | } 126 | 127 | 128 | } 129 | --------------------------------------------------------------------------------