├── .github
└── workflows
│ └── build.yml
├── .gitignore
├── CHANGELOG.md
├── HEADER
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
└── main
├── java
└── pl
│ └── js6pak
│ └── mojangfix
│ ├── MojangFixMod.java
│ ├── client
│ ├── MojangFixClientMod.java
│ ├── gui
│ │ ├── CallbackButtonWidget.java
│ │ ├── CallbackConfirmScreen.java
│ │ ├── ControlsListWidget.java
│ │ └── multiplayer
│ │ │ ├── DirectConnectScreen.java
│ │ │ ├── EditServerScreen.java
│ │ │ ├── MultiplayerScreen.java
│ │ │ ├── MultiplayerServerListWidget.java
│ │ │ └── ServerData.java
│ └── skinfix
│ │ ├── CapeImageProcessor.java
│ │ ├── PlayerEntityModel.java
│ │ ├── PlayerProfile.java
│ │ ├── SkinService.java
│ │ └── provider
│ │ ├── AshconProfileProvider.java
│ │ ├── MojangProfileProvider.java
│ │ └── ProfileProvider.java
│ ├── mixin
│ ├── client
│ │ ├── MinecraftAccessor.java
│ │ ├── ScreenAccessor.java
│ │ ├── auth
│ │ │ ├── ClientNetworkHandlerMixin.java
│ │ │ └── SessionMixin.java
│ │ ├── controls
│ │ │ ├── ControlsOptionsScreenMixin.java
│ │ │ ├── GameOptionsMixin.java
│ │ │ └── KeyBindingMixin.java
│ │ ├── inventory
│ │ │ ├── ContainerScreenMixin.java
│ │ │ └── PlayerEntityMixin.java
│ │ ├── misc
│ │ │ ├── DeathScreenMixin.java
│ │ │ ├── InGameHudMixin.java
│ │ │ ├── MinecraftAppletMixin.java
│ │ │ ├── MinecraftMixin.java
│ │ │ ├── ResourceDownloadThreadMixin.java
│ │ │ ├── ScreenMixin.java
│ │ │ └── TitleScreenMixin.java
│ │ ├── multiplayer
│ │ │ ├── ReturnToMainMenuMixin.java
│ │ │ └── TitleScreenMixin.java
│ │ ├── skin
│ │ │ ├── BipedEntityModelMixin.java
│ │ │ ├── ClientPlayerEntityMixin.java
│ │ │ ├── EntityRenderDispatcherMixin.java
│ │ │ ├── ModelPartMixin.java
│ │ │ ├── OtherPlayerEntityMixin.java
│ │ │ ├── PlayerEntityMixin.java
│ │ │ ├── PlayerEntityRendererMixin.java
│ │ │ ├── SkinImageProcessorMixin.java
│ │ │ └── WorldRendererMixin.java
│ │ └── text
│ │ │ ├── TextFieldWidgetMixin.java
│ │ │ ├── chat
│ │ │ ├── ChatScreenMixin.java
│ │ │ └── SleepingChatScreenMixin.java
│ │ │ └── sign
│ │ │ ├── ClientNetworkHandlerMixin.java
│ │ │ ├── SignBlockEntityMixin.java
│ │ │ ├── SignBlockEntityRendererMixin.java
│ │ │ └── SignEditScreenMixin.java
│ └── server
│ │ └── auth
│ │ ├── ServerNetworkHandlerAccessor.java
│ │ └── ServerNetworkHandlerMixin.java
│ ├── mixinterface
│ ├── ChatScreenAccessor.java
│ ├── GameSettingsAccessor.java
│ ├── KeyBindingAccessor.java
│ ├── ModelPartAccessor.java
│ ├── PlayerEntityAccessor.java
│ ├── PlayerEntityRendererAccessor.java
│ ├── SessionAccessor.java
│ ├── SignBlockEntityAccessor.java
│ ├── SkinImageProcessorAccessor.java
│ └── TextFieldWidgetAccessor.java
│ └── util
│ └── Formatting.java
└── resources
├── assets
└── mojangfix
│ └── icon.png
├── fabric.mod.json
├── mob
├── alex.png
└── steve.png
└── mojangfix.mixins.json
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: build
2 | on: [ pull_request, push ]
3 |
4 | jobs:
5 | build:
6 | runs-on: ubuntu-22.04
7 | steps:
8 | - name: checkout repository
9 | uses: actions/checkout@v3
10 | - name: validate gradle wrapper
11 | uses: gradle/wrapper-validation-action@v1
12 | - name: setup jdk
13 | uses: actions/setup-java@v3
14 | with:
15 | java-version: 17
16 | distribution: 'microsoft'
17 | cache: 'gradle'
18 | - name: build
19 | run: |
20 | # https://github.com/diffplug/spotless/tree/main/plugin-gradle#using-ratchetfrom-on-ci-systems
21 | git fetch origin master
22 |
23 | ./gradlew build
24 | - name: capture build artifacts
25 | uses: actions/upload-artifact@v3
26 | with:
27 | name: Artifacts
28 | path: build/libs/
29 | - name: release
30 | uses: softprops/action-gh-release@v1
31 | if: startsWith(github.ref, 'refs/tags/')
32 | with:
33 | draft: false
34 | body_path: CHANGELOG.md
35 | files: build/libs/*.jar
36 | - name: modrinth
37 | if: startsWith(github.ref, 'refs/tags/')
38 | env:
39 | MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
40 | run: ./gradlew modrinth
41 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # gradle
2 |
3 | .gradle/
4 | build/
5 | out/
6 | classes/
7 |
8 | # eclipse
9 |
10 | *.launch
11 |
12 | # idea
13 |
14 | .idea/
15 | *.iml
16 | *.ipr
17 | *.iws
18 |
19 | # vscode
20 |
21 | .settings/
22 | .vscode/
23 | bin/
24 | .classpath
25 | .project
26 |
27 | # macos
28 |
29 | *.DS_Store
30 |
31 | # fabric
32 |
33 | run/
34 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | - Fix skin rendering by @forkiesassds in https://github.com/js6pak/mojangfix/pull/16
--------------------------------------------------------------------------------
/HEADER:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) $YEAR js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MojangFix
2 | Minecraft b1.7.3 mod that fixes skins, authentication and more
3 |
4 | ## Features
5 | Skin and cape fix (including 1.8+ outer layers)
6 |
7 | 
8 |
9 |
10 | Authentication fix
11 |
12 | 
13 | Allows the server to verify that the connecting player is logged in
14 |
15 |
16 | Multiplayer server list
17 |
18 | 
19 |
20 | (server status not implemented yet)
21 |
22 |
23 | Scrollable keybinds gui
24 |
25 | 
26 |
27 |
28 | Better text edition
29 |
30 | 
31 |
32 |
33 | Inventory tweaks
34 |
35 |
36 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'babric-loom' version '1.4-SNAPSHOT'
3 | id "maven-publish"
4 | id("com.modrinth.minotaur") version "2.+"
5 | id "com.diffplug.spotless" version "6.2.2"
6 | }
7 |
8 | sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
9 |
10 | archivesBaseName = project.archives_base_name
11 | group = project.maven_group
12 |
13 | def ENV = System.getenv()
14 | if (ENV.GITHUB_RUN_NUMBER) {
15 | if (ENV.GITHUB_REF && ENV.GITHUB_REF.startsWith("refs/tags/")) {
16 | version = project.mod_version
17 | spotless.enforceCheck = false
18 | } else {
19 | version = project.mod_version + '-ci.' + ENV.GITHUB_RUN_NUMBER
20 | }
21 | } else {
22 | version = project.mod_version + '+local'
23 | }
24 |
25 | repositories {
26 | maven {
27 | name = 'Babric'
28 | url = 'https://maven.glass-launcher.net/babric'
29 | }
30 | maven {
31 | name = "Jitpack"
32 | url = "https://jitpack.io/"
33 | content {
34 | includeGroup("com.github.GeyserMC")
35 | }
36 | }
37 | }
38 |
39 | loom {
40 | gluedMinecraftJar()
41 | customMinecraftManifest.set("https://babric.github.io/manifest-polyfill/${minecraft_version}.json")
42 | intermediaryUrl.set("https://maven.glass-launcher.net/babric/babric/intermediary/%1\$s/intermediary-%1\$s-v2.jar")
43 | }
44 |
45 | dependencies {
46 | minecraft "com.mojang:minecraft:${project.minecraft_version}"
47 | mappings "babric:barn:${project.yarn_mappings}:v2"
48 | modImplementation "babric:fabric-loader:${project.loader_version}"
49 |
50 | implementation "org.slf4j:slf4j-api:1.8.0-beta4"
51 | implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0"
52 |
53 | def lombok = "org.projectlombok:lombok:1.18.22"
54 | compileOnly lombok
55 | annotationProcessor lombok
56 |
57 | include(implementation("com.github.GeyserMC:MCAuthLib:d9d773e5d50327c33898c65cd545a4f6ef3ba1b5"))
58 | }
59 |
60 | processResources {
61 | inputs.property "version", project.version
62 |
63 | filesMatching("fabric.mod.json") {
64 | expand "version": project.version
65 | }
66 | }
67 |
68 | tasks.withType(JavaCompile) {
69 | options.encoding = "UTF-8"
70 | }
71 |
72 | spotless {
73 | ratchetFrom "origin/master"
74 | java {
75 | licenseHeaderFile(rootProject.file("HEADER"))
76 | }
77 | }
78 |
79 | modrinth {
80 | token = System.getenv("MODRINTH_TOKEN")
81 | projectId = "8sdj2JBj"
82 | uploadFile = remapJar
83 | gameVersions = [project.minecraft_version]
84 | loaders = ["fabric"]
85 | changelog = rootProject.file("CHANGELOG.md").text
86 | syncBodyFrom = rootProject.file("README.md").text
87 | }
88 | tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Done to increase the memory available to gradle.
2 | org.gradle.jvmargs=-Xmx1G
3 |
4 | # Fabric Properties
5 | # check these on https://fabricmc.net/develop
6 | minecraft_version=b1.7.3
7 | yarn_mappings=b1.7.3+build.8
8 | loader_version=0.14.24-babric.1
9 |
10 | # Mod Properties
11 | mod_version = 0.5.3
12 | maven_group = pl.js6pak
13 | archives_base_name = mojangfix
14 |
15 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/js6pak/mojangfix/8713bd5aa18bd1640347ddfe327961f99c5efb46/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | # This is normally unused
84 | # shellcheck disable=SC2034
85 | APP_BASE_NAME=${0##*/}
86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
88 |
89 | # Use the maximum available, or set MAX_FD != -1 to use that value.
90 | MAX_FD=maximum
91 |
92 | warn () {
93 | echo "$*"
94 | } >&2
95 |
96 | die () {
97 | echo
98 | echo "$*"
99 | echo
100 | exit 1
101 | } >&2
102 |
103 | # OS specific support (must be 'true' or 'false').
104 | cygwin=false
105 | msys=false
106 | darwin=false
107 | nonstop=false
108 | case "$( uname )" in #(
109 | CYGWIN* ) cygwin=true ;; #(
110 | Darwin* ) darwin=true ;; #(
111 | MSYS* | MINGW* ) msys=true ;; #(
112 | NONSTOP* ) nonstop=true ;;
113 | esac
114 |
115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
116 |
117 |
118 | # Determine the Java command to use to start the JVM.
119 | if [ -n "$JAVA_HOME" ] ; then
120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
121 | # IBM's JDK on AIX uses strange locations for the executables
122 | JAVACMD=$JAVA_HOME/jre/sh/java
123 | else
124 | JAVACMD=$JAVA_HOME/bin/java
125 | fi
126 | if [ ! -x "$JAVACMD" ] ; then
127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
128 |
129 | Please set the JAVA_HOME variable in your environment to match the
130 | location of your Java installation."
131 | fi
132 | else
133 | JAVACMD=java
134 | if ! command -v java >/dev/null 2>&1
135 | then
136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 | fi
142 |
143 | # Increase the maximum file descriptors if we can.
144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
145 | case $MAX_FD in #(
146 | max*)
147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148 | # shellcheck disable=SC3045
149 | MAX_FD=$( ulimit -H -n ) ||
150 | warn "Could not query maximum file descriptor limit"
151 | esac
152 | case $MAX_FD in #(
153 | '' | soft) :;; #(
154 | *)
155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156 | # shellcheck disable=SC3045
157 | ulimit -n "$MAX_FD" ||
158 | warn "Could not set maximum file descriptor limit to $MAX_FD"
159 | esac
160 | fi
161 |
162 | # Collect all arguments for the java command, stacking in reverse order:
163 | # * args from the command line
164 | # * the main class name
165 | # * -classpath
166 | # * -D...appname settings
167 | # * --module-path (only if needed)
168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
169 |
170 | # For Cygwin or MSYS, switch paths to Windows format before running java
171 | if "$cygwin" || "$msys" ; then
172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
174 |
175 | JAVACMD=$( cygpath --unix "$JAVACMD" )
176 |
177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
178 | for arg do
179 | if
180 | case $arg in #(
181 | -*) false ;; # don't mess with options #(
182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
183 | [ -e "$t" ] ;; #(
184 | *) false ;;
185 | esac
186 | then
187 | arg=$( cygpath --path --ignore --mixed "$arg" )
188 | fi
189 | # Roll the args list around exactly as many times as the number of
190 | # args, so each arg winds up back in the position where it started, but
191 | # possibly modified.
192 | #
193 | # NB: a `for` loop captures its iteration list before it begins, so
194 | # changing the positional parameters here affects neither the number of
195 | # iterations, nor the values presented in `arg`.
196 | shift # remove old arg
197 | set -- "$@" "$arg" # push replacement arg
198 | done
199 | fi
200 |
201 |
202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204 |
205 | # Collect all arguments for the java command;
206 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
207 | # shell script including quotes and variable substitutions, so put them in
208 | # double quotes to make sure that they get re-expanded; and
209 | # * put everything else in single quotes, so that it's not re-expanded.
210 |
211 | set -- \
212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
213 | -classpath "$CLASSPATH" \
214 | org.gradle.wrapper.GradleWrapperMain \
215 | "$@"
216 |
217 | # Stop when "xargs" is not available.
218 | if ! command -v xargs >/dev/null 2>&1
219 | then
220 | die "xargs is not available"
221 | fi
222 |
223 | # Use "xargs" to parse quoted args.
224 | #
225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
226 | #
227 | # In Bash we could simply go:
228 | #
229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
230 | # set -- "${ARGS[@]}" "$@"
231 | #
232 | # but POSIX shell has neither arrays nor command substitution, so instead we
233 | # post-process each arg (as a line of input to sed) to backslash-escape any
234 | # character that might be a shell metacharacter, then use eval to reverse
235 | # that process (while maintaining the separation between arguments), and wrap
236 | # the whole thing up as a single "set" statement.
237 | #
238 | # This will of course break if any of these variables contains a newline or
239 | # an unmatched quote.
240 | #
241 |
242 | eval "set -- $(
243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
244 | xargs -n1 |
245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
246 | tr '\n' ' '
247 | )" '"$@"'
248 |
249 | exec "$JAVACMD" "$@"
250 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo.
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48 | echo.
49 | echo Please set the JAVA_HOME variable in your environment to match the
50 | echo location of your Java installation.
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo.
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62 | echo.
63 | echo Please set the JAVA_HOME variable in your environment to match the
64 | echo location of your Java installation.
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
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 %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 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 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | maven {
4 | name = 'Fabric'
5 | url = 'https://maven.fabricmc.net/'
6 | }
7 | maven {
8 | name = 'Babric'
9 | url = 'https://maven.glass-launcher.net/babric'
10 | }
11 | mavenCentral()
12 | gradlePluginPortal()
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/MojangFixMod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix;
17 |
18 | import net.fabricmc.api.ModInitializer;
19 | import net.fabricmc.loader.api.FabricLoader;
20 | import net.fabricmc.loader.api.ModContainer;
21 | import net.fabricmc.loader.api.metadata.ModMetadata;
22 | import org.slf4j.Logger;
23 | import org.slf4j.LoggerFactory;
24 |
25 | public class MojangFixMod implements ModInitializer {
26 | private static Logger LOGGER;
27 | private static ModMetadata METADATA;
28 |
29 | @Override
30 | public void onInitialize() {
31 | ModContainer mod = FabricLoader.getInstance()
32 | .getModContainer("mojangfix")
33 | .orElseThrow(NullPointerException::new);
34 |
35 | METADATA = mod.getMetadata();
36 | LOGGER = LoggerFactory.getLogger(METADATA.getName());
37 | }
38 |
39 | public static Logger getLogger() {
40 | if (LOGGER == null) {
41 | throw new IllegalStateException("Logger not yet available");
42 | }
43 |
44 | return LOGGER;
45 | }
46 |
47 | public static ModMetadata getMetadata() {
48 | if (METADATA == null) {
49 | throw new NullPointerException("Metadata hasn't been populated yet");
50 | }
51 |
52 | return METADATA;
53 | }
54 |
55 | public static String getVersion() {
56 | return getMetadata().getVersion().getFriendlyString();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/MojangFixClientMod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client;
17 |
18 | import net.fabricmc.api.ClientModInitializer;
19 | import net.minecraft.client.option.KeyBinding;
20 | import org.lwjgl.input.Keyboard;
21 |
22 | public class MojangFixClientMod implements ClientModInitializer {
23 | public final static KeyBinding COMMAND_KEYBIND = new KeyBinding("Command", Keyboard.KEY_SLASH);
24 |
25 | @Override
26 | public void onInitializeClient() {
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/gui/CallbackButtonWidget.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.gui;
17 |
18 | import net.minecraft.client.gui.widget.ButtonWidget;
19 |
20 | import java.util.function.Consumer;
21 |
22 | public class CallbackButtonWidget extends ButtonWidget {
23 | private final Consumer onPress;
24 |
25 | public CallbackButtonWidget(int x, int y, String label, Consumer onPress) {
26 | this(x, y, 200, 20, label, onPress);
27 | }
28 |
29 | public CallbackButtonWidget(int x, int y, int width, int height, String label, Consumer onPress) {
30 | super(-1, x, y, width, height, label);
31 | this.onPress = onPress;
32 | }
33 |
34 | public void onPress() {
35 | this.onPress.accept(this);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/gui/CallbackConfirmScreen.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.gui;
17 |
18 | import net.minecraft.client.gui.screen.ConfirmScreen;
19 | import net.minecraft.client.gui.screen.Screen;
20 | import net.minecraft.client.gui.widget.ButtonWidget;
21 |
22 | import java.util.function.Consumer;
23 |
24 | public class CallbackConfirmScreen extends ConfirmScreen {
25 | private final Consumer callback;
26 |
27 | public CallbackConfirmScreen(Screen screen, String title, String message, String yes, String no, Consumer callback) {
28 | super(screen, title, message, yes, no, -1);
29 | this.callback = callback;
30 | }
31 |
32 | @Override
33 | protected void buttonClicked(ButtonWidget button) {
34 | this.callback.accept(button.id == 0);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/gui/ControlsListWidget.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.gui;
17 |
18 | import lombok.Getter;
19 | import lombok.RequiredArgsConstructor;
20 | import lombok.Setter;
21 | import net.minecraft.client.Minecraft;
22 | import net.minecraft.client.gui.screen.option.KeybindsScreen;
23 | import net.minecraft.client.gui.widget.ButtonWidget;
24 | import net.minecraft.client.gui.widget.EntryListWidget;
25 | import net.minecraft.client.option.GameOptions;
26 | import net.minecraft.client.option.KeyBinding;
27 | import net.minecraft.client.render.Tessellator;
28 | import pl.js6pak.mojangfix.mixinterface.KeyBindingAccessor;
29 |
30 | import java.util.HashMap;
31 | import java.util.Map;
32 |
33 | public class ControlsListWidget extends EntryListWidget {
34 | private final Minecraft minecraft;
35 | private final GameOptions options;
36 |
37 | @Getter
38 | @Setter
39 | @RequiredArgsConstructor
40 | public static class KeyBindingEntry {
41 | private final ButtonWidget editButton;
42 | private final ButtonWidget resetButton;
43 | }
44 |
45 | @Getter
46 | private final Map buttons = new HashMap<>();
47 |
48 | public ControlsListWidget(KeybindsScreen parent, Minecraft minecraft, GameOptions options) {
49 | super(minecraft, parent.width, parent.height, 36, parent.height - 36, 20);
50 | this.minecraft = minecraft;
51 | this.options = options;
52 | }
53 |
54 | @Override
55 | protected int getEntryCount() {
56 | return options.allKeys.length;
57 | }
58 |
59 | @Override
60 | protected void entryClicked(int i, boolean bl) {
61 | }
62 |
63 | @Override
64 | protected boolean isSelectedEntry(int i) {
65 | return false;
66 | }
67 |
68 | @Override
69 | protected void renderBackground() {
70 | }
71 |
72 | private int mouseX;
73 | private int mouseY;
74 |
75 | @Override
76 | public void render(int mouseX, int mouseY, float delta) {
77 | this.mouseX = mouseX;
78 | this.mouseY = mouseY;
79 | super.render(mouseX, mouseY, delta);
80 | }
81 |
82 | @Override
83 | protected void renderEntry(int index, int x, int y, int l, Tessellator tessellator) {
84 | KeyBinding keyBinding = options.allKeys[index];
85 | KeyBindingEntry entry = buttons.get(keyBinding);
86 |
87 | minecraft.textRenderer.drawWithShadow(options.getKeybindName(index), x, y + 5, -1);
88 |
89 | ButtonWidget editButton = entry.getEditButton();
90 | editButton.x = x + 100;
91 | editButton.y = y;
92 | editButton.render(minecraft, mouseX, mouseY);
93 |
94 | ButtonWidget resetButton = entry.getResetButton();
95 | resetButton.x = editButton.x + 75;
96 | resetButton.y = editButton.y;
97 | resetButton.active = ((KeyBindingAccessor) keyBinding).getDefaultKeyCode() != keyBinding.code;
98 | resetButton.render(minecraft, mouseX, mouseY);
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/gui/multiplayer/DirectConnectScreen.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.gui.multiplayer;
17 |
18 | import net.minecraft.client.Minecraft;
19 | import net.minecraft.client.gui.screen.ConnectScreen;
20 | import net.minecraft.client.gui.screen.Screen;
21 | import net.minecraft.client.gui.widget.ButtonWidget;
22 | import net.minecraft.client.gui.widget.TextFieldWidget;
23 | import net.minecraft.client.resource.language.TranslationStorage;
24 | import org.lwjgl.input.Keyboard;
25 | import pl.js6pak.mojangfix.client.gui.CallbackButtonWidget;
26 |
27 | public class DirectConnectScreen extends Screen {
28 | private static final int DEFAULT_PORT = 25565;
29 |
30 | private final Screen parent;
31 | private TextFieldWidget addressField;
32 | private CallbackButtonWidget connectButton;
33 |
34 | public DirectConnectScreen(Screen parent) {
35 | this.parent = parent;
36 | }
37 |
38 | public static int parseIntWithDefault(String s, int def) {
39 | try {
40 | return Integer.parseInt(s.trim());
41 | } catch (Exception e) {
42 | return def;
43 | }
44 | }
45 |
46 | public static void connect(Minecraft minecraft, String addressText) {
47 | String[] split = addressText.split(":");
48 | minecraft.setScreen(new ConnectScreen(minecraft, split[0], split.length > 1 ? parseIntWithDefault(split[1], DEFAULT_PORT) : DEFAULT_PORT));
49 | }
50 |
51 | @Override
52 | public void tick() {
53 | this.addressField.tick();
54 | }
55 |
56 | public void init() {
57 | Keyboard.enableRepeatEvents(true);
58 |
59 | TranslationStorage translationStorage = TranslationStorage.getInstance();
60 | this.buttons.add(connectButton = new CallbackButtonWidget(this.width / 2 - 100, this.height / 4 + 96 + 12, translationStorage.get("multiplayer.connect"), button -> {
61 | String address = this.addressField.getText().trim();
62 | this.minecraft.options.lastServer = address.replaceAll(":", "_");
63 | this.minecraft.options.save();
64 | connect(this.minecraft, address);
65 | }));
66 | this.buttons.add(new CallbackButtonWidget(this.width / 2 - 100, this.height / 4 + 120 + 12, translationStorage.get("gui.cancel"), button -> {
67 | this.minecraft.setScreen(this.parent);
68 | }));
69 | String lastServer = this.minecraft.options.lastServer.replaceAll("_", ":");
70 | connectButton.active = lastServer.length() > 0;
71 | this.addressField = new TextFieldWidget(this, this.textRenderer, this.width / 2 - 100, this.height / 4 - 10 + 50 + 18, 200, 20, lastServer);
72 | this.addressField.focused = true;
73 | this.addressField.setMaxLength(128);
74 | }
75 |
76 | public void removed() {
77 | Keyboard.enableRepeatEvents(false);
78 | }
79 |
80 | protected void keyPressed(char character, int keyCode) {
81 | this.addressField.keyPressed(character, keyCode);
82 | if (keyCode == Keyboard.KEY_RETURN) {
83 | this.buttonClicked((ButtonWidget) this.buttons.get(0));
84 | }
85 |
86 | ((ButtonWidget) this.buttons.get(0)).active = this.addressField.getText().length() > 0;
87 | }
88 |
89 | protected void mouseClicked(int mouseX, int mouseY, int button) {
90 | super.mouseClicked(mouseX, mouseY, button);
91 | this.addressField.mouseClicked(mouseX, mouseY, button);
92 | }
93 |
94 | public void render(int mouseX, int mouseY, float delta) {
95 | this.renderBackground();
96 | this.drawCenteredTextWithShadow(this.textRenderer, "Direct connect", this.width / 2, this.height / 4 - 60 + 20, 16777215);
97 | this.drawCenteredTextWithShadow(this.textRenderer, TranslationStorage.getInstance().get("multiplayer.ipinfo"), this.width / 2, this.height / 4 - 60 + 60 + 36, 10526880);
98 | this.addressField.render();
99 | super.render(mouseX, mouseY, delta);
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/gui/multiplayer/EditServerScreen.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.gui.multiplayer;
17 |
18 | import net.minecraft.client.gui.screen.Screen;
19 | import net.minecraft.client.gui.widget.ButtonWidget;
20 | import net.minecraft.client.gui.widget.TextFieldWidget;
21 | import net.minecraft.client.resource.language.TranslationStorage;
22 | import org.lwjgl.input.Keyboard;
23 | import pl.js6pak.mojangfix.client.gui.CallbackButtonWidget;
24 |
25 | public class EditServerScreen extends Screen {
26 | private final ServerData server;
27 | private ButtonWidget button;
28 | private final MultiplayerScreen parent;
29 | private TextFieldWidget nameTextField;
30 | private TextFieldWidget ipTextField;
31 |
32 | public EditServerScreen(MultiplayerScreen parent, ServerData server) {
33 | this.parent = parent;
34 | this.server = server;
35 | }
36 |
37 | public void tick() {
38 | this.nameTextField.tick();
39 | this.ipTextField.tick();
40 | }
41 |
42 | public void init() {
43 | Keyboard.enableRepeatEvents(true);
44 | this.buttons.add(this.button = new CallbackButtonWidget(this.width / 2 - 100, this.height / 4 + 96 + 12, this.server == null ? "Add" : "Edit", button -> {
45 | if (this.server != null) {
46 | this.server.setName(this.nameTextField.getText());
47 | this.server.setIp(this.ipTextField.getText());
48 | } else {
49 | this.parent.getServersList().add(new ServerData(this.nameTextField.getText(), this.ipTextField.getText()));
50 | }
51 |
52 | this.parent.saveServers();
53 | this.minecraft.setScreen(this.parent);
54 | }));
55 | this.buttons.add(new CallbackButtonWidget(this.width / 2 - 100, this.height / 4 + 120 + 12, TranslationStorage.getInstance().get("gui.cancel"), button -> {
56 | this.minecraft.setScreen(this.parent);
57 | }));
58 | this.nameTextField = new TextFieldWidget(this, this.textRenderer, this.width / 2 - 100, 60, 200, 20, this.server == null ? "" : this.server.getName());
59 | this.nameTextField.setMaxLength(32);
60 | this.ipTextField = new TextFieldWidget(this, this.textRenderer, this.width / 2 - 100, 106, 200, 20, this.server == null ? "" : this.server.getIp());
61 | this.ipTextField.setMaxLength(32);
62 | this.updateButton();
63 | }
64 |
65 | private void updateButton() {
66 | this.button.active = this.nameTextField.getText().trim().length() > 0 && this.ipTextField.getText().trim().length() > 0;
67 | }
68 |
69 | public void removed() {
70 | Keyboard.enableRepeatEvents(false);
71 | }
72 |
73 | @Override
74 | protected void keyPressed(char character, int keyCode) {
75 | this.nameTextField.keyPressed(character, keyCode);
76 | this.ipTextField.keyPressed(character, keyCode);
77 | this.updateButton();
78 | if (character == Keyboard.KEY_RETURN) {
79 | this.buttonClicked(this.button);
80 | }
81 |
82 | }
83 |
84 | protected void mouseClicked(int mouseX, int mouseY, int varbutton) {
85 | super.mouseClicked(mouseX, mouseY, varbutton);
86 | this.nameTextField.mouseClicked(mouseX, mouseY, varbutton);
87 | this.ipTextField.mouseClicked(mouseX, mouseY, varbutton);
88 | }
89 |
90 | public void render(int mouseX, int mouseY, float delta) {
91 | this.renderBackground();
92 | this.drawStringWithShadow(this.textRenderer, (this.server == null ? "Add" : "Edit") + " Server", this.width / 2, 20, 16777215);
93 | this.drawStringWithShadow(this.textRenderer, "Server name", this.width / 2 - 100, 47, 10526880);
94 | this.drawStringWithShadow(this.textRenderer, "Server IP", this.width / 2 - 100, 94, 10526880);
95 | this.nameTextField.render();
96 | this.ipTextField.render();
97 | super.render(mouseX, mouseY, delta);
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/gui/multiplayer/MultiplayerScreen.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.gui.multiplayer;
17 |
18 | import lombok.Getter;
19 | import net.minecraft.client.Minecraft;
20 | import net.minecraft.client.font.TextRenderer;
21 | import net.minecraft.client.gui.screen.Screen;
22 | import net.minecraft.client.gui.screen.TitleScreen;
23 | import net.minecraft.client.gui.widget.ButtonWidget;
24 | import net.minecraft.client.resource.language.TranslationStorage;
25 | import net.minecraft.nbt.NbtCompound;
26 | import net.minecraft.nbt.NbtIo;
27 | import pl.js6pak.mojangfix.client.gui.CallbackButtonWidget;
28 | import pl.js6pak.mojangfix.client.gui.CallbackConfirmScreen;
29 |
30 | import java.io.*;
31 | import java.util.ArrayList;
32 | import java.util.List;
33 |
34 | public class MultiplayerScreen extends Screen {
35 | private final Screen parent;
36 | private String title;
37 | private boolean joining;
38 |
39 | @Getter
40 | private ServerData selectedServer;
41 |
42 | @Getter
43 | private List serversList;
44 |
45 | private MultiplayerServerListWidget serverListWidget;
46 |
47 | private ButtonWidget buttonEdit;
48 | private ButtonWidget buttonConnect;
49 | private ButtonWidget buttonDelete;
50 |
51 | public MultiplayerScreen() {
52 | this(new TitleScreen());
53 | }
54 |
55 | public MultiplayerScreen(Screen parent) {
56 | this.parent = parent;
57 | }
58 |
59 | public void init() {
60 | this.title = TranslationStorage.getInstance().get("multiplayer.title");
61 | this.loadServers();
62 | this.serverListWidget = new MultiplayerServerListWidget(this);
63 | this.initButtons();
64 | }
65 |
66 | private void loadServers() {
67 | this.selectedServer = null;
68 |
69 | try {
70 | File serversFile = new File(Minecraft.getRunDirectory(), "servers.dat");
71 | if (serversFile.exists()) {
72 | NbtCompound nbt = NbtIo.read(new DataInputStream(new FileInputStream(serversFile)));
73 | this.serversList = ServerData.load(nbt.getList("servers"));
74 | } else {
75 | this.serversList = new ArrayList<>();
76 | this.saveServers();
77 | }
78 | } catch (IOException e) {
79 | e.printStackTrace();
80 | }
81 |
82 | }
83 |
84 | public void initButtons() {
85 | TranslationStorage translationStorage = TranslationStorage.getInstance();
86 | this.buttons.add(this.buttonConnect = new CallbackButtonWidget(this.width / 2 - 150 - 4, this.height - 52, 100, 20, "Connect", button -> {
87 | this.joinServer(this.selectedServer);
88 | }));
89 | this.buttons.add(new CallbackButtonWidget(this.width / 2 - 50, this.height - 52, 100, 20, "Direct connect", button -> {
90 | this.minecraft.setScreen(new DirectConnectScreen(this));
91 | }));
92 | this.buttons.add(new CallbackButtonWidget(this.width / 2 + 50 + 4, this.height - 52, 100, 20, "Add server", button -> {
93 | this.minecraft.setScreen(new EditServerScreen(this, null));
94 | }));
95 | this.buttons.add(this.buttonEdit = new CallbackButtonWidget(this.width / 2 - 154, this.height - 28, 70, 20, "Edit", button -> {
96 | this.minecraft.setScreen(new EditServerScreen(this, this.selectedServer));
97 | }));
98 | this.buttons.add(this.buttonDelete = new CallbackButtonWidget(this.width / 2 - 74, this.height - 28, 70, 20, translationStorage.get("selectWorld.delete"), button -> {
99 | TranslationStorage translate = TranslationStorage.getInstance();
100 | this.minecraft.setScreen(new CallbackConfirmScreen(this,
101 | translate.get("Are you sure you want to delete this server?"),
102 | "'" + this.selectedServer.getName() + "' " + translate.get("selectWorld.deleteWarning"),
103 | translate.get("selectWorld.deleteButton"),
104 | translate.get("gui.cancel"),
105 | (result) -> {
106 | if (result) {
107 | this.deleteServer(this.selectedServer);
108 | }
109 |
110 | this.minecraft.setScreen(this);
111 | }));
112 | }));
113 | this.buttons.add(new CallbackButtonWidget(this.width / 2 + 4, this.height - 28, 150, 20, translationStorage.get("gui.cancel"), button -> {
114 | this.minecraft.setScreen(this.parent);
115 | }));
116 | this.buttonConnect.active = false;
117 | this.buttonEdit.active = false;
118 | this.buttonDelete.active = false;
119 | }
120 |
121 | @Override
122 | protected void buttonClicked(ButtonWidget button) {
123 | this.serverListWidget.buttonClicked(button);
124 | }
125 |
126 | public void selectServer(int slot, boolean join) {
127 | selectedServer = serversList.get(slot);
128 | boolean selected = selectedServer != null;
129 |
130 | buttonEdit.active = selected;
131 | buttonDelete.active = selected;
132 | buttonConnect.active = selected;
133 |
134 | if (selected && join) {
135 | joinServer(selectedServer);
136 | }
137 | }
138 |
139 | public void joinServer(ServerData server) {
140 | this.minecraft.setScreen(null);
141 | if (!this.joining) {
142 | this.joining = true;
143 | DirectConnectScreen.connect(this.minecraft, server.getIp());
144 | }
145 | }
146 |
147 | public void deleteServer(ServerData server) {
148 | this.serversList.remove(server);
149 | this.saveServers();
150 | }
151 |
152 | public void saveServers() {
153 | try {
154 | NbtCompound compound = new NbtCompound();
155 | compound.put("servers", ServerData.save(serversList));
156 | NbtIo.write(compound, new DataOutputStream(new FileOutputStream(new File(Minecraft.getRunDirectory(), "servers.dat"))));
157 | } catch (IOException e) {
158 | e.printStackTrace();
159 | }
160 |
161 | }
162 |
163 | @Override
164 | public void render(int mouseX, int mouseY, float delta) {
165 | this.serverListWidget.render(mouseX, mouseY, delta);
166 | this.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 20, 16777215);
167 | super.render(mouseX, mouseY, delta);
168 | }
169 |
170 | public Minecraft getMinecraft() {
171 | return this.minecraft;
172 | }
173 |
174 | public TextRenderer getFontRenderer() {
175 | return this.textRenderer;
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/gui/multiplayer/MultiplayerServerListWidget.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.gui.multiplayer;
17 |
18 | import net.minecraft.client.gui.widget.EntryListWidget;
19 | import net.minecraft.client.render.Tessellator;
20 |
21 | public class MultiplayerServerListWidget extends EntryListWidget {
22 | private final MultiplayerScreen parent;
23 |
24 | public MultiplayerServerListWidget(MultiplayerScreen parent) {
25 | super(parent.getMinecraft(), parent.width, parent.height, 32, parent.height - 64, 36);
26 | this.parent = parent;
27 | }
28 |
29 | @Override
30 | protected int getEntryCount() {
31 | return this.parent.getServersList().size();
32 | }
33 |
34 | @Override
35 | protected void entryClicked(int slot, boolean doubleClick) {
36 | this.parent.selectServer(slot, doubleClick);
37 | }
38 |
39 | @Override
40 | protected boolean isSelectedEntry(int i) {
41 | return i == this.parent.getServersList().indexOf(this.parent.getSelectedServer());
42 | }
43 |
44 | @Override
45 | protected int getEntriesHeight() {
46 | return this.parent.getServersList().size() * 36;
47 | }
48 |
49 | @Override
50 | protected void renderBackground() {
51 | this.parent.renderBackground();
52 | }
53 |
54 | @Override
55 | protected void renderEntry(int index, int x, int y, int l, Tessellator arg) {
56 | ServerData server = this.parent.getServersList().get(index);
57 | this.parent.drawStringWithShadow(this.parent.getFontRenderer(), server.getName(), x + 2, y + 1, 0xffffff);
58 | this.parent.drawStringWithShadow(this.parent.getFontRenderer(), server.getIp(), x + 2, y + 12, 0x808080);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/gui/multiplayer/ServerData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.gui.multiplayer;
17 |
18 | import lombok.Getter;
19 | import lombok.NonNull;
20 | import lombok.RequiredArgsConstructor;
21 | import lombok.Setter;
22 | import net.minecraft.nbt.NbtCompound;
23 | import net.minecraft.nbt.NbtList;
24 |
25 | import java.util.ArrayList;
26 | import java.util.List;
27 |
28 | @Getter
29 | @Setter
30 | @RequiredArgsConstructor
31 | public class ServerData {
32 | @NonNull
33 | private String name;
34 |
35 | @NonNull
36 | private String ip;
37 |
38 | public NbtCompound save() {
39 | NbtCompound nbt = new NbtCompound();
40 | nbt.putString("name", name);
41 | nbt.putString("ip", ip);
42 | return nbt;
43 | }
44 |
45 | public ServerData(NbtCompound nbt) {
46 | this(nbt.getString("name"), nbt.getString("ip"));
47 | }
48 |
49 | public static NbtList save(List servers) {
50 | NbtList nbt = new NbtList();
51 | for (ServerData server : servers) {
52 | nbt.add(server.save());
53 | }
54 | return nbt;
55 | }
56 |
57 | public static List load(NbtList nbt) {
58 | ArrayList servers = new ArrayList<>();
59 | for (int i = 0; i < nbt.size(); i++) {
60 | servers.add(new ServerData((NbtCompound) nbt.get(i)));
61 | }
62 | return servers;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/skinfix/CapeImageProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.skinfix;
17 |
18 | import net.minecraft.client.texture.ImageProcessor;
19 |
20 | import java.awt.*;
21 | import java.awt.image.BufferedImage;
22 |
23 | public class CapeImageProcessor implements ImageProcessor {
24 | @Override
25 | public BufferedImage process(BufferedImage image) {
26 | if (image == null) {
27 | return null;
28 | } else {
29 | int width = 64;
30 | int height = 32;
31 |
32 | for (int i = image.getHeight(); width < image.getWidth() || height < i; height *= 2) {
33 | width *= 2;
34 | }
35 |
36 | BufferedImage bufferedimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
37 | Graphics graphics = bufferedimage.getGraphics();
38 | graphics.drawImage(image, 0, 0, null);
39 | graphics.dispose();
40 | return bufferedimage;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/skinfix/PlayerEntityModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.skinfix;
17 |
18 | import net.minecraft.client.model.ModelPart;
19 | import net.minecraft.client.render.entity.model.BipedEntityModel;
20 | import pl.js6pak.mojangfix.mixinterface.ModelPartAccessor;
21 |
22 | public class PlayerEntityModel extends BipedEntityModel {
23 | public final ModelPart leftSleeve;
24 | public final ModelPart rightSleeve;
25 | public final ModelPart leftPantLeg;
26 | public final ModelPart rightPantLeg;
27 | public final ModelPart jacket;
28 |
29 | public PlayerEntityModel(float scale, boolean thinArms) {
30 | super(scale);
31 | if (thinArms) {
32 | this.leftArm = this.createModelPart(32, 48);
33 | this.leftArm.addCuboid(-1.0F, -2.0F, -2.0F, 3, 12, 4, scale);
34 | this.leftArm.setPivot(5.0F, 2.5F, 0.0F);
35 | this.rightArm = this.createModelPart(40, 16);
36 | this.rightArm.addCuboid(-2.0F, -2.0F, -2.0F, 3, 12, 4, scale);
37 | this.rightArm.setPivot(-5.0F, 2.5F, 0.0F);
38 | this.leftSleeve = this.createModelPart(48, 48);
39 | this.leftSleeve.addCuboid(-1.0F, -2.0F, -2.0F, 3, 12, 4, scale + 0.25F);
40 | this.leftSleeve.setPivot(5.0F, 2.5F, 0.0F);
41 | this.rightSleeve = this.createModelPart(40, 32);
42 | this.rightSleeve.addCuboid(-2.0F, -2.0F, -2.0F, 3, 12, 4, scale + 0.25F);
43 | this.rightSleeve.setPivot(-5.0F, 2.5F, 10.0F);
44 | } else {
45 | this.leftArm = this.createModelPart(32, 48);
46 | this.leftArm.addCuboid(-1.0F, -2.0F, -2.0F, 4, 12, 4, scale);
47 | this.leftArm.setPivot(5.0F, 2.0F, 0.0F);
48 | this.leftSleeve = this.createModelPart(48, 48);
49 | this.leftSleeve.addCuboid(-1.0F, -2.0F, -2.0F, 4, 12, 4, scale + 0.25F);
50 | this.leftSleeve.setPivot(5.0F, 2.0F, 0.0F);
51 | this.rightSleeve = this.createModelPart(40, 32);
52 | this.rightSleeve.addCuboid(-3.0F, -2.0F, -2.0F, 4, 12, 4, scale + 0.25F);
53 | this.rightSleeve.setPivot(-5.0F, 2.0F, 10.0F);
54 | }
55 |
56 | this.leftLeg = this.createModelPart(16, 48);
57 | this.leftLeg.addCuboid(-2.0F, 0.0F, -2.0F, 4, 12, 4, scale);
58 | this.leftLeg.setPivot(2.0F, 12.0F, 0.0F);
59 | this.leftPantLeg = this.createModelPart(0, 48);
60 | this.leftPantLeg.addCuboid(-2.0F, 0.0F, -2.0F, 4, 12, 4, scale + 0.25F);
61 | this.leftPantLeg.setPivot(1.9F, 12.0F, 0.0F);
62 | this.rightPantLeg = this.createModelPart(0, 32);
63 | this.rightPantLeg.addCuboid(-2.0F, 0.0F, -2.0F, 4, 12, 4, scale + 0.25F);
64 | this.rightPantLeg.setPivot(-1.9F, 12.0F, 0.0F);
65 | this.jacket = this.createModelPart(16, 32);
66 | this.jacket.addCuboid(-4.0F, 0.0F, -2.0F, 8, 12, 4, scale + 0.25F);
67 | this.jacket.setPivot(0.0F, 0.0F, 0.0F);
68 | }
69 |
70 | private ModelPart createModelPart(int x, int y) {
71 | ModelPart modelRenderer = new ModelPart(x, y);
72 | ((ModelPartAccessor) modelRenderer).setTextureHeight(64);
73 | return modelRenderer;
74 | }
75 |
76 | @Override
77 | public void render(float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch, float scale) {
78 | super.render(limbAngle, limbDistance, animationProgress, headYaw, headPitch, scale);
79 |
80 | this.leftPantLeg.render(scale);
81 | this.rightPantLeg.render(scale);
82 | this.leftSleeve.render(scale);
83 | this.rightSleeve.render(scale);
84 | this.jacket.render(scale);
85 | }
86 |
87 | public void copyPositionAndRotation(ModelPart from, ModelPart to) {
88 | to.setPivot(from.pivotX, from.pivotY, from.pivotZ);
89 | to.yaw = from.yaw;
90 | to.pitch = from.pitch;
91 | to.roll = from.roll;
92 | }
93 |
94 | @Override
95 | public void setAngles(float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch, float scale) {
96 | super.setAngles(limbAngle, limbDistance, animationProgress, headYaw, headPitch, scale);
97 | this.copyPositionAndRotation(this.leftLeg, this.leftPantLeg);
98 | this.copyPositionAndRotation(this.rightLeg, this.rightPantLeg);
99 | this.copyPositionAndRotation(this.leftArm, this.leftSleeve);
100 | this.copyPositionAndRotation(this.rightArm, this.rightSleeve);
101 | this.copyPositionAndRotation(this.body, this.jacket);
102 | this.copyPositionAndRotation(this.head, this.hat);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/skinfix/PlayerProfile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.skinfix;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 | import lombok.Data;
20 |
21 | import java.time.Instant;
22 | import java.util.UUID;
23 |
24 | @Data
25 | public class PlayerProfile {
26 | private UUID uuid;
27 | private String skinUrl;
28 | private String capeUrl;
29 | private GameProfile.TextureModel model;
30 | private Instant lastFetched = Instant.now();
31 |
32 | public PlayerProfile(UUID uuid, String skinUrl, String capeUrl, GameProfile.TextureModel model) {
33 | this.uuid = uuid;
34 | this.skinUrl = skinUrl;
35 | this.capeUrl = capeUrl;
36 | this.model = model;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/skinfix/SkinService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.skinfix;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 | import com.github.steveice10.mc.auth.exception.property.PropertyException;
20 | import net.minecraft.entity.player.PlayerEntity;
21 | import pl.js6pak.mojangfix.MojangFixMod;
22 | import pl.js6pak.mojangfix.client.skinfix.provider.AshconProfileProvider;
23 | import pl.js6pak.mojangfix.client.skinfix.provider.MojangProfileProvider;
24 | import pl.js6pak.mojangfix.client.skinfix.provider.ProfileProvider;
25 | import pl.js6pak.mojangfix.mixin.client.MinecraftAccessor;
26 | import pl.js6pak.mojangfix.mixinterface.PlayerEntityAccessor;
27 |
28 | import java.nio.charset.StandardCharsets;
29 | import java.util.*;
30 | import java.util.concurrent.ConcurrentHashMap;
31 | import java.util.concurrent.ConcurrentMap;
32 | import java.util.concurrent.ExecutionException;
33 | import java.util.concurrent.locks.ReentrantLock;
34 |
35 | public class SkinService {
36 | public static final String RESOURCES_URL = "http://mcresources.modification-station.net/MinecraftResources/";
37 | public static final String STEVE_TEXTURE = "/mob/steve.png";
38 | public static final String ALEX_TEXTURE = "/mob/alex.png";
39 |
40 | private static final SkinService INSTANCE = new SkinService();
41 |
42 | public static SkinService getInstance() {
43 | return INSTANCE;
44 | }
45 |
46 | private final ConcurrentMap locks = new ConcurrentHashMap<>();
47 | private final Map profiles = new HashMap<>();
48 |
49 | private final List providers = Arrays.asList(new AshconProfileProvider(), new MojangProfileProvider());
50 |
51 | private static GameProfile.TextureModel getTextureModelForUUID(UUID uuid) {
52 | return (uuid.hashCode() & 1) != 0 ? GameProfile.TextureModel.SLIM : GameProfile.TextureModel.NORMAL;
53 | }
54 |
55 | private void updatePlayer(PlayerEntity player, PlayerProfile playerProfile) {
56 | if (playerProfile == null) return;
57 |
58 | PlayerEntityAccessor accessor = (PlayerEntityAccessor) player;
59 | accessor.setTextureModel(playerProfile.getModel());
60 | player.skinUrl = playerProfile.getSkinUrl();
61 | player.capeUrl = player.playerCapeUrl = playerProfile.getCapeUrl();
62 | MinecraftAccessor.getInstance().worldRenderer.loadEntitySkin(player);
63 | }
64 |
65 | private boolean updatePlayer(PlayerEntity player) {
66 | if (profiles.containsKey(player.name)) {
67 | PlayerProfile profile = profiles.get(player.name);
68 | updatePlayer(player, profile);
69 | return true;
70 | }
71 |
72 | return false;
73 | }
74 |
75 | private void initOffline(PlayerEntity player) {
76 | UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.name).getBytes(StandardCharsets.UTF_8));
77 | PlayerEntityAccessor accessor = (PlayerEntityAccessor) player;
78 | final GameProfile.TextureModel model = getTextureModelForUUID(uuid);
79 | accessor.setTextureModel(model);
80 | }
81 |
82 | public void init(PlayerEntity player) {
83 | if (updatePlayer(player)) return;
84 |
85 | initOffline(player);
86 |
87 | (new Thread(() -> {
88 | init(player.name);
89 | updatePlayer(player);
90 | })).start();
91 | }
92 |
93 | public void init(String name) {
94 | if (profiles.containsKey(name)) return;
95 |
96 | ReentrantLock lock;
97 | if (locks.containsKey(name)) {
98 | lock = locks.get(name);
99 | } else {
100 | locks.put(name, lock = new ReentrantLock());
101 | }
102 |
103 | lock.lock();
104 | try {
105 | if (profiles.containsKey(name)) return;
106 |
107 | for (ProfileProvider provider : providers) {
108 | GameProfile profile;
109 |
110 | try {
111 | profile = provider.get(name).get();
112 | } catch (InterruptedException | ExecutionException e) {
113 | MojangFixMod.getLogger().warn("Lookup using {} for profile {} failed!", provider.getClass().getSimpleName(), name);
114 | continue;
115 | }
116 |
117 | Map textures;
118 |
119 | try {
120 | textures = profile.getTextures();
121 | } catch (PropertyException e) {
122 | MojangFixMod.getLogger().warn("Texture decoding using {} for profile {} failed!", provider.getClass().getSimpleName(), name);
123 | continue;
124 | }
125 |
126 | GameProfile.Texture skin = textures.get(GameProfile.TextureType.SKIN);
127 | GameProfile.TextureModel model = skin == null ? SkinService.getTextureModelForUUID(profile.getId()) : skin.getModel();
128 | String skinUrl = skin == null ? null : skin.getURL();
129 | GameProfile.Texture cape = textures.get(GameProfile.TextureType.CAPE);
130 | String capeUrl = cape == null ? null : cape.getURL();
131 | PlayerProfile playerProfile = new PlayerProfile(profile.getId(), skinUrl, capeUrl, model);
132 |
133 | MojangFixMod.getLogger().info("Downloaded profile: " + profile.getName() + " (" + profile.getId() + ")");
134 | profiles.put(name, playerProfile);
135 | return;
136 | }
137 |
138 | profiles.put(name, null);
139 | } finally {
140 | lock.unlock();
141 | }
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/skinfix/provider/AshconProfileProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.skinfix.provider;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 | import com.github.steveice10.mc.auth.exception.request.RequestException;
20 | import com.github.steveice10.mc.auth.util.HTTP;
21 | import lombok.Data;
22 |
23 | import java.net.Proxy;
24 | import java.net.URI;
25 | import java.util.Collections;
26 | import java.util.UUID;
27 | import java.util.concurrent.CompletableFuture;
28 | import java.util.concurrent.Future;
29 |
30 | public class AshconProfileProvider implements ProfileProvider {
31 | @Override
32 | public Future get(String username) {
33 | try {
34 | Response response = HTTP.makeRequest(Proxy.NO_PROXY, URI.create("https://api.ashcon.app/mojang/v2/user/" + username), null, Response.class);
35 | GameProfile gameProfile = new GameProfile(response.uuid, username);
36 |
37 | Response.Textures.Property raw = response.textures.raw;
38 | gameProfile.setProperties(Collections.singletonList(new GameProfile.Property("textures", raw.value, raw.signature)));
39 |
40 | return CompletableFuture.completedFuture(gameProfile);
41 | } catch (RequestException e) {
42 | CompletableFuture future = new CompletableFuture<>();
43 | future.completeExceptionally(e);
44 | return future;
45 | }
46 | }
47 |
48 | @Data
49 | private static class Response {
50 | private UUID uuid;
51 | private Textures textures;
52 |
53 | @Data
54 | private static class Textures {
55 | private boolean slim;
56 | private boolean custom;
57 | private Property raw;
58 |
59 | @Data
60 | private static class Property {
61 | private String value;
62 | private String signature;
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/skinfix/provider/MojangProfileProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.skinfix.provider;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 | import com.github.steveice10.mc.auth.exception.profile.ProfileException;
20 | import com.github.steveice10.mc.auth.service.ProfileService;
21 | import com.github.steveice10.mc.auth.service.SessionService;
22 | import pl.js6pak.mojangfix.mixinterface.SessionAccessor;
23 |
24 | import java.util.concurrent.CompletableFuture;
25 | import java.util.concurrent.Future;
26 |
27 | public class MojangProfileProvider implements ProfileProvider {
28 | private final ProfileService profileService = new ProfileService();
29 |
30 | @Override
31 | public Future get(String username) {
32 | CompletableFuture future = new CompletableFuture<>();
33 |
34 | profileService.findProfilesByName(new String[]{username}, new ProfileService.ProfileLookupCallback() {
35 | public void onProfileLookupSucceeded(GameProfile profile) {
36 | SessionService sessionService = SessionAccessor.SESSION_SERVICE;
37 |
38 | try {
39 | sessionService.fillProfileProperties(profile);
40 | future.complete(profile);
41 | } catch (ProfileException e) {
42 | future.completeExceptionally(e);
43 | }
44 | }
45 |
46 | public void onProfileLookupFailed(GameProfile profile, Exception e) {
47 | future.completeExceptionally(e);
48 | }
49 | }, false);
50 |
51 | return future;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/client/skinfix/provider/ProfileProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.client.skinfix.provider;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 |
20 | import java.util.concurrent.Future;
21 |
22 | public interface ProfileProvider {
23 | Future get(String username);
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/MinecraftAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client;
17 |
18 | import net.minecraft.client.Minecraft;
19 | import org.spongepowered.asm.mixin.Mixin;
20 | import org.spongepowered.asm.mixin.gen.Accessor;
21 |
22 | @Mixin(Minecraft.class)
23 | public interface MinecraftAccessor {
24 | @Accessor(value = "INSTANCE")
25 | static Minecraft getInstance() {
26 | throw new UnsupportedOperationException();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/ScreenAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client;
17 |
18 | import net.minecraft.client.gui.screen.Screen;
19 | import net.minecraft.client.gui.widget.ButtonWidget;
20 | import org.spongepowered.asm.mixin.Mixin;
21 | import org.spongepowered.asm.mixin.gen.Invoker;
22 |
23 | @Mixin(Screen.class)
24 | public interface ScreenAccessor {
25 | @Invoker
26 | void callButtonClicked(ButtonWidget button);
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/auth/ClientNetworkHandlerMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.auth;
17 |
18 | import com.github.steveice10.mc.auth.exception.request.RequestException;
19 | import net.minecraft.client.Minecraft;
20 | import net.minecraft.client.network.ClientNetworkHandler;
21 | import net.minecraft.network.Connection;
22 | import net.minecraft.network.Packet;
23 | import net.minecraft.network.packet.handshake.HandshakePacket;
24 | import net.minecraft.network.packet.login.LoginHelloPacket;
25 | import org.spongepowered.asm.mixin.Mixin;
26 | import org.spongepowered.asm.mixin.Shadow;
27 | import org.spongepowered.asm.mixin.injection.At;
28 | import org.spongepowered.asm.mixin.injection.Inject;
29 | import org.spongepowered.asm.mixin.injection.Redirect;
30 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
31 | import pl.js6pak.mojangfix.mixinterface.SessionAccessor;
32 |
33 | @Mixin(ClientNetworkHandler.class)
34 | public abstract class ClientNetworkHandlerMixin {
35 | @Shadow
36 | private Minecraft minecraft;
37 |
38 | @Shadow
39 | private Connection connection;
40 |
41 | @Shadow
42 | public abstract void sendPacket(Packet arg);
43 |
44 | @Redirect(method = "handleHandshake", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z"))
45 | private boolean checkServerId(String serverId, Object offline) {
46 | return serverId.trim().isEmpty() || serverId.equals(offline) || this.minecraft.session.sessionId.trim().isEmpty() || this.minecraft.session.sessionId.equals(offline);
47 | }
48 |
49 | @Inject(method = "handleHandshake", at = @At(value = "NEW", target = "java/net/URL"), cancellable = true)
50 | private void onJoinServer(HandshakePacket packet, CallbackInfo ci) {
51 | SessionAccessor session = (SessionAccessor) this.minecraft.session;
52 |
53 | try {
54 | if (session.getGameProfile() == null || session.getAccessToken() == null) {
55 | this.connection.disconnect("disconnect.loginFailedInfo", "Invalid access token!");
56 | }
57 |
58 | SessionAccessor.SESSION_SERVICE.joinServer(session.getGameProfile(), session.getAccessToken(), packet.name);
59 | this.sendPacket(new LoginHelloPacket(this.minecraft.session.username, 14));
60 | } catch (RequestException e) {
61 | this.connection.disconnect("disconnect.loginFailedInfo", e.getClass().getSimpleName() + "\n" + e.getMessage());
62 | }
63 |
64 | ci.cancel();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/auth/SessionMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.auth;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 | import lombok.Getter;
20 | import net.minecraft.client.util.Session;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.Unique;
23 | import org.spongepowered.asm.mixin.injection.At;
24 | import org.spongepowered.asm.mixin.injection.Inject;
25 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
26 | import pl.js6pak.mojangfix.MojangFixMod;
27 | import pl.js6pak.mojangfix.client.skinfix.SkinService;
28 | import pl.js6pak.mojangfix.mixinterface.SessionAccessor;
29 |
30 | import java.util.UUID;
31 | import java.util.regex.Pattern;
32 |
33 | @Mixin(Session.class)
34 | public class SessionMixin implements SessionAccessor {
35 | @Unique
36 | @Getter
37 | private GameProfile gameProfile;
38 |
39 | @Unique
40 | @Getter
41 | private String accessToken;
42 |
43 | @Unique
44 | private static final Pattern UUID_PATTERN = Pattern.compile("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})");
45 |
46 | @Inject(method = "", at = @At("RETURN"))
47 | private void onInit(String username, String sessionId, CallbackInfo ci) {
48 | String[] split = sessionId.split(":");
49 | if (split.length == 3 && split[0].equalsIgnoreCase("token")) {
50 | accessToken = split[1];
51 | UUID uuid = UUID.fromString(UUID_PATTERN.matcher(split[2]).replaceAll("$1-$2-$3-$4-$5"));
52 | gameProfile = new GameProfile(uuid, username);
53 |
54 | MojangFixMod.getLogger().info("Signed as {} ({})", username, uuid);
55 | } else {
56 | MojangFixMod.getLogger().info("Signed as {}", username);
57 | }
58 |
59 | SkinService.getInstance().init(username);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/controls/ControlsOptionsScreenMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.controls;
17 |
18 | import net.minecraft.client.gui.screen.Screen;
19 | import net.minecraft.client.gui.screen.option.KeybindsScreen;
20 | import net.minecraft.client.gui.widget.ButtonWidget;
21 | import net.minecraft.client.gui.widget.OptionButtonWidget;
22 | import net.minecraft.client.option.GameOptions;
23 | import net.minecraft.client.option.KeyBinding;
24 | import org.spongepowered.asm.mixin.Mixin;
25 | import org.spongepowered.asm.mixin.Shadow;
26 | import org.spongepowered.asm.mixin.Unique;
27 | import org.spongepowered.asm.mixin.injection.At;
28 | import org.spongepowered.asm.mixin.injection.Inject;
29 | import org.spongepowered.asm.mixin.injection.Redirect;
30 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
31 | import pl.js6pak.mojangfix.client.gui.CallbackButtonWidget;
32 | import pl.js6pak.mojangfix.client.gui.ControlsListWidget;
33 | import pl.js6pak.mojangfix.mixinterface.KeyBindingAccessor;
34 |
35 | @Mixin(KeybindsScreen.class)
36 | public class ControlsOptionsScreenMixin extends Screen {
37 | @Shadow
38 | private GameOptions gameOptions;
39 |
40 | @Unique
41 | private ControlsListWidget controlsList;
42 |
43 | @Inject(method = "init", at = @At("HEAD"))
44 | private void onInit(CallbackInfo ci) {
45 | this.controlsList = new ControlsListWidget((KeybindsScreen) (Object) this, minecraft, gameOptions);
46 | }
47 |
48 | @Redirect(method = "init", at = @At(value = "NEW", target = "net/minecraft/client/gui/widget/OptionButtonWidget"))
49 | private OptionButtonWidget redirectOptionButtonWidget(int id, int x, int y, int width, int height, String text) {
50 | OptionButtonWidget editButton = new OptionButtonWidget(id, -1, -1, width, height, text);
51 | CallbackButtonWidget resetButton = new CallbackButtonWidget(-1, -1, 50, 20, "Reset", (button) -> {
52 | KeyBinding keyBinding = this.gameOptions.allKeys[id];
53 | keyBinding.code = ((KeyBindingAccessor) keyBinding).getDefaultKeyCode();
54 | ((ButtonWidget) this.buttons.get(id)).text = this.gameOptions.getKeybindKey(id);
55 | });
56 | controlsList.getButtons().put(this.gameOptions.allKeys[id], new ControlsListWidget.KeyBindingEntry(editButton, resetButton));
57 | return editButton;
58 | }
59 |
60 | @Inject(method = "init", at = @At("RETURN"))
61 | private void afterInit(CallbackInfo ci) {
62 | for (ControlsListWidget.KeyBindingEntry entry : controlsList.getButtons().values()) {
63 | this.buttons.add(entry.getResetButton());
64 | }
65 | }
66 |
67 | @Unique
68 | private ButtonWidget doneButton;
69 |
70 | @Redirect(method = "init", at = @At(value = "NEW", target = "net/minecraft/client/gui/widget/ButtonWidget"))
71 | private ButtonWidget redirectDoneButton(int id, int x, int y, String text) {
72 | return doneButton = new ButtonWidget(id, x, this.height - 30, text);
73 | }
74 |
75 | @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/option/KeybindsScreen;renderBackground()V", shift = At.Shift.AFTER))
76 | private void onRender(int mouseX, int mouseY, float delta, CallbackInfo ci) {
77 | this.controlsList.render(mouseX, mouseY, delta);
78 | }
79 |
80 | @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/option/KeybindsScreen;method_1943()I"), cancellable = true)
81 | private void onDrawButtons(int mouseX, int mouseY, float delta, CallbackInfo ci) {
82 | doneButton.render(this.minecraft, mouseX, mouseY);
83 | ci.cancel();
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/controls/GameOptionsMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.controls;
17 |
18 | import lombok.Getter;
19 | import lombok.Setter;
20 | import net.minecraft.client.option.GameOptions;
21 | import net.minecraft.client.option.KeyBinding;
22 | import org.spongepowered.asm.mixin.Mixin;
23 | import org.spongepowered.asm.mixin.Shadow;
24 | import org.spongepowered.asm.mixin.Unique;
25 | import org.spongepowered.asm.mixin.injection.At;
26 | import org.spongepowered.asm.mixin.injection.Inject;
27 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28 | import pl.js6pak.mojangfix.client.MojangFixClientMod;
29 | import pl.js6pak.mojangfix.mixinterface.GameSettingsAccessor;
30 |
31 | import java.util.ArrayList;
32 | import java.util.Arrays;
33 |
34 | @Mixin(GameOptions.class)
35 | public class GameOptionsMixin implements GameSettingsAccessor {
36 | @Shadow
37 | public KeyBinding[] allKeys;
38 |
39 | @Unique
40 | @Getter
41 | @Setter
42 | private boolean showDebugInfoGraph;
43 |
44 | @Inject(method = {"()V", "(Lnet/minecraft/client/Minecraft;Ljava/io/File;)V"}, at = @At("RETURN"))
45 | public void onInit(CallbackInfo ci) {
46 | ArrayList newKeys = new ArrayList<>(Arrays.asList(allKeys));
47 | newKeys.add(MojangFixClientMod.COMMAND_KEYBIND);
48 | allKeys = newKeys.toArray(new KeyBinding[0]);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/controls/KeyBindingMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.controls;
17 |
18 | import lombok.Getter;
19 | import net.minecraft.client.option.KeyBinding;
20 | import org.spongepowered.asm.mixin.Mixin;
21 | import org.spongepowered.asm.mixin.Shadow;
22 | import org.spongepowered.asm.mixin.Unique;
23 | import org.spongepowered.asm.mixin.injection.At;
24 | import org.spongepowered.asm.mixin.injection.Inject;
25 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
26 | import pl.js6pak.mojangfix.mixinterface.KeyBindingAccessor;
27 |
28 | @Mixin(KeyBinding.class)
29 | public class KeyBindingMixin implements KeyBindingAccessor {
30 | @Shadow
31 | public int code;
32 |
33 | @Unique
34 | @Getter
35 | private int defaultKeyCode;
36 |
37 | @Inject(method = "", at = @At("RETURN"))
38 | private void onInit(String translationKey, int code, CallbackInfo ci) {
39 | this.defaultKeyCode = this.code;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/inventory/ContainerScreenMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.inventory;
17 |
18 | import net.minecraft.client.gui.screen.Screen;
19 | import net.minecraft.client.gui.screen.container.ContainerScreen;
20 | import net.minecraft.inventory.Container;
21 | import net.minecraft.item.ItemStack;
22 | import net.minecraft.screen.slot.Slot;
23 | import org.lwjgl.input.Keyboard;
24 | import org.lwjgl.input.Mouse;
25 | import org.spongepowered.asm.mixin.Mixin;
26 | import org.spongepowered.asm.mixin.Shadow;
27 | import org.spongepowered.asm.mixin.Unique;
28 | import org.spongepowered.asm.mixin.injection.At;
29 | import org.spongepowered.asm.mixin.injection.Inject;
30 | import org.spongepowered.asm.mixin.injection.Redirect;
31 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
32 |
33 | import java.util.HashSet;
34 | import java.util.Set;
35 |
36 | @Mixin(ContainerScreen.class)
37 | public abstract class ContainerScreenMixin extends Screen {
38 | @Shadow
39 | protected abstract Slot getSlotAt(int x, int y);
40 |
41 | @Shadow
42 | public Container container;
43 |
44 | @Shadow
45 | protected abstract boolean isPointOverSlot(Slot slot, int x, int Y);
46 |
47 | @Unique
48 | private Slot slot;
49 |
50 | @Unique
51 | private final Set hoveredSlots = new HashSet<>();
52 |
53 | @Inject(method = "mouseReleased", at = @At("RETURN"))
54 | private void onMouseReleased(int mouseX, int mouseY, int button, CallbackInfo ci) {
55 | slot = this.getSlotAt(mouseX, mouseY);
56 |
57 | if (slot == null)
58 | return;
59 |
60 | ItemStack cursorStack = minecraft.player.inventory.getCursorStack();
61 | if (button == -1 && Mouse.isButtonDown(1) && cursorStack != null) {
62 | if (!hoveredSlots.contains(slot)) {
63 | if (slot.hasStack() && !slot.getStack().isItemEqual(cursorStack)) {
64 | return;
65 | }
66 |
67 | hoveredSlots.add(slot);
68 | if (hoveredSlots.size() > 1) {
69 | this.minecraft.interactionManager.clickSlot(this.container.syncId, slot.id, 1, false, this.minecraft.player);
70 | }
71 | }
72 | } else {
73 | hoveredSlots.clear();
74 | }
75 | }
76 |
77 | @Unique
78 | private boolean drawingHoveredSlot;
79 |
80 | @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/container/ContainerScreen;isPointOverSlot(Lnet/minecraft/screen/slot/Slot;II)Z"))
81 | private boolean redirectIsPointOverSlot(ContainerScreen guiContainer, Slot slot, int x, int y) {
82 | return (drawingHoveredSlot = hoveredSlots.contains(slot)) || isPointOverSlot(slot, x, y);
83 | }
84 |
85 | @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/container/ContainerScreen;fillGradient(IIIIII)V", ordinal = 0))
86 | private void redirectFillGradient(ContainerScreen instance, int startX, int startY, int endX, int endY, int colorStart, int colorEnd) {
87 | if (colorStart != colorEnd) throw new AssertionError();
88 | int color = drawingHoveredSlot ? 0x20ffffff : colorStart;
89 | this.fillGradient(startX, startY, endX, endY, color, color);
90 | }
91 |
92 | @Inject(method = "keyPressed", at = @At("RETURN"))
93 | private void onKeyPressed(char character, int keyCode, CallbackInfo ci) {
94 | if (this.slot == null)
95 | return;
96 |
97 | if (keyCode == this.minecraft.options.dropKey.code) {
98 | if (this.minecraft.player.inventory.getCursorStack() != null)
99 | return;
100 |
101 | this.minecraft.interactionManager.clickSlot(this.container.syncId, slot.id, 0, false, this.minecraft.player);
102 | this.minecraft.interactionManager.clickSlot(this.container.syncId, -999, Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) ? 0 : 1, false, this.minecraft.player);
103 | this.minecraft.interactionManager.clickSlot(this.container.syncId, slot.id, 0, false, this.minecraft.player);
104 | }
105 |
106 | if (keyCode >= Keyboard.KEY_1 && keyCode <= Keyboard.KEY_9) {
107 | if (this.minecraft.player.inventory.getCursorStack() == null)
108 | this.minecraft.interactionManager.clickSlot(this.container.syncId, slot.id, 0, false, this.minecraft.player);
109 | this.minecraft.interactionManager.clickSlot(this.container.syncId, 35 + keyCode - 1, 0, false, this.minecraft.player);
110 | this.minecraft.interactionManager.clickSlot(this.container.syncId, slot.id, 0, false, this.minecraft.player);
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/inventory/PlayerEntityMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.inventory;
17 |
18 | import net.minecraft.client.Minecraft;
19 | import net.minecraft.client.network.MultiplayerClientPlayerEntity;
20 | import net.minecraft.entity.player.PlayerEntity;
21 | import org.lwjgl.input.Keyboard;
22 | import org.spongepowered.asm.mixin.Mixin;
23 | import org.spongepowered.asm.mixin.injection.At;
24 | import org.spongepowered.asm.mixin.injection.Inject;
25 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
26 | import pl.js6pak.mojangfix.mixin.client.MinecraftAccessor;
27 |
28 | @Mixin({MultiplayerClientPlayerEntity.class, PlayerEntity.class})
29 | public abstract class PlayerEntityMixin {
30 | @Inject(method = "dropSelectedItem", at = @At("HEAD"), cancellable = true)
31 | private void onDropSelectedItem(CallbackInfo ci) {
32 | if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
33 | Minecraft minecraft = MinecraftAccessor.getInstance();
34 | PlayerEntity playerEntity = (PlayerEntity) (Object) this;
35 |
36 | minecraft.interactionManager.clickSlot(0, 36 + playerEntity.inventory.selectedSlot, 0, false, minecraft.player);
37 | minecraft.interactionManager.clickSlot(0, -999, 0, false, minecraft.player);
38 | ci.cancel();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/misc/DeathScreenMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.misc;
17 |
18 | import net.minecraft.client.gui.screen.DeathScreen;
19 | import org.spongepowered.asm.mixin.Mixin;
20 | import org.spongepowered.asm.mixin.injection.Constant;
21 | import org.spongepowered.asm.mixin.injection.ModifyConstant;
22 | import pl.js6pak.mojangfix.util.Formatting;
23 |
24 | @Mixin(DeathScreen.class)
25 | public class DeathScreenMixin {
26 | @ModifyConstant(method = "render", constant = @Constant(stringValue = "Score: &e"))
27 | private String getResourcesUrl(String def) {
28 | return def.replace('&', Formatting.FORMATTING_CODE_PREFIX);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/misc/InGameHudMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.misc;
17 |
18 | import net.minecraft.client.Minecraft;
19 | import net.minecraft.client.gui.DrawableHelper;
20 | import net.minecraft.client.gui.hud.InGameHud;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.Shadow;
23 | import org.spongepowered.asm.mixin.injection.At;
24 | import org.spongepowered.asm.mixin.injection.Inject;
25 | import org.spongepowered.asm.mixin.injection.Slice;
26 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
27 |
28 | @Mixin(InGameHud.class)
29 | public class InGameHudMixin extends DrawableHelper {
30 | @Shadow
31 | private Minecraft minecraft;
32 |
33 | @Inject(
34 | method = "render",
35 | at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glPopMatrix()V", ordinal = 0, remap = false),
36 | slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/client/option/GameOptions;debugHud:Z"))
37 | )
38 | private void onRenderGameOverlay(CallbackInfo ci) {
39 | this.drawStringWithShadow(this.minecraft.textRenderer, "Seed: " + this.minecraft.world.getSeed(), 2, 88 + 8 + 8, 0xe0e0e0);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/misc/MinecraftAppletMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.misc;
17 |
18 | import net.minecraft.client.Minecraft;
19 | import net.minecraft.client.MinecraftApplet;
20 | import org.objectweb.asm.Opcodes;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.injection.At;
23 | import org.spongepowered.asm.mixin.injection.Redirect;
24 |
25 | @Mixin(MinecraftApplet.class)
26 | public class MinecraftAppletMixin {
27 | @Redirect(method = "init", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/client/Minecraft;isApplet:Z"))
28 | private void disableIsApplet(Minecraft minecraft, boolean value) {
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/misc/MinecraftMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.misc;
17 |
18 | import net.minecraft.client.Minecraft;
19 | import net.minecraft.client.gui.screen.ChatScreen;
20 | import net.minecraft.client.gui.screen.Screen;
21 | import net.minecraft.client.option.GameOptions;
22 | import org.lwjgl.LWJGLException;
23 | import org.lwjgl.input.Keyboard;
24 | import org.lwjgl.opengl.Display;
25 | import org.lwjgl.opengl.PixelFormat;
26 | import org.objectweb.asm.Opcodes;
27 | import org.spongepowered.asm.mixin.Mixin;
28 | import org.spongepowered.asm.mixin.Shadow;
29 | import org.spongepowered.asm.mixin.injection.At;
30 | import org.spongepowered.asm.mixin.injection.Inject;
31 | import org.spongepowered.asm.mixin.injection.Redirect;
32 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
33 | import pl.js6pak.mojangfix.client.MojangFixClientMod;
34 | import pl.js6pak.mojangfix.mixinterface.ChatScreenAccessor;
35 | import pl.js6pak.mojangfix.mixinterface.GameSettingsAccessor;
36 |
37 | @Mixin(Minecraft.class)
38 | public abstract class MinecraftMixin {
39 | @Shadow
40 | public GameOptions options;
41 |
42 | @Shadow
43 | public abstract void setScreen(Screen screen);
44 |
45 | @Shadow
46 | public abstract boolean isWorldRemote();
47 |
48 | @Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/option/GameOptions;debugHud:Z", ordinal = 0, shift = At.Shift.BEFORE))
49 | private void onF3(CallbackInfo ci) {
50 | GameSettingsAccessor gameSettings = (GameSettingsAccessor) this.options;
51 | gameSettings.setShowDebugInfoGraph(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL));
52 | }
53 |
54 | @Redirect(method = "run", at = @At(value = "FIELD", target = "Lnet/minecraft/client/option/GameOptions;debugHud:Z", opcode = Opcodes.GETFIELD))
55 | private boolean getShowDebugInfo(GameOptions gameSettings) {
56 | return gameSettings.debugHud && ((GameSettingsAccessor) this.options).isShowDebugInfoGraph();
57 | }
58 |
59 | @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isWorldRemote()Z", ordinal = 0))
60 | private void onKey(CallbackInfo ci) {
61 | if (this.isWorldRemote() && Keyboard.getEventKey() == MojangFixClientMod.COMMAND_KEYBIND.code) {
62 | this.setScreen(((ChatScreenAccessor) new ChatScreen()).setInitialMessage("/"));
63 | }
64 | }
65 |
66 | @Redirect(method = "init", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;create()V", ordinal = 0, remap = false))
67 | private void onDisplayCreate() throws LWJGLException {
68 | PixelFormat pixelformat = new PixelFormat();
69 | pixelformat = pixelformat.withDepthBits(24);
70 | Display.create(pixelformat);
71 | }
72 |
73 | @Inject(method = "startSessionCheck", at = @At("HEAD"), cancellable = true)
74 | private void disableSessionCheck(CallbackInfo ci) {
75 | ci.cancel();
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/misc/ResourceDownloadThreadMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.misc;
17 |
18 | import net.minecraft.client.resource.ResourceDownloadThread;
19 | import org.spongepowered.asm.mixin.Mixin;
20 | import org.spongepowered.asm.mixin.injection.Constant;
21 | import org.spongepowered.asm.mixin.injection.ModifyConstant;
22 | import pl.js6pak.mojangfix.client.skinfix.SkinService;
23 |
24 | @Mixin(ResourceDownloadThread.class)
25 | public class ResourceDownloadThreadMixin {
26 | @ModifyConstant(method = "run", constant = @Constant(stringValue = "http://s3.amazonaws.com/MinecraftResources/"), remap = false)
27 | private String getResourcesUrl(String def) {
28 | return SkinService.RESOURCES_URL;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/misc/ScreenMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.misc;
17 |
18 | import net.minecraft.client.gui.screen.Screen;
19 | import net.minecraft.client.gui.widget.ButtonWidget;
20 | import org.spongepowered.asm.mixin.Mixin;
21 | import org.spongepowered.asm.mixin.injection.At;
22 | import org.spongepowered.asm.mixin.injection.Redirect;
23 | import pl.js6pak.mojangfix.client.gui.CallbackButtonWidget;
24 | import pl.js6pak.mojangfix.mixin.client.ScreenAccessor;
25 |
26 | @Mixin(Screen.class)
27 | public class ScreenMixin {
28 | @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;buttonClicked(Lnet/minecraft/client/gui/widget/ButtonWidget;)V"))
29 | private void onActionPerformed(Screen screen, ButtonWidget button) {
30 | if (button instanceof CallbackButtonWidget) {
31 | CallbackButtonWidget buttonWidget = (CallbackButtonWidget) button;
32 | buttonWidget.onPress();
33 | return;
34 | }
35 | ((ScreenAccessor) screen).callButtonClicked(button);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/misc/TitleScreenMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.misc;
17 |
18 | import net.minecraft.client.gui.screen.Screen;
19 | import net.minecraft.client.gui.screen.TitleScreen;
20 | import org.spongepowered.asm.mixin.Mixin;
21 | import org.spongepowered.asm.mixin.injection.At;
22 | import org.spongepowered.asm.mixin.injection.Inject;
23 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
24 | import pl.js6pak.mojangfix.MojangFixMod;
25 |
26 | @Mixin(TitleScreen.class)
27 | public abstract class TitleScreenMixin extends Screen {
28 | @Inject(method = "render", at = @At("RETURN"))
29 | private void onDrawScreen(CallbackInfo ci) {
30 | this.drawStringWithShadow(this.textRenderer, MojangFixMod.getMetadata().getName() + " " + MojangFixMod.getVersion(), 2, 2 + 10, 0x505050);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/multiplayer/ReturnToMainMenuMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.multiplayer;
17 |
18 | import net.minecraft.client.Minecraft;
19 | import net.minecraft.client.gui.screen.ConnectScreen;
20 | import net.minecraft.client.gui.screen.DisconnectedScreen;
21 | import net.minecraft.client.gui.screen.Screen;
22 | import org.spongepowered.asm.mixin.Mixin;
23 | import org.spongepowered.asm.mixin.injection.At;
24 | import org.spongepowered.asm.mixin.injection.Redirect;
25 | import pl.js6pak.mojangfix.client.gui.multiplayer.MultiplayerScreen;
26 |
27 | @Mixin({DisconnectedScreen.class, ConnectScreen.class})
28 | public class ReturnToMainMenuMixin {
29 | @Redirect(method = "buttonClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screen/Screen;)V"))
30 | private void redirectSetScreen(Minecraft minecraft, Screen screen) {
31 | minecraft.setScreen(new MultiplayerScreen());
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/multiplayer/TitleScreenMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.multiplayer;
17 |
18 | import net.minecraft.client.Minecraft;
19 | import net.minecraft.client.gui.screen.Screen;
20 | import net.minecraft.client.gui.screen.TitleScreen;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.injection.At;
23 | import org.spongepowered.asm.mixin.injection.Redirect;
24 | import pl.js6pak.mojangfix.client.gui.multiplayer.MultiplayerScreen;
25 |
26 | @Mixin(TitleScreen.class)
27 | public class TitleScreenMixin extends Screen {
28 | @Redirect(method = "buttonClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screen/Screen;)V", ordinal = 2))
29 | private void onNewGuiMainMenu(Minecraft minecraft, Screen screen) {
30 | minecraft.setScreen(new MultiplayerScreen(this));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/skin/BipedEntityModelMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.skin;
17 |
18 | import net.minecraft.client.model.ModelPart;
19 | import net.minecraft.client.render.entity.model.BipedEntityModel;
20 | import org.spongepowered.asm.mixin.Mixin;
21 | import org.spongepowered.asm.mixin.injection.At;
22 | import org.spongepowered.asm.mixin.injection.At.Shift;
23 | import org.spongepowered.asm.mixin.injection.Redirect;
24 | import org.spongepowered.asm.mixin.injection.Slice;
25 | import pl.js6pak.mojangfix.mixinterface.ModelPartAccessor;
26 | import pl.js6pak.mojangfix.client.skinfix.PlayerEntityModel;
27 |
28 | @Mixin(BipedEntityModel.class)
29 | public class BipedEntityModelMixin {
30 | @Redirect(
31 | method = "(FF)V",
32 | at = @At(value = "NEW", target = "net/minecraft/client/model/ModelPart"),
33 | slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;ears:Lnet/minecraft/client/model/ModelPart;", shift = Shift.AFTER))
34 | )
35 | private ModelPart onTexturedQuad(int u, int v) {
36 | ModelPart modelPart = new ModelPart(u, v);
37 |
38 | BipedEntityModel self = (BipedEntityModel) (Object) this;
39 | if (self instanceof PlayerEntityModel) {
40 | ((ModelPartAccessor) modelPart).setTextureHeight(64);
41 | }
42 |
43 | return modelPart;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/skin/ClientPlayerEntityMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.skin;
17 |
18 | import net.minecraft.entity.player.ClientPlayerEntity;
19 | import net.minecraft.entity.player.PlayerEntity;
20 | import net.minecraft.world.World;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.injection.At;
23 | import org.spongepowered.asm.mixin.injection.Inject;
24 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
25 | import pl.js6pak.mojangfix.client.skinfix.SkinService;
26 |
27 | @Mixin(ClientPlayerEntity.class)
28 |
29 | public abstract class ClientPlayerEntityMixin extends PlayerEntity {
30 | public ClientPlayerEntityMixin(World arg) {
31 | super(arg);
32 | }
33 |
34 | @Inject(method = "", at = @At("RETURN"))
35 | private void onInit(CallbackInfo ci) {
36 | SkinService.getInstance().init(this);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/skin/EntityRenderDispatcherMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.skin;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 | import net.minecraft.client.render.entity.EntityRenderDispatcher;
20 | import net.minecraft.client.render.entity.EntityRenderer;
21 | import net.minecraft.client.render.entity.PlayerEntityRenderer;
22 | import net.minecraft.entity.Entity;
23 | import net.minecraft.entity.player.PlayerEntity;
24 | import org.spongepowered.asm.mixin.Mixin;
25 | import org.spongepowered.asm.mixin.Shadow;
26 | import org.spongepowered.asm.mixin.Unique;
27 | import org.spongepowered.asm.mixin.injection.At;
28 | import org.spongepowered.asm.mixin.injection.Inject;
29 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
30 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
31 | import pl.js6pak.mojangfix.mixinterface.PlayerEntityAccessor;
32 | import pl.js6pak.mojangfix.mixinterface.PlayerEntityRendererAccessor;
33 |
34 | import java.util.HashMap;
35 | import java.util.Map;
36 |
37 | @Mixin(EntityRenderDispatcher.class)
38 | public class EntityRenderDispatcherMixin {
39 | @Shadow
40 | private Map, EntityRenderer> renderers;
41 |
42 | @Unique
43 | private final Map playerRenderers = new HashMap<>();
44 |
45 | @Inject(method = "", at = @At("RETURN"))
46 | private void onInit(CallbackInfo ci) {
47 | for (GameProfile.TextureModel model : GameProfile.TextureModel.values()) {
48 | PlayerEntityRenderer renderer = new PlayerEntityRenderer();
49 | ((PlayerEntityRendererAccessor) renderer).setThinArms(model == GameProfile.TextureModel.SLIM);
50 | renderer.setDispatcher((EntityRenderDispatcher) (Object) this);
51 | playerRenderers.put(model, renderer);
52 | }
53 |
54 | this.renderers.put(PlayerEntity.class, playerRenderers.get(GameProfile.TextureModel.NORMAL));
55 | }
56 |
57 | @Inject(method = "get(Lnet/minecraft/entity/Entity;)Lnet/minecraft/client/render/entity/EntityRenderer;", at = @At("HEAD"), cancellable = true)
58 | private void onGet(Entity entity, CallbackInfoReturnable cir) {
59 | if (entity instanceof PlayerEntity) {
60 | PlayerEntity player = (PlayerEntity) entity;
61 | GameProfile.TextureModel textureModel = ((PlayerEntityAccessor) player).getTextureModel();
62 | cir.setReturnValue(playerRenderers.get(textureModel));
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/skin/ModelPartMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.skin;
17 |
18 | import lombok.Getter;
19 | import lombok.Setter;
20 | import net.minecraft.client.model.ModelPart;
21 | import net.minecraft.client.model.Quad;
22 | import net.minecraft.client.model.Vertex;
23 | import org.spongepowered.asm.mixin.Mixin;
24 | import org.spongepowered.asm.mixin.Unique;
25 | import org.spongepowered.asm.mixin.injection.At;
26 | import org.spongepowered.asm.mixin.injection.Redirect;
27 | import pl.js6pak.mojangfix.mixinterface.ModelPartAccessor;
28 |
29 | @Mixin(ModelPart.class)
30 | public abstract class ModelPartMixin implements ModelPartAccessor {
31 | @Unique
32 | @Setter
33 | @Getter
34 | private int textureWidth = 64;
35 |
36 | @Unique
37 | @Setter
38 | @Getter
39 | private int textureHeight = 32;
40 |
41 | @Redirect(method = "addCuboid(FFFIIIF)V", at = @At(value = "NEW", target = "([Lnet/minecraft/client/model/Vertex;IIII)Lnet/minecraft/client/model/Quad;"))
42 | private Quad redirectQuad(Vertex[] vertices, int u1, int v1, int u2, int v2) {
43 | Quad quad = new Quad(vertices);
44 |
45 | vertices[0] = vertices[0].remap((float) u2 / textureWidth, (float) v1 / textureHeight);
46 | vertices[1] = vertices[1].remap((float) u1 / textureWidth, (float) v1 / textureHeight);
47 | vertices[2] = vertices[2].remap((float) u1 / textureWidth, (float) v2 / textureHeight);
48 | vertices[3] = vertices[3].remap((float) u2 / textureWidth, (float) v2 / textureHeight);
49 |
50 | return quad;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/skin/OtherPlayerEntityMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.skin;
17 |
18 | import net.minecraft.client.network.OtherPlayerEntity;
19 | import net.minecraft.entity.player.PlayerEntity;
20 | import net.minecraft.world.World;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.injection.At;
23 | import org.spongepowered.asm.mixin.injection.Inject;
24 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
25 | import pl.js6pak.mojangfix.client.skinfix.SkinService;
26 |
27 | @Mixin(OtherPlayerEntity.class)
28 | public abstract class OtherPlayerEntityMixin extends PlayerEntity {
29 | public OtherPlayerEntityMixin(World arg) {
30 | super(arg);
31 | }
32 |
33 | @Inject(method = "", at = @At("RETURN"))
34 | private void onInit(CallbackInfo ci) {
35 | SkinService.getInstance().init(this);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/skin/PlayerEntityMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.skin;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 | import lombok.Getter;
20 | import net.minecraft.entity.LivingEntity;
21 | import net.minecraft.entity.player.PlayerEntity;
22 | import net.minecraft.world.World;
23 | import org.spongepowered.asm.mixin.Mixin;
24 | import org.spongepowered.asm.mixin.Unique;
25 | import org.spongepowered.asm.mixin.injection.*;
26 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
27 | import pl.js6pak.mojangfix.mixinterface.PlayerEntityAccessor;
28 | import pl.js6pak.mojangfix.client.skinfix.SkinService;
29 |
30 | @Mixin(PlayerEntity.class)
31 | public abstract class PlayerEntityMixin extends LivingEntity implements PlayerEntityAccessor {
32 | @Unique
33 | @Getter
34 | private GameProfile.TextureModel textureModel;
35 |
36 | public PlayerEntityMixin(World world) {
37 | super(world);
38 | }
39 |
40 | @Inject(method = "updateCapeUrl", at = @At("HEAD"), cancellable = true)
41 | private void cancelUpdateCapeUrl(CallbackInfo ci) {
42 | ci.cancel();
43 | }
44 |
45 | @Redirect(method = "", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;texture:Ljava/lang/String;"))
46 | private void redirectTexture(PlayerEntity instance, String value) {
47 | this.setTextureModel(GameProfile.TextureModel.NORMAL);
48 | }
49 |
50 | @Unique
51 | public void setTextureModel(GameProfile.TextureModel textureModel) {
52 | this.textureModel = textureModel;
53 | this.texture = textureModel == GameProfile.TextureModel.NORMAL ? SkinService.STEVE_TEXTURE : SkinService.ALEX_TEXTURE;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/skin/PlayerEntityRendererMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022-2024 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.skin;
17 |
18 | import net.minecraft.client.render.entity.LivingEntityRenderer;
19 | import net.minecraft.client.render.entity.PlayerEntityRenderer;
20 | import net.minecraft.client.render.entity.model.BipedEntityModel;
21 | import net.minecraft.client.render.entity.model.EntityModel;
22 | import org.lwjgl.opengl.GL11;
23 | import org.spongepowered.asm.mixin.Mixin;
24 | import org.spongepowered.asm.mixin.Shadow;
25 | import org.spongepowered.asm.mixin.injection.At;
26 | import org.spongepowered.asm.mixin.injection.Inject;
27 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28 | import pl.js6pak.mojangfix.mixinterface.PlayerEntityRendererAccessor;
29 | import pl.js6pak.mojangfix.client.skinfix.PlayerEntityModel;
30 |
31 | @Mixin(PlayerEntityRenderer.class)
32 | public abstract class PlayerEntityRendererMixin extends LivingEntityRenderer implements PlayerEntityRendererAccessor {
33 | @Shadow
34 | private BipedEntityModel bipedModel;
35 |
36 | public PlayerEntityRendererMixin(EntityModel arg, float f) {
37 | super(arg, f);
38 | }
39 |
40 | public void setThinArms(boolean thinArms) {
41 | this.model = this.bipedModel = new PlayerEntityModel(0.0F, thinArms);
42 | }
43 |
44 | @Inject(method = "renderHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/ModelPart;render(F)V"))
45 | private void fixFirstPerson$1(CallbackInfo ci) {
46 | GL11.glDisable(GL11.GL_CULL_FACE);
47 | GL11.glEnable(GL11.GL_BLEND);
48 | GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
49 | }
50 |
51 | @Inject(method = "renderHand", at = @At("RETURN"))
52 | private void fixFirstPerson$2(CallbackInfo ci) {
53 | ((PlayerEntityModel) bipedModel).rightSleeve.render(0.0625F);
54 | GL11.glDisable(GL11.GL_BLEND);
55 | GL11.glEnable(GL11.GL_CULL_FACE);
56 | }
57 |
58 | @Inject(method = "render(Lnet/minecraft/entity/player/PlayerEntity;DDDFF)V",
59 | at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;render(Lnet/minecraft/entity/LivingEntity;DDDFF)V"))
60 | private void fixOuterLayer$1(CallbackInfo ci) {
61 | GL11.glEnable(GL11.GL_BLEND);
62 | GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
63 | }
64 |
65 | @Inject(method = "render(Lnet/minecraft/entity/player/PlayerEntity;DDDFF)V", at = @At("RETURN"))
66 | private void fixOuterLayer$2(CallbackInfo ci) {
67 | GL11.glDisable(GL11.GL_BLEND);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/skin/SkinImageProcessorMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.skin;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 | import lombok.Setter;
20 | import net.minecraft.client.texture.SkinImageProcessor;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.injection.At;
23 | import org.spongepowered.asm.mixin.injection.Constant;
24 | import org.spongepowered.asm.mixin.injection.Inject;
25 | import org.spongepowered.asm.mixin.injection.ModifyConstant;
26 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
27 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
28 | import pl.js6pak.mojangfix.mixinterface.SkinImageProcessorAccessor;
29 |
30 | import java.awt.Color;
31 | import java.awt.Graphics;
32 | import java.awt.Graphics2D;
33 | import java.awt.image.BufferedImage;
34 | import java.awt.image.ColorModel;
35 | import java.awt.image.WritableRaster;
36 |
37 | @Mixin(SkinImageProcessor.class)
38 | public class SkinImageProcessorMixin implements SkinImageProcessorAccessor {
39 | @Setter
40 | private GameProfile.TextureModel textureModel;
41 |
42 | @ModifyConstant(method = "process", constant = @Constant(intValue = 32, ordinal = 0))
43 | private int getImageHeight(int def) {
44 | return 64;
45 | }
46 |
47 | @Inject(method = "process", at = @At(value = "INVOKE", target = "Ljava/awt/Graphics;dispose()V"), locals = LocalCapture.CAPTURE_FAILHARD)
48 | private void onSkinGraphics(BufferedImage bufferedImage, CallbackInfoReturnable cir, BufferedImage parsedImage, Graphics g) {
49 | if (g instanceof Graphics2D) {
50 | Graphics2D graphics = (Graphics2D) g;
51 | if (bufferedImage.getHeight() == 32) {
52 | graphics.drawImage(bufferedImage.getSubimage(0, 16, 16, 16), 16, 48, 16, 16, null);
53 | graphics.drawImage(bufferedImage.getSubimage(40, 16, 16, 16), 32, 48, 16, 16, null);
54 | }
55 |
56 | for (int i = 0; i < 2; ++i) {
57 | this.flipArea(graphics, parsedImage, 16 + i * 32, 0, 8, 8);
58 | }
59 |
60 | boolean isSlim = textureModel == GameProfile.TextureModel.SLIM;
61 |
62 | for (int i = 1; i <= 2; ++i) {
63 | this.flipArea(graphics, parsedImage, 8, i * 16, 4, 4);
64 | this.flipArea(graphics, parsedImage, 28, i * 16, 8, 4);
65 | this.flipArea(graphics, parsedImage, isSlim ? 47 : 48, i * 16, isSlim ? 3 : 4, 4);
66 | }
67 |
68 | for (int i = 0; i < 4; ++i) {
69 | boolean isSlimArm = isSlim && i >= 2;
70 | this.flipArea(graphics, parsedImage, (isSlimArm ? 7 : 8) + i * 16, 48, isSlimArm ? 3 : 4, 4);
71 | }
72 | }
73 |
74 | }
75 |
76 | public BufferedImage deepCopy(BufferedImage image) {
77 | ColorModel colorModel = image.getColorModel();
78 | boolean isAlphaPremultiplied = colorModel.isAlphaPremultiplied();
79 | WritableRaster raster = image.copyData(image.getRaster().createCompatibleWritableRaster());
80 | return new BufferedImage(colorModel, raster, isAlphaPremultiplied, null);
81 | }
82 |
83 | private void flipArea(Graphics2D graphics, BufferedImage bufferedImage, int x, int y, int width, int height) {
84 | BufferedImage image = this.deepCopy(bufferedImage.getSubimage(x, y, width, height));
85 | graphics.setBackground(new Color(0, true));
86 | graphics.clearRect(x, y, width, height);
87 | graphics.drawImage(image, x, y + height, width, -height, null);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/skin/WorldRendererMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.skin;
17 |
18 | import net.minecraft.client.render.WorldRenderer;
19 | import net.minecraft.client.texture.ImageProcessor;
20 | import net.minecraft.entity.Entity;
21 | import net.minecraft.entity.player.ClientPlayerEntity;
22 | import net.minecraft.entity.player.PlayerEntity;
23 | import org.spongepowered.asm.mixin.Mixin;
24 | import org.spongepowered.asm.mixin.Unique;
25 | import org.spongepowered.asm.mixin.injection.At;
26 | import org.spongepowered.asm.mixin.injection.Inject;
27 | import org.spongepowered.asm.mixin.injection.ModifyArg;
28 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29 | import pl.js6pak.mojangfix.client.skinfix.CapeImageProcessor;
30 | import pl.js6pak.mojangfix.mixinterface.PlayerEntityAccessor;
31 | import pl.js6pak.mojangfix.mixinterface.SkinImageProcessorAccessor;
32 |
33 | @Mixin(WorldRenderer.class)
34 | public class WorldRendererMixin {
35 | @Inject(method = "unloadEntitySkin", at = @At("HEAD"), cancellable = true)
36 | private void dontUnloadLocalPlayerSkin(Entity entity, CallbackInfo ci) {
37 | if (entity instanceof ClientPlayerEntity) {
38 | ci.cancel();
39 | }
40 | }
41 |
42 | @Unique
43 | private Entity currentEntity; // I hate this but there is no way to get it from @ModifyArg
44 |
45 | @Inject(method = "loadEntitySkin", at = @At("HEAD"))
46 | private void getEnttity(Entity entity, CallbackInfo ci) {
47 | currentEntity = entity;
48 | }
49 |
50 | @ModifyArg(
51 | method = "loadEntitySkin", index = 1,
52 | at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/TextureManager;downloadImage(Ljava/lang/String;Lnet/minecraft/client/texture/ImageProcessor;)Lnet/minecraft/client/texture/ImageDownload;", ordinal = 0)
53 | )
54 | private ImageProcessor redirectSkinProcessor(ImageProcessor def) {
55 | if (currentEntity instanceof PlayerEntity) {
56 | PlayerEntityAccessor playerEntityAccessor = (PlayerEntityAccessor) currentEntity;
57 | SkinImageProcessorAccessor skinImageProcessorAccessor = (SkinImageProcessorAccessor) def;
58 | skinImageProcessorAccessor.setTextureModel(playerEntityAccessor.getTextureModel());
59 | }
60 | return def;
61 | }
62 |
63 | @ModifyArg(
64 | method = "loadEntitySkin", index = 1,
65 | at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/TextureManager;downloadImage(Ljava/lang/String;Lnet/minecraft/client/texture/ImageProcessor;)Lnet/minecraft/client/texture/ImageDownload;", ordinal = 1)
66 | )
67 | private ImageProcessor redirectCapeProcessor(ImageProcessor def) {
68 | return new CapeImageProcessor();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/text/TextFieldWidgetMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.text;
17 |
18 | import net.minecraft.client.font.TextRenderer;
19 | import net.minecraft.client.gui.widget.TextFieldWidget;
20 | import org.lwjgl.input.Keyboard;
21 | import org.objectweb.asm.Opcodes;
22 | import org.spongepowered.asm.mixin.Mixin;
23 | import org.spongepowered.asm.mixin.Shadow;
24 | import org.spongepowered.asm.mixin.Unique;
25 | import org.spongepowered.asm.mixin.injection.*;
26 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
27 | import pl.js6pak.mojangfix.mixinterface.TextFieldWidgetAccessor;
28 |
29 | @Mixin(TextFieldWidget.class)
30 | public class TextFieldWidgetMixin implements TextFieldWidgetAccessor {
31 | @Shadow
32 | public boolean focused;
33 |
34 | @Shadow
35 | public boolean enabled;
36 |
37 | @Shadow
38 | private String text;
39 |
40 | @Shadow
41 | private int focusedTicks;
42 |
43 | @Shadow
44 | private int maxLength;
45 |
46 | @Unique
47 | private int cursorPosition;
48 |
49 | @Redirect(method = "keyPressed", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;text:Ljava/lang/String;", opcode = Opcodes.PUTFIELD))
50 | private void onClipboardPaste(TextFieldWidget guiTextField, String value) {
51 | this.write(value.substring(this.text.length()));
52 | }
53 |
54 | @ModifyConstant(method = "keyPressed", constant = @Constant(intValue = Keyboard.KEY_BACK))
55 | private int cancelRemoveKey(int def) {
56 | return -1;
57 | }
58 |
59 | @ModifyConstant(method = "keyPressed", constant = @Constant(intValue = 32))
60 | private int getClipboardMaxLength(int def) {
61 | return this.maxLength;
62 | }
63 |
64 | @Inject(method = "keyPressed", at = @At(value = "JUMP", ordinal = 2))
65 | private void onKeyTyped(char character, int keyCode, CallbackInfo ci) {
66 | if (keyCode == Keyboard.KEY_BACK && this.text.length() > 0 && -this.cursorPosition < this.text.length()) {
67 | this.text = (new StringBuilder(this.text)).deleteCharAt(this.text.length() + this.cursorPosition - 1).toString();
68 | }
69 |
70 | if (keyCode == Keyboard.KEY_DELETE && this.text.length() > 0 && this.cursorPosition < 0) {
71 | this.text = (new StringBuilder(this.text)).delete(this.text.length() + this.cursorPosition, this.text.length() + this.cursorPosition + 1).toString();
72 | ++this.cursorPosition;
73 | }
74 |
75 | if (keyCode == Keyboard.KEY_LEFT && -this.cursorPosition < this.text.length()) {
76 | --this.cursorPosition;
77 | }
78 |
79 | if (keyCode == Keyboard.KEY_RIGHT && this.cursorPosition < 0) {
80 | ++this.cursorPosition;
81 | }
82 |
83 | if (keyCode == Keyboard.KEY_HOME) {
84 | this.cursorPosition = -this.text.length();
85 | }
86 |
87 | if (keyCode == Keyboard.KEY_END) {
88 | this.cursorPosition = 0;
89 | }
90 | }
91 |
92 | public void write(String text) {
93 | this.text = (new StringBuilder(this.text)).insert(this.text.length() + this.cursorPosition, text).toString();
94 | }
95 |
96 | @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;drawStringWithShadow(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;III)V"))
97 | private void onDrawTextBox(TextFieldWidget guiTextField, TextRenderer textRenderer, String text, int x, int y, int color) {
98 | guiTextField.drawStringWithShadow(textRenderer, this.getDisplayText(), x, y, color);
99 | }
100 |
101 | public String getDisplayText() {
102 | boolean caretVisible = this.focused && this.focusedTicks / 6 % 2 == 0;
103 | return this.enabled ? (new StringBuilder(this.text)).insert(this.text.length() + this.cursorPosition, caretVisible ? "_" : "").toString() : this.text;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/text/chat/ChatScreenMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022-2023 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.text.chat;
17 |
18 | import net.minecraft.client.font.TextRenderer;
19 | import net.minecraft.client.gui.screen.ChatScreen;
20 | import net.minecraft.client.gui.screen.Screen;
21 | import net.minecraft.client.gui.widget.TextFieldWidget;
22 | import org.lwjgl.input.Keyboard;
23 | import org.objectweb.asm.Opcodes;
24 | import org.spongepowered.asm.mixin.Mixin;
25 | import org.spongepowered.asm.mixin.Unique;
26 | import org.spongepowered.asm.mixin.injection.At;
27 | import org.spongepowered.asm.mixin.injection.Inject;
28 | import org.spongepowered.asm.mixin.injection.Redirect;
29 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
30 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
31 | import pl.js6pak.mojangfix.mixinterface.ChatScreenAccessor;
32 | import pl.js6pak.mojangfix.mixinterface.TextFieldWidgetAccessor;
33 |
34 | import java.util.ArrayList;
35 | import java.util.List;
36 |
37 | @Mixin(ChatScreen.class)
38 | public class ChatScreenMixin extends Screen implements ChatScreenAccessor {
39 | @Unique
40 | private String initialMessage = "";
41 |
42 | public ChatScreen setInitialMessage(String initialMessage) {
43 | this.initialMessage = initialMessage;
44 | return (ChatScreen) (Object) this;
45 | }
46 |
47 | @Unique
48 | private TextFieldWidget textField;
49 |
50 | @Unique
51 | private int chatHistoryPosition;
52 |
53 | @Unique
54 | private static final List CHAT_HISTORY = new ArrayList<>();
55 |
56 | @Inject(method = "init", at = @At("RETURN"))
57 | private void onInit(CallbackInfo ci) {
58 | this.textField = new TextFieldWidget(this, this.textRenderer, 2, this.height - 14, this.width - 2, this.height - 2, this.initialMessage);
59 | this.textField.setFocused(true);
60 | this.textField.setMaxLength(100);
61 | }
62 |
63 | @Inject(method = "tick", at = @At("HEAD"), cancellable = true)
64 | private void onTick(CallbackInfo ci) {
65 | this.textField.tick();
66 | ci.cancel();
67 | }
68 |
69 | @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ChatScreen;drawStringWithShadow(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;III)V"))
70 | private void redirectDrawString(ChatScreen chatScreen, TextRenderer textRenderer, String text, int x, int y, int color) {
71 | this.drawStringWithShadow(textRenderer, "> " + ((TextFieldWidgetAccessor) this.textField).getDisplayText(), x, y, color);
72 | }
73 |
74 | @Redirect(method = "*", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/ChatScreen;text:Ljava/lang/String;", opcode = Opcodes.GETFIELD))
75 | private String getMessage(ChatScreen chatScreen) {
76 | return this.textField.getText();
77 | }
78 |
79 | @Inject(method = "keyPressed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ClientPlayerEntity;sendChatMessage(Ljava/lang/String;)V"), locals = LocalCapture.CAPTURE_FAILHARD)
80 | private void onSendChatMessage(char character, int keyCode, CallbackInfo ci, String var3, String message) {
81 | int size = CHAT_HISTORY.size();
82 | if (size > 0 && CHAT_HISTORY.get(size - 1).equals(message)) {
83 | return;
84 | }
85 |
86 | CHAT_HISTORY.add(message);
87 | }
88 |
89 | private void setTextFromHistory() {
90 | this.textField.setText(CHAT_HISTORY.get(CHAT_HISTORY.size() + this.chatHistoryPosition));
91 | }
92 |
93 | @Inject(method = "keyPressed", at = @At(value = "JUMP", opcode = Opcodes.IF_ICMPNE, ordinal = 2), cancellable = true)
94 | private void onKeyPressed(char character, int keyCode, CallbackInfo ci) {
95 | if (keyCode == Keyboard.KEY_UP && this.chatHistoryPosition > -CHAT_HISTORY.size()) {
96 | --this.chatHistoryPosition;
97 | this.setTextFromHistory();
98 | } else if (keyCode == Keyboard.KEY_DOWN && this.chatHistoryPosition < -1) {
99 | ++this.chatHistoryPosition;
100 | this.setTextFromHistory();
101 | } else {
102 | this.textField.keyPressed(character, keyCode);
103 | }
104 |
105 | ci.cancel();
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/text/chat/SleepingChatScreenMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.text.chat;
17 |
18 | import net.minecraft.client.gui.screen.ChatScreen;
19 | import net.minecraft.client.gui.screen.SleepingChatScreen;
20 | import org.lwjgl.input.Keyboard;
21 | import org.spongepowered.asm.mixin.Mixin;
22 | import org.spongepowered.asm.mixin.injection.At;
23 | import org.spongepowered.asm.mixin.injection.Constant;
24 | import org.spongepowered.asm.mixin.injection.ModifyConstant;
25 | import org.spongepowered.asm.mixin.injection.Redirect;
26 |
27 | @Mixin(SleepingChatScreen.class)
28 | public class SleepingChatScreenMixin extends ChatScreen {
29 | @Redirect(method = "init", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;enableRepeatEvents(Z)V", remap = false))
30 | private void redirectEnableInput(boolean enable) {
31 | super.init();
32 | }
33 |
34 | @Redirect(method = "removed", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;enableRepeatEvents(Z)V", remap = false))
35 | private void redirectDisableInput(boolean enable) {
36 | super.removed();
37 | }
38 |
39 | @ModifyConstant(method = "keyPressed", constant = @Constant(intValue = Keyboard.KEY_RETURN))
40 | private int ignoreEnter(int def) {
41 | return -1;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/text/sign/ClientNetworkHandlerMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.text.sign;
17 |
18 | import net.minecraft.block.entity.BlockEntity;
19 | import net.minecraft.block.entity.SignBlockEntity;
20 | import net.minecraft.client.gui.widget.TextFieldWidget;
21 | import net.minecraft.client.network.ClientNetworkHandler;
22 | import net.minecraft.network.packet.play.UpdateSignPacket;
23 | import org.spongepowered.asm.mixin.Mixin;
24 | import org.spongepowered.asm.mixin.injection.At;
25 | import org.spongepowered.asm.mixin.injection.Inject;
26 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
27 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
28 | import pl.js6pak.mojangfix.mixinterface.SignBlockEntityAccessor;
29 |
30 | @Mixin(ClientNetworkHandler.class)
31 | public class ClientNetworkHandlerMixin {
32 | @Inject(method = "handleUpdateSign", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/SignBlockEntity;markDirty()V"), locals = LocalCapture.CAPTURE_FAILHARD)
33 | private void onHandleSignUpdate(UpdateSignPacket packet, CallbackInfo ci, BlockEntity blockEntity, SignBlockEntity sign, int var4) {
34 | TextFieldWidget[] textFields = ((SignBlockEntityAccessor) sign).getTextFields();
35 | for (int i = 0; i < packet.text.length; i++) {
36 | textFields[i].setText(packet.text[i]);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/text/sign/SignBlockEntityMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.text.sign;
17 |
18 | import lombok.Getter;
19 | import net.minecraft.block.entity.BlockEntity;
20 | import net.minecraft.block.entity.SignBlockEntity;
21 | import net.minecraft.client.gui.widget.TextFieldWidget;
22 | import org.spongepowered.asm.mixin.Mixin;
23 | import org.spongepowered.asm.mixin.Shadow;
24 | import org.spongepowered.asm.mixin.Unique;
25 | import org.spongepowered.asm.mixin.injection.At;
26 | import org.spongepowered.asm.mixin.injection.Inject;
27 | import org.spongepowered.asm.mixin.injection.Redirect;
28 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29 | import pl.js6pak.mojangfix.mixin.client.MinecraftAccessor;
30 | import pl.js6pak.mojangfix.mixinterface.SignBlockEntityAccessor;
31 |
32 | @Mixin(SignBlockEntity.class)
33 | public class SignBlockEntityMixin extends BlockEntity implements SignBlockEntityAccessor {
34 | @Shadow
35 | public String[] texts;
36 |
37 | @Unique
38 | @Getter
39 | private final TextFieldWidget[] textFields = new TextFieldWidget[4];
40 |
41 | @Inject(method = "", at = @At("RETURN"))
42 | private void onInit(CallbackInfo ci) {
43 | for (int i = 0; i < texts.length; i++) {
44 | TextFieldWidget textField = textFields[i] = new TextFieldWidget(null, MinecraftAccessor.getInstance().textRenderer, -1, -1, -1, -1, texts[i]);
45 | textField.setMaxLength(15);
46 | }
47 | }
48 |
49 | @Inject(method = "readNbt", at = @At("RETURN"))
50 | private void onReadNbt(CallbackInfo ci) {
51 | for (int i = 0; i < texts.length; i++) {
52 | textFields[i].setText(texts[i]);
53 | }
54 | }
55 |
56 | @Redirect(method = "writeNbt", at = @At(value = "FIELD", target = "Lnet/minecraft/block/entity/SignBlockEntity;texts:[Ljava/lang/String;", args = "array=get"))
57 | private String getSignText(String[] signText, int i) {
58 | return textFields[i].getText();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/text/sign/SignBlockEntityRendererMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.text.sign;
17 |
18 | import net.minecraft.block.entity.SignBlockEntity;
19 | import net.minecraft.client.render.block.entity.SignBlockEntityRenderer;
20 | import org.spongepowered.asm.mixin.Mixin;
21 | import org.spongepowered.asm.mixin.Unique;
22 | import org.spongepowered.asm.mixin.injection.At;
23 | import org.spongepowered.asm.mixin.injection.Inject;
24 | import org.spongepowered.asm.mixin.injection.Redirect;
25 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
26 | import pl.js6pak.mojangfix.mixinterface.TextFieldWidgetAccessor;
27 | import pl.js6pak.mojangfix.mixinterface.SignBlockEntityAccessor;
28 |
29 | @Mixin(SignBlockEntityRenderer.class)
30 | public class SignBlockEntityRendererMixin {
31 | @Unique
32 | private SignBlockEntity sign;
33 |
34 | @Inject(method = "render(Lnet/minecraft/block/entity/SignBlockEntity;DDDF)V", at = @At("HEAD"))
35 | private void onRender(SignBlockEntity sign, double x, double y, double z, float var8, CallbackInfo ci) {
36 | this.sign = sign;
37 | }
38 |
39 | @Redirect(method = "render(Lnet/minecraft/block/entity/SignBlockEntity;DDDF)V", at = @At(value = "FIELD", target = "Lnet/minecraft/block/entity/SignBlockEntity;texts:[Ljava/lang/String;", args = "array=get"))
40 | private String getSignText(String[] signText, int i) {
41 | return ((TextFieldWidgetAccessor) ((SignBlockEntityAccessor) sign).getTextFields()[i]).getDisplayText();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/client/text/sign/SignEditScreenMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022-2023 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.client.text.sign;
17 |
18 | import net.minecraft.block.entity.SignBlockEntity;
19 | import net.minecraft.client.gui.screen.ingame.SignEditScreen;
20 | import net.minecraft.client.gui.widget.TextFieldWidget;
21 | import org.objectweb.asm.Opcodes;
22 | import org.spongepowered.asm.mixin.Mixin;
23 | import org.spongepowered.asm.mixin.Shadow;
24 | import org.spongepowered.asm.mixin.injection.At;
25 | import org.spongepowered.asm.mixin.injection.Inject;
26 | import org.spongepowered.asm.mixin.injection.Redirect;
27 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28 | import pl.js6pak.mojangfix.mixinterface.SignBlockEntityAccessor;
29 |
30 | import java.util.Arrays;
31 |
32 | @Mixin(SignEditScreen.class)
33 | public class SignEditScreenMixin {
34 | @Shadow
35 | private SignBlockEntity sign;
36 |
37 | @Shadow
38 | private int currentRow;
39 |
40 | @Shadow
41 | private int ticksSinceOpened;
42 |
43 | @Inject(method = "init", at = @At("RETURN"))
44 | private void onInit(CallbackInfo ci) {
45 | TextFieldWidget[] textFields = ((SignBlockEntityAccessor) this.sign).getTextFields();
46 | textFields[0].setFocused(true);
47 | }
48 |
49 | @Inject(method = "keyPressed", at = @At(value = "JUMP", opcode = Opcodes.IF_ICMPNE, ordinal = 2), cancellable = true)
50 | private void onKeyPressed(char character, int keyCode, CallbackInfo ci) {
51 | TextFieldWidget[] textFields = ((SignBlockEntityAccessor) this.sign).getTextFields();
52 | for (TextFieldWidget textField : textFields) {
53 | textField.setFocused(false);
54 | }
55 | textFields[this.currentRow].setFocused(true);
56 | textFields[this.currentRow].keyPressed(character, keyCode);
57 | this.sign.texts[this.currentRow] = textFields[this.currentRow].getText();
58 | ci.cancel();
59 | }
60 |
61 | @Inject(method = "removed", at = @At("RETURN"))
62 | private void onRemoved(CallbackInfo ci) {
63 | TextFieldWidget[] textFields = ((SignBlockEntityAccessor) this.sign).getTextFields();
64 | for (TextFieldWidget textField : textFields) {
65 | textField.setFocused(false);
66 | }
67 | }
68 |
69 | @Redirect(method = "removed", at = @At(value = "FIELD", target = "Lnet/minecraft/block/entity/SignBlockEntity;texts:[Ljava/lang/String;"))
70 | private String[] getSignText(SignBlockEntity sign) {
71 | return Arrays.stream(((SignBlockEntityAccessor) sign).getTextFields()).map(TextFieldWidget::getText).toArray(String[]::new);
72 | }
73 |
74 | @Inject(method = "tick", at = @At("HEAD"), cancellable = true)
75 | private void onTick(CallbackInfo ci) {
76 | ((SignBlockEntityAccessor) this.sign).getTextFields()[this.currentRow].tick();
77 | ticksSinceOpened = 6;
78 | ci.cancel();
79 | }
80 | }
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/server/auth/ServerNetworkHandlerAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.server.auth;
17 |
18 | import net.minecraft.network.packet.login.LoginHelloPacket;
19 | import net.minecraft.server.network.ServerLoginNetworkHandler;
20 | import org.spongepowered.asm.mixin.Mixin;
21 | import org.spongepowered.asm.mixin.gen.Accessor;
22 |
23 | @Mixin(ServerLoginNetworkHandler.class)
24 | public interface ServerNetworkHandlerAccessor {
25 | @Accessor
26 | String getServerId();
27 |
28 | @Accessor
29 | void setLoginPacket(LoginHelloPacket loginPacket);
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixin/server/auth/ServerNetworkHandlerMixin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixin.server.auth;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 | import com.github.steveice10.mc.auth.exception.request.RequestException;
20 | import com.github.steveice10.mc.auth.service.SessionService;
21 | import net.minecraft.network.packet.login.LoginHelloPacket;
22 | import net.minecraft.server.network.ServerLoginNetworkHandler;
23 | import org.spongepowered.asm.mixin.*;
24 | import pl.js6pak.mojangfix.MojangFixMod;
25 |
26 | @Mixin(targets = "net.minecraft.server.network.ServerLoginNetworkHandler$AuthThread")
27 | public class ServerNetworkHandlerMixin {
28 | @Shadow
29 | @Final
30 | ServerLoginNetworkHandler networkHandler;
31 |
32 | @Shadow
33 | @Final
34 | LoginHelloPacket loginPacket;
35 |
36 | @Unique
37 | private static final SessionService SESSION_SERVICE = new SessionService();
38 |
39 | /**
40 | * @reason Swap auth logic completely
41 | * @author js6pak
42 | */
43 | @Overwrite(remap = false)
44 | public void run() {
45 | try {
46 | ServerNetworkHandlerAccessor accessor = (ServerNetworkHandlerAccessor) networkHandler;
47 |
48 | try {
49 | GameProfile gameProfile = SESSION_SERVICE.getProfileByServer(loginPacket.username, accessor.getServerId());
50 |
51 | if (gameProfile != null) {
52 | MojangFixMod.getLogger().info("Authenticated " + gameProfile.getName() + " as " + gameProfile.getId());
53 | accessor.setLoginPacket(loginPacket);
54 | return;
55 | }
56 | } catch (RequestException ignored) {
57 | }
58 |
59 | networkHandler.disconnect("Failed to verify username!");
60 | } catch (Exception e) {
61 | networkHandler.disconnect("Failed to verify username! [internal error " + e + "]");
62 | e.printStackTrace();
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixinterface/ChatScreenAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixinterface;
17 |
18 | import net.minecraft.client.gui.screen.ChatScreen;
19 |
20 | public interface ChatScreenAccessor {
21 | ChatScreen setInitialMessage(String initialMessage);
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixinterface/GameSettingsAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixinterface;
17 |
18 | public interface GameSettingsAccessor {
19 | boolean isShowDebugInfoGraph();
20 |
21 | void setShowDebugInfoGraph(boolean showDebugInfoGraph);
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixinterface/KeyBindingAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixinterface;
17 |
18 | public interface KeyBindingAccessor {
19 | int getDefaultKeyCode();
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixinterface/ModelPartAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixinterface;
17 |
18 | public interface ModelPartAccessor {
19 | int getTextureWidth();
20 |
21 | void setTextureWidth(int textureWidth);
22 |
23 | int getTextureHeight();
24 |
25 | void setTextureHeight(int textureHeight);
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixinterface/PlayerEntityAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixinterface;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 |
20 | public interface PlayerEntityAccessor {
21 | GameProfile.TextureModel getTextureModel();
22 |
23 | void setTextureModel(GameProfile.TextureModel textureModel);
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixinterface/PlayerEntityRendererAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixinterface;
17 |
18 | public interface PlayerEntityRendererAccessor {
19 | void setThinArms(boolean thinArms);
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixinterface/SessionAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixinterface;
17 |
18 | import com.github.steveice10.mc.auth.data.GameProfile;
19 | import com.github.steveice10.mc.auth.service.SessionService;
20 |
21 | public interface SessionAccessor {
22 | GameProfile getGameProfile();
23 |
24 | String getAccessToken();
25 |
26 | SessionService SESSION_SERVICE = new SessionService();
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixinterface/SignBlockEntityAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixinterface;
17 |
18 | import net.minecraft.client.gui.widget.TextFieldWidget;
19 |
20 | public interface SignBlockEntityAccessor {
21 | TextFieldWidget[] getTextFields();
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixinterface/SkinImageProcessorAccessor.java:
--------------------------------------------------------------------------------
1 | package pl.js6pak.mojangfix.mixinterface;
2 |
3 | import com.github.steveice10.mc.auth.data.GameProfile;
4 |
5 | public interface SkinImageProcessorAccessor {
6 | void setTextureModel(GameProfile.TextureModel textureModel);
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/mixinterface/TextFieldWidgetAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.mixinterface;
17 |
18 | public interface TextFieldWidgetAccessor {
19 | String getDisplayText();
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/pl/js6pak/mojangfix/util/Formatting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 js6pak
3 | *
4 | * This file is part of MojangFix.
5 | *
6 | * MojangFix is free software: you can redistribute it and/or modify it under the terms of the
7 | * GNU Lesser General Public License as published by the Free Software Foundation, version 3.
8 | *
9 | * MojangFix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU Lesser General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License along with MojangFix. If not, see .
14 | */
15 |
16 | package pl.js6pak.mojangfix.util;
17 |
18 | import java.util.Locale;
19 | import java.util.regex.Pattern;
20 |
21 | public enum Formatting {
22 | BLACK("BLACK", '0', 0, 0x0),
23 | DARK_BLUE("DARK_BLUE", '1', 1, 0xaa),
24 | DARK_GREEN("DARK_GREEN", '2', 2, 0xaa00),
25 | DARK_AQUA("DARK_AQUA", '3', 3, 0xaaaa),
26 | DARK_RED("DARK_RED", '4', 4, 0xaa0000),
27 | DARK_PURPLE("DARK_PURPLE", '5', 5, 0xaa00aa),
28 | GOLD("GOLD", '6', 6, 0xffaa00),
29 | GRAY("GRAY", '7', 7, 0xaaaaaa),
30 | DARK_GRAY("DARK_GRAY", '8', 8, 0x555555),
31 | BLUE("BLUE", '9', 9, 0x5555ff),
32 | GREEN("GREEN", 'a', 10, 0x55ff55),
33 | AQUA("AQUA", 'b', 11, 0x55ffff),
34 | RED("RED", 'c', 12, 0xff5555),
35 | LIGHT_PURPLE("LIGHT_PURPLE", 'd', 13, 0xff55ff),
36 | YELLOW("YELLOW", 'e', 14, 0xffff55),
37 | WHITE("WHITE", 'f', 15, 0xffffff),
38 |
39 | OBFUSCATED("OBFUSCATED", 'k', true),
40 | RESET("RESET", 'r', -1, null);
41 |
42 | public static final char FORMATTING_CODE_PREFIX = '\u00a7';
43 | private static final Pattern FORMATTING_CODE_PATTERN = Pattern.compile("(?i)" + FORMATTING_CODE_PREFIX + "[0-9A-FKR]");
44 |
45 | private final String name;
46 | private final char code;
47 | private final boolean modifier;
48 | private final String stringValue;
49 | private final int colorIndex;
50 | private final Integer colorValue;
51 |
52 | Formatting(String name, char code, int colorIndex, Integer colorValue) {
53 | this(name, code, false, colorIndex, colorValue);
54 | }
55 |
56 | Formatting(String name, char code, boolean modifier) {
57 | this(name, code, modifier, -1, null);
58 | }
59 |
60 | Formatting(String name, char code, boolean modifier, int colorIndex, Integer colorValue) {
61 | this.name = name;
62 | this.code = code;
63 | this.modifier = modifier;
64 | this.colorIndex = colorIndex;
65 | this.colorValue = colorValue;
66 | this.stringValue = FORMATTING_CODE_PREFIX + Character.toString(code);
67 | }
68 |
69 | public int getColorIndex() {
70 | return this.colorIndex;
71 | }
72 |
73 | public boolean isModifier() {
74 | return this.modifier;
75 | }
76 |
77 | public boolean isColor() {
78 | return !this.modifier && this != RESET;
79 | }
80 |
81 | public Integer getColorValue() {
82 | return this.colorValue;
83 | }
84 |
85 | public boolean affectsGlyphWidth() {
86 | return !this.modifier;
87 | }
88 |
89 | public String getName() {
90 | return this.name().toLowerCase(Locale.ROOT);
91 | }
92 |
93 | public String toString() {
94 | return this.stringValue;
95 | }
96 |
97 | public static String strip(String string) {
98 | return string == null ? null : FORMATTING_CODE_PATTERN.matcher(string).replaceAll("");
99 | }
100 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/mojangfix/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/js6pak/mojangfix/8713bd5aa18bd1640347ddfe327961f99c5efb46/src/main/resources/assets/mojangfix/icon.png
--------------------------------------------------------------------------------
/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "mojangfix",
4 | "version": "${version}",
5 | "name": "MojangFix",
6 | "description": "Fixes skins, authentication and more",
7 | "authors": [
8 | "js6pak"
9 | ],
10 | "contact": {
11 | "sources": "https://github.com/js6pak/mojangfix"
12 | },
13 | "license": "LGPL-3.0-only",
14 | "icon": "assets/mojangfix/icon.png",
15 | "environment": "*",
16 | "entrypoints": {
17 | "main": [
18 | "pl.js6pak.mojangfix.MojangFixMod"
19 | ],
20 | "client": [
21 | "pl.js6pak.mojangfix.client.MojangFixClientMod"
22 | ]
23 | },
24 | "mixins": [
25 | "mojangfix.mixins.json"
26 | ],
27 | "depends": {
28 | "fabricloader": "*",
29 | "minecraft": "1.0.0-beta.7.3"
30 | }
31 | }
--------------------------------------------------------------------------------
/src/main/resources/mob/alex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/js6pak/mojangfix/8713bd5aa18bd1640347ddfe327961f99c5efb46/src/main/resources/mob/alex.png
--------------------------------------------------------------------------------
/src/main/resources/mob/steve.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/js6pak/mojangfix/8713bd5aa18bd1640347ddfe327961f99c5efb46/src/main/resources/mob/steve.png
--------------------------------------------------------------------------------
/src/main/resources/mojangfix.mixins.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": true,
3 | "minVersion": "0.8",
4 | "package": "pl.js6pak.mojangfix.mixin",
5 | "compatibilityLevel": "JAVA_8",
6 | "injectors": {
7 | "defaultRequire": 1
8 | },
9 | "client": [
10 | "client.MinecraftAccessor",
11 | "client.ScreenAccessor",
12 | "client.auth.ClientNetworkHandlerMixin",
13 | "client.auth.SessionMixin",
14 | "client.controls.ControlsOptionsScreenMixin",
15 | "client.controls.GameOptionsMixin",
16 | "client.controls.KeyBindingMixin",
17 | "client.inventory.ContainerScreenMixin",
18 | "client.inventory.PlayerEntityMixin",
19 | "client.misc.DeathScreenMixin",
20 | "client.misc.InGameHudMixin",
21 | "client.misc.MinecraftAppletMixin",
22 | "client.misc.MinecraftMixin",
23 | "client.misc.ResourceDownloadThreadMixin",
24 | "client.misc.ScreenMixin",
25 | "client.misc.TitleScreenMixin",
26 | "client.multiplayer.ReturnToMainMenuMixin",
27 | "client.multiplayer.TitleScreenMixin",
28 | "client.skin.BipedEntityModelMixin",
29 | "client.skin.ClientPlayerEntityMixin",
30 | "client.skin.EntityRenderDispatcherMixin",
31 | "client.skin.ModelPartMixin",
32 | "client.skin.OtherPlayerEntityMixin",
33 | "client.skin.PlayerEntityMixin",
34 | "client.skin.PlayerEntityRendererMixin",
35 | "client.skin.SkinImageProcessorMixin",
36 | "client.skin.WorldRendererMixin",
37 | "client.text.TextFieldWidgetMixin",
38 | "client.text.chat.ChatScreenMixin",
39 | "client.text.chat.SleepingChatScreenMixin",
40 | "client.text.sign.ClientNetworkHandlerMixin",
41 | "client.text.sign.SignBlockEntityMixin",
42 | "client.text.sign.SignBlockEntityRendererMixin",
43 | "client.text.sign.SignEditScreenMixin"
44 | ],
45 | "server": [
46 | "server.auth.ServerNetworkHandlerAccessor",
47 | "server.auth.ServerNetworkHandlerMixin"
48 | ]
49 | }
--------------------------------------------------------------------------------