diff --git a/.editorconfig b/.editorconfig index ccc1595..f9d6551 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,26 +4,18 @@ root = true charset = utf-8 end_of_line = lf insert_final_newline = true -tab_width = 4 +indent_style = space +indent_size = 4 trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false -[*.gradle] -indent_style = tab - -[*.java] -indent_style = tab - [*.json] -indent_style = space indent_size = 2 -[fabric.mod.json] -indent_style = tab -tab_width = 2 +[*.yml] +indent_size = 2 [*.properties] -indent_style = space -indent_size = 2 +indent_size = 2 \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..eaeceee --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +* text=auto eol=lf +gradlew text eol=lf +*.bat text eol=crlf +*.cmd text eol=crlf +gradle-wrapper.jar -text -diff -merge -filter \ No newline at end of file diff --git a/.gitignore b/.gitignore index e75a605..dc6e0de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ .gradle/ .idea/ +.vscode/ +bin/ build/ out/ run/ run-server/ +.PVS-Studio diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 76306b5..0000000 --- a/build.gradle +++ /dev/null @@ -1,177 +0,0 @@ -plugins { - id 'maven-publish' - id 'fabric-loom' version '1.10.0-bta' - id 'java' -} - -import org.gradle.internal.os.OperatingSystem - -project.ext.lwjglVersion = "3.3.3" - -switch (OperatingSystem.current()) { - case OperatingSystem.LINUX: - project.ext.lwjglNatives = "natives-linux" - break - case OperatingSystem.WINDOWS: - project.ext.lwjglNatives = "natives-windows" - break - case OperatingSystem.MAC_OS: - project.ext.lwjglNatives = "natives-macos" -} - -group = project.mod_group -archivesBaseName = project.mod_name -version = project.mod_version - -loom { - noIntermediateMappings() - customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${project.bta_channel}/v${project.bta_version}/manifest.json") -} - -repositories { - mavenCentral() - maven { url = "https://jitpack.io" } - maven { - name = 'Babric' - url = 'https://maven.glass-launcher.net/babric' - } - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - maven { - name = 'SignalumMavenInfrastructure' - url = 'https://maven.thesignalumproject.net/infrastructure' - } - maven { - name = 'SignalumMavenReleases' - url = 'https://maven.thesignalumproject.net/releases' - } - ivy { - url = "https://github.com/Better-than-Adventure" - patternLayout { - artifact "[organisation]/releases/download/v[revision]/[module].jar" - m2compatible = true - } - metadataSources { artifact() } - } - ivy { - url = "https://downloads.betterthanadventure.net/bta-client/${project.bta_channel}/" - patternLayout { - artifact "/v[revision]/client.jar" - m2compatible = true - } - metadataSources { artifact() } - } - ivy { - url = "https://downloads.betterthanadventure.net/bta-server/${project.bta_channel}/" - patternLayout { - artifact "/v[revision]/server.jar" - m2compatible = true - } - metadataSources { artifact() } - } - ivy { - url = "https://piston-data.mojang.com" - patternLayout { - artifact "v1/[organisation]/[revision]/[module].jar" - m2compatible = true - } - metadataSources { artifact() } - } - -} - -dependencies { - minecraft "::${project.bta_version}" - mappings loom.layered() {} - - modRuntimeOnly "objects:client:43db9b498cb67058d2e12d394e6507722e71bb45" // https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - - // Helper library - // If you do not need Halplibe you can comment this line out or delete this line - modImplementation("turniplabs:halplibe:${project.halplibe_version}") - modImplementation("turniplabs:modmenu-bta:${project.mod_menu_version}") - - implementation "useless:btabackpacks:1.1.10-7.3_03" - - implementation "org.slf4j:slf4j-api:1.8.0-beta4" - implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0" - - implementation 'com.google.guava:guava:33.0.0-jre' - implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1' - var log4jVersion = "2.20.0" - implementation("org.apache.logging.log4j:log4j-core:${log4jVersion}") - implementation("org.apache.logging.log4j:log4j-api:${log4jVersion}") - implementation("org.apache.logging.log4j:log4j-1.2-api:${log4jVersion}") - - include(implementation("org.apache.commons:commons-lang3:3.12.0")) - - modImplementation("com.github.Better-than-Adventure:legacy-lwjgl3:1.0.5") - implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion") - - runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives" - runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives" - runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives" - runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives" - runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives" - runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives" - implementation "org.lwjgl:lwjgl:$lwjglVersion" - implementation "org.lwjgl:lwjgl-assimp:$lwjglVersion" - implementation "org.lwjgl:lwjgl-glfw:$lwjglVersion" - implementation "org.lwjgl:lwjgl-openal:$lwjglVersion" - implementation "org.lwjgl:lwjgl-opengl:$lwjglVersion" - implementation "org.lwjgl:lwjgl-stb:$lwjglVersion" -} - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - withSourcesJar() -} - -tasks.withType(JavaCompile).configureEach { - options.release.set 8 -} - -jar { - from("LICENSE") { - rename { "${it}_${archivesBaseName}" } - } -} - -configurations.configureEach { - // Removes LWJGL2 dependencies - exclude group: "org.lwjgl.lwjgl" -} - -processResources { - inputs.property "version", version - - filesMatching("fabric.mod.json") { - expand "version": version - } -} - -publishing { - repositories { - maven { - name = "signalumMaven" - url = "https://maven.thesignalumproject.net/releases" - credentials(PasswordCredentials) - authentication { - basic(BasicAuthentication) - } - } - } - - publications { - maven(MavenPublication) { - groupId = project.mod_group - artifactId = project.mod_name - version = project.mod_version - from components.java - } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..91c61d9 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,160 @@ +import com.smushytaco.lwjgl_gradle.Preset +plugins { + alias(libs.plugins.loom) + alias(libs.plugins.lwjgl) + java +} +val modVersion = providers.gradleProperty("mod_version") +val modGroup = providers.gradleProperty("mod_group") +val modName = providers.gradleProperty("mod_name") + +val javaVersion = libs.versions.java.map { it.toInt() } + +base.archivesName = modName +group = modGroup.get() +version = modVersion.get() +loom { + customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${libs.versions.btaChannel.get()}/v${libs.versions.bta.get()}/manifest.json") +} +repositories { + mavenCentral() + maven("https://jitpack.io") + maven("https://maven.fabricmc.net/") { name = "Fabric" } + maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" } + maven("https://maven.thesignalumproject.net/releases") { name = "SignalumMavenReleases" } + ivy("https://github.com/Better-than-Adventure") { + patternLayout { artifact("[organisation]/releases/download/v[revision]/[module].jar") } + metadataSources { artifact() } + } + ivy("https://downloads.betterthanadventure.net/bta-client/${libs.versions.btaChannel.get()}/") { + patternLayout { artifact("/v[revision]/client.jar") } + metadataSources { artifact() } + } + ivy("https://downloads.betterthanadventure.net/bta-server/${libs.versions.btaChannel.get()}/") { + patternLayout { artifact("/v[revision]/server.jar") } + metadataSources { artifact() } + } + ivy("https://piston-data.mojang.com") { + patternLayout { artifact("v1/[organisation]/[revision]/[module].jar") } + metadataSources { artifact() } + } + ivy("https://github.com/") { + patternLayout { artifact("v1/[organisation]/[revision]/[module].jar") } + metadataSources { artifact() } + } + ivy("https://github.com/") { + patternLayout { artifact("[organization]/[module]/releases/download/[revision]/[module]-[revision].jar") } + metadataSources { artifact() } + } + repositories { + exclusiveContent { + forRepository { + maven("https://api.modrinth.com/maven") { name = "Modrinth" } + } + filter { includeGroup("maven.modrinth") } + } + } +} +lwjgl { + version = libs.versions.lwjgl + implementation(Preset.MINIMAL_OPENGL) +} +dependencies { + minecraft("::${libs.versions.bta.get()}") + + runtimeOnly(libs.clientJar) + implementation(libs.loader) + implementation(libs.halplibe) + implementation(libs.modMenu) + implementation(libs.legacyLwjgl) + + compileOnly(libs.dragonfly) + + compileOnly(libs.catalyst.core) + compileOnly(libs.catalyst.effects) + + compileOnly(libs.uselessNumerical.get().let { "${it.group}:${it.name}:${it.version}-${libs.versions.bta.get()}" }) + + compileOnly(libs.btwaila) + compileOnly(libs.commandly) + + compileOnly(libs.deep) + + compileOnly(libs.backpacks) + + compileOnly(libs.aether) + + implementation(libs.slf4jApi) + implementation(libs.guava) + implementation(libs.log4j.slf4j2.impl) + implementation(libs.log4j.core) + implementation(libs.log4j.api) + implementation(libs.log4j.api12) + implementation(libs.gson) + + implementation(libs.commonsLang3) + include(libs.commonsLang3) +} +java { + toolchain { + languageVersion = javaVersion.map { JavaLanguageVersion.of(it) } + vendor = JvmVendorSpec.ADOPTIUM + } + sourceCompatibility = JavaVersion.toVersion(javaVersion.get()) + targetCompatibility = JavaVersion.toVersion(javaVersion.get()) + withSourcesJar() +} +val licenseFile = run { + val rootLicense = layout.projectDirectory.file("LICENSE") + val parentLicense = layout.projectDirectory.file("../LICENSE") + when { + rootLicense.asFile.exists() -> { + logger.lifecycle("Using LICENSE from project root: {}", rootLicense.asFile) + rootLicense + } + parentLicense.asFile.exists() -> { + logger.lifecycle("Using LICENSE from parent directory: {}", parentLicense.asFile) + parentLicense + } + else -> { + logger.warn("No LICENSE file found in project or parent directory.") + null + } + } +} +tasks { + withType().configureEach { + options.encoding = "UTF-8" + sourceCompatibility = javaVersion.get().toString() + targetCompatibility = javaVersion.get().toString() + if (javaVersion.get() > 8) options.release = javaVersion + } + named("updateDaemonJvm") { + languageVersion = libs.versions.gradleJava.map { JavaLanguageVersion.of(it.toInt()) } + vendor = JvmVendorSpec.ADOPTIUM + } + withType().configureEach { defaultCharacterEncoding = "UTF-8" } + withType().configureEach { options.encoding = "UTF-8" } + withType().configureEach { defaultCharacterEncoding = "UTF-8" } + withType().configureEach { + licenseFile?.let { + from(it) { + rename { original -> "${original}_${archiveBaseName.get()}" } + } + } + } + processResources { + val resourceMap = mapOf( + "version" to modVersion.get(), + "fabricloader" to libs.versions.loader.get(), + "halplibe" to libs.versions.halplibe.get(), + "java" to libs.versions.java.get(), + "modmenu" to libs.versions.modMenu.get() + ) + inputs.properties(resourceMap) + filesMatching("fabric.mod.json") { expand(resourceMap) } + filesMatching("**/*.mixins.json") { expand(resourceMap.filterKeys { it == "java" }) } + } +} +// Removes LWJGL2 dependencies +configurations.configureEach { exclude(group = "org.lwjgl.lwjgl") } diff --git a/gradle.properties b/gradle.properties index 94b9234..40d6a30 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,20 +1,18 @@ -org.gradle.jvmargs=-Xmx2G -org.gradle.parallel = true -org.gradle.daemon = true -fabric.loom.multiProjectOptimisation=true - -# BTA -bta_version=7.3_03 -bta_channel=release - -# Loader -loader_version=0.15.6-bta.7 - -# Other Mods -mod_menu_version=3.0.0 -halplibe_version=5.2.4 - -# Mod -mod_version=1.1.0-7.3_03 +########################################################################## +# Standard Properties +org.gradle.jvmargs = -Xmx2G +org.gradle.warning.mode = all +# This currently has to be set to false because the "Minecraft Client" and "Minecraft Server" configurations generated +# by IntelliJ aren't currently compatible with the configuration cache. If you use the runClient and runServer Gradle +# tasks instead, then this can (and should) be set to true. +org.gradle.configuration-cache = false +########################################################################## +# Mod Properties +mod_version=1.2.0-7.3_04 mod_group=useless mod_name=moonsteel +########################################################################## +# Plugin Dependency +# Check this on https://plugins.gradle.org/plugin/org.gradle.toolchains.foojay-resolver-convention/ +foojay_resolver_version = 1.0.0 +########################################################################## diff --git a/gradle/gradle-daemon-jvm.properties b/gradle/gradle-daemon-jvm.properties new file mode 100644 index 0000000..e409a46 --- /dev/null +++ b/gradle/gradle-daemon-jvm.properties @@ -0,0 +1,13 @@ +#This file is generated by updateDaemonJvm +toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect +toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect +toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect +toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect +toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/46949723aaa20c7b64d7ecfed7207034/redirect +toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d6690dfd71c4c91e08577437b5b2beb0/redirect +toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect +toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect +toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3cd7045fca9a72cd9bc7d14a385e594c/redirect +toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/552c7bffe0370c66410a51c55985b511/redirect +toolchainVendor=ADOPTIUM +toolchainVersion=21 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..7e9f1ca --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,89 @@ +[versions] +########################################################################## +# Plugins +# Check this on https://github.com/FabricMC/fabric-loom/releases/latest/ +loom = "1.14-SNAPSHOT" +# Check this on https://plugins.gradle.org/plugin/com.smushytaco.lwjgl3/ +lwjglPlugin = "1.0.0" +########################################################################## +# Java Configuration +# The Java version the JDK will be for compiling and running code. +java = "8" +# The Java version the JDK will be for running Gradle. +gradleJava = "21" +########################################################################## +# Mod Dependencies +# Check this on https://downloads.betterthanadventure.net/bta-client/ +bta = "7.3_04" +# Options are release, prerelease, nightly, and misc. +btaChannel = "release" +# Check this on https://maven.thesignalumproject.net/#/infrastructure/net/fabricmc/fabric-loader/ +loader = "0.18.1-bta.9" +# Check this on https://github.com/Turnip-Labs/ModMenu/releases/latest/ +modMenu = "4.0.0" +# Check this on https://github.com/Turnip-Labs/bta-halplibe/releases/latest/ +halplibe = "5.3.3" +# Check this on https://github.com/Better-than-Adventure/legacy-lwjgl3/releases/latest/ +legacyLwjgl = "1.0.6" +# Check this on https://maven.thesignalumproject.net/#/releases/sunsetsatellite/catalyst-core/ +catalyst-core = "2.2.0" +# Check this on https://maven.thesignalumproject.net/#/releases/sunsetsatellite/catalyst-effects/ +catalyst-effects = "2.5.3" +# Check this on https://maven.thesignalumproject.net/#/releases/useless/btwaila/ +btwaila = "1.2.2-7.3_04" +# Check this on https://modrinth.com/mod/bta-uselessnumerical/versions/ +uselessNumerical = "1.1.0" +# Check this on https://maven.thesignalumproject.net/#/releases/useless/dragonfly/ +dragonfly = "1.7.0-alpha.7" +# Check this on https://github.com/Redart15/Commandly/releases/ +commandly = "1.1.3+7.3_04" +# Check this on https://github.com/bta-team-port/better-with-aether/releases +aether = "0.14.0+7.3_04" +# Check this on https://modrinth.com/mod/deepbta +deep = "1.5.1" +# Check this on https://modrinth.com/mod/better-with-backpacks +backpacks = "1.1.10-7.3_03" +########################################################################## +# Dependencies +# Check this on https://central.sonatype.com/artifact/org.slf4j/slf4j-api/ +slf4jApi = "2.0.17" +# Check this on https://central.sonatype.com/artifact/com.google.guava/guava/ +guava = "33.5.0-jre" +# Check this on https://central.sonatype.com/artifact/org.apache.logging.log4j/log4j-api/ +log4j = "2.20.0" +# Check this on https://central.sonatype.com/artifact/com.google.code.gson/gson/ +gson = "2.13.2" +# Check this on https://central.sonatype.com/artifact/org.apache.commons/commons-lang3/ +commonsLang3 = "3.20.0" +# This should match the version used by the current BTA release. +lwjgl = "3.3.3" +########################################################################## + +[libraries] +loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "loader" } +halplibe = { group = "turniplabs", name = "halplibe", version.ref = "halplibe" } +modMenu = { group = "turniplabs", name = "modmenu-bta", version.ref = "modMenu" } +legacyLwjgl = { group = "com.github.Better-than-Adventure", name = "legacy-lwjgl3", version.ref = "legacyLwjgl" } +dragonfly = { group = "useless", name = "dragonfly", version.ref = "dragonfly" } +catalyst-core = { group = "sunsetsatellite", name = "catalyst-core", version.ref = "catalyst-core" } +catalyst-effects = { group = "sunsetsatellite", name = "catalyst-effects", version.ref = "catalyst-effects" } +uselessNumerical = { group = "gungun974", name = "uselessnumerical", version.ref = "uselessNumerical" } +btwaila = { group = "useless", name = "btwaila", version.ref = "btwaila" } +commandly = { group = "redart15", name = "Commandly", version.ref = "commandly" } +backpacks = { group = "maven.modrinth", name = "better-with-backpacks", version.ref = "backpacks" } +aether = { group = "maven.modrinth", name = "better-with-aether-bta", version.ref = "aether" } +deep = { group = "maven.modrinth", name = "deepbta", version.ref = "deep" } +slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4jApi" } +guava = { group = "com.google.guava", name = "guava", version.ref = "guava" } +log4j-slf4j2-impl = { group = "org.apache.logging.log4j", name = "log4j-slf4j2-impl", version.ref = "log4j" } +log4j-core = { group = "org.apache.logging.log4j", name = "log4j-core", version.ref = "log4j" } +log4j-api = { group = "org.apache.logging.log4j", name = "log4j-api", version.ref = "log4j" } +log4j-api12 = { group = "org.apache.logging.log4j", name = "log4j-1.2-api", version.ref = "log4j" } +gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" } +commonsLang3 = { group = "org.apache.commons", name = "commons-lang3", version.ref = "commonsLang3" } +# https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar +clientJar = { group = "objects", name = "client", version = "43db9b498cb67058d2e12d394e6507722e71bb45" } + +[plugins] +loom = { id = "net.fabricmc.fabric-loom", version.ref = "loom" } +lwjgl = { id = "com.smushytaco.lwjgl3", version.ref = "lwjglPlugin" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d6e308a..4eac4a8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-all.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 744e882..adff685 100644 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015 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. @@ -15,81 +15,114 @@ # 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 UN*X -## +# +# 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 -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +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 -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# 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"' +# 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" +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 - ;; +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" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +131,118 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + 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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +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 -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -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" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + 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 - i=`expr $i + 1` + # 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 - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# 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, 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" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# 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 index 107acd3..c4bdd3a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @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 +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +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 @@ -56,32 +59,33 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +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 %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +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! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +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 diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 8b12c9d..0000000 --- a/settings.gradle +++ /dev/null @@ -1,21 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - maven { - name = 'Jitpack' - url = 'https://jitpack.io' - } - maven { - name = 'Babric' - url = 'https://maven.glass-launcher.net/babric' - } - maven { - name = 'SignalumMavenInfrastructure' - url = 'https://maven.thesignalumproject.net/infrastructure' - } - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..1a7446a --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,60 @@ +val modName = providers.gradleProperty("mod_name") +rootProject.name = modName.get() +pluginManagement { + fun isRepoHealthy(url: String): Boolean { + var connection: javax.net.ssl.HttpsURLConnection? = null + return try { + connection = java.net.URI(url).toURL().openConnection() as javax.net.ssl.HttpsURLConnection + connection.requestMethod = "HEAD" + connection.connectTimeout = 2000 + connection.readTimeout = 2000 + connection.instanceFollowRedirects = true + connection.connect() + val code = connection.responseCode + code in 200..399 + } catch (_: Exception) { + false + } finally { + connection?.disconnect() + } + } + fun repoUrlWithFallbacks(candidates: List): String { + if (candidates.isEmpty()) { + val badLink = "https://mock.httpstatus.io/500" + logger.error("No repositories have been provided. Defaulting to: {}", badLink) + return badLink + } + val chosenRepository = candidates.firstOrNull { isRepoHealthy(it) } ?: run { + if (candidates.size == 1) { + logger.error("\"{}\" could not be resolved.", candidates.first()) + } else { + logger.error("All {} repositories could not be resolved. Defaulting to: {}", candidates.size, candidates.first()) + } + return candidates.first() + } + logger.lifecycle("Using \"{}\" as the Fabric repository.", chosenRepository) + return chosenRepository + } + repositories { + maven( + repoUrlWithFallbacks( + listOf( + "https://maven.fabricmc.net", + "https://maven2.fabricmc.net", + "https://maven3.fabricmc.net" + ) + ) + ) { name = "Fabric" } + maven("https://jitpack.io") { name = "Jitpack" } + maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" } + mavenCentral() + gradlePluginPortal() + } + val foojayResolverVersion = providers.gradleProperty("foojay_resolver_version") + plugins { + id("org.gradle.toolchains.foojay-resolver-convention").version(foojayResolverVersion.get()) + } +} +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") +} diff --git a/src/main/java/useless/moonsteel/BackpackProxy.java b/src/main/java/useless/moonsteel/BackpackProxy.java deleted file mode 100644 index 7d052a2..0000000 --- a/src/main/java/useless/moonsteel/BackpackProxy.java +++ /dev/null @@ -1,10 +0,0 @@ -package useless.moonsteel; - -import net.minecraft.core.item.Item; -import useless.moonsteel.item.ItemStarBackpack; - -public class BackpackProxy { - public static Item proxyBackpack(final String name, final String namespaceId, final int id) { - return new ItemStarBackpack(name, namespaceId, id); - } -} diff --git a/src/main/java/useless/moonsteel/ContainerStarBackpack.java b/src/main/java/useless/moonsteel/ContainerStarBackpack.java deleted file mode 100644 index 47a7d42..0000000 --- a/src/main/java/useless/moonsteel/ContainerStarBackpack.java +++ /dev/null @@ -1,73 +0,0 @@ -package useless.moonsteel; - -import net.minecraft.core.InventoryAction; -import net.minecraft.core.entity.player.Player; -import net.minecraft.core.player.inventory.menu.MenuAbstract; -import net.minecraft.core.player.inventory.slot.Slot; -import useless.moonsteel.interfaces.IStarBackpack; - -import java.util.List; - -public class ContainerStarBackpack extends MenuAbstract { - public StarBackpackInventory backpackInventory; - public ContainerStarBackpack(final Player player) { - this.backpackInventory = ((IStarBackpack)player).moonsteel$getStarBackpackInventory(); - final int slotsNum = this.backpackInventory.getContainerSize(); - final int rows = (int)Math.ceil((double)slotsNum / 9.0); - - for(int i = 0; i < rows; ++i) { - int width = 9; - if (i == rows - 1) { - width = slotsNum - 9 * i; - } - - for(int k = 0; k < width; ++k) { - this.addSlot(new SlotStarBackpack(this.backpackInventory, k + i * 9, 8 + k * 18, 18 + 18 * i)); - } - } - - for(int i = 0; i < 3; ++i) { - for(int k = 0; k < 9; ++k) { - this.addSlot(new Slot(player.inventory, k + i * 9 + 9, 8 + k * 18, 84 + i * 18)); - } - } - - for(int j = 0; j < 9; ++j) { - this.addSlot(new Slot(player.inventory, j, 8 + j * 18, 142)); - } - } - - @Override - public List getMoveSlots(final InventoryAction inventoryAction, final Slot slot, final int i, final Player entityPlayer) { - final int chestSize = this.backpackInventory.getContainerSize(); - if (slot.index >= 0 && slot.index < chestSize) { - return this.getSlots(0, chestSize, false); - } else { - if (inventoryAction == InventoryAction.MOVE_ALL) { - if (slot.index >= chestSize && slot.index < chestSize + 27) { - return this.getSlots(chestSize, 27, false); - } - - if (slot.index >= chestSize + 27 && slot.index < chestSize + 36) { - return this.getSlots(chestSize + 27, 9, false); - } - } else if (slot.index >= chestSize && slot.index < chestSize + 36) { - return this.getSlots(chestSize, 36, false); - } - - return null; - } - } - - @Override - public List getTargetSlots(final InventoryAction inventoryAction, final Slot slot, final int i, final Player entityPlayer) { - final int chestSize = this.backpackInventory.getContainerSize(); - return slot.index < chestSize ? this.getSlots(chestSize, 36, true) : this.getSlots(0, chestSize, false); - } - - @Override - public boolean stillValid(final Player entityPlayer) { - return this.backpackInventory.stillValid(entityPlayer); - } - -} diff --git a/src/main/java/useless/moonsteel/GuiStarBackpack.java b/src/main/java/useless/moonsteel/GuiStarBackpack.java deleted file mode 100644 index 5f91553..0000000 --- a/src/main/java/useless/moonsteel/GuiStarBackpack.java +++ /dev/null @@ -1,46 +0,0 @@ -package useless.moonsteel; - -import net.minecraft.client.gui.container.ScreenContainerAbstract; -import net.minecraft.core.entity.player.Player; -import net.minecraft.core.lang.I18n; -import org.lwjgl.opengl.GL11; -import tosutosu.betterwithbackpacks.BetterWithBackpacks; - -public class GuiStarBackpack extends ScreenContainerAbstract { - private int GUIx; - private int GUIy; - private int rows; - private int slotsNum; - private final ContainerStarBackpack backpack; - public GuiStarBackpack(Player player) { - super(new ContainerStarBackpack(player)); - backpack = (ContainerStarBackpack) inventorySlots; - } - - public void init() { - this.GUIx = (this.width - this.xSize) / 2; - this.GUIy = (this.height - this.ySize) / 2; - this.slotsNum = this.backpack.backpackInventory.getContainerSize(); - this.rows = (int)Math.ceil((double)this.slotsNum / 9.0); - super.init(); - } - - protected void drawGuiContainerForegroundLayer() { - this.font.drawString(I18n.getInstance().translateKey(this.backpack.backpackInventory.getNameTranslationKey()), 8, 6, BetterWithBackpacks.GUI_LABEL_COLOR); - this.font.drawString("Inventory", 8, this.ySize - 96 + 2, BetterWithBackpacks.GUI_LABEL_COLOR); - } - - protected void drawGuiContainerBackgroundLayer(float f) { - GL11.glColor3d(1.0, 1.0, 1.0); - this.mc.textureManager.loadTexture("/assets/betterwithbackpacks/gui/backpack.png").bind(); - this.drawTexturedModalRect(this.GUIx, this.GUIy, 0, 0, this.xSize, this.ySize); - - for(int i = 0; i < this.rows; ++i) { - if (i == this.rows - 1) { - this.drawTexturedModalRect(this.GUIx + 7, this.GUIy + 17 + 18 * i, 0, 166, 18 * (this.slotsNum - 9 * i), 18); - } else { - this.drawTexturedModalRect(this.GUIx + 7, this.GUIy + 17 + 18 * i, 0, 166, 162, 18); - } - } - } -} diff --git a/src/main/java/useless/moonsteel/MoonSteel.java b/src/main/java/useless/moonsteel/MoonSteel.java index dda0a95..cf4d5cb 100644 --- a/src/main/java/useless/moonsteel/MoonSteel.java +++ b/src/main/java/useless/moonsteel/MoonSteel.java @@ -8,8 +8,6 @@ import net.minecraft.core.world.World; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import tosutosu.betterwithbackpacks.ModItems; -import turniplabs.halplibe.helper.CreativeHelper; import turniplabs.halplibe.helper.EntityHelper; import turniplabs.halplibe.util.ConfigHandler; import turniplabs.halplibe.util.GameStartEntrypoint; @@ -17,63 +15,61 @@ import java.util.Properties; - public class MoonSteel implements ModInitializer, GameStartEntrypoint { public static final String MOD_ID = "moonsteel"; public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); - public static boolean backpackPresent = FabricLoader.getInstance().isModLoaded("betterwithbackpacks"); - public static int blockId; - public static int itemId; - public static int GUI_ID; - public static int FORTUNE_AMOUNT; - public static int LOOTING_AMOUNT; - public static int STAR_SPAWN_RATE; - static { - final Properties prop = new Properties(); - prop.setProperty("starting_block_id","6700"); - prop.setProperty("starting_item_id","21400"); - prop.setProperty("gui_backpack_id","20"); - prop.setProperty("fortune_amount","3"); - prop.setProperty("looting_amount","3"); - prop.setProperty("star_spawn_rate","7500"); - final ConfigHandler config = new ConfigHandler(MOD_ID,prop); + public static boolean backpackPresent = FabricLoader.getInstance().isModLoaded("betterwithbackpacks"); + public static int blockId; + public static int itemId; + public static int GUI_ID; + public static int FORTUNE_AMOUNT; + public static int LOOTING_AMOUNT; + public static int STAR_SPAWN_RATE; + + static { + final Properties prop = new Properties(); + prop.setProperty("starting_block_id", "6700"); + prop.setProperty("starting_item_id", "21400"); + prop.setProperty("gui_backpack_id", "20"); + prop.setProperty("fortune_amount", "3"); + prop.setProperty("looting_amount", "3"); + prop.setProperty("star_spawn_rate", "7500"); + final ConfigHandler config = new ConfigHandler(MOD_ID, prop); - blockId = config.getInt("starting_block_id"); - itemId = config.getInt("starting_item_id"); - GUI_ID = config.getInt("gui_backpack_id"); - FORTUNE_AMOUNT = config.getInt("fortune_amount"); - LOOTING_AMOUNT = config.getInt("looting_amount"); - STAR_SPAWN_RATE=config.getInt("star_spawn_rate"); + blockId = config.getInt("starting_block_id"); + itemId = config.getInt("starting_item_id"); + GUI_ID = config.getInt("gui_backpack_id"); + FORTUNE_AMOUNT = config.getInt("fortune_amount"); + LOOTING_AMOUNT = config.getInt("looting_amount"); + STAR_SPAWN_RATE = config.getInt("star_spawn_rate"); - config.updateConfig(); - } + config.updateConfig(); + } + + public static ItemStack starZombieSword; + public static boolean forceChunkLoads = false; - public static ItemStack starZombieSword; - public static boolean forceChunkLoads = false; @Override public void onInitialize() { LOGGER.info("MoonSteel initialized."); } - @Override - public void beforeGameStart() { - SoundTypes.loadSoundsJson(MOD_ID); - EntityHelper.createTileEntity(TileEntityStellarRewinder.class, NamespaceID.getPermanent(MOD_ID, "moonsteel$stellar_rewinder"), "moonsteel$stellar_rewinder"); - MoonSteelBlocks.init(); - MoonSteelItems.init(); - if (backpackPresent){ - CreativeHelper.setParent(MoonSteelItems.BACKPACK_COSMIC.getDefaultStack(), ModItems.diamondBackpack.getDefaultStack()); - } - } + @Override + public void beforeGameStart() { + SoundTypes.loadSoundsJson(MOD_ID); + EntityHelper.createTileEntity(TileEntityStellarRewinder.class, NamespaceID.getPermanent(MOD_ID, "moonsteel$stellar_rewinder"), "moonsteel$stellar_rewinder"); + MoonSteelBlocks.init(); + MoonSteelItems.init(); + } - @Override - public void afterGameStart() { + @Override + public void afterGameStart() { - } + } - public static boolean isStarTime(final World world){ - if (world.worldType.hasCeiling()) return false; - if (world.isDaytime()) return false; - return world.getWorldTime() % 2000 <= 200; - } + public static boolean isStarTime(final World world) { + if (world.worldType.hasCeiling()) return false; + if (world.isDaytime()) return false; + return world.getWorldTime() % 2000 <= 200; + } } diff --git a/src/main/java/useless/moonsteel/MoonSteelBlocks.java b/src/main/java/useless/moonsteel/MoonSteelBlocks.java index e5715d2..c65341e 100644 --- a/src/main/java/useless/moonsteel/MoonSteelBlocks.java +++ b/src/main/java/useless/moonsteel/MoonSteelBlocks.java @@ -1,60 +1,62 @@ package useless.moonsteel; -import net.minecraft.core.block.Block; -import net.minecraft.core.block.BlockLogic; -import net.minecraft.core.block.BlockLogicLeavesBase; -import net.minecraft.core.block.BlockLogicOreCoal; -import net.minecraft.core.block.BlockLogicOreDiamond; -import net.minecraft.core.block.BlockLogicOreGold; -import net.minecraft.core.block.BlockLogicOreIron; -import net.minecraft.core.block.BlockLogicOreLapis; -import net.minecraft.core.block.BlockLogicOreNetherCoal; -import net.minecraft.core.block.BlockLogicOreRedstone; -import net.minecraft.core.block.BlockLogicTallGrass; +import net.minecraft.core.block.*; import net.minecraft.core.block.material.Material; import net.minecraft.core.block.tag.BlockTags; import net.minecraft.core.data.tag.Tag; +import silveon22.deep.block.ore.*; import turniplabs.halplibe.helper.BlockBuilder; import useless.moonsteel.block.BlockStellarRewinder; import useless.moonsteel.block.BlockTorchStar; import static useless.moonsteel.MoonSteel.MOD_ID; +import static useless.moonsteel.compat.deep.MoonSteelDeepCompatibility.IS_DEEP_LOADED; public class MoonSteelBlocks { - public static Block BLOCK_MOONSTEEL = new BlockBuilder(MOD_ID) - .setHardness(5f) - .setResistance(2000f) - .addTags(BlockTags.MINEABLE_BY_PICKAXE) - .build("block", "block_moonsteel", MoonSteel.blockId++, b -> new BlockLogic(b, Material.metal)); - public static Block TORCH_STAR = new BlockBuilder(MOD_ID) - .setLuminance(15) - .build("torch.star", "torch_star", MoonSteel.blockId++,BlockTorchStar::new) - .withDisabledNeighborNotifyOnMetadataChange(); - public static Block STELLAR_REWINDER = new BlockBuilder(MOD_ID) - .setHardness(3.5f) - .addTags(BlockTags.MINEABLE_BY_PICKAXE) - .build("stellar.rewinder", "stellar_rewinder", MoonSteel.blockId++, b -> new BlockStellarRewinder(b, Material.metal)) - .withImmovableFlagSet(); - - - public static Tag> FORCE_FORTUNE = Tag.of("moonsteel$force_enable_fortune"); - public static Tag> FORCE_NO_FORTUNE = Tag.of("moonsteel$force_disable_fortune"); - public static boolean canBeFortuned(Block block){ - if (block.hasTag(FORCE_FORTUNE)) return true; - if (block.hasTag(FORCE_NO_FORTUNE)) return false; - if (Block.hasLogicClass(block, BlockLogicLeavesBase.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreCoal.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreDiamond.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreGold.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreIron.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreLapis.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreNetherCoal.class)) return true; - if (Block.hasLogicClass(block, BlockLogicOreRedstone.class)) return true; - if (Block.hasLogicClass(block, BlockLogicTallGrass.class)) return true; - return false; - } - - public static void init() { - - } + public static Block BLOCK_MOONSTEEL = new BlockBuilder(MOD_ID) + .setHardness(5f) + .setResistance(2000f) + .addTags(BlockTags.MINEABLE_BY_PICKAXE) + .build("block", "block_moonsteel", MoonSteel.blockId++, b -> new BlockLogic(b, Material.metal)); + public static Block TORCH_STAR = new BlockBuilder(MOD_ID) + .setLuminance(15) + .build("torch.star", "torch_star", MoonSteel.blockId++, BlockTorchStar::new) + .withDisabledNeighborNotifyOnMetadataChange(); + public static Block STELLAR_REWINDER = new BlockBuilder(MOD_ID) + .setHardness(3.5f) + .addTags(BlockTags.MINEABLE_BY_PICKAXE) + .build("stellar.rewinder", "stellar_rewinder", MoonSteel.blockId++, b -> new BlockStellarRewinder(b, Material.metal)) + .withImmovableFlagSet(); + + + public static Tag> FORCE_FORTUNE = Tag.of("moonsteel$force_enable_fortune"); + public static Tag> FORCE_NO_FORTUNE = Tag.of("moonsteel$force_disable_fortune"); + + public static boolean canBeFortuned(Block block) { + if (block.hasTag(FORCE_FORTUNE)) return true; + if (block.hasTag(FORCE_NO_FORTUNE)) return false; + if (Block.hasLogicClass(block, BlockLogicLeavesBase.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreCoal.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreDiamond.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreGold.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreIron.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreLapis.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreNetherCoal.class)) return true; + if (Block.hasLogicClass(block, BlockLogicOreRedstone.class)) return true; + if (IS_DEEP_LOADED) { + if (Block.hasLogicClass(block, BlockLogicAmethystOre.class)) return true; + if (Block.hasLogicClass(block, BlockLogicBismuthOre.class)) return true; + if (Block.hasLogicClass(block, BlockLogicLeadOre.class)) return true; + if (Block.hasLogicClass(block, BlockLogicMagnetOre.class)) return true; + if (Block.hasLogicClass(block, BlockLogicRhodoniteOre.class)) return true; + if (Block.hasLogicClass(block, BlockLogicSilverOre.class)) return true; + if (Block.hasLogicClass(block, BlockLogicTopazOre.class)) return true; + if (Block.hasLogicClass(block, BlockLogicUraniumOre.class)) return true; + } + return Block.hasLogicClass(block, BlockLogicTallGrass.class); + } + + public static void init() { + + } } diff --git a/src/main/java/useless/moonsteel/MoonSteelClient.java b/src/main/java/useless/moonsteel/MoonSteelClient.java index 77a747f..2e4dc05 100644 --- a/src/main/java/useless/moonsteel/MoonSteelClient.java +++ b/src/main/java/useless/moonsteel/MoonSteelClient.java @@ -14,21 +14,21 @@ import static useless.moonsteel.MoonSteel.MOD_ID; public class MoonSteelClient implements ClientStartEntrypoint { - @Override - public void beforeClientStart() { - for (final AtlasStitcher stitcher : TextureRegistry.stitcherMap.values()) { - try { - TextureRegistry.initializeAllFiles(MOD_ID, stitcher, true); - } catch (URISyntaxException | IOException e) { - MoonSteel.LOGGER.error("Failed to initialize texture files!", e); - } - } - SoundRepository.registerNamespace(MOD_ID); - } + @Override + public void beforeClientStart() { + for (final AtlasStitcher stitcher : TextureRegistry.stitcherMap.values()) { + try { + TextureRegistry.initializeAllFiles(MOD_ID, stitcher, true); + } catch (URISyntaxException | IOException e) { + MoonSteel.LOGGER.error("Failed to initialize texture files!", e); + } + } + SoundRepository.registerNamespace(MOD_ID); + } - @Override - public void afterClientStart() { - ParticleDispatcher.getInstance().addDispatch("moonsteel$star", (world, x, y, z, motionX, motionY, motionZ, data) -> new ParticleStar(world, x, y, z, motionX, motionY, motionX)); - ParticleDispatcher.getInstance().addDispatch("moonsteel$magic_smoke", (world, x, y, z, motionX, motionY, motionZ, data) -> new ParticleMagicSmoke(world, x, y, z, motionX, motionY, motionX)); - } + @Override + public void afterClientStart() { + ParticleDispatcher.getInstance().addDispatch("moonsteel$star", (world, x, y, z, motionX, motionY, motionZ, data) -> new ParticleStar(world, x, y, z, motionX, motionY, motionX)); + ParticleDispatcher.getInstance().addDispatch("moonsteel$magic_smoke", (world, x, y, z, motionX, motionY, motionZ, data) -> new ParticleMagicSmoke(world, x, y, z, motionX, motionY, motionX)); + } } diff --git a/src/main/java/useless/moonsteel/MoonSteelItems.java b/src/main/java/useless/moonsteel/MoonSteelItems.java index 88b975e..ee2783f 100644 --- a/src/main/java/useless/moonsteel/MoonSteelItems.java +++ b/src/main/java/useless/moonsteel/MoonSteelItems.java @@ -6,11 +6,7 @@ import net.minecraft.core.item.material.ArmorMaterial; import net.minecraft.core.item.material.ToolMaterial; import net.minecraft.core.item.tag.ItemTags; -import net.minecraft.core.item.tool.ItemToolAxe; -import net.minecraft.core.item.tool.ItemToolHoe; -import net.minecraft.core.item.tool.ItemToolPickaxe; -import net.minecraft.core.item.tool.ItemToolShovel; -import net.minecraft.core.item.tool.ItemToolSword; +import net.minecraft.core.item.tool.*; import turniplabs.halplibe.helper.ArmorHelper; import turniplabs.halplibe.helper.ItemBuilder; import useless.moonsteel.item.ItemConnectedStar; @@ -18,49 +14,67 @@ import static useless.moonsteel.MoonSteel.MOD_ID; public class MoonSteelItems { - public static ToolMaterial moonSteelTool = new ToolMaterial().setDurability(1536).setEfficiency(7.0f, 14.0f).setMiningLevel(3).setDamage(2); - public static Item INGOT_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new Item("ingot.moonsteel", MOD_ID + ":item/ingot_moonsteel", MoonSteel.itemId++)); - public static Item INGOT_MOONSTEEL_CRUDE = new ItemBuilder(MOD_ID) - .build(new Item("crude.moonsteel", MOD_ID + ":item/ingot_moonsteel_crude", MoonSteel.itemId++)); - public static Item TOOL_PICKAXE_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemToolPickaxe("tool.pickaxe.moonsteel", MOD_ID + ":item/tool_pickaxe_moonsteel", MoonSteel.itemId++, moonSteelTool)); - public static Item TOOL_AXE_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemToolAxe("tool.axe.moonsteel", MOD_ID + ":item/tool_axe_moonsteel", MoonSteel.itemId++, moonSteelTool)); - public static Item TOOL_SHOVEL_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemToolShovel("tool.shovel.moonsteel", MOD_ID + ":item/tool_shovel_moonsteel", MoonSteel.itemId++, moonSteelTool)); - public static Item TOOL_HOE_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemToolHoe("tool.hoe.moonsteel", MOD_ID + ":item/tool_hoe_moonsteel", MoonSteel.itemId++, moonSteelTool)); - public static Item TOOL_SWORD_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemToolSword("tool.sword.moonsteel", MOD_ID + ":item/tool_sword_moonsteel", MoonSteel.itemId++, moonSteelTool)); - public static ArmorMaterial moonSteelArmor = ArmorHelper.createArmorMaterial(MOD_ID, "moonsteel", 800, 51f, 45f, 45f, 100f); - public static Item ARMOR_HELMET_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemArmor("helmet.moonsteel", MOD_ID + ":item/armor_helmet_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_HEAD)); - public static Item ARMOR_CHESTPLATE_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemArmor("chestplate.moonsteel", MOD_ID + ":item/armor_chestplate_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_CHEST)); - public static Item ARMOR_LEGGINGS_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemArmor("leggings.moonsteel", MOD_ID + ":item/armor_leggings_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_LEGS)); - public static Item ARMOR_BOOTS_MOONSTEEL = new ItemBuilder(MOD_ID) - .build(new ItemArmor("boots.moonsteel", MOD_ID + ":item/armor_boots_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_BOOTS)); - public static Item STAR_FALLEN = new ItemBuilder(MOD_ID) - .build(new Item("star.fallen", MOD_ID + ":item/star_fallen", MoonSteel.itemId++)); - public static Item STAR_CONNECTED = new ItemBuilder(MOD_ID) - .setStackSize(1) - .build(new ItemConnectedStar("star.connected", MOD_ID + ":item/star_connected", MoonSteel.itemId++)); - public static Item BACKPACK_COSMIC; + public static ToolMaterial moonSteelTool = new ToolMaterial().setDurability(1536).setEfficiency(7.0f, 14.0f).setMiningLevel(3).setDamage(2); + public static ArmorMaterial moonSteelArmor = ArmorHelper.createArmorMaterial(MOD_ID, "moonsteel", 800, 51f, 45f, 45f, 100f); - public static void init() { - MoonSteel.LOGGER.info("Backpacks present: {}", MoonSteel.backpackPresent); - if (MoonSteel.backpackPresent){ - BACKPACK_COSMIC = new ItemBuilder(MOD_ID) - .setStackSize(1) - .build( BackpackProxy.proxyBackpack("backpack.cosmic", MOD_ID + ":item/backpack_cosmic", MoonSteel.itemId++)); - } else { - BACKPACK_COSMIC = new ItemBuilder(MOD_ID) - .setStackSize(1) - .setTags(ItemTags.NOT_IN_CREATIVE_MENU) - .build(new Item("backpack.cosmic.missing", MOD_ID + ":item/backpack_cosmic", MoonSteel.itemId++)); - } - MoonSteel.starZombieSword = MoonSteelItems.TOOL_SWORD_MOONSTEEL.getDefaultStack(); - } + public static Item INGOT_MOONSTEEL; + public static Item INGOT_MOONSTEEL_CRUDE; + + public static Item TOOL_PICKAXE_MOONSTEEL; + public static Item TOOL_AXE_MOONSTEEL; + public static Item TOOL_SHOVEL_MOONSTEEL; + public static Item TOOL_HOE_MOONSTEEL; + public static Item TOOL_SWORD_MOONSTEEL; + + public static Item ARMOR_HELMET_MOONSTEEL; + public static Item ARMOR_CHESTPLATE_MOONSTEEL; + public static Item ARMOR_LEGGINGS_MOONSTEEL; + public static Item ARMOR_BOOTS_MOONSTEEL; + + public static Item STAR_FALLEN; + public static Item STAR_CONNECTED; + + private static boolean hasInit = false; + + public static void init() { + if (!hasInit) { + hasInit = true; + initializeItems(); + } + MoonSteel.starZombieSword = MoonSteelItems.TOOL_SWORD_MOONSTEEL.getDefaultStack(); + } + + public static void initializeItems() { + + + INGOT_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new Item("ingot.moonsteel", MOD_ID + ":item/ingot_moonsteel", MoonSteel.itemId++)); + INGOT_MOONSTEEL_CRUDE = new ItemBuilder(MOD_ID) + .build(new Item("crude.moonsteel", MOD_ID + ":item/ingot_moonsteel_crude", MoonSteel.itemId++)); + TOOL_PICKAXE_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemToolPickaxe("tool.pickaxe.moonsteel", MOD_ID + ":item/tool_pickaxe_moonsteel", MoonSteel.itemId++, moonSteelTool)); + TOOL_AXE_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemToolAxe("tool.axe.moonsteel", MOD_ID + ":item/tool_axe_moonsteel", MoonSteel.itemId++, moonSteelTool)); + TOOL_SHOVEL_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemToolShovel("tool.shovel.moonsteel", MOD_ID + ":item/tool_shovel_moonsteel", MoonSteel.itemId++, moonSteelTool)); + TOOL_HOE_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemToolHoe("tool.hoe.moonsteel", MOD_ID + ":item/tool_hoe_moonsteel", MoonSteel.itemId++, moonSteelTool)); + TOOL_SWORD_MOONSTEEL = new ItemBuilder(MOD_ID) + .setTags(ItemTags.PREVENT_CREATIVE_MINING) + .build(new ItemToolSword("tool.sword.moonsteel", MOD_ID + ":item/tool_sword_moonsteel", MoonSteel.itemId++, moonSteelTool)); + ARMOR_HELMET_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemArmor("helmet.moonsteel", MOD_ID + ":item/armor_helmet_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_HEAD)); + ARMOR_CHESTPLATE_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemArmor("chestplate.moonsteel", MOD_ID + ":item/armor_chestplate_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_CHEST)); + ARMOR_LEGGINGS_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemArmor("leggings.moonsteel", MOD_ID + ":item/armor_leggings_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_LEGS)); + ARMOR_BOOTS_MOONSTEEL = new ItemBuilder(MOD_ID) + .build(new ItemArmor("boots.moonsteel", MOD_ID + ":item/armor_boots_moonsteel", MoonSteel.itemId++, moonSteelArmor, IArmorItem.PIECE_BOOTS)); + STAR_FALLEN = new ItemBuilder(MOD_ID) + .build(new Item("star.fallen", MOD_ID + ":item/star_fallen", MoonSteel.itemId++)); + STAR_CONNECTED = new ItemBuilder(MOD_ID) + .setStackSize(1) + .build(new ItemConnectedStar("star.connected", MOD_ID + ":item/star_connected", MoonSteel.itemId++)); + + } } diff --git a/src/main/java/useless/moonsteel/MoonSteelMixinPlugin.java b/src/main/java/useless/moonsteel/MoonSteelMixinPlugin.java deleted file mode 100644 index e4a6e68..0000000 --- a/src/main/java/useless/moonsteel/MoonSteelMixinPlugin.java +++ /dev/null @@ -1,49 +0,0 @@ -package useless.moonsteel; - -import net.fabricmc.loader.api.FabricLoader; -import org.objectweb.asm.tree.ClassNode; -import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; - -import java.util.List; -import java.util.Set; -import java.util.function.Supplier; - -public class MoonSteelMixinPlugin implements IMixinConfigPlugin { - private static final Supplier BACKPACKS = () -> FabricLoader.getInstance().isModLoaded("betterwithbackpacks"); - @Override - public void onLoad(String mixinPackage) { - - } - - @Override - public String getRefMapperConfig() { - return null; - } - - @Override - public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - if (mixinClassName.startsWith("useless.moonsteel.mixin.backpack")) return BACKPACKS.get(); - return true; - } - - @Override - public void acceptTargets(Set myTargets, Set otherTargets) { - - } - - @Override - public List getMixins() { - return null; - } - - @Override - public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - - } - - @Override - public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - - } -} diff --git a/src/main/java/useless/moonsteel/MoonSteelModels.java b/src/main/java/useless/moonsteel/MoonSteelModels.java index fb446aa..e76a3c4 100644 --- a/src/main/java/useless/moonsteel/MoonSteelModels.java +++ b/src/main/java/useless/moonsteel/MoonSteelModels.java @@ -1,5 +1,7 @@ package useless.moonsteel; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.render.EntityRenderDispatcher; import net.minecraft.client.render.TileEntityRenderDispatcher; import net.minecraft.client.render.block.color.BlockColorDispatcher; @@ -19,70 +21,70 @@ import static useless.moonsteel.MoonSteel.MOD_ID; +@Environment(EnvType.CLIENT) public class MoonSteelModels implements ModelEntrypoint { - @Override - public void initBlockModels(final BlockModelDispatcher dispatcher) { - final Side[] S_TB = {Side.TOP, Side.BOTTOM}; - final Side[] S_SIDES = {Side.NORTH, Side.EAST, Side.SOUTH, Side.WEST}; - - dispatcher.addDispatch(new BlockModelStandard<>(MoonSteelBlocks.BLOCK_MOONSTEEL) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/moonsteel_block_side", S_SIDES) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/moonsteel_block_top", Side.TOP) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/moonsteel_block_bottom", Side.BOTTOM)); - - dispatcher.addDispatch(new BlockModelTorch<>(MoonSteelBlocks.TORCH_STAR) - .setAllTextures(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/startorch")); - - dispatcher.addDispatch(new BlockModelStellarRewinder<>(MoonSteelBlocks.STELLAR_REWINDER) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/stellarrewinder_side", Side.SOUTH, Side.WEST, Side.EAST) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/stellarrewinder_front", Side.NORTH) - .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/stellarrewinder_top", S_TB)); - } - - @Override - public void initItemModels(final ItemModelDispatcher dispatcher) { - dispatcher.addDispatch(makeModel(MoonSteelItems.INGOT_MOONSTEEL, "moonsteel_ingot")); - dispatcher.addDispatch(makeModel(MoonSteelItems.INGOT_MOONSTEEL_CRUDE, "moonsteel_crude")); - dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_PICKAXE_MOONSTEEL, "moonsteel_pickaxe").setFull3D()); - dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_AXE_MOONSTEEL, "moonsteel_axe").setFull3D()); - dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_SHOVEL_MOONSTEEL, "moonsteel_shovel").setFull3D()); - dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_HOE_MOONSTEEL, "moonsteel_hoe").setFull3D()); - dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_SWORD_MOONSTEEL, "moonsteel_sword").setFull3D()); - dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_HELMET_MOONSTEEL, "moonsteel_helmet")); - dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_CHESTPLATE_MOONSTEEL, "moonsteel_chestplate")); - dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_LEGGINGS_MOONSTEEL, "moonsteel_leggings")); - dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_BOOTS_MOONSTEEL, "moonsteel_boots")); - dispatcher.addDispatch(makeModel(MoonSteelItems.STAR_FALLEN, "fallen_star").setFullBright()); - dispatcher.addDispatch(setIcon(new ItemModelConnectStar(MoonSteelItems.STAR_CONNECTED, null), MOD_ID + ":item/connected_star_off").setFullBright()); - dispatcher.addDispatch(makeModel(MoonSteelItems.BACKPACK_COSMIC, "starpack")); - } - - public static @NotNull ItemModelStandard makeModel(@NotNull final Item item, @NotNull final String textureValue) { - return setIcon(new ItemModelStandard(item, null), NamespaceID.getTemp(MOD_ID, "item/" + textureValue)); - } - - public static @NotNull T setIcon(@NotNull final T model, @NotNull final String texture) { - model.icon = TextureRegistry.getTexture(texture); - return model; - } - - public static @NotNull T setIcon(@NotNull final T model, @NotNull final NamespaceID texture) { - model.icon = TextureRegistry.getTexture(texture); - return model; - } - - @Override - public void initEntityModels(final EntityRenderDispatcher dispatcher) { - - } - - @Override - public void initTileEntityModels(final TileEntityRenderDispatcher dispatcher) { - - } - - @Override - public void initBlockColors(final BlockColorDispatcher dispatcher) { - - } + @Override + public void initBlockModels(final BlockModelDispatcher dispatcher) { + final Side[] S_TB = {Side.TOP, Side.BOTTOM}; + final Side[] S_SIDES = {Side.NORTH, Side.EAST, Side.SOUTH, Side.WEST}; + + dispatcher.addDispatch(new BlockModelStandard<>(MoonSteelBlocks.BLOCK_MOONSTEEL) + .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/moonsteel_block_side", S_SIDES) + .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/moonsteel_block_top", Side.TOP) + .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/moonsteel_block_bottom", Side.BOTTOM)); + + dispatcher.addDispatch(new BlockModelTorch<>(MoonSteelBlocks.TORCH_STAR) + .setAllTextures(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/startorch")); + + dispatcher.addDispatch(new BlockModelStellarRewinder<>(MoonSteelBlocks.STELLAR_REWINDER) + .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/stellarrewinder_side", Side.SOUTH, Side.WEST, Side.EAST) + .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/stellarrewinder_front", Side.NORTH) + .setTex(BlockModelStandard.BLOCK_TEXTURES, MOD_ID + ":block/stellarrewinder_top", S_TB)); + } + + @Override + public void initItemModels(final ItemModelDispatcher dispatcher) { + dispatcher.addDispatch(makeModel(MoonSteelItems.INGOT_MOONSTEEL, "moonsteel_ingot")); + dispatcher.addDispatch(makeModel(MoonSteelItems.INGOT_MOONSTEEL_CRUDE, "moonsteel_crude")); + dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_PICKAXE_MOONSTEEL, "moonsteel_pickaxe").setFull3D()); + dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_AXE_MOONSTEEL, "moonsteel_axe").setFull3D()); + dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_SHOVEL_MOONSTEEL, "moonsteel_shovel").setFull3D()); + dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_HOE_MOONSTEEL, "moonsteel_hoe").setFull3D()); + dispatcher.addDispatch(makeModel(MoonSteelItems.TOOL_SWORD_MOONSTEEL, "moonsteel_sword").setFull3D()); + dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_HELMET_MOONSTEEL, "moonsteel_helmet")); + dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_CHESTPLATE_MOONSTEEL, "moonsteel_chestplate")); + dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_LEGGINGS_MOONSTEEL, "moonsteel_leggings")); + dispatcher.addDispatch(makeModel(MoonSteelItems.ARMOR_BOOTS_MOONSTEEL, "moonsteel_boots")); + dispatcher.addDispatch(makeModel(MoonSteelItems.STAR_FALLEN, "fallen_star").setFullBright()); + dispatcher.addDispatch(setIcon(new ItemModelConnectStar(MoonSteelItems.STAR_CONNECTED, null), MOD_ID + ":item/connected_star_off").setFullBright()); + } + + public static @NotNull ItemModelStandard makeModel(@NotNull final Item item, @NotNull final String textureValue) { + return setIcon(new ItemModelStandard(item, null), NamespaceID.getTemp(MOD_ID, "item/" + textureValue)); + } + + public static @NotNull T setIcon(@NotNull final T model, @NotNull final String texture) { + model.icon = TextureRegistry.getTexture(texture); + return model; + } + + public static @NotNull T setIcon(@NotNull final T model, @NotNull final NamespaceID texture) { + model.icon = TextureRegistry.getTexture(texture); + return model; + } + + @Override + public void initEntityModels(final EntityRenderDispatcher dispatcher) { + + } + + @Override + public void initTileEntityModels(final TileEntityRenderDispatcher dispatcher) { + + } + + @Override + public void initBlockColors(final BlockColorDispatcher dispatcher) { + + } } diff --git a/src/main/java/useless/moonsteel/MoonSteelRecipes.java b/src/main/java/useless/moonsteel/MoonSteelRecipes.java index 03c9d1d..4fb3c81 100644 --- a/src/main/java/useless/moonsteel/MoonSteelRecipes.java +++ b/src/main/java/useless/moonsteel/MoonSteelRecipes.java @@ -6,165 +6,157 @@ import net.minecraft.core.item.ItemStack; import net.minecraft.core.item.Items; import net.minecraft.core.util.helper.DyeColor; -import tosutosu.betterwithbackpacks.ModItems; import turniplabs.halplibe.helper.RecipeBuilder; import turniplabs.halplibe.util.RecipeEntrypoint; import static useless.moonsteel.MoonSteel.MOD_ID; public class MoonSteelRecipes implements RecipeEntrypoint { - @Override - public void onRecipesReady() { - LookupFuelFurnace.instance.addFuelEntry(MoonSteelItems.STAR_FALLEN.id, 9600); - LookupFuelFurnaceBlast.instance.addFuelEntry(MoonSteelItems.STAR_FALLEN.id, 9600); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - " F ", - "FSF", - " F ") - .addInput('F', MoonSteelItems.STAR_FALLEN) - .addInput('S', Items.INGOT_STEEL_CRUDE) - .create("raw_moonsteel", MoonSteelItems.INGOT_MOONSTEEL_CRUDE.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "M", - "M", - "S") - .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) - .addInput('S', Items.STICK) - .create("moonsteel_sword", MoonSteelItems.TOOL_SWORD_MOONSTEEL.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "MMM", - " S ", - " S ") - .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) - .addInput('S', Items.STICK) - .create("moonsteel_pickaxe", MoonSteelItems.TOOL_PICKAXE_MOONSTEEL.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "MM", - "MS", - " S") - .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) - .addInput('S', Items.STICK) - .create("moonsteel_axe", MoonSteelItems.TOOL_AXE_MOONSTEEL.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "M", - "S", - "S") - .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) - .addInput('S', Items.STICK) - .create("moonsteel_shovel", MoonSteelItems.TOOL_SHOVEL_MOONSTEEL.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "MM", - " S", - " S") - .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) - .addInput('S', Items.STICK) - .create("moonsteel_hoe", MoonSteelItems.TOOL_HOE_MOONSTEEL.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "MMM", - "M M", - " ") - .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) - .create("moonsteel_helmet", MoonSteelItems.ARMOR_HELMET_MOONSTEEL.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "M M", - "MMM", - "MMM") - .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) - .create("moonsteel_chestplate", MoonSteelItems.ARMOR_CHESTPLATE_MOONSTEEL.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "MMM", - "M M", - "M M") - .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) - .create("moonsteel_leggings", MoonSteelItems.ARMOR_LEGGINGS_MOONSTEEL.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "M M", - "M M", - " ") - .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) - .create("moonsteel_boots", MoonSteelItems.ARMOR_BOOTS_MOONSTEEL.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "MMM", - "MMM", - "MMM") - .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) - .create("block_of_moonsteel", MoonSteelBlocks.BLOCK_MOONSTEEL.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "F", - "S") - .addInput('F', MoonSteelItems.STAR_FALLEN) - .addInput('S', Items.STICK) - .create("stardust_torches", new ItemStack(MoonSteelBlocks.TORCH_STAR, 8)); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "DLD", - "LFL", - "DLD") - .addInput('F', MoonSteelItems.STAR_FALLEN) - .addInput('L', Items.DYE, DyeColor.BLUE.itemMeta) - .addInput('D', Items.DIAMOND) - .create("connected_star", MoonSteelItems.STAR_CONNECTED.getDefaultStack()); - - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "SSS", - "ICI", - "SSS") - .addInput('S', Items.INGOT_STEEL) - .addInput('I', Items.INGOT_IRON) - .addInput('C', MoonSteelItems.STAR_CONNECTED) - .create("stellar_rewinder", MoonSteelBlocks.STELLAR_REWINDER.getDefaultStack()); - - if (MoonSteel.backpackPresent){ - RecipeBuilder.Shaped(MOD_ID) - .setShape( - "MMM", - "MSM", - "MMM") - .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) - .addInput('S', ModItems.goldBackpack) - .create("cosmic_backpack", MoonSteelItems.BACKPACK_COSMIC.getDefaultStack()); - } - - RecipeBuilder.BlastFurnace(MOD_ID) - .setInput(MoonSteelItems.INGOT_MOONSTEEL_CRUDE) - .create("moonsteel", MoonSteelItems.INGOT_MOONSTEEL.getDefaultStack()); - - RecipeBuilder.Trommel(MOD_ID) - .setInput(MoonSteelItems.STAR_FALLEN) - .addEntry(new WeightedRandomLootObject(Items.COAL.getDefaultStack(), 1, 3), 14) - .addEntry(new WeightedRandomLootObject(Items.ORE_RAW_IRON.getDefaultStack(), 1), 5) - .addEntry(new WeightedRandomLootObject(Items.ORE_RAW_GOLD.getDefaultStack(), 1), 1) - .create("fallenstar"); - } - - @Override - public void initNamespaces() { - RecipeBuilder.initNameSpace(MOD_ID); - } + @Override + public void onRecipesReady() { + LookupFuelFurnace.instance.addFuelEntry(MoonSteelItems.STAR_FALLEN.id, 9600); + LookupFuelFurnaceBlast.instance.addFuelEntry(MoonSteelItems.STAR_FALLEN.id, 9600); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + " F ", + "FSF", + " F ") + .addInput('F', MoonSteelItems.STAR_FALLEN) + .addInput('S', Items.INGOT_STEEL_CRUDE) + .create("raw_moonsteel", MoonSteelItems.INGOT_MOONSTEEL_CRUDE.getDefaultStack()); + + RecipeBuilder.Shapeless(MOD_ID) + .addInput(MoonSteelBlocks.BLOCK_MOONSTEEL) + .create("block_of_moonsteel_to_moonsteel", new ItemStack(MoonSteelItems.INGOT_MOONSTEEL, 9)); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "M", + "M", + "S") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .addInput('S', Items.STICK) + .create("moonsteel_sword", MoonSteelItems.TOOL_SWORD_MOONSTEEL.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "MMM", + " S ", + " S ") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .addInput('S', Items.STICK) + .create("moonsteel_pickaxe", MoonSteelItems.TOOL_PICKAXE_MOONSTEEL.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "MM", + "MS", + " S") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .addInput('S', Items.STICK) + .create("moonsteel_axe", MoonSteelItems.TOOL_AXE_MOONSTEEL.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "M", + "S", + "S") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .addInput('S', Items.STICK) + .create("moonsteel_shovel", MoonSteelItems.TOOL_SHOVEL_MOONSTEEL.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "MM", + " S", + " S") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .addInput('S', Items.STICK) + .create("moonsteel_hoe", MoonSteelItems.TOOL_HOE_MOONSTEEL.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "MMM", + "M M", + " ") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .create("moonsteel_helmet", MoonSteelItems.ARMOR_HELMET_MOONSTEEL.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "M M", + "MMM", + "MMM") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .create("moonsteel_chestplate", MoonSteelItems.ARMOR_CHESTPLATE_MOONSTEEL.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "MMM", + "M M", + "M M") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .create("moonsteel_leggings", MoonSteelItems.ARMOR_LEGGINGS_MOONSTEEL.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "M M", + "M M", + " ") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .create("moonsteel_boots", MoonSteelItems.ARMOR_BOOTS_MOONSTEEL.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "MMM", + "MMM", + "MMM") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .create("block_of_moonsteel", MoonSteelBlocks.BLOCK_MOONSTEEL.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "F", + "S") + .addInput('F', MoonSteelItems.STAR_FALLEN) + .addInput('S', Items.STICK) + .create("stardust_torches", new ItemStack(MoonSteelBlocks.TORCH_STAR, 8)); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "DLD", + "LFL", + "DLD") + .addInput('F', MoonSteelItems.STAR_FALLEN) + .addInput('L', Items.DYE, DyeColor.BLUE.itemMeta) + .addInput('D', Items.DIAMOND) + .create("connected_star", MoonSteelItems.STAR_CONNECTED.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "SSS", + "ICI", + "SSS") + .addInput('S', Items.INGOT_STEEL) + .addInput('I', Items.INGOT_IRON) + .addInput('C', MoonSteelItems.STAR_CONNECTED) + .create("stellar_rewinder", MoonSteelBlocks.STELLAR_REWINDER.getDefaultStack()); + + RecipeBuilder.BlastFurnace(MOD_ID) + .setInput(MoonSteelItems.INGOT_MOONSTEEL_CRUDE) + .create("moonsteel", MoonSteelItems.INGOT_MOONSTEEL.getDefaultStack()); + + RecipeBuilder.Trommel(MOD_ID) + .setInput(MoonSteelItems.STAR_FALLEN) + .addEntry(new WeightedRandomLootObject(Items.COAL.getDefaultStack(), 1, 3), 14) + .addEntry(new WeightedRandomLootObject(Items.ORE_RAW_IRON.getDefaultStack(), 1), 5) + .addEntry(new WeightedRandomLootObject(Items.ORE_RAW_GOLD.getDefaultStack(), 1), 1) + .create("fallenstar"); + } + + @Override + public void initNamespaces() { + RecipeBuilder.initNameSpace(MOD_ID); + } } diff --git a/src/main/java/useless/moonsteel/SlotStarBackpack.java b/src/main/java/useless/moonsteel/SlotStarBackpack.java deleted file mode 100644 index 37ff236..0000000 --- a/src/main/java/useless/moonsteel/SlotStarBackpack.java +++ /dev/null @@ -1,16 +0,0 @@ -package useless.moonsteel; - -import net.minecraft.core.item.ItemStack; -import net.minecraft.core.player.inventory.container.Container; -import net.minecraft.core.player.inventory.slot.Slot; -import tosutosu.betterwithbackpacks.item.ItemBackpack; - -public class SlotStarBackpack extends Slot { - public SlotStarBackpack(Container inventory, int id, int x, int y) { - super(inventory, id, x, y); - } - public boolean mayPlace(ItemStack itemstack) { - return itemstack != null && !(itemstack.getItem() instanceof ItemBackpack) && !this.isLocked(); - } - -} diff --git a/src/main/java/useless/moonsteel/StarBackpackInventory.java b/src/main/java/useless/moonsteel/StarBackpackInventory.java deleted file mode 100644 index 0a2f95f..0000000 --- a/src/main/java/useless/moonsteel/StarBackpackInventory.java +++ /dev/null @@ -1,115 +0,0 @@ -package useless.moonsteel; - -import com.mojang.nbt.tags.CompoundTag; -import com.mojang.nbt.tags.ListTag; -import net.minecraft.core.entity.player.Player; -import net.minecraft.core.item.ItemStack; -import net.minecraft.core.player.inventory.InventorySorter; -import net.minecraft.core.player.inventory.container.Container; -import tosutosu.betterwithbackpacks.BetterWithBackpacks; - -public class StarBackpackInventory implements Container { - public static int starBackpackSize = 18; - protected ItemStack[] backpackItemStacks; - public Player player; - - public StarBackpackInventory(Player player) { - this.player = player; - this.backpackItemStacks = new ItemStack[starBackpackSize]; - } - - @Override - public int getContainerSize() { - return starBackpackSize; - } - - @Override - public ItemStack getItem(int i) { - return this.backpackItemStacks[i]; - } - - @Override - public ItemStack removeItem(int i, int j) { - if (this.backpackItemStacks[i] != null) { - if (this.backpackItemStacks[i].stackSize <= j) { - ItemStack itemstack = this.backpackItemStacks[i]; - this.backpackItemStacks[i] = null; - return itemstack; - } else { - ItemStack itemstack1 = this.backpackItemStacks[i].splitStack(j); - if (this.backpackItemStacks[i].stackSize <= 0) { - this.backpackItemStacks[i] = null; - } - - return itemstack1; - } - } else { - return null; - } - } - - @Override - public void setItem(int i, ItemStack itemStack) { - this.backpackItemStacks[i] = itemStack; - if (itemStack != null && itemStack.stackSize > this.getMaxStackSize()) { - itemStack.stackSize = this.getMaxStackSize(); - } - } - - @Override - public String getNameTranslationKey() { - return "moonsteel.container.backpack.star.name"; - } - - @Override - public int getMaxStackSize() { - return 64; - } - - @Override - public void setChanged() { - - } - - public void readFromNBT(ListTag tagList) { - this.backpackItemStacks = new ItemStack[this.getContainerSize()]; - - for(int i = 0; i < tagList.tagCount(); ++i) { - CompoundTag nbttagcompound1 = (CompoundTag)tagList.tagAt(i); - byte byte0 = nbttagcompound1.getByte("Slot"); - if (byte0 >= 0 && byte0 < this.backpackItemStacks.length) { - this.backpackItemStacks[byte0] = ItemStack.readItemStackFromNbt(nbttagcompound1); - } - } - } - - public ListTag writeToNBT(ListTag tagList) { - for(int i = 0; i < this.backpackItemStacks.length; ++i) { - if (this.backpackItemStacks[i] != null) { - CompoundTag nbttagcompound1 = new CompoundTag(); - nbttagcompound1.putByte("Slot", (byte)i); - this.backpackItemStacks[i].writeToNBT(nbttagcompound1); - tagList.addTag(nbttagcompound1); - } - } - - return tagList; - } - - @Override - public boolean stillValid(Player entityPlayer) { - if (!BetterWithBackpacks.ENABLE_BACKPACKS) { - return false; - } else if (entityPlayer.getHeldItem() == null) { - return false; - } else { - ItemStack heldItem = entityPlayer.getHeldItem(); - return heldItem.getItem() == MoonSteelItems.BACKPACK_COSMIC; - } - } - - @Override - public void sortContainer() { - InventorySorter.sortInventory(this.backpackItemStacks); - } -} diff --git a/src/main/java/useless/moonsteel/block/BlockModelStellarRewinder.java b/src/main/java/useless/moonsteel/block/BlockModelStellarRewinder.java index 6447bad..3f41835 100644 --- a/src/main/java/useless/moonsteel/block/BlockModelStellarRewinder.java +++ b/src/main/java/useless/moonsteel/block/BlockModelStellarRewinder.java @@ -10,18 +10,20 @@ import useless.moonsteel.MoonSteel; public class BlockModelStellarRewinder extends BlockModelHorizontalRotation { - private static IconCoordinate icon_front = TextureRegistry.getTexture(MoonSteel.MOD_ID + ":block/stellarrewinder_front"); - private static IconCoordinate icon_front_active = TextureRegistry.getTexture(MoonSteel.MOD_ID + ":block/stellarrewinder_front_active"); - public BlockModelStellarRewinder(Block block) { - super(block); - } - @Override - public IconCoordinate getBlockTexture(WorldSource blockAccess, int x, int y, int z, Side side) { - IconCoordinate iconCoordinate = super.getBlockTexture(blockAccess, x, y, z, side); - TileEntityStellarRewinder rewinder = (TileEntityStellarRewinder) blockAccess.getTileEntity(x,y,z); - if (rewinder.inUse && iconCoordinate == icon_front){ - iconCoordinate = icon_front_active; - } - return iconCoordinate; - } + private static final IconCoordinate icon_front = TextureRegistry.getTexture(MoonSteel.MOD_ID + ":block/stellarrewinder_front"); + private static final IconCoordinate icon_front_active = TextureRegistry.getTexture(MoonSteel.MOD_ID + ":block/stellarrewinder_front_active"); + + public BlockModelStellarRewinder(Block block) { + super(block); + } + + @Override + public IconCoordinate getBlockTexture(WorldSource blockAccess, int x, int y, int z, Side side) { + IconCoordinate iconCoordinate = super.getBlockTexture(blockAccess, x, y, z, side); + TileEntityStellarRewinder rewinder = (TileEntityStellarRewinder) blockAccess.getTileEntity(x, y, z); + if (rewinder.inUse && iconCoordinate == icon_front) { + iconCoordinate = icon_front_active; + } + return iconCoordinate; + } } diff --git a/src/main/java/useless/moonsteel/block/BlockStellarRewinder.java b/src/main/java/useless/moonsteel/block/BlockStellarRewinder.java index 2e5305a..dbceac7 100644 --- a/src/main/java/useless/moonsteel/block/BlockStellarRewinder.java +++ b/src/main/java/useless/moonsteel/block/BlockStellarRewinder.java @@ -10,20 +10,20 @@ import useless.moonsteel.MoonSteelItems; public class BlockStellarRewinder extends BlockLogicRotatable { - //Uses BlockTileEntityRotatable for its rotation properties not because its a tileEntity - public BlockStellarRewinder(Block block, Material material) { - super(block, material); - block.withEntity(TileEntityStellarRewinder::new); - } + //Uses BlockTileEntityRotatable for its rotation properties not because its a tileEntity + public BlockStellarRewinder(Block block, Material material) { + super(block, material); + block.withEntity(TileEntityStellarRewinder::new); + } - @Override - public boolean onBlockRightClicked(World world, int x, int y, int z, Player player, Side side, double xHit, double yHit) { - ItemStack heldItem = player.getHeldItem(); - TileEntityStellarRewinder rewinder = (TileEntityStellarRewinder) world.getTileEntity(x,y,z); - if (heldItem != null && heldItem.getItem() == MoonSteelItems.STAR_CONNECTED){ - rewinder.linkStar(heldItem); - return true; - } - return false; - } + @Override + public boolean onBlockRightClicked(World world, int x, int y, int z, Player player, Side side, double xHit, double yHit) { + ItemStack heldItem = player.getHeldItem(); + TileEntityStellarRewinder rewinder = (TileEntityStellarRewinder) world.getTileEntity(x, y, z); + if (heldItem != null && heldItem.getItem().equals(MoonSteelItems.STAR_CONNECTED)) { + rewinder.linkStar(heldItem); + return true; + } + return false; + } } diff --git a/src/main/java/useless/moonsteel/block/BlockTorchStar.java b/src/main/java/useless/moonsteel/block/BlockTorchStar.java index 2875086..0cc7b97 100644 --- a/src/main/java/useless/moonsteel/block/BlockTorchStar.java +++ b/src/main/java/useless/moonsteel/block/BlockTorchStar.java @@ -7,37 +7,38 @@ import java.util.Random; public class BlockTorchStar extends BlockLogicTorch { - public BlockTorchStar(final Block block) { - super(block); - } - @Override - public void animationTick(final World world, final int x, final int y, final int z, final Random rand) { - final double xPos = x + 0.5; - final double yPos = y + 0.575; - final double zPos = z + 0.5; - final double d3 = 0.22; - final double d4 = 0.27; - final int side = world.getBlockMetadata(x, y, z) & MASK_DIRECTION; - switch (side) { - case SIDE_WEST: - world.spawnParticle("moonsteel$magic_smoke", xPos - d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); - world.spawnParticle("moonsteel$star", xPos - d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); - break; - case SIDE_EAST: - world.spawnParticle("moonsteel$magic_smoke", xPos + d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); - world.spawnParticle("moonsteel$star", xPos + d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); - break; - case SIDE_NORTH: - world.spawnParticle("moonsteel$magic_smoke", xPos, yPos + d3, zPos - d4, 0.0F, 0.0F, 0.0F, 0); - world.spawnParticle("moonsteel$star", xPos, yPos + d3, zPos - d4, 0.0F, 0.0F, 0.0F, 0); - break; - case SIDE_SOUTH: - world.spawnParticle("moonsteel$magic_smoke", xPos, yPos + d3, zPos + d4, 0.0F, 0.0F, 0.0F, 0); - world.spawnParticle("moonsteel$star", xPos, yPos + d3, zPos + d4, 0.0F, 0.0F, 0.0F, 0); - break; - case SIDE_BOTTOM: - world.spawnParticle("moonsteel$magic_smoke", xPos, yPos, zPos, 0.0F, 0.0F, 0.0F, 0); - world.spawnParticle("moonsteel$star", xPos, yPos, zPos, 0.0F, 0.0F, 0.0F, 0); - } - } + public BlockTorchStar(final Block block) { + super(block); + } + + @Override + public void animationTick(final World world, final int x, final int y, final int z, final Random rand) { + final double xPos = x + 0.5; + final double yPos = y + 0.575; + final double zPos = z + 0.5; + final double d3 = 0.22; + final double d4 = 0.27; + final int side = world.getBlockMetadata(x, y, z) & MASK_DIRECTION; + switch (side) { + case SIDE_WEST: + world.spawnParticle("moonsteel$magic_smoke", xPos - d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); + world.spawnParticle("moonsteel$star", xPos - d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); + break; + case SIDE_EAST: + world.spawnParticle("moonsteel$magic_smoke", xPos + d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); + world.spawnParticle("moonsteel$star", xPos + d4, yPos + d3, zPos, 0.0F, 0.0F, 0.0F, 0); + break; + case SIDE_NORTH: + world.spawnParticle("moonsteel$magic_smoke", xPos, yPos + d3, zPos - d4, 0.0F, 0.0F, 0.0F, 0); + world.spawnParticle("moonsteel$star", xPos, yPos + d3, zPos - d4, 0.0F, 0.0F, 0.0F, 0); + break; + case SIDE_SOUTH: + world.spawnParticle("moonsteel$magic_smoke", xPos, yPos + d3, zPos + d4, 0.0F, 0.0F, 0.0F, 0); + world.spawnParticle("moonsteel$star", xPos, yPos + d3, zPos + d4, 0.0F, 0.0F, 0.0F, 0); + break; + case SIDE_BOTTOM: + world.spawnParticle("moonsteel$magic_smoke", xPos, yPos, zPos, 0.0F, 0.0F, 0.0F, 0); + world.spawnParticle("moonsteel$star", xPos, yPos, zPos, 0.0F, 0.0F, 0.0F, 0); + } + } } diff --git a/src/main/java/useless/moonsteel/block/TileEntityStellarRewinder.java b/src/main/java/useless/moonsteel/block/TileEntityStellarRewinder.java index 3b0cfb4..5a41391 100644 --- a/src/main/java/useless/moonsteel/block/TileEntityStellarRewinder.java +++ b/src/main/java/useless/moonsteel/block/TileEntityStellarRewinder.java @@ -8,60 +8,62 @@ import useless.moonsteel.MoonSteel; public class TileEntityStellarRewinder extends TileEntity { - public boolean inUse = false; - public long checkCode = 0; - public Side side = Side.NORTH; + public boolean inUse = false; + public long checkCode = 0; + public Side side = Side.NORTH; - public ItemStack linkStar(ItemStack stack){ - checkCode = worldObj.rand.nextLong(); - side = Side.getSideById(worldObj.getBlockMetadata(x, y, z)); - if (stack.getData().getBoolean("moonsteel$has_location")){ - int destX = stack.getData().getInteger("moonsteel$x"); - int destY = stack.getData().getInteger("moonsteel$y"); - int destZ = stack.getData().getInteger("moonsteel$z"); - MoonSteel.forceChunkLoads = true; - Chunk chunk = worldObj.getChunkProvider().provideChunk(destX >> 4, destZ >> 4); - MoonSteel.forceChunkLoads = false; - TileEntity te = chunk.getTileEntity(destX &0xF, destY, destZ &0xF); - if (te instanceof TileEntityStellarRewinder && ((TileEntityStellarRewinder) te).canTeleport(stack)){ - ((TileEntityStellarRewinder) te).setInUse(false); - } - } - stack.getData().putBoolean("moonsteel$has_location", true); - stack.getData().putInt("moonsteel$x", x ); - stack.getData().putInt("moonsteel$y", y ); - stack.getData().putInt("moonsteel$z", z ); - stack.getData().putInt("moonsteel$dimension", worldObj.dimension.id); - stack.getData().putLong("moonsteel$checkcode", checkCode); - setInUse(true); - return stack; - } - public boolean canTeleport(ItemStack stack){ - boolean can = true; - can &= stack.getData().getInteger("moonsteel$x") == x; - can &= stack.getData().getInteger("moonsteel$y") == y; - can &= stack.getData().getInteger("moonsteel$z") == z; - can &= stack.getData().getLong("moonsteel$checkcode") == checkCode; - return can; - } - public void setInUse(boolean flag){ - inUse = flag; - worldObj.notifyBlockChange(x, y, z, worldObj.getBlockId(x, y, z)); - } + public ItemStack linkStar(ItemStack stack) { + checkCode = worldObj.rand.nextLong(); + side = Side.getSideById(worldObj.getBlockMetadata(x, y, z)); + if (stack.getData().getBoolean("moonsteel$has_location")) { + int destX = stack.getData().getInteger("moonsteel$x"); + int destY = stack.getData().getInteger("moonsteel$y"); + int destZ = stack.getData().getInteger("moonsteel$z"); + MoonSteel.forceChunkLoads = true; + Chunk chunk = worldObj.getChunkProvider().provideChunk(destX >> 4, destZ >> 4); + MoonSteel.forceChunkLoads = false; + TileEntity te = chunk.getTileEntity(destX & 0xF, destY, destZ & 0xF); + if (te instanceof TileEntityStellarRewinder && ((TileEntityStellarRewinder) te).canTeleport(stack)) { + ((TileEntityStellarRewinder) te).setInUse(false); + } + } + stack.getData().putBoolean("moonsteel$has_location", true); + stack.getData().putInt("moonsteel$x", x); + stack.getData().putInt("moonsteel$y", y); + stack.getData().putInt("moonsteel$z", z); + stack.getData().putInt("moonsteel$dimension", worldObj.dimension.id); + stack.getData().putLong("moonsteel$checkcode", checkCode); + setInUse(true); + return stack; + } - @Override - public void readFromNBT(CompoundTag tag) { - super.readFromNBT(tag); - this.inUse = tag.getBoolean("inuse"); - this.checkCode = tag.getLong("checkcode"); - this.side = Side.getSideById(tag.getInteger("side")); - } + public boolean canTeleport(ItemStack stack) { + boolean can = true; + can &= stack.getData().getInteger("moonsteel$x") == x; + can &= stack.getData().getInteger("moonsteel$y") == y; + can &= stack.getData().getInteger("moonsteel$z") == z; + can &= stack.getData().getLong("moonsteel$checkcode") == checkCode; + return can; + } - @Override - public void writeToNBT(CompoundTag tag) { - super.writeToNBT(tag); - tag.putBoolean("inuse", inUse); - tag.putLong("checkcode", checkCode); - tag.putInt("side", side.getId()); - } + public void setInUse(boolean flag) { + inUse = flag; + worldObj.notifyBlockChange(x, y, z, worldObj.getBlockId(x, y, z)); + } + + @Override + public void readFromNBT(CompoundTag tag) { + super.readFromNBT(tag); + this.inUse = tag.getBoolean("inuse"); + this.checkCode = tag.getLong("checkcode"); + this.side = Side.getSideById(tag.getInteger("side")); + } + + @Override + public void writeToNBT(CompoundTag tag) { + super.writeToNBT(tag); + tag.putBoolean("inuse", inUse); + tag.putLong("checkcode", checkCode); + tag.putInt("side", side.getId()); + } } diff --git a/src/main/java/useless/moonsteel/compat/backpacks/ContainerStarBackpack.java b/src/main/java/useless/moonsteel/compat/backpacks/ContainerStarBackpack.java new file mode 100644 index 0000000..4a94ed7 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/ContainerStarBackpack.java @@ -0,0 +1,75 @@ +package useless.moonsteel.compat.backpacks; + +import net.minecraft.core.InventoryAction; +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.player.inventory.menu.MenuAbstract; +import net.minecraft.core.player.inventory.slot.Slot; +import useless.moonsteel.compat.backpacks.interfaces.IStarBackpack; + +import java.util.Collections; +import java.util.List; + +public class ContainerStarBackpack extends MenuAbstract { + public StarBackpackInventory backpackInventory; + + public ContainerStarBackpack(final Player player) { + this.backpackInventory = ((IStarBackpack) player).moonsteel$getStarBackpackInventory(); + final int slotsNum = this.backpackInventory.getContainerSize(); + final int rows = (int) Math.ceil(slotsNum / 9.0); + + for (int i = 0; i < rows; ++i) { + int width = 9; + if (i == rows - 1) { + width = slotsNum - 9 * i; + } + + for (int k = 0; k < width; ++k) { + this.addSlot(new SlotStarBackpack(this.backpackInventory, k + i * 9, 8 + k * 18, 18 + 18 * i)); + } + } + + for (int i = 0; i < 3; ++i) { + for (int k = 0; k < 9; ++k) { + this.addSlot(new Slot(player.inventory, k + i * 9 + 9, 8 + k * 18, 84 + i * 18)); + } + } + + for (int j = 0; j < 9; ++j) { + this.addSlot(new Slot(player.inventory, j, 8 + j * 18, 142)); + } + } + + @Override + public List getMoveSlots(final InventoryAction inventoryAction, final Slot slot, final int i, final Player entityPlayer) { + final int chestSize = this.backpackInventory.getContainerSize(); + if (slot.index >= 0 && slot.index < chestSize) { + return this.getSlots(0, chestSize, false); + } else { + if (inventoryAction == InventoryAction.MOVE_ALL) { + if (slot.index >= chestSize && slot.index < chestSize + 27) { + return this.getSlots(chestSize, 27, false); + } + + if (slot.index >= chestSize + 27 && slot.index < chestSize + 36) { + return this.getSlots(chestSize + 27, 9, false); + } + } else if (slot.index >= chestSize && slot.index < chestSize + 36) { + return this.getSlots(chestSize, 36, false); + } + + return Collections.emptyList(); + } + } + + @Override + public List getTargetSlots(final InventoryAction inventoryAction, final Slot slot, final int i, final Player entityPlayer) { + final int chestSize = this.backpackInventory.getContainerSize(); + return slot.index < chestSize ? this.getSlots(chestSize, 36, true) : this.getSlots(0, chestSize, false); + } + + @Override + public boolean stillValid(final Player entityPlayer) { + return this.backpackInventory.stillValid(entityPlayer); + } + +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/GuiStarBackpack.java b/src/main/java/useless/moonsteel/compat/backpacks/GuiStarBackpack.java new file mode 100644 index 0000000..f4a755a --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/GuiStarBackpack.java @@ -0,0 +1,52 @@ +package useless.moonsteel.compat.backpacks; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.gui.container.ScreenContainerAbstract; +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.lang.I18n; +import org.lwjgl.opengl.GL11; +import tosutosu.betterwithbackpacks.BetterWithBackpacks; + +@Environment(EnvType.CLIENT) +public class GuiStarBackpack extends ScreenContainerAbstract { + private int GUIx; + private int GUIy; + private int rows; + private int slotsNum; + private final ContainerStarBackpack backpack; + + public GuiStarBackpack(Player player) { + super(new ContainerStarBackpack(player)); + backpack = (ContainerStarBackpack) inventorySlots; + } + + @Override + public void init() { + this.GUIx = (this.width - this.xSize) / 2; + this.GUIy = (this.height - this.ySize) / 2; + this.slotsNum = this.backpack.backpackInventory.getContainerSize(); + this.rows = (int) Math.ceil(this.slotsNum / 9.0); + super.init(); + } + + @Override + protected void drawGuiContainerForegroundLayer() { + this.font.drawString(I18n.getInstance().translateKey(this.backpack.backpackInventory.getNameTranslationKey()), 8, 6, BetterWithBackpacks.GUI_LABEL_COLOR); + this.font.drawString("Inventory", 8, this.ySize - 96 + 2, BetterWithBackpacks.GUI_LABEL_COLOR); + } + + protected void drawGuiContainerBackgroundLayer(float f) { + GL11.glColor3d(1.0, 1.0, 1.0); + this.mc.textureManager.loadTexture("/assets/betterwithbackpacks/gui/backpack.png").bind(); + this.drawTexturedModalRect(this.GUIx, this.GUIy, 0, 0, this.xSize, this.ySize); + + for (int i = 0; i < this.rows; ++i) { + if (i == this.rows - 1) { + this.drawTexturedModalRect(this.GUIx + 7, this.GUIy + 17 + 18 * i, 0, 166, 18 * (this.slotsNum - 9 * i), 18); + } else { + this.drawTexturedModalRect(this.GUIx + 7, this.GUIy + 17 + 18 * i, 0, 166, 162, 18); + } + } + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/ItemStarBackpack.java b/src/main/java/useless/moonsteel/compat/backpacks/ItemStarBackpack.java new file mode 100644 index 0000000..1c7c933 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/ItemStarBackpack.java @@ -0,0 +1,23 @@ +package useless.moonsteel.compat.backpacks; + +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.world.World; +import tosutosu.betterwithbackpacks.BetterWithBackpacks; +import tosutosu.betterwithbackpacks.item.ItemBackpack; +import useless.moonsteel.compat.backpacks.interfaces.IStarBackpack; + +public class ItemStarBackpack extends ItemBackpack { + public ItemStarBackpack(String name, String namespaceId, int id) { + super(name, namespaceId, id, StarBackpackInventory.starBackpackSize); + } + + @Override + public ItemStack onUseItem(ItemStack itemstack, World world, Player entityplayer) { + if (!world.isClientSide && BetterWithBackpacks.ENABLE_BACKPACKS) { + ((IStarBackpack) entityplayer).moonsteel$displayGuiStarBackpack(); + } + + return itemstack; + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackCompatibility.java b/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackCompatibility.java new file mode 100644 index 0000000..64166a3 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackCompatibility.java @@ -0,0 +1,104 @@ +package useless.moonsteel.compat.backpacks; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; +import net.minecraft.client.render.EntityRenderDispatcher; +import net.minecraft.client.render.TileEntityRenderDispatcher; +import net.minecraft.client.render.block.color.BlockColorDispatcher; +import net.minecraft.client.render.block.model.BlockModelDispatcher; +import net.minecraft.client.render.item.model.ItemModelDispatcher; +import org.spongepowered.asm.mixin.Mixins; +import tosutosu.betterwithbackpacks.ModItems; +import turniplabs.halplibe.helper.CreativeHelper; +import turniplabs.halplibe.util.GameStartEntrypoint; +import turniplabs.halplibe.util.ModelEntrypoint; +import turniplabs.halplibe.util.RecipeEntrypoint; + +public class MoonSteelBackpackCompatibility implements PreLaunchEntrypoint, GameStartEntrypoint, ModelEntrypoint, RecipeEntrypoint { + + public static boolean IS_BACKPACK_LOADED = false; + + public static ModelEntrypoint modelEntryPointDelegate; + public static RecipeEntrypoint recipeEntrypointDelegate; + + + @Override + public void onPreLaunch() { + FabricLoader loader = FabricLoader.getInstance(); + + IS_BACKPACK_LOADED = loader.isModLoaded("betterwithbackpacks"); + + if (IS_BACKPACK_LOADED) { + Mixins.addConfiguration("compat/backpack/backpack.mixins.json"); + + try { + modelEntryPointDelegate = (ModelEntrypoint) Class + .forName("useless.moonsteel.compat.backpacks.MoonSteelBackpackModels") + .getConstructor() + .newInstance(); + + recipeEntrypointDelegate = (RecipeEntrypoint) Class + .forName("useless.moonsteel.compat.backpacks.MoonSteelBackpackRecipes") + .getConstructor() + .newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + private static void callInit(String classPath, String methodName) { + try { + Class.forName(classPath).getMethod(methodName).invoke(null); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void beforeGameStart() { + if (IS_BACKPACK_LOADED) { + callInit("useless.moonsteel.compat.backpacks.MoonSteelBackpackItems", "init"); + CreativeHelper.setParent(MoonSteelBackpackItems.BACKPACK_COSMIC.getDefaultStack(), ModItems.diamondBackpack.getDefaultStack()); + } + } + + @Override + public void afterGameStart() { + } + + @Override + public void initBlockColors(BlockColorDispatcher dispatcher) { + if (IS_BACKPACK_LOADED) modelEntryPointDelegate.initBlockColors(dispatcher); + } + + @Override + public void initBlockModels(BlockModelDispatcher dispatcher) { + if (IS_BACKPACK_LOADED) modelEntryPointDelegate.initBlockModels(dispatcher); + } + + @Override + public void initItemModels(ItemModelDispatcher dispatcher) { + if (IS_BACKPACK_LOADED) modelEntryPointDelegate.initItemModels(dispatcher); + } + + @Override + public void initEntityModels(EntityRenderDispatcher dispatcher) { + if (IS_BACKPACK_LOADED) modelEntryPointDelegate.initEntityModels(dispatcher); + } + + @Override + public void initTileEntityModels(TileEntityRenderDispatcher dispatcher) { + if (IS_BACKPACK_LOADED) modelEntryPointDelegate.initTileEntityModels(dispatcher); + } + + @Override + public void onRecipesReady() { + if (IS_BACKPACK_LOADED) recipeEntrypointDelegate.onRecipesReady(); + } + + @Override + public void initNamespaces() { + if (IS_BACKPACK_LOADED) recipeEntrypointDelegate.initNamespaces(); + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackItems.java b/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackItems.java new file mode 100644 index 0000000..b51058e --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackItems.java @@ -0,0 +1,26 @@ +package useless.moonsteel.compat.backpacks; + +import net.minecraft.core.item.Item; +import turniplabs.halplibe.helper.ItemBuilder; +import useless.moonsteel.MoonSteel; + +import static useless.moonsteel.MoonSteel.MOD_ID; + +public class MoonSteelBackpackItems { + public static Item BACKPACK_COSMIC; + + private static boolean hasInit = false; + + public static void init() { + if (!hasInit) { + hasInit = true; + initializeItems(); + } + } + + public static void initializeItems() { + BACKPACK_COSMIC = new ItemBuilder(MOD_ID) + .setStackSize(1) + .build(new ItemStarBackpack("backpack.cosmic", MOD_ID + ":item/backpack_cosmic", MoonSteel.itemId++)); + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackModels.java b/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackModels.java new file mode 100644 index 0000000..a6e1e80 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackModels.java @@ -0,0 +1,39 @@ +package useless.moonsteel.compat.backpacks; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.render.EntityRenderDispatcher; +import net.minecraft.client.render.TileEntityRenderDispatcher; +import net.minecraft.client.render.block.color.BlockColorDispatcher; +import net.minecraft.client.render.block.model.BlockModelDispatcher; +import net.minecraft.client.render.item.model.ItemModelDispatcher; +import turniplabs.halplibe.util.ModelEntrypoint; +import useless.moonsteel.MoonSteelModels; + +@Environment(EnvType.CLIENT) +public class MoonSteelBackpackModels implements ModelEntrypoint { + @Override + public void initBlockModels(BlockModelDispatcher dispatcher) { + + } + + @Override + public void initItemModels(ItemModelDispatcher dispatcher) { + dispatcher.addDispatch(MoonSteelModels.makeModel(MoonSteelBackpackItems.BACKPACK_COSMIC, "starpack")); + } + + @Override + public void initEntityModels(EntityRenderDispatcher dispatcher) { + + } + + @Override + public void initTileEntityModels(TileEntityRenderDispatcher dispatcher) { + + } + + @Override + public void initBlockColors(BlockColorDispatcher dispatcher) { + + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackRecipes.java b/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackRecipes.java new file mode 100644 index 0000000..6aaa127 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/MoonSteelBackpackRecipes.java @@ -0,0 +1,27 @@ +package useless.moonsteel.compat.backpacks; + +import tosutosu.betterwithbackpacks.ModItems; +import turniplabs.halplibe.helper.RecipeBuilder; +import turniplabs.halplibe.util.RecipeEntrypoint; +import useless.moonsteel.MoonSteelItems; + +import static useless.moonsteel.MoonSteel.MOD_ID; + +public class MoonSteelBackpackRecipes implements RecipeEntrypoint { + @Override + public void onRecipesReady() { + RecipeBuilder.Shaped(MOD_ID) + .setShape( + "MMM", + "MSM", + "MMM") + .addInput('M', MoonSteelItems.INGOT_MOONSTEEL) + .addInput('S', ModItems.goldBackpack) + .create("cosmic_backpack", MoonSteelBackpackItems.BACKPACK_COSMIC.getDefaultStack()); + } + + @Override + public void initNamespaces() { + RecipeBuilder.initNameSpace(MOD_ID); + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/SlotStarBackpack.java b/src/main/java/useless/moonsteel/compat/backpacks/SlotStarBackpack.java new file mode 100644 index 0000000..d027c3c --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/SlotStarBackpack.java @@ -0,0 +1,18 @@ +package useless.moonsteel.compat.backpacks; + +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.player.inventory.container.Container; +import net.minecraft.core.player.inventory.slot.Slot; +import tosutosu.betterwithbackpacks.item.ItemBackpack; + +public class SlotStarBackpack extends Slot { + public SlotStarBackpack(Container inventory, int id, int x, int y) { + super(inventory, id, x, y); + } + + @Override + public boolean mayPlace(ItemStack itemstack) { + return itemstack != null && !(itemstack.getItem() instanceof ItemBackpack) && !this.isLocked(); + } + +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/StarBackpackInventory.java b/src/main/java/useless/moonsteel/compat/backpacks/StarBackpackInventory.java new file mode 100644 index 0000000..32e8ce3 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/StarBackpackInventory.java @@ -0,0 +1,120 @@ +package useless.moonsteel.compat.backpacks; + +import com.mojang.nbt.tags.CompoundTag; +import com.mojang.nbt.tags.ListTag; +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.player.inventory.InventorySorter; +import net.minecraft.core.player.inventory.container.Container; +import tosutosu.betterwithbackpacks.BetterWithBackpacks; + +import static useless.moonsteel.compat.backpacks.MoonSteelBackpackCompatibility.IS_BACKPACK_LOADED; + +public class StarBackpackInventory implements Container { + public static int starBackpackSize = 18; + protected ItemStack[] backpackItemStacks; + public Player player; + + public StarBackpackInventory(Player player) { + this.player = player; + this.backpackItemStacks = new ItemStack[starBackpackSize]; + } + + @Override + public int getContainerSize() { + return starBackpackSize; + } + + @Override + public ItemStack getItem(int i) { + return this.backpackItemStacks[i]; + } + + @Override + public ItemStack removeItem(int i, int j) { + if (this.backpackItemStacks[i] != null) { + if (this.backpackItemStacks[i].stackSize <= j) { + ItemStack itemstack = this.backpackItemStacks[i]; + this.backpackItemStacks[i] = null; + return itemstack; + } else { + ItemStack itemstack1 = this.backpackItemStacks[i].splitStack(j); + if (this.backpackItemStacks[i].stackSize <= 0) { + this.backpackItemStacks[i] = null; + } + + return itemstack1; + } + } else { + return null; + } + } + + @Override + public void setItem(int i, ItemStack itemStack) { + this.backpackItemStacks[i] = itemStack; + if (itemStack != null && itemStack.stackSize > this.getMaxStackSize()) { + itemStack.stackSize = this.getMaxStackSize(); + } + } + + @Override + public String getNameTranslationKey() { + return "moonsteel.container.backpack.star.name"; + } + + @Override + public int getMaxStackSize() { + return 64; + } + + @Override + public void setChanged() { + + } + + public void readFromNBT(ListTag tagList) { + this.backpackItemStacks = new ItemStack[this.getContainerSize()]; + + for (int i = 0; i < tagList.tagCount(); ++i) { + CompoundTag nbttagcompound1 = (CompoundTag) tagList.tagAt(i); + byte byte0 = nbttagcompound1.getByte("Slot"); + if (byte0 >= 0 && byte0 < this.backpackItemStacks.length) { + this.backpackItemStacks[byte0] = ItemStack.readItemStackFromNbt(nbttagcompound1); + } + } + } + + public ListTag writeToNBT(ListTag tagList) { + for (int i = 0; i < this.backpackItemStacks.length; ++i) { + if (this.backpackItemStacks[i] != null) { + CompoundTag nbttagcompound1 = new CompoundTag(); + nbttagcompound1.putByte("Slot", (byte) i); + this.backpackItemStacks[i].writeToNBT(nbttagcompound1); + tagList.addTag(nbttagcompound1); + } + } + + return tagList; + } + + @Override + public boolean stillValid(Player entityPlayer) { + if (!BetterWithBackpacks.ENABLE_BACKPACKS) { + return false; + } else if (entityPlayer.getHeldItem() == null) { + return false; + } else { + ItemStack heldItem = entityPlayer.getHeldItem(); + if (IS_BACKPACK_LOADED) { + return heldItem.getItem().equals(MoonSteelBackpackItems.BACKPACK_COSMIC); + } + } + return false; + } + + @Override + public void sortContainer() { + InventorySorter.sortInventory(this.backpackItemStacks); + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/interfaces/IStarBackpack.java b/src/main/java/useless/moonsteel/compat/backpacks/interfaces/IStarBackpack.java new file mode 100644 index 0000000..6c90a8c --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/interfaces/IStarBackpack.java @@ -0,0 +1,11 @@ +package useless.moonsteel.compat.backpacks.interfaces; + +import useless.moonsteel.compat.backpacks.StarBackpackInventory; + +public interface IStarBackpack { + StarBackpackInventory moonsteel$getStarBackpackInventory(); + + void moonsteel$setStarBackpackInventory(StarBackpackInventory backpackInventory); + + void moonsteel$displayGuiStarBackpack(); +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/mixin/PacketHandlerClientMixin.java b/src/main/java/useless/moonsteel/compat/backpacks/mixin/PacketHandlerClientMixin.java new file mode 100644 index 0000000..81ac236 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/mixin/PacketHandlerClientMixin.java @@ -0,0 +1,31 @@ +package useless.moonsteel.compat.backpacks.mixin; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.Minecraft; +import net.minecraft.client.net.handler.PacketHandlerClient; +import net.minecraft.core.net.packet.PacketContainerOpen; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import useless.moonsteel.MoonSteel; +import useless.moonsteel.compat.backpacks.interfaces.IStarBackpack; + +@Environment(EnvType.CLIENT) +@Mixin(value = PacketHandlerClient.class, remap = false) +public abstract class PacketHandlerClientMixin { + @Final + @Shadow + private Minecraft mc; + + @Inject(method = "handleOpenWindow", at = @At("TAIL")) + public void inject(final PacketContainerOpen packetContainerOpen, final CallbackInfo ci) { + if (packetContainerOpen.inventoryType == MoonSteel.GUI_ID) { + ((IStarBackpack) (this.mc.thePlayer)).moonsteel$displayGuiStarBackpack(); + this.mc.thePlayer.craftingInventory.containerId = packetContainerOpen.windowId; + } + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/mixin/PlayerListMixin.java b/src/main/java/useless/moonsteel/compat/backpacks/mixin/PlayerListMixin.java new file mode 100644 index 0000000..a2a3111 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/mixin/PlayerListMixin.java @@ -0,0 +1,21 @@ +package useless.moonsteel.compat.backpacks.mixin; + +import com.llamalad7.mixinextras.sugar.Local; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.server.entity.player.PlayerServer; +import net.minecraft.server.net.PlayerList; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import useless.moonsteel.compat.backpacks.interfaces.IStarBackpack; + +@Environment(EnvType.SERVER) +@Mixin(value = PlayerList.class, remap = false) +public class PlayerListMixin { + @Inject(method = "recreatePlayerEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/player/inventory/container/ContainerInventory;transferAllContents(Lnet/minecraft/core/player/inventory/container/ContainerInventory;)V", shift = At.Shift.AFTER)) + public void keepBackpackMP(final PlayerServer previousPlayer, final int i, final CallbackInfoReturnable cir, @Local(name = "newPlayer") final PlayerServer newPlayer) { + ((IStarBackpack) newPlayer).moonsteel$setStarBackpackInventory(((IStarBackpack) previousPlayer).moonsteel$getStarBackpackInventory()); + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/MinecraftMixin.java b/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/MinecraftMixin.java new file mode 100644 index 0000000..68815d1 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/MinecraftMixin.java @@ -0,0 +1,26 @@ +package useless.moonsteel.compat.backpacks.mixin.backpack; + +import com.llamalad7.mixinextras.sugar.Local; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.player.PlayerLocal; +import net.minecraft.core.entity.player.Player; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import useless.moonsteel.compat.backpacks.interfaces.IStarBackpack; + +@Environment(EnvType.CLIENT) +@Mixin(value = Minecraft.class, remap = false) +public class MinecraftMixin { + @Shadow + public PlayerLocal thePlayer; + + @Inject(method = "respawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/player/PlayerLocal;setGamemode(Lnet/minecraft/core/player/gamemode/Gamemode;)V", shift = At.Shift.AFTER)) + public void keepBackpack(boolean flag, int i, CallbackInfo ci, @Local Player previousPlayer) { + ((IStarBackpack) thePlayer).moonsteel$setStarBackpackInventory(((IStarBackpack) previousPlayer).moonsteel$getStarBackpackInventory()); + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/PlayerLocalMixin.java b/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/PlayerLocalMixin.java new file mode 100644 index 0000000..90bddbf --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/PlayerLocalMixin.java @@ -0,0 +1,30 @@ +package useless.moonsteel.compat.backpacks.mixin.backpack; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.player.PlayerLocal; +import net.minecraft.core.world.World; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import useless.moonsteel.compat.backpacks.GuiStarBackpack; + +@Environment(EnvType.CLIENT) +@Mixin(value = PlayerLocal.class, remap = false) +public class PlayerLocalMixin extends PlayerMixin { + @Shadow + protected Minecraft mc; + @Unique + public PlayerLocal thisAs = (PlayerLocal) (Object) this; + + public PlayerLocalMixin(@Nullable World world) { + super(world); + } + + @Override + public void moonsteel$displayGuiStarBackpack() { + this.mc.displayScreen(new GuiStarBackpack(this.thisAs)); + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/PlayerMixin.java b/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/PlayerMixin.java new file mode 100644 index 0000000..6c22226 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/PlayerMixin.java @@ -0,0 +1,61 @@ +package useless.moonsteel.compat.backpacks.mixin.backpack; + +import com.mojang.nbt.tags.CompoundTag; +import com.mojang.nbt.tags.ListTag; +import net.minecraft.core.entity.Mob; +import net.minecraft.core.entity.player.Player; +import net.minecraft.core.world.World; +import org.jetbrains.annotations.Nullable; +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; +import useless.moonsteel.compat.backpacks.StarBackpackInventory; +import useless.moonsteel.compat.backpacks.interfaces.IStarBackpack; +import useless.moonsteel.interfaces.ITeleporter; + +@Mixin(value = Player.class, remap = false) +public abstract class PlayerMixin extends Mob implements IStarBackpack, ITeleporter { + @Unique + public StarBackpackInventory starBackpackInventory; + + protected PlayerMixin(@Nullable final World world) { + super(world); + } + + @Inject(method = "(Lnet/minecraft/core/world/World;)V", at = @At("TAIL")) + private void createBackpack(final World world, final CallbackInfo ci) { + this.starBackpackInventory = new StarBackpackInventory((Player) (Object) this); + } + + @Inject(method = "addAdditionalSaveData", at = @At("TAIL")) + private void addData(final CompoundTag tag, final CallbackInfo ci) { + tag.put("moonsteel$InventoryStardust", this.starBackpackInventory.writeToNBT(new ListTag())); + } + + @Inject(method = "readAdditionalSaveData", at = @At("TAIL")) + private void loadData(final CompoundTag tag, final CallbackInfo ci) { + this.starBackpackInventory.readFromNBT(tag.getList("moonsteel$InventoryStardust")); + } + + @Override + public StarBackpackInventory moonsteel$getStarBackpackInventory() { + return this.starBackpackInventory; + } + + @Override + public void moonsteel$setStarBackpackInventory(final StarBackpackInventory backpackInventory) { + this.starBackpackInventory = backpackInventory; + } + + @Override + public void moonsteel$displayGuiStarBackpack() { + + } + + @Override + public void moonsteel$teleport(final double x, final double y, final double z) { + setPos(x, y + this.bbHeight, z); + } +} diff --git a/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/PlayerServerMixin.java b/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/PlayerServerMixin.java new file mode 100644 index 0000000..ce153b2 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/backpacks/mixin/backpack/PlayerServerMixin.java @@ -0,0 +1,51 @@ +package useless.moonsteel.compat.backpacks.mixin.backpack; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.core.net.packet.PacketContainerOpen; +import net.minecraft.core.world.World; +import net.minecraft.server.entity.player.PlayerServer; +import net.minecraft.server.net.handler.PacketHandlerServer; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import useless.moonsteel.MoonSteel; +import useless.moonsteel.compat.backpacks.ContainerStarBackpack; + +@Environment(EnvType.SERVER) +@Mixin(value = PlayerServer.class, remap = false) +public abstract class PlayerServerMixin extends PlayerMixin { + protected PlayerServerMixin(@Nullable World world) { + super(world); + } + + @Shadow + protected abstract void getNextWindowId(); + + @Shadow + private int currentWindowId; + @Shadow + public PacketHandlerServer playerNetServerHandler; + @Unique + public PlayerServer thisAs = (PlayerServer) (Object) this; + + @Override + public void moonsteel$displayGuiStarBackpack() { + this.getNextWindowId(); + ContainerStarBackpack backpack = new ContainerStarBackpack(thisAs); + this.thisAs + .playerNetServerHandler + .sendPacket( + new PacketContainerOpen(this.currentWindowId, MoonSteel.GUI_ID, "moonsteel$StarBackpack", backpack.backpackInventory.getContainerSize()) + ); + this.thisAs.craftingInventory = backpack; + this.thisAs.craftingInventory.containerId = this.currentWindowId; + this.thisAs.craftingInventory.addSlotListener(this.thisAs); + } + + @Override + public void moonsteel$teleport(final double x, final double y, final double z) { + this.playerNetServerHandler.teleport(x, y, z); + } +} diff --git a/src/main/java/useless/moonsteel/compat/deep/MoonSteelDeepCompatibility.java b/src/main/java/useless/moonsteel/compat/deep/MoonSteelDeepCompatibility.java new file mode 100644 index 0000000..a164783 --- /dev/null +++ b/src/main/java/useless/moonsteel/compat/deep/MoonSteelDeepCompatibility.java @@ -0,0 +1,15 @@ +package useless.moonsteel.compat.deep; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; + +public class MoonSteelDeepCompatibility implements PreLaunchEntrypoint { + + public static boolean IS_DEEP_LOADED = false; + + @Override + public void onPreLaunch() { + FabricLoader loader = FabricLoader.getInstance(); + IS_DEEP_LOADED = loader.isModLoaded("deep"); + } +} diff --git a/src/main/java/useless/moonsteel/fx/ParticleMagicSmoke.java b/src/main/java/useless/moonsteel/fx/ParticleMagicSmoke.java index 1d08481..fbb2ecf 100644 --- a/src/main/java/useless/moonsteel/fx/ParticleMagicSmoke.java +++ b/src/main/java/useless/moonsteel/fx/ParticleMagicSmoke.java @@ -1,5 +1,7 @@ package useless.moonsteel.fx; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.entity.particle.ParticleSmoke; import net.minecraft.client.render.LightmapHelper; import net.minecraft.client.render.tessellator.Tessellator; @@ -10,64 +12,70 @@ import static useless.moonsteel.MoonSteel.MOD_ID; +@Environment(EnvType.CLIENT) public class ParticleMagicSmoke extends ParticleSmoke { - private static final IconCoordinate smoke = TextureRegistry.getTexture(MOD_ID + ":item/particle_magicsmoke"); - public float sizeO; - public ParticleMagicSmoke(World world, double x, double y, double z, double xa, double ya, double za) { - super(world, x, y, z, xa, ya, za); - this.rCol = 1; - this.gCol = 1; - this.bCol = 1; - this.tex = smoke; - this.lifetime = (int)(5.0 / (Math.random() * 0.9 + 0.2)); - size *= 1.5f; - sizeO = size; - } - @Override - public void render(Tessellator t, float partialTick, double xOff, double yOff, double zOff, float xa, float ya, float za, float xa2, float za2) { - float f6 = ((float)this.age + partialTick) / (float)this.lifetime * 32.0f; - if (f6 < 0.0f) { - f6 = 0.0f; - } - if (f6 > 1.0f) { - f6 = 1.0f; - } - this.size = this.sizeO * f6; - if (this.tex != null) { - final float u0 = (float)this.tex.getIconUMin(); - final float u2 = (float)this.tex.getIconUMax(); - final float v0 = (float)this.tex.getIconVMin(); - final float v2 = (float)this.tex.getIconVMax(); - final float r = 0.1F * this.size; - final float x = (float)(this.xo + (this.x - this.xo) * (double)partialTick - xOff); - final float y = (float)(this.yo + (this.y - this.yo) * (double)partialTick - yOff); - final float z = (float)(this.zo + (this.z - this.zo) * (double)partialTick - zOff); - float br = 1.0F; - if (LightmapHelper.isLightmapEnabled()) { - t.setLightmapCoord(this.getLightmapCoord(partialTick)); - } else { - br = this.getBrightness(partialTick); - } + private static final IconCoordinate smoke = TextureRegistry.getTexture(MOD_ID + ":item/particle_magicsmoke"); + public float sizeO; - t.setColorOpaque_F(this.rCol * br, this.gCol * br, this.bCol * br); - t.addVertexWithUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u2, v2); - t.addVertexWithUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u2, v0); - t.addVertexWithUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u0, v0); - t.addVertexWithUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u0, v2); - } - } - @Override - public float getBrightness(float partialTick) { - float decay = MathHelper.clamp(((float)this.age + partialTick) / (float)this.lifetime, 0.0f, 1.0f); - return super.getBrightness(partialTick) * decay + (1.0f - decay); - } - @Override - public int getParticleTexture() { - return 2; - } - @Override - public void tick() { - super.tick(); - this.tex = smoke; - } + public ParticleMagicSmoke(World world, double x, double y, double z, double xa, double ya, double za) { + super(world, x, y, z, xa, ya, za); + this.rCol = 1; + this.gCol = 1; + this.bCol = 1; + this.tex = smoke; + this.lifetime = (int) (5.0 / (random.nextInt() * 0.9 + 0.2)); + size *= 1.5f; + sizeO = size; + } + + @Override + public void render(Tessellator t, float partialTick, double xOff, double yOff, double zOff, float xa, float ya, float za, float xa2, float za2) { + float f6 = (this.age + partialTick) / this.lifetime * 32.0F; + if (f6 < 0.0f) { + f6 = 0.0f; + } + if (f6 > 1.0f) { + f6 = 1.0f; + } + this.size = this.sizeO * f6; + if (this.tex != null) { + final float u0 = (float) this.tex.getIconUMin(); + final float u2 = (float) this.tex.getIconUMax(); + final float v0 = (float) this.tex.getIconVMin(); + final float v2 = (float) this.tex.getIconVMax(); + final float r = 0.1F * this.size; + final float x = (float) (this.xo + (this.x - this.xo) * partialTick - xOff); + final float y = (float) (this.yo + (this.y - this.yo) * partialTick - yOff); + final float z = (float) (this.zo + (this.z - this.zo) * partialTick - zOff); + float br = 1.0F; + if (LightmapHelper.isLightmapEnabled()) { + t.setLightmapCoord(this.getLightmapCoord(partialTick)); + } else { + br = this.getBrightness(partialTick); + } + + t.setColorOpaque_F(this.rCol * br, this.gCol * br, this.bCol * br); + t.addVertexWithUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u2, v2); + t.addVertexWithUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u2, v0); + t.addVertexWithUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u0, v0); + t.addVertexWithUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u0, v2); + } + } + + @Override + public float getBrightness(float partialTick) { + float decay = MathHelper.clamp((this.age + partialTick) / this.lifetime, 0.0f, 1.0f); + return super.getBrightness(partialTick) * decay + (1.0f - decay); + } + + @Override + public int getParticleTexture() { + return 2; + } + + @Override + public void tick() { + super.tick(); + this.tex = smoke; + } } diff --git a/src/main/java/useless/moonsteel/fx/ParticleStar.java b/src/main/java/useless/moonsteel/fx/ParticleStar.java index 41b0873..b54b453 100644 --- a/src/main/java/useless/moonsteel/fx/ParticleStar.java +++ b/src/main/java/useless/moonsteel/fx/ParticleStar.java @@ -1,5 +1,7 @@ package useless.moonsteel.fx; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.entity.particle.ParticleFlame; import net.minecraft.client.render.LightmapHelper; import net.minecraft.client.render.tessellator.Tessellator; @@ -9,49 +11,54 @@ import static useless.moonsteel.MoonSteel.MOD_ID; +@Environment(EnvType.CLIENT) public class ParticleStar extends ParticleFlame { - private static final IconCoordinate star = TextureRegistry.getTexture(MOD_ID + ":item/particle_star"); - public float sizeO; - public ParticleStar(final World world, final double x, final double y, final double z, final double xd, final double yd, final double zd) { - super(world, x, y, z, xd, yd, zd, Type.ORANGE); - this.tex = star; - this.size *= 2.25f; - this.sizeO = this.size; - } - @Override - public void render(final Tessellator t, final float partialTick, final double xOff, final double yOff, final double zOff, final float xa, final float ya, final float za, final float xa2, final float za2) { - final float s = ((float)this.age + partialTick) / (float)this.lifetime; - this.size = this.sizeO * (1.0f - s * s * 0.5f); - if (this.tex != null) { - final float u0 = (float)this.tex.getIconUMin(); - final float u2 = (float)this.tex.getIconUMax(); - final float v0 = (float)this.tex.getIconVMin(); - final float v2 = (float)this.tex.getIconVMax(); - final float r = 0.1F * this.size; - final float x = (float)(this.xo + (this.x - this.xo) * (double)partialTick - xOff); - final float y = (float)(this.yo + (this.y - this.yo) * (double)partialTick - yOff); - final float z = (float)(this.zo + (this.z - this.zo) * (double)partialTick - zOff); - float br = 1.0F; - if (LightmapHelper.isLightmapEnabled()) { - t.setLightmapCoord(this.getLightmapCoord(partialTick)); - } else { - br = this.getBrightness(partialTick); - } - - t.setColorOpaque_F(this.rCol * br, this.gCol * br, this.bCol * br); - t.addVertexWithUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u2, v2); - t.addVertexWithUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u2, v0); - t.addVertexWithUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u0, v0); - t.addVertexWithUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u0, v2); - } - } - @Override - public void tick() { - super.tick(); - this.tex = star; - } - @Override - public int getParticleTexture() { - return 2; - } + private static final IconCoordinate star = TextureRegistry.getTexture(MOD_ID + ":item/particle_star"); + public float sizeO; + + public ParticleStar(final World world, final double x, final double y, final double z, final double xd, final double yd, final double zd) { + super(world, x, y, z, xd, yd, zd, Type.ORANGE); + this.tex = star; + this.size *= 2.25f; + this.sizeO = this.size; + } + + @Override + public void render(final Tessellator t, final float partialTick, final double xOff, final double yOff, final double zOff, final float xa, final float ya, final float za, final float xa2, final float za2) { + final float s = (this.age + partialTick) / this.lifetime; + this.size = this.sizeO * (1.0f - s * s * 0.5f); + if (this.tex != null) { + final float u0 = (float) this.tex.getIconUMin(); + final float u2 = (float) this.tex.getIconUMax(); + final float v0 = (float) this.tex.getIconVMin(); + final float v2 = (float) this.tex.getIconVMax(); + final float r = 0.1F * this.size; + final float x = (float) (this.xo + (this.x - this.xo) * partialTick - xOff); + final float y = (float) (this.yo + (this.y - this.yo) * partialTick - yOff); + final float z = (float) (this.zo + (this.z - this.zo) * partialTick - zOff); + float br = 1.0F; + if (LightmapHelper.isLightmapEnabled()) { + t.setLightmapCoord(this.getLightmapCoord(partialTick)); + } else { + br = this.getBrightness(partialTick); + } + + t.setColorOpaque_F(this.rCol * br, this.gCol * br, this.bCol * br); + t.addVertexWithUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u2, v2); + t.addVertexWithUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u2, v0); + t.addVertexWithUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u0, v0); + t.addVertexWithUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u0, v2); + } + } + + @Override + public void tick() { + super.tick(); + this.tex = star; + } + + @Override + public int getParticleTexture() { + return 2; + } } diff --git a/src/main/java/useless/moonsteel/interfaces/IFallenStar.java b/src/main/java/useless/moonsteel/interfaces/IFallenStar.java index 6639f6d..8f9e8f2 100644 --- a/src/main/java/useless/moonsteel/interfaces/IFallenStar.java +++ b/src/main/java/useless/moonsteel/interfaces/IFallenStar.java @@ -1,5 +1,5 @@ package useless.moonsteel.interfaces; public interface IFallenStar { - void moonsteel$setDaylightSensitive(boolean flag); + void moonsteel$setDaylightSensitive(boolean flag); } diff --git a/src/main/java/useless/moonsteel/interfaces/IMoonGrav.java b/src/main/java/useless/moonsteel/interfaces/IMoonGrav.java index c7e8884..2f1a069 100644 --- a/src/main/java/useless/moonsteel/interfaces/IMoonGrav.java +++ b/src/main/java/useless/moonsteel/interfaces/IMoonGrav.java @@ -1,5 +1,5 @@ package useless.moonsteel.interfaces; public interface IMoonGrav { - double moonsteel$getGravScalar(); + double moonsteel$getGravScalar(); } diff --git a/src/main/java/useless/moonsteel/interfaces/IStarBackpack.java b/src/main/java/useless/moonsteel/interfaces/IStarBackpack.java deleted file mode 100644 index ff1f551..0000000 --- a/src/main/java/useless/moonsteel/interfaces/IStarBackpack.java +++ /dev/null @@ -1,9 +0,0 @@ -package useless.moonsteel.interfaces; - -import useless.moonsteel.StarBackpackInventory; - -public interface IStarBackpack { - StarBackpackInventory moonsteel$getStarBackpackInventory(); - void moonsteel$setStarBackpackInventory(StarBackpackInventory backpackInventory); - void moonsteel$displayGuiStarBackpack(); -} diff --git a/src/main/java/useless/moonsteel/interfaces/IStarZombie.java b/src/main/java/useless/moonsteel/interfaces/IStarZombie.java index af45d54..9192900 100644 --- a/src/main/java/useless/moonsteel/interfaces/IStarZombie.java +++ b/src/main/java/useless/moonsteel/interfaces/IStarZombie.java @@ -1,5 +1,5 @@ package useless.moonsteel.interfaces; public interface IStarZombie { - boolean moonsteel$isStarZombie(); + boolean moonsteel$isStarZombie(); } diff --git a/src/main/java/useless/moonsteel/interfaces/ITeleporter.java b/src/main/java/useless/moonsteel/interfaces/ITeleporter.java index 74795e1..fa44233 100644 --- a/src/main/java/useless/moonsteel/interfaces/ITeleporter.java +++ b/src/main/java/useless/moonsteel/interfaces/ITeleporter.java @@ -1,5 +1,5 @@ package useless.moonsteel.interfaces; public interface ITeleporter { - void moonsteel$teleport(double x, double y, double z); + void moonsteel$teleport(double x, double y, double z); } diff --git a/src/main/java/useless/moonsteel/item/ItemConnectedStar.java b/src/main/java/useless/moonsteel/item/ItemConnectedStar.java index bee58ba..32620a8 100644 --- a/src/main/java/useless/moonsteel/item/ItemConnectedStar.java +++ b/src/main/java/useless/moonsteel/item/ItemConnectedStar.java @@ -13,40 +13,40 @@ import useless.moonsteel.interfaces.ITeleporter; public class ItemConnectedStar extends Item { - public ItemConnectedStar(String name, String namespaceId, int id) { - super(name, namespaceId, id); - } + public ItemConnectedStar(String name, String namespaceId, int id) { + super(name, namespaceId, id); + } - @Override - public ItemStack onUseItem(ItemStack itemstack, World world, Player entityplayer) { - if (itemstack.getData().getBoolean("moonsteel$has_location")){ - int destX = itemstack.getData().getInteger("moonsteel$x"); - int destY = itemstack.getData().getInteger("moonsteel$y"); - int destZ = itemstack.getData().getInteger("moonsteel$z"); - int dim = itemstack.getData().getInteger("moonsteel$dimension"); - if (dim != world.dimension.id) { - entityplayer.sendTranslatedChatMessage("moonsteel.teleport.fail.dimension"); - return itemstack; - } - int cost = MathHelper.floor(entityplayer.distanceTo(destX, destY, destZ)); - if (entityplayer.score < cost) { - entityplayer.sendTranslatedChatMessage("moonsteel.teleport.fail.score"); - return itemstack; - } - MoonSteel.forceChunkLoads = true; - Chunk chunk = world.getChunkProvider().provideChunk(destX >> 4, destZ >> 4); - MoonSteel.forceChunkLoads = false; - TileEntity te = chunk.getTileEntity(destX &0xF, destY, destZ &0xF); - if (te instanceof TileEntityStellarRewinder && ((TileEntityStellarRewinder) te).canTeleport(itemstack)){ - entityplayer.score -= cost; - Side side = ((TileEntityStellarRewinder) te).side; - ((ITeleporter) entityplayer).moonsteel$teleport(destX + side.getOffsetX() + 0.5f, destY + side.getOffsetY(), destZ + side.getOffsetZ() + 0.5f); - ((TileEntityStellarRewinder) te).setInUse(false); - } else if (!world.isClientSide) { - entityplayer.sendTranslatedChatMessage("moonsteel.teleport.fail.missing"); - } - itemstack.getData().putBoolean("moonsteel$has_location", false); - } - return itemstack; - } + @Override + public ItemStack onUseItem(ItemStack itemstack, World world, Player entityplayer) { + if (itemstack.getData().getBoolean("moonsteel$has_location")) { + int destX = itemstack.getData().getInteger("moonsteel$x"); + int destY = itemstack.getData().getInteger("moonsteel$y"); + int destZ = itemstack.getData().getInteger("moonsteel$z"); + int dim = itemstack.getData().getInteger("moonsteel$dimension"); + if (dim != world.dimension.id) { + entityplayer.sendTranslatedChatMessage("moonsteel.teleport.fail.dimension"); + return itemstack; + } + int cost = MathHelper.floor(entityplayer.distanceTo(destX, destY, destZ)); + if (entityplayer.score < cost) { + entityplayer.sendTranslatedChatMessage("moonsteel.teleport.fail.score"); + return itemstack; + } + MoonSteel.forceChunkLoads = true; + Chunk chunk = world.getChunkProvider().provideChunk(destX >> 4, destZ >> 4); + MoonSteel.forceChunkLoads = false; + TileEntity te = chunk.getTileEntity(destX & 0xF, destY, destZ & 0xF); + if (te instanceof TileEntityStellarRewinder && ((TileEntityStellarRewinder) te).canTeleport(itemstack)) { + entityplayer.score -= cost; + Side side = ((TileEntityStellarRewinder) te).side; + ((ITeleporter) entityplayer).moonsteel$teleport(destX + side.getOffsetX() + 0.5f, destY + side.getOffsetY(), destZ + side.getOffsetZ() + 0.5f); + ((TileEntityStellarRewinder) te).setInUse(false); + } else if (!world.isClientSide) { + entityplayer.sendTranslatedChatMessage("moonsteel.teleport.fail.missing"); + } + itemstack.getData().putBoolean("moonsteel$has_location", false); + } + return itemstack; + } } diff --git a/src/main/java/useless/moonsteel/item/ItemModelConnectStar.java b/src/main/java/useless/moonsteel/item/ItemModelConnectStar.java index 9f92fe6..ab84872 100644 --- a/src/main/java/useless/moonsteel/item/ItemModelConnectStar.java +++ b/src/main/java/useless/moonsteel/item/ItemModelConnectStar.java @@ -1,5 +1,7 @@ package useless.moonsteel.item; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.render.item.model.ItemModelStandard; import net.minecraft.client.render.texture.stitcher.IconCoordinate; import net.minecraft.client.render.texture.stitcher.TextureRegistry; @@ -10,17 +12,20 @@ import org.jetbrains.annotations.Nullable; import useless.moonsteel.MoonSteel; +@Environment(EnvType.CLIENT) public class ItemModelConnectStar extends ItemModelStandard { - private static final IconCoordinate star_connected = TextureRegistry.getTexture(MoonSteel.MOD_ID + ":item/connected_star"); - public ItemModelConnectStar(final Item item, final String namespace) { - super(item, namespace); - } - @NotNull - @Override - public IconCoordinate getIcon(@Nullable final Entity entity, final ItemStack itemStack) { - if (itemStack.getData().getBoolean("moonsteel$has_location")){ - return star_connected; - } - return super.getIcon(entity, itemStack); - } + private static final IconCoordinate star_connected = TextureRegistry.getTexture(MoonSteel.MOD_ID + ":item/connected_star"); + + public ItemModelConnectStar(final Item item, final String namespace) { + super(item, namespace); + } + + @NotNull + @Override + public IconCoordinate getIcon(@Nullable final Entity entity, final ItemStack itemStack) { + if (itemStack.getData().getBoolean("moonsteel$has_location")) { + return star_connected; + } + return super.getIcon(entity, itemStack); + } } diff --git a/src/main/java/useless/moonsteel/item/ItemStarBackpack.java b/src/main/java/useless/moonsteel/item/ItemStarBackpack.java deleted file mode 100644 index 566f1ea..0000000 --- a/src/main/java/useless/moonsteel/item/ItemStarBackpack.java +++ /dev/null @@ -1,23 +0,0 @@ -package useless.moonsteel.item; - -import net.minecraft.core.entity.player.Player; -import net.minecraft.core.item.ItemStack; -import net.minecraft.core.world.World; -import tosutosu.betterwithbackpacks.BetterWithBackpacks; -import tosutosu.betterwithbackpacks.item.ItemBackpack; -import useless.moonsteel.StarBackpackInventory; -import useless.moonsteel.interfaces.IStarBackpack; - -public class ItemStarBackpack extends ItemBackpack { - public ItemStarBackpack(String name, String namespaceId, int id) { - super(name, namespaceId, id, StarBackpackInventory.starBackpackSize); - } - @Override - public ItemStack onUseItem(ItemStack itemstack, World world, Player entityplayer) { - if (!world.isClientSide && BetterWithBackpacks.ENABLE_BACKPACKS) { - ((IStarBackpack)entityplayer).moonsteel$displayGuiStarBackpack(); - } - - return itemstack; - } -} diff --git a/src/main/java/useless/moonsteel/mixin/BlockLogicMixin.java b/src/main/java/useless/moonsteel/mixin/BlockLogicMixin.java index 9a22352..60c58e4 100644 --- a/src/main/java/useless/moonsteel/mixin/BlockLogicMixin.java +++ b/src/main/java/useless/moonsteel/mixin/BlockLogicMixin.java @@ -19,26 +19,26 @@ import useless.moonsteel.MoonSteelBlocks; import useless.moonsteel.MoonSteelItems; -@Mixin(value = BlockLogic.class,remap = false) +@Mixin(value = BlockLogic.class, remap = false) public abstract class BlockLogicMixin { - @Shadow - @Final - @NotNull - public Block block; + @Shadow + @Final + @NotNull + public Block block; - @Shadow - public abstract void dropBlockWithCause(World world, EnumDropCause cause, int x, int y, int z, int meta, TileEntity tileEntity, Player player); + @Shadow + public abstract void dropBlockWithCause(World world, EnumDropCause cause, int x, int y, int z, int meta, TileEntity tileEntity, Player player); - @Inject(method = "harvestBlock(Lnet/minecraft/core/world/World;Lnet/minecraft/core/entity/player/Player;IIIILnet/minecraft/core/block/entity/TileEntity;)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/core/block/BlockLogic;dropBlockWithCause(Lnet/minecraft/core/world/World;Lnet/minecraft/core/enums/EnumDropCause;IIIILnet/minecraft/core/block/entity/TileEntity;Lnet/minecraft/core/entity/player/Player;)V", - shift = At.Shift.AFTER)) - private void multiplyHarvest(final World world, final Player entityplayer, final int x, final int y, final int z, final int meta, final TileEntity tileEntity, final CallbackInfo ci){ - final ItemStack heldItemStack = entityplayer.inventory.getCurrentItem(); - if (heldItemStack != null && heldItemStack.getItem() instanceof ItemTool && ((ItemTool) heldItemStack.getItem()).getMaterial() == MoonSteelItems.moonSteelTool && MoonSteelBlocks.canBeFortuned(this.block)){ - for (int i = 0; i < world.rand.nextInt(MoonSteel.FORTUNE_AMOUNT); i++) { - dropBlockWithCause(world, EnumDropCause.PROPER_TOOL, x, y, z, meta, tileEntity, entityplayer); - } - } - } + @Inject(method = "harvestBlock(Lnet/minecraft/core/world/World;Lnet/minecraft/core/entity/player/Player;IIIILnet/minecraft/core/block/entity/TileEntity;)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/core/block/BlockLogic;dropBlockWithCause(Lnet/minecraft/core/world/World;Lnet/minecraft/core/enums/EnumDropCause;IIIILnet/minecraft/core/block/entity/TileEntity;Lnet/minecraft/core/entity/player/Player;)V", + shift = At.Shift.AFTER)) + private void multiplyHarvest(final World world, final Player entityplayer, final int x, final int y, final int z, final int meta, final TileEntity tileEntity, final CallbackInfo ci) { + final ItemStack heldItemStack = entityplayer.inventory.getCurrentItem(); + if (heldItemStack != null && heldItemStack.getItem() instanceof ItemTool && ((ItemTool) heldItemStack.getItem()).getMaterial() == MoonSteelItems.moonSteelTool && MoonSteelBlocks.canBeFortuned(this.block)) { + for (int i = 0; i < world.rand.nextInt(MoonSteel.FORTUNE_AMOUNT); i++) { + dropBlockWithCause(world, EnumDropCause.PROPER_TOOL, x, y, z, meta, tileEntity, entityplayer); + } + } + } } diff --git a/src/main/java/useless/moonsteel/mixin/ChunkProviderServerMixin.java b/src/main/java/useless/moonsteel/mixin/ChunkProviderServerMixin.java index 38b3ae7..b9fd519 100644 --- a/src/main/java/useless/moonsteel/mixin/ChunkProviderServerMixin.java +++ b/src/main/java/useless/moonsteel/mixin/ChunkProviderServerMixin.java @@ -11,11 +11,11 @@ @Mixin(value = ChunkProviderServer.class, remap = false) public class ChunkProviderServerMixin { - @Shadow - public boolean chunkLoadOverride; + @Shadow + public boolean chunkLoadOverride; - @Inject(method = "provideChunk(II)Lnet/minecraft/core/world/chunk/Chunk;", at = @At("HEAD")) - private void overrideChunks(final int chunkX, final int chunkZ, final CallbackInfoReturnable cir){ - this.chunkLoadOverride = MoonSteel.forceChunkLoads; - } + @Inject(method = "provideChunk(II)Lnet/minecraft/core/world/chunk/Chunk;", at = @At("HEAD")) + private void overrideChunks(final int chunkX, final int chunkZ, final CallbackInfoReturnable cir) { + this.chunkLoadOverride = MoonSteel.forceChunkLoads; + } } diff --git a/src/main/java/useless/moonsteel/mixin/ChunkProviderStaticMixin.java b/src/main/java/useless/moonsteel/mixin/ChunkProviderStaticMixin.java index 949ab8e..08cba57 100644 --- a/src/main/java/useless/moonsteel/mixin/ChunkProviderStaticMixin.java +++ b/src/main/java/useless/moonsteel/mixin/ChunkProviderStaticMixin.java @@ -9,10 +9,10 @@ @Mixin(value = ChunkProviderStatic.class, remap = false) public class ChunkProviderStaticMixin { - @Inject(method = "canChunkExist(II)Z", at = @At("HEAD"), cancellable = true) - private void overrideChunk(final int chunkX, final int chunkZ, final CallbackInfoReturnable cir){ - if (MoonSteel.forceChunkLoads){ - cir.setReturnValue(true); - } - } + @Inject(method = "canChunkExist(II)Z", at = @At("HEAD"), cancellable = true) + private void overrideChunk(final int chunkX, final int chunkZ, final CallbackInfoReturnable cir) { + if (MoonSteel.forceChunkLoads) { + cir.setReturnValue(true); + } + } } diff --git a/src/main/java/useless/moonsteel/mixin/MobRenderZombieArmoredMixin.java b/src/main/java/useless/moonsteel/mixin/MobRenderZombieArmoredMixin.java index 20338e7..5ac6c37 100644 --- a/src/main/java/useless/moonsteel/mixin/MobRenderZombieArmoredMixin.java +++ b/src/main/java/useless/moonsteel/mixin/MobRenderZombieArmoredMixin.java @@ -12,15 +12,15 @@ @Mixin(value = MobRendererZombieArmored.class, remap = false) public class MobRenderZombieArmoredMixin extends MobRendererBiped { - public MobRenderZombieArmoredMixin(final ModelBiped model, final float shadowSize) { - super(model, shadowSize); - } + public MobRenderZombieArmoredMixin(final ModelBiped model, final float shadowSize) { + super(model, shadowSize); + } - @Inject(method = "prepareArmor(Lnet/minecraft/core/entity/monster/MobZombieArmored;IF)Z", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/MobRendererZombieArmored;bindTexture(Ljava/lang/String;)V", shift = At.Shift.AFTER)) - private void starZombie(final MobZombieArmored zombie, final int renderPass, final float partialTick, final CallbackInfoReturnable cir){ - if (((IStarZombie)zombie).moonsteel$isStarZombie()){ - this.bindTexture("/assets/moonsteel/textures/armor/moonsteel_" + (renderPass != 2 ? 1 : 2) + ".png"); - } - } + @Inject(method = "prepareArmor(Lnet/minecraft/core/entity/monster/MobZombieArmored;IF)Z", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/MobRendererZombieArmored;bindTexture(Ljava/lang/String;)V", shift = At.Shift.AFTER)) + private void starZombie(final MobZombieArmored zombie, final int renderPass, final float partialTick, final CallbackInfoReturnable cir) { + if (((IStarZombie) zombie).moonsteel$isStarZombie()) { + this.bindTexture("/assets/moonsteel/textures/armor/moonsteel_" + (renderPass != 2 ? 1 : 2) + ".png"); + } + } } diff --git a/src/main/java/useless/moonsteel/mixin/PacketHandlerClientMixin.java b/src/main/java/useless/moonsteel/mixin/PacketHandlerClientMixin.java deleted file mode 100644 index ae9194b..0000000 --- a/src/main/java/useless/moonsteel/mixin/PacketHandlerClientMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package useless.moonsteel.mixin; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.net.handler.PacketHandlerClient; -import net.minecraft.core.net.packet.PacketContainerOpen; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import useless.moonsteel.MoonSteel; -import useless.moonsteel.interfaces.IStarBackpack; - -@Mixin(value= PacketHandlerClient.class,remap = false) -public abstract class PacketHandlerClientMixin { - @Final - @Shadow - private Minecraft mc; - - @Inject(method="handleOpenWindow",at=@At("TAIL")) - public void inject(final PacketContainerOpen packetContainerOpen, final CallbackInfo ci) { - if (packetContainerOpen.inventoryType == MoonSteel.GUI_ID) { - ((IStarBackpack)(this.mc.thePlayer)).moonsteel$displayGuiStarBackpack(); - this.mc.thePlayer.craftingInventory.containerId = packetContainerOpen.windowId; - } - } -} diff --git a/src/main/java/useless/moonsteel/mixin/PlayerListMixin.java b/src/main/java/useless/moonsteel/mixin/PlayerListMixin.java deleted file mode 100644 index ce6c351..0000000 --- a/src/main/java/useless/moonsteel/mixin/PlayerListMixin.java +++ /dev/null @@ -1,18 +0,0 @@ -package useless.moonsteel.mixin; - -import com.llamalad7.mixinextras.sugar.Local; -import net.minecraft.server.entity.player.PlayerServer; -import net.minecraft.server.net.PlayerList; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import useless.moonsteel.interfaces.IStarBackpack; - -@Mixin(value = PlayerList.class, remap = false) -public class PlayerListMixin { - @Inject(method = "recreatePlayerEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/player/inventory/container/ContainerInventory;transferAllContents(Lnet/minecraft/core/player/inventory/container/ContainerInventory;)V", shift = At.Shift.AFTER)) - public void keepBackpackMP(final PlayerServer previousPlayer, final int i, final CallbackInfoReturnable cir, @Local(name = "newPlayer") final PlayerServer newPlayer){ - ((IStarBackpack)newPlayer).moonsteel$setStarBackpackInventory(((IStarBackpack)previousPlayer).moonsteel$getStarBackpackInventory()); - } -} diff --git a/src/main/java/useless/moonsteel/mixin/WorldFeatureLabyrinthMixin.java b/src/main/java/useless/moonsteel/mixin/WorldFeatureLabyrinthMixin.java index 9d3ba24..8d91709 100644 --- a/src/main/java/useless/moonsteel/mixin/WorldFeatureLabyrinthMixin.java +++ b/src/main/java/useless/moonsteel/mixin/WorldFeatureLabyrinthMixin.java @@ -2,7 +2,6 @@ import net.minecraft.core.WeightedRandomBag; import net.minecraft.core.WeightedRandomLootObject; -import net.minecraft.core.item.ItemStack; import net.minecraft.core.world.World; import net.minecraft.core.world.generate.feature.WorldFeatureLabyrinth; import org.spongepowered.asm.mixin.Mixin; @@ -10,18 +9,17 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import useless.moonsteel.MoonSteel; import useless.moonsteel.MoonSteelItems; import java.util.Random; @Mixin(value = WorldFeatureLabyrinth.class, remap = false) public class WorldFeatureLabyrinthMixin { - @Shadow - public WeightedRandomBag chestLoot; + @Shadow + public WeightedRandomBag chestLoot; - @Inject(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/WeightedRandomBag;addEntry(Ljava/lang/Object;D)V", ordinal = 0)) - private void addLoot(final World world, final Random random, final int x, final int y, final int z, final CallbackInfoReturnable cir){ - this.chestLoot.addEntry(new WeightedRandomLootObject(MoonSteelItems.INGOT_MOONSTEEL_CRUDE.getDefaultStack(), 1, 4), 5d); - } + @Inject(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/WeightedRandomBag;addEntry(Ljava/lang/Object;D)V", ordinal = 0)) + private void addLoot(final World world, final Random random, final int x, final int y, final int z, final CallbackInfoReturnable cir) { + this.chestLoot.addEntry(new WeightedRandomLootObject(MoonSteelItems.INGOT_MOONSTEEL_CRUDE.getDefaultStack(), 1, 4), 5d); + } } diff --git a/src/main/java/useless/moonsteel/mixin/WorldMixin.java b/src/main/java/useless/moonsteel/mixin/WorldMixin.java index 1286579..024f933 100644 --- a/src/main/java/useless/moonsteel/mixin/WorldMixin.java +++ b/src/main/java/useless/moonsteel/mixin/WorldMixin.java @@ -12,41 +12,40 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import useless.moonsteel.MoonSteel; import useless.moonsteel.MoonSteelItems; import useless.moonsteel.interfaces.IFallenStar; -import java.util.Iterator; import java.util.Random; @Mixin(value = World.class, remap = false) public abstract class WorldMixin { - @Shadow - public abstract Chunk getChunkFromChunkCoords(int x, int z); - - @Shadow - public WorldType worldType; - - @Shadow - protected int updateLCG; - - @Shadow - public abstract EntityItem dropItem(int x, int y, int z, ItemStack itemStack); - - @Shadow - public Random rand; - @Inject(method = "updateBlocksAndPlayCaveSounds()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/world/World;getChunkFromChunkCoords(II)Lnet/minecraft/core/world/chunk/Chunk;", shift = At.Shift.AFTER)) - private void makeTheStarsFall(final CallbackInfo ci, @Local(name = "coordinate") final ChunkCoordinate coordinate){ - if (!MoonSteel.isStarTime((World) (Object)this)) return; - final Chunk chunk = this.getChunkFromChunkCoords(coordinate.x, coordinate.z); - if (this.rand.nextInt(MoonSteel.STAR_SPAWN_RATE) == 0){ - this.updateLCG = this.updateLCG * 3 + 1013904223; - final int randVal = this.updateLCG >> 2; - final int blockX = chunk.xPosition * 16 + (randVal & 0xF); - final int blockZ = chunk.zPosition * 16 + (randVal / 256 & 0xF); - - ((IFallenStar)dropItem(blockX, this.worldType.getMaxY() + 32, blockZ, MoonSteelItems.STAR_FALLEN.getDefaultStack())).moonsteel$setDaylightSensitive(true); - } - } + @Shadow + public abstract Chunk getChunkFromChunkCoords(int x, int z); + + @Shadow + public WorldType worldType; + + @Shadow + protected int updateLCG; + + @Shadow + public abstract EntityItem dropItem(int x, int y, int z, ItemStack itemStack); + + @Shadow + public Random rand; + + @Inject(method = "updateBlocksAndPlayCaveSounds()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/world/World;getChunkFromChunkCoords(II)Lnet/minecraft/core/world/chunk/Chunk;", shift = At.Shift.AFTER)) + private void makeTheStarsFall(final CallbackInfo ci, @Local(name = "coordinate") final ChunkCoordinate coordinate) { + if (!MoonSteel.isStarTime((World) (Object) this)) return; + final Chunk chunk = this.getChunkFromChunkCoords(coordinate.x, coordinate.z); + if (this.rand.nextInt(MoonSteel.STAR_SPAWN_RATE) == 0) { + this.updateLCG = this.updateLCG * 3 + 1013904223; + final int randVal = this.updateLCG >> 2; + final int blockX = chunk.xPosition * 16 + (randVal & 0xF); + final int blockZ = chunk.zPosition * 16 + (randVal / 256 & 0xF); + + ((IFallenStar) dropItem(blockX, this.worldType.getMaxY() + 32, blockZ, MoonSteelItems.STAR_FALLEN.getDefaultStack())).moonsteel$setDaylightSensitive(true); + } + } } diff --git a/src/main/java/useless/moonsteel/mixin/accessor/ItemToolSwordAccessor.java b/src/main/java/useless/moonsteel/mixin/accessor/ItemToolSwordAccessor.java index 9945b73..6cfdffc 100644 --- a/src/main/java/useless/moonsteel/mixin/accessor/ItemToolSwordAccessor.java +++ b/src/main/java/useless/moonsteel/mixin/accessor/ItemToolSwordAccessor.java @@ -7,6 +7,6 @@ @Mixin(value = ItemToolSword.class, remap = false) public interface ItemToolSwordAccessor { - @Accessor - ToolMaterial getMaterial(); + @Accessor + ToolMaterial getMaterial(); } diff --git a/src/main/java/useless/moonsteel/mixin/backpack/MinecraftMixin.java b/src/main/java/useless/moonsteel/mixin/backpack/MinecraftMixin.java deleted file mode 100644 index b64b2b5..0000000 --- a/src/main/java/useless/moonsteel/mixin/backpack/MinecraftMixin.java +++ /dev/null @@ -1,23 +0,0 @@ -package useless.moonsteel.mixin.backpack; - -import com.llamalad7.mixinextras.sugar.Local; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.PlayerLocal; -import net.minecraft.core.entity.player.Player; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import useless.moonsteel.interfaces.IStarBackpack; - -@Mixin(value = Minecraft.class, remap = false) -public class MinecraftMixin { - @Shadow - public PlayerLocal thePlayer; - - @Inject(method = "respawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/player/PlayerLocal;setGamemode(Lnet/minecraft/core/player/gamemode/Gamemode;)V", shift = At.Shift.AFTER)) - public void keepBackpack(boolean flag, int i, CallbackInfo ci, @Local Player previousPlayer){ - ((IStarBackpack)thePlayer).moonsteel$setStarBackpackInventory(((IStarBackpack)previousPlayer).moonsteel$getStarBackpackInventory()); - } -} diff --git a/src/main/java/useless/moonsteel/mixin/backpack/PlayerLocalMixin.java b/src/main/java/useless/moonsteel/mixin/backpack/PlayerLocalMixin.java deleted file mode 100644 index 8616cb9..0000000 --- a/src/main/java/useless/moonsteel/mixin/backpack/PlayerLocalMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package useless.moonsteel.mixin.backpack; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.PlayerLocal; -import net.minecraft.core.world.World; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import useless.moonsteel.GuiStarBackpack; - -@Mixin(value = PlayerLocal.class, remap = false) -public class PlayerLocalMixin extends PlayerMixin { - @Shadow - protected Minecraft mc; - @Unique - public PlayerLocal thisAs = (PlayerLocal) (Object)this; - - public PlayerLocalMixin(@Nullable World world) { - super(world); - } - - @Override - public void moonsteel$displayGuiStarBackpack() { - this.mc.displayScreen(new GuiStarBackpack(this.thisAs)); - } -} diff --git a/src/main/java/useless/moonsteel/mixin/backpack/PlayerMixin.java b/src/main/java/useless/moonsteel/mixin/backpack/PlayerMixin.java deleted file mode 100644 index 52f4a6a..0000000 --- a/src/main/java/useless/moonsteel/mixin/backpack/PlayerMixin.java +++ /dev/null @@ -1,58 +0,0 @@ -package useless.moonsteel.mixin.backpack; - -import com.mojang.nbt.tags.CompoundTag; -import com.mojang.nbt.tags.ListTag; -import net.minecraft.core.entity.Mob; -import net.minecraft.core.entity.player.Player; -import net.minecraft.core.world.World; -import org.jetbrains.annotations.Nullable; -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; -import useless.moonsteel.StarBackpackInventory; -import useless.moonsteel.interfaces.IStarBackpack; -import useless.moonsteel.interfaces.ITeleporter; - -@Mixin(value = Player.class, remap = false) -public abstract class PlayerMixin extends Mob implements IStarBackpack, ITeleporter { - @Unique - public StarBackpackInventory starBackpackInventory; - - public PlayerMixin(@Nullable final World world) { - super(world); - } - - @Inject(method = "(Lnet/minecraft/core/world/World;)V", at = @At("TAIL")) - private void createBackpack(final World world, final CallbackInfo ci){ - this.starBackpackInventory = new StarBackpackInventory((Player) (Object)this); - } - @Inject(method = "addAdditionalSaveData", at = @At("TAIL")) - private void addData(final CompoundTag tag, final CallbackInfo ci){ - tag.put("moonsteel$InventoryStardust", this.starBackpackInventory.writeToNBT(new ListTag())); - } - @Inject(method = "readAdditionalSaveData", at = @At("TAIL")) - private void loadData(final CompoundTag tag, final CallbackInfo ci){ - this.starBackpackInventory.readFromNBT(tag.getList("moonsteel$InventoryStardust")); - } - @Override - public StarBackpackInventory moonsteel$getStarBackpackInventory() { - return this.starBackpackInventory; - } - - @Override - public void moonsteel$setStarBackpackInventory(final StarBackpackInventory backpackInventory) { - this.starBackpackInventory = backpackInventory; - } - - @Override - public void moonsteel$displayGuiStarBackpack() { - - } - - @Override - public void moonsteel$teleport(final double x, final double y, final double z) { - setPos(x, y + this.bbHeight, z); - } -} diff --git a/src/main/java/useless/moonsteel/mixin/backpack/PlayerServerMixin.java b/src/main/java/useless/moonsteel/mixin/backpack/PlayerServerMixin.java deleted file mode 100644 index d0f7461..0000000 --- a/src/main/java/useless/moonsteel/mixin/backpack/PlayerServerMixin.java +++ /dev/null @@ -1,48 +0,0 @@ -package useless.moonsteel.mixin.backpack; - -import net.minecraft.core.net.packet.PacketContainerOpen; -import net.minecraft.core.world.World; -import net.minecraft.server.entity.player.PlayerServer; -import net.minecraft.server.net.handler.PacketHandlerServer; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import useless.moonsteel.ContainerStarBackpack; -import useless.moonsteel.MoonSteel; - -@Mixin(value = PlayerServer.class, remap = false) -public abstract class PlayerServerMixin extends PlayerMixin { - public PlayerServerMixin(@Nullable World world) { - super(world); - } - - @Shadow - protected abstract void getNextWindowId(); - - @Shadow - private int currentWindowId; - @Shadow - public PacketHandlerServer playerNetServerHandler; - @Unique - public PlayerServer thisAs = (PlayerServer) (Object)this; - - @Override - public void moonsteel$displayGuiStarBackpack() { - this.getNextWindowId(); - ContainerStarBackpack backpack = new ContainerStarBackpack(thisAs); - this.thisAs - .playerNetServerHandler - .sendPacket( - new PacketContainerOpen(this.currentWindowId, MoonSteel.GUI_ID, "moonsteel$StarBackpack", backpack.backpackInventory.getContainerSize()) - ); - this.thisAs.craftingInventory = backpack; - this.thisAs.craftingInventory.containerId = this.currentWindowId; - this.thisAs.craftingInventory.addSlotListener(this.thisAs); - } - - @Override - public void moonsteel$teleport(final double x, final double y, final double z) { - this.playerNetServerHandler.teleport(x, y, z); - } -} diff --git a/src/main/java/useless/moonsteel/mixin/entity/EntityItemMixin.java b/src/main/java/useless/moonsteel/mixin/entity/EntityItemMixin.java index ca8d498..a1c05ff 100644 --- a/src/main/java/useless/moonsteel/mixin/entity/EntityItemMixin.java +++ b/src/main/java/useless/moonsteel/mixin/entity/EntityItemMixin.java @@ -17,43 +17,47 @@ @Mixin(value = EntityItem.class, remap = false) public abstract class EntityItemMixin extends Entity implements IFallenStar { - @Shadow - public ItemStack item; - @Unique - public boolean despawnInDay = false; - - public EntityItemMixin(final World world) { - super(world); - } - @Inject(method = "(Lnet/minecraft/core/world/World;DDDLnet/minecraft/core/item/ItemStack;)V", at = @At("TAIL")) - private void constuct1(final World world, final double d, final double d1, final double d2, final ItemStack itemstack, final CallbackInfo ci){ - if (itemstack.getItem() == MoonSteelItems.STAR_FALLEN){ - this.viewScale = 30; - if (this.y > world.getWorldType().getMaxY()){ - world.playSoundEffect(null, SoundCategory.WEATHER_SOUNDS, (float) this.x, world.findTopSolidBlock((int) this.x, (int) this.z) + 10, (float) this.z, "moonsteel:starspawn", 5, 1f + this.random.nextFloat() * 0.1f); - } - } - } - @Inject(method = "tick()V", at = @At("TAIL")) - private void tick(final CallbackInfo ci){ - if (this.despawnInDay && this.world.isDaytime()){ - this.remove(); - } - } - - @Override - public void moonsteel$setDaylightSensitive(final boolean flag) { - this.despawnInDay = flag; - } - @Inject(method = "addAdditionalSaveData", at = @At("TAIL")) - private void saveData(final CompoundTag tag, final CallbackInfo ci){ - tag.putBoolean("moonsteel$daydespawn", this.despawnInDay); - } - @Inject(method = "readAdditionalSaveData", at = @At("TAIL")) - private void loadData(final CompoundTag tag, final CallbackInfo ci){ - this.despawnInDay = tag.getBoolean("moonsteel$daydespawn"); - if (this.item.getItem() == MoonSteelItems.STAR_FALLEN){ - this.viewScale = 5; - } - } + @Shadow + public ItemStack item; + @Unique + public boolean despawnInDay = false; + + protected EntityItemMixin(final World world) { + super(world); + } + + @Inject(method = "(Lnet/minecraft/core/world/World;DDDLnet/minecraft/core/item/ItemStack;)V", at = @At("TAIL")) + private void constuct1(final World world, final double d, final double d1, final double d2, final ItemStack itemstack, final CallbackInfo ci) { + if (itemstack.getItem().equals(MoonSteelItems.STAR_FALLEN)) { + this.viewScale = 30; + if (this.y > world.getWorldType().getMaxY()) { + world.playSoundEffect(null, SoundCategory.WEATHER_SOUNDS, (float) this.x, world.findTopSolidBlock((int) this.x, (int) this.z) + 10, (float) this.z, "moonsteel:starspawn", 5, 1f + this.random.nextFloat() * 0.1f); + } + } + } + + @Inject(method = "tick()V", at = @At("TAIL")) + private void tick(final CallbackInfo ci) { + if (this.despawnInDay && this.world.isDaytime()) { + this.remove(); + } + } + + @Override + public void moonsteel$setDaylightSensitive(final boolean flag) { + this.despawnInDay = flag; + } + + @Inject(method = "addAdditionalSaveData", at = @At("TAIL")) + private void saveData(final CompoundTag tag, final CallbackInfo ci) { + tag.putBoolean("moonsteel$daydespawn", this.despawnInDay); + } + + @Inject(method = "readAdditionalSaveData", at = @At("TAIL")) + private void loadData(final CompoundTag tag, final CallbackInfo ci) { + this.despawnInDay = tag.getBoolean("moonsteel$daydespawn"); + if (this.item.getItem().equals(MoonSteelItems.STAR_FALLEN)) { + this.viewScale = 5; + } + } } diff --git a/src/main/java/useless/moonsteel/mixin/entity/MobMixin.java b/src/main/java/useless/moonsteel/mixin/entity/MobMixin.java index d2cf89b..fd956f3 100644 --- a/src/main/java/useless/moonsteel/mixin/entity/MobMixin.java +++ b/src/main/java/useless/moonsteel/mixin/entity/MobMixin.java @@ -14,53 +14,54 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import useless.moonsteel.MoonSteel; import useless.moonsteel.MoonSteelItems; import useless.moonsteel.interfaces.IMoonGrav; -import useless.moonsteel.MoonSteel; import useless.moonsteel.mixin.accessor.ItemToolSwordAccessor; @Mixin(value = Mob.class, remap = false) public abstract class MobMixin extends Entity { - @Shadow - protected abstract void dropDeathItems(); + @Shadow + protected abstract void dropDeathItems(); + + protected MobMixin(final World world) { + super(world); + } - public MobMixin(final World world) { - super(world); - } + @Redirect(method = "moveEntityWithHeading(FF)V", at = @At(value = "FIELD", target = "Lnet/minecraft/core/entity/Mob;yd:D", opcode = Opcodes.PUTFIELD)) + private void entityGravity(final Mob entity, final double yd) { //Probably terrible way of modifying gravity by a scalar + if (entity instanceof IMoonGrav) { + final double offset = -(yd - this.yd); + final double scalar = ((IMoonGrav) entity).moonsteel$getGravScalar(); + if ((0.021 > offset && offset > 0.019) || (0.081 > offset && offset > 0.079)) { // If falling in water or in air + entity.yd -= offset * scalar; + } else if ((-0.251 < yd && yd < -0.249)) { // Terminal velocity + entity.yd = yd * scalar; + } else { // Else regular behavior + entity.yd = yd; + } + } else { + entity.yd = yd; + } + } - @Redirect(method = "moveEntityWithHeading(FF)V", at = @At(value = "FIELD", target = "Lnet/minecraft/core/entity/Mob;yd:D", opcode = Opcodes.PUTFIELD)) - private void entityGravity(final Mob entity, final double yd){ //Probably terrible way of modifying gravity by a scalar - if (entity instanceof IMoonGrav){ - final double offset = -(yd - this.yd); - final double scalar = ((IMoonGrav) entity).moonsteel$getGravScalar(); - if ((0.021 > offset && offset > 0.019) || (0.081 > offset && offset > 0.079)){ // If falling in water or in air - entity.yd -= offset * scalar; - } else if ((-0.251 < yd && yd < -0.249)) { // Terminal velocity - entity.yd = yd * scalar; - } else { // Else regular behavior - entity.yd = yd; - } - } else { - entity.yd = yd; - } - } - @ModifyVariable(method = "causeFallDamage(F)V", at = @At(value = "STORE"), ordinal = 0) - private int changeFallDamage(final int i){ - if (this instanceof IMoonGrav){ - return (int)((i * ((IMoonGrav) this).moonsteel$getGravScalar()) - (3/((IMoonGrav) this).moonsteel$getGravScalar()) + 3); - } - return i; - } + @ModifyVariable(method = "causeFallDamage(F)V", at = @At(value = "STORE"), ordinal = 0) + private int changeFallDamage(final int i) { + if (this instanceof IMoonGrav) { + return (int) ((i * ((IMoonGrav) this).moonsteel$getGravScalar()) - (3 / ((IMoonGrav) this).moonsteel$getGravScalar()) + 3); + } + return i; + } - @Inject(method = "onDeath(Lnet/minecraft/core/entity/Entity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/entity/Mob;dropDeathItems()V")) - private void multiplyDrop(final Entity entity, final CallbackInfo ci){ - if (entity instanceof Player){ - final ItemStack heldStack = ((Player) entity).getHeldItem(); - if (heldStack != null && heldStack.getItem() instanceof ItemToolSword && ((ItemToolSwordAccessor) heldStack.getItem()).getMaterial() == MoonSteelItems.moonSteelTool){ - for (int i = 0; i < this.random.nextInt(MoonSteel.LOOTING_AMOUNT); i++) { - dropDeathItems(); - } - } - } - } + @Inject(method = "onDeath(Lnet/minecraft/core/entity/Entity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/entity/Mob;dropDeathItems()V")) + private void multiplyDrop(final Entity entity, final CallbackInfo ci) { + if (entity instanceof Player) { + final ItemStack heldStack = ((Player) entity).getHeldItem(); + if (heldStack != null && heldStack.getItem() instanceof ItemToolSword && ((ItemToolSwordAccessor) heldStack.getItem()).getMaterial() == MoonSteelItems.moonSteelTool) { + for (int i = 0; i < this.random.nextInt(MoonSteel.LOOTING_AMOUNT); i++) { + dropDeathItems(); + } + } + } + } } diff --git a/src/main/java/useless/moonsteel/mixin/entity/MobZombieArmoredMixin.java b/src/main/java/useless/moonsteel/mixin/entity/MobZombieArmoredMixin.java index 63556b7..11befcd 100644 --- a/src/main/java/useless/moonsteel/mixin/entity/MobZombieArmoredMixin.java +++ b/src/main/java/useless/moonsteel/mixin/entity/MobZombieArmoredMixin.java @@ -21,70 +21,73 @@ @Mixin(value = MobZombieArmored.class, remap = false) public abstract class MobZombieArmoredMixin extends MobZombie implements IMoonGrav, IStarZombie { - @Unique - private static final int DATA_FLAG_STARTIME = 20; - @Shadow - public abstract int[] getArmorBreakPoints(); + @Unique + private static final int DATA_FLAG_STARTIME = 20; - @Shadow - public abstract boolean isHoldingSword(); + @Shadow + public abstract int[] getArmorBreakPoints(); - public MobZombieArmoredMixin(final World world) { - super(world); - } + @Shadow + public abstract boolean isHoldingSword(); - @Inject(method = "defineSynchedData", at = @At("TAIL")) - public void defineSynchedData(final CallbackInfo ci){ - this.entityData.define(DATA_FLAG_STARTIME, (byte)0, Byte.class); - } + protected MobZombieArmoredMixin(final World world) { + super(world); + } - @Inject(method = "spawnInit", at = @At("TAIL")) - public void sInit(final CallbackInfo ci){ - if (MoonSteel.isStarTime(this.world)){ - this.entityData.set(DATA_FLAG_STARTIME, (byte)1); - } - } - @Override - public double moonsteel$getGravScalar() { - if (moonsteel$isStarZombie()){ - double scalar = 1d; - final int[] breakPoints = this.getArmorBreakPoints(); - for (int i = 0; i < 4; ++i) { - if (this.getHealth() > breakPoints[i]) scalar -= 0.125d; - } - return scalar; - } - return 1d; - } + @Inject(method = "defineSynchedData", at = @At("TAIL")) + public void defineSynchedData(final CallbackInfo ci) { + this.entityData.define(DATA_FLAG_STARTIME, (byte) 0, Byte.class); + } - @Override - public boolean moonsteel$isStarZombie() { - return this.entityData.getByte(DATA_FLAG_STARTIME) == 1; - } - @Inject(method = "getHeldItem()Lnet/minecraft/core/item/ItemStack;", at = @At("HEAD"), cancellable = true) - private void sword(final CallbackInfoReturnable cir){ - if (isHoldingSword() && moonsteel$isStarZombie()){ - cir.setReturnValue(MoonSteel.starZombieSword); - } - } + @Inject(method = "spawnInit", at = @At("TAIL")) + public void sInit(final CallbackInfo ci) { + if (MoonSteel.isStarTime(this.world)) { + this.entityData.set(DATA_FLAG_STARTIME, (byte) 1); + } + } - @Redirect(method = "hurt(Lnet/minecraft/core/entity/Entity;ILnet/minecraft/core/util/helper/DamageType;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/entity/monster/MobZombieArmored;dropItem(Lnet/minecraft/core/item/ItemStack;F)Lnet/minecraft/core/entity/EntityItem;")) - private EntityItem spawnRedirect(final MobZombieArmored instance, final ItemStack stack, final float v){ - if (moonsteel$isStarZombie()){ - return dropItem(MoonSteelItems.STAR_FALLEN.getDefaultStack(), v); - } - return dropItem(stack, v); - } + @Override + public double moonsteel$getGravScalar() { + if (moonsteel$isStarZombie()) { + double scalar = 1d; + final int[] breakPoints = this.getArmorBreakPoints(); + for (int i = 0; i < 4; ++i) { + if (this.getHealth() > breakPoints[i]) scalar -= 0.125d; + } + return scalar; + } + return 1d; + } - @Inject(method = "addAdditionalSaveData", at = @At("TAIL")) - public void addAdditionalSaveData(final CompoundTag tag, final CallbackInfo ci) { - tag.putByte("moonsteel$starzombie", this.entityData.getByte(DATA_FLAG_STARTIME)); - } + @Override + public boolean moonsteel$isStarZombie() { + return this.entityData.getByte(DATA_FLAG_STARTIME) == 1; + } - @Inject(method = "readAdditionalSaveData", at = @At("TAIL")) - public void readAdditionalSaveData(final CompoundTag tag, final CallbackInfo ci) { - this.entityData.set(DATA_FLAG_STARTIME, tag.getByte("moonsteel$starzombie")); - } + @Inject(method = "getHeldItem()Lnet/minecraft/core/item/ItemStack;", at = @At("HEAD"), cancellable = true) + private void sword(final CallbackInfoReturnable cir) { + if (isHoldingSword() && moonsteel$isStarZombie()) { + cir.setReturnValue(MoonSteel.starZombieSword); + } + } + + @Redirect(method = "hurt(Lnet/minecraft/core/entity/Entity;ILnet/minecraft/core/util/helper/DamageType;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/entity/monster/MobZombieArmored;dropItem(Lnet/minecraft/core/item/ItemStack;F)Lnet/minecraft/core/entity/EntityItem;")) + private EntityItem spawnRedirect(final MobZombieArmored instance, final ItemStack stack, final float v) { + if (moonsteel$isStarZombie()) { + return dropItem(MoonSteelItems.STAR_FALLEN.getDefaultStack(), v); + } + return dropItem(stack, v); + } + + @Inject(method = "addAdditionalSaveData", at = @At("TAIL")) + public void addAdditionalSaveData(final CompoundTag tag, final CallbackInfo ci) { + tag.putByte("moonsteel$starzombie", this.entityData.getByte(DATA_FLAG_STARTIME)); + } + + @Inject(method = "readAdditionalSaveData", at = @At("TAIL")) + public void readAdditionalSaveData(final CompoundTag tag, final CallbackInfo ci) { + this.entityData.set(DATA_FLAG_STARTIME, tag.getByte("moonsteel$starzombie")); + } } diff --git a/src/main/java/useless/moonsteel/mixin/entity/PlayerMixin.java b/src/main/java/useless/moonsteel/mixin/entity/PlayerMixin.java index 9d42e12..d2bdfef 100644 --- a/src/main/java/useless/moonsteel/mixin/entity/PlayerMixin.java +++ b/src/main/java/useless/moonsteel/mixin/entity/PlayerMixin.java @@ -10,16 +10,20 @@ @Mixin(value = Player.class, remap = false) public class PlayerMixin implements IMoonGrav { - @Shadow - public ContainerInventory inventory; + @Shadow + public ContainerInventory inventory; - @Override - public double moonsteel$getGravScalar() { - double scalar = 0d; - if (inventory.armorItemInSlot(IArmorItem.PIECE_HEAD) != null && inventory.armorItemInSlot(IArmorItem.PIECE_HEAD).getItem() == MoonSteelItems.ARMOR_HELMET_MOONSTEEL) scalar += 0.167d; - if (inventory.armorItemInSlot(IArmorItem.PIECE_CHEST) != null && inventory.armorItemInSlot(IArmorItem.PIECE_CHEST).getItem() == MoonSteelItems.ARMOR_CHESTPLATE_MOONSTEEL) scalar += 0.334d; - if (inventory.armorItemInSlot(IArmorItem.PIECE_LEGS) != null && inventory.armorItemInSlot(IArmorItem.PIECE_LEGS).getItem() == MoonSteelItems.ARMOR_LEGGINGS_MOONSTEEL) scalar += 0.167d; - if (inventory.armorItemInSlot(IArmorItem.PIECE_BOOTS) != null && inventory.armorItemInSlot(IArmorItem.PIECE_BOOTS).getItem() == MoonSteelItems.ARMOR_BOOTS_MOONSTEEL) scalar += 0.334d; - return (1/(scalar + 1)); - } + @Override + public double moonsteel$getGravScalar() { + double scalar = 0d; + if (inventory.armorItemInSlot(IArmorItem.PIECE_HEAD) != null && inventory.armorItemInSlot(IArmorItem.PIECE_HEAD).getItem().equals(MoonSteelItems.ARMOR_HELMET_MOONSTEEL)) + scalar += 0.167d; + if (inventory.armorItemInSlot(IArmorItem.PIECE_CHEST) != null && inventory.armorItemInSlot(IArmorItem.PIECE_CHEST).getItem().equals(MoonSteelItems.ARMOR_CHESTPLATE_MOONSTEEL)) + scalar += 0.334d; + if (inventory.armorItemInSlot(IArmorItem.PIECE_LEGS) != null && inventory.armorItemInSlot(IArmorItem.PIECE_LEGS).getItem().equals(MoonSteelItems.ARMOR_LEGGINGS_MOONSTEEL)) + scalar += 0.167d; + if (inventory.armorItemInSlot(IArmorItem.PIECE_BOOTS) != null && inventory.armorItemInSlot(IArmorItem.PIECE_BOOTS).getItem().equals(MoonSteelItems.ARMOR_BOOTS_MOONSTEEL)) + scalar += 0.334d; + return (1 / (scalar + 1)); + } } diff --git a/src/main/resources/assets/moonsteel/textures/item/moonsteel_crude.png b/src/main/resources/assets/moonsteel/textures/item/moonsteel_crude.png index cb21d4c..c15b1df 100644 Binary files a/src/main/resources/assets/moonsteel/textures/item/moonsteel_crude.png and b/src/main/resources/assets/moonsteel/textures/item/moonsteel_crude.png differ diff --git a/src/main/resources/compat/backpack/backpack.mixins.json b/src/main/resources/compat/backpack/backpack.mixins.json new file mode 100644 index 0000000..40fb10b --- /dev/null +++ b/src/main/resources/compat/backpack/backpack.mixins.json @@ -0,0 +1,23 @@ +{ + "required": true, + "mixinextras": { + "minVersion": "0.5.0" + }, + "package": "useless.moonsteel.compat.backpacks.mixin", + "compatibilityLevel": "JAVA_${java}", + "injectors": { + "defaultRequire": 1 + }, + "server": [ + "PlayerListMixin", + "backpack.PlayerServerMixin" + ], + "mixins": [ + "backpack.PlayerMixin" + ], + "client": [ + "PacketHandlerClientMixin", + "backpack.MinecraftMixin", + "backpack.PlayerLocalMixin" + ] +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2449953..d421a3a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -2,57 +2,63 @@ "schemaVersion": 1, "id": "moonsteel", "version": "${version}", - "name": "MoonMoonMoon", "description": "Adds a new cosmic material to the game with special properties.", "authors": [ "Useless" ], - "contributors": [ - "BigJango" - ], - "contact": { + "contributors": [ + "BigJango", + "LukeisStuff" + ], + "contact": { "homepage": "https://github.com/UselessSolutions/moonmoonmoon", "issues": "https://github.com/UselessSolutions/moonmoonmoon/issues" }, - - "icon": "icon.png", + "icon": "icon.png", "license": "CC0-1.0", - "environment": "*", "entrypoints": { "main": [ - "useless.moonsteel.MoonSteel" + "useless.moonsteel.MoonSteel" + ], + "beforeGameStart": [ + "useless.moonsteel.MoonSteel", + "useless.moonsteel.compat.backpacks.MoonSteelBackpackCompatibility" + ], + "afterGameStart": [ + "useless.moonsteel.MoonSteel", + "useless.moonsteel.compat.backpacks.MoonSteelBackpackCompatibility" + ], + "recipesReady": [ + "useless.moonsteel.MoonSteelRecipes", + "useless.moonsteel.compat.backpacks.MoonSteelBackpackCompatibility" ], - "beforeGameStart": [ - "useless.moonsteel.MoonSteel" - ], - "afterGameStart": [ - "useless.moonsteel.MoonSteel" - ], - "recipesReady": [ - "useless.moonsteel.MoonSteelRecipes" - ], - "beforeClientStart": [ - "useless.moonsteel.MoonSteelClient" - ], - "afterClientStart": [ - "useless.moonsteel.MoonSteelClient" - ], - "initModels": [ - "useless.moonsteel.MoonSteelModels" - ] - }, + "beforeClientStart": [ + "useless.moonsteel.MoonSteelClient" + ], + "afterClientStart": [ + "useless.moonsteel.MoonSteelClient" + ], + "initModels": [ + "useless.moonsteel.MoonSteelModels", + "useless.moonsteel.compat.backpacks.MoonSteelBackpackCompatibility" + ], + "preLaunch": [ + "useless.moonsteel.compat.deep.MoonSteelDeepCompatibility", + "useless.moonsteel.compat.backpacks.MoonSteelBackpackCompatibility" + ] + }, "mixins": [ - "moonsteel.mixins.json" + "moonsteel.mixins.json" ], - "depends": { - "minecraft": "~7.3", - "fabricloader": ">=0.13.3", - "halplibe": ">=5.2.0" + "fabricloader": ">=${fabricloader}", + "halplibe": ">=${halplibe}", + "minecraft": "*", + "java": ">=${java}" }, "suggests": { - "betterwithbackpacks": ">=1.1.10" + "modmenu": ">=${modmenu}" } } diff --git a/src/main/resources/lang/moonsteel/en_US.lang b/src/main/resources/lang/moonsteel/en_US.lang index 8f86ac3..f560ea1 100644 --- a/src/main/resources/lang/moonsteel/en_US.lang +++ b/src/main/resources/lang/moonsteel/en_US.lang @@ -2,6 +2,7 @@ item.moonsteel.ingot.moonsteel.name=Moonsteel Ingot item.moonsteel.ingot.moonsteel.desc=Steel and Stardust fused into a powerful alloy. item.moonsteel.crude.moonsteel.name=Crude Moonsteel item.moonsteel.crude.moonsteel.desc=Steel and Stardust waiting to be fused. + item.moonsteel.tool.axe.moonsteel.name=Moonsteel Axe item.moonsteel.tool.axe.moonsteel.desc=Chop some trees with this fortunate moonsteel tool. item.moonsteel.tool.pickaxe.moonsteel.name=Moonsteel Pickaxe @@ -12,6 +13,7 @@ item.moonsteel.tool.hoe.moonsteel.name=Moonsteel Hoe item.moonsteel.tool.hoe.moonsteel.desc=Till the land with this fortunate moonsteel tool. item.moonsteel.tool.sword.moonsteel.name=Moonsteel Sword item.moonsteel.tool.sword.moonsteel.desc=Slay pesky monsters with this fortunate moonsteel tool. + item.moonsteel.helmet.moonsteel.name=Moonsteel Helmet item.moonsteel.helmet.moonsteel.desc=A weightless moonsteel helmet. item.moonsteel.chestplate.moonsteel.name=Moonsteel Chestplate @@ -20,12 +22,11 @@ item.moonsteel.leggings.moonsteel.name=Moonsteel Leggings item.moonsteel.leggings.moonsteel.desc=A pair of weightless moonsteel leggings. item.moonsteel.boots.moonsteel.name=Moonsteel Boots item.moonsteel.boots.moonsteel.desc=A pair of weightless moonsteel boots. + item.moonsteel.star.fallen.name=Fallen Star item.moonsteel.star.fallen.desc=A fallen stellar object with interesting properties. item.moonsteel.backpack.cosmic.name=Stardust Backpack item.moonsteel.backpack.cosmic.desc=Stores your items in a pocket dimension. -item.moonsteel.backpack.cosmic.missing.name=Install Better with Backpacks -item.moonsteel.backpack.cosmic.missing.desc=This item does nothing without Better with Backpacks item.moonsteel.star.connected.name=Connected Star item.moonsteel.star.connected.desc=A star entangled with a location. diff --git a/src/main/resources/lang/moonsteel/ru_RU.lang b/src/main/resources/lang/moonsteel/ru_RU.lang index 9e3dec1..79dfccb 100644 --- a/src/main/resources/lang/moonsteel/ru_RU.lang +++ b/src/main/resources/lang/moonsteel/ru_RU.lang @@ -2,6 +2,7 @@ item.moonsteel.ingot.moonsteel.name=Лунсталный Слиток item.moonsteel.ingot.moonsteel.desc=Сталь и Звезди слито в одно целое. item.moonsteel.crude.moonsteel.name=Сырая Лунсталь item.moonsteel.crude.moonsteel.desc=Сталь и Звезди ждут чтобы быть слитым в одно целое. + item.moonsteel.tool.axe.moonsteel.name=Лунстальный топор item.moonsteel.tool.axe.moonsteel.desc=Рубите деревья этим удачним лунстальным инструментом. item.moonsteel.tool.pickaxe.moonsteel.name=Лунстальный кирка @@ -12,6 +13,7 @@ item.moonsteel.tool.hoe.moonsteel.name=Лунстальный мотыга item.moonsteel.tool.hoe.moonsteel.desc=Вскопайте землю этим удачним лунстальным инструментом. item.moonsteel.tool.sword.moonsteel.name=Лунсталный меч item.moonsteel.tool.sword.moonsteel.desc=Вейте монстров этим удачним лунстальным инструментом. + item.moonsteel.helmet.moonsteel.name=Лунсталный шлем item.moonsteel.helmet.moonsteel.desc=Невесомый, но сильный лунстальный шлем. item.moonsteel.chestplate.moonsteel.name=Лунсталный нагрудник @@ -20,12 +22,11 @@ item.moonsteel.leggings.moonsteel.name=Лунсталный поноги item.moonsteel.leggings.moonsteel.desc=Невесомые, но сильные лунстальные поноги. item.moonsteel.boots.moonsteel.name=Лунсталный ботинки item.moonsteel.boots.moonsteel.desc=Невесомые, но сильные лунстальные ботинки. + item.moonsteel.star.fallen.name=Потеряная Звезвда item.moonsteel.star.fallen.desc=Ох звезда, от куда ты пришла? item.moonsteel.backpack.cosmic.name=Звезвдный Рюкзак item.moonsteel.backpack.cosmic.desc=Хранит ваши предметы в карманном измерении. -item.moonsteel.backpack.cosmic.missing.name=Установи мод Better with Backpacks -item.moonsteel.backpack.cosmic.missing.desc=Ничего не делает без Better with Backpacks item.moonsteel.star.connected.name=Соединенная звезда item.moonsteel.star.connected.desc=Звезда связання с чем-то. diff --git a/src/main/resources/moonsteel.mixins.json b/src/main/resources/moonsteel.mixins.json index 6d15536..caf4cc6 100644 --- a/src/main/resources/moonsteel.mixins.json +++ b/src/main/resources/moonsteel.mixins.json @@ -1,23 +1,21 @@ { "required": true, - "minVersion": "0.8", + "mixinextras": { + "minVersion": "0.5.0" + }, "package": "useless.moonsteel.mixin", - "compatibilityLevel": "JAVA_8", - "plugin": "useless.moonsteel.MoonSteelMixinPlugin", + "compatibilityLevel": "JAVA_${java}", "injectors": { "defaultRequire": 1 }, "server": [ - "ChunkProviderServerMixin", - "PlayerListMixin", - "backpack.PlayerServerMixin" + "ChunkProviderServerMixin" ], "mixins": [ "BlockLogicMixin", "WorldFeatureLabyrinthMixin", "WorldMixin", "accessor.ItemToolSwordAccessor", - "backpack.PlayerMixin", "entity.EntityItemMixin", "entity.MobMixin", "entity.MobZombieArmoredMixin", @@ -25,9 +23,6 @@ ], "client": [ "ChunkProviderStaticMixin", - "MobRenderZombieArmoredMixin", - "PacketHandlerClientMixin", - "backpack.MinecraftMixin", - "backpack.PlayerLocalMixin" + "MobRenderZombieArmoredMixin" ] }