├── .github
└── workflows
│ ├── build.yml
│ └── release.yml
├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
├── main
├── java
│ └── eu
│ │ └── pb4
│ │ └── sgui
│ │ ├── api
│ │ ├── ClickType.java
│ │ ├── GuiHelpers.java
│ │ ├── ScreenProperty.java
│ │ ├── SlotHolder.java
│ │ ├── elements
│ │ │ ├── AnimatedGuiElement.java
│ │ │ ├── AnimatedGuiElementBuilder.java
│ │ │ ├── BookElementBuilder.java
│ │ │ ├── GuiElement.java
│ │ │ ├── GuiElementBuilder.java
│ │ │ ├── GuiElementBuilderInterface.java
│ │ │ └── GuiElementInterface.java
│ │ └── gui
│ │ │ ├── AnvilInputGui.java
│ │ │ ├── BaseSlotGui.java
│ │ │ ├── BookGui.java
│ │ │ ├── GuiInterface.java
│ │ │ ├── HotbarGui.java
│ │ │ ├── MerchantGui.java
│ │ │ ├── SignGui.java
│ │ │ ├── SimpleGui.java
│ │ │ ├── SimpleGuiBuilder.java
│ │ │ ├── SlotGuiInterface.java
│ │ │ └── layered
│ │ │ ├── BackendSimpleGui.java
│ │ │ ├── Layer.java
│ │ │ ├── LayerView.java
│ │ │ └── LayeredGui.java
│ │ ├── impl
│ │ └── PlayerExtensions.java
│ │ ├── mixin
│ │ ├── PlayerInteractEntityC2SPacketAccessor.java
│ │ ├── ScreenHandlerAccessor.java
│ │ ├── ScreenHandlerMixin.java
│ │ ├── ServerPlayNetworkHandlerMixin.java
│ │ ├── ServerPlayerEntityAccessor.java
│ │ ├── ServerPlayerEntityMixin.java
│ │ └── SignBlockEntityAccessor.java
│ │ └── virtual
│ │ ├── FakeScreenHandler.java
│ │ ├── SguiScreenHandlerFactory.java
│ │ ├── VirtualScreenHandlerInterface.java
│ │ ├── book
│ │ ├── BookInventory.java
│ │ ├── BookScreenHandler.java
│ │ └── BookSlot.java
│ │ ├── hotbar
│ │ └── HotbarScreenHandler.java
│ │ ├── inventory
│ │ ├── VirtualInventory.java
│ │ ├── VirtualScreenHandler.java
│ │ └── VirtualSlot.java
│ │ ├── merchant
│ │ ├── VirtualMerchant.java
│ │ ├── VirtualMerchantScreenHandler.java
│ │ └── VirtualTradeOutputSlot.java
│ │ └── sign
│ │ └── VirtualSignBlockEntity.java
└── resources
│ ├── assets
│ └── icon.png
│ ├── fabric.mod.json
│ └── sgui.mixins.json
└── testmod
├── java
└── eu
│ └── pb4
│ └── sgui
│ └── testmod
│ ├── BookInputGui.java
│ ├── SGuiTest.java
│ ├── SnakeGui.java
│ └── TypewriterGui.java
└── resources
└── fabric.mod.json
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | # Automatically build the project and run any configured tests for every push
2 | # and submitted pull request. This can help catch issues that only occur on
3 | # certain platforms or Java versions, and provides a first line of defence
4 | # against bad commits.
5 |
6 | name: build
7 | on: [pull_request, push]
8 |
9 | jobs:
10 | build:
11 | strategy:
12 | matrix:
13 | # Use these Java versions
14 | java: [
15 | 21 # Latest version
16 | ]
17 | # and run on both Linux and Windows
18 | os: [ubuntu-latest]
19 | runs-on: ${{ matrix.os }}
20 | steps:
21 | - name: checkout repository
22 | uses: actions/checkout@v4
23 | - name: validate gradle wrapper
24 | uses: gradle/wrapper-validation-action@v3
25 | - name: setup jdk ${{ matrix.java }}
26 | uses: actions/setup-java@v4
27 | with:
28 | distribution: temurin
29 | java-version: ${{ matrix.java }}
30 | - name: make gradle wrapper executable
31 | if: ${{ runner.os != 'Windows' }}
32 | run: chmod +x ./gradlew
33 | - name: build
34 | run: ./gradlew build
35 | - name: capture build artifacts
36 | if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from LTS java on one OS
37 | uses: actions/upload-artifact@v4
38 | with:
39 | name: Artifacts
40 | path: build/libs/
41 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | release:
5 | types:
6 | - published
7 | workflow_dispatch:
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 |
13 | steps:
14 | - uses: actions/cache@v4
15 | with:
16 | path: |
17 | ~/.gradle/loom-cache
18 | ~/.gradle/caches
19 | ~/.gradle/wrapper
20 | key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
21 | restore-keys: |
22 | gradle-
23 | - uses: actions/checkout@v4
24 | - name: Set up JDK
25 | uses: actions/setup-java@v4
26 | with:
27 | distribution: temurin
28 | java-version: 21
29 |
30 | - name: Grant execute permission for gradlew
31 | run: chmod +x gradlew
32 |
33 | - name: Build and publish with Gradle
34 | run: ./gradlew build publish
35 | env:
36 | MAVEN_URL: ${{ secrets.MAVEN_URL }}
37 | MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
38 | MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
39 |
40 | - name: Upload GitHub release
41 | uses: AButler/upload-release-assets@v3.0
42 | with:
43 | files: 'build/libs/*.jar;!build/libs/*-sources.jar;!build/libs/*-dev.jar'
44 | repo-token: ${{ secrets.GITHUB_TOKEN }}
45 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SGui (Server Gui)
2 | It's a small, jij-able library that allows creation of server side guis.
3 |
4 | ## Usage:
5 | Add it to your dependencies like this:
6 |
7 | ```
8 | repositories {
9 | maven { url 'https://maven.nucleoid.xyz' }
10 | }
11 |
12 | dependencies {
13 | modImplementation include("eu.pb4:sgui:[TAG]")
14 | }
15 | ```
16 |
17 | After that you are ready to go! You can use SimpleGUI and other classes directly for simple ones or extend
18 | them for more complex guis.
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'fabric-loom' version '1.10.+'
3 | id 'maven-publish'
4 | }
5 |
6 | sourceCompatibility = JavaVersion.VERSION_21
7 | targetCompatibility = JavaVersion.VERSION_21
8 |
9 | archivesBaseName = project.archives_base_name
10 | version = project.mod_version
11 | group = project.maven_group
12 |
13 | repositories {
14 | // Add repositories to retrieve artifacts from in here.
15 | // You should only use this when depending on other mods because
16 | // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
17 | // See https://docs.gradle.org/current/userguide/declaring_repositories.html
18 | // for more information about repositories.
19 |
20 | maven { url "https://jitpack.io" }
21 | }
22 |
23 | sourceSets {
24 | testmod {
25 | runtimeClasspath += main.runtimeClasspath
26 | compileClasspath += main.compileClasspath
27 | }
28 | }
29 |
30 | loom {
31 | runs {
32 | testmodClient {
33 | client()
34 | ideConfigGenerated project.rootProject == project
35 | name = "Test Mod Client"
36 | source sourceSets.testmod
37 | }
38 | testmodServer {
39 | server()
40 | ideConfigGenerated project.rootProject == project
41 | name = "Test Mod Server"
42 | source sourceSets.testmod
43 | }
44 | }
45 | }
46 |
47 | dependencies {
48 | // To change the versions see the gradle.properties file
49 | minecraft "com.mojang:minecraft:${project.minecraft_version}"
50 | mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
51 | modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
52 |
53 | // Fabric API. This is technically optional, but you probably want it anyway.
54 | modCompileOnly modLocalRuntime("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
55 |
56 | //modRuntime "com.github.SuperCoder7979:databreaker:0.2.6"
57 |
58 | // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
59 | // You may need to force-disable transitiveness on them.
60 | testmodImplementation sourceSets.main.output
61 | }
62 |
63 | processResources {
64 | inputs.property "version", project.version
65 |
66 | filesMatching("fabric.mod.json") {
67 | expand "version": project.version
68 | }
69 | }
70 |
71 | tasks.withType(JavaCompile).configureEach {
72 | // ensure that the encoding is set to UTF-8, no matter what the system default is
73 | // this fixes some edge cases with special characters not displaying correctly
74 | // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
75 | // If Javadoc is generated, this must be specified in that task too.
76 | it.options.encoding = "UTF-8"
77 |
78 |
79 | it.options.release = 21
80 |
81 | }
82 |
83 | java {
84 | // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
85 | // if it is present.
86 | // If you remove this line, sources will not be generated.
87 | withSourcesJar()
88 | }
89 |
90 | jar {
91 | from("LICENSE") {
92 | rename { "${it}_${project.archivesBaseName}"}
93 | }
94 | }
95 |
96 | def env = System.getenv()
97 |
98 | // configure the maven publication
99 | publishing {
100 | publications {
101 | mavenJava(MavenPublication) {
102 | // add all the jars that should be included when publishing to maven
103 | artifact(remapJar) {
104 | builtBy remapJar
105 | }
106 | artifact(sourcesJar) {
107 | builtBy remapSourcesJar
108 | }
109 | }
110 | }
111 |
112 | // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
113 | repositories {
114 | // Add repositories to publish to here.
115 | // Notice: This block does NOT have the same function as the block in the top level.
116 | // The repositories here will be used for publishing your artifact, not for
117 | // retrieving dependencies.
118 | repositories {
119 | if (env.MAVEN_URL) {
120 | maven {
121 | credentials {
122 | username env.MAVEN_USERNAME
123 | password env.MAVEN_PASSWORD
124 | }
125 | url env.MAVEN_URL
126 | }
127 | } else {
128 | mavenLocal()
129 | }
130 | }
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/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/versions.html
6 | minecraft_version=1.21.6-pre3
7 | yarn_mappings=1.21.6-pre3+build.1
8 | loader_version=0.16.14
9 |
10 | #Fabric api
11 | fabric_version=0.126.0+1.21.6
12 |
13 | # Mod Properties
14 | mod_version = 1.10.0+1.21.6
15 | maven_group = eu.pb4
16 | archives_base_name = sgui
17 |
18 | # Dependencies
19 | # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Patbox/sgui/44d8e2f430db2ff3b9a3ad7ef40bcc1373b12879/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.12-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or 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 UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/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 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | maven {
4 | name = 'Fabric'
5 | url = 'https://maven.fabricmc.net/'
6 | }
7 | gradlePluginPortal()
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/eu/pb4/sgui/api/ClickType.java:
--------------------------------------------------------------------------------
1 | package eu.pb4.sgui.api;
2 |
3 | import net.minecraft.screen.slot.SlotActionType;
4 |
5 | /**
6 | * Simplified Click Type
7 | *
8 | * The API supplies onClick methods with these more accurate click types.
9 | * Use the fields in this enum to get a more general idea of the click.
10 | */
11 | public enum ClickType {
12 | MOUSE_LEFT(true, false, false, false, -1, false, false),
13 | MOUSE_RIGHT(false, true, false, false, -1, false, false),
14 | MOUSE_LEFT_SHIFT(true, false, false, true, -1, false, false),
15 | MOUSE_RIGHT_SHIFT(false, true, false, true, -1, false, false),
16 | NUM_KEY_1(false, false, false, false, 1, true, false),
17 | NUM_KEY_2(false, false, false, false, 2, true, false),
18 | NUM_KEY_3(false, false, false, false, 3, true, false),
19 | NUM_KEY_4(false, false, false, false, 4, true, false),
20 | NUM_KEY_5(false, false, false, false, 5, true, false),
21 | NUM_KEY_6(false, false, false, false, 6, true, false),
22 | NUM_KEY_7(false, false, false, false, 7, true, false),
23 | NUM_KEY_8(false, false, false, false, 8, true, false),
24 | NUM_KEY_9(false, false, false, false, 9, true, false),
25 | MOUSE_MIDDLE(false, false, true, false, -1, false, false),
26 | DROP(false, false, false, false, -1, false, false),
27 | CTRL_DROP(false, false, false, false, -1, false, false),
28 | MOUSE_LEFT_OUTSIDE(true, false, false, false, -1, false, false),
29 | MOUSE_RIGHT_OUTSIDE(false, true, false, false, -1, false, false),
30 | MOUSE_LEFT_DRAG_START(true, false, false, false, 0, false, true),
31 | MOUSE_RIGHT_DRAG_START(false, true, false, false, 0, false, true),
32 | MOUSE_MIDDLE_DRAG_START(false, false, true, false, 0, false, true),
33 | MOUSE_LEFT_DRAG_ADD(true, false, false, false, 1, false, true),
34 | MOUSE_RIGHT_DRAG_ADD(false, true, false, false, 1, false, true),
35 | MOUSE_MIDDLE_DRAG_ADD(false, false, true, false, 1, false, true),
36 | MOUSE_LEFT_DRAG_END(true, false, false, false, 2, false, true),
37 | MOUSE_RIGHT_DRAG_END(false, true, false, false, 2, false, true),
38 | MOUSE_MIDDLE_DRAG_END(false, false, true, false, 2, false, true),
39 | MOUSE_DOUBLE_CLICK(false, false, true, false, -1, false, false),
40 | UNKNOWN(false, false, false, false, -1, false, false),
41 | OFFHAND_SWAP(false, false, false, false, 40, false, false);
42 |
43 | public final boolean isLeft;
44 | public final boolean isRight;
45 | public final boolean isMiddle;
46 | public final boolean shift;
47 | public final int value;
48 | public final boolean numKey;
49 | public final boolean isDragging;
50 |
51 | ClickType(boolean isLeft, boolean isRight, boolean isMiddle, boolean shift, int value, boolean numKey, boolean isDragging) {
52 | this.isLeft = isLeft;
53 | this.isRight = isRight;
54 | this.isMiddle = isMiddle;
55 | this.shift = shift;
56 | this.value = value;
57 | this.numKey = numKey;
58 | this.isDragging = isDragging;
59 | }
60 |
61 | public static ClickType toClickType(SlotActionType action, int button, int slot) {
62 | switch (action) {
63 | case PICKUP:
64 | return button == 0 ? MOUSE_LEFT : MOUSE_RIGHT;
65 | case QUICK_MOVE:
66 | return button == 0 ? MOUSE_LEFT_SHIFT : MOUSE_RIGHT_SHIFT;
67 | case SWAP:
68 | if (button >= 0 && button < 9) {
69 | return ClickType.values()[button + 4];
70 | } else if (button == 40) {
71 | return ClickType.OFFHAND_SWAP;
72 | }
73 | break;
74 | case CLONE:
75 | return MOUSE_MIDDLE;
76 | case THROW:
77 | return slot == -999 ? (button == 0 ? MOUSE_LEFT_OUTSIDE : MOUSE_RIGHT_OUTSIDE) : (button == 0 ? DROP : CTRL_DROP);
78 | case QUICK_CRAFT:
79 | switch (button) {
80 | case 0:
81 | return MOUSE_LEFT_DRAG_START;
82 | case 1:
83 | return MOUSE_LEFT_DRAG_ADD;
84 | case 2:
85 | return MOUSE_LEFT_DRAG_END;
86 | case 4:
87 | return MOUSE_RIGHT_DRAG_START;
88 | case 5:
89 | return MOUSE_RIGHT_DRAG_ADD;
90 | case 6:
91 | return MOUSE_RIGHT_DRAG_END;
92 | case 8:
93 | return MOUSE_MIDDLE_DRAG_START;
94 | case 9:
95 | return MOUSE_MIDDLE_DRAG_ADD;
96 | case 10:
97 | return MOUSE_MIDDLE_DRAG_END;
98 | }
99 | case PICKUP_ALL:
100 | return MOUSE_DOUBLE_CLICK;
101 | }
102 |
103 | return UNKNOWN;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/main/java/eu/pb4/sgui/api/GuiHelpers.java:
--------------------------------------------------------------------------------
1 | package eu.pb4.sgui.api;
2 |
3 | import eu.pb4.sgui.api.gui.GuiInterface;
4 | import eu.pb4.sgui.impl.PlayerExtensions;
5 | import eu.pb4.sgui.virtual.VirtualScreenHandlerInterface;
6 | import net.minecraft.item.ItemStack;
7 | import net.minecraft.network.packet.s2c.play.InventoryS2CPacket;
8 | import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
9 | import net.minecraft.screen.ScreenHandlerType;
10 | import net.minecraft.server.network.ServerPlayerEntity;
11 | import net.minecraft.text.Style;
12 | import net.minecraft.text.TextColor;
13 | import net.minecraft.util.Formatting;
14 | import org.jetbrains.annotations.Nullable;
15 |
16 | import java.util.function.UnaryOperator;
17 |
18 | public final class GuiHelpers {
19 | public static final UnaryOperator