commit 96a5b076528f769e7e060e318671f2d6f73be8a8 Author: Konhaiii Date: Sun Jun 1 17:44:30 2025 +0200 Initial commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..097f9f9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf + +# These are Windows script files and should use crlf +*.bat text eol=crlf + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8fc3827 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,30 @@ +# Automatically build the project and run any configured tests for every push +# and submitted pull request. This can help catch issues that only occur on +# certain platforms or Java versions, and provides a first line of defence +# against bad commits. + +name: build +on: [pull_request, push] + +jobs: + build: + runs-on: ubuntu-24.04 + steps: + - name: checkout repository + uses: actions/checkout@v4 + - name: validate gradle wrapper + uses: gradle/actions/wrapper-validation@v4 + - name: setup jdk + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'microsoft' + - name: make gradle wrapper executable + run: chmod +x ./gradlew + - name: build + run: ./gradlew build + - name: capture build artifacts + uses: actions/upload-artifact@v4 + with: + name: Artifacts + path: build/libs/ \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c476faf --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ + +# java + +hs_err_*.log +replay_*.log +*.hprof +*.jfr diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e1c81eb --- /dev/null +++ b/LICENSE @@ -0,0 +1,151 @@ +Creative Commons Attribution-NonCommercial 4.0 International + +Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. + +Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors. + +Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public. + +Creative Commons Attribution-NonCommercial 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. + +Section 1 – Definitions. + + a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. + + d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. + + g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights under this Public License. + + i. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. + + j. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. + + k. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. + + l. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. +Section 2 – Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: + + A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and + + B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only. + + 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. + + 3. Term. The term of this Public License is specified in Section 6(a). + + 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. + + 5. Downstream recipients. + + A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. + + B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. + + 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this Public License. + + 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. +Section 3 – License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified form), You must: + + A. retain the following if it is supplied by the Licensor with the Licensed Material: + + i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of warranties; + + v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + + B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and + + C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. + + 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. +Section 4 – Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only; + + b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. +For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. + +Section 5 – Disclaimer of Warranties and Limitation of Liability. + + a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. + + b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. + + c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. +Section 6 – Term and Termination. + + a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. +Section 7 – Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. +Section 8 – Interpretation. + + a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. + + c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. + + d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. +Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. + +Creative Commons may be contacted at creativecommons.org. \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..110b08a --- /dev/null +++ b/build.gradle @@ -0,0 +1,95 @@ +plugins { + id 'fabric-loom' version "${loom_version}" + id 'maven-publish' +} + +version = project.mod_version +group = project.maven_group + +base { + archivesName = project.archives_base_name +} + +repositories { + maven { + name = "TerraformersMC" + url = "https://maven.terraformersmc.com/" + } + maven { + name = "Ladysnake Libs" + url = 'https://maven.ladysnake.org/releases' + } +} + +loom { + splitEnvironmentSourceSets() + + mods { + "powered_jetpacks" { + sourceSet sourceSets.main + sourceSet sourceSets.client + } + } + +} + +dependencies { + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "dev.emi:trinkets:${trinkets_version}" + + include(modApi("teamreborn:energy:${project.energy_version}")) { + transitive = false + } +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": inputs.properties.version + } +} + +tasks.withType(JavaCompile).configureEach { + it.options.release = 17 +} + +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +jar { + inputs.property "archivesName", project.base.archivesName + + from("LICENSE") { + rename { "${it}_${inputs.properties.archivesName}"} + } +} + +// configure the maven publication +publishing { + publications { + create("mavenJava", MavenPublication) { + artifactId = project.archives_base_name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..e986c1f --- /dev/null +++ b/gradle.properties @@ -0,0 +1,20 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true + +# Fabric Properties +# check these on https://fabricmc.net/develop +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.10 +loader_version=0.16.14 +loom_version=1.10-SNAPSHOT + +# Mod Properties +mod_version=1.0.0 +maven_group=konhaiii.powered_jetpacks +archives_base_name=powered_jetpacks + +# Dependencies +energy_version=3.0.0 +trinkets_version=3.7.1 +fabric_version=0.92.5+1.20.1 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..a4b76b9 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e18bc25 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..f3b75f3 --- /dev/null +++ b/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..9d21a21 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..75c4d72 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } +} \ No newline at end of file diff --git a/src/client/java/konhaiii/powered_jetpacks/PoweredJetpacksClient.java b/src/client/java/konhaiii/powered_jetpacks/PoweredJetpacksClient.java new file mode 100644 index 0000000..d558815 --- /dev/null +++ b/src/client/java/konhaiii/powered_jetpacks/PoweredJetpacksClient.java @@ -0,0 +1,37 @@ +package konhaiii.powered_jetpacks; + +import konhaiii.powered_jetpacks.hud.JetpackHUD; +import konhaiii.powered_jetpacks.renderers.JetpackRenderer; +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; +import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; +import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback; +import net.minecraft.client.render.entity.feature.FeatureRendererContext; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.Identifier; + +public class PoweredJetpacksClient implements ClientModInitializer { + @Override + public void onInitializeClient() { + ItemTooltipCallback.EVENT.register(new StackToolTipHandler()); + HudRenderCallback.EVENT.register(new JetpackHUD()); + LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper, context) -> { + if (entityRenderer != null) { + FeatureRendererContext> featureRendererContext = + new FeatureRendererContext<>() { + @Override + public EntityModel getModel() { + return null; + } + + @Override + public Identifier getTexture(LivingEntity entity) { + return null; + } + }; + registrationHelper.register(new JetpackRenderer<>(featureRendererContext)); + } + }); + } +} \ No newline at end of file diff --git a/src/client/java/konhaiii/powered_jetpacks/StackToolTipHandler.java b/src/client/java/konhaiii/powered_jetpacks/StackToolTipHandler.java new file mode 100644 index 0000000..558ad83 --- /dev/null +++ b/src/client/java/konhaiii/powered_jetpacks/StackToolTipHandler.java @@ -0,0 +1,80 @@ +package konhaiii.powered_jetpacks; + +import konhaiii.powered_jetpacks.energy.EnergySystem; +import konhaiii.powered_jetpacks.item.special.JetpackItem; +import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.text.MutableText; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; + +import java.util.List; + +public class StackToolTipHandler implements ItemTooltipCallback { + @Override + public void getTooltip(ItemStack itemStack, TooltipContext tooltipContext, List tooltipLines) { + Item item = itemStack.getItem(); + if (item instanceof JetpackItem jetpackItem) { + + if (Screen.hasShiftDown()) { + MutableText line1 = Text.literal(EnergySystem.getEnergy(jetpackItem.getStoredEnergy(itemStack))); + line1.append("/"); + line1.append(EnergySystem.getEnergyUnit(jetpackItem.getEnergyCapacity(itemStack))); + line1.formatted(Formatting.GOLD); + + tooltipLines.add(1, line1); + + int percentage = percentage(jetpackItem.getStoredEnergy(itemStack), jetpackItem.getEnergyCapacity(itemStack)); + MutableText line2 = Text.literal(String.valueOf(percentage)).append("%"); + line2.append(" "); + line2.formatted(Formatting.GRAY); + line2.append(I18n.translate("tooltip.powered_jetpacks.power_charged")); + tooltipLines.add(2, line2); + + double inputRate = jetpackItem.getEnergyMaxInput(itemStack); + double outputRate = jetpackItem.getEnergyMaxOutput(itemStack); + + MutableText line3 = Text.literal(""); + if (inputRate != 0 && inputRate == outputRate){ + line3.append(I18n.translate("tooltip.powered_jetpacks.transfer_rate")); + line3.append(" : "); + line3.formatted(Formatting.GRAY); + line3.append(EnergySystem.getEnergyUnitDiminished(inputRate)); + line3.formatted(Formatting.GOLD); + } + else if(inputRate != 0){ + line3.append(I18n.translate("tooltip.powered_jetpacks.input_rate")); + line3.append(" : "); + line3.formatted(Formatting.GRAY); + line3.append(EnergySystem.getEnergyUnitDiminished(inputRate)); + line3.formatted(Formatting.GOLD); + } + else if (outputRate !=0){ + line3.append(I18n.translate("tooltip.powered_jetpacks.output_rate")); + line3.append(" : "); + line3.formatted(Formatting.GRAY); + line3.append(EnergySystem.getEnergyUnitDiminished(outputRate)); + line3.formatted(Formatting.GOLD); + } + tooltipLines.add(3, line3); + } else { + MutableText line1 = Text.literal(EnergySystem.getEnergyDiminished(jetpackItem.getStoredEnergy(itemStack))); + line1.append("/"); + line1.append(EnergySystem.getEnergyUnitDiminished(jetpackItem.getEnergyCapacity(itemStack))); + line1.formatted(Formatting.GOLD); + + tooltipLines.add(1, line1); + } + } + } + + private int percentage(double CurrentValue, double MaxValue) { + if (CurrentValue == 0) + return 0; + return (int) ((CurrentValue * 100.0f) / MaxValue); + } +} diff --git a/src/client/java/konhaiii/powered_jetpacks/hud/JetpackHUD.java b/src/client/java/konhaiii/powered_jetpacks/hud/JetpackHUD.java new file mode 100644 index 0000000..b27ac04 --- /dev/null +++ b/src/client/java/konhaiii/powered_jetpacks/hud/JetpackHUD.java @@ -0,0 +1,55 @@ +package konhaiii.powered_jetpacks.hud; + +import dev.emi.trinkets.api.TrinketsApi; +import konhaiii.powered_jetpacks.item.special.JetpackItem; +import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Pair; + +import static net.minecraft.client.resource.language.I18n.translate; + +public class JetpackHUD implements HudRenderCallback { + + @Override + public void onHudRender(DrawContext drawContext, float tickDelta) { + MinecraftClient client = MinecraftClient.getInstance(); + if (client.player == null) return; + + ItemStack chestStack = client.player.getEquippedStack(EquipmentSlot.CHEST); + ItemStack backStack = TrinketsApi.getTrinketComponent(client.player).map(component -> + component.getEquipped(stack -> stack.getItem() instanceof JetpackItem) + .stream() + .findFirst() + .map(Pair::getRight) + .orElse(ItemStack.EMPTY) + ).orElse(ItemStack.EMPTY); + + ItemStack jetpackStack = isValidJetpack(chestStack) ? chestStack : (!backStack.isEmpty() ? backStack : ItemStack.EMPTY); + + if (!jetpackStack.isEmpty()) { + JetpackItem jetpack = (JetpackItem) jetpackStack.getItem(); + long energy = jetpack.getStoredEnergy(jetpackStack); + long maxEnergy = jetpack.getEnergyCapacity(jetpackStack); + + TextRenderer textRenderer = client.textRenderer; + int percentage = percentage(energy, maxEnergy); + String energyText = translate("hud.powered_jetpacks.jetpack_power").concat(String.valueOf(percentage)).concat("%"); + + drawContext.drawTextWithShadow(textRenderer, energyText, 10, 10, 0xFFFFFF); + } + } + + private boolean isValidJetpack(ItemStack stack) { + return stack.getItem() instanceof JetpackItem; + } + + private int percentage(double CurrentValue, double MaxValue) { + if (CurrentValue == 0) + return 0; + return (int) ((CurrentValue * 100.0f) / MaxValue); + } +} \ No newline at end of file diff --git a/src/client/java/konhaiii/powered_jetpacks/mixin/client/ClientPlayerEntityMixin.java b/src/client/java/konhaiii/powered_jetpacks/mixin/client/ClientPlayerEntityMixin.java new file mode 100644 index 0000000..5c4a546 --- /dev/null +++ b/src/client/java/konhaiii/powered_jetpacks/mixin/client/ClientPlayerEntityMixin.java @@ -0,0 +1,77 @@ +package konhaiii.powered_jetpacks.mixin.client; + +import dev.emi.trinkets.api.TrinketsApi; +import konhaiii.powered_jetpacks.item.special.JetpackItem; +import konhaiii.powered_jetpacks.packet.JetpackPacket; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.util.Pair; +import net.minecraft.util.math.Vec3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ClientPlayerEntity.class) +public abstract class ClientPlayerEntityMixin { + @Unique + private int soundCounter = 8; + + @Inject(method = "tick", at = @At("HEAD")) + private void onTick(CallbackInfo ci) { + ClientPlayerEntity player = (ClientPlayerEntity) (Object) this; + ItemStack chestStack = player.getEquippedStack(EquipmentSlot.CHEST); + ItemStack backStack = TrinketsApi.getTrinketComponent(player).map(component -> + component.getEquipped(stack -> stack.getItem() instanceof JetpackItem) + .stream() + .findFirst() + .map(Pair::getRight) + .orElse(ItemStack.EMPTY) + ).orElse(ItemStack.EMPTY); + ItemStack jetpackStack = null; + if (isValidJetpack(chestStack)) { + jetpackStack = chestStack; + } else if (isValidJetpack(backStack)) { + jetpackStack = backStack; + } + + if (jetpackStack != null && player.input.jumping) { + PacketByteBuf buf = PacketByteBufs.create(); + JetpackItem jetpack = (JetpackItem) jetpackStack.getItem(); + Vec3d velocity = player.getVelocity(); + float horizontalBoost = jetpack.getFlightSpeed(); + player.setVelocity( + velocity.x + (player.getRotationVector().x * horizontalBoost), + jetpack.addToVerticalVelocity(player.getVelocity().y), + velocity.z + (player.getRotationVector().z * horizontalBoost) + ); + player.fallDistance = 0; + + soundCounter++; + if (soundCounter >= 8) { + JetpackPacket.encode(new JetpackPacket(true), buf); + soundCounter = 0; + } else { + JetpackPacket.encode(new JetpackPacket(false), buf); + } + ClientPlayNetworking.send(JetpackPacket.getPacketId(), buf); + } else if (soundCounter != 8) { + soundCounter = 8; + } + } + @Unique + private boolean isValidJetpack(ItemStack stack) { + if (stack.getItem() instanceof JetpackItem jetpack) { + if (jetpack.getEnergyCost() <= 0) { + return true; + } + return jetpack.getStoredEnergy(stack) > 0; + } + return false; + } +} \ No newline at end of file diff --git a/src/client/java/konhaiii/powered_jetpacks/models/JetpackModel.java b/src/client/java/konhaiii/powered_jetpacks/models/JetpackModel.java new file mode 100644 index 0000000..0ea5c4e --- /dev/null +++ b/src/client/java/konhaiii/powered_jetpacks/models/JetpackModel.java @@ -0,0 +1,110 @@ +package konhaiii.powered_jetpacks.models; + +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.math.Direction; + +import java.util.*; + +public class JetpackModel extends EntityModel { + private final ModelPart middle; + private final ModelPart bottomLeft; + private final ModelPart bottomRight; + private final ModelPart mainLeft; + private final ModelPart mainRight; + + public JetpackModel() { + // Middle part + Map middleUVs = Map.of( + Direction.NORTH, new UV(8, 2, 16, 16), + Direction.EAST, new UV(6, 2, 16, 16), + Direction.SOUTH, new UV(4, 2, 16, 16), + Direction.WEST, new UV(10, 2, 16, 16), + Direction.UP, new UV(4, 4, 16, 16), + Direction.DOWN, new UV(6, 6, 16, 16) + ); + this.middle = createCuboid(7, 2, 7, 2, 8, 2, middleUVs); + + // Bottom left part + Map bottomLeftUVs = Map.of( + Direction.NORTH, new UV(4, 0, 16, 16), + Direction.EAST, new UV(2, 0, 16, 16), + Direction.SOUTH, new UV(0, 0, 16, 16), + Direction.WEST, new UV(6, 0, 16, 16), + Direction.UP, new UV(2, 0, 16, 16), + Direction.DOWN, new UV(4, 0, 16, 16) + ); + this.bottomLeft = createCuboid(4, 0, 7, 2, 1, 2, bottomLeftUVs); + + // Bottom right part + Map bottomRightUVs = Map.of( + Direction.NORTH, new UV(4, 0, 16, 16), + Direction.EAST, new UV(2, 0, 16, 16), + Direction.SOUTH, new UV(0, 0, 16, 16), + Direction.WEST, new UV(6, 0, 16, 16), + Direction.UP, new UV(2, 0, 16, 16), + Direction.DOWN, new UV(4, 0, 16, 16) + ); + this.bottomRight = createCuboid(10, 0, 7, 2, 1, 2, bottomRightUVs); + + // Main left part + Map mainLeftUVs = Map.of( + Direction.NORTH, new UV(8, 0, 16, 16), + Direction.EAST, new UV(4, 0, 16, 16), + Direction.SOUTH, new UV(0, 0, 16, 16), + Direction.WEST, new UV(12, 0, 16, 16), + Direction.UP, new UV(4, 0, 16, 16), + Direction.DOWN, new UV(4, 0, 16, 16) + ); + this.mainLeft = createCuboid(3, 1, 6, 4, 10, 4, mainLeftUVs); + + // Main right part + Map mainRightUVs = Map.of( + Direction.NORTH, new UV(8, 0, 16, 16), + Direction.EAST, new UV(4, 0, 16, 16), + Direction.SOUTH, new UV(0, 0, 16, 16), + Direction.WEST, new UV(12, 0, 16, 16), + Direction.UP, new UV(4, 0, 16, 16), + Direction.DOWN, new UV(4, 0, 16, 16) + ); + this.mainRight = createCuboid(9, 1, 6, 4, 10, 4, mainRightUVs); + } + + private ModelPart createCuboid(int x, int y, int z, int width, int height, int depth, Map faceUVs) { + List cuboids = new ArrayList<>(); + + for (Direction face : faceUVs.keySet()) { + UV uv = faceUVs.get(face); + ModelPart.Cuboid cuboid = new ModelPart.Cuboid( + uv.u, uv.v, + x, y, z, + width, height, depth, + 0, 0, 0, + false, + uv.uWidth, uv.vHeight, + EnumSet.of(face) + ); + cuboids.add(cuboid); + } + + return new ModelPart(cuboids, Map.of()); + } + + public record UV(int u, int v, int uWidth, int vHeight) { + } + + @Override + public void setAngles(T entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {} + + @Override + public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) { + middle.render(matrices, vertices, light, overlay, red, green, blue, alpha); + bottomLeft.render(matrices, vertices, light, overlay, red, green, blue, alpha); + bottomRight.render(matrices, vertices, light, overlay, red, green, blue, alpha); + mainLeft.render(matrices, vertices, light, overlay, red, green, blue, alpha); + mainRight.render(matrices, vertices, light, overlay, red, green, blue, alpha); + } +} \ No newline at end of file diff --git a/src/client/java/konhaiii/powered_jetpacks/renderers/JetpackRenderer.java b/src/client/java/konhaiii/powered_jetpacks/renderers/JetpackRenderer.java new file mode 100644 index 0000000..1fccad3 --- /dev/null +++ b/src/client/java/konhaiii/powered_jetpacks/renderers/JetpackRenderer.java @@ -0,0 +1,71 @@ +package konhaiii.powered_jetpacks.renderers; + +import dev.emi.trinkets.api.TrinketsApi; +import konhaiii.powered_jetpacks.PoweredJetpacks; +import konhaiii.powered_jetpacks.item.ModItems; +import konhaiii.powered_jetpacks.item.special.JetpackItem; +import konhaiii.powered_jetpacks.models.JetpackModel; +import net.minecraft.client.render.OverlayTexture; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.feature.FeatureRenderer; +import net.minecraft.client.render.entity.feature.FeatureRendererContext; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Identifier; +import net.minecraft.util.Pair; +import net.minecraft.util.math.RotationAxis; + +public class JetpackRenderer> extends FeatureRenderer { + private final JetpackModel jetpackModel; + private static final Identifier BASIC_JETPACK_TEXTURE = new Identifier(PoweredJetpacks.MOD_ID, "textures/jetpack/basic_jetpack.png"); + private static final Identifier ADVANCED_JETPACK_TEXTURE = new Identifier(PoweredJetpacks.MOD_ID, "textures/jetpack/advanced_jetpack.png"); + private static final Identifier INDUSTRIAL_JETPACK_TEXTURE = new Identifier(PoweredJetpacks.MOD_ID, "textures/jetpack/industrial_jetpack.png"); + + public JetpackRenderer(FeatureRendererContext context) { + super(context); + this.jetpackModel = new JetpackModel<>(); + } + + @Override + public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) { + ItemStack chestStack = entity.getEquippedStack(EquipmentSlot.CHEST); + + ItemStack backStack = TrinketsApi.getTrinketComponent(entity).map(component -> + component.getEquipped(stack -> stack.getItem() instanceof JetpackItem) + .stream() + .findFirst() + .map(Pair::getRight) + .orElse(ItemStack.EMPTY) + ).orElse(ItemStack.EMPTY); + + ItemStack jetpackStack = isValidJetpack(chestStack) ? chestStack : (!backStack.isEmpty() ? backStack : ItemStack.EMPTY); + + if (!jetpackStack.isEmpty()) { + matrixStack.push(); + matrixStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180)); + matrixStack.translate(-0.5D, -0.7D, -0.8D); + this.jetpackModel.setAngles(entity, limbAngle, limbDistance, animationProgress, headYaw, headPitch); + VertexConsumer vertexConsumer; + if (jetpackStack.getItem() == ModItems.BASIC_JETPACK) { + vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityCutout(BASIC_JETPACK_TEXTURE)); + } else if (jetpackStack.getItem() == ModItems.ADVANCED_JETPACK) { + vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityCutout(ADVANCED_JETPACK_TEXTURE)); + } else { + vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityCutout(INDUSTRIAL_JETPACK_TEXTURE)); + } + + this.jetpackModel.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); + + matrixStack.pop(); + } + } + + private boolean isValidJetpack(ItemStack stack) { + return stack.getItem() instanceof JetpackItem; + } +} \ No newline at end of file diff --git a/src/client/resources/powered_jetpacks.client.mixins.json b/src/client/resources/powered_jetpacks.client.mixins.json new file mode 100644 index 0000000..54cd31f --- /dev/null +++ b/src/client/resources/powered_jetpacks.client.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "konhaiii.powered_jetpacks.mixin.client", + "compatibilityLevel": "JAVA_17", + "client": [ + "ClientPlayerEntityMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/src/main/java/konhaiii/powered_jetpacks/PoweredJetpacks.java b/src/main/java/konhaiii/powered_jetpacks/PoweredJetpacks.java new file mode 100644 index 0000000..90ff42f --- /dev/null +++ b/src/main/java/konhaiii/powered_jetpacks/PoweredJetpacks.java @@ -0,0 +1,29 @@ +package konhaiii.powered_jetpacks; + +import konhaiii.powered_jetpacks.config.ModConfig; +import konhaiii.powered_jetpacks.item.ModItems; +import konhaiii.powered_jetpacks.packet.JetpackPacket; +import konhaiii.powered_jetpacks.sounds.ModSounds; +import net.fabricmc.api.ModInitializer; + +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PoweredJetpacks implements ModInitializer { + public static final String MOD_ID = "powered_jetpacks"; + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); + public static ModConfig config; + + @Override + public void onInitialize() { + LOGGER.info("Initialize"); + config = ModConfig.loadConfig(); + ModItems.initialize(); + ModSounds.initialize(); + ServerPlayNetworking.registerGlobalReceiver(JetpackPacket.getPacketId(), (server, player, handler, buf, responseSender) -> { + JetpackPacket packet = JetpackPacket.decode(buf); + server.execute(() -> JetpackPacket.handle(player, packet)); + }); + } +} \ No newline at end of file diff --git a/src/main/java/konhaiii/powered_jetpacks/config/ModConfig.java b/src/main/java/konhaiii/powered_jetpacks/config/ModConfig.java new file mode 100644 index 0000000..0d30345 --- /dev/null +++ b/src/main/java/konhaiii/powered_jetpacks/config/ModConfig.java @@ -0,0 +1,60 @@ +package konhaiii.powered_jetpacks.config; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonSyntaxException; +import konhaiii.powered_jetpacks.PoweredJetpacks; + +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; + +public class ModConfig { + private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); + private static final Path CONFIG_PATH = Path.of("config", "powered_jetpacks.json"); + + public int basicJetpackMaxEnergy = 10000; + public int basicJetpackInputEnergy = 128; + public float basicJetpackVerticalSpeed = 1.0f; + public float basicJetpackHorizontalSpeed = 0.0f; + public int basicJetpackEnergyCost = 2; + public int advancedJetpackMaxEnergy = 100000; + public int advancedJetpackInputEnergy = 2048; + public float advancedJetpackVerticalSpeed = 1.5f; + public float advancedJetpackHorizontalSpeed = 0.05f; + public int advancedJetpackEnergyCost = 16; + public int industrialJetpackMaxEnergy = 1000000; + public int industrialJetpackInputEnergy = 8192; + public float industrialJetpackVerticalSpeed = 2.0f; + public float industrialJetpackHorizontalSpeed = 0.1f; + public int industrialJetpackEnergyCost = 64; + + public static ModConfig loadConfig() { + if (!Files.exists(CONFIG_PATH)) { + ModConfig defaultConfig = new ModConfig(); + defaultConfig.saveConfig(); + return defaultConfig; + } + + try (Reader reader = Files.newBufferedReader(CONFIG_PATH)) { + return GSON.fromJson(reader, ModConfig.class); + } catch (IOException | JsonSyntaxException exception) { + PoweredJetpacks.LOGGER.error(exception.getMessage()); + return new ModConfig(); + } + } + + public void saveConfig() { + try { + Files.createDirectories(CONFIG_PATH.getParent()); + try (Writer writer = Files.newBufferedWriter(CONFIG_PATH, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) { + GSON.toJson(this, writer); + } + } catch (IOException exception) { + PoweredJetpacks.LOGGER.error(exception.getMessage()); + } + } +} diff --git a/src/main/java/konhaiii/powered_jetpacks/energy/EnergySystem.java b/src/main/java/konhaiii/powered_jetpacks/energy/EnergySystem.java new file mode 100644 index 0000000..abb505d --- /dev/null +++ b/src/main/java/konhaiii/powered_jetpacks/energy/EnergySystem.java @@ -0,0 +1,90 @@ +package konhaiii.powered_jetpacks.energy; + +import java.text.DecimalFormat; +import java.util.Locale; + +public class EnergySystem { + public static final String EnergyAbbreviation = "E"; + public static final char[] magnitude = new char[] { 'k', 'M', 'G', 'T' }; + + public static String getEnergyUnitDiminished(double energy) { + return getFinalString(energy, true, true); + } + public static String getEnergyDiminished(double energy) { + return getFinalString(energy, false, true); + } + public static String getEnergyUnit(double energy) { + return getFinalString(energy, true, false); + } + public static String getEnergy(double energy) { + return getFinalString(energy, false, false); + } + + private static String getFinalString(double energy, boolean showUnit, boolean showDiminutive) { + String returnValue = ""; + double finalValue = 0f; + double value = energy; + int i = 0; + boolean doFormat = true; + boolean showMagnitude = true; + + if (showDiminutive) { + if (energy < 1000) { + doFormat = false; + showMagnitude = false; + finalValue = value; + } else if (value >= 1000) { + for (i = 0; ; i++) { + if (value < 10000 && value % 1000 >= 100) { + finalValue = Math.floor(value / 1000); + finalValue += ((float) value % 1000) / 1000; + break; + } + value /= 1000; + if (value < 1000) { + finalValue = value; + break; + } + } + } + + if (i > 10) { + doFormat = false; + showMagnitude = false; + } else if (i > 3) { + finalValue = energy; + showMagnitude = false; + } + } else { + finalValue = value; + showMagnitude = false; + } + + if (doFormat) { + DecimalFormat formatter = (DecimalFormat) DecimalFormat.getInstance(Locale.ENGLISH); + returnValue += formatter.format(finalValue); + int idx = returnValue.lastIndexOf(formatter.getDecimalFormatSymbols().getDecimalSeparator()); + if (idx > 0){ + returnValue = returnValue.substring(0, idx + 2); + } + } + else { + if (i>10){ + returnValue += "∞"; + } + else { + returnValue += value; + } + } + + if (showMagnitude) { + returnValue += magnitude[i]; + } + + if (showUnit) { + returnValue += " " + EnergyAbbreviation; + } + + return returnValue; + } +} diff --git a/src/main/java/konhaiii/powered_jetpacks/item/ModItems.java b/src/main/java/konhaiii/powered_jetpacks/item/ModItems.java new file mode 100644 index 0000000..d5f718d --- /dev/null +++ b/src/main/java/konhaiii/powered_jetpacks/item/ModItems.java @@ -0,0 +1,52 @@ +package konhaiii.powered_jetpacks.item; + +import konhaiii.powered_jetpacks.PoweredJetpacks; +import konhaiii.powered_jetpacks.item.special.JetpackItem; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; + +public class ModItems { + public static Item register(Item item, String id) { + Identifier itemID = new Identifier(PoweredJetpacks.MOD_ID, id); + + return Registry.register(Registries.ITEM, itemID, item); + } + + public static final Item BASIC_JETPACK = register( + new JetpackItem(PoweredJetpacks.config.basicJetpackMaxEnergy, PoweredJetpacks.config.basicJetpackInputEnergy, PoweredJetpacks.config.basicJetpackVerticalSpeed, PoweredJetpacks.config.basicJetpackHorizontalSpeed, PoweredJetpacks.config.basicJetpackEnergyCost), + "basic_jetpack" + ); + + public static final Item ADVANCED_JETPACK = register( + new JetpackItem(PoweredJetpacks.config.advancedJetpackMaxEnergy, PoweredJetpacks.config.advancedJetpackInputEnergy, PoweredJetpacks.config.advancedJetpackVerticalSpeed, PoweredJetpacks.config.advancedJetpackHorizontalSpeed, PoweredJetpacks.config.advancedJetpackEnergyCost), + "advanced_jetpack" + ); + + public static final Item INDUSTRIAL_JETPACK = register( + new JetpackItem(PoweredJetpacks.config.industrialJetpackMaxEnergy, PoweredJetpacks.config.industrialJetpackInputEnergy, PoweredJetpacks.config.industrialJetpackVerticalSpeed, PoweredJetpacks.config.industrialJetpackHorizontalSpeed, PoweredJetpacks.config.industrialJetpackEnergyCost), + "industrial_jetpack" + ); + + public static void initialize() { + Registry.register(Registries.ITEM_GROUP, ITEM_GROUP_KEY, ITEM_GROUP); + ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP_KEY).register(itemGroup -> { + itemGroup.add(BASIC_JETPACK); + itemGroup.add(ADVANCED_JETPACK); + itemGroup.add(INDUSTRIAL_JETPACK); + }); + } + + public static final RegistryKey ITEM_GROUP_KEY = RegistryKey.of(Registries.ITEM_GROUP.getKey(), new Identifier(PoweredJetpacks.MOD_ID, "item_group")); + public static final ItemGroup ITEM_GROUP = FabricItemGroup.builder() + .icon(() -> new ItemStack(BASIC_JETPACK)) + .displayName(Text.translatable("itemGroup.powered_jetpacks")) + .build(); +} \ No newline at end of file diff --git a/src/main/java/konhaiii/powered_jetpacks/item/special/JetpackItem.java b/src/main/java/konhaiii/powered_jetpacks/item/special/JetpackItem.java new file mode 100644 index 0000000..7b627f9 --- /dev/null +++ b/src/main/java/konhaiii/powered_jetpacks/item/special/JetpackItem.java @@ -0,0 +1,91 @@ +package konhaiii.powered_jetpacks.item.special; + +import dev.emi.trinkets.api.TrinketItem; +import net.minecraft.block.DispenserBlock; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ArmorItem; +import net.minecraft.item.Equipment; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.world.World; +import team.reborn.energy.api.base.SimpleEnergyItem; + +public class JetpackItem extends TrinketItem implements SimpleEnergyItem, Equipment { + private final int maxEnergy; + private final int inputEnergy; + private final float flightPower; + private final float flightSpeed; + private final int energyCost; + + public JetpackItem(int maxEnergy, int inputEnergy, float flightPower, float flightSpeed, int energyCost) { + super(new Settings().maxCount(1)); + this.maxEnergy = maxEnergy; + this.inputEnergy = inputEnergy; + this.flightPower = flightPower; + this.flightSpeed = flightSpeed; + this.energyCost = energyCost; + DispenserBlock.registerBehavior(this, ArmorItem.DISPENSER_BEHAVIOR); + } + + @Override + public long getEnergyCapacity(ItemStack itemStack) { + return maxEnergy; + } + + @Override + public long getEnergyMaxInput(ItemStack itemStack) { + return inputEnergy; + } + + @Override + public long getEnergyMaxOutput(ItemStack itemStack) { + return 0; + } + + @Override + public boolean isItemBarVisible(ItemStack stack) { + return true; + } + + @Override + public int getItemBarStep(ItemStack stack) { + return Math.round(getStoredEnergy(stack) * 13.f / getEnergyCapacity(stack)); + } + + @Override + public int getItemBarColor(ItemStack stack) { + return 0xff8006; + } + + @Override + public EquipmentSlot getSlotType() { + return EquipmentSlot.CHEST; + } + + @Override + public TypedActionResult use(World world, PlayerEntity user, Hand hand) { + return this.equipAndSwap(this, world, user, hand); + } + + public void extractEnergy(ItemStack stack, boolean simulate) { + long energyStored = getStoredEnergy(stack); + long energyExtracted = Math.min(energyStored, energyCost); + if (!simulate) { + setStoredEnergy(stack, energyStored - energyExtracted); + } + } + + public double addToVerticalVelocity(double velocityY) { + return Math.min(velocityY + (0.1*flightPower), (0.25*flightPower)); + } + + public float getFlightSpeed() { + return flightSpeed; + } + + public int getEnergyCost() { + return energyCost; + } +} diff --git a/src/main/java/konhaiii/powered_jetpacks/packet/JetpackPacket.java b/src/main/java/konhaiii/powered_jetpacks/packet/JetpackPacket.java new file mode 100644 index 0000000..1369646 --- /dev/null +++ b/src/main/java/konhaiii/powered_jetpacks/packet/JetpackPacket.java @@ -0,0 +1,93 @@ +package konhaiii.powered_jetpacks.packet; + +import dev.emi.trinkets.api.TrinketsApi; +import konhaiii.powered_jetpacks.PoweredJetpacks; +import konhaiii.powered_jetpacks.item.special.JetpackItem; +import konhaiii.powered_jetpacks.sounds.ModSounds; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.sound.SoundCategory; +import net.minecraft.util.Identifier; +import net.minecraft.util.Pair; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +public record JetpackPacket(boolean shouldPlaySound) { + private static final Identifier PACKET_ID = new Identifier(PoweredJetpacks.MOD_ID, "jetpack_packet"); + + public static void encode(JetpackPacket packet, PacketByteBuf buf) { + buf.writeBoolean(packet.shouldPlaySound); + } + + public static JetpackPacket decode(PacketByteBuf buf) { + return new JetpackPacket(buf.readBoolean()); + } + + public static void handle(ServerPlayerEntity player, JetpackPacket packet) { + ItemStack chestStack = player.getEquippedStack(EquipmentSlot.CHEST); + + ItemStack backStack = TrinketsApi.getTrinketComponent(player).map(component -> + component.getEquipped(stack -> stack.getItem() instanceof JetpackItem) + .stream() + .findFirst() + .map(Pair::getRight) + .orElse(ItemStack.EMPTY) + ).orElse(ItemStack.EMPTY); + ItemStack jetpackStack = null; + if (isValidJetpack(chestStack)) { + jetpackStack = chestStack; + } else if (isValidJetpack(backStack)) { + jetpackStack = backStack; + } + + if (jetpackStack != null) { + JetpackItem jetpack = (JetpackItem) jetpackStack.getItem(); + player.fallDistance = 0; + + World world = player.getWorld(); + BlockPos blockPos = player.getBlockPos(); + + if (packet.shouldPlaySound()) { + if (!world.isClient) { + world.playSound(null, blockPos, ModSounds.JETPACK_SOUND, SoundCategory.PLAYERS, 1f, 1f); + } + } + + Vec3d lookVec = player.getRotationVector(); + double offsetBack = -0.25; + double offsetSide = 0.2; + double centerX = player.getX() + lookVec.x * offsetBack; + double centerY = player.getY() + 0.75; + double centerZ = player.getZ() + lookVec.z * offsetBack; + double leftX = centerX + lookVec.z * offsetSide; + double leftZ = centerZ - lookVec.x * offsetSide; + double rightX = centerX - lookVec.z * offsetSide; + double rightZ = centerZ + lookVec.x * offsetSide; + ((ServerWorld) world).spawnParticles(ParticleTypes.FLAME, leftX, centerY, leftZ,1,0,0,0,0.1); + ((ServerWorld) world).spawnParticles(ParticleTypes.SMOKE, leftX, centerY, leftZ,1,0,0,0,0.1); + ((ServerWorld) world).spawnParticles(ParticleTypes.FLAME, rightX, centerY, rightZ,1,0,0,0,0.1); + ((ServerWorld) world).spawnParticles(ParticleTypes.SMOKE, rightX, centerY, rightZ,1,0,0,0,0.1); + + jetpack.extractEnergy(jetpackStack, false); + } + } + + private static boolean isValidJetpack(ItemStack stack) { + if (stack.getItem() instanceof JetpackItem jetpack) { + if (jetpack.getEnergyCost() <= 0) { + return true; + } + return jetpack.getStoredEnergy(stack) > 0; + } + return false; + } + + public static Identifier getPacketId() { + return PACKET_ID; + } +} \ No newline at end of file diff --git a/src/main/java/konhaiii/powered_jetpacks/sounds/ModSounds.java b/src/main/java/konhaiii/powered_jetpacks/sounds/ModSounds.java new file mode 100644 index 0000000..e36b8b5 --- /dev/null +++ b/src/main/java/konhaiii/powered_jetpacks/sounds/ModSounds.java @@ -0,0 +1,19 @@ +package konhaiii.powered_jetpacks.sounds; + +import konhaiii.powered_jetpacks.PoweredJetpacks; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.sound.SoundEvent; +import net.minecraft.util.Identifier; + +public class ModSounds { + public static final SoundEvent JETPACK_SOUND = registerSoundEvent(); + + private static SoundEvent registerSoundEvent() { + Identifier id = new Identifier(PoweredJetpacks.MOD_ID, "jetpack_use"); + return Registry.register(Registries.SOUND_EVENT, id, SoundEvent.of(id)); + } + + public static void initialize() { + } +} \ No newline at end of file diff --git a/src/main/resources/assets/powered_jetpacks/icon.png b/src/main/resources/assets/powered_jetpacks/icon.png new file mode 100644 index 0000000..0cf6f70 Binary files /dev/null and b/src/main/resources/assets/powered_jetpacks/icon.png differ diff --git a/src/main/resources/assets/powered_jetpacks/lang/en_us.json b/src/main/resources/assets/powered_jetpacks/lang/en_us.json new file mode 100644 index 0000000..5ed0d48 --- /dev/null +++ b/src/main/resources/assets/powered_jetpacks/lang/en_us.json @@ -0,0 +1,12 @@ +{ + "item.powered_jetpacks.basic_jetpack": "Basic Jetpack", + "item.powered_jetpacks.advanced_jetpack": "Advanced Jetpack", + "item.powered_jetpacks.industrial_jetpack": "Industrial Jetpack", + "itemGroup.powered_jetpacks": "Powered Jetpacks", + "tooltip.powered_jetpacks.energy_meter": "%s/%s", + "tooltip.powered_jetpacks.power_charged": "Charged", + "tooltip.powered_jetpacks.input_rate": "Input Rate", + "tooltip.powered_jetpacks.output_rate": "Output Rate", + "tooltip.powered_jetpacks.transfer_rate": "Transfer Rate", + "hud.powered_jetpacks.jetpack_power": "Jetpack Power: " +} \ No newline at end of file diff --git a/src/main/resources/assets/powered_jetpacks/models/item/advanced_jetpack.json b/src/main/resources/assets/powered_jetpacks/models/item/advanced_jetpack.json new file mode 100644 index 0000000..5bbbabf --- /dev/null +++ b/src/main/resources/assets/powered_jetpacks/models/item/advanced_jetpack.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "powered_jetpacks:item/advanced_jetpack" + } +} diff --git a/src/main/resources/assets/powered_jetpacks/models/item/basic_jetpack.json b/src/main/resources/assets/powered_jetpacks/models/item/basic_jetpack.json new file mode 100644 index 0000000..dfe8720 --- /dev/null +++ b/src/main/resources/assets/powered_jetpacks/models/item/basic_jetpack.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "powered_jetpacks:item/basic_jetpack" + } +} diff --git a/src/main/resources/assets/powered_jetpacks/models/item/industrial_jetpack.json b/src/main/resources/assets/powered_jetpacks/models/item/industrial_jetpack.json new file mode 100644 index 0000000..ba5ba27 --- /dev/null +++ b/src/main/resources/assets/powered_jetpacks/models/item/industrial_jetpack.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "powered_jetpacks:item/industrial_jetpack" + } +} diff --git a/src/main/resources/assets/powered_jetpacks/sounds.json b/src/main/resources/assets/powered_jetpacks/sounds.json new file mode 100644 index 0000000..4a5da12 --- /dev/null +++ b/src/main/resources/assets/powered_jetpacks/sounds.json @@ -0,0 +1,5 @@ +{ + "jetpack_use": { + "sounds": ["powered_jetpacks:jetpack_use"] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/powered_jetpacks/sounds/jetpack_use.ogg b/src/main/resources/assets/powered_jetpacks/sounds/jetpack_use.ogg new file mode 100644 index 0000000..c7b6b59 Binary files /dev/null and b/src/main/resources/assets/powered_jetpacks/sounds/jetpack_use.ogg differ diff --git a/src/main/resources/assets/powered_jetpacks/textures/item/advanced_jetpack.png b/src/main/resources/assets/powered_jetpacks/textures/item/advanced_jetpack.png new file mode 100644 index 0000000..8506006 Binary files /dev/null and b/src/main/resources/assets/powered_jetpacks/textures/item/advanced_jetpack.png differ diff --git a/src/main/resources/assets/powered_jetpacks/textures/item/basic_jetpack.png b/src/main/resources/assets/powered_jetpacks/textures/item/basic_jetpack.png new file mode 100644 index 0000000..5be3acc Binary files /dev/null and b/src/main/resources/assets/powered_jetpacks/textures/item/basic_jetpack.png differ diff --git a/src/main/resources/assets/powered_jetpacks/textures/item/industrial_jetpack.png b/src/main/resources/assets/powered_jetpacks/textures/item/industrial_jetpack.png new file mode 100644 index 0000000..8476e9f Binary files /dev/null and b/src/main/resources/assets/powered_jetpacks/textures/item/industrial_jetpack.png differ diff --git a/src/main/resources/assets/powered_jetpacks/textures/jetpack/advanced_jetpack.png b/src/main/resources/assets/powered_jetpacks/textures/jetpack/advanced_jetpack.png new file mode 100644 index 0000000..155acad Binary files /dev/null and b/src/main/resources/assets/powered_jetpacks/textures/jetpack/advanced_jetpack.png differ diff --git a/src/main/resources/assets/powered_jetpacks/textures/jetpack/basic_jetpack.png b/src/main/resources/assets/powered_jetpacks/textures/jetpack/basic_jetpack.png new file mode 100644 index 0000000..29ff6e8 Binary files /dev/null and b/src/main/resources/assets/powered_jetpacks/textures/jetpack/basic_jetpack.png differ diff --git a/src/main/resources/assets/powered_jetpacks/textures/jetpack/industrial_jetpack.png b/src/main/resources/assets/powered_jetpacks/textures/jetpack/industrial_jetpack.png new file mode 100644 index 0000000..a0d5917 Binary files /dev/null and b/src/main/resources/assets/powered_jetpacks/textures/jetpack/industrial_jetpack.png differ diff --git a/src/main/resources/data/powered_jetpacks/advancements/recipes/transportation/advanced_jetpack.json b/src/main/resources/data/powered_jetpacks/advancements/recipes/transportation/advanced_jetpack.json new file mode 100644 index 0000000..50a5fca --- /dev/null +++ b/src/main/resources/data/powered_jetpacks/advancements/recipes/transportation/advanced_jetpack.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_redstone": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:redstone" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "powered_jetpacks:advanced_jetpack" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_redstone", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "powered_jetpacks:advanced_jetpack" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/src/main/resources/data/powered_jetpacks/advancements/recipes/transportation/basic_jetpack.json b/src/main/resources/data/powered_jetpacks/advancements/recipes/transportation/basic_jetpack.json new file mode 100644 index 0000000..06e4adf --- /dev/null +++ b/src/main/resources/data/powered_jetpacks/advancements/recipes/transportation/basic_jetpack.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_redstone": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:redstone" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "powered_jetpacks:basic_jetpack" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_redstone", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "powered_jetpacks:basic_jetpack" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/src/main/resources/data/powered_jetpacks/advancements/recipes/transportation/industrial_jetpack.json b/src/main/resources/data/powered_jetpacks/advancements/recipes/transportation/industrial_jetpack.json new file mode 100644 index 0000000..e800c05 --- /dev/null +++ b/src/main/resources/data/powered_jetpacks/advancements/recipes/transportation/industrial_jetpack.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_redstone": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:redstone" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "powered_jetpacks:industrial_jetpack" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_redstone", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "powered_jetpacks:industrial_jetpack" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/src/main/resources/data/powered_jetpacks/recipes/advanced_jetpack.json b/src/main/resources/data/powered_jetpacks/recipes/advanced_jetpack.json new file mode 100644 index 0000000..e3cb0c0 --- /dev/null +++ b/src/main/resources/data/powered_jetpacks/recipes/advanced_jetpack.json @@ -0,0 +1,27 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "I": { + "item": "minecraft:gold_ingot" + }, + "L": { + "item": "minecraft:leather" + }, + "R": { + "item": "minecraft:redstone" + }, + "B": { + "item": "minecraft:gold_block" + } + }, + "pattern": [ + "RIR", + "BLB", + "I I" + ], + "result": { + "item": "powered_jetpacks:advanced_jetpack" + }, + "show_notification": true +} \ No newline at end of file diff --git a/src/main/resources/data/powered_jetpacks/recipes/basic_jetpack.json b/src/main/resources/data/powered_jetpacks/recipes/basic_jetpack.json new file mode 100644 index 0000000..eb4f284 --- /dev/null +++ b/src/main/resources/data/powered_jetpacks/recipes/basic_jetpack.json @@ -0,0 +1,27 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "I": { + "item": "minecraft:iron_ingot" + }, + "L": { + "item": "minecraft:leather" + }, + "R": { + "item": "minecraft:redstone" + }, + "B": { + "item": "minecraft:iron_block" + } + }, + "pattern": [ + "RIR", + "BLB", + "I I" + ], + "result": { + "item": "powered_jetpacks:basic_jetpack" + }, + "show_notification": true +} \ No newline at end of file diff --git a/src/main/resources/data/powered_jetpacks/recipes/industrial_jetpack.json b/src/main/resources/data/powered_jetpacks/recipes/industrial_jetpack.json new file mode 100644 index 0000000..eaee1ba --- /dev/null +++ b/src/main/resources/data/powered_jetpacks/recipes/industrial_jetpack.json @@ -0,0 +1,27 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "I": { + "item": "minecraft:diamond" + }, + "L": { + "item": "minecraft:leather" + }, + "R": { + "item": "minecraft:redstone" + }, + "B": { + "item": "minecraft:diamond_block" + } + }, + "pattern": [ + "RIR", + "BLB", + "I I" + ], + "result": { + "item": "powered_jetpacks:industrial_jetpack" + }, + "show_notification": true +} \ No newline at end of file diff --git a/src/main/resources/data/trinkets/entities/powered_jetpacks.json b/src/main/resources/data/trinkets/entities/powered_jetpacks.json new file mode 100644 index 0000000..290fa98 --- /dev/null +++ b/src/main/resources/data/trinkets/entities/powered_jetpacks.json @@ -0,0 +1,8 @@ +{ + "entities": [ + "player" + ], + "slots": [ + "chest/back" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/trinkets/tags/items/chest/back.json b/src/main/resources/data/trinkets/tags/items/chest/back.json new file mode 100644 index 0000000..5b3ceee --- /dev/null +++ b/src/main/resources/data/trinkets/tags/items/chest/back.json @@ -0,0 +1,8 @@ +{ + "replace": false, + "values": [ + "powered_jetpacks:basic_jetpack", + "powered_jetpacks:advanced_jetpack", + "powered_jetpacks:industrial_jetpack" + ] +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..c380fe5 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,41 @@ +{ + "schemaVersion": 1, + "id": "powered_jetpacks", + "version": "${version}", + "name": "Powered Jetpacks", + "description": "Add energy-powered jetpacks to Minecraft.", + "authors": [ + "Konhaiii" + ], + "contact": { + "homepage": "https://fabricmc.net/", + "sources": "https://github.com/FabricMC/fabric-example-mod" + }, + "license": "CC0-1.0", + "icon": "assets/powered_jetpacks/icon.png", + "environment": "*", + "entrypoints": { + "main": [ + "konhaiii.powered_jetpacks.PoweredJetpacks" + ], + "client": [ + "konhaiii.powered_jetpacks.PoweredJetpacksClient" + ] + }, + "mixins": [ + "powered_jetpacks.mixins.json", + { + "config": "powered_jetpacks.client.mixins.json", + "environment": "client" + } + ], + "depends": { + "fabricloader": ">=0.16.14", + "minecraft": "~1.20.1", + "java": ">=17", + "fabric-api": "*" + }, + "suggests": { + "another-mod": "*" + } +} \ No newline at end of file diff --git a/src/main/resources/powered_jetpacks.mixins.json b/src/main/resources/powered_jetpacks.mixins.json new file mode 100644 index 0000000..018e476 --- /dev/null +++ b/src/main/resources/powered_jetpacks.mixins.json @@ -0,0 +1,9 @@ +{ + "required": true, + "package": "konhaiii.powered_jetpacks.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file